summaryrefslogtreecommitdiff
path: root/home/map.asm
diff options
context:
space:
mode:
Diffstat (limited to 'home/map.asm')
-rw-r--r--home/map.asm258
1 files changed, 129 insertions, 129 deletions
diff --git a/home/map.asm b/home/map.asm
index 1e409f0fc..a66391896 100644
--- a/home/map.asm
+++ b/home/map.asm
@@ -2,8 +2,8 @@
Clearwc7e8:: ; 210f
ld hl, wc7e8
- ld bc, 24
- ld a, $0
+ ld bc, wc7e8_End - wc7e8
+ ld a, 0
call ByteFill
ret
; 211b
@@ -72,7 +72,7 @@ GetMapSceneID:: ; 2147
.next
pop hl
- ld de, 4 ; size of an entry in the scene script table
+ ld de, 4 ; scene_script size
add hl, de
jr .loop
@@ -249,7 +249,7 @@ GetDestinationWarpNumber:: ; 2252
ld a, [hROMBank]
push af
- call SwitchToMapScriptHeaderBank
+ call SwitchToMapScriptsBank
call .GetDestinationWarpNumber
pop de
@@ -270,7 +270,7 @@ GetDestinationWarpNumber:: ; 2252
ret z
ld c, a
- ld hl, wCurrMapWarpHeaderPointer
+ ld hl, wCurrMapWarpsPointer
ld a, [hli]
ld h, [hl]
ld l, a
@@ -321,7 +321,7 @@ CopyWarpData:: ; 22a7
ld a, [hROMBank]
push af
- call SwitchToMapScriptHeaderBank
+ call SwitchToMapScriptsBank
call .CopyWarpData
pop af
@@ -332,7 +332,7 @@ CopyWarpData:: ; 22a7
.CopyWarpData: ; 22b4
push bc
- ld hl, wCurrMapWarpHeaderPointer
+ ld hl, wCurrMapWarpsPointer
ld a, [hli]
ld h, [hl]
ld l, a
@@ -384,7 +384,7 @@ CheckIndoorMap:: ; 22f4
ret
; 2300
-; XXX
+; unused
cp INDOOR
ret z
cp GATE
@@ -394,35 +394,35 @@ CheckIndoorMap:: ; 22f4
; 2309
LoadMapAttributes:: ; 2309
- call CopyMapHeaders
- call SwitchToMapScriptHeaderBank
+ call CopyMapDefAndData
+ call SwitchToMapScriptsBank
call ReadMapScripts
- xor a
- call ReadMapEventHeader
+ xor a ; do not skip object_events
+ call ReadMapEvents
ret
; 2317
LoadMapAttributes_SkipPeople:: ; 2317
- call CopyMapHeaders
- call SwitchToMapScriptHeaderBank
+ call CopyMapDefAndData
+ call SwitchToMapScriptsBank
call ReadMapScripts
- ld a, $1
- call ReadMapEventHeader
+ ld a, TRUE ; skip object events
+ call ReadMapEvents
ret
; 2326
-CopyMapHeaders:: ; 2326
- call PartiallyCopyMapHeader
- call SwitchToMapBank
- call GetSecondaryMapHeaderPointer
- call CopySecondMapHeader
+CopyMapDefAndData:: ; 2326
+ call PartialCopyMapDef
+ call SwitchToMapDataBank
+ call GetMapDataPointer
+ call CopyMapData
call GetMapConnections
ret
; 2336
-ReadMapEventHeader:: ; 2336
+ReadMapEvents:: ; 2336
push af
- ld hl, MapEventHeaderPointer
+ ld hl, MapEventsPointer
ld a, [hli]
ld h, [hl]
ld l, a
@@ -433,7 +433,7 @@ ReadMapEventHeader:: ; 2336
call ReadBGEvents
pop af
- and a
+ and a ; skip object events?
ret nz
call ReadObjectEvents
@@ -441,7 +441,7 @@ ReadMapEventHeader:: ; 2336
; 234f
ReadMapScripts:: ; 234f
- ld hl, MapScriptHeaderPointer
+ ld hl, MapScriptsPointer
ld a, [hli]
ld h, [hl]
ld l, a
@@ -450,9 +450,9 @@ ReadMapScripts:: ; 234f
ret
; 235c
-CopySecondMapHeader:: ; 235c
- ld de, MapHeader
- ld c, 12 ; size of the second map header
+CopyMapData:: ; 235c
+ ld de, wMapData
+ ld c, wMapDataEnd - wMapData
.loop
ld a, [hli]
ld [de], a
@@ -516,14 +516,14 @@ ReadMapSceneScripts:: ; 23ac
ld c, a
ld [wCurrMapSceneScriptCount], a ; current map scene script count
ld a, l
- ld [wCurrMapSceneScriptHeaderPointer], a ; map scene script pointer
+ ld [wCurrMapSceneScriptsPointer], a ; map scene script pointer
ld a, h
- ld [wCurrMapSceneScriptHeaderPointer + 1], a
+ ld [wCurrMapSceneScriptsPointer + 1], a
ld a, c
and a
ret z
- ld bc, 4 ; size of a map scene script header entry
+ ld bc, 4 ; scene_script size
call AddNTimes
ret
; 23c3
@@ -533,9 +533,9 @@ ReadMapCallbacks:: ; 23c3
ld c, a
ld [wCurrMapCallbackCount], a
ld a, l
- ld [wCurrMapCallbackHeaderPointer], a
+ ld [wCurrMapCallbacksPointer], a
ld a, h
- ld [wCurrMapCallbackHeaderPointer + 1], a
+ ld [wCurrMapCallbacksPointer + 1], a
ld a, c
and a
ret z
@@ -550,9 +550,9 @@ ReadWarps:: ; 23da
ld c, a
ld [wCurrMapWarpCount], a
ld a, l
- ld [wCurrMapWarpHeaderPointer], a
+ ld [wCurrMapWarpsPointer], a
ld a, h
- ld [wCurrMapWarpHeaderPointer + 1], a
+ ld [wCurrMapWarpsPointer + 1], a
ld a, c
and a
ret z
@@ -566,9 +566,9 @@ ReadCoordEvents:: ; 23f1
ld c, a
ld [wCurrMapCoordEventCount], a
ld a, l
- ld [wCurrMapCoordEventHeaderPointer], a
+ ld [wCurrMapCoordEventsPointer], a
ld a, h
- ld [wCurrMapCoordEventHeaderPointer + 1], a
+ ld [wCurrMapCoordEventsPointer + 1], a
ld a, c
and a
@@ -584,9 +584,9 @@ ReadBGEvents:: ; 2408
ld c, a
ld [wCurrMapBGEventCount], a
ld a, l
- ld [wCurrMapBGEventHeaderPointer], a
+ ld [wCurrMapBGEventsPointer], a
ld a, h
- ld [wCurrMapBGEventHeaderPointer + 1], a
+ ld [wCurrMapBGEventsPointer + 1], a
ld a, c
and a
@@ -606,12 +606,12 @@ ReadObjectEvents:: ; 241f
inc de
ld [wCurrMapObjectEventCount], a
ld a, e
- ld [wCurrMapObjectEventHeaderPointer], a
+ ld [wCurrMapObjectEventsPointer], a
ld a, d
- ld [wCurrMapObjectEventHeaderPointer + 1], a
+ ld [wCurrMapObjectEventsPointer + 1], a
ld a, [wCurrMapObjectEventCount]
- call CopyMapObjectHeaders
+ call CopyMapObjectEvents
; get NUM_OBJECTS - [wCurrMapObjectEventCount]
ld a, [wCurrMapObjectEventCount]
@@ -643,7 +643,7 @@ ReadObjectEvents:: ; 241f
ret
; 2457
-CopyMapObjectHeaders:: ; 2457
+CopyMapObjectEvents:: ; 2457
and a
ret z
@@ -690,10 +690,10 @@ ClearObjectStructs:: ; 2471
; 248a
RestoreFacingAfterWarp:: ; 248a
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
rst Bankswitch
- ld hl, MapEventHeaderPointer
+ ld hl, MapEventsPointer
ld a, [hli]
ld h, [hl]
ld l, a
@@ -759,12 +759,12 @@ ChangeMap:: ; 24e4
add hl, bc
ld c, 3
add hl, bc
- ld a, [MapBlockDataBank]
+ ld a, [MapBlocksBank]
rst Bankswitch
- ld a, [MapBlockDataPointer]
+ ld a, [MapBlocksPointer]
ld e, a
- ld a, [MapBlockDataPointer+1]
+ ld a, [MapBlocksPointer + 1]
ld d, a
ld a, [MapHeight]
ld b, a
@@ -802,7 +802,7 @@ FillMapConnections:: ; 2524
ld b, a
ld a, [NorthConnectedMapNumber]
ld c, a
- call GetAnyMapBlockdataBank
+ call GetAnyMapBlocksBank
ld a, [NorthConnectionStripPointer]
ld l, a
@@ -825,7 +825,7 @@ FillMapConnections:: ; 2524
ld b, a
ld a, [SouthConnectedMapNumber]
ld c, a
- call GetAnyMapBlockdataBank
+ call GetAnyMapBlocksBank
ld a, [SouthConnectionStripPointer]
ld l, a
@@ -848,7 +848,7 @@ FillMapConnections:: ; 2524
ld b, a
ld a, [WestConnectedMapNumber]
ld c, a
- call GetAnyMapBlockdataBank
+ call GetAnyMapBlocksBank
ld a, [WestConnectionStripPointer]
ld l, a
@@ -871,7 +871,7 @@ FillMapConnections:: ; 2524
ld b, a
ld a, [EastConnectedMapNumber]
ld c, a
- call GetAnyMapBlockdataBank
+ call GetAnyMapBlocksBank
ld a, [EastConnectionStripPointer]
ld l, a
@@ -992,20 +992,20 @@ CallMapScript:: ; 2631
ld a, [ScriptRunning]
and a
ret nz
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
jr CallScript
; 263b
RunMapCallback:: ; 263b
-; Will run the first callback found in the map header with execution index equal to a.
+; Will run the first callback found with execution index equal to a.
ld b, a
ld a, [hROMBank]
push af
- call SwitchToMapScriptHeaderBank
+ call SwitchToMapScriptsBank
call .FindCallback
jr nc, .done
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
ld b, a
ld d, h
ld e, l
@@ -1022,7 +1022,7 @@ RunMapCallback:: ; 263b
ld c, a
and a
ret z
- ld hl, wCurrMapCallbackHeaderPointer
+ ld hl, wCurrMapCallbacksPointer
ld a, [hli]
ld h, [hl]
ld l, a
@@ -1352,7 +1352,7 @@ UpdateBGMapRow:: ; 27d3
dec c
jr nz, .loop
ld a, SCREEN_WIDTH
- ld [hFFDC], a
+ ld [hBGMapTileCount], a
ret
; 27f8
@@ -1371,7 +1371,7 @@ UpdateBGMapColumn:: ; 27f8
inc d
; cap d at HIGH(vBGMap0)
ld a, d
- and $3
+ and %11
or HIGH(vBGMap0)
ld d, a
@@ -1379,11 +1379,11 @@ UpdateBGMapColumn:: ; 27f8
dec c
jr nz, .loop
ld a, SCREEN_HEIGHT
- ld [hFFDC], a
+ ld [hBGMapTileCount], a
ret
; 2816
-; unreferenced
+Unreferenced_Function2816::
ld hl, BGMapBuffer
ld bc, BGMapBufferEnd - BGMapBuffer
xor a
@@ -1401,7 +1401,7 @@ LoadTilesetGFX:: ; 2821
ld a, [rSVBK]
push af
- ld a, $6
+ ld a, BANK(wDecompressScratch)
ld [rSVBK], a
ld a, e
@@ -1429,10 +1429,11 @@ LoadTilesetGFX:: ; 2821
pop af
ld [rSVBK], a
+; These tilesets support dynamic per-mapgroup roof tiles.
ld a, [wTileset]
- cp TILESET_JOHTO_1
+ cp TILESET_JOHTO
jr z, .load_roof
- cp TILESET_JOHTO_2
+ cp TILESET_JOHTO_MODERN
jr z, .load_roof
cp TILESET_BATTLE_TOWER_OUTSIDE
jr z, .load_roof
@@ -1859,7 +1860,7 @@ CheckFacingBGEvent:: ; 2a8b
ld c, a
ld a, [hROMBank]
push af
- call SwitchToMapScriptHeaderBank
+ call SwitchToMapScriptsBank
call CheckIfFacingTileCoordIsBGEvent
pop hl
ld a, h
@@ -1869,7 +1870,7 @@ CheckFacingBGEvent:: ; 2a8b
CheckIfFacingTileCoordIsBGEvent:: ; 2aaa
; Checks to see if you are facing a BG event. If so, copies it into EngineBuffer1 and sets carry.
- ld hl, wCurrMapBGEventHeaderPointer
+ ld hl, wCurrMapBGEventsPointer
ld a, [hli]
ld h, [hl]
ld l, a
@@ -1915,7 +1916,7 @@ CheckCurrentMapCoordEvents:: ; 2ad4
ld c, a
ld a, [hROMBank]
push af
- call SwitchToMapScriptHeaderBank
+ call SwitchToMapScriptsBank
call .CoordEventCheck
pop hl
ld a, h
@@ -1924,7 +1925,7 @@ CheckCurrentMapCoordEvents:: ; 2ad4
.CoordEventCheck:
; Checks to see if you are standing on a coord event. If yes, copies the event to EngineBuffer1 and sets carry.
- ld hl, wCurrMapCoordEventHeaderPointer
+ ld hl, wCurrMapCoordEventsPointer
ld a, [hli]
ld h, [hl]
ld l, a
@@ -1983,7 +1984,7 @@ FadeToMenu:: ; 2b29
xor a
ld [hBGMapMode], a
call LoadStandardMenuDataHeader
- farcall FadeOutPalettes
+ farcall Special_FadeOutPalettes
call ClearSprites
call DisableSpriteUpdates
ret
@@ -2009,7 +2010,7 @@ FinishExitMenu:: ; 2b5c
call GetSGBLayout
farcall LoadOW_BGPal7
call WaitBGMap2
- farcall FadeInPalettes
+ farcall Special_FadeInPalettes
call EnableSpriteUpdates
ret
; 2b74
@@ -2042,7 +2043,7 @@ ReturnToMapWithSpeechTextbox:: ; 0x2b74
ReloadTilesetAndPalettes:: ; 2bae
call DisableLCD
call ClearSprites
- farcall RefreshSprites
+ farcall Special_RefreshSprites
call LoadStandardFont
call LoadFontsExtra
ld a, [hROMBank]
@@ -2051,7 +2052,7 @@ ReloadTilesetAndPalettes:: ; 2bae
ld b, a
ld a, [MapNumber]
ld c, a
- call SwitchToAnyMapBank
+ call SwitchToAnyMapDataBank
farcall UpdateTimeOfDayPal
call OverworldTextModeSwitch
call LoadTilesetGFX
@@ -2064,21 +2065,20 @@ ReloadTilesetAndPalettes:: ; 2bae
ret
; 2be5
-GetMapHeaderPointer:: ; 2be5
+GetMapDefPointer:: ; 2be5
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
-GetAnyMapHeaderPointer:: ; 0x2bed
+GetAnyMapDefPointer:: ; 0x2bed
; Prior to calling this function, you must have switched banks so that
; MapGroupPointers is visible.
; inputs:
; b = map group, c = map number
-; XXX de = ???
; outputs:
-; hl points to the map header
+; hl points to the map_def
push bc ; save map number for later
; get pointer to map group
@@ -2094,7 +2094,7 @@ GetAnyMapHeaderPointer:: ; 0x2bed
ld l, a
pop bc ; restore map number
- ; find the cth map header
+ ; find the cth map_def
dec c
ld b, 0
ld a, 9
@@ -2102,28 +2102,28 @@ GetAnyMapHeaderPointer:: ; 0x2bed
ret
; 0x2c04
-GetMapHeaderMember:: ; 0x2c04
-; Extract data from the current map's header.
+GetMapDefField:: ; 0x2c04
+; Extract data from the current map's map_def.
; inputs:
-; de = offset of desired data within the mapheader
+; de = offset of desired data within the map_def (a MAPDEF_* constant)
; outputs:
-; bc = data from the current map's header
-; (e.g., de = $0003 would return a pointer to the secondary map header)
+; bc = data from the current map's map_def
+; (e.g., de = MAPDEF_TILESET would return a pointer to the tileset id)
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
-GetAnyMapHeaderMember:: ; 0x2c0c
+GetAnyMapDefField:: ; 0x2c0c
; bankswitch
ld a, [hROMBank]
push af
ld a, BANK(MapGroupPointers)
rst Bankswitch
- call GetAnyMapHeaderPointer
+ call GetAnyMapDefPointer
add hl, de
ld c, [hl]
inc hl
@@ -2135,44 +2135,44 @@ GetAnyMapHeaderMember:: ; 0x2c0c
ret
; 0x2c1c
-SwitchToMapBank:: ; 2c1c
+SwitchToMapDataBank:: ; 2c1c
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
-SwitchToAnyMapBank:: ; 2c24
- call GetAnyMapBank
+SwitchToAnyMapDataBank:: ; 2c24
+ call GetAnyMapDataBank
rst Bankswitch
ret
; 2c29
-GetMapBank:: ; 2c29
+GetMapDataBank:: ; 2c29
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
-GetAnyMapBank:: ; 2c31
+GetAnyMapDataBank:: ; 2c31
push hl
push de
- ld de, MAPHEADER_MAPHEADER2_BANK
- call GetAnyMapHeaderMember
+ ld de, MAPDEF_MAPDATA_BANK
+ call GetAnyMapDefField
ld a, c
pop de
pop hl
ret
; 2c3d
-PartiallyCopyMapHeader:: ; 2c3d
-; Copy second map header bank, tileset, environment, and second map header address
-; from the current map's map header.
+PartialCopyMapDef:: ; 2c3d
+; Copy map data bank, tileset, environment, and map data address
+; from the current map's map_def.
ld a, [hROMBank]
push af
ld a, BANK(MapGroupPointers)
rst Bankswitch
- call GetMapHeaderPointer
- ld de, wSecondMapHeaderBank
- ld bc, MapHeader - wSecondMapHeaderBank
+ call GetMapDefPointer
+ ld de, wPartialMapDef
+ ld bc, wPartialMapDefEnd - wPartialMapDef
call CopyBytes
pop af
@@ -2180,36 +2180,36 @@ PartiallyCopyMapHeader:: ; 2c3d
ret
; 2c52
-SwitchToMapScriptHeaderBank:: ; 2c52
- ld a, [MapScriptHeaderBank]
+SwitchToMapScriptsBank:: ; 2c52
+ ld a, [MapScriptsBank]
rst Bankswitch
ret
; 2c57
-GetMapScriptHeaderBank:: ; 2c57
- ld a, [MapScriptHeaderBank]
+GetMapScriptsBank:: ; 2c57
+ ld a, [MapScriptsBank]
ret
; 2c5b
-GetAnyMapBlockdataBank:: ; 2c5b
+GetAnyMapBlocksBank:: ; 2c5b
; Return the blockdata bank for group b map c.
push hl
push de
push bc
push bc
- ld de, MAPHEADER_MAPHEADER2
- call GetAnyMapHeaderMember
+ ld de, MAPDEF_MAPDATA
+ call GetAnyMapDefField
ld l, c
ld h, b
pop bc
push hl
- ld de, MAPHEADER_MAPHEADER2_BANK
- call GetAnyMapHeaderMember
+ ld de, MAPDEF_MAPDATA_BANK
+ call GetAnyMapDefField
pop hl
- ld de, MAPHEADER_MAPHEADER2 ; blockdata bank
+ ld de, MAPDEF_MAPDATA ; blockdata bank
add hl, de
ld a, c
call GetFarByte
@@ -2221,12 +2221,12 @@ GetAnyMapBlockdataBank:: ; 2c5b
ret
; 2c7d
-GetSecondaryMapHeaderPointer:: ; 0x2c7d
-; returns the current map's secondary map header pointer in hl.
+GetMapDataPointer:: ; 0x2c7d
+; returns the current map's data pointer in hl.
push bc
push de
- ld de, MAPHEADER_MAPHEADER2
- call GetMapHeaderMember
+ ld de, MAPDEF_MAPDATA
+ call GetMapDefField
ld l, c
ld h, b
pop de
@@ -2238,8 +2238,8 @@ GetMapEnvironment:: ; 2c8a
push hl
push de
push bc
- ld de, MAPHEADER_ENVIRONMENT
- call GetMapHeaderMember
+ ld de, MAPDEF_ENVIRONMENT
+ call GetMapDefField
ld a, c
pop bc
pop de
@@ -2247,15 +2247,15 @@ GetMapEnvironment:: ; 2c8a
ret
; 2c98
- ret ; XXX
+ ret ; unused
; 2c99
GetAnyMapEnvironment:: ; 2c99
push hl
push de
push bc
- ld de, MAPHEADER_ENVIRONMENT
- call GetAnyMapHeaderMember
+ ld de, MAPDEF_ENVIRONMENT
+ call GetAnyMapDefField
ld a, c
pop bc
pop de
@@ -2264,8 +2264,8 @@ GetAnyMapEnvironment:: ; 2c99
; 2ca7
GetAnyMapTileset:: ; 2ca7
- ld de, MAPHEADER_TILESET
- call GetAnyMapHeaderMember
+ ld de, MAPDEF_TILESET
+ call GetAnyMapDefField
ld a, c
ret
; 2caf
@@ -2276,8 +2276,8 @@ GetWorldMapLocation:: ; 0x2caf
push de
push bc
- ld de, MAPHEADER_LOCATION
- call GetAnyMapHeaderMember
+ ld de, MAPDEF_LOCATION
+ call GetAnyMapDefField
ld a, c
pop bc
@@ -2286,11 +2286,11 @@ GetWorldMapLocation:: ; 0x2caf
ret
; 0x2cbd
-GetMapHeaderMusic:: ; 2cbd
+GetMapMusic:: ; 2cbd
push hl
push bc
- ld de, MAPHEADER_MUSIC
- call GetMapHeaderMember
+ ld de, MAPDEF_MUSIC
+ call GetMapDefField
ld a, c
cp MUSIC_MAHOGANY_MART
jr z, .mahoganymart
@@ -2331,13 +2331,13 @@ GetMapHeaderMusic:: ; 2cbd
jr .done
; 2cff
-GetMapHeaderTimeOfDayNybble:: ; 2cff
+GetMapTimeOfDay:: ; 2cff
call GetPhoneServiceTimeOfDayByte
and $f
ret
; 2d05
-GetMapHeaderPhoneServiceNybble:: ; 2d05
+GetMapPhoneService:: ; 2d05
call GetPhoneServiceTimeOfDayByte
and $f0
swap a
@@ -2348,8 +2348,8 @@ GetPhoneServiceTimeOfDayByte:: ; 2d0d
push hl
push bc
- ld de, MAPHEADER_PALETTE
- call GetMapHeaderMember
+ ld de, MAPDEF_PALETTE
+ call GetMapDefField
ld a, c
pop bc
@@ -2362,8 +2362,8 @@ GetFishingGroup:: ; 2d19
push hl
push bc
- ld de, MAPHEADER_FISHGROUP
- call GetMapHeaderMember
+ ld de, MAPDEF_FISHGROUP
+ call GetMapDefField
ld a, c
pop bc