Save adventure location with team and inventory

This commit is contained in:
LyokoAgents committed 2026-10-28 23:59:14 +00:00
1 parent 1141765231
commit 59c44c2b45
16 files changed
+444 -203

No files matched your search

+48 -7
View File
@@ -5,13 +5,54 @@ unsigned char test_save[32];
void save_from_menu(void)
{
assert(!save_menu_input(0, 1));
assert(save_menu_input(START, 1) && save_menu.phase == SAVE_MENU_OPTIONS);
assert(!save_menu_input(0, 1));
assert(save_menu_input(A, 1) && save_menu.phase == SAVE_MENU_SAVED);
assert(!save_menu_input(0, 1));
assert(save_menu_input(B, 1) && save_menu.phase == SAVE_MENU_CLOSED);
assert(!save_menu_input(0, 1));
struct Location location;
default_location(&location);
save_at_menu(&location, SAVE_MENU_SAVED);
}
int menu_input(unsigned keys, int can_open)
{
struct Location location;
default_location(&location);
return save_menu_input(keys, can_open, &location);
}
void save_at_menu(const struct Location *location, enum SaveMenuPhase expected)
{
assert(!save_menu_input(0, 1, location));
assert(save_menu_input(START, 1, location) && save_menu.phase == SAVE_MENU_OPTIONS);
assert(!save_menu_input(0, 1, location));
assert(save_menu_input(A, 1, location) && save_menu.phase == expected);
assert(!save_menu_input(0, 1, location));
assert(save_menu_input(B, 1, location) && save_menu.phase == SAVE_MENU_CLOSED);
assert(!save_menu_input(0, 1, location));
}
void checksum_fixture(void)
{
if (test_save[4] == 6) {
unsigned crc = save_crc(test_save, 17);
test_save[17] = (unsigned char)(crc >> 8);
test_save[18] = (unsigned char)crc;
} else {
unsigned checksum = 0xa5 ^ test_save[4] ^ test_save[5] ^ test_save[6];
if (test_save[4] >= 3) {
checksum ^= test_save[7];
for (int i = 0; i < CAUGHT_CAPACITY; ++i) checksum ^= test_save[8 + i];
}
test_save[test_save[4] == 2 ? 7 : 13] = (unsigned char)checksum;
test_save[test_save[4] == 2 ? 8 : 14] = 0x5a;
}
}
/* Convert a fixture, never player data, retaining only fields supported by that version. */
void legacy_fixture(int version)
{
test_save[4] = (unsigned char)version;
test_save[5] &= version == 5 ? 63 : version == 4 ? 7 : 3;
if (version == 1) {
test_save[5] = 1; test_save[6] = 0xa5; test_save[7] = 0x5a;
} else checksum_fixture();
}
void render_scene(int x, int y)