Identify more labels and constants

This commit is contained in:
Rangi 2020-06-29 19:35:47 -04:00
parent f2efda1f68
commit e171c84c29
5 changed files with 115 additions and 98 deletions

View File

@ -247,21 +247,21 @@ UpdateChannels:
ldh [rNR10], a ldh [rNR10], a
.noPitchSweep .noPitchSweep
bit NOTE_REST, [hl] ; rest bit NOTE_REST, [hl] ; rest
jr nz, .ch1rest jr nz, .ch1_rest
bit NOTE_NOISE_SAMPLING, [hl] bit NOTE_NOISE_SAMPLING, [hl]
jr nz, .asm_e81a2 jr nz, .ch1_noise_sampling
bit NOTE_FREQ_OVERRIDE, [hl] bit NOTE_FREQ_OVERRIDE, [hl]
jr nz, .frequency_override jr nz, .ch1_frequency_override
bit NOTE_VIBRATO_OVERRIDE, [hl] bit NOTE_VIBRATO_OVERRIDE, [hl]
jr nz, .asm_e8184 jr nz, .ch1_vibrato_override
jr .check_duty_override jr .ch1_check_duty_override
.frequency_override .ch1_frequency_override
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ldh [rNR13], a ldh [rNR13], a
ld a, [wCurTrackFrequency + 1] ld a, [wCurTrackFrequency + 1]
ldh [rNR14], a ldh [rNR14], a
.check_duty_override .ch1_check_duty_override
bit NOTE_DUTY_OVERRIDE, [hl] bit NOTE_DUTY_OVERRIDE, [hl]
ret z ret z
ld a, [wCurTrackDuty] ld a, [wCurTrackDuty]
@ -272,7 +272,7 @@ UpdateChannels:
ldh [rNR11], a ldh [rNR11], a
ret ret
.asm_e8184 .ch1_vibrato_override
ld a, [wCurTrackDuty] ld a, [wCurTrackDuty]
ld d, a ld d, a
ldh a, [rNR11] ldh a, [rNR11]
@ -283,7 +283,7 @@ UpdateChannels:
ldh [rNR13], a ldh [rNR13], a
ret ret
.ch1rest .ch1_rest
ldh a, [rNR52] ldh a, [rNR52]
and %10001110 ; ch1 off and %10001110 ; ch1 off
ldh [rNR52], a ldh [rNR52], a
@ -291,7 +291,7 @@ UpdateChannels:
call ClearChannel call ClearChannel
ret ret
.asm_e81a2 .ch1_noise_sampling
ld hl, wCurTrackDuty ld hl, wCurTrackDuty
ld a, $3f ; sound length ld a, $3f ; sound length
or [hl] or [hl]
@ -310,11 +310,11 @@ UpdateChannels:
ld hl, CHANNEL_NOTE_FLAGS ld hl, CHANNEL_NOTE_FLAGS
add hl, bc add hl, bc
bit NOTE_REST, [hl] ; rest bit NOTE_REST, [hl] ; rest
jr nz, .ch2rest jr nz, .ch2_rest
bit NOTE_NOISE_SAMPLING, [hl] bit NOTE_NOISE_SAMPLING, [hl]
jr nz, .asm_e8204 jr nz, .ch2_noise_sampling
bit NOTE_VIBRATO_OVERRIDE, [hl] bit NOTE_VIBRATO_OVERRIDE, [hl]
jr nz, .asm_e81e6 jr nz, .ch2_vibrato_override
bit NOTE_DUTY_OVERRIDE, [hl] bit NOTE_DUTY_OVERRIDE, [hl]
ret z ret z
ld a, [wCurTrackDuty] ld a, [wCurTrackDuty]
@ -325,14 +325,14 @@ UpdateChannels:
ldh [rNR21], a ldh [rNR21], a
ret ret
.asm_e81db ; unused .ch2_frequency_override ; unreferenced
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ldh [rNR23], a ldh [rNR23], a
ld a, [wCurTrackFrequency + 1] ld a, [wCurTrackFrequency + 1]
ldh [rNR24], a ldh [rNR24], a
ret ret
.asm_e81e6 .ch2_vibrato_override
ld a, [wCurTrackDuty] ld a, [wCurTrackDuty]
ld d, a ld d, a
ldh a, [rNR21] ldh a, [rNR21]
@ -343,7 +343,7 @@ UpdateChannels:
ldh [rNR23], a ldh [rNR23], a
ret ret
.ch2rest .ch2_rest
ldh a, [rNR52] ldh a, [rNR52]
and %10001101 ; ch2 off and %10001101 ; ch2 off
ldh [rNR52], a ldh [rNR52], a
@ -351,7 +351,7 @@ UpdateChannels:
call ClearChannel call ClearChannel
ret ret
.asm_e8204 .ch2_noise_sampling
ld hl, wCurTrackDuty ld hl, wCurTrackDuty
ld a, $3f ; sound length ld a, $3f ; sound length
or [hl] or [hl]
@ -369,27 +369,27 @@ UpdateChannels:
.Channel7: .Channel7:
ld hl, CHANNEL_NOTE_FLAGS ld hl, CHANNEL_NOTE_FLAGS
add hl, bc add hl, bc
bit NOTE_REST, [hl] ; rest bit NOTE_REST, [hl]
jr nz, .ch3rest jr nz, .ch3_rest
bit NOTE_NOISE_SAMPLING, [hl] bit NOTE_NOISE_SAMPLING, [hl]
jr nz, .asm_e824d jr nz, .ch3_noise_sampling
bit NOTE_VIBRATO_OVERRIDE, [hl] bit NOTE_VIBRATO_OVERRIDE, [hl]
jr nz, .asm_e823a jr nz, .ch3_vibrato_override
ret ret
.asm_e822f ; unused .ch3_frequency_override ; unreferenced
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ldh [rNR33], a ldh [rNR33], a
ld a, [wCurTrackFrequency + 1] ld a, [wCurTrackFrequency + 1]
ldh [rNR34], a ldh [rNR34], a
ret ret
.asm_e823a .ch3_vibrato_override
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ldh [rNR33], a ldh [rNR33], a
ret ret
.ch3rest .ch3_rest
ldh a, [rNR52] ldh a, [rNR52]
and %10001011 ; ch3 off and %10001011 ; ch3 off
ldh [rNR52], a ldh [rNR52], a
@ -397,12 +397,12 @@ UpdateChannels:
call ClearChannel call ClearChannel
ret ret
.asm_e824d .ch3_noise_sampling
ld a, $3f ; sound length ld a, $3f ; sound length
ldh [rNR31], a ldh [rNR31], a
xor a xor a
ldh [rNR30], a ldh [rNR30], a
call .asm_e8268 call .load_wave_pattern
ld a, $80 ld a, $80
ldh [rNR30], a ldh [rNR30], a
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
@ -412,7 +412,7 @@ UpdateChannels:
ldh [rNR34], a ldh [rNR34], a
ret ret
.asm_e8268 .load_wave_pattern
push hl push hl
ld a, [wCurTrackVolumeEnvelope] ld a, [wCurTrackVolumeEnvelope]
and $f ; only 0-9 are valid and $f ; only 0-9 are valid
@ -470,18 +470,18 @@ endr
.Channel8: .Channel8:
ld hl, CHANNEL_NOTE_FLAGS ld hl, CHANNEL_NOTE_FLAGS
add hl, bc add hl, bc
bit NOTE_REST, [hl] ; rest bit NOTE_REST, [hl]
jr nz, .ch4rest jr nz, .ch4_rest
bit NOTE_NOISE_SAMPLING, [hl] bit NOTE_NOISE_SAMPLING, [hl]
jr nz, .asm_e82d4 jr nz, .ch4_noise_sampling
ret ret
.asm_e82c1 ; unused .ch4_frequency_override ; unreferenced
ld a, [wCurTrackFrequency] ld a, [wCurTrackFrequency]
ldh [rNR43], a ldh [rNR43], a
ret ret
.ch4rest .ch4_rest
ldh a, [rNR52] ldh a, [rNR52]
and %10000111 ; ch4 off and %10000111 ; ch4 off
ldh [rNR52], a ldh [rNR52], a
@ -489,7 +489,7 @@ endr
call ClearChannel call ClearChannel
ret ret
.asm_e82d4 .ch4_noise_sampling
ld a, $3f ; sound length ld a, $3f ; sound length
ldh [rNR41], a ldh [rNR41], a
ld a, [wCurTrackVolumeEnvelope] ld a, [wCurTrackVolumeEnvelope]

View File

@ -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: PokemonCenterPC:
call PC_CheckPartyForPokemon call PC_CheckPartyForPokemon
ret c ret c
@ -39,14 +53,8 @@ PokemonCenterPC:
dw PlaceNthMenuStrings dw PlaceNthMenuStrings
dw .JumpTable 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: .JumpTable:
; entries correspond to PCPC_* constants ; entries correspond to PCPCITEM_* constants
dw PlayersPC, .String_PlayersPC dw PlayersPC, .String_PlayersPC
dw BillsPC, .String_BillsPC dw BillsPC, .String_BillsPC
dw OaksPC, .String_OaksPC dw OaksPC, .String_OaksPC
@ -60,42 +68,44 @@ PCPC_TURN_OFF EQU 4
.String_TurnOff: db "TURN OFF@" .String_TurnOff: db "TURN OFF@"
.WhichPC: .WhichPC:
; before Pokédex ; entries correspond to PCPC_* constants
; PCPC_BEFORE_POKEDEX
db 3 db 3
db PCPC_BILLS_PC db PCPCITEM_BILLS_PC
db PCPC_PLAYERS_PC db PCPCITEM_PLAYERS_PC
db PCPC_TURN_OFF db PCPCITEM_TURN_OFF
db -1 ; end db -1 ; end
; before Hall Of Fame ; PCPC_BEFORE_HOF
db 4 db 4
db PCPC_BILLS_PC db PCPCITEM_BILLS_PC
db PCPC_PLAYERS_PC db PCPCITEM_PLAYERS_PC
db PCPC_OAKS_PC db PCPCITEM_OAKS_PC
db PCPC_TURN_OFF db PCPCITEM_TURN_OFF
db -1 ; end db -1 ; end
; postgame ; PCPC_POSTGAME
db 5 db 5
db PCPC_BILLS_PC db PCPCITEM_BILLS_PC
db PCPC_PLAYERS_PC db PCPCITEM_PLAYERS_PC
db PCPC_OAKS_PC db PCPCITEM_OAKS_PC
db PCPC_HALL_OF_FAME db PCPCITEM_HALL_OF_FAME
db PCPC_TURN_OFF db PCPCITEM_TURN_OFF
db -1 ; end db -1 ; end
.ChooseWhichPCListToUse: .ChooseWhichPCListToUse:
call CheckReceivedDex call CheckReceivedDex
jr nz, .got_dex jr nz, .got_dex
ld a, 0 ; before Pokédex ld a, PCPC_BEFORE_POKEDEX
ret ret
.got_dex .got_dex
ld a, [wHallOfFameCount] ld a, [wHallOfFameCount]
and a and a
ld a, 1 ; before Hall Of Fame ld a, PCPC_BEFORE_HOF
ret z ret z
ld a, 2 ; postgame ld a, PCPC_POSTGAME
ret ret
PC_CheckPartyForPokemon: PC_CheckPartyForPokemon:
@ -113,6 +123,22 @@ PC_CheckPartyForPokemon:
text_far _PokecenterPCCantUseText text_far _PokecenterPCCantUseText
text_end 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: BillsPC:
call PC_PlayChoosePCSound call PC_PlayChoosePCSound
ld hl, PokecenterBillsPCText ld hl, PokecenterBillsPCText
@ -125,7 +151,7 @@ PlayersPC:
call PC_PlayChoosePCSound call PC_PlayChoosePCSound
ld hl, PokecenterPlayersPCText ld hl, PokecenterPlayersPCText
call PC_DisplayText call PC_DisplayText
ld b, $0 ld b, PLAYERSPC_NORMAL
call _PlayersPC call _PlayersPC
and a and a
ret ret
@ -182,7 +208,7 @@ _PlayersHousePC:
call PC_PlayBootSound call PC_PlayBootSound
ld hl, PlayersPCTurnOnText ld hl, PlayersPCTurnOnText
call PC_DisplayText call PC_DisplayText
ld b, $1 ld b, PLAYERSPC_HOUSE
call _PlayersPC call _PlayersPC
and a and a
jr nz, .asm_156f9 jr nz, .asm_156f9
@ -190,12 +216,12 @@ _PlayersHousePC:
call ApplyTilemap call ApplyTilemap
call UpdateSprites call UpdateSprites
call PC_PlayShutdownSound call PC_PlayShutdownSound
ld c, $0 ld c, FALSE
ret ret
.asm_156f9 .asm_156f9
call ClearBGPalettes call ClearBGPalettes
ld c, $1 ld c, TRUE
ret ret
PlayersPCTurnOnText: PlayersPCTurnOnText:
@ -241,20 +267,12 @@ PlayersPCMenuData:
.PlayersPCMenuData: .PlayersPCMenuData:
db STATICMENU_CURSOR | STATICMENU_WRAP ; flags db STATICMENU_CURSOR | STATICMENU_WRAP ; flags
db 0 ; # items? db 0 ; # items?
dw .PlayersPCMenuList1 dw .WhichPC
dw PlaceNthMenuStrings dw PlaceNthMenuStrings
dw .PlayersPCMenuPointers 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: .PlayersPCMenuPointers:
; entries correspond to PLAYERSPC_* constants ; entries correspond to PLAYERSPCITEM_* constants
dw PlayerWithdrawItemMenu, .WithdrawItem dw PlayerWithdrawItemMenu, .WithdrawItem
dw PlayerDepositItemMenu, .DepositItem dw PlayerDepositItemMenu, .DepositItem
dw PlayerTossItemMenu, .TossItem dw PlayerTossItemMenu, .TossItem
@ -271,23 +289,26 @@ PLAYERSPC_LOG_OFF EQU 6
.TurnOff: db "TURN OFF@" .TurnOff: db "TURN OFF@"
.LogOff: db "LOG OFF@" .LogOff: db "LOG OFF@"
.PlayersPCMenuList1: .WhichPC:
; entries correspond to PLAYERSPC_* constants
; PLAYERSPC_NORMAL
db 5 db 5
db PLAYERSPC_WITHDRAW_ITEM db PLAYERSPCITEM_WITHDRAW_ITEM
db PLAYERSPC_DEPOSIT_ITEM db PLAYERSPCITEM_DEPOSIT_ITEM
db PLAYERSPC_TOSS_ITEM db PLAYERSPCITEM_TOSS_ITEM
db PLAYERSPC_MAIL_BOX db PLAYERSPCITEM_MAIL_BOX
db PLAYERSPC_TURN_OFF db PLAYERSPCITEM_TURN_OFF
db -1 ; end db -1 ; end
.PlayersPCMenuList2: ; PLAYERSPC_HOUSE
db 6 db 6
db PLAYERSPC_WITHDRAW_ITEM db PLAYERSPCITEM_WITHDRAW_ITEM
db PLAYERSPC_DEPOSIT_ITEM db PLAYERSPCITEM_DEPOSIT_ITEM
db PLAYERSPC_TOSS_ITEM db PLAYERSPCITEM_TOSS_ITEM
db PLAYERSPC_MAIL_BOX db PLAYERSPCITEM_MAIL_BOX
db PLAYERSPC_DECORATION db PLAYERSPCITEM_DECORATION
db PLAYERSPC_LOG_OFF db PLAYERSPCITEM_LOG_OFF
db -1 ; end db -1 ; end
PC_DisplayTextWaitMenu: PC_DisplayTextWaitMenu:
@ -445,7 +466,7 @@ PlayerDepositItemMenu:
.TryDepositItem: .TryDepositItem:
ld a, [wSpriteUpdatesEnabled] ld a, [wSpriteUpdatesEnabled]
push af push af
ld a, $0 ld a, FALSE
ld [wSpriteUpdatesEnabled], a ld [wSpriteUpdatesEnabled], a
farcall CheckItemMenu farcall CheckItemMenu
ld a, [wItemAttributeParamBuffer] ld a, [wItemAttributeParamBuffer]
@ -485,7 +506,7 @@ PlayerDepositItemMenu:
ld a, [wItemAttributeParamBuffer] ld a, [wItemAttributeParamBuffer]
and a and a
jr z, .AskQuantity jr z, .AskQuantity
ld a, $1 ld a, 1
ld [wItemQuantityChangeBuffer], a ld [wItemQuantityChangeBuffer], a
jr .ContinueDeposit jr .ContinueDeposit
@ -550,7 +571,7 @@ PCItemsJoypad:
.loop .loop
ld a, [wSpriteUpdatesEnabled] ld a, [wSpriteUpdatesEnabled]
push af push af
ld a, $0 ld a, FALSE
ld [wSpriteUpdatesEnabled], a ld [wSpriteUpdatesEnabled], a
ld hl, .PCItemsMenuData ld hl, .PCItemsMenuData
call CopyMenuHeader call CopyMenuHeader

View File

@ -14,7 +14,7 @@ FarDecompress::
ret ret
Decompress:: 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 is mainly (but not necessarily) used for graphics.
; This function decompresses lz-compressed data from hl to de. ; This function decompresses lz-compressed data from hl to de.

View File

@ -1,23 +1,21 @@
FarCall_de:: FarCall_de::
; Call a:de. ; Call a:de.
; Preserves other registers. ; Preserves other registers.
ldh [hTempBank], a ldh [hTempBank], a
ldh a, [hROMBank] ldh a, [hROMBank]
push af push af
ldh a, [hTempBank] ldh a, [hTempBank]
rst Bankswitch rst Bankswitch
call .de call FarCall_JumpToDE
jr ReturnFarCall jr ReturnFarCall
.de FarCall_JumpToDE:
push de push de
ret ret
FarCall_hl:: FarCall_hl::
; Call a:hl. ; Call a:hl.
; Preserves other registers. ; Preserves other registers.
ldh [hTempBank], a ldh [hTempBank], a
ldh a, [hROMBank] ldh a, [hROMBank]
push af push af
@ -29,7 +27,6 @@ FarCall_hl::
ReturnFarCall:: ReturnFarCall::
; We want to retain the contents of f. ; We want to retain the contents of f.
; To do this, we can pop to bc instead of af. ; To do this, we can pop to bc instead of af.
ld a, b ld a, b
ld [wFarCallBCBuffer], a ld [wFarCallBCBuffer], a
ld a, c ld a, c
@ -40,6 +37,7 @@ ReturnFarCall::
ld a, b ld a, b
rst Bankswitch rst Bankswitch
; Restore the contents of bc.
ld a, [wFarCallBCBuffer] ld a, [wFarCallBCBuffer]
ld b, a ld b, a
ld a, [wFarCallBCBuffer + 1] ld a, [wFarCallBCBuffer + 1]

View File

@ -334,14 +334,13 @@ Request1bpp::
jr .loop jr .loop
Get2bpp:: Get2bpp::
; copy c 2bpp tiles from b:de to hl
ldh a, [rLCDC] ldh a, [rLCDC]
bit rLCDC_ENABLE, a bit rLCDC_ENABLE, a
jp nz, Request2bpp jp nz, Request2bpp
; fallthrough ; fallthrough
Copy2bpp: Copy2bpp:
; copy c 2bpp tiles from b:de to hl
push hl push hl
ld h, d ld h, d
ld l, e ld l, e
@ -364,14 +363,13 @@ Copy2bpp:
jp FarCopyBytes jp FarCopyBytes
Get1bpp:: Get1bpp::
; copy c 1bpp tiles from b:de to hl
ldh a, [rLCDC] ldh a, [rLCDC]
bit rLCDC_ENABLE, a bit rLCDC_ENABLE, a
jp nz, Request1bpp jp nz, Request1bpp
; fallthrough ; fallthrough
Copy1bpp:: Copy1bpp::
; copy c 1bpp tiles from b:de to hl
push de push de
ld d, h ld d, h
ld e, l ld e, l