Add memory wipe function

This commit is contained in:
Lorenzo Carletti 2021-11-30 12:53:36 +01:00
parent 6e21c0ef92
commit 40dbb00b22
4 changed files with 61 additions and 6 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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));
}

View File

@ -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();
void start_tests();
void blank_memory();
extern void vblank();
extern void cpufastset(void *source, void *dest, int mode);