Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef inc_save
- #define inc_save
- #include "types.h"
- #include "enumerations.h"
- #pragma pack(push)
- #pragma pack(1)
- namespace inindo
- {
- enum lineup_t : u08
- {
- front_right,
- front_center,
- front_left,
- rear_right,
- rear_center,
- rear_left,
- };
- enum location_type_t : u08
- {
- castle,
- inn,
- tea,
- unk,
- };
- enum game_mode_t : u08
- {
- normal,
- sorcerer,
- };
- struct save_data_t
- {
- // 000
- u08 head[2];
- struct date_t
- {
- // 002
- u08 year;
- // 003
- u08 month;
- // 004
- u08 day;
- // 005
- u08 time;
- } date;
- // 006
- u08 unk0;
- // 007
- // energy left before rest needed
- // max 180 = 60 time units * 3 days
- u08 strength;
- // 008
- u08 unk1a;
- // 009
- // high nibble = step (8)
- // low nibble = facing direction (NWES = 0123)
- u08 unk1b;
- // 00a
- u08 unk1c;
- // 00b
- u16 unk2[2];
- // 00f
- struct party_t
- {
- // 00f
- struct location_t
- {
- // world (nihon) map position
- // 00f
- u16 w[4];
- // sub-map position (town, dungeon, ...)
- // 017
- u16 x;
- // 019
- u16 y;
- } location;
- // 01b
- u16 gold;
- // 01d
- u08 size;
- // 01e
- u08 member_id[3];
- // combat formation
- // 021
- lineup_t lineup[3];
- // 024
- struct status_flags_t
- {
- // poison shows over injury
- u08 poison : 1;
- u08 injury : 1;
- // aphrodisia (eel extract) shows over poison or injury
- // makes you walk in random directions (?)
- // shows as "blind" in the US version
- // has own icon in the Japanese version
- u08 aphrodisia : 1;
- // other bits show up as injury (?)
- u08 unk45678 : 5;
- } status[3];
- // 027
- item_id_t inventory[3][15];
- } party;
- //
- struct pawn_t
- {
- u08 thousand_gold;
- item_id_t slot[31];
- } pawn;
- //
- struct bingo_t
- {
- u16 lowclass_chips;
- u16 highclass_chips;
- } bingo;
- // 078
- u08 player_level;
- // 079
- u16 unk3[24];
- // 0a9
- char name[11];
- // 0b4
- struct character_status_t
- {
- // static (ROM) character description index
- u08 character_index;
- // linked list starting from location flags
- // status index, not description index
- u08 with_index;
- u16 max_health;
- u16 health;
- u16 max_energy;
- u16 energy;
- u16 exp_needed;
- u08 level;
- struct flags_bitset_t
- {
- location_type_t location_type : 2;
- u08 unk345678 : 6;
- } flags;
- u08 trust;
- u08 intelligence;
- u08 speed;
- // 0c0
- u08 luck;
- u16 magic;
- u08 defense;
- u08 resist;
- u08 power;
- item_id_t equipped[5];
- u08 ai_data[3];
- struct ai_status_t
- {
- character_ai_command_t command : 3;
- u08 unk : 5;
- } ai_status;
- } status[63];
- // 894
- u16 unk4a[52];
- // 8fc
- u16 unk4b[16];
- // 91c
- struct province_t
- {
- u08 ruler;
- u08 daimyo;
- u16 gold;
- u16 rice;
- u16 soldiers;
- u08 arms;
- u08 training;
- u08 person[3];
- u08 trust[3];
- struct ai_status_t
- {
- province_id_t target_province : 5;
- province_ai_algorithm_t algorithm : 3;
- u08 people : 2;
- province_ai_command_t command : 2;
- u08 unk : 4;
- } ai_status;
- } province[30];
- // b38
- struct location_flags_t
- {
- // linked list end via status indices
- u08 visitor : 8;
- u08 unk1 : 8;
- u08 unk2 : 7;
- // the player has visited this location
- u08 visited : 1;
- } location[48];
- // bc8
- // most even bytes = 0, few change to 2
- u08 unk5[828];
- // f04
- // game flags
- // 0 - 17: 0 (null), 1 (active) or 2 (complete)
- // 18 is game mode: 0 (normal), 1 (magical)
- // 19 is unknown
- u08 flag[20];
- };
- // container that implements checksum functions
- struct save_container_t
- {
- u16 compute_checksum(const void *pdata, int length)
- {
- u08 *p = (u08 *)pdata;
- u16 checksum = 0;
- for (int i = 0; i < length; i++) {
- checksum += p[i];
- }
- return checksum;
- }
- bool fix_checksum()
- {
- const int game_data_size = sizeof(save_data_t);
- ASSERT(game_data_size == 3864);
- u16 new_checksum = compute_checksum(&save_data, game_data_size);
- if (new_checksum == checksum) {
- return false;
- } else {
- checksum = new_checksum;
- return true;
- }
- }
- bool is_dirty()
- {
- const int game_data_size = sizeof(save_data_t);
- ASSERT(game_data_size == 3864);
- u16 new_checksum = compute_checksum(&save_data, game_data_size);
- return (new_checksum != checksum);
- }
- void write(const char *filename);
- // 000
- save_data_t save_data;
- // f18
- u16 checksum;
- // f1a
- char koei[4];
- // f1e
- u08 padding[226];
- };
- };
- #pragma pack(pop)
- #endif
Advertisement
Advertisement
Advertisement
RAW Paste Data
Copied
Advertisement