diff options
author | Bryan Bishop <kanzure@gmail.com> | 2012-01-11 11:45:21 -0600 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2012-01-11 11:45:21 -0600 |
commit | 3dc998e060b0b5eef9edfdb7f48cceb4f8d318fa (patch) | |
tree | 297f43bd38afdf5235f8d338c99dec84fbaa8d70 | |
parent | 58f94c6b0d21f4bf12684dc9bac9244d33dcf92c (diff) | |
parent | 92a0acca73fcb9c71b01757da9ceadc7e862355e (diff) |
Merge in sawakita's coincase work.
hg-commit-id: 3265210c8894
-rw-r--r-- | constants.asm | 11 | ||||
-rw-r--r-- | pokered.asm | 482 |
2 files changed, 462 insertions, 31 deletions
diff --git a/constants.asm b/constants.asm index f3ec0a5c..dafee50e 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 @@ -139,10 +141,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 @@ -150,6 +158,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 d2eb5b4f..9e929b91 100644 --- a/pokered.asm +++ b/pokered.asm @@ -1165,31 +1165,31 @@ Route2Text2: ; 0x24f4 INCBIN "baserom.gbc",$24fd,$2f9e - $24fd -GetMonName: ; 0x2f9e - push hl - ld a, [$ff00+$b8] - push af - ld a, $7 - ldh [$b8], a - ld [$2000], a - ld a, [$d11e] - dec a - ld hl, $421e - ld c, $a - ld b, $0 - call $3a87 - ld de, $cd6d - push de - ld bc, $000a - call CopyData - ld hl, $cd77 - ld [hl], $50 - pop de - pop af - ldh [$b8], a - ld [$2000], a - pop hl - ret +GetMonName: ; 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 @@ -1275,6 +1275,7 @@ HiddenPrefix: db "HM" INCBIN "baserom.gbc",$3040,$31cc - $3040 + LoadTrainerHeader: ; 0x31cc call $3157 xor a @@ -1336,10 +1337,22 @@ LoadTrainerHeader: ; 0x31cc inc [hl] ret -INCBIN "baserom.gbc",$324c,$247 +INCBIN "baserom.gbc",$324c,$3474 - $324c -Function3493: ; 3493 -; XXX what does this do +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 ; related to Pokémon Tower and ghosts ld a,$1C call Predef @@ -13867,7 +13880,7 @@ Function583A: ; 583A cp a,$95 ; Pokémon Tower jr nc,.next\@ ld b,SILPH_SCOPE - call Function3493 + call IsItemInBag ; $3493 ret z .next\@ ld a,1 @@ -21010,7 +21023,377 @@ 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 + 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 GetMonName + FuncCoord 2,4 + ld hl,Coord + call PlaceString + ld a,[W_PRIZE2] + ld [$D11E],a + call GetMonName + FuncCoord 2,6 + ld hl,Coord + call PlaceString + ld a,[W_PRIZE3] + ld [$D11E],a + call GetMonName + 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 GetMonName +.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] @@ -30457,7 +30840,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:62E7 + 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 |