From: mrdudz Date: Sun, 27 Sep 2015 16:12:25 +0000 (+0200) Subject: initial commit of soft80 implementation X-Git-Tag: V2.16~210^2~56 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9e08c53b01436c22095ce9d7b35cf9d38d4c1c39;p=cc65 initial commit of soft80 implementation --- diff --git a/libsrc/c64/extra/soft80.s b/libsrc/c64/extra/soft80.s new file mode 100644 index 000000000..baf61f635 --- /dev/null +++ b/libsrc/c64/extra/soft80.s @@ -0,0 +1,58 @@ + + + ; soft80_cgetc.s + .import soft80_cgetc + .export _cgetc := soft80_cgetc + + ; soft80_chline.s + .import soft80_chlinexy + .import soft80_chline + .export _chlinexy := soft80_chlinexy + .export _chline := soft80_chline + + ; soft80_color.s + .import soft80_textcolor + .import soft80_bgcolor + .import soft80_bordercolor + .export _textcolor := soft80_textcolor + .export _bgcolor := soft80_bgcolor + .export _bordercolor := soft80_bordercolor + + ; soft80_cputc.s + .import soft80_cputc + .import soft80_cputcxy + .import soft80_cputdirect + .import soft80_putchar + .import soft80_newline + .import soft80_plot + .export _cputc := soft80_cputc + .export _cputcxy := soft80_cputcxy + .export cputdirect := soft80_cputdirect + .export putchar := soft80_putchar + .export newline := soft80_newline + .export plot := soft80_plot + + ; soft80_cvline.s + .import soft80_cvlinexy + .import soft80_cvline + .export _cvlinexy := soft80_cvlinexy + .export _cvline := soft80_cvline + + ; soft80_kclrscr.s + .import soft80_kclrscr + .export _clrscr := soft80_kclrscr + .export CLRSCR := soft80_kclrscr + + ; soft80_kplot.s + .import soft80_kplot + .export PLOT := soft80_kplot + + ; soft80_kscreen.s + .import soft80_kscreen + .export SCREEN := soft80_kscreen + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import soft80_init +conio_init = soft80_init diff --git a/libsrc/c64/soft80.inc b/libsrc/c64/soft80.inc new file mode 100644 index 000000000..d67011b4a --- /dev/null +++ b/libsrc/c64/soft80.inc @@ -0,0 +1,29 @@ + +; ram under i/o +soft80_lo_charset = $d000 +soft80_hi_charset = $d400 +soft80_vram = $d800 +soft80_colram = $d800 ; color ram (used for temp. storage) +; ram under kernel +soft80_bitmap = $e000 + +charsperline = 80 +screenrows = 25 + +CH_ESC = 95 +CH_HLINE = 96 +CH_CROSS = 123 +CH_VLINE = 125 +CH_PI = 126 + +; FIXME: these are defined in cbm.h normally, the putchar stuff should accept +; the regular codes instead of the following ones: + +CH_LTEE = 171-160 +CH_URCORNER = 174-160 +CH_LLCORNER = 173-160 +CH_ULCORNER = 176-160 +CH_BTEE = 177-160 +CH_TTEE = 178-160 +CH_RTEE = 179-160 +CH_LRCORNER = 189-160 diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s new file mode 100644 index 000000000..7b8a260f1 --- /dev/null +++ b/libsrc/c64/soft80_cgetc.s @@ -0,0 +1,90 @@ +; +; char cgetc (void); +; + + .export soft80_cgetc + .import cursor ; FIX/CHECK + .import putcolor ; FIX/CHECK + + .include "c64.inc" + .include "soft80.inc" + +soft80_cgetc: + lda KEY_COUNT ; Get number of characters + bne L3 ; Jump if there are already chars waiting + +; Switch on the cursor if needed + + lda cursor + jsr setcursor ; set cursor on or off accordingly + +L1: lda KEY_COUNT ; wait for key + beq L1 + + ldx #0 + lda CURS_FLAG + bne L2 + inx +L2: txa + jsr setcursor + +L3: jsr KBDREAD ; Read char and return in A + ldx #0 + rts + +; Switch the cursor on or off + +; A= 0: cursor off +; 1: cursor on + + .proc setcursor + + ; On or off? + cmp CURS_STATE + bne @set + rts +@set: + sta CURS_STATE + + sei + lda $01 + pha + lda #$34 + sta $01 + + jsr putcolor + + ldy #$00 + + lda CURS_X + and #$01 + bne @l1 + + .repeat 8,line + lda (SCREEN_PTR),y + eor #$f0 + sta (SCREEN_PTR),y + .if (line < 7) + iny + .endif + .endrepeat + +@back: + pla + sta $01 + cli + rts + +@l1: + .repeat 8,line + lda (SCREEN_PTR),y + eor #$0f + sta (SCREEN_PTR),y + .if line < 7 + iny + .endif + .endrepeat + + jmp @back + + .endproc diff --git a/libsrc/c64/soft80_charset.s b/libsrc/c64/soft80_charset.s new file mode 100644 index 000000000..5a180e233 --- /dev/null +++ b/libsrc/c64/soft80_charset.s @@ -0,0 +1,290 @@ +; FIXME: generate charset at runtime + +soft80_lo_charset0: +.byte $0f,$03,$0f,$00,$0f,$07,$05,$0e +.byte $0f,$05,$0e,$0b,$0f,$0b,$0f,$0f +.byte $0f,$0b,$0f,$0b,$07,$07,$0e,$00 +.byte $00,$0f,$0e,$0f,$0c,$0b,$03,$03 +.byte $0f,$0b,$05,$05,$0b,$05,$0b,$0b +.byte $0d,$07,$0f,$0f,$0f,$0f,$0f,$0d +.byte $0b,$0b,$0b,$0b,$05,$01,$0b,$01 +.byte $0b,$0b,$0f,$0f,$0d,$0f,$07,$0b +.byte $0b,$0f,$0f,$0f,$0f,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f +.byte $0f,$0f,$0f,$09,$07,$03,$0b,$0f +.byte $0f,$0b,$03,$0b,$03,$01,$01,$0b +.byte $05,$01,$09,$05,$07,$05,$05,$0b +.byte $03,$0b,$03,$0b,$01,$05,$05,$05 +.byte $05,$05,$01,$0b,$07,$0b,$0f,$0a + +soft80_lo_charset1: +.byte $0f,$03,$0f,$0f,$0f,$07,$05,$0e +.byte $0f,$0a,$0e,$0b,$0f,$0b,$0f,$0f +.byte $0f,$0b,$0f,$0b,$07,$07,$0e,$00 +.byte $00,$0f,$0e,$0f,$0c,$0b,$03,$03 +.byte $0f,$0b,$05,$05,$09,$05,$05,$0b +.byte $0b,$0b,$05,$0b,$0f,$0f,$0f,$0d +.byte $05,$0b,$05,$05,$05,$07,$05,$05 +.byte $05,$05,$0f,$0f,$0b,$0f,$0b,$05 +.byte $05,$0f,$07,$0f,$0d,$0f,$09,$0f +.byte $07,$0b,$0d,$07,$03,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0f,$0b,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0b,$07,$0b,$0b,$0b +.byte $0f,$0b,$05,$05,$05,$07,$07,$05 +.byte $05,$0b,$0d,$05,$07,$01,$01,$05 +.byte $05,$05,$05,$05,$0b,$05,$05,$05 +.byte $05,$05,$0d,$0b,$07,$0b,$0f,$0a + +soft80_lo_charset2: +.byte $0f,$03,$0f,$0f,$0f,$07,$0a,$0e +.byte $0f,$05,$0e,$0b,$0f,$0b,$0f,$0f +.byte $0f,$0b,$0f,$0b,$07,$07,$0e,$0f +.byte $00,$0f,$0d,$0f,$0c,$0b,$03,$03 +.byte $0f,$0b,$05,$00,$07,$0d,$0b,$07 +.byte $0b,$0b,$0b,$0b,$0f,$0f,$0f,$0b +.byte $01,$03,$0d,$0d,$05,$03,$07,$0d +.byte $05,$05,$0b,$0b,$0b,$08,$0b,$0d +.byte $01,$0b,$07,$09,$0d,$0b,$0b,$09 +.byte $07,$0f,$0f,$07,$0b,$05,$03,$0b +.byte $03,$09,$03,$09,$01,$05,$05,$05 +.byte $05,$05,$01,$0b,$0b,$0b,$05,$0b +.byte $0f,$05,$05,$07,$05,$07,$07,$07 +.byte $05,$0b,$0d,$03,$07,$01,$01,$05 +.byte $05,$05,$05,$07,$0b,$05,$05,$05 +.byte $0b,$05,$0b,$0b,$0b,$0b,$0a,$05 + +soft80_lo_charset3: +.byte $09,$03,$0f,$0f,$0f,$07,$0a,$0e +.byte $0f,$0a,$0e,$08,$0f,$08,$03,$0f +.byte $08,$00,$00,$03,$07,$07,$0e,$0f +.byte $0f,$0f,$05,$0f,$0c,$03,$03,$03 +.byte $0f,$0b,$0f,$05,$0b,$0b,$0b,$0f +.byte $0b,$0b,$01,$01,$0f,$01,$0f,$0b +.byte $05,$0b,$0b,$0b,$01,$0d,$03,$0b +.byte $0b,$09,$0f,$0f,$07,$0f,$0d,$0b +.byte $01,$0d,$03,$07,$09,$05,$01,$05 +.byte $03,$03,$0d,$05,$0b,$01,$05,$05 +.byte $05,$05,$05,$07,$0b,$05,$05,$05 +.byte $05,$05,$0d,$0b,$0b,$0b,$05,$00 +.byte $00,$01,$03,$07,$05,$03,$03,$01 +.byte $01,$0b,$0d,$03,$07,$05,$01,$05 +.byte $03,$05,$03,$0b,$0b,$05,$05,$01 +.byte $0b,$0b,$0b,$00,$0b,$0b,$05,$05 + +soft80_lo_charset4: +.byte $09,$03,$00,$0f,$0f,$07,$05,$0e +.byte $05,$05,$0e,$08,$0c,$08,$03,$0f +.byte $08,$00,$00,$03,$07,$07,$0e,$0f +.byte $0f,$0f,$03,$03,$0f,$03,$0f,$0c +.byte $0f,$0f,$0f,$00,$0d,$07,$04,$0f +.byte $0b,$0b,$0b,$0b,$0f,$0f,$0f,$0b +.byte $05,$0b,$07,$0d,$0d,$0d,$05,$0b +.byte $05,$0d,$0f,$0f,$0b,$08,$0b,$0b +.byte $07,$09,$05,$07,$05,$01,$0b,$05 +.byte $05,$0b,$0d,$03,$0b,$01,$05,$05 +.byte $05,$05,$07,$0b,$0b,$05,$05,$01 +.byte $0b,$05,$0b,$0b,$0b,$0b,$0f,$00 +.byte $00,$05,$05,$07,$05,$07,$07,$05 +.byte $05,$0b,$0d,$03,$07,$05,$01,$05 +.byte $07,$05,$03,$0d,$0b,$05,$05,$01 +.byte $0b,$0b,$0b,$00,$07,$0b,$05,$0a + +soft80_lo_charset5: +.byte $0f,$03,$00,$0f,$0f,$07,$05,$0e +.byte $05,$0a,$0e,$0b,$0c,$0f,$0b,$0f +.byte $0b,$0f,$0b,$0b,$07,$07,$0e,$0f +.byte $0f,$00,$03,$03,$0f,$0f,$0f,$0c +.byte $0f,$0f,$0f,$05,$03,$05,$05,$0f +.byte $0b,$0b,$05,$0b,$0b,$0f,$0b,$07 +.byte $05,$0b,$07,$05,$0d,$05,$05,$0b +.byte $05,$05,$0b,$0b,$0b,$0f,$0b,$0f +.byte $05,$05,$05,$07,$05,$07,$0b,$09 +.byte $05,$0b,$0d,$05,$0b,$05,$05,$05 +.byte $03,$09,$07,$0d,$0b,$05,$0b,$01 +.byte $05,$09,$07,$0b,$0d,$0b,$0f,$0b +.byte $0f,$05,$05,$05,$05,$07,$07,$05 +.byte $05,$0b,$05,$05,$07,$05,$05,$05 +.byte $07,$0b,$05,$05,$0b,$05,$0b,$05 +.byte $05,$0b,$07,$0b,$07,$0b,$05,$0a + +soft80_lo_charset6: +.byte $0f,$03,$00,$0f,$0f,$07,$0a,$0e +.byte $0a,$05,$0e,$0b,$0c,$0f,$0b,$00 +.byte $0b,$0f,$0b,$0b,$07,$07,$0e,$0f +.byte $0f,$00,$07,$03,$0f,$0f,$0f,$0c +.byte $0f,$0b,$0f,$05,$0b,$05,$08,$0f +.byte $0d,$07,$0f,$0f,$0b,$0f,$0b,$07 +.byte $0b,$01,$01,$0b,$0d,$0b,$0b,$0b +.byte $0b,$0b,$0f,$0b,$0d,$0f,$07,$0b +.byte $0b,$09,$03,$09,$09,$09,$0b,$0d +.byte $05,$01,$0d,$05,$01,$05,$05,$0b +.byte $07,$0d,$07,$03,$0d,$09,$0b,$05 +.byte $05,$0d,$01,$09,$0d,$03,$0f,$0b +.byte $0f,$05,$03,$0b,$03,$01,$07,$0b +.byte $05,$01,$0b,$05,$01,$05,$05,$0b +.byte $07,$0d,$05,$0b,$0b,$0b,$0b,$05 +.byte $05,$0b,$01,$0b,$0b,$0b,$05,$05 + +soft80_lo_charset7: +.byte $0f,$03,$00,$0f,$00,$07,$0a,$0e +.byte $0a,$0a,$0e,$0b,$0c,$0f,$0b,$00 +.byte $0b,$0f,$0b,$0b,$07,$07,$0e,$0f +.byte $0f,$00,$0f,$03,$0f,$0f,$0f,$0c +.byte $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0f,$07,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f +.byte $0f,$0f,$0f,$07,$0f,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0f,$0f,$0f,$0f,$03 +.byte $0f,$0f,$03,$0f,$0f,$0f,$0f,$0f +.byte $07,$0d,$0f,$0f,$0f,$0f,$0f,$0f +.byte $0f,$03,$0f,$0f,$0f,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f +.byte $0f,$0f,$0f,$0b,$0b,$0b,$0f,$05 + +soft80_hi_charset0: +.byte $f0,$30,$f0,$00,$f0,$70,$50,$e0 +.byte $f0,$50,$e0,$b0,$f0,$b0,$f0,$f0 +.byte $f0,$b0,$f0,$b0,$70,$70,$e0,$00 +.byte $00,$f0,$e0,$f0,$c0,$b0,$30,$30 +.byte $f0,$b0,$50,$50,$b0,$50,$b0,$b0 +.byte $d0,$70,$f0,$f0,$f0,$f0,$f0,$d0 +.byte $b0,$b0,$b0,$b0,$50,$10,$b0,$10 +.byte $b0,$b0,$f0,$f0,$d0,$f0,$70,$b0 +.byte $b0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$90,$70,$30,$b0,$f0 +.byte $f0,$b0,$30,$b0,$30,$10,$10,$b0 +.byte $50,$10,$90,$50,$70,$50,$50,$b0 +.byte $30,$b0,$30,$b0,$10,$50,$50,$50 +.byte $50,$50,$10,$b0,$70,$b0,$f0,$a0 + +soft80_hi_charset1: +.byte $f0,$30,$f0,$f0,$f0,$70,$50,$e0 +.byte $f0,$a0,$e0,$b0,$f0,$b0,$f0,$f0 +.byte $f0,$b0,$f0,$b0,$70,$70,$e0,$00 +.byte $00,$f0,$e0,$f0,$c0,$b0,$30,$30 +.byte $f0,$b0,$50,$50,$90,$50,$50,$b0 +.byte $b0,$b0,$50,$b0,$f0,$f0,$f0,$d0 +.byte $50,$b0,$50,$50,$50,$70,$50,$50 +.byte $50,$50,$f0,$f0,$b0,$f0,$b0,$50 +.byte $50,$f0,$70,$f0,$d0,$f0,$90,$f0 +.byte $70,$b0,$d0,$70,$30,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$f0,$b0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$b0,$70,$b0,$b0,$b0 +.byte $f0,$b0,$50,$50,$50,$70,$70,$50 +.byte $50,$b0,$d0,$50,$70,$10,$10,$50 +.byte $50,$50,$50,$50,$b0,$50,$50,$50 +.byte $50,$50,$d0,$b0,$70,$b0,$f0,$a0 + +soft80_hi_charset2: +.byte $f0,$30,$f0,$f0,$f0,$70,$a0,$e0 +.byte $f0,$50,$e0,$b0,$f0,$b0,$f0,$f0 +.byte $f0,$b0,$f0,$b0,$70,$70,$e0,$f0 +.byte $00,$f0,$d0,$f0,$c0,$b0,$30,$30 +.byte $f0,$b0,$50,$00,$70,$d0,$b0,$70 +.byte $b0,$b0,$b0,$b0,$f0,$f0,$f0,$b0 +.byte $10,$30,$d0,$d0,$50,$30,$70,$d0 +.byte $50,$50,$b0,$b0,$b0,$80,$b0,$d0 +.byte $10,$b0,$70,$90,$d0,$b0,$b0,$90 +.byte $70,$f0,$f0,$70,$b0,$50,$30,$b0 +.byte $30,$90,$30,$90,$10,$50,$50,$50 +.byte $50,$50,$10,$b0,$b0,$b0,$50,$b0 +.byte $f0,$50,$50,$70,$50,$70,$70,$70 +.byte $50,$b0,$d0,$30,$70,$10,$10,$50 +.byte $50,$50,$50,$70,$b0,$50,$50,$50 +.byte $b0,$50,$b0,$b0,$b0,$b0,$a0,$50 + +soft80_hi_charset3: +.byte $90,$30,$f0,$f0,$f0,$70,$a0,$e0 +.byte $f0,$a0,$e0,$80,$f0,$80,$30,$f0 +.byte $80,$00,$00,$30,$70,$70,$e0,$f0 +.byte $f0,$f0,$50,$f0,$c0,$30,$30,$30 +.byte $f0,$b0,$f0,$50,$b0,$b0,$b0,$f0 +.byte $b0,$b0,$10,$10,$f0,$10,$f0,$b0 +.byte $50,$b0,$b0,$b0,$10,$d0,$30,$b0 +.byte $b0,$90,$f0,$f0,$70,$f0,$d0,$b0 +.byte $10,$d0,$30,$70,$90,$50,$10,$50 +.byte $30,$30,$d0,$50,$b0,$10,$50,$50 +.byte $50,$50,$50,$70,$b0,$50,$50,$50 +.byte $50,$50,$d0,$b0,$b0,$b0,$50,$00 +.byte $00,$10,$30,$70,$50,$30,$30,$10 +.byte $10,$b0,$d0,$30,$70,$50,$10,$50 +.byte $30,$50,$30,$b0,$b0,$50,$50,$10 +.byte $b0,$b0,$b0,$00,$b0,$b0,$50,$50 + +soft80_hi_charset4: +.byte $90,$30,$00,$f0,$f0,$70,$50,$e0 +.byte $50,$50,$e0,$80,$c0,$80,$30,$f0 +.byte $80,$00,$00,$30,$70,$70,$e0,$f0 +.byte $f0,$f0,$30,$30,$f0,$30,$f0,$c0 +.byte $f0,$f0,$f0,$00,$d0,$70,$40,$f0 +.byte $b0,$b0,$b0,$b0,$f0,$f0,$f0,$b0 +.byte $50,$b0,$70,$d0,$d0,$d0,$50,$b0 +.byte $50,$d0,$f0,$f0,$b0,$80,$b0,$b0 +.byte $70,$90,$50,$70,$50,$10,$b0,$50 +.byte $50,$b0,$d0,$30,$b0,$10,$50,$50 +.byte $50,$50,$70,$b0,$b0,$50,$50,$10 +.byte $b0,$50,$b0,$b0,$b0,$b0,$f0,$00 +.byte $00,$50,$50,$70,$50,$70,$70,$50 +.byte $50,$b0,$d0,$30,$70,$50,$10,$50 +.byte $70,$50,$30,$d0,$b0,$50,$50,$10 +.byte $b0,$b0,$b0,$00,$70,$b0,$50,$a0 + +soft80_hi_charset5: +.byte $f0,$30,$00,$f0,$f0,$70,$50,$e0 +.byte $50,$a0,$e0,$b0,$c0,$f0,$b0,$f0 +.byte $b0,$f0,$b0,$b0,$70,$70,$e0,$f0 +.byte $f0,$00,$30,$30,$f0,$f0,$f0,$c0 +.byte $f0,$f0,$f0,$50,$30,$50,$50,$f0 +.byte $b0,$b0,$50,$b0,$b0,$f0,$b0,$70 +.byte $50,$b0,$70,$50,$d0,$50,$50,$b0 +.byte $50,$50,$b0,$b0,$b0,$f0,$b0,$f0 +.byte $50,$50,$50,$70,$50,$70,$b0,$90 +.byte $50,$b0,$d0,$50,$b0,$50,$50,$50 +.byte $30,$90,$70,$d0,$b0,$50,$b0,$10 +.byte $50,$90,$70,$b0,$d0,$b0,$f0,$b0 +.byte $f0,$50,$50,$50,$50,$70,$70,$50 +.byte $50,$b0,$50,$50,$70,$50,$50,$50 +.byte $70,$b0,$50,$50,$b0,$50,$b0,$50 +.byte $50,$b0,$70,$b0,$70,$b0,$50,$a0 + +soft80_hi_charset6: +.byte $f0,$30,$00,$f0,$f0,$70,$a0,$e0 +.byte $a0,$50,$e0,$b0,$c0,$f0,$b0,$00 +.byte $b0,$f0,$b0,$b0,$70,$70,$e0,$f0 +.byte $f0,$00,$70,$30,$f0,$f0,$f0,$c0 +.byte $f0,$b0,$f0,$50,$b0,$50,$80,$f0 +.byte $d0,$70,$f0,$f0,$b0,$f0,$b0,$70 +.byte $b0,$10,$10,$b0,$d0,$b0,$b0,$b0 +.byte $b0,$b0,$f0,$b0,$d0,$f0,$70,$b0 +.byte $b0,$90,$30,$90,$90,$90,$b0,$d0 +.byte $50,$10,$d0,$50,$10,$50,$50,$b0 +.byte $70,$d0,$70,$30,$d0,$90,$b0,$50 +.byte $50,$d0,$10,$90,$d0,$30,$f0,$b0 +.byte $f0,$50,$30,$b0,$30,$10,$70,$b0 +.byte $50,$10,$b0,$50,$10,$50,$50,$b0 +.byte $70,$d0,$50,$b0,$b0,$b0,$b0,$50 +.byte $50,$b0,$10,$b0,$b0,$b0,$50,$50 + +soft80_hi_charset7: +.byte $f0,$30,$00,$f0,$00,$70,$a0,$e0 +.byte $a0,$a0,$e0,$b0,$c0,$f0,$b0,$00 +.byte $b0,$f0,$b0,$b0,$70,$70,$e0,$f0 +.byte $f0,$00,$f0,$30,$f0,$f0,$f0,$c0 +.byte $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$f0,$70,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$70,$f0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$f0,$f0,$f0,$f0,$30 +.byte $f0,$f0,$30,$f0,$f0,$f0,$f0,$f0 +.byte $70,$d0,$f0,$f0,$f0,$f0,$f0,$f0 +.byte $f0,$30,$f0,$f0,$f0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 +.byte $f0,$f0,$f0,$b0,$b0,$b0,$f0,$50 + diff --git a/libsrc/c64/soft80_chline.s b/libsrc/c64/soft80_chline.s new file mode 100644 index 000000000..0fc711870 --- /dev/null +++ b/libsrc/c64/soft80_chline.s @@ -0,0 +1,28 @@ +; +; void chlinexy (unsigned char x, unsigned char y, unsigned char length); +; void chline (unsigned char length); +; + + .export soft80_chlinexy, soft80_chline + .import popa, _gotoxy, cputdirect ; FIX/CHECK + .importzp tmp1 + +soft80_chlinexy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length + +soft80_chline: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #96 ; Horizontal line, screen code + jsr cputdirect ; Direct output + dec tmp1 + bne L1 +L9: rts + + + + diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s new file mode 100644 index 000000000..553bc7f29 --- /dev/null +++ b/libsrc/c64/soft80_color.s @@ -0,0 +1,100 @@ +; +; unsigned char __fastcall__ textcolor (unsigned char color); +; unsigned char __fastcall__ bgcolor (unsigned char color); +; unsigned char __fastcall__ bordercolor (unsigned char color); +; + + .export soft80_textcolor, soft80_bgcolor, soft80_bordercolor + .export __textcolor,__bgcolor ; CHECK/FIX + + .importzp tmp1,tmp2 + + .import soft80_checkchar + + .include "c64.inc" + .include "soft80.inc" + +soft80_textcolor: + + ldx __textcolor ; get old value + sta __textcolor ; set new value + + lda __bgcolor + asl a + asl a + asl a + asl a + ora __textcolor + sta CHARCOLOR + + txa ; get old value + rts + + +soft80_bgcolor: + cmp __bgcolor + beq _donothing + ldx __bgcolor ; get old value + sta __bgcolor ; set new value + asl a + asl a + asl a + asl a + sta tmp2 ; shifted new value + ora __textcolor + sta CHARCOLOR ; text/bg combo for new chars + txa + pha ; save old value + sta tmp1 + + sei + lda $01 + pha + + lda #$34 + sta $01 + + ldx #$00 + +lp2: + .repeat $4,page + + .scope + lda soft80_vram+(page*$100),x + and #$0f + cmp tmp1 ; old bg color + bne as + ; is old bg color + ; is space + ;lda __bgcolor +as: + ora tmp2 ; new bg color + sta soft80_vram+(page*$100),x + .endscope + + .endrepeat + + inx + bne lp2 + + pla + sta $01 + cli + + pla ; get old value +_donothing: + rts + + +soft80_bordercolor: + ldx VIC_BORDERCOLOR ; get old value + sta VIC_BORDERCOLOR ; set new value + txa + rts + + ; FIXME: shouldnt they be in zeropage? + .bss +__textcolor: + .res 1 +__bgcolor: + .res 1 diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s new file mode 100644 index 000000000..20d9926de --- /dev/null +++ b/libsrc/c64/soft80_conio.s @@ -0,0 +1,74 @@ +; +; Low level stuff for screen output/console input +; + + .constructor soft80_init, 24 + .destructor soft80_shutdown + + .import soft80_kclrscr, soft80_plotinit + .import __textcolor, __bgcolor ; CHECK/FIX + + .include "c64.inc" + .include "soft80.inc" + +soft80_init: + lda #$3b + sta VIC_CTRL1 + lda #$00 + sta CIA2_PRA + lda #$68 + sta VIC_VIDEO_ADR + lda #$c8 + sta VIC_CTRL2 + +; copy charset to RAM under I/O -> FIXME: generate at runtime + sei + lda $01 + pha + lda #$34 + sta $01 + + lda #>soft80_lo_charset0 + sta @hi1+2 + lda #>$d000 + sta @hi2+2 + + ldy #8 +@l2: + ldx #0 +@l1: +@hi1: lda soft80_lo_charset0,x +@hi2: sta $d000,x + inx + bne @l1 + inc @hi1+2 + inc @hi2+2 + dey + bne @l2 + + pla + sta $01 + cli + + jsr soft80_plotinit + + lda #1 + sta __textcolor + lda #0 + sta __bgcolor + + jmp soft80_kclrscr + +soft80_shutdown: + lda #$1b + sta VIC_CTRL1 + lda #$03 + sta CIA2_PRA + lda #$15 + sta VIC_VIDEO_ADR + rts + +; FIXME: generate the charset at init time, and put it into RAM under I/O + + .include "soft80_charset.s" + diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s new file mode 100644 index 000000000..2e75aa541 --- /dev/null +++ b/libsrc/c64/soft80_cputc.s @@ -0,0 +1,419 @@ +; +; void cputcxy (unsigned char x, unsigned char y, char c); +; void cputc (char c); +; + + .export soft80_cputcxy, soft80_cputc + .export soft80_cputdirect, soft80_putchar + .export putcolor ; FIX/CHECK + + .export soft80_newline, soft80_plot + .import popa, _gotoxy + .import xsize + .import PLOT ; FIX/CHECK + .importzp tmp4,tmp3 + .import __bgcolor ; FIX/CHECK + + .macpack longbranch + + .include "c64.inc" + .include "soft80.inc" + +soft80_cputcxy: + pha ; Save C + jsr popa ; Get Y + jsr _gotoxy ; Set cursor, drop x + pla ; Restore C + +; Plot a character - also used as internal function + +soft80_cputc: + cmp #$0A ; CR? + bne L1 + + lda #0 + sta CURS_X + + ; Set cursor position, calculate RAM pointers +soft80_plot: + ldx CURS_Y + ldy CURS_X + clc + jmp PLOT ; Set the new cursor + +L1: cmp #$0D ; LF? + beq soft80_newline ; Recalculate pointers + + ; Printable char of some sort + + tay + bpl L10 + + clc + adc #$20 + and #$7F +L10: + +soft80_cputdirect: + jsr soft80_putchar ; Write the character to the screen + +; Advance cursor position + +advance: + iny + cpy #charsperline + beq L3 + + sty CURS_X + tya + and #$01 + bne @L5 + + lda SCREEN_PTR + clc + adc #8 + sta SCREEN_PTR + bcc @L4 + inc SCREEN_PTR+1 +@L4: + inc CRAM_PTR + bne @L5 + inc CRAM_PTR+1 +@L5: + rts +L3: + inc CURS_Y ; new line + ldy #0 ; + cr + sty CURS_X + jmp soft80_plot + +soft80_newline: + + lda SCREEN_PTR + clc + adc #<(40*8) + sta SCREEN_PTR + + lda SCREEN_PTR+1 + adc #>(40*8) + sta SCREEN_PTR+1 + + lda CRAM_PTR + clc + adc #40 + sta CRAM_PTR + bcc L5 + inc CRAM_PTR+1 +L5: + inc CURS_Y + rts + +; Write one character to the screen without doing anything else +; in: A: character +; returns: Y: cursor X position +; this function is going to be used a lot so we unroll it a bit for speed + +;--- start color vodoo + +; remove color from cell +; y unmodified +remcolor: + + ;ldy #$00 ; is still $00 + + lda (CRAM_PTR),y ; vram + and #$0f + cmp __bgcolor + jeq @l2b ; vram==bgcolor + + inc $01 + lda (CRAM_PTR),y ; colram + stx $01 ;$34 + and #$0f + cmp __bgcolor + beq @l2s ; colram==bgcolor + + ; vram = colram + ;inc $01 + ;lda (CRAM_PTR),y ; colram + ;stx $01 ;$34 + ;and #$0f + + sta tmp3 + lda (CRAM_PTR),y ; vram + and #$f0 + ora tmp3 + sta (CRAM_PTR),y ; vram + + ; colram = bgcolor + lda __bgcolor + inc $01 + sta (CRAM_PTR),y ; colram + stx $01 ;$34 + + jmp @l2b + +@l2s: + ; colram is bgcolor + ; => only one char in cell used + + jsr soft80_checkchar + bcc @l2b ; space at current position + + ; vram = bgcolor + lda (CRAM_PTR),y ; vram + and #$f0 + ora __bgcolor + sta (CRAM_PTR),y ; vram +@l2b: + rts + +; put color to cell +; y unmodified +putcolor: + + ;ldy #$00 ; is still $00 + + lda (CRAM_PTR),y ; vram + and #$0f + cmp __bgcolor + beq @l2s ; vram==bgcolor => first char in cell + + ; vram!=bgcolor => second char in cell + + inc $01 ;$35 + lda (CRAM_PTR),y ; colram + stx $01 ;$34 + and #$0f + cmp __bgcolor + bne @l2s ; colram!=bgcolor + + ; colram==bgcolor => second char in cell or overwrite 1st char + + jsr soft80_checkchar + bcs @l2a ; char at current position => overwrite 1st + + ; colram=vram + lda (CRAM_PTR),y ; vram + inc $01 + sta (CRAM_PTR),y ; colram + stx $01 ;$34 + + ;jmp @l2a + +@l2s: + ; colram!=bgcolor => alread 2 chars in cell +@l2a: + + ; Set color + lda CHARCOLOR + sta (CRAM_PTR),y ; vram + + rts + + +;--- end color vodoo + + .export soft80_checkchar + +; test if there is a space or a character at current position +; CLC: space SEC: character +soft80_checkchar: + + ;ldy #$00 ; is still $00 + + lda CURS_X + and #$01 + jne @l1a + + .repeat 8,line + lda (SCREEN_PTR),y + and #$f0 + cmp #$f0 + bne @l2b + .if (line < 7) + iny + .endif + .endrepeat + + ldy #$00 + clc + rts +@l2b: + ldy #$00 + sec + rts +@l1a: + .repeat 8,line + lda (SCREEN_PTR),y + and #$0f + cmp #$0f + bne @l2bb + .if line < 7 + iny + .endif + .endrepeat + ldy #$00 + clc + rts +@l2bb: + ldy #$00 + sec + rts + +; output space + +_space: + + lda RVS + jne _spaceinvers + + jsr remcolor + + ;ldy #$00 ; is still $00 + + lda CURS_X + and #$01 + bne @l1 + + .repeat 8,line + lda (SCREEN_PTR),y + ora #$f0 + sta (SCREEN_PTR),y + .if (line < 7) + iny + .endif + .endrepeat + jmp _back +@l1: + .repeat 8,line + lda (SCREEN_PTR),y + ora #$0f + sta (SCREEN_PTR),y + .if line < 7 + iny + .endif + .endrepeat +@l2: + jmp _back + +; output inverted space + +_spaceinvers: + + jsr putcolor + + lda CURS_X + and #$01 + bne @l1 + + .repeat 8,line + lda (SCREEN_PTR),y + and #$0f + sta (SCREEN_PTR),y + .if line < 7 + iny + .endif + .endrepeat + jmp _back +@l1: + .repeat 8,line + lda (SCREEN_PTR),y + and #$f0 + sta (SCREEN_PTR),y + .if line < 7 + iny + .endif + .endrepeat + + jmp _back + +; output a character + +soft80_putchar: + sta tmp3 + + sei + ldx $01 + stx tmp4 + ldx #$34 + + stx $01 ; will stay $34 for space + ldy #$00 ; will be $00 from now on + + cmp #' ' ; space is a special (optimized) case + jeq _space + + jsr putcolor + +; output character +char: + ldx tmp3 + + lda RVS + jne _invers + + lda CURS_X + and #$01 + bne @l1 + + .repeat 8,line + lda (SCREEN_PTR),y + and #$0f + ora soft80_hi_charset+(line*$80),x + sta (SCREEN_PTR),y + .if line < 7 + iny + .endif + .endrepeat + jmp @l2 +@l1: + + .repeat 8,line + lda (SCREEN_PTR),y + and #$f0 + ora soft80_lo_charset+(line*$80),x + sta (SCREEN_PTR),y + .if line < 7 + iny + .endif + .endrepeat + +@l2: + +_back: + lda tmp4 + sta $01 + cli + + ldy CURS_X + rts + +; output inverted character +_invers: + + lda CURS_X + and #$01 + bne @l1 + + .repeat 8,line + lda (SCREEN_PTR),y + ora #$f0 + eor soft80_hi_charset+(line*$80),x + sta (SCREEN_PTR),y + .if line < 7 + iny + .endif + .endrepeat + jmp _back +@l1: + .repeat 8,line + lda (SCREEN_PTR),y + ora #$0f + eor soft80_lo_charset+(line*$80),x + sta (SCREEN_PTR),y + .if line < 7 + iny + .endif + .endrepeat + jmp _back diff --git a/libsrc/c64/soft80_cvline.s b/libsrc/c64/soft80_cvline.s new file mode 100644 index 000000000..78f92278d --- /dev/null +++ b/libsrc/c64/soft80_cvline.s @@ -0,0 +1,28 @@ +; +; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); +; void cvline (unsigned char length); +; + + .export soft80_cvline, soft80_cvlinexy + .import popa, _gotoxy, putchar, newline ; CHECK/FIX + .importzp tmp1 + +soft80_cvlinexy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length and run into soft80_cvlinexy + +soft80_cvline: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #125 ; Vertical bar + jsr putchar ; Write, no cursor advance + jsr newline ; Advance cursor to next line + dec tmp1 + bne L1 +L9: rts + + + diff --git a/libsrc/c64/soft80_kclrscr.s b/libsrc/c64/soft80_kclrscr.s new file mode 100644 index 000000000..e801c9398 --- /dev/null +++ b/libsrc/c64/soft80_kclrscr.s @@ -0,0 +1,60 @@ + + .export soft80_kclrscr + .import soft80_kplot + .import __bgcolor ; FIX/CHECK + + .include "c64.inc" + .include "soft80.inc" + +soft80_kclrscr: + + lda #$ff + + ldx #$00 +lp1: + .repeat $20,page + sta soft80_bitmap+(page*$100),x + .endrepeat + inx + bne lp1 + + sei + ldy $01 + lda #$34 + sta $01 + + lda CHARCOLOR + and #$f0 + ora __bgcolor + + ;ldx #$00 +lp2: + .repeat $4,page + sta soft80_vram+(page*$100),x + .endrepeat + inx + bne lp2 + + inc $01 + + lda __bgcolor + ;ldx #$00 +lp3: + .repeat $4,page + sta soft80_colram+(page*$100),x + .endrepeat + inx + bne lp3 + + + sty $01 + cli + + ldx #0 + ldy #0 + clc + jmp soft80_kplot + + + + diff --git a/libsrc/c64/soft80_kplot.s b/libsrc/c64/soft80_kplot.s new file mode 100644 index 000000000..c6c6b94cc --- /dev/null +++ b/libsrc/c64/soft80_kplot.s @@ -0,0 +1,101 @@ + + .export soft80_kplot + .export soft80_plotinit + + .include "c64.inc" + .include "soft80.inc" + +soft80_kplot: + bcs @getpos + + ; calc pointer to bitmap + lda _bitmaplo,x + clc + adc _bitmapxlo,y + sta SCREEN_PTR + lda _bitmaphi,x + adc _bitmapxhi,y + sta SCREEN_PTR+1 + + ; calc pointer to vram + tya + lsr a + clc + adc _vramlo,x + sta CRAM_PTR + lda #0 + adc _vramhi,x + sta CRAM_PTR+1 + +@getpos: + ldx CURS_Y + ldy CURS_X + rts + + ; FIXME: perhaps just include the respective tables directly? +soft80_plotinit: + ; create screen-rows base tables (bitmap) + lda #soft80_bitmap + sta SCREEN_PTR+1 + + ldx #$00 +l1: + lda SCREEN_PTR + sta _bitmaplo,x + clc + adc #<(40*8) + sta SCREEN_PTR + lda SCREEN_PTR+1 + sta _bitmaphi,x + adc #>(40*8) + sta SCREEN_PTR+1 + inx + cpx #25 + bne l1 + + ; create screen-rows base tables (colorram) + + lda #soft80_vram + sta CRAM_PTR+1 + + ldx #$00 +l1b: + lda CRAM_PTR + sta _vramlo,x + clc + adc #<(40) + sta CRAM_PTR + lda CRAM_PTR+1 + sta _vramhi,x + adc #>(40) + sta CRAM_PTR+1 + inx + cpx #25 + bne l1b + + rts + +_bitmapxlo: + .repeat 80,col1 + .byte <((col1/2)*8) + .endrepeat + +_bitmapxhi: + .repeat 80,col + .byte >((col/2)*8) + .endrepeat + + .bss +_vramlo: + .res 25 +_vramhi: + .res 25 +_bitmaplo: + .res 25 +_bitmaphi: + .res 25 + diff --git a/libsrc/c64/soft80_kscreen.s b/libsrc/c64/soft80_kscreen.s new file mode 100644 index 000000000..22c7b6788 --- /dev/null +++ b/libsrc/c64/soft80_kscreen.s @@ -0,0 +1,9 @@ + + .export soft80_kscreen + + .include "soft80.inc" + +soft80_kscreen: + ldy #screenrows + ldx #charsperline + rts diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c new file mode 100644 index 000000000..6ec17eb1f --- /dev/null +++ b/testcode/lib/conio.c @@ -0,0 +1,65 @@ + +#include +#include +#include + +void main(void) +{ + int i, j; + unsigned char xsize, ysize, n; + + clrscr(); + screensize(&xsize, &ysize); + + cputs("cc65 conio test"); + cputsxy(0, 2, "colors:" ); + for (i = 3; i < 6; ++i) { + gotoxy(i,i); + for (j = 0; j < 16; ++j) { + textcolor(j); + cputc('X'); + } + } + textcolor(1); + + cprintf("\n\n\rscreensize is: %dx%d", xsize, ysize ); + + chlinexy(0,10,xsize); + cvlinexy(0,10,3); + chlinexy(0,12,xsize); + cvlinexy(xsize-1,10,3); + cputcxy(0,10,CH_ULCORNER); + cputcxy(xsize-1,10,CH_URCORNER); + cputcxy(0,12,CH_LLCORNER); + cputcxy(xsize-1,12,CH_LRCORNER); + + gotoxy(0,ysize - 2 - ((256 + xsize) / xsize)); + for (i = 0; i < xsize; ++i) { + cputc('0' + i % 10); + } + for (i = 0; i < 256; ++i) { + if ((i != '\n') && (i != '\r')) { + cputc(i); + } + } + while(wherex() > 0) { + cputc('#'); + } + for (i = 0; i < xsize; ++i) { + cputc('0' + i % 10); + } + + for(;;) { + + gotoxy(xsize - 10, 3); + j = (n >> 5) & 1; + revers(j); + cputc(j ? 'R' : ' '); + cputs(" revers"); + revers(0); + + ++n; + } + + for(;;); +}