This commit is contained in:
Clownacy 2019-02-09 22:55:26 +00:00
commit 20dbf8a2c8
5 changed files with 116 additions and 11 deletions

4
.gitignore vendored
View file

@ -3,8 +3,8 @@
# Misc
/obj
Config.dat
*rofile.dat
*.dat
*.rec
build.7z
build.zip

View file

@ -11,19 +11,22 @@
#include "KeyControl.h"
#include "Escape.h"
#include "Organya.h"
#include "MycParam.h"
#include "Main.h"
#include "Stage.h"
#include "Draw.h"
#include "TextScr.h"
#define MAX_STRIP 0x10
CREDIT Credit;
STRIP Strip[16];
STRIP Strip[MAX_STRIP];
ILLUSTRATION Illust;
//Update casts
void ActionStripper()
{
for (int s = 0; s < 16; s++)
for (int s = 0; s < MAX_STRIP; s++)
{
//Move up
if (Strip[s].flag & 0x80 && Credit.mode)
@ -37,7 +40,7 @@ void ActionStripper()
//Draw casts
void PutStripper()
{
for (int s = 0; s < 16; s++)
for (int s = 0; s < MAX_STRIP; s++)
{
if (Strip[s].flag & 0x80)
{
@ -58,7 +61,7 @@ void PutStripper()
//Create a cast object
void SetStripper(int x, int y, char *text, int cast)
{
for (int s = 0; s < 16; s++)
for (int s = 0; s < MAX_STRIP; s++)
{
if (!(Strip[s].flag & 0x80))
{
@ -81,7 +84,7 @@ void SetStripper(int x, int y, char *text, int cast)
//Regenerate cast text
void RestoreStripper()
{
for (int s = 0; s < 16; s++)
for (int s = 0; s < MAX_STRIP; s++)
{
if (Strip[s].flag & 0x80)
{
@ -436,7 +439,7 @@ int Scene_DownIsland(int mode)
PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 80 + (WINDOW_HEIGHT - 240) / 2, &rc_sky, 21);
PutBitmap3(&rc_frame, sprite.x / 0x200 - 20 + (WINDOW_WIDTH - 320) / 2, sprite.y / 512 - 12 + (WINDOW_HEIGHT - 240) / 2, &rc_sprite, 21);
PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 128 + (WINDOW_HEIGHT - 240) / 2, &rc_ground, 21);
//PutTimeCounter(16, 8);
PutTimeCounter(16, 8);
PutFramePerSecound();
if (!Flip_SystemTask())

View file

@ -28,6 +28,7 @@
#include "Caret.h"
#include "Map.h"
#include "Main.h"
#include "MycParam.h"
#include "MapName.h"
#include "Sound.h"
#include "Organya.h"
@ -258,7 +259,7 @@ int ModeTitle()
bContinue = IsProfile();
//Set character
time_counter = 0;//LoadTimeCounter();
time_counter = LoadTimeCounter();
if (time_counter && time_counter < 18000)
char_type = 1;
@ -395,8 +396,8 @@ int ModeTitle()
//Draw carets
PutCaret(0, 0);
//if (time_counter)
// PutTimeCounter(16, 8);
if (time_counter)
PutTimeCounter(16, 8);
PutFramePerSecound();
@ -569,6 +570,7 @@ int ModeAction()
}
PutMapName(false);
PutTimeCounter(16, 8);
if (g_GameFlags & 2)
{

View file

@ -3,6 +3,7 @@
#include "MycParam.h"
#include "NpChar.h"
#include "CommonDefines.h"
#include "Tags.h"
#include "ArmsItem.h"
#include "ValueView.h"
#include "TextScr.h"
@ -28,6 +29,8 @@ ARMS_LEVEL gArmsLevelTable[14] =
{{40, 60, 200}}
};
int time_count;
void AddExpMyChar(int x)
{
int lv = gArmsData[gSelectedArms].level - 1;
@ -341,3 +344,90 @@ void PutMyAir(int x, int y)
PutBitmap3(&grcGame, x, y, &rcAir[0], 26);
}
}
void PutTimeCounter(int x, int y)
{
RECT rcTime[3];
rcTime[0] = {112, 104, 120, 112};
rcTime[1] = {120, 104, 128, 112};
rcTime[2] = {128, 104, 160, 112};
if (gMC.equip & 0x100)
{
//Draw clock and increase time
if (g_GameFlags & 2)
{
if (time_count < 300000)
++time_count;
if (time_count % 30 <= 10)
PutBitmap3(&grcGame, x, y, &rcTime[1], 26);
else
PutBitmap3(&grcGame, x, y, &rcTime[0], 26);
}
else
{
PutBitmap3(&grcGame, x, y, &rcTime[0], 26);
}
//Draw time
PutNumber4(x, y, time_count / 3000, false);
PutNumber4(x + 20, y, time_count / 50 % 60, true);
PutNumber4(x + 32, y, time_count / 5 % 10, false);
PutBitmap3(&grcGame, x + 30, y, &rcTime[2], 26);
}
else
{
time_count = 0;
}
}
int LoadTimeCounter()
{
//Open file
char path[PATH_LENGTH];
sprintf(path, "%s/290.rec", gModulePath);
SDL_RWops *fp = SDL_RWFromFile(path, "rb");
if (!fp)
return 0;
REC rec;
//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);
//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
uint8_t *p;
for (int i = 0; i < 4; i++)
{
p = (uint8_t*)&rec.counter[i];
p[0] -= rec.random[i];
p[1] -= rec.random[i];
p[2] -= rec.random[i];
p[3] -= rec.random[i] >> 1;
}
//Verify checksum's result
if (rec.counter[0] == rec.counter[1] && rec.counter[0] == rec.counter[2])
{
time_count = rec.counter[0];
return rec.counter[0];
}
else
{
time_count = 0;
return 0;
}
}

View file

@ -1,9 +1,16 @@
#pragma once
#include <stdint.h>
struct ARMS_LEVEL
{
int exp[3];
};
struct REC
{
int32_t counter[4];
uint8_t random[4];
};
extern ARMS_LEVEL gArmsLevelTable[14];
void AddExpMyChar(int x);
@ -18,3 +25,6 @@ void PutArmsEnergy(bool flash);
void PutActiveArmsList();
void PutMyLife(bool flash);
void PutMyAir(int x, int y);
void PutTimeCounter(int x, int y);
int LoadTimeCounter();