diff options
33 files changed, 247 insertions, 162 deletions
| diff --git a/engine/battle/core.asm b/engine/battle/core.asm index b3d82f8c..77f0c0c6 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2310,7 +2310,7 @@ UseBagItem:  	call GetItemName  	call CopyStringToCF4B ; copy name  	xor a -	ld [wd152], a +	ld [wPseudoItemID], a  	call UseItem  	call LoadHudTilePatterns  	call ClearSprites diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm index 788dd777..aad8c468 100755 --- a/engine/hidden_object_functions17.asm +++ b/engine/hidden_object_functions17.asm @@ -349,12 +349,21 @@ GymTrashScript: ; 5ddfc (17:5dfc)  	add hl, de  	ld a, [hli] -	ld [$ffdb], a +; There is a bug in this code. It should calculate a value in the range [0, 3] +; but if the mask and random number don't have any 1 bits in common, then +; the result of the AND will be 0. When 1 is subtracted from that, the value +; will become $ff. This will result in 255 being added to hl, which will cause +; hl to point to one of the zero bytes that pad the end of the ROM bank. +; Trash can 0 was intended to be able to have the second lock only when the +; first lock was in trash can 1 or 3. However, due to this bug, trash can 0 can +; have the second lock regardless of which trash can had the first lock. + +	ld [hGymTrashCanRandNumMask], a  	push hl  	call Random  	swap a  	ld b, a -	ld a, [$ffdb] +	ld a, [hGymTrashCanRandNumMask]  	and b  	dec a  	pop hl @@ -398,6 +407,12 @@ GymTrashScript: ; 5ddfc (17:5dfc)  	jp PrintPredefTextID  GymTrashCans: ; 5de7d (17:5e7d) +; byte 0: mask for random number +; bytes 1-4: indices of the trash cans that can have the second lock +;            (but see the comment above explaining a bug regarding this) +; Note that the mask is simply the number of valid trash can indices that +; follow. The remaining bytes are filled with 0 to pad the length of each entry +; to 5 bytes.  	db 2,  1,  3,  0,  0 ; 0  	db 3,  0,  2,  4,  0 ; 1  	db 2,  1,  5,  0,  0 ; 2 diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm index 00744c5d..0a93fd44 100755 --- a/engine/hidden_object_functions18.asm +++ b/engine/hidden_object_functions18.asm @@ -19,7 +19,7 @@ GymStatues: ; 62419 (18:6419)  	jr .loop  .match  	ld b, [hl] -	ld a, [wd72a] +	ld a, [wBeatGymFlags]  	and b  	cp b  	tx_pre_id GymStatueText2 diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm index 4e76d996..e3c296ca 100755 --- a/engine/hidden_object_functions7.asm +++ b/engine/hidden_object_functions7.asm @@ -125,21 +125,21 @@ PrintCinnabarQuiz: ; 1ea17 (7:6a17)  CinnabarGymQuiz: ; 1ea25 (7:6a25)  	TX_ASM  	xor a -	ld [wda38], a +	ld [wOpponentAfterWrongAnswer], a  	ld a, [wHiddenObjectFunctionArgument]  	push af  	and $f -	ld [$ffdb], a +	ld [hGymGateIndex], a  	pop af  	and $f0  	swap a  	ld [$ffdc], a  	ld hl, CinnabarGymQuizIntroText  	call PrintText -	ld a, [$ffdb] +	ld a, [hGymGateIndex]  	dec a  	add a -	ld d, $0 +	ld d, 0  	ld e, a  	ld hl, CinnabarQuizQuestions  	add hl, de @@ -198,10 +198,10 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)  	ld c, a  	ld a, [wCurrentMenuItem]  	cp c -	jr nz, .asm_1eab8 +	jr nz, .wrongAnswer  	ld hl, wd126  	set 5, [hl] -	ld a, [$ffdb] +	ld a, [hGymGateIndex]  	ld [$ffe0], a  	ld hl, CinnabarGymQuizCorrectText  	call PrintText @@ -211,14 +211,14 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)  	ld b, FLAG_SET  	call CinnabarGymGateFlagAction  	jp UpdateCinnabarGymGateTileBlocks_ -.asm_1eab8 +.wrongAnswer  	call WaitForSoundToFinish  	ld a, SFX_DENIED  	call PlaySound  	call WaitForSoundToFinish  	ld hl, CinnabarGymQuizIncorrectText  	call PrintText -	ld a, [$ffdb] +	ld a, [hGymGateIndex]  	add $2  	AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2  	ld c, a @@ -228,9 +228,9 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)  	ld a, c  	and a  	ret nz -	ld a, [$ffdb] +	ld a, [hGymGateIndex]  	add $2 -	ld [wda38], a +	ld [wOpponentAfterWrongAnswer], a  	ret  CinnabarGymQuizCorrectText: ; 1eae3 (7:6ae3) @@ -261,9 +261,9 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)  ; Update the overworld map with open floor blocks or locked gate blocks  ; depending on event flags.  	ld a, 6 -	ld [$ffdb], a +	ld [hGymGateIndex], a  .loop -	ld a, [$ffdb] +	ld a, [hGymGateIndex]  	dec a  	add a  	add a @@ -276,9 +276,9 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)  	ld c, a  	inc hl  	ld a, [hl] -	ld [wd12f], a +	ld [wGymGateTileBlock], a  	push bc -	ld a, [$ffdb] +	ld a, [hGymGateIndex]  	ld [$ffe0], a  	AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0  	ld c, a @@ -287,7 +287,7 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)  	ld a, c  	and a  	jr nz, .unlocked -	ld a, [wd12f] +	ld a, [wGymGateTileBlock]  	jr .next  .unlocked  	ld a, $e @@ -295,7 +295,7 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)  	pop bc  	ld [wNewTileBlockID], a  	predef ReplaceTileBlock -	ld hl, $ffdb +	ld hl, hGymGateIndex  	dec [hl]  	jr nz, .loop  	ret diff --git a/engine/items/items.asm b/engine/items/items.asm index 5669f012..7f16691d 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -628,7 +628,7 @@ ItemUseEvoStone: ; da5b (3:5a5b)  	ld a,[wWhichPokemon]  	push af  	ld a,[wcf91] -	ld [wd156],a +	ld [wEvoStoneItemID],a  	push af  	ld a,EVO_STONE_PARTY_MENU  	ld [wPartyMenuTypeOrMessageID],a @@ -679,7 +679,7 @@ ItemUseMedicine: ; dabb (3:5abb)  	ld [wPartyMenuTypeOrMessageID],a  	ld a,$ff  	ld [wUpdateSpritesEnabled],a -	ld a,[wd152] +	ld a,[wPseudoItemID]  	and a ; using Softboiled?  	jr z,.notUsingSoftboiled  ; if using softboiled @@ -712,7 +712,7 @@ ItemUseMedicine: ; dabb (3:5abb)  	ld [wcf91],a  	pop af  	ld [wWhichPokemon],a -	ld a,[wd152] +	ld a,[wPseudoItemID]  	and a ; using Softboiled?  	jr z,.checkItemType  ; if using softboiled @@ -865,7 +865,7 @@ ItemUseMedicine: ; dabb (3:5abb)  	ld [wHPBarMaxHP+1],a  	ld a,[hl]  	ld [wHPBarMaxHP],a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian) -	ld a,[wd152] +	ld a,[wPseudoItemID]  	and a ; using Softboiled?  	jp z,.notUsingSoftboiled2  ; if using softboiled @@ -1052,7 +1052,7 @@ ItemUseMedicine: ; dabb (3:5abb)  	call ItemUseNoEffect  	jp .done  .doneHealing -	ld a,[wd152] +	ld a,[wPseudoItemID]  	and a ; using Softboiled?  	jr nz,.skipRemovingItem ; no item to remove if using Softboiled  	push hl @@ -1107,7 +1107,7 @@ ItemUseMedicine: ; dabb (3:5abb)  	pop af  	pop af  .done -	ld a,[wd152] +	ld a,[wPseudoItemID]  	and a ; using Softboiled?  	ret nz ; if so, return  	call GBPalWhiteOut @@ -1381,7 +1381,7 @@ ItemUseEscapeRope: ; dfaf (3:5faf)  	inc a  	ld [wEscapedFromBattle],a  	ld [wActionResultOrTookBattleTurn],a ; item used -	ld a,[wd152] +	ld a,[wPseudoItemID]  	and a ; using Dig?  	ret nz ; if so, return  	call ItemUseReloadOverworldData @@ -1419,7 +1419,7 @@ ItemUseXAccuracy: ; e013 (3:6013)  ; The Card Key is handled in a different way.  ItemUseCardKey: ; e022 (3:6022)  	xor a -	ld [wd71f],a +	ld [wUnusedD71F],a  	call GetTileAndCoordsInFrontOfPlayer  	ld a,[GetTileAndCoordsInFrontOfPlayer] ; $4586  	cp a,$18 @@ -1451,7 +1451,7 @@ ItemUseCardKey: ; e022 (3:6022)  	cp e  	jr nz,.nextEntry3  	ld a,[hl] -	ld [wd71f],a +	ld [wUnusedD71F],a  	jr .done  .nextEntry1  	inc hl diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index a46abf2a..994841d3 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -278,7 +278,7 @@ LinkMenu: ; 5c0a (1:5c0a)  	ld [wSerialExchangeNybbleSendData], a  	inc a ; LINK_STATE_IN_CABLE_CLUB  	ld [wLinkState], a -	ld [wcc47], a +	ld [wEnteringCableClub], a  	jr SpecialEnterMap  .choseCancel  	xor a @@ -322,7 +322,7 @@ SpecialEnterMap: ; 5d5f (1:5d5f)  	call ResetPlayerSpriteData  	ld c, 20  	call DelayFrames -	ld a, [wcc47] +	ld a, [wEnteringCableClub]  	and a  	ret nz  	jp EnterMap diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index 00ae3912..42ab553a 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -167,7 +167,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)  	dec hl  	dec hl  	ld b,[hl] -	ld a,[wd156] ; evolution stone item ID +	ld a,[wEvoStoneItemID] ; the stone the player used  	inc hl  	inc hl  	inc hl diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm index f2f2a794..2bf932ba 100755 --- a/engine/menu/prize_menu.asm +++ b/engine/menu/prize_menu.asm @@ -65,11 +65,11 @@ GetPrizeMenuId: ; 5278e (14:678e)  ; (distinguishing between Pokemon names  ; and Items (specifically TMs) names)  	ld a,[hSpriteIndexOrTextID] -	sub a,$03       ; prize-texts' id are 3, 4 and 5 -	ld [wd12f],a    ; prize-texts' id (relative, i.e. 0, 1 or 2) +	sub a,3       ; prize-texts' id are 3, 4 and 5 +	ld [wWhichPrizeWindow],a    ; prize-texts' id (relative, i.e. 0, 1 or 2)  	add a  	add a -	ld d,$00 +	ld d,0  	ld e,a  	ld hl,PrizeDifferentMenuPtrs  	add hl,de @@ -84,10 +84,10 @@ GetPrizeMenuId: ; 5278e (14:678e)  	ld a,[hli]  	ld h,[hl]  	ld l,a -	ld de,wd141 -	ld bc,$0006 +	ld de,wPrize1Price +	ld bc,6  	call CopyData -	ld a,[wd12f] +	ld a,[wWhichPrizeWindow]  	cp a,$02        ;is TM_menu?  	jr nz,.putMonName  	ld a,[W_PRIZE1] @@ -127,7 +127,7 @@ GetPrizeMenuId: ; 5278e (14:678e)  	ld de,NoThanksText  	call PlaceString  ; put prices on the right side of the textbox -	ld de,wd141 +	ld de,wPrize1Price  	coord hl, 13, 5  ; reg. c:  ; [low nybble] number of bytes @@ -136,11 +136,11 @@ GetPrizeMenuId: ; 5278e (14:678e)  ; Function $15CD displays BCD value (same routine  ; used by text-command $02)  	call PrintBCDNumber -	ld de,wd143 +	ld de,wPrize2Price  	coord hl, 13, 7  	ld c,(%1 << 7 | 2)  	call PrintBCDNumber -	ld de,wd145 +	ld de,wPrize3Price  	coord hl, 13, 9  	ld c,(1 << 7 | 2)  	jp PrintBCDNumber @@ -172,11 +172,11 @@ PrintPrizePrice: ; 5287a (14:687a)  	db "      @"  LoadCoinsToSubtract: ; 528b1 (14:68b1) -	ld a,[wd139] ; backup of selected menu_entry +	ld a,[wWhichPrize]  	add a -	ld d,$00 +	ld d,0  	ld e,a -	ld hl,wd141 ; first prize's price +	ld hl,wPrize1Price  	add hl,de ; get selected prize's price  	xor a  	ld [hUnusedCoinsByte],a @@ -187,15 +187,15 @@ LoadCoinsToSubtract: ; 528b1 (14:68b1)  	ret  HandlePrizeChoice: ; 528c6 (14:68c6) -	ld a,[wCurrentMenuItem] ; selected menu_entry -	ld [wd139],a -	ld d,$00 +	ld a,[wCurrentMenuItem] +	ld [wWhichPrize],a +	ld d,0  	ld e,a  	ld hl,W_PRIZE1  	add hl,de  	ld a,[hl]  	ld [wd11e],a -	ld a,[wd12f] +	ld a,[wWhichPrizeWindow]  	cp a,$02 ; is prize a TM?  	jr nz,.GetMonName  	call GetItemName @@ -205,14 +205,14 @@ HandlePrizeChoice: ; 528c6 (14:68c6)  .GivePrize  	ld hl,SoYouWantPrizeTextPtr  	call PrintText -	call YesNoChoice ; yes/no textbox +	call YesNoChoice  	ld a,[wCurrentMenuItem] ; yes/no answer (Y=0, N=1)  	and a  	jr nz,.PrintOhFineThen  	call LoadCoinsToSubtract  	call HasEnoughCoins  	jr c,.NotEnoughCoins -	ld a,[wd12f] +	ld a,[wWhichPrizeWindow]  	cp a,$02  	jr nz,.GiveMon  	ld a,[wd11e] diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index 481c0fbe..0895258c 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -167,7 +167,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)  	jp z,.loop  	ld a,SURFBOARD  	ld [wcf91],a -	ld [wd152],a +	ld [wPseudoItemID],a  	call UseItem  	ld a,[wActionResultOrTookBattleTurn]  	and a @@ -195,7 +195,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)  .dig  	ld a,ESCAPE_ROPE  	ld [wcf91],a -	ld [wd152],a +	ld [wPseudoItemID],a  	call UseItem  	ld a,[wActionResultOrTookBattleTurn]  	and a @@ -260,7 +260,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)  	push af  	ld a,POTION  	ld [wcf91],a -	ld [wd152],a +	ld [wPseudoItemID],a  	call UseItem  	pop af  	ld [wPartyAndBillsPCSavedMenuItem],a @@ -381,8 +381,8 @@ StartMenu_Item: ; 13302 (4:7302)  	ld a,[wCurrentMenuItem]  	and a  	jr nz,.tossItem -.useItem -	ld [wd152],a +; use item +	ld [wPseudoItemID],a ; a must be 0 due to above conditional jump  	ld a,[wcf91]  	cp a,HM_01  	jr nc,.useItem_partyMenu @@ -399,7 +399,7 @@ StartMenu_Item: ; 13302 (4:7302)  	jp ItemMenuLoop  .useItem_closeMenu  	xor a -	ld [wd152],a +	ld [wPseudoItemID],a  	call UseItem  	ld a,[wActionResultOrTookBattleTurn]  	and a diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index c9265f3e..0c01e38c 100755 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -178,7 +178,7 @@ PewterMovementScript_WalkToMuseum: ; 1a514 (6:6514)  	dec a  	ld [wSimulatedJoypadStatesIndex], a  	xor a -	ld [wd12f], a +	ld [wWhichPewterGuy], a  	predef PewterGuys  	ld hl, wNPCMovementDirections2  	ld de, RLEList_PewterMuseumGuy @@ -234,8 +234,8 @@ PewterMovementScript_WalkToGym: ; 1a581 (6:6581)  	call DecodeRLEList  	dec a  	ld [wSimulatedJoypadStatesIndex], a -	ld a, $1 -	ld [wd12f], a +	ld a, 1 +	ld [wWhichPewterGuy], a  	predef PewterGuys  	ld hl, wNPCMovementDirections2  	ld de, RLEList_PewterGymGuy diff --git a/engine/overworld/pewter_guys.asm b/engine/overworld/pewter_guys.asm index fa0dd4a7..4ac60e00 100755 --- a/engine/overworld/pewter_guys.asm +++ b/engine/overworld/pewter_guys.asm @@ -9,7 +9,7 @@ PewterGuys: ; 37ca1 (d:7ca1)  	ld d, h  	ld e, l  	ld hl, PointerTable_37ce6 -	ld a, [wd12f] +	ld a, [wWhichPewterGuy]  	add a  	ld b, 0  	ld c, a @@ -21,17 +21,17 @@ PewterGuys: ; 37ca1 (d:7ca1)  	ld b, a  	ld a, [W_XCOORD]  	ld c, a -.asm_37cc7 +.findMatchingCoordsLoop  	ld a, [hli]  	cp b -	jr nz, .asm_37ce1 +	jr nz, .nextEntry1  	ld a, [hli]  	cp c -	jr nz, .asm_37ce2 +	jr nz, .nextEntry2  	ld a, [hli]  	ld h, [hl]  	ld l, a -.asm_37cd2 +.copyMovementDataLoop  	ld a, [hli]  	cp $ff  	ret z @@ -40,13 +40,13 @@ PewterGuys: ; 37ca1 (d:7ca1)  	ld a, [wSimulatedJoypadStatesIndex]  	inc a  	ld [wSimulatedJoypadStatesIndex], a -	jr .asm_37cd2 -.asm_37ce1 +	jr .copyMovementDataLoop +.nextEntry1  	inc hl -.asm_37ce2 +.nextEntry2  	inc hl  	inc hl -	jr .asm_37cc7 +	jr .findMatchingCoordsLoop  PointerTable_37ce6: ; 37ce6 (d:7ce6)  	dw PewterMuseumGuyCoords diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm index a983881d..7d2ec0dd 100755 --- a/engine/overworld/trainers.asm +++ b/engine/overworld/trainers.asm @@ -24,16 +24,16 @@ _GetSpritePosition2: ; 56819 (15:6819)  	ld [H_SPRITEINDEX], a  	call GetSpriteDataPointer  	ld a, [hli] ; c1x4 (screen Y pos) -	ld [wd130], a +	ld [wSavedSpriteScreenY], a  	inc hl  	ld a, [hl] ; c1x6 (screen X pos) -	ld [wd131], a +	ld [wSavedSpriteScreenX], a  	ld de, $104 - $6  	add hl, de  	ld a, [hli] ; c2x4 (map Y pos) -	ld [wd132], a +	ld [wSavedSpriteMapY], a  	ld a, [hl] ; c2x5 (map X pos) -	ld [wd133], a +	ld [wSavedSpriteMapX], a  	ret  _SetSpritePosition1: ; 5683d (15:683d) @@ -61,16 +61,16 @@ _SetSpritePosition2: ; 5685d (15:685d)  	ld a, [wSpriteIndex]  	ld [H_SPRITEINDEX], a  	call GetSpriteDataPointer -	ld a, [wd130] +	ld a, [wSavedSpriteScreenY]  	ld [hli], a  	inc hl -	ld a, [wd131] +	ld a, [wSavedSpriteScreenX]  	ld [hl], a  	ld de, $00fe  	add hl, de -	ld a, [wd132] +	ld a, [wSavedSpriteMapY]  	ld [hli], a -	ld a, [wd133] +	ld a, [wSavedSpriteMapX]  	ld [hl], a  	ret @@ -1144,7 +1144,7 @@ DisplayTextID:: ; 2920 (0:2920)  	jr nz,HoldTextDisplayOpen  AfterDisplayingTextID:: ; 29d6 (0:29d6) -	ld a,[wcc47] +	ld a,[wEnteringCableClub]  	and a  	jr nz,HoldTextDisplayOpen  	call WaitForTextScrollButtonPress ; wait for a button press after displaying all the text @@ -4162,7 +4162,7 @@ HandleDownArrowBlinkTiming:: ; 3c04 (0:3c04)  ; The following code either enables or disables the automatic drawing of  ; text boxes by DisplayTextID. Both functions cause DisplayTextID to wait -; for a button press after displaying text (unless [wcc47] is set). +; for a button press after displaying text (unless [wEnteringCableClub] is set).  EnableAutoTextBoxDrawing:: ; 3c3c (0:3c3c)  	xor a diff --git a/home/overworld.asm b/home/overworld.asm index bd9f4a0a..3675eca8 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -106,13 +106,14 @@ OverworldLoopLessDelay::  	aCoord 8, 9  	ld [wTilePlayerStandingOn],a ; unused?  	call DisplayTextID ; display either the start menu or the NPC/sign text -	ld a,[wcc47] +	ld a,[wEnteringCableClub]  	and a  	jr z,.checkForOpponent  	dec a -	ld a,$00 -	ld [wcc47],a +	ld a,0 +	ld [wEnteringCableClub],a  	jr z,.changeMap +; XXX can this code be reached?  	predef LoadSAV  	ld a,[W_CURMAP]  	ld [wDestinationMap],a @@ -470,16 +471,16 @@ WarpFound1:: ; 0735 (0:0735)  WarpFound2:: ; 073c (0:073c)  	ld a,[wNumberOfWarps]  	sub c -	ld [wd73b],a ; save ID of used warp +	ld [wWarpedFromWhichWarp],a ; save ID of used warp  	ld a,[W_CURMAP] -	ld [wd73c],a +	ld [wWarpedFromWhichMap],a  	call CheckIfInOutsideMap  	jr nz,.indoorMaps  ; this is for handling "outside" maps that can't have the 0xFF destination map  	ld a,[W_CURMAP]  	ld [wLastMap],a  	ld a,[W_CURMAPWIDTH] -	ld [wd366],a +	ld [wUnusedD366],a ; not read  	ld a,[hWarpDestinationMap]  	ld [W_CURMAP],a  	cp a,ROCK_TUNNEL_1 diff --git a/home/text.asm b/home/text.asm index d57fc03f..366dfd73 100644 --- a/home/text.asm +++ b/home/text.asm @@ -376,9 +376,9 @@ TextCommandProcessor:: ; 1b40 (0:1b40)  	xor e  	ld [wLetterPrintingDelayFlags],a  	ld a,c -	ld [wcc3a],a +	ld [wUnusedCC3A],a  	ld a,b -	ld [wcc3b],a +	ld [wUnusedCC3B],a  NextTextCommand:: ; 1b55 (0:1b55)  	ld a,[hli] @@ -487,10 +487,10 @@ TextCommand02:: ; 1ba5 (0:1ba5)  TextCommand03:: ; 1bb7 (0:1bb7)  	pop hl  	ld a,[hli] -	ld [wcc3a],a +	ld [wUnusedCC3A],a  	ld c,a  	ld a,[hli] -	ld [wcc3b],a +	ld [wUnusedCC3B],a  	ld b,a  	jp NextTextCommand @@ -265,6 +265,10 @@ H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10  hFossilCounter EQU $FFDB +hGymGateIndex EQU $FFDB + +hGymTrashCanRandNumMask EQU $FFDB +  hItemToRemoveID    EQU $FFDB  hItemToRemoveIndex EQU $FFDC @@ -687,9 +687,9 @@ LoadSpecialWarpData: ; 62ff (1:62ff)  	ld a, [wWhichDungeonWarp]  	ld c, a  	ld hl, DungeonWarpList -	ld de, $0 -	ld a, $6 -	ld [wd12f], a +	ld de, 0 +	ld a, 6 +	ld [wDungeonWarpDataEntrySize], a  .dungeonWarpListLoop  	ld a, [hli]  	cp b @@ -701,7 +701,7 @@ LoadSpecialWarpData: ; 62ff (1:62ff)  	cp c  	jr z, .matchedDungeonWarpID  .nextDungeonWarp -	ld a, [wd12f] +	ld a, [wDungeonWarpDataEntrySize]  	add e  	ld e, a  	jr .dungeonWarpListLoop @@ -2063,7 +2063,7 @@ ClearVariablesAfterLoadingMapData: ; c335 (3:4335)  	ld [hJoyReleased], a  	ld [hJoyHeld], a  	ld [wActionResultOrTookBattleTurn], a -	ld [wd5a3], a +	ld [wUnusedD5A3], a  	ld hl, wCardKeyDoorY  	ld [hli], a  	ld [hl], a @@ -3640,8 +3640,8 @@ _AddPartyMon: ; f2e5 (3:72e5)  	ld b, FLAG_TEST  	ld hl, wPokedexOwned  	call FlagAction -	ld a, c -	ld [wd153], a +	ld a, c ; whether the mon was already flagged as owned +	ld [wUnusedD153], a ; not read  	ld a, [wd11e]  	dec a  	ld c, a @@ -4463,7 +4463,7 @@ InitPlayerData2:  	ld [wPlayerID + 1], a  	ld a, $ff -	ld [wd71b], a                 ; XXX what's this? +	ld [wUnusedD71B], a  	ld hl, wPartyCount  	call InitializeEmptyList diff --git a/scripts/celadongym.asm b/scripts/celadongym.asm index 9d761a31..5dc328c7 100755 --- a/scripts/celadongym.asm +++ b/scripts/celadongym.asm @@ -62,7 +62,7 @@ CeladonGymText_48963: ; 48963 (12:4963)  .asm_4898c  	ld hl, W_OBTAINEDBADGES  	set 3, [hl] -	ld hl, wd72a +	ld hl, wBeatGymFlags  	set 3, [hl]  	; deactivate gym trainers diff --git a/scripts/celadonmartelevator.asm b/scripts/celadonmartelevator.asm index de924849..53f1f434 100755 --- a/scripts/celadonmartelevator.asm +++ b/scripts/celadonmartelevator.asm @@ -16,9 +16,9 @@ CeladonMartElevatorScript: ; 48600 (12:4600)  CeladonMartElevatorScript_4861c: ; 4861c (12:461c)  	ld hl, wWarpEntries -	ld a, [wd73b] +	ld a, [wWarpedFromWhichWarp]  	ld b, a -	ld a, [wd73c] +	ld a, [wWarpedFromWhichMap]  	ld c, a  	call CeladonMartElevatorScript_4862a diff --git a/scripts/ceruleangym.asm b/scripts/ceruleangym.asm index c8ce12b9..a7845c68 100755 --- a/scripts/ceruleangym.asm +++ b/scripts/ceruleangym.asm @@ -62,7 +62,7 @@ CeruleanGymScript_5c70d: ; 5c70d (17:470d)  .asm_5c736  	ld hl, W_OBTAINEDBADGES  	set 1, [hl] -	ld hl, wd72a +	ld hl, wBeatGymFlags  	set 1, [hl]  	; deactivate gym trainers diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm index 18737d2b..60df9338 100755 --- a/scripts/cinnabargym.asm +++ b/scripts/cinnabargym.asm @@ -32,7 +32,7 @@ CinnabarGymScript_75792: ; 75792 (1d:5792)  	ld [wJoyIgnore], a  	ld [W_CINNABARGYMCURSCRIPT], a  	ld [W_CURMAPSCRIPT], a -	ld [wda38], a +	ld [wOpponentAfterWrongAnswer], a  	ret  CinnabarGymScript_757a0: ; 757a0 (1d:57a0) @@ -47,7 +47,7 @@ CinnabarGymScriptPointers: ; 757a6 (1d:57a6)  	dw CinnabarGymScript3  CinnabarGymScript0: ; 757ae (1d:57ae) -	ld a, [wda38] +	ld a, [wOpponentAfterWrongAnswer]  	and a  	ret z  	ld [H_SPRITEINDEX], a @@ -83,7 +83,7 @@ CinnabarGymScript1: ; 757dc (1d:57dc)  	ret nz  	xor a  	ld [wJoyIgnore], a -	ld a, [wda38] +	ld a, [wOpponentAfterWrongAnswer]  	ld [wTrainerHeaderFlagBit], a  	ld [hSpriteIndexOrTextID], a  	jp DisplayTextID @@ -127,7 +127,7 @@ CinnabarGymScript2: ; 757f6 (1d:57f6)  	call UpdateCinnabarGymGateTileBlocks  	xor a  	ld [wJoyIgnore], a -	ld [wda38], a +	ld [wOpponentAfterWrongAnswer], a  	ld a, $0  	ld [W_CINNABARGYMCURSCRIPT], a  	ld [W_CURMAPSCRIPT], a @@ -159,7 +159,7 @@ CinnabarGymScript3_75857: ; 75857 (1d:5857)  .asm_75880  	ld hl, W_OBTAINEDBADGES  	set 6, [hl] -	ld hl, wd72a +	ld hl, wBeatGymFlags  	set 6, [hl]  	; deactivate gym trainers diff --git a/scripts/fuchsiagym.asm b/scripts/fuchsiagym.asm index 0855d506..9bbc38a8 100755 --- a/scripts/fuchsiagym.asm +++ b/scripts/fuchsiagym.asm @@ -62,7 +62,7 @@ FuchsiaGymScript3_75497: ; 75497 (1d:5497)  .asm_754c0  	ld hl, W_OBTAINEDBADGES  	set 4, [hl] -	ld hl, wd72a +	ld hl, wBeatGymFlags  	set 4, [hl]  	; deactivate gym trainers diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 329d3c25..93f87657 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -522,11 +522,11 @@ OaksLabScript15: ; 1ceb0 (7:4eb0)  	ld [wMissableObjectIndex], a  	predef ShowObject  	ld a, [wNPCMovementDirections2Index] -	ld [wd157], a -	ld b, $0 +	ld [wSavedNPCMovementDirections2Index], a +	ld b, 0  	ld c, a  	ld hl, wNPCMovementDirections2 -	ld a, $40 +	ld a, NPC_MOVEMENT_UP  	call FillMemory  	ld [hl], $ff  	ld a, $1 @@ -604,11 +604,11 @@ OaksLabScript16: ; 1cf12 (7:4f12)  	ld a, HS_OLD_MAN  	ld [wMissableObjectIndex], a  	predef ShowObject -	ld a, [wd157] -	ld b, $0 +	ld a, [wSavedNPCMovementDirections2Index] +	ld b, 0  	ld c, a  	ld hl, wNPCMovementDirections2 -	xor a +	xor a ; NPC_MOVEMENT_DOWN  	call FillMemory  	ld [hl], $ff  	ld a, $ff diff --git a/scripts/pewtergym.asm b/scripts/pewtergym.asm index 704ea104..81fcb600 100755 --- a/scripts/pewtergym.asm +++ b/scripts/pewtergym.asm @@ -62,7 +62,7 @@ PewterGymScript_5c3df: ; 5c3df (17:43df)  .asm_5c408  	ld hl, W_OBTAINEDBADGES  	set 0, [hl] -	ld hl, wd72a +	ld hl, wBeatGymFlags  	set 0, [hl]  	ld a, HS_GYM_GUY @@ -183,7 +183,7 @@ PewterGymAfterBattleText1: ; 5c4da (17:44da)  PewterGymText3: ; 5c4df (17:44df)  	TX_ASM -	ld a, [wd72a] +	ld a, [wBeatGymFlags]  	bit 0, a  	jr nz, .asm_5c50c  	ld hl, PewterGymText_5c515 diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm index f1fceb2f..a4635aa3 100755 --- a/scripts/pokemontower7.asm +++ b/scripts/pokemontower7.asm @@ -57,7 +57,7 @@ PokemonTower7Script3: ; 60d56 (18:4d56)  	ld [wJoyIgnore], a  	ld [wSpriteIndex], a  	ld [wTrainerHeaderFlagBit], a -	ld [wda38], a +	ld [wUnusedDA38], a  	ld a, $0  	ld [W_POKEMONTOWER7CURSCRIPT], a  	ld [W_CURMAPSCRIPT], a diff --git a/scripts/rockethideoutelevator.asm b/scripts/rockethideoutelevator.asm index be9c7cf2..52c7fad3 100755 --- a/scripts/rockethideoutelevator.asm +++ b/scripts/rockethideoutelevator.asm @@ -16,9 +16,9 @@ RocketHideoutElevatorScript: ; 45710 (11:5710)  RocketHideoutElevatorScript_4572c: ; 4572c (11:572c)  	ld hl, wWarpEntries -	ld a, [wd73b] +	ld a, [wWarpedFromWhichWarp]  	ld b, a -	ld a, [wd73c] +	ld a, [wWarpedFromWhichMap]  	ld c, a  	call RocketHideoutElevatorScript_4573a diff --git a/scripts/saffrongym.asm b/scripts/saffrongym.asm index e712689f..9ee632f7 100755 --- a/scripts/saffrongym.asm +++ b/scripts/saffrongym.asm @@ -62,7 +62,7 @@ SaffronGymText_5d068: ; 5d068 (17:5068)  .asm_5d091  	ld hl, W_OBTAINEDBADGES  	set 5, [hl] -	ld hl, wd72a +	ld hl, wBeatGymFlags  	set 5, [hl]  	; deactivate gym trainers diff --git a/scripts/seafoamislands5.asm b/scripts/seafoamislands5.asm index eca361f3..87942ca0 100755 --- a/scripts/seafoamislands5.asm +++ b/scripts/seafoamislands5.asm @@ -35,12 +35,12 @@ SeafoamIslands5Script0: ; 467c7 (11:67c7)  	ld a, [wCoordIndex]  	cp $3  	jr nc, .asm_467e6 -	ld a, $40 -	ld [wccd4], a -	ld a, $2 +	ld a, NPC_MOVEMENT_UP +	ld [wSimulatedJoypadStatesEnd + 1], a +	ld a, 2  	jr .asm_467e8  .asm_467e6 -	ld a, $1 +	ld a, 1  .asm_467e8  	ld [wSimulatedJoypadStatesIndex], a  	ld a, D_UP diff --git a/scripts/silphcoelevator.asm b/scripts/silphcoelevator.asm index b328c14c..36dbb6d2 100755 --- a/scripts/silphcoelevator.asm +++ b/scripts/silphcoelevator.asm @@ -16,9 +16,9 @@ SilphCoElevatorScript: ; 457c0 (11:57c0)  SilphCoElevatorScript_457dc: ; 457dc (11:57dc)  	ld hl, wWarpEntries -	ld a, [wd73b] +	ld a, [wWarpedFromWhichWarp]  	ld b, a -	ld a, [wd73c] +	ld a, [wWarpedFromWhichMap]  	ld c, a  	call SilphCoElevatorScript_457ea diff --git a/scripts/vermilioncity.asm b/scripts/vermilioncity.asm index 64ccc477..de721a2f 100755 --- a/scripts/vermilioncity.asm +++ b/scripts/vermilioncity.asm @@ -84,8 +84,8 @@ VermilionCityScript2: ; 19833 (6:5833)  	ld [wJoyIgnore], a  	ld a, D_UP  	ld [wSimulatedJoypadStatesEnd], a -	ld [wccd4], a -	ld a, $2 +	ld [wSimulatedJoypadStatesEnd + 1], a +	ld a, 2  	ld [wSimulatedJoypadStatesIndex], a  	call StartSimulatingJoypadStates  	ld a, $3 diff --git a/scripts/vermiliongym.asm b/scripts/vermiliongym.asm index 0282e340..5c504335 100755 --- a/scripts/vermiliongym.asm +++ b/scripts/vermiliongym.asm @@ -81,7 +81,7 @@ VermilionGymScript_5caaa: ; 5caaa (17:4aaa)  .asm_5cad3  	ld hl, W_OBTAINEDBADGES  	set 2, [hl] -	ld hl, wd72a +	ld hl, wBeatGymFlags  	set 2, [hl]  	; deactivate gym trainers @@ -247,7 +247,7 @@ VermilionGymAfterBattleText3: ; 5cbd6 (17:4bd6)  VermilionGymText5: ; 5cbdb (17:4bdb)  	TX_ASM -	ld a, [wd72a] +	ld a, [wBeatGymFlags]  	bit 2, a  	jr nz, .asm_5cbeb  	ld hl, VermilionGymText_5cbf4 diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm index 0e075b2f..8e012040 100755 --- a/scripts/viridiangym.asm +++ b/scripts/viridiangym.asm @@ -156,7 +156,7 @@ ViridianGymScript3_74995: ; 74995 (1d:4995)  .asm_749be  	ld hl, W_OBTAINEDBADGES  	set 7, [hl] -	ld hl, wd72a +	ld hl, wBeatGymFlags  	set 7, [hl]  	; deactivate gym trainers @@ -295,9 +295,11 @@ wTradeCenterPointerTableIndex:: ; cc38  	ds 1 -; group these two together -wcc3a:: ds 1 ; both used in home/text.asm -wcc3b:: ds 1 +wUnusedCC3A:: ; cc3a +	ds 1 + +wUnusedCC3B:: ; cc3b +	ds 1  wDoNotWaitForButtonPressAfterDisplayingText:: ; cc3c  ; if non-zero, skip waiting for a button press after displaying text in DisplayTextID @@ -312,8 +314,7 @@ wSerialExchangeNybbleTempReceiveData:: ; cc3d  wLinkMenuSelectionReceiveBuffer:: ; cc3d  ; two byte buffer  ; the received menu selection is stored twice - -wcc3d:: ds 1 ; not used for anything other than mentioned above (haha link function) +	ds 1  wSerialExchangeNybbleReceiveData:: ; cc3e  ; the final received nybble is stored here by Serial_ExchangeNybble @@ -336,8 +337,10 @@ wLinkTimeoutCounter:: ; cc47  wUnknownSerialCounter:: ; cc47  ; 2 bytes -wcc47:: ds 1 ; used in text id stuff -wcc48:: ds 1 ; part of wUnknownSerialCounter +wEnteringCableClub:: ; cc47 +	ds 1 + +	ds 1  wWhichTradeMonSelectionMenu:: ; cc49  ; $00 = player mons @@ -412,9 +415,7 @@ wSlotMachineSavedROMBank:: ; cc5e  ; ROM back to return to when the player is done with the slot machine  	ds 1 -	ds 12 - -wcc6b:: ds 14 ; doesn't seem to be used for anything, probably just more storage +	ds 26  wAnimPalette:: ; cc79  	ds 1 @@ -452,8 +453,8 @@ wCanEvolveFlags:: ; ccd3  ; Other methods of evolution simply set it by calling TryEvolvingMon.  	ds 1 -wForceEvolution:: -wccd4:: ds 1 ; has a direct reference for simulated joypad stuff in vermillion and seafoam +wForceEvolution:: ; ccd4 +	ds 1  ; if [ccd5] != 1, the second AI layer is not applied  wAILayer2Encouragement:: ; ccd5 @@ -1942,12 +1943,36 @@ wMenuExitMethod:: ; d12e  ; $02 = the user pressed B or pressed A with the second menu item selected  	ds 1 -wd12f:: ds 1 ; used in some coordinatestuff, npc pathstuff, and game corner prize stuff -wd130:: ds 1 ; saved value of screen Y coord of trainer sprite -wd131:: ds 1 ; saved value of screen X coord of trainer sprite -wd132:: ds 1 ; saved value of map Y coordinate of trainer sprite (not sure for purpose) -wd133:: ds 6 ; saved value of map X coordinate of trainer sprite -wd139:: ds 1 ; backup of selected menu entry for game corner prizes +wDungeonWarpDataEntrySize:: ; d12f +; the size is always 6, so they didn't need a variable in RAM for this + +wWhichPewterGuy:: ; d12f +; 0 = museum guy +; 1 = gym guy + +wWhichPrizeWindow:: ; d12f +; there are 3 windows, from 0 to 2 + +wGymGateTileBlock:: ; d12f +; a horizontal or vertical gate block +	ds 1 + +wSavedSpriteScreenY:: ; d130 +	ds 1 + +wSavedSpriteScreenX:: ; d131 +	ds 1 + +wSavedSpriteMapY:: ; d132 +	ds 1 + +wSavedSpriteMapX:: ; d133 +	ds 1 + +	ds 5 + +wWhichPrize:: ; d139 +	ds 1  wIgnoreInputCounter:: ; d13a  ; counts downward each frame @@ -1974,9 +1999,16 @@ W_PRIZE3:: ; d13f  wSerialRandomNumberListBlock:: ; d141  ; the first 7 bytes are the preamble -wd141:: ds 2 ; prices for prizes -wd143:: ds 2 ; prices for prizes -wd145:: ds 3 ; prices for prizes +wPrize1Price:: ; d141 +	ds 2 + +wPrize2Price:: ; d143 +	ds 2 + +wPrize3Price:: ; d145 +	ds 2 + +	ds 1  wLinkBattleRandomNumberList:: ; d148  ; shared list of 9 random numbers, indexed by wLinkBattleRandomNumberListIndex @@ -1985,11 +2017,23 @@ wLinkBattleRandomNumberList:: ; d148  wSerialPlayerDataBlock:: ; d152  ; the first 6 bytes are the preamble -wd152:: ds 1 ; used as a temporary storage for the item used -wd153:: ds 3 ; written to during pokedex flag action but doesn't seem to be read from -wd156:: ds 1 ; evolution stone ID used -wd157:: ds 1 ; used with oak's lab script (related to npc movement directions), possibly indirectly accessed with values below +wPseudoItemID:: ; d152 +; When a real item is being used, this is 0. +; When a move is acting as an item, this is the ID of the item it's acting as. +; For example, out-of-battle Dig is executed using a fake Escape Rope item. In +; that case, this would be ESCAPE_ROPE. +	ds 1 + +wUnusedD153:: ; d153 +	ds 1 + +	ds 2 +wEvoStoneItemID:: ; d156 +	ds 1 + +wSavedNPCMovementDirections2Index:: ; d157 +	ds 1  wPlayerName:: ; d158  	ds 11 @@ -2092,7 +2136,8 @@ W_XBLOCKCOORD:: ; d364  wLastMap:: ; d365  	ds 1 -wd366:: ds 1 ; W_CURMAPWIDTH of the last outdoor map visited when entering an inside map +wUnusedD366:: ; d366 +	ds 1  W_CURMAPTILESET:: ; d367  	ds 1 @@ -2344,7 +2389,8 @@ wNumHoFTeams:: ; d5a2  ; number of HOF teams  	ds 1 -wd5a3:: ds 1 ; unused? (written to when loading map data) +wUnusedD5A3:: ; d5a3 +	ds 1  wPlayerCoins:: ; d5a4  	ds 2 ; BCD @@ -2635,7 +2681,8 @@ wDestinationMap:: ; d71a  ; destination map (for certain types of special warps, not ordinary walking)  	ds 1 -wd71b:: ds 1 ; written to but doesn't seem to be read +wUnusedD71B:: ; d71b +	ds 1  wTileInFrontOfBoulderAndBoulderCollisionResult:: ; d71c  ; used to store the tile in front of the boulder when trying to push a boulder @@ -2650,7 +2697,10 @@ wWhichDungeonWarp:: ; d71e  ; which dungeon warp within the source map was used  	ds 1 -wd71f:: ds 9 ; used with card key +wUnusedD71F:: ; d71f +	ds 1 + +	ds 8  wd728::  ; bit 0: using Strength outside of battle @@ -2658,7 +2708,12 @@ wd728::  	ds 1 -wd72a:: ds 2 ; flags for if a gym is beaten, also used to determine whether to display your name on the gym statues +wBeatGymFlags:: ; d72a +; redundant because it matches W_OBTAINEDBADGES +; used to determine whether to show name on statue and in two NPC text scripts +	ds 1 + +	ds 1  wd72c:: ; d72c  ; bit 0: if not set, the 3 minimum steps between random battles have passed @@ -2717,8 +2772,13 @@ wCompletedInGameTradeFlags:: ; d737  	ds 2 -wd73b:: ds 1 ; used with elevator warps -wd73c:: ds 3 ; also used with elevator warps +wWarpedFromWhichWarp:: ; d73b +	ds 1 + +wWarpedFromWhichMap:: ; d73c +	ds 1 + +	ds 2  wCardKeyDoorY:: ; d73f  	ds 1 @@ -2767,7 +2827,12 @@ W_TRAINERHEADERPTR:: ; da30  	ds 6 -wda38:: ds 1 ; used with cinnabar gym questions and pokemon tower 7F? +wOpponentAfterWrongAnswer:: ; da38 +; the trainer the player must face after getting a wrong answer in the Cinnabar +; gym quiz + +wUnusedDA38:: ; da38 +	ds 1  W_CURMAPSCRIPT:: ; da39  ; index of current map script, mostly used as index for function pointer array | 
