First post, by Peter Swinkels
I already asked this question at https://www.vbforums.com/editpost.php?p=5531200&do=editpost but I get the feeling I may have more success here. (Given this relates to MS-DOS programming and older hardware.)
Whenever I needed a delay in my QBasic/QB45 program I would use a simple delay based on the TIMER function:
DEFINT A-Z
CLS
Delay! = .25
DO
StartTime! = TIMER
DO WHILE TIMER < StartTime! + Delay! OR TIMER < StartTime!
'Put code that doesn't need to be timed here.
LOOP
'Put code that needs to be timed here.
PRINT "*";
LOOP
However sometimes I would want to use more precise timing but could never figure out a decent way of implementing it. After some searching online I found it was very hard to find anything about this subject for QBasic. What I found usually was in some other language using some internal high-precision Delay method (Turbo Basic and Turbo C++ for example.) or some highly technical info about the 8253/8253 PIT chip. The closest I have found to what I need is at https://www.franksteinberg.de/pbeisp.htm in a file called "Timing.zip". Unfortunately most of the commenting and documentation is in German and what I have found in English are long-winded technical documents.
My question is: could someone help me narrow down all this information to something straightforward that does pretty much the same thing as in my TIMER example, but with greater precision?
Yes, I know QBasic/QB45 might be too slow to go into the millisecond range unless the CPU is fast enough without resorting to assembly code, but I would prefer to avoid assembly language if possible. While I do understand assembly language somewhat, any attempt at using it in combination with QBasic/QB45 by me resulted in just freezing the system. There is something about CALL ABSOLUTE I never quite got.
If it's not possible in QBasic, then how is it done in asm or C?
Do not read if you don't like attention seeking self-advertisements!
Did you read it anyway? Well, you can find all sorts of stuff I made using various programming languages over here:
https://github.com/peterswinkels