Skip to content

Commit

Permalink
Press B in the battle menu to move the cursor to Run.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Nov 25, 2018
1 parent 3b6085a commit f422cb5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 52 deletions.
18 changes: 6 additions & 12 deletions engine/battle/menu.asm
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
LoadBattleMenu: ; 24ef2
ld hl, BattleMenuDataHeader
call LoadMenuDataHeader
ld a, [wBattleMenuCursorBuffer]
ld [wMenuCursorBuffer], a
call InterpretBattleMenu
ld a, [wMenuCursorBuffer]
ld [wBattleMenuCursorBuffer], a
jp ExitMenu
jr _BattleMenuCommon
; 24f0b

ContestBattleMenu: ; 24f13
ld hl, ContestBattleMenuDataHeader
jr ContestSafariBattleMenuCommon
jr _BattleMenuCommon
; 24f19

SafariBattleMenu:
ld hl, SafariBattleMenuDataHeader
ContestSafariBattleMenuCommon:
_BattleMenuCommon:
call LoadMenuDataHeader
ld a, [wBattleMenuCursorBuffer]
ld [wMenuCursorBuffer], a
Expand All @@ -34,7 +28,7 @@ BattleMenuDataHeader: ; 24f2c
; 24f34

.MenuData2: ; 0x24f34
db $81 ; flags
db $91 ; flags
dn 2, 2 ; rows, columns
db 6 ; spacing
dba .Strings
Expand All @@ -57,7 +51,7 @@ ContestBattleMenuDataHeader: ; 24f89
; 24f91

.MenuData2: ; 24f91
db $81 ; flags
db $91 ; flags
dn 2, 2 ; rows, columns
db 12 ; spacing
dba .Strings
Expand Down Expand Up @@ -86,7 +80,7 @@ SafariBattleMenuDataHeader:
db 1 ; default option

.MenuData2:
db $81 ; flags
db $91 ; flags
dn 2, 2 ; rows, columns
db 12 ; spacing
dba .Strings
Expand Down
57 changes: 25 additions & 32 deletions engine/menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,6 @@ _2DMenu_:: ; 2400e
call Draw2DMenu
call UpdateSprites
call ApplyTilemap
jp Get2DMenuSelection
; 24022

_InterpretBattleMenu:: ; 24022
ld hl, CopyMenuData2
ld a, [wMenuData2_2DMenuItemStringsBank]
call FarCall_hl

call Draw2DMenu
call UpdateSprites
call ApplyTilemap
jp Get2DMenuSelection
; 2403c

Draw2DMenu: ; 24085
xor a
ld [hBGMapMode], a
call MenuBox
jp Place2DMenuItemStrings
; 2408f

Get2DMenuSelection: ; 2408f
call Init2DMenuCursorPosition
Expand All @@ -36,15 +16,15 @@ Get2DMenuSelection: ; 2408f
jr z, .skip
call GetMenuJoypad
bit SELECT_F, a
jr nz, .quit1
jr nz, .quit

.skip
ld a, [wMenuData2Flags]
bit 0, a
jr nz, .skip2
call GetMenuJoypad
bit B_BUTTON_F, a
jr nz, .quit2
jr nz, .quit

.skip2
ld a, [w2DMenuNumCols]
Expand All @@ -59,11 +39,7 @@ Get2DMenuSelection: ; 2408f
and a
ret

.quit1
scf
ret

.quit2
.quit
scf
ret
; 240cd
Expand All @@ -81,6 +57,11 @@ GetMenuNumberOfRows: ; 240d3
ret
; 240db

Draw2DMenu: ; 24085
xor a
ld [hBGMapMode], a
call MenuBox

Place2DMenuItemStrings:
ld hl, wMenuData2_2DMenuItemStringsAddr
ld e, [hl]
Expand Down Expand Up @@ -291,13 +272,13 @@ Menu_WasButtonPressed: ; 24259
_2DMenuInterpretJoypad: ; 24270
call GetMenuJoypad
bit A_BUTTON_F, a
jp nz, .a_b_start_select
jp nz, .a_start_select
bit B_BUTTON_F, a
jp nz, .a_b_start_select
jp nz, .b_button
bit SELECT_F, a
jp nz, .a_b_start_select
jp nz, .a_start_select
bit START_F, a
jp nz, .a_b_start_select
jp nz, .a_start_select
bit D_RIGHT_F, a
jr nz, .d_right
bit D_LEFT_F, a
Expand Down Expand Up @@ -410,11 +391,23 @@ _2DMenuInterpretJoypad: ; 24270
ret
; 24318

.a_b_start_select ; 24318
.a_start_select ; 24318
xor a
ret
; 2431a

.b_button
ld a, [wMenuData2Flags]
bit 4, a ; should B move to Run?
jr z, .no_b_run
; Run is the bottom-right item
ld a, $2
ld [wMenuCursorX], a
ld [wMenuCursorY], a
.no_b_run
xor a
ret

Move2DMenuCursor: ; 2431a
ld hl, wCursorCurrentTile
ld a, [hli]
Expand Down
8 changes: 0 additions & 8 deletions home/menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,3 @@ _2DMenu:: ; 202a
ld a, [wMenuCursorBuffer]
ret
; 2039

InterpretBattleMenu:: ; 2039
ld a, [hROMBank]
ld [wMenuData2_2DMenuItemStringsBank], a
farcall _InterpretBattleMenu
ld a, [wMenuCursorBuffer]
ret
; 2048

0 comments on commit f422cb5

Please sign in to comment.