Saving Nikumaru Counter
This commit is contained in:
parent
efec3d420d
commit
ded926b422
8 changed files with 88 additions and 17 deletions
18
Makefile
18
Makefile
|
@ -1,25 +1,25 @@
|
||||||
ifeq ($(RELEASE), 1)
|
ifeq ($(RELEASE), 1)
|
||||||
CXXFLAGS := -O3 -s
|
CXXFLAGS := -O3 -s
|
||||||
FILENAME_DEF = release
|
FILENAME_DEF = release
|
||||||
else
|
else
|
||||||
CXXFLAGS := -O0 -g
|
CXXFLAGS := -O0 -g
|
||||||
FILENAME_DEF = debug
|
FILENAME_DEF = debug
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(JAPANESE), 1)
|
ifeq ($(JAPANESE), 1)
|
||||||
CXXFLAGS += -DJAPANESE
|
CXXFLAGS += -DJAPANESE
|
||||||
LIBS += -liconv
|
LIBS += -liconv
|
||||||
ifeq ($(RELEASE), 1)
|
ifeq ($(RELEASE), 1)
|
||||||
FILENAME_DEF = releasejp
|
FILENAME_DEF = releasejp
|
||||||
else
|
else
|
||||||
FILENAME_DEF = debugjp
|
FILENAME_DEF = debugjp
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
FILENAME ?= $(FILENAME_DEF)
|
FILENAME ?= $(FILENAME_DEF)
|
||||||
|
|
||||||
ifeq ($(FIX_BUGS), 1)
|
ifeq ($(FIX_BUGS), 1)
|
||||||
CXXFLAGS += -DFIX_BUGS
|
CXXFLAGS += -DFIX_BUGS
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(WINDOWS), 1)
|
ifeq ($(WINDOWS), 1)
|
||||||
|
|
BIN
build/data/ArmsItemJapanese.tsc
Normal file
BIN
build/data/ArmsItemJapanese.tsc
Normal file
Binary file not shown.
BIN
build/data/CreditJapanese.tsc
Normal file
BIN
build/data/CreditJapanese.tsc
Normal file
Binary file not shown.
BIN
build/data/HeadJapanese.tsc
Normal file
BIN
build/data/HeadJapanese.tsc
Normal file
Binary file not shown.
1
build/data/StageSelectJapanese.tsc
Normal file
1
build/data/StageSelectJapanese.tsc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
drqqqNK}傑嘲飼<E598B2>楓屯榑リフラハテ<>眦)テテ愑2ツマ<EFBE82>額zzz}<7D><>KdrqqrNK}傑嘲飼<E598B2>楓篤淨セト般2ル閤<EFBE99>額zzz}<7D><>KdrqqsNK}傑嘲飼<E598B2>楓篤焼米チトハ}連額zzz}<7D><>KdrqqtNK}傑嘲飼<E598B2>楓鳶<E6A593>'}<7D>額zzz}<7D><>KdrqquNK}傑嘲飼<E598B2>楓沌フシ}<7D>額zzz}<7D><>KdrqqvNK}傑嘲飼<E598B2>楓瀞&ユ<>ハチ}<7D>額zzz}<7D><>KNK
|
|
@ -382,6 +382,75 @@ void PutTimeCounter(int x, int y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SaveTimeCounter()
|
||||||
|
{
|
||||||
|
REC rec;
|
||||||
|
|
||||||
|
//Quit if player doesn't have the Nikumaru Counter
|
||||||
|
if (!(gMC.equip & 0x100))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//Get last time
|
||||||
|
char path[PATH_LENGTH];
|
||||||
|
sprintf(path, "%s/290.rec", gModulePath);
|
||||||
|
|
||||||
|
SDL_RWops *fp = SDL_RWFromFile(path, "rb");
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
|
//Read data
|
||||||
|
rec.counter[0] = SDL_ReadLE32(fp);
|
||||||
|
rec.counter[1] = SDL_ReadLE32(fp);
|
||||||
|
rec.counter[2] = SDL_ReadLE32(fp);
|
||||||
|
rec.counter[3] = SDL_ReadLE32(fp);
|
||||||
|
rec.random[0] = SDL_ReadU8(fp);
|
||||||
|
rec.random[1] = SDL_ReadU8(fp);
|
||||||
|
rec.random[2] = SDL_ReadU8(fp);
|
||||||
|
rec.random[3] = SDL_ReadU8(fp);
|
||||||
|
SDL_RWclose(fp);
|
||||||
|
|
||||||
|
//Decode from checksum
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
uint8_t *p = (uint8_t*)&rec.counter[i];
|
||||||
|
p[0] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i]) : (rec.random[i] >> 1);
|
||||||
|
p[1] -= rec.random[i];
|
||||||
|
p[2] -= rec.random[i];
|
||||||
|
p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i] >> 1) : (rec.random[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//If this is faster than our new time, quit
|
||||||
|
if (rec.counter[0] < time_count)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Save new time
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
rec.counter[i] = time_count;
|
||||||
|
rec.random[i] = Random(0, 250) + i;
|
||||||
|
|
||||||
|
uint8_t *p = (uint8_t*)&rec.counter[i];
|
||||||
|
p[0] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i]) : (rec.random[i] >> 1);
|
||||||
|
p[1] -= rec.random[i];
|
||||||
|
p[2] -= rec.random[i];
|
||||||
|
p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i] >> 1) : (rec.random[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fp = SDL_RWFromFile(path, "wb");
|
||||||
|
if (!fp)
|
||||||
|
return false;
|
||||||
|
SDL_WriteLE32(fp, rec.counter[0]);
|
||||||
|
SDL_WriteLE32(fp, rec.counter[1]);
|
||||||
|
SDL_WriteLE32(fp, rec.counter[2]);
|
||||||
|
SDL_WriteLE32(fp, rec.counter[3]);
|
||||||
|
SDL_WriteU8(fp, rec.random[0]);
|
||||||
|
SDL_WriteU8(fp, rec.random[1]);
|
||||||
|
SDL_WriteU8(fp, rec.random[2]);
|
||||||
|
SDL_WriteU8(fp, rec.random[3]);
|
||||||
|
SDL_RWclose(fp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int LoadTimeCounter()
|
int LoadTimeCounter()
|
||||||
{
|
{
|
||||||
//Open file
|
//Open file
|
||||||
|
@ -405,18 +474,14 @@ int LoadTimeCounter()
|
||||||
rec.random[3] = SDL_ReadU8(fp);
|
rec.random[3] = SDL_ReadU8(fp);
|
||||||
SDL_RWclose(fp);
|
SDL_RWclose(fp);
|
||||||
|
|
||||||
//HACK: this swaps the random values to correspond to the correct bytes
|
|
||||||
*((uint32_t*)rec.random) = SDL_SwapLE32(*((uint32_t*)rec.random));
|
|
||||||
|
|
||||||
//Decode from checksum
|
//Decode from checksum
|
||||||
uint8_t *p;
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
p = (uint8_t*)&rec.counter[i];
|
uint8_t *p = (uint8_t*)&rec.counter[i];
|
||||||
p[0] -= rec.random[i];
|
p[0] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i]) : (rec.random[i] >> 1);
|
||||||
p[1] -= rec.random[i];
|
p[1] -= rec.random[i];
|
||||||
p[2] -= rec.random[i];
|
p[2] -= rec.random[i];
|
||||||
p[3] -= rec.random[i] >> 1;
|
p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i] >> 1) : (rec.random[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Verify checksum's result
|
//Verify checksum's result
|
||||||
|
|
|
@ -26,5 +26,5 @@ void PutActiveArmsList();
|
||||||
void PutMyLife(bool flash);
|
void PutMyLife(bool flash);
|
||||||
void PutMyAir(int x, int y);
|
void PutMyAir(int x, int y);
|
||||||
void PutTimeCounter(int x, int y);
|
void PutTimeCounter(int x, int y);
|
||||||
|
bool SaveTimeCounter();
|
||||||
int LoadTimeCounter();
|
int LoadTimeCounter();
|
||||||
|
|
|
@ -706,6 +706,11 @@ int TextScriptProc()
|
||||||
ChangeMyUnit(z);
|
ChangeMyUnit(z);
|
||||||
gTS.p_read += 8;
|
gTS.p_read += 8;
|
||||||
}
|
}
|
||||||
|
else if (IS_COMMAND('S','T','C'))
|
||||||
|
{
|
||||||
|
SaveTimeCounter();
|
||||||
|
gTS.p_read += 4;
|
||||||
|
}
|
||||||
else if (IS_COMMAND('T','R','A'))
|
else if (IS_COMMAND('T','R','A'))
|
||||||
{
|
{
|
||||||
z = GetTextScriptNo(gTS.p_read + 4);
|
z = GetTextScriptNo(gTS.p_read + 4);
|
||||||
|
|
Loading…
Add table
Reference in a new issue