-
Notifications
You must be signed in to change notification settings - Fork 93
Adding a new button on the Pause menu
In this tutorial we are going to Add a new button to the Pause Menu and Expand its size.
First we will have to expand the pause menu to be able to add the new option. Edit the file in src/engine/menus/gift_center.asm:
Unknown_10d98:
db 12, 0 ; start menu coords
- db 8, 14 ; start menu text box dimensions
+ db 8, 16 ; start menu text box dimensions
db 14, 2 ; text alignment for InitTextPrinting
tx PauseMenuOptionsText
db $ff
db 13, 2 ; cursor x, cursor y
db 2 ; y displacement between items
- db 6 ; number of items
+ db 7 ; number of items
Here what we basically do is change the dimensions of the Menu (from 8x14 to 8x16) and expand the number of places that the cursor can go through.
Now that we have expanded the Menu we can add a new option to it, for this tutorial we will add the "Read Mail" option from the PC. Edit the file in src/engine/overworld/overworld.asm:
.wait_input
call DoFrameIfLCDEnabled
call HandleMenuInput
jr nc, .wait_input
ld a, e
ld [wSelectedPauseMenuItem], a
ldh a, [hCurMenuItem]
cp e
jr nz, .exit
- cp $5
+ cp $6
jr z, .exit
The first thing we must do is modify this small part in the "PauseMenu:" function, what this does is determine in which position the Exit option is which in the original Menu is in the fifth position, we must modify it according to the number of options we have now (6). Now let's move on to modify something further down:
PauseMenuPointerTable:
dw PauseMenu_Status
dw PauseMenu_Diary
dw PauseMenu_Deck
dw PauseMenu_Card
+ dw PauseMenu_ReadMail
dw PauseMenu_Config
dw PauseMenu_Exit
In this table you will find the options available in the Pause Menu which are defined below this one, what we will do is add this new option and we will define this below:
+ PauseMenu_ReadMail:
+ xor a
+ ldh [hSCX], a
+ ldh [hSCY], a
+ call Set_OBJ_8x16
+ farcall SetDefaultPalettes
+ farcall PCMenu_ReadMail
+ jp Set_OBJ_8x8
With this we now have a function that will directly open the "Read Mail" option in the Pause Menu.
Now that we have the menu configured we have to deal with the simplest and easiest thing, the names of the options. Edit src/text/text3.asm:
PauseMenuOptionsText:
text "Status"
line "Diary"
line "Deck"
line "Card"
+ line "Read Mail"
line "Config"
line "Exit"
done
We simply add a new line to the text, in this case the Name that we want to add to the option (Keep in mind that the order shown here has to match the order that is in the Table above), and it would be ready for testing!. (I must also clarify that it is very possible that you will reach a "bank overflow" with this modification, please check the "Add new text" tutorial, if that is the case.)
And the final result would look like this, as you can see the pause menu is larger and the option can be used from the start of the game: