Improve some innacurate function names from pokecrystal

This commit is contained in:
xCrystal 2023-08-28 13:30:13 +02:00
parent 11db1300b2
commit fd6f02036e
18 changed files with 76 additions and 63 deletions

View File

@ -14,19 +14,29 @@
- **PrintText2bpp**: SpeechTextbox2bpp + UpdateSprites + ApplyTilemap + ClearTextbox + PrintTextboxText
- **MapTextbox**: ClearTextbox + redraw tile behind cursor + SafeUpdateSprites + disable OAM update + ApplyTilemap + PrintTextboxText + enable OAM update
- **MenuBox**: Calls Textbox1bpp or Textbox2bpp, depending on the value at wMenuBoxUse2bppFrame, with menu location and dimensions. wMenuBoxUse2bppFrame, as part of menu data, is cleared (FALSE means 1bpp) by ClearMenuAndWindowData
- **OverworldTextModeSwitch**: LoadMapPart + SwapTextboxPalettes
- **LoadScreenTilemap**: From the metatile-based 24x20 map in wSurroundingTiles, load the corresponding 20x18 tiles to wTilemap. Later, BackupBGMap* from ScrollMap* copies new row/column from wTilemap to wBGMapBuffer. _ScrollBGMapPalettes populates wBGMapPalBuffer based on the tiles at wBGMapBuffer. These are read during vblank by UpdateBGMapBuffer.
- **LoadScreenAttrmapPals**: Load wAttrmap palette numbers based on the tileset palettes of the current map. Called only by LoadScreenTilemapAndAttrmapPals.
- **LoadScreenTilemapAndAttrmapPals**: LoadScreenTilemap + LoadScreenAttrmapPals. Often used to reload screen after closing a text box.
- **LoadFont_NoOAMUpdate**: LoadFrame + Hide Window + LoadStandardFont with OAM update disabled
- **LoadOverworldFont_NoOAMUpdate**: LoadOverworldFontAndFrame + hide Window with OAM update disabled
- **OpenText1bpp**, **OpenText2bpp**: ClearMenuAndWindowData + ReanchorBGMap_NoOAMUpdate + SpeechTextbox1bpp + _OpenAndCloseMenu_HDMATransferTilemapAndAttrmap + hide Window
- **ReanchorBGMap_NoOAMUpdate**: LoadScreenTilemapAndAttrmapPals + HDMATransferTilemapAndAttrmap_OpenAndCloseMenu, then fill BG map with all black while Window is displayed, finally anchor map and objects. Followed by CopyTilemapAtOnce or by a *_HDMATransferTilemapAndAttrmap to redraw the screen.
- **OpenText1bpp**, **OpenText2bpp**: ClearMenuAndWindowData + ReanchorBGMap_NoOAMUpdate + SpeechTextbox1bpp + HDMATransferTilemapAndAttrmap_OpenAndCloseMenu + hide Window
- **OpenText1bpp**: Loads 1bpp font (LoadFont_NoOAMUpdate)
- **OpenText2bpp**: Doesn't load 2bpp font
- **RefreshScreen**: Same as OpenText functions but doesn't call any SpeechTextbox
- **HDMATransferTilemapAndAttrmap_OverworldEffect**: Like HDMATransferTilemapAndAttrmap_OpenAndCloseMenu but with slightly different scanline timing. So it's essentially like RefreshScreen minus the anchoring part.
- **Request1bpp**, **Request2bpp**: Copy 1bpp or 2bpp tiles at a rate of TILES_PER_CYCLE (8) per frame during vblank. Wait until complete
- **Copy1bpp**, **Copy2bpp**: Copy 1bpp or 2bpp tiles immediately
- **Get1bpp**, **Get2bpp**: Call Copy1bpp or Copy2bpp if LCD disabled. Request1bpp or Request2bpp otherwise
- **HDMATransfer1bpp**: Copy 1bpp tiles via HDMA. Maximum 16 tiles per frame
- **HDMATransfer2bpp**: Copy 2bpp tiles via HDMA. No hardcoded limit. Timing considers 1 tile per hblank
- **Get1bppViaHDMA**, **Get2bppViaHDMA**: Call Copy1bpp or Copy2bpp if LCD disabled. HDMATransfer1bpp or HDMATransfer2bpp otherwise
- **refreshscreen**: RefreshScreen
- **reloadmappart**: LoadScreenTilemapAndAttrmapPals + GetMovementPermissions + HDMATransferTilemapAndAttrmap_OverworldEffect + UpdateSprites. Similar to refreshscreen, but does not reanchor. On the other hand, it refreshes movement permissions. Often used after a block change or field move, which can affect collisions.

View File

@ -1023,7 +1023,7 @@ TilesetColorPicker: ; unreferenced
ld [wDebugTilesetCurColor], a
ldh [hMapAnims], a
call ClearSprites
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
call WaitBGMap2
xor a
ldh [hBGMapMode], a

View File

@ -58,7 +58,7 @@ ShakeHeadbuttTree:
jr .loop
.done
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
call WaitBGMap
xor a
ldh [hBGMapMode], a

View File

@ -220,7 +220,7 @@ CutDownTreeOrGrass:
ld [hl], a
xor a
ldh [hBGMapMode], a
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
call UpdateSprites
call DelayFrame
ld a, [wCutWhirlpoolAnimationType]
@ -1171,7 +1171,7 @@ DisappearWhirlpool:
ld [hl], a
xor a
ldh [hBGMapMode], a
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
ld a, [wCutWhirlpoolAnimationType]
ld e, a
farcall PlayWhirlpoolSound

View File

@ -212,7 +212,7 @@ _PlayersHousePC:
call _PlayersPC
and a
jr nz, .changed_deco_tiles
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
call ApplyTilemap
call UpdateSprites
call PC_PlayShutdownSound

View File

@ -35,7 +35,7 @@ ClosePokepic::
call GetMemCGBLayout
xor a
ldh [hBGMapMode], a
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
call ApplyTilemap
call UpdateSprites
call LoadStandardFont

View File

@ -26,11 +26,13 @@ HDMATransferAttrmapToWRAMBank3:
call HDMATransferToWRAMBank3
ret
ReloadMapPart::
HDMATransferTilemapAndAttrmap_OverworldEffect::
ld hl, .Function
jp CallInSafeGFXMode
.Function:
; Pad BG attrs with $00
; Pad BG tiles with " "
decoord 0, 0, wAttrmap
ld hl, wScratchAttrmap
call PadAttrmapForHDMATransfer
@ -39,31 +41,31 @@ ReloadMapPart::
call PadTilemapForHDMATransfer
call DelayFrame
; Transfer Attrmap and Tilemap to BG map
di
ldh a, [rVBK]
push af
ld a, $1
ldh [rVBK], a
ld hl, wScratchAttrmap
call HDMATransfer_Wait127Scanlines_toBGMap
call HDMATransfer_EndBeforeScanline128_toBGMap
ld a, $0
ldh [rVBK], a
ld hl, wScratchTilemap
call HDMATransfer_Wait127Scanlines_toBGMap
call HDMATransfer_EndBeforeScanline128_toBGMap
pop af
ldh [rVBK], a
ei
ret
OpenAndCloseMenu_HDMATransferTilemapAndAttrmap::
_HDMATransferTilemapAndAttrmap_OpenAndCloseMenu::
ld hl, .Function
jp CallInSafeGFXMode
.Function:
; Transfer wAttrmap and Tilemap to BGMap
; Fill vBGAttrs with $00
; Fill vBGTiles with " "
; Pad BG attrs with $00
; Pad BG tiles with " "
decoord 0, 0, wAttrmap
ld hl, wScratchAttrmap
call PadAttrmapForHDMATransfer
@ -72,17 +74,18 @@ OpenAndCloseMenu_HDMATransferTilemapAndAttrmap::
call PadTilemapForHDMATransfer
call DelayFrame
; Transfer Attrmap and Tilemap to BG map
di
ldh a, [rVBK]
push af
ld a, $1
ldh [rVBK], a
ld hl, wScratchAttrmap
call HDMATransfer_Wait123Scanlines_toBGMap
call HDMATransfer_EndBeforeScanline124_toBGMap
ld a, $0
ldh [rVBK], a
ld hl, wScratchTilemap
call HDMATransfer_Wait123Scanlines_toBGMap
call HDMATransfer_EndBeforeScanline124_toBGMap
pop af
ldh [rVBK], a
ei
@ -131,7 +134,7 @@ WaitDMATransfer:
jr nz, .loop
ret
HDMATransfer_Wait127Scanlines_toBGMap:
HDMATransfer_EndBeforeScanline128_toBGMap:
; HDMA transfer from hl to [hBGMapAddress]
; hBGMapAddress -> de
; 2 * SCREEN_HEIGHT -> c
@ -140,9 +143,9 @@ HDMATransfer_Wait127Scanlines_toBGMap:
ldh a, [hBGMapAddress]
ld e, a
ld c, 2 * SCREEN_HEIGHT
jr HDMATransfer_Wait127Scanlines
jr HDMATransfer_EndBeforeScanline128
HDMATransfer_Wait123Scanlines_toBGMap:
HDMATransfer_EndBeforeScanline124_toBGMap:
; HDMA transfer from hl to [hBGMapAddress]
; hBGMapAddress -> de
; 2 * SCREEN_HEIGHT -> c
@ -152,7 +155,7 @@ HDMATransfer_Wait123Scanlines_toBGMap:
ldh a, [hBGMapAddress]
ld e, a
ld c, 2 * SCREEN_HEIGHT
jr HDMATransfer_Wait123Scanlines
jr HDMATransfer_EndBeforeScanline124
HDMATransfer_NoDI:
; HDMA transfer from hl to [hBGMapAddress]
@ -213,12 +216,12 @@ HDMATransfer_NoDI:
res 7, [hl]
ret
HDMATransfer_Wait123Scanlines:
ld b, $7b
HDMATransfer_EndBeforeScanline124:
ld b, 124 - 1
jr _continue_HDMATransfer
HDMATransfer_Wait127Scanlines:
ld b, $7f
HDMATransfer_EndBeforeScanline128:
ld b, 128 - 1
_continue_HDMATransfer:
; a lot of waiting around for hardware registers
; [rHDMA1, rHDMA2] = hl & $fff0
@ -372,7 +375,7 @@ HDMATransfer2bpp::
ld d, h
ld e, l
ld hl, wScratchTilemap
call HDMATransfer_Wait127Scanlines
call HDMATransfer_EndBeforeScanline128
; restore the previous bank
pop af
@ -437,7 +440,7 @@ HDMATransfer1bpp::
ld d, h
ld e, l
ld hl, wScratchTilemap
call HDMATransfer_Wait127Scanlines
call HDMATransfer_EndBeforeScanline128
pop af
ldh [rSVBK], a
@ -459,13 +462,13 @@ HDMATransfer_OnlyTopFourRows:
ld c, $8
ld hl, wScratchTilemap + $80
debgcoord 0, 0, vBGMap1
call HDMATransfer_Wait127Scanlines
call HDMATransfer_EndBeforeScanline128
ld a, $0
ldh [rVBK], a
ld c, $8
ld hl, wScratchTilemap
debgcoord 0, 0, vBGMap1
call HDMATransfer_Wait127Scanlines
call HDMATransfer_EndBeforeScanline128
ret
.Copy:

View File

@ -624,7 +624,7 @@ RestoreOverworldMapTiles: ; unreferenced
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyBytes
call CloseSRAM
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
xor a ; sScratch
call OpenSRAM
ld hl, sScratch

View File

@ -33,7 +33,7 @@ StartMenu::
call DrawVariableLengthMenuBox
call .DrawBugContestStatusBox
call SafeUpdateSprites
call _OpenAndCloseMenu_HDMATransferTilemapAndAttrmap
call HDMATransferTilemapAndAttrmap_OpenAndCloseMenu
farcall LoadFont_NoOAMUpdate
call .DrawBugContestStatus
call UpdateTimePals

View File

@ -27,10 +27,10 @@ ReanchorBGMap_NoOAMUpdate::
ldh [hBGMapMode], a
ld a, $90
ldh [hWY], a
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
ld a, HIGH(vBGMap1)
call .LoadBGMapAddrIntoHRAM
call _OpenAndCloseMenu_HDMATransferTilemapAndAttrmap
call HDMATransferTilemapAndAttrmap_OpenAndCloseMenu
farcall ApplyPals
ld a, TRUE
ldh [hCGBPalUpdate], a

View File

@ -1,4 +1,4 @@
_LoadMapPart::
_LoadScreenTilemap::
ld hl, wSurroundingTiles
ld a, [wPlayerMetatileY]
and a

View File

@ -124,25 +124,25 @@ UpdateOverworldMap:
.step_down
call .ScrollOverworldMapDown
call LoadMapPart
call LoadScreenTilemap
call ScrollMapDown
ret
.step_up
call .ScrollOverworldMapUp
call LoadMapPart
call LoadScreenTilemap
call ScrollMapUp
ret
.step_left
call .ScrollOverworldMapLeft
call LoadMapPart
call LoadScreenTilemap
call ScrollMapLeft
ret
.step_right
call .ScrollOverworldMapRight
call LoadMapPart
call LoadScreenTilemap
call ScrollMapRight
ret

View File

@ -947,7 +947,7 @@ ApplyObjectFacing:
ret
.DisableTextTiles:
call LoadMapPart
call LoadScreenTilemap
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
.loop
@ -2170,9 +2170,9 @@ Script_changeblock:
Script_reloadmappart::
xor a
ldh [hBGMapMode], a
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
call GetMovementPermissions
farcall ReloadMapPart
farcall HDMATransferTilemapAndAttrmap_OverworldEffect
call UpdateSprites
ret
@ -2212,7 +2212,7 @@ Script_writeunusedbyte:
ret
Script_closetext:
call _OpenAndCloseMenu_HDMATransferTilemapAndAttrmap
call HDMATransferTilemapAndAttrmap_OpenAndCloseMenu
call CloseText
ret

View File

@ -219,7 +219,7 @@ LoadMapTimeOfDay:
ld [wSpriteUpdatesEnabled], a
farcall ReplaceTimeOfDayPals
farcall UpdateTimeOfDayPal
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
call .ClearBGMap
call .PushAttrmap
ret

View File

@ -1,4 +1,4 @@
_SwapTextboxPalettes::
_LoadScreenAttrmapPals::
hlcoord 0, 0
decoord 0, 0, wAttrmap
ld b, SCREEN_HEIGHT

View File

@ -91,12 +91,12 @@ GetMapSceneID::
pop bc
ret
OverworldTextModeSwitch::
call LoadMapPart
call SwapTextboxPalettes
LoadScreenTilemapAndAttrmapPals::
call LoadScreenTilemap
call LoadScreenAttrmapPals
ret
LoadMapPart::
LoadScreenTilemap::
ldh a, [hROMBank]
push af
@ -109,9 +109,9 @@ LoadMapPart::
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call ByteFill
ld a, BANK(_LoadMapPart)
ld a, BANK(_LoadScreenTilemap)
rst Bankswitch
call _LoadMapPart
call _LoadScreenTilemap
pop af
rst Bankswitch
@ -1952,7 +1952,7 @@ ReloadTilesetAndPalettes::
ld c, a
call SwitchToAnyMapAttributesBank
farcall UpdateTimeOfDayPal
call OverworldTextModeSwitch
call LoadScreenTilemapAndAttrmapPals
call LoadTilesetGFX
ld a, 9
call SkipMusic

View File

@ -288,8 +288,8 @@ ReloadSpritesNoPalettes::
call DelayFrame
ret
SwapTextboxPalettes::
homecall _SwapTextboxPalettes
LoadScreenAttrmapPals::
homecall _LoadScreenAttrmapPals
ret
ScrollBGMapPalettes::

View File

@ -6,7 +6,7 @@ RefreshScreen::
rst Bankswitch
call ReanchorBGMap_NoOAMUpdate
call _OpenAndCloseMenu_HDMATransferTilemapAndAttrmap
call HDMATransferTilemapAndAttrmap_OpenAndCloseMenu
call HideWindow_EnableLCDInt
pop af
@ -22,8 +22,8 @@ CloseText::
call ClearMenuAndWindowData
xor a
ldh [hBGMapMode], a
call OverworldTextModeSwitch
call _OpenAndCloseMenu_HDMATransferTilemapAndAttrmap
call LoadScreenTilemapAndAttrmapPals
call HDMATransferTilemapAndAttrmap_OpenAndCloseMenu
xor a
ldh [hBGMapMode], a
call SafeUpdateSprites
@ -46,10 +46,10 @@ OpenText2bpp::
ld a, BANK(ReanchorBGMap_NoOAMUpdate)
rst Bankswitch
; assumes that the overworld 2bpp font and frame are loaded when calling this
call ReanchorBGMap_NoOAMUpdate ; clear bgmap
; assumes that the overworld 2bpp font and frame are loaded when calling this
call ReanchorBGMap_NoOAMUpdate ; anchor bgmap
call SpeechTextbox2bpp
call _OpenAndCloseMenu_HDMATransferTilemapAndAttrmap ; anchor bgmap
call HDMATransferTilemapAndAttrmap_OpenAndCloseMenu ; transfer bgmap
call HideWindow_EnableLCDInt
pop af
@ -64,9 +64,9 @@ OpenText1bpp::
ld a, BANK(ReanchorBGMap_NoOAMUpdate) ; aka BANK(LoadFont_NoOAMUpdate)
rst Bankswitch
call ReanchorBGMap_NoOAMUpdate ; clear bgmap
call ReanchorBGMap_NoOAMUpdate ; anchor bgmap
call SpeechTextbox1bpp
call _OpenAndCloseMenu_HDMATransferTilemapAndAttrmap ; anchor bgmap
call HDMATransferTilemapAndAttrmap_OpenAndCloseMenu ; transfer bgmap
call LoadFont_NoOAMUpdate ; load 1bpp font and frame, hide window
pop af
@ -74,13 +74,13 @@ OpenText1bpp::
ret
_OpenAndCloseMenu_HDMATransferTilemapAndAttrmap::
HDMATransferTilemapAndAttrmap_OpenAndCloseMenu::
ldh a, [hOAMUpdate]
push af
ld a, $1
ldh [hOAMUpdate], a
farcall OpenAndCloseMenu_HDMATransferTilemapAndAttrmap
farcall _HDMATransferTilemapAndAttrmap_OpenAndCloseMenu
pop af
ldh [hOAMUpdate], a