From 40dbb00b229cb8eb548cd5ae3b94dc7e7d0fbdee Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Tue, 30 Nov 2021 12:53:36 +0100 Subject: [PATCH] Add memory wipe function --- src/c/battle_data.h | 30 +++++++++++++++++++++++++++--- src/c/tests/battle_test.c | 3 ++- src/c/tests/main_test.c | 14 ++++++++++++++ src/c/tests/main_test.h | 20 ++++++++++++++++++-- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/src/c/battle_data.h b/src/c/battle_data.h index cb28f2b..c008d92 100644 --- a/src/c/battle_data.h +++ b/src/c/battle_data.h @@ -18,9 +18,33 @@ typedef struct BATTLE_DATA { } BATTLE_DATA; typedef struct ENEMY_DATA { - byte unknown[0x14]; - char* encounter_text; - byte unknown_2[0x28]; + /* 0 */ byte unk0[6]; + /* 6 */ unsigned short hp; + /* 8 */ unsigned short pp; + /* A */ byte unkA[2]; + /* C */ unsigned int exp; + /* 10 */ unsigned short money; + /* 12 */ unsigned short overworldAnim; + /* 14 */ char *encounter_text; + /* 18 */ char *death_text; + /* 1C */ byte palette; + /* 1D */ byte level; + /* 1E */ byte bgm; + /* 1F */ byte offense; + /* 20 */ byte defense; + /* 21 */ byte unk21; + /* 22 */ byte speed; + /* 23 */ byte guts; + /* 24 */ byte luck; + /* 25 */ byte unk25[3]; + /* 28 */ unsigned short actions[4]; + /* 30 */ unsigned short finalAction; + /* 32 */ unsigned short actionArgs[4]; + /* 3A */ byte unk3A[2]; + /* 3C */ byte unk3C; + /* 3D */ byte itemDropped; + /* 3E */ byte unk3E; + /* 3F */ byte mirrorSuccess; } ENEMY_DATA; #endif \ No newline at end of file diff --git a/src/c/tests/battle_test.c b/src/c/tests/battle_test.c index 68fad17..6f97747 100644 --- a/src/c/tests/battle_test.c +++ b/src/c/tests/battle_test.c @@ -64,9 +64,10 @@ void setup_battle_tests() setup_king_name(); m2_is_battle = 1; (*(byte*)(0x3005050)) = 0xFF; - (*(short*)(0x30023DC)) = 0; //Default delay between prints + (*(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 m2_script_readability = false; } diff --git a/src/c/tests/main_test.c b/src/c/tests/main_test.c index a8971b1..082dfc7 100644 --- a/src/c/tests/main_test.c +++ b/src/c/tests/main_test.c @@ -6,10 +6,24 @@ void start_tests() { start_session(); + blank_memory(); start_battle_tests(); + blank_memory(); + end_session(); while(1) vblank(); +} + +void blank_memory() +{ + int blank_value = 0; + cpufastset(&blank_value, (void*)EWRAM, CPUFASTSET_FILL | (EWRAM_SIZE >> 2)); + cpufastset(&blank_value, (void*)IWRAM, CPUFASTSET_FILL | (IWRAM_SIZE >> 3)); + cpufastset(&blank_value, (void*)IO, CPUFASTSET_FILL | (IO_SIZE >> 2)); + cpufastset(&blank_value, (void*)PALETTES, CPUFASTSET_FILL | (PALETTES_SIZE >> 2)); + cpufastset(&blank_value, (void*)VRAM, CPUFASTSET_FILL | (VRAM_SIZE >> 2)); + cpufastset(&blank_value, (void*)OBJECTS, CPUFASTSET_FILL | (OBJECTS_SIZE >> 2)); } \ No newline at end of file diff --git a/src/c/tests/main_test.h b/src/c/tests/main_test.h index 36df6f2..1c4812c 100644 --- a/src/c/tests/main_test.h +++ b/src/c/tests/main_test.h @@ -1,5 +1,21 @@ #include "debug_printf/test_print.h" -void start_tests(); +#define CPUFASTSET_FILL (0x1000000) +#define EWRAM (0x2000000) +#define EWRAM_SIZE (0x40000) +#define IWRAM (0x3000000) +#define IWRAM_SIZE (0x8000) +#define IO (0x4000000) +#define IO_SIZE (0x400) +#define PALETTES (0x5000000) +#define PALETTES_SIZE (0x400) +#define VRAM (0x6000000) +#define VRAM_SIZE (0x18000) +#define OBJECTS (0x7000000) +#define OBJECTS_SIZE (0x400) -extern void vblank(); \ No newline at end of file +void start_tests(); +void blank_memory(); + +extern void vblank(); +extern void cpufastset(void *source, void *dest, int mode); \ No newline at end of file