diff --git a/src/4cade.a b/src/4cade.a index 2202a2293..9cc62a58d 100644 --- a/src/4cade.a +++ b/src/4cade.a @@ -133,8 +133,6 @@ gGlobalPrefsStore ; which is apparently one of the acceptable values) gGamesListStore !word $FDFD ; SMC -StoreAYAndSwitchToBank2 - +ST16 PTR SwitchToBank2 +READ_RAM2_WRITE_RAM2 rts @@ -175,7 +173,6 @@ COPYSRC = * !pseudopc hdddataend { COPYDST = * !source "src/prodos.impl.lc2.a" - !source "src/ui.font.lc2.a" !source "src/glue.prorwts2.lc2.a" !source "src/glue.launch.lc2.a" !source "src/hw.accel.lc2.a" @@ -189,7 +186,7 @@ COPYSRC = * EvenLasterMover FONTSRC = * !pseudopc FONTDST { - !source "src/ui.font.data.lc2.a" + !source "src/ui.font.data.a" } !if RELBASE = $2000 { !ifdef PASS2 { diff --git a/src/constants.a b/src/constants.a index df7f4214a..cc7b0a07d 100644 --- a/src/constants.a +++ b/src/constants.a @@ -10,7 +10,7 @@ ; ...unused... ; E000..E3FF - HGR font data ; ...unused... -; EA23..FFEE - main program code +; E962..FFEE - main program code ; FFEF..FFF9 - API functions and global constants available for main program ; code, prelaunchers, transition effects, &c. ; (LoadFileDirect, Wait/UnwaitForVBL, MockingboardStuff, MachineStatus) @@ -19,8 +19,8 @@ ; LC RAM BANK 2 ; D000..D3FF - ProRWTS data ; D400..D6C3 - ProRWTS code -; D6C4..DB91 - HGR font code & ProRWTS glue code -; DB92..DB98 - backup of stack (during gameplay and self-running demos) +; D6C4..DAB8 - ProRWTS glue code +; DAB9..DABF - backup of stack (during gameplay and self-running demos) ; ...unused... ; DBB4..DBFF - (de)acceleration function ; DC00..DFFF - unused diff --git a/src/ui.credits.a b/src/ui.credits.a index 7f5f0ecc7..5c998dffa 100644 --- a/src/ui.credits.a +++ b/src/ui.credits.a @@ -70,7 +70,7 @@ Credits ror ; draw on offscreen page +LDADDR $800 +ST16 PTR -;DrawPageInternal inlined here +;DrawPage inlined here ; ; PTR contains address of array of length-prefixed strings ; length #$FF terminates @@ -86,11 +86,10 @@ Credits ldx #0 stx VTAB php ; save C, but Z=1 because of ldx #0 - jsr SwitchToBank2 @drawLine lda $FF sta HTAB - jsr DrawStringInternal + jsr DrawString_PTR_is_already_set bmi @donePage clc adc PTR @@ -101,7 +100,6 @@ Credits php beq @drawLine ; always branches @donePage - jsr SwitchToBank1 plp ;end inline jsr ShowOtherPage ; show credits diff --git a/src/ui.font.a b/src/ui.font.a index c0658692d..9670c0d6e 100644 --- a/src/ui.font.a +++ b/src/ui.font.a @@ -3,29 +3,162 @@ ; ; 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 ; - Draw40Chars ; - DrawCenteredString ; - DrawString ; -DrawString - jsr StoreAYAndSwitchToBank2 - jsr DrawStringInternal - ; /!\ execution falls through here to JmpSwitch - -JmpSwitch - jmp SwitchToBank1 - Draw40Chars - jsr SwitchToBank2 - jsr Draw40CharsInternal - beq JmpSwitch ; always +; A/Y contains address of character buffer +; carry bit clear -> draw on page 1 +; carry bit set -> draw on page 2 +; $25 contains textpage line (0..23) (this is the standard VTAB address) +; drawing starts at HTAB 0 +; increments VTAB on exit +; sets HTAB to 0 on exit +; Z=1 on exit +; clobbers A/X/Y + jsr + + ldx #40 + jsr .DrawBufferInternal ++ ldx #0 + stx HTAB + rts DrawCenteredString - jsr StoreAYAndSwitchToBank2 - jsr DrawCenteredStringInternal - bne JmpSwitch ; always +; A/Y contains address of length-prefixed string +; carry bit clear -> draw on page 1 +; carry bit set -> draw on page 2 +; $25 contains textpage line (0..23) (this is the standard VTAB address) +; clobbers A/X/Y + +ST16 PTR + php + ldy #0 + lda #40 + sec + sbc (PTR),y + lsr + sta HTAB + plp + jmp DrawString_PTR_is_already_set + +DrawString +; A/Y contains address of length-prefixed string +; length can be 0 +; carry bit clear -> draw on page 1 +; carry bit set -> draw on page 2 +; $24 contains starting column (0..39) (this is the standard HTAB address) +; $25 contains textpage line (0..23) (this is the standard VTAB address) +; clobbers A/X/Y + +ST16 PTR +DrawString_PTR_is_already_set + ldy #0 + lda (PTR),y + inc PTR + bne + + inc PTR+1 ++ tax + bpl + + rts ++ + +LD16 PTR + ; /!\ execution falls through here to .DrawBufferInternal + +.DrawBufferInternal +; [private] +; A/Y contains address of character buffer +; X contains buffer length (0..40) +; carry bit clear -> draw on page 1 +; carry bit set -> draw on page 2 +; characters MUST have high bit off (0x00..0x7F) +; special characters (0x00..0x1F) will be drawn +; $24 contains starting column (0..39) (this is the standard HTAB address) +; $25 contains textpage line (0..23) (this is the standard VTAB address) +; all characters are drawn on the same line +; HTAB is incremented for each character +; clobbers X,Y +; increments VTAB on exit +; A=buffer length on exit +; N=0,Z=0 on exit + +ST16 DBISrc+1 + php + lda VTAB + asl + asl + asl +; routine to calculate memory address within HGR page +; and self-modify addresses within draw loop that follows +; (routine clobbers A and Y but preserves X) + asl + tay + and #$F0 + bpl @calc1 + ora #$05 +@calc1 bcc @calc2 + ora #$0A +@calc2 asl + asl + sta @hgrlo+1 + tya + and #$0E + adc #$10 + asl @hgrlo+1 + rol + plp + bcc + + eor #$60 + clc ++ + sta DBIRow0+2 + adc #$04 + sta DBIRow1+2 + adc #$04 + sta DBIRow2+2 + adc #$04 + sta DBIRow3+2 + adc #$04 + sta DBIRow4+2 + adc #$04 + sta DBIRow5+2 + adc #$04 + sta DBIRow6+2 + adc #$04 + sta DBIRow7+2 +@hgrlo lda #$FD + adc HTAB + sta DBIRow0+1 + sta DBIRow1+1 + sta DBIRow2+1 + sta DBIRow3+1 + sta DBIRow4+1 + sta DBIRow5+1 + sta DBIRow6+1 + sta DBIRow7+1 + txa + pha + bpl + ; always branches because X is 0..40 +DBILoop +DBISrc ldy $FDFD,x + lda FontDataRow0,y +DBIRow0 sta $FDFD,x + lda FontDataRow1,y +DBIRow1 sta $FDFD,x + lda FontDataRow2,y +DBIRow2 sta $FDFD,x + lda FontDataRow3,y +DBIRow3 sta $FDFD,x + lda FontDataRow4,y +DBIRow4 sta $FDFD,x + lda FontDataRow5,y +DBIRow5 sta $FDFD,x + lda FontDataRow6,y +DBIRow6 sta $FDFD,x + lda FontDataRow7,y +DBIRow7 sta $FDFD,x + inc HTAB ++ dex + bpl DBILoop + pla ; A = buffer length (passed in in X) + inc VTAB + rts diff --git a/src/ui.font.data.lc2.a b/src/ui.font.data.a similarity index 100% rename from src/ui.font.data.lc2.a rename to src/ui.font.data.a diff --git a/src/ui.font.lc2.a b/src/ui.font.lc2.a deleted file mode 100644 index 5e4be86c6..000000000 --- a/src/ui.font.lc2.a +++ /dev/null @@ -1,159 +0,0 @@ -;license:MIT -;(c) 2018-2021 by 4am -; -; 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 ui.font -; which handle bank switching for you. -; - -Draw40CharsInternal -; A/Y contains address of character buffer -; carry bit clear -> draw on page 1 -; carry bit set -> draw on page 2 -; $25 contains textpage line (0..23) (this is the standard VTAB address) -; drawing starts at HTAB 0 -; increments VTAB on exit -; sets HTAB to 0 on exit -; Z=1 on exit -; clobbers A/X/Y - jsr + - ldx #40 - jsr DrawBufferInternal -+ ldx #0 - stx HTAB - rts - -DrawCenteredStringInternal -; PTR contains address of length-prefixed string -; carry bit clear -> draw on page 1 -; carry bit set -> draw on page 2 -; $25 contains textpage line (0..23) (this is the standard VTAB address) -; clobbers A/X/Y - php - ldy #0 - lda #40 - sec - sbc (PTR),y - lsr - sta HTAB - plp - ; /!\ execution falls through here to DrawStringInternal - -DrawStringInternal -; PTR contains address of length-prefixed string -; length can be 0 -; carry bit clear -> draw on page 1 -; carry bit set -> draw on page 2 -; $24 contains starting column (0..39) (this is the standard HTAB address) -; $25 contains textpage line (0..23) (this is the standard VTAB address) -; clobbers A/X/Y - ldy #0 - lda (PTR),y - inc PTR - bne + - inc PTR+1 -+ tax - bpl + - rts -+ - +LD16 PTR - ; /!\ execution falls through here to DrawBufferInternal - -DrawBufferInternal -; A/Y contains address of character buffer -; X contains buffer length (0..40) -; carry bit clear -> draw on page 1 -; carry bit set -> draw on page 2 -; characters MUST have high bit off (0x00..0x7F) -; special characters (0x00..0x1F) will be drawn -; $24 contains starting column (0..39) (this is the standard HTAB address) -; $25 contains textpage line (0..23) (this is the standard VTAB address) -; all characters are drawn on the same line -; HTAB is incremented for each character -; clobbers X,Y -; increments VTAB on exit -; A=buffer length on exit -; N=0,Z=0 on exit - +ST16 DBISrc+1 - php - lda VTAB - asl - asl - asl -; routine to calculate memory address within HGR page -; and self-modify addresses within draw loop that follows -; (routine clobbers A and Y but preserves X) - asl - tay - and #$F0 - bpl @calc1 - ora #$05 -@calc1 bcc @calc2 - ora #$0A -@calc2 asl - asl - sta @hgrlo+1 - tya - and #$0E - adc #$10 - asl @hgrlo+1 - rol - plp - bcc + - eor #$60 - clc -+ - sta DBIRow0+2 - adc #$04 - sta DBIRow1+2 - adc #$04 - sta DBIRow2+2 - adc #$04 - sta DBIRow3+2 - adc #$04 - sta DBIRow4+2 - adc #$04 - sta DBIRow5+2 - adc #$04 - sta DBIRow6+2 - adc #$04 - sta DBIRow7+2 -@hgrlo lda #$FD - adc HTAB - sta DBIRow0+1 - sta DBIRow1+1 - sta DBIRow2+1 - sta DBIRow3+1 - sta DBIRow4+1 - sta DBIRow5+1 - sta DBIRow6+1 - sta DBIRow7+1 - txa - pha - bpl + ; always branches because X is 0..40 -DBILoop -DBISrc ldy $FDFD,x - lda FontDataRow0,y -DBIRow0 sta $FDFD,x - lda FontDataRow1,y -DBIRow1 sta $FDFD,x - lda FontDataRow2,y -DBIRow2 sta $FDFD,x - lda FontDataRow3,y -DBIRow3 sta $FDFD,x - lda FontDataRow4,y -DBIRow4 sta $FDFD,x - lda FontDataRow5,y -DBIRow5 sta $FDFD,x - lda FontDataRow6,y -DBIRow6 sta $FDFD,x - lda FontDataRow7,y -DBIRow7 sta $FDFD,x - inc HTAB -+ dex - bpl DBILoop - pla ; A = buffer length (passed in in X) - inc VTAB - rts