ref: e171c84c2990df2c1a3773885297089869a0fd58
parent: f2efda1f68230ec917cd148759bb9798a75a8f60
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Mon Jun 29 15:35:47 EDT 2020
Identify more labels and constants
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -247,21 +247,21 @@
ldh [rNR10], a
.noPitchSweep
bit NOTE_REST, [hl] ; rest
- jr nz, .ch1rest
+ jr nz, .ch1_rest
bit NOTE_NOISE_SAMPLING, [hl]
- jr nz, .asm_e81a2
+ jr nz, .ch1_noise_sampling
bit NOTE_FREQ_OVERRIDE, [hl]
- jr nz, .frequency_override
+ jr nz, .ch1_frequency_override
bit NOTE_VIBRATO_OVERRIDE, [hl]
- jr nz, .asm_e8184
- jr .check_duty_override
+ jr nz, .ch1_vibrato_override
+ jr .ch1_check_duty_override
-.frequency_override
+.ch1_frequency_override
ld a, [wCurTrackFrequency]
ldh [rNR13], a
ld a, [wCurTrackFrequency + 1]
ldh [rNR14], a
-.check_duty_override
+.ch1_check_duty_override
bit NOTE_DUTY_OVERRIDE, [hl]
ret z
ld a, [wCurTrackDuty]
@@ -272,7 +272,7 @@
ldh [rNR11], a
ret
-.asm_e8184
+.ch1_vibrato_override
ld a, [wCurTrackDuty]
ld d, a
ldh a, [rNR11]
@@ -283,7 +283,7 @@
ldh [rNR13], a
ret
-.ch1rest
+.ch1_rest
ldh a, [rNR52]
and %10001110 ; ch1 off
ldh [rNR52], a
@@ -291,7 +291,7 @@
call ClearChannel
ret
-.asm_e81a2
+.ch1_noise_sampling
ld hl, wCurTrackDuty
ld a, $3f ; sound length
or [hl]
@@ -310,11 +310,11 @@
ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
bit NOTE_REST, [hl] ; rest
- jr nz, .ch2rest
+ jr nz, .ch2_rest
bit NOTE_NOISE_SAMPLING, [hl]
- jr nz, .asm_e8204
+ jr nz, .ch2_noise_sampling
bit NOTE_VIBRATO_OVERRIDE, [hl]
- jr nz, .asm_e81e6
+ jr nz, .ch2_vibrato_override
bit NOTE_DUTY_OVERRIDE, [hl]
ret z
ld a, [wCurTrackDuty]
@@ -325,7 +325,7 @@
ldh [rNR21], a
ret
-.asm_e81db ; unused
+.ch2_frequency_override ; unreferenced
ld a, [wCurTrackFrequency]
ldh [rNR23], a
ld a, [wCurTrackFrequency + 1]
@@ -332,7 +332,7 @@
ldh [rNR24], a
ret
-.asm_e81e6
+.ch2_vibrato_override
ld a, [wCurTrackDuty]
ld d, a
ldh a, [rNR21]
@@ -343,7 +343,7 @@
ldh [rNR23], a
ret
-.ch2rest
+.ch2_rest
ldh a, [rNR52]
and %10001101 ; ch2 off
ldh [rNR52], a
@@ -351,7 +351,7 @@
call ClearChannel
ret
-.asm_e8204
+.ch2_noise_sampling
ld hl, wCurTrackDuty
ld a, $3f ; sound length
or [hl]
@@ -369,15 +369,15 @@
.Channel7:
ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
- bit NOTE_REST, [hl] ; rest
- jr nz, .ch3rest
+ bit NOTE_REST, [hl]
+ jr nz, .ch3_rest
bit NOTE_NOISE_SAMPLING, [hl]
- jr nz, .asm_e824d
+ jr nz, .ch3_noise_sampling
bit NOTE_VIBRATO_OVERRIDE, [hl]
- jr nz, .asm_e823a
+ jr nz, .ch3_vibrato_override
ret
-.asm_e822f ; unused
+.ch3_frequency_override ; unreferenced
ld a, [wCurTrackFrequency]
ldh [rNR33], a
ld a, [wCurTrackFrequency + 1]
@@ -384,12 +384,12 @@
ldh [rNR34], a
ret
-.asm_e823a
+.ch3_vibrato_override
ld a, [wCurTrackFrequency]
ldh [rNR33], a
ret
-.ch3rest
+.ch3_rest
ldh a, [rNR52]
and %10001011 ; ch3 off
ldh [rNR52], a
@@ -397,12 +397,12 @@
call ClearChannel
ret
-.asm_e824d
+.ch3_noise_sampling
ld a, $3f ; sound length
ldh [rNR31], a
xor a
ldh [rNR30], a
- call .asm_e8268
+ call .load_wave_pattern
ld a, $80
ldh [rNR30], a
ld a, [wCurTrackFrequency]
@@ -412,7 +412,7 @@
ldh [rNR34], a
ret
-.asm_e8268
+.load_wave_pattern
push hl
ld a, [wCurTrackVolumeEnvelope]
and $f ; only 0-9 are valid
@@ -470,18 +470,18 @@
.Channel8:
ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
- bit NOTE_REST, [hl] ; rest
- jr nz, .ch4rest
+ bit NOTE_REST, [hl]
+ jr nz, .ch4_rest
bit NOTE_NOISE_SAMPLING, [hl]
- jr nz, .asm_e82d4
+ jr nz, .ch4_noise_sampling
ret
-.asm_e82c1 ; unused
+.ch4_frequency_override ; unreferenced
ld a, [wCurTrackFrequency]
ldh [rNR43], a
ret
-.ch4rest
+.ch4_rest
ldh a, [rNR52]
and %10000111 ; ch4 off
ldh [rNR52], a
@@ -489,7 +489,7 @@
call ClearChannel
ret
-.asm_e82d4
+.ch4_noise_sampling
ld a, $3f ; sound length
ldh [rNR41], a
ld a, [wCurTrackVolumeEnvelope]
--- a/engine/events/pokecenter_pc.asm
+++ b/engine/events/pokecenter_pc.asm
@@ -1,3 +1,17 @@
+ ; PokemonCenterPC.WhichPC indexes
+ const_def
+ const PCPC_BEFORE_POKEDEX ; 0
+ const PCPC_BEFORE_HOF ; 1
+ const PCPC_POSTGAME ; 2
+
+ ; PokemonCenterPC.JumpTable indexes
+ const_def
+ const PCPCITEM_PLAYERS_PC ; 0
+ const PCPCITEM_BILLS_PC ; 1
+ const PCPCITEM_OAKS_PC ; 2
+ const PCPCITEM_HALL_OF_FAME ; 3
+ const PCPCITEM_TURN_OFF ; 4
+
PokemonCenterPC:
call PC_CheckPartyForPokemon
ret c
@@ -39,14 +53,8 @@
dw PlaceNthMenuStrings
dw .JumpTable
-PCPC_PLAYERS_PC EQU 0
-PCPC_BILLS_PC EQU 1
-PCPC_OAKS_PC EQU 2
-PCPC_HALL_OF_FAME EQU 3
-PCPC_TURN_OFF EQU 4
-
.JumpTable:
-; entries correspond to PCPC_* constants
+; entries correspond to PCPCITEM_* constants
dw PlayersPC, .String_PlayersPC
dw BillsPC, .String_BillsPC
dw OaksPC, .String_OaksPC
@@ -60,42 +68,44 @@
.String_TurnOff: db "TURN OFF@"
.WhichPC:
- ; before Pokédex
+; entries correspond to PCPC_* constants
+
+ ; PCPC_BEFORE_POKEDEX
db 3
- db PCPC_BILLS_PC
- db PCPC_PLAYERS_PC
- db PCPC_TURN_OFF
+ db PCPCITEM_BILLS_PC
+ db PCPCITEM_PLAYERS_PC
+ db PCPCITEM_TURN_OFF
db -1 ; end
- ; before Hall Of Fame
+ ; PCPC_BEFORE_HOF
db 4
- db PCPC_BILLS_PC
- db PCPC_PLAYERS_PC
- db PCPC_OAKS_PC
- db PCPC_TURN_OFF
+ db PCPCITEM_BILLS_PC
+ db PCPCITEM_PLAYERS_PC
+ db PCPCITEM_OAKS_PC
+ db PCPCITEM_TURN_OFF
db -1 ; end
- ; postgame
+ ; PCPC_POSTGAME
db 5
- db PCPC_BILLS_PC
- db PCPC_PLAYERS_PC
- db PCPC_OAKS_PC
- db PCPC_HALL_OF_FAME
- db PCPC_TURN_OFF
+ db PCPCITEM_BILLS_PC
+ db PCPCITEM_PLAYERS_PC
+ db PCPCITEM_OAKS_PC
+ db PCPCITEM_HALL_OF_FAME
+ db PCPCITEM_TURN_OFF
db -1 ; end
.ChooseWhichPCListToUse:
call CheckReceivedDex
jr nz, .got_dex
- ld a, 0 ; before Pokédex
+ ld a, PCPC_BEFORE_POKEDEX
ret
.got_dex
ld a, [wHallOfFameCount]
and a
- ld a, 1 ; before Hall Of Fame
+ ld a, PCPC_BEFORE_HOF
ret z
- ld a, 2 ; postgame
+ ld a, PCPC_POSTGAME
ret
PC_CheckPartyForPokemon:
@@ -113,6 +123,22 @@
text_far _PokecenterPCCantUseText
text_end
+
+ ; PlayersPCMenuData.WhichPC indexes
+ const_def
+ const PLAYERSPC_NORMAL ; 0
+ const PLAYERSPC_HOUSE ; 1
+
+ ; PlayersPCMenuData.PlayersPCMenuPointers indexes
+ const_def
+ const PLAYERSPCITEM_WITHDRAW_ITEM ; 0
+ const PLAYERSPCITEM_DEPOSIT_ITEM ; 1
+ const PLAYERSPCITEM_TOSS_ITEM ; 2
+ const PLAYERSPCITEM_MAIL_BOX ; 3
+ const PLAYERSPCITEM_DECORATION ; 4
+ const PLAYERSPCITEM_TURN_OFF ; 5
+ const PLAYERSPCITEM_LOG_OFF ; 6
+
BillsPC:
call PC_PlayChoosePCSound
ld hl, PokecenterBillsPCText
@@ -125,7 +151,7 @@
call PC_PlayChoosePCSound
ld hl, PokecenterPlayersPCText
call PC_DisplayText
- ld b, $0
+ ld b, PLAYERSPC_NORMAL
call _PlayersPC
and a
ret
@@ -182,7 +208,7 @@
call PC_PlayBootSound
ld hl, PlayersPCTurnOnText
call PC_DisplayText
- ld b, $1
+ ld b, PLAYERSPC_HOUSE
call _PlayersPC
and a
jr nz, .asm_156f9
@@ -190,12 +216,12 @@
call ApplyTilemap
call UpdateSprites
call PC_PlayShutdownSound
- ld c, $0
+ ld c, FALSE
ret
.asm_156f9
call ClearBGPalettes
- ld c, $1
+ ld c, TRUE
ret
PlayersPCTurnOnText:
@@ -241,20 +267,12 @@
.PlayersPCMenuData:
db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
db 0 ; # items?
- dw .PlayersPCMenuList1
+ dw .WhichPC
dw PlaceNthMenuStrings
dw .PlayersPCMenuPointers
-PLAYERSPC_WITHDRAW_ITEM EQU 0
-PLAYERSPC_DEPOSIT_ITEM EQU 1
-PLAYERSPC_TOSS_ITEM EQU 2
-PLAYERSPC_MAIL_BOX EQU 3
-PLAYERSPC_DECORATION EQU 4
-PLAYERSPC_TURN_OFF EQU 5
-PLAYERSPC_LOG_OFF EQU 6
-
.PlayersPCMenuPointers:
-; entries correspond to PLAYERSPC_* constants
+; entries correspond to PLAYERSPCITEM_* constants
dw PlayerWithdrawItemMenu, .WithdrawItem
dw PlayerDepositItemMenu, .DepositItem
dw PlayerTossItemMenu, .TossItem
@@ -271,23 +289,26 @@
.TurnOff: db "TURN OFF@"
.LogOff: db "LOG OFF@"
-.PlayersPCMenuList1:
+.WhichPC:
+; entries correspond to PLAYERSPC_* constants
+
+ ; PLAYERSPC_NORMAL
db 5
- db PLAYERSPC_WITHDRAW_ITEM
- db PLAYERSPC_DEPOSIT_ITEM
- db PLAYERSPC_TOSS_ITEM
- db PLAYERSPC_MAIL_BOX
- db PLAYERSPC_TURN_OFF
+ db PLAYERSPCITEM_WITHDRAW_ITEM
+ db PLAYERSPCITEM_DEPOSIT_ITEM
+ db PLAYERSPCITEM_TOSS_ITEM
+ db PLAYERSPCITEM_MAIL_BOX
+ db PLAYERSPCITEM_TURN_OFF
db -1 ; end
-.PlayersPCMenuList2:
+ ; PLAYERSPC_HOUSE
db 6
- db PLAYERSPC_WITHDRAW_ITEM
- db PLAYERSPC_DEPOSIT_ITEM
- db PLAYERSPC_TOSS_ITEM
- db PLAYERSPC_MAIL_BOX
- db PLAYERSPC_DECORATION
- db PLAYERSPC_LOG_OFF
+ db PLAYERSPCITEM_WITHDRAW_ITEM
+ db PLAYERSPCITEM_DEPOSIT_ITEM
+ db PLAYERSPCITEM_TOSS_ITEM
+ db PLAYERSPCITEM_MAIL_BOX
+ db PLAYERSPCITEM_DECORATION
+ db PLAYERSPCITEM_LOG_OFF
db -1 ; end
PC_DisplayTextWaitMenu:
@@ -445,7 +466,7 @@
.TryDepositItem:
ld a, [wSpriteUpdatesEnabled]
push af
- ld a, $0
+ ld a, FALSE
ld [wSpriteUpdatesEnabled], a
farcall CheckItemMenu
ld a, [wItemAttributeParamBuffer]
@@ -485,7 +506,7 @@
ld a, [wItemAttributeParamBuffer]
and a
jr z, .AskQuantity
- ld a, $1
+ ld a, 1
ld [wItemQuantityChangeBuffer], a
jr .ContinueDeposit
@@ -550,7 +571,7 @@
.loop
ld a, [wSpriteUpdatesEnabled]
push af
- ld a, $0
+ ld a, FALSE
ld [wSpriteUpdatesEnabled], a
ld hl, .PCItemsMenuData
call CopyMenuHeader
--- a/home/decompress.asm
+++ b/home/decompress.asm
@@ -14,7 +14,7 @@
ret
Decompress::
-; Pokemon Crystal uses an lz variant for compression.
+; Pokemon GSC uses an lz variant (lz3) for compression.
; This is mainly (but not necessarily) used for graphics.
; This function decompresses lz-compressed data from hl to de.
--- a/home/farcall.asm
+++ b/home/farcall.asm
@@ -1,16 +1,15 @@
FarCall_de::
; Call a:de.
; Preserves other registers.
-
ldh [hTempBank], a
ldh a, [hROMBank]
push af
ldh a, [hTempBank]
rst Bankswitch
- call .de
+ call FarCall_JumpToDE
jr ReturnFarCall
-.de
+FarCall_JumpToDE:
push de
ret
@@ -17,7 +16,6 @@
FarCall_hl::
; Call a:hl.
; Preserves other registers.
-
ldh [hTempBank], a
ldh a, [hROMBank]
push af
@@ -29,7 +27,6 @@
ReturnFarCall::
; We want to retain the contents of f.
; To do this, we can pop to bc instead of af.
-
ld a, b
ld [wFarCallBCBuffer], a
ld a, c
@@ -40,6 +37,7 @@
ld a, b
rst Bankswitch
+; Restore the contents of bc.
ld a, [wFarCallBCBuffer]
ld b, a
ld a, [wFarCallBCBuffer + 1]
--- a/home/gfx.asm
+++ b/home/gfx.asm
@@ -334,6 +334,7 @@
jr .loop
Get2bpp::
+; copy c 2bpp tiles from b:de to hl
ldh a, [rLCDC]
bit rLCDC_ENABLE, a
jp nz, Request2bpp
@@ -340,8 +341,6 @@
; fallthrough
Copy2bpp:
-; copy c 2bpp tiles from b:de to hl
-
push hl
ld h, d
ld l, e
@@ -364,6 +363,7 @@
jp FarCopyBytes
Get1bpp::
+; copy c 1bpp tiles from b:de to hl
ldh a, [rLCDC]
bit rLCDC_ENABLE, a
jp nz, Request1bpp
@@ -370,8 +370,6 @@
; fallthrough
Copy1bpp::
-; copy c 1bpp tiles from b:de to hl
-
push de
ld d, h
ld e, l