summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/bank1.asm64
-rw-r--r--src/engine/bank2.asm4
-rw-r--r--src/engine/home.asm88
-rw-r--r--src/wram.asm11
4 files changed, 112 insertions, 55 deletions
diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm
index d9ce2b4..46a4b20 100644
--- a/src/engine/bank1.asm
+++ b/src/engine/bank1.asm
@@ -846,8 +846,8 @@ DuelMenu_Attack: ; 46fc (1:46fc)
.open_attack_menu
push af
ld a, [wSelectedDuelSubMenuItem]
- ld hl, AttackMenuCursorData
- call InitializeCursorParameters
+ ld hl, AttackMenuParameters
+ call InitializeMenuParameters
pop af
ld [wNumMenuItems], a
ldh a, [hWhoseTurn]
@@ -950,8 +950,8 @@ Func_478b: ; 478b (1:478b)
jr z, .asm_47d4
ret
-AttackMenuCursorData:
- db 1, 13 ; x, y
+AttackMenuParameters:
+ db 1, 13 ; cursor x, cursor y
db 2 ; y displacement between items
db 2 ; number of items
db $0f ; cursor tile number
@@ -1454,10 +1454,10 @@ Func_4b38: ; 4b38 (1:4b38)
cp $ff
ret z
call DrawCardListScreenLayout
- call CountCardsInDuelTempList
- ld hl, $5710
- ld de, $0
- call Func_2799
+ call CountCardsInDuelTempList ; list length
+ ld hl, CardListParameters ; other list params
+ lb de, 0, 0 ; initial page scroll offset, initial item (in the visible page)
+ call PrintCardListItems
ldtx hl, TheCardYouReceivedText
lb de, 1, 1
call Func_22ae
@@ -1706,10 +1706,10 @@ Func_4e40: ; 4e40 (1:4e40)
lb de, 0, 0
lb bc, 20, 13
call DrawRegularTextBox
- call CountCardsInDuelTempList
- ld hl, $5710
- ld de, $0
- call Func_2799
+ call CountCardsInDuelTempList ; list length
+ ld hl, CardListParameters ; other list params
+ lb de, 0, 0 ; initial page scroll offset, initial item (in the visible page)
+ call PrintCardListItems
ldtx hl, DuelistHandText
lb de, 1, 1
call Func_22ae
@@ -2040,19 +2040,19 @@ Func_55f0: ; 55f0 (1:55f0)
call DrawNarrowTextBox
call $56a0
.asm_55f6
- call CountCardsInDuelTempList
+ call CountCardsInDuelTempList ; list length
ld hl, wSelectedDuelSubMenuItem
- ld e, [hl]
+ ld e, [hl] ; initial item (in the visible page)
inc hl
- ld d, [hl]
- ld hl, $5710
- call Func_2799
+ ld d, [hl] ; initial page scroll offset
+ ld hl, CardListParameters ; other list params
+ call PrintCardListItems
call Func_58aa
call EnableLCD
.asm_560b
call DoFrame
call $5690
- call Func_2626
+ call HandleCardListInput
jr nc, .asm_560b
ld hl, wSelectedDuelSubMenuItem
ld [hl], e
@@ -2125,7 +2125,19 @@ Func_55f0: ; 55f0 (1:55f0)
ret
; 0x5690
- INCROM $5690, $5744
+ INCROM $5690, $5710
+
+CardListParameters: ; 5710 (1;5710)
+ db 1, 3 ; cursor x, cursor y
+ db 4 ; item x
+ db $0e
+ db 5 ; number of items selectable without scrolling
+ db $0f ; cursor tile number
+ db $00 ; tile behind cursor
+ dw $5719 ; function pointer if non-0
+; 0x5719
+
+ INCROM $5719, $5744
Func_5744: ; 5744 (1:5744)
ld hl, wcbd8
@@ -2662,14 +2674,14 @@ _OpenPlayAreaScreen: ; 600e (1:600e)
call $61c7
call EnableLCD
.asm_6034
- ld hl, CursorData_60be
+ ld hl, MenuParameters_60be
ld a, [wcbd2]
or a
jr z, .asm_6040
- ld hl, CursorData_60c6
+ ld hl, MenuParameters_60c6
.asm_6040
ld a, [wSelectedDuelSubMenuItem]
- call InitializeCursorParameters
+ call InitializeMenuParameters
ld a, [wcbc8]
ld [wNumMenuItems], a
.asm_604c
@@ -2735,16 +2747,16 @@ _OpenPlayAreaScreen: ; 600e (1:600e)
ret
; 0x60be
-CursorData_60be: ; 60be (1:60be)
- db 0, 0 ; x, y
+MenuParameters_60be: ; 60be (1:60be)
+ db 0, 0 ; cursor x, cursor y
db 3 ; y displacement between items
db 6 ; number of items
db $0f ; cursor tile number
db $00 ; tile behind cursor
dw $60ce ; function pointer if non-0
-CursorData_60c6: ; 60c6 (1:60c6)
- db 0, 3 ; x, y
+MenuParameters_60c6: ; 60c6 (1:60c6)
+ db 0, 3 ; cursor x, cursor y
db 3 ; y displacement between items
db 6 ; number of items
db $0f ; cursor tile number
diff --git a/src/engine/bank2.asm b/src/engine/bank2.asm
index 5ec3e16..179111e 100644
--- a/src/engine/bank2.asm
+++ b/src/engine/bank2.asm
@@ -80,7 +80,7 @@ Func_8db0: ; 8db0 (2:4db0)
Func_8dbc: ; 8dbc (2:4dbc)
ld hl, Unknown_8de2
- call InitializeCursorParameters
+ call InitializeMenuParameters
ldtx hl, PleaseSelectDeckText
call DrawWideTextBox_PrintText
.asm_8dc8
@@ -912,7 +912,7 @@ Func_ba04: ; ba04 (2:7a04)
ld [wd0a5], a
xor a
ld hl, $7b6e
- call InitializeCursorParameters
+ call InitializeMenuParameters
ldtx hl, PleaseSelectDeckText
call DrawWideTextBox_PrintText
ld a, $5
diff --git a/src/engine/home.asm b/src/engine/home.asm
index fab80c3..b06f28c 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -6431,12 +6431,52 @@ Func_256d: ; 256d (0:256d)
ret
; 0x2589
- INCROM $2589, $2626
+ INCROM $2589, $25ea
-Func_2626: ; 2626 (0:2626)
+; initializes parameters for a card list (e.g. list of hand cards in a duel or booster pack cards)
+; input: a = list length, de = initial page scroll offset, initial item (in the visible page)
+; hl: 9 bytes with the rest of the parameters
+InitializeCardListParameters: ; 25ea (0:25ea)
+ ld [wNumListItems], a
+ ld a, d
+ ld [wListScrollOffset], a
+ ld a, e
+ ld [wCurMenuItem], a
+ add d
+ ldh [hCurrentMenuItem], a
+ ld a, [hli]
+ ld [wCursorXPosition], a
+ ld a, [hli]
+ ld [wCursorYPosition], a
+ ld a, [hli]
+ ld [wListItemXPosition], a
+ ld a, [hli]
+ ld [wcd1c], a
+ ld a, [hli]
+ ld [wNumMenuItems], a
+ ld a, [hli]
+ ld [wCursorTileNumber], a
+ ld a, [hli]
+ ld [wTileBehindCursor], a
+ ld a, [hli]
+ ld [wListFunctionPointer], a
+ ld a, [hli]
+ ld [wListFunctionPointer + 1], a
+ xor a
+ ld [wCursorBlinkCounter], a
+ ld a, 1
+ ld [wYDisplacementBetweenMenuItems], a
+ ret
+; 0x2626
+
+; similar to HandleMenuInput, but conveniently returns parameters related
+; to the state of the list in a, d, and e if A or B were pressed.
+; also returns carry if A or B were pressed, nc otherwise.
+; used in the Hand card list and Discard Pile card list screens.
+HandleCardListInput: ; 2626 (0:2626)
call HandleMenuInput
ret nc
- ld a, [wcd19]
+ ld a, [wListScrollOffset]
ld d, a
ld a, [wCurMenuItem]
ld e, a
@@ -6445,12 +6485,12 @@ Func_2626: ; 2626 (0:2626)
ret
; 0x2636
-; initializes cursor parameters given the 8 bytes starting at hl,
+; initializes parameters for a menu, given the 8 bytes starting at hl,
; which represent the following:
-; x coord, y coord, y displacement between items, number of items,
-; cursor tile number, tile behind cursor, ???? (unknown function pointer if non-0)
+; cursor x coord, cursor y coord, y displacement between items, number of items,
+; cursor tile number, tile behind cursor, function pointer if non-0.
; also sets the current menu item to the one specified in register a
-InitializeCursorParameters: ; 2636 (0:2636)
+InitializeMenuParameters: ; 2636 (0:2636)
ld [wCurMenuItem], a
ldh [hCurrentMenuItem], a
ld de, wCursorXPosition
@@ -6693,8 +6733,10 @@ DuelMenuCursorCoords: ; 278d (0:278d)
db 14, 14 ; Retreat
db 14, 16 ; Done
-Func_2799: ; 2799 (0:2799)
- call $25ea
+; print the items of a list of cards (hand cards in a duel, cards from a booster pack...)
+; and initialize the parameters of the list
+PrintCardListItems: ; 2799 (0:2799)
+ call InitializeCardListParameters
ld hl, wMenuFunctionPointer
ld a, LOW($283f)
ld [hli], a
@@ -6705,7 +6747,7 @@ Func_2799: ; 2799 (0:2799)
ld a, $01
ld [wcd97], a
ld e, $00
- ld a, [wcd19]
+ ld a, [wListScrollOffset]
or a
jr z, .asm_27b9
ld e, $0c
@@ -6717,10 +6759,10 @@ Func_2799: ; 2799 (0:2799)
ld a, e
call WriteToBGMap0AddressFromBCCoord
ld e, $00
- ld a, [wcd19]
+ ld a, [wListScrollOffset]
ld hl, wNumMenuItems
add [hl]
- ld hl, wcd1b
+ ld hl, wNumListItems
cp [hl]
jr nc, .asm_27d5
ld e, $2f
@@ -6732,14 +6774,14 @@ Func_2799: ; 2799 (0:2799)
ld c, a
ld a, e
call WriteToBGMap0AddressFromBCCoord
- ld a, [wcd19]
+ ld a, [wListScrollOffset]
ld e, a
ld d, $00
ld hl, wDuelTempList
add hl, de
ld a, [wNumMenuItems]
ld b, a
- ld a, [wcd1a]
+ ld a, [wListItemXPosition]
ld d, a
ld a, [wCursorYPosition]
ld e, a
@@ -6762,7 +6804,7 @@ Func_2799: ; 2799 (0:2799)
pop bc
pop hl
inc hl
- ld a, [wcd1b]
+ ld a, [wNumListItems]
dec a
inc c
cp c
@@ -6946,8 +6988,8 @@ DrawNarrowTextBox: ; 2a6f (0:2a6f)
DrawNarrowTextBox_WaitForInput: ; 2a7c (0:2a7c)
call DrawNarrowTextBox_PrintTextNoDelay
xor a
- ld hl, NarrowTextBoxPromptCursorData
- call InitializeCursorParameters
+ ld hl, NarrowTextBoxMenuParameters
+ call InitializeMenuParameters
call EnableLCD
.wait_A_or_B_loop
call DoFrame
@@ -6957,8 +6999,8 @@ DrawNarrowTextBox_WaitForInput: ; 2a7c (0:2a7c)
jr z, .wait_A_or_B_loop
ret
-NarrowTextBoxPromptCursorData: ; 2a96 (0:2a96)
- db 10, 17 ; x, y
+NarrowTextBoxMenuParameters: ; 2a96 (0:2a96)
+ db 10, 17 ; corsor x, cursor y
db 1 ; y displacement between items
db 1 ; number of items
db $2f ; cursor tile number
@@ -6978,8 +7020,8 @@ DrawWideTextBox_WaitForInput: ; 2aab (0:2aab)
; fallthrough
WaitForWideTextBoxInput: ; 2aae (0:2aae)
xor a
- ld hl, WideTextBoxPromptCursorData
- call InitializeCursorParameters
+ ld hl, WideTextBoxMenuParameters
+ call InitializeMenuParameters
call EnableLCD
.wait_A_or_B_loop
call DoFrame
@@ -6990,8 +7032,8 @@ WaitForWideTextBoxInput: ; 2aae (0:2aae)
call EraseCursor
ret
-WideTextBoxPromptCursorData: ; 2ac8 (0:2ac8)
- db 18, 17 ; x, y
+WideTextBoxMenuParameters: ; 2ac8 (0:2ac8)
+ db 18, 17 ; cursor x, cursor y
db 1 ; y displacement between items
db 1 ; number of items
db $2f ; cursor tile number
diff --git a/src/wram.asm b/src/wram.asm
index e3857c8..ade377a 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -890,19 +890,22 @@ wTileBehindCursor:: ; cd16
wMenuFunctionPointer:: ; cd17
ds $2
-wcd19:: ; cd19
+wListScrollOffset:: ; cd19
ds $1
-wcd1a:: ; cd1a
+wListItemXPosition:: ; cd1a
ds $1
-wcd1b:: ; cd1b
+wNumListItems:: ; cd1b
ds $1
wcd1c:: ; cd1c
ds $1
- ds $7a
+wListFunctionPointer:: ; cd1d
+ ds $2
+
+ ds $78
wcd97:: ; cd97
ds $1