move font drawing routines to LC RAM 2

This commit is contained in:
4am 2019-09-10 14:21:23 -04:00
parent 27ec2ebd4e
commit 912d4d892a
4 changed files with 58 additions and 15 deletions

View File

@ -80,7 +80,7 @@ RestoreStackNextTime
!source "src/textrank.a" !source "src/textrank.a"
!source "src/parse.common.a" !source "src/parse.common.a"
!source "src/parse.prefs.a" !source "src/parse.prefs.a"
!source "src/ui.font.a" !source "src/glue.font.a"
; add new files above here so ui.common stays last ; add new files above here so ui.common stays last
!source "src/ui.common.a" !source "src/ui.common.a"
MachineStatus MachineStatus
@ -104,9 +104,12 @@ gGamesListStore
LastMover LastMover
!pseudopc $D600 { !pseudopc $D600 {
!source "src/ui.font.data.a" !source "src/ui.font.data.a"
!source "src/ui.font.a"
!source "src/prodos.impl.a" !source "src/prodos.impl.a"
!if * > $DEFF { !if * > $DEFF {
!error "code is too large: ends at ", * !error "code is too large: ends at ", *
; } else {
; !warn "LCRAM2 ends at ", *
} }
} }
EvenLasterMover EvenLasterMover

View File

@ -16,8 +16,8 @@
; D000..D3FF - ProRWTS data ; D000..D3FF - ProRWTS data
; D400..D5FF - ProRWTS code ; D400..D5FF - ProRWTS code
; D600..D9FF - HGR font data ; D600..D9FF - HGR font data
; DA00..DD5C - ProRWTS glue code ; DA00..DEE6 - ProRWTS glue code
; DD5D..DFEF - unused ; DEE7..DFEF - unused
; DFF0..DFFF - backup of stack (during gameplay and self-running demos) ; DFF0..DFFF - backup of stack (during gameplay and self-running demos)
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------

38
src/glue.font.a Normal file
View File

@ -0,0 +1,38 @@
;license:MIT
;(c) 2018-9 by 4am
;
; hi-res font drawing routines
;
; Glue functions that handle bank switching and calling the real font drawing routines
; that live in LC RAM 2 now.
;
; Public functions
; - DrawPage
; - Draw40Chars
; - DrawString
; - DrawBuffer
;
DrawPage
+READ_RAM2_WRITE_RAM2
jsr DrawPageInternal
+READ_RAM1_WRITE_RAM1
rts
Draw40Chars
+READ_RAM2_WRITE_RAM2
jsr Draw40CharsInternal
+READ_RAM1_WRITE_RAM1
rts
DrawString
+READ_RAM2_WRITE_RAM2
jsr DrawStringInternal
+READ_RAM1_WRITE_RAM1
rts
DrawBuffer
+READ_RAM2_WRITE_RAM2
jsr DrawBufferInternal
+READ_RAM1_WRITE_RAM1
rts

View File

@ -3,14 +3,18 @@
; ;
; hi-res font drawing routines ; hi-res font drawing routines
; ;
; /!\ These live in LC RAM 2 and rely on the font data which is also in LC RAM 2. /!\
; Code in LC RAM 1 (which is most program code) should call the functions in glue.font
; which handle bank switching for you.
;
; Public functions ; Public functions
; - DrawPage ; - DrawPageInternal
; - Draw40Chars ; - Draw40CharsInternal
; - DrawString ; - DrawStringInternal
; - DrawBuffer ; - DrawBufferInternal
; ;
DrawPage DrawPageInternal
; A/Y contains address of character buffer ; A/Y contains address of character buffer
; carry bit clear -> draw on page 1 ; carry bit clear -> draw on page 1
; carry bit set -> draw on page 2 ; carry bit set -> draw on page 2
@ -51,7 +55,7 @@ DrawPage
+LDAY PTR +LDAY PTR
plp plp
php php
jsr DrawBuffer jsr DrawBufferInternal
@skip inc SAVE ; skip carriage return @skip inc SAVE ; skip carriage return
lda SAVE ; advance PTR to start of next line lda SAVE ; advance PTR to start of next line
clc clc
@ -65,7 +69,7 @@ DrawPage
plp plp
rts rts
Draw40Chars Draw40CharsInternal
; A/Y contains address of character buffer ; A/Y contains address of character buffer
; carry bit clear -> draw on page 1 ; carry bit clear -> draw on page 1
; carry bit set -> draw on page 2 ; carry bit set -> draw on page 2
@ -76,13 +80,13 @@ Draw40Chars
; clobbers A/X/Y ; clobbers A/X/Y
jsr + jsr +
ldx #40 ldx #40
jsr DrawBuffer jsr DrawBufferInternal
inc VTAB inc VTAB
+ ldx #0 + ldx #0
stx HTAB stx HTAB
rts rts
DrawString DrawStringInternal
; A/Y contains address of length-prefixed string ; A/Y contains address of length-prefixed string
; carry bit clear -> draw on page 1 ; carry bit clear -> draw on page 1
; carry bit set -> draw on page 2 ; carry bit set -> draw on page 2
@ -102,7 +106,7 @@ DrawString
+LDAY PTR +LDAY PTR
; note: execution falls through here ; note: execution falls through here
DrawBuffer DrawBufferInternal
; A/Y contains address of character buffer ; A/Y contains address of character buffer
; X contains buffer length (1..40) ; X contains buffer length (1..40)
; carry bit clear -> draw on page 1 ; carry bit clear -> draw on page 1
@ -174,7 +178,6 @@ DrawBuffer
sta @row5+1 sta @row5+1
sta @row6+1 sta @row6+1
sta @row7+1 sta @row7+1
+READ_RAM2_WRITE_RAM2
@loop @loop
@src ldy $FDFD,x @src ldy $FDFD,x
lda FontDataRow0,y lda FontDataRow0,y
@ -196,5 +199,4 @@ DrawBuffer
inc HTAB inc HTAB
dex dex
bpl @loop bpl @loop
+READ_RAM1_WRITE_RAM1
rts rts