CGA Game Timing Question (Developers)
Hello! I've recently fallen down a rabbit hole of playing around with CGA graphics with the intent of making a space shooter game that doesn't look terrible in CGA, and runs without lag on vintage PCs.
Anyway, it seems like the best method is to do my video writes once vertical retrace starts so that the writes occur when the screen isn't being drawn, and also has the benefit of being a good timer for the game to allow it to be speed-independent.
I have some simple code that works great on DosBox-X, but when I tried to run it on FreeDOS running under VirtualBox, it runs at the speed of light (clearly the code to wait for vertical retrace doesn't work there).
So, my question is: is this a good way of doing things, and is this code the best way to accomplish it?
// If a retrace is in progress, wait for it to end.
// Wait for a new retrace to begin, then exit.
void wait_vsync() {
while( inp(0x3DA)&0x08 ) { // Wait for retrace to complete
}
while( !(inp(0x3DA)&0x08) ) { // Wait for next retrace to start
}
}
I can also share the source (Open Watcom compiler) and binary if that would be helpful, though it doesn't look like I can upload them here. Thanks in advance for any advice!
Complete thread:
- CGA Game Timing Question - KarlG, 21.05.2022, 18:16
- CGA Game Timing Question - glennmcc, 21.05.2022, 19:13
- CGA Game Timing Question - KarlG, 21.05.2022, 20:13
- CGA Game Timing Question - glennmcc, 21.05.2022, 20:30
- CGA Game Timing Question - KarlG, 21.05.2022, 20:41
- CGA Game Timing Question - tkchia, 21.05.2022, 21:38
- CGA Game Timing Question - KarlG, 22.05.2022, 00:37
- CGA Game Timing Question - rr, 22.05.2022, 10:46
- CGA Game Timing Question - KarlG, 22.05.2022, 00:37
- CGA Game Timing Question - tkchia, 21.05.2022, 21:38
- CGA Game Timing Question - KarlG, 21.05.2022, 20:41
- CGA Game Timing Question - glennmcc, 21.05.2022, 20:30
- CGA Game Timing Question - KarlG, 21.05.2022, 20:13
- CGA Game Timing Question - glennmcc, 21.05.2022, 19:13