From 9c15769c3a9dace1c9a6bd0d5f0545c706bab9e3 Mon Sep 17 00:00:00 2001 From: 4am Date: Thu, 19 Apr 2018 10:05:48 -0400 Subject: [PATCH] use cheap local labels (requires ACME 0.96.3 or later) --- src/constants.a | 2 + src/glue.zinfo.a | 12 +++--- src/okvs.a | 88 +++++++++++++++++++++----------------------- src/parse.common.a | 66 +++++++++++++++++++-------------- src/parse.gameinfo.a | 36 +++++++++--------- src/parse.prefs.a | 46 +++++++++++------------ src/pitchdark.init.a | 15 ++++---- src/prodos.mli.a | 56 ++++++++++++++-------------- src/prodos.path.a | 8 ++-- src/ui.common.a | 26 ++++++------- src/ui.main.a | 47 +++++++++++------------ src/ui.main.keys.a | 81 +++++++++++++++++++--------------------- src/ui.options.a | 30 +++++++-------- src/ui.resume.a | 13 ++++--- src/ui.sound.a | 3 -- src/ui.versions.a | 37 +++++++++---------- 16 files changed, 279 insertions(+), 287 deletions(-) diff --git a/src/constants.a b/src/constants.a index 4c522e4..06c11a4 100644 --- a/src/constants.a +++ b/src/constants.a @@ -34,6 +34,8 @@ NODEV = $BF10 ; means 'no device connected' RAM32 = $BF26 ; S3,D2 /RAM device DEVCNT = $BF31 ; ProDOS device count DEVLST = $BF32 ; ProDOS device list +SPEAKER = $C030 ; used by SoftBell +WAIT = $FCA8 MAGICRTS = $FF58 ; used to set overflow bit ; zero page diff --git a/src/glue.zinfo.a b/src/glue.zinfo.a index 679e161..efa6830 100644 --- a/src/glue.zinfo.a +++ b/src/glue.zinfo.a @@ -50,14 +50,14 @@ LoadSavedGameInfo +LDADDR zinfo_base +STAY ZPTR ldx #0 -.zParseLoop +@zParseLoop +LDAY ZPTR pha phy phx jsr ResetPath lda (ZPTR) - beq .saveAndMoveToNextSlot; no saved game in this slot + beq @saveAndMoveToNextSlot; no saved game in this slot inc gSavedGamesSlotsInUse ; update number of slots in use (separate from length of store) +LDAY ZPTR jsr AddToPathWithHighBit ; add location information @@ -71,7 +71,7 @@ LoadSavedGameInfo +LDADDR kLeftParen jsr AddToPathWithHighBit ; add ' (' lda (ZPTR) - bne .justTime + bne @justTime lda ZPTR clc adc #(score_offset-time_offset) @@ -91,7 +91,7 @@ LoadSavedGameInfo inc ZPTR+1 + ; A/Y -> ZINFO moves field (length-prefixed string, guaranteed non-empty) ; execution falls through here -.justTime +@justTime +LDAY ZPTR jsr AddToPathWithHighBit ; add final piece of information (moves or time, depending on how we got here) +LDADDR kRightParen @@ -99,7 +99,7 @@ LoadSavedGameInfo +LDADDR kNullByte jsr AddToPath ; add 0x00 ; execution falls through here -.saveAndMoveToNextSlot +@saveAndMoveToNextSlot plx phx txa @@ -130,7 +130,7 @@ LoadSavedGameInfo inx cpx #zinfo_maxslots bcs + - jmp .zParseLoop + jmp @zParseLoop + rts kZINFOFilename diff --git a/src/okvs.a b/src/okvs.a index a6c4a88..3f7dd0f 100644 --- a/src/okvs.a +++ b/src/okvs.a @@ -130,7 +130,7 @@ okvs_append +STAY SRC ; SRC -> new key to copy lda (SRC) inc - sta .append_keylen + sta @keylen tay - dey ; copy new key lda (SRC),y @@ -140,7 +140,7 @@ okvs_append lda PTR ; update PTR to byte after copied key clc -.append_keylen=*+1 +@keylen=*+1 adc #$FD ; SMC sta PTR bcc + @@ -153,7 +153,7 @@ okvs_append bne + lda (SRC) ; no max, use actual length instead inc -+ sta .append_valuelen ++ sta @valuelen tay - dey lda (SRC),y @@ -163,7 +163,7 @@ okvs_append lda PTR clc -.append_valuelen=*+1 +@valuelen=*+1 adc #$FD ; SMC sta SRC bcc + @@ -198,18 +198,18 @@ okvs_get +PARAMS_ON_STACK 4 jsr SetPTRFromStackParams lda (PTR) - beq .get_fail ; no keys, fail immediately + beq @fail ; no keys, fail immediately tax ; X = number of keys inx - stx .get_maxkeys + stx @maxkeys ldx #0 jsr incptr ; PTR -> first record +LDPARAM 3 +STAY SRC ; SRC -> key we want to find lda (SRC) inc - sta .get_matchlen -.get_match_record_loop + sta @matchlen +@matchRecordLoop lda PTR+1 sta DEST+1 lda PTR @@ -219,17 +219,17 @@ okvs_get bcc + inc DEST+1 ; DEST -> key of this record + ldy #0 -.get_match_key_loop +@matchKeyLoop lda (SRC),y cmp (DEST),y - bne .get_next + bne @next iny -.get_matchlen=*+1 +@matchlen=*+1 cpy #$FD ; SMC - bne .get_match_key_loop + bne @matchKeyLoop +LDAY PTR clc - adc .get_matchlen + adc @matchlen bcc + iny + clc @@ -239,14 +239,12 @@ okvs_get iny clc + rts -.get_next - jsr derefptr ; PTR -> next record +@next jsr derefptr ; PTR -> next record inx -.get_maxkeys=*+1 +@maxkeys=*+1 cpx #$FD ; SMC - bne .get_match_record_loop -.get_fail - sec + bne @matchRecordLoop +@fail sec rts ;------------------------------------------------------------------------------ @@ -268,11 +266,11 @@ okvs_nth ldy #3 lda (PARAM),y tax ; X = numeric index of key to get - beq + + beq @found - jsr derefptr dex bne - -+ jsr incptr +@found jsr incptr jsr incptr +LDAY PTR rts @@ -302,14 +300,14 @@ okvs_update sta SAVE dey - lda (PARAM),y - sta .getparams,y + sta @getparams,y dey bne - jsr okvs_get -.getparams=*-1 +@getparams=*-1 !word $FDFD ; SMC !word $FDFD ; SMC - bcs .exit + bcs @exit +STAY DEST lda (SAVE) tay @@ -319,7 +317,7 @@ okvs_update cpy #$FF bne - clc -.exit rts +@exit rts ;------------------------------------------------------------------------------ ; okvs_iter @@ -338,14 +336,13 @@ okvs_iter +PARAMS_ON_STACK 4 jsr SetPTRFromStackParams lda (PTR) - beq .iterDone ; no keys, exit immediately - sta .iterMax + beq @exit ; no keys, exit immediately + sta @max +LDPARAM 3 - +STAY .iterCallback + +STAY @callback jsr incptr ; PTR -> first record ldx #0 -.iterLoop - +LDAY PTR +@loop +LDAY PTR pha ; save PTR on stack (in case callback clobbers it) phy clc @@ -353,7 +350,7 @@ okvs_iter bcc + iny ; A/Y -> key + phx -.iterCallback=*+1 +@callback=*+1 jsr $FDFD ; SMC plx ply @@ -361,11 +358,10 @@ okvs_iter +STAY PTR ; restore PTR from stack jsr derefptr ; PTR -> next record inx -.iterMax=*+1 +@max=*+1 cpx #$FD ; SMC - bne .iterLoop -.iterDone - rts + bne @loop +@exit rts ;------------------------------------------------------------------------------ ; okvs_iter_values @@ -384,28 +380,27 @@ okvs_iter_values +PARAMS_ON_STACK 4 jsr SetPTRFromStackParams lda (PTR) - beq .iterValuesDone ; no keys, exit immediately - sta .iterValuesMax + beq @exit ; no keys, exit immediately + sta @max +LDPARAM 3 - +STAY .iterValuesCallback + +STAY @callback jsr incptr ; PTR -> first record ldx #0 -.iterValuesLoop - ldy #2 +@loop ldy #2 lda (PTR),y ; A = length of key clc adc #3 ; skip over pointer to next record (2 bytes) + key length (1 byte) - sta .iterValuesSkipLen + sta @skiplen +LDAY PTR pha ; save PTR on stack (in case callback clobbers it) phy clc -.iterValuesSkipLen=*+1 ; skip over key +@skiplen=*+1 ; skip over key adc #$FD ; SMC bcc + iny ; A/Y -> value + phx -.iterValuesCallback=*+1 +@callback=*+1 jsr $FDFD ; SMC plx ply @@ -413,11 +408,10 @@ okvs_iter_values +STAY PTR ; restore PTR from stack jsr derefptr ; PTR -> next record inx -.iterValuesMax=*+1 +@max=*+1 cpx #$FD ; SMC - bne .iterValuesLoop -.iterValuesDone - rts + bne @loop +@exit rts ;------------------------------------------------------------------------------ ; okvs_as_boolean diff --git a/src/parse.common.a b/src/parse.common.a index dbd9b3e..49483d6 100644 --- a/src/parse.common.a +++ b/src/parse.common.a @@ -5,7 +5,9 @@ ; ; Public functions: ; - ParseKeyValueText +; - IncAndGetChar ; + ;------------------------------------------------------------------------------ ; ParseKeyValueText ; parse buffer with KEY=VALUE lines of text into an okvs @@ -26,15 +28,15 @@ ParseKeyValueText +PARAMS_ON_STACK 5 +LDPARAM 1 - +STAY .store1 - +STAY .store2 + +STAY @store1 + +STAY @store2 +LDPARAM 3 +STAY $FE ldy #5 lda (PARAM),y - sta .useMaxLength+1 + sta @maxLength lda ($FE) pha @@ -49,65 +51,73 @@ ParseKeyValueText dey + sty $FF jsr okvs_init ; reset key/value store -.store1 !word $FDFD ; SMC +@store1 !word $FDFD ; SMC ldy #$00 ; index into ($FE) pointing to current character -.newKey - ldx #$00 ; X = index into current key -.gatherKey +@newkey ldx #$00 ; X = index into current key +@gatherKey jsr IncAndGetChar and #$7F ; keys get their high bit stripped cmp #$23 ; '#' is starts a comment (until CR) - beq .skipComment + beq @skipComment cmp #$3D ; '=' ends the key - beq .endKey + beq @endKey cmp #$0D ; found CR before '=', ignore key and start over (also handles blank lines) - beq .newKey + beq @newkey cmp #$5B ; '[' ends the parsing beq .parseKeyValueDone sta gKey,x inx - bpl .gatherKey -.endKey - stx gKeyLen + bpl @gatherKey +@endKey stx gKeyLen ldx #$00 ; now X = index into the current value -.gatherValue - jsr IncAndGetChar ; note: values do NOT get their high bit stripped +@gatherValue + jsr IncAndGetChar ; note: values do NOT get their high bit stripped cmp #$0D ; CR ends the value - beq .endValue + beq @endValue cmp #$00 ; null also ends the value - beq .endValue + beq @endValue sta gVal,x inx - bpl .gatherValue -.endValue + bpl @gatherValue +@endValue stx gValLen cpx #1 - bne .useMaxLength + bne @useMaxLength lda gVal and #1 sta gVal ; single-character values get converted to #$00 or #$01 in prefs store lda #0 +HIDE_NEXT_2_BYTES -.useMaxLength +@useMaxLength +@maxLength=*+1 lda #$FD ; SMC - sta .appendMaxLength ; all other values get upgraded to max_length so we can update them in place + 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 -.store2 !word $FDFD ; SMC +@store2 !word $FDFD ; SMC !word gKeyLen !word gValLen -.appendMaxLength +@appendMaxLength !byte $FD ; SMC ply - bra .newKey + bra @newkey -.skipComment ; skip to CR +@skipComment ; skip to CR jsr IncAndGetChar cmp #$0D ; CR - bne .skipComment - bra .newKey + bne @skipComment + bra @newkey +;------------------------------------------------------------------------------ +; IncAndGetChar +; +; in: Y = index into ($FE) +; ($FE) -> buffer +; out: A contains next byte from buffer +; Y incremented +; $FF possibly incremented +;------------------------------------------------------------------------------ IncAndGetChar iny bne + diff --git a/src/parse.gameinfo.a b/src/parse.gameinfo.a index 8d2c96f..832dacc 100644 --- a/src/parse.gameinfo.a +++ b/src/parse.gameinfo.a @@ -81,32 +81,32 @@ LoadGameInfo ldy #$00 ; index into ($FE) pointing to current character ldx #$08 ; index into sectionPointers array, stores pointer to start of each section -.convertSectionLoop +@convertSectionLoop jsr IncAndGetChar -.convertSectionNoInc +@convertSectionNoInc cmp #$5B ; '[' is the start of a new section - beq .skipSectionName + beq @skipSectionName cmp #$0D ; CR -> 0x00 (WeeGUI wants null-terminated strings) - beq .null + beq @null cmp #$5E ; '^' -> closed-apple mousetext - beq .ca + beq @ca cmp #$26 ; '&' -> open-apple mousetext - beq .oa + beq @oa ora #$80 ; all other characters -> set high bit +HIDE_NEXT_2_BYTES -.null lda #$00 +@null lda #$00 +HIDE_NEXT_2_BYTES -.ca lda #$40 +@ca lda #$40 +HIDE_NEXT_2_BYTES -.oa lda #$41 +@oa lda #$41 sta ($FE),y - bra .convertSectionLoop + bra @convertSectionLoop ; We found the start of a new section, so skip to the first character on the next line -.skipSectionName +@skipSectionName jsr IncAndGetChar cmp #$0D ; CR - bne .skipSectionName + bne @skipSectionName jsr IncAndGetChar ; We are at the start of a section, so save this address in the sectionPointers array @@ -122,7 +122,7 @@ LoadGameInfo pla dex dex - bpl .convertSectionNoInc + bpl @convertSectionNoInc ; We are done converting the game info file. ; Now handle the individual sections that require further parsing. @@ -187,13 +187,13 @@ CheckForSavedGames jsr AddToPath jsr GetFileInfo !word gPathname - bcs .no ; no file -> no saved games + bcs @no ; no file -> no saved games lda blocks+1 - bne .yes ; file exists and is quite large -> assume saved games + bne @yes ; file exists and is quite large -> assume saved games lda blocks cmp #$06 ; file exists but is small -> no saved games (.Z4/.Z5 files have a 5 block 'empty' .sav file) - bcc .no -.yes lda auxtype ; if low byte of auxtype is $3x, x is the last save slot + bcc @no +@yes lda auxtype ; if low byte of auxtype is $3x, x is the last save slot and #$F0 cmp #$30 bne + @@ -204,6 +204,6 @@ CheckForSavedGames sta gLastSavedGameSlot lda #1 +HIDE_NEXT_2_BYTES -.no lda #0 +@no lda #0 sta gHasSavedGames rts diff --git a/src/parse.prefs.a b/src/parse.prefs.a index d9015d0..56c2cee 100644 --- a/src/parse.prefs.a +++ b/src/parse.prefs.a @@ -57,12 +57,12 @@ kLastPlayed ;------------------------------------------------------------------------------ SaveGlobalPreferences lda gGlobalPrefsDirty - beq + + beq @exit +LDADDR kGlobalPrefsBuffer +STAY $FE - +LDADDR .fluff1 + +LDADDR kFluff1 jsr addString jsr addBooleanFromStore @@ -77,39 +77,39 @@ SaveGlobalPreferences jsr addBooleanFromStore !word kAutoScript - +LDADDR .fluff2 + +LDADDR kFluff2 jsr addString jsr addStringFromStore !word kLastPlayed - +LDADDR .fluff3 + +LDADDR kFluff3 jsr addString jsr okvs_iter !word gGamesListStore !word addGameToPrefs - +LDADDR .eof + +LDADDR kEOF jsr addString lda $FE - sta .filelen + sta @filelen lda $FF sec sbc #>kGlobalPrefsBuffer - sta .filelen+1 + sta @filelen+1 jsr SaveFile !word kGlobalPrefsFilename !byte 4 ; filetype=TXT !word 0 ; auxtype=0000 !word kGlobalPrefsBuffer -.filelen !word $FDFD ; SMC +@filelen !word $FDFD ; SMC !word kProDOSFileBuffer stz gGlobalPrefsDirty -+ rts +@exit rts addGameToPrefs +STAY + @@ -122,17 +122,17 @@ addBooleanFromStore +HIDE_NEXT_2_BYTES addStringFromStore lda #$80 ; BRA opcode - sta .skipOverBooleanLogic + sta @skipOverBooleanLogic +PARAMS_ON_STACK 2 +LDPARAM 1 - +STAY .key + +STAY @key jsr addString - +LDADDR .equals + +LDADDR kEquals jsr addString jsr okvs_get !word gGlobalPrefsStore -.key !word $FDFD ; SMC -.skipOverBooleanLogic +@key !word $FDFD ; SMC +@skipOverBooleanLogic bra + ; SMC (opcode may become BIT) +STAY PTR ldy #1 @@ -141,14 +141,14 @@ addStringFromStore sta (PTR),y +LDAY PTR + jsr addString - +LDADDR .lf + +LDADDR kLF jmp addString addString +STAY $00 lda ($00) inc - sta .stringlen + sta @len ldy #1 - lda ($00),y sta ($FE) @@ -156,26 +156,26 @@ addString inc $FE bne + inc $FF -.stringlen=*+1 +@len=*+1 + cpy #$FD ; SMC bne - rts -.equals !byte 1 +kEquals !byte 1 !raw "=" -.lf !byte 1 +kLF !byte 1 !byte $0D -.fluff1 !byte 101 +kFluff1 !byte 101 !raw "# Pitch Dark preferences file",$0D !raw "# Do not edit by hand.",$0D !raw "# Or do. I'm a comment, not a cop.",$0D,$0D !raw "# value=0|1",$0D -.fluff2 !byte 24 +kFluff2 !byte 24 !byte $0D !raw "# value=game directory",$0D -.fluff3 !byte 58 +kFluff3 !byte 58 !byte $0D !raw "# key=game directory, value=filename of selected version",$0D -.eof !byte 7 +kEOF !byte 7 !byte $0D !raw "[eof]",$0D diff --git a/src/pitchdark.init.a b/src/pitchdark.init.a index cd8695a..fbd867e 100644 --- a/src/pitchdark.init.a +++ b/src/pitchdark.init.a @@ -17,19 +17,20 @@ ;------------------------------------------------------------------------------ lda RAM32 cmp NODEV - bne + + bne @maybeRAMdisk lda RAM32+1 cmp NODEV+1 - beq .noRAMdisk -+ ldy DEVCNT + beq @noRAMdisk +@maybeRAMdisk + ldy DEVCNT - lda DEVLST, y and #$F3 cmp #$B3 - beq .foundRAMdisk + beq @foundRAMdisk dey bpl - - bmi .noRAMdisk -.foundRAMdisk + bmi @noRAMdisk +@foundRAMdisk - lda DEVLST+1, y ; move other devices up in list sta DEVLST, y beq + ; device list is zero-terminated @@ -40,7 +41,7 @@ lda NODEV+1 sta RAM32+1 dec DEVCNT ; reduce ProDOS device count -.noRAMdisk +@noRAMdisk ;------------------------------------------------------------------------------ ; clear options script and make checksum invalid diff --git a/src/prodos.mli.a b/src/prodos.mli.a index 0134c31..3ec302b 100644 --- a/src/prodos.mli.a +++ b/src/prodos.mli.a @@ -64,7 +64,7 @@ LoadFile +STAY mliparam+3 ; ProDOS file buffer jsr _openfile - bcs + ; C set on error + bcs @exit ; C set on error pha ; push file reference number +LDPARAM 3 @@ -81,7 +81,7 @@ LoadFile plp ; restore flags from readfile ; (so caller gets codes from read attempt, ; not close) -+ rts +@exit rts ;------------------------------- ; LoadDHRFile @@ -111,8 +111,8 @@ LoadDHRFile bne - jsr _openfile - bcs .dhrexit ; C set on error - sta .saverefnum ; store file refnum + bcs @exit ; C set on error + sta @saverefnum ; store file refnum ldy #$20 stz mliparam+2 ; read into $2000 in main mem @@ -121,34 +121,34 @@ LoadDHRFile sty mliparam+5 jsr _readfile - bcs .close + bcs @close sta $C000 ldx #$20 ; copy $2000 bytes to auxmem - stx .copya+2 - stx .copyb+2 - ldy #$00 -.writeToAuxLoop + stx @copya+2 + stx @copyb+2 + ldy #0 +@writeToAuxLoop sta $C005 -.copya lda $FF00, y -.copyb sta $FF00, y +@copya lda $FF00, y +@copyb sta $FF00, y iny - bne .copya + bne @copya sta $C004 - inc .copya+2 - inc .copyb+2 + inc @copya+2 + inc @copyb+2 dex - bne .writeToAuxLoop + bne @writeToAuxLoop - lda .saverefnum + lda @saverefnum jsr _readfile ; read another $2000 bytes into $2000 (stays in main mem) -.close php ; save flags from readfile -.saverefnum=*+1 - lda #$d1 ; file refnum (set above) +@close php ; save flags from readfile +@saverefnum=*+1 + lda #$FD ; file refnum (SMC) jsr _closefile plp ; restore flags from readfile -.dhrexit rts +@exit rts ;------------------------------- ; SaveFile @@ -192,12 +192,12 @@ SaveFile lda #CMD_CREATE ; MLI create command ldy #PC_CREATE ; number of parameters for 'create' command jsr mli - bcs + + bcs @exit +LDPARAM 10 +STAY mliparam+3 ; PrODOS file buffer jsr _openfile - bcs + + bcs @exit sta mliparam+1 ; store file reference number +LDPARAM 6 @@ -212,7 +212,7 @@ SaveFile plp ; restore flags from write ; (so caller gets codes from write attempt, ; not close) -+ rts +@exit rts ;------------------------------- ; SetPrefix @@ -270,11 +270,11 @@ _openfile lda #CMD_OPEN ; MLI command ldy #PC_OPEN ; number of parameters for 'open' command jsr mli - bcs + + bcs @exit lda refnum ; caller should save file reference number ; as this memory location may be ; overwritten by later MLI calls -+ rts +@exit rts ;------------------------------- ; read an open file via ProDOS MLI @@ -291,9 +291,9 @@ _readfile lda #CMD_READ ; MLI read command ldy #PC_READ ; number of parameters for 'read' command jsr mli - bcs + + bcs @exit lda mliparam+1 ; if no error, return file reference number -+ rts +@exit rts ;------------------------------- ; close an open file @@ -328,7 +328,7 @@ mli sta mlicmd ; store command code jsr PRODOSMLI ; call ProDOS mlicmd !byte 00 ; command number !word mliparam ; address of parameter table -mliexit rts + rts mliparam !byte $FE,$FE,$FE,$FE filetype !byte $FE ; file type (set by MLI get_file_info) auxtype ; auxiliary file type (2 bytes, set by MLI get_file_info) diff --git a/src/prodos.path.a b/src/prodos.path.a index 479ed0a..4ed1c42 100644 --- a/src/prodos.path.a +++ b/src/prodos.path.a @@ -41,20 +41,20 @@ AddToPathWithHighBit +HIDE_NEXT_2_BYTES AddToPath ldx #0 - stx .mask + stx @mask +STAY $00 ldx gPathname ; current pathname length lda ($00) ; length of this segment inc - sta .len + sta @len ldy #$01 - lda ($00),y -.mask=*+1 +@mask=*+1 ora #$FD ; SMC sta gPathname+1,x inx iny -.len=*+1 +@len=*+1 cpy #$FD ; SMC bcc - stx gPathname diff --git a/src/ui.common.a b/src/ui.common.a index 00d36e8..f3af2b2 100644 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -39,17 +39,16 @@ kStringCancel ;------------------------------------------------------------------------------ HardResetWeeGUI lda #15 ; highest possible WeeGUI view ID - sta kHardResetDummyView - +LDAY kHardResetDummyView + sta @kHardResetDummyView + +LDAY @kHardResetDummyView +STAY PARAM0 -.hardResetLoop - ldx #WGCreateView +- ldx #WGCreateView jsr WeeGUI ; create dummy views to reset state on all views - dec kHardResetDummyView - bpl .hardResetLoop + dec @kHardResetDummyView + bpl - ldx #WGResetAll ; reset WeeGUI (destroys everything we just created) jmp WeeGUI -kHardResetDummyView +@kHardResetDummyView !byte 0,0,0,0,0,0,0,0 ;------------------------------------------------------------------------------ @@ -99,12 +98,12 @@ CreateCheckbox +HIDE_NEXT_2_BYTES CreateButton ldx #WGCreateButton - stx .createViewType + stx @type +PARAMS_ON_STACK 2 +LDPARAM 1 +STAY PARAM0 -.createViewType=*+1 +@type=*+1 ldx #$FD ; SMC jsr WeeGUI ldx #WGViewSetRawTitle @@ -224,7 +223,7 @@ SimulateClick ; all other registers and flags clobbered ;------------------------------------------------------------------------------ GetCheckedRadioButton - sty .radioMax + sty @max - pha ldx #WGSelectView jsr WeeGUI @@ -232,15 +231,14 @@ GetCheckedRadioButton jsr WeeGUI lda PARAM0 and #1 - bne .radioFound + bne @found pla inc -.radioMax=*+1 +@max=*+1 cmp #$FD ; SMC bcc - +HIDE_NEXT_2_BYTES -.radioFound - pla +@found pla clc rts diff --git a/src/ui.main.a b/src/ui.main.a index 966e4ad..048d510 100644 --- a/src/ui.main.a +++ b/src/ui.main.a @@ -87,14 +87,14 @@ RepaintMainIfDirty !word kViewNext lda gHasSavedGames ; create 'play game' or 'resume game' button - beq .wantPlayButton + beq @wantPlayButton jsr CreateButton !word kViewResume - bra .donePlayOrResume -.wantPlayButton + bra @donePlayOrResume +@wantPlayButton jsr CreateButton !word kViewPlay -.donePlayOrResume +@donePlayOrResume jsr CreateOrDestroyButton ; create or destroy 'artwork' button !byte ID_BOXART @@ -112,7 +112,7 @@ RepaintMainIfDirty !word kHasVersions pla ; clear screen before repainting? - beq .nohome ; no -> repaint over existing screen, YOLO + beq @nohome ; no -> repaint over existing screen, YOLO ldx #WGClearScreen ; clear screen jsr WeeGUI @@ -132,7 +132,7 @@ RepaintMainIfDirty bne - ldx #WGSyncGlobalCursor jsr WeeGUI -.nohome +@nohome ldx #WGSelectView ; delete info box but leave its contents on screen lda #ID_INFO ; (harmless if it doesn't exist yet) jsr WeeGUI @@ -191,31 +191,29 @@ CreateOrDestroyButton pha ; A = WeeGUI view ID +LDPARAM 2 - +STAY .viewConfigurationRecord + +STAY @vcr +LDPARAM 4 - +STAY .optionsStoreKey + +STAY @key jsr okvs_get !word gOptionsStore -.optionsStoreKey - !word $FDFD ; SMC +@key !word $FDFD ; SMC plx ; X = WeeGUI view ID jsr okvs_as_boolean - beq .destroy + beq @destroy lda gViewInUse,x ; create button if it doesn't exist - bne .createDestroyDone ; oh it does exist, so we're done + bne @exit ; oh it does exist, so we're done lda #1 sta gViewInUse,x jsr CreateButton -.viewConfigurationRecord - !word $FDFD ; SMC -.createDestroyDone - rts +@vcr !word $FDFD ; SMC +@exit rts -.destroy lda gViewInUse,x ; destroy button if it exists - beq .createDestroyDone ; oh it doesn't exist, so we're done +@destroy + lda gViewInUse,x ; destroy button if it exists + beq @exit ; oh it doesn't exist, so we're done lda #0 sta gViewInUse,x txa ; A = WeeGUI view ID @@ -236,9 +234,9 @@ PaintDescriptionView jsr MultiPrint lda SAVE - cmp #10 ; minimum content height + cmp #10 bcs + - lda #10 + lda #10 ; minimum content height + ldx #WGSetContentHeight ; set content height so we stop scrolling on the last line of text jmp WeeGUI @@ -273,10 +271,9 @@ PaintInfoView +HIDE_NEXT_2_BYTES MultiPrint stz SAVE ; VTAB, but 0-indexed - stx .printLineLength+1 + stx @linelen +STAY SRC -.printLoop - stz PARAM0 +@loop stz PARAM0 lda SAVE sta PARAM1 ldx #WGSetCursor @@ -288,14 +285,14 @@ MultiPrint jsr WeeGUI lda SRC clc -.printLineLength +@linelen=*+1 adc #$FD ; SMC sta SRC bcc + inc SRC+1 + inc SAVE lda (SRC) - bne .printLoop + bne @loop rts ;------------------------------------------------------------------------------ diff --git a/src/ui.main.keys.a b/src/ui.main.keys.a index e84158a..736d78f 100644 --- a/src/ui.main.keys.a +++ b/src/ui.main.keys.a @@ -56,28 +56,24 @@ _endMainKeys HandleKey ldx #_endMainKeys-kMainKeys - cmp kMainKeys,x - beq .foundKey + beq @found dex dex bpl - -.notFound - jmp SoftBell ; unknown key, beep softly -.foundKey - lda kMainKeys+1,x ; get ID associated with this key - bpl .activateView ; ID < #$80 is a WeeGUI view, so activate it +@error jmp SoftBell ; unknown key, beep softly +@found lda kMainKeys+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 + beq @x ; an undocumented feature cmp #ID_Y - beq .y + beq @y cmp #ID_Z - beq .z + beq @z cmp #ID_SCROLLDOWN ; arrow keys scroll the description box - beq .handleScrollDown -.handleScrollUp + beq @down lda #$01 +HIDE_NEXT_2_BYTES -.handleScrollDown - lda #$FF +@down lda #$FF pha ldx #WGSelectView lda #ID_DESCRIPTION @@ -85,47 +81,45 @@ HandleKey ldx #WGScrollYBy pla jsr WeeGUI - bra .focusAndDoAction -.activateView + bra @click +@activateView tax ldy gViewInUse,x - beq .notFound + beq @error ldx #WGSelectView jsr WeeGUI -.focusAndDoAction - jmp SimulateClick +@click jmp SimulateClick ;------------------------------------------------------------------------------ ; XYZZY handler ;------------------------------------------------------------------------------ -.y lda .xyzzyCounter +@y lda @xyzzyCounter cmp #1 - beq .y1 + beq @y1 cmp #4 - bne .xyzzyReset - beq .xyzzyGo -.z lda .xyzzyCounter + bne @xyzzyReset + beq @xyzzyGo +@z lda @xyzzyCounter cmp #2 - beq .z1 + beq @z1 cmp #3 - beq .z2 - bra .xyzzyReset -.x lda #1 + beq @z2 + bra @xyzzyReset +@x lda #1 +HIDE_NEXT_2_BYTES -.y1 lda #2 +@y1 lda #2 +HIDE_NEXT_2_BYTES -.z1 lda #3 +@z1 lda #3 +HIDE_NEXT_2_BYTES -.z2 lda #4 +@z2 lda #4 +HIDE_NEXT_2_BYTES -.xyzzyReset +@xyzzyReset lda #0 - sta .xyzzyCounter -.xyzzyError - jmp SoftBell -.xyzzyCounter + sta @xyzzyCounter + bra @error +@xyzzyCounter !byte 0 -.xyzzyGo +@xyzzyGo jsr SaveGlobalPreferences jsr ResetPath +LDADDR kArtworkRootDirectory @@ -133,7 +127,7 @@ HandleKey jsr SetPrefix ; must set ProDOS prefix to directory where DHGR files actually are !word gPathname ; (DHRSLIDE does not look in subdirectories) - bcs .xyzzyError + bcs @error jsr ResetPath +LDADDR kDHRSLIDEFilename @@ -172,20 +166,21 @@ callback_previous !word gGamesListStore tax dex -+ bra .loadNewGameInfoAndRepaint ++ bra loadNewGameInfoAndRepaint callback_next jsr GetCurrentGameIndex inx - stx .n + stx @n jsr okvs_len !word gGamesListStore - ldx .n -.n=*+1 + ldx @n +@n=*+1 cmp #$FD ; SMC - bne .loadNewGameInfoAndRepaint + bne loadNewGameInfoAndRepaint ldx #0 -.loadNewGameInfoAndRepaint + +loadNewGameInfoAndRepaint stx + jsr okvs_nth !word gGamesListStore diff --git a/src/ui.options.a b/src/ui.options.a index 8a92e57..43151d6 100644 --- a/src/ui.options.a +++ b/src/ui.options.a @@ -118,12 +118,12 @@ OptionsDialog HandleOptionsKey ldx #_endOptionsKeys-kOptionsKeys - cmp kOptionsKeys,x - beq + + beq @found dex dex bpl - jmp SoftBell -+ lda kOptionsKeys+1,x +@found lda kOptionsKeys+1,x ldx #WGSelectView jsr WeeGUI jmp SimulateClick @@ -153,33 +153,33 @@ SetCheckboxByPref ldy #1 lda (PARAM),y - sta .checkboxViewID + sta @view +LDPARAM 2 - +STAY + + +STAY @key jsr okvs_get !word gGlobalPrefsStore -+ !word $FDFD ; SMC - bcs + +@key !word $FDFD ; SMC + bcs @exit jsr okvs_as_boolean - beq + + beq @exit ldx #WGSelectView -.checkboxViewID=*+1 +@view=*+1 lda #$FD ; SMC jsr WeeGUI ldx #WGSetState lda #1 sta PARAM0 jsr WeeGUI -+ rts +@exit rts SetPrefByCheckbox +PARAMS_ON_STACK 3 +LDPARAM 2 - +STAY + + +STAY @key ldy #1 lda (PARAM),y ldx #WGSelectView @@ -189,15 +189,15 @@ SetPrefByCheckbox lda PARAM0 and #1 - sta +++ + sta @valueb jsr okvs_update !word gGlobalPrefsStore -+ !word $FDFD ; SMC - !word ++ +@key !word $FDFD ; SMC + !word @value rts -++ !byte 1 -+++ !byte $FD ; SMC +@value !byte 1 +@valueb !byte $FD ; SMC ;------------------------------------------------------------------------------ ; WeeGUI view configuration records diff --git a/src/ui.resume.a b/src/ui.resume.a index 1f93613..748e9c2 100644 --- a/src/ui.resume.a +++ b/src/ui.resume.a @@ -157,12 +157,12 @@ ResumeDialog HandleResumeKey ldx #_endResumeKeys-kResumeKeys - cmp kResumeKeys,x - beq + + beq @found dex dex bpl - jmp SoftBell -+ +@found ; TODO need to handle up and down arrow keys like versions dialog lda kResumeKeys+1,x ldx #WGSelectView @@ -183,7 +183,7 @@ CreateResumeRadioCallback +STAY PTR lda (PTR) sta gResumeViewInUse+1,x ; mark whether this view is in use (hotkeys activate based on this array) - beq ++ ; length=0 means this slot is unused, so we're done + beq @exit ; length=0 means this slot is unused, so we're done lda PTR inc ; skip over length byte @@ -199,7 +199,7 @@ CreateResumeRadioCallback !word kViewResumeRadio inc iResumeVTAB inc iResumeVTAB -++ rts +@exit rts ;------------------------------------------------------------------------------ ; PrintResumeLabelCallback @@ -214,7 +214,7 @@ CreateResumeRadioCallback PrintResumeLabelCallback +STAY PTR lda (PTR) - beq ++ ; length=0 means this slot is unused, so we're done + beq .printResumeExit ; length=0 means this slot is unused, so we're done lda PTR inc ; skip over length byte @@ -230,7 +230,8 @@ iResumeVTAB !word $FDFD ; SMC inc iResumeVTAB inc iResumeVTAB -++ rts +.printResumeExit + rts ;------------------------------------------------------------------------------ ; ResumeOKCallback diff --git a/src/ui.sound.a b/src/ui.sound.a index 91011e1..569439d 100644 --- a/src/ui.sound.a +++ b/src/ui.sound.a @@ -7,9 +7,6 @@ ; - SoftBell ; -WAIT = $FCA8 -SPEAKER = $C030 - ;------------------------------------------------------------------------------ ; SoftBell ; diff --git a/src/ui.versions.a b/src/ui.versions.a index 7de9057..60da97b 100644 --- a/src/ui.versions.a +++ b/src/ui.versions.a @@ -178,22 +178,20 @@ HandleVersionsKey ; out: all registers and flags clobbered ldx #_endVersionsKeys-kVersionsKeys - cmp kVersionsKeys,x - beq .foundVersionKey + beq @found dex dex bpl - -.versionKeyError - jmp SoftBell -.foundVersionKey - lda kVersionsKeys+1,x ; get action ID associated with this key - bmi + +@error jmp SoftBell +@found lda kVersionsKeys+1,x ; get action ID associated with this key + bmi @updown tax ; action ID < #$80 is a WeeGUI view, so activate it ldy gVersionsViewInUse,x - beq .versionKeyError + beq @error ldx #WGSelectView jsr WeeGUI jmp SimulateClick -+ pha ; action ID >= #$80 is a screen-specific action, so stash it for now +@updown pha ; action ID >= #$80 is a screen-specific action, so stash it for now jsr GetCheckedVersion ; figure out which radio button is checked ldx #WGSelectView ; uncheck it and repaint it jsr WeeGUI @@ -204,18 +202,17 @@ HandleVersionsKey jsr WeeGUI plx ; X = action ID (pushed earlier from A) cpx #ID_VERSIONS_PREVIOUS - beq .previousVersion + beq @up cmp iNumVersions ; find 'next' view ID (wrapping around to 1) bcs + inc +HIDE_NEXT_2_BYTES + lda #1 - bra .checkNewVersion -.previousVersion - dec - bne .checkNewVersion + bra @checkNewVersion +@up dec + bne @checkNewVersion lda iNumVersions -.checkNewVersion +@checkNewVersion ldx #WGSelectView ; check new radio button and repaint it jsr WeeGUI ldx #WGViewFocus @@ -254,19 +251,19 @@ GetCheckedVersion VersionsOKCallback jsr GetCheckedVersion dec - sta + + sta @n jsr okvs_nth !word gVersionsStore -+ !byte $FD ; SMC - +STAY ++ +@n !byte $FD ; SMC + +STAY @value jsr okvs_get !word gGlobalPrefsStore !word kLastPlayed - +STAY + + +STAY @key jsr okvs_update !word gGlobalPrefsStore -+ !word $FDFD ; SMC -++ !word $FDFD ; SMC +@key !word $FDFD ; SMC +@value !word $FDFD ; SMC lda #1 sta gGlobalPrefsDirty ; must set, otherwise SaveGlobalPreferences does nothing