First post, by hornet1990
Hi
Not sure if this just a me problem but I unearthed some of my earliest VGA coding experiments from 30 years ago so tried recompiling (Watcom 10.6) and running it in dosbox-x (2nd May release, Visual Studio SDL1 - pretty much out of the box config) but it runs way too fast. The animation rate is tied to the vsync and should be updating every 4 frames (~67ms at 60Hz). The code in question is running double buffered and waiting for the retrace (reading port 0x03da) to copy the back buffer to the VGA memory (0xA0000), so in theory it should be running at ~60 to 75Hz but isn't.
The only way I can get it animating at a sensible speed is to massively drop the cpu cycles. I initially picked the "emulate P100" setting to match my machine of the day, but 53k cycles is way too high, 12k is better although arguably still a bit too quick, but then that drops it to 30fps, 6k drops it to 15fps. The vsync option under the video menu seems to make absolutely zero difference.
I tried another experiment (using Open Watcom 2 beta as my Watcom 10.6 refused to emit RDTSC) reading the RDTSC around the retrace and usually get ridiculously low and/or consistent values indicating that it isn't really waiting, or somehow 0x03da is being set according to the cpu cycles rather than real time of 1 second / refresh rate.
What am I missing? I then tried another test which just writes a pixel to the buffer, waits for the retrace, then copies the changed scanline to the display memory before plotting another pixel. In theory that should be taking 4 to 5 seconds to write a single line of 320 pixels (since it is writing 60-75 pixels per second in theory), but is taking less than a second per line with the same 12k cycle configuration.
The retrace code is this, and as far as I can remember worked fine on real hardware back in the day:
#pragma wait_retrace = \"mov dx,0x03da" \"l1: in al,dx" \"test al,0x08" \"jnz l1" \"l2: in al,dx" \"test al,0x08" \"jz l2" \modify [edx eax] ;
Any ideas? Didn't many games and demos back in the 90's use vsync for their timing?
Thanks
https://rogueone.uk Kyro and other things