From 622e65929b8d8b4c03ee10fe9c8101dbf7e4afec Mon Sep 17 00:00:00 2001 From: 4am Date: Mon, 18 Oct 2021 16:13:05 -0400 Subject: [PATCH] move DrawPage inline --- src/constants.a | 6 +-- src/macros.a | 22 ++++----- src/ui.attract.dhgr.a | 1 + src/ui.credits.a | 106 +++++++++++++++++++++++++++--------------- src/ui.font.a | 9 +--- src/ui.font.lc2.a | 33 ------------- 6 files changed, 86 insertions(+), 91 deletions(-) diff --git a/src/constants.a b/src/constants.a index 49ebfbdde..b97259c81 100644 --- a/src/constants.a +++ b/src/constants.a @@ -7,7 +7,7 @@ ; ; LC RAM BANK 1 ; D000..E789 - persistent data structures (gGlobalPrefsStore, gGamesListStore) -; E979..FFF1 - main program code +; E95E..FFF1 - main program code ; FFF2..FFF9 - API functions and global constants available for main program ; code, prelaunchers, transition effects, &c. ; (Wait/UnwaitForVBL, MockingboardStuff, MachineStatus) @@ -16,8 +16,8 @@ ; LC RAM BANK 2 ; D000..D3FF - ProRWTS data ; D400..D66F - ProRWTS code -; D670..DB91 - HGR font code & ProRWTS glue code -; DB4D..DB5C - backup of stack (during gameplay and self-running demos) +; D670..DB2D - HGR font code & ProRWTS glue code +; DB2E..DB3D - backup of stack (during gameplay and self-running demos) ; ...unused... ; DBB4..DBFF - (de)acceleration function ; DC00..DFFF - HGR font data diff --git a/src/macros.a b/src/macros.a index e248259a5..d551d470c 100755 --- a/src/macros.a +++ b/src/macros.a @@ -209,35 +209,35 @@ ; various language card configurations !macro READ_RAM1_NO_WRITE { - bit $C088 + sta $C088 } !macro READ_RAM1_WRITE_RAM1 { - bit $C08B - bit $C08B + sta $C08B + sta $C08B } !macro READ_RAM2_NO_WRITE { - bit $C080 + sta $C080 } !macro READ_RAM2_WRITE_RAM2 { - bit $C083 - bit $C083 + sta $C083 + sta $C083 } !macro READ_ROM_WRITE_RAM1 { - bit $C089 - bit $C089 + sta $C089 + sta $C089 } !macro READ_ROM_WRITE_RAM2 { - bit $C081 - bit $C081 + sta $C081 + sta $C081 } !macro READ_ROM_NO_WRITE { - bit $C082 + sta $C082 } ; requires setting zpCharMask in zero page to #$FF or #$DF before use diff --git a/src/ui.attract.dhgr.a b/src/ui.attract.dhgr.a index 3e2c20d5c..89186f332 100644 --- a/src/ui.attract.dhgr.a +++ b/src/ui.attract.dhgr.a @@ -283,6 +283,7 @@ DrawGameTitleInActionSlideshow ldy gPathname sta gPathname,y +LDADDR gPathname + +ST16 PTR sec jsr DrawString @fallthroughForDHGR diff --git a/src/ui.credits.a b/src/ui.credits.a index 96102b7e5..34230aa07 100644 --- a/src/ui.credits.a +++ b/src/ui.credits.a @@ -4,46 +4,10 @@ ; credits page ; ; Public functions -; - Credits ; - Help +; - Credits ; -;------------------------------------------------------------------------------ -; Credits -; display credits page and wait -; -; in: none -; out: C clear -; all other flags and registers clobbered -;------------------------------------------------------------------------------ -Credits - jsr LoadFile ; load credits text into $8000 - !word kRootDirectory - !word kCreditsFile - !word $8000 -.clearAndDisplayHelp - jsr ForceHGRMode - jsr ClearOffscreen - ldx #0 -.displayHelp - lda OffscreenPage - ror ; draw on offscreen page - +LDADDR $8000 - jsr DrawPage ; draw credits - jsr ShowOtherPage ; show credits - jsr WaitForKeyFor30Seconds; wait - bit CLEARKBD ; don't care about key - cmp #$81 ; Ctrl-A = about - beq Credits - cmp #$90 ; Ctrl-P = launch joystick calibration program - bne + - jmp Joystick -+ cmp #$83 ; Ctrl-C = toggle cheat mode - bne + - jsr ToggleCheat -+ sec ; if called from search mode, tell caller to refresh - rts - ;------------------------------------------------------------------------------ ; Help ; display per-game or global help page and wait @@ -83,3 +47,71 @@ Help jsr LoadHelpOffscreen ; load fancy backdrop ldx #7 bne .displayHelp ; always branches + +;------------------------------------------------------------------------------ +; Credits +; display credits page and wait +; +; in: none +; out: C clear +; all other flags and registers clobbered +;------------------------------------------------------------------------------ +Credits + jsr LoadFile ; load credits text into $8000 + !word kRootDirectory + !word kCreditsFile + !word $8000 +.clearAndDisplayHelp + jsr ForceHGRMode + jsr ClearOffscreen + ldx #0 ; left margin (0 for credits, different for global help) +.displayHelp + lda OffscreenPage + ror ; draw on offscreen page + +LDADDR $8000 + +ST16 PTR +;DrawPageInternal inlined here +; +; PTR contains address of array of length-prefixed strings +; length #$FF terminates +; X contains 0-indexed left margin (HTAB) +; carry bit clear -> draw on page 1 +; carry bit set -> draw on page 2 +; drawing starts at VTAB 0 +; each line starts at column X which was passed in (0-indexed) +; clobbers $FF +; clobbers A/X/Y +; preserves C, other flags clobbered + stx $FF + ldx #0 + stx VTAB + php ; save C, but Z=1 because of ldx #0 +@drawLine + lda $FF + sta HTAB + jsr DrawString + bmi @donePage + clc + adc PTR + sta PTR + bcc + + inc PTR+1 ++ plp ; restore C to whatever it was on entry + php + beq @drawLine ; always branches +@donePage + plp +;end inline + jsr ShowOtherPage ; show credits + jsr WaitForKeyFor30Seconds; wait + bit CLEARKBD ; don't care about key + cmp #$81 ; Ctrl-A = about + beq Credits + cmp #$90 ; Ctrl-P = launch joystick calibration program + bne + + jmp Joystick ++ cmp #$83 ; Ctrl-C = toggle cheat mode + bne + + jsr ToggleCheat ++ sec ; if called from search mode, tell caller to refresh + rts diff --git a/src/ui.font.a b/src/ui.font.a index 7d902cdd1..8e78dc152 100644 --- a/src/ui.font.a +++ b/src/ui.font.a @@ -7,20 +7,15 @@ ; that live in LC RAM 2 now. ; ; Public functions -; - DrawPage ; - Draw40Chars ; - DrawCenteredString ; - DrawString ; DrawString - jsr StoreAYAndSwitchToBank2 + jsr SwitchToBank2 jsr DrawStringInternal - bne JmpSwitch ; always - -DrawPage - jsr StoreAYAndSwitchToBank2 - jsr DrawPageInternal + ; /!\ execution falls through here to JmpSwitch JmpSwitch jmp SwitchToBank1 diff --git a/src/ui.font.lc2.a b/src/ui.font.lc2.a index 40214eb48..5e4be86c6 100644 --- a/src/ui.font.lc2.a +++ b/src/ui.font.lc2.a @@ -8,39 +8,6 @@ ; which handle bank switching for you. ; -DrawPageInternal -; PTR contains address of array of length-prefixed strings -; length #$FF terminates -; X contains 0-indexed left margin (HTAB) -; carry bit clear -> draw on page 1 -; carry bit set -> draw on page 2 -; drawing starts at VTAB 0 -; each line starts at column X which was passed in (0-indexed) -; clobbers PTR -; clobbers $FF -; clobbers A/X/Y -; preserves C, other flags clobbered - stx $FF - ldx #0 - stx VTAB - php ; save C, but Z=1 because of ldx #0 -@drawLine - lda $FF - sta HTAB - jsr DrawStringInternal - bmi @donePage - clc - adc PTR - sta PTR - bcc + - inc PTR+1 -+ plp ; restore C to whatever it was on entry - php - beq @drawLine ; always branches -@donePage - plp - rts - Draw40CharsInternal ; A/Y contains address of character buffer ; carry bit clear -> draw on page 1