sptr = $02 mptr = $04 refptr = $06 maskptr = $08 cptr = $0a xtmp = $10 ytmp = $11 numlines = $12 linepos = $13 currcol = $14 currpage = $18 failed = $20 c128detected = $30 ;------------------------------------------------------------------------------- ; $08 bytes cpubuf = REGBUFFER ; !byte 0,0,0,0,0,0,0,0 ; $30 bytes vicbuf = cpubuf + $08 ; !byte 0,0,0,0,0,0,0,0 ; !byte 0,0,0,0,0,0,0,0 ; !byte 0,0,0,0,0,0,0,0 ; !byte 0,0,0,0,0,0,0,0 ; !byte 0,0,0,0,0,0,0,0 ; !byte 0,0,0,0,0,0,0,0 ; $10 + 8 cia1buf = vicbuf + $30 ; !byte 0,0,0,0,0,0,0,0 ; !byte 0,0,0,0,0,0,0,0 ; $10 + 8 cia2buf = cia1buf + $10 + 8 ; !byte 0,0,0,0,0,0,0,0 ; !byte 0,0,0,0,0,0,0,0 ; $08 ramebuf = cia2buf + $10 + 8 ; !byte 0,0,0,0,0,0,0,0 ; !byte 0,0,0,0,0,0,0,0 cpubuf_first = cpubuf + $80 vicbuf_first = vicbuf + $80 cia1buf_first = cia1buf + $80 cia2buf_first = cia2buf + $80 ramebuf_first = ramebuf + $80 pages = MEMBUFFER ;------------------------------------------------------------------------------- * = CODESTART ;------------------------------------------------------------------------------- start: php ; push status sei cld sta cpubuf+0 stx cpubuf+1 sty cpubuf+2 tsx stx cpubuf+3 pla ; get status sta cpubuf+4 lda #0 sta cpubuf+5 sta cpubuf+6 sta cpubuf+7 ldx $00 ldy $01 lda #$2f sta $00 lda #$37 sta $01 stx pages stx cpubuf+6 sty pages+1 sty cpubuf+7 ldx #$ff txs ; detect C128 in C64 mode ldx #0 lda #$cc sta $d030 lda $d030 cmp #$fc beq isc128 ldx #1 isc128: stx c128detected lda c128detected bne + lda #$77 sta cpuref + 7 ; $01 + lda #5 sta failed lda #0 ldy #0 lpp1b: sta vicbuf,y iny bne lpp1b jsr readpages jsr readrameblock !if (1 = 1) { ; delay so floppy can finish reset routine etc ldx #2 * 60 waitframes: lda #$80 cmp $d012 bne *-3 cmp $d012 beq *-3 dex bne waitframes } jsr readioblock ldy #$7f lpp1c: lda vicbuf,y sta vicbuf_first,y dey bpl lpp1c ; show results jsr clear ; clear screen and setup VIC jsr setupvic jsr showcpublock jsr showrameblock jsr showioblock jsr showpage lda c128detected bne + ldx #5 - lda c128string,x sta $0428+30,x dex bpl - + lda failed sta $d020 ldx #0 ; success cmp #5 beq nofail ldx #$ff ; failure nofail: stx $d7ff !if (CRTMODE = 1) { jmp crtstartup } normalstartup: ; wait until key pressed wait3a: inc $d020 dec $d020 jsr keyscan cmp #$ff beq wait3a ; wait until no key pressed wait3: jsr keyscan cmp #$ff bne wait3 mainlp: ; wait until no key pressed wait1: jsr restorevic jsr readioblock jsr setupvic jsr showioblock jsr showpage jsr keyscan cmp #$ff bne wait1 ; wait until key pressed wait2: jsr restorevic jsr readioblock jsr setupvic jsr showioblock jsr showpage jsr keyscan cmp #$ff beq wait2 cmp #%11111110 ; + beq plus cmp #%11110111 ; - beq minus cmp #%01111111 ; , beq firstpage cmp #%11101111 ; . beq iopage jmp mainlp minus: dec currpage jmp mainlp plus: inc currpage jmp mainlp firstpage: lda #0 sta currpage jmp mainlp iopage: lda #$de sta currpage jmp mainlp !if (CRTMODE = 1) { crtstartup: lda #>irqnmi sta $ffff sta $fffb lda #$0400 sta sptr+1 lda #<$0400 sta sptr lda #>cpubuf sta mptr+1 lda #cpuref sta refptr+1 lda #cpumask sta maskptr+1 lda #($0400+(2*40)) sta sptr+1 lda #<($0400+(2*40)) sta sptr lda #>vicbuf sta mptr+1 lda #vicref sta refptr+1 lda #vicmask sta maskptr+1 lda #($0400+(9*40)) sta sptr+1 lda #<($0400+(9*40)) sta sptr lda #>cia1buf sta mptr+1 lda #cia1ref sta refptr+1 lda #cia1mask sta maskptr+1 lda #($0400+(13*40)) sta sptr+1 lda #<($0400+(13*40)) sta sptr lda #>cia2buf sta mptr+1 lda #cia2ref sta refptr+1 lda #cia2mask sta maskptr+1 lda #($0400+(17*40)) sta sptr+1 lda #<($0400+(17*40)) sta sptr lda #>ramebuf sta mptr+1 lda #rameref sta refptr+1 lda #ramemask sta maskptr+1 lda #($0400+(40*16)) sta sptr+1 lda #<($0400+(40*16)) sta sptr+0 lda #1 sta currcol lda #38 sta linepos lda currpage jsr puthex lda currpage cmp #4 bcc skp lda currpage sta mptr+1 lda #0 sta mptr ldy #0 plpa1: lda (mptr),y sta $0400+(18*40)+24,y lda #1 sta $d800+(18*40)+24,y iny bne plpa1 rts skp: lda currpage tax clc adc #>pages sta mptr+1 txa clc adc #>pagesref sta refptr+1 txa clc adc #>pagesmask sta maskptr+1 lda #