mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08: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:
parent
9f835560d7
commit
2957bce0a9
@ -61,6 +61,7 @@ DEF NUM_FRAMES EQU const_value
|
|||||||
const_def
|
const_def
|
||||||
const FAST_TEXT_DELAY_F ; 0
|
const FAST_TEXT_DELAY_F ; 0
|
||||||
const TEXT_DELAY_F ; 1
|
const TEXT_DELAY_F ; 1
|
||||||
|
const TEXT_2BPP_F ; 2
|
||||||
|
|
||||||
; wGBPrinterBrightness::
|
; wGBPrinterBrightness::
|
||||||
DEF GBPRINTER_LIGHTEST EQU $00
|
DEF GBPRINTER_LIGHTEST EQU $00
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
#### Textboxes
|
#### Textboxes
|
||||||
|
|
||||||
- **Textbox1bpp**: TextboxBorder + TextboxPalette
|
- **Textbox1bpp**: TextboxBorder + TextboxAttributes1bpp
|
||||||
- **Textbox2bpp**: _OverworldTextbox + TextboxPalette
|
- **Textbox2bpp**: _OverworldTextbox + TextboxAttributes2bpp
|
||||||
- **SpeechTextbox1bpp**: Textbox1bpp with speech location and dimensions
|
- **SpeechTextbox1bpp**: Textbox1bpp with speech location and dimensions
|
||||||
- **SpeechTextbox2bpp**: Textbox2bpp with speech location and dimensions
|
- **SpeechTextbox2bpp**: Textbox2bpp with speech location and dimensions
|
||||||
- **ClearTextbox**: Clear the inside of a speech textbox (fill with " ")
|
- **ClearTextbox**: Clear the inside of a speech textbox (fill with " ")
|
||||||
@ -24,7 +24,7 @@
|
|||||||
- **PrintText1bpp**, **FarPrintText1bpp**: SpeechTextbox1bpp + UpdateSprites + ApplyTilemap + ClearTextbox + PrintTextboxText
|
- **PrintText1bpp**, **FarPrintText1bpp**: SpeechTextbox1bpp + UpdateSprites + ApplyTilemap + ClearTextbox + PrintTextboxText
|
||||||
- **PrintText2bpp**: SpeechTextbox2bpp + UpdateSprites + ApplyTilemap + ClearTextbox + PrintTextboxText
|
- **PrintText2bpp**: SpeechTextbox2bpp + UpdateSprites + ApplyTilemap + ClearTextbox + PrintTextboxText
|
||||||
- **MapTextbox**: ClearTextbox + redraw tile behind cursor + SafeUpdateSprites + disable OAM update + ApplyTilemap + PrintTextboxText + enable OAM update
|
- **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
|
- **MenuBox**: Calls Textbox1bpp or Textbox2bpp, depending on the value at wTextboxFlags[TEXT_2BPP_F], with menu location and dimensions.
|
||||||
|
|
||||||
#### Overworld map scrolling
|
#### Overworld map scrolling
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
StartMenu::
|
StartMenu::
|
||||||
call ClearMenuAndWindowData
|
call ClearMenuAndWindowData
|
||||||
|
|
||||||
|
ld hl, wTextboxFlags
|
||||||
|
res TEXT_2BPP_F, [hl]
|
||||||
|
|
||||||
ld de, SFX_MENU
|
ld de, SFX_MENU
|
||||||
call PlaySFX
|
call PlaySFX
|
||||||
|
|
||||||
@ -378,7 +381,7 @@ endr
|
|||||||
hlcoord 0, 13
|
hlcoord 0, 13
|
||||||
ld b, 3
|
ld b, 3
|
||||||
ld c, 8
|
ld c, 8
|
||||||
jp TextboxPalette
|
jp TextboxAttributes1bpp
|
||||||
|
|
||||||
.IsMenuAccountOn:
|
.IsMenuAccountOn:
|
||||||
ld a, [wOptions2]
|
ld a, [wOptions2]
|
||||||
|
@ -110,6 +110,8 @@ EnterMap:
|
|||||||
ld [wXYComparePointer], a
|
ld [wXYComparePointer], a
|
||||||
ld [wXYComparePointer + 1], a
|
ld [wXYComparePointer + 1], a
|
||||||
call SetUpFiveStepWildEncounterCooldown
|
call SetUpFiveStepWildEncounterCooldown
|
||||||
|
ld hl, wTextboxFlags
|
||||||
|
set TEXT_2BPP_F, [hl]
|
||||||
farcall RunMapSetupScript
|
farcall RunMapSetupScript
|
||||||
call DisableEvents
|
call DisableEvents
|
||||||
|
|
||||||
|
@ -2252,14 +2252,14 @@ UpdateObjectFrozen:
|
|||||||
call CheckObjectOnScreen
|
call CheckObjectOnScreen
|
||||||
jr c, SetFacing_Standing
|
jr c, SetFacing_Standing
|
||||||
call UpdateObjectTile
|
call UpdateObjectTile
|
||||||
farcall HandleFrozenObjectAction ; no need to farcall
|
call HandleFrozenObjectAction
|
||||||
xor a
|
xor a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
UpdateRespawnedObjectFrozen:
|
UpdateRespawnedObjectFrozen:
|
||||||
call CheckObjectOnScreen
|
call CheckObjectOnScreen
|
||||||
jr c, SetFacing_Standing
|
jr c, SetFacing_Standing
|
||||||
farcall HandleFrozenObjectAction ; no need to farcall
|
call HandleFrozenObjectAction
|
||||||
xor a
|
xor a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -2283,7 +2283,7 @@ UpdateObjectTile:
|
|||||||
ld hl, OBJECT_TILE
|
ld hl, OBJECT_TILE
|
||||||
add hl, bc
|
add hl, bc
|
||||||
ld [hl], a
|
ld [hl], a
|
||||||
farcall UpdateTallGrassFlags ; no need to farcall
|
call UpdateTallGrassFlags
|
||||||
ret
|
ret
|
||||||
|
|
||||||
CheckObjectOnScreen:
|
CheckObjectOnScreen:
|
||||||
@ -2332,7 +2332,7 @@ CheckObjectCoveredByTextbox:
|
|||||||
cp $f0
|
cp $f0
|
||||||
jr nc, .ok1
|
jr nc, .ok1
|
||||||
cp SCREEN_WIDTH_PX
|
cp SCREEN_WIDTH_PX
|
||||||
jp nc, .nope
|
jp nc, .disappear
|
||||||
.ok1
|
.ok1
|
||||||
; Account for objects currently moving left/right.
|
; Account for objects currently moving left/right.
|
||||||
and %00000111
|
and %00000111
|
||||||
@ -2365,7 +2365,7 @@ CheckObjectCoveredByTextbox:
|
|||||||
cp $f0
|
cp $f0
|
||||||
jr nc, .ok4
|
jr nc, .ok4
|
||||||
cp SCREEN_HEIGHT_PX
|
cp SCREEN_HEIGHT_PX
|
||||||
jr nc, .nope
|
jr nc, .disappear
|
||||||
.ok4
|
.ok4
|
||||||
; Account for objects currently moving up/down.
|
; Account for objects currently moving up/down.
|
||||||
and %00000111
|
and %00000111
|
||||||
@ -2419,23 +2419,50 @@ CheckObjectCoveredByTextbox:
|
|||||||
push bc
|
push bc
|
||||||
call Coord2Tile
|
call Coord2Tile
|
||||||
pop bc
|
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.
|
; 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]
|
ld a, [hl]
|
||||||
cp FIRST_REGULAR_TEXT_CHAR
|
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
|
.ok8
|
||||||
dec d
|
dec d
|
||||||
jr nz, .next
|
jr nz, .next
|
||||||
.ok9
|
.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
|
dec e
|
||||||
|
ld a, e
|
||||||
|
cp $ff
|
||||||
jr nz, .loop
|
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
|
ret
|
||||||
|
|
||||||
.nope
|
.not_disappear
|
||||||
scf
|
and a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
HandleNPCStep::
|
HandleNPCStep::
|
||||||
@ -2584,7 +2611,7 @@ ResetFollower:
|
|||||||
cp -1
|
cp -1
|
||||||
ret z
|
ret z
|
||||||
call GetObjectStruct
|
call GetObjectStruct
|
||||||
farcall ResetObject ; no need to farcall
|
call ResetObject
|
||||||
ld a, -1
|
ld a, -1
|
||||||
ld [wObjectFollow_Follower], a
|
ld [wObjectFollow_Follower], a
|
||||||
ret
|
ret
|
||||||
|
@ -383,8 +383,6 @@ Script_promptbutton:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
Script_yesorno:
|
Script_yesorno:
|
||||||
ld a, TRUE
|
|
||||||
ld [wMenuBoxUse2bppFrame], a
|
|
||||||
call YesNoBox
|
call YesNoBox
|
||||||
ld a, FALSE
|
ld a, FALSE
|
||||||
jr c, .no
|
jr c, .no
|
||||||
@ -425,8 +423,6 @@ Script_closepokepic:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
Script_verticalmenu:
|
Script_verticalmenu:
|
||||||
ld a, TRUE
|
|
||||||
ld [wMenuBoxUse2bppFrame], a
|
|
||||||
ld a, [wScriptBank]
|
ld a, [wScriptBank]
|
||||||
ld hl, VerticalMenu
|
ld hl, VerticalMenu
|
||||||
rst FarCall
|
rst FarCall
|
||||||
@ -438,8 +434,6 @@ Script_verticalmenu:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
Script__2dmenu:
|
Script__2dmenu:
|
||||||
ld a, TRUE
|
|
||||||
ld [wMenuBoxUse2bppFrame], a
|
|
||||||
ld a, [wScriptBank]
|
ld a, [wScriptBank]
|
||||||
ld hl, _2DMenu
|
ld hl, _2DMenu
|
||||||
rst FarCall
|
rst FarCall
|
||||||
|
@ -209,8 +209,8 @@ MenuBox::
|
|||||||
call GetMenuBoxDims
|
call GetMenuBoxDims
|
||||||
dec b
|
dec b
|
||||||
dec c
|
dec c
|
||||||
ld a, [wMenuBoxUse2bppFrame]
|
ld a, [wTextboxFlags]
|
||||||
and a
|
bit TEXT_2BPP_F, a
|
||||||
jp z, Textbox1bpp
|
jp z, Textbox1bpp
|
||||||
ld d, h
|
ld d, h
|
||||||
ld e, l
|
ld e, l
|
||||||
|
@ -72,7 +72,7 @@ Textbox1bpp::
|
|||||||
call TextboxBorder
|
call TextboxBorder
|
||||||
pop hl
|
pop hl
|
||||||
pop bc
|
pop bc
|
||||||
jr TextboxPalette
|
jr TextboxAttributes1bpp
|
||||||
|
|
||||||
TextboxBorder::
|
TextboxBorder::
|
||||||
; Top
|
; Top
|
||||||
@ -120,15 +120,23 @@ TextboxBorder::
|
|||||||
jr nz, .loop
|
jr nz, .loop
|
||||||
ret
|
ret
|
||||||
|
|
||||||
TextboxPalette::
|
TextboxAttributes1bpp::
|
||||||
; Fill text box width c height b at hl with pal 7
|
; Fill text box width c height b at hl with PAL_BG_TEXT
|
||||||
|
ld a, PAL_BG_TEXT
|
||||||
|
jr _TextboxAttributes
|
||||||
|
|
||||||
|
TextboxAttributes2bpp::
|
||||||
|
; Fill text box width c height b at hl with PAL_BG_TEXT | PRIORITY
|
||||||
|
ld a, PAL_BG_TEXT | PRIORITY
|
||||||
|
; fallthrough
|
||||||
|
|
||||||
|
_TextboxAttributes:
|
||||||
ld de, wAttrmap - wTilemap
|
ld de, wAttrmap - wTilemap
|
||||||
add hl, de
|
add hl, de
|
||||||
inc b
|
inc b
|
||||||
inc b
|
inc b
|
||||||
inc c
|
inc c
|
||||||
inc c
|
inc c
|
||||||
ld a, PAL_BG_TEXT
|
|
||||||
.col
|
.col
|
||||||
push bc
|
push bc
|
||||||
push hl
|
push hl
|
||||||
@ -155,7 +163,7 @@ Textbox2bpp::
|
|||||||
farcall _OverworldTextbox
|
farcall _OverworldTextbox
|
||||||
pop hl
|
pop hl
|
||||||
pop bc
|
pop bc
|
||||||
jp TextboxPalette
|
jp TextboxAttributes2bpp
|
||||||
|
|
||||||
RadioTerminator::
|
RadioTerminator::
|
||||||
ld hl, .stop
|
ld hl, .stop
|
||||||
|
@ -46,6 +46,9 @@ OpenText2bpp::
|
|||||||
ld a, BANK(ReanchorBGMap_NoOAMUpdate)
|
ld a, BANK(ReanchorBGMap_NoOAMUpdate)
|
||||||
rst Bankswitch
|
rst Bankswitch
|
||||||
|
|
||||||
|
ld hl, wTextboxFlags
|
||||||
|
set TEXT_2BPP_F, [hl]
|
||||||
|
|
||||||
; assumes that the overworld 2bpp font and frame are loaded when calling this
|
; assumes that the overworld 2bpp font and frame are loaded when calling this
|
||||||
call ReanchorBGMap_NoOAMUpdate ; anchor bgmap
|
call ReanchorBGMap_NoOAMUpdate ; anchor bgmap
|
||||||
call SpeechTextbox2bpp
|
call SpeechTextbox2bpp
|
||||||
@ -64,6 +67,9 @@ OpenText1bpp::
|
|||||||
ld a, BANK(ReanchorBGMap_NoOAMUpdate) ; aka BANK(LoadFont_NoOAMUpdate)
|
ld a, BANK(ReanchorBGMap_NoOAMUpdate) ; aka BANK(LoadFont_NoOAMUpdate)
|
||||||
rst Bankswitch
|
rst Bankswitch
|
||||||
|
|
||||||
|
ld hl, wTextboxFlags
|
||||||
|
res TEXT_2BPP_F, [hl]
|
||||||
|
|
||||||
call ReanchorBGMap_NoOAMUpdate ; anchor bgmap
|
call ReanchorBGMap_NoOAMUpdate ; anchor bgmap
|
||||||
call SpeechTextbox1bpp
|
call SpeechTextbox1bpp
|
||||||
call HDMATransferTilemapAndAttrmap_OpenAndCloseMenu ; transfer bgmap
|
call HDMATransferTilemapAndAttrmap_OpenAndCloseMenu ; transfer bgmap
|
||||||
|
@ -1192,8 +1192,7 @@ wMenuCursorY:: db
|
|||||||
wMenuCursorX:: db
|
wMenuCursorX:: db
|
||||||
wCursorOffCharacter:: db
|
wCursorOffCharacter:: db
|
||||||
wCursorCurrentTile:: dw
|
wCursorCurrentTile:: dw
|
||||||
wMenuBoxUse2bppFrame:: db
|
ds 3
|
||||||
ds 2
|
|
||||||
wMoreMenuDataEnd::
|
wMoreMenuDataEnd::
|
||||||
|
|
||||||
wOverworldDelay:: db
|
wOverworldDelay:: db
|
||||||
@ -1253,7 +1252,8 @@ wTextboxFrame::
|
|||||||
db
|
db
|
||||||
wTextboxFlags::
|
wTextboxFlags::
|
||||||
; bit 0: 1-frame text delay
|
; bit 0: 1-frame text delay
|
||||||
; bit 4: no text delay
|
; bit 1: no text delay
|
||||||
|
; bit 2: 2bpp textbox (and text)
|
||||||
db
|
db
|
||||||
wGBPrinterBrightness::
|
wGBPrinterBrightness::
|
||||||
; bit 0-6: brightness
|
; bit 0-6: brightness
|
||||||
|
Loading…
Reference in New Issue
Block a user