-
Notifications
You must be signed in to change notification settings - Fork 0
/
TR4SaveGame.h
585 lines (467 loc) · 17.9 KB
/
TR4SaveGame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
#pragma once
#include "TRXTools.h"
#include "TR45SaveGame.h"
//
/////////////////////////////////////////////////////////////////////////////
// TR4SaveGame.h : header file
//
/////////////////////////////////////////////////////////////////////////////
//
// 00000001
#define TR40_GUN_SET1 0x01
// 00000100
#define TR40_GUN_SET4 0x04
// 00001000
#define TR40_GUN_SET8 0x08
// 00001001
#define TR40_GUN_SET (TR40_GUN_SET1|TR40_GUN_SET8)
// 00001101
#define TR40_GUN_MASK (TR40_GUN_SET1|TR40_GUN_SET4|TR40_GUN_SET8)
//
/////////////////////////////////////////////////////////////////////////////
// CTR4SaveGame document
//
/////////////////////////////////////////////////////////////////////////////
/*
* ------------------------------------------------
* Definition.
* ------------------------------------------------
*/
#define TR4MAXLEVEL 38
#define TR4BUFFEREND 14014
#define TR4LEVELMINSIZE 15954
#define TR4LEVELMAXSIZE 15955
//
// 0x3ed :
// 0x3ef :
// 0x3f0 0x3f1
// East West : 0x3f0 0x3f1 0x3f7
// Height : 0x3f2 0x3f3 and 0x3f7
// North South : 0x3f4 0x3f5 0x3f7
// 0x3f6 : room
// 0x3f6 - 0x3f7 : Orientation
/*
* ------------------------------------------------
* Structures.
* ------------------------------------------------
*/
#pragma pack(push, pack1, 1)
// Position is Variable
// The room may be 82 (dec) before the 02 02 xx 67
// This structure is 8 before the 02 02 xx 67
#define TR4_POSITION_OFFSET 11
#define TR4_FACTOR 2L
struct TR4_POSITION
{
BYTE cMoving1; // 0000 Change when moving
BYTE unknown1; // 0001
WORD wWestToEast; // 0002-0003 Change when moving East West
short wVertical; // 0004-0005
WORD wSouthToNorth; // 0006-0007 Change when moving South North
BYTE cRoom; // 0008
BYTE unknown2; // 0009
BYTE cOrientation; // 000a
BYTE indicator1; // 000b eg 0x02
BYTE indicator2; // 000c eg 0x02
BYTE indicator3; // 000d
BYTE indicator4; // 000e eg 0x67
BYTE unknown3; // 000f
BYTE cMoving2; // 0010 Change when moving
BYTE unknown4;
WORD heath; // 0012
};
#define TR4_LIFE_OFFSET (offsetof(TR4_POSITION,heath)-offsetof(TR4_POSITION,indicator1))
struct TR4Gun
{
// 0x169 : 09
BYTE m_gunPistol;
// 0x16a : 01
BYTE m_gunUzis;
// 0x16b : 09
BYTE m_gunRiotGun;
// 0x16c : 09
BYTE m_gunCrossBow;
// 0x16d : 09
BYTE m_gunGrenadesLauncher;
// 0x16e : 01
BYTE m_gunRevolver;
// 0x16f : 01
BYTE m_gunLaserLight;
// 0x170 : 01
BYTE m_gunBinocular;
// 0x171 : 01
BYTE m_gunCrowBar;
// 0x172-0x18e : Objects
union
{
BYTE m_Object [ 29 ];
struct Detailed
{
// Address : 1 - 3 : 3 Object
BYTE m_Objects [ 3 ];
// Address : 4 - 6 : 3 Examine
BYTE m_Examine [ 3 ];
// Address : 7 - 18 : 12 Puzzle
BYTE m_Puzzle [ 12 ];
// 19 - 20 : 16 (8 Puzzle Combo * 2)
BYTE m_PuzzleCombo [ 2 ]; // Four by byte
// Address : 21 - 22 : 12 Keys
// Byte 1 : Keys 1 to 8
// Byte 2 : Keys 9 to 12
BYTE m_Key [ 2 ]; // Six by byte
// Address : 23 - 24 : 16 (8 Key Combo * 2)
// 8 Key Combo3
BYTE m_KeyCombo [ 2 ]; // Three by byte
// Address : 25 - 26 : 4 Pickup
// Seem to be 4 by byte only first byte used
BYTE m_Pickup [ 2 ]; // Four by byte
// Address : 27 - 28 : 8 (4 Pickup Combo * 2)
BYTE m_PickupCombo [ 2 ]; // Four by byte
// Address : 29
// Amulet
BYTE m_Amulet;
};
};
};
typedef struct TR4Gun TR4GUN;
struct TR4Ammo
{
// 0x190
WORD m_iSmallMedipak;
// 0x192
WORD m_iLargeMedipak;
// 0x194 / 0x195 : 01
WORD m_iFlares;
// 0x196
// Normally 0xFFFF
WORD m_iGunAmmos;
// 0x198
WORD m_iUziAmmos;
// 0x19a
WORD m_iRevolverAmmos;
// 0x19c/ 0x19d
WORD m_iShotGunAmmo1;
// 0x19e/ 0x19f
WORD m_iShotGunAmmo2;
// 0x1A0
WORD m_iGrenade1;
// 0x1A2
WORD m_iGrenade2;
// 0x1A4
WORD m_iGrenade3;
// 0x1A6
WORD m_iCrossbow1;
// 0x1A8
WORD m_iCrossbow2;
// 0x1AA
WORD m_iCrossbow3;
//
BYTE m_Filler2 [ 0x1fb - 0x1AA - sizeof(short) ];
// 0x1fb
BYTE m_iSecretCount;
};
typedef struct TR4Ammo TR4AMMO;
struct TR4Save
{
union
{
struct
{
char szSavename [ 24 ];
char cFiller1 [ 51 ];
// 0x4b / 0x4c
WORD iSaveNumber;
};
struct
{
char cFiller1A [ 0x9B ];
// 0x9b
// 0x04 = normal
// 0x0c = burning
BYTE laraState;
};
struct
{
char cFiller1B [ 0x6d ];
WORD iAir;
};
struct
{
char cFiller2 [ 0x169 ];
// 0x169
TR4GUN tagGuns;
};
struct
{
char cFiller3 [ 0x190 ];
// 0x194
TR4AMMO tagAmmo;
};
struct
{
char cFiller3b [ 0x1b5];
// 0x1b5
BYTE m_cLevels [ 10 ];
};
// 0x1e8 : statistics timing ...
// 000001ED distance
// 0x3e51 une sorte de checksum
struct
{
char cFiller4 [ 0x3e51 ];
BYTE checkSum;
};
struct
{
char cFullBuffer [ TR4LEVELMAXSIZE ];
};
};
};
typedef struct TR4Save TR4SAVE;
#pragma pack(pop, pack1)
class CTR4SaveGame : public CTR45SaveGame
{
DECLARE_DYNAMIC(CTR4SaveGame)
friend class CTRSaveGame;
protected:
CTR4SaveGame();
public:
virtual ~CTR4SaveGame();
// Attributes
protected :
TR4SAVE *m_pBuffer;
TR4SAVE *m_pBufferBackup;
protected :
// Mask
BYTE iMaskCompass;
BYTE iMaskGun;
BYTE iMaskPistol;
BYTE iMaskRevolver;
BYTE iMaskUzi;
BYTE iMaskRiotGun;
BYTE iMaskCrossBow;
BYTE iMaskGrenade;
BYTE iMaskCrowBar;
BYTE iMaskHeadSet;
BYTE iMaskLaser;
BYTE iMaskBinocular;
BYTE iRiotGunUnits;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTR4SaveGame)
public:
//}}AFX_VIRTUAL
// Implementation
public:
char *getBufferAddress ();
char *getBufferBackupAddress ();
size_t getBufferLength();
BOOL BufferModified();
void discard();
int GetLaraState ( );
void SetLaraState ( int state );
WORD *GetTR4LifeAddress();
int GetLife ();
void SetLife ( const char *szLife );
void *GetIndicatorAddress ( int index = 0 );
int GetMap1 ();
int GetMap2 ();
int GetItem1 ();
int GetItem2 ();
int GetItem3 ();
int GetItem4 ();
int GetKey1 ();
int GetKey2 ();
int GetKey3 ();
int GetKey4 ();
int GetTreasure1 ( int iX );
int GetTreasure2 ( int iX );
int GetTreasure3 ( int iX );
int GetTreasure4 ( int iX );
void SetMap1 ( char *szString );
void SetMap2 ( char *szString );
void SetItem1 ( char *szString );
void SetItem2 ( char *szString );
void SetItem3 ( char *szString );
void SetItem4 ( char *szString );
void SetKey1 ( char *szString );
void SetKey2 ( char *szString );
void SetKey3 ( char *szString );
void SetKey4 ( char *szString );
void SetTreasure1 ( char *szString, int iX );
void SetTreasure2 ( char *szString, int iX );
void SetTreasure3 ( char *szString, int iX );
void SetTreasure4 ( char *szString, int iX );
void SetAllObjects ();
int IsLaraBurning ();
void SetLaraBurning (int state = -1);
void SetLaraNoBurning (int state = -1);
char *GetSaveName ();
int GetSaveNumber ();
int GetCurrentSecrets ( );
void SetCurrentSecrets ( char *szString, int iX = -1 );
void SetAllSecrets ( );
int GetMaximumSecrets ( int iX );
int GetUnlimitedAmmos();
void SetUnlimitedAmmos ( int iMask );
int GetGunAmmos ( );
int GetSmallMedipak ( int iX );
int GetLargeMedipak ( int iX );
int GetAir ( );
int GetFlares ( int iX );
int GetLaser ( int iX = 0 );
int GetBinocular ( int iX = 0 );
void SetGunAmmos ( const char *szGunAmmos );
void SetSmallMedipak ( const char *szString, int iX );
void SetLargeMedipak ( const char *szString, int iX );
void SetAir ( const char *szString );
void SetFlares ( const char *szString, int iX );
void SetLaser ( char *szString, int iX );
void SetBinocular ( char *szString, int iX );
int CheckWeapon1 ( int iX );
int CheckWeapon2 ( int iX );
int CheckWeapon3 ( int iX );
int CheckWeapon4 ( int iX );
int CheckWeapon5 ( int iX );
int CheckWeapon6 ( int iX );
int CheckWeapon7 ( int iX );
int CheckWeapon8 ( int iX );
int CheckWeapon9 ( int iX );
// No Compass
BYTE GrabWeapon0 ( int iX, bool bAdd = true, bool bChange = true );
virtual BOOL HasWeapon0 () { return TRUE; };
virtual BOOL HasAmmos0 () { return FALSE; };
// Pistols
BYTE GrabWeapon1 ( int iX, bool bAdd = true, bool bChange = true );
virtual BOOL HasWeapon1 () { return CTRXTools::IsEnablePistol(getFullVersion(), getLevel() ); };
virtual BOOL HasAmmos1 () { return TRUE; };
// Pistols
virtual const char *GetLabel1() { return "Guns / Pistols"; };
virtual UINT GetBitmap1 ( ) { return IDB_GUNS; };
// Revolver
BYTE GrabWeapon2 ( int iX, bool bAdd = true, bool bChange = true );
virtual BOOL HasWeapon2 () { return CTRXTools::IsEnableMagnum(getFullVersion(), getLevel() ); };
virtual BOOL HasAmmos2 () { return CTRXTools::IsAmmosMagnum(getFullVersion(), getLevel() ); };
// Revolver
virtual const char *GetLabel2() { return "Revolver"; };
virtual UINT GetBitmap2 ( ) { return IDB_REVOLVER; };
// Uzi
BYTE GrabWeapon3 ( int iX, bool bAdd = true, bool bChange = true );
virtual BOOL HasWeapon3 () { return CTRXTools::IsEnableUzi(getFullVersion(), getLevel() ); };
virtual BOOL HasAmmos3 () { return CTRXTools::IsAmmosUzi(getFullVersion(), getLevel() ); };
// Uzi
virtual const char *GetLabel3() { return "Uzi"; };
virtual UINT GetBitmap3 ( ) { return IDB_UZIS; };
// Riot Gun
BYTE GrabWeapon4 ( int iX, bool bAdd = true, bool bChange = true );
virtual BOOL HasWeapon4 () { return CTRXTools::IsEnableRiotgun(getFullVersion(), getLevel() ); };
virtual BOOL HasAmmos4 () { return CTRXTools::IsAmmosRiotgun(getFullVersion(), getLevel() ); };
// Riot Gun
virtual const char *GetLabel4() { return "Riot Gun"; };
virtual UINT GetBitmap4 ( ) { return IDB_RIOT_GUN; };
//
BYTE GrabWeapon5 ( int iX, bool bAdd = true, bool bChange = true );
virtual BOOL HasWeapon5 () { return CTRXTools::IsEnableM16(getFullVersion(), getLevel() ); };
virtual BOOL HasAmmos5 () { return CTRXTools::IsAmmosM16(getFullVersion(), getLevel() ); };
//
BYTE GrabWeapon6 ( int iX, bool bAdd = true, bool bChange = true );
virtual BOOL HasWeapon6 () { return CTRXTools::IsEnableRocket(getFullVersion(), getLevel() ); };
virtual BOOL HasAmmos6 () { return CTRXTools::IsAmmosRocket(getFullVersion(), getLevel() ); };
// Grenade Launcher
BYTE GrabWeapon7 ( int iX, bool bAdd = true, bool bChange = true );
virtual BOOL HasWeapon7 () { return CTRXTools::IsEnableGrenade(getFullVersion(), getLevel() ); };
virtual BOOL HasAmmos7 () { return CTRXTools::IsAmmosGrenade(getFullVersion(), getLevel() ); };
// Grenade Launcher
virtual const char *GetLabel7() { return "Grenade Launcher"; };
virtual UINT GetBitmap7 ( ) { return IDB_GRENADE_LAUNCHER; };
// Crossbow
BYTE GrabWeapon8 ( int iX, bool bAdd = true, bool bChange = true );
virtual BOOL HasWeapon8 () { return CTRXTools::IsEnableHarpoon(getFullVersion(), getLevel() ); };
virtual BOOL HasAmmos8 () { return CTRXTools::IsAmmosHarpoon(getFullVersion(), getLevel() ); };
// Crossbow
virtual const char *GetLabel8() { return "Crossbow"; };
virtual UINT GetBitmap8 ( ) { return IDB_CROSSBOW; };
// Crossbar
BYTE GrabWeapon9 ( int iX, bool bAdd = true, bool bChange = true );
virtual BOOL HasWeapon9 () { return CTRXTools::IsEnableCrowbar(getFullVersion(), getLevel() ); };
virtual BOOL HasAmmos9 () { return FALSE; };
// Crossbow
virtual const char *GetLabel9() { return "Crowbar"; };
virtual UINT GetBitmap9 ( ) { return IDB_CROWBAR; };
//
virtual UINT GetAmmoBitmap1 ( ) { return IDB_AMMOS_GUNS; };
//
int GetAmmos1( int iX );
void SetAmmos1 ( const char *szString, int iX );
//
int GetAmmos2( int iX );
virtual UINT GetAmmoBitmap2 ( ) { return IDB_AMMOS_REVOLVER; };
void SetAmmos2 ( const char *szString, int iX );
//
int GetAmmos3( int iX );
virtual UINT GetAmmoBitmap3 ( ) { return IDB_AMMOS_UZIS; };
void SetAmmos3 ( const char *szString, int iX );
//
int GetAmmos4a ( int iX );
int GetAmmos4b ( int iX );
virtual UINT GetAmmoBitmap4 ( ) { return IDB_AMMOS_RIOTGUN; };
void SetAmmos4a ( const char *szString, int iX );
void SetAmmos4b ( const char *szString, int iX );
//
int GetAmmos5 ( int iX );
virtual UINT GetAmmoBitmap5 ( ) { return IDB_AMMOS_GUNS; };
void SetAmmos5 ( const char *szString, int iX );
//
int GetAmmos6( int iX );
virtual UINT GetAmmoBitmap6 ( ) { return IDB_AMMOS_GUNS; };
void SetAmmos6 ( const char *szString, int iX );
int GetAmmos7a( int iX );
int GetAmmos7b( int iX );
int GetAmmos7c( int iX );
virtual UINT GetAmmoBitmap7 ( ) { return IDB_AMMOS_GRENADES; };
void SetAmmos7a ( const char *szString, int iX );
void SetAmmos7b ( const char *szString, int iX );
void SetAmmos7c ( const char *szString, int iX );
//
int GetAmmos8a( int iX );
int GetAmmos8b( int iX );
int GetAmmos8c( int iX );
virtual UINT GetAmmoBitmap8 ( ) { return IDB_AMMOS_ARROW; };
void SetAmmos8a ( const char *szString, int iX );
void SetAmmos8b ( const char *szString, int iX );
void SetAmmos8c ( const char *szString, int iX );
//
virtual BOOL HasItems ( ) { return TRUE; };
virtual void SetItems ( int item, BYTE value );
virtual BYTE GetItems ( int item );
// Simple Check for version TR4
int Valid ();
void SetInvalid ();
virtual int getLevelIndex();
virtual int getLevel();
const char *GetStatus ();
void GetDetailedInfo ( char *szGame, size_t iSize, int *iGame, int *iLevel,
char *szTitle, size_t iSizeTile );
void writeSaveGame();
int ReadSavegame( const char *pFilename );
void RetrieveInformation( const char *pFilename );
TR4GUN *SearchGunStructure ( WORD m_iHealth, int *iPos );
int CheckIfAmmosMatch ( TR4GUN *pGun, WORD gunBitmap );
void RetrieveHeader();
void GetAmmosValues ( );
int ConvertSecretBack ( int iSecret );
int ConvertSecret ( int iSecret );
const TR_POSITION *GetPosition ( );
TR4_POSITION *GetTR4Position ( );
BOOL SetPosition ( DWORD dwWestToEast, DWORD dwVertical, DWORD dwSouthToNorth, WORD wDirection, WORD wRoom );
static const char *GetIndicatorFileType()
{
return ".tr4.txt";
}
// Generated message map functions
};
//
extern TR45_INDICATORS IndicatorsTR4Table [ MAX_INDICATORS ];
extern int IndicatorsTR4TableCount;