diff --git a/notes/m2-notes.txt b/notes/m2-notes.txt index cd3130b..a388953 100644 --- a/notes/m2-notes.txt +++ b/notes/m2-notes.txt @@ -151,6 +151,11 @@ Subroutines 80BF858: goods character selector state machine r0: window pointer returns: 0 if no action, 1 if descending deeper into window, -1 if exited +80C0420: goods character selector state machine (escargo express check-out from Tracy) + seems to be identical to 80BF858 except that the window is shifted down by one tile, + and the text is shifted down another tile so that it renders properly + r0: window pointer + returns: 0 if no action, 1 if A/L pressed, -1 if B/select pressed 80C0A5C: render numbers on status window 80C1FBC: draw PSI window for character r0 80C239C: print PSI name with Greek letter diff --git a/src/c/goods.c b/src/c/goods.c index f833afd..6971479 100644 --- a/src/c/goods.c +++ b/src/c/goods.c @@ -9,7 +9,9 @@ // Returns 1 if the user steps into the inner window, // -1 if the user steps back out to the previous window, // and 0 for no action. -int goods_outer_process(WINDOW* window) +// y_offset is added to account for the Tracy goods window, which +// the game offsets by one tile downwards +int goods_outer_process(WINDOW* window, int y_offset) { // Get the weird signed parity value short unknown = window->unknown6; @@ -115,7 +117,7 @@ int goods_outer_process(WINDOW* window) // Print item names if (!window->vwf_skip) { - goods_print_items(window, current_items); + goods_print_items(window, current_items, y_offset); window->vwf_skip = true; } @@ -389,7 +391,7 @@ int goods_inner_process(WINDOW *window, unsigned short *items) m2_clearwindowtiles(window); if (weird_value > 0) - goods_print_items(window, items); + goods_print_items(window, items, 0); } if (state_shadow.up || state_shadow.down || state_shadow.left || state_shadow.right) @@ -446,10 +448,10 @@ int goods_inner_process(WINDOW *window, unsigned short *items) // Prints all 14 items to a goods window. // Erases the slot before printing. Prints blanks for null items. -void goods_print_items(WINDOW *window, unsigned short *items) +void goods_print_items(WINDOW *window, unsigned short *items, int y_offset) { int item_x = (window->window_x << 3) + 8; - int item_y = window->window_y << 3; + int item_y = (window->window_y + y_offset) << 3; for (int i = 0; i < 14; i++) { diff --git a/src/c/goods.h b/src/c/goods.h index 32f0958..e673ed1 100644 --- a/src/c/goods.h +++ b/src/c/goods.h @@ -18,9 +18,9 @@ typedef enum GOODS_ACTION ACTION_STEPOUT = -1 } GOODS_ACTION; -int goods_outer_process(WINDOW* window); +int goods_outer_process(WINDOW* window, int y_offset); int goods_inner_process(WINDOW *window, unsigned short *items); -void goods_print_items(WINDOW *window, unsigned short *items); +void goods_print_items(WINDOW *window, unsigned short *items, int y_offset); extern bool m2_isequipped(int item_index); extern void m2_soundeffect(int index); diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 4c2dc3d..dec9361 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -631,6 +631,17 @@ pop {pc} .org 0x80BF858 push {lr} +mov r1,0 +bl goods_outer_process +pop {pc} + +//--------------------------------------------------------- +// C0420 hacks (Goods outer menu for Tracy) +//--------------------------------------------------------- + +.org 0x80C0420 +push {lr} +mov r1,1 bl goods_outer_process pop {pc}