Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Simple loop to burn time in a program
- ; Syntax used is for ca65
- ; The three bytes needed in RAM
- nmi_wait: .res 1
- one_second: .res 1
- big_seconds: .res 1
- ; The routine nmi_wait
- nmi_wait:
- lda nmi_num
- : cmp nmi_num
- beq :-
- rts
- ; Must have one_second and big_seconds already setup.
- ; Use #$3c in one_second to wait 60 frames
- ; Use the number of seconds you want to use in big_seconds
- loop:
- lda one_second ; Subtract one_second by one
- sec ; and if it's not zero, branch
- sbc #$01 ; over
- sta one_second ;
- bne @end ;
- lda #$3c ; When one_second reaches zero,
- sta one_second ; reset it to #$3c and subtract
- lda big_seconds ; big_seconds by one. Test if
- sec ; big_seconds is zero. If not,
- sbc #$01 ; we wait for another NMI and
- sta big_seconds ; start the loop over. If zero,
- bne @end ; jmp over the nmi_wait...
- jmp @finally ;
- @end: ;
- jsr nmi_wait ;
- jmp loop ;
- @finally: ; Here we begin setup for the next
- ; loop in the program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement