Skip to content

Instantly share code, notes, and snippets.

@r-moeritz
Last active October 20, 2019 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r-moeritz/3e14863e6b9711e1033af07da0564fa6 to your computer and use it in GitHub Desktop.
Save r-moeritz/3e14863e6b9711e1033af07da0564fa6 to your computer and use it in GitHub Desktop.
Raster interrupt sample from Compute's Machine Language Routines for the Commodore 64/128
5 sys 49152
10 print chr$(147):poke 49408+33,0:poke 49455+33,0
15 for a=832 to 896:poke a,255:next
20 for a=2040 to 2047:poke a,13:next
30 poke 49408+21,255:poke 49455+21,255
40 for a=49408 to 49422 step 2:poke a,b*25+50:poke a+47,b*25+50:b=b+1:next
50 for a=49409 to 49423 step 2:poke a,100:poke a+47,200:next
*=$c000
;
vic = $d000
newvic = $c100
ciaicr = $dc0d
scroly = $d011
irqmsk = $d01a
vicirq = $d019
raster = $d012
irqvec = $0314
irqnor = $ea31
irqend = $febc
;
ras64 lda #$7f
sta ciaicr
lda #<main
sta irqvec
lda #>main
sta irqvec+1
lda scroly
and #$7f
sta scroly
lda #1
sta irqmsk
ldy #46
;
copy lda vic,y
sta newvic,y
sta newvic+47,y
dey
bpl copy
lda newvic+$11
and #$7f
sta newvic+$11
sta newvic+47+$11
rts
;
main lda #1
sta vicirq
ldx #147
ldy #46
lda raster
cmp #147
bcc top
ldx #1
ldy #93
;
top txa
pha
ldx #3
;
delay dex
bne delay
nop
ldx #46
;
copybk lda newvic,y
sta vic,x
dey
dex
bpl copybk
pla
sta raster
lda ciaicr
lsr
bcc noirq
jmp irqnor
;
noirq jmp irqend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment