lda TIME1 #CmpAccBranchEq #000, j_p00 #CmpAccBranchEq #011, j_x00 #CmpAccBranchEq #013, j_p01 #CmpAccBranchEq #024, j_x00 #CmpAccBranchEq #026, j_p02 #CmpAccBranchEq #037, j_x00 #CmpAccBranchEq #039, j_p03 #CmpAccBranchEq #050, j_x00 #CmpAccBranchEq #052, j_p04 #CmpAccBranchEq #053, j_p05 #CmpAccBranchEq #054, j_p06 #CmpAccBranchEq #059, j_p07 etc.. jmp updatesites ;jump table j_x00: jmp blkpart j_p00: jmp part0 j_p01: jmp part1 j_p02: jmp part2 j_p03: jmp part3 j_p04: jmp part4 j_p05: jmp part4b j_p06: jmp part4c j_p07: jmp part4d etc.. jmp sync_time
lda TIME1 #CmpAccBranchEq #000, blkpart #CmpAccBranchEq #011, part0 #CmpAccBranchEq #013, part1 #CmpAccBranchEq #024, part2 #CmpAccBranchEq #026, part3 #CmpAccBranchEq #037, part4 #CmpAccBranchEq #039, part4b #CmpAccBranchEq #050, part4c #CmpAccBranchEq #052, part4d
ldx TIME1 lda tbll,x sta patchjmp+1 lda tblh,x sta patchjmp+2 patchjmp jmp $ffff tbll byte <blkpart ;0 byte 0,0,0,0,0,0,0,0,0,0 ; 1-10 byte <part0 ;11 byte 0 ;12 byte <part1 ;13 byte 0 byte <part2 byte <part3 byte <part4 byte <part4b byte <part4c byte <part4d tblh byte >blkpart ;0 byte 0,0,0,0,0,0,0,0,0,0 ; 1-10 byte >part0 ;11 byte 0 ;12 byte >part1 ;13 byte 0 byte >part2 byte >part3 byte >part4 byte >part4b byte >part4c byte >part4d
*=$1000 =$2 time1 = $2 =[0,$1023,10,$1029,20,$102f] timings := [0, part1, 10, part2, 20, part3] =[0,$1023,10,$1029,20,$102f,30,$1035] timings ..= [30, part4] .1000 a5 02 lda $02 call lda time1 .1002 ae 16 10 ldx $1016 ldx index .1005 dd 17 10 cmp $1017,x cmp times,x .1008 90 0b bcc $1015 bcc + ;are we there yet? .100a ee 16 10 inc $1016 inc index ;next .100d bd 1f 10 lda $101f,x lda highs,x .1010 48 pha pha .1011 bd 1b 10 lda $101b,x lda lows,x .1014 48 pha pha ;jump .1015 60 rts + rts >1016 00 index .byte 0 >1017 00 0a 14 1e times .byte timings[0::2] ;slice it >101b 22 28 2e 34 lows .byte <(timings[1::2]-1) >101f 10 10 10 10 highs .byte >(timings[1::2]-1) .1023 a9 01 lda #$01 part1 lda #1 .1025 8d 20 d0 sta $d020 sta $d020 .1028 60 rts rts .1029 a9 02 lda #$02 part2 lda #2 .102b 8d 20 d0 sta $d020 sta $d020 .102e 60 rts rts .102f a9 03 lda #$03 part3 lda #3 .1031 8d 20 d0 sta $d020 sta $d020 .1034 60 rts rts .1035 a9 04 lda #$04 part4 lda #4 .1037 8d 20 d0 sta $d020 sta $d020 .103a 60 rts rts
doing a bpl instead of beq will cause unexpected behavior (i.e. run all the parts at the same time)
lda seekcyclelo cmp cyclecountlo lda seekcyclemid sbc cyclecountmid lda seekcyclehi sbc cyclecounthi bcs wait