Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Creates a time delay on the 6502. Easy to adapt the intervals or even parameterise the subroutine
; Written for the CA65 assembler and tested on a NES emulator
.zeropage
counter_lsb: .res 1
counter_msb: .res 1
.proc RateLimit
lda #$EE ; Most Significant Byte 'interval'
sta counter_msb
LOOP_MSB:
lda #$00 ; Least Significant Byte 'interval'
sta counter_lsb
LOOP_LSB:
inc counter_lsb
lda counter_lsb
bne LOOP_LSB
inc counter_msb
lda counter_msb
bne LOOP_MSB
rts
.endproc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment