aboutsummaryrefslogtreecommitdiffstats
path: root/home
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2026-01-17 22:38:33 -0600
committerdannye <33dannye@gmail.com>2026-01-17 22:38:33 -0600
commitbc2354dd6626ce28bb9561547ed2107cfa56c18e (patch)
tree5902d4c3389253c76b7c3351e0d7dfecb551c28d /home
parentIdentify characters in `_OakSpeechText2B` and `Printer_GetMonStats.IDNo` (#144) (diff)
parentUse macros for `WildMonEncounterSlotChances` (#562) (diff)
downloadpokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.tar.gz
pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.tar.xz
pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.zip
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to 'home')
-rw-r--r--home/clear_sprites.asm8
-rw-r--r--home/hidden_events.asm (renamed from home/hidden_objects.asm)14
-rw-r--r--home/joypad2.asm4
-rw-r--r--home/list_menu.asm16
-rw-r--r--home/load_font.asm12
-rw-r--r--home/map_objects.asm4
-rw-r--r--home/move_mon.asm4
-rw-r--r--home/overworld.asm65
-rw-r--r--home/pics.asm10
-rw-r--r--home/pokemon.asm6
-rw-r--r--home/print_bcd.asm4
-rw-r--r--home/print_num.asm17
-rw-r--r--home/print_text.asm2
-rw-r--r--home/reset_player_sprite.asm3
-rw-r--r--home/start_menu.asm2
-rw-r--r--home/text_script.asm4
-rw-r--r--home/trainers.asm28
-rw-r--r--home/vcopy.asm29
-rw-r--r--home/window.asm12
19 files changed, 124 insertions, 120 deletions
diff --git a/home/clear_sprites.asm b/home/clear_sprites.asm
index 6d1066fa..c18b1ff3 100644
--- a/home/clear_sprites.asm
+++ b/home/clear_sprites.asm
@@ -9,10 +9,10 @@ ClearSprites::
ret
HideSprites::
- ld a, 160
- ld hl, wShadowOAM
- ld de, 4
- ld b, 40
+ ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS
+ ld hl, wShadowOAMSprite00YCoord
+ ld de, OBJ_SIZE
+ ld b, OAM_COUNT
.loop
ld [hl], a
add hl, de
diff --git a/home/hidden_objects.asm b/home/hidden_events.asm
index c1e1c9d3..ae8ee439 100644
--- a/home/hidden_objects.asm
+++ b/home/hidden_events.asm
@@ -2,27 +2,27 @@ UpdateCinnabarGymGateTileBlocks::
farcall UpdateCinnabarGymGateTileBlocks_
ret
-CheckForHiddenObjectOrBookshelfOrCardKeyDoor::
+CheckForHiddenEventOrBookshelfOrCardKeyDoor::
ldh a, [hLoadedROMBank]
push af
ldh a, [hJoyHeld]
bit B_PAD_A, a
jr z, .nothingFound
; A button is pressed
- ld a, BANK(CheckForHiddenObject)
+ ld a, BANK(CheckForHiddenEvent)
call BankswitchCommon
- call CheckForHiddenObject
- ldh a, [hDidntFindAnyHiddenObject]
+ call CheckForHiddenEvent
+ ldh a, [hDidntFindAnyHiddenEvent]
and a
- jr nz, .hiddenObjectNotFound
+ jr nz, .hiddenEventNotFound
xor a
ldh [hItemAlreadyFound], a
- ld a, [wHiddenObjectFunctionRomBank]
+ ld a, [wHiddenEventFunctionRomBank]
call BankswitchCommon
call JumpToAddress
ldh a, [hItemAlreadyFound]
jr .done
-.hiddenObjectNotFound
+.hiddenEventNotFound
predef GetTileAndCoordsInFrontOfPlayer
farcall PrintBookshelfText
ldh a, [hInteractedWithBookshelf]
diff --git a/home/joypad2.asm b/home/joypad2.asm
index da824797..a2860b02 100644
--- a/home/joypad2.asm
+++ b/home/joypad2.asm
@@ -25,7 +25,7 @@ JoypadLowSensitivity::
ldh a, [hJoyPressed] ; newly pressed buttons
and a ; have any buttons been newly pressed since last check?
jr z, .noNewlyPressedButtons
-.newlyPressedButtons
+; newly pressed buttons
ld a, 30 ; half a second delay
ldh [hFrameCounter], a
ret
@@ -33,7 +33,7 @@ JoypadLowSensitivity::
ldh a, [hFrameCounter]
and a ; is the delay over?
jr z, .delayOver
-.delayNotOver
+; delay not over
xor a
ldh [hJoy5], a ; report no buttons as pressed
ret
diff --git a/home/list_menu.asm b/home/list_menu.asm
index cae0a1d5..4faa738f 100644
--- a/home/list_menu.asm
+++ b/home/list_menu.asm
@@ -65,7 +65,7 @@ DisplayListMenuIDLoop::
ld a, [wBattleType]
and a ; is it the Old Man battle?
jr z, .notOldManBattle
-.oldManBattle
+; Old Man battle
ld a, '▶'
ldcoord_a 5, 4 ; place menu cursor in front of first menu entry
ld c, 20
@@ -178,7 +178,7 @@ DisplayListMenuIDLoop::
bit B_PAD_DOWN, b
ld hl, wListScrollOffset
jr z, .upPressed
-.downPressed
+; Down pressed
ld a, [hl]
add 3
ld b, a
@@ -377,7 +377,7 @@ PrintListMenuEntries::
jr z, .pokemonPCMenu
cp MOVESLISTMENU
jr z, .movesMenu
-.itemMenu
+; item menu
call GetItemName
jr .placeNameString
.pokemonPCMenu
@@ -408,7 +408,7 @@ PrintListMenuEntries::
ld a, [wPrintItemPrices]
and a ; should prices be printed?
jr z, .skipPrintingItemPrice
-.printItemPrice
+; print item price
push hl
ld a, [de]
ld de, ItemPrices
@@ -423,7 +423,7 @@ PrintListMenuEntries::
ld a, [wListMenuID]
and a ; PCPOKEMONLISTMENU?
jr nz, .skipPrintingPokemonLevel
-.printPokemonLevel
+; print Pokemon level
ld a, [wNamedObjectIndex]
push af
push hl
@@ -448,12 +448,12 @@ PrintListMenuEntries::
ld a, [wMonDataLocation]
and a ; is it a list of party pokemon or box pokemon?
jr z, .skipCopyingLevel
-.copyLevel
+; copy level
ld a, [wLoadedMonBoxLevel]
ld [wLoadedMonLevel], a
.skipCopyingLevel
pop hl
- ld bc, $1c
+ ld bc, SCREEN_WIDTH + 8 ; 1 row down and 8 columns right
add hl, bc
call PrintLevel
pop af
@@ -465,7 +465,7 @@ PrintListMenuEntries::
ld a, [wListMenuID]
cp ITEMLISTMENU
jr nz, .nextListEntry
-.printItemQuantity
+; print item quantity
ld a, [wNamedObjectIndex]
ld [wCurItem], a
call IsKeyItem ; check if item is unsellable
diff --git a/home/load_font.asm b/home/load_font.asm
index c9a009f7..bb1b1492 100644
--- a/home/load_font.asm
+++ b/home/load_font.asm
@@ -2,7 +2,7 @@ LoadFontTilePatterns::
ldh a, [rLCDC]
bit B_LCDC_ENABLE, a
jr nz, .on
-.off
+; off
ld hl, FontGraphics
ld de, vFont
ld bc, FontGraphicsEnd - FontGraphics
@@ -11,14 +11,14 @@ LoadFontTilePatterns::
.on
ld de, FontGraphics
ld hl, vFont
- lb bc, BANK(FontGraphics), (FontGraphicsEnd - FontGraphics) / $8
+ lb bc, BANK(FontGraphics), (FontGraphicsEnd - FontGraphics) / TILE_1BPP_SIZE
jp CopyVideoDataDouble ; if LCD is on, transfer during V-blank
LoadTextBoxTilePatterns::
ldh a, [rLCDC]
bit B_LCDC_ENABLE, a
jr nz, .on
-.off
+; off
ld hl, TextBoxGraphics
ld de, vChars2 tile $60
ld bc, TextBoxGraphicsEnd - TextBoxGraphics
@@ -27,14 +27,14 @@ LoadTextBoxTilePatterns::
.on
ld de, TextBoxGraphics
ld hl, vChars2 tile $60
- lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / $10
+ lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / TILE_SIZE
jp CopyVideoData ; if LCD is on, transfer during V-blank
LoadHpBarAndStatusTilePatterns::
ldh a, [rLCDC]
bit B_LCDC_ENABLE, a
jr nz, .on
-.off
+; off
ld hl, HpBarAndStatusGraphics
ld de, vChars2 tile $62
ld bc, HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics
@@ -43,5 +43,5 @@ LoadHpBarAndStatusTilePatterns::
.on
ld de, HpBarAndStatusGraphics
ld hl, vChars2 tile $62
- lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / $10
+ lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / TILE_SIZE
jp CopyVideoData ; if LCD is on, transfer during V-blank
diff --git a/home/map_objects.asm b/home/map_objects.asm
index 2e553371..3b1a1f08 100644
--- a/home/map_objects.asm
+++ b/home/map_objects.asm
@@ -190,7 +190,7 @@ CheckCoords::
ld hl, wCoordIndex
inc [hl]
pop hl
-.compareYCoord
+; compare Y coord
cp b
jr z, .compareXCoord
inc hl
@@ -199,7 +199,7 @@ CheckCoords::
ld a, [hli]
cp c
jr nz, .loop
-.inArray
+; in array
scf
ret
.notInArray
diff --git a/home/move_mon.asm b/home/move_mon.asm
index 45b10322..def60bc1 100644
--- a/home/move_mon.asm
+++ b/home/move_mon.asm
@@ -94,7 +94,7 @@ CalcStat::
srl c
pop hl
push bc
- ld bc, wPartyMon1DVs - (wPartyMon1HPExp - 1) ; also wEnemyMonDVs - wEnemyMonHP
+ ld bc, MON_DVS - (MON_HP_EXP - 1)
add hl, bc
pop bc
ld a, c
@@ -106,7 +106,7 @@ CalcStat::
jr z, .getSpeedIV
cp $5
jr z, .getSpecialIV
-.getHpIV
+; get HP IV
push bc
ld a, [hl] ; Atk IV
swap a
diff --git a/home/overworld.asm b/home/overworld.asm
index b5625e9d..6fafe717 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -88,10 +88,10 @@ OverworldLoopLessDelay::
jp nz, .noDirectionButtonsPressed
call IsPlayerCharacterBeingControlledByGame
jr nz, .checkForOpponent
- call CheckForHiddenObjectOrBookshelfOrCardKeyDoor
+ call CheckForHiddenEventOrBookshelfOrCardKeyDoor
ldh a, [hItemAlreadyFound]
and a
- jp z, OverworldLoop ; jump if a hidden object or bookshelf was found, but not if a card key door was found
+ jp z, OverworldLoop ; jump if a hidden event or bookshelf was found, but not if a card key door was found
xor a
ld [wd435], a ; new yellow address
call IsSpriteOrSignInFrontOfPlayer
@@ -114,7 +114,7 @@ OverworldLoopLessDelay::
and a
jr z, .checkForOpponent
xor a
- ld [wLinkTimeoutCounter], a
+ ld [wEnteringCableClub], a
jp EnterMap
.checkForOpponent
ld a, [wCurOpponent]
@@ -480,7 +480,7 @@ WarpFound2::
; for maps that can have the 0xFF destination map, which means to return to the outside map
; not all these maps are necessarily indoors, though
.indoorMaps
- ldh a, [hWarpDestinationMap] ; destination map
+ ldh a, [hWarpDestinationMap]
cp LAST_MAP
jr z, .goBackOutside
; if not going back to the previous map
@@ -518,7 +518,7 @@ WarpFound2::
; if no matching warp was found
CheckMapConnections::
-.checkWestMap
+; check west map
ld a, [wXCoord]
cp $ff
jr nz, .checkEastMap
@@ -539,7 +539,7 @@ CheckMapConnections::
srl c
jr z, .savePointer1
.pointerAdjustmentLoop1
- ld a, [wWestConnectedMapWidth] ; width of connected map
+ ld a, [wWestConnectedMapWidth]
add MAP_BORDER * 2
ld e, a
ld d, 0
@@ -556,7 +556,7 @@ CheckMapConnections::
.checkEastMap
ld b, a
- ld a, [wCurrentMapWidth2] ; map width
+ ld a, [wCurrentMapWidth2]
cp b
jr nz, .checkNorthMap
ld a, [wEastConnectedMap]
@@ -1125,7 +1125,7 @@ IsSpriteInFrontOfPlayer2::
.doneCheckingDirection
ld [wPlayerDirection], a
ld hl, wSprite01StateData1
-; yellow does not have the "if sprites are existant" check
+; yellow does not have the "if sprites are existent" check
ld e, $01
ld d, $f
.spriteLoop
@@ -1148,7 +1148,7 @@ IsSpriteInFrontOfPlayer2::
.nextSprite
pop hl
ld a, l
- add $10
+ add SPRITESTATEDATA1_LENGTH
ld l, a
inc e
dec d
@@ -1176,10 +1176,10 @@ IsSpriteInFrontOfPlayer2::
SignLoop::
; search if a player is facing a sign
- ld hl, wSignCoords ; start of sign coordinates
- ld a, [wNumSigns] ; number of signs in the map
+ ld hl, wSignCoords
+ ld a, [wNumSigns]
ld b, a
- ld c, $00
+ ld c, 0
.signLoop
inc c
ld a, [hli] ; sign Y
@@ -1187,17 +1187,15 @@ SignLoop::
jr z, .yCoordMatched
inc hl
jr .retry
-
.yCoordMatched
ld a, [hli] ; sign X
cp e
jr nz, .retry
-.xCoordMatched
-; found sign
+; X coord matched: found sign
push hl
push bc
- ld hl, wSignTextIDs ; start of sign text ID's
- ld b, $00
+ ld hl, wSignTextIDs
+ ld b, 0
dec c
add hl, bc
ld a, [hl]
@@ -1206,7 +1204,6 @@ SignLoop::
pop hl
scf
ret
-
.retry
dec b
jr nz, .signLoop
@@ -1272,8 +1269,8 @@ CollisionCheckOnLand::
; function that checks if the tile in front of the player is passable
; clears carry if it is, sets carry if not
CheckTilePassable::
- predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player
- ld a, [wTileInFrontOfPlayer] ; tile in front of player
+ predef GetTileAndCoordsInFrontOfPlayer
+ ld a, [wTileInFrontOfPlayer]
ld c, a
call IsTilePassable
ret
@@ -1284,7 +1281,7 @@ CheckTilePassable::
; sets carry if there is a collision and unsets carry if not
CheckForJumpingAndTilePairCollisions::
push hl
- predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player
+ predef GetTileAndCoordsInFrontOfPlayer
push de
push bc
farcall HandleLedges ; check if the player is trying to jump a ledge
@@ -1317,7 +1314,7 @@ CheckForTilePairCollisions::
inc hl
jr .tilePairCollisionLoop
.tilesetMatches
- ld a, [wTilePlayerStandingOn] ; tile the player is on
+ ld a, [wTilePlayerStandingOn]
ld b, a
ld a, [hl]
cp b
@@ -1352,8 +1349,8 @@ INCLUDE "data/tilesets/pair_collision_tile_ids.asm"
LoadCurrentMapView::
ldh a, [hLoadedROMBank]
push af
- ld a, [wTilesetBank] ; tile data ROM bank
- call BankswitchCommon ; switch to ROM bank that contains tile data
+ ld a, [wTilesetBank]
+ call BankswitchCommon
ld a, [wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view
ld e, a
ld a, [wCurrentTileBlockMapViewPointer + 1]
@@ -1434,7 +1431,7 @@ LoadCurrentMapView::
dec b
jr nz, .rowLoop2
pop af
- call BankswitchCommon ; restore previous ROM bank
+ call BankswitchCommon
ret
AdvancePlayerSprite::
@@ -1794,11 +1791,11 @@ LoadPlayerSpriteGraphicsCommon::
; function to load data from the map header
LoadMapHeader::
- farcall MarkTownVisitedAndLoadMissableObjects
+ farcall MarkTownVisitedAndLoadToggleableObjects
jr asm_0dbd
-Func_0db5:: ; XXX
- farcall LoadMissableObjectData
+Func_0db5:: ; unreferenced
+ farcall LoadToggleableObjectData
asm_0dbd:
ld a, [wCurMapTileset]
ld [wUnusedCurMapTilesetCopy], a
@@ -1829,7 +1826,7 @@ asm_0dbd:
; copy connection data (if any) to WRAM
ld a, [wCurMapConnections]
ld b, a
-.checkNorth
+; check north
bit NORTH_F, b
jr z, .checkSouth
ld de, wNorthConnectionHeader
@@ -1862,7 +1859,7 @@ asm_0dbd:
ld de, wMapBackgroundTile
ld a, [hli]
ld [de], a
-.loadWarpData
+; load warp data
ld a, [hli]
ld [wNumberOfWarps], a
and a
@@ -1978,8 +1975,8 @@ LoadMapData::
ld a, [wStatusFlags7]
bit BIT_NO_MAP_MUSIC, a
jr nz, .restoreRomBank
- call UpdateMusic6Times ; music related
- call PlayDefaultMusicFadeOutCurrent ; music related
+ call UpdateMusic6Times
+ call PlayDefaultMusicFadeOutCurrent
.restoreRomBank
pop af
call BankswitchCommon
@@ -2021,7 +2018,7 @@ FinishReloadingMap:
ret ; useless
ResetMapVariables::
- ld a, $98
+ ld a, HIGH(vBGMap0)
ld [wMapViewVRAMPointer + 1], a
xor a
ld [wMapViewVRAMPointer], a
@@ -2150,7 +2147,7 @@ InitSprites::
pop de
pop hl
ld a, [wNumSprites]
- and a ; are sprites existant?
+ and a ; are there any sprites?
ret z ; don't copy sprite data if not
ld b, a
ld c, $0
diff --git a/home/pics.asm b/home/pics.asm
index 18d86f2e..b4e923c8 100644
--- a/home/pics.asm
+++ b/home/pics.asm
@@ -123,8 +123,8 @@ AlignSpriteDataCentered::
dec c
jr nz, .columnInnerLoop
pop hl
- ld bc, 7 * 8 ; 7 tiles
- add hl, bc ; advance one full column
+ ld bc, 7 * TILE_1BPP_SIZE
+ add hl, bc ; advance one full column
pop af
dec a
jr nz, .columnLoop
@@ -152,7 +152,7 @@ InterlaceMergeSpriteBuffers::
ld hl, sSpriteBuffer2 + (SPRITEBUFFERSIZE - 1) ; destination: end of buffer 2
ld de, sSpriteBuffer1 + (SPRITEBUFFERSIZE - 1) ; source 2: end of buffer 1
ld bc, sSpriteBuffer0 + (SPRITEBUFFERSIZE - 1) ; source 1: end of buffer 0
- ld a, SPRITEBUFFERSIZE / 2 ; $c4
+ ld a, SPRITEBUFFERSIZE / 2
ldh [hSpriteInterlaceCounter], a
.interlaceLoop
ld a, [de]
@@ -184,9 +184,9 @@ InterlaceMergeSpriteBuffers::
or c
jr nz, .swapLoop
.notFlipped
- pop hl
+ pop hl ; hl = output address
ld de, sSpriteBuffer1
- ld c, (2 * SPRITEBUFFERSIZE) / 16 ; $31, number of 16 byte chunks to be copied
+ ld c, PIC_SIZE ; tiles
ldh a, [hLoadedROMBank]
ld b, a
call CopyVideoData
diff --git a/home/pokemon.asm b/home/pokemon.asm
index 2246e383..4c248064 100644
--- a/home/pokemon.asm
+++ b/home/pokemon.asm
@@ -349,11 +349,7 @@ PrintStatusCondition::
pop de
jr nz, PrintStatusConditionNotFainted
; if the pokemon's HP is 0, print "FNT"
- ld a, 'F'
- ld [hli], a
- ld a, 'N'
- ld [hli], a
- ld [hl], 'T'
+ ld_hli_a_string "FNT"
and a
ret
diff --git a/home/print_bcd.asm b/home/print_bcd.asm
index 2e501be5..cac6aba3 100644
--- a/home/print_bcd.asm
+++ b/home/print_bcd.asm
@@ -31,9 +31,9 @@ PrintBCDNumber::
inc de
dec c
jr nz, .loop
- bit BIT_LEADING_ZEROES, b
+ bit BIT_LEADING_ZEROES, b ; were any non-zero digits printed?
jr z, .done ; if so, we are done
-.numberEqualsZero ; if every digit of the BCD number is zero
+; if every digit of the BCD number is zero, print the last 0
bit BIT_LEFT_ALIGN, b
jr nz, .skipRightAlignmentAdjustment
dec hl ; if the string is right-aligned, it needs to be moved back one space
diff --git a/home/print_num.asm b/home/print_num.asm
index e0af0a4e..0280da8d 100644
--- a/home/print_num.asm
+++ b/home/print_num.asm
@@ -93,11 +93,16 @@ MACRO print_digit
call .NextDigit
ENDM
-.millions print_digit 1000000
-.hundred_thousands print_digit 100000
-.ten_thousands print_digit 10000
-.thousands print_digit 1000
-.hundreds print_digit 100
+; millions
+ print_digit 1000000
+.hundred_thousands
+ print_digit 100000
+.ten_thousands
+ print_digit 10000
+.thousands
+ print_digit 1000
+.hundreds
+ print_digit 100
.tens
ld c, 0
@@ -124,7 +129,7 @@ ENDM
.next
call .NextDigit
-.ones
+; ones
ld a, '0'
add b
ld [hli], a
diff --git a/home/print_text.asm b/home/print_text.asm
index fe784350..8e351ba3 100644
--- a/home/print_text.asm
+++ b/home/print_text.asm
@@ -24,7 +24,7 @@ PrintLetterDelay::
.checkButtons
call Joypad
ldh a, [hJoyHeld]
-.checkAButton
+; check A button
bit B_PAD_A, a
jr z, .checkBButton
jr .endWait
diff --git a/home/reset_player_sprite.asm b/home/reset_player_sprite.asm
index 2765d613..6e341363 100644
--- a/home/reset_player_sprite.asm
+++ b/home/reset_player_sprite.asm
@@ -15,7 +15,8 @@ ResetPlayerSpriteData::
; overwrites sprite data with zeroes
ResetPlayerSpriteData_ClearSpriteData::
- ld bc, $10
+ ld bc, SPRITESTATEDATA1_LENGTH
+ ASSERT SPRITESTATEDATA2_LENGTH == SPRITESTATEDATA1_LENGTH
xor a
call FillMemory
ret
diff --git a/home/start_menu.asm b/home/start_menu.asm
index b1bc0539..f2aae5dd 100644
--- a/home/start_menu.asm
+++ b/home/start_menu.asm
@@ -14,7 +14,7 @@ RedisplayStartMenu_DoNotDrawStartMenu::
.loop
call HandleMenuInput
ld b, a
-.checkIfUpPressed
+; check if Up pressed
bit B_PAD_UP, a
jr z, .checkIfDownPressed
ld a, [wCurrentMenuItem] ; menu selection
diff --git a/home/text_script.asm b/home/text_script.asm
index 44ba4567..96a6b11d 100644
--- a/home/text_script.asm
+++ b/home/text_script.asm
@@ -112,8 +112,8 @@ CloseTextDisplay::
ldh [hAutoBGTransferEnabled], a ; disable continuous WRAM to VRAM transfer each V-blank
; loop to make sprites face the directions they originally faced before the dialogue
ld hl, wSprite01StateData2OrigFacingDirection
- ld c, $0f
- ld de, $10
+ ld c, NUM_SPRITESTATEDATA_STRUCTS - 1
+ ld de, SPRITESTATEDATA1_LENGTH
.restoreSpriteFacingDirectionLoop
ld a, [hl] ; x#SPRITESTATEDATA2_ORIGFACINGDIRECTION
dec h
diff --git a/home/trainers.asm b/home/trainers.asm
index fa9167fc..6e007a95 100644
--- a/home/trainers.asm
+++ b/home/trainers.asm
@@ -19,7 +19,7 @@ ExecuteCurMapScriptInTable::
ld hl, wStatusFlags7
bit BIT_USE_CUR_MAP_SCRIPT, [hl]
res BIT_USE_CUR_MAP_SCRIPT, [hl]
- jr z, .useProvidedIndex ; test if map script index was overridden manually
+ jr z, .useProvidedIndex ; test if map script index was overridden manually
ld a, [wCurMapScript]
.useProvidedIndex
pop hl
@@ -31,12 +31,12 @@ ExecuteCurMapScriptInTable::
LoadGymLeaderAndCityName::
push de
ld de, wGymCityName
- ld bc, $11
- call CopyData ; load city name
+ ld bc, GYM_CITY_LENGTH
+ call CopyData ; load city name
pop hl
ld de, wGymLeaderName
ld bc, NAME_LENGTH
- jp CopyData ; load gym leader name
+ jp CopyData ; load gym leader name
; reads specific information from trainer header (pointed to at wTrainerHeaderPtr)
; a: offset in header data
@@ -155,7 +155,7 @@ ENDC
ldh [hJoyHeld], a
call TrainerWalkUpToPlayer_Bank0
ld hl, wCurMapScript
- inc [hl] ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle)
+ inc [hl] ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle)
ret
; display the before battle text after the enemy trainer has walked up to the player's sprite
@@ -179,7 +179,7 @@ StartTrainerBattle::
ld hl, wStatusFlags4
set BIT_UNKNOWN_4_1, [hl]
ld hl, wCurMapScript
- inc [hl] ; increment map script index (next script function is usually EndTrainerBattle)
+ inc [hl] ; increment map script index (next script function is usually EndTrainerBattle)
ret
EndTrainerBattle::
@@ -201,14 +201,14 @@ EndTrainerBattle::
call TrainerFlagAction ; flag trainer as fought
ld a, [wEnemyMonOrTrainerClass]
cp OPP_ID_OFFSET
- jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite)
- ld hl, wMissableObjectList
+ jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite)
+ ld hl, wToggleableObjectList
ld de, $2
ld a, [wSpriteIndex]
- call IsInArray ; search for sprite ID
+ call IsInArray ; search for sprite ID
inc hl
ld a, [hl]
- ld [wMissableObjectIndex], a ; load corresponding missable object index and remove it
+ ld [wToggleableObjectIndex], a ; load corresponding toggleable object index and remove it
predef HideObject
.skipRemoveSprite
ld hl, wStatusFlags5
@@ -269,7 +269,7 @@ CheckForEngagingTrainers::
.trainerLoop
call StoreTrainerHeaderPointer ; set trainer header pointer to current trainer
ld a, [de]
- ld [wSpriteIndex], a ; store trainer flag's bit
+ ld [wSpriteIndex], a ; store trainer flag's bit
ld [wTrainerHeaderFlagBit], a
cp -1
ret z
@@ -278,7 +278,7 @@ CheckForEngagingTrainers::
ld b, FLAG_TEST
ld a, [wTrainerHeaderFlagBit]
ld c, a
- call TrainerFlagAction ; read trainer flag
+ call TrainerFlagAction ; read trainer flag
ld a, c
and a ; has the trainer already been defeated?
jr nz, .continue
@@ -299,7 +299,7 @@ CheckForEngagingTrainers::
pop hl
ld a, [wTrainerSpriteOffset]
and a
- ret nz ; break if the trainer is engaging
+ ret nz ; break if the trainer is engaging
.continue
ld hl, $c
add hl, de
@@ -364,8 +364,8 @@ PrintEndBattleText::
GetSavedEndBattleTextPointer::
ld a, [wBattleResult]
and a
-; won battle
jr nz, .lostBattle
+; won battle
ld a, [wEndBattleWinTextPointer]
ld h, a
ld a, [wEndBattleWinTextPointer + 1]
diff --git a/home/vcopy.asm b/home/vcopy.asm
index 1a67cdb5..c9fcfb34 100644
--- a/home/vcopy.asm
+++ b/home/vcopy.asm
@@ -20,9 +20,14 @@ GetRowColAddressBgMap::
; INPUT: h - high byte of background tile map address in VRAM
ClearBgMap::
ld a, ' '
- jr .next
+ jr FillBgMapCommon
+
+; fills a VRAM background map with tile index in register l
+; INPUT: h - high byte of background tile map address in VRAM
+FillBgMap:: ; unreferenced
ld a, l
-.next
+
+FillBgMapCommon:
ld de, TILEMAP_AREA
ld l, e
.loop
@@ -69,8 +74,8 @@ RedrawRowOrColumn::
.noCarry
; the following 4 lines wrap us from bottom to top if necessary
ld a, d
- and $3
- or $98
+ and HIGH(TILEMAP_AREA - 1)
+ or HIGH(vBGMap0)
ld d, a
dec c
jr nz, .loop1
@@ -86,7 +91,7 @@ RedrawRowOrColumn::
push de
call .DrawHalf ; draw upper half
pop de
- ld a, TILEMAP_WIDTH ; width of VRAM background map
+ ld a, TILEMAP_WIDTH
add e
ld e, a
; fall through and draw lower half
@@ -102,10 +107,10 @@ RedrawRowOrColumn::
ld a, e
inc a
; the following 6 lines wrap us from the right edge to the left edge if necessary
- and $1f
+ and %11111
ld b, a
ld a, e
- and $e0
+ and %11100000
or b
ld e, a
dec c
@@ -130,7 +135,7 @@ AutoBgMapTransfer::
dec a
jr z, .transferMiddleThird
.transferBottomThird
- hlcoord 0, 12
+ hlcoord 0, 2 * SCREEN_HEIGHT / 3
ld sp, hl
ldh a, [hAutoBGTransferDest + 1]
ld h, a
@@ -150,7 +155,7 @@ AutoBgMapTransfer::
ld a, TRANSFERMIDDLE
jr .doTransfer
.transferMiddleThird
- hlcoord 0, 6
+ hlcoord 0, SCREEN_HEIGHT / 3
ld sp, hl
ldh a, [hAutoBGTransferDest + 1]
ld h, a
@@ -161,7 +166,7 @@ AutoBgMapTransfer::
ld a, TRANSFERBOTTOM
.doTransfer
ldh [hAutoBGTransferPortion], a ; store next portion
- ld b, 6
+ ld b, SCREEN_HEIGHT / 3
TransferBgRows::
; unrolled loop and using pop for speed
@@ -364,7 +369,7 @@ UpdateMovingBgTiles::
; water
ld hl, vTileset tile $14
- ld c, $10
+ ld c, TILE_SIZE
ld a, [wMovingBGTilesCounter2]
inc a
@@ -409,7 +414,7 @@ UpdateMovingBgTiles::
ld hl, FlowerTile3
.copy
ld de, vTileset tile $03
- ld c, $10
+ ld c, TILE_SIZE
.loop
ld a, [hli]
ld [de], a
diff --git a/home/window.asm b/home/window.asm
index c34b4f69..fcc048ec 100644
--- a/home/window.asm
+++ b/home/window.asm
@@ -54,11 +54,11 @@ HandleMenuInput_::
jr nz, .checkOtherKeys
bit B_PAD_UP, a
jr z, .checkIfDownPressed
-.upPressed
+; Up pressed
ld a, [wCurrentMenuItem] ; selected menu item
and a ; already at the top of the menu?
jr z, .alreadyAtTop
-.notAtTop
+; not at top
dec a
ld [wCurrentMenuItem], a ; move selected menu item up one space
jr .checkOtherKeys
@@ -72,14 +72,14 @@ HandleMenuInput_::
.checkIfDownPressed
bit B_PAD_DOWN, a
jr z, .checkOtherKeys
-.downPressed
+; Down pressed
ld a, [wCurrentMenuItem]
inc a
ld c, a
ld a, [wMaxMenuItem]
cp c
jr nc, .notAtBottom
-.alreadyAtBottom
+; already at bottom
ld a, [wMenuWrappingEnabled]
and a ; is wrapping around enabled?
jr z, .noWrappingAround
@@ -95,7 +95,7 @@ HandleMenuInput_::
ldh a, [hJoy5]
and PAD_A | PAD_B
jr z, .skipPlayingSound
-.AButtonOrBButtonPressed
+; A or B pressed
push hl
ld hl, wMiscFlags
bit BIT_NO_MENU_BUTTON_SOUND, [hl]
@@ -153,7 +153,7 @@ PlaceMenuCursor::
ld a, [hl]
cp '▶' ; was an arrow next to the previously selected menu item?
jr nz, .skipClearingArrow
-.clearArrow
+; clear arrow
ld a, [wTileBehindCursor]
ld [hl], a
.skipClearingArrow