summaryrefslogtreecommitdiff
path: root/home
diff options
context:
space:
mode:
Diffstat (limited to 'home')
-rw-r--r--home/audio.asm47
-rw-r--r--home/cry.asm18
-rw-r--r--home/fade.asm3
-rw-r--r--home/game_time.asm2
-rw-r--r--home/init.asm18
-rw-r--r--home/lcd.asm3
-rw-r--r--home/map.asm258
-rw-r--r--home/map_objects.asm4
-rw-r--r--home/menu.asm27
-rw-r--r--home/mobile.asm6
-rw-r--r--home/names.asm26
-rw-r--r--home/palettes.asm2
-rw-r--r--home/pokedex_flags.asm2
-rw-r--r--home/serial.asm133
-rw-r--r--home/sine.asm2
-rw-r--r--home/text.asm188
-rw-r--r--home/trainers.asm14
-rw-r--r--home/vblank.asm4
-rw-r--r--home/video.asm12
-rw-r--r--home/window.asm2
20 files changed, 381 insertions, 390 deletions
diff --git a/home/audio.asm b/home/audio.asm
index 35f98af4d..44786ee29 100644
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -141,7 +141,7 @@ PlayMusic2:: ; 3bbc
; 3be3
-PlayCryHeader:: ; 3be3
+PlayCry:: ; 3be3
; Play cry header de.
push hl
@@ -176,11 +176,11 @@ endr
ld a, [hl]
ld [CryLength + 1], a
- ld a, BANK(_PlayCryHeader)
+ ld a, BANK(_PlayCry)
ld [hROMBank], a
ld [MBC3RomBank], a
- call _PlayCryHeader
+ call _PlayCry
pop af
ld [hROMBank], a
@@ -319,7 +319,7 @@ Unused_FadeOutMusic:: ; 3ca8
; 3cae
FadeInMusic:: ; 3cae
- ld a, 4 | 1 << 7
+ ld a, 4 | (1 << MUSIC_FADE_IN_F)
ld [MusicFade], a
ret
; 3cb4
@@ -340,7 +340,7 @@ FadeToMapMusic:: ; 3cbc
push bc
push af
- call GetMapMusic
+ call GetMapMusic_MaybeSpecial
ld a, [wMapMusic]
cp e
jr z, .done
@@ -368,7 +368,7 @@ PlayMapMusic:: ; 3cdf
push bc
push af
- call GetMapMusic
+ call GetMapMusic_MaybeSpecial
ld a, [wMapMusic]
cp e
jr z, .done
@@ -402,7 +402,7 @@ EnterMapMusic:: ; 3d03
ld a, [PlayerState]
cp PLAYER_BIKE
jr z, .play
- call GetMapMusic
+ call GetMapMusic_MaybeSpecial
.play
push de
ld de, MUSIC_NONE
@@ -495,27 +495,26 @@ SpecialMapMusic:: ; 3d62
ret
; 3d97
-GetMapMusic:: ; 3d97
+GetMapMusic_MaybeSpecial:: ; 3d97
call SpecialMapMusic
ret c
- call GetMapHeaderMusic
+ call GetMapMusic
ret
; 3d9f
-Function3d9f:: ; 3d9f
+Unreferenced_Function3d9f:: ; 3d9f
; Places a BCD number at the
; upper center of the screen.
-; Unreferenced.
- ld a, 4 * 8
- ld [Sprites + 38 * 4], a
- ld [Sprites + 39 * 4], a
- ld a, 10 * 8
- ld [Sprites + 38 * 4 + 1], a
- ld a, 11 * 8
- ld [Sprites + 39 * 4 + 1], a
+ ld a, 4 * TILE_WIDTH
+ ld [Sprite39YCoord], a
+ ld [Sprite40YCoord], a
+ ld a, 10 * TILE_WIDTH
+ ld [Sprite39XCoord], a
+ ld a, 11 * TILE_WIDTH
+ ld [Sprite40XCoord], a
xor a
- ld [Sprites + 38 * 4 + 3], a
- ld [Sprites + 39 * 4 + 3], a
+ ld [Sprite39Attributes], a
+ ld [Sprite40Attributes], a
ld a, [wc296]
cp 100
jr nc, .max
@@ -525,17 +524,17 @@ Function3d9f:: ; 3d9f
swap a
and $f
add "0"
- ld [Sprites + 38 * 4 + 2], a
+ ld [Sprite39TileID], a
ld a, b
and $f
add "0"
- ld [Sprites + 39 * 4 + 2], a
+ ld [Sprite40TileID], a
ret
.max
ld a, "9"
- ld [Sprites + 38 * 4 + 2], a
- ld [Sprites + 39 * 4 + 2], a
+ ld [Sprite39TileID], a
+ ld [Sprite40TileID], a
ret
; 3dde
diff --git a/home/cry.asm b/home/cry.asm
index 393534a29..204b02ba4 100644
--- a/home/cry.asm
+++ b/home/cry.asm
@@ -3,7 +3,7 @@ PlayStereoCry:: ; 37b6
ld a, 1
ld [wStereoPanningMask], a
pop af
- call _PlayCry
+ call _PlayMonCry
call WaitSFX
ret
; 37c4
@@ -15,27 +15,27 @@ PlayStereoCry2:: ; 37c4
ld a, 1
ld [wStereoPanningMask], a
pop af
- jp _PlayCry
+ jp _PlayMonCry
; 37ce
-PlayCry:: ; 37ce
- call PlayCry2
+PlayMonCry:: ; 37ce
+ call PlayMonCry2
call WaitSFX
ret
; 37d5
-PlayCry2:: ; 37d5
+PlayMonCry2:: ; 37d5
; Don't wait for the cry to end.
push af
xor a
ld [wStereoPanningMask], a
ld [CryTracks], a
pop af
- call _PlayCry
+ call _PlayMonCry
ret
; 37e2
-_PlayCry:: ; 37e2
+_PlayMonCry:: ; 37e2
push hl
push de
push bc
@@ -45,7 +45,7 @@ _PlayCry:: ; 37e2
ld e, c
ld d, b
- call PlayCryHeader
+ call PlayCry
.done
pop bc
@@ -54,7 +54,7 @@ _PlayCry:: ; 37e2
ret
; 37f3
-LoadCryHeader:: ; 37f3
+LoadCry:: ; 37f3
; Load cry header bc.
call GetCryIndex
diff --git a/home/fade.asm b/home/fade.asm
index c5eb2c2eb..d81a49c6c 100644
--- a/home/fade.asm
+++ b/home/fade.asm
@@ -1,8 +1,7 @@
; Functions to fade the screen in and out.
-Function48c:: ; 48c
-; XXX
+Unreferenced_Function48c:: ; 48c
; TimeOfDayFade
ld a, [TimeOfDayPal]
ld b, a
diff --git a/home/game_time.asm b/home/game_time.asm
index 69ea0099e..36dcaa282 100644
--- a/home/game_time.asm
+++ b/home/game_time.asm
@@ -16,7 +16,7 @@ GameTimer:: ; 209e
ld a, [rSVBK]
push af
- ld a, 1
+ ld a, BANK(GameTime)
ld [rSVBK], a
call UpdateGameTimer
diff --git a/home/init.asm b/home/init.asm
index 8895da0f9..d8e476c3f 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -32,7 +32,7 @@ _Start:: ; 16e
.load
ld [hCGB], a
ld a, $1
- ld [hFFEA], a
+ ld [hSystemBooted], a
; 17d
@@ -55,7 +55,7 @@ Init:: ; 17d
ld [rOBP1], a
ld [rTMA], a
ld [rTAC], a
- ld [$d000], a
+ ld [WRAM1_Begin], a
ld a, %100 ; Start timer at 4096Hz
ld [rTAC], a
@@ -84,14 +84,14 @@ Init:: ; 17d
; Clear HRAM
ld a, [hCGB]
push af
- ld a, [hFFEA]
+ ld a, [hSystemBooted]
push af
xor a
ld hl, HRAM_Begin
ld bc, HRAM_End - HRAM_Begin
call ByteFill
pop af
- ld [hFFEA], a
+ ld [hSystemBooted], a
pop af
ld [hCGB], a
@@ -136,8 +136,8 @@ Init:: ; 17d
; BG on
ld [rLCDC], a
- ld a, -1
- ld [hLinkPlayerNumber], a
+ ld a, CONNECTION_NOT_ESTABLISHED
+ ld [hSerialConnectionStatus], a
farcall InitCGBPals
@@ -182,11 +182,11 @@ ClearVRAM:: ; 245
ld [rVBK], a
call .clear
- xor a
+ xor a ; 0
ld [rVBK], a
.clear
- ld hl, vTiles0
- ld bc, $2000
+ ld hl, VRAM_Begin
+ ld bc, VRAM_End - VRAM_Begin
xor a
call ByteFill
ret
diff --git a/home/lcd.asm b/home/lcd.asm
index dfb174ee1..e2fb4c5a9 100644
--- a/home/lcd.asm
+++ b/home/lcd.asm
@@ -1,8 +1,7 @@
; LCD handling
-Function547:: ; 547
-; Unreferenced
+Unreferenced_Function547:: ; 547
ld a, [hLCDCPointer]
cp rSCX - $ff00
ret nz
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
diff --git a/home/map_objects.asm b/home/map_objects.asm
index 3857bef0c..1db2bb3ba 100644
--- a/home/map_objects.asm
+++ b/home/map_objects.asm
@@ -316,7 +316,7 @@ CheckObjectTime:: ; 18f5
ret
; 194d
-; XXX
+; unused
ld [hMapObjectIndexBuffer], a
call GetMapObject
call CopyObjectStruct
@@ -383,7 +383,7 @@ CopyPlayerObjectTemplate:: ; 19a6
ret
; 19b8
-; XXX
+Unreferenced_Function19b8:
call GetMapObject
ld hl, MAPOBJECT_OBJECT_STRUCT_ID
add hl, bc
diff --git a/home/menu.asm b/home/menu.asm
index 03cec64df..f8ade3f58 100644
--- a/home/menu.asm
+++ b/home/menu.asm
@@ -28,8 +28,7 @@ MenuTextBox:: ; 1d4f
jp PrintText
; 1d57
-ret_1d57:: ; 1d57
-; unreferenced
+; unused
ret
; 1d58
@@ -40,9 +39,8 @@ LoadMenuTextBox:: ; 1d58
; 1d5f
.MenuDataHeader: ; 1d5f
- db $40 ; tile backup
- db 12, 0 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 12, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw vTiles0
db 0 ; default option
; 1d67
@@ -60,9 +58,8 @@ LoadStandardMenuDataHeader:: ; 1d6e
; 1d75
.MenuDataHeader: ; 1d75
- db $40 ; tile backup
- db 0, 0 ; start coords
- db 17, 19 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw 0
db 1 ; default option
; 1d7d
@@ -183,15 +180,14 @@ InterpretTwoOptionMenu:: ; 1dfe
; 1e1d
YesNoMenuDataHeader:: ; 1e1d
- db $40 ; tile backup
- db 5, 10 ; start coords
- db 9, 15 ; end coords
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 10, 5, 15, 9
dw .MenuData2
db 1 ; default option
; 1e25
.MenuData2: ; 1e25
- db $c0 ; flags
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2
db "YES@"
db "NO@"
@@ -453,8 +449,7 @@ PlaceNthMenuStrings:: ; 1f8d
ret
; 1f9e
-Function1f9e:: ; 1f9e
-; unreferenced
+Unreferenced_Function1f9e:: ; 1f9e
call GetMenuDataPointerTableEntry
inc hl
inc hl
@@ -499,7 +494,7 @@ ClearWindowData:: ; 1fbf
ld a, [rSVBK]
push af
- ld a, $7
+ ld a, BANK(wWindowStack)
ld [rSVBK], a
xor a
@@ -517,7 +512,7 @@ ClearWindowData:: ; 1fbf
; 1ff0
.bytefill ; 1ff0
- ld bc, $0010
+ ld bc, $10
xor a
call ByteFill
ret
diff --git a/home/mobile.asm b/home/mobile.asm
index f50571ff4..1248c3f7e 100644
--- a/home/mobile.asm
+++ b/home/mobile.asm
@@ -127,8 +127,7 @@ Timer:: ; 3e93
reti
; 3ed7
-Function3ed7:: ; 3ed7
-; unreferenced
+Unreferenced_Function3ed7:: ; 3ed7
ld [$dc02], a
ld a, [hROMBank]
push af
@@ -160,8 +159,7 @@ Function3eea:: ; 3eea
ret
; 3efd
-Function3efd:: ; 3efd
-; unreferenced
+Unreferenced_Function3efd:: ; 3efd
push hl
hlcoord 0, 12
ld b, 4
diff --git a/home/names.asm b/home/names.asm
index c8f873c3f..37ce4f37d 100644
--- a/home/names.asm
+++ b/home/names.asm
@@ -1,13 +1,13 @@
NamesPointers:: ; 33ab
-; entries correspond to GetName constants (see constants/misc_constants.asm)
- dba PokemonNames
- dba MoveNames
- dbw 0, 0
- dba ItemNames
- dbw 0, PartyMonOT
- dbw 0, OTPartyMonOT
- dba TrainerClassNames
- dbw $4, $4b52 ; within PackMenuGFX
+; entries correspond to GetName constants (see constants/text_constants.asm)
+ dba PokemonNames ; MON_NAME (not used; jumps to GetPokemonName)
+ dba MoveNames ; MOVE_NAME
+ dbw 0, NULL ; DUMMY_NAME
+ dba ItemNames ; ITEM_NAME
+ dbw 0, PartyMonOT ; PARTY_OT_NAME
+ dbw 0, OTPartyMonOT ; ENEMY_OT_NAME
+ dba TrainerClassNames ; TRAINER_NAME
+ dbw 4, MoveDescriptions ; MOVE_DESC_NAME_BROKEN (wrong bank)
; 33c3
GetName:: ; 33c3
@@ -20,13 +20,13 @@ GetName:: ; 33c3
push de
ld a, [wNamedObjectTypeBuffer]
- cp PKMN_NAME
+ cp MON_NAME
jr nz, .NotPokeName
ld a, [CurSpecies]
ld [wd265], a
call GetPokemonName
- ld hl, PKMN_NAME_LENGTH
+ ld hl, MON_NAME_LENGTH
add hl, de
ld e, l
ld d, h
@@ -140,9 +140,9 @@ GetPokemonName:: ; 343b
; Terminator
ld de, StringBuffer1
push de
- ld bc, PKMN_NAME_LENGTH - 1
+ ld bc, MON_NAME_LENGTH - 1
call CopyBytes
- ld hl, StringBuffer1 + PKMN_NAME_LENGTH - 1
+ ld hl, StringBuffer1 + MON_NAME_LENGTH - 1
ld [hl], "@"
pop de
diff --git a/home/palettes.asm b/home/palettes.asm
index 79ff71887..9f10da118 100644
--- a/home/palettes.asm
+++ b/home/palettes.asm
@@ -319,7 +319,7 @@ ret_d90:: ; d90
; d91
-Special_ReloadSpritesNoPalettes:: ; d91
+ReloadSpritesNoPalettes:: ; d91
ld a, [hCGB]
and a
ret z
diff --git a/home/pokedex_flags.asm b/home/pokedex_flags.asm
index 7aacd4981..bedb91d18 100644
--- a/home/pokedex_flags.asm
+++ b/home/pokedex_flags.asm
@@ -31,7 +31,7 @@ CheckSeenMon:: ; 339b
PokedexFlagAction:: ; 33a1
ld d, 0
- predef FlagPredef
+ predef SmallFarFlagAction
ld a, c
and a
ret
diff --git a/home/serial.asm b/home/serial.asm
index b0151eae2..7fdf1fc03 100644
--- a/home/serial.asm
+++ b/home/serial.asm
@@ -14,9 +14,9 @@ Serial:: ; 6ef
bit 0, a
jr nz, .printer
- ld a, [hLinkPlayerNumber]
- inc a ; is it equal to -1?
- jr z, .init_player_number
+ ld a, [hSerialConnectionStatus]
+ inc a ; is it equal to CONNECTION_NOT_ESTABLISHED?
+ jr z, .establish_connection
ld a, [rSB]
ld [hSerialReceive], a
@@ -24,8 +24,8 @@ Serial:: ; 6ef
ld a, [hSerialSend]
ld [rSB], a
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr z, .player2
ld a, 0 << rSC_ON
@@ -42,22 +42,22 @@ Serial:: ; 6ef
call PrinterReceive
jr .end
-.init_player_number
+.establish_connection
ld a, [rSB]
- cp $1
+ cp USING_EXTERNAL_CLOCK
jr z, .player1
- cp $2
+ cp USING_INTERNAL_CLOCK
jr nz, .player2
.player1
ld [hSerialReceive], a
- ld [hLinkPlayerNumber], a
- cp $2
+ ld [hSerialConnectionStatus], a
+ cp USING_INTERNAL_CLOCK
jr z, ._player2
xor a
ld [rSB], a
- ld a, $3
+ ld a, 3
ld [rDIV], a
.wait_bit_7
@@ -76,9 +76,9 @@ Serial:: ; 6ef
ld [rSB], a
.player2
- ld a, $1
- ld [hFFCA], a
- ld a, $fe
+ ld a, TRUE
+ ld [hSerialReceivedNewData], a
+ ld a, SERIAL_NO_DATA_BYTE
ld [hSerialSend], a
.end
@@ -89,13 +89,13 @@ Serial:: ; 6ef
reti
; 75f
-Function75f:: ; 75f
+Serial_ExchangeBytes:: ; 75f
ld a, $1
- ld [hFFCC], a
+ ld [hSerialIgnoringInitialData], a
.loop
ld a, [hl]
ld [hSerialSend], a
- call Function78a
+ call Serial_ExchangeByte
push bc
ld b, a
inc hl
@@ -103,16 +103,16 @@ Function75f:: ; 75f
.wait
dec a
jr nz, .wait
- ld a, [hFFCC]
+ ld a, [hSerialIgnoringInitialData]
and a
ld a, b
pop bc
jr z, .load
dec hl
- cp $fd
+ cp SERIAL_PREAMBLE_BYTE
jr nz, .loop
xor a
- ld [hFFCC], a
+ ld [hSerialIgnoringInitialData], a
jr .loop
.load
@@ -125,24 +125,24 @@ Function75f:: ; 75f
ret
; 78a
-Function78a:: ; 78a
+Serial_ExchangeByte:: ; 78a
.loop
xor a
- ld [hFFCA], a
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld [hSerialReceivedNewData], a
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr nz, .not_player_2
- ld a, $1
+ ld a, (0 << rSC_ON) | 1
ld [rSC], a
- ld a, $81
+ ld a, (1 << rSC_ON) | 1
ld [rSC], a
.not_player_2
.loop2
- ld a, [hFFCA]
+ ld a, [hSerialReceivedNewData]
and a
jr nz, .reset_ffca
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr nz, .not_player_1_or_wLinkTimeoutFrames_zero
call CheckwLinkTimeoutFramesNonzero
jr z, .not_player_1_or_wLinkTimeoutFrames_zero
@@ -162,8 +162,8 @@ Function78a:: ; 78a
.not_player_1_or_wLinkTimeoutFrames_zero
ld a, [rIE]
- and $f
- cp $8
+ and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
+ cp 1 << SERIAL
jr nz, .loop2
ld a, [wcf5d]
dec a
@@ -173,8 +173,8 @@ Function78a:: ; 78a
dec a
ld [wcf5d + 1], a
jr nz, .loop2
- ld a, [hLinkPlayerNumber]
- cp $1
+ ld a, [hSerialConnectionStatus]
+ cp USING_EXTERNAL_CLOCK
jr z, .reset_ffca
ld a, 255
@@ -184,19 +184,20 @@ Function78a:: ; 78a
.reset_ffca
xor a
- ld [hFFCA], a
+ ld [hSerialReceivedNewData], a
ld a, [rIE]
- and $f
- sub $8
+ and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
+ sub 1 << SERIAL
jr nz, .rIE_not_equal_8
+ ; LOW($5000)
ld [wcf5d], a
- ld a, $50
+ ld a, HIGH($5000)
ld [wcf5d + 1], a
.rIE_not_equal_8
ld a, [hSerialReceive]
- cp $fe
+ cp SERIAL_NO_DATA_BYTE
ret nz
call CheckwLinkTimeoutFramesNonzero
jr z, .wLinkTimeoutFrames_zero
@@ -216,9 +217,9 @@ Function78a:: ; 78a
.wLinkTimeoutFrames_zero
ld a, [rIE]
- and $f
- cp $8
- ld a, $fe
+ and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
+ cp 1 << SERIAL
+ ld a, SERIAL_NO_DATA_BYTE
ret z
ld a, [hl]
ld [hSerialSend], a
@@ -243,29 +244,31 @@ CheckwLinkTimeoutFramesNonzero:: ; 82b
; 833
SerialDisconnected:: ; 833
- dec a
+ dec a ; a is always 0 when this is called
ld [wLinkTimeoutFrames], a
ld [wLinkTimeoutFrames + 1], a
ret
; 83b
-Function83b:: ; 83b
+; This is used to exchange the button press and selected menu item on the link menu.
+; The data is sent thrice and read twice to increase reliability.
+Serial_ExchangeLinkMenuSelection:: ; 83b
ld hl, wPlayerLinkAction
ld de, wOtherPlayerLinkMode
- ld c, $2
- ld a, $1
- ld [hFFCC], a
+ ld c, 2
+ ld a, TRUE
+ ld [hSerialIgnoringInitialData], a
.asm_847
call DelayFrame
ld a, [hl]
ld [hSerialSend], a
- call Function78a
+ call Serial_ExchangeByte
ld b, a
inc hl
- ld a, [hFFCC]
+ ld a, [hSerialIgnoringInitialData]
and a
- ld a, $0
- ld [hFFCC], a
+ ld a, FALSE
+ ld [hSerialIgnoringInitialData], a
jr nz, .asm_847
ld a, b
ld [de], a
@@ -275,15 +278,14 @@ Function83b:: ; 83b
ret
; 862
-Function862:: ; 862
+Serial_PrintWaitingTextAndSyncAndExchangeNybble:: ; 862
call LoadTileMapToTempTileMap
callfar PlaceWaitingText
call WaitLinkTransfer
jp Call_LoadTempTileMapToTileMap
; 871
-
-Function871:: ; 871
+Serial_SyncAndExchangeNybble:: ; 871
call LoadTileMapToTempTileMap
callfar PlaceWaitingText
jp WaitLinkTransfer
@@ -356,12 +358,12 @@ LinkTransfer:: ; 8c1
ld a, [wPlayerLinkAction]
add b
ld [hSerialSend], a
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
jr nz, .player_1
- ld a, $1
+ ld a, (0 << rSC_ON) | 1
ld [rSC], a
- ld a, $81
+ ld a, (1 << rSC_ON) | 1
ld [rSC], a
.player_1
@@ -388,28 +390,27 @@ LinkDataReceived:: ; 908
; Let the other system know that the data has been received.
xor a
ld [hSerialSend], a
- ld a, [hLinkPlayerNumber]
- cp $2
+ ld a, [hSerialConnectionStatus]
+ cp USING_INTERNAL_CLOCK
ret nz
- ld a, $1
+ ld a, (0 << rSC_ON) | 1
ld [rSC], a
- ld a, $81
+ ld a, (1 << rSC_ON) | 1
ld [rSC], a
ret
; 919
-Function919:: ; 919
-; XXX
+Unreferenced_Function919:: ; 919
ld a, [wLinkMode]
and a
ret nz
- ld a, $2
+ ld a, USING_INTERNAL_CLOCK
ld [rSB], a
xor a
ld [hSerialReceive], a
- ld a, $0
+ ld a, 0 << rSC_ON
ld [rSC], a
- ld a, $80
+ ld a, 1 << rSC_ON
ld [rSC], a
ret
; 92e
diff --git a/home/sine.asm b/home/sine.asm
index 810845860..eff5ed299 100644
--- a/home/sine.asm
+++ b/home/sine.asm
@@ -1,6 +1,6 @@
Cosine:: ; 1b0f
; Return d * cos(a) in hl
- add $10 ; 90 degrees
+ add %010000 ; 90 degrees
Sine:: ; 1b11
; Return d * sin(a) in hl
diff --git a/home/text.asm b/home/text.asm
index 191c96172..2dbb85f6d 100644
--- a/home/text.asm
+++ b/home/text.asm
@@ -47,10 +47,8 @@ ClearScreen:: ; fdb
TextBox:: ; fe8
-; Draw a text box at hl with room for
-; b lines of c characters each.
-; Places a border around the textbox,
-; then switches the palette to the
+; Draw a text box at hl with room for b lines of c characters each.
+; Places a border around the textbox, then switches the palette to the
; text black-and-white scheme.
push bc
push hl
@@ -146,7 +144,7 @@ SpeechTextBox:: ; 103e
; 1048
TestText:: ; 1048
- text "ゲームフりーク!"
+ text "ゲームフりーク!"
done
; 1052
@@ -216,31 +214,31 @@ dict2: MACRO
._\@:
ENDM
- dict "<DAY>", Char15
+ dict TX_DAY, DayOfWeekChar
dict "<LINE>", LineChar
dict "<NEXT>", NextLineChar
dict TX_FAR, TextFar
- dict $00, NullChar
- dict $4c, Char4C
- dict $4b, Char4B
+ dict TX_START, NullChar
+ dict "<SCROLL>", _ContTextNoPause
+ dict "<_CONT>", _ContText
dict "<PARA>", Paragraph
dict "<MOM>", PrintMomsName
dict "<PLAYER>", PrintPlayerName
dict "<RIVAL>", PrintRivalName
- dict $35, Char35
- dict $36, Char36
- dict $37, Char37
+ dict "<ROUTE>", PlaceJPRoute
+ dict "<WATASHI>", PlaceWatashi
+ dict "<KOKO_WA>", PlaceKokoWa
dict "<RED>", PrintRedsName
dict "<GREEN>", PrintGreensName
dict "#", PlacePOKe
dict "<PC>", PCChar
dict "<ROCKET>", RocketChar
dict "<TM>", TMChar
- dict "<TRNER>", TrainerChar
+ dict "<TRAINER>", TrainerChar
dict "<KOUGEKI>", PlaceKougeki
- dict "<LNBRK>", Char22
+ dict "<LNBRK>", LineBreakChar
dict "<CONT>", ContText
- dict "<......>", SixDotsChar
+ dict "<……>", SixDotsChar
dict "<DONE>", DoneText
dict "<PROMPT>", PromptText
dict "<PKMN>", PlacePKMN
@@ -265,32 +263,32 @@ ENDM
jp NextChar
.not_diacritic
- cp $60 ; Regular characters
+ cp FIRST_REGULAR_TEXT_CHAR
jr nc, .place
cp "パ"
jr nc, .handakuten
.dakuten
- cp $20
- jr nc, .daku1
+ cp FIRST_HIRAGANA_DAKUTEN_CHAR
+ jr nc, .hiragana_dakuten
add "カ" - "ガ"
- jr .daku2
-.daku1
+ jr .katakana_dakuten
+.hiragana_dakuten
add "か" - "が"
-.daku2
+.katakana_dakuten
ld b, "゙" ; dakuten
call Diacritic
jr .place
.handakuten
cp "ぱ"
- jr nc, .han1
+ jr nc, .hiragana_handakuten
add "ハ" - "パ"
- jr .han2
-.han1
+ jr .katakana_handakuten
+.hiragana_handakuten
add "は" - "ぱ"
-.han2
+.katakana_handakuten
ld b, "゚" ; handakuten
call Diacritic
@@ -301,7 +299,7 @@ ENDM
; 0x117b
-Char15:: ; 117b
+DayOfWeekChar:: ; 117b
ld c, l
ld b, h
farcall Function17f036
@@ -330,20 +328,20 @@ PlaceKougeki: print_name KougekiText ; 11cc
SixDotsChar: print_name SixDotsCharText ; 11d3
PlacePKMN: print_name PlacePKMNText ; 11da
PlacePOKE: print_name PlacePOKEText ; 11e1
-Char35: print_name Char35Text ; 11e8
-Char36: print_name Char36Text ; 11ef
-Char37: print_name Char37Text ; 11f6
+PlaceJPRoute: print_name PlaceJPRouteText ; 11e8
+PlaceWatashi: print_name PlaceWatashiText ; 11ef
+PlaceKokoWa: print_name PlaceKokoWaText ; 11f6
PlaceMoveTargetsName:: ; 11fd
ld a, [hBattleTurn]
xor 1
- jr PlaceMoveTargetsName_5A
+ jr PlaceMoveUsersName.place
PlaceMoveUsersName:: ; 1203
ld a, [hBattleTurn]
-PlaceMoveTargetsName_5A: ; 1205
+.place: ; 1205
push de
and a
jr nz, .enemy
@@ -352,7 +350,7 @@ PlaceMoveTargetsName_5A: ; 1205
jr PlaceCommandCharacter
.enemy
- ld de, EnemyText ; Enemy
+ ld de, EnemyText
call PlaceString
ld h, b
ld l, c
@@ -377,7 +375,7 @@ PlaceEnemysName:: ; 121b
call PlaceString
ld h, b
ld l, c
- ld de, String12a2
+ ld de, String_Space
call PlaceString
push bc
callfar Battle_GetTrainerName
@@ -402,9 +400,9 @@ PlaceGenderedPlayerName:: ; 1252
ld l, c
ld a, [wPlayerGender]
bit 0, a
- ld de, String_kun
+ ld de, KunSuffixText
jr z, PlaceCommandCharacter
- ld de, String_chan
+ ld de, ChanSuffixText
jr PlaceCommandCharacter
@@ -416,22 +414,23 @@ PlaceCommandCharacter:: ; 126a
jp NextChar
; 0x1273
-TMCharText:: db "TM@" ; 1273
-TrainerCharText:: db "TRAINER@" ; 1276
-PCCharText:: db "PC@" ; 127e
-RocketCharText:: db "ROCKET@" ; 1281
-PlacePOKeText:: db "POKé@" ; 1288
-KougekiText:: db "こうげき@" ; 128d
-SixDotsCharText:: db "……@" ; 1292
-EnemyText:: db "Enemy @" ; 1295
-PlacePKMNText:: db "<PK><MN>@" ; PK MN ; 129c
-PlacePOKEText:: db "<PO><KE>@" ; PO KE ; 129f
-String12a2:: db " @" ; 12a2
-Char35Text::
-Char36Text::
-Char37Text:: db "@" ; 12a4
-String_kun:: db "@" ; 12a5
-String_chan:: db "@" ; 12a6
+TMCharText:: db "TM@"
+TrainerCharText:: db "TRAINER@"
+PCCharText:: db "PC@"
+RocketCharText:: db "ROCKET@"
+PlacePOKeText:: db "POKé@"
+KougekiText:: db "こうげき@"
+SixDotsCharText:: db "……@"
+EnemyText:: db "Enemy @"
+PlacePKMNText:: db "<PK><MN>@"
+PlacePOKEText:: db "<PO><KE>@"
+String_Space:: db " @"
+; These strings have been dummied out.
+PlaceJPRouteText::
+PlaceWatashiText::
+PlaceKokoWaText:: db "@"
+KunSuffixText:: db "@"
+ChanSuffixText:: db "@"
; 12a7
NextLineChar:: ; 12a7
@@ -442,7 +441,7 @@ NextLineChar:: ; 12a7
jp NextChar
; 12b0
-Char22:: ; 12b0
+LineBreakChar:: ; 12b0
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
@@ -525,7 +524,7 @@ Paragraph:: ; 12f2
; 131f
-Char4B:: ; 131f
+_ContText:: ; 131f
ld a, [wLinkMode]
or a
jr nz, .communication
@@ -541,8 +540,9 @@ Char4B:: ; 131f
ld a, [wLinkMode]
or a
call z, UnloadBlinkingCursor
+ ; fallthrough
-Char4C:: ; 1337
+_ContTextNoPause:: ; 1337
push de
call TextScroll
call TextScroll
@@ -563,7 +563,7 @@ ContText:: ; 1345
pop de
jp NextChar
-.cont db $4b, "@"
+.cont: db "<_CONT>@"
; 1356
@@ -598,7 +598,8 @@ DoneText:: ; 137c
ld de, .stop
dec de
ret
-.stop db "@"
+
+.stop: db "@"
; 1383
NullChar:: ; 1383
@@ -690,7 +691,7 @@ PokeFluteTerminatorCharacter:: ; 13e0
ld hl, .stop
ret
-.stop db "@"
+.stop: db "@"
; 13e5
@@ -734,30 +735,30 @@ DoTextUntilTerminator:: ; 13f6
; 1410
TextCommands:: ; 1410
-; entries correspond to macros/text.asm enumeration
- dw Text_TX
- dw Text_TX_RAM
- dw Text_TX_BCD
- dw Text_TX_MOVE
- dw Text_TX_BOX
- dw Text_TX_LOW
- dw Text_WAIT_BUTTON
- dw Text_TX_SCROLL
- dw Text_START_ASM
- dw Text_TX_NUM
- dw Text_TX_EXIT
- dw Text_PlaySound ; $0b
- dw Text_TX_DOTS
- dw Text_0D
- dw Text_PlaySound ; $0e
- dw Text_PlaySound ; $0f
- dw Text_PlaySound ; $10
- dw Text_PlaySound ; $11
- dw Text_PlaySound ; $12
- dw Text_PlaySound ; $13
- dw Text_TX_STRINGBUFFER
- dw Text_TX_DAY
- dw Text_TX_FAR
+; entries correspond to TX_* constants (see macros/scripts/text.asm)
+ dw Text_TX ; TX_START
+ dw Text_TX_RAM ; TX_RAM
+ dw Text_TX_BCD ; TX_BCD
+ dw Text_TX_MOVE ; TX_MOVE
+ dw Text_TX_BOX ; TX_BOX
+ dw Text_TX_LOW ; TX_LOW
+ dw Text_WAIT_BUTTON ; WAIT_BUTTON
+ dw Text_TX_SCROLL ; TX_SCROLL
+ dw Text_START_ASM ; START_ASM
+ dw Text_TX_NUM ; TX_NUM
+ dw Text_TX_EXIT ; TX_EXIT
+ dw Text_PlaySound ; TX_SOUND_DEX_FANFARE_50_79
+ dw Text_TX_DOTS ; TX_DOTS
+ dw Text_LINK_WAIT_BUTTON ; TX_LINK_WAIT_BUTTON
+ dw Text_PlaySound ; TX_SOUND_DEX_FANFARE_20_49
+ dw Text_PlaySound ; TX_SOUND_ITEM
+ dw Text_PlaySound ; TX_SOUND_CAUGHT_MON
+ dw Text_PlaySound ; TX_SOUND_DEX_FANFARE_80_109
+ dw Text_PlaySound ; TX_SOUND_FANFARE
+ dw Text_PlaySound ; TX_SOUND_SLOT_MACHINE_START
+ dw Text_TX_STRINGBUFFER ; TX_STRINGBUFFER
+ dw Text_TX_DAY ; TX_DAY
+ dw Text_TX_FAR ; TX_FAR
; 143e
Text_TX:: ; 143e
@@ -899,9 +900,9 @@ Text_WAIT_BUTTON:: ; 149f
ld a, [wLinkMode]
cp LINK_COLOSSEUM
- jp z, Text_0D
+ jp z, Text_LINK_WAIT_BUTTON
cp LINK_MOBILE
- jp z, Text_0D
+ jp z, Text_LINK_WAIT_BUTTON
push hl
call LoadBlinkingCursor
@@ -1015,14 +1016,13 @@ Text_PlaySound:: ; 1500
ret
; 1522
-Function1522:: ; 1522
-; XXX
+Unreferenced_Function1522:: ; 1522
; TX_CRY
push de
ld e, [hl]
inc hl
ld d, [hl]
- call PlayCry
+ call PlayMonCry
pop de
pop hl
pop bc
@@ -1030,13 +1030,13 @@ Function1522:: ; 1522
; 152d
TextSFX:: ; 152d
- dbw TX_SOUND_0B, SFX_DEX_FANFARE_50_79
- dbw TX_SOUND_12, SFX_FANFARE
- dbw TX_SOUND_0E, SFX_DEX_FANFARE_20_49
- dbw TX_SOUND_0F, SFX_ITEM
- dbw TX_SOUND_10, SFX_CAUGHT_MON
- dbw TX_SOUND_11, SFX_DEX_FANFARE_80_109
- dbw TX_SOUND_13, SFX_SLOT_MACHINE_START
+ dbw TX_SOUND_DEX_FANFARE_50_79, SFX_DEX_FANFARE_50_79
+ dbw TX_SOUND_FANFARE, SFX_FANFARE
+ dbw TX_SOUND_DEX_FANFARE_20_49, SFX_DEX_FANFARE_20_49
+ dbw TX_SOUND_ITEM, SFX_ITEM
+ dbw TX_SOUND_CAUGHT_MON, SFX_CAUGHT_MON
+ dbw TX_SOUND_DEX_FANFARE_80_109, SFX_DEX_FANFARE_80_109
+ dbw TX_SOUND_SLOT_MACHINE_START, SFX_SLOT_MACHINE_START
db -1
; 1543
@@ -1069,7 +1069,7 @@ Text_TX_DOTS:: ; 1543
ret
; 1562
-Text_0D:: ; 1562
+Text_LINK_WAIT_BUTTON:: ; 1562
; wait for key down
; display arrow
push hl
diff --git a/home/trainers.asm b/home/trainers.asm
index 857a95629..4eabfbcbb 100644
--- a/home/trainers.asm
+++ b/home/trainers.asm
@@ -2,7 +2,7 @@ CheckTrainerBattle2:: ; 3600
ld a, [hROMBank]
push af
- call SwitchToMapScriptHeaderBank
+ call SwitchToMapScriptsBank
call CheckTrainerBattle
pop bc
@@ -110,7 +110,7 @@ TalkToTrainer:: ; 3674
ld [EngineBuffer3], a
LoadTrainer_continue:: ; 367e
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
ld [EngineBuffer1], a
ld a, [hLastTalked]
@@ -120,8 +120,8 @@ LoadTrainer_continue:: ; 367e
add hl, bc
ld a, [EngineBuffer1]
call GetFarHalfword
- ld de, wTempTrainerHeader
- ld bc, wTempTrainerHeaderEnd - wTempTrainerHeader
+ ld de, wTempTrainer
+ ld bc, wTempTrainerEnd - wTempTrainer
ld a, [EngineBuffer1]
call FarCopyBytes
xor a
@@ -221,7 +221,7 @@ CheckTrainerFlag:: ; 36f5
ld a, [hli]
ld h, [hl]
ld l, a
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
call GetFarHalfword
ld d, h
ld e, l
@@ -240,7 +240,7 @@ PrintWinLossText:: ; 3718
cp BATTLETYPE_CANLOSE
jr .canlose ; ??????????
-; unreferenced
+; unused
ld hl, wWinTextPointer
jr .ok
@@ -255,7 +255,7 @@ PrintWinLossText:: ; 3718
ld a, [hli]
ld h, [hl]
ld l, a
- call GetMapScriptHeaderBank
+ call GetMapScriptsBank
call FarPrintText
call WaitBGMap
call WaitPressAorB_BlinkCursor
diff --git a/home/vblank.asm b/home/vblank.asm
index cb8c5ba56..5afecdad0 100644
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -190,7 +190,7 @@ VBlank1:: ; 337
jr c, .done
call UpdateBGMap
- call Serve2bppRequest@VBlank
+ call Serve2bppRequest_VBlank
call hPushOAM
.done
@@ -280,7 +280,7 @@ VBlank3:: ; 396
jr c, .done
call UpdateBGMap
- call Serve2bppRequest@VBlank
+ call Serve2bppRequest_VBlank
call hPushOAM
.done
diff --git a/home/video.asm b/home/video.asm
index 8f14dfeee..2f06effa0 100644
--- a/home/video.asm
+++ b/home/video.asm
@@ -20,10 +20,10 @@ DMATransfer:: ; 15d8
UpdateBGMapBuffer:: ; 15e3
-; Copy [hFFDC] 16x8 tiles from BGMapBuffer
+; Copy [hBGMapTileCount] 16x8 tiles from BGMapBuffer
; to bg map addresses in BGMapBufferPtrs.
-; [hFFDC] must be even since this is done in pairs.
+; [hBGMapTileCount] must be even since this is done in pairs.
; Return carry on success.
@@ -76,10 +76,10 @@ rept 2
endr
; We've done 2 16x8 blocks
- ld a, [hFFDC]
+ ld a, [hBGMapTileCount]
dec a
dec a
- ld [hFFDC], a
+ ld [hBGMapTileCount], a
jr nz, .next
@@ -379,7 +379,7 @@ Serve2bppRequest:: ; 1769
jr _Serve2bppRequest
-Serve2bppRequest@VBlank:: ; 1778
+Serve2bppRequest_VBlank:: ; 1778
ld a, [Requested2bpp]
and a
@@ -466,7 +466,7 @@ AnimateTileset:: ; 17d3
ld a, [rSVBK]
push af
- ld a, 1
+ ld a, BANK(TilesetAnim)
ld [rSVBK], a
ld a, [rVBK]
diff --git a/home/window.asm b/home/window.asm
index 0570bbb01..67debe5d3 100644
--- a/home/window.asm
+++ b/home/window.asm
@@ -99,7 +99,7 @@ SafeUpdateSprites:: ; 2e31
ld [hOAMUpdate], a
ret
-; XXX
+; unused
scf
ret
; 2e50