OS 2.30+ Timer BCALLs: Call InitTimer, then StartTimer. While timer has started, it records the number of ticks, which you get with CheckTimer or CheckTimerRestart. You can call RestartTimer, CheckTimer, CheckTimerRestart as many times as you want, and you can call StartTimer again once you've called StopTimer. Call KillTimer when done. InitTimer: 526Ch: Initializes crystal timer and memory. Inputs: None Outputs: B=70h (this must be passed to the other routines, for some reason). A=error code (0 is success, 1 if timer already initialized). Carry flag means problems. This does not actually start the timer. Sets bit 0 of (9C0Ch) and resets the others. Returns C set and A=1 if already set. Outputs: B is 70h, NC and A=0. KillTimer: 526Fh: Uninitializes crystal timer and memory. Inputs: A=70h (why?) Outputs: A=error code (0 is success, 2 if A wasn't 70h or timer wasn't initialized). Carry flag means problems. Zeroes out 9C0Ch-9C12h (timer memory). Returns C set and A=2 if A was not 70h. Returns C set and A=2 if 0,(9C0Ch) was reset. Turns off timer and zeroes out 9C0Ch-9C12h. Returns NC and A=0 if success. StartTimer: 5272h: Starts timer. Inputs: DE is number of ticks (at 933Hz). A=70h (why?) C!=0 to keep looping the timer. Outputs: A=error code (0 is success, 2 if A wasn't 70h or timer wasn't initialized). (3 is if timer was already started). Carry flag means problems. Returns C set and A=2 if A was not 70h. Returns C set and A=2 if 0,(9C0Ch) was reset. Returns C set and A=3 if 1,(9C0Ch) was set. Sets bits 0 and 1 of (9C0Ch). Inputs: if C is nonzero, 3,(9C0Ch) is set. DE is put in (9C0Dh) and (9C0Fh). Zero is put in (9C11h). 41h is output to port 30h (933Hz). So I guess multiply number of seconds you want by 933 to get DE value. Start the timer for DE ticks. If 0 was passed to DE in this routine, it returns. Sets 0,(9C0Ch), 2,(9C0Ch), and resets 1,(9C0Ch). Increases (9C11h). RestartTimer: 5275h: Restarts timer. Inputs: DE is number of ticks (at 933Hz). A=70h (why?) C!=0 to keep looping the timer. Outputs: A=error code (0 is success, 2 if A wasn't 70h or timer wasn't initialized). Carry flag means problems. Same as StartTimer, except it will not return C set and A=3 if 1,(9C0Ch) set. WaitTimer: 527Bh: Waits until timer has stopped. Inputs: DE is number of ticks (at 933Hz). A=70h (why?) Outputs: A=error code (0 is success, 2 if A wasn't 70h or timer wasn't initialized). (3 is if timer was already started). Carry flag means problems. Calls StartTimer with C=0 and returns if problems. Then loops until 2,(9C0Ch) is set, then returns NC and A=0. StopTimer: 5278h: Stops the timer. Inputs: A=70h (why?) Outputs: A=error code (0 is success, 2 if A wasn't 70h or timer wasn't initialized). Carry flag means problems. Returns C set and A=2 if A was not 70h. Returns C set and A=2 if 0,(9C0Ch) was reset. Kills the timer. Resets 1,(9C0Ch). Returns NC and A=0. CheckTimer: 527Eh: Checks the number of ticks since timer has been started. Inputs: A=70h (why?) Outputs: HL is number of ticks (this can overflow). A=error code (0 is success, 2 if A wasn't 70h or timer wasn't initialized). Carry flag means problems. Returns NZ if timer has expired. Returns C set and A=2 if A was not 70h. Returns C set and A=2 if 0,(9C0Ch) was reset. Returns (9C11h) in HL, NC and A=0, and bit 2,(9C0Ch). CheckTimerRestart: 5281h: Checks the number of ticks since timer has been started and resets the count of ticks. Inputs: A=70h (why?) Outputs: HL is number of ticks (this can overflow). A=error code (0 is success, 2 if A wasn't 70h or timer wasn't initialized). Carry flag means problems. Returns C set and A=2 if A was not 70h. Returns C set and A=2 if 0,(9C0Ch) was reset. Resets 2,(9C0Ch). Returns (9C11h) in HL, then zeroes out (9C11h) and returns NC and A=0. 9C0Dh: sent to (9C0Fh) if bit 3 of flag byte was set, and then bit 1 is set. 9C0Fh: decreased by one and then 0FFh output to port 32h until zero. 9C10h: once (9C0Fh) is zero, this is outout to port 32h. 9C11h: increased once counter outputs are done, set to 0FFFFh if zero. 9C0Ch: flag byte. Bit 1 reset and bit 2 set when timer expires. If bit 3 is reset, nothing else happens. Bit 0 set means timer has initted. Bit 1 set means timer is still going. Bit 2 set means timer expired. Bit 3 set means to keep looping the counter.