I am working on a loading screen, and what I wanted was a simple raster trick (just change the border colour on the bottom half of the screen), and also call the KERNAL to load some more data from a disk. Easy peasy, right?
Here is my code. It loads with
; The following is a short BASIC program; ; 10 SYS 2304 ; and causes the machine to jump to the machine code include later on. ; 2304 decimal is 900 hex. .byt $01, $08, $0C, $08, $0A, $00, $9E, $20 .byt $32, $33, $30, $34, $00, $00, $00 ; Fill up with no-ops until the start of the program. .dsb 242,$EA * = $0900 sei ; Turn BASIC off but leave KERNAL and IO on. lda #$36 sta $01 ; Enable raster interrupt signals from VIC lda #%00000001 sta $d01a ; Set the irqserve routine to start when raster line 0 hits. lda #0 sta $d012 lda #<irqserve sta $0314 lda #>irqserve sta $0315 ; enable interrupts again cli ; Infinite loop. stop: jmp stop
As you can see, it ends in an infinite loop, which means the program should end there, right? That's not how this program behaves. This program will eventually return the user to the BASIC prompt. I'm trying to figure out why, and the problem appears to be in the routine
irqserve: ; Look at the raster counter to see how far down the screen we are lda $d012 beq bluborder cmp #116 bcc blackborder jmp irqend bluborder: lda #$01 ; change border colour sta $d020 ; Next interrupt should fire at raster line 116. lda #116 sta $d012 jmp irqend blackborder: lda #$00 ; change border colour sta $d020 ; Next interrupt should fire at raster line 0. sta $d012 irqend: rts
But what I can't figure out though is what to do at the end of my interrupt handler. Should it jump back to the KERNAL? Or do