diff --git a/res/text/stationfall.txt b/res/text/stationfall.txt index 98bbabe..cfe92f0 100644 --- a/res/text/stationfall.txt +++ b/res/text/stationfall.txt @@ -13,7 +13,7 @@ only meant that your dull life of cleaning grotch cages was replaced by an equally dull life of paperwork. Now you've got another assignment tailor- made for a grotchbrain: pilot a spacetruck to a nearby station to pick up a - load of trivial forms. Trot and doublt trot! + load of trivial forms. Trot and double trot! But all is not lost. By a happy twist of fate, your companion for the journey is your old pal Floyd! That's right, it's the same mischievous diff --git a/src/launch.a b/src/launch.a index 4adb127..f337fa8 100644 --- a/src/launch.a +++ b/src/launch.a @@ -86,8 +86,7 @@ LaunchInterpreter ; change prefix to folder of file we want the interpreter to open jsr ResetPath - lda #kGameRootDirectory + +LDADDR kGameRootDirectory jsr AddToPath jsr okvs_get @@ -122,8 +121,7 @@ LaunchInterpreter LoadInterpreter jsr ResetPath - lda #<.interpreterFilename - ldy #>.interpreterFilename + +LDADDR .interpreterFilename jsr AddToPath jsr LoadFile diff --git a/src/macros.a b/src/macros.a index b759f5c..bfe3ed4 100644 --- a/src/macros.a +++ b/src/macros.a @@ -13,3 +13,18 @@ PARAM = $00 + phx pha } + +!macro LDADDR .ptr { + lda #<.ptr + ldy #>.ptr +} + +!macro LDAY .ptr { + lda .ptr + ldy .ptr+1 +} + +!macro STAY .ptr { + sta .ptr + sty .ptr+1 +} diff --git a/src/okvs.a b/src/okvs.a index 8dcae2c..a8ff009 100644 --- a/src/okvs.a +++ b/src/okvs.a @@ -249,8 +249,7 @@ okvs_get .matchlen=*+1 cpy #$FD ; SMC bne .matchKeyLoop - lda PTR - ldy PTR+1 + +LDAY PTR clc adc .matchlen bcc + @@ -298,8 +297,7 @@ okvs_nth .done jsr incptr jsr incptr - lda PTR - ldy PTR+1 + +LDAY PTR rts ;------------------------------------------------------------------------------ @@ -335,8 +333,7 @@ okvs_update !word $FDFD ; SMC !word $FDFD ; SMC bcs .exit - sta DEST - sty DEST+1 + +STAY DEST lda (SAVE) tay - lda (SAVE),y @@ -357,8 +354,7 @@ okvs_update ; X preserved, A/Y clobbered ;------------------------------------------------------------------------------ okvs_as_boolean - sta PTR - sty PTR+1 + +STAY PTR lda (PTR) cmp #1 bne + diff --git a/src/parse.common.a b/src/parse.common.a index 9f3e126..de7495f 100644 --- a/src/parse.common.a +++ b/src/parse.common.a @@ -24,12 +24,12 @@ ParseKeyValueText ldy #1 lda (PARAM),y - sta .initStore - sta .appendStore + sta .store1 + sta .store2 iny lda (PARAM),y - sta .initStore+1 - sta .appendStore+1 + sta .store1+1 + sta .store2+1 iny lda (PARAM),y sta $FE @@ -53,8 +53,7 @@ ParseKeyValueText dey + sty $FF jsr okvs_init ; reset key/value store -.initStore - !word $FDFD ; SMC +.store1 !word $FDFD ; SMC ldy #$00 ; index into ($FE) pointing to current character .newKey @@ -69,7 +68,7 @@ ParseKeyValueText cmp #$0D ; found CR before '=', ignore key and start over (also handles blank lines) beq .newKey cmp #$5B ; '[' ends the parsing - beq .exit + beq .done sta gKey,x inx bpl .gatherKey @@ -99,8 +98,7 @@ ParseKeyValueText sta .appendMaxLength ; all other values get upgraded to max_length so we can update them in place phy ; okvs functions clobber everything but we need Y jsr okvs_append -.appendStore - !word $FDFD ; SMC +.store2 !word $FDFD ; SMC !word gKeyLen !word gValLen .appendMaxLength @@ -119,5 +117,5 @@ IncAndGetChar bne + inc $FF + lda ($FE),y -.exit rts +.done rts } diff --git a/src/parse.gameinfo.a b/src/parse.gameinfo.a index 51d9d94..9cf9830 100644 --- a/src/parse.gameinfo.a +++ b/src/parse.gameinfo.a @@ -43,8 +43,7 @@ addrInfo ;------------------------------------------------------------------------------ LoadGameInfo jsr ResetPath - lda #kTextRootDirectory + +LDADDR kTextRootDirectory jsr AddToPath jsr okvs_get !word gGlobalPrefsStore @@ -115,10 +114,8 @@ LoadGameInfo !word addrVersions !byte 0 - lda SRC ; save pointer to free space for next store - sta gOptionsStore - lda SRC+1 - sta gOptionsStore+1 + +LDAY SRC + +STAY gOptionsStore ; save pointer to free space for next store jsr ParseKeyValueText ; parse [options] section into gOptionsStore !word gOptionsStore diff --git a/src/parse.gamelist.a b/src/parse.gamelist.a index 71b2c1d..b57e824 100644 --- a/src/parse.gamelist.a +++ b/src/parse.gamelist.a @@ -19,14 +19,13 @@ LoadGameList jsr LoadFile ; load prefs file at $2000 !word .gamesListFilename -.listAddress - !word $2000 +.handle !word $2000 !word $2000 !word kProDOSFileBuffer jsr ParseKeyValueText ; parse contents into games list store !word gGamesListStore - !word .listAddress + !word .handle !byte 0 lda SRC ; save pointer to free space for next store diff --git a/src/parse.prefs.a b/src/parse.prefs.a index bf57f22..6766d8c 100644 --- a/src/parse.prefs.a +++ b/src/parse.prefs.a @@ -53,21 +53,18 @@ LoadGlobalPreferences jsr LoadFile ; load prefs file at $2000 !word .globalPrefsFilename -.prefsAddress - !word $2000 +.handle !word $2000 !word $2000 !word kProDOSFileBuffer jsr ParseKeyValueText ; parse contents into global prefs store !word gGlobalPrefsStore - !word .prefsAddress + !word .handle !byte 16 - lda SRC ; save pointer to free space for next store - sta gVersionsStore - lda SRC+1 - sta gVersionsStore+1 - rts + +LDAY SRC + +STAY gVersionsStore ; save pointer to free space for next store +.exit rts ;------------------------------------------------------------------------------ ; SaveGlobalPreferences @@ -77,15 +74,12 @@ LoadGlobalPreferences ;------------------------------------------------------------------------------ SaveGlobalPreferences lda gNeedToSavePrefs - bne + - rts -+ + beq .exit stz $FE lda #$20 sta $FF - lda #<.fluff1 - ldy #>.fluff1 + +LDADDR .fluff1 jsr addString jsr addBooleanFromStore @@ -100,15 +94,13 @@ SaveGlobalPreferences jsr addBooleanFromStore !word kAutoScript - lda #<.fluff2 - ldy #>.fluff2 + +LDADDR .fluff2 jsr addString jsr addStringFromStore !word kLastPlayed - lda #<.fluff3 - ldy #>.fluff3 + +LDADDR .fluff3 jsr addString jsr okvs_len @@ -117,41 +109,38 @@ SaveGlobalPreferences ldx #0 .gameLoop phx - stx .n + stx + jsr okvs_nth !word gGamesListStore -.n !byte $FD ; SMC - sta .gameKey - sty .gameKey+1 ++ !byte $FD ; SMC + +STAY + jsr addStringFromStore -.gameKey !word $FDFD ; SMC ++ !word $FDFD ; SMC plx inx .numberOfGames=*+1 cpx #$FD ; SMC bne .gameLoop - lda #<.eof - ldy #>.eof + +LDADDR .eof jsr addString lda $FE - sta .prefslen + sta .filelen lda $FF sec sbc #$20 - sta .prefslen+1 + sta .filelen+1 jsr SaveFile !word .globalPrefsFilename !byte 4 ; filetype=TXT !word 0 ; auxtype=0000 !word $2000 -.prefslen - !word $FDFD ; SMC +.filelen !word $FDFD ; SMC !word kProDOSFileBuffer - stz gNeedToSavePrefs + stz gNeedToSavePrefs rts addBooleanFromStore @@ -163,39 +152,33 @@ addStringFromStore +PARAMS_ON_STACK 2 ldy #1 lda (PARAM),y - sta .storeKey + sta .key pha iny lda (PARAM),y - sta .storeKey+1 + sta .key+1 tay pla jsr addString - lda #<.equals - ldy #>.equals + +LDADDR .equals jsr addString jsr okvs_get !word gGlobalPrefsStore -.storeKey - !word $FDFD ; SMC +.key !word $FDFD ; SMC .skipOverBooleanLogic bra + ; SMC (opcode may become BIT) - sta PTR - sty PTR+1 + +STAY PTR ldy #1 lda (PTR),y ora #$30 sta (PTR),y - lda PTR - ldy PTR+1 + +LDAY PTR + jsr addString - lda #<.lf - ldy #>.lf + +LDADDR .lf jmp addString addString - sta $00 - sty $01 + +STAY $00 lda ($00) inc sta .len diff --git a/src/path.a b/src/path.a index ec63034..0592265 100644 --- a/src/path.a +++ b/src/path.a @@ -35,8 +35,7 @@ ResetPath ;------------------------------------------------------------------------------ !zone { AddToPath - sta $00 - sty $01 + +STAY $00 ldx gPathname ; current pathname length lda ($00) ; length of this segment inc @@ -64,8 +63,7 @@ AddToPath ;------------------------------------------------------------------------------ !zone { SetStartupPath - sta $00 - sty $01 + +STAY $00 lda ($00) tay - lda ($00),y diff --git a/src/pitchdark.a b/src/pitchdark.a index dc4035a..a73caa4 100644 --- a/src/pitchdark.a +++ b/src/pitchdark.a @@ -1,5 +1,12 @@ ;license:MIT ;(c) 2018 by 4am +; +; Public entry points +; - MainScreen + +; Public functions +; - ExitWeeGUI +; !cpu 65c02 !ct "src/lcase.ct" @@ -42,7 +49,7 @@ Start jsr ClearInterpreterOptions ; clear options struct at $300 jsr WGInit ; initialize WeeGUI jsr LoadGameList ; get master list of games - jsr LoadGlobalPreferences ; get current game and global options + jsr LoadGlobalPreferences ; get global options, including current game jsr LoadGameInfo ; get current game description and game-specific options ldx #WGEnableMouse ; enable mouse support jsr WeeGUI @@ -58,11 +65,11 @@ MainScreen bit $C010 ; clear keyboard strobe .runLoop ldx #WGPendingViewAction - jsr WeeGUI + jsr WeeGUI ; handle mouse movement and clicks lda $c000 bpl .runLoop bit $c010 - jsr HandleKey + jsr HandleKey ; handle keypresses bra .runLoop ExitWeeGUI @@ -72,4 +79,4 @@ ExitWeeGUI jmp WeeGUI gGamesListStore - !word *+2 ; address first okvs store + !word *+2 ; address of first okvs store diff --git a/src/ui.common.a b/src/ui.common.a index 5e80d13..bb291ef 100644 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -64,10 +64,8 @@ CreateButton ;------------------------------------------------------------------------------ CreateTitleView ldx #WGCreateView ; create title bar on top line - lda #viewTitle - sta PARAM1 + +LDADDR viewTitle + +STAY PARAM0 jmp WeeGUI ;------------------------------------------------------------------------------ @@ -84,10 +82,8 @@ PaintTitleView jsr WeeGUI jsr INVERSE ldx #WGPrint - lda #<.stringTitle - sta PARAM0 - lda #>.stringTitle - sta PARAM1 + +LDADDR .stringTitle + +STAY PARAM0 jsr WeeGUI jmp NORMAL diff --git a/src/ui.main.a b/src/ui.main.a index de6b93b..8176981 100644 --- a/src/ui.main.a +++ b/src/ui.main.a @@ -37,10 +37,8 @@ CreateViews jsr CreateTitleView ldx #WGCreateView ; create horizontal rule - lda #<.viewHR - sta PARAM0 - lda #>.viewHR - sta PARAM1 + +LDADDR .viewHR + +STAY PARAM0 jsr WeeGUI jsr CreateButton ; create various buttons @@ -59,29 +57,21 @@ CreateViews !word .viewOptions ldx #WGCreateView ; create borderless frame for game title and info - lda #<.viewInfo - sta PARAM0 - lda #>.viewInfo - sta PARAM1 + +LDADDR .viewInfo + +STAY PARAM0 jsr WeeGUI ldx #WGViewSetAction - lda #paintInfoView - sta PARAM1 + +LDADDR paintInfoView + +STAY PARAM0 jsr WeeGUI ldx #WGCreateView ; create scrollable frame for game description text - lda #<.viewDescription - sta PARAM0 - lda #>.viewDescription - sta PARAM1 + +LDADDR .viewDescription + +STAY PARAM0 jsr WeeGUI ldx #WGViewSetAction - lda #paintDescriptionView - sta PARAM1 + +LDADDR paintDescriptionView + +STAY PARAM0 jmp WeeGUI ;------------------------------------------------------------------------------ @@ -138,8 +128,7 @@ paintDescriptionView ldx #WGSelectView lda #ID_DESCRIPTION jsr WeeGUI - lda addrDescription - ldy addrDescription+1 + +LDAY addrDescription ldx #78 jsr multiPrint lda .vtab+1 @@ -153,8 +142,7 @@ paintInfoView ldx #WGSelectView lda #ID_INFO jsr WeeGUI - lda addrInfo - ldy addrInfo+1 + +LDAY addrInfo ldx #65 phx jsr multiPrint @@ -169,20 +157,15 @@ paintInfoView jsr okvs_get ; get shortname of current game !word gGlobalPrefsStore !word kLastPlayed - sta .key1 - sty .key1+1 - + +STAY + jsr okvs_get ; get selected version of this game !word gGlobalPrefsStore -.key1 !word $FDFD ; SMC - sta .key2 - sty .key2+1 - ++ !word $FDFD ; SMC + +STAY + jsr okvs_get ; get long description of this version !word gVersionsStore -.key2 !word $FDFD ; SMC - sta SRC - sty SRC+1 ++ !word $FDFD ; SMC + +STAY SRC lda (SRC) tay - lda (SRC),y @@ -195,8 +178,7 @@ paintInfoView jmp .printLoop multiPrint - sta $00 - sty $01 + +STAY $00 stx .printLineLength+1 stz .htab+1 stz .vtab+1 diff --git a/src/ui.main.keys.a b/src/ui.main.keys.a index 7a4fd13..d90aa6d 100644 --- a/src/ui.main.keys.a +++ b/src/ui.main.keys.a @@ -11,10 +11,10 @@ ; !zone { -kGameRootDirectory ; length-prefixed pathname of where game subdirectories are stored +kGameRootDirectory ; length-prefixed pathname of game subdirectories !byte 2 !raw "Z/" -kHintsRootDirectory ; length-prefixed pathname of where game subdirectories are stored +kHintsRootDirectory ; length-prefixed pathname of hint files !byte 5 !raw "PRIZM/" kArtworkRootDirectory ; length-prefixed pathname of DHGR box art @@ -69,17 +69,17 @@ HandleKey dex dex bpl - - jmp SoftBell + jmp SoftBell ; unknown key, beep softly .foundKey - lda .keys+1,x - bpl .activateView - cmp #ID_X - beq .x + lda .keys+1,x ; get ID associated with this key + bpl .activateView ; ID < #$80 is a WeeGUI view, so activate it + cmp #ID_X ; X, Y, and Z keys are part of + beq .x ; an undocumented feature cmp #ID_Y beq .y cmp #ID_Z beq .z - cmp #ID_SCROLLDOWN + cmp #ID_SCROLLDOWN ; arrow keys scroll the description box beq .handleScrollDown .handleScrollUp lda #$01 @@ -87,7 +87,6 @@ HandleKey .handleScrollDown lda #$FF pha -.handleScroll ldx #WGSelectView lda #ID_DESCRIPTION jsr WeeGUI @@ -143,15 +142,13 @@ HandleKey jsr WeeGUI jsr SaveGlobalPreferences jsr ResetPath - lda #kArtworkRootDirectory + +LDADDR kArtworkRootDirectory jsr AddToPath jsr SetPrefix !word gPathname bcs .xyzzyError jsr ResetPath - lda #<.dhrslideFilename - ldy #>.dhrslideFilename + +LDADDR .dhrslideFilename jsr AddToPath jsr LoadFile !word gPathname @@ -166,7 +163,6 @@ HandleKey .dhrslideFilename !byte 15 !raw "DHRSLIDE.SYSTEM" - } !zone { @@ -174,12 +170,10 @@ GetCurrentGameIndex jsr okvs_get ; get shortname of current game !word gGlobalPrefsStore !word kLastPlayed - sta .gameNamePtr - sty .gameNamePtr+1 + +STAY + jsr okvs_get ; get numeric index !word gGamesListStore -.gameNamePtr - !word $FDFD ; SMC ++ !word $FDFD ; SMC rts ; X = index of current game callback_previous @@ -191,6 +185,7 @@ callback_previous tax dex + bra .loadNewGameInfoAndRepaint + callback_next jsr GetCurrentGameIndex inx @@ -203,16 +198,15 @@ callback_next bne .loadNewGameInfoAndRepaint ldx #0 .loadNewGameInfoAndRepaint - stx .nth + stx + jsr okvs_nth !word gGamesListStore -.nth !byte $FD ; SMC - sta .gameptr - sty .gameptr+1 ++ !byte $FD ; SMC + +STAY + jsr okvs_update !word gGlobalPrefsStore !word kLastPlayed -.gameptr !word $FDFD ; SMC ++ !word $FDFD ; SMC lda #1 sta gNeedToSavePrefs jsr LoadGameInfo @@ -228,8 +222,7 @@ callback_options !zone { callback_boxart jsr ResetPath - lda #kArtworkRootDirectory + +LDADDR kArtworkRootDirectory jsr AddToPath jsr okvs_get !word gGlobalPrefsStore @@ -277,8 +270,7 @@ callback_clues bcs .cluesError ; change prefix to folder of file we want the interpreter to open jsr ResetPath - lda #kHintsRootDirectory + +LDADDR kHintsRootDirectory jsr AddToPath jsr SetPrefix !word gPathname diff --git a/src/ui.options.a b/src/ui.options.a index 6c14e31..af03d7b 100644 --- a/src/ui.options.a +++ b/src/ui.options.a @@ -53,16 +53,12 @@ OptionsDialog jsr CreateTitleView ; create title bar (defined in paintcommon.a) ldx #WGCreateView ; create frame - lda #<.viewFrame - sta PARAM0 - lda #>.viewFrame - sta PARAM1 + +LDADDR .viewFrame + +STAY PARAM0 jsr WeeGUI ldx #WGViewSetTitle - lda #<.stringFrame - sta PARAM0 - lda #>.stringFrame - sta PARAM1 + +LDADDR .stringFrame + +STAY PARAM0 jsr WeeGUI jsr CreateButton ; create UI controls @@ -110,10 +106,8 @@ OptionsDialog sta PARAM1 jsr WeeGUI ldx #WGPrint - lda #<.stringForce40Description - sta PARAM0 - lda #>.stringForce40Description - sta PARAM1 + +LDADDR .stringForce40Description + +STAY PARAM0 jsr WeeGUI ldx #WGSetCursor @@ -123,10 +117,8 @@ OptionsDialog sta PARAM1 jsr WeeGUI ldx #WGPrint - lda #<.stringForceUpperDescription - sta PARAM0 - lda #>.stringForceUpperDescription - sta PARAM1 + +LDADDR .stringForceUpperDescription + +STAY PARAM0 jsr WeeGUI ldx #WGSetCursor @@ -136,10 +128,8 @@ OptionsDialog sta PARAM1 jsr WeeGUI ldx #WGPrint - lda #<.stringScriptToFileDescription - sta PARAM0 - lda #>.stringScriptToFileDescription - sta PARAM1 + +LDADDR .stringScriptToFileDescription + +STAY PARAM0 jsr WeeGUI ldx #WGSetCursor @@ -149,10 +139,8 @@ OptionsDialog sta PARAM1 jsr WeeGUI ldx #WGPrint - lda #<.stringAutoScriptDescription - sta PARAM0 - lda #>.stringAutoScriptDescription - sta PARAM1 + +LDADDR .stringAutoScriptDescription + +STAY PARAM0 jsr WeeGUI .runLoop