Last active
September 27, 2020 21:44
-
-
Save mrspeaker/50aa6405efa57c20399753d374076880 to your computer and use it in GitHub Desktop.
spr-spr-collision irq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BasicUpstart2(entry) | |
entry: | |
sei | |
jsr init_sprites | |
lda #$7f | |
sta $dc0d // Disable CIA #1 | |
lda #%11110100 // Enable sprite collision irq | |
sta $d01a | |
lda #<irq | |
ldx #>irq | |
sta $314 | |
stx $315 | |
cli | |
lda $d01e | |
jmp * | |
irq: | |
dec $d020 | |
lda $d019 | |
ora #%00000100 | |
sta $d019 | |
// lda #3 // Load/store does not work... | |
// sta $d01e | |
lda $d01e // Have to just read it to clear and enable? | |
pla | |
tay | |
pla | |
tax | |
pla | |
rti | |
init_sprites: | |
lda #%00000011 | |
sta $d015 | |
// load sprite data | |
ldx #$40 | |
!: | |
lda spr_data,x | |
sta $340,x | |
dex | |
bpl !- | |
lda #$340/64 | |
sta $7f8 | |
sta $7f9 | |
// position | |
lda #70 | |
sta $d001 | |
sta $d002 | |
sta $d003 | |
lda #80 | |
sta $d000 | |
rts | |
spr_data: | |
.fill 64, $ff |
Ok, after help from the people-in-the-know...
Reading the register will clear it and re-enable it. Writing has no effect - they are just for reading.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update/fix to this gist: https://gist.github.com/mrspeaker/47014f128ebfc1afe243d04a41b008cd
Turns out I needed to READ address $D01E to make it fire - then also read it every time AFTER ack'ing the IRQ with
dec $d019
.My docs don't seem to say reading is necessary to reset it, but seems like it is.