Posted By
siz on 2020-12-07 15:57:01
| Re: Cartridge and raster interrupts
Here is an example (made with 64TAss but probably the code is readable anyway):
*= $8000
vidinit = $ff81 ioinit = $ff84 ramtest = $ff87 restorio = $ff8a
texty = 12
jmp start jmp start .byte 1 ; Marker that ROM should be autostarted .text "cbm" ; Marker that this is an expansion ROM
start sei lda $fb ; Get current ROM bank (to provide runnability in any slots) and #$03 ; Use our ROM in low bank only and KERNAL in high tax sta $fdd0,x ; Do bank selection
jsr ioinit ; Do standard initialization instead of KERNAL reset jsr restorio jsr vidinit ldx #irqend-irq ; Copy IRq routing to RAM at $2000 - lda irq,x sta $2000,x dex bpl -
lda #2 ; Enable raster interrupt only sta $ff0a lda #96 ; Raster interrupt at line 96 sta $ff0b lda #<$2000 ; Set IRq vector to $2000 ldx #>$2000 sta $0314 stx $0315 cli lda #$d4 ; Switch to lower case charset sta $ff13 ldx #txtend-txt-1 ; Copy text to screen - lda txt,x sta $0c00+texty*40,x lda #$71 ; Set text color to white sta $0800+texty*40,x dex bpl -
jmp * ; Infinite loop: main routine has nothing to do
irq lda #$32 ; Load color red into register A ldx #180
- cpx $ff1e ; Wait for rasterline end bcs -
sta $ff19 ; Set border color sta $ff15 ; Set background color lda #0 ; Load color black into register A ldx #231 ; Wait a bit - dex ; (this could have been to separate interrupts to allow bne - ; main thread to use the time but this is an example only) sta $ff19 ; Set border color sta $ff15 ; Set background color
lda $ff09 ; Clear interrupt request sta $ff09 jmp $fcbe ; Use ROM interrupt handler to restore ROM bank and registers and return from the interrupt irqend
.enc screen txt .text "Cartridge ROM Raster IRq example by Siz/Absence" txtend
; Fill to 16k boundary .fill $c000-*, $ff
|