Skip to content

Commit

Permalink
More WRAM label cleanup (still needs UNIONs and renaming)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed May 31, 2021
1 parent 5c73cff commit f9ae7b1
Show file tree
Hide file tree
Showing 9 changed files with 301 additions and 576 deletions.
8 changes: 4 additions & 4 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6900,9 +6900,9 @@ ResetCryModifiers:

; animates the mon "growing" out of the pokeball
AnimateSendingOutMon:
ld a, [wPredefRegisters]
ld a, [wPredefHL]
ld h, a
ld a, [wPredefRegisters + 1]
ld a, [wPredefHL + 1]
ld l, a
ldh a, [hStartTileID]
ldh [hBaseTileID], a
Expand Down Expand Up @@ -6940,9 +6940,9 @@ AnimateSendingOutMon:
jr CopyUncompressedPicToHL

CopyUncompressedPicToTilemap:
ld a, [wPredefRegisters]
ld a, [wPredefHL]
ld h, a
ld a, [wPredefRegisters + 1]
ld a, [wPredefHL + 1]
ld l, a
ldh a, [hStartTileID]
CopyUncompressedPicToHL::
Expand Down
2 changes: 1 addition & 1 deletion engine/items/town_map.asm
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ ToText:
db "To@"

BuildFlyLocationsList:
ld hl, wFlyLocationsList - 1
ld hl, wFlyAnimUsingCoordList
ld [hl], $ff
inc hl
ld a, [wTownVisitedFlag]
Expand Down
2 changes: 1 addition & 1 deletion engine/menus/party_menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ RedrawPartyMenu_::
ld l, a
ld de, wEvosMoves
ld a, BANK(EvosMovesPointerTable)
ld bc, wEvosMoves.end - wEvosMoves
ld bc, wEvosMovesEnd - wEvosMoves
call FarCopyData
ld hl, wEvosMoves
ld de, .notAbleToEvolveText
Expand Down
10 changes: 5 additions & 5 deletions engine/predefs.asm
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
GetPredefPointer::
; Store the contents of the register
; pairs (hl, de, bc) at wPredefRegisters.
; Back up the contents of the registers (hl, de, bc).
; Then put the bank and address of predef
; wPredefID in [wPredefBank] and hl.

ld a, h
ld [wPredefRegisters], a
ld [wPredefHL], a
ld a, l
ld [wPredefRegisters + 1], a
ld [wPredefHL + 1], a

ld hl, wPredefRegisters + 2
ld hl, wPredefDE
ld a, d
ld [hli], a
ld a, e
ld [hli], a

ASSERT wPredefDE + 2 == wPredefBC
ld a, b
ld [hli], a
ld [hl], c
Expand Down
42 changes: 21 additions & 21 deletions home/overworld.asm
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ CheckMapConnections::
ld a, [wXCoord]
cp $ff
jr nz, .checkEastMap
ld a, [wMapConn3Ptr]
ld a, [wWestConnectedMap]
ld [wCurMap], a
ld a, [wWestConnectedMapXAlignment] ; new X coordinate upon entering west map
ld [wXCoord], a
Expand Down Expand Up @@ -587,7 +587,7 @@ CheckMapConnections::
ld a, [wCurrentMapWidth2] ; map width
cp b
jr nz, .checkNorthMap
ld a, [wMapConn4Ptr]
ld a, [wEastConnectedMap]
ld [wCurMap], a
ld a, [wEastConnectedMapXAlignment] ; new X coordinate upon entering east map
ld [wXCoord], a
Expand Down Expand Up @@ -623,7 +623,7 @@ CheckMapConnections::
ld a, [wYCoord]
cp $ff
jr nz, .checkSouthMap
ld a, [wMapConn1Ptr]
ld a, [wNorthConnectedMap]
ld [wCurMap], a
ld a, [wNorthConnectedMapYAlignment] ; new Y coordinate upon entering north map
ld [wYCoord], a
Expand Down Expand Up @@ -651,7 +651,7 @@ CheckMapConnections::
ld a, [wCurrentMapHeight2]
cp b
jr nz, .didNotEnterConnectedMap
ld a, [wMapConn2Ptr]
ld a, [wSouthConnectedMap]
ld [wCurMap], a
ld a, [wSouthConnectedMapYAlignment] ; new Y coordinate upon entering south map
ld [wYCoord], a
Expand Down Expand Up @@ -937,7 +937,7 @@ LoadTileBlockMap::
dec b
jr nz, .rowLoop
.northConnection
ld a, [wMapConn1Ptr]
ld a, [wNorthConnectedMap]
cp $ff
jr z, .southConnection
call SwitchToMapRomBank
Expand All @@ -949,13 +949,13 @@ LoadTileBlockMap::
ld e, a
ld a, [wNorthConnectionStripDest + 1]
ld d, a
ld a, [wNorthConnectionStripWidth]
ld a, [wNorthConnectionStripLength]
ldh [hNorthSouthConnectionStripWidth], a
ld a, [wNorthConnectedMapWidth]
ldh [hNorthSouthConnectedMapWidth], a
call LoadNorthSouthConnectionsTileMap
.southConnection
ld a, [wMapConn2Ptr]
ld a, [wSouthConnectedMap]
cp $ff
jr z, .westConnection
call SwitchToMapRomBank
Expand All @@ -967,13 +967,13 @@ LoadTileBlockMap::
ld e, a
ld a, [wSouthConnectionStripDest + 1]
ld d, a
ld a, [wSouthConnectionStripWidth]
ld a, [wSouthConnectionStripLength]
ldh [hNorthSouthConnectionStripWidth], a
ld a, [wSouthConnectedMapWidth]
ldh [hNorthSouthConnectedMapWidth], a
call LoadNorthSouthConnectionsTileMap
.westConnection
ld a, [wMapConn3Ptr]
ld a, [wWestConnectedMap]
cp $ff
jr z, .eastConnection
call SwitchToMapRomBank
Expand All @@ -985,13 +985,13 @@ LoadTileBlockMap::
ld e, a
ld a, [wWestConnectionStripDest + 1]
ld d, a
ld a, [wWestConnectionStripHeight]
ld a, [wWestConnectionStripLength]
ld b, a
ld a, [wWestConnectedMapWidth]
ldh [hEastWestConnectedMapWidth], a
call LoadEastWestConnectionsTileMap
.eastConnection
ld a, [wMapConn4Ptr]
ld a, [wEastConnectedMap]
cp $ff
jr z, .done
call SwitchToMapRomBank
Expand All @@ -1003,7 +1003,7 @@ LoadTileBlockMap::
ld e, a
ld a, [wEastConnectionStripDest + 1]
ld d, a
ld a, [wEastConnectionStripHeight]
ld a, [wEastConnectionStripLength]
ld b, a
ld a, [wEastConnectedMapWidth]
ldh [hEastWestConnectedMapWidth], a
Expand Down Expand Up @@ -2046,32 +2046,32 @@ LoadMapHeader::
jr nz, .copyFixedHeaderLoop
; initialize all the connected maps to disabled at first, before loading the actual values
ld a, $ff
ld [wMapConn1Ptr], a
ld [wMapConn2Ptr], a
ld [wMapConn3Ptr], a
ld [wMapConn4Ptr], a
ld [wNorthConnectedMap], a
ld [wSouthConnectedMap], a
ld [wWestConnectedMap], a
ld [wEastConnectedMap], a
; copy connection data (if any) to WRAM
ld a, [wMapConnections]
ld b, a
.checkNorth
bit 3, b
jr z, .checkSouth
ld de, wMapConn1Ptr
ld de, wNorthConnectionHeader
call CopyMapConnectionHeader
.checkSouth
bit 2, b
jr z, .checkWest
ld de, wMapConn2Ptr
ld de, wSouthConnectionHeader
call CopyMapConnectionHeader
.checkWest
bit 1, b
jr z, .checkEast
ld de, wMapConn3Ptr
ld de, wWestConnectionHeader
call CopyMapConnectionHeader
.checkEast
bit 0, b
jr z, .getObjectDataPointer
ld de, wMapConn4Ptr
ld de, wEastConnectionHeader
call CopyMapConnectionHeader
.getObjectDataPointer
ld a, [hli]
Expand All @@ -2094,7 +2094,7 @@ LoadMapHeader::
ld c, a
ld de, wWarpEntries
.warpLoop ; one warp per loop iteration
ld b, $04
ld b, 4
.warpInnerLoop
ld a, [hli]
ld [de], a
Expand Down
12 changes: 6 additions & 6 deletions home/predef.asm
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ Predef::
GetPredefRegisters::
; Restore the contents of register pairs
; when GetPredefPointer was called.
ld a, [wPredefRegisters + 0]
ld a, [wPredefHL]
ld h, a
ld a, [wPredefRegisters + 1]
ld a, [wPredefHL + 1]
ld l, a
ld a, [wPredefRegisters + 2]
ld a, [wPredefDE]
ld d, a
ld a, [wPredefRegisters + 3]
ld a, [wPredefDE + 1]
ld e, a
ld a, [wPredefRegisters + 4]
ld a, [wPredefBC]
ld b, a
ld a, [wPredefRegisters + 5]
ld a, [wPredefBC + 1]
ld c, a
ret
11 changes: 11 additions & 0 deletions macros/wram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,14 @@ sprite_oam_struct: MACRO
\1TileID:: db
\1Attributes:: db
ENDM

map_connection_struct: MACRO
\1ConnectedMap:: db
\1ConnectionStripSrc:: dw
\1ConnectionStripDest:: dw
\1ConnectionStripLength:: db
\1ConnectedMapWidth:: db
\1ConnectedMapYAlignment:: db
\1ConnectedMapXAlignment:: db
\1ConnectedMapViewPointer:: dw
ENDM
4 changes: 2 additions & 2 deletions scripts/VermilionDock.asm
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ VermilionDock_1dc7c:
VermilionDock_EraseSSAnne:
; Fill the area the S.S. Anne occupies in BG map 0 with water tiles.
ld hl, wVermilionDockTileMapBuffer
ld bc, (5 * BG_MAP_WIDTH) + SCREEN_WIDTH
ld bc, wVermilionDockTileMapBufferEnd - wVermilionDockTileMapBuffer
ld a, $14 ; water tile
call FillMemory
hlbgcoord 0, 10
ld de, wVermilionDockTileMapBuffer
ld bc, (6 * BG_MAP_WIDTH) / 16
lb bc, BANK(wVermilionDockTileMapBuffer), 12
call CopyVideoData

; Replace the blocks of the lower half of the ship with water blocks. This
Expand Down
Loading

0 comments on commit f9ae7b1

Please sign in to comment.