shithub: pokered

Download patch

ref: 9c93fb0b7559e9d657a91d2b508ecebe58eee544
parent: 229126d940f3763294f9ad4e0d48b83d4996c6bc
author: Rangi <[email protected]>
date: Tue Jun 1 16:39:05 EDT 2021

Use more UNIONs for overlapping WRAM labels

--- a/wram.asm
+++ b/wram.asm
@@ -33,8 +33,10 @@
 
 wChannelFlags1:: ds NUM_CHANNELS
 wChannelFlags2:: ds NUM_CHANNELS
+
 wChannelDutyCycles:: ds NUM_CHANNELS
 wChannelDutyCyclePatterns:: ds NUM_CHANNELS
+
 ; reloaded at the beginning of a note. counts down until the vibrato begins.
 wChannelVibratoDelayCounters:: ds NUM_CHANNELS
 wChannelVibratoExtents:: ds NUM_CHANNELS
@@ -44,6 +46,7 @@
 wChannelFrequencyLowBytes:: ds NUM_CHANNELS
 ; delay of the beginning of the vibrato from the start of the note
 wChannelVibratoDelayCounterReloadValues:: ds NUM_CHANNELS
+
 wChannelPitchSlideLengthModifiers:: ds NUM_CHANNELS
 wChannelPitchSlideFrequencySteps:: ds NUM_CHANNELS
 wChannelPitchSlideFrequencyStepsFractionalPart:: ds NUM_CHANNELS
@@ -52,6 +55,7 @@
 wChannelPitchSlideCurrentFrequencyLowBytes:: ds NUM_CHANNELS
 wChannelPitchSlideTargetFrequencyHighBytes:: ds NUM_CHANNELS
 wChannelPitchSlideTargetFrequencyLowBytes:: ds NUM_CHANNELS
+
 ; Note delays are stored as 16-bit fixed-point numbers where the integer part
 ; is 8 bits and the fractional part is 8 bits.
 wChannelNoteDelayCounters:: ds NUM_CHANNELS
@@ -58,6 +62,7 @@
 wChannelLoopCounters:: ds NUM_CHANNELS
 wChannelNoteSpeeds:: ds NUM_CHANNELS
 wChannelNoteDelayCountersFractionalPart:: ds NUM_CHANNELS
+
 wChannelOctaves:: ds NUM_CHANNELS
 ; also includes fade for hardware channels that support it
 wChannelVolumes:: ds NUM_CHANNELS
@@ -335,70 +340,86 @@
 
 	ds 2
 
-wVermilionDockTileMapBuffer:: ; ds 5 * BG_MAP_WIDTH + SCREEN_WIDTH
+; This union spans 180 bytes.
+UNION
+wVermilionDockTileMapBuffer:: ds 5 * BG_MAP_WIDTH + SCREEN_WIDTH
+wVermilionDockTileMapBufferEnd::
 
-wOaksAideRewardItemName:: ; ds ITEM_NAME_LENGTH
+NEXTU
+wOaksAideRewardItemName:: ds ITEM_NAME_LENGTH
 
-wElevatorWarpMaps:: ; ds 11 * 2
+NEXTU
+wElevatorWarpMaps:: ds 11 * 2
 
+NEXTU
 ; List of bag items that has been filtered to a certain type of items,
 ; such as drinks or fossils.
-wFilteredBagItems:: ; ds 3 + 1
+wFilteredBagItems:: ds 4
 
+NEXTU
 ; Saved copy of OAM for the first frame of the animation to make it easy to
 ; flip back from the second frame.
-wMonPartySpritesSavedOAM:: ; ds $60
+wMonPartySpritesSavedOAM:: ds $60
 
-wTrainerCardBlkPacket:: ; ds $40
+NEXTU
+wTrainerCardBlkPacket:: ds $40
 
-wHallOfFame:: ; ds HOF_TEAM
+NEXTU
+wHallOfFame:: ds HOF_TEAM
 
-wNPCMovementDirections:: ; ds $ff
+NEXTU
+wNPCMovementDirections:: ds 180
 
-wBoostExpByExpAll::
-; values between 0-6. Shake screen horizontally, shake screen vertically, blink Pokemon...
-wAnimationType::
+NEXTU
+wDexRatingNumMonsSeen:: db
+wDexRatingNumMonsOwned:: db
+wDexRatingText:: db
+
+NEXTU
 ; If a random number greater than this value is generated, then the player is
 ; allowed to have three 7 symbols or bar symbols line up.
 ; So, this value is actually the chance of NOT entering that mode.
 ; If the slot is lucky, it equals 250, giving a 5/256 (~2%) chance.
 ; Otherwise, it equals 253, giving a 2/256 (~0.8%) chance.
-wSlotMachineSevenAndBarModeChance::
-wUnusedCC5B::
-wDexRatingNumMonsSeen:: db
-
-wDexRatingNumMonsOwned:: db
-
-wDexRatingText:: db
-
+wSlotMachineSevenAndBarModeChance:: db
+	ds 2
 ; ROM back to return to when the player is done with the slot machine
 wSlotMachineSavedROMBank:: db
+	ds 166
+wLuckySlotHiddenObjectIndex:: db
 
-	ds 26
-
+NEXTU
+; values between 0-6. Shake screen horizontally, shake screen vertically, blink Pokemon...
+wAnimationType:: db
+	ds 29
 wAnimPalette:: db
 
-	ds 29
-
-UNION
-wNPCMovementDirections2:: ds 10
-; used in Pallet Town scripted movement
-wNumStepsToTake:: db
-
 NEXTU
+	ds 60
 ; temporary buffer when swapping party mon data
 wSwitchPartyMonTempBuffer:: ds 44 ; party_struct size
-ENDU
 
-	ds 15
-
-wRLEByteCount:: db
-
+NEXTU
+	ds 120
 ; this is the end of the joypad states
 ; the list starts above this address and extends downwards in memory until here
 ; overloaded with below labels
 wSimulatedJoypadStatesEnd::
 
+NEXTU
+wBoostExpByExpAll::
+wUnusedCC5B:: db
+
+	ds 59
+
+wNPCMovementDirections2:: ds 10
+; used in Pallet Town scripted movement
+wNumStepsToTake:: db
+
+	ds 48
+
+wRLEByteCount:: db
+
 wParentMenuItem::
 ; 0 = not added
 ; 1 = added
@@ -483,20 +504,15 @@
 
 	ds 13
 
-UNION
-wLuckySlotHiddenObjectIndex::
 ; number of hits by enemy in attacks like Double Slap, etc.
-wEnemyNumHits:: db
-
-NEXTU
-; the amount of damage accumulated by the enemy while biding (2 bytes)
+wEnemyNumHits:: ; db
+; the amount of damage accumulated by the enemy while biding
 wEnemyBideAccumulatedDamage:: dw
-ENDU
 
 	ds 8
+ENDU
 
-wVermilionDockTileMapBufferEnd::
-
+; This union spans 39 bytes.
 UNION
 wInGameTradeGiveMonSpecies:: db
 wInGameTradeTextPointerTablePointer:: dw
@@ -891,58 +907,62 @@
 	ds 5
 ENDU
 
+UNION
 ; buffer for transferring the random number list generated by the other gameboy
-wSerialOtherGameboyRandomNumberListBlock:: ; ds $11
-
+wSerialOtherGameboyRandomNumberListBlock:: ds $11
+NEXTU
 ; second buffer for temporarily saving and restoring current screen's tiles (e.g. if menus are drawn on top)
-wTileMapBackup2:: ds 20 * 18
+wTileMapBackup2:: ds SCREEN_WIDTH * SCREEN_HEIGHT
+ENDU
 
+; This union spans 30 bytes.
+UNION
 ; Temporary storage area
-wBuffer:: ; ds 30
+wBuffer:: ds 30
 
-wNamingScreenNameLength::
-wEvoOldSpecies::
-; lower nybble is x, upper nybble is y
-wTownMapCoords::
-; whether WriteMonMoves is being used to make a mon learn moves from day care
-; non-zero if so
-wLearningMovesFromDayCare::
-wChangeMonPicEnemyTurnSpecies::
-wHPBarMaxHP::
-	db
+NEXTU
+wEvoOldSpecies:: db
+wEvoNewSpecies:: db
+wEvoMonTileOffset:: db
+wEvoCancelled:: db
 
+NEXTU
+wNamingScreenNameLength:: db
 ; non-zero when the player has chosen to submit the name
-wNamingScreenSubmitName::
-wChangeMonPicPlayerTurnSpecies::
-wEvoNewSpecies::
-	db
+wNamingScreenSubmitName:: db
+; 0 = upper case
+; 1 = lower case
+wAlphabetCase:: db
+	ds 1
+wNamingScreenLetter:: db
 
-UNION
+NEXTU
+wChangeMonPicEnemyTurnSpecies:: db
+wChangeMonPicPlayerTurnSpecies:: db
+
+NEXTU
+wHPBarMaxHP:: dw
 wHPBarOldHP:: dw
 wHPBarNewHP:: dw
 wHPBarDelta:: db
 wHPBarTempHP:: dw
 	ds 11
-wHPBarHPDifference:: db
+wHPBarHPDifference:: dw
 
 NEXTU
-; 0 = upper case
-; 1 = lower case
-wAlphabetCase::
-wEvoMonTileOffset::
+; lower nybble is x, upper nybble is y
+wTownMapCoords::
+; whether WriteMonMoves is being used to make a mon learn moves from day care
+; non-zero if so
+wLearningMovesFromDayCare::
 	db
 
-wEvoCancelled:: db
+	ds 27
 
-wNamingScreenLetter:: db
-ENDU
-
-	ds 7
-
 ; the item that the AI used
 wAIItem:: db
-
 wUsedItemOnWhichPokemon:: db
+ENDU
 
 ; sound ID during battle animations
 wAnimSoundID:: db
@@ -1004,12 +1024,15 @@
 
 wDefaultPaletteCommand:: db
 
-wPlayerHPBarColor:: ; dw
+UNION
+wPlayerHPBarColor:: dw
 
+NEXTU
 ; species of the mon whose palette is used for the whole screen
 wWholeScreenPaletteMonSpecies:: db
 
 wEnemyHPBarColor:: db
+ENDU
 
 ; 0: green
 ; 1: yellow
@@ -1025,20 +1048,22 @@
 wPalPacket::
 	db
 
-wPartyMenuBlkPacket:: ; ds $30
+; This union spans 49 bytes.
+UNION
+wPartyMenuBlkPacket:: ds $30
 
+NEXTU
 	ds 29
-
 ; storage buffer for various strings
-wcf4b:: ; ds 20
+wcf4b:: ds 20
 
+NEXTU
+	ds 29
 ; the total amount of exp a mon gained
 wExpAmountGained:: dw
-
 wGainBoostedExp:: db
+ENDU
 
-	ds 17
-
 wGymCityName:: ds 17
 
 wGymLeaderName:: ds NAME_LENGTH
@@ -1164,12 +1189,15 @@
 
 	ds 1
 
-wTempMoveNameBuffer:: ; ds 14
+UNION
+wTempMoveNameBuffer:: ds 14
 
+NEXTU
 ; The name of the mon that is learning a move.
-wLearnMoveMonName:: ; ds NAME_LENGTH
+wLearnMoveMonName:: ds NAME_LENGTH
+ENDU
 
-	ds 16
+	ds 2
 
 ; money received after battle = base money × level of highest-level enemy mon
 wTrainerBaseMoney:: dw ; BCD
@@ -1291,28 +1319,31 @@
 
 	ds 1
 
+UNION
 ; the amount of damage accumulated by the player while biding
-wPlayerBideAccumulatedDamage:: ; dw
+wPlayerBideAccumulatedDamage:: dw
 
-wUnknownSerialCounter2:: ; dw
+NEXTU
+wUnknownSerialCounter2:: dw
 
+NEXTU
 ; number of hits by player in attacks like Double Slap, etc.
 wPlayerNumHits:: db
+ENDU
 
-	ds 3
+	ds 2
 
 ; non-zero when an item or move that allows escape from battle was used
 wEscapedFromBattle:: db
 
-; BCD number
-wAmountMoneyWon:: ; ds 3
+UNION
+wAmountMoneyWon:: ds 3 ; BCD
 
+NEXTU
 wObjectToHide:: db
-
 wObjectToShow:: db
+ENDU
 
-	ds 1
-
 ; the map you will start at when the debug bit is set
 wDefaultMap::
 wMenuItemOffset::
@@ -1355,11 +1386,18 @@
 ; number of tiles in current battle animation frame block
 wNumFBTiles:: db
 
-wFlashScreenLongCounter::
-wSpiralBallsBaseY::
+UNION
+wSpiralBallsBaseY:: db
+wSpiralBallsBaseX:: db
+
+NEXTU
 ; bits 0-6: index into FallingObjects_DeltaXs array (0 - 8)
 ; bit 7: direction; 0 = right, 1 = left
-wFallingObjectMovementByte::
+wFallingObjectMovementByte:: db
+wNumFallingObjects:: db
+
+NEXTU
+wFlashScreenLongCounter::
 wNumShootingBalls::
 ; $01 if mon is moving from left gameboy to right gameboy; $00 if vice versa
 wTradedMonMovingRight::
@@ -1370,8 +1408,6 @@
 wUnusedD08A::
 	db
 
-wSpiralBallsBaseX::
-wNumFallingObjects::
 wSlideMonDelay::
 ; generic counter variable for various animations
 wAnimCounter::
@@ -1382,13 +1418,11 @@
 ; 04: reverse the subanimation
 wSubAnimTransform::
 	db
+ENDU
 
 wEndBattleWinTextPointer:: dw
-
 wEndBattleLoseTextPointer:: dw
-
 	ds 2
-
 wEndBattleTextRomBank:: db
 
 	ds 1
@@ -1396,16 +1430,19 @@
 ; the address _of the address_ of the current subanimation entry
 wSubAnimAddrPtr:: dw
 
+UNION
 ; the address of the current subentry of the current subanimation
-wSubAnimSubEntryAddr:: ; dw
+wSubAnimSubEntryAddr:: dw
 
+NEXTU
 ; If non-zero, the allow matches flag is always set.
 ; There is a 1/256 (~0.4%) chance that this value will be set to 60, which is
 ; the only way it can increase. Winning certain payout amounts will decrement it
 ; or zero it.
 wSlotMachineAllowMatchesCounter:: db
+ENDU
 
-	ds 3
+	ds 2
 
 wOutwardSpiralTileMapPointer:: db
 
@@ -1637,8 +1674,10 @@
 
 	ds 1
 
-wSerialRandomNumberListBlock:: ; ds $11
+UNION
+wSerialRandomNumberListBlock:: ds $11
 
+NEXTU
 wPrize1Price:: dw
 wPrize2Price:: dw
 wPrize3Price:: dw
@@ -1647,6 +1686,7 @@
 
 ; shared list of 9 random numbers, indexed by wLinkBattleRandomNumberListIndex
 wLinkBattleRandomNumberList:: ds 10
+ENDU
 
 wSerialPlayerDataBlock:: ; ds $1a8