fork/training-mode-ce

git clone https://git.julia.blue/fork/training-mode-ce

Alex Harrisonextract and version old savestate versiondcc8e3f

nix
8.3 KiB208 linesraw
1#ifndef SAVESTATE_V1_H
2#define SAVESTATE_V1_H
3
4#include "../MexTK/mex.h"
5
6#define EVENT_DATASIZE 512
7
8typedef struct FtSaveStateData_v1
9{
10    int is_exist;
11    int state_id;
12    float facing_direction;
13    float state_frame;
14    float state_rate;
15    float state_blend;
16    // Legacy - no longer used now that we update the animation when restoring state.
17    Vec4 XRotN_rot; // XRotN
18    struct phys phys;
19    ColorOverlay color[3];
20    struct input input;
21    CollData coll_data;
22    struct
23    {
24        void *alloc;            // 0x0
25        CmSubject *next;        // 0x4
26        int kind;               // 0x8 1 = disabled, 2 = only focus if close to center
27        u8 flags_x80 : 1;       // 0xC 0x80
28        u8 is_disable : 1;      // 0xC 0x40
29        Vec3 cam_pos;           // 0x10
30        Vec3 bone_pos;          // 0x1c
31        float direction;        // 0x28
32        float boundleft_curr;   // 0x2C
33        float boundright_curr;  // 0x30
34        float boundtop_curr;    // 0x34
35        float boundbottom_curr; // 0x38
36        float x3c;              // 0x3c
37        float boundleft_proj;   // 0x40
38        float boundright_proj;  // 0x44
39        float boundtop_proj;    // 0x48
40        float boundbottom_proj; // 0x4c
41        // the savestate CmSubject struct is missing one field compared
42        // to the CmSubject struct defined in MexTK
43    } camera_subject;
44    ftHit hitbox[4];
45    ftHit throw_hitbox[2];
46    ftHit thrown_hitbox;
47    struct flags flags;                // 0x2210
48    struct fighter_var fighter_var;    // 0x222c
49    struct state_var state_var;        // 0x2340
50    struct ftcmd_var ftcmd_var;        // 0x2200
51    struct
52    {
53        int behavior;                  // 0x182c
54        float percent;                 // 0x1830
55        int x1834;                     // 0x1834
56        float percent_temp;            // 0x1838
57        int applied;                   // 0x183c
58        int x1840;                     // 0x1840
59        FtDmgLog hit_log;              // 0x1844, info regarding the last solid hit
60        FtDmgLog tip_log;              // 0x1870, info regarding the last phantom hit
61        float tip_hitlag;              // 0x189c, hitlag is stored here during phantom hits @ 8006d774
62        float tip_force_applied;       // 0x18a0, used to check if a tip happened this frame
63        float kb_mag;                  // 0x18a4  kb magnitude
64        int x18a8;                     // 0x18a8
65        int time_since_hit;            // 0x18ac   in frames
66        float armor_unk;               // 0x18b0, is prioritized over the armor below
67        float armor;                   // 0x18b4, used by yoshi double jump
68        Vec2 vibrate_offset;           // 0x18b8
69        int x18c0;                     // 0x18c0
70        int source_ply;                // 0x18c4   damage source ply number
71        int x18c8;                     // 0x18c8
72        int x18cc;                     // 0x18cc
73        int x18d0;                     // 0x18d0
74        int x18d4;                     // 0x18d4
75        int x18d8;                     // 0x18d8
76        int x18dc;                     // 0x18dc
77        int x18e0;                     // 0x18e0
78        int x18e4;                     // 0x18e4
79        int x18e8;                     // 0x18e8
80        u16 atk_instance_hurtby;       // 0x18ec. Last Attack Instance This Player Was Hit by,
81        int x18f0;                     // 0x18f0
82        int x18f4;                     // 0x18f4
83        u8 vibrate_index;              // 0x18f8, which dmg vibration values to use
84        u8 x18f9;                      // 0x18f9
85        u16 vibrate_timer;             // 0x18fa
86        u8 vibrate_index_cur;          // 0x18fc, index of the current offset
87        u8 vibrate_offset_num;         // 0x18fd, number of different offsets for this dmg vibration index
88        Vec2 ground_slope;             // 0x1900
89        int x1908;                     // 0x1908
90        void *random_sfx_table;        // 0x190c, contains a ptr to an sfx table when requesting a random sfx
91        int x1910;                     // 0x1910
92        int x1914;                     // 0x1914
93        struct                         // aka clank
94        {                              //
95            int dmg_dealt;             // 0x1918,
96            float dmg_based_rate_mult; // 0x191c, updated @ 80077aec (when hitting projectile). is equal to 3 + (damageDealt * 0.3)
97            float dir;                 // 0x1920, direction the rebound/clank occured in
98        } rebound;                     //
99        int x1924;                     // 0x1924
100        int x1928;                     // 0x1928
101        int x192c;                     // 0x192c
102        struct                         // 0x1930
103        {                              //
104            Vec3 pos_prev;             // 0x1930
105            Vec3 pos_cur;              // 0x193c
106        } footstool;                   //
107        int x1948;                     // 0x1948
108        int x194c;                     // 0x194c
109        int x1950;                     // 0x1950
110        float x1954;                   // 0x1954,
111        float hitlag_env_frames;       // 0x1958, Environment Hitlag Counter (used for peachs castle switches)
112        float hitlag_frames;           // 0x195c
113        // the savestate dmg struct is missing two fields compared
114        // to the dmg struct defined in MexTK
115    } dmg;
116    struct grab grab;                  // 0x1a4c
117    struct jump jump;                  // 0x1968
118    struct smash smash;                // 0x2114
119    struct hurt hurt;                  // 0x1988
120    struct shield shield;
121    struct shield_bubble shield_bubble;   // 0x19c0
122    struct reflect_bubble reflect_bubble; // 0x19e4
123    struct absorb_bubble absorb_bubble;   // 0x1a08
124    struct reflect_hit reflect_hit;       // 0x1a2c
125    struct absorb_hit absorb_hit;         // 0x1a40
126    struct cb cb;
127} FtSaveStateData_v1;
128
129typedef struct FtSaveState_v1
130{
131    FtSaveStateData_v1 data[2];
132    struct
133    {
134        int state;           // 0x00 = not present, 0x02 = HMN, 0x03 = CPU
135        int c_kind;          // external ID
136        int p_kind;          // (0x00 is HMN, 0x01 is CPU, 0x02 is Demo, 0x03 n/a)
137        u8 isTransformed[2]; // 0xC, 1 indicates the fighter that is active
138        Vec3 tagPos;         // 0x10
139        Vec3 spawnPos;       // 0x1C
140        Vec3 respawnPos;     // 0x28
141        int x34;
142        int x38;
143        int x3C;
144        float initialFacing; // 0x40
145        u8 costume;          // 0x44
146        u8 color_accent;     // 0x45, will correspond to port color when ffa and team color when teams
147        u8 tint;             // 0x46
148        u8 team;             // 0x47
149        u8 controller;       // 0x48
150        u8 cpuLv;            // 0x49
151        u8 cpuKind;          // 0x4a
152        u8 handicap;         // 0x4b
153        u8 x4c;              // 0x4c
154        u8 kirby_copy;       // 0x4d, index of kirby copy ability
155        u8 x4e;              // 0x4e
156        u8 x4f;              // 0x4f
157        float attack;        // 0x50
158        float defense;       // 0x54
159        float scale;         // 0x58
160        u16 damage;          // 0x5c
161        u16 initialDamage;   // 0x5e
162        u16 stamina;         // 0x60
163        int falls[2];        // 0x68
164        int ko[6];           // 0x70
165        int x88;
166        u16 selfDestructs;
167        u8 stocks;
168        int coins_curr;
169        int coins_total;
170        int x98;
171        int x9c;
172        int stickSmashes[2];
173        int tag;
174        u8 xac_80 : 1;        // 0xac, 0x80
175        u8 is_multispawn : 1; // 0xac, 0x40
176        u8 xac_3f : 6;        // 0xac, 0x3f
177        u8 xad;               // 0xad
178        u8 xae;               // 0xae
179        u8 xaf;               // 0xaf
180        GOBJ *gobj[2];        // 0xb0
181        // Omitting Playerblock fields recently added to MexTK
182    } player_block;
183    int stale_queue[11];
184} FtSaveState_v1;
185
186typedef struct Savestate_v1
187{
188    int is_exist;
189    int frame;
190    u8 event_data[EVENT_DATASIZE];
191    FtSaveState_v1 ft_state[6];
192} Savestate_v1;
193
194enum savestate_flags {
195    // save: perform initial safety checks 
196    Savestate_Checks = 1 << 0,
197    
198    // save/load: don't play sfx and screen flash 
199    Savestate_Silent = 1 << 1,
200    
201    // load: mirror savestate
202    Savestate_Mirror = 1 << 2,
203};
204
205int Savestate_Save_v1(Savestate_v1 *savestate, int flags);
206int Savestate_Load_v1(Savestate_v1 *savestate, int flags);
207
208#endif