Profile saving stuff
This commit is contained in:
parent
3aed029174
commit
9fb2e33e17
7 changed files with 95 additions and 11 deletions
BIN
build/Profile - Copy.dat
Normal file
BIN
build/Profile - Copy.dat
Normal file
Binary file not shown.
|
@ -12,6 +12,7 @@
|
||||||
#include "MiniMap.h"
|
#include "MiniMap.h"
|
||||||
#include "MyChar.h"
|
#include "MyChar.h"
|
||||||
#include "Frame.h"
|
#include "Frame.h"
|
||||||
|
#include "SelStage.h"
|
||||||
#include "ValueView.h"
|
#include "ValueView.h"
|
||||||
#include "Stage.h"
|
#include "Stage.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
@ -36,7 +37,80 @@ bool IsProfile()
|
||||||
|
|
||||||
bool SaveProfile(char *name)
|
bool SaveProfile(char *name)
|
||||||
{
|
{
|
||||||
|
//Get path
|
||||||
|
char path[PATH_LENGTH];
|
||||||
|
if ( name )
|
||||||
|
sprintf(path, "%s/%s", gModulePath, name);
|
||||||
|
else
|
||||||
|
sprintf(path, "%s/%s", gModulePath, gDefaultName);
|
||||||
|
|
||||||
|
//Open file
|
||||||
|
PROFILE profile;
|
||||||
|
|
||||||
|
SDL_RWops *fp = SDL_RWFromFile(path, "wb");
|
||||||
|
if (!fp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//Set up profile
|
||||||
|
memset(&profile, 0, sizeof(PROFILE));
|
||||||
|
memcpy(profile.code, gProfileCode, sizeof(profile.code));
|
||||||
|
memcpy(profile.FLAG, "FLAG", sizeof(profile.FLAG));
|
||||||
|
profile.stage = gStageNo;
|
||||||
|
profile.music = gMusicNo;
|
||||||
|
profile.x = gMC.x;
|
||||||
|
profile.y = gMC.y;
|
||||||
|
profile.direct = gMC.direct;
|
||||||
|
profile.max_life = gMC.max_life;
|
||||||
|
profile.life = gMC.life;
|
||||||
|
profile.star = gMC.star;
|
||||||
|
profile.select_arms = gSelectedArms;
|
||||||
|
profile.select_item = gSelectedItem;
|
||||||
|
profile.equip = gMC.equip;
|
||||||
|
profile.unit = gMC.unit;
|
||||||
|
profile.counter = gCounter;
|
||||||
|
memcpy(profile.arms, gArmsData, sizeof(profile.arms));
|
||||||
|
memcpy(profile.items, gItemData, sizeof(profile.items));
|
||||||
|
memcpy(profile.permitstage, gPermitStage, sizeof(profile.permitstage));
|
||||||
|
memcpy(profile.permit_mapping, gMapping, sizeof(profile.permit_mapping));
|
||||||
|
memcpy(profile.flags, gFlagNPC, sizeof(profile.flags));
|
||||||
|
|
||||||
|
//Write to file
|
||||||
|
SDL_RWwrite(fp, profile.code, 8, 1);
|
||||||
|
SDL_WriteLE32(fp, profile.stage);
|
||||||
|
SDL_WriteLE32(fp, profile.music);
|
||||||
|
SDL_WriteLE32(fp, profile.x);
|
||||||
|
SDL_WriteLE32(fp, profile.y);
|
||||||
|
SDL_WriteLE32(fp, profile.direct);
|
||||||
|
SDL_WriteLE16(fp, profile.max_life);
|
||||||
|
SDL_WriteLE16(fp, profile.star);
|
||||||
|
SDL_WriteLE16(fp, profile.life);
|
||||||
|
SDL_WriteLE16(fp, profile.a);
|
||||||
|
SDL_WriteLE32(fp, profile.select_arms);
|
||||||
|
SDL_WriteLE32(fp, profile.select_item);
|
||||||
|
SDL_WriteLE32(fp, profile.equip);
|
||||||
|
SDL_WriteLE32(fp, profile.unit);
|
||||||
|
SDL_WriteLE32(fp, profile.counter);
|
||||||
|
for (int arm = 0; arm < 8; arm++)
|
||||||
|
{
|
||||||
|
SDL_WriteLE32(fp, profile.arms[arm].code);
|
||||||
|
SDL_WriteLE32(fp, profile.arms[arm].level);
|
||||||
|
SDL_WriteLE32(fp, profile.arms[arm].exp);
|
||||||
|
SDL_WriteLE32(fp, profile.arms[arm].max_num);
|
||||||
|
SDL_WriteLE32(fp, profile.arms[arm].num);
|
||||||
|
}
|
||||||
|
for (int item = 0; item < 32; item++)
|
||||||
|
SDL_WriteLE32(fp, profile.items[item].code);
|
||||||
|
for (int stage = 0; stage < 8; stage++)
|
||||||
|
{
|
||||||
|
SDL_WriteLE32(fp, profile.permitstage[stage].index);
|
||||||
|
SDL_WriteLE32(fp, profile.permitstage[stage].event);
|
||||||
|
}
|
||||||
|
SDL_RWwrite(fp, profile.permit_mapping, 0x80, 1);
|
||||||
|
SDL_RWwrite(fp, "FLAG", 4, 1);
|
||||||
|
SDL_RWwrite(fp, profile.flags, 1000, 1);
|
||||||
|
|
||||||
|
SDL_RWclose(fp);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadProfile(char *name)
|
bool LoadProfile(char *name)
|
||||||
|
@ -88,7 +162,11 @@ bool LoadProfile(char *name)
|
||||||
}
|
}
|
||||||
for (int item = 0; item < 32; item++)
|
for (int item = 0; item < 32; item++)
|
||||||
profile.items[item].code = SDL_ReadLE32(fp);
|
profile.items[item].code = SDL_ReadLE32(fp);
|
||||||
SDL_RWread(fp, profile.permitstage, 8, 8);
|
for (int stage = 0; stage < 8; stage++)
|
||||||
|
{
|
||||||
|
profile.permitstage[stage].index = SDL_ReadLE32(fp);
|
||||||
|
profile.permitstage[stage].event = SDL_ReadLE32(fp);
|
||||||
|
}
|
||||||
SDL_RWread(fp, profile.permit_mapping, 0x80, 1);
|
SDL_RWread(fp, profile.permit_mapping, 0x80, 1);
|
||||||
SDL_RWread(fp, profile.FLAG, 4, 1);
|
SDL_RWread(fp, profile.FLAG, 4, 1);
|
||||||
SDL_RWread(fp, profile.flags, 1000, 1);
|
SDL_RWread(fp, profile.flags, 1000, 1);
|
||||||
|
@ -101,9 +179,9 @@ bool LoadProfile(char *name)
|
||||||
|
|
||||||
memcpy(gArmsData, profile.arms, sizeof(gArmsData));
|
memcpy(gArmsData, profile.arms, sizeof(gArmsData));
|
||||||
memcpy(gItemData, profile.items, sizeof(gItemData));
|
memcpy(gItemData, profile.items, sizeof(gItemData));
|
||||||
//memcpy(gPermitStage, profile.permitstage, 0x40u);
|
memcpy(gPermitStage, profile.permitstage, sizeof(gPermitStage));
|
||||||
memcpy(gMapping, profile.permit_mapping, 0x80);
|
memcpy(gMapping, profile.permit_mapping, sizeof(gMapping));
|
||||||
memcpy(gFlagNPC, profile.flags, 1000);
|
memcpy(gFlagNPC, profile.flags, sizeof(gFlagNPC));
|
||||||
|
|
||||||
//Load stage
|
//Load stage
|
||||||
ChangeMusic(profile.music);
|
ChangeMusic(profile.music);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "ArmsItem.h"
|
#include "ArmsItem.h"
|
||||||
|
#include "SelStage.h"
|
||||||
|
|
||||||
struct PROFILE
|
struct PROFILE
|
||||||
{
|
{
|
||||||
|
@ -21,7 +22,7 @@ struct PROFILE
|
||||||
int counter;
|
int counter;
|
||||||
ARMS arms[8];
|
ARMS arms[8];
|
||||||
ITEM items[32];
|
ITEM items[32];
|
||||||
char permitstage[8][8];
|
PERMIT_STAGE permitstage[8];
|
||||||
char permit_mapping[0x80];
|
char permit_mapping[0x80];
|
||||||
char FLAG[4];
|
char FLAG[4];
|
||||||
uint8_t flags[1000];
|
uint8_t flags[1000];
|
||||||
|
|
|
@ -10,11 +10,7 @@
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
static struct
|
PERMIT_STAGE gPermitStage[8];
|
||||||
{
|
|
||||||
int index;
|
|
||||||
int event;
|
|
||||||
} gPermitStage[8];
|
|
||||||
|
|
||||||
static int gSelectedStage;
|
static int gSelectedStage;
|
||||||
static int gStageSelectTitleY;
|
static int gStageSelectTitleY;
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
struct PERMIT_STAGE
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
int event;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern PERMIT_STAGE gPermitStage[8];
|
||||||
|
|
||||||
void ClearPermitStage(void);
|
void ClearPermitStage(void);
|
||||||
bool AddPermitStage(int index, int event);
|
bool AddPermitStage(int index, int event);
|
||||||
|
|
|
@ -13,6 +13,7 @@ struct STAGE_TABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int gStageNo;
|
extern int gStageNo;
|
||||||
|
extern int gMusicNo;
|
||||||
|
|
||||||
bool TransferStage(int no, int w, int x, int y);
|
bool TransferStage(int no, int w, int x, int y);
|
||||||
void ChangeMusic(int no);
|
void ChangeMusic(int no);
|
||||||
|
|
|
@ -678,6 +678,7 @@ int TextScriptProc()
|
||||||
y = GetTextScriptNo(gTS.p_read + 9);
|
y = GetTextScriptNo(gTS.p_read + 9);
|
||||||
AddPermitStage(x, y);
|
AddPermitStage(x, y);
|
||||||
gTS.p_read += 13;
|
gTS.p_read += 13;
|
||||||
|
}
|
||||||
else if (IS_COMMAND('M','P','+'))
|
else if (IS_COMMAND('M','P','+'))
|
||||||
{
|
{
|
||||||
x = GetTextScriptNo(gTS.p_read + 4);
|
x = GetTextScriptNo(gTS.p_read + 4);
|
||||||
|
|
Loading…
Add table
Reference in a new issue