08-09-2003, 09:06 AM
Ok, so I'm running into a problem. For the game I'm working on (it is my first real graphical game) I want to skip my graphics routines entirely unless it has been at least 1/60th of a second since the last time they ran (I hope that made sense) so that the other portions of my program can run faster. The problem I have is that the TIMER function of qbasic isn't precise enough, and when I try to use the CLOCK& function outlined in the FAQ, I get an overflow error. I'm wondering if anyone has any ideas for how I should go about correcting this; btw I've included a copy of the function. Also, if anyone feels like explaining the code, in regards to what ports are being accessed and what information is being peek'd I'm all ears. Thanks.
Code:
FUNCTION CLOCK&
' Get the number of timer ticks at
' 0000:046C
DEF SEG = 0
Ticks& = PEEK(&H46C)
Ticks& = Ticks& + PEEK(&H46D) * 256
Ticks& = Ticks& + PEEK(&H46E) * 65536
DEF SEG
' Latch the counter and obtain the PIT
' countdown status.
OUT &H43, &H4
LSB = INP(&H40)
HSB = 255 - INP(&H40)
' Compute the CLOCK& value
CLOCK& = Ticks& * 256 + HSB
END FUNCTION