shithub: pokecrystal

Download patch

ref: b791198f74e55ff6a96d33784d9661854dbca113
parent: 4fe0d93d4c0536b3517ba4b58822e5f6b1019382
parent: 349664ec15995b40151378bbfc405930d47a3c5c
author: Rangi <35663410+Rangi42@users.noreply.github.com>
date: Sat Feb 9 13:03:07 EST 2019

Merge pull request #596 from Rangi42/master

Remove the nested UNION within battle WRAM

--- a/engine/games/unown_puzzle.asm
+++ b/engine/games/unown_puzzle.asm
@@ -14,8 +14,8 @@
 	xor a
 	ldh [hBGMapMode], a
 	call DisableLCD
-	ld hl, wc608 ; includes wPuzzlePieces
-	ld bc, wc7e8 - wc608
+	ld hl, wUnownPuzzle ; includes wPuzzlePieces
+	ld bc, wUnownPuzzleEnd - wUnownPuzzle
 	xor a
 	call ByteFill
 	ld hl, UnownPuzzleCursorGFX
--- a/engine/overworld/overworld.asm
+++ b/engine/overworld/overworld.asm
@@ -594,7 +594,7 @@
 	jr c, .done
 
 	ld a, h
-	add $8
+	add HIGH(vTiles1 - vTiles0)
 	ld h, a
 	call .CopyToVram
 
--- a/engine/overworld/warp_connection.asm
+++ b/engine/overworld/warp_connection.asm
@@ -1,6 +1,6 @@
 
 HandleNewMap:
-	call Clearwc7e8
+	call ClearUnusedC7E8
 	call ResetMapBufferEventFlags
 	call ResetFlashIfOutOfCave
 	call GetCurrentMapSceneID
--- a/engine/rtc/timeset.asm
+++ b/engine/rtc/timeset.asm
@@ -44,7 +44,7 @@
 	ld hl, Text_WokeUpOak
 	call PrintText
 	ld hl, wTimeSetBuffer
-	ld bc, 50
+	ld bc, wTimeSetBufferEnd - wTimeSetBuffer
 	xor a
 	call ByteFill
 	ld a, 10 ; default hour = 10 AM
--- a/home/map.asm
+++ b/home/map.asm
@@ -1,8 +1,8 @@
 ; Functions dealing with rendering and interacting with maps.
 
-Clearwc7e8::
-	ld hl, wc7e8
-	ld bc, wc7e8_End - wc7e8
+ClearUnusedC7E8::
+	ld hl, wUnusedC7E8
+	ld bc, wUnusedC7E8End - wUnusedC7E8
 	ld a, 0
 	call ByteFill
 	ret
--- a/pokecrystal.link
+++ b/pokecrystal.link
@@ -319,7 +319,7 @@
 	align 8
 	"Sprites"
 	"Tilemap"
-	"Battle"
+	"Miscellaneous"
 	"Overworld Map"
 	"Video"
 WRAMX 1
--- a/wram.asm
+++ b/wram.asm
@@ -354,55 +354,27 @@
 wTileMapEnd::
 
 
-SECTION "Battle", WRAM0
+SECTION "Miscellaneous", WRAM0
 
+; This union spans 480 bytes from c608 to c7e8.
 UNION ; c608
-; unidentified uses
-wc608:: ds 53
-wc63d:: ds 5
-wc642:: ds 5
-wc647:: ds 33
-wc668:: ds 32
-wc688:: ds 2
-wc68a:: ds 350
-
-NEXTU ; c608
 ; surrounding tiles
+; This buffer determines the size for the rest of the union;
+; it uses exactly 480 bytes.
 wSurroundingTiles:: ds SURROUNDING_WIDTH * SURROUNDING_HEIGHT
 
 NEXTU ; c608
 ; box save buffer
+; SaveBoxAddress uses this buffer in three steps because it
+; needs more space than the buffer can hold.
 wBoxPartialData:: ds 480
 wBoxPartialDataEnd::
 
 NEXTU ; c608
-; odd egg
-wOddEgg:: party_struct wOddEgg
-wOddEggName:: ds MON_NAME_LENGTH
-wOddEggOTName:: ds NAME_LENGTH
-
-NEXTU ; c608
 ; battle tower temp struct
 wBT_OTTemp:: battle_tower_struct wBT_OTTemp
 
 NEXTU ; c608
-; hall of fame temp struct
-wHallOfFameTemp:: hall_of_fame wHallOfFameTemp
-
-NEXTU ; c608
-; timeset temp storage
-wTimeSetBuffer::
-	ds 20
-wInitHourBuffer:: db ; c61c
-	ds 9
-wInitMinuteBuffer:: db ; c626
-
-NEXTU ; c608
-; link engine data
-wLink_c608:: ds 10
-wc612:: ds 10
-
-NEXTU ; c608
 ; battle data
 wBattle::
 wEnemyMoveStruct::  move_struct wEnemyMoveStruct ; c608
@@ -578,9 +550,6 @@
 wPlayerDefLevel:: db ; c6cd
 wPlayerSpdLevel:: db ; c6ce
 wPlayerSAtkLevel:: db ; c6cf
-
-UNION ; c6d0
-; finish battle RAM
 wPlayerSDefLevel:: db ; c6d0
 wPlayerAccLevel:: db ; c6d1
 wPlayerEvaLevel:: db ; c6d2
@@ -739,12 +708,108 @@
 wPlayerJustGotFrozen:: db ; c73c
 wEnemyJustGotFrozen:: db ; c73d
 wBattleEnd::
-; Battle RAM
-; c741
 
+NEXTU ; c608
+; unown puzzle
+wUnownPuzzle::
+	ds 200
+wPuzzlePieces:: ds 6 * 6
+	ds 244
+wUnownPuzzleEnd::
+
+NEXTU ; c608
+
+; This union spans 200 bytes from c608 to c6d0.
+UNION ; c608
+; timeset temp storage
+wTimeSetBuffer::
+	ds 20
+wInitHourBuffer:: db ; c61c
+	ds 9
+wInitMinuteBuffer:: db ; c626
+	ds 19
+wTimeSetBufferEnd::
+
+NEXTU ; c608
+; hall of fame temp struct
+wHallOfFameTemp:: hall_of_fame wHallOfFameTemp
+
+NEXTU ; c608
+; link engine data
+wLink_c608:: ds 10
+wc612:: ds 10
+
+NEXTU ; c608
+; odd egg
+wOddEgg:: party_struct wOddEgg
+wOddEggName:: ds MON_NAME_LENGTH
+wOddEggOTName:: ds NAME_LENGTH
+
+NEXTU ; c608
+; mobile data
+wc608:: ds 53
+wc63d:: ds 5
+wc642:: ds 5
+wc647:: ds 33
+wc668:: ds 32
+wc688:: ds 2
+wc68a:: ds 4
+	ds 66
+
+ENDU ; c6d0
+
+; This union spans 280 bytes from c6d0 to c7e8.
+UNION ; c6d0
+; pokedex
+wPokedexDataStart:: ; c6d0
+wPokedexOrder:: ds $100 ; >= NUM_POKEMON
+wPokedexOrderEnd::
+wDexListingScrollOffset:: db ; offset of the first displayed entry from the start
+wDexListingCursor:: db ; Dex cursor
+wDexListingEnd:: db ; Last mon to display
+wDexListingHeight:: db ; number of entries displayed at once in the dex listing
+wCurDexMode:: db ; Pokedex Mode
+wDexSearchMonType1:: db ; first type to search
+wDexSearchMonType2:: db ; second type to search
+wDexSearchResultCount:: db
+wDexArrowCursorPosIndex:: db
+wDexArrowCursorDelayCounter:: db
+wDexArrowCursorBlinkCounter:: db
+wDexSearchSlowpokeFrame:: db
+wUnlockedUnownMode:: db
+wDexCurUnownIndex:: db
+wDexUnownCount:: db
+wDexConvertedMonType:: db ; mon type converted from dex search mon type
+wDexListingScrollOffsetBackup:: db
+wDexListingCursorBackup:: db
+wBackupDexListingCursor:: db
+wBackupDexListingPage:: db
+wDexCurLocation:: db
+if DEF(_CRYSTAL11)
+wPokedexStatus:: db
+wPokedexDataEnd::
+else
+wPokedexDataEnd:: ds 1
+endc
+	ds 2
+
 NEXTU ; c6d0
+; pokegear
+wPokegearPhoneLoadNameBuffer:: db ; c6d0
+wPokegearPhoneCursorPosition:: db ; c6d1
+wPokegearPhoneScrollPosition:: db ; c6d2
+wPokegearPhoneSelectedPerson:: db ; c6d3
+wPokegearPhoneSubmenuCursor:: db ; c6d4
+wPokegearMapCursorObjectPointer:: dw ; c6d5
+wPokegearMapCursorLandmark:: db ; c6d7
+wPokegearMapPlayerIconLandmark:: db ; c6d8
+wPokegearRadioChannelBank:: db ; c6d9
+wPokegearRadioChannelAddr:: dw ; c6da
+wPokegearRadioMusicPlaying:: db ; c6dc
+
+NEXTU ; c6d0
 ; trade
-wTrademons::
+wTrademons:: ; c6d0
 wPlayerTrademon:: trademon wPlayerTrademon
 wOTTrademon::     trademon wOTTrademon
 wTrademonsEnd::
@@ -765,22 +830,8 @@
 wNamingScreenStringEntryCoord:: dw ; c6d8
 
 NEXTU ; c6d0
-; pokegear
-wPokegearPhoneLoadNameBuffer:: db ; c6d0
-wPokegearPhoneCursorPosition:: db ; c6d1
-wPokegearPhoneScrollPosition:: db ; c6d2
-wPokegearPhoneSelectedPerson:: db ; c6d3
-wPokegearPhoneSubmenuCursor:: db ; c6d4
-wPokegearMapCursorObjectPointer:: dw ; c6d5
-wPokegearMapCursorLandmark:: db ; c6d7
-wPokegearMapPlayerIconLandmark:: db ; c6d8
-wPokegearRadioChannelBank:: db ; c6d9
-wPokegearRadioChannelAddr:: dw ; c6da
-wPokegearRadioMusicPlaying:: db ; c6dc
-
-NEXTU ; c6d0
 ; slot machine
-wSlots::
+wSlots:: ; c6d0
 wReel1:: slot_reel wReel1
 wReel2:: slot_reel wReel2
 wReel3:: slot_reel wReel3
@@ -805,7 +856,7 @@
 
 NEXTU ; c6d0
 ; card flip
-wCardFlip::
+wCardFlip:: ; c6d0
 wDeck:: ds 24
 wDeckEnd::
 ; c6e8
@@ -817,7 +868,7 @@
 
 NEXTU ; c6d0
 ; dummy game
-wDummyGame::
+wDummyGame:: ; c6d0
 wDummyGameCards:: ds 9 * 5
 wDummyGameCardsEnd::
 wDummyGameLastCardPicked:: db ; c6fd
@@ -832,46 +883,6 @@
 wDummyGameEnd::
 
 NEXTU ; c6d0
-; unown puzzle
-wUnownPuzzle::
-wPuzzlePieces:: ds 6 * 6
-wUnownPuzzleEnd::
-
-NEXTU ; c6d0
-; pokedex
-wPokedexDataStart::
-wPokedexOrder:: ds $100 ; >= NUM_POKEMON
-wPokedexOrderEnd::
-wDexListingScrollOffset:: db ; offset of the first displayed entry from the start
-wDexListingCursor:: db ; Dex cursor
-wDexListingEnd:: db ; Last mon to display
-wDexListingHeight:: db ; number of entries displayed at once in the dex listing
-wCurDexMode:: db ; Pokedex Mode
-wDexSearchMonType1:: db ; first type to search
-wDexSearchMonType2:: db ; second type to search
-wDexSearchResultCount:: db
-wDexArrowCursorPosIndex:: db
-wDexArrowCursorDelayCounter:: db
-wDexArrowCursorBlinkCounter:: db
-wDexSearchSlowpokeFrame:: db
-wUnlockedUnownMode:: db
-wDexCurUnownIndex:: db
-wDexUnownCount:: db
-wDexConvertedMonType:: db ; mon type converted from dex search mon type
-wDexListingScrollOffsetBackup:: db
-wDexListingCursorBackup:: db
-wBackupDexListingCursor:: db
-wBackupDexListingPage:: db
-wDexCurLocation:: db
-if DEF(_CRYSTAL11)
-wPokedexStatus:: db
-wPokedexDataEnd::
-else
-wPokedexDataEnd:: ds 1
-endc
-	ds 2
-
-NEXTU ; c6d0
 ; mobile data
 wc6d0:: ds 56
 wc708:: db
@@ -896,10 +907,11 @@
 wc7d3:: ds 1
 wc7d4:: ds 1
 ENDU ; c7e8
+
 ENDU ; c7e8
 
-wc7e8:: ds 24
-wc7e8_End::
+wUnusedC7E8:: ds 24
+wUnusedC7E8End::
 
 
 SECTION "Overworld Map", WRAM0