From fad84ad9be484bc95644464ccf029abd2e90b5ec Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Sat, 18 Dec 2021 02:20:00 +0100 Subject: [PATCH 1/2] Add front row and back row target boundary tests --- src/c/tests/battle_test.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/c/tests/battle_test.c b/src/c/tests/battle_test.c index 22a1494..d21ada0 100644 --- a/src/c/tests/battle_test.c +++ b/src/c/tests/battle_test.c @@ -81,7 +81,15 @@ void test_target_text() store_pixels_overworld_buffer(0x10); // This is just for visualization purposes assert_message(text_stayed_inside(window_pointers[3]), "Target text for Enemy %d - W", j); } - + + printTargetOfAttack(0,-1); // To the front row + store_pixels_overworld_buffer(0x10); // This is just for visualization purposes + assert(text_stayed_inside(window_pointers[3])); + + printTargetOfAttack(1,-1); // To the back row + store_pixels_overworld_buffer(0x10); // This is just for visualization purposes + assert(text_stayed_inside(window_pointers[3])); + } static void _setup() From dbedc3712a64af978d1b74d6e3fb1e4f2768f17b Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Mon, 20 Dec 2021 00:34:28 +0100 Subject: [PATCH 2/2] Add overworld menu's items boundary testing --- build.ps1 | 1 + src/c/ext.c | 1 + src/c/tests/main_test.c | 2 + src/c/tests/menu_test.c | 123 ++++++++++++++++++++++++++++++++++++++++ src/c/tests/menu_test.h | 11 ++++ src/m2-hack.asm | 1 + test.ps1 | 2 +- 7 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 src/c/tests/menu_test.c create mode 100644 src/c/tests/menu_test.h diff --git a/build.ps1 b/build.ps1 index c9a3155..bae1450 100644 --- a/build.ps1 +++ b/build.ps1 @@ -39,6 +39,7 @@ $input_c_test_files = "src/c/tests/test_utils.c", "src/c/tests/test_m2_utils.c", "src/c/tests/battle_test.c", + "src/c/tests/menu_test.c", "src/c/tests/debug_printf/test_print.c", "src/c/tests/debug_printf/mgba.c", "src/c/tests/debug_printf/printf.c" diff --git a/src/c/ext.c b/src/c/ext.c index 467055f..b01735e 100644 --- a/src/c/ext.c +++ b/src/c/ext.c @@ -37,4 +37,5 @@ byte* __attribute__((naked)) m2_malloc(int size) {} void __attribute__((naked)) m2_free(int* address) {} void __attribute__((naked)) m2_title_teardown() {} void __attribute__((naked)) vblank() {} +int __attribute__((naked)) m2_set_equippables(WINDOW* window, unsigned short choice, byte* index_list) {} void __attribute__((naked)) reg_ram_reset(int flag) {} \ No newline at end of file diff --git a/src/c/tests/main_test.c b/src/c/tests/main_test.c index a8971b1..6123c15 100644 --- a/src/c/tests/main_test.c +++ b/src/c/tests/main_test.c @@ -1,5 +1,6 @@ #include "main_test.h" #include "battle_test.h" +#include "menu_test.h" #include "debug_printf/test_print.h" void start_tests() @@ -7,6 +8,7 @@ void start_tests() start_session(); start_battle_tests(); + start_menu_tests(); end_session(); diff --git a/src/c/tests/menu_test.c b/src/c/tests/menu_test.c new file mode 100644 index 0000000..e362e1a --- /dev/null +++ b/src/c/tests/menu_test.c @@ -0,0 +1,123 @@ +#include "menu_test.h" + +#define GOODS_X 0x6 +#define GOODS_Y 0x1 +#define GOODS_WIDTH 0x17 +#define GOODS_HEIGHT 0xE + +#define INNERMOST_EQUIP_X 0x12 +#define INNERMOST_EQUIP_Y 0x1 +#define INNERMOST_EQUIP_WIDTH 0xB +#define INNERMOST_EQUIP_HEIGHT 0xE + +#define TOTAL_ITEMS 253 + +#define CHOICE_WEAPONS 0x3 +#define CHOICE_BODY 0x4 +#define CHOICE_ARMS 0x5 +#define CHOICE_OTHER 0x6 + +void getEquippables(byte* equip_buffers); + +void test_items_text() +{ + byte equip_buffers[TOTAL_ITEMS]; + getEquippables(equip_buffers); + m2_setupwindow((window_pointers[4]), GOODS_X, GOODS_Y, GOODS_WIDTH, GOODS_HEIGHT); + + *active_window_party_member = 0; + unsigned short *current_items = (*pc_stats)[0].goods; + byte *current_equipment = (*pc_stats)[0].equipment; + current_items[0] = 0; + + for(int i = 0; i < TOTAL_ITEMS; i++) + { + current_items[1] = i; + current_equipment[0] = 0; + initWindow_buffer(window_pointers[4], NULL, 0); + goods_print_items(window_pointers[4], current_items, 0); + store_pixels_overworld_buffer(0x10); // This is just for visualization purposes + assert_message(text_stayed_inside(window_pointers[4]), "Goods window: Item %d", i); + if(equip_buffers[i] != 0) + { + current_equipment[0] = 2; + initWindow_buffer(window_pointers[4], NULL, 0); + goods_print_items(window_pointers[4], current_items, 0); + store_pixels_overworld_buffer(0x10); // This is just for visualization purposes + assert_message(text_stayed_inside(window_pointers[4]), "Goods window: Item %d - Equipped", i); + } + } +} + +void test_equip_text() +{ + byte fsp_buffer[0x20]; + free_strings_pointers[3] = fsp_buffer; + byte equipped_buffer[6]; + byte equip_buffers[TOTAL_ITEMS]; + getEquippables(equip_buffers); + equipped_buffer[4] = 1; + equipped_buffer[5] = 0xFF; + m2_setupwindow((window_pointers[4]), INNERMOST_EQUIP_X, INNERMOST_EQUIP_Y, INNERMOST_EQUIP_WIDTH, INNERMOST_EQUIP_HEIGHT); + + *active_window_party_member = 0; + *((unsigned short*)0x3005224) = CHOICE_WEAPONS; + unsigned short *current_items = (*pc_stats)[0].goods; + byte *current_equipment = (*pc_stats)[0].equipment; + window_pointers[4]->cursor_x = 1; + window_pointers[4]->number_text_area = equipped_buffer; + + for(int i = 0; i < TOTAL_ITEMS; i++) + { + if(equip_buffers[i] != 0) + { + current_items[0] = i; + current_equipment[0] = 1; + initWindow_buffer(window_pointers[4], NULL, 0); + equippablePrint(window_pointers[4]); + store_pixels_overworld_buffer(0x10); // This is just for visualization purposes + assert_message(text_stayed_inside(window_pointers[4]), "Equip window: Item %d - Equipped", i); + } + } +} + +void getEquippables(byte* equip_buffers) +{ + byte buffer[0x20]; + + for(int i = 0; i < TOTAL_ITEMS; i++) + { + for(int j = 0; j < 4; j++) + { + if(j == 0 || equip_buffers[i] == 0) + { + *active_window_party_member = (short)j; + unsigned short *current_items = (*pc_stats)[j].goods; + current_items[0] = i; + int found = 0; + found += m2_set_equippables((window_pointers[4]), CHOICE_WEAPONS, buffer); + found += m2_set_equippables((window_pointers[4]), CHOICE_BODY, buffer); + found += m2_set_equippables((window_pointers[4]), CHOICE_ARMS, buffer); + found += m2_set_equippables((window_pointers[4]), CHOICE_OTHER, buffer); + equip_buffers[i] = found; + } + } + } +} + +static void _setup() +{ + (window_pointers[4]) = (struct WINDOW*)0x2030948; + (*(byte*)(0x3005050)) = 0xFF; + (*(short*)(0x30023DC)) = 0; // Default delay between prints + (*(int*)(0x3005220)) = 0x2028820; + *tilemap_pointer= (unsigned short*)0x2028018; + (*(unsigned short*)(0x500001E)) = 0x7FFF; // Make it so it's easy to check what's being written + setup_overworld_buffer(); +} + +void start_menu_tests() +{ + run_test(test_items_text); + run_test(test_equip_text); +} \ No newline at end of file diff --git a/src/c/tests/menu_test.h b/src/c/tests/menu_test.h new file mode 100644 index 0000000..f5b94e7 --- /dev/null +++ b/src/c/tests/menu_test.h @@ -0,0 +1,11 @@ +#include "test_utils.h" +#include "test_m2_utils.h" +#include "debug_printf/test_print.h" + +#include "../goods.h" +#include "../equip.h" +#include "../vwf.h" + +void start_menu_tests(); + +extern int m2_set_equippables(WINDOW* window, unsigned short choice, byte* index_list); \ No newline at end of file diff --git a/src/m2-hack.asm b/src/m2-hack.asm index b2aeca6..c1de416 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -2400,6 +2400,7 @@ disclaimer_map: .definelabel m2_statuswindow_numbers,0x80C0A5C .definelabel m2_menuwindow ,0x80C1C98 .definelabel m2_psiwindow ,0x80C1FBC +.definelabel m2_set_equippables ,0x80C51A0 .definelabel m2_drawwindow ,0x80C87D0 .definelabel m2_print_window ,0x80C8BE4 .definelabel m2_print_alphabet ,0x80C8FFC diff --git a/test.ps1 b/test.ps1 index 09246bd..c2a9d2c 100644 --- a/test.ps1 +++ b/test.ps1 @@ -1,6 +1,6 @@ $test_rom_file = "bin/m12test.gba" $log_file = "bin/test.log" -$sleep_time = 60 +$sleep_time = 120 $failure_text = "FAIL" $end_text = "Done!" $mgba_name = "mgba-sdl"