#define poke(addr,val) .(:lda #val:sta addr:.) #define doke(addr,val) .(:lda #<val:sta addr:lda #>val:sta addr+1:.) #define endIRQ pla:tay:pla:tax:pla:rti #define ackIRQ pha:lda $d019:sta $d019:txa:pha:tya:pha *= $0801-2 .word *+2 ; load address .byt $0b,$08,$0a,$00,$9e,$32,$30,$36,$31,0,0,0 ; 10 sys2061 main: poke($d021,$04) sta 646 lda#147 jsr $ffd2 poke($d021,0) poke($0400,1) ;something to see poke($0428,2) jsr IRQstart loop: inc $7e7 ; a nice untidy main loop to ensure instability! bpl loop jmp loop IRQstart poke($dc0d,$7f) ; kill CIA irq sei poke($01, $35) ; disable ROM poke($d01a,$01) ; enable VIC irq poke($d011,$1b) ; clear high bit of irq rasterline poke($d012,$32) ; last invisible line doke($fffe,irq1 ) ; set irq vector cli rts irq1: ackIRQ poke($d020,$0f) ; this is unstable! poke($d011,$1a) ; force partial badline before screen starts poke($d020,$0b) ; this is stable ^_^ poke($d011,$1b) ; trigger normal re-fetch of first row of chars poke($d012,$ff) ; set end-of-screen irq doke($fffe,irq2 ) endIRQ irq2: ackIRQ ;ensure first row of chars is already being displayed when badline forced by irq1 poke($d011,$18) poke($d012,$32 ) doke($fffe,irq1 ) endIRQ
; ------------------------------------------------------------------------------ rasterlogo1 = $34 ; ------------------------------------------------------------------------------ .code .org $07ff ; ------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------ ; "sys" basic ; ------------------------------------------------------------------------------ .word *+2 ;loading bytes basicstub: .word @nextline .word 2012 ; line number .byte $9e ; sys .byte <(((init / 1000) .mod 10) + $30) .byte <(((init / 100 ) .mod 10) + $30) .byte <(((init / 10 ) .mod 10) + $30) .byte <(((init ) .mod 10) + $30) .byte 0 ;end of line @nextline: .word 0 ;empty line == end basic code init: lda #$00 sta $d020 sta $d021 sta $3fff ; ------------------------------------------------------------------------------ ;set up irq ; ------------------------------------------------------------------------------ setup: lda #$1b sta $d011 lda #rasterlogo1 sta $d012 ldy #$00 sty $d015 sei lda #$7f sta $dc0d sta $dd0d lda #$35 sta $01 lda #<irq1 sta $fffe lda #>irq1 sta $ffff lda #$01 sta $d01a lda $dc0d lda $dd0d lda #$01 sta $d019 cli jmp * ; ------------------------------------------------------------------------------ ; Routine in interrupt ; ------------------------------------------------------------------------------ irq1: ldx #$08 dex bne *-1 lda $d012 and #$07 ora #$18 sta $d011 cmp $00,x cmp $00,x cmp $00 inc $d021 inc $d021 inc $d021 inc $d021 inc $d021 inc $d021 ldy #$00 sty $d021 lda #$1b sta $d011 asl $d019 rti