You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
Don't hide sprites behind a 2BPP textbox if they are partially outside of it, and make 2BPP textboxes have priority over objects (#7); Generalize 1bpp/2bpp text state tracking (#10) [reworks 052d246e
]
This commit is contained in:
@@ -13,6 +13,9 @@
|
||||
StartMenu::
|
||||
call ClearMenuAndWindowData
|
||||
|
||||
ld hl, wTextboxFlags
|
||||
res TEXT_2BPP_F, [hl]
|
||||
|
||||
ld de, SFX_MENU
|
||||
call PlaySFX
|
||||
|
||||
@@ -378,7 +381,7 @@ endr
|
||||
hlcoord 0, 13
|
||||
ld b, 3
|
||||
ld c, 8
|
||||
jp TextboxPalette
|
||||
jp TextboxAttributes1bpp
|
||||
|
||||
.IsMenuAccountOn:
|
||||
ld a, [wOptions2]
|
||||
|
@@ -110,6 +110,8 @@ EnterMap:
|
||||
ld [wXYComparePointer], a
|
||||
ld [wXYComparePointer + 1], a
|
||||
call SetUpFiveStepWildEncounterCooldown
|
||||
ld hl, wTextboxFlags
|
||||
set TEXT_2BPP_F, [hl]
|
||||
farcall RunMapSetupScript
|
||||
call DisableEvents
|
||||
|
||||
|
@@ -2252,14 +2252,14 @@ UpdateObjectFrozen:
|
||||
call CheckObjectOnScreen
|
||||
jr c, SetFacing_Standing
|
||||
call UpdateObjectTile
|
||||
farcall HandleFrozenObjectAction ; no need to farcall
|
||||
call HandleFrozenObjectAction
|
||||
xor a
|
||||
ret
|
||||
|
||||
UpdateRespawnedObjectFrozen:
|
||||
call CheckObjectOnScreen
|
||||
jr c, SetFacing_Standing
|
||||
farcall HandleFrozenObjectAction ; no need to farcall
|
||||
call HandleFrozenObjectAction
|
||||
xor a
|
||||
ret
|
||||
|
||||
@@ -2283,7 +2283,7 @@ UpdateObjectTile:
|
||||
ld hl, OBJECT_TILE
|
||||
add hl, bc
|
||||
ld [hl], a
|
||||
farcall UpdateTallGrassFlags ; no need to farcall
|
||||
call UpdateTallGrassFlags
|
||||
ret
|
||||
|
||||
CheckObjectOnScreen:
|
||||
@@ -2332,7 +2332,7 @@ CheckObjectCoveredByTextbox:
|
||||
cp $f0
|
||||
jr nc, .ok1
|
||||
cp SCREEN_WIDTH_PX
|
||||
jp nc, .nope
|
||||
jp nc, .disappear
|
||||
.ok1
|
||||
; Account for objects currently moving left/right.
|
||||
and %00000111
|
||||
@@ -2365,7 +2365,7 @@ CheckObjectCoveredByTextbox:
|
||||
cp $f0
|
||||
jr nc, .ok4
|
||||
cp SCREEN_HEIGHT_PX
|
||||
jr nc, .nope
|
||||
jr nc, .disappear
|
||||
.ok4
|
||||
; Account for objects currently moving up/down.
|
||||
and %00000111
|
||||
@@ -2419,23 +2419,50 @@ CheckObjectCoveredByTextbox:
|
||||
push bc
|
||||
call Coord2Tile
|
||||
pop bc
|
||||
; NPCs disappear if standing on tile $60-$7f (or $e0-$ff),
|
||||
; NPCs disappear if standing on tiles FIRST_REGULAR_TEXT_CHAR or above,
|
||||
; since those IDs are for text characters and textbox frames.
|
||||
; - if 1bpp text, a single textbox tile overlapping with the sprite makes it disappear.
|
||||
; - if 2bpp text, sprite only disappears if ALL overlapping tiles are textbox tiles.
|
||||
ld a, [hl]
|
||||
cp FIRST_REGULAR_TEXT_CHAR
|
||||
jr nc, .nope
|
||||
jr c, .object_not_in_textbox
|
||||
|
||||
;.object_in_textbox
|
||||
ld a, [wTextboxFlags]
|
||||
bit TEXT_2BPP_F, a
|
||||
jr z, .disappear
|
||||
jr .ok8
|
||||
|
||||
.object_not_in_textbox
|
||||
ld a, [wTextboxFlags]
|
||||
bit TEXT_2BPP_F, a
|
||||
jr nz, .not_disappear
|
||||
|
||||
.ok8
|
||||
dec d
|
||||
jr nz, .next
|
||||
.ok9
|
||||
; while sprites are centered to tiles in the X axis exactly on top of two adjacent horizonal tiles,
|
||||
; in the Y axis they occupy 4-8-4 pixels of adjacent vertical tiles instead.
|
||||
; this is why we loop here one more time (thrice for regular-sized sprites) than horizontally.
|
||||
dec e
|
||||
ld a, e
|
||||
cp $ff
|
||||
jr nz, .loop
|
||||
|
||||
and a
|
||||
; if we managed make it here without returning early, there are only two options:
|
||||
; - if 1bpp text, the sprite is wholly outside of a textbox
|
||||
; - if 2bpp text, the sprite is wholly inside a textbox
|
||||
ld a, [wTextboxFlags]
|
||||
bit TEXT_2BPP_F, a
|
||||
jr z, .not_disappear
|
||||
|
||||
.disappear
|
||||
scf
|
||||
ret
|
||||
|
||||
.nope
|
||||
scf
|
||||
.not_disappear
|
||||
and a
|
||||
ret
|
||||
|
||||
HandleNPCStep::
|
||||
@@ -2584,7 +2611,7 @@ ResetFollower:
|
||||
cp -1
|
||||
ret z
|
||||
call GetObjectStruct
|
||||
farcall ResetObject ; no need to farcall
|
||||
call ResetObject
|
||||
ld a, -1
|
||||
ld [wObjectFollow_Follower], a
|
||||
ret
|
||||
|
@@ -383,8 +383,6 @@ Script_promptbutton:
|
||||
ret
|
||||
|
||||
Script_yesorno:
|
||||
ld a, TRUE
|
||||
ld [wMenuBoxUse2bppFrame], a
|
||||
call YesNoBox
|
||||
ld a, FALSE
|
||||
jr c, .no
|
||||
@@ -425,8 +423,6 @@ Script_closepokepic:
|
||||
ret
|
||||
|
||||
Script_verticalmenu:
|
||||
ld a, TRUE
|
||||
ld [wMenuBoxUse2bppFrame], a
|
||||
ld a, [wScriptBank]
|
||||
ld hl, VerticalMenu
|
||||
rst FarCall
|
||||
@@ -438,8 +434,6 @@ Script_verticalmenu:
|
||||
ret
|
||||
|
||||
Script__2dmenu:
|
||||
ld a, TRUE
|
||||
ld [wMenuBoxUse2bppFrame], a
|
||||
ld a, [wScriptBank]
|
||||
ld hl, _2DMenu
|
||||
rst FarCall
|
||||
|
Reference in New Issue
Block a user