Tiles can have different attributes in different blocks

This commit is contained in:
Zeta_Null 2023-09-13 12:44:30 -04:00
parent 94d9c77070
commit 820c2257bc
374 changed files with 554 additions and 348 deletions

View file

@ -90,8 +90,7 @@ GetMapSceneID::
ret
OverworldTextModeSwitch::
call LoadMapPart
jp SwapTextboxPalettes
; fallthrough
LoadMapPart::
ldh a, [hROMBank]
@ -105,6 +104,10 @@ LoadMapPart::
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call ByteFill
ld a, [wTilesetAttributesBank]
rst Bankswitch
call LoadMetatileAttributes
ld a, BANK(_LoadMapPart)
rst Bankswitch
@ -115,12 +118,27 @@ LoadMapPart::
ret
LoadMetatiles::
ld hl, wSurroundingTiles
ld de, wTilesetBlocksAddress
jr _LoadMetatilesOrAttributes
LoadMetatileAttributes::
ld hl, wSurroundingAttributes
ld de, wTilesetAttributesAddress
; fallthrough
_LoadMetatilesOrAttributes:
ld a, [de]
ld [wTilesetDataAddress], a
inc de
ld a, [de]
ld [wTilesetDataAddress + 1], a
; de <- wOverworldMapAnchor
ld a, [wOverworldMapAnchor]
ld e, a
ld a, [wOverworldMapAnchor + 1]
ld d, a
ld hl, wSurroundingTiles
ld b, SCREEN_META_HEIGHT
.row
@ -143,19 +161,23 @@ LoadMetatiles::
ld e, l
ld d, h
; Set hl to the address of the current metatile data ([wTilesetBlocksAddress] + (a) tiles).
; BUG: LoadMetatiles wraps around past 128 blocks (see docs/bugs_and_glitches.md)
add a
ld l, a
ld h, 0
add hl, hl
add hl, hl
add hl, hl
ld a, [wTilesetBlocksAddress]
add hl, hl
ld a, [wTilesetDataAddress]
add l
ld l, a
ld a, [wTilesetBlocksAddress + 1]
ld a, [wTilesetDataAddress + 1]
adc h
ld h, a
ldh a, [rSVBK]
push af
ld a, BANK("Surrounding Data")
ldh [rSVBK], a
; copy the 4x4 metatile
rept METATILE_WIDTH - 1
@ -176,6 +198,10 @@ rept METATILE_WIDTH
ld [de], a
inc de
endr
pop af
ldh [rSVBK], a
; Next metatile
pop hl
ld de, METATILE_WIDTH
@ -1143,8 +1169,9 @@ ScrollMapUp::
hlcoord 0, 0
ld de, wBGMapBuffer
call BackupBGMapRow
ld c, 2 * SCREEN_WIDTH
call ScrollBGMapPalettes
hlcoord 0, 0, wAttrmap
ld de, wBGMapPalBuffer
call BackupBGMapRow
ld a, [wBGMapAnchor]
ld e, a
ld a, [wBGMapAnchor + 1]
@ -1158,8 +1185,9 @@ ScrollMapDown::
hlcoord 0, SCREEN_HEIGHT - 2
ld de, wBGMapBuffer
call BackupBGMapRow
ld c, 2 * SCREEN_WIDTH
call ScrollBGMapPalettes
hlcoord 0, SCREEN_HEIGHT - 2, wAttrmap
ld de, wBGMapPalBuffer
call BackupBGMapRow
ld a, [wBGMapAnchor]
ld l, a
ld a, [wBGMapAnchor + 1]
@ -1181,8 +1209,9 @@ ScrollMapLeft::
hlcoord 0, 0
ld de, wBGMapBuffer
call BackupBGMapColumn
ld c, 2 * SCREEN_HEIGHT
call ScrollBGMapPalettes
hlcoord 0, 0, wAttrmap
ld de, wBGMapPalBuffer
call BackupBGMapColumn
ld a, [wBGMapAnchor]
ld e, a
ld a, [wBGMapAnchor + 1]
@ -1196,8 +1225,9 @@ ScrollMapRight::
hlcoord SCREEN_WIDTH - 2, 0
ld de, wBGMapBuffer
call BackupBGMapColumn
ld c, 2 * SCREEN_HEIGHT
call ScrollBGMapPalettes
hlcoord SCREEN_WIDTH - 2, 0, wAttrmap
ld de, wBGMapPalBuffer
call BackupBGMapColumn
ld a, [wBGMapAnchor]
ld e, a
and %11100000

View file

@ -319,11 +319,3 @@ ReloadSpritesNoPalettes::
ld a, TRUE
ldh [hCGBPalUpdate], a
jp DelayFrame
SwapTextboxPalettes::
homecall _SwapTextboxPalettes
ret
ScrollBGMapPalettes::
homecall _ScrollBGMapPalettes
ret