move some stuff to init segment, saves roughly 1480 bytes :)
This commit is contained in:
parent
362a172477
commit
f462c173fb
4 changed files with 104 additions and 61 deletions
|
@ -7,7 +7,17 @@ soft80_lo_charset = $d000
|
||||||
soft80_hi_charset = $d400
|
soft80_hi_charset = $d400
|
||||||
soft80_vram = $d800 ; ram under i/o
|
soft80_vram = $d800 ; ram under i/o
|
||||||
soft80_colram = $d800 ; color ram (used for temp. storage)
|
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
|
soft80_bitmap = $e000
|
||||||
|
|
||||||
charsperline = 80
|
charsperline = 80
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
.export soft80_charset
|
.export soft80_charset
|
||||||
|
|
||||||
.rodata
|
.segment "INIT"
|
||||||
soft80_charset:
|
soft80_charset:
|
||||||
.byte $0f,$03,$0f,$00,$0f,$07,$05,$0e
|
.byte $0f,$03,$0f,$00,$0f,$07,$05,$0e
|
||||||
.byte $0f,$05,$0e,$0b,$0f,$0b,$0f,$0f
|
.byte $0f,$05,$0e,$0b,$0f,$0b,$0f,$0f
|
||||||
|
|
|
@ -17,6 +17,28 @@
|
||||||
.include "soft80.inc"
|
.include "soft80.inc"
|
||||||
|
|
||||||
soft80_init:
|
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
|
lda #$3b
|
||||||
sta VIC_CTRL1
|
sta VIC_CTRL1
|
||||||
lda #$00
|
lda #$00
|
||||||
|
@ -26,14 +48,28 @@ soft80_init:
|
||||||
lda #$c8
|
lda #$c8
|
||||||
sta VIC_CTRL2
|
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
|
; copy charset to RAM under I/O
|
||||||
; FIXME: move charset and this constructor into init segment
|
|
||||||
sei
|
sei
|
||||||
lda $01
|
lda $01
|
||||||
pha
|
pha
|
||||||
lda #$34
|
lda #$34
|
||||||
sta $01
|
sta $01
|
||||||
|
|
||||||
|
inc soft80_first_init
|
||||||
|
|
||||||
lda #>soft80_charset
|
lda #>soft80_charset
|
||||||
sta ptr1+1
|
sta ptr1+1
|
||||||
lda #<soft80_charset
|
lda #<soft80_charset
|
||||||
|
@ -66,45 +102,58 @@ soft80_init:
|
||||||
dex
|
dex
|
||||||
bne @l2
|
bne @l2
|
||||||
|
|
||||||
|
; copy the kplot tables to ram under I/O
|
||||||
|
;ldx #0 ; is 0
|
||||||
|
@l3:
|
||||||
|
lda soft80_tables_data_start,x
|
||||||
|
sta soft80_bitmapxlo,x
|
||||||
|
lda soft80_tables_data_start + (soft80_tables_data_end - soft80_tables_data_start - $100) ,x
|
||||||
|
sta soft80_bitmapxlo + (soft80_tables_data_end - soft80_tables_data_start - $100),x
|
||||||
|
inx
|
||||||
|
bne @l3
|
||||||
|
|
||||||
pla
|
pla
|
||||||
sta $01
|
sta $01
|
||||||
cli
|
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
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
jmp soft80_kclrscr
|
|
||||||
|
|
||||||
soft80_shutdown:
|
|
||||||
lda #$1b
|
|
||||||
sta VIC_CTRL1
|
|
||||||
lda #$03
|
|
||||||
sta CIA2_PRA
|
|
||||||
lda #$15
|
|
||||||
sta VIC_VIDEO_ADR
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; the following tables take up 267 bytes, used by kplot
|
||||||
|
soft80_tables_data_start:
|
||||||
|
|
||||||
|
soft80_bitmapxlo_data:
|
||||||
|
.repeat 80,col
|
||||||
|
.byte <((col/2)*8)
|
||||||
|
.endrepeat
|
||||||
|
soft80_bitmapxhi_data:
|
||||||
|
.repeat 80,col
|
||||||
|
.byte >((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
|
; 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
|
; be moved into a section other than .bss so they survive after the init
|
||||||
; code has been run.
|
; code has been run.
|
||||||
|
|
||||||
.bss
|
.data ; FIXME
|
||||||
soft80_internal_textcolor:
|
soft80_internal_textcolor:
|
||||||
.res 1
|
.res 1
|
||||||
soft80_internal_bgcolor:
|
soft80_internal_bgcolor:
|
||||||
|
@ -112,3 +161,6 @@ soft80_internal_bgcolor:
|
||||||
soft80_internal_cursorxlsb:
|
soft80_internal_cursorxlsb:
|
||||||
.res 1
|
.res 1
|
||||||
|
|
||||||
|
.data
|
||||||
|
soft80_first_init:
|
||||||
|
.byte 0 ; flag to check first init, this really must be in .data
|
||||||
|
|
|
@ -17,6 +17,12 @@ soft80_kplot:
|
||||||
stx CURS_Y
|
stx CURS_Y
|
||||||
sty CURS_X
|
sty CURS_X
|
||||||
|
|
||||||
|
sei
|
||||||
|
lda $01
|
||||||
|
pha
|
||||||
|
lda #$34 ; enable RAM under I/O
|
||||||
|
sta $01
|
||||||
|
|
||||||
; calc pointer to bitmap
|
; calc pointer to bitmap
|
||||||
lda soft80_bitmapylo,x
|
lda soft80_bitmapylo,x
|
||||||
clc
|
clc
|
||||||
|
@ -41,40 +47,15 @@ soft80_kplot:
|
||||||
adc soft80_vramhi,x
|
adc soft80_vramhi,x
|
||||||
sta CRAM_PTR+1
|
sta CRAM_PTR+1
|
||||||
|
|
||||||
|
pla
|
||||||
|
sta $01
|
||||||
|
cli
|
||||||
|
|
||||||
@getpos:
|
@getpos:
|
||||||
ldx CURS_Y
|
ldx CURS_Y
|
||||||
ldy CURS_X
|
ldy CURS_X
|
||||||
rts
|
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
|
; force the init constructor to be imported
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue