Add target_name boundary tests
This commit is contained in:
parent
8f24089e13
commit
008b96204e
25
README.md
25
README.md
|
@ -60,3 +60,28 @@ This project aims to both complete the VWF codebase and to provide a tool for tr
|
|||
2. `dotnet build tools/ScriptToolGui -o bin/ScriptToolGui`
|
||||
3. Run with `dotnet bin/ScriptToolGui/ScriptToolGui.dll` (or just run the EXE file directly).
|
||||
|
||||
# Testing
|
||||
|
||||
## Dependencies
|
||||
- [mGBA 0.9.3 or later, or nightly built after Nov 29, 2021](https://mgba.io/downloads.html)
|
||||
- [Building dependencies](#Building)
|
||||
|
||||
1. One-time setup
|
||||
1. Install .NET Core 2.1, PowerShell Core, and GNU Arm Embedded Toolchain. Make sure the Arm toolchain's `bin` folder is in your `PATH`.
|
||||
2. Create a `bin` folder in the root of the repo.
|
||||
3. Copy MOTHER 1+2 ROM to `bin/m12fresh.gba`.
|
||||
4. Copy EarthBound ROM to `bin/eb.smc`.
|
||||
5. Run `build-tools.ps1`.
|
||||
- Windows: `.\build-tools.ps1` in a PowerShell prompt
|
||||
- Linux and MacOS: `pwsh build-tools.ps1`
|
||||
6. Copy/build `armips` to `bin`.
|
||||
- Windows: grab the latest release [here](https://github.com/Kingcom/armips/releases) and copy the executable to `bin/armips.exe`.
|
||||
- Linux: follow the [README](https://github.com/Kingcom/armips/blob/master/Readme.md) to build `armips` and copy the executable to `bin/armips`.
|
||||
- MacOS: grab the latest release [here](https://github.com/Emory-M/armips/releases) and copy the executable to `bin/armips`.
|
||||
7. Copy/build `mgba-sdl` to `bin`.
|
||||
- You can also use mgba-QT (which is normally named mgba), but you will need to change the name of the executed program in `test.ps1`.
|
||||
2. Running the tests
|
||||
1. Run `test.ps1`.
|
||||
2. The default compiled ROM is copied to `bin/m12test.gba`.
|
||||
3. The tests' log will be in `bin/test.log`.
|
||||
4. The output will also be visible in the console.
|
||||
|
|
|
@ -36,7 +36,8 @@ $input_c_files =
|
|||
|
||||
$input_c_test_files =
|
||||
"src/c/tests/main_test.c",
|
||||
"src/c/tests/utils.c",
|
||||
"src/c/tests/test_utils.c",
|
||||
"src/c/tests/test_m2_utils.c",
|
||||
"src/c/tests/battle_test.c",
|
||||
"src/c/tests/debug_printf/test_print.c",
|
||||
"src/c/tests/debug_printf/mgba.c",
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#include "battle_test.h"
|
||||
#include "utils.h"
|
||||
#include "debug_printf/test_print.h"
|
||||
|
||||
void test_encounter_text()
|
||||
{
|
||||
|
@ -56,9 +54,40 @@ void test_death_text()
|
|||
|
||||
}
|
||||
|
||||
void test_target_text()
|
||||
{
|
||||
m2_btl_user_ptr->is_enemy = true;
|
||||
m2_btl_enemies_size = 1;
|
||||
m2_btl_user_ptr->letter = 1;
|
||||
m2_btl_user_ptr->unknown_3[0] = 1;
|
||||
|
||||
for(int j = 0; j <= 230; j++)
|
||||
{
|
||||
m2_btl_user_ptr->id = j;
|
||||
m2_btl_user_ptr->enemy_id = j;
|
||||
printTargetOfAttack(0,0);
|
||||
store_pixels_overworld_buffer(0x10); // This is just for visualization purposes
|
||||
assert_message(text_stayed_inside(window_pointers[3]), "Target text for Enemy %d", j);
|
||||
}
|
||||
|
||||
m2_btl_user_ptr->letter = W_LETTER - INITIAL_SYMBOL_ENEMY;
|
||||
m2_btl_user_ptr->unknown_3[0] = 0;
|
||||
|
||||
for(int j = 0; j <= 230; j++)
|
||||
{
|
||||
m2_btl_user_ptr->id = j;
|
||||
m2_btl_user_ptr->enemy_id = j;
|
||||
printTargetOfAttack(0,0);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void _setup()
|
||||
{
|
||||
(window_pointers[2]) = (struct WINDOW*)0x2029F88;
|
||||
(window_pointers[3]) = (struct WINDOW*)0x2029FD8;
|
||||
m2_setupwindow((window_pointers[2]), 4, 1, 0x16, 4);
|
||||
m2_btl_user_ptr = (BATTLE_DATA*)0x2021110;
|
||||
m2_btl_target_ptr = (BATTLE_DATA*)0x2021110;
|
||||
|
@ -69,12 +98,15 @@ static void _setup()
|
|||
(*(short*)(0x30023DC)) = 0; // Default delay between prints
|
||||
(*(int*)(0x3005220)) = 0x2028820;
|
||||
*tilemap_pointer= (unsigned short*)0x2028018;
|
||||
(*(byte*)(0x202514C)) = 8; // Point to the btl_user_ptr
|
||||
(*(unsigned short*)(0x500001E)) = 0x7FFF; // Make it so it's easy to check what's being written
|
||||
m2_script_readability = false;
|
||||
setup_overworld_buffer();
|
||||
}
|
||||
|
||||
void start_battle_tests()
|
||||
{
|
||||
run_test(test_encounter_text);
|
||||
run_test(test_death_text);
|
||||
run_test(test_target_text);
|
||||
}
|
|
@ -1,6 +1,11 @@
|
|||
#include "../battle_data.h"
|
||||
#include "test_utils.h"
|
||||
#include "test_m2_utils.h"
|
||||
#include "debug_printf/test_print.h"
|
||||
|
||||
#include "../battle_data.h"
|
||||
#include "../battle.h"
|
||||
#include "../vwf.h"
|
||||
|
||||
#define INITIAL_SYMBOL_ENEMY 0x70
|
||||
|
||||
void start_battle_tests();
|
||||
|
|
|
@ -1,19 +1,7 @@
|
|||
#include "utils.h"
|
||||
|
||||
#define CPUFASTSET_FILL (0x1000000)
|
||||
#define IWRAM (0x3000000)
|
||||
#define IWRAM_SIZE (0x8000-0x2000)
|
||||
|
||||
#define NON_IWRAM_RESET 0xFD
|
||||
#include "test_m2_utils.h"
|
||||
|
||||
#define RIGHT_BORDER_TILE 0x0095
|
||||
|
||||
void blank_memory()
|
||||
{
|
||||
int blank_value = 0;
|
||||
cpufastset(&blank_value, (void*)IWRAM, CPUFASTSET_FILL | (IWRAM_SIZE >> 2));
|
||||
reg_ram_reset(NON_IWRAM_RESET);
|
||||
}
|
||||
#define OVERWORLD_BUFFER_LIMIT 0x2028000
|
||||
|
||||
void setup_ness_name()
|
||||
{
|
||||
|
@ -42,3 +30,8 @@ bool text_stayed_inside(WINDOW* window)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void setup_overworld_buffer()
|
||||
{
|
||||
*((int*)(OVERWORLD_BUFFER_POINTER)) = OVERWORLD_BUFFER_LIMIT - OVERWORLD_BUFFER_SIZE;
|
||||
}
|
|
@ -1,24 +1,18 @@
|
|||
#ifndef TEST_UTILS
|
||||
#define TEST_UTILS
|
||||
#ifndef TEST_M2_UTILS
|
||||
#define TEST_M2_UTILS
|
||||
|
||||
#include "../window.h"
|
||||
#include "../vwf.h"
|
||||
#include "../locs.h"
|
||||
|
||||
#define W_LETTER 0x87
|
||||
#define KING_OFFSET 0x1C
|
||||
|
||||
#define run_test(func) \
|
||||
blank_memory();\
|
||||
_setup();\
|
||||
func();
|
||||
|
||||
void setup_ness_name();
|
||||
void setup_king_name();
|
||||
void blank_memory();
|
||||
bool text_stayed_inside(WINDOW* window);
|
||||
void setup_overworld_buffer();
|
||||
|
||||
extern void cpufastset(void *source, void *dest, int mode);
|
||||
extern void reg_ram_reset(int flag);
|
||||
extern int m2_setupwindow(WINDOW* window, short window_x, short window_y, short window_width, short window_height);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,14 @@
|
|||
#include "test_utils.h"
|
||||
|
||||
#define CPUFASTSET_FILL (0x1000000)
|
||||
#define IWRAM (0x3000000)
|
||||
#define IWRAM_SIZE (0x8000-0x2000)
|
||||
|
||||
#define NON_IWRAM_RESET 0xFD
|
||||
|
||||
void blank_memory()
|
||||
{
|
||||
int blank_value = 0;
|
||||
cpufastset(&blank_value, (void*)IWRAM, CPUFASTSET_FILL | (IWRAM_SIZE >> 2));
|
||||
reg_ram_reset(NON_IWRAM_RESET);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef TEST_UTILS
|
||||
#define TEST_UTILS
|
||||
|
||||
#define run_test(func) \
|
||||
blank_memory();\
|
||||
_setup();\
|
||||
func();
|
||||
|
||||
void blank_memory();
|
||||
|
||||
extern void cpufastset(void *source, void *dest, int mode);
|
||||
extern void reg_ram_reset(int flag);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue