From 9e08c53b01436c22095ce9d7b35cf9d38d4c1c39 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 27 Sep 2015 18:12:25 +0200 Subject: [PATCH 01/54] initial commit of soft80 implementation --- libsrc/c64/extra/soft80.s | 58 +++++ libsrc/c64/soft80.inc | 29 +++ libsrc/c64/soft80_cgetc.s | 90 ++++++++ libsrc/c64/soft80_charset.s | 290 +++++++++++++++++++++++++ libsrc/c64/soft80_chline.s | 28 +++ libsrc/c64/soft80_color.s | 100 +++++++++ libsrc/c64/soft80_conio.s | 74 +++++++ libsrc/c64/soft80_cputc.s | 419 ++++++++++++++++++++++++++++++++++++ libsrc/c64/soft80_cvline.s | 28 +++ libsrc/c64/soft80_kclrscr.s | 60 ++++++ libsrc/c64/soft80_kplot.s | 101 +++++++++ libsrc/c64/soft80_kscreen.s | 9 + testcode/lib/conio.c | 65 ++++++ 13 files changed, 1351 insertions(+) create mode 100644 libsrc/c64/extra/soft80.s create mode 100644 libsrc/c64/soft80.inc create mode 100644 libsrc/c64/soft80_cgetc.s create mode 100644 libsrc/c64/soft80_charset.s create mode 100644 libsrc/c64/soft80_chline.s create mode 100644 libsrc/c64/soft80_color.s create mode 100644 libsrc/c64/soft80_conio.s create mode 100644 libsrc/c64/soft80_cputc.s create mode 100644 libsrc/c64/soft80_cvline.s create mode 100644 libsrc/c64/soft80_kclrscr.s create mode 100644 libsrc/c64/soft80_kplot.s create mode 100644 libsrc/c64/soft80_kscreen.s create mode 100644 testcode/lib/conio.c 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(;;); +} From fba28f46f6b71b1861db902291251d50facdb0de Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 27 Sep 2015 18:36:53 +0200 Subject: [PATCH 02/54] fix initial text- and background colors --- libsrc/c64/soft80_color.s | 9 +++------ libsrc/c64/soft80_conio.s | 12 +++++++----- testcode/lib/conio.c | 9 +++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index 553bc7f29..c176eca7f 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -25,15 +25,13 @@ soft80_textcolor: asl a asl a ora __textcolor - sta CHARCOLOR + sta CHARCOLOR ; text/bg combo for new chars txa ; get old value rts soft80_bgcolor: - cmp __bgcolor - beq _donothing ldx __bgcolor ; get old value sta __bgcolor ; set new value asl a @@ -62,8 +60,8 @@ lp2: .scope lda soft80_vram+(page*$100),x and #$0f - cmp tmp1 ; old bg color - bne as + ;cmp tmp1 ; old bg color + ;bne as ; is old bg color ; is space ;lda __bgcolor @@ -82,7 +80,6 @@ as: cli pla ; get old value -_donothing: rts diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 20d9926de..eb05e4e8b 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -6,7 +6,7 @@ .destructor soft80_shutdown .import soft80_kclrscr, soft80_plotinit - .import __textcolor, __bgcolor ; CHECK/FIX + .import soft80_textcolor, soft80_bgcolor .include "c64.inc" .include "soft80.inc" @@ -52,10 +52,12 @@ soft80_init: jsr soft80_plotinit - lda #1 - sta __textcolor - lda #0 - sta __bgcolor + lda 646 ; use current textcolor + jsr soft80_textcolor + + lda VIC_BG_COLOR0 ; use current bgcolor + and #$0f + jsr soft80_bgcolor jmp soft80_kclrscr diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index 6ec17eb1f..752687f34 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -5,13 +5,14 @@ void main(void) { - int i, j; - unsigned char xsize, ysize, n; + int i, j, n; + unsigned char xsize, ysize, tcol; clrscr(); screensize(&xsize, &ysize); - cputs("cc65 conio test"); + + tcol = textcolor(1); cputsxy(0, 2, "colors:" ); for (i = 3; i < 6; ++i) { gotoxy(i,i); @@ -20,7 +21,7 @@ void main(void) cputc('X'); } } - textcolor(1); + textcolor(tcol); cprintf("\n\n\rscreensize is: %dx%d", xsize, ysize ); From b5a6578dcab61be7f34fe19d959c7bac3dac2f4d Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 27 Sep 2015 18:49:30 +0200 Subject: [PATCH 03/54] include bitmap and vram row tables directly rather than generating them (saves space) --- libsrc/c64/soft80_conio.s | 4 +-- libsrc/c64/soft80_kplot.s | 71 +++++++++------------------------------ 2 files changed, 16 insertions(+), 59 deletions(-) diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index eb05e4e8b..199ac3584 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -5,7 +5,7 @@ .constructor soft80_init, 24 .destructor soft80_shutdown - .import soft80_kclrscr, soft80_plotinit + .import soft80_kclrscr .import soft80_textcolor, soft80_bgcolor .include "c64.inc" @@ -50,8 +50,6 @@ soft80_init: sta $01 cli - jsr soft80_plotinit - lda 646 ; use current textcolor jsr soft80_textcolor diff --git a/libsrc/c64/soft80_kplot.s b/libsrc/c64/soft80_kplot.s index c6c6b94cc..a813fd679 100644 --- a/libsrc/c64/soft80_kplot.s +++ b/libsrc/c64/soft80_kplot.s @@ -1,6 +1,5 @@ .export soft80_kplot - .export soft80_plotinit .include "c64.inc" .include "soft80.inc" @@ -32,70 +31,30 @@ soft80_kplot: 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 - + .rodata _bitmapxlo: - .repeat 80,col1 - .byte <((col1/2)*8) + .repeat 80,col + .byte <((col/2)*8) .endrepeat _bitmapxhi: .repeat 80,col .byte >((col/2)*8) .endrepeat - - .bss _vramlo: - .res 25 + .repeat 25,row + .byte <(soft80_vram+(row*40)) + .endrepeat _vramhi: - .res 25 + .repeat 25,row + .byte >(soft80_vram+(row*40)) + .endrepeat _bitmaplo: - .res 25 + .repeat 25,row + .byte <(soft80_bitmap+(row*40*8)) + .endrepeat _bitmaphi: - .res 25 + .repeat 25,row + .byte >(soft80_bitmap+(row*40*8)) + .endrepeat From c221fe22f66dd0371097c9eb1a23685d77eb3fa6 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 27 Sep 2015 19:10:06 +0200 Subject: [PATCH 04/54] prepend soft80_ to some more internally used functions --- libsrc/c64/soft80_cgetc.s | 4 ++-- libsrc/c64/soft80_chline.s | 18 +++++++++--------- libsrc/c64/soft80_cputc.s | 17 +++++++++-------- libsrc/c64/soft80_cvline.s | 6 +++--- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index 7b8a260f1..12b2071a2 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -4,7 +4,7 @@ .export soft80_cgetc .import cursor ; FIX/CHECK - .import putcolor ; FIX/CHECK + .import soft80_putcolor .include "c64.inc" .include "soft80.inc" @@ -52,7 +52,7 @@ L3: jsr KBDREAD ; Read char and return in A lda #$34 sta $01 - jsr putcolor + jsr soft80_putcolor ldy #$00 diff --git a/libsrc/c64/soft80_chline.s b/libsrc/c64/soft80_chline.s index 0fc711870..de6ab7637 100644 --- a/libsrc/c64/soft80_chline.s +++ b/libsrc/c64/soft80_chline.s @@ -4,21 +4,21 @@ ; .export soft80_chlinexy, soft80_chline - .import popa, _gotoxy, cputdirect ; FIX/CHECK + .import popa, _gotoxy, soft80_cputdirect .importzp tmp1 soft80_chlinexy: - pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params - pla ; Restore the length + 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 + cmp #0 ; Is the length zero? + beq L9 ; Jump if done sta tmp1 -L1: lda #96 ; Horizontal line, screen code - jsr cputdirect ; Direct output +L1: lda #96 ; Horizontal line, screen code + jsr soft80_cputdirect ; Direct output dec tmp1 bne L1 L9: rts diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 2e75aa541..c81913476 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -5,15 +5,16 @@ .export soft80_cputcxy, soft80_cputc .export soft80_cputdirect, soft80_putchar - .export putcolor ; FIX/CHECK - + .export soft80_putcolor .export soft80_newline, soft80_plot + .import popa, _gotoxy .import xsize - .import PLOT ; FIX/CHECK - .importzp tmp4,tmp3 + .import soft80_kplot .import __bgcolor ; FIX/CHECK + .importzp tmp4,tmp3 + .macpack longbranch .include "c64.inc" @@ -39,7 +40,7 @@ soft80_plot: ldx CURS_Y ldy CURS_X clc - jmp PLOT ; Set the new cursor + jmp soft80_kplot ; Set the new cursor L1: cmp #$0D ; LF? beq soft80_newline ; Recalculate pointers @@ -170,7 +171,7 @@ remcolor: ; put color to cell ; y unmodified -putcolor: +soft80_putcolor: ;ldy #$00 ; is still $00 @@ -301,7 +302,7 @@ _space: _spaceinvers: - jsr putcolor + jsr soft80_putcolor lda CURS_X and #$01 @@ -344,7 +345,7 @@ soft80_putchar: cmp #' ' ; space is a special (optimized) case jeq _space - jsr putcolor + jsr soft80_putcolor ; output character char: diff --git a/libsrc/c64/soft80_cvline.s b/libsrc/c64/soft80_cvline.s index 78f92278d..a24d17c79 100644 --- a/libsrc/c64/soft80_cvline.s +++ b/libsrc/c64/soft80_cvline.s @@ -4,7 +4,7 @@ ; .export soft80_cvline, soft80_cvlinexy - .import popa, _gotoxy, putchar, newline ; CHECK/FIX + .import popa, _gotoxy, soft80_putchar, soft80_newline .importzp tmp1 soft80_cvlinexy: @@ -18,8 +18,8 @@ soft80_cvline: 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 + jsr soft80_putchar ; Write, no cursor advance + jsr soft80_newline ; Advance cursor to next line dec tmp1 bne L1 L9: rts From 257183fa551bc628874913b8a89b28b3b8b4b6b8 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 27 Sep 2015 19:34:43 +0200 Subject: [PATCH 05/54] removed duplicate copy of charset and shift it at init time, saves 1k --- libsrc/c64/soft80_charset.s | 153 ------------------------------------ libsrc/c64/soft80_chline.s | 2 +- libsrc/c64/soft80_conio.s | 43 ++++++---- libsrc/c64/soft80_cvline.s | 2 +- 4 files changed, 31 insertions(+), 169 deletions(-) diff --git a/libsrc/c64/soft80_charset.s b/libsrc/c64/soft80_charset.s index 5a180e233..999d199f0 100644 --- a/libsrc/c64/soft80_charset.s +++ b/libsrc/c64/soft80_charset.s @@ -1,6 +1,4 @@ -; 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 @@ -18,7 +16,6 @@ soft80_lo_charset0: .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 @@ -36,7 +33,6 @@ soft80_lo_charset1: .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 @@ -54,7 +50,6 @@ soft80_lo_charset2: .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 @@ -72,7 +67,6 @@ soft80_lo_charset3: .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 @@ -90,7 +84,6 @@ soft80_lo_charset4: .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 @@ -108,7 +101,6 @@ soft80_lo_charset5: .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 @@ -126,7 +118,6 @@ soft80_lo_charset6: .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 @@ -144,147 +135,3 @@ soft80_lo_charset7: .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 index de6ab7637..ac9d123d3 100644 --- a/libsrc/c64/soft80_chline.s +++ b/libsrc/c64/soft80_chline.s @@ -17,7 +17,7 @@ soft80_chline: cmp #0 ; Is the length zero? beq L9 ; Jump if done sta tmp1 -L1: lda #96 ; Horizontal line, screen code +L1: lda #96 ; Horizontal line, petscii code jsr soft80_cputdirect ; Direct output dec tmp1 bne L1 diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 199ac3584..fd2d7fd4d 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -8,6 +8,8 @@ .import soft80_kclrscr .import soft80_textcolor, soft80_bgcolor + .importzp ptr1, ptr2, ptr3 + .include "c64.inc" .include "soft80.inc" @@ -28,22 +30,36 @@ soft80_init: lda #$34 sta $01 - lda #>soft80_lo_charset0 - sta @hi1+2 - lda #>$d000 - sta @hi2+2 + lda #>soft80_charset + sta ptr1+1 + lda #soft80_lo_charset + sta ptr2+1 + lda #soft80_hi_charset + sta ptr3+1 + lda # Date: Mon, 28 Sep 2015 15:10:57 +0200 Subject: [PATCH 06/54] added extra check for graphical chars --- libsrc/c64/soft80.inc | 24 +++++++++--------------- libsrc/c64/soft80_chline.s | 5 ++++- libsrc/c64/soft80_cputc.s | 19 +++++++++++++++---- libsrc/c64/soft80_cvline.s | 5 ++++- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/libsrc/c64/soft80.inc b/libsrc/c64/soft80.inc index d67011b4a..d534cac69 100644 --- a/libsrc/c64/soft80.inc +++ b/libsrc/c64/soft80.inc @@ -1,10 +1,8 @@ -; ram under i/o soft80_lo_charset = $d000 soft80_hi_charset = $d400 -soft80_vram = $d800 +soft80_vram = $d800 ; ram under i/o soft80_colram = $d800 ; color ram (used for temp. storage) -; ram under kernel soft80_bitmap = $e000 charsperline = 80 @@ -15,15 +13,11 @@ 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 +CH_LTEE = 171 +CH_URCORNER = 174 +CH_LLCORNER = 173 +CH_ULCORNER = 176 +CH_BTEE = 177 +CH_TTEE = 178 +CH_RTEE = 179 +CH_LRCORNER = 189 diff --git a/libsrc/c64/soft80_chline.s b/libsrc/c64/soft80_chline.s index ac9d123d3..e15d0c483 100644 --- a/libsrc/c64/soft80_chline.s +++ b/libsrc/c64/soft80_chline.s @@ -7,6 +7,9 @@ .import popa, _gotoxy, soft80_cputdirect .importzp tmp1 + .include "c64.inc" + .include "soft80.inc" + soft80_chlinexy: pha ; Save the length jsr popa ; Get y @@ -17,7 +20,7 @@ soft80_chline: cmp #0 ; Is the length zero? beq L9 ; Jump if done sta tmp1 -L1: lda #96 ; Horizontal line, petscii code +L1: lda #CH_HLINE ; Horizontal line, petscii code jsr soft80_cputdirect ; Direct output dec tmp1 bne L1 diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index c81913476..d4c7e3050 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -40,28 +40,39 @@ soft80_plot: ldx CURS_Y ldy CURS_X clc - jmp soft80_kplot ; Set the new cursor + jmp soft80_kplot ; Set the new cursor L1: cmp #$0D ; LF? - beq soft80_newline ; Recalculate pointers + beq soft80_newline ; Recalculate pointers ; Printable char of some sort tay bpl L10 + ; extra check for petscii codes 160-191, these have been moved to + ; 0-31 in the charset + and #%11100000 + cmp #%10100000 + bne @sk + + tya + and #%00011111 + bpl L10 ; branch always +@sk: + tya clc adc #$20 and #$7F L10: soft80_cputdirect: - jsr soft80_putchar ; Write the character to the screen + jsr soft80_putchar ; Write the character to the screen ; Advance cursor position advance: - iny + iny ; contains CURS_X cpy #charsperline beq L3 diff --git a/libsrc/c64/soft80_cvline.s b/libsrc/c64/soft80_cvline.s index 847186a3b..eaa850118 100644 --- a/libsrc/c64/soft80_cvline.s +++ b/libsrc/c64/soft80_cvline.s @@ -7,6 +7,9 @@ .import popa, _gotoxy, soft80_putchar, soft80_newline .importzp tmp1 + .include "c64.inc" + .include "soft80.inc" + soft80_cvlinexy: pha ; Save the length jsr popa ; Get y @@ -17,7 +20,7 @@ soft80_cvline: cmp #0 ; Is the length zero? beq L9 ; Jump if done sta tmp1 -L1: lda #125 ; Vertical bar, petscii code +L1: lda #CH_VLINE ; Vertical bar, petscii code jsr soft80_putchar ; Write, no cursor advance jsr soft80_newline ; Advance cursor to next line dec tmp1 From d211eeaa4136dce489c036556d4bc43614cfb728 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 28 Sep 2015 15:29:14 +0200 Subject: [PATCH 07/54] fix conio test to work on vic20 screen --- testcode/lib/conio.c | 48 +++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index 752687f34..f1b21e7a5 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -3,6 +3,15 @@ #include #include + +static char grid[5][5] = { + { CH_ULCORNER, CH_HLINE, CH_TTEE, CH_HLINE, CH_URCORNER }, + { CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE }, + { CH_LTEE, CH_HLINE, CH_CROSS, CH_HLINE, CH_RTEE }, + { CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE }, + { CH_LLCORNER, CH_HLINE, CH_BTEE, CH_HLINE, CH_LRCORNER }, +}; + void main(void) { int i, j, n; @@ -12,10 +21,10 @@ void main(void) screensize(&xsize, &ysize); cputs("cc65 conio test"); - tcol = textcolor(1); - cputsxy(0, 2, "colors:" ); - for (i = 3; i < 6; ++i) { - gotoxy(i,i); + cputsxy(0, 2, "Colors:" ); + tcol = textcolor(0); /* remember original textcolor */ + for (i = 0; i < 3; ++i) { + gotoxy(i,3 + i); for (j = 0; j < 16; ++j) { textcolor(j); cputc('X'); @@ -23,21 +32,30 @@ void main(void) } textcolor(tcol); - cprintf("\n\n\rscreensize is: %dx%d", xsize, ysize ); + cprintf("\n\n\r Screensize 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); + chlinexy(0,6,xsize); + cvlinexy(0,6,3); + chlinexy(0,8,xsize); + cvlinexy(xsize-1,6,3); + cputcxy(0,6,CH_ULCORNER); + cputcxy(xsize-1,6,CH_URCORNER); + cputcxy(0,8,CH_LLCORNER); + cputcxy(xsize-1,8,CH_LRCORNER); + + for (i = 0; i < 5; ++i) { + gotoxy(xsize - 5,i); + for (j = 0; j < 5; ++j) { + cputc(grid[i][j]); + } + } gotoxy(0,ysize - 2 - ((256 + xsize) / xsize)); + revers(1); for (i = 0; i < xsize; ++i) { cputc('0' + i % 10); } + revers(0); for (i = 0; i < 256; ++i) { if ((i != '\n') && (i != '\r')) { cputc(i); @@ -46,13 +64,15 @@ void main(void) while(wherex() > 0) { cputc('#'); } + revers(1); for (i = 0; i < xsize; ++i) { cputc('0' + i % 10); } + revers(0); for(;;) { - gotoxy(xsize - 10, 3); + gotoxy(8, 2); j = (n >> 5) & 1; revers(j); cputc(j ? 'R' : ' '); From 7486923c1786b6c64e8d0bad52217ed54c8eed3f Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 28 Sep 2015 15:57:16 +0200 Subject: [PATCH 08/54] dont use seperate file for charset data --- libsrc/c64/soft80_charset.s | 137 ------------------------------------ libsrc/c64/soft80_conio.s | 136 ++++++++++++++++++++++++++++++++++- 2 files changed, 135 insertions(+), 138 deletions(-) delete mode 100644 libsrc/c64/soft80_charset.s diff --git a/libsrc/c64/soft80_charset.s b/libsrc/c64/soft80_charset.s deleted file mode 100644 index 999d199f0..000000000 --- a/libsrc/c64/soft80_charset.s +++ /dev/null @@ -1,137 +0,0 @@ - -.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 - -.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 - -.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 - -.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 - -.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 - -.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 - -.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 - -.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 - diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index fd2d7fd4d..84e5157c8 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -84,6 +84,140 @@ soft80_shutdown: sta VIC_VIDEO_ADR rts + .rodata soft80_charset: - .include "soft80_charset.s" + .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 + .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 + + .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 + + .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 + + .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 + + .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 + + .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 + + .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 From 841d764a83a8d517654ff6a26d3b0eb5ee2dc369 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 28 Sep 2015 16:10:11 +0200 Subject: [PATCH 09/54] some cleanup, checked usage of __bgcolor and __textcolor --- libsrc/c64/soft80_cgetc.s | 2 +- libsrc/c64/soft80_color.s | 3 +-- libsrc/c64/soft80_cputc.s | 2 +- libsrc/c64/soft80_kclrscr.s | 2 +- libsrc/c64/soft80_kplot.s | 3 ++- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index 12b2071a2..a8c52c1a2 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -3,7 +3,7 @@ ; .export soft80_cgetc - .import cursor ; FIX/CHECK + .import cursor .import soft80_putcolor .include "c64.inc" diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index c176eca7f..8475cc05c 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -5,7 +5,7 @@ ; .export soft80_textcolor, soft80_bgcolor, soft80_bordercolor - .export __textcolor,__bgcolor ; CHECK/FIX + .export __textcolor, __bgcolor .importzp tmp1,tmp2 @@ -89,7 +89,6 @@ soft80_bordercolor: txa rts - ; FIXME: shouldnt they be in zeropage? .bss __textcolor: .res 1 diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index d4c7e3050..590e16740 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -11,7 +11,7 @@ .import popa, _gotoxy .import xsize .import soft80_kplot - .import __bgcolor ; FIX/CHECK + .import __bgcolor .importzp tmp4,tmp3 diff --git a/libsrc/c64/soft80_kclrscr.s b/libsrc/c64/soft80_kclrscr.s index e801c9398..ff1a14a07 100644 --- a/libsrc/c64/soft80_kclrscr.s +++ b/libsrc/c64/soft80_kclrscr.s @@ -1,7 +1,7 @@ .export soft80_kclrscr .import soft80_kplot - .import __bgcolor ; FIX/CHECK + .import __bgcolor .include "c64.inc" .include "soft80.inc" diff --git a/libsrc/c64/soft80_kplot.s b/libsrc/c64/soft80_kplot.s index a813fd679..884404b5f 100644 --- a/libsrc/c64/soft80_kplot.s +++ b/libsrc/c64/soft80_kplot.s @@ -18,7 +18,8 @@ soft80_kplot: ; calc pointer to vram tya - lsr a + lsr a ; NOTE: we can save 2 cycles here at the expense of + ; making the tables twice as big (+50 bytes) clc adc _vramlo,x sta CRAM_PTR From 4949836d1692a88c1ebbb71a1b6c7936f9c28e63 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 28 Sep 2015 17:12:20 +0200 Subject: [PATCH 10/54] fixed kplot --- libsrc/c64/soft80_kplot.s | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libsrc/c64/soft80_kplot.s b/libsrc/c64/soft80_kplot.s index 884404b5f..eaaed7596 100644 --- a/libsrc/c64/soft80_kplot.s +++ b/libsrc/c64/soft80_kplot.s @@ -7,6 +7,9 @@ soft80_kplot: bcs @getpos + stx CURS_Y + sty CURS_X + ; calc pointer to bitmap lda _bitmaplo,x clc From f39337a6ec6483f16ed109b7deb0030269ec403c Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 28 Sep 2015 17:12:33 +0200 Subject: [PATCH 11/54] added input test --- testcode/lib/conio.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index f1b21e7a5..f998abeae 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -3,7 +3,6 @@ #include #include - static char grid[5][5] = { { CH_ULCORNER, CH_HLINE, CH_TTEE, CH_HLINE, CH_URCORNER }, { CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE }, @@ -15,11 +14,11 @@ static char grid[5][5] = { void main(void) { int i, j, n; - unsigned char xsize, ysize, tcol; + unsigned char xsize, ysize, tcol, inpos = 0; clrscr(); screensize(&xsize, &ysize); - cputs("cc65 conio test"); + cputs("cc65 conio test\n\rInput:[ ]"); cputsxy(0, 2, "Colors:" ); tcol = textcolor(0); /* remember original textcolor */ @@ -70,15 +69,21 @@ void main(void) } revers(0); + cursor(1); for(;;) { gotoxy(8, 2); - j = (n >> 5) & 1; + j = n & 1; revers(j); cputc(j ? 'R' : ' '); + revers(j ^ 1); cputs(" revers"); revers(0); + gotoxy(7 + inpos,1); + cputc(cgetc()); + inpos = (inpos + 1) & 7; + ++n; } From 5ea842b88b7e799826f33ec9b8c80d4a0091bebe Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 1 Oct 2015 15:03:11 +0200 Subject: [PATCH 12/54] SCREEN->screensize --- libsrc/c64/extra/soft80.s | 4 ++-- libsrc/c64/{soft80_kscreen.s => soft80_scrsize.s} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename libsrc/c64/{soft80_kscreen.s => soft80_scrsize.s} (64%) diff --git a/libsrc/c64/extra/soft80.s b/libsrc/c64/extra/soft80.s index baf61f635..e6b373b64 100644 --- a/libsrc/c64/extra/soft80.s +++ b/libsrc/c64/extra/soft80.s @@ -48,8 +48,8 @@ .export PLOT := soft80_kplot ; soft80_kscreen.s - .import soft80_kscreen - .export SCREEN := soft80_kscreen + .import soft80_screensize + .export screensize := soft80_screensize ;------------------------------------------------------------------------------- ; force the init constructor to be imported diff --git a/libsrc/c64/soft80_kscreen.s b/libsrc/c64/soft80_scrsize.s similarity index 64% rename from libsrc/c64/soft80_kscreen.s rename to libsrc/c64/soft80_scrsize.s index 22c7b6788..caaeb4791 100644 --- a/libsrc/c64/soft80_kscreen.s +++ b/libsrc/c64/soft80_scrsize.s @@ -1,9 +1,9 @@ - .export soft80_kscreen + .export soft80_screensize .include "soft80.inc" -soft80_kscreen: +soft80_screensize: ldy #screenrows ldx #charsperline rts From 23473641f474e33f2062b0aa4c93b66b8187ab25 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 1 Oct 2015 17:16:02 +0200 Subject: [PATCH 13/54] fix clrscr so it doesnt wipe sprite pointers --- libsrc/c64/soft80_kclrscr.s | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libsrc/c64/soft80_kclrscr.s b/libsrc/c64/soft80_kclrscr.s index ff1a14a07..c2f09f76e 100644 --- a/libsrc/c64/soft80_kclrscr.s +++ b/libsrc/c64/soft80_kclrscr.s @@ -12,9 +12,10 @@ soft80_kclrscr: ldx #$00 lp1: - .repeat $20,page + .repeat $1f,page sta soft80_bitmap+(page*$100),x .endrepeat + sta soft80_bitmap+$1e40,x inx bne lp1 @@ -29,9 +30,10 @@ lp1: ;ldx #$00 lp2: - .repeat $4,page - sta soft80_vram+(page*$100),x - .endrepeat + sta soft80_vram,x + sta soft80_vram+$100,x + sta soft80_vram+$200,x + sta soft80_vram+$2e8,x inx bne lp2 @@ -40,9 +42,10 @@ lp2: lda __bgcolor ;ldx #$00 lp3: - .repeat $4,page - sta soft80_colram+(page*$100),x - .endrepeat + sta soft80_colram,x + sta soft80_colram+$100,x + sta soft80_colram+$200,x + sta soft80_colram+$2e8,x inx bne lp3 From ee54f7f40c7a89d78683eb79c709748922d98fd4 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Tue, 6 Oct 2015 19:33:43 +0200 Subject: [PATCH 14/54] optimized clrscr for size --- libsrc/c64/soft80_kclrscr.s | 60 +++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/libsrc/c64/soft80_kclrscr.s b/libsrc/c64/soft80_kclrscr.s index c2f09f76e..2e7457679 100644 --- a/libsrc/c64/soft80_kclrscr.s +++ b/libsrc/c64/soft80_kclrscr.s @@ -2,22 +2,36 @@ .export soft80_kclrscr .import soft80_kplot .import __bgcolor + .importzp ptr1 .include "c64.inc" .include "soft80.inc" soft80_kclrscr: + lda #soft80_bitmap + sta ptr1+1 + lda #$ff - ldx #$00 -lp1: - .repeat $1f,page - sta soft80_bitmap+(page*$100),x - .endrepeat + ldx #$1f +@lp2: + ldy #0 +@lp1: + sta (ptr1),y + iny + bne @lp1 + inc ptr1+1 + dex + bne @lp2 + + ;ldx #$00 +@lp3: sta soft80_bitmap+$1e40,x inx - bne lp1 + bne @lp3 sei ldy $01 @@ -27,28 +41,12 @@ lp1: lda CHARCOLOR and #$f0 ora __bgcolor + jsr clear ; clear vram - ;ldx #$00 -lp2: - sta soft80_vram,x - sta soft80_vram+$100,x - sta soft80_vram+$200,x - sta soft80_vram+$2e8,x - inx - bne lp2 - - inc $01 + inc $01 ; -> $35 lda __bgcolor - ;ldx #$00 -lp3: - sta soft80_colram,x - sta soft80_colram+$100,x - sta soft80_colram+$200,x - sta soft80_colram+$2e8,x - inx - bne lp3 - + jsr clear ; clear color ram sty $01 cli @@ -58,6 +56,16 @@ lp3: clc jmp soft80_kplot - + ; clear loop for colram and vram +clear: + ;ldx #$00 +@lp1: + sta soft80_colram,x + sta soft80_colram+$100,x + sta soft80_colram+$200,x + sta soft80_colram+$2e8,x + inx + bne @lp1 + rts From 67dabb8489759a789e1b778dfa313441e8fe16bf Mon Sep 17 00:00:00 2001 From: mrdudz Date: Tue, 6 Oct 2015 20:18:40 +0200 Subject: [PATCH 15/54] attempted fix for the color problem noticed by oliver --- libsrc/c64/soft80_color.s | 130 +++++++++++++++++++++----------------- 1 file changed, 73 insertions(+), 57 deletions(-) diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index 8475cc05c..ee226633a 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -7,7 +7,7 @@ .export soft80_textcolor, soft80_bgcolor, soft80_bordercolor .export __textcolor, __bgcolor - .importzp tmp1,tmp2 + .importzp tmp1, tmp2 .import soft80_checkchar @@ -15,74 +15,90 @@ .include "soft80.inc" soft80_textcolor: - ldx __textcolor ; get old value sta __textcolor ; set new value + jsr mkcharcolor + + txa ; get old value + rts + +soft80_bgcolor: + ldx __bgcolor ; get old value + stx tmp2 ; save old value + sta __bgcolor ; set new value + + jsr mkcharcolor + + ; if the old bg color is equal to color ram of that cell, then also + ; update the color ram to the new value. + ; FIXME: perhaps we must also check if the non visible character is not + ; a space, and NOT update the color ram in that case. + ldx #$00 +lp1: + .repeat $3,page + .scope + lda soft80_colram+(page*$100),x + and #$0f + cmp tmp2 ; old bg color + bne @sk1 + lda __bgcolor + sta soft80_colram+(page*$100),x +@sk1: + .endscope + .endrepeat + + .scope + lda soft80_colram+$2e8,x + and #$0f + cmp tmp2 ; old bg color + bne @sk1 + lda __bgcolor + sta soft80_colram+$2e8,x +@sk1: + .endscope + + inx + bne lp1 + + sei + ldy $01 + lda #$34 ; disable I/O + sta $01 + + ldx #$00 +@lp2: + .repeat $3,page + lda soft80_vram+(page*$100),x + and #$0f + ora tmp1 ; new bg color (high nibble) + sta soft80_vram+(page*$100),x + .endrepeat + lda soft80_vram+$2e8,x + and #$0f + ora tmp1 ; new bg color (high nibble) + sta soft80_vram+$2e8,x + + inx + bne @lp2 + + sty $01 ; enable I/O + cli + + lda tmp2 ; get old value + rts + +mkcharcolor: lda __bgcolor asl a asl a asl a asl a + sta tmp1 ; remember new bg color (high nibble) ora __textcolor sta CHARCOLOR ; text/bg combo for new chars - - txa ; get old value rts - -soft80_bgcolor: - 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 - rts - - soft80_bordercolor: ldx VIC_BORDERCOLOR ; get old value sta VIC_BORDERCOLOR ; set new value From e54ad81ce8f796f89ea72f029d2be4d82d6aad75 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 8 Oct 2015 20:43:25 +0200 Subject: [PATCH 16/54] some more rework, second attempt on fixing the color issues. added ifdefs to disable the color voodoo alltogether for debugging purposes. --- libsrc/c64/soft80.inc | 7 + libsrc/c64/soft80_cgetc.s | 71 +++----- libsrc/c64/soft80_color.s | 43 +++-- libsrc/c64/soft80_conio.s | 13 +- libsrc/c64/soft80_cputc.s | 344 ++++++++++++++++++++---------------- libsrc/c64/soft80_kclrscr.s | 12 +- 6 files changed, 256 insertions(+), 234 deletions(-) diff --git a/libsrc/c64/soft80.inc b/libsrc/c64/soft80.inc index d534cac69..f2058f91d 100644 --- a/libsrc/c64/soft80.inc +++ b/libsrc/c64/soft80.inc @@ -21,3 +21,10 @@ CH_BTEE = 177 CH_TTEE = 178 CH_RTEE = 179 CH_LRCORNER = 189 + +;------------------------------------------------------------------------------- +; set to 0 to disable the color-ram "voodoo" for debugging purposes +.define SOFT80COLORVOODOO 1 +; set to 0 to disable special case optimization for the "space" character +.define SOFT80FASTSPACE 1 + diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index a8c52c1a2..723c5ade8 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -4,87 +4,66 @@ .export soft80_cgetc .import cursor - .import soft80_putcolor .include "c64.inc" .include "soft80.inc" +.if SOFT80COLORVOODOO = 1 + .import soft80_putcolor +.endif + 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 + jsr invertcursor ; 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 + jsr invertcursor ; set cursor on or off accordingly L3: jsr KBDREAD ; Read char and return in A ldx #0 rts -; Switch the cursor on or off +; Switch the cursor on or off (invert) -; A= 0: cursor off -; 1: cursor on - - .proc setcursor - - ; On or off? - cmp CURS_STATE - bne @set +invertcursor: + lda cursor + bne @invert rts -@set: - sta CURS_STATE +@invert: sei lda $01 pha - lda #$34 + lda #$34 ; enable RAM under I/O sta $01 - jsr soft80_putcolor - ldy #$00 +.if SOFT80COLORVOODOO = 1 + jsr soft80_putcolor +.else + lda CHARCOLOR + sta (CRAM_PTR),y ; vram +.endif lda CURS_X and #$01 - bne @l1 - - .repeat 8,line + tax +@lp1: lda (SCREEN_PTR),y - eor #$f0 + eor nibble,x sta (SCREEN_PTR),y - .if (line < 7) iny - .endif - .endrepeat + cpy #8 + bne @lp1 -@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 + .rodata +nibble: .byte $f0, $0f diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index ee226633a..f537f8d84 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -30,57 +30,54 @@ soft80_bgcolor: jsr mkcharcolor +.if SOFT80COLORVOODOO = 1 ; if the old bg color is equal to color ram of that cell, then also ; update the color ram to the new value. ; FIXME: perhaps we must also check if the non visible character is not ; a space, and NOT update the color ram in that case. ldx #$00 lp1: - .repeat $3,page + .repeat $4,page .scope - lda soft80_colram+(page*$100),x + lda soft80_colram+(page*250),x and #$0f cmp tmp2 ; old bg color bne @sk1 - lda __bgcolor - sta soft80_colram+(page*$100),x + lda __bgcolor ; new bg color + sta soft80_colram+(page*250),x @sk1: .endscope .endrepeat - .scope - lda soft80_colram+$2e8,x - and #$0f - cmp tmp2 ; old bg color - bne @sk1 - lda __bgcolor - sta soft80_colram+$2e8,x -@sk1: - .endscope - inx bne lp1 +.endif sei ldy $01 lda #$34 ; disable I/O sta $01 + ; if the old bg color is equal to text color in this cell, then also + ; update the text color to the new value. + ; FIXME: perhaps we need to check for space, see note above ldx #$00 -@lp2: - .repeat $3,page - lda soft80_vram+(page*$100),x +lp2: + .repeat $4,page + .scope + lda soft80_vram+(page*250),x and #$0f + cmp tmp2 ; old bg color + bne @sk2 + lda __bgcolor ; new bg color +@sk2: ora tmp1 ; new bg color (high nibble) - sta soft80_vram+(page*$100),x + sta soft80_vram+(page*250),x + .endscope .endrepeat - lda soft80_vram+$2e8,x - and #$0f - ora tmp1 ; new bg color (high nibble) - sta soft80_vram+$2e8,x inx - bne @lp2 + bne lp2 sty $01 ; enable I/O cli diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 84e5157c8..5fbeaadc1 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -6,7 +6,7 @@ .destructor soft80_shutdown .import soft80_kclrscr - .import soft80_textcolor, soft80_bgcolor + .import __textcolor, __bgcolor .importzp ptr1, ptr2, ptr3 @@ -67,11 +67,18 @@ soft80_init: cli lda 646 ; use current textcolor - jsr soft80_textcolor + and #$0f + sta __textcolor lda VIC_BG_COLOR0 ; use current bgcolor and #$0f - jsr soft80_bgcolor + sta __bgcolor + asl a + asl a + asl a + asl a + ora __textcolor + sta CHARCOLOR jmp soft80_kclrscr diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 590e16740..41132a346 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -5,7 +5,6 @@ .export soft80_cputcxy, soft80_cputc .export soft80_cputdirect, soft80_putchar - .export soft80_putcolor .export soft80_newline, soft80_plot .import popa, _gotoxy @@ -20,6 +19,10 @@ .include "c64.inc" .include "soft80.inc" +.if SOFT80COLORVOODOO = 1 + .export soft80_putcolor +.endif + soft80_cputcxy: pha ; Save C jsr popa ; Get Y @@ -125,163 +128,17 @@ L5: ; 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 -soft80_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 - +.if SOFT80FASTSPACE = 1 ; output space - +; in: y must be $00 _space: lda RVS jne _spaceinvers +.if SOFT80COLORVOODOO = 1 jsr remcolor - +.endif ;ldy #$00 ; is still $00 lda CURS_X @@ -310,10 +167,15 @@ _space: jmp _back ; output inverted space - +; in: y must be $00 _spaceinvers: +.if SOFT80COLORVOODOO = 1 jsr soft80_putcolor +.else + lda CHARCOLOR + sta (CRAM_PTR),y ; vram +.endif lda CURS_X and #$01 @@ -339,11 +201,12 @@ _spaceinvers: .endrepeat jmp _back +.endif ; output a character soft80_putchar: - sta tmp3 + sta tmp3 ; remember charcode sei ldx $01 @@ -353,14 +216,20 @@ soft80_putchar: stx $01 ; will stay $34 for space ldy #$00 ; will be $00 from now on +.if SOFT80FASTSPACE = 1 cmp #' ' ; space is a special (optimized) case jeq _space +.endif +.if SOFT80COLORVOODOO = 1 jsr soft80_putcolor +.else + lda CHARCOLOR + sta (CRAM_PTR),y ; vram +.endif + ; output character -; output character -char: - ldx tmp3 + ldx tmp3 ; get charcode lda RVS jne _invers @@ -429,3 +298,166 @@ _invers: .endif .endrepeat jmp _back + +;------------------------------------------------------------------------------- + +.if SOFT80COLORVOODOO = 1 +;--- start color vodoo + +; remove color from cell, called before putting a "space" character to the bitmap +; y unmodified +remcolor: + + ;ldy #$00 ; is still $00 + + ; if the textcolor in vram is equal to the background color, then + ; no (visible) character is in the current cell and we can exit + ; immediately. + lda (CRAM_PTR),y ; vram (textcolor) + and #$0f + cmp __bgcolor + jeq @l2b ; yes, vram==bgcolor + + ; now check if the textcolor in color ram is equal the background color, + ; if yes then there is only one (visible) character in the current cell + inc $01 + lda (CRAM_PTR),y ; colram (2nd textcolor) + stx $01 ;$34 + and #$0f + cmp __bgcolor + beq @l2s ; yes, colram==bgcolor + + ; two characters in the current cell, of which one will get removed + + ; vram = colram + ;inc $01 + ;lda (CRAM_PTR),y ; colram + ;stx $01 ;$34 + ;and #$0f + + ; move 2nd text color to vram + 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 (textcolor) = bgcolor + lda (CRAM_PTR),y ; vram + and #$f0 + ora __bgcolor + sta (CRAM_PTR),y ; vram +@l2b: + rts + +; put color to cell +; in: $01 is $34 (RAM under I/O) when entering +; y must be $00 +; out: y = $00 +soft80_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 + + ;.export soft80_checkchar + +; test if there is a space or a character at current position +; in: y must be $00 +; out: CLC: space SEC: character +; y = $00 +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 + +;--- end color vodoo +.endif diff --git a/libsrc/c64/soft80_kclrscr.s b/libsrc/c64/soft80_kclrscr.s index 2e7457679..790aa2749 100644 --- a/libsrc/c64/soft80_kclrscr.s +++ b/libsrc/c64/soft80_kclrscr.s @@ -33,9 +33,14 @@ soft80_kclrscr: inx bne @lp3 +.if SOFT80COLORVOODOO = 1 + lda __bgcolor + jsr clear ; clear color ram +.endif + sei ldy $01 - lda #$34 + lda #$34 ; enable RAM under I/O sta $01 lda CHARCOLOR @@ -43,11 +48,6 @@ soft80_kclrscr: ora __bgcolor jsr clear ; clear vram - inc $01 ; -> $35 - - lda __bgcolor - jsr clear ; clear color ram - sty $01 cli From f712e9448ade899d57ed993c8ce6351214d1c3e1 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Fri, 9 Oct 2015 13:34:23 +0200 Subject: [PATCH 17/54] some cleanup/rework --- libsrc/c64/extra/soft80.s | 5 ----- libsrc/c64/soft80_cgetc.s | 6 ++++++ libsrc/c64/soft80_color.s | 8 ++++++-- libsrc/c64/soft80_cputc.s | 2 -- libsrc/c64/soft80_kplot.s | 5 +++++ libsrc/c64/soft80_scrsize.s | 6 ++++++ 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/libsrc/c64/extra/soft80.s b/libsrc/c64/extra/soft80.s index e6b373b64..80ef338b6 100644 --- a/libsrc/c64/extra/soft80.s +++ b/libsrc/c64/extra/soft80.s @@ -51,8 +51,3 @@ .import soft80_screensize .export screensize := soft80_screensize -;------------------------------------------------------------------------------- -; force the init constructor to be imported - - .import soft80_init -conio_init = soft80_init diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index 723c5ade8..c68035dc5 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -67,3 +67,9 @@ invertcursor: .rodata nibble: .byte $f0, $0f + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import soft80_init +conio_init = soft80_init diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index f537f8d84..3d9cca56c 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -9,8 +9,6 @@ .importzp tmp1, tmp2 - .import soft80_checkchar - .include "c64.inc" .include "soft80.inc" @@ -107,3 +105,9 @@ __textcolor: .res 1 __bgcolor: .res 1 + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import soft80_init +conio_init = soft80_init diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 41132a346..233132dca 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -410,8 +410,6 @@ soft80_putcolor: rts - ;.export soft80_checkchar - ; test if there is a space or a character at current position ; in: y must be $00 ; out: CLC: space SEC: character diff --git a/libsrc/c64/soft80_kplot.s b/libsrc/c64/soft80_kplot.s index eaaed7596..6df33c008 100644 --- a/libsrc/c64/soft80_kplot.s +++ b/libsrc/c64/soft80_kplot.s @@ -62,3 +62,8 @@ _bitmaphi: .byte >(soft80_bitmap+(row*40*8)) .endrepeat +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import soft80_init +conio_init = soft80_init diff --git a/libsrc/c64/soft80_scrsize.s b/libsrc/c64/soft80_scrsize.s index caaeb4791..1873f7327 100644 --- a/libsrc/c64/soft80_scrsize.s +++ b/libsrc/c64/soft80_scrsize.s @@ -7,3 +7,9 @@ soft80_screensize: ldy #screenrows ldx #charsperline rts + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import soft80_init +conio_init = soft80_init From 0b9d67d8a864d02631881b7cdc2e0e720d8bd2b9 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Fri, 9 Oct 2015 13:40:10 +0200 Subject: [PATCH 18/54] use default prio for the constructor --- libsrc/c64/soft80_conio.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 5fbeaadc1..6b909822a 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -2,7 +2,7 @@ ; Low level stuff for screen output/console input ; - .constructor soft80_init, 24 + .constructor soft80_init .destructor soft80_shutdown .import soft80_kclrscr From 03c6af3e15168eabaf9527814f561ba7670b0bf8 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Fri, 9 Oct 2015 23:39:37 +0200 Subject: [PATCH 19/54] rewrote color voodoo --- libsrc/c64/soft80_cgetc.s | 36 ++++++---- libsrc/c64/soft80_cputc.s | 136 +++++++++++++++++++++++++++----------- 2 files changed, 120 insertions(+), 52 deletions(-) diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index c68035dc5..130aca7c5 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -4,23 +4,22 @@ .export soft80_cgetc .import cursor + .importzp tmp1 .include "c64.inc" .include "soft80.inc" -.if SOFT80COLORVOODOO = 1 - .import soft80_putcolor -.endif - soft80_cgetc: lda KEY_COUNT ; Get number of characters bne L3 ; Jump if there are already chars waiting + ldx #1 jsr invertcursor ; set cursor on or off accordingly L1: lda KEY_COUNT ; wait for key beq L1 + ldx #0 jsr invertcursor ; set cursor on or off accordingly L3: jsr KBDREAD ; Read char and return in A @@ -36,18 +35,13 @@ invertcursor: @invert: sei - lda $01 + lda $01 ; enable RAM under I/O pha - lda #$34 ; enable RAM under I/O + lda #$34 sta $01 ldy #$00 -.if SOFT80COLORVOODOO = 1 - jsr soft80_putcolor -.else - lda CHARCOLOR - sta (CRAM_PTR),y ; vram -.endif + jsr setcolor lda CURS_X and #$01 @@ -65,6 +59,24 @@ invertcursor: cli rts + ; do not use soft80_putcolor here to make sure the cursor is always + ; shown using the current textcolor without disturbing the "color voodoo" + ; in soft80_cputc +setcolor: + ;ldy #0 ; is 0 + txa + bne @set + ; restore old value + lda tmp1 + sta (CRAM_PTR),y ; vram + rts +@set: + lda (CRAM_PTR),y ; vram + sta tmp1 + lda CHARCOLOR + sta (CRAM_PTR),y ; vram + rts + .rodata nibble: .byte $f0, $0f diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 233132dca..3ef982aaa 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -10,7 +10,7 @@ .import popa, _gotoxy .import xsize .import soft80_kplot - .import __bgcolor + .import __bgcolor, __textcolor .importzp tmp4,tmp3 @@ -300,12 +300,36 @@ _invers: jmp _back ;------------------------------------------------------------------------------- +; optional "color voodoo". the problem is that each 8x8 cell can only contain +; two colors, one of which is used for the background color, so two characters +; have to share the same text color. +; +; - in a cell that contains two spaces, both the color ram and the text color +; in vram contain the background color +; +; - in a cell that contains one character, its text color goes into vram. the +; color ram contains the background color. +; +; - in a cell that contains two characters, the color of the left character goes +; to vram (and is shared by both for display). the "would be" color of the +; right character goes to color ram as a reminder and can be restored when one +; of the two characters is cleared by a space. .if SOFT80COLORVOODOO = 1 -;--- start color vodoo ; remove color from cell, called before putting a "space" character to the bitmap -; y unmodified +; +; __ -> __ - +; _A -> _A - +; B_ -> B_ - +; _A -> __ vram = bgcol +; B_ -> __ vram = bgcol +; BA -> _A vram = colram, colram = bgcol +; BA -> B_ colram = bgcol +; +; in: x must be $34 +; y must be $00 +; out: y = $00 remcolor: ;ldy #$00 ; is still $00 @@ -316,16 +340,16 @@ remcolor: lda (CRAM_PTR),y ; vram (textcolor) and #$0f cmp __bgcolor - jeq @l2b ; yes, vram==bgcolor + beq @sk1 ; yes, vram==bgcolor ; now check if the textcolor in color ram is equal the background color, ; if yes then there is only one (visible) character in the current cell - inc $01 + inc $01 ; $35 lda (CRAM_PTR),y ; colram (2nd textcolor) - stx $01 ;$34 + stx $01 ; $34 and #$0f cmp __bgcolor - beq @l2s ; yes, colram==bgcolor + beq @sk2 ; yes, colram==bgcolor ; two characters in the current cell, of which one will get removed @@ -334,41 +358,58 @@ remcolor: ;lda (CRAM_PTR),y ; colram ;stx $01 ;$34 ;and #$0f + sta tmp3 ; A contains colram - ; move 2nd text color to vram - sta tmp3 + lda CURS_X + and #$01 + bne @sk3 + + ; vram = colram lda (CRAM_PTR),y ; vram and #$f0 ora tmp3 sta (CRAM_PTR),y ; vram - +@sk3: ; colram = bgcolor lda __bgcolor - inc $01 + inc $01 ; $35 sta (CRAM_PTR),y ; colram - stx $01 ;$34 + stx $01 ; $34 - jmp @l2b + rts -@l2s: +@sk2: ; colram is bgcolor ; => only one char in cell used jsr soft80_checkchar - bcc @l2b ; space at current position + bcc @sk1 ; space at current position ; vram (textcolor) = bgcolor lda (CRAM_PTR),y ; vram and #$f0 ora __bgcolor sta (CRAM_PTR),y ; vram -@l2b: +@sk1: rts ; put color to cell -; in: $01 is $34 (RAM under I/O) when entering -; y must be $00 -; out: y = $00 +; +; __ -> _A vram = textcol +; __ -> B_ vram = textcol +; _A -> BA colram = vram, vram = textcol +; B_ -> BA colram = textcol +; +; _A -> _C vram = textcol +; B_ -> C_ vram = textcol +; BA -> BC colram = textcol +; BA -> CA vram = textcol +; +; in: $01 is $34 (RAM under I/O) when entering +; x must be $34 +; y must be $00 +; out: x = $34 +; y = $00 soft80_putcolor: ;ldy #$00 ; is still $00 @@ -376,38 +417,54 @@ soft80_putcolor: lda (CRAM_PTR),y ; vram and #$0f cmp __bgcolor - beq @l2s ; vram==bgcolor => first char in cell + beq @sk1 ; vram==bgcolor => first char in cell ; vram!=bgcolor => second char in cell - inc $01 ;$35 + inc $01 ; $35 lda (CRAM_PTR),y ; colram - stx $01 ;$34 + stx $01 ; $34 and #$0f cmp __bgcolor - bne @l2s ; colram!=bgcolor + beq @l2s ; colram==bgcolor -> second char in cell - ; colram==bgcolor => second char in cell or overwrite 1st char + ; botch characters in the cell are used - jsr soft80_checkchar - bcs @l2a ; char at current position => overwrite 1st + lda CURS_X + and #$01 + bne @sk2 ; jump if odd xpos - ; 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 + ; vram = textcol lda CHARCOLOR sta (CRAM_PTR),y ; vram + rts +@l2s: + ; one character in cell is already used + jsr soft80_checkchar + bcs @sk1 ; char at current position => overwrite 1st + + lda CURS_X + and #$01 + beq @sk3 ; jump if even xpos +@sk2: + ; colram = textcol + lda __textcolor + inc $01 ; $35 + sta (CRAM_PTR),y ; colram + stx $01 ; $34 + rts + +@sk3: + ; colram=vram + lda (CRAM_PTR),y ; vram + inc $01 ; $35 + sta (CRAM_PTR),y ; colram + stx $01 ; $34 +@sk1: + ; vram = textcol + lda CHARCOLOR + sta (CRAM_PTR),y ; vram rts ; test if there is a space or a character at current position @@ -457,5 +514,4 @@ soft80_checkchar: sec rts -;--- end color vodoo .endif From 70ed96d06d948f0732f0379b8df9f9934c44ec3a Mon Sep 17 00:00:00 2001 From: mrdudz Date: Fri, 9 Oct 2015 23:39:55 +0200 Subject: [PATCH 20/54] updated conio test --- testcode/lib/conio.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index f998abeae..3e4b4539f 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -18,7 +18,7 @@ void main(void) clrscr(); screensize(&xsize, &ysize); - cputs("cc65 conio test\n\rInput:[ ]"); + cputs("cc65 conio test\n\rInput: [ ]"); cputsxy(0, 2, "Colors:" ); tcol = textcolor(0); /* remember original textcolor */ @@ -80,9 +80,18 @@ void main(void) cputs(" revers"); revers(0); - gotoxy(7 + inpos,1); - cputc(cgetc()); - inpos = (inpos + 1) & 7; + gotoxy(8 + inpos,1); + i = cgetc(); + if ((i >= '0') && (i<='9')) { + textcolor(i - '0'); + } else if (i == CH_CURS_LEFT) { + inpos = (inpos - 1) & 7; + } else if (i == CH_CURS_RIGHT) { + inpos = (inpos + 1) & 7; + } else { + cputc(i); + inpos = (inpos + 1) & 7; + } ++n; } From 32397b9a2b7363c10ff9c46897a27c4e818137dc Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 11 Oct 2015 17:07:48 +0200 Subject: [PATCH 21/54] print a space for 0x0a and 0x0d in the char matrix --- testcode/lib/conio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index 3e4b4539f..a7a83594e 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -58,6 +58,8 @@ void main(void) for (i = 0; i < 256; ++i) { if ((i != '\n') && (i != '\r')) { cputc(i); + } else { + cputc(' '); } } while(wherex() > 0) { From d8d7f53d1b2187d2ba44a00d7002e49a592b8da2 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 11 Oct 2015 17:13:28 +0200 Subject: [PATCH 22/54] move charset to seperate file again, added comments on charset layout --- libsrc/c64/soft80_cgetc.s | 2 + libsrc/c64/soft80_charset.s | 171 ++++++++++++++++++++++++++++++++++++ libsrc/c64/soft80_conio.s | 143 +----------------------------- libsrc/c64/soft80_cputc.s | 3 +- 4 files changed, 179 insertions(+), 140 deletions(-) create mode 100644 libsrc/c64/soft80_charset.s diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index 130aca7c5..7d8a1d88f 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -1,4 +1,6 @@ ; +; Groepaz/Hitmen, 11.10.2015 +; ; char cgetc (void); ; diff --git a/libsrc/c64/soft80_charset.s b/libsrc/c64/soft80_charset.s new file mode 100644 index 000000000..f44fdaf77 --- /dev/null +++ b/libsrc/c64/soft80_charset.s @@ -0,0 +1,171 @@ +; +; Groepaz/Hitmen, 10.10.2015 +; +; character set for use with the soft80 implementation +; + +; the format of the data follows the following layout: +; +; - to avoid unnecessary petscii->screencode conversions, the order of the +; individual characters is different to the C64 ROM charset: +; - $00 - $1f screencodes $60 - $7f (petscii codes $a0 - $bf) +; - $20 - $3f screencodes $20 - $3f (petscii codes $20 - $3f) +; - $40 - $5f screencodes $00 - $1f (petscii codes $40 - $5f) +; - $60 - $7f screencodes $40 - $5f (petscii codes $60 - $7f) +; - only 128 characters are defined here, the soft80 implementation will invert +; the graphics data for inverted display on the fly. +; - finally the lower 4bits are "inverted", ie a space character is represented +; as $0f, $0f, $0f, $0f, $0f, $0f, $0f, $0f +; +; the graphics data is arranged differently to normal C64 charsets for speed, +; first comes the first row of all characters, then the second row in the next +; block, etc. like this: +; +; +000 ....xxxx ......xx ....xxxx ........ +; +080 ....xxxx ......xx ....xxxx ....xxxx +; +100 ....xxxx ......xx ....xxxx ....xxxx +; +180 ....x..x ......xx ....xxxx ....xxxx +; +200 ....x..x ......xx ........ ....xxxx +; +280 ....xxxx ......xx ........ ....xxxx +; +300 ....xxxx ......xx ........ ....xxxx +; +380 ....xxxx ......xx ........ ....xxxx + + .export soft80_charset + + .rodata +soft80_charset: + .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 + + .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 + + .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 + + .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 + + .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 + + .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 + + .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 + + .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 diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 6b909822a..333251854 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -1,11 +1,13 @@ ; -; Low level stuff for screen output/console input +; Groepaz/Hitmen, 11.10.2015 +; +; Low level init code for soft80 screen output/console input ; .constructor soft80_init .destructor soft80_shutdown - .import soft80_kclrscr + .import soft80_kclrscr, soft80_charset .import __textcolor, __bgcolor .importzp ptr1, ptr2, ptr3 @@ -91,140 +93,3 @@ soft80_shutdown: sta VIC_VIDEO_ADR rts - .rodata -soft80_charset: - .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 - - .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 - - .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 - - .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 - - .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 - - .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 - - .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 - - .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 diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 3ef982aaa..a7662f1ad 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -1,4 +1,6 @@ ; +; Groepaz/Hitmen, 11.10.2015 +; ; void cputcxy (unsigned char x, unsigned char y, char c); ; void cputc (char c); ; @@ -49,7 +51,6 @@ L1: cmp #$0D ; LF? beq soft80_newline ; Recalculate pointers ; Printable char of some sort - tay bpl L10 From 07f1879f85f7cbb1f61f483c14e2ced159062e1f Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 14:40:12 +0200 Subject: [PATCH 23/54] added some more comments and -headers --- libsrc/c64/extra/soft80.s | 4 ++++ libsrc/c64/soft80.inc | 5 +++++ libsrc/c64/soft80_charset.s | 13 ++++++++++++- libsrc/c64/soft80_chline.s | 2 ++ libsrc/c64/soft80_color.s | 2 ++ libsrc/c64/soft80_conio.s | 3 ++- libsrc/c64/soft80_cvline.s | 2 ++ libsrc/c64/soft80_kclrscr.s | 5 +++++ libsrc/c64/soft80_kplot.s | 9 +++++++++ libsrc/c64/soft80_scrsize.s | 5 +++++ 10 files changed, 48 insertions(+), 2 deletions(-) diff --git a/libsrc/c64/extra/soft80.s b/libsrc/c64/extra/soft80.s index 80ef338b6..d43443fc8 100644 --- a/libsrc/c64/extra/soft80.s +++ b/libsrc/c64/extra/soft80.s @@ -1,3 +1,7 @@ +; +; Groepaz/Hitmen, 12.10.2015 +; +; import/overload stubs for the soft80 implementation ; soft80_cgetc.s diff --git a/libsrc/c64/soft80.inc b/libsrc/c64/soft80.inc index f2058f91d..a4bee337a 100644 --- a/libsrc/c64/soft80.inc +++ b/libsrc/c64/soft80.inc @@ -1,3 +1,7 @@ +; +; Groepaz/Hitmen, 12.10.2015 +; +; internal constants for the soft80 implementation soft80_lo_charset = $d000 soft80_hi_charset = $d400 @@ -8,6 +12,7 @@ soft80_bitmap = $e000 charsperline = 80 screenrows = 25 +; FIXME: these should match petscii and perhaps come from a common cbm.inc? CH_ESC = 95 CH_HLINE = 96 CH_CROSS = 123 diff --git a/libsrc/c64/soft80_charset.s b/libsrc/c64/soft80_charset.s index f44fdaf77..7a4e10968 100644 --- a/libsrc/c64/soft80_charset.s +++ b/libsrc/c64/soft80_charset.s @@ -1,5 +1,5 @@ ; -; Groepaz/Hitmen, 10.10.2015 +; Groepaz/Hitmen, 12.10.2015 ; ; character set for use with the soft80 implementation ; @@ -14,6 +14,8 @@ ; - $60 - $7f screencodes $40 - $5f (petscii codes $60 - $7f) ; - only 128 characters are defined here, the soft80 implementation will invert ; the graphics data for inverted display on the fly. +; - since the charset is 4 by 8 pixels, only the lower 4bit of each byte is +; used. the upper bits have to be 0. ; - finally the lower 4bits are "inverted", ie a space character is represented ; as $0f, $0f, $0f, $0f, $0f, $0f, $0f, $0f ; @@ -29,6 +31,15 @@ ; +280 ....xxxx ......xx ........ ....xxxx ; +300 ....xxxx ......xx ........ ....xxxx ; +380 ....xxxx ......xx ........ ....xxxx +; [...] +; +040 ....x.xx ....xxxx ....xxxx ....xxxx +; +0c0 .....x.x ....xxxx .....xxx ....xxxx +; +140 .......x ....x.xx .....xxx ....x..x +; +1c0 .......x ....xx.x ......xx .....xxx +; +240 .....xxx ....x..x .....x.x .....xxx +; +2c0 .....x.x .....x.x .....x.x .....xxx +; +340 ....x.xx ....x..x ......xx ....x..x +; +3c0 ....xxxx ....xxxx ....xxxx ....xxxx .export soft80_charset diff --git a/libsrc/c64/soft80_chline.s b/libsrc/c64/soft80_chline.s index e15d0c483..73c8c1e26 100644 --- a/libsrc/c64/soft80_chline.s +++ b/libsrc/c64/soft80_chline.s @@ -1,4 +1,6 @@ ; +; Groepaz/Hitmen, 12.10.2015 +; ; void chlinexy (unsigned char x, unsigned char y, unsigned char length); ; void chline (unsigned char length); ; diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index 3d9cca56c..925b161ed 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -1,4 +1,6 @@ ; +; Groepaz/Hitmen, 12.10.2015 +; ; unsigned char __fastcall__ textcolor (unsigned char color); ; unsigned char __fastcall__ bgcolor (unsigned char color); ; unsigned char __fastcall__ bordercolor (unsigned char color); diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 333251854..6691158d7 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -25,7 +25,8 @@ soft80_init: lda #$c8 sta VIC_CTRL2 -; copy charset to RAM under I/O -> FIXME: generate at runtime + ; copy charset to RAM under I/O + ; FIXME: move charset and this constructor into init segment sei lda $01 pha diff --git a/libsrc/c64/soft80_cvline.s b/libsrc/c64/soft80_cvline.s index eaa850118..e2c6e947c 100644 --- a/libsrc/c64/soft80_cvline.s +++ b/libsrc/c64/soft80_cvline.s @@ -1,4 +1,6 @@ ; +; Groepaz/Hitmen, 12.10.2015 +; ; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); ; void cvline (unsigned char length); ; diff --git a/libsrc/c64/soft80_kclrscr.s b/libsrc/c64/soft80_kclrscr.s index 790aa2749..95633de79 100644 --- a/libsrc/c64/soft80_kclrscr.s +++ b/libsrc/c64/soft80_kclrscr.s @@ -1,3 +1,8 @@ +; +; Groepaz/Hitmen, 12.10.2015 +; +; lowlevel kclrscr for soft80 implementation +; .export soft80_kclrscr .import soft80_kplot diff --git a/libsrc/c64/soft80_kplot.s b/libsrc/c64/soft80_kplot.s index 6df33c008..e359e9f58 100644 --- a/libsrc/c64/soft80_kplot.s +++ b/libsrc/c64/soft80_kplot.s @@ -1,4 +1,10 @@ +; +; Groepaz/Hitmen, 12.10.2015 +; +; lowlevel kplot function for the soft80 implementation +; + .export soft80_kplot .include "c64.inc" @@ -35,6 +41,9 @@ soft80_kplot: ldy CURS_X rts + ; FIXME: the following tables take up 260 bytes, perhaps move them + ; to 0xdc00... area in ram under i/o + .rodata _bitmapxlo: .repeat 80,col diff --git a/libsrc/c64/soft80_scrsize.s b/libsrc/c64/soft80_scrsize.s index 1873f7327..b0f4f71e7 100644 --- a/libsrc/c64/soft80_scrsize.s +++ b/libsrc/c64/soft80_scrsize.s @@ -1,3 +1,8 @@ +; +; Groepaz/Hitmen, 12.10.2015 +; +; lowlevel screensize function for the soft80 implementation +; .export soft80_screensize From 7f2df8e8e684fc7cfd481327e69939dc39b25b59 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 15:04:55 +0200 Subject: [PATCH 24/54] move internal text/bgcolor variables into the file that also contains the init code for them. also rename them to avoid namespace pollution --- libsrc/c64/soft80_color.s | 24 +++++++++--------------- libsrc/c64/soft80_conio.s | 19 +++++++++++++++---- libsrc/c64/soft80_cputc.s | 25 +++++++++++++++---------- libsrc/c64/soft80_kclrscr.s | 6 +++--- 4 files changed, 42 insertions(+), 32 deletions(-) diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index 925b161ed..51a19f26e 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -7,7 +7,7 @@ ; .export soft80_textcolor, soft80_bgcolor, soft80_bordercolor - .export __textcolor, __bgcolor + .import soft80_internal_textcolor, soft80_internal_bgcolor .importzp tmp1, tmp2 @@ -15,8 +15,8 @@ .include "soft80.inc" soft80_textcolor: - ldx __textcolor ; get old value - sta __textcolor ; set new value + ldx soft80_internal_textcolor ; get old value + sta soft80_internal_textcolor ; set new value jsr mkcharcolor @@ -24,9 +24,9 @@ soft80_textcolor: rts soft80_bgcolor: - ldx __bgcolor ; get old value + ldx soft80_internal_bgcolor ; get old value stx tmp2 ; save old value - sta __bgcolor ; set new value + sta soft80_internal_bgcolor ; set new value jsr mkcharcolor @@ -43,7 +43,7 @@ lp1: and #$0f cmp tmp2 ; old bg color bne @sk1 - lda __bgcolor ; new bg color + lda soft80_internal_bgcolor ; new bg color sta soft80_colram+(page*250),x @sk1: .endscope @@ -69,7 +69,7 @@ lp2: and #$0f cmp tmp2 ; old bg color bne @sk2 - lda __bgcolor ; new bg color + lda soft80_internal_bgcolor ; new bg color @sk2: ora tmp1 ; new bg color (high nibble) sta soft80_vram+(page*250),x @@ -86,13 +86,13 @@ lp2: rts mkcharcolor: - lda __bgcolor + lda soft80_internal_bgcolor asl a asl a asl a asl a sta tmp1 ; remember new bg color (high nibble) - ora __textcolor + ora soft80_internal_textcolor sta CHARCOLOR ; text/bg combo for new chars rts @@ -102,12 +102,6 @@ soft80_bordercolor: txa rts - .bss -__textcolor: - .res 1 -__bgcolor: - .res 1 - ;------------------------------------------------------------------------------- ; force the init constructor to be imported diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 6691158d7..d63f01045 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -8,7 +8,7 @@ .destructor soft80_shutdown .import soft80_kclrscr, soft80_charset - .import __textcolor, __bgcolor + .export soft80_internal_textcolor, soft80_internal_bgcolor .importzp ptr1, ptr2, ptr3 @@ -71,16 +71,16 @@ soft80_init: lda 646 ; use current textcolor and #$0f - sta __textcolor + sta soft80_internal_textcolor lda VIC_BG_COLOR0 ; use current bgcolor and #$0f - sta __bgcolor + sta soft80_internal_bgcolor asl a asl a asl a asl a - ora __textcolor + ora soft80_internal_textcolor sta CHARCOLOR jmp soft80_kclrscr @@ -94,3 +94,14 @@ soft80_shutdown: sta VIC_VIDEO_ADR rts +;------------------------------------------------------------------------------- +; FIXME: when the code is fixed to use the "init" segment, these variables must +; be moved into a section other than .bss so they survive after the init +; code has been run. + + .bss +soft80_internal_textcolor: + .res 1 +soft80_internal_bgcolor: + .res 1 + diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index a7662f1ad..466b25057 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -12,7 +12,7 @@ .import popa, _gotoxy .import xsize .import soft80_kplot - .import __bgcolor, __textcolor + .import soft80_internal_bgcolor, soft80_internal_textcolor .importzp tmp4,tmp3 @@ -70,6 +70,9 @@ L1: cmp #$0D ; LF? and #$7F L10: + ; entry point for direct output of a character. the value passed in + ; akku must match the offset in the charset. + ; - the following may not modify tmp1 soft80_cputdirect: jsr soft80_putchar ; Write the character to the screen @@ -103,6 +106,7 @@ L3: sty CURS_X jmp soft80_plot + ; - the following may not modify tmp1 soft80_newline: lda SCREEN_PTR @@ -204,8 +208,9 @@ _spaceinvers: jmp _back .endif -; output a character - + ; entry point for outputting one character in internal encoding + ; without advancing cursor position + ; - the following may not modify tmp1 soft80_putchar: sta tmp3 ; remember charcode @@ -340,7 +345,7 @@ remcolor: ; immediately. lda (CRAM_PTR),y ; vram (textcolor) and #$0f - cmp __bgcolor + cmp soft80_internal_bgcolor beq @sk1 ; yes, vram==bgcolor ; now check if the textcolor in color ram is equal the background color, @@ -349,7 +354,7 @@ remcolor: lda (CRAM_PTR),y ; colram (2nd textcolor) stx $01 ; $34 and #$0f - cmp __bgcolor + cmp soft80_internal_bgcolor beq @sk2 ; yes, colram==bgcolor ; two characters in the current cell, of which one will get removed @@ -372,7 +377,7 @@ remcolor: sta (CRAM_PTR),y ; vram @sk3: ; colram = bgcolor - lda __bgcolor + lda soft80_internal_bgcolor inc $01 ; $35 sta (CRAM_PTR),y ; colram stx $01 ; $34 @@ -389,7 +394,7 @@ remcolor: ; vram (textcolor) = bgcolor lda (CRAM_PTR),y ; vram and #$f0 - ora __bgcolor + ora soft80_internal_bgcolor sta (CRAM_PTR),y ; vram @sk1: rts @@ -417,7 +422,7 @@ soft80_putcolor: lda (CRAM_PTR),y ; vram and #$0f - cmp __bgcolor + cmp soft80_internal_bgcolor beq @sk1 ; vram==bgcolor => first char in cell ; vram!=bgcolor => second char in cell @@ -426,7 +431,7 @@ soft80_putcolor: lda (CRAM_PTR),y ; colram stx $01 ; $34 and #$0f - cmp __bgcolor + cmp soft80_internal_bgcolor beq @l2s ; colram==bgcolor -> second char in cell ; botch characters in the cell are used @@ -450,7 +455,7 @@ soft80_putcolor: beq @sk3 ; jump if even xpos @sk2: ; colram = textcol - lda __textcolor + lda soft80_internal_textcolor inc $01 ; $35 sta (CRAM_PTR),y ; colram stx $01 ; $34 diff --git a/libsrc/c64/soft80_kclrscr.s b/libsrc/c64/soft80_kclrscr.s index 95633de79..0b438be6b 100644 --- a/libsrc/c64/soft80_kclrscr.s +++ b/libsrc/c64/soft80_kclrscr.s @@ -6,7 +6,7 @@ .export soft80_kclrscr .import soft80_kplot - .import __bgcolor + .import soft80_internal_bgcolor .importzp ptr1 .include "c64.inc" @@ -39,7 +39,7 @@ soft80_kclrscr: bne @lp3 .if SOFT80COLORVOODOO = 1 - lda __bgcolor + lda soft80_internal_bgcolor jsr clear ; clear color ram .endif @@ -50,7 +50,7 @@ soft80_kclrscr: lda CHARCOLOR and #$f0 - ora __bgcolor + ora soft80_internal_bgcolor jsr clear ; clear vram sty $01 From 2a0f6c420b37c0ae6d14f8a6b91e95fc67682b74 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 15:18:36 +0200 Subject: [PATCH 25/54] moved bordercolor function into a seperate file --- libsrc/c64/extra/soft80.s | 4 +++- libsrc/c64/soft80_bordercolor.s | 17 +++++++++++++++++ libsrc/c64/soft80_color.s | 9 +-------- 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 libsrc/c64/soft80_bordercolor.s diff --git a/libsrc/c64/extra/soft80.s b/libsrc/c64/extra/soft80.s index d43443fc8..162abb132 100644 --- a/libsrc/c64/extra/soft80.s +++ b/libsrc/c64/extra/soft80.s @@ -17,9 +17,11 @@ ; soft80_color.s .import soft80_textcolor .import soft80_bgcolor - .import soft80_bordercolor .export _textcolor := soft80_textcolor .export _bgcolor := soft80_bgcolor + + ; soft80_bordercolor.s + .import soft80_bordercolor .export _bordercolor := soft80_bordercolor ; soft80_cputc.s diff --git a/libsrc/c64/soft80_bordercolor.s b/libsrc/c64/soft80_bordercolor.s new file mode 100644 index 000000000..057cc410a --- /dev/null +++ b/libsrc/c64/soft80_bordercolor.s @@ -0,0 +1,17 @@ +; +; Groepaz/Hitmen, 12.10.2015 +; +; unsigned char __fastcall__ bordercolor (unsigned char color); +; + + .export soft80_bordercolor + + .include "c64.inc" + + ; FIXME: if we'd move this function into a seperate file in the regular + ; conio lib, then we dont need this override at all. +soft80_bordercolor: + ldx VIC_BORDERCOLOR ; get old value + sta VIC_BORDERCOLOR ; set new value + txa + rts diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index 51a19f26e..2d856508c 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -3,10 +3,9 @@ ; ; 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 soft80_textcolor, soft80_bgcolor .import soft80_internal_textcolor, soft80_internal_bgcolor .importzp tmp1, tmp2 @@ -96,12 +95,6 @@ mkcharcolor: sta CHARCOLOR ; text/bg combo for new chars rts -soft80_bordercolor: - ldx VIC_BORDERCOLOR ; get old value - sta VIC_BORDERCOLOR ; set new value - txa - rts - ;------------------------------------------------------------------------------- ; force the init constructor to be imported From 21732e3c5bf540126278848fa1f4d4a60f32013b Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 15:44:41 +0200 Subject: [PATCH 26/54] maintain lsb of cursor x position internally, saves some bytes and some cycles too :) --- libsrc/c64/soft80_cgetc.s | 8 ++++--- libsrc/c64/soft80_conio.s | 3 +++ libsrc/c64/soft80_cputc.s | 42 +++++++++++++++++++++++-------------- libsrc/c64/soft80_kplot.s | 5 +++++ libsrc/c64/soft80_scrsize.s | 6 ------ 5 files changed, 39 insertions(+), 25 deletions(-) diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index 7d8a1d88f..7bb67f0ae 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -5,6 +5,7 @@ ; .export soft80_cgetc + .import soft80_internal_cursorxlsb .import cursor .importzp tmp1 @@ -45,9 +46,10 @@ invertcursor: ldy #$00 jsr setcolor - lda CURS_X - and #$01 - tax + ;lda CURS_X + ;and #$01 + ;tax + ldx soft80_internal_cursorxlsb @lp1: lda (SCREEN_PTR),y eor nibble,x diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index d63f01045..344831447 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -9,6 +9,7 @@ .import soft80_kclrscr, soft80_charset .export soft80_internal_textcolor, soft80_internal_bgcolor + .export soft80_internal_cursorxlsb .importzp ptr1, ptr2, ptr3 @@ -104,4 +105,6 @@ soft80_internal_textcolor: .res 1 soft80_internal_bgcolor: .res 1 +soft80_internal_cursorxlsb: + .res 1 diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 466b25057..4f2eb7ada 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -13,6 +13,7 @@ .import xsize .import soft80_kplot .import soft80_internal_bgcolor, soft80_internal_textcolor + .import soft80_internal_cursorxlsb .importzp tmp4,tmp3 @@ -86,6 +87,7 @@ advance: sty CURS_X tya and #$01 + sta soft80_internal_cursorxlsb bne @L5 lda SCREEN_PTR @@ -146,8 +148,9 @@ _space: .endif ;ldy #$00 ; is still $00 - lda CURS_X - and #$01 + ;lda CURS_X + ;and #$01 + lda soft80_internal_cursorxlsb bne @l1 .repeat 8,line @@ -182,8 +185,9 @@ _spaceinvers: sta (CRAM_PTR),y ; vram .endif - lda CURS_X - and #$01 + ;lda CURS_X + ;and #$01 + lda soft80_internal_cursorxlsb bne @l1 .repeat 8,line @@ -240,8 +244,9 @@ soft80_putchar: lda RVS jne _invers - lda CURS_X - and #$01 + ;lda CURS_X + ;and #$01 + lda soft80_internal_cursorxlsb bne @l1 .repeat 8,line @@ -279,8 +284,9 @@ _back: ; output inverted character _invers: - lda CURS_X - and #$01 + ;lda CURS_X + ;and #$01 + lda soft80_internal_cursorxlsb bne @l1 .repeat 8,line @@ -366,8 +372,9 @@ remcolor: ;and #$0f sta tmp3 ; A contains colram - lda CURS_X - and #$01 + ;lda CURS_X + ;and #$01 + lda soft80_internal_cursorxlsb bne @sk3 ; vram = colram @@ -436,8 +443,9 @@ soft80_putcolor: ; botch characters in the cell are used - lda CURS_X - and #$01 + ;lda CURS_X + ;and #$01 + lda soft80_internal_cursorxlsb bne @sk2 ; jump if odd xpos ; vram = textcol @@ -450,8 +458,9 @@ soft80_putcolor: jsr soft80_checkchar bcs @sk1 ; char at current position => overwrite 1st - lda CURS_X - and #$01 + ;lda CURS_X + ;and #$01 + lda soft80_internal_cursorxlsb beq @sk3 ; jump if even xpos @sk2: ; colram = textcol @@ -481,8 +490,9 @@ soft80_checkchar: ;ldy #$00 ; is still $00 - lda CURS_X - and #$01 + ;lda CURS_X + ;and #$01 + lda soft80_internal_cursorxlsb jne @l1a .repeat 8,line diff --git a/libsrc/c64/soft80_kplot.s b/libsrc/c64/soft80_kplot.s index e359e9f58..8d8c77c5c 100644 --- a/libsrc/c64/soft80_kplot.s +++ b/libsrc/c64/soft80_kplot.s @@ -6,6 +6,7 @@ ; .export soft80_kplot + .import soft80_internal_cursorxlsb .include "c64.inc" .include "soft80.inc" @@ -25,6 +26,10 @@ soft80_kplot: adc _bitmapxhi,y sta SCREEN_PTR+1 + tya + and #1 + sta soft80_internal_cursorxlsb + ; calc pointer to vram tya lsr a ; NOTE: we can save 2 cycles here at the expense of diff --git a/libsrc/c64/soft80_scrsize.s b/libsrc/c64/soft80_scrsize.s index b0f4f71e7..9f1701a9a 100644 --- a/libsrc/c64/soft80_scrsize.s +++ b/libsrc/c64/soft80_scrsize.s @@ -12,9 +12,3 @@ soft80_screensize: ldy #screenrows ldx #charsperline rts - -;------------------------------------------------------------------------------- -; force the init constructor to be imported - - .import soft80_init -conio_init = soft80_init From a2b514a7cff1512ecce4dd4074440324044b3c0d Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 15:54:08 +0200 Subject: [PATCH 27/54] fix some style issues --- libsrc/c64/soft80_color.s | 32 ++++++++++++++++---------------- libsrc/c64/soft80_conio.s | 4 ++-- libsrc/c64/soft80_kclrscr.s | 6 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index 2d856508c..fe2be71d5 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -14,18 +14,18 @@ .include "soft80.inc" soft80_textcolor: - ldx soft80_internal_textcolor ; get old value - sta soft80_internal_textcolor ; set new value + ldx soft80_internal_textcolor ; get old value + sta soft80_internal_textcolor ; set new value jsr mkcharcolor - txa ; get old value + txa ; get old value rts soft80_bgcolor: - ldx soft80_internal_bgcolor ; get old value - stx tmp2 ; save old value - sta soft80_internal_bgcolor ; set new value + ldx soft80_internal_bgcolor ; get old value + stx tmp2 ; save old value + sta soft80_internal_bgcolor ; set new value jsr mkcharcolor @@ -40,9 +40,9 @@ lp1: .scope lda soft80_colram+(page*250),x and #$0f - cmp tmp2 ; old bg color + cmp tmp2 ; old bg color bne @sk1 - lda soft80_internal_bgcolor ; new bg color + lda soft80_internal_bgcolor ; new bg color sta soft80_colram+(page*250),x @sk1: .endscope @@ -54,7 +54,7 @@ lp1: sei ldy $01 - lda #$34 ; disable I/O + lda #$34 ; disable I/O sta $01 ; if the old bg color is equal to text color in this cell, then also @@ -66,11 +66,11 @@ lp2: .scope lda soft80_vram+(page*250),x and #$0f - cmp tmp2 ; old bg color + cmp tmp2 ; old bg color bne @sk2 - lda soft80_internal_bgcolor ; new bg color + lda soft80_internal_bgcolor ; new bg color @sk2: - ora tmp1 ; new bg color (high nibble) + ora tmp1 ; new bg color (high nibble) sta soft80_vram+(page*250),x .endscope .endrepeat @@ -78,10 +78,10 @@ lp2: inx bne lp2 - sty $01 ; enable I/O + sty $01 ; enable I/O cli - lda tmp2 ; get old value + lda tmp2 ; get old value rts mkcharcolor: @@ -90,9 +90,9 @@ mkcharcolor: asl a asl a asl a - sta tmp1 ; remember new bg color (high nibble) + sta tmp1 ; remember new bg color (high nibble) ora soft80_internal_textcolor - sta CHARCOLOR ; text/bg combo for new chars + sta CHARCOLOR ; text/bg combo for new chars rts ;------------------------------------------------------------------------------- diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 344831447..bc4d5c0ab 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -70,11 +70,11 @@ soft80_init: sta $01 cli - lda 646 ; use current textcolor + lda 646 ; use current textcolor and #$0f sta soft80_internal_textcolor - lda VIC_BG_COLOR0 ; use current bgcolor + lda VIC_BG_COLOR0 ; use current bgcolor and #$0f sta soft80_internal_bgcolor asl a diff --git a/libsrc/c64/soft80_kclrscr.s b/libsrc/c64/soft80_kclrscr.s index 0b438be6b..811ea665f 100644 --- a/libsrc/c64/soft80_kclrscr.s +++ b/libsrc/c64/soft80_kclrscr.s @@ -40,18 +40,18 @@ soft80_kclrscr: .if SOFT80COLORVOODOO = 1 lda soft80_internal_bgcolor - jsr clear ; clear color ram + jsr clear ; clear color ram .endif sei ldy $01 - lda #$34 ; enable RAM under I/O + lda #$34 ; enable RAM under I/O sta $01 lda CHARCOLOR and #$f0 ora soft80_internal_bgcolor - jsr clear ; clear vram + jsr clear ; clear vram sty $01 cli From bc85d90468f6375d8ee426c9645940f07f8da241 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 16:15:40 +0200 Subject: [PATCH 28/54] check for space bottom up, which is faster for the average case --- libsrc/c64/soft80_cputc.s | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 4f2eb7ada..9f27f64d7 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -482,30 +482,39 @@ soft80_putcolor: sta (CRAM_PTR),y ; vram rts +; ; test if there is a space or a character at current position -; in: y must be $00 +; +; in: x = $34 +; y must be $00 ; out: CLC: space SEC: character +; x = $34 ; y = $00 soft80_checkchar: - ;ldy #$00 ; is still $00 + ;ldy #$00 ; is still $00 ;lda CURS_X ;and #$01 lda soft80_internal_cursorxlsb - jne @l1a + bne @l1a + ; check charset data from bottom up, since a lot of eg lowercase chars + ; have no data in the top rows, but all of the DO have data in the + ; second to bottom row, this will likely be faster in average. + + ldy #7 .repeat 8,line lda (SCREEN_PTR),y and #$f0 cmp #$f0 bne @l2b .if (line < 7) - iny + dey .endif .endrepeat - ldy #$00 + ;ldy #$00 ; is 0 clc rts @l2b: @@ -513,16 +522,17 @@ soft80_checkchar: sec rts @l1a: + ldy #$07 .repeat 8,line lda (SCREEN_PTR),y and #$0f cmp #$0f bne @l2bb .if line < 7 - iny + dey .endif .endrepeat - ldy #$00 + ;ldy #$00 ; is 0 clc rts @l2bb: From cf8b21b27ef84f35a14407f724df66a6c23f2406 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 17:12:44 +0200 Subject: [PATCH 29/54] size optimization --- libsrc/c64/soft80_cgetc.s | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index 7bb67f0ae..e578111ea 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -16,13 +16,13 @@ soft80_cgetc: lda KEY_COUNT ; Get number of characters bne L3 ; Jump if there are already chars waiting - ldx #1 + sec jsr invertcursor ; set cursor on or off accordingly L1: lda KEY_COUNT ; wait for key beq L1 - ldx #0 + clc jsr invertcursor ; set cursor on or off accordingly L3: jsr KBDREAD ; Read char and return in A @@ -59,7 +59,7 @@ invertcursor: bne @lp1 pla - sta $01 + sta $01 ; enable I/O cli rts @@ -68,8 +68,7 @@ invertcursor: ; in soft80_cputc setcolor: ;ldy #0 ; is 0 - txa - bne @set + bcs @set ; restore old value lda tmp1 sta (CRAM_PTR),y ; vram From ead9950044034660f20e1fea8c7efd0558c2a750 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 18:01:48 +0200 Subject: [PATCH 30/54] some code shuffling to get rid of long branches --- libsrc/c64/soft80_conio.s | 4 + libsrc/c64/soft80_cputc.s | 188 ++++++++++++++++++++------------------ 2 files changed, 102 insertions(+), 90 deletions(-) diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index bc4d5c0ab..388f53023 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -70,6 +70,10 @@ soft80_init: sta $01 cli + ; the "color voodoo" in other parts of the code relies on the vram and + ; colorram being set up as expected, which is why we cant use the + ; _bgcolor and _textcolor functions here. + lda 646 ; use current textcolor and #$0f sta soft80_internal_textcolor diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 9f27f64d7..fa6a2574f 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -10,22 +10,16 @@ .export soft80_newline, soft80_plot .import popa, _gotoxy - .import xsize + .import soft80_kplot .import soft80_internal_bgcolor, soft80_internal_textcolor .import soft80_internal_cursorxlsb .importzp tmp4,tmp3 - .macpack longbranch - .include "c64.inc" .include "soft80.inc" -.if SOFT80COLORVOODOO = 1 - .export soft80_putcolor -.endif - soft80_cputcxy: pha ; Save C jsr popa ; Get Y @@ -51,10 +45,18 @@ soft80_plot: L1: cmp #$0D ; LF? beq soft80_newline ; Recalculate pointers - ; Printable char of some sort + ; shortcut for codes < $80 ... codes $20-$7f can be printed directly, + ; codes $00-$1f are control codes which are not printable and thus may + ; give undefined result. tay bpl L10 + ; codes $80-$ff must get converted like this: + ; $80-$9f -> dont care (control codes) + ; $a0-$bf -> $00-$1f + ; $c0-$df -> $60-$7f + ; $e0-$ff -> $00-$1f + ; extra check for petscii codes 160-191, these have been moved to ; 0-31 in the charset and #%11100000 @@ -77,9 +79,7 @@ L10: soft80_cputdirect: jsr soft80_putchar ; Write the character to the screen -; Advance cursor position - -advance: + ; Advance cursor position iny ; contains CURS_X cpy #charsperline beq L3 @@ -130,53 +130,29 @@ 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 +;------------------------------------------------------------------------------- +; All following code belongs to the character output to bitmap +; +; this stuff is going to be used a lot so we unroll it a bit for speed +;------------------------------------------------------------------------------- .if SOFT80FASTSPACE = 1 -; output space -; in: y must be $00 -_space: - - lda RVS - jne _spaceinvers - -.if SOFT80COLORVOODOO = 1 - jsr remcolor -.endif - ;ldy #$00 ; is still $00 - - ;lda CURS_X - ;and #$01 - lda soft80_internal_cursorxlsb - bne @l1 +; output inverted space (odd) +draw_spaceinvers_odd: .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 + and #$f0 sta (SCREEN_PTR),y .if line < 7 iny .endif .endrepeat -@l2: - jmp _back + jmp draw_back -; output inverted space +; output inverted space (general entry point) ; in: y must be $00 -_spaceinvers: +draw_spaceinvers: .if SOFT80COLORVOODOO = 1 jsr soft80_putcolor @@ -188,8 +164,9 @@ _spaceinvers: ;lda CURS_X ;and #$01 lda soft80_internal_cursorxlsb - bne @l1 + bne draw_spaceinvers_odd +; output inverted space (even) .repeat 8,line lda (SCREEN_PTR),y and #$0f @@ -198,23 +175,57 @@ _spaceinvers: iny .endif .endrepeat - jmp _back -@l1: + jmp draw_back + +; output space (odd) +draw_space_odd: .repeat 8,line lda (SCREEN_PTR),y - and #$f0 + ora #$0f sta (SCREEN_PTR),y .if line < 7 iny .endif .endrepeat + jmp draw_back - jmp _back +; output space (general entry point) +; in: y must be $00 +draw_space: + + lda RVS + bne draw_spaceinvers + +.if SOFT80COLORVOODOO = 1 + jsr remcolor +.endif + ;ldy #$00 ; is still $00 + + ;lda CURS_X + ;and #$01 + lda soft80_internal_cursorxlsb + bne draw_space_odd + +; output space (even) + .repeat 8,line + lda (SCREEN_PTR),y + ora #$f0 + sta (SCREEN_PTR),y + .if (line < 7) + iny + .endif + .endrepeat + jmp draw_back .endif - ; entry point for outputting one character in internal encoding - ; without advancing cursor position - ; - the following may not modify tmp1 +;------------------------------------------------------------------------------- +; output one character in internal encoding without advancing cursor position +; generic entry point +; +; - the following may not modify tmp1 +; in: A: charcode +; out: Y: CURS_X +; soft80_putchar: sta tmp3 ; remember charcode @@ -228,7 +239,7 @@ soft80_putchar: .if SOFT80FASTSPACE = 1 cmp #' ' ; space is a special (optimized) case - jeq _space + beq draw_space .endif .if SOFT80COLORVOODOO = 1 @@ -237,18 +248,18 @@ soft80_putchar: lda CHARCOLOR sta (CRAM_PTR),y ; vram .endif - ; output character +; output character ldx tmp3 ; get charcode lda RVS - jne _invers - - ;lda CURS_X - ;and #$01 + beq @skp + jmp draw_charinvers +@skp: lda soft80_internal_cursorxlsb - bne @l1 + bne draw_char_even +; output character (odd) .repeat 8,line lda (SCREEN_PTR),y and #$0f @@ -258,9 +269,10 @@ soft80_putchar: iny .endif .endrepeat - jmp @l2 -@l1: + jmp draw_back +; output character (even) +draw_char_even: .repeat 8,line lda (SCREEN_PTR),y and #$f0 @@ -271,9 +283,7 @@ soft80_putchar: .endif .endrepeat -@l2: - -_back: +draw_back: lda tmp4 sta $01 cli @@ -281,13 +291,23 @@ _back: ldy CURS_X rts -; output inverted character -_invers: +; output inverted character (odd) +draw_charinvers_odd: + .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 draw_back - ;lda CURS_X - ;and #$01 +; output inverted character (generic) +draw_charinvers: lda soft80_internal_cursorxlsb - bne @l1 + bne draw_charinvers_odd .repeat 8,line lda (SCREEN_PTR),y @@ -298,18 +318,7 @@ _invers: 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 + jmp draw_back ;------------------------------------------------------------------------------- ; optional "color voodoo". the problem is that each 8x8 cell can only contain @@ -500,7 +509,7 @@ soft80_checkchar: bne @l1a ; check charset data from bottom up, since a lot of eg lowercase chars - ; have no data in the top rows, but all of the DO have data in the + ; have no data in the top rows, but all of them DO have data in the ; second to bottom row, this will likely be faster in average. ldy #7 @@ -513,7 +522,6 @@ soft80_checkchar: dey .endif .endrepeat - ;ldy #$00 ; is 0 clc rts @@ -527,7 +535,7 @@ soft80_checkchar: lda (SCREEN_PTR),y and #$0f cmp #$0f - bne @l2bb + bne @l2b .if line < 7 dey .endif @@ -535,9 +543,9 @@ soft80_checkchar: ;ldy #$00 ; is 0 clc rts -@l2bb: - ldy #$00 - sec - rts +;@l2bb: +; ldy #$00 +; sec +; rts .endif From aed0549760322d20afb27d99b50659e972498d2c Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 18:09:50 +0200 Subject: [PATCH 31/54] remove some commented out code --- libsrc/c64/soft80_cgetc.s | 4 +--- libsrc/c64/soft80_color.s | 3 ++- libsrc/c64/soft80_cputc.s | 23 +++-------------------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index e578111ea..849af753a 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -46,9 +46,6 @@ invertcursor: ldy #$00 jsr setcolor - ;lda CURS_X - ;and #$01 - ;tax ldx soft80_internal_cursorxlsb @lp1: lda (SCREEN_PTR),y @@ -74,6 +71,7 @@ setcolor: sta (CRAM_PTR),y ; vram rts @set: + ; save old value lda (CRAM_PTR),y ; vram sta tmp1 lda CHARCOLOR diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index fe2be71d5..ab4b4a01f 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -24,11 +24,12 @@ soft80_textcolor: soft80_bgcolor: ldx soft80_internal_bgcolor ; get old value - stx tmp2 ; save old value sta soft80_internal_bgcolor ; set new value jsr mkcharcolor + stx tmp2 ; save old value + .if SOFT80COLORVOODOO = 1 ; if the old bg color is equal to color ram of that cell, then also ; update the color ram to the new value. diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index fa6a2574f..0d450d27b 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -161,8 +161,6 @@ draw_spaceinvers: sta (CRAM_PTR),y ; vram .endif - ;lda CURS_X - ;and #$01 lda soft80_internal_cursorxlsb bne draw_spaceinvers_odd @@ -201,8 +199,6 @@ draw_space: .endif ;ldy #$00 ; is still $00 - ;lda CURS_X - ;and #$01 lda soft80_internal_cursorxlsb bne draw_space_odd @@ -381,8 +377,6 @@ remcolor: ;and #$0f sta tmp3 ; A contains colram - ;lda CURS_X - ;and #$01 lda soft80_internal_cursorxlsb bne @sk3 @@ -452,8 +446,6 @@ soft80_putcolor: ; botch characters in the cell are used - ;lda CURS_X - ;and #$01 lda soft80_internal_cursorxlsb bne @sk2 ; jump if odd xpos @@ -467,8 +459,6 @@ soft80_putcolor: jsr soft80_checkchar bcs @sk1 ; char at current position => overwrite 1st - ;lda CURS_X - ;and #$01 lda soft80_internal_cursorxlsb beq @sk3 ; jump if even xpos @sk2: @@ -503,8 +493,6 @@ soft80_checkchar: ;ldy #$00 ; is still $00 - ;lda CURS_X - ;and #$01 lda soft80_internal_cursorxlsb bne @l1a @@ -517,7 +505,7 @@ soft80_checkchar: lda (SCREEN_PTR),y and #$f0 cmp #$f0 - bne @l2b + bne @ischar .if (line < 7) dey .endif @@ -525,7 +513,7 @@ soft80_checkchar: ;ldy #$00 ; is 0 clc rts -@l2b: +@ischar: ldy #$00 sec rts @@ -535,7 +523,7 @@ soft80_checkchar: lda (SCREEN_PTR),y and #$0f cmp #$0f - bne @l2b + bne @ischar .if line < 7 dey .endif @@ -543,9 +531,4 @@ soft80_checkchar: ;ldy #$00 ; is 0 clc rts -;@l2bb: -; ldy #$00 -; sec -; rts - .endif From 4557e8d004844dd8c24ec3587d1f9c54851d6ba7 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 18:53:55 +0200 Subject: [PATCH 32/54] optimize charcode conversion, shorter and faster now :) --- libsrc/c64/soft80_cputc.s | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 0d450d27b..e336e1c7c 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -49,7 +49,7 @@ L1: cmp #$0D ; LF? ; codes $00-$1f are control codes which are not printable and thus may ; give undefined result. tay - bpl L10 + bpl @L10 ; codes $80-$ff must get converted like this: ; $80-$9f -> dont care (control codes) @@ -57,21 +57,11 @@ L1: cmp #$0D ; LF? ; $c0-$df -> $60-$7f ; $e0-$ff -> $00-$1f - ; extra check for petscii codes 160-191, these have been moved to - ; 0-31 in the charset - and #%11100000 - cmp #%10100000 - bne @sk - - tya - and #%00011111 - bpl L10 ; branch always -@sk: - tya + ora #%01000000 ; $40 clc - adc #$20 - and #$7F -L10: + adc #%00100000 ; $20 + and #%01111111 ; $7f +@L10: ; entry point for direct output of a character. the value passed in ; akku must match the offset in the charset. From bf3ea5328f13ced74f497efdf680dec0eb9d7781 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 19:03:50 +0200 Subject: [PATCH 33/54] inverted result for checkchar, saving some bytes and cycles --- libsrc/c64/soft80_cputc.s | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index e336e1c7c..c7ba6e096 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -389,7 +389,7 @@ remcolor: ; => only one char in cell used jsr soft80_checkchar - bcc @sk1 ; space at current position + bcs @sk1 ; space at current position ; vram (textcolor) = bgcolor lda (CRAM_PTR),y ; vram @@ -447,7 +447,7 @@ soft80_putcolor: @l2s: ; one character in cell is already used jsr soft80_checkchar - bcs @sk1 ; char at current position => overwrite 1st + bcc @sk1 ; char at current position => overwrite 1st lda soft80_internal_cursorxlsb beq @sk3 ; jump if even xpos @@ -476,7 +476,8 @@ soft80_putcolor: ; ; in: x = $34 ; y must be $00 -; out: CLC: space SEC: character +; out: SEC: space +; CLC: character ; x = $34 ; y = $00 soft80_checkchar: @@ -501,11 +502,11 @@ soft80_checkchar: .endif .endrepeat ;ldy #$00 ; is 0 - clc + ;sec ; is set rts @ischar: ldy #$00 - sec + ;clc ; is cleared rts @l1a: ldy #$07 @@ -519,6 +520,6 @@ soft80_checkchar: .endif .endrepeat ;ldy #$00 ; is 0 - clc + ;sec ; is set rts .endif From e9f0b7943eed63fc533c24976abd7e9ecc66be44 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 19:57:33 +0200 Subject: [PATCH 34/54] some renaming, preparing plot table names --- libsrc/c64/soft80_cputc.s | 21 ++++++++------------- libsrc/c64/soft80_kplot.s | 29 ++++++++++++++--------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index c7ba6e096..0e8cb0bd8 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -72,7 +72,7 @@ soft80_cputdirect: ; Advance cursor position iny ; contains CURS_X cpy #charsperline - beq L3 + beq @L3 sty CURS_X tya @@ -92,7 +92,7 @@ soft80_cputdirect: inc CRAM_PTR+1 @L5: rts -L3: +@L3: inc CURS_Y ; new line ldy #0 ; + cr sty CURS_X @@ -114,9 +114,9 @@ soft80_newline: clc adc #40 sta CRAM_PTR - bcc L5 + bcc @L5 inc CRAM_PTR+1 -L5: +@L5: inc CURS_Y rts @@ -336,7 +336,8 @@ draw_charinvers: ; ; in: x must be $34 ; y must be $00 -; out: y = $00 +; out: x = $34 +; y = $00 remcolor: ;ldy #$00 ; is still $00 @@ -357,23 +358,17 @@ remcolor: and #$0f cmp soft80_internal_bgcolor beq @sk2 ; yes, colram==bgcolor + sta tmp3 ; A contains colram ; two characters in the current cell, of which one will get removed - ; vram = colram - ;inc $01 - ;lda (CRAM_PTR),y ; colram - ;stx $01 ;$34 - ;and #$0f - sta tmp3 ; A contains colram - lda soft80_internal_cursorxlsb bne @sk3 ; vram = colram lda (CRAM_PTR),y ; vram and #$f0 - ora tmp3 + ora tmp3 ; colram value sta (CRAM_PTR),y ; vram @sk3: ; colram = bgcolor diff --git a/libsrc/c64/soft80_kplot.s b/libsrc/c64/soft80_kplot.s index 8d8c77c5c..79a14cbcb 100644 --- a/libsrc/c64/soft80_kplot.s +++ b/libsrc/c64/soft80_kplot.s @@ -18,12 +18,12 @@ soft80_kplot: sty CURS_X ; calc pointer to bitmap - lda _bitmaplo,x + lda soft80_bitmapylo,x clc - adc _bitmapxlo,y + adc soft80_bitmapxlo,y sta SCREEN_PTR - lda _bitmaphi,x - adc _bitmapxhi,y + lda soft80_bitmapyhi,x + adc soft80_bitmapxhi,y sta SCREEN_PTR+1 tya @@ -32,13 +32,13 @@ soft80_kplot: ; calc pointer to vram tya - lsr a ; NOTE: we can save 2 cycles here at the expense of - ; making the tables twice as big (+50 bytes) + lsr a + clc - adc _vramlo,x + adc soft80_vramlo,x sta CRAM_PTR lda #0 - adc _vramhi,x + adc soft80_vramhi,x sta CRAM_PTR+1 @getpos: @@ -50,28 +50,27 @@ soft80_kplot: ; to 0xdc00... area in ram under i/o .rodata -_bitmapxlo: +soft80_bitmapxlo: .repeat 80,col .byte <((col/2)*8) .endrepeat - -_bitmapxhi: +soft80_bitmapxhi: .repeat 80,col .byte >((col/2)*8) .endrepeat -_vramlo: +soft80_vramlo: .repeat 25,row .byte <(soft80_vram+(row*40)) .endrepeat -_vramhi: +soft80_vramhi: .repeat 25,row .byte >(soft80_vram+(row*40)) .endrepeat -_bitmaplo: +soft80_bitmapylo: .repeat 25,row .byte <(soft80_bitmap+(row*40*8)) .endrepeat -_bitmaphi: +soft80_bitmapyhi: .repeat 25,row .byte >(soft80_bitmap+(row*40*8)) .endrepeat From 57a43b673587fe25b9ca741e9247c5da8d7af8a1 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 20:38:06 +0200 Subject: [PATCH 35/54] style issues --- libsrc/c64/soft80_cgetc.s | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index 849af753a..ba16614af 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -14,18 +14,18 @@ soft80_cgetc: lda KEY_COUNT ; Get number of characters - bne L3 ; Jump if there are already chars waiting + bne @L3 ; Jump if there are already chars waiting sec jsr invertcursor ; set cursor on or off accordingly -L1: lda KEY_COUNT ; wait for key - beq L1 +@L1: lda KEY_COUNT ; wait for key + beq @L1 clc jsr invertcursor ; set cursor on or off accordingly -L3: jsr KBDREAD ; Read char and return in A +@L3: jsr KBDREAD ; Read char and return in A ldx #0 rts From 5840d1c08c6e1f1ba16c821c1ecb9ab93f24e176 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 20:46:53 +0200 Subject: [PATCH 36/54] increase conio constructor priority --- libsrc/c64/soft80_conio.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 388f53023..f6efe3382 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -4,7 +4,7 @@ ; Low level init code for soft80 screen output/console input ; - .constructor soft80_init + .constructor soft80_init, 8 .destructor soft80_shutdown .import soft80_kclrscr, soft80_charset From d6f48629ad22803dc260e9c659c81b357a82c70e Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 21:02:48 +0200 Subject: [PATCH 37/54] export mouse driver related symbols --- libsrc/c64/extra/soft80.s | 3 +++ libsrc/c64/soft80.inc | 1 + 2 files changed, 4 insertions(+) diff --git a/libsrc/c64/extra/soft80.s b/libsrc/c64/extra/soft80.s index 162abb132..5490a3790 100644 --- a/libsrc/c64/extra/soft80.s +++ b/libsrc/c64/extra/soft80.s @@ -3,6 +3,7 @@ ; ; import/overload stubs for the soft80 implementation + .include "../soft80.inc" ; soft80_cgetc.s .import soft80_cgetc @@ -57,3 +58,5 @@ .import soft80_screensize .export screensize := soft80_screensize + .export mcb_spritememory := soft80_spriteblock + .export mcb_spritepointer := (soft80_vram + $03F8) diff --git a/libsrc/c64/soft80.inc b/libsrc/c64/soft80.inc index a4bee337a..678000967 100644 --- a/libsrc/c64/soft80.inc +++ b/libsrc/c64/soft80.inc @@ -7,6 +7,7 @@ soft80_lo_charset = $d000 soft80_hi_charset = $d400 soft80_vram = $d800 ; ram under i/o soft80_colram = $d800 ; color ram (used for temp. storage) +soft80_spriteblock = $dc00 soft80_bitmap = $e000 charsperline = 80 From 362a1724776e569c1c8dbb96dd477cfb4182b334 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 21:23:27 +0200 Subject: [PATCH 38/54] remove chline/cvline dupes --- libsrc/c64/extra/soft80.s | 21 +++++++-------------- libsrc/c64/soft80_chline.s | 33 --------------------------------- libsrc/c64/soft80_cvline.s | 33 --------------------------------- 3 files changed, 7 insertions(+), 80 deletions(-) delete mode 100644 libsrc/c64/soft80_chline.s delete mode 100644 libsrc/c64/soft80_cvline.s diff --git a/libsrc/c64/extra/soft80.s b/libsrc/c64/extra/soft80.s index 5490a3790..9efb8d577 100644 --- a/libsrc/c64/extra/soft80.s +++ b/libsrc/c64/extra/soft80.s @@ -9,12 +9,6 @@ .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 @@ -39,12 +33,6 @@ .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 @@ -58,5 +46,10 @@ .import soft80_screensize .export screensize := soft80_screensize - .export mcb_spritememory := soft80_spriteblock - .export mcb_spritepointer := (soft80_vram + $03F8) + ; VIC sprite data for the mouse pointer + .export mcb_spritememory := soft80_spriteblock + .export mcb_spritepointer := (soft80_vram + $03F8) + + ; Chars used by chline () and cvline () + .exportzp chlinechar = CH_HLINE + .exportzp cvlinechar = CH_VLINE diff --git a/libsrc/c64/soft80_chline.s b/libsrc/c64/soft80_chline.s deleted file mode 100644 index 73c8c1e26..000000000 --- a/libsrc/c64/soft80_chline.s +++ /dev/null @@ -1,33 +0,0 @@ -; -; Groepaz/Hitmen, 12.10.2015 -; -; void chlinexy (unsigned char x, unsigned char y, unsigned char length); -; void chline (unsigned char length); -; - - .export soft80_chlinexy, soft80_chline - .import popa, _gotoxy, soft80_cputdirect - .importzp tmp1 - - .include "c64.inc" - .include "soft80.inc" - -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 #CH_HLINE ; Horizontal line, petscii code - jsr soft80_cputdirect ; Direct output - dec tmp1 - bne L1 -L9: rts - - - - diff --git a/libsrc/c64/soft80_cvline.s b/libsrc/c64/soft80_cvline.s deleted file mode 100644 index e2c6e947c..000000000 --- a/libsrc/c64/soft80_cvline.s +++ /dev/null @@ -1,33 +0,0 @@ -; -; Groepaz/Hitmen, 12.10.2015 -; -; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); -; void cvline (unsigned char length); -; - - .export soft80_cvline, soft80_cvlinexy - .import popa, _gotoxy, soft80_putchar, soft80_newline - .importzp tmp1 - - .include "c64.inc" - .include "soft80.inc" - -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 #CH_VLINE ; Vertical bar, petscii code - jsr soft80_putchar ; Write, no cursor advance - jsr soft80_newline ; Advance cursor to next line - dec tmp1 - bne L1 -L9: rts - - - From f462c173fbdafba1eb2b5070a77265002d397dcf Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 12 Oct 2015 23:39:47 +0200 Subject: [PATCH 39/54] move some stuff to init segment, saves roughly 1480 bytes :) --- libsrc/c64/soft80.inc | 12 +++- libsrc/c64/soft80_charset.s | 2 +- libsrc/c64/soft80_conio.s | 112 ++++++++++++++++++++++++++---------- libsrc/c64/soft80_kplot.s | 39 ++++--------- 4 files changed, 104 insertions(+), 61 deletions(-) diff --git a/libsrc/c64/soft80.inc b/libsrc/c64/soft80.inc index 678000967..ca5c713ce 100644 --- a/libsrc/c64/soft80.inc +++ b/libsrc/c64/soft80.inc @@ -7,7 +7,17 @@ soft80_lo_charset = $d000 soft80_hi_charset = $d400 soft80_vram = $d800 ; ram under i/o soft80_colram = $d800 ; color ram (used for temp. storage) -soft80_spriteblock = $dc00 +soft80_spriteblock = $dc00 ; 64 bytes reserved for pointer sprite data + +; tables for kplot +soft80_bitmapxlo = $dc40 ; (80 bytes) +soft80_bitmapxhi = $dc40 + 80 ; (80 bytes) +soft80_vramlo = $dc40 + 160 ; (25 bytes) +; align to next page for speed +soft80_vramhi = $dd00 ; (25 bytes) +soft80_bitmapylo = $dd00 + 25 ; (25 bytes) +soft80_bitmapyhi = $dd00 + 50 ; (25 bytes) + soft80_bitmap = $e000 charsperline = 80 diff --git a/libsrc/c64/soft80_charset.s b/libsrc/c64/soft80_charset.s index 7a4e10968..678439a30 100644 --- a/libsrc/c64/soft80_charset.s +++ b/libsrc/c64/soft80_charset.s @@ -43,7 +43,7 @@ .export soft80_charset - .rodata + .segment "INIT" soft80_charset: .byte $0f,$03,$0f,$00,$0f,$07,$05,$0e .byte $0f,$05,$0e,$0b,$0f,$0b,$0f,$0f diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index f6efe3382..06bebc907 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -17,6 +17,28 @@ .include "soft80.inc" soft80_init: + lda soft80_first_init + bne @skp + jsr firstinit +@skp: + ; the "color voodoo" in other parts of the code relies on the vram and + ; colorram being set up as expected, which is why we cant use the + ; _bgcolor and _textcolor functions here. + + lda 646 ; use current textcolor + and #$0f + sta soft80_internal_textcolor + + lda VIC_BG_COLOR0 ; use current bgcolor + and #$0f + sta soft80_internal_bgcolor + asl a + asl a + asl a + asl a + ora soft80_internal_textcolor + sta CHARCOLOR + lda #$3b sta VIC_CTRL1 lda #$00 @@ -26,14 +48,28 @@ soft80_init: lda #$c8 sta VIC_CTRL2 + jmp soft80_kclrscr + +soft80_shutdown: + lda #$1b + sta VIC_CTRL1 + lda #$03 + sta CIA2_PRA + lda #$15 + sta VIC_VIDEO_ADR + rts + + .segment "INIT" +firstinit: ; copy charset to RAM under I/O - ; FIXME: move charset and this constructor into init segment sei lda $01 pha lda #$34 sta $01 + inc soft80_first_init + lda #>soft80_charset sta ptr1+1 lda #((col/2)*8) + .endrepeat +soft80_vramlo_data: + .repeat 25,row + .byte <(soft80_vram+(row*40)) + .endrepeat + .byte 0,0,0,0,0,0,0 ; padding to next page +soft80_vramhi_data: + .repeat 25,row + .byte >(soft80_vram+(row*40)) + .endrepeat +soft80_bitmapylo_data: + .repeat 25,row + .byte <(soft80_bitmap+(row*40*8)) + .endrepeat +soft80_bitmapyhi_data: + .repeat 25,row + .byte >(soft80_bitmap+(row*40*8)) + .endrepeat + +soft80_tables_data_end: + ;------------------------------------------------------------------------------- ; FIXME: when the code is fixed to use the "init" segment, these variables must ; be moved into a section other than .bss so they survive after the init ; code has been run. - .bss + .data ; FIXME soft80_internal_textcolor: .res 1 soft80_internal_bgcolor: @@ -112,3 +161,6 @@ soft80_internal_bgcolor: soft80_internal_cursorxlsb: .res 1 + .data +soft80_first_init: + .byte 0 ; flag to check first init, this really must be in .data diff --git a/libsrc/c64/soft80_kplot.s b/libsrc/c64/soft80_kplot.s index 79a14cbcb..bd52ee6d3 100644 --- a/libsrc/c64/soft80_kplot.s +++ b/libsrc/c64/soft80_kplot.s @@ -17,6 +17,12 @@ soft80_kplot: stx CURS_Y sty CURS_X + sei + lda $01 + pha + lda #$34 ; enable RAM under I/O + sta $01 + ; calc pointer to bitmap lda soft80_bitmapylo,x clc @@ -41,40 +47,15 @@ soft80_kplot: adc soft80_vramhi,x sta CRAM_PTR+1 + pla + sta $01 + cli + @getpos: ldx CURS_Y ldy CURS_X rts - ; FIXME: the following tables take up 260 bytes, perhaps move them - ; to 0xdc00... area in ram under i/o - - .rodata -soft80_bitmapxlo: - .repeat 80,col - .byte <((col/2)*8) - .endrepeat -soft80_bitmapxhi: - .repeat 80,col - .byte >((col/2)*8) - .endrepeat -soft80_vramlo: - .repeat 25,row - .byte <(soft80_vram+(row*40)) - .endrepeat -soft80_vramhi: - .repeat 25,row - .byte >(soft80_vram+(row*40)) - .endrepeat -soft80_bitmapylo: - .repeat 25,row - .byte <(soft80_bitmap+(row*40*8)) - .endrepeat -soft80_bitmapyhi: - .repeat 25,row - .byte >(soft80_bitmap+(row*40*8)) - .endrepeat - ;------------------------------------------------------------------------------- ; force the init constructor to be imported From 08d7eefdd7178705628f3d8ad28e9f9041f2e511 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Tue, 13 Oct 2015 04:14:04 +0200 Subject: [PATCH 40/54] another size optimization, make bgcolor() much more robust --- libsrc/c64/soft80_color.s | 190 ++++++++++++++++++++++++-------------- libsrc/c64/soft80_cputc.s | 6 +- 2 files changed, 125 insertions(+), 71 deletions(-) diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index ab4b4a01f..e84b6fa60 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -7,6 +7,8 @@ .export soft80_textcolor, soft80_bgcolor .import soft80_internal_textcolor, soft80_internal_bgcolor + .import soft80_internal_cursorxlsb + .import soft80_kplot, soft80_checkchar .importzp tmp1, tmp2 @@ -17,74 +19,6 @@ soft80_textcolor: ldx soft80_internal_textcolor ; get old value sta soft80_internal_textcolor ; set new value - jsr mkcharcolor - - txa ; get old value - rts - -soft80_bgcolor: - ldx soft80_internal_bgcolor ; get old value - sta soft80_internal_bgcolor ; set new value - - jsr mkcharcolor - - stx tmp2 ; save old value - -.if SOFT80COLORVOODOO = 1 - ; if the old bg color is equal to color ram of that cell, then also - ; update the color ram to the new value. - ; FIXME: perhaps we must also check if the non visible character is not - ; a space, and NOT update the color ram in that case. - ldx #$00 -lp1: - .repeat $4,page - .scope - lda soft80_colram+(page*250),x - and #$0f - cmp tmp2 ; old bg color - bne @sk1 - lda soft80_internal_bgcolor ; new bg color - sta soft80_colram+(page*250),x -@sk1: - .endscope - .endrepeat - - inx - bne lp1 -.endif - - sei - ldy $01 - lda #$34 ; disable I/O - sta $01 - - ; if the old bg color is equal to text color in this cell, then also - ; update the text color to the new value. - ; FIXME: perhaps we need to check for space, see note above - ldx #$00 -lp2: - .repeat $4,page - .scope - lda soft80_vram+(page*250),x - and #$0f - cmp tmp2 ; old bg color - bne @sk2 - lda soft80_internal_bgcolor ; new bg color -@sk2: - ora tmp1 ; new bg color (high nibble) - sta soft80_vram+(page*250),x - .endscope - .endrepeat - - inx - bne lp2 - - sty $01 ; enable I/O - cli - - lda tmp2 ; get old value - rts - mkcharcolor: lda soft80_internal_bgcolor asl a @@ -94,6 +28,126 @@ mkcharcolor: sta tmp1 ; remember new bg color (high nibble) ora soft80_internal_textcolor sta CHARCOLOR ; text/bg combo for new chars + + txa ; get old value + rts + +soft80_bgcolor: + ldx soft80_internal_bgcolor ; get old value + stx tmp2 ; save old value + sta soft80_internal_bgcolor ; set new value + + jsr mkcharcolor + + lda CURS_X + pha + lda CURS_Y + pha + + ldy #0 + ldx #0 + clc + jsr soft80_kplot + + sei + lda $01 + pha + ldx #$34 + stx $01 ; $34 + + ;ldy #0 ; is still 0 + + lda #24 + sta CURS_Y +lpy: + lda #39 + sta CURS_X +lpx: + +.if SOFT80COLORVOODOO = 1 + ; if the old bg color is equal to color ram of that cell, then also + ; update the color ram to the new value. + + inc $01 ; $35 + lda (CRAM_PTR),y ; colram + stx $01 ; $34 + + and #$0f + cmp tmp2 ; old bg color + bne @sk1 + + ; if the left character in the cell is not a space, then dont update + ; the color ram + lda #1 + sta soft80_internal_cursorxlsb + jsr soft80_checkchar + bcc @sk1 + lda soft80_internal_bgcolor ; new bg color + + inc $01 ; $35 + sta (CRAM_PTR),y ; colram + stx $01 ; $34 +@sk1: +.endif + ; if the old bg color is equal to text color in this cell, then also + ; update the text color to the new value. + + lda (CRAM_PTR),y ; vram + and #$0f + cmp tmp2 ; old bg color + bne @sk2 + + ; if there are non space characters in the cell, do not update the + ; color ram + pha + lda #0 + sta soft80_internal_cursorxlsb + jsr soft80_checkchar + pla + bcc @sk2 + + pha + inc soft80_internal_cursorxlsb + jsr soft80_checkchar + pla + bcc @sk2 + + lda soft80_internal_bgcolor ; new bg color +@sk2: + ora tmp1 ; new bg color (high nibble) + sta (CRAM_PTR),y ; vram + + inc CRAM_PTR + bne @sk3 + inc CRAM_PTR+1 +@sk3: + + lda SCREEN_PTR + clc + adc #8 + sta SCREEN_PTR + bcc @sk4 + inc SCREEN_PTR+1 +@sk4: + + dec CURS_X + bpl lpx + + dec CURS_Y + bpl lpy + + pla + sta $01 ; enable I/O + cli + + pla ; CURS_Y + tax + pla ; CURS_X + tay + clc + jsr soft80_kplot + + lda tmp2 ; get old value rts ;------------------------------------------------------------------------------- diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 0e8cb0bd8..92aa728de 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -8,6 +8,7 @@ .export soft80_cputcxy, soft80_cputc .export soft80_cputdirect, soft80_putchar .export soft80_newline, soft80_plot + .export soft80_checkchar .import popa, _gotoxy @@ -470,15 +471,14 @@ soft80_putcolor: ; test if there is a space or a character at current position ; ; in: x = $34 -; y must be $00 +; $01 must be $34 +; ; out: SEC: space ; CLC: character ; x = $34 ; y = $00 soft80_checkchar: - ;ldy #$00 ; is still $00 - lda soft80_internal_cursorxlsb bne @l1a From ffda2a36031a163ec74a54ac87a0fd3210111c60 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Tue, 13 Oct 2015 04:14:23 +0200 Subject: [PATCH 41/54] updated conio test --- testcode/lib/conio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index a7a83594e..eebcd195e 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -14,7 +14,7 @@ static char grid[5][5] = { void main(void) { int i, j, n; - unsigned char xsize, ysize, tcol, inpos = 0; + unsigned char xsize, ysize, tcol, bgcol, inpos = 0; clrscr(); screensize(&xsize, &ysize); @@ -22,6 +22,7 @@ void main(void) cputsxy(0, 2, "Colors:" ); tcol = textcolor(0); /* remember original textcolor */ + bgcol = bgcolor(0); /* remember original background color */ for (i = 0; i < 3; ++i) { gotoxy(i,3 + i); for (j = 0; j < 16; ++j) { @@ -30,6 +31,7 @@ void main(void) } } textcolor(tcol); + bgcolor(bgcol); cprintf("\n\n\r Screensize is: %dx%d", xsize, ysize ); @@ -90,6 +92,12 @@ void main(void) inpos = (inpos - 1) & 7; } else if (i == CH_CURS_RIGHT) { inpos = (inpos + 1) & 7; + } else if (i == CH_F7) { + bgcol = (bgcol + 1) & 0x0f; + bgcolor(bgcol); + } else if (i == CH_F8) { + bgcol = (bgcol - 1) & 0x0f; + bgcolor(bgcol); } else { cputc(i); inpos = (inpos + 1) & 7; From c7080313746fafb082e29ffa65355030bf8f4aaa Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 14 Oct 2015 17:24:16 +0200 Subject: [PATCH 42/54] use 'soft80_internal_cellcolor' for the current cell color, and CHARCOLOR for the actual textcolor --- libsrc/c64/soft80_cgetc.s | 4 ++-- libsrc/c64/soft80_color.s | 10 +++++----- libsrc/c64/soft80_conio.s | 14 +++++++------- libsrc/c64/soft80_cputc.s | 12 ++++++------ libsrc/c64/soft80_kclrscr.s | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index ba16614af..5343027bb 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -5,7 +5,7 @@ ; .export soft80_cgetc - .import soft80_internal_cursorxlsb + .import soft80_internal_cellcolor, soft80_internal_cursorxlsb .import cursor .importzp tmp1 @@ -74,7 +74,7 @@ setcolor: ; save old value lda (CRAM_PTR),y ; vram sta tmp1 - lda CHARCOLOR + lda soft80_internal_cellcolor sta (CRAM_PTR),y ; vram rts diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index e84b6fa60..bbd666af7 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -6,7 +6,7 @@ ; .export soft80_textcolor, soft80_bgcolor - .import soft80_internal_textcolor, soft80_internal_bgcolor + .import soft80_internal_cellcolor, soft80_internal_bgcolor .import soft80_internal_cursorxlsb .import soft80_kplot, soft80_checkchar @@ -16,8 +16,8 @@ .include "soft80.inc" soft80_textcolor: - ldx soft80_internal_textcolor ; get old value - sta soft80_internal_textcolor ; set new value + ldx CHARCOLOR ; get old value + sta CHARCOLOR ; set new value mkcharcolor: lda soft80_internal_bgcolor @@ -26,8 +26,8 @@ mkcharcolor: asl a asl a sta tmp1 ; remember new bg color (high nibble) - ora soft80_internal_textcolor - sta CHARCOLOR ; text/bg combo for new chars + ora CHARCOLOR + sta soft80_internal_cellcolor ; text/bg combo for new chars txa ; get old value rts diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index 06bebc907..d2dfb913e 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -8,7 +8,7 @@ .destructor soft80_shutdown .import soft80_kclrscr, soft80_charset - .export soft80_internal_textcolor, soft80_internal_bgcolor + .export soft80_internal_bgcolor, soft80_internal_cellcolor .export soft80_internal_cursorxlsb .importzp ptr1, ptr2, ptr3 @@ -25,9 +25,9 @@ soft80_init: ; colorram being set up as expected, which is why we cant use the ; _bgcolor and _textcolor functions here. - lda 646 ; use current textcolor - and #$0f - sta soft80_internal_textcolor + lda CHARCOLOR ; use current textcolor + and #$0f ; make sure the upper nibble is 0s + sta CHARCOLOR lda VIC_BG_COLOR0 ; use current bgcolor and #$0f @@ -36,8 +36,8 @@ soft80_init: asl a asl a asl a - ora soft80_internal_textcolor - sta CHARCOLOR + ora CHARCOLOR + sta soft80_internal_cellcolor lda #$3b sta VIC_CTRL1 @@ -154,7 +154,7 @@ soft80_tables_data_end: ; code has been run. .data ; FIXME -soft80_internal_textcolor: +soft80_internal_cellcolor: .res 1 soft80_internal_bgcolor: .res 1 diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 92aa728de..1ded7ef6a 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -13,7 +13,7 @@ .import popa, _gotoxy .import soft80_kplot - .import soft80_internal_bgcolor, soft80_internal_textcolor + .import soft80_internal_bgcolor, soft80_internal_cellcolor .import soft80_internal_cursorxlsb .importzp tmp4,tmp3 @@ -148,7 +148,7 @@ draw_spaceinvers: .if SOFT80COLORVOODOO = 1 jsr soft80_putcolor .else - lda CHARCOLOR + lda soft80_internal_cellcolor sta (CRAM_PTR),y ; vram .endif @@ -232,7 +232,7 @@ soft80_putchar: .if SOFT80COLORVOODOO = 1 jsr soft80_putcolor .else - lda CHARCOLOR + lda soft80_internal_cellcolor sta (CRAM_PTR),y ; vram .endif @@ -436,7 +436,7 @@ soft80_putcolor: bne @sk2 ; jump if odd xpos ; vram = textcol - lda CHARCOLOR + lda soft80_internal_cellcolor sta (CRAM_PTR),y ; vram rts @@ -449,7 +449,7 @@ soft80_putcolor: beq @sk3 ; jump if even xpos @sk2: ; colram = textcol - lda soft80_internal_textcolor + lda CHARCOLOR inc $01 ; $35 sta (CRAM_PTR),y ; colram stx $01 ; $34 @@ -463,7 +463,7 @@ soft80_putcolor: stx $01 ; $34 @sk1: ; vram = textcol - lda CHARCOLOR + lda soft80_internal_cellcolor sta (CRAM_PTR),y ; vram rts diff --git a/libsrc/c64/soft80_kclrscr.s b/libsrc/c64/soft80_kclrscr.s index 811ea665f..7c313afcf 100644 --- a/libsrc/c64/soft80_kclrscr.s +++ b/libsrc/c64/soft80_kclrscr.s @@ -6,7 +6,7 @@ .export soft80_kclrscr .import soft80_kplot - .import soft80_internal_bgcolor + .import soft80_internal_bgcolor, soft80_internal_cellcolor .importzp ptr1 .include "c64.inc" @@ -48,7 +48,7 @@ soft80_kclrscr: lda #$34 ; enable RAM under I/O sta $01 - lda CHARCOLOR + lda soft80_internal_cellcolor and #$f0 ora soft80_internal_bgcolor jsr clear ; clear vram From d4f88c8f7141119b6efd1869ff247515a7c09601 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 14 Oct 2015 17:24:42 +0200 Subject: [PATCH 43/54] update conio test --- testcode/lib/conio.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index eebcd195e..0dddacfdf 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -1,3 +1,14 @@ +/* + * conio api test program + * + * keys: + * + * 1...0 change text color + * F5/F6 change border color + * F7/F8 change background color + * + */ + #include #include @@ -14,7 +25,7 @@ static char grid[5][5] = { void main(void) { int i, j, n; - unsigned char xsize, ysize, tcol, bgcol, inpos = 0; + unsigned char xsize, ysize, tcol, bgcol, bcol, inpos = 0; clrscr(); screensize(&xsize, &ysize); @@ -23,6 +34,7 @@ void main(void) cputsxy(0, 2, "Colors:" ); tcol = textcolor(0); /* remember original textcolor */ bgcol = bgcolor(0); /* remember original background color */ + bcol = bordercolor(0); /* remember original border color */ for (i = 0; i < 3; ++i) { gotoxy(i,3 + i); for (j = 0; j < 16; ++j) { @@ -92,6 +104,12 @@ void main(void) inpos = (inpos - 1) & 7; } else if (i == CH_CURS_RIGHT) { inpos = (inpos + 1) & 7; + } else if (i == CH_F5) { + bgcol = (bgcol + 1) & 0x0f; + bordercolor(bgcol); + } else if (i == CH_F6) { + bgcol = (bgcol - 1) & 0x0f; + bordercolor(bgcol); } else if (i == CH_F7) { bgcol = (bgcol + 1) & 0x0f; bgcolor(bgcol); From 59dd15aa55341264776a9515e43e42c9b03c4f05 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 14 Oct 2015 17:25:35 +0200 Subject: [PATCH 44/54] split regular color.s into color.s and bordercolor.s --- libsrc/c64/bordercolor.s | 17 +++++++++++++++++ libsrc/c64/color.s | 10 +--------- 2 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 libsrc/c64/bordercolor.s diff --git a/libsrc/c64/bordercolor.s b/libsrc/c64/bordercolor.s new file mode 100644 index 000000000..73dfc0a99 --- /dev/null +++ b/libsrc/c64/bordercolor.s @@ -0,0 +1,17 @@ +; +; Ullrich von Bassewitz, 06.08.1998 +; +; unsigned char __fastcall__ bordercolor (unsigned char color); +; + + + .export _bordercolor + + .include "c64.inc" + +_bordercolor: + ldx VIC_BORDERCOLOR ; get old value + sta VIC_BORDERCOLOR ; set new value + txa + rts + diff --git a/libsrc/c64/color.s b/libsrc/c64/color.s index bfc371931..de9a973e7 100644 --- a/libsrc/c64/color.s +++ b/libsrc/c64/color.s @@ -7,7 +7,7 @@ ; - .export _textcolor, _bgcolor, _bordercolor + .export _textcolor, _bgcolor .include "c64.inc" @@ -23,11 +23,3 @@ _bgcolor: sta VIC_BG_COLOR0 ; set new value txa rts - - -_bordercolor: - ldx VIC_BORDERCOLOR ; get old value - sta VIC_BORDERCOLOR ; set new value - txa - rts - From f391c1c3d5f12b0fbfd1a9152efc69fe1b4fc8b9 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 14 Oct 2015 17:33:58 +0200 Subject: [PATCH 45/54] remove soft80_bordercolor override --- libsrc/c64/extra/soft80.s | 4 ---- libsrc/c64/soft80_bordercolor.s | 17 ----------------- 2 files changed, 21 deletions(-) delete mode 100644 libsrc/c64/soft80_bordercolor.s diff --git a/libsrc/c64/extra/soft80.s b/libsrc/c64/extra/soft80.s index 9efb8d577..c1e74d66a 100644 --- a/libsrc/c64/extra/soft80.s +++ b/libsrc/c64/extra/soft80.s @@ -15,10 +15,6 @@ .export _textcolor := soft80_textcolor .export _bgcolor := soft80_bgcolor - ; soft80_bordercolor.s - .import soft80_bordercolor - .export _bordercolor := soft80_bordercolor - ; soft80_cputc.s .import soft80_cputc .import soft80_cputcxy diff --git a/libsrc/c64/soft80_bordercolor.s b/libsrc/c64/soft80_bordercolor.s deleted file mode 100644 index 057cc410a..000000000 --- a/libsrc/c64/soft80_bordercolor.s +++ /dev/null @@ -1,17 +0,0 @@ -; -; Groepaz/Hitmen, 12.10.2015 -; -; unsigned char __fastcall__ bordercolor (unsigned char color); -; - - .export soft80_bordercolor - - .include "c64.inc" - - ; FIXME: if we'd move this function into a seperate file in the regular - ; conio lib, then we dont need this override at all. -soft80_bordercolor: - ldx VIC_BORDERCOLOR ; get old value - sta VIC_BORDERCOLOR ; set new value - txa - rts From 795a1a1b87a35d6d04e62d6416bc3e2794046d6a Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 14 Oct 2015 17:34:29 +0200 Subject: [PATCH 46/54] fix bordercolor in test --- testcode/lib/conio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c index 0dddacfdf..3a8048632 100644 --- a/testcode/lib/conio.c +++ b/testcode/lib/conio.c @@ -35,6 +35,7 @@ void main(void) tcol = textcolor(0); /* remember original textcolor */ bgcol = bgcolor(0); /* remember original background color */ bcol = bordercolor(0); /* remember original border color */ + bgcolor(bgcol);bordercolor(bcol); for (i = 0; i < 3; ++i) { gotoxy(i,3 + i); for (j = 0; j < 16; ++j) { @@ -43,7 +44,6 @@ void main(void) } } textcolor(tcol); - bgcolor(bgcol); cprintf("\n\n\r Screensize is: %dx%d", xsize, ysize ); From e6f5c7d8da65d1d249fc6a636ed668a4c229eac0 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 14 Oct 2015 17:50:44 +0200 Subject: [PATCH 47/54] some comments --- libsrc/c64/extra/soft80.s | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/libsrc/c64/extra/soft80.s b/libsrc/c64/extra/soft80.s index c1e74d66a..4ee030c81 100644 --- a/libsrc/c64/extra/soft80.s +++ b/libsrc/c64/extra/soft80.s @@ -7,13 +7,13 @@ ; soft80_cgetc.s .import soft80_cgetc - .export _cgetc := soft80_cgetc + .export _cgetc := soft80_cgetc ; cgetc.s ; soft80_color.s .import soft80_textcolor .import soft80_bgcolor - .export _textcolor := soft80_textcolor - .export _bgcolor := soft80_bgcolor + .export _textcolor := soft80_textcolor ; color.s + .export _bgcolor := soft80_bgcolor ; color.s ; soft80_cputc.s .import soft80_cputc @@ -22,25 +22,26 @@ .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 + .export _cputc := soft80_cputc ; cputc.s + .export _cputcxy := soft80_cputcxy ; cputc.s + .export cputdirect := soft80_cputdirect ; cputc.s + .export putchar := soft80_putchar ; cputc.s + .export newline := soft80_newline ; cputc.s + .export plot := soft80_plot ; cputc.s ; soft80_kclrscr.s .import soft80_kclrscr - .export _clrscr := soft80_kclrscr - .export CLRSCR := soft80_kclrscr + .export _clrscr := soft80_kclrscr ; clrscr.s + .export CLRSCR := soft80_kclrscr ; kernal func (c64.inc) ; soft80_kplot.s .import soft80_kplot - .export PLOT := soft80_kplot + .export PLOT := soft80_kplot ; kplot.s ; soft80_kscreen.s .import soft80_screensize - .export screensize := soft80_screensize + .export screensize := soft80_screensize ; _scrsize.s + .export SCREEN := soft80_screensize ; kernal func (kernal.s) ; VIC sprite data for the mouse pointer .export mcb_spritememory := soft80_spriteblock From b9c688d997a3c0cdce096f3a8d225026bb736a45 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Wed, 14 Oct 2015 17:52:14 +0200 Subject: [PATCH 48/54] remove deleted function from comment --- libsrc/c64/color.s | 1 - 1 file changed, 1 deletion(-) diff --git a/libsrc/c64/color.s b/libsrc/c64/color.s index de9a973e7..86d6aefe8 100644 --- a/libsrc/c64/color.s +++ b/libsrc/c64/color.s @@ -3,7 +3,6 @@ ; ; unsigned char __fastcall__ textcolor (unsigned char color); ; unsigned char __fastcall__ bgcolor (unsigned char color); -; unsigned char __fastcall__ bordercolor (unsigned char color); ; From 8263083506e54b5f97cb6373d172877219565ac0 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 15 Oct 2015 15:11:05 +0200 Subject: [PATCH 49/54] move variables into INITBSS --- libsrc/c64/soft80_conio.s | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libsrc/c64/soft80_conio.s b/libsrc/c64/soft80_conio.s index d2dfb913e..4e24a0341 100644 --- a/libsrc/c64/soft80_conio.s +++ b/libsrc/c64/soft80_conio.s @@ -149,11 +149,7 @@ soft80_bitmapyhi_data: soft80_tables_data_end: ;------------------------------------------------------------------------------- -; FIXME: when the code is fixed to use the "init" segment, these variables must -; be moved into a section other than .bss so they survive after the init -; code has been run. - - .data ; FIXME + .segment "INITBSS" soft80_internal_cellcolor: .res 1 soft80_internal_bgcolor: From 5099910b18c9ed9bb6603d3f9b4622e2039020a2 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 18 Oct 2015 23:57:58 +0200 Subject: [PATCH 50/54] updated docs --- doc/c64.sgml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/c64.sgml b/doc/c64.sgml index ca99e0061..f22eca3e1 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -116,6 +116,30 @@ cl65 -o file.prg -u __EXEHDR__ -t c64 -C c64-asm.cfg source.s Please note that in this case a changed start address doesn't make sense, since the program must be loaded to the BASIC start address. +Extras

+ +80 Columns conio driver

+ +The C64 package comes with an alternative software driven 80 columns +module +cl65 -t c64 myprog.c c64-soft80.o + + +Note that the soft80 conio driver is incompatible with the +Platform-specific header files

@@ -216,6 +240,9 @@ configuration. palette of the 16 C64 colors).

+Note that the graphics drivers are incompatible with the +Extended memory drivers

@@ -241,7 +268,7 @@ configuration. A driver for the hidden RAM below the I/O area and kernal ROM. Supports 48 256 byte pages. Please note that this driver is incompatible with any of the - graphics drivers! + graphics drivers, or the soft80 conio driver! A driver for the RamCart 64/128 written and contributed by Maciej Witkowiak. From d6d016bb80bcfd3b40c218b16e7dc31425fa7792 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 19 Oct 2015 02:47:40 +0200 Subject: [PATCH 51/54] updated comments --- libsrc/c64/soft80_cgetc.s | 2 ++ libsrc/c64/soft80_charset.s | 2 +- libsrc/c64/soft80_color.s | 2 ++ libsrc/c64/soft80_cputc.s | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index 5343027bb..ae0e23857 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -1,6 +1,8 @@ ; ; Groepaz/Hitmen, 11.10.2015 ; +; high level implementation for the soft80 implementation +; ; char cgetc (void); ; diff --git a/libsrc/c64/soft80_charset.s b/libsrc/c64/soft80_charset.s index 678439a30..69fd3527f 100644 --- a/libsrc/c64/soft80_charset.s +++ b/libsrc/c64/soft80_charset.s @@ -1,7 +1,7 @@ ; ; Groepaz/Hitmen, 12.10.2015 ; -; character set for use with the soft80 implementation +; character set for use with the soft80 implementations ; ; the format of the data follows the following layout: diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index bbd666af7..8c1d113ac 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -1,6 +1,8 @@ ; ; Groepaz/Hitmen, 12.10.2015 ; +; high level implementation for the soft80 implementation +; ; unsigned char __fastcall__ textcolor (unsigned char color); ; unsigned char __fastcall__ bgcolor (unsigned char color); ; diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 1ded7ef6a..acbe5b560 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -1,6 +1,8 @@ ; ; Groepaz/Hitmen, 11.10.2015 ; +; high level implementation for the soft80 implementation +; ; void cputcxy (unsigned char x, unsigned char y, char c); ; void cputc (char c); ; From 60334c40e6191d48b540d26e3ec79e091886c0c4 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 19 Oct 2015 02:49:32 +0200 Subject: [PATCH 52/54] added size optimized monochrom soft80 driver --- libsrc/c64/extra/soft80mono.s | 55 +++++++++ libsrc/c64/soft80mono_cgetc.s | 66 ++++++++++ libsrc/c64/soft80mono_color.s | 65 ++++++++++ libsrc/c64/soft80mono_conio.s | 168 ++++++++++++++++++++++++++ libsrc/c64/soft80mono_cputc.s | 205 ++++++++++++++++++++++++++++++++ libsrc/c64/soft80mono_kclrscr.s | 63 ++++++++++ libsrc/c64/soft80mono_kplot.s | 52 ++++++++ 7 files changed, 674 insertions(+) create mode 100644 libsrc/c64/extra/soft80mono.s create mode 100644 libsrc/c64/soft80mono_cgetc.s create mode 100644 libsrc/c64/soft80mono_color.s create mode 100644 libsrc/c64/soft80mono_conio.s create mode 100644 libsrc/c64/soft80mono_cputc.s create mode 100644 libsrc/c64/soft80mono_kclrscr.s create mode 100644 libsrc/c64/soft80mono_kplot.s diff --git a/libsrc/c64/extra/soft80mono.s b/libsrc/c64/extra/soft80mono.s new file mode 100644 index 000000000..f91f4a76a --- /dev/null +++ b/libsrc/c64/extra/soft80mono.s @@ -0,0 +1,55 @@ +; +; Groepaz/Hitmen, 19.10.2015 +; +; import/overload stubs for the monochrome soft80 implementation +; +; - optimized for size, almost 1k smaller footprint than the full color version +; - textcolor() sets one common text color for the whole screen +; + .include "../soft80.inc" + + ; soft80mono_cgetc.s + .import soft80mono_cgetc + .export _cgetc := soft80mono_cgetc ; cgetc.s + + ; soft80mono_color.s + .import soft80mono_textcolor + .import soft80mono_bgcolor + .export _textcolor := soft80mono_textcolor ; color.s + .export _bgcolor := soft80mono_bgcolor ; color.s + + ; soft80mono_cputc.s + .import soft80mono_cputc + .import soft80mono_cputcxy + .import soft80mono_cputdirect + .import soft80mono_putchar + .import soft80mono_newline + .import soft80mono_plot + .export _cputc := soft80mono_cputc ; cputc.s + .export _cputcxy := soft80mono_cputcxy ; cputc.s + .export cputdirect := soft80mono_cputdirect ; cputc.s + .export putchar := soft80mono_putchar ; cputc.s + .export newline := soft80mono_newline ; cputc.s + .export plot := soft80mono_plot ; cputc.s + + ; soft80mono_kclrscr.s + .import soft80mono_kclrscr + .export _clrscr := soft80mono_kclrscr ; clrscr.s + .export CLRSCR := soft80mono_kclrscr ; kernal func (c64.inc) + + ; soft80mono_kplot.s + .import soft80mono_kplot + .export PLOT := soft80mono_kplot ; kplot.s + + ; soft80_kscreen.s + .import soft80_screensize + .export screensize := soft80_screensize ; _scrsize.s + .export SCREEN := soft80_screensize ; kernal func (kernal.s) + + ; VIC sprite data for the mouse pointer + .export mcb_spritememory := soft80_spriteblock + .export mcb_spritepointer := (soft80_vram + $03F8) + + ; Chars used by chline () and cvline () + .exportzp chlinechar = CH_HLINE + .exportzp cvlinechar = CH_VLINE diff --git a/libsrc/c64/soft80mono_cgetc.s b/libsrc/c64/soft80mono_cgetc.s new file mode 100644 index 000000000..d99dc7775 --- /dev/null +++ b/libsrc/c64/soft80mono_cgetc.s @@ -0,0 +1,66 @@ +; +; Groepaz/Hitmen, 19.10.2015 +; +; high level implementation for the monochrome soft80 implementation +; +; char cgetc (void); +; + + .export soft80mono_cgetc + .import soft80mono_internal_cellcolor, soft80mono_internal_cursorxlsb + .import soft80mono_internal_nibble + .import cursor + .importzp tmp1 + + .include "c64.inc" + .include "soft80.inc" + +soft80mono_cgetc: + lda KEY_COUNT ; Get number of characters + bne @L3 ; Jump if there are already chars waiting + + jsr invertcursor ; set cursor on or off accordingly + +@L1: lda KEY_COUNT ; wait for key + beq @L1 + + jsr invertcursor ; set cursor on or off accordingly + +@L3: jsr KBDREAD ; Read char and return in A + ldx #0 + rts + +; Switch the cursor on or off (invert) + +invertcursor: + lda cursor + bne @invert + rts +@invert: + + sei + lda $01 ; enable RAM under I/O + pha + lda #$34 + sta $01 + + ldy #$00 + ldx soft80mono_internal_cursorxlsb +@lp1: + lda (SCREEN_PTR),y + eor soft80mono_internal_nibble,x + sta (SCREEN_PTR),y + iny + cpy #8 + bne @lp1 + + pla + sta $01 ; enable I/O + cli + rts + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import soft80mono_init +conio_init = soft80mono_init diff --git a/libsrc/c64/soft80mono_color.s b/libsrc/c64/soft80mono_color.s new file mode 100644 index 000000000..aa24957d5 --- /dev/null +++ b/libsrc/c64/soft80mono_color.s @@ -0,0 +1,65 @@ +; +; Groepaz/Hitmen, 19.10.2015 +; +; high level implementation for the monochrome soft80 implementation +; +; unsigned char __fastcall__ textcolor (unsigned char color); +; unsigned char __fastcall__ bgcolor (unsigned char color); +; + + .export soft80mono_textcolor, soft80mono_bgcolor + .import soft80mono_internal_cellcolor, soft80mono_internal_bgcolor + + .importzp tmp1 + + .include "c64.inc" + .include "soft80.inc" + +soft80mono_textcolor: + ldx CHARCOLOR ; get old value + stx tmp1 ; save old value + sta CHARCOLOR ; set new value + +mkcharcolor: + lda soft80mono_internal_bgcolor + asl a + asl a + asl a + asl a + ora CHARCOLOR + sta soft80mono_internal_cellcolor ; text/bg combo for new chars + + sei + ldy $01 + lda #$34 ; enable RAM under I/O + sta $01 + + lda soft80mono_internal_cellcolor + ; clear loop for vram + ldx #$00 +@lp1: + sta soft80_vram,x + sta soft80_vram+$100,x + sta soft80_vram+$200,x + sta soft80_vram+$2e8,x + inx + bne @lp1 + + sty $01 + cli + + lda tmp1 ; get old value + rts + +soft80mono_bgcolor: + ldx soft80mono_internal_bgcolor ; get old value + stx tmp1 ; save old value + sta soft80mono_internal_bgcolor ; set new value + + jmp mkcharcolor + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import soft80mono_init +conio_init = soft80mono_init diff --git a/libsrc/c64/soft80mono_conio.s b/libsrc/c64/soft80mono_conio.s new file mode 100644 index 000000000..759b280c6 --- /dev/null +++ b/libsrc/c64/soft80mono_conio.s @@ -0,0 +1,168 @@ +; +; Groepaz/Hitmen, 19.10.2015 +; +; Low level init code for the monochrome soft80 screen output/console input +; + + .constructor soft80mono_init, 8 + .destructor soft80mono_shutdown + + .import soft80mono_kclrscr, soft80_charset + .export soft80mono_internal_bgcolor, soft80mono_internal_cellcolor + .export soft80mono_internal_cursorxlsb + .export soft80mono_internal_nibble + + .importzp ptr1, ptr2, ptr3 + + .include "c64.inc" + .include "soft80.inc" + +soft80mono_init: + lda soft80mono_first_init + bne @skp + jsr firstinit +@skp: + ; the "color voodoo" in other parts of the code relies on the vram and + ; colorram being set up as expected, which is why we cant use the + ; _bgcolor and _textcolor functions here. + + lda CHARCOLOR ; use current textcolor + and #$0f ; make sure the upper nibble is 0s + sta CHARCOLOR + + lda VIC_BG_COLOR0 ; use current bgcolor + and #$0f + sta soft80mono_internal_bgcolor + asl a + asl a + asl a + asl a + ora CHARCOLOR + sta soft80mono_internal_cellcolor + + lda #$3b + sta VIC_CTRL1 + lda #$00 + sta CIA2_PRA + lda #$68 + sta VIC_VIDEO_ADR + lda #$c8 + sta VIC_CTRL2 + + jmp soft80mono_kclrscr + +soft80mono_shutdown: + lda #$1b + sta VIC_CTRL1 + lda #$03 + sta CIA2_PRA + lda #$15 + sta VIC_VIDEO_ADR + rts + + .segment "INIT" +firstinit: + ; copy charset to RAM under I/O + sei + lda $01 + pha + lda #$34 + sta $01 + + inc soft80mono_first_init + + lda #>soft80_charset + sta ptr1+1 + lda #soft80_lo_charset + sta ptr2+1 + lda #soft80_hi_charset + sta ptr3+1 + lda #((col/2)*8) + .endrepeat +soft80_vramlo_data: + .repeat 25,row + .byte <(soft80_vram+(row*40)) + .endrepeat + .byte 0,0,0,0,0,0,0 ; padding to next page +soft80_vramhi_data: + .repeat 25,row + .byte >(soft80_vram+(row*40)) + .endrepeat +soft80_bitmapylo_data: + .repeat 25,row + .byte <(soft80_bitmap+(row*40*8)) + .endrepeat +soft80_bitmapyhi_data: + .repeat 25,row + .byte >(soft80_bitmap+(row*40*8)) + .endrepeat + +soft80_tables_data_end: + +;------------------------------------------------------------------------------- + .segment "INITBSS" +soft80mono_internal_cellcolor: + .res 1 +soft80mono_internal_bgcolor: + .res 1 +soft80mono_internal_cursorxlsb: + .res 1 + + .data +soft80mono_first_init: + .byte 0 ; flag to check first init, this really must be in .data + + .rodata +soft80mono_internal_nibble: + .byte $f0, $0f + diff --git a/libsrc/c64/soft80mono_cputc.s b/libsrc/c64/soft80mono_cputc.s new file mode 100644 index 000000000..c89362cb5 --- /dev/null +++ b/libsrc/c64/soft80mono_cputc.s @@ -0,0 +1,205 @@ +; +; Groepaz/Hitmen, 19.10.2015 +; +; high level implementation for the monochrome soft80 implementation +; +; void cputcxy (unsigned char x, unsigned char y, char c); +; void cputc (char c); +; + + .export soft80mono_cputcxy, soft80mono_cputc + .export soft80mono_cputdirect, soft80mono_putchar + .export soft80mono_newline, soft80mono_plot + + .import popa, _gotoxy + + .import soft80mono_kplot + .import soft80mono_internal_bgcolor, soft80mono_internal_cellcolor + .import soft80mono_internal_cursorxlsb, soft80mono_internal_nibble + + .importzp tmp4, tmp3, ptr2 + + .include "c64.inc" + .include "soft80.inc" + +soft80mono_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 + +soft80mono_cputc: + cmp #$0A ; CR? + bne L1 + + lda #0 + sta CURS_X + + ; Set cursor position, calculate RAM pointers +soft80mono_plot: + ldx CURS_Y + ldy CURS_X + clc + jmp soft80mono_kplot ; Set the new cursor + +L1: cmp #$0D ; LF? + beq soft80mono_newline ; Recalculate pointers + + ; shortcut for codes < $80 ... codes $20-$7f can be printed directly, + ; codes $00-$1f are control codes which are not printable and thus may + ; give undefined result. + tay + bpl @L10 + + ; codes $80-$ff must get converted like this: + ; $80-$9f -> dont care (control codes) + ; $a0-$bf -> $00-$1f + ; $c0-$df -> $60-$7f + ; $e0-$ff -> $00-$1f + + ora #%01000000 ; $40 + clc + adc #%00100000 ; $20 + and #%01111111 ; $7f +@L10: + + ; entry point for direct output of a character. the value passed in + ; akku must match the offset in the charset. + ; - the following may not modify tmp1 +soft80mono_cputdirect: + jsr soft80mono_putchar ; Write the character to the screen + + ; Advance cursor position + iny ; contains CURS_X + cpy #charsperline + beq @L3 + + sty CURS_X + tya + and #$01 + sta soft80mono_internal_cursorxlsb + bne @L4 + + lda SCREEN_PTR + clc + adc #8 + sta SCREEN_PTR + bcc @L4 + inc SCREEN_PTR+1 +@L4: + rts +@L3: + inc CURS_Y ; new line + ldy #0 ; + cr + sty CURS_X + jmp soft80mono_plot + + ; - the following may not modify tmp1 +soft80mono_newline: + + lda SCREEN_PTR + clc + adc #<(40*8) + sta SCREEN_PTR + + lda SCREEN_PTR+1 + adc #>(40*8) + sta SCREEN_PTR+1 + + inc CURS_Y + rts + +;------------------------------------------------------------------------------- +; output one character in internal encoding without advancing cursor position +; generic entry point +; +; - the following may not modify tmp1 +; in: A: charcode +; out: Y: CURS_X +; +soft80mono_putchar: + sta tmp3 ; save charcode + + sei + lda $01 + pha + lda #$34 + sta $01 ; enable RAM under I/O + + ldy #$00 ; will be $00 from now on + + ldx soft80mono_internal_cursorxlsb + lda chardatal,x + clc + adc tmp3 + sta ptr2 + lda chardatah,x + adc #0 + sta ptr2+1 + + lda RVS + bne draw_charinvers + + lda nibble,x + sta tmp3 + + ;ldy #0 ; is still $00 +@lp1: + lda (SCREEN_PTR),y + and tmp3 + ora (ptr2),y + sta (SCREEN_PTR),y + clc + lda ptr2 + adc #$7f + sta ptr2 + bcc @sk1 + inc ptr2+1 +@sk1: + iny + cpy #8 + bne @lp1 + +draw_back: + pla + sta $01 + cli + + ldy CURS_X + rts + +; output inverted character +draw_charinvers: + lda soft80mono_internal_nibble,x + sta tmp3 + + ;ldy #0 ; is still $00 +@lp1: + lda (SCREEN_PTR),y + ora tmp3 + eor (ptr2),y + sta (SCREEN_PTR),y + clc + lda ptr2 + adc #$7f + sta ptr2 + bcc @sk1 + inc ptr2+1 +@sk1: + iny + cpy #8 + bne @lp1 + jmp draw_back + + .rodata +chardatal: + .byte soft80_hi_charset + .byte >soft80_lo_charset +nibble: + .byte $0f, $f0 + diff --git a/libsrc/c64/soft80mono_kclrscr.s b/libsrc/c64/soft80mono_kclrscr.s new file mode 100644 index 000000000..99243c699 --- /dev/null +++ b/libsrc/c64/soft80mono_kclrscr.s @@ -0,0 +1,63 @@ +; +; Groepaz/Hitmen, 19.10.2015 +; +; lowlevel kclrscr for the monochrome soft80 implementation +; + + .export soft80mono_kclrscr + .import soft80mono_kplot + .import soft80mono_internal_bgcolor, soft80mono_internal_cellcolor + .importzp ptr1 + + .include "c64.inc" + .include "soft80.inc" + +soft80mono_kclrscr: + + lda #soft80_bitmap + sta ptr1+1 + + lda #$ff + + ldx #$1f +@lp2: + ldy #0 +@lp1: + sta (ptr1),y + iny + bne @lp1 + inc ptr1+1 + dex + bne @lp2 + + ;ldx #$00 +@lp3: + sta soft80_bitmap+$1e40,x + inx + bne @lp3 + + sei + ldy $01 + lda #$34 ; enable RAM under I/O + sta $01 + + lda soft80mono_internal_cellcolor + ; clear loop for vram + ;ldx #$00 +@lp4: + sta soft80_vram,x + sta soft80_vram+$100,x + sta soft80_vram+$200,x + sta soft80_vram+$2e8,x + inx + bne @lp4 + + sty $01 + cli + + ldx #0 + ldy #0 + clc + jmp soft80mono_kplot diff --git a/libsrc/c64/soft80mono_kplot.s b/libsrc/c64/soft80mono_kplot.s new file mode 100644 index 000000000..b987924f3 --- /dev/null +++ b/libsrc/c64/soft80mono_kplot.s @@ -0,0 +1,52 @@ + +; +; Groepaz/Hitmen, 19.10.2015 +; +; lowlevel kplot function for the monochrome soft80 implementation +; + + .export soft80mono_kplot + .import soft80mono_internal_cursorxlsb + + .include "c64.inc" + .include "soft80.inc" + +soft80mono_kplot: + bcs @getpos + + stx CURS_Y + sty CURS_X + + sei + lda $01 + pha + lda #$34 ; enable RAM under I/O + sta $01 + + ; calc pointer to bitmap + lda soft80_bitmapylo,x + clc + adc soft80_bitmapxlo,y + sta SCREEN_PTR + lda soft80_bitmapyhi,x + adc soft80_bitmapxhi,y + sta SCREEN_PTR+1 + + tya + and #1 + sta soft80mono_internal_cursorxlsb + + pla + sta $01 + cli + +@getpos: + ldx CURS_Y + ldy CURS_X + rts + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import soft80mono_init +conio_init = soft80mono_init From 07a77d1259087e683f48033d5f6cde9596c36cdf Mon Sep 17 00:00:00 2001 From: mrdudz Date: Mon, 19 Oct 2015 03:12:19 +0200 Subject: [PATCH 53/54] updated docs --- doc/c64.sgml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/c64.sgml b/doc/c64.sgml index f22eca3e1..80f0334d0 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -141,6 +141,16 @@ Note that the soft80 conio driver is incompatible with the 80 Columns conio driver (monochrome)

+ +In an (even more) memory constrained situation, a size optimized version of the +software driven 80 columns module may be used, which only supports one common +text color for the whole screen. + + +cl65 -t c64 myprog.c c64-soft80mono.o + + Platform-specific header files

Programs containing C64-specific code may use the Date: Thu, 22 Oct 2015 17:33:01 +0200 Subject: [PATCH 54/54] removed apple2 specific note --- doc/c64.sgml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/c64.sgml b/doc/c64.sgml index 80f0334d0..a3e9e1291 100644 --- a/doc/c64.sgml +++ b/doc/c64.sgml @@ -127,8 +127,7 @@ and $ffff. In memory constrained situations the memory from $400 to $7FF can be made available to a program by calling