You are not logged in.
Pages: 1
What i'm trying to do is to open the start menu when going to a specific spot in the overworld, here's the code:
ld a, [wYCoord]
cp $6
ret nz
ld a, [wXCoord]
cp $3
ret nz
xor a
ld [hSCX], a
ld [hSCY], a
ld [hWY], a
inc a
ld [hAutoBGTransferEnabled], a
call LoadFontTilePatterns
call DisplayStartMenu
And it works pretty much as intended
What i don't understand is why i have to set the screen and window positioning to 0 before calling DisplayStartMenu from a script, whereas when i call it by pressing start hSCX, hSCY aren't set to 0
My final objective is to draw an image to a white screen, this one is just an exercise to see if i understand how it works
I also wonder if there's a better way to do it
Last edited by Ax461 (2017-12-24 14:29:57)
Offline
Interesting question!
There is actually a better way to do this.
Replace your snip of code with this:
ld a, [wYCoord]
cp $6
ret nz
ld a, [wXCoord]
cp $3
ret nz
xor a
ld [hSpriteIndexOrTextID],a
call DisplayTextID
Text ID 0 is a shortcut to display the start menu from the overworld
By simply loading the right tiles and calling DisplayStartMenu, you skip some other necessary initialization that is done by DisplayTextID
The only piece of initialization that you are missing is a call to DisplayTextIDInit, so you can also use this code:
ld a, [wYCoord]
cp $6
ret nz
ld a, [wXCoord]
cp $3
ret nz
callba DisplayTextIDInit
call DisplayStartMenu
To just take the most essential stuff out of DisplayTextIDInit, you could use this code:
ld a, [wYCoord]
cp $6
ret nz
ld a, [wXCoord]
cp $3
ret nz
ld hl,wFontLoaded
set 0,[hl]
ld b,$9c
call CopyScreenTileBufferToVRAM
xor a
ld [hWY],a
call LoadFontTilePatterns
ld a,$01
ld [H_AUTOBGTRANSFERENABLED],a
call DisplayStartMenu
However, the sprite data copy loops that I excluded are still necessary to prevent very minor graphical glitches
The two most important steps you were missing are setting the wFontLoaded flag (which fixes how sprites are updated/reloaded when the text box is closed) and copying the BG Map at $9800 into the BG Map at $9C00 (where the text box is displayed from)
Since the BG Map at $9C00 is used, you actually don't want to set hSCX and hSCY to 0. That causes the player to get de-synchronized from the overworld map.
Offline
Pages: 1