From: mrdudz Date: Mon, 12 Oct 2015 21:39:47 +0000 (+0200) Subject: move some stuff to init segment, saves roughly 1480 bytes :) X-Git-Tag: V2.16~210^2~16 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f462c173fbdafba1eb2b5070a77265002d397dcf;p=cc65 move some stuff to init segment, saves roughly 1480 bytes :) --- 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