processor 6502 cinv = $314 cnmi = $FFFA .org $801 basic: .word 0$ ; link to next line .word 1995 ; line number .byte $9E ; SYS token ; SYS digits .if (* + 8) / 10000 .byte $30 + (* + 8) / 10000 .endif .if (* + 7) / 1000 .byte $30 + (* + 7) % 10000 / 1000 .endif .if (* + 6) / 100 .byte $30 + (* + 6) % 1000 / 100 .endif .if (* + 5) / 10 .byte $30 + (* + 5) % 100 / 10 .endif .byte $30 + (* + 4) % 10 0$: .byte 0,0,0 ; end of BASIC program start: jsr init sei lda #$35 sta $01 ldy #$7f sty $dd0d lda $dd0d lda #nmi sta cnmi ; set the new interrupt vector sty cnmi+1 ldx #$00 loop1: lda $d011 bpl loop1 loop2: lda $d011 bmi loop2 lda #44 loop3: cmp $d012 bne loop3 ; now we're on rasterline 44 and avoid VICII DMA ldy #$ff sty $dd06 sty $dd07 timer: ldy #$10 sty $dd04 ldy #$00 sty $dd05 ldy #$1d sty $dd0f ldy #$dd sty $dd0e ldy #$81 sty $dd0d nop nop nop nop nop nop nop nop ldy $dd0d nop nop lda $dd06 sta $0400,x tya sta $0401,x inc timer + 1 inx inx cpx #$14 endloop: beq startagain jmp loop1 startagain: ldy #10 ldx #25 lp3: lda $0400,x cmp $0428,x bne sk3 dex bpl lp3 ldy #5 sk3: sty $d020 lda $d020 and #$0f ldx #0 ; success cmp #5 beq nofail ldx #$ff ; failure nofail: stx $d7ff ldx #$10 stx timer + 1 ldx #$00 jmp loop1 nmi: tay lda $dd0d tya rti init: lda #$20 ldx #0 lp1: sta $0400,x inx bne lp1 ldx #$27 lp2: lda refdata,x sta $0428,x dex bpl lp2 rts refdata: .if NEWCIA = 0 .byte $c5, $00, $c5, $00, $c5, $2c, $c5, $2c, $c5, $2c, $c5, $2c, $c5, $2c, $da, $01 .byte $c5, $2c, $c5, $2c .byte $20, $20, $20, $20, $20, $20, $3c, $12, $05, $06, $3a, $03, $09, $01, $20, $32, $20, $0f, $0c, $04 .endif .if NEWCIA = 1 .byte $c5, $00, $c5, $00, $c5, $00, $c5, $2c, $c5, $2c, $c5, $2c, $c5, $2c, $c5, $2c .byte $c5, $2c, $c5, $2c .byte $20, $20, $20, $20, $20, $20, $3c, $12, $05, $06, $3a, $03, $09, $01, $20, $32, $20, $0e, $05, $17 .endif