Merge pull request #325 from zladx/tileset-commands

This commit is contained in:
Pierre de La Morinerie 2020-11-18 22:28:35 +01:00 committed by GitHub
commit 9d144979fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 106 additions and 72 deletions

View File

@ -977,17 +977,17 @@ label_D15::
ld a, TRANSCIENT_VFX_SWORD_POKE ; $0D19: $3E $05
jp AddTranscientVfx ; $0D1B: $C3 $C7 $0C
; Schedule the loading of the tilesets for the next room,
; Schedule the loading of object and OAM tilesets for the next room,
; (either during a map transition or a room transition).
;
; Actual loading will be done during the next vblank period.
LoadRoomTiles::
SelectRoomTilesets::
ld a, BANK(TilesetTables) ; $0D1E: $3E $20
ld [MBC3SelectBank], a ; $0D20: $EA $00 $21
; ------------------------------------------------------------
;
; Load Background tileset
; Select the new BG objects tileset
;
; ------------------------------------------------------------
@ -1104,7 +1104,7 @@ LoadRoomTiles::
; ------------------------------------------------------------
;
; Select Sprites tileset
; Select the new OAM tileset
; Main theme is data_020_70D3. Final subset is selected by the room/scene
; TODO: multible iterations of commenting needed. This code is total spagetti.
;
@ -4484,7 +4484,7 @@ GetObjectPhysicsFlagsAndRestoreBank3::
pop af ; $2A35: $F1
ret ; $2A36: $C9
LoadTileset1E::
LoadCreditsKoholintDisappearingTiles::
ld a, BANK(EndingTiles) ; $2A37: $3E $13
call AdjustBankNumberForGBC ; $2A39: $CD $0B $0B
ld [MBC3SelectBank], a ; $2A3C: $EA $00 $21
@ -4499,8 +4499,10 @@ LoadTileset1E::
ld bc, TILE_SIZE * $80 ; $2A51: $01 $00 $08
jp CopyData ; $2A54: $C3 $14 $29
LoadTileset1F::
; Copy tiles for the stairs sequence of credits to tiles memory
LoadCreditsStairsTiles::
call LoadTileset15 ; $2A57: $CD $66 $2A
ld de, vTiles0 + $400 ; $2A5A: $11 $00 $84
ld hl, EndingTiles + $3600 ; $2A5D: $21 $00 $76
ld bc, TILE_SIZE * $10 ; $2A60: $01 $00 $01
@ -4537,7 +4539,9 @@ LoadTileset15::
ld bc, TILE_SIZE * $20 ; $2AA8: $01 $00 $02
jp CopyData ; $2AAB: $C3 $14 $29
LoadTileset1D::
; Copy tiles for the various Koholint views while the instruments are
; playing to tiles memory
LoadCreditsKoholintViewsTiles::
ld a, BANK(Overworld1Tiles) ; $2AAE: $3E $0C
call AdjustBankNumberForGBC ; $2AB0: $CD $0B $0B
ld [MBC3SelectBank], a ; $2AB3: $EA $00 $21
@ -4550,7 +4554,7 @@ LoadTileset1D::
call AdjustBankNumberForGBC ; $2AC4: $CD $0B $0B
ld [MBC3SelectBank], a ; $2AC7: $EA $00 $21
ld hl, Npc3Tiles + $2000 ; $2ACA: $21 $00 $60
ld de, $8000 ; $2ACD: $11 $00 $80
ld de, vTiles0 ; $2ACD: $11 $00 $80
ld bc, TILE_SIZE * $80 ; $2AD0: $01 $00 $08
call CopyData ; $2AD3: $CD $14 $29
@ -4558,11 +4562,11 @@ LoadTileset1D::
call AdjustBankNumberForGBC ; $2AD8: $CD $0B $0B
ld [MBC3SelectBank], a ; $2ADB: $EA $00 $21
ld hl, Overworld2Tiles + $600 ; $2ADE: $21 $00 $60
ld de, $8800 ; $2AE1: $11 $00 $88
ld de, vTiles1 ; $2AE1: $11 $00 $88
ld bc, TILE_SIZE * $80 ; $2AE4: $01 $00 $08
jp CopyData ; $2AE7: $C3 $14 $29
LoadTileset18::
LoadCreditsLinkOnSeaCloseTiles::
ld hl, EndingTiles ; $2AEA: $21 $00 $40
ldh a, [hIsGBC] ; $2AED: $F0 $FE
and a ; $2AEF: $A7
@ -4571,11 +4575,11 @@ LoadTileset18::
ld a, BANK(PhotoAlbumTiles) ; $2AF5: $3E $35
jr label_2B06 ; $2AF7: $18 $0D
LoadTileset17::
LoadCreditsSunAboveTiles::
ld hl, EndingTiles + $800 ; $2AF9: $21 $00 $48
jr label_2B01 ; $2AFC: $18 $03
LoadTileset16::
LoadCreditsLinkOnSeaLargeTiles::
ld hl, EndingTiles + $2000 ; $2AFE: $21 $00 $60
label_2B01::
@ -4596,7 +4600,7 @@ label_2B06::
ld bc, TILE_SIZE * $100 ; $2B20: $01 $00 $10
jp CopyData ; $2B23: $C3 $14 $29
LoadTileset1B::
LoadCreditsRollTiles::
call PlayAudioStep ; $2B26: $CD $A4 $08
ld hl, FontLargeTiles + $100 ; $2B29: $21 $00 $68
@ -4668,7 +4672,7 @@ ELSE
jp CopyData ; $2B6F: $C3 $14 $29
ENDC
LoadTileset1A::
LoadCreditsLinkFaceCloseUpTiles::
ld hl, EndingTiles + $3800 ; $2B72: $21 $00 $78
ldh a, [hIsGBC] ; $2B75: $F0 $FE
and a ; $2B77: $A7
@ -4677,7 +4681,7 @@ LoadTileset1A::
ld a, BANK(EndingCGBAltTiles) ; $2B7D: $3E $35
jr label_2B95 ; $2B7F: $18 $14
LoadTileset19::
LoadCreditsLinkSeatedOnLogTiles::
ld hl, EndingTiles + $800 ; $2B81: $21 $00 $48
ldh a, [hIsGBC] ; $2B84: $F0 $FE
and a ; $2B86: $A7
@ -4996,7 +5000,7 @@ func_2D50::
call CopyData ; $2D75: $CD $14 $29
ret ; $2D78: $C9
; Load Map n°10 (introduction sequence)
; Copy opening sequence tiles to tiles memory
LoadIntroSequenceTiles::
; Load rain tiles
ld a, BANK(IntroRainTiles) ; $2D79: $3E $01
@ -5020,6 +5024,7 @@ LoadIntroSequenceTiles::
ld bc, TILE_SIZE * $100 ; $2DA1: $01 $00 $10
jp CopyData ; $2DA4: $C3 $14 $29
; Copy title screen tiles to tiles memory
LoadTitleScreenTiles::
; Load title logo
ld a, BANK(TitleLogoTitles) ; $2DA7: $3E $0F
@ -5061,7 +5066,8 @@ LoadTitleScreenTiles::
ld bc, TILE_SIZE * $10 ; $2DE3: $01 $00 $01
jp CopyData ; $2DE6: $C3 $14 $29
LoadWorldMinimapTiles::
; Copy tiles for the World Map to tiles memory
LoadWorldMapTiles::
; Load world map tiles
ld a, BANK(WorldMapTiles) ; $2DE9: $3E $0C
call SwitchAdjustedBank ; $2DEB: $CD $13 $08
@ -5070,25 +5076,29 @@ LoadWorldMinimapTiles::
ld bc, TILE_SIZE * $80 ; $2DF4: $01 $00 $08
call CopyData ; $2DF7: $CD $14 $29
; Load some overworld tiles
; Load some overworld objects tiles (house, owl, etc),
; to display them when the cursor hovers a specific room.
ld hl, Overworld1Tiles + $100 ; $2DFA: $21 $00 $50
ld de, vTiles0 + $200 ; $2DFD: $11 $00 $82
ld bc, TILE_SIZE * $10 ; $2E00: $01 $00 $01
jp CopyData ; $2E03: $C3 $14 $29
; Copy tiles for Face Shrine mural to tiles memory
LoadFaceShrineReliefTiles::
ld hl, ReliefTiles ; $2E06: $21 $00 $70
jr LoadStaticPictureTiles ; $2E09: $18 $08
; Copy tiles for the Schule painting to tiles memory
LoadSchulePaintingTiles::
ld hl, PaintingTiles ; $2E0B: $21 $00 $78
jr LoadStaticPictureTiles ; $2E0E: $18 $03
; Copy tiles for Christine portrait to tiles memory
LoadChristinePortraitTiles::
ld hl, ChristineTiles ; $2E10: $21 $00 $58
; fallthrough
; Load tiles for a static full-screen picture to vTiles2
; Copy tiles for a static full-screen picture to vTiles2
; Inputs:
; hl tiles source address
LoadStaticPictureTiles::
@ -5112,7 +5122,8 @@ LoadEaglesTowerTopTiles::
ld bc, TILE_SIZE * $40 ; $2E3B: $01 $00 $04
jp CopyData ; $2E3E: $C3 $14 $29
LoadTileset13::
; Copy tiles for Marin's beach sequence to tiles memory
LoadMarinBeachTiles::
ld a, BANK(FontLargeTiles) ; $2E41: $3E $10
call SwitchAdjustedBank ; $2E43: $CD $13 $08
@ -5126,7 +5137,7 @@ LoadTileset13::
ld bc, TILE_SIZE * $60 ; $2E58: $01 $00 $06
jp CopyData ; $2E5B: $C3 $14 $29
; Tiles for Saving and Game Over screens
; Copy tiles for Saving and Game Over screens to tiles memory
LoadSaveMenuTiles::
ld a, BANK(SaveMenuTiles) ; $2E5E: $3E $0F
call SwitchBank ; $2E60: $CD $0C $08
@ -5139,9 +5150,12 @@ LoadSaveMenuTiles::
NpcTilesBankTable::
db $00, BANK(Npc2Tiles), BANK(Npc1Tiles), BANK(Npc3Tiles) ; $2E6F
; For overworld or indoor rooms, load lower section of OAM tiles (NPCs),
; and upper section of BG tiles.
LoadWorldTiles::
; For overworld or indoor rooms, load room-specific tiles.
;
; That means:
; - the lower section of OAM tiles (NPCs),
; - the upper section of BG tiles.
LoadRoomSpecificTiles::
ldh a, [hMapId] ; $2E73: $F0 $F7
cp MAP_COLOR_DUNGEON ; $2E75: $FE $FF
jr nz, .colorDungeonEnd ; $2E77: $20 $0B
@ -7384,8 +7398,8 @@ LoadRoomTemplate_trampoline::
ld [MBC3SelectBank], a ; $38F8: $EA $00 $21
ret ; $38FB: $C9
LoadTileset0E_trampoline::
callsb LoadTileset0E ; $38FC: $3E $20 $EA $00 $21 $CD $8B $58
LoadWorldMapBGMap_trampoline::
callsb LoadWorldMapBGMap ; $38FC: $3E $20 $EA $00 $21 $CD $8B $58
ret ; $3904: $C9
SwitchToMapDataBank::
@ -7402,11 +7416,11 @@ SwitchToMapDataBank::
ld [MBC3SelectBank], a ; $3911: $EA $00 $21
ret ; $3914: $C9
LoadTileset22_trampoline::
jpsb LoadTileset22 ; $3915: $3E $27 $EA $00 $21 $C3 $C5 $7F
LoadCreditsMarinPortraitTiles_trampoline::
jpsb LoadCreditsMarinPortraitTiles ; $3915: $3E $27 $EA $00 $21 $C3 $C5 $7F
LoadTileset23_trampoline::
jpsb LoadTileset23 ; $391D: $3E $20 $EA $00 $21 $C3 $E6 $7D
LoadThanksForPlayingTiles_trampoline::
jpsb LoadThanksForPlayingTiles ; $391D: $3E $20 $EA $00 $21 $C3 $E6 $7D
include "code/home/entities.asm"

View File

@ -2922,44 +2922,50 @@ PadRoomObjectsArea::
.end
ret ; $6CE2: $C9
; Fade from white?
;
; Used when:
; - Displaying a menu
; - Displaying a static picture (peach, eagle's tower collapse)
LoadTileset0F::
ld bc, $400 ; $6CE3: $01 $00 $04
ld hl, $9800 ; $6CE6: $21 $00 $98
ld hl, vBGMap0 ; $6CE6: $21 $00 $98
jr_001_6CE9::
.loop
ld e, $00 ; $6CE9: $1E $00
ld a, l ; $6CEB: $7D
and $20 ; $6CEC: $E6 $20
jr z, jr_001_6CF1 ; $6CEE: $28 $01
jr z, .jr_001_6CF1 ; $6CEE: $28 $01
inc e ; $6CF0: $1C
jr_001_6CF1::
.jr_001_6CF1
ld d, $AE ; $6CF1: $16 $AE
ld a, l ; $6CF3: $7D
and $01 ; $6CF4: $E6 $01
xor e ; $6CF6: $AB
jr z, jr_001_6CFA ; $6CF7: $28 $01
jr z, .jr_001_6CFA ; $6CF7: $28 $01
inc d ; $6CF9: $14
jr_001_6CFA::
.jr_001_6CFA
ld a, l ; $6CFA: $7D
and $1F ; $6CFB: $E6 $1F
cp $14 ; $6CFD: $FE $14
jr nc, jr_001_6D02 ; $6CFF: $30 $01
jr nc, .jr_001_6D02 ; $6CFF: $30 $01
ld [hl], d ; $6D01: $72
jr_001_6D02::
.jr_001_6D02
inc hl ; $6D02: $23
dec bc ; $6D03: $0B
ld a, b ; $6D04: $78
or c ; $6D05: $B1
jr nz, jr_001_6CE9 ; $6D06: $20 $E1
jr nz, .loop ; $6D06: $20 $E1
ldh a, [hIsGBC] ; $6D08: $F0 $FE
and a ; $6D0A: $A7
jr z, jr_001_6D10 ; $6D0B: $28 $03
jr z, .jr_001_6D10 ; $6D0B: $28 $03
call func_001_6D11 ; $6D0D: $CD $11 $6D
jr_001_6D10::
.jr_001_6D10
ret ; $6D10: $C9
func_001_6D11::
@ -2972,7 +2978,7 @@ func_001_6D11::
jr_001_6D1C::
ld a, $01 ; $6D1C: $3E $01
ld [rVBK], a ; $6D1E: $E0 $4F
ld hl, $9800 ; $6D20: $21 $00 $98
ld hl, vBGMap0 ; $6D20: $21 $00 $98
ld bc, $400 ; $6D23: $01 $00 $04
jr_001_6D26::

View File

@ -247,33 +247,33 @@ TilemapLoadingHandlersTable::
._06 dw LoadIndoorTiles
._07 dw LoadBaseOverworldTiles ; same as command $05
._08 dw FillBGMapWith7E
._09 dw LoadWorldTiles
._09 dw LoadRoomSpecificTiles
._0A dw LoadMapData.return
._0B dw LoadWorldMinimapTiles
._0B dw LoadWorldMapTiles
._0C dw LoadMapData.return
._0D dw LoadSaveMenuTiles
._0E dw LoadTileset0E_trampoline
._0F dw LoadTileset0F_trampoline
._0E dw LoadWorldMapBGMap_trampoline
._0F dw LoadTileset0F_trampoline ; fade from white? used in menus
._10 dw LoadIntroSequenceTiles
._11 dw LoadTitleScreenTiles
._12 dw LoadChristinePortraitTiles
._13 dw LoadTileset13
._13 dw LoadMarinBeachTiles
._14 dw LoadFaceShrineReliefTiles
._15 dw LoadTileset15
._16 dw LoadTileset16
._17 dw LoadTileset17
._18 dw LoadTileset18
._19 dw LoadTileset19
._1A dw LoadTileset1A
._1B dw LoadTileset1B
._1C dw LoadTileset1A
._1D dw LoadTileset1D
._1E dw LoadTileset1E
._1F dw LoadTileset1F
._16 dw LoadCreditsLinkOnSeaLargeTiles
._17 dw LoadCreditsSunAboveTiles
._18 dw LoadCreditsLinkOnSeaCloseTiles
._19 dw LoadCreditsLinkSeatedOnLogTiles
._1A dw LoadCreditsLinkFaceCloseUpTiles
._1B dw LoadCreditsRollTiles
._1C dw LoadCreditsLinkFaceCloseUpTiles
._1D dw LoadCreditsKoholintViewsTiles
._1E dw LoadCreditsKoholintDisappearingTiles
._1F dw LoadCreditsStairsTiles
._20 dw LoadSchulePaintingTiles
._21 dw LoadEaglesTowerTopTiles
._22 dw LoadTileset22_trampoline
._23 dw LoadTileset23_trampoline
._22 dw LoadCreditsMarinPortraitTiles_trampoline
._23 dw LoadThanksForPlayingTiles_trampoline
data_020_46AA::
db HIGH(ColorDungeonNpcTiles + $1100), BANK(ColorDungeonNpcTiles)
@ -2228,7 +2228,8 @@ Data_020_578B::
db $04, $04, $04, $04, $04, $04, $07, $00 ; $587B
db $04, $04, $00, $00, $00, $00, $03, $03 ; $5883
LoadTileset0E::
; Copy the World Map tilemap to BG memory
LoadWorldMapBGMap::
ld a, LOW(Data_20_568B) ; $588B: $3E $8B
ldh [hMultiPurposeA], a ; $588D: $E0 $E1
ld a, HIGH(Data_20_568B) ; $588F: $3E $56
@ -6226,7 +6227,8 @@ jr_020_7DCB:
ret ; $7DE5: $C9
LoadTileset23::
; Copy tiles for the Credits "Thanks for playing" message to tiles memory
LoadThanksForPlayingTiles::
ld c, HIGH(vTiles0 + $1000 - $8000) ; dest ; $7DE6: $0E $10
ld b, HIGH(ThanksForPlayingTiles) ; src ; $7DE8: $06 $68
ld a, BANK(ThanksForPlayingTiles) ; src bank ; $7DEA: $3E $38

View File

@ -1066,11 +1066,13 @@ MarinPortraitTilesTable::
._02 db HIGH(MarinPortraitTiles + $200), BANK(MarinPortraitTiles)
._03 db HIGH(MarinPortraitOverlayTiles + $000), BANK(MarinPortraitOverlayTiles)
._04 db HIGH(MarinPortraitOverlayTiles + $100), BANK(MarinPortraitOverlayTiles)
._05 db HIGH(PhotoAlbumTiles + $700), BANK(PhotoAlbumTiles)
._05 db HIGH(PhotoAlbumTiles + $700), BANK(PhotoAlbumTiles)
; Copy data from a source specified in the table
; to a destination in VRAM specified by wD01A
LoadTileset22::
; Copy tiles of Marin's portrait to tiles memory, in several steps.
;
; Inputs:
; wD01A: copy step (from 0 to 5)
LoadCreditsMarinPortraitTiles::
; Destination address higher byte
ld a, [wD01A] ; $7FC5: $FA $1A $D0
cp $05 ; $7FC8: $FE $05

View File

@ -2043,7 +2043,7 @@ jr_017_55FC:
; Handles:
; - the fade-to-white of Link on the stairs
; - the various views ok Koholint
; - the various views of Koholint
; - the island disappearing
; - link's platform rumbling
CreditsInstrumentsPlayingHandler::
@ -2106,10 +2106,13 @@ func_017_5665::
ld a, $1D ; $5676: $3E $1D
ld [wTileMapToLoad], a ; $5678: $EA $FE $D6
ld a, $01 ; $567B: $3E $01
ld [wPaletteUnknownE], a ; $567D: $EA $D5 $DD
xor a ; $5680: $AF
ldh [hBaseScrollY], a ; $5681: $E0 $97
call DisableAllEntities ; $5683: $CD $2A $56
jp IncrementD000AndReturn ; $5686: $C3 $25 $56
@ -2489,6 +2492,7 @@ func_017_58C3::
jr_017_58D0:
ret ; $58D0: $C9
; Load koholint island disapearing GFX
func_017_58D1::
ld a, [wD006] ; $58D1: $FA $06 $D0
and a ; $58D4: $A7
@ -2500,8 +2504,10 @@ func_017_58D1::
ld a, $1E ; $58DF: $3E $1E
ld [wTileMapToLoad], a ; $58E1: $EA $FE $D6
ld a, $01 ; $58E4: $3E $01
ld [wPaletteUnknownE], a ; $58E6: $EA $D5 $DD
call DisableAllEntities ; $58E9: $CD $2A $56
jp IncrementD000AndReturn ; $58EC: $C3 $25 $56
@ -2736,8 +2742,10 @@ func_017_5A66::
ld [wScreenShakeHorizontal], a ; $5A7E: $EA $55 $C1
ld a, LINK_ANIMATION_STATE_STANDING_DOWN ; $5A81: $3E $00
ldh [hLinkAnimationState], a ; $5A83: $E0 $9D
ld a, $15 ; $5A85: $3E $15
ld [wTileMapToLoad], a ; $5A87: $EA $FE $D6
xor a ; $5A8A: $AF
ld [wPaletteUnknownE], a ; $5A8B: $EA $D5 $DD
ld a, $E8 ; $5A8E: $3E $E8
@ -3324,6 +3332,7 @@ CreditsSunAboveHandler::
CreditsSunAbove0Handler::
ld a, $17 ; $6129: $3E $17
ld [wTileMapToLoad], a ; $612B: $EA $FE $D6
ld a, $01 ; $612E: $3E $01
ld [wPaletteUnknownE], a ; $6130: $EA $D5 $DD
xor a ; $6133: $AF

View File

@ -568,7 +568,7 @@ IncrementRoomTransitionStateAndReturn::
ret ; $7B3D: $C9
RoomTransitionLoadTiles::
call LoadRoomTiles ; $7B3E: $CD $1E $0D
call SelectRoomTilesets ; $7B3E: $CD $1E $0D
; If room has mobile blocks…
ld a, [wRoomSwitchableObject] ; $7B41: $FA $FA $D6

View File

@ -232,7 +232,7 @@ GameplayWorldSubtype2Handler::
ei ; $44C8: $FB
jr_001_44C9::
call LoadRoomTiles ; $44C9: $CD $1E $0D
call SelectRoomTilesets ; $44C9: $CD $1E $0D
xor a ; $44CC: $AF
ldh [hNeedsUpdatingBGTiles], a ; $44CD: $E0 $90
ldh [hNeedsUpdatingEnnemiesTiles], a ; $44CF: $E0 $91

View File

@ -23,7 +23,7 @@ GAMEPLAY_FILE_DELETE equ $04
GAMEPLAY_FILE_COPY equ $05
GAMEPLAY_FILE_SAVE equ $06
GAMEPLAY_WORLD_MAP equ $07
GAMEPLAY_PEACH_PIC equ $08
GAMEPLAY_PEACH_PIC equ $08 ; also used for the Eagle's Tower collapse cutscene
GAMEPLAY_MARIN_BEACH equ $09
GAMEPLAY_WF_MURAL equ $0A
GAMEPLAY_WORLD equ $0B
@ -213,7 +213,7 @@ LINK_ANIMATION_STATE_MOVING_SWIMMING_1_RIGHT equ $47
LINK_ANIMATION_STATE_HOLD_SWIMMING_1_LEFT equ $48
LINK_ANIMATION_STATE_MOVING_SWIMMING_1_LEFT equ $49
LINK_ANIMATION_STATE_HOLD_SWIMMING_1_UP equ $4A
LINK_ANIMATION_STATE_MOVING_SWIMMING_1_UP equ $4B
LINK_ANIMATION_STATE_MOVING_SWIMMING_1_UP equ $4B
LINK_ANIMATION_STATE_HOLD_SWIMMING_1_DOWN equ $4C
LINK_ANIMATION_STATE_MOVING_SWIMMING_1_DOWN equ $4D
LINK_ANIMATION_STATE_HOLD_SWIMMING_2 equ $4E
@ -351,7 +351,7 @@ ONE_HEART equ $08
LOW_MAX_HEALTH equ $07
MEDIUM_MAX_HEALTH equ $0B
;HIGH_MAX_HEALTH equ
;HIGH_MAX_HEALTH equ
; how much time has to pass until the player can receive damage again
DAMAGE_COOLDOWN_TIME equ $A0

View File

@ -2342,7 +2342,8 @@ wEnginePaused::
wLCDControl::
ds 1 ; D6FD
; TODO comment
; ID of a VRAM copying command that will be executed on next vblank.
; See possible values at TilemapLoadingHandlersTable
wTileMapToLoad::
ds 1 ; D6FE