-2

I'm not very experienced in asm x8086 for DOSBox, and I'm programming a connect4 game. I've made all the code and it works. I want to implement a "timer" so that each player has 20 seconds to decide their move, if this time happens then the move is made randomly by the program.

I know I have to use RTC but I don't have any idea on how to program this. How can I do it?

Thanks in advice :D I need it as soon as possible as it is for my university.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • https://wiki.osdev.org/RTC#Possible_Uses and https://wiki.osdev.org/Programmable_Interval_Timer. The PIT sounds like a better choice for waking up and telling the user their time expired. Or use the RTC to generate timer interrupts if you want to update a clock. – Peter Cordes May 18 '18 at 05:09

2 Answers2

0

The BIOS sets up an 18.18 Hz interrupt. I don't know whether DOSBox sets it up this way, but it seems likely. You can hook this by changing the interrupt vector for interrupt 1Ch to point to your handler. Before changing the vector, save the previous vector and then jump to it at the end of your handler. Once you count up to 364, the desired 20 seconds has passed.

prl
  • 11,716
  • 2
  • 13
  • 31
0

A couple more options, instead of hooking the timer interrupt:

1) The BIOS tick counter is a DWORD in the BDA at 40:6c. You can read it directly from your wait loop and wait until it increments by 364.

2) Int 1Ah implements several timer services that you may find useful.

prl
  • 11,716
  • 2
  • 13
  • 31