Prep for bug testing

This commit is contained in:
The Gears of Progress 2024-07-03 17:44:33 -04:00
parent 7ba3e3467d
commit add977cf02
12 changed files with 167 additions and 1153 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 601 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -1,7 +1,7 @@
#ifndef BACKGROUND_ENGINE_H
#define BACKGROUND_ENGINE_H
void background_frame();
void background_frame(int global_frame_count);
void set_textbox_large();
void set_textbox_small();
void show_textbox();

View File

@ -2,19 +2,20 @@
#define DEBUG_MODE_H
#define DEBUG_MODE false
#define IGNORE_GAME_PAK true
#define IGNORE_LINK_CABLE true
#define IGNORE_MG_E4_FLAGS true
#define IGNORE_UNRECEIVED_PKMN true
#define IGNORE_GAME_PAK false
#define IGNORE_LINK_CABLE false
#define IGNORE_MG_E4_FLAGS false
#define IGNORE_UNRECEIVED_PKMN false
#define FORCE_TUTORIAL false
#define DONT_REMOVE_PKMN false
#define SHOW_INVALID_PKMN false
#define DEBUG_GAME RUBY_ID
#define DEBUG_VERS VERS_1_1
#define DEBUG_GAME FIRERED_ID
#define DEBUG_VERS VERS_1_0
#define DEBUG_LANG LANG_ENG
#define ENABLE_MATCH_PID true
#define ENABLE_OLD_EVENT true
#define ENABLE_DEBUG_SCREEN true
#endif

View File

@ -332,9 +332,9 @@ const struct ROM_DATA ENG_FIRERED_v0 = {
.special_DrawWholeMapView = 0x8E,
// PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt
.e4_flag = 0x860 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR"
.mg_flag = 0x860 + 0x7B, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS
.unused_flag_start = 0x20, // The start of the unused flags and must have 31 open flags in a row
.e4_flag = 0x800 + 0x2C, // The flag that is set when you become champion. Often listed as "GAME_CLEAR"
.mg_flag = 0x800 + 0x39, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS
.unused_flag_start = 0xAF, // The start of the unused flags and must have 31 open flags in a row
.map_bank = 31,
.map_id = 0,
@ -384,9 +384,9 @@ const struct ROM_DATA ENG_LEAFGREEN_v0 = {
.special_DrawWholeMapView = 0x8E,
// PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt
.e4_flag = 0x860 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR"
.mg_flag = 0x860 + 0x7B, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS
.unused_flag_start = 0x20, // The start of the unused flags and must have 31 open flags in a row
.e4_flag = 0x800 + 0x2C, // The flag that is set when you become champion. Often listed as "GAME_CLEAR"
.mg_flag = 0x800 + 0x39, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS
.unused_flag_start = 0xAF, // The start of the unused flags and must have 31 open flags in a row
.map_bank = 31,
.map_id = 0,
@ -436,9 +436,9 @@ const struct ROM_DATA ENG_FIRERED_v1 = {
.special_DrawWholeMapView = 0x8E,
// PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt
.e4_flag = 0x860 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR"
.mg_flag = 0x860 + 0x7B, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS
.unused_flag_start = 0x20, // The start of the unused flags and must have 31 open flags in a row
.e4_flag = 0x800 + 0x2C, // The flag that is set when you become champion. Often listed as "GAME_CLEAR"
.mg_flag = 0x800 + 0x39, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS
.unused_flag_start = 0xAF, // The start of the unused flags and must have 31 open flags in a row
.map_bank = 31,
.map_id = 0,
@ -488,9 +488,9 @@ const struct ROM_DATA ENG_LEAFGREEN_v1 = {
.special_DrawWholeMapView = 0x8E,
// PKHeX's list of flags is useful for making sure the detection is accurate: https://github.com/kwsch/PKHeX/blob/78a557c3cdaa6f48b42cc96df8ccb4d20b897937/PKHeX.Core/Resources/text/other/flags_rs.txt
.e4_flag = 0x860 + 0x04, // The flag that is set when you become champion. Often listed as "GAME_CLEAR"
.mg_flag = 0x860 + 0x7B, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS
.unused_flag_start = 0x20, // The start of the unused flags and must have 31 open flags in a row
.e4_flag = 0x800 + 0x2C, // The flag that is set when you become champion. Often listed as "GAME_CLEAR"
.mg_flag = 0x800 + 0x39, // The flag that is set when you enable Mystery Gift. Known as "EXDATA_ENABLE" in RS
.unused_flag_start = 0xAF, // The start of the unused flags and must have 31 open flags in a row
.map_bank = 31,
.map_id = 0,

View File

@ -13,7 +13,7 @@
// | Offset | Size | Contents
// --------------------------
#define CAUGHT_DATA 0x00 // | 0x0 | 32 | Flags for each Pokemon species
#define TUTORIAL_FLAG 0x20 // | 0x1 | 1 | Has made it through the tutorial
#define TUTORIAL_FLAG 0x20 // | 0x21 | 1 | Has made it through the tutorial
#define DEFAULT_LANGUAGE 0x21 // | 0x22 | 1 | Default international language
#define SAVE_DATA_SIZE 0x22
@ -23,7 +23,6 @@ void load_custom_save_data();
void write_custom_save_data();
bool is_caught(int dex_num);
void set_caught(int dex_num);
int get_def_lang();
void set_def_lang(int nLang);
int get_def_lang_num();
bool get_tutorial_flag();

View File

@ -8,13 +8,13 @@
#define SBB 24
int x, y;
void background_frame()
void background_frame(int global_frame_count)
{
x++;
y++;
x++;
y++;
REG_BG0HOFS = x;
REG_BG0VOFS = y;
REG_BG0HOFS = x;
REG_BG0VOFS = y;
}
void set_textbox_large()

View File

@ -16,7 +16,7 @@ void global_next_frame()
rand_next_frame();
// tte_set_pos(0, 0);
// tte_write(std::to_string(get_rand_u32()).c_str());
background_frame();
background_frame(global_frame_count);
oam_copy(oam_mem, obj_buffer, num_sprites);
VBlankIntrWait();
// mmFrame(); //Music

View File

@ -40,6 +40,7 @@ TODO:
- MissingNo/Enigma Berry
- Text translations
- Add support for other languages
- Add in dolls for gen 2/3
- Doxygen generation
--------
*/
@ -80,6 +81,16 @@ int test_main(void) Music
}
*/
template <typename I>
std::string n2hexstr(I w, size_t hex_len = sizeof(I) << 1)
{
static const char *digits = "0123456789ABCDEF";
std::string rc(hex_len, '0');
for (size_t i = 0, j = (hex_len - 1) * 4; i < hex_len; ++i, j -= 4)
rc[i] = digits[(w >> j) & 0x0f];
return rc;
}
void load_graphics()
{
tte_erase_rect(0, 0, H_MAX, V_MAX);
@ -144,7 +155,6 @@ void game_load_error(void)
tte_set_margins(40, 24, 206, 104);
set_textbox_large();
tte_write("#{cx:0xF000}The Pok@mon save\nfile was not loaded successfully.\n\nPlease remove and\nreinsert the Game\nPak, and then press the A button.");
// tte_write(std::to_string(get_gamecode() >> 8).c_str());
key_poll();
while (!key_hit(KEY_A))
{
@ -199,6 +209,7 @@ int credits()
{
set_textbox_large();
tte_write(credits_array[curr_credits_num].c_str());
if (key_hit(KEY_B))
{
hide_text_box();
@ -213,9 +224,69 @@ int credits()
{
curr_credits_num++;
}
if (ENABLE_DEBUG_SCREEN && key_hit(KEY_SELECT))
{
u32 pkmn_flags = 0;
bool e4_flag = read_flag(curr_rom.e4_flag);
bool mg_flag = read_flag(curr_rom.mg_flag);
bool all_collected_flag = read_flag(curr_rom.all_collected_flag);
for (int i = 0; i < 30; i++)
{
pkmn_flags |= (read_flag(curr_rom.pkmn_collected_flag_start + i) << i);
}
bool tutorial = get_tutorial_flag();
int def_lang = get_def_lang_num();
set_textbox_large();
tte_write("Debug info:\n\nG: ");
std::string lang;
lang += curr_rom.language;
tte_write(lang.c_str());
switch (curr_rom.gamecode)
{
case RUBY_ID:
tte_write("-R-");
break;
case SAPPHIRE_ID:
tte_write("-S-");
break;
case FIRERED_ID:
tte_write("-F-");
break;
case LEAFGREEN_ID:
tte_write("-L-");
break;
case EMERALD_ID:
tte_write("-E-");
break;
}
tte_write(std::to_string(curr_rom.version).c_str());
tte_write("\nF: ");
tte_write(std::to_string(e4_flag).c_str());
tte_write(std::to_string(mg_flag).c_str());
tte_write(std::to_string(all_collected_flag).c_str());
tte_write("-");
tte_write((n2hexstr(pkmn_flags)).c_str());
tte_write("\nS: ");
tte_write(std::to_string(tutorial).c_str());
tte_write("-");
tte_write((n2hexstr(def_lang)).c_str());
while (true)
{
if (key_hit(KEY_B))
{
hide_text_box();
set_textbox_small();
return 0;
}
global_next_frame();
}
}
global_next_frame();
}
}
};
int main(void)
{

View File

@ -1000,6 +1000,8 @@ byte *generate_payload(GB_ROM curr_rom, bool debug)
// ld [hl], a
payload_storage[offset++] = 0x77;
// call TakePartyItem
// call _RemovePokemon
if (DONT_REMOVE_PKMN)
{
@ -1007,6 +1009,7 @@ byte *generate_payload(GB_ROM curr_rom, bool debug)
}
else
{
//write_call(curr_rom.generation, payload_storage, offset, 0x046C60);
write_call(curr_rom.generation, payload_storage, offset, curr_rom._RemovePokemon);
}
@ -1092,7 +1095,7 @@ int test_main() // Rename to "main" to send the payload to test_payload.txt
{
freopen("test_payload.txt", "w", stdout);
std::cout << std::endl;
byte *payload = generate_payload(ENG_YELLOW, true);
byte *payload = generate_payload(ENG_CRYSTAL, true);
for (int i = 0; i < PAYLOAD_SIZE; i++)
{
std::cout << "0x" << std::setfill('0') << std::setw(2) << std::hex << std::uppercase << (unsigned int)payload[i] << ", ";

File diff suppressed because it is too large Load Diff