diff options
author | entrpntr <entrpntr@gmail.com> | 2020-04-10 22:57:05 -0400 |
---|---|---|
committer | entrpntr <entrpntr@gmail.com> | 2020-04-10 22:57:05 -0400 |
commit | ac8070fa92e5295908ae22f6892157baf81b64ce (patch) | |
tree | 010694d6f8c7f38fbae34779d9be297de8dc794f | |
parent | 22922bbb5965dfbcd9fc4aaffff92967d1f7f390 (diff) |
Add engine/events/pokemon_pc.asm and engine/items/mart.asm.
-rw-r--r-- | charmap.asm | 62 | ||||
-rw-r--r-- | constants/engine_flags.asm | 28 | ||||
-rw-r--r-- | constants/wram_constants.asm | 11 | ||||
-rw-r--r-- | data/items/bargain_shop.asm | 8 | ||||
-rw-r--r-- | data/text/common_2.asm | 89 | ||||
-rw-r--r-- | engine/events/pokemon_pc.asm | 658 | ||||
-rwxr-xr-x | engine/events/specials.asm | 2 | ||||
-rwxr-xr-x | engine/items/items.asm | 4 | ||||
-rw-r--r-- | engine/items/mart.asm | 811 | ||||
-rw-r--r-- | engine/menus/intro_menu.asm | 16 | ||||
-rwxr-xr-x | engine/overworld/time.asm | 6 | ||||
-rw-r--r-- | engine/pokemon/bills_pc_top.asm | 14 | ||||
-rw-r--r-- | main.asm | 51 | ||||
-rw-r--r-- | wram.asm | 80 |
14 files changed, 1706 insertions, 134 deletions
diff --git a/charmap.asm b/charmap.asm index 2f0b813b..595c7cf3 100644 --- a/charmap.asm +++ b/charmap.asm @@ -170,20 +170,19 @@ charmap "8", $fe charmap "9", $ff -; Japanese, for those bits of text that -; were not translated to English. +; Japanese kana, for those bits of text that were not translated to English - charmap "ガ", $5 - charmap "ギ", $6 - charmap "グ", $7 - charmap "ゲ", $8 - charmap "ゴ", $9 - charmap "ザ", $a - charmap "ジ", $b - charmap "ズ", $c - charmap "ゼ", $d - charmap "ゾ", $e - charmap "ダ", $f + charmap "ガ", $05 + charmap "ギ", $06 + charmap "グ", $07 + charmap "ゲ", $08 + charmap "ゴ", $09 + charmap "ザ", $0a + charmap "ジ", $0b + charmap "ズ", $0c + charmap "ゼ", $0d + charmap "ゾ", $0e + charmap "ダ", $0f charmap "ヂ", $10 charmap "ヅ", $11 charmap "デ", $12 @@ -193,7 +192,6 @@ charmap "ビ", $1a charmap "ブ", $1b charmap "ボ", $1c -; charmap "ベ", $1d charmap "が", $26 charmap "ぎ", $27 @@ -227,11 +225,18 @@ charmap "ぺ", $47 charmap "ぽ", $48 + charmap "「", $70 + charmap "」", $71 + charmap "』", $73 + charmap "⋯", $75 + + charmap " ", $7f + charmap "ア", $80 charmap "イ", $81 charmap "ウ", $82 charmap "エ", $83 - charmap "ォ", $84 + charmap "オ", $84 charmap "カ", $85 charmap "キ", $86 charmap "ク", $87 @@ -282,7 +287,6 @@ charmap "う", $b3 charmap "え", $b4 charmap "お", $b5 - charmap "か", $b6 charmap "き", $b7 charmap "く", $b8 @@ -308,7 +312,6 @@ charmap "ふ", $cc charmap "へ", $cd charmap "ほ", $ce - charmap "ま", $cf charmap "み", $d0 charmap "む", $d1 @@ -331,8 +334,31 @@ charmap "ょ", $e2 charmap "ー", $e3 - charmap "゚", $e4 charmap "゙", $e5 + charmap "?", $e6 + charmap "!", $e7 + charmap "。", $e8 + charmap "ァ", $e9 + charmap "ゥ", $ea + charmap "ェ", $eb + + charmap "円", $f0 + + charmap ".", $f2 + charmap "/", $f3 + + charmap "ォ", $f4 + + charmap "0", $f6 + charmap "1", $f7 + charmap "2", $f8 + charmap "3", $f9 + charmap "4", $fa + charmap "5", $fb + charmap "6", $fc + charmap "7", $fd + charmap "8", $fe + charmap "9", $ff diff --git a/constants/engine_flags.asm b/constants/engine_flags.asm index 41d52d25..51fb02cc 100644 --- a/constants/engine_flags.asm +++ b/constants/engine_flags.asm @@ -92,19 +92,19 @@ engine_flag_def ENGINE_LUCKY_NUMBER_SHOW, wLuckyNumberShowFlag, 0 engine_flag_def ENGINE_4E, wStatusFlags2, 3 - engine_flag_def ENGINE_KURT_MAKING_BALLS, wDailyFlags, 0 ; kurt making balls - engine_flag_def ENGINE_DAILY_BUG_CONTEST, wDailyFlags, 1 ; did bug catching contest today ; $50 - engine_flag_def ENGINE_SPECIAL_WILDDATA, wDailyFlags, 2 ; special wilddata? - engine_flag_def ENGINE_TIME_CAPSULE, wDailyFlags, 3 ; time capsule (24h wait) - engine_flag_def ENGINE_ALL_FRUIT_TREES, wDailyFlags, 4 ; all fruit trees - engine_flag_def ENGINE_GOT_SHUCKIE_TODAY, wDailyFlags, 5 ; shuckle given - engine_flag_def ENGINE_GOLDENROD_UNDERGROUND_MERCHANT_CLOSED, wDailyFlags, 6 ; goldenrod underground merchant closed - engine_flag_def ENGINE_FOUGHT_IN_TRAINER_HALL_TODAY, wDailyFlags, 7 ; fought in trainer hall today + engine_flag_def ENGINE_KURT_MAKING_BALLS, wDailyFlags1, 0 ; kurt making balls + engine_flag_def ENGINE_DAILY_BUG_CONTEST, wDailyFlags1, 1 ; did bug catching contest today ; $50 + engine_flag_def ENGINE_SPECIAL_WILDDATA, wDailyFlags1, 2 ; special wilddata? + engine_flag_def ENGINE_TIME_CAPSULE, wDailyFlags1, 3 ; time capsule (24h wait) + engine_flag_def ENGINE_ALL_FRUIT_TREES, wDailyFlags1, 4 ; all fruit trees + engine_flag_def ENGINE_GOT_SHUCKIE_TODAY, wDailyFlags1, 5 ; shuckle given + engine_flag_def ENGINE_GOLDENROD_UNDERGROUND_MERCHANT_CLOSED, wDailyFlags1, 6 ; goldenrod underground merchant closed + engine_flag_def ENGINE_FOUGHT_IN_TRAINER_HALL_TODAY, wDailyFlags1, 7 ; fought in trainer hall today - engine_flag_def ENGINE_MT_MOON_SQUARE_CLEFAIRY, wWeeklyFlags, 0 ; mt moon square clefairy - engine_flag_def ENGINE_UNION_CAVE_LAPRAS, wWeeklyFlags, 1 ; union cave lapras ; $58 - engine_flag_def ENGINE_GOLDENROD_UNDERGROUND_GOT_HAIRCUT, wWeeklyFlags, 2 ; goldenrod underground haircut used - engine_flag_def ENGINE_GOLDENROD_DEPT_STORE_TM27_RETURN, wWeeklyFlags, 3 ; goldenrod mall happiness event floor05 person07 - engine_flag_def ENGINE_DAISYS_GROOMING, wWeeklyFlags, 4 ; tea in blues house - engine_flag_def ENGINE_INDIGO_PLATEAU_RIVAL_FIGHT, wWeeklyFlags, 5 ; indigo plateau rival fight + engine_flag_def ENGINE_MT_MOON_SQUARE_CLEFAIRY, wDailyFlags2, 0 ; mt moon square clefairy + engine_flag_def ENGINE_UNION_CAVE_LAPRAS, wDailyFlags2, 1 ; union cave lapras ; $58 + engine_flag_def ENGINE_GOLDENROD_UNDERGROUND_GOT_HAIRCUT, wDailyFlags2, 2 ; goldenrod underground haircut used + engine_flag_def ENGINE_GOLDENROD_DEPT_STORE_TM27_RETURN, wDailyFlags2, 3 ; goldenrod mall happiness event floor05 person07 + engine_flag_def ENGINE_DAISYS_GROOMING, wDailyFlags2, 4 ; tea in blues house + engine_flag_def ENGINE_INDIGO_PLATEAU_RIVAL_FIGHT, wDailyFlags2, 5 ; indigo plateau rival fight NUM_ENGINE_FLAGS EQU const_value diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm index 96d78f92..40ff3791 100644 --- a/constants/wram_constants.asm +++ b/constants/wram_constants.asm @@ -206,6 +206,17 @@ PLAYER_SURF_PIKA EQU 8 const BIKEFLAGS_ALWAYS_ON_BIKE_F ; 1 const BIKEFLAGS_DOWNHILL_F ; 2 +; wDailyFlags1:: + const_def + const DAILYFLAGS1_KURT_MAKING_BALLS_F ; 0 + const DAILYFLAGS1_BUG_CONTEST_F ; 1 + const DAILYFLAGS1_FISH_SWARM_F ; 2 + const DAILYFLAGS1_TIME_CAPSULE_F ; 3 + const DAILYFLAGS1_ALL_FRUIT_TREES_F ; 4 + const DAILYFLAGS1_GOT_SHUCKIE_TODAY_F ; 5 + const DAILYFLAGS1_GOLDENROD_UNDERGROUND_BARGAIN_F ; 6 + const DAILYFLAGS1_TRAINER_HOUSE_F ; 7 + ; wDayCareMan:: ; dc40 DAYCAREMAN_HAS_MON_F EQU 0 DAYCAREMAN_MONS_COMPATIBLE_F EQU 5 diff --git a/data/items/bargain_shop.asm b/data/items/bargain_shop.asm new file mode 100644 index 00000000..a17db655 --- /dev/null +++ b/data/items/bargain_shop.asm @@ -0,0 +1,8 @@ +BargainShopData: + db 5 + dbw NUGGET, 4500 + dbw PEARL, 650 + dbw BIG_PEARL, 3500 + dbw STARDUST, 900 + dbw STAR_PIECE, 4600 + db -1 diff --git a/data/text/common_2.asm b/data/text/common_2.asm index 1d73bb74..d5bc6741 100644 --- a/data/text/common_2.asm +++ b/data/text/common_2.asm @@ -713,18 +713,18 @@ UnknownText_0x1c12fc:: cont "received?" done -UnknownText_0x1c1328:: +_PokecenterPCCantUseText:: text "Bzzzzt! You must" line "have a #MON to" cont "use this!" prompt -UnknownText_0x1c1353:: +_PlayersPCTurnOnText:: text "<PLAYER> turned on" line "the PC." prompt -UnknownText_0x1c1368:: +_PlayersPCAskWhatDoText:: text "What do you want" line "to do?" done @@ -748,7 +748,7 @@ _PlayersPCNoRoomWithdrawText:: line "for more items." prompt -UnknownText_0x1c13df:: +_PlayersPCNoItemsText:: text "No items here!" prompt @@ -771,16 +771,16 @@ _PlayersPCNoRoomDepositText:: line "store items." prompt -UnknownText_0x1c144d:: +_PokecenterPCTurnOnText:: text "<PLAYER> turned on" line "the PC." prompt -UnknownText_0x1c1462:: +_PokecenterPCWhoseText:: text "Access whose PC?" done -UnknownText_0x1c1474:: +_PokecenterBillsPCText:: text "BILL's PC" line "accessed." @@ -788,14 +788,14 @@ UnknownText_0x1c1474:: line "System opened." prompt -UnknownText_0x1c14a4:: +_PokecenterPlayersPCText:: text "Accessed own PC." para "Item Storage" line "System opened." prompt -UnknownText_0x1c14d2:: +_PokecenterOaksPCText:: text "PROF.OAK's PC" line "accessed." @@ -803,7 +803,7 @@ UnknownText_0x1c14d2:: line "System opened." prompt -UnknownText_0x1c1505:: +_PokecenterPCOaksClosedText:: text "…" line "Link closed…" done @@ -1384,11 +1384,11 @@ UnknownText_0x1c4be3:: line "is evolving!" done -UnknownText_0x1c4bfd:: +_MartHowManyText:: text "How many?" done -UnknownText_0x1c4c08:: +_MartFinalPriceText:: text_decimal wItemQuantityChangeBuffer, 1, 2 text " @" text_ram wStringBuffer2 @@ -1398,7 +1398,7 @@ UnknownText_0x1c4c08:: text "." done -UnknownText_0x1c4c28:: +_HerbShopLadyIntroText:: text "Hello, dear." para "I sell inexpensive" @@ -1413,11 +1413,11 @@ UnknownText_0x1c4c28:: para "Hehehehe…" done -UnknownText_0x1c4ca3:: +_HerbalLadyHowManyText:: text "How many?" done -UnknownText_0x1c4cae:: +_HerbalLadyFinalPriceText:: text_decimal wItemQuantityChangeBuffer, 1, 2 text " @" text_ram wStringBuffer2 @@ -1427,27 +1427,27 @@ UnknownText_0x1c4cae:: text "." done -UnknownText_0x1c4cce:: +_HerbalLadyThanksText:: text "Thank you, dear." line "Hehehehe…" done -UnknownText_0x1c4cea:: +_HerbalLadyPackFullText:: text "Oh? Your PACK is" line "full, dear." done -UnknownText_0x1c4d08:: +_HerbalLadyNoMoneyText:: text "Hehehe… You don't" line "have the money." done -UnknownText_0x1c4d2a:: +_HerbalLadyComeAgainText:: text "Come again, dear." line "Hehehehe…" done -UnknownText_0x1c4d47:: +_BargainShopIntroText:: text "Hiya! Care to see" line "some bargains?" @@ -1458,7 +1458,7 @@ UnknownText_0x1c4d47:: line "one of each item." done -UnknownText_0x1c4db0:: +_BargainShopFinalPriceText:: text_ram wStringBuffer2 text " costs" line "¥@" @@ -1466,41 +1466,41 @@ UnknownText_0x1c4db0:: text ". Want it?" done -UnknownText_0x1c4dcd:: +_BargainShopThanksText:: text "Thanks." done -UnknownText_0x1c4dd6:: +_BargainShopPackFullText:: text "Uh-oh, your PACK" line "is chock-full." done -UnknownText_0x1c4df7:: +_BargainShopSoldOutText:: text "You bought that" line "already. I'm all" cont "sold out of it." done -UnknownText_0x1c4e28:: +_BargainShopNoFundsText:: text "Uh-oh, you're" line "short on funds." done -UnknownText_0x1c4e46:: +_BargainShopComeAgainText:: text "Come by again" line "sometime." done -UnknownText_0x1c4e5f:: +_PharmacyIntroText:: text "What's up? Need" line "some medicine?" done -UnknownText_0x1c4e7e:: +_PharmacyHowManyText:: text "How many?" done -UnknownText_0x1c4e89:: +_PharmacyFinalPriceText:: text_decimal wItemQuantityChangeBuffer, 1, 2 text " @" text_ram wStringBuffer2 @@ -1510,35 +1510,36 @@ UnknownText_0x1c4e89:: text "." done -UnknownText_0x1c4eab:: +_PharmacyThanksText:: text "Thanks much!" done -UnknownText_0x1c4eb9:: +_PharmacyPackFullText:: text "You don't have any" line "more space." done -UnknownText_0x1c4ed8:: +_PharmacyNoMoneyText:: text "Huh? That's not" line "enough money." done -UnknownText_0x1c4ef6:: +_PharmacyComeAgainText:: text "All right." line "See you around." done -UnknownText_0x1c4f12:: +;unused +_NothingToSellText:: text "You don't have" line "anything to sell." prompt -UnknownText_0x1c4f33:: +_MartSellHowManyText:: text "How many?" done -UnknownText_0x1c4f3e:: +_MartSellPriceText:: text "I can pay you" line "¥@" text_decimal hMoneyTemp, 3, 6 @@ -1547,41 +1548,41 @@ UnknownText_0x1c4f3e:: para "Is that OK?" done -UnknownText_0x1c4f62:: +_MartWelcomeText:: text "Welcome! How may I" line "help you?" done -UnknownText_0x1c4f80:: +_MartThanksText:: text "Here you are." line "Thank you!" done -UnknownText_0x1c4f9a:: +_MartNoMoneyText:: text "You don't have" line "enough money." done -UnknownText_0x1c4fb7:: +_MartPackFullText:: text "You can't carry" line "any more items." done -UnknownText_0x1c4fd7:: +_MartCantBuyText:: text "Sorry, I can't buy" line "that from you." done -UnknownText_0x1c4ff9:: +_MartComeAgainText:: text "Please come again!" done -UnknownText_0x1c500d:: +_MartAskMoreText:: text "Can I do anything" line "else for you?" done -UnknownText_0x1c502e:: +_MartBoughtText:: text "Got ¥@" text_decimal hMoneyTemp, 3, 6 text " for" diff --git a/engine/events/pokemon_pc.asm b/engine/events/pokemon_pc.asm new file mode 100644 index 00000000..e22a2ffc --- /dev/null +++ b/engine/events/pokemon_pc.asm @@ -0,0 +1,658 @@ +PokemonCenterPC: + call PC_CheckPartyForPokemon + ret c + call PC_PlayBootSound + ld hl, PokecenterPCTurnOnText + call PC_DisplayText + ld hl, PokecenterPCWhoseText + call PC_DisplayTextWaitMenu + ld hl, .TopMenu + call LoadMenuHeader +.loop + xor a + ldh [hBGMapMode], a + call .ChooseWhichPCListToUse + ld [wWhichIndexSet], a + call DoNthMenu + jr c, .shutdown + ld a, [wMenuSelection] + ld hl, .JumpTable + call MenuJumptable + jr nc, .loop + +.shutdown + call PC_PlayShutdownSound + call ExitMenu + call CloseWindow + ret + +.TopMenu: + db MENU_BACKUP_TILES | MENU_NO_CLICK_SFX ; flags + menu_coords 0, 0, 15, 12 + dw .MenuData + db 1 ; default option + +.MenuData: + db STATICMENU_CURSOR | STATICMENU_WRAP ; flags + db 0 ; items + dw .WhichPC + dw PlaceNthMenuStrings + dw .JumpTable + +PCPC_PLAYERS_PC EQU 0 +PCPC_BILLS_PC EQU 1 +PCPC_OAKS_PC EQU 2 +PCPC_HALL_OF_FAME EQU 3 +PCPC_TURN_OFF EQU 4 + +.JumpTable: +; entries correspond to PCPC_* constants + dw PlayersPC, .String_PlayersPC + dw BillsPC, .String_BillsPC + dw OaksPC, .String_OaksPC + dw HallOfFamePC, .String_HallOfFame + dw TurnOffPC, .String_TurnOff + +.String_PlayersPC: db "<PLAYER>'s PC@" +.String_BillsPC: db "BILL's PC@" +.String_OaksPC: db "PROF.OAK's PC@" +.String_HallOfFame: db "HALL OF FAME@" +.String_TurnOff: db "TURN OFF@" + +.WhichPC: + ; before Pokédex + db 3 + db PCPC_BILLS_PC + db PCPC_PLAYERS_PC + db PCPC_TURN_OFF + db -1 ; end + + ; before Hall Of Fame + db 4 + db PCPC_BILLS_PC + db PCPC_PLAYERS_PC + db PCPC_OAKS_PC + db PCPC_TURN_OFF + db -1 ; end + + ; postgame + db 5 + db PCPC_BILLS_PC + db PCPC_PLAYERS_PC + db PCPC_OAKS_PC + db PCPC_HALL_OF_FAME + db PCPC_TURN_OFF + db -1 ; end + +.ChooseWhichPCListToUse: + call CheckReceivedDex + jr nz, .got_dex + ld a, 0 ; before Pokédex + ret + +.got_dex + ld a, [wHallOfFameCount] + and a + ld a, 1 ; before Hall Of Fame + ret z + ld a, 2 ; postgame + ret + +PC_CheckPartyForPokemon: + ld a, [wPartyCount] + and a + ret nz + ld de, SFX_CHOOSE_PC_OPTION + call PlaySFX + ld hl, .PokecenterPCCantUseText + call PC_DisplayText + scf + ret + +.PokecenterPCCantUseText: + text_far _PokecenterPCCantUseText + text_end + +BillsPC: + call PC_PlayChoosePCSound + ld hl, PokecenterBillsPCText + call PC_DisplayText + farcall _BillsPC + and a + ret + +PlayersPC: + call PC_PlayChoosePCSound + ld hl, PokecenterPlayersPCText + call PC_DisplayText + ld b, $0 + call _PlayersPC + and a + ret + +OaksPC: + call PC_PlayChoosePCSound + ld hl, PokecenterOaksPCText + call PC_DisplayText + farcall ProfOaksPC + and a + ret + +HallOfFamePC: + call PC_PlayChoosePCSound + call FadeToMenu + farcall _HallOfFamePC + call CloseSubmenu + and a + ret + +TurnOffPC: + ld hl, PokecenterPCOaksClosedText + call PrintText + scf + ret + +PC_PlayBootSound: + ld de, SFX_BOOT_PC + jr PC_WaitPlaySFX + +PC_PlayShutdownSound: + ld de, SFX_SHUT_DOWN_PC + call PC_WaitPlaySFX + call WaitSFX + ret + +PC_PlayChoosePCSound: + ld de, SFX_CHOOSE_PC_OPTION + jr PC_WaitPlaySFX + +PC_PlaySwapItemsSound: + ld de, SFX_SWITCH_POKEMON + call PC_WaitPlaySFX + ld de, SFX_SWITCH_POKEMON + +PC_WaitPlaySFX: + push de + call WaitSFX + pop de + call PlaySFX + ret + +_PlayersHousePC: + call PC_PlayBootSound + ld hl, PlayersPCTurnOnText + call PC_DisplayText + ld b, $1 + call _PlayersPC + and a + jr nz, .asm_156f9 + call OverworldTextModeSwitch + call ApplyTilemap + call UpdateSprites + call PC_PlayShutdownSound + ld c, $0 + ret + +.asm_156f9 + call ClearBGPalettes + ld c, $1 + ret + +PlayersPCTurnOnText: + text_far _PlayersPCTurnOnText + text_end + +_PlayersPC: + ld a, b + ld [wWhichIndexSet], a + ld hl, PlayersPCAskWhatDoText + call PC_DisplayTextWaitMenu + call Function15715 + call ExitMenu + ret + +Function15715: + xor a + ld [wPCItemsCursor], a + ld [wPCItemsScrollPosition], a + ld hl, PlayersPCMenuData + call LoadMenuHeader +.asm_15722 + call UpdateTimePals + call DoNthMenu + jr c, .asm_15731 + call MenuJumptable + jr nc, .asm_15722 + jr .asm_15732 + +.asm_15731 + xor a + +.asm_15732 + call ExitMenu + ret + +PlayersPCMenuData: + db MENU_BACKUP_TILES ; flags + menu_coords 0, 0, 15, 12 + dw .PlayersPCMenuData + db 1 ; default selected option + +.PlayersPCMenuData: + db STATICMENU_CURSOR | STATICMENU_WRAP ; flags + db 0 ; # items? + dw .PlayersPCMenuList1 + dw PlaceNthMenuStrings + dw .PlayersPCMenuPointers + +PLAYERSPC_WITHDRAW_ITEM EQU 0 +PLAYERSPC_DEPOSIT_ITEM EQU 1 +PLAYERSPC_TOSS_ITEM EQU 2 +PLAYERSPC_MAIL_BOX EQU 3 +PLAYERSPC_DECORATION EQU 4 +PLAYERSPC_TURN_OFF EQU 5 +PLAYERSPC_LOG_OFF EQU 6 + +.PlayersPCMenuPointers: +; entries correspond to PLAYERSPC_* constants + dw PlayerWithdrawItemMenu, .WithdrawItem + dw PlayerDepositItemMenu, .DepositItem + dw PlayerTossItemMenu, .TossItem + dw PlayerMailBoxMenu, .MailBox + dw PlayerDecorationMenu, .Decoration + dw PlayerLogOffMenu, .LogOff + dw PlayerLogOffMenu, .TurnOff + +.WithdrawItem: db "WITHDRAW ITEM@" +.DepositItem: db "DEPOSIT ITEM@" +.TossItem: db "TOSS ITEM@" +.MailBox: db "MAIL BOX@" +.Decoration: db "DECORATION@" +.TurnOff: db "TURN OFF@" +.LogOff: db "LOG OFF@" + +.PlayersPCMenuList1: + db 5 + db PLAYERSPC_WITHDRAW_ITEM + db PLAYERSPC_DEPOSIT_ITEM + db PLAYERSPC_TOSS_ITEM + db PLAYERSPC_MAIL_BOX + db PLAYERSPC_TURN_OFF + db -1 ; end + +.PlayersPCMenuList2: + db 6 + db PLAYERSPC_WITHDRAW_ITEM + db PLAYERSPC_DEPOSIT_ITEM + db PLAYERSPC_TOSS_ITEM + db PLAYERSPC_MAIL_BOX + db PLAYERSPC_DECORATION + db PLAYERSPC_LOG_OFF + db -1 ; end + +PC_DisplayTextWaitMenu: + ld a, [wOptions] + push af + set NO_TEXT_SCROLL, a + ld [wOptions], a + call MenuTextbox + pop af + ld [wOptions], a + ret + +PlayersPCAskWhatDoText: + text_far _PlayersPCAskWhatDoText + text_end + +PlayerWithdrawItemMenu: + call LoadStandardMenuHeader + farcall ClearPCItemScreen +.loop + call PCItemsJoypad + jr c, .quit + call .Submenu + jr .loop + +.quit + call CloseSubmenu + xor a + ret + +.Submenu: + ; check if the item has a quantity + farcall _CheckTossableItem + ld a, [wItemAttributeParamBuffer] + and a + jr z, .askquantity + + ; items without quantity are always ×1 + ld a, 1 + ld [wItemQuantityChangeBuffer], a + jr .withdraw + +.askquantity + ld hl, .PlayersPCHowManyWithdrawText + call MenuTextbox + farcall SelectQuantityToToss + call ExitMenu + call ExitMenu + jr c, .done + +.withdraw + ld a, [wItemQuantityChangeBuffer] + ld [wBuffer1], a ; quantity + ld a, [wCurItemQuantity] + ld [wBuffer2], a + ld hl, wNumItems + call ReceiveItem + jr nc, .PackFull + ld a, [wBuffer1] + ld [wItemQuantityChangeBuffer], a + ld a, [wBuffer2] + ld [wCurItemQuantity], a + ld hl, wNumPCItems + call TossItem + predef PartyMonItemName + ld hl, .PlayersPCWithdrewItemsText + call MenuTextbox + xor a + ldh [hBGMapMode], a + call ExitMenu + ret + +.PackFull: + ld hl, .PlayersPCNoRoomWithdrawText + call MenuTextboxBackup + ret + +.done + ret + +.PlayersPCHowManyWithdrawText: + text_far _PlayersPCHowManyWithdrawText + text_end + +.PlayersPCWithdrewItemsText: + text_far _PlayersPCWithdrewItemsText + text_end + +.PlayersPCNoRoomWithdrawText: + text_far _PlayersPCNoRoomWithdrawText + text_end + +PlayerTossItemMenu: + call LoadStandardMenuHeader + farcall ClearPCItemScreen +.loop + call PCItemsJoypad + jr c, .quit + ld de, wNumPCItems + farcall TossItemFromPC + jr .loop + +.quit + call CloseSubmenu + xor a + ret + +PlayerDecorationMenu: + farcall _PlayerDecorationMenu + ld a, c + and a + ret z + scf + ret + +PlayerLogOffMenu: + xor a + scf + ret + +PlayerDepositItemMenu: + call .CheckItemsInBag + jr c, .nope + call DisableSpriteUpdates + call LoadStandardMenuHeader + farcall DepositSellInitPackBuffers +.loop + farcall DepositSellPack + ld a, [wPackUsedItem] + and a + jr z, .close + call .TryDepositItem + farcall CheckRegisteredItem + jr .loop + +.close + call CloseSubmenu + +.nope + xor a + ret + +.CheckItemsInBag: + farcall HasNoItems + ret nc + ld hl, .PlayersPCNoItemsText + call MenuTextboxBackup + scf + ret + +.PlayersPCNoItemsText: + text_far _PlayersPCNoItemsText + text_end + +.TryDepositItem: + ld a, [wSpriteUpdatesEnabled] + push af + ld a, $0 + ld [wSpriteUpdatesEnabled], a + farcall CheckItemMenu + ld a, [wItemAttributeParamBuffer] + ld hl, .dw + rst JumpTable + pop af + ld [wSpriteUpdatesEnabled], a + ret + +.dw +; entries correspond to ITEMMENU_* constants + dw .tossable ; ITEMMENU_NOUSE + dw .no_toss + dw .no_toss + dw .no_toss + dw .tossable ; ITEMMENU_CURRENT + dw .tossable ; ITEMMENU_PARTY + dw .tossable ; ITEMMENU_CLOSE + +.no_toss + ret + +.tossable + ld a, [wBuffer1] + push af + ld a, [wBuffer2] + push af + call .DepositItem + pop af + ld [wBuffer2], a + pop af + ld [wBuffer1], a + ret + +.DepositItem: + farcall _CheckTossableItem + ld a, [wItemAttributeParamBuffer] + and a + jr z, .AskQuantity + ld a, $1 + ld [wItemQuantityChangeBuffer], a + jr .ContinueDeposit + +.AskQuantity: + ld hl, .PlayersPCHowManyDepositText + call MenuTextbox + farcall SelectQuantityToToss + push af + call ExitMenu + call ExitMenu + pop af + jr c, .DeclinedToDeposit + +.ContinueDeposit: + ld a, [wItemQuantityChangeBuffer] + ld [wBuffer1], a + ld a, [wCurItemQuantity] + ld [wBuffer2], a + ld hl, wNumPCItems + call ReceiveItem + jr nc, .NoRoomInPC + ld a, [wBuffer1] + ld [wItemQuantityChangeBuffer], a + ld a, [wBuffer2] + ld [wCurItemQuantity], a + ld hl, wNumItems + call TossItem + predef PartyMonItemName + ld hl, .PlayersPCDepositItemsText + call PrintText + ret + +.NoRoomInPC: + ld hl, .PlayersPCNoRoomDepositText + call PrintText + ret + +.DeclinedToDeposit: + and a + ret + +.PlayersPCHowManyDepositText: + text_far _PlayersPCHowManyDepositText + text_end + +.PlayersPCDepositItemsText: + text_far _PlayersPCDepositItemsText + text_end + +.PlayersPCNoRoomDepositText: + text_far _PlayersPCNoRoomDepositText + text_end + +PlayerMailBoxMenu: + farcall _PlayerMailBoxMenu + xor a + ret + +PCItemsJoypad: + xor a + ld [wSwitchItem], a +.loop + ld a, [wSpriteUpdatesEnabled] + push af + ld a, $0 + ld [wSpriteUpdatesEnabled], a + ld hl, .PCItemsMenuData + call CopyMenuHeader + hlcoord 0, 0 + ld b, 10 + ld c, 18 + call Textbox + ld a, [wPCItemsCursor] + ld [wMenuCursorBuffer], a + ld a, [wPCItemsScrollPosition] + ld [wMenuScrollPosition], a + call ScrollingMenu + ld a, [wMenuScrollPosition] + ld [wPCItemsScrollPosition], a + ld a, [wMenuCursorY] + ld [wPCItemsCursor], a + pop af + ld [wSpriteUpdatesEnabled], a + ld a, [wSwitchItem] + and a + jr nz, .moving_stuff_around + ld a, [wMenuJoypad] + cp B_BUTTON + jr z, .b_1 + cp A_BUTTON + jr z, .a_1 + cp SELECT + jr z, .select_1 + jr .next + +.moving_stuff_around + ld a, [wMenuJoypad] + cp B_BUTTON + jr z, .b_2 + cp A_BUTTON + jr z, .a_select_2 + cp SELECT + jr z, .a_select_2 + jr .next + +.b_2 + xor a + ld [wSwitchItem], a + jr .next + +.a_select_2 + call PC_PlaySwapItemsSound +.select_1 + farcall SwitchItemsInBag +.next + jp .loop + +.a_1 + farcall ScrollingMenu_ClearLeftColumn + call PlaceHollowCursor + and a + ret + +.b_1 + scf + ret + +.PCItemsMenuData: + db MENU_BACKUP_TILES ; flags + menu_coords 4, 1, 18, 10 + dw .MenuData + db 1 ; default option + +.MenuData: + db SCROLLINGMENU_ENABLE_SELECT | SCROLLINGMENU_ENABLE_FUNCTION3 | SCROLLINGMENU_DISPLAY_ARROWS ; flags + db 4, 8 ; rows, columns + db SCROLLINGMENU_ITEMS_QUANTITY ; item format + dbw 0, wNumPCItems + dba PlaceMenuItemName + dba PlaceMenuItemQuantity + dba UpdateItemDescription + +PC_DisplayText: + call MenuTextbox + call ExitMenu + ret + +PokecenterPCTurnOnText: + text_far _PokecenterPCTurnOnText + text_end + +PokecenterPCWhoseText: + text_far _PokecenterPCWhoseText + text_end + +PokecenterBillsPCText: + text_far _PokecenterBillsPCText + text_end + +PokecenterPlayersPCText: + text_far _PokecenterPlayersPCText + text_end + +PokecenterOaksPCText: + text_far _PokecenterOaksPCText + text_end + +PokecenterPCOaksClosedText: + text_far _PokecenterPCOaksClosedText + text_end diff --git a/engine/events/specials.asm b/engine/events/specials.asm index 8b7243d1..11ae421e 100755 --- a/engine/events/specials.asm +++ b/engine/events/specials.asm @@ -248,7 +248,7 @@ DisplayLinkRecord: ; c434 (3:4434) PlayersHousePC: ; c441 (3:4441) xor a ld [wScriptVar], a - farcall Function159b0 + farcall _PlayersHousePC ld a, c ld [wScriptVar], a ret diff --git a/engine/items/items.asm b/engine/items/items.asm index 7cd1de67..c24d580b 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -139,10 +139,10 @@ GetPocketCapacity: ; d290 (3:5290) .asm_d29b ld c, MAX_PC_ITEMS ld a, e - cp wPCItems % $100 + cp LOW(wNumPCItems) jr nz, .asm_d2a6 ld a, d - cp wPCItems / $100 + cp HIGH(wNumPCItems) ret z .asm_d2a6 ld c, MAX_BALLS diff --git a/engine/items/mart.asm b/engine/items/mart.asm new file mode 100644 index 00000000..3978ef33 --- /dev/null +++ b/engine/items/mart.asm @@ -0,0 +1,811 @@ + const_def + const MARTTEXT_HOW_MANY + const MARTTEXT_COSTS_THIS_MUCH + const MARTTEXT_NOT_ENOUGH_MONEY + const MARTTEXT_BAG_FULL + const MARTTEXT_HERE_YOU_GO + const MARTTEXT_SOLD_OUT + +GetMart: + ld a, e + cp (Marts.End - Marts) / 2 + jr c, .IsAMart + ld b, BANK(DefaultMart) + ld de, DefaultMart + ret + +.IsAMart: + ld hl, Marts + add hl, de + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld b, BANK(Marts) + ret + +OpenMartDialog:: + call GetMart + ld a, c + ld [wMartType], a + call LoadMartPointer + ld a, [wMartType] + ld hl, .dialogs + rst JumpTable + ret + +.dialogs + dw MartDialog + dw HerbShop + dw BargainShop + dw Pharmacist + +MartDialog: + ld a, MARTTYPE_STANDARD + ld [wMartType], a + xor a ; STANDARDMART_HOWMAYIHELPYOU + ld [wMartJumptableIndex], a + call StandardMart + ret + +HerbShop: + call FarReadMart + call LoadStandardMenuHeader + ld hl, HerbShopLadyIntroText + call MartTextbox + call BuyMenu + ld hl, HerbalLadyComeAgainText + call MartTextbox + ret + +BargainShop: + ld b, BANK(BargainShopData) + ld de, BargainShopData + call LoadMartPointer + call ReadMart + call LoadStandardMenuHeader + ld hl, BargainShopIntroText + call MartTextbox + call BuyMenu + ld hl, wBargainShopFlags + ld a, [hli] + or [hl] + jr z, .skip_set + ld hl, wDailyFlags1 + set DAILYFLAGS1_GOLDENROD_UNDERGROUND_BARGAIN_F, [hl] + +.skip_set + ld hl, BargainShopComeAgainText + call MartTextbox + ret + +Pharmacist: + call FarReadMart + call LoadStandardMenuHeader + ld hl, PharmacyIntroText + call MartTextbox + call BuyMenu + ld hl, PharmacyComeAgainText + call MartTextbox + ret + +LoadMartPointer: + ld a, b + ld [wMartPointerBank], a + ld a, e + ld [wMartPointer], a + ld a, d + ld [wMartPointer + 1], a + ld hl, wCurMart + xor a + ld bc, wCurMartEnd - wCurMart + call ByteFill + xor a ; STANDARDMART_HOWMAYIHELPYOU + ld [wMartJumptableIndex], a + ld [wBargainShopFlags], a + ld [wFacingDirection], a + ret + +; StandardMart.MartFunctions indexes + const_def + const STANDARDMART_HOWMAYIHELPYOU ; 0 + const STANDARDMART_TOPMENU ; 1 + const STANDARDMART_BUY ; 2 + const STANDARDMART_SELL ; 3 + const STANDARDMART_QUIT ; 4 + const STANDARDMART_ANYTHINGELSE ; 5 + +STANDARDMART_EXIT EQU -1 + +StandardMart: +.loop + ld a, [wMartJumptableIndex] + ld hl, .MartFunctions + rst JumpTable + ld [wMartJumptableIndex], a + cp STANDARDMART_EXIT + jr nz, .loop + ret + +.MartFunctions: +; entries correspond to STANDARDMART_* constants + dw .HowMayIHelpYou + dw .TopMenu + dw .Buy + dw .Sell + dw .Quit + dw .AnythingElse + +.HowMayIHelpYou: + call LoadStandardMenuHeader + ld hl, MartWelcomeText + call PrintText + ld a, STANDARDMART_TOPMENU + ret + +.TopMenu: + ld hl, MenuHeader_BuySell + call CopyMenuHeader + call VerticalMenu + jr c, .quit + ld a, [wMenuCursorY] + cp $1 + jr z, .buy + cp $2 + jr z, .sell +.quit + ld a, STANDARDMART_QUIT + ret +.buy + ld a, STANDARDMART_BUY + ret +.sell + ld a, STANDARDMART_SELL + ret + +.Buy: + call ExitMenu + call FarReadMart + call BuyMenu + and a + ld a, STANDARDMART_ANYTHINGELSE + ret + +.Sell: + call ExitMenu + call SellMenu + ld a, STANDARDMART_ANYTHINGELSE + ret + +.Quit: + call ExitMenu + ld hl, MartComeAgainText + call MartTextbox + ld a, STANDARDMART_EXIT + ret + +.AnythingElse: + call LoadStandardMenuHeader + ld hl, MartAskMoreText + call PrintText + ld a, STANDARDMART_TOPMENU + ret + +FarReadMart: + ld hl, wMartPointer + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wCurMart +.CopyMart: + ld a, [wMartPointerBank] + call GetFarByte + ld [de], a + inc hl + inc de + cp -1 + jr nz, .CopyMart + ld hl, wMartItem1BCD + ld de, wCurMart + 1 +.ReadMartItem: + ld a, [de] + inc de + cp -1 + jr z, .done + push de + call GetMartItemPrice + pop de + jr .ReadMartItem + +.done + ret + +GetMartItemPrice: +; Return the price of item a in BCD at hl and in tiles at wStringBuffer1. + push hl + ld [wCurItem], a + farcall GetItemPrice + pop hl + +GetMartPrice: +; Return price de in BCD at hl and in tiles at wStringBuffer1. + push hl + ld a, d + ld [wStringBuffer2], a + ld a, e + ld [wStringBuffer2 + 1], a + ld hl, wStringBuffer1 + ld de, wStringBuffer2 + lb bc, PRINTNUM_LEADINGZEROS | 2, 6 ; 6 digits + call PrintNum + pop hl + + ld de, wStringBuffer1 + ld c, 6 / 2 ; 6 digits +.loop + call .CharToNybble + swap a + ld b, a + call .CharToNybble + or b + ld [hli], a + dec c + jr nz, .loop + ret + +.CharToNybble: + ld a, [de] + inc de + cp " " + jr nz, .not_space + ld a, "0" + +.not_space + sub "0" + ret + +ReadMart: +; Load the mart pointer. Mart data is local (no need for bank). + ld hl, wMartPointer + ld a, [hli] + ld h, [hl] + ld l, a + push hl +; set hl to the first item + inc hl + ld bc, wMartItem1BCD + ld de, wCurMart + 1 +.loop +; copy the item to wCurMart + (ItemIndex) + ld a, [hli] + ld [de], a + inc de +; -1 is the terminator + cp -1 + jr z, .done + + push de +; copy the price to de + ld a, [hli] + ld e, a + ld a, [hli] + ld d, a +; convert the price to 3-byte BCD at [bc] + push hl + ld h, b + ld l, c + call GetMartPrice + ld b, h + ld c, l + pop hl + + pop de + jr .loop + +.done + pop hl + ld a, [hl] + ld [wCurMart], a + ret + +INCLUDE "data/items/bargain_shop.asm" + +BuyMenu: + call FadeToMenu + farcall BlankScreen + xor a + ld [wMenuScrollPositionBackup], a + ld a, 1 + ld [wMenuCursorBufferBackup], a +.loop + call BuyMenuLoop ; menu loop + jr nc, .loop + call CloseSubmenu + ret + +LoadBuyMenuText: +; load text from a nested table +; which table is in wMartType +; which entry is in register a + push af + call GetMartDialogGroup ; gets a pointer from GetMartDialogGroup.MartTextFunctionPointers + ld a, [hli] + ld h, [hl] + ld l, a + pop af + ld e, a + ld d, 0 + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call PrintText + ret + +MartAskPurchaseQuantity: + call GetMartDialogGroup ; gets a pointer from GetMartDialogGroup.MartTextFunctionPointers + inc hl + inc hl + ld a, [hl] + and a + jp z, StandardMartAskPurchaseQuantity + jp BargainShopAskPurchaseQuantity + +GetMartDialogGroup: + ld a, [wMartType] + ld e, a + ld d, 0 + ld hl, .MartTextFunctionPointers + add hl, de + add hl, de + add hl, de + ret + +.MartTextFunctionPointers: + dwb .StandardMartPointers, 0 + dwb .HerbShopPointers, 0 + dwb .BargainShopPointers, 1 + dwb .PharmacyPointers, 0 + +.StandardMartPointers: + dw MartHowManyText + dw MartFinalPriceText + dw MartNoMoneyText + dw MartPackFullText + dw MartThanksText + dw BuyMenuLoop + +.HerbShopPointers: + dw HerbalLadyHowManyText + dw HerbalLadyFinalPriceText + dw HerbalLadyNoMoneyText + dw HerbalLadyPackFullText + dw HerbalLadyThanksText + dw BuyMenuLoop + +.BargainShopPointers: + dw BuyMenuLoop + dw BargainShopFinalPriceText + dw BargainShopNoFundsText + dw BargainShopPackFullText + dw BargainShopThanksText + dw BargainShopSoldOutText + +.PharmacyPointers: + dw PharmacyHowManyText + dw PharmacyFinalPriceText + dw PharmacyNoMoneyText + dw PharmacyPackFullText + dw PharmacyThanksText + dw BuyMenuLoop + +BuyMenuLoop: + farcall PlaceMoneyTopRight + call UpdateSprites + ld hl, MenuHeader_Buy + call CopyMenuHeader + ld a, [wMenuCursorBufferBackup] + ld [wMenuCursorBuffer], a + ld a, [wMenuScrollPositionBackup] + ld [wMenuScrollPosition], a + call ScrollingMenu + ld a, [wMenuScrollPosition] + ld [wMenuScrollPositionBackup], a + ld a, [wMenuCursorY] + ld [wMenuCursorBufferBackup], a + call SpeechTextbox + ld a, [wMenuJoypad] + cp B_BUTTON + jr z, .set_carry + cp A_BUTTON + jr z, .useless_pointer + +.useless_pointer + call MartAskPurchaseQuantity + jr c, .cancel + call MartConfirmPurchase + jr c, .cancel + ld de, wMoney + ld bc, hMoneyTemp + ld a, 3 ; useless load + call CompareMoney + jr c, .insufficient_funds + ld hl, wNumItems + call ReceiveItem + jr nc, .insufficient_bag_space + ld a, [wMartItemID] + ld e, a + ld d, 0 + ld b, SET_FLAG + ld hl, wBargainShopFlags + call FlagAction + call PlayTransactionSound + ld de, wMoney + ld bc, hMoneyTemp + call TakeMoney + ld a, MARTTEXT_HERE_YOU_GO + call LoadBuyMenuText + call JoyWaitAorB + +.cancel + call SpeechTextbox + and a + ret + +.set_carry + scf + ret + +.insufficient_bag_space + ld a, MARTTEXT_BAG_FULL + call LoadBuyMenuText + call JoyWaitAorB + and a + ret + +.insufficient_funds + ld a, MARTTEXT_NOT_ENOUGH_MONEY + call LoadBuyMenuText + call JoyWaitAorB + and a + ret + +StandardMartAskPurchaseQuantity: + ld a, 99 + ld [wItemQuantityBuffer], a + ld a, MARTTEXT_HOW_MANY + call LoadBuyMenuText + farcall SelectQuantityToBuy + call ExitMenu + ret + +MartConfirmPurchase: + predef PartyMonItemName + ld a, MARTTEXT_COSTS_THIS_MUCH + call LoadBuyMenuText + call YesNoBox + ret + +BargainShopAskPurchaseQuantity: + ld a, 1 + ld [wItemQuantityChangeBuffer], a + ld a, [wMartItemID] + ld e, a + ld d, 0 + ld b, CHECK_FLAG + ld hl, wBargainShopFlags + call FlagAction + ld a, c + and a + jr nz, .SoldOut + ld a, [wMartItemID] + ld e, a + ld d, 0 + ld hl, wMartPointer + ld a, [hli] + ld h, [hl] + ld l, a + inc hl + add hl, de + add hl, de + add hl, de + inc hl + ld a, [hli] + ldh [hMoneyTemp + 2], a + ld a, [hl] + ldh [hMoneyTemp + 1], a + xor a + ldh [hMoneyTemp], a + and a + ret + +.SoldOut: + ld a, MARTTEXT_SOLD_OUT + call LoadBuyMenuText + call JoyWaitAorB + scf + ret + +MartHowManyText: + text_far _MartHowManyText + text_end + +MartFinalPriceText: + text_far _MartFinalPriceText + text_end + +MenuHeader_Buy: + db MENU_BACKUP_TILES ; flags + menu_coords 1, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 + dw .MenuData + db 1 ; default option + +.MenuData + db SCROLLINGMENU_DISPLAY_ARROWS | SCROLLINGMENU_ENABLE_FUNCTION3 ; flags + db 4, 8 ; rows, columns + db SCROLLINGMENU_ITEMS_NORMAL ; item format + dbw 0, wCurMart + dba PlaceMenuItemName + dba .PrintBCDPrices + dba UpdateItemDescription + +.PrintBCDPrices: + ld a, [wScrollingMenuCursorPosition] + ld c, a + ld b, 0 + ld hl, wMartItem1BCD + add hl, bc + add hl, bc + add hl, bc + push de + ld d, h + ld e, l + pop hl + ld bc, SCREEN_WIDTH + add hl, bc + ld c, PRINTNUM_LEADINGZEROS | PRINTNUM_MONEY | 3 + call PrintBCDNumber + ret + +HerbShopLadyIntroText: + text_far _HerbShopLadyIntroText + text_end + +HerbalLadyHowManyText: + text_far _HerbalLadyHowManyText + text_end + +HerbalLadyFinalPriceText: + text_far _HerbalLadyFinalPriceText + text_end + +HerbalLadyThanksText: + text_far _HerbalLadyThanksText + text_end + +HerbalLadyPackFullText: + text_far _HerbalLadyPackFullText + text_end + +HerbalLadyNoMoneyText: + text_far _HerbalLadyNoMoneyText + text_end + +HerbalLadyComeAgainText: + text_far _HerbalLadyComeAgainText + text_end + +BargainShopIntroText: + text_far _BargainShopIntroText + text_end + +BargainShopFinalPriceText: + text_far _BargainShopFinalPriceText + text_end + +BargainShopThanksText: + text_far _BargainShopThanksText + text_end + +BargainShopPackFullText: + text_far _BargainShopPackFullText + text_end + +BargainShopSoldOutText: + text_far _BargainShopSoldOutText + text_end + +BargainShopNoFundsText: + text_far _BargainShopNoFundsText + text_end + +BargainShopComeAgainText: + text_far _BargainShopComeAgainText + text_end + +PharmacyIntroText: + text_far _PharmacyIntroText + text_end + +PharmacyHowManyText: + text_far _PharmacyHowManyText + text_end + +PharmacyFinalPriceText: + text_far _PharmacyFinalPriceText + text_end + +PharmacyThanksText: + text_far _PharmacyThanksText + text_end + +PharmacyPackFullText: + text_far _PharmacyPackFullText + text_end + +PharmacyNoMoneyText: + text_far _PharmacyNoMoneyText + text_end + +PharmacyComeAgainText: + text_far _PharmacyComeAgainText + text_end + +SellMenu: + call DisableSpriteUpdates + farcall DepositSellInitPackBuffers +.loop + farcall DepositSellPack + ld a, [wPackUsedItem] + and a + jp z, .quit + call .TryToSellItem + jr .loop + +.quit + call ReturnToMapWithSpeechTextbox + and a + ret + +.Unreferenced_NothingToSell: + ld hl, .NothingToSellText + call MenuTextboxBackup + and a + ret + +.NothingToSellText: + text_far _NothingToSellText + text_end + +.TryToSellItem: + farcall CheckItemMenu + ld a, [wItemAttributeParamBuffer] + ld hl, .dw + rst JumpTable + ret + +.dw + dw .try_sell + dw .cant_buy + dw .cant_buy + dw .cant_buy + dw .try_sell + dw .try_sell + dw .try_sell + +.cant_buy + ret + +.try_sell + farcall _CheckTossableItem + ld a, [wItemAttributeParamBuffer] + and a + jr z, .okay_to_sell + ld hl, MartCantBuyText + call PrintText + and a + ret + +.okay_to_sell + ld hl, MartSellHowManyText + call PrintText + farcall PlaceMoneyAtTopLeftOfTextbox + farcall SelectQuantityToSell + call ExitMenu + jr c, .declined + hlcoord 1, 14 + lb bc, 3, 18 + call ClearBox + ld hl, MartSellPriceText + call PrintTextboxText + call YesNoBox + jr c, .declined + ld de, wMoney + ld bc, hMoneyTemp + call GiveMoney + ld a, [wMartItemID] + ld hl, wNumItems + call TossItem + predef PartyMonItemName + hlcoord 1, 14 + lb bc, 3, 18 + call ClearBox + ld hl, MartBoughtText + call PrintTextboxText + call PlayTransactionSound + farcall PlaceMoneyBottomLeft + call JoyWaitAorB + +.declined + call ExitMenu + and a + ret + +MartSellHowManyText: + text_far _MartSellHowManyText + text_end + +MartSellPriceText: + text_far _MartSellPriceText + text_end + +.UnusedString161d2: + db "!ダミー!@" + +MartWelcomeText: + text_far _MartWelcomeText + text_end + +MenuHeader_BuySell: + db MENU_BACKUP_TILES ; flags + menu_coords 0, 0, 11, 8 + dw .MenuData + db 1 ; default option + +.MenuData + db STATICMENU_CURSOR ; strings + db 3 ; items + db "BUY@" + db "SELL@" + db "QUIT@" + +MartThanksText: + text_far _MartThanksText + text_end + +MartNoMoneyText: + text_far _MartNoMoneyText + text_end + +MartPackFullText: + text_far _MartPackFullText + text_end + +MartCantBuyText: + text_far _MartCantBuyText + text_end + +MartComeAgainText: + text_far _MartComeAgainText + text_end + +MartAskMoreText: + text_far _MartAskMoreText + text_end + +MartBoughtText: + text_far _MartBoughtText + text_end + +PlayTransactionSound: + call WaitSFX + ld de, SFX_TRANSACTION + call PlaySFX + ret + +MartTextbox: + call MenuTextbox + call JoyWaitAorB + call ExitMenu + ret diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm index 0d8f7712..db0d929a 100644 --- a/engine/menus/intro_menu.asm +++ b/engine/menus/intro_menu.asm @@ -289,7 +289,7 @@ Function5c41: ; 5c41 (1:5c41) ld [wPlayerID + 1], a ld hl, wPartyCount - call Function5d15 + call .InitList xor a ld [wCurBox], a @@ -300,17 +300,17 @@ Function5c41: ; 5c41 (1:5c41) ld a, BANK(sBoxCount) call OpenSRAM ld hl, sBoxCount - call Function5d15 + call .InitList call CloseSRAM ld hl, wNumItems - call Function5d15 + call .InitList ld hl, wNumKeyItems - call Function5d15 + call .InitList ld hl, wNumBalls - call Function5d15 - ld hl, wPCItems - call Function5d15 + call .InitList + ld hl, wNumPCItems + call .InitList xor a ld [wRoamMon1Species], a @@ -373,7 +373,7 @@ ENDC call ResetGameTime ret -Function5d15: ; 5d15 (1:5d15) +.InitList: xor a ld [hli], a dec a diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm index 6324420f..2ca7e101 100755 --- a/engine/overworld/time.asm +++ b/engine/overworld/time.asm @@ -87,7 +87,7 @@ CheckDailyResetTimer: call Function1183b ret nc xor a - ld hl, wDailyFlags + ld hl, wDailyFlags1 ld [hli], a ld [hl], a jr asm_11867 @@ -170,12 +170,12 @@ Function118f8: ; 118f8 (4:58f8) call Function11972 ret - ld hl, wDailyFlags + ld hl, wDailyFlags1 set 2, [hl] ret and a - ld hl, wDailyFlags + ld hl, wDailyFlags1 bit 2, [hl] ret nz scf diff --git a/engine/pokemon/bills_pc_top.asm b/engine/pokemon/bills_pc_top.asm index 1dad31a6..38cfc479 100644 --- a/engine/pokemon/bills_pc_top.asm +++ b/engine/pokemon/bills_pc_top.asm @@ -1,4 +1,4 @@ -BillsPC_: +_BillsPC: call BillsPC_CheckHavePokemon ret c call BillsPC_LogIn @@ -22,7 +22,7 @@ BillsPC_LogIn: ; e3f7 (3:63f7) xor a ldh [hBGMapMode], a call LoadStandardMenuHeader - call Functione566 + call ClearPCItemScreen ld hl, wOptions ld a, [hl] push af @@ -116,7 +116,7 @@ BillsPC_MovePKMNMenu: jr c, .asm_e4cf farcall MovePKMNWithoutMail_ ; 38:6f47 call ReturnToMapFromSubmenu - call Functione566 + call ClearPCItemScreen .asm_e4cf call CloseWindow and a @@ -130,7 +130,7 @@ BillsPC_DepositMenu: call LoadStandardMenuHeader farcall DepositPokemon_ ; 38:6b9e call ReturnToMapFromSubmenu - call Functione566 + call ClearPCItemScreen call CloseWindow and a ret @@ -196,7 +196,7 @@ BillsPC_WithdrawMenu: call LoadStandardMenuHeader farcall WithdrawPokemon_ ; 38:6d71 call ReturnToMapFromSubmenu - call Functione566 + call ClearPCItemScreen call CloseWindow and a ret @@ -219,11 +219,11 @@ Text_CantTakeAnyMorePokemon: db "@" BillsPC_ChangeBoxMenu: - farcall ChangeBox_ ; 38:7d25 + farcall ChangeBox_ and a ret -Functione566: ; e566 (3:6566) +ClearPCItemScreen: call DisableSpriteUpdates xor a ldh [hBGMapMode], a @@ -82,16 +82,22 @@ INCLUDE "engine/overworld/load_map_part.asm" dr $153ba, $15440 ; random slots stuff? INCLUDE "engine/overworld/spawn_points.asm" INCLUDE "engine/overworld/map_setup.asm" - dr $156be, $15871 -PokemonCenterPC: - dr $15871, $159b0 -Function159b0: - dr $159b0, $1624f + dr $156be, $15871 ; ? +INCLUDE "engine/events/pokemon_pc.asm" +INCLUDE "engine/items/mart.asm" +GiveMoney: + dr $1622c, $1624f TakeMoney: dr $1624f, $16260 CompareMoney: - dr $16260, $1646d + dr $16260, $162fe +Marts: + dr $162fe, $16342 +.End: + dr $16342, $16469 +DefaultMart: + dr $16469, $1646d BankOfMom: dr $1646d, $16935 INCLUDE "engine/events/daycare.asm" @@ -143,7 +149,9 @@ LoadObjectMasks: _InitScrollingMenu:: dr $244d7, $244f3 _ScrollingMenu:: - dr $244f3, $24834 + dr $244f3, $2462e +ScrollingMenu_ClearLeftColumn: + dr $2462e, $24834 SwitchItemsInBag: dr $24834, $249dc PlaceMenuItemName: @@ -151,7 +159,11 @@ PlaceMenuItemName: PlaceMenuItemQuantity: dr $249eb, $24a10 PlaceMoneyTopRight: - dr $24a10, $24a4d + dr $24a10, $24a18 +PlaceMoneyBottomLeft: + dr $24a18, $24a20 +PlaceMoneyAtTopLeftOfTextbox: + dr $24a20, $24a4d DisplayCoinCaseBalance: dr $24a4d, $24a76 DisplayMoneyAndCoinBalance: @@ -165,15 +177,23 @@ Function24b8d: MonSubmenu: dr $24c89, $24f20 SelectQuantityToToss: - dr $24f20, $25061 + dr $24f20, $24f2a +SelectQuantityToBuy: + dr $24f2a, $24f42 +SelectQuantityToSell: + dr $24f42, $25061 TrainerCard: - dr $25061, $267ca + dr $25061, $267af +ProfOaksPC: + dr $267af, $267ca ProfOaksPCBoot: dr $267ca, $2692d InitDecorations: - dr $2692d, $270d5 + dr $2692d, $26938 +_PlayerDecorationMenu: + dr $26938, $270d5 ReceiveDecorationC: dr $270d5, $271be @@ -401,7 +421,9 @@ RestorePartyMonMail: DeletePartyMonMail: dr $44870, $4488c IsAnyPokemonHoldingMail: - dr $4488c, $44aa2 + dr $4488c, $448ab +_PlayerMailBoxMenu: + dr $448ab, $44aa2 SECTION "bank14", ROMX @@ -489,7 +511,10 @@ _PrinterReceive:: PrintMailAndExit: dr $845d4, $84684 Function84684: - dr $84684, $87bfd + dr $84684, $86632 + +_HallOfFamePC: + dr $86632, $87bfd SECTION "bank23", ROMX SaveMenu_CopyTilemapAtOnce: @@ -137,8 +137,8 @@ wPrinterConnectionOpen:: ds 1 wPrinterOpcode:: ds 1 ; c1d4 wc1d5:: ds 1 ; c1d5 wDisableTextAcceleration:: ds 1 ; c1d6 -wc1d7:: ds 1 ; c1d7 -wc1d8:: ds 1 ; c1d8 +wPCItemsCursor:: db ; c1d7 +wPCItemsScrollPosition:: db ; c1d8 wc1d9:: ds 1 ; c1d9 wc1da:: ds 1 ; c1da wc1db:: ds 1 ; c1db @@ -2318,6 +2318,19 @@ wBugContestWinnersEnd:: wBugContestWinnerName:: ds NAME_LENGTH NEXTU ; ceed +; mart items +wMartItem1BCD:: ds 3 +wMartItem2BCD:: ds 3 +wMartItem3BCD:: ds 3 +wMartItem4BCD:: ds 3 +wMartItem5BCD:: ds 3 +wMartItem6BCD:: ds 3 +wMartItem7BCD:: ds 3 +wMartItem8BCD:: ds 3 +wMartItem9BCD:: ds 3 +wMartItem10BCD:: ds 3 + +NEXTU ; ceed ; radio data wCurRadioLine:: db wNextRadioLine:: db @@ -2433,6 +2446,14 @@ wCurBGEventType:: db wCurBGEventScriptAddr:: dw NEXTU ; cf29 +; mart data +wMartType:: db +wMartPointerBank:: db +wMartPointer:: dw +wMartJumptableIndex:: db +wBargainShopFlags:: db + +NEXTU ; cf29 ; player movement data wCurInput:: wFacingTileID:: db @@ -2452,6 +2473,12 @@ NEXTU ; cf29 ; std script buffer ds 1 wJumpStdScriptBuffer:: ds 3 + +NEXTU ; cf29 +; backup menu data + ds 7 +wMenuCursorBufferBackup:: db +wMenuScrollPositionBackup:: db ENDU wcf3a:: ds 1 @@ -2562,22 +2589,26 @@ wcfe8:: ds 1 ; cfe8 wBattleResult:: ds 1 ; cfe9 wcfea:: ds 1 ; cfea wUsingItemWithSelect:: ds 1 ; cfeb -wCurElevator:: db ; cfec -wCurElevatorFloors:: ds 1 ; cfed -wcfee:: ds 1 ; cfee -wcfef:: ds 1 ; cfef -wcff0:: ds 1 ; cff0 -wcff1:: ds 1 ; cff1 -wcff2:: ds 1 ; cff2 -wcff3:: ds 1 ; cff3 -wcff4:: ds 1 ; cff4 -wcff5:: ds 1 ; cff5 -wcff6:: ds 1 ; cff6 -wcff7:: ds 1 ; cff7 -wcff8:: ds 1 ; cff8 -wcff9:: ds 1 ; cff9 -wcffa:: ds 1 ; cffa -wcffb:: ds 1 ; cffb + +UNION ; cfec +; mart data +wCurMart:: ds 16 +wCurMartEnd:: + +NEXTU ; cfec +; elevator data +wCurElevator:: db +wCurElevatorFloors:: db + +NEXTU ; cfec +; mailbox data +wCurMessageScrollPosition:: db +wCurMessageIndex:: db +wMailboxCount:: db +wMailboxItems:: ds MAILBOX_CAPACITY +wMailboxEnd:: ; d0fe +ENDU ; cffc + wcffc:: ds 1 ; cffc wcffd:: ds 1 ; cffd wcffe:: ds 1 ; cffe @@ -2587,7 +2618,9 @@ SECTION "WRAM1", WRAMX, BANK[$1] wd000:: ds 1 ; d000 wd001:: ds 1 ; d001 wCurItem:: db ; d002 -wCurItemQuantity:: db ; d003 +wCurItemQuantity:: ; d003 +wMartItemID:: + db wCurPartySpecies:: ; d004 ds 1 @@ -3151,11 +3184,10 @@ wNumBalls:: ds 1 ; d5fc wBalls:: ds MAX_BALLS * 2 + 1 ; d5fd wBallsEnd:: +wNumPCItems:: ds 1 wPCItems:: ds MAX_PC_ITEMS * 2 + 1 ; d616 wPCItemsEnd:: - ds 1 - wPokegearFlags:: ; d67c ; bit 0: map ; bit 1: radio @@ -3174,7 +3206,7 @@ wRegisteredItem:: ds 1 ; d681 wPlayerState:: ds 1 ; d682 -wd683:: ds 1 ; d683 +wHallOfFameCount:: db ; d683 wd684:: ds 1 ; d684 wd685:: ds 1 ; d685 wd686:: ds 1 ; d686 @@ -3545,8 +3577,8 @@ wd962:: ds 1 ; d962 wMomItemTriggerBalance:: ds 3 ; d963 wDailyResetTimer:: dw ; d966 -wDailyFlags:: ds 1 ; d968 -wWeeklyFlags:: ds 1 ; d969 +wDailyFlags1:: db ; d968 +wDailyFlags2:: db ; d969 wd96a:: ds 1 ; d96a wd96b:: ds 1 ; d96b wd96c:: ds 1 ; d96c |