-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMenuNotes.txt
142 lines (123 loc) · 4.95 KB
/
MenuNotes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
All offsets and routines are for FE8U
E_Menu related routines:
0804ECB0 | StartMenuExt | Starts Menu proc
Arguments:
r0 = pointer to Menu Definition
r1 = geometry
r2 = background BG index
r3 = base tile index for UI tiles
[sp+0] = foreground BG index
[sp+4] = ? (stored to field 0x68)
[sp+8] = Parent proc (0 is valid, and will make the E_Menu a toplevel thread 3 proc)
Returns:
r0 = Menu proc pointer
0804EBE4 | StartMenu | Starts Menu proc, BG1 is background, BG0 is foreground, no parent proc, default geometry, default everything
Arguments:
r0 = pointer to Menu Definition
Returns:
r0 = Menu proc pointer
0804EB98 | StartMenuAdjusted | Same as StartMenu, except default geometry is adjusted given the parameters
Arguments:
r0 = pointer to Menu Definition
r1 = some x screen position ?
r2 = X tile position of menu on the left
r3 = X tile position of menu of the right
Returns:
r0 = E_Menu proc pointer
0804EBC8 | StartMenuChild | Same as StartMenu, except the proc has a parent
Arguments:
r0 = pointer to Menu Definition
r1 = Parent proc
Returns:
r0 = E_Menu proc pointer
0804EC98 | StartMenuAt | Starts Menu proc, BG1 is background, BG0 is foreground
Arguments:
r0 = pointer to Menu Definition
r1 = geometry
r2 = parent proc
Returns:
r0 = E_Menu proc pointer
0804EF20 | EndAllMenus | Kills *all* the E_Menus
Arguments: nothing
Returns: nothing
MENU PROC CODE:
Note: the Menu proc is quite more complex than the average proc, it makes use of jumps and the code is scattered in more than one location.
Start: (085B64D0)
SET_NAME "E_Menu"
SLEEP 0
WHILE_EXISTS GENS PROC (0859A548)
CALL NewGreenTextColorManager (080049AC)
CALL 0804EF70 (Draws the Menu)
CALL 0804EF38 (Calls some routines in definitions)
JUMP Idle (085B64B8)
END
Idle: (085B64B8)
LOOP 0804F164 (Manages Key presses and all that)
CALL EndGreenTextColorManager (080049D0)
END
HelpTextCall: TODO
PROC_085B64D0 (E_Menu):
2C | word | geometry (4 bytes in order: x, y, w, h)
30 | word | pointer to Menu definition
34 | n*4 | array of pointers to 6C_085B6510 (Menu Commands)
60 | byte | command count
61 | byte | current command index
62 | byte | last command index
63 | byte | Bitfield:
0x01: Non Blocking
0x08: When set, won't draw?
0x20: When set, will draw the hand cursor with movement phase and all
0x40: When set, will draw the hand cursor on current selected command
0x80: When set, immediately and "silently" ends the menu
64 | byte
bit 0-1: Background BG Index
bit 2-3: Foreground BG Index
66 | short | base tile index for UI window tiles
68 | short | One of the construction arguments is stored here
PROC_085B6510 (E_Menu Command Child): // There is one per menu command, and there is no code (Or rather, the one code there is does nothing, forever)
2A | short | tile x for drawing
2C | short | tile y for drawing
30 | word | pointer to ROM command struct
34 | ----- | Text Struct
3C | byte | index of command definition (aka index of command including the one not usable)
3D | byte | result of usability routine
Menu definition:
00 | word | default geometry settings (byte order: x, y, width, height)
04 | word | first byte is window frame style
08 | word | Pointer to command definitions
0C | word | Pointer to routine: Called on Construction (after the menu has been drawn for the first time)
10 | word | Pointer to routine: Called by Generic R-Text at Start
14 | word | Pointer to routine:
18 | word | Pointer to routine: called on B Press
1C | word | Pointer to routine: called on R Press
20 | word | Pointer to routine: Called by Generic R-Text at End
Command definition:
00 | word | Raw (not compressed) Name Text Pointer (used when Name Id is zero)
04 | short | Name Text Id
06 | short | RMenu Text Id
08 | byte | color index
09 | byte | command id (used for disabling commands through events)
0A | short | unused/padding?
0C | word | Usability Routine
10 | word | Draw Routine (if zero, default draw is called, which simply draws text)
14 | word | Effect Routine
18 | word | Idle Routine (Called each frame this command is selected)
1C | word | Hover Routine (Called when you get the cursor on this menu option)
20 | word | Opposite of above (Called when you get the cursor out of this menu option)
Usability Arguments:
r0 = Pointer to Command definition
r1 = Command definition index
Draw/Effect/Idle Arguments:
r0 = menu proc
r1 = relevant command proc
Usability Return Value:
1 for usable, 2 for grayed, 3 for non-usable
Effect/Idle Routine Return Value (r0 Bitfield):
& 0x01 | Doesn't do things related to drawing the hand cursor?
& 0x02 | Ends the menu
& 0x04 | Plays beep sound
& 0x08 | Plays boop sound
& 0x10 | Clears menu graphics
& 0x20 | Ends Face #0
& 0x40 | - (Not handled)
& 0x80 | Orrs 0x80 to E_Menu+0x63 bitfield (Ends the menu on next proc cycle (next frame, unless the menu proc was blocked))