From e590a10b8136656570d84af27f2907f2e1f57e3c Mon Sep 17 00:00:00 2001 From: Sawakita Date: Sun, 8 Jan 2012 14:07:32 +0100 Subject: Function3493 is now labeled CheckBagItemExist. hg-commit-id: 8afe60ff982a --- pokered.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokered.asm b/pokered.asm index 102127d5..e25e9c81 100644 --- a/pokered.asm +++ b/pokered.asm @@ -1090,7 +1090,7 @@ HiddenPrefix: INCBIN "baserom.gbc",$3040,$3493 - $3040 -Function3493: ; 3493 +CheckBagItemExist: ; $3493: ; 3493 ; XXX what does this do ; related to Pokémon Tower and ghosts ld a,$1C @@ -12146,7 +12146,7 @@ Function583A: ; 583A cp a,$95 ; Pokémon Tower jr nc,.next\@ ld b,SILPH_SCOPE - call Function3493 + call CheckBagItemExist ; $3493 ret z .next\@ ld a,1 -- cgit v1.2.3 From 4b11f36a0aff0751dedf2b536b40b5424b3b3871 Mon Sep 17 00:00:00 2001 From: Sawakita Date: Sun, 8 Jan 2012 14:12:18 +0100 Subject: Add explanatory comment to function CheckBagItemExist ($3493). hg-commit-id: 1765b4515253 --- pokered.asm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pokered.asm b/pokered.asm index e25e9c81..248dbb1e 100644 --- a/pokered.asm +++ b/pokered.asm @@ -1091,8 +1091,9 @@ HiddenPrefix: INCBIN "baserom.gbc",$3040,$3493 - $3040 CheckBagItemExist: ; $3493: ; 3493 -; XXX what does this do -; related to Pokémon Tower and ghosts +; given an item_id in b +; set zero flag if item isn't in player's bag +; else reset zero flag ld a,$1C call Predef ld a,b -- cgit v1.2.3 From cdaf8e3d9a8fe4c3e9c53269424aada468fdb6ab Mon Sep 17 00:00:00 2001 From: Sawakita Date: Sun, 8 Jan 2012 23:45:46 +0100 Subject: Add function to get a monster's name from a given id (internal order). hg-commit-id: 42e7deffd9b8 --- constants.asm | 6 ++++++ pokered.asm | 29 +++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/constants.asm b/constants.asm index 6275215c..9d4b4a7e 100644 --- a/constants.asm +++ b/constants.asm @@ -137,10 +137,16 @@ W_CURENEMYLVL EQU $D127 W_ISLINKBATTLE EQU $D12B +W_PRIZE1 EQU $D13D +W_PRIZE2 EQU $D13E +W_PRIZE3 EQU $D13F + W_PLAYERNAME EQU $D158 ; 11 characters, including null W_NUMINPARTY EQU $D163 +W_NUMBAGITEMS EQU $D31D + W_RIVALNAME EQU $D34A ; 11 characters, including null W_CURMAP EQU $D35E diff --git a/pokered.asm b/pokered.asm index 248dbb1e..497ea609 100644 --- a/pokered.asm +++ b/pokered.asm @@ -1003,7 +1003,32 @@ MartInventories: ; 2442 db $FE,7,ULTRA_BALL,GREAT_BALL,FULL_RESTORE,MAX_POTION,FULL_HEAL db REVIVE,MAX_REPEL,$FF -INCBIN "baserom.gbc",$24D6,$2FCF - $24D6 +INCBIN "baserom.gbc",$24D6,$2F9E - $24D6 +GetMonsterName: ; 2F9E + push hl + ld a,[$ffb8] + push af + ld a,BANK(MonsterNames) ; 07 + ld [$ffb8],a + ld [$2000],a + ld a,[$d11e] + dec a + ld hl,MonsterNames ; 421E + ld c,10 + ld b,0 + call AddNTimes + ld de,$cd6d + push de + ld bc,10 + call CopyData + ld hl,$cd77 + ld [hl],$50 + pop de + pop af + ld [$ffb8],a + ld [$2000],a + pop hl + ret GetItemName: ; 2FCF ; given an item ID at [$D11E], store the name of the item into a string @@ -1247,7 +1272,7 @@ GetName: ; 376B dec a jr nz,.otherEntries\@ ;1 = MON_NAMES - call $2f9e; GetMonName + call GetMonsterName ld hl,11 add hl,de ld e,l -- cgit v1.2.3 From 6ca9439c651672a306d42659cd0772439b6450f9 Mon Sep 17 00:00:00 2001 From: Sawakita Date: Tue, 10 Jan 2012 23:54:38 +0100 Subject: Function $3493, former CheckBagItemExist, is now called IsItemInBag (consistency). Added base routine for text-special id $F7 hg-commit-id: 105c01affa23 --- constants.asm | 5 +++++ pokered.asm | 22 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/constants.asm b/constants.asm index 9d4b4a7e..f5e5a67a 100644 --- a/constants.asm +++ b/constants.asm @@ -2,6 +2,8 @@ RED EQU 1 BLUE EQU 0 GREEN EQU 0 +;\1 = X +;\2 = Y FuncCoord: MACRO Coord = $C3A0 + 20 * \2 + \1 ENDM @@ -154,6 +156,9 @@ W_CURMAP EQU $D35E W_YCOORD EQU $D361 ; player’s position on the current map W_XCOORD EQU $D362 +W_PLAYERCOINS1 EQU $D5A4 +W_PLAYERCOINS2 EQU $D5A5 + W_RIVALSTARTER EQU $D715 W_PLAYERSTARTER EQU $D717 diff --git a/pokered.asm b/pokered.asm index 497ea609..327bf7ed 100644 --- a/pokered.asm +++ b/pokered.asm @@ -1113,9 +1113,19 @@ TechnicalPrefix: HiddenPrefix: db "HM" -INCBIN "baserom.gbc",$3040,$3493 - $3040 +INCBIN "baserom.gbc",$3040,$3474 - $3040 -CheckBagItemExist: ; $3493: ; 3493 +FuncTX_F7: ; 3474 +; XXX find a better name for this function +; special_F7 + ld b,BANK(CeladonPrizeMenu) + ld hl,CeladonPrizeMenu + call Bankswitch + jp $29DF ; continue to main text-engine function + +INCBIN "baserom.gbc",$347F,$3493 - $347F + +IsItemInBag: ; 3493 ; given an item_id in b ; set zero flag if item isn't in player's bag ; else reset zero flag @@ -12172,7 +12182,7 @@ Function583A: ; 583A cp a,$95 ; Pokémon Tower jr nc,.next\@ ld b,SILPH_SCOPE - call CheckBagItemExist ; $3493 + call IsItemInBag ; $3493 ret z .next\@ ld a,1 @@ -17310,7 +17320,11 @@ Mansion4Object: ; 0x52498 (size=69) ; warp-to EVENT_DISP $f, $16, $17 ; MANSION_1 -INCBIN "baserom.gbc",$524dd,$1b23 +INCBIN "baserom.gbc",$524DD,$5271B - $524DD + +CeladonPrizeMenu: ; 14:671B +INCBIN "baserom.gbc",$5271B,$54000 - $5271B +;INCBIN "baserom.gbc",$52996,$54000 - $52996 SECTION "bank15",DATA,BANK[$15] -- cgit v1.2.3 From 722120503405b6f3f707d26dd2317938cb8d7ff7 Mon Sep 17 00:00:00 2001 From: Sawakita Date: Wed, 11 Jan 2012 01:16:24 +0100 Subject: Add texts used in Prize Corner Menu script (aka text-special $F7). Add also what seems a leftover unused text. hg-commit-id: 0dfe514a7bbb --- pokered.asm | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/pokered.asm b/pokered.asm index 327bf7ed..449f7d6e 100644 --- a/pokered.asm +++ b/pokered.asm @@ -23445,7 +23445,44 @@ _CantMoveText: db 0,$5A,$4F db "can't move!",$58 -INCBIN "baserom.gbc",$89A29,$8A425 - $89A29 +INCBIN "baserom.gbc",$89A29,$8A28E - $89A29 + +_RequireCoinCaseText: ; 22:628E + db 0,"A COIN CASE is",$4F + db "required!@@" + +_ExchangeCoinsForPrizesText: ; 22:62A9 + db 0,"We exchange your",$4F + db "coins for prizes.",$58 + +_WhichPrizeText: ; 22:62CD + db 0,"Which prize do",$4F + db "you want?",$57 + +_HereYouGoText: ; 22:62E6 + db 0,"Here you go!@@" + +_SoYouWantPrizeText: ; 22:62F6 + db 0,"So, you want",$4F + db "@" + db 1 + dw $CD6D + db 0,"?",$57 + +_SorryNeedMoreCoins: ; 22:630B + db 0,"Sorry, you need",$4F + db "more coins.@@" + +_OopsYouDontHaveEnoughRoomText: ; 22:6329 + db 0,"Oops! You don't",$4F + db "have enough room.@@" + +_OhFineThenText: ; 22:634C + db 0,"Oh, fine then.@@" +;635d + +INCBIN "baserom.gbc",$8A35D,$8A425 - $8A35D + INCLUDE "text/oakspeech.tx" INCBIN "baserom.gbc",$8A605,$6696 - $6605 -- cgit v1.2.3 From 92a0acca73fcb9c71b01757da9ceadc7e862355e Mon Sep 17 00:00:00 2001 From: Sawakita Date: Wed, 11 Jan 2012 16:30:43 +0100 Subject: Add complete Text-special command $F7, used in CeladonPrizeRoom's menus. Add also some unused data. hg-commit-id: 1aa76dd5de95 --- pokered.asm | 372 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 369 insertions(+), 3 deletions(-) diff --git a/pokered.asm b/pokered.asm index 449f7d6e..0199cffc 100644 --- a/pokered.asm +++ b/pokered.asm @@ -17323,8 +17323,374 @@ Mansion4Object: ; 0x52498 (size=69) INCBIN "baserom.gbc",$524DD,$5271B - $524DD CeladonPrizeMenu: ; 14:671B -INCBIN "baserom.gbc",$5271B,$54000 - $5271B -;INCBIN "baserom.gbc",$52996,$54000 - $52996 + ld b,COIN_CASE + call IsItemInBag + jr nz,.havingCoinCase\@ + ld hl,RequireCoinCaseTextPtr + jp PrintText +.havingCoinCase\@ + ld hl,$D730 + set 6,[hl] + ld hl,ExchangeCoinsForPrizesTextPtr + call PrintText +; the following are the menu settings + xor a + ld [$CC26],a + ld [$CC2A],a + ld a,$03 + ld [$CC29],a + ld a,$03 + ld [$CC28],a + ld a,$04 + ld [$CC24],a + ld a,$01 + ld [$CC25],a + call PrintPrizePrice ; 687A + FuncCoord 0,2 + ld hl,Coord + ld b,$08 + ld c,$10 + call TextBoxBorder + call GetPrizeMenuId ;678E + call $2429 + ld hl,WhichPrizeTextPtr + call PrintText + call $3ABE ; menu choice handler + bit 1,a ; keypress = B (Cancel) + jr nz,.NoChoice\@ + ld a,[$CC26] + cp a,$03 ; "NO,THANKS" choice + jr z,.NoChoice\@ + call HandlePrizeChoice ; 14:68C6 +.NoChoice\@ + ld hl,$D730 + res 6,[hl] + ret + +RequireCoinCaseTextPtr: ; 14:677E + TX_FAR _RequireCoinCaseText ; 22:628E + db $0D + db "@" + +ExchangeCoinsForPrizesTextPtr: ; 14:6784 + TX_FAR _ExchangeCoinsForPrizesText ; 22:62A9 + db "@" + +WhichPrizeTextPtr: ; 14:6789 + TX_FAR _WhichPrizeText ; 22:62CD + db "@" + +GetPrizeMenuId: ; 14:678E +; determine which one among the three +; prize-texts has been selected +; using the text ID (stored in [$FF8C]) +; load the three prizes at $D13D-$D13F +; load the three prices ar $D141-$D146 +; display the three prizes' names +; (distinguishing between Pokemon names +; and Items (specifically TMs) names) + ld a,[$FF8C] + sub a,$03 ; prize-texts' id are 3, 4 and 5 + ld [$D12F],a ; prize-texts' id (relative, i.e. 0, 1 or 2) + add a + add a + ld d,$00 + ld e,a + ld hl,PrizeDifferentMenuPtrs + add hl,de + ld a,[hli] + ld d,[hl] + ld e,a + inc hl + push hl + ld hl,W_PRIZE1 + call $3829 ; XXX what does this do + pop hl + ld a,[hli] + ld h,[hl] + ld l,a + ld de,$D141 + ld bc,$0006 + call CopyData + ld a,[$D12F] + cp a,$02 ;is TM_menu? + jr nz,.putMonName\@ + ld a,[W_PRIZE1] + ld [$D11E],a + call GetItemName + FuncCoord 2,4 + ld hl,Coord + call PlaceString + ld a,[W_PRIZE2] + ld [$D11E],a + call GetItemName + FuncCoord 2,6 + ld hl,Coord + call PlaceString + ld a,[W_PRIZE3] + ld [$D11E],a + call GetItemName + FuncCoord 2,8 + ld hl,Coord + call PlaceString + jr .putNoThanksText\@ +.putMonName\@ ; 14:67EC + ld a,[W_PRIZE1] + ld [$D11E],a + call GetMonsterName + FuncCoord 2,4 + ld hl,Coord + call PlaceString + ld a,[W_PRIZE2] + ld [$D11E],a + call GetMonsterName + FuncCoord 2,6 + ld hl,Coord + call PlaceString + ld a,[W_PRIZE3] + ld [$D11E],a + call GetMonsterName + FuncCoord 2,8 + ld hl,Coord + call PlaceString +.putNoThanksText\@ ; 14:6819 + FuncCoord 2,10 + ld hl,Coord + ld de,NoThanksText + call PlaceString +; put prices on the right side of the textbox + ld de,$D141 + FuncCoord 13,5 + ld hl,Coord +; reg. c: +; [low nybble] number of bytes +; [bit 765 = %100] space-padding (not zero-padding) + ld c,(1 << 7 | 2) +; Function $15CD displays BCD value (same routine +; used by text-command $02) + call $15CD ; Print_BCD + ld de,$D143 + FuncCoord 13,7 + ld hl,Coord + ld c,(%1 << 7 | 2) + call $15CD + ld de,$D145 + FuncCoord 13,9 + ld hl,Coord + ld c,(1 << 7 | 2) + jp $15CD + +PrizeDifferentMenuPtrs: ; 14:6843 + dw PrizeMenuMon1Entries + dw PrizeMenuMon1Cost + + dw PrizeMenuMon2Entries + dw PrizeMenuMon2Cost + + dw PrizeMenuTMsEntries + dw PrizeMenuTMsCost + +NoThanksText: ; 14:684F + db "NO THANKS@" + +PrizeMenuMon1Entries: ; 14:6859 + db ABRA + db CLEFAIRY + db NIDORINA + db "@" +PrizeMenuMon1Cost: ; 14:685D + db $01,$80 + db $05,$00 + db $12,$00 + db "@" + +PrizeMenuMon2Entries: ; 14:6864 + db DRATINI + db SCYTHER + db PORYGON + db "@" +PrizeMenuMon2Cost: ; 14:6868 + db $28,$00 ; 2800 Coins + db $55,$00 ; 5500 Coins + db $99,$99 ; 9999 Coins + db "@" + +PrizeMenuTMsEntries: ; 14:686F + db TM_23 + db TM_15 + db TM_50 + db "@" +PrizeMenuTMsCost: ; 14:6873 + db $33,$00 ; 3300 Coins + db $55,$00 ; 5500 Coins + db $77,$00 ; 7700 Coins + db "@" + +PrintPrizePrice: ; 14:687A + FuncCoord 11,0 + ld hl,Coord + ld b,$01 + ld c,$07 + call TextBoxBorder + call $2429 ; XXX save OAM? + FuncCoord 12,0 + ld hl,Coord + ld de,.CoinText\@ + call PlaceString + FuncCoord 13,1 + ld hl,Coord + ld de,.SixSpacesText\@ + call PlaceString + FuncCoord 13,1 + ld hl,Coord + ld de,W_PLAYERCOINS1 + ld c,%10000010 + call $15CD + ret + +.CoinText\@ ; 14:68A5 + db "COIN@" + +.SixSpacesText\@ ; 14:68AA + db " @" + +LoadCoinsToSubtract: ; 14:68B1 + ld a,[$D139] ; backup of selected menu_entry + add a + ld d,$00 + ld e,a + ld hl,$D141 ; first prize's price + add hl,de ; get selected prize's price + xor a + ld [$FF9F],a + ld a,[hli] + ld [$FFA0],a + ld a,[hl] + ld [$FFA1],a + ret + +HandlePrizeChoice: ; 14:68C6 + ld a,[$CC26] ; selected menu_entry + ld [$D139],a + ld d,$00 + ld e,a + ld hl,W_PRIZE1 + add hl,de + ld a,[hl] + ld [$D11E],a + ld a,[$D12F] + cp a,$02 ; is prize a TM? + jr nz,.GetMonName\@ + call GetItemName + jr .GivePrize\@ +.GetMonName\@ ; 14:68E3 + call GetMonsterName +.GivePrize\@ ; 14:68E6 + ld hl,SoYouWantPrizeTextPtr + call PrintText + call $35EC ; yes/no textbox + ld a,[$CC26] ; yes/no answer (Y=0, N=1) + and a + jr nz,.PrintOhFineThen\@ + call LoadCoinsToSubtract + call $35B1 ; subtract COINs from COIN_CASE + jr c,.NotEnoughCoins\@ + ld a,[$D12F] + cp a,$02 + jr nz,.GiveMon\@ + ld a,[$D11E] + ld b,a + ld a,$01 + ld c,a + call $3E2E ; GiveItem + jr nc,.BagIsFull\@ + jr .SubtractCoins\@ +.GiveMon\@ ; 14:6912 + ld a,[$D11E] + ld [$CF91],a + push af + call GetPrizeMonLevel ; 14:6977 + ld c,a + pop af + ld b,a + call $3E48 ; GivePokemon + push af + ld a,[$CCD3] ; XXX is there room? + and a + call z,$3865 + pop af + ret nc +.SubtractCoins\@ ; 14:692C + call LoadCoinsToSubtract + ld hl,$FFA1 + ld de,W_PLAYERCOINS2 + ld c,$02 ; how many bytes + ld a,$0C + call Predef ; subtract coins (BCD daa operations) + jp PrintPrizePrice +.BagIsFull\@ ; 14:693F + ld hl,PrizeRoomBagIsFullTextPtr + jp PrintText +.NotEnoughCoins\@ ; 14:6945 + ld hl,SorryNeedMoreCoinsTextPtr + jp PrintText +.PrintOhFineThen\@ ; 14:694B + ld hl,OhFineThenTextPtr + jp PrintText + +UnknownData52951: ; 14:6951 +; XXX what's this? + db $00,$01,$00,$01,$00,$01,$00,$00,$01 + +HereYouGoTextPtr: + TX_FAR _HereYouGoText ; 22:62E7 + db $0D + db "@" + +SoYouWantPrizeTextPtr: ; 14:6960 + TX_FAR _SoYouWantPrizeText ; 22:62F6 + db "@" + +SorryNeedMoreCoinsTextPtr: ; 14:6965 + TX_FAR _SorryNeedMoreCoins ; 22:630B + db $0D + db "@" + +PrizeRoomBagIsFullTextPtr: ; 14:696B + TX_FAR _OopsYouDontHaveEnoughRoomText ; 22:6329 + db $0D + db "@" + +OhFineThenTextPtr: ; 14:6971 + TX_FAR _OhFineThenText; 22:634C + db $0D ; wait keypress (A/B) without blink + db "@" + +GetPrizeMonLevel: ; 14:6977 + ld a,[$CF91] + ld b,a + ld hl,PrizeMonLevelDictionary +.loop\@ ; 14:697E + ld a,[hli] + cp b + jr z,.matchFound\@ + inc hl + jr .loop\@ +.matchFound\@ ; 14:6985 + ld a,[hl] + ld [$D127],a + ret + +PrizeMonLevelDictionary: ; 14:698A + db ABRA,9 + db CLEFAIRY,8 + db NIDORINA,17 + + db DRATINI,18 + db SCYTHER,25 + db PORYGON,26 + +INCBIN "baserom.gbc",$52996,$54000 - $52996 SECTION "bank15",DATA,BANK[$15] @@ -23459,7 +23825,7 @@ _WhichPrizeText: ; 22:62CD db 0,"Which prize do",$4F db "you want?",$57 -_HereYouGoText: ; 22:62E6 +_HereYouGoText: ; 22:62E7 db 0,"Here you go!@@" _SoYouWantPrizeText: ; 22:62F6 -- cgit v1.2.3