Skip to content

Instantly share code, notes, and snippets.

@geon
Created August 1, 2021 20:47
Show Gist options
  • Save geon/ad49bc60d6b94f2766ff1fc02ce441ef to your computer and use it in GitHub Desktop.
Save geon/ad49bc60d6b94f2766ff1fc02ce441ef to your computer and use it in GitHub Desktop.
Modified version of the interrupt handling in https://www.youtube.com/watch?v=LpG9gqPtNLo
; 10 SYS (4096)
*=$0801
BYTE $0E, $08, $0A, $00, $9E, $20, $28, $34, $30, $39, $36, $29, $00, $00, $00
*=$1000
start
sei ; disable interrupts
lda #$7f ; turn off the CIA timer interrupt
sta $dc0d
sta $dd0d
SetupRasterInt 100, my_interrupt1
lda #$01 ; enable raster interrupt
sta $d01a
cli ; enable interrupts
main_loop
; do some work here
inc $d021
jmp main_loop
my_interrupt1
inc $d020
; do some stuff
ldx #200
@delay
inx
bne @delay
dec $d020
SetupRasterInt 200, my_interrupt2
rts
my_interrupt2
inc $d020
; do some stuff
ldx #200
@delay
inx
bne @delay
dec $d020
SetupRasterInt 100, my_interrupt1
rts
; params: raster line, adress
defm SetupRasterInt
lda #$7f ; clear high bit of raster line
and $d011
sta $d011
lda #/1 ; set raster interrupt to trigger on line
sta $d012
lda #<@interuptHandler ; set pointer for raster interrupt
sta $0314
lda #>@interuptHandler
sta $0315
jmp @end
@interuptHandler
; Set bit 0 in Interrupt Status Register to acknowledge raster interrupt
inc $d019
; callback
jsr /2
; Restores A, X & Y registers and CPU flags before returing from Interrupt.
jmp $ea81
@end
endm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment