diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e045f948eb..816c61629e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,17 +22,9 @@ jobs: run: | sudo apt-get install -yq libpng-dev sudo make install - cd .. - rm -rf rgbds - - name: Make - run: | - make -j$(nproc) - if ! git diff-index --quiet HEAD --; then - echo 'Uncommitted changes detected:' - git diff-index HEAD -- - return 1 - fi + - name: Make ROM + run: make -j$(nproc) - name: Archive map file uses: actions/upload-artifact@v4 @@ -42,7 +34,9 @@ jobs: if-no-files-found: error - name: Check free space - run: tools/free_space.awk BANK=all pokecrystal.map + run: | + chmod +x tools/free_space.awk + tools/free_space.awk BANK=all pokecrystal.map - name: Create release draft uses: ncipollo/release-action@v1 diff --git a/data/phone/text/mom.asm b/data/phone/text/mom.asm index 8ef86603d3..89743a377e 100644 --- a/data/phone/text/mom.asm +++ b/data/phone/text/mom.asm @@ -105,8 +105,8 @@ MomYouveSavedText: done MomOKIllSaveText: - text "OK. I'll save your" - line "money." + text "OK! I'll save your" + line "money!" done MomPhoneWontSaveMoneyText: @@ -159,7 +159,8 @@ MomPhoneLectureText: para "I wish you would" line "have told me…" - - para "What about money?" - line "Should I save it?" + + para "Don't worry, I'll" + line "help you save" + cont "money, alright?" done diff --git a/data/text/common_1.asm b/data/text/common_1.asm index 3cf8440f7f..c63f7eb224 100644 --- a/data/text/common_1.asm +++ b/data/text/common_1.asm @@ -1362,19 +1362,9 @@ _MomLeavingText1:: para "On a long journey," line "money's important." - - para "Do you want me to" - line "save your money?" done _MomLeavingText2:: - text "OK, I'll take care" - line "of your money." - - para "<……><……><……>" - prompt - -_MomLeavingText3:: text "Be careful." para "#MON are your" diff --git a/engine/events/mom.asm b/engine/events/mom.asm index e7621ae4fa..4b781c7e08 100644 --- a/engine/events/mom.asm +++ b/engine/events/mom.asm @@ -11,15 +11,12 @@ BankOfMom: jr nz, .done call .RunJumptable jr .loop - .done pop af ldh [hInMenu], a ret - .RunJumptable: jumptable .dw, wJumptableIndex - .dw dw .CheckIfBankInitialized dw .InitializeBank @@ -39,35 +36,21 @@ BankOfMom: ld [wMomSavingMoney], a ld a, $1 jr .done_0 - .savingmoneyalready ld a, $2 - .done_0 ld [wJumptableIndex], a ret - .InitializeBank: ld hl, MomLeavingText1 call PrintText - call YesNoBox - jr c, .DontSaveMoney - ld hl, MomLeavingText2 - call PrintText ld a, (1 << MOM_ACTIVE_F) | (1 << MOM_SAVING_SOME_MONEY_F) - jr .done_1 - -.DontSaveMoney: - ld a, 1 << MOM_ACTIVE_F - -.done_1 ld [wMomSavingMoney], a - ld hl, MomLeavingText3 + ld hl, MomLeavingText2 call PrintText ld a, $8 ld [wJumptableIndex], a ret - .IsThisAboutYourMoney: ld hl, MomIsThisAboutYourMoneyText call PrintText @@ -75,15 +58,12 @@ BankOfMom: jr c, .nope ld a, $3 jr .done_2 - .nope call DSTChecks ld a, $7 - .done_2 ld [wJumptableIndex], a ret - .AccessBankOfMom: ld hl, MomBankWhatDoYouWantToDoText call PrintText @@ -100,26 +80,20 @@ BankOfMom: jr z, .deposit cp $3 jr z, .stopsaving - .cancel ld a, $7 jr .done_3 - .withdraw ld a, $5 jr .done_3 - .deposit ld a, $4 jr .done_3 - .stopsaving ld a, $6 - .done_3 ld [wJumptableIndex], a ret - .StoreMoney: ld hl, MomStoreMoneyText call PrintText @@ -168,24 +142,19 @@ BankOfMom: call PrintText ld a, $8 jr .done_4 - .InsufficientFundsInWallet: ld hl, MomInsufficientFundsInWalletText call PrintText ret - .NotEnoughRoomInBank: ld hl, MomNotEnoughRoomInBankText call PrintText ret - .CancelDeposit: ld a, $7 - .done_4 ld [wJumptableIndex], a ret - .TakeMoney: ld hl, MomTakeMoneyText call PrintText @@ -234,24 +203,19 @@ BankOfMom: call PrintText ld a, $8 jr .done_5 - .InsufficientFundsInBank: ld hl, MomHaventSavedThatMuchText call PrintText ret - .NotEnoughRoomInWallet: ld hl, MomNotEnoughRoomInWalletText call PrintText ret - .CancelWithdraw: ld a, $7 - .done_5 ld [wJumptableIndex], a ret - .StopOrStartSavingMoney: ld hl, MomSaveMoneyText call PrintText @@ -264,18 +228,15 @@ BankOfMom: ld a, $8 ld [wJumptableIndex], a ret - .StopSavingMoney: ld a, 1 << MOM_ACTIVE_F ld [wMomSavingMoney], a ld a, $7 ld [wJumptableIndex], a ret - .JustDoWhatYouCan: ld hl, MomJustDoWhatYouCanText call PrintText - .AskDST: ld hl, wJumptableIndex set 7, [hl] @@ -290,12 +251,9 @@ DSTChecks: and a ; within one hour of 00:00? jr z, .LostBooklet jr .loop - .NotDST: cp 23 ; within one hour of 23:00? jr nz, .loop - ; fallthrough - .LostBooklet: call .ClearBox bccoord 1, 14 @@ -308,7 +266,6 @@ DSTChecks: ld hl, .MomLostGearBookletText call PrintTextboxTextAt ret - .loop call .ClearBox bccoord 1, 14 @@ -328,7 +285,6 @@ DSTChecks: ld hl, .TimesetNotDSTText call PrintTextboxTextAt ret - .SetDST: ld hl, .TimesetAskDSTText call PrintTextboxTextAt @@ -343,7 +299,6 @@ DSTChecks: ld hl, .TimesetDSTText call PrintTextboxTextAt ret - .SetClockForward: ld a, [wStartHour] add 1 @@ -357,7 +312,6 @@ DSTChecks: adc 0 ld [wStartDay], a ret - .SetClockBack: ld a, [wStartHour] sub 1 @@ -372,33 +326,26 @@ DSTChecks: .DontLoopDayBack: ld [wStartDay], a ret - .ClearBox: hlcoord 1, 14 lb bc, 3, 18 call ClearBox ret - .TimesetAskAdjustDSTText: text_far _TimesetAskAdjustDSTText text_end - .MomLostGearBookletText: text_far _MomLostGearBookletText text_end - .TimesetAskDSTText: text_far _TimesetAskDSTText text_end - .TimesetDSTText: text_far _TimesetDSTText text_end - .TimesetAskNotDSTText: text_far _TimesetAskNotDSTText text_end - .TimesetNotDSTText: text_far _TimesetNotDSTText text_end @@ -409,6 +356,7 @@ Mom_SetUpWithdrawMenu: Mom_SetUpDepositMenu: ld de, Mom_DepositString + ; fallthrough Mom_ContinueMenuSetup: push de xor a @@ -476,19 +424,15 @@ Mom_WithdrawDepositMenuJoypad: ld b, 0 add hl, bc ld [hl], " " - .skip call WaitBGMap jr .loop - .pressedB scf ret - .pressedA and a ret - .dpadaction ld hl, hJoyLast ld a, [hl] @@ -505,7 +449,6 @@ Mom_WithdrawDepositMenuJoypad: jr nz, .movecursorright and a ret - .movecursorleft ld hl, wMomBankDigitCursorPosition ld a, [hl] @@ -513,7 +456,6 @@ Mom_WithdrawDepositMenuJoypad: ret z dec [hl] ret - .movecursorright ld hl, wMomBankDigitCursorPosition ld a, [hl] @@ -521,7 +463,6 @@ Mom_WithdrawDepositMenuJoypad: ret nc inc [hl] ret - .incrementdigit ld hl, .DigitQuantities call .getdigitquantity @@ -530,7 +471,6 @@ Mom_WithdrawDepositMenuJoypad: ld de, wStringBuffer2 farcall GiveMoney ret - .decrementdigit ld hl, .DigitQuantities call .getdigitquantity @@ -539,7 +479,6 @@ Mom_WithdrawDepositMenuJoypad: ld de, wStringBuffer2 farcall TakeMoney ret - .getdigitquantity ld a, [wMomBankDigitCursorPosition] push de @@ -550,7 +489,6 @@ Mom_WithdrawDepositMenuJoypad: add hl, de pop de ret - .DigitQuantities: for x, 5, -1, -1 bigdt 10**x @@ -570,10 +508,6 @@ MomLeavingText2: text_far _MomLeavingText2 text_end -MomLeavingText3: - text_far _MomLeavingText3 - text_end - MomIsThisAboutYourMoneyText: text_far _MomIsThisAboutYourMoneyText text_end @@ -643,11 +577,10 @@ BankOfMom_MenuHeader: menu_coords 0, 0, 10, 10 dw .MenuData db 1 ; default option - .MenuData: db STATICMENU_CURSOR ; flags db 4 ; items db "GET@" db "SAVE@" db "CHANGE@" - db "CANCEL@" + db "CANCEL@" \ No newline at end of file diff --git a/engine/phone/scripts/mom.asm b/engine/phone/scripts/mom.asm index 40a8ba5bd3..8ce0825f36 100644 --- a/engine/phone/scripts/mom.asm +++ b/engine/phone/scripts/mom.asm @@ -8,7 +8,6 @@ MomPhoneCalleeScript: checkevent EVENT_GOT_A_POKEMON_FROM_ELM iftrue MomPhoneNoPokedexScript sjump MomPhoneNoPokemonScript - .started_quest checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_8 iftrue MomPhoneHangUpScript @@ -35,17 +34,14 @@ MomPhoneInTown: farwritetext MomPhoneGenericAreaText promptbutton sjump MomSavingMoney - .newbark farwritetext MomPhoneNewBarkText promptbutton sjump MomSavingMoney - .cherrygrove farwritetext MomPhoneCherrygroveText promptbutton sjump MomSavingMoney - .violet getlandmarkname STRING_BUFFER_4, LANDMARK_SPROUT_TOWER sjump MomPhoneLandmark @@ -72,31 +68,26 @@ MomSavingMoney: checkmoney MOMS_MONEY, 0 ifequal HAVE_MORE, .SavingHasMoney sjump .SavingNoMoney - .NotSaving: checkmoney MOMS_MONEY, 0 ifequal HAVE_MORE, .HasMoney sjump .NoMoney - .SavingHasMoney: getmoney STRING_BUFFER_3, MOMS_MONEY farwritetext MomCheckBalanceText yesorno iftrue MomPhoneSaveMoneyScript sjump MomPhoneWontSaveMoneyScript - .SavingNoMoney: farwritetext MomImportantToSaveText yesorno iftrue MomPhoneSaveMoneyScript sjump MomPhoneWontSaveMoneyScript - .NoMoney: farwritetext MomYoureNotSavingText yesorno iftrue MomPhoneSaveMoneyScript sjump MomPhoneWontSaveMoneyScript - .HasMoney: getmoney STRING_BUFFER_3, MOMS_MONEY farwritetext MomYouveSavedText @@ -137,6 +128,6 @@ MomPhoneLectureScript: setflag ENGINE_MOM_ACTIVE specialphonecall SPECIALCALL_NONE farwritetext MomPhoneLectureText - yesorno - iftrue MomPhoneSaveMoneyScript - sjump MomPhoneWontSaveMoneyScript + setflag ENGINE_MOM_SAVING_MONEY + promptbutton + sjump MomPhoneHangUpScript diff --git a/maps/PlayersHouse1F.asm b/maps/PlayersHouse1F.asm index f914bd86d9..b08fcee00f 100644 --- a/maps/PlayersHouse1F.asm +++ b/maps/PlayersHouse1F.asm @@ -29,9 +29,9 @@ MeetMomRightScript: iffalse .OnRight applymovement PLAYERSHOUSE1F_MOM1, MomTurnsTowardPlayerMovement sjump MeetMomScript - .OnRight: applymovement PLAYERSHOUSE1F_MOM1, MomWalksToPlayerMovement + ; fallthrough MeetMomScript: opentext writetext ElmsLookingForYouText @@ -55,29 +55,14 @@ MeetMomScript: yesorno iffalse .SetDayOfWeek sjump .DayOfWeekDone - .WrongDay: special InitialClearDSTFlag yesorno iffalse .SetDayOfWeek .DayOfWeekDone: writetext ComeHomeForDSTText - yesorno - iffalse .ExplainPhone - sjump .KnowPhone - -.KnowPhone: - writetext KnowTheInstructionsText - promptbutton - sjump .FinishPhone - -.ExplainPhone: - writetext DontKnowTheInstructionsText promptbutton - sjump .FinishPhone - -.FinishPhone: - writetext InstructionsNextText + writetext PhoneInstructionsText waitbutton closetext checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1 @@ -85,15 +70,12 @@ MeetMomScript: checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_2 iffalse .FromLeft sjump .Finish - .FromRight: applymovement PLAYERSHOUSE1F_MOM1, MomTurnsBackMovement sjump .Finish - .FromLeft: applymovement PLAYERSHOUSE1F_MOM1, MomWalksBackMovement sjump .Finish - .Finish: special RestartMapMusic turnobject PLAYERSHOUSE1F_MOM1, LEFT @@ -128,19 +110,16 @@ MomScript: waitbutton closetext end - .GotAPokemon: writetext SoWhatWasProfElmsErrandText waitbutton closetext end - .FirstTimeBanking: writetext ImBehindYouText waitbutton closetext end - .GaveMysteryEgg: setevent EVENT_FIRST_TIME_BANKING_WITH_MOM .BankOfMom: @@ -159,22 +138,18 @@ NeighborScript: iftrue .DayScript checktime NITE iftrue .NiteScript - .MornScript: writetext NeighborMornIntroText promptbutton sjump .Main - .DayScript: writetext NeighborDayIntroText promptbutton sjump .Main - .NiteScript: writetext NeighborNiteIntroText promptbutton sjump .Main - .Main: writetext NeighborText waitbutton @@ -256,31 +231,17 @@ ComeHomeForDSTText: para "for Daylight" line "Saving Time." - - para "By the way, do you" - line "know how to use" - cont "the PHONE?" done -KnowTheInstructionsText: - text "Don't you just" - line "turn the #GEAR" - - para "on and select the" - line "PHONE icon?" - done - -DontKnowTheInstructionsText: - text "I'll read the" - line "instructions." - - para "Turn the #GEAR" +PhoneInstructionsText: + text "By the way, to use" + line "the PHONE, just" + + para "turn the #GEAR" line "on and select the" cont "PHONE icon." - done - -InstructionsNextText: - text "Phone numbers are" + + para "Phone numbers are" line "stored in memory." para "Just choose a name" diff --git a/tools/free_space.awk b/tools/free_space.awk new file mode 100644 index 0000000000..168fde85dc --- /dev/null +++ b/tools/free_space.awk @@ -0,0 +1,78 @@ +#!/usr/bin/gawk -f + +# Usage: tools/free_space.awk [BANK=] pokecrystal.map + +# The BANK argument allows printing free space in one, all, or none of the ROM's banks. +# Valid arguments are numbers (in decimal "42" or hexadecimal "0x2a"), "all" or "none". +# If not specified, defaults to "none". +# The `BANK` argument MUST be before the map file name, otherwise it has no effect! +# Yes: tools/free_space.awk BANK=all pokecrystal.map +# No: tools/free_space.awk pokecrystal.map BANK=42 + +# Copyright (c) 2020, Eldred Habert. +# SPDX-License-Identifier: MIT + +BEGIN { + nb_banks = 0 + free = 0 + rom_bank = 0 # Safety net for malformed files + + # Default settings + # Variables assigned via the command-line (except through `-v`) are *after* `BEGIN` + BANK="none" +} + +# Only accept ROM banks, ignore everything else +toupper($0) ~ /^[ \t]*ROM[0X][ \t]+BANK[ \t]+#/ { + nb_banks++ + rom_bank = 1 + split($0, fields, /[ \t]/) + bank_num = strtonum(substr(fields[3], 2)) +} + +function register_bank(amount) { + free += amount + rom_bank = 0 # Reject upcoming banks by default + + if (BANK ~ /all/ || BANK == bank_num) { + printf "Bank %3d: %5d/16384 (%.2f%%)\n", bank_num, amount, amount * 100 / 16384 + } +} +function register_bank_str(str) { + if (str ~ /\$[0-9A-F]+/) { + register_bank(strtonum("0x" substr(str, 2))) + } else { + printf "Malformed number? \"%s\" does not start with '$'\n", str + } +} + +rom_bank && toupper($0) ~ /^[ \t]*EMPTY$/ { + # Empty bank + register_bank(16384) +} +rom_bank && toupper($0) ~ /^[ \t]*SLACK:[ \t]/ { + # Old (rgbds <=0.6.0) end-of-bank free space + register_bank_str($2) +} +rom_bank && toupper($0) ~ /^[ \t]*TOTAL EMPTY:[ \t]/ { + # New (rgbds >=0.6.1) total free space + register_bank_str($3) +} + +END { + # Determine number of banks, by rounding to upper power of 2 + total_banks = 2 # Smallest size is 2 banks + while (total_banks < nb_banks) { + total_banks *= 2 + } + + # RGBLINK omits "trailing" ROM banks, so fake them + bank_num = nb_banks + while (bank_num < total_banks) { + register_bank(16384) + bank_num++ + } + + total = total_banks * 16384 + printf "Free space: %5d/%5d (%.2f%%)\n", free, total, free * 100 / total +}