Hi, I want to change the game time of FF8 for PSX.
I don't have Visual C++ 2006 but I downloaded Griever's source code and I wrote a program in C++ trying to change the game time.
It doesn't work. Here I post the source code of my program.
Can anyone tell me what it's wrong?
Thank you and a happy new year to all users.
This is my code:
#include <cstdlib>
#include <iostream>
#include <fstream>
//Types of data used in this program. I use Dev C++, and so I don't know if BYTE, USHORT, etc. that I defined here
//are the same types of Visual C++ 2006.
typedef char BYTE;
typedef unsigned short int USHORT;
typedef unsigned int UINT;
/////////////////////////////////////////////////////////////////
// Final Fantasy VIII codes
/*
This, untill the main program, is the structure of one FF8 save block
that I've found on Griever's source code.
*/
/*
enum FF8CHARID {
Squall,
Zell,
Irvine,
Quistis,
Rinoa,
Selphie,
Seifer,
Edea,
Laguna,
_zz1,
_zz2,
_blank,
Griever,
MiniMog,
Chicobo,
Angelo,
None = 0xFF
};
*/
#define CHAR_SQUALL 0
#define CHAR_ZELL 1
#define CHAR_IRVINE 2
#define CHAR_QUISTIS 3
#define CHAR_RINOA 4
#define CHAR_SELPHIE 5
#define CHAR_SEIFER 6
#define CHAR_EDEA 7
#define CHAR_LAGUNA 8
#define CHAR_KIROS 9
#define CHAR_WARD 10
#define CHAR_GRIEVER 12
#define CHAR_MINIMOG 13
#define CHAR_CHICOBO 14
#define CHAR_ANGELO 15
#define CHAR_NONE 0xFF
typedef BYTE FF8CHARID;
struct _FF8ITEM {
BYTE type;
char *name;
};
struct _FF8ABILITY {
BYTE type;
BYTE ap;
char *name;
};
struct _FF8MAGIC {
char *name;
};
#define CARD(t,l,r,b) { 0x##t,0x##l,0x##r,0x##b }
#define NONE -1
#define FIRE 0
#define ICE 1
#define THUNDER 2
#define EARTH 3
#define POISON 4
#define WIND 5
#define WATER 6
#define HOLY 7
#define SIMPLE 0
#define BOSS 1
#define GF 2
#define PLAYER 3
struct _FF8CARD {
char *name;
struct _FF8CARDVALUES {
char top;
char left;
char right;
char bottom;
} values;
char element;
char border;
};
struct _FF8CARDLOCATION {
char *name;
};
struct _FF8LOCATION {
char *name;
};
typedef BYTE _FF8INNATEABILITY;
/////////////////////////////////////////////////////////////////
// Final Fantasy VIII save file structures
// Unknown data
struct UNKNOWN {
UNKNOWN () { data = 0xFF; }
BYTE data;
};
// FF8 text identifier
typedef char FF8STR;
// Save file description block
struct FF8DESC {
USHORT checktag; // Tag - must be 0x0FF8
USHORT location; // Current location
UNKNOWN zz0[4];
USHORT saves; // Number of saves
UINT gil; // Gil
UINT seconds; // Game time
BYTE level; // Lead character's level
FF8CHARID party[3]; // [3] Current party
};
// Guardian Force block
struct FF8GF {
FF8STR name[10]; // [10] GF name
UNKNOWN zz1[2];
UINT exp; // GF EXP
UNKNOWN zz2;
BYTE found; // Has GF been found?
USHORT hp; // Current HP
BYTE abilities[16]; // [16] Learned abilities (bLearned[i] = abilities[i/8] & (1 << (i%8)))
BYTE ap[21]; // [21] Ability APs
UNKNOWN zz3[3];
USHORT kills; // Number of enemies killed
USHORT ko; // Number of KOs
BYTE learning; // Ability being learnt
BYTE forgotten[3]; // Abilities forgotten
};
// Magic block
struct FF8MAGIC {
BYTE type;
BYTE amount;
};
// Character block
struct FF8CHAR {
USHORT hp; // Current HP
USHORT basehp; // Base HP
UINT exp; // EXP
FF8CHARID id; // Character id
BYTE weapon; // Current weapon
BYTE str; // Strength
BYTE vit; // Vitality
BYTE mag; // Magic
BYTE spr; // Spr
BYTE spd; // Speed
BYTE luck; // Luck
FF8MAGIC magic[32]; // [32] Magic library (stock)
BYTE ab_command[3]; // [3] Command abilities
UNKNOWN zz;
BYTE ab_char[4]; // [4] Character abilities
USHORT gf; // Junctioned GFs
UNKNOWN zz2[2];
BYTE junction[19]; // [19] Junctions
// 00: HP Junction (Magic Type)
// 01: Str Junction (Magic Type)
// 02: Vit Junction (Magic Type)
// 03: Mag Junction (Magic Type)
// 04: Spr Junction (Magic Type)
// 05: Spd Junction (Magic Type)
// 06: Hit Junction (Magic Type)
// 07: Eva Junction (Magic Type)
// 08: Luck Junction (Magic Type)
// 09: Elem-Atk Junction (Magic Type)
// 10: ST-Atk Junction (Magic Type)
// 11: Elem-Def Junction 1 (Magic Type)
// 12: Elem-Def Junction 2 (Magic Type)
// 13: Elem-Def Junction 3 (Magic Type)
// 14: Elem-Def Junction 4 (Magic Type)
// 15: ST-Def Junction 1 (Magic Type)
// 16: ST-Def Junction 2 (Magic Type)
// 17: ST-Def Junction 3 (Magic Type)
// 18: ST-Def Junction 4 (Magic Type)
UNKNOWN zz3;
USHORT compat[16]; // [16] GF compatibility
USHORT kills; // Number of enemies killed
USHORT ko; // Number of KOs
BYTE stats; // Can view stats?
UNKNOWN zz4;
BYTE status; // Status effects
// 1: ????
// 2: Poison
// 4: Petrify
// 8: Darkness
// 16: Silence
// 32: Berserk
// 64: Zombie
// 128: ????
UNKNOWN zz5;
};
// Item block
struct FF8ITEM {
BYTE type;
BYTE amount;
};
// Card identifier
typedef BYTE FF8CARD; // 0x80: Collected 0x7F: Amount
// Rare cards: Location
struct FF8CONFIG {
BYTE spd_battle; // Battle speed (0=fast,4=slow)
BYTE spd_battlemsg; // Battle message speed (0=fast,4=slow)
BYTE spd_fieldmsg; // Field message speed (0=fast,4=slow)
BYTE soundvolume; // Sound volume (0-100(%))
BYTE options; // Misc. options
// 1: ATB - 1:Wait 0:Active
// 2: ???
// 4: Cursor - 1:Memory 0:Initial
// 8: ???
// 16: ???
// 32: Controller - 1:Customize 0:Normal
// 64: ???
// 128: ???
BYTE scan; // 1: Scan - 1:Always 0:Once
BYTE camera; // Camera movement (0=100%,4=0%)
UNKNOWN zz1;
UNKNOWN buttons[12]; // [12] Button configuration (?)
};
// Chocobo World data
struct FF8CHOCOBO {
UNKNOWN zz[64];
};
// Save file block
struct FF8BLOCK {
UNKNOWN zz1[384];
USHORT checksum1; // Checksum
FF8DESC desc; // Save block description
FF8STR squall[12]; // [12] Squall's name
FF8STR rinoa[12]; // [12] Rinoa's name
FF8STR angelo[8]; // [8] Angelo's name
UNKNOWN zz0[4];
FF8STR chicobo[4]; // [4] Chicobo's name
UNKNOWN zz01[8];
BYTE disc; // Current disc (zero based)
UNKNOWN zz[3];
UINT saves; // Number of times saved (*2?)
FF8GF gf[16]; // [16] GF blocks
FF8CHAR chars[8]; // [8] Character blocks
UNKNOWN zz2[400];
FF8CONFIG config; // Configuration
FF8CHARID party[3]; // [3] Party
UNKNOWN zz22[5];
FF8STR griever[8]; // [8] Griever's name
UNKNOWN zz23[8];
UINT gil; // Gil
UNKNOWN zz24[4];
BYTE limits[6]; // [6] Learned limit breaks
// [0]-[1] Quistis
// [2]-[3] Zell
// [4] Irvine
// [5] Selphie
BYTE combine_compl; // Rinoa's Combine: Angelo Abilities Completed
BYTE combine_known; // Rinoa's Combine: Angelo Abilities Known
BYTE combine_left[8]; // [8] Rinoa's Combine: Points left to learn different abilities
// [0] 'Angelo Rush' (max 10)
// [1] 'Angelo Recover' (max 30)
// [2] 'Angelo Reverse' (max 40)
// [3] 'Angelo Search' (max 60)
// [4] 'Angelo Cannon' (max 80)
// [5] 'Angelo Strike' (max 120)
// [6] 'Invincible Moon' (max 140)
// [7] 'Wishing Star' (max 160)
BYTE b_items[32]; // [32] Order of battle items
FF8ITEM items[198]; // [198] Items
//#############################################################################################
UINT seconds; // Game time (I want to change this)
//#############################################################################################
UNKNOWN zz28[8];
UINT battleswon; // Number of battles won
UNKNOWN zz29[2];
USHORT battlesescaped; // Number of battles escaped
UNKNOWN zz30[60];
BYTE limit_options; // Limit break options (1:Renzokuken Auto, 2:Duel Auto)
BYTE limit_indicator; // Renzokuken indicator (128)
BYTE dreamworld; // Party isolated / Dream world (1)
BYTE information[9]; // [9] Information (bitmask)
// [0]1-8: Location information
// [2]1-8: Location information
// [3]1-4: Location information
// [3]5-8: Term information
// [4]1-8: Term information
// [5]1-6: Term information
// [5]7-8: People information
// [6]1-5: People information
// [6]6-8: Character reports
// [7]1-4: Character reports
// [8]3-3: Term information
// [8]4-6: Report information
UNKNOWN zz31;
BYTE gf_reports[3]; // [3] GF reports
UNKNOWN zz3[3];
BYTE testlevel; // Current written test level
UNKNOWN zz39[4];
FF8CHARID party_field[3]; // [3] Current field party ([0] = leader)
UNKNOWN zz395[7];
USHORT location; // Current location
USHORT location_last; // Last location (?)
UNKNOWN zz4[30];
UINT steps; // Number of steps taken
USHORT payslip; // Payslip steps
UNKNOWN zz5[6];
USHORT seedlevel; // SeeD Level
UNKNOWN zz55[66];
UNKNOWN zz550[2];
// USHORT location_last; // Last location ?
UNKNOWN zz551[186];
BYTE tt_rules[8]; // [8] Region game rules
BYTE tt_traderules[8]; // [8] Region trade rules
BYTE tt_lastrules[2]; // [2] Last game rules remembered ([1] = second to last)
BYTE tt_lastregion[2]; // [2] Last region remembered ([1] = second to last)
UNKNOWN zz555;
BYTE tt_currules; // Current game rule
BYTE tt_curtraderule; // Current trade rules
BYTE tt_cardqueen; // Card Queen's location
BYTE tt_traderating_region; // Region for trade rating
BYTE tt_traderating; // Trade rating
UNKNOWN zz6[1110];
FF8CARD cards[77]; // [77] Cards (bit 8=collected, bit 1-7=amount)
BYTE card_locations[33]; // [33] Card locations
BYTE cards_rare[5]; // [5] Rare cards found (bFound[i] = cardsfound[i/8] & (1 << (i%8)))
UNKNOWN zz7[9];
USHORT test1;
USHORT test2;
FF8CHOCOBO cw; // Chocobo World data
USHORT checksum2; // Checksum (identical to checksum1)
BYTE padding[2782]; // Padding, makes save block 8192 bytes
};
/////////////////////////////////////////////////////////////////
// Main Program
/////////////////////////////////////////////////////////////////
/*
This is my code.
The problem is that the game seconds are not right, so the data read from the memory card is not saved correctly
in the FF8BLOCK structure.
And the size of my block is 8196 instead of 8192, and I don't know why.
*/
using namespace std;
int main(int argc, char *argv[])
{char FileName[100];
USHORT blocco;
FF8BLOCK ff8;
fstream FileMem;
while(1)
{//START of While
cout<<"Size of my block: "<<sizeof(ff8)<<".\n";
strcpy(FileName,"");
cout << "Name of the memory card:\n";
cin >> FileName;
FileMem.open(FileName,ios::binary | ios::in | ios::out);
if(!FileMem)
cout<<"Impossible to open the file.\n\n";
else
{
cout << "File loaded.\nInsert number of the block:\n";
cin >> blocco;
blocco-=1; //because I think that the block start from zero
cout <<endl<<endl;
int m_Type = 1; //I have a Memory Card File of 131'072 Byte, so the m_Type is 1 and theOffSet is zero.
int offset;
if(m_Type==1) offset = 0; //this is my case
if(m_Type==2) offset = 0xF40;
if(m_Type==3) offset = 64;
//8192 is 0x2000
//now I do the same things that Griever do to read from the Memory Card:
FileMem.seekg(offset+8192+(8192*blocco), ios::beg);
FileMem.read((char*)&ff8, 8192);
cout<<"Game time: "<<ff8.seconds<<";\n"; //but they are not right
ff8.seconds = 20000; //sample value
//and now I write on file. The writing seems to be correct, but the modify is not correct.
//So the second doesn't change.
FileMem.seekp(offset+8192+(8192*blocco), ios::beg);
FileMem.write((char*)&ff8, 8192);
cout<<"Game time modified.\n\n\n";
FileMem.close();
}
}//FINE While
return EXIT_SUCCESS; //end of Windows Application
}