#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
mov #$00, $d020
.pc = $0810 sei lda #$35 // switch off kernal sta $01 ldx #$00 stx $d015 // switch off sprites stx $3fff // clear garbage gfx inx stx $d01a // raster interrupt lda #$7f // clear timers sta $dc0d sta $dd0d lda #$1b // clear MSB of rasterline sta $d011 lda #$33 // set triggering rasterline sta $d012 ldx #<irq // set IRQ vectors ldy #>irq stx $fffe sty $ffff lda $dc0d // ack pending timers lda $dd0d lda #$01 // ack pending irq sta $d019 cli jmp * // infinite loop irq: sta saveA stx saveX sty saveY ldx #$08 timeloop1: dex bne timeloop1 nop nop lda $d012 // DMA and #$07 ora #$18 sta $d011 bit $eaea bit $eaea bit $eaea bit $eaea bit $eaea bit $eaea bit $eaea bit $eaea bit $eaea bit $eaea bit $eaea bit $eaea bit $eaea // jitters, change into bit $ea to stabilize ldy #$c0 lda #$c8 sty $d021 sta $d021 lda #$1b sta $d011 asl $d019 .label saveA = * +1 lda #$00 .label saveX = * +1 ldx #$00 .label saveY = * +1 ldy #$00 rti