gozar Posted February 3, 2018 Share Posted February 3, 2018 I've set up the following as a VBI, and it works for the most part: ; Constants VVBLKI = $0222; VBI vector SYSVBV = $e45f; jump to OS VBI RTCLOK = $14 counth = $604 countl = $605 ts0 = $600 ts1 = $601 ts2 = $602 ts3 = $603 *= $610 SETUP lda #0 sta countl ; Reset counter to 0 sta counth lda #<VBI; register new VBI subroutine sta VVBLKI lda #>VBI sta VVBLKI+1 lda #$c0; enable VBI's/DLI's sta NMIEN rts VBI lda #60 cmp RTCLOK bcs done lda #0 sta RTCLOK ; Reset Clock inc ts0 bne done inc ts1 bne done inc ts2 bne done inc ts3 done inc countl bne check1k inc counth check1k ldy countl lda counth cpy #$e8 bne exit cmp #$03 bne exit inc RTCLOK lda #0 sta countl sta counth exit jmp SYSVBV The VBI increments a 32 bit number every second located at $600. It all works except the code increments the number slightly slower than a second. Joe_z did the math for me, and every 1000 jiffies I need to add 1 jiffy since the clock isn't precisely 60 times a second. That's what the check1k procedure does, but it doesn't seem to help, the clock still runs slow. What did I miss? (p.s. This is a procedure in a larger MAD Pascal program.) Quote Link to comment Share on other sites More sharing options...
MaPa Posted February 3, 2018 Share Posted February 3, 2018 IMHO you should compare to #59 and not #60 if you use BCS.. in your case you are counting 61 frames and not 60. 2 Quote Link to comment Share on other sites More sharing options...
shanti77 Posted February 3, 2018 Share Posted February 3, 2018 (edited) ... Edited February 3, 2018 by shanti77 Quote Link to comment Share on other sites More sharing options...
phaeron Posted February 3, 2018 Share Posted February 3, 2018 Think your correction divisor needs to be more like 1/777. 1/1000 would be for color NTSC broadcast rate, 59.94 fps. The Atari is a bit slower than that. Quote Link to comment Share on other sites More sharing options...
Rybags Posted February 4, 2018 Share Posted February 4, 2018 May as well cater for PAL too... looks like an extra tick every 357 makes it more accurate. In both cases you'll still get drift. I don't know if an extra couple of layers of corrections will bring it true or if it's just a repeating series of errors. You'd probably be able to get more accurate timing using Pokey Timers but even then you're still relying on the system clock speed which in itself has some inaccuracy. Quote Link to comment Share on other sites More sharing options...
gozar Posted February 4, 2018 Author Share Posted February 4, 2018 MaPa is correct, 59 fixed the issue. I used bcs because it would sometimes miss comparing to exactly 60. Once I get it working, I’m planning on fixing it for PAL too. Thanks all! Sent from my iPad using Tapatalk Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.