Sync'ing while thinking.
My first attempt at stabilizing the frame height while Four-Play is thinking did not go so well. From what I understand, a frame lasts for 19912 cycles (76 cycles/line * 262 lines). To set the timer to last a whole frame, you would write #18 to T0124T. Then the timer would count down to 0 for 19456 (1024*19) cycles. At this point the timer is set to 255, and counts down once per clock, so it would loop from 255 to 0 twice in the last 456 clocks of the frame.In order to write to VSYNC at the correct time, you'd want to read INTIM before it flips to 255. Ideally you'd read it at 0. Then you would wait 456 cycles to reach the end of the frame (minus the overhead to read INTIM, etc.) If you do not read INTIM soon enough, its value changes every cycle and might as well be random.Does my understanding of the timer sound correct? Here is the code I tried to do VSYNC in time. It comes at the the beginning of a routine that is called often while the game is thinking.
Check4InARow lda INTIM bne CheckVertical jsr SyncCheckVertical...Sync sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC lda #2 sta VSYNC sta WSYNC sta WSYNC sta WSYNC lda #0 sta VSYNC lda #18 sta T1024T rts
18 Comments
Recommended Comments