Name some WRAM labels and functions

This commit is contained in:
Electro 2026-02-08 20:33:56 +00:00
parent 9c8a79d13f
commit 1e82a6a9bb
16 changed files with 115 additions and 96 deletions

View File

@ -186,7 +186,7 @@ CardTypeTable:
assert_table_length NUM_CARD_TYPES
; calculate the chance of each type (BOOSTER_CARD_TYPE_*) for the next card
; return a = [wd4ca]: sum of all chances
; return a = [wTempBoosterChances]: sum of all chances
CalculateTypeChances:
ld c, NUM_BOOSTER_CARD_TYPES
xor a
@ -195,7 +195,7 @@ CalculateTypeChances:
ld [hli], a
dec c
jr nz, .delete_temp_type_chance_table_loop
ld [wd4ca], a
ld [wTempBoosterChances], a
ld bc, $00
.check_if_type_is_valid
push bc
@ -212,31 +212,31 @@ CalculateTypeChances:
ld hl, wBoosterTempTypeChancesTable
add hl, bc
ld [hl], a
ld a, [wd4ca]
ld a, [wTempBoosterChances]
add [hl]
ld [wd4ca], a
ld [wTempBoosterChances], a
.amount_of_type_or_chance_zero
pop bc
inc c
ld a, c
cp NUM_BOOSTER_CARD_TYPES
jr c, .check_if_type_is_valid
ld a, [wd4ca]
ld a, [wTempBoosterChances]
ret
; input: a = random number (between 0 and the sum of all chances)
; store the randomly generated booster card type in [wBoosterJustDrawnCardType]
DetermineBoosterCardType:
ld [wd4ca], a
ld [wTempBoosterChances], a
ld c, $00
ld hl, wBoosterTempTypeChancesTable
.loop_through_card_types
ld a, [hl]
or a
jr z, .skip_no_chance_type
ld a, [wd4ca]
ld a, [wTempBoosterChances]
sub [hl]
ld [wd4ca], a
ld [wTempBoosterChances], a
jr c, .found_card_type
.skip_no_chance_type
inc hl
@ -261,7 +261,7 @@ DetermineBoosterCard:
add hl, bc
ld a, [hl]
call Random
ld [wd4ca], a
ld [wTempBoosterChances], a
ld hl, wBoosterViableCardList
.find_matching_card_loop
ld a, [hli]
@ -271,11 +271,11 @@ DetermineBoosterCard:
ld a, [wBoosterJustDrawnCardType]
cp [hl]
jr nz, .card_incorrect_type
ld a, [wd4ca]
ld a, [wTempBoosterChances]
or a
jr z, .got_valid_card
dec a
ld [wd4ca], a
ld [wTempBoosterChances], a
.card_incorrect_type
inc hl
jr .find_matching_card_loop

View File

@ -20,7 +20,7 @@ InitAITurnVars:
xor a
ld [wPreviousAIFlags], a
ld [wAITriedAttack], a
ld [wcddc], a
ld [wUnused_cddc], a
ld [wAIRetreatedThisTurn], a
; checks if the Player used an attack last turn

View File

@ -2043,7 +2043,7 @@ AIDecide_PokemonBreeder:
ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA
call GetTurnDuelistVariable
ld c, a
ld e, $00
ld e, PLAY_AREA_ARENA
ld d, $00
; find highest score in wce08
@ -2057,7 +2057,7 @@ AIDecide_PokemonBreeder:
; store this score to wce06
ld a, [hl]
ld [wce06], a
; store this PLay Area location to wce07
; store this Play Area location to wce07
ld a, e
ld [wce07], a
@ -2162,7 +2162,7 @@ AIDecide_PokemonBreeder:
; store the score in wce06
ld a, b
ld [wce06], a
; store this PLay Area location to wce07
; store this Play Area location to wce07
ld a, e
ld [wce07], a

View File

@ -7647,9 +7647,9 @@ InitVariablesToBeginDuel:
xor a
ld [wDuelFinished], a
ld [wDuelTurns], a
ld [wcce7], a
ld [wUnused_cce7], a
ld a, $ff
ld [wcc0f], a
ld [wUnused_cc0f], a
ld [wPlayerAttackingCardIndex], a
ld [wPlayerAttackingAttackIndex], a
call EnableSRAM
@ -7811,11 +7811,11 @@ ClearNonTurnTemporaryDuelvars::
ret
; same as ClearNonTurnTemporaryDuelvars, except the non-turn holder's arena
; Pokemon status condition is copied to wccc5
; Pokemon status condition is copied to wUnused_DefendingPkmnStatus
ClearNonTurnTemporaryDuelvars_CopyStatus::
ld a, DUELVARS_ARENA_CARD_STATUS
call GetNonTurnDuelistVariable
ld [wccc5], a
ld [wUnused_DefendingPkmnStatus], a
call ClearNonTurnTemporaryDuelvars
ret

View File

@ -443,7 +443,7 @@ HandleSwitchDefendingPokemonEffect:
call SwapTurn
xor a
ld [wccc5], a
ld [wUnused_DefendingPkmnStatus], a
ld [wDuelDisplayedScreen], a
inc a
ld [wDefendingWasForcedToSwitch], a
@ -466,7 +466,7 @@ HandleNoDamageOrEffect:
; de = HP amount to recover
ApplyAndAnimateHPRecovery:
push de
ld hl, wccbd
ld hl, wUnused_HPRecoverAmount
ld [hl], e
inc hl
ld [hl], d

View File

@ -352,9 +352,9 @@ Func_80238: ; unreferenced
ld a, TILE_SIZE
ld [wCurSpriteTileSize], a
xor a
ld [wd4cb], a
ld [wWhichVRAMBank], a ; VRAM0
ld a, $80
ld [wd4ca], a
ld [wVRAMTileOffset], a
call LoadGfxDataFromTempPointerToVRAMBank_Tiles0ToTiles2
pop hl
ret
@ -380,7 +380,7 @@ LoadSpriteGfx:
ret
; loads graphics data pointed by wTempPointer in wTempPointerBank
; to the VRAM bank according to wd4cb, in address pointed by wVRAMPointer
; to the VRAM bank according to wWhichVRAMBank, in address pointed by wVRAMPointer
LoadGfxDataFromTempPointerToVRAMBank:
call GetTileOffsetPointerAndSwitchVRAM
jr LoadGfxDataFromTempPointer
@ -418,7 +418,7 @@ LoadGfxDataFromTempPointer:
; convert wVRAMTileOffset to address in VRAM
; and stores it in wVRAMPointer
; switches VRAM according to wd4cb
; switches VRAM according to wWhichVRAMBank
GetTileOffsetPointerAndSwitchVRAM:
; address of the tile offset is wVRAMTileOffset * $10 + $8000
ld a, [wVRAMTileOffset]
@ -431,16 +431,16 @@ GetTileOffsetPointerAndSwitchVRAM:
add HIGH(v0Tiles0) ; $80
ld [wVRAMPointer + 1], a
; if bottom bit in wd4cb is not set = VRAM0
; if bottom bit in wd4cb is set = VRAM1
ld a, [wd4cb]
; if bottom bit in wWhichVRAMBank is not set = VRAM0
; if bottom bit in wWhichVRAMBank is set = VRAM1
ld a, [wWhichVRAMBank]
and $1
call BankswitchVRAM
ret
; converts wVRAMTileOffset to address in VRAM
; and stores it in wVRAMPointer
; switches VRAM according to wd4cb
; switches VRAM according to wWhichVRAMBank
; then changes wVRAMPointer such that
; addresses to Tiles0 is changed to Tiles2
GetTileOffsetPointerAndSwitchVRAM_Tiles0ToTiles2:
@ -493,20 +493,20 @@ LoadTilesetGfx:
; used to sequentially copy gfx data in the order
; v0Tiles1 -> v0Tiles2 -> v1Tiles1 -> v1Tiles2
lb bc, $0, LOW(v0Tiles2 / TILE_SIZE) ; $00
lb bc, BANK("VRAM0"), LOW(v0Tiles2 / TILE_SIZE) ; $00
call .CopyGfxData
jr z, .done
lb bc, $0, LOW(v0Tiles1 / TILE_SIZE) ; $80
lb bc, BANK("VRAM0"), LOW(v0Tiles1 / TILE_SIZE) ; $80
call .CopyGfxData
jr z, .done
; VRAM1 only used in CGB console
ld a, [wConsole]
cp CONSOLE_CGB
jr nz, .done
lb bc, $1, LOW(v1Tiles2 / TILE_SIZE) ; $00
lb bc, BANK("VRAM1"), LOW(v1Tiles2 / TILE_SIZE) ; $00
call .CopyGfxData
jr z, .done
lb bc, $1, LOW(v1Tiles1 / TILE_SIZE) ; $80
lb bc, BANK("VRAM1"), LOW(v1Tiles1 / TILE_SIZE) ; $80
call .CopyGfxData
.done
@ -519,14 +519,14 @@ LoadTilesetGfx:
; c must match with wVRAMTileOffset
; if c = $00, copies it to Tiles2
; if c = $80, copies it to Tiles1
; b must match with VRAM bank in wd4cb
; b must match with VRAM bank in wWhichVRAMBank
; prepares next call to this routine if data wasn't fully copied
; so that it copies to the right VRAM section
.CopyGfxData
push hl
push bc
push de
ld a, [wd4cb]
ld a, [wWhichVRAMBank]
cp b
jr nz, .skip
ld a, [wVRAMTileOffset]
@ -535,7 +535,7 @@ LoadTilesetGfx:
bit 7, a
jr nz, .skip
; (wd4cb == b) and
; (wWhichVRAMBank == b) and
; bit 7 in c is same as bit 7 in wVRAMTileOffset
ld a, c
add $80
@ -573,7 +573,7 @@ LoadTilesetGfx:
push hl
ldh a, [hBankVRAM]
push af
ld a, [wd4cb]
ld a, [wWhichVRAMBank]
and $01
call BankswitchVRAM
call CopyGfxDataFromTempBank
@ -605,9 +605,9 @@ LoadTilesetGfx:
pop af
; if it overflows
; (which means a tile group after Tiles2)
; then set wd4cb for VRAM1
ld a, [hl] ; wd4cb
adc $00
; then set wWhichVRAMBank for VRAM1
ld a, [hl] ; wWhichVRAMBank
adc 0
ld [hl], a
.skip

View File

@ -342,11 +342,11 @@ HandleAnimationFrame:
adc 0
ld [hl], a
ld de, wLoadedPalData
ld de, wLoadedFrameData
ld bc, SPRITE_FRAME_OFFSET_SIZE
call CopyBankedDataToDE
pop hl ; beginning of current sprite_anim_buffer
ld de, wLoadedPalData
ld de, wLoadedFrameData
ld a, [de]
call GetAnimFramePointerFromOffset
inc de
@ -384,11 +384,11 @@ HandleAnimationFrame:
ret
; Calls GetAnimationFramePointer after setting up wTempPointerBank
; and wVRAMTileOffset
; and wWhichAnimationFrame
; a - frame offset from Animation Data
; hl - beginning of Sprite Anim Buffer
GetAnimFramePointerFromOffset:
ld [wVRAMTileOffset], a
ld [wWhichAnimationFrame], a
push hl
push bc
push de
@ -568,7 +568,7 @@ Func_12c05:
Func_12c4f:
push af
xor a
ld [wd4cb], a
ld [wWhichVRAMBank], a ; VRAM0
ld a, d
ld [wVRAMTileOffset], a
pop af

View File

@ -49,9 +49,9 @@ LoadCollectedMedalTilemaps:
jr nz, .loop_medals
ld a, $80
ld [wd4ca], a
ld [wVRAMTileOffset], a
xor a
ld [wd4cb], a
ld [wWhichVRAMBank], a ; VRAM0
farcall LoadTilesetGfx
xor a
ld [wWhichOBP], a ; not used

View File

@ -38,7 +38,7 @@ LoadMapTilesAndPals:
ld a, LOW(v0Tiles1 / TILE_SIZE)
ld [wVRAMTileOffset], a
xor a ; VRAM0
ld [wd4cb], a
ld [wWhichVRAMBank], a
call LoadTilesetGfx
xor a

View File

@ -77,9 +77,9 @@ _LoadScene::
pop bc ; base x,y
call LoadScene_LoadSGBPacket
ld a, [hli]
ld [wd4ca], a ; tile offset
ld [wVRAMTileOffset], a ; tile offset
ld a, [hli]
ld [wd4cb], a ; vram0 or vram1
ld [wWhichVRAMBank], a ; vram0 or vram1
farcall LoadTilesetGfx
.next_sprite
ld a, [hli]
@ -272,9 +272,9 @@ _DrawPortrait::
push hl
ld [wCurTileset], a
ld a, d
ld [wd4ca], a
ld [wVRAMTileOffset], a
xor a
ld [wd4cb], a
ld [wWhichVRAMBank], a ; VRAM0
farcall LoadTilesetGfx
pop hl
xor a
@ -326,8 +326,8 @@ SetBoosterLogoOAM:
push de
push bc
xor a
ld [wd4cb], a
ld [wd4ca], a
ld [wWhichVRAMBank], a ; VRAM0
ld [wVRAMTileOffset], a
ld a, SPRITE_BOOSTER_PACK_OAM
farcall LoadSpriteGfx
pop bc

View File

@ -586,14 +586,14 @@ SendSGBPortraitPalettes:
push hl
ld hl, SGBData_PlayerPortraitPals
call DecompressSGBPalette
ld hl, wLoadedPalData
ld hl, wDecompressionBuffer
ld de, wTempSGBPacket + $1
ld bc, $8
call CopyDataHLtoDE
pop hl
call DecompressSGBPalette
ld hl, wLoadedPalData + 2
ld hl, wDecompressionBuffer + 2
ld de, wTempSGBPacket + $9
ld bc, $6
call CopyDataHLtoDE

View File

@ -1486,7 +1486,7 @@ UpdateArenaCardIDsAndClearTwoTurnDuelVars::
ld [wTempNonTurnDuelistCardID], a
call SwapTurn
xor a
ld [wccec], a
ld [wSentAttackDataToLinkOpponent], a
ld [wStatusConditionQueueIndex], a
ld [wEffectFailed], a
ld [wIsDamageToSelf], a
@ -1670,15 +1670,15 @@ UsePokemonPower::
; in a link duel, it's used to send the other game data about the
; attack being in use, triggering a call to OppAction_BeginUseAttack in the receiver
SendAttackDataToLinkOpponent::
ld a, [wccec]
ld a, [wSentAttackDataToLinkOpponent]
or a
ret nz
ldh a, [hTemp_ffa0]
push af
ldh a, [hTempCardIndex_ff9f]
push af
ld a, $1
ld [wccec], a
ld a, TRUE
ld [wSentAttackDataToLinkOpponent], a
ld a, [wPlayerAttackingCardIndex]
ldh [hTempCardIndex_ff9f], a
ld a, [wPlayerAttackingAttackIndex]

View File

@ -139,14 +139,14 @@ DrawSpriteAnimationFrame::
; Loads a pointer to the current animation frame into SPRITE_ANIM_FRAME_DATA_POINTER using
; the current frame's offset
; [wd4ca] - current frame offset
; [wWhichAnimationFrame] - current frame in the animation
; wTempPointer* - Pointer to current Animation
GetAnimationFramePointer::
ldh a, [hBankROM]
push af
push hl
push hl
ld a, [wd4ca]
ld a, [wWhichAnimationFrame]
cp $ff
jr nz, .useLoadedOffset
ld de, SpriteNullAnimationPointer
@ -162,7 +162,7 @@ GetAnimationFramePointer::
ld a, [hli]
push af
ld a, [wd4ca]
ld a, [wWhichAnimationFrame]
rlca
ld e, [hl]
add e

View File

@ -265,14 +265,15 @@ SerialSendByte::
push de
push bc
push af
.asm_e0e
.loop_wait
ld a, [wcb80]
ld e, a
ld a, [wSerialSendBufIndex]
dec a
and $1f
cp e
jr z, .asm_e0e
jr z, .loop_wait
; wSerialSendBufIndex != wcb80
ld d, $0
ld a, e
inc a
@ -452,9 +453,12 @@ SerialRecvBytes::
scf
ret
Func_0ef1::
ld de, wcb79
ld hl, sp+$fe
; saves address of sp-2 to wSerialReturnSP
; and saves return address of current routine to wSerialReturnAddress
; unreferenced
UnreferencedSaveSerialReturnAddress:
ld de, wSerialReturnSP
ld hl, sp+-2
ld a, l
ld [de], a
inc de
@ -464,26 +468,29 @@ Func_0ef1::
pop hl
push hl
ld a, l
ld [de], a
ld [de], a ; wSerialReturnAddress
inc de
ld a, h
ld [de], a
or a
ret
Func_0f05::
; if wSerialReturnAddress is non-NULL, then set sp to address in wSerialReturnSP
; and jump to address in wSerialReturnAddress
; unreferenced
UnreferencedGoToSerialReturnAddress:
push hl
ld hl, wcb7b
ld hl, wSerialReturnAddress
ld a, [hli]
or [hl]
pop hl
ret z
ld hl, wcb79
ld hl, wSerialReturnSP
ld a, [hli]
ld h, a
ld l, a
ld sp, hl
ld hl, wcb7b
ld hl, wSerialReturnAddress
ld a, [hli]
ld h, [hl]
ld l, a

View File

@ -77,7 +77,7 @@ DrawLabeledTextBox::
push bc
push hl
; top left tile of the box
ld hl, wc000
ld hl, wLabeledTextBoxTopBorder
ld a, TX_SYMBOL
ld [hli], a
ld a, SYM_BOX_TOP_L
@ -90,7 +90,7 @@ DrawLabeledTextBox::
ld d, h
pop hl
call CopyText
ld hl, wc000 + 3
ld hl, wLabeledTextBoxTopBorder + 3
call GetTextLengthInTiles
ld l, e
ld h, d
@ -125,7 +125,7 @@ DrawLabeledTextBox::
push de
push bc
call InitTextPrinting
ld hl, wc000
ld hl, wLabeledTextBoxTopBorder
call ProcessText
pop bc
pop de

View File

@ -12,7 +12,9 @@ wTempCardCollection:: ; c000
NEXTU
wc000:: ; c000
; used in DrawLabeledTextBox to draw the top border
; of a label text box (with top border symbols and NPC name)
wLabeledTextBoxTopBorder:: ; c000
ds $100
NEXTU
@ -367,10 +369,12 @@ wSerialCounter2:: ; cb77
wSerialTimeoutCounter:: ; cb78
ds $1
wcb79:: ; cb79
; stores a stack pointer to be used with wSerialReturnAddress
wSerialReturnSP:: ; cb79
ds $2
wcb7b:: ; cb7b
; stores a return address to be used with wSerialReturnSP
wSerialReturnAddress:: ; cb7b
ds $2
wSerialSendSave:: ; cb7d
@ -665,7 +669,7 @@ wDuelistType:: ; cc0d
wOpponentDeckID:: ; cc0e
ds $1
wcc0f:: ; cc0f
wUnused_cc0f:: ; cc0f
ds $1
; index (0-1) of the attack or Pokemon Power being used by the player's arena card
@ -740,8 +744,9 @@ wAIMinDamage:: ; ccbb
wAIMaxDamage:: ; ccbc
ds $1
; only written, never read
wccbd:: ; ccbd
; holds amount of HP recovered in ApplyAndAnimateHPRecovery
; only written to, never read
wUnused_HPRecoverAmount:: ; ccbd
ds $2
; damage dealt by an attack to a target
@ -763,7 +768,8 @@ wTempNonTurnDuelistCardID:: ; ccc4
ds $1
; the status condition of the defending Pokemon is loaded here after an attack
wccc5:: ; ccc5
; only written to, never read
wUnused_DefendingPkmnStatus:: ; ccc5
ds $1
; *_ATTACK constants for selected attack
@ -805,7 +811,8 @@ wStatusConditionQueue:: ; ccce
wIsDamageToSelf:: ; cce6
ds $1
wcce7:: ; cce7
; set to 0, never used
wUnused_cce7:: ; cce7
ds $1
wDuelFinishParam:: ; cce8
@ -819,7 +826,10 @@ wDeckName:: ; cce9
wTempPlayAreaLocation_cceb:: ; cceb
ds $1
wccec:: ; ccec
; when sending attack data to opponent, is set to TRUE
; seems to be used to avoid sending duplicate data
; when using an attack through Metronome
wSentAttackDataToLinkOpponent:: ; ccec
ds $1
; used by the effect functions to return the cause of an effect to fail
@ -1184,7 +1194,8 @@ wAIRetreatFlags:: ; cdda
wAITriedAttack:: ; cddb
ds $1
wcddc:: ; cddc
; set to 0, never used
wUnused_cddc:: ; cddc
ds $1
; used to temporarily backup wPlayAreaAIScore values.
@ -2196,19 +2207,15 @@ wBGMapCGBMode:: ; d23c
wBGMapBank:: ; d23d
ds $1
UNION
; palette loaded from Palette* data
wLoadedPalData:: ; d23e
ds $50
NEXTU
; temporary frame data loaded in HandleAnimationFrame
wLoadedFrameData:: ; d23e
; where BG map data or other compressed data is decompressed
wDecompressionBuffer:: ; d23e
ds $40
ENDU
ds $50
wDecompressionRowWidth:: ; d28e
ds $1
@ -2662,7 +2669,12 @@ wVRAMTileOffset:: ; d4ca
; which object palette to load to (DMG)
wWhichOBP:: ; d4ca
wd4ca:: ; d4ca
; temporary storage of variables when
; calculating booster chances of cards
wTempBoosterChances:: ; d4ca
; current frame to load when processing an animation
wWhichAnimationFrame:: ; d4ca
ds $1
; for LoadOBPalette
@ -2673,9 +2685,9 @@ wWhichOBPalIndex:: ; d4cb
; which background palette index to load to (CGB)
wWhichBGPalIndex:: ; d4cb
; bottom bit stores which VRAM bank to draw certain gfx
; stores which VRAM bank to draw certain gfx
; $0 = VRAM0, $1 = VRAM1
wd4cb:: ; d4cb
wWhichVRAMBank:: ; d4cb
ds $1
ds $3