ref: efec3d420d60b03cf7b619f310f0a943a40fa0be
parent: 4bbc2fa7792300e3409bac4d010e528e42d27a24
author: cuckydev <cuckydev@users.noreply.github.com>
date: Sat Feb 9 11:11:06 EST 2019
Added Nikumaru Counter
--- a/.gitignore
+++ b/.gitignore
@@ -3,8 +3,8 @@
# Misc
/obj
-Config.dat
-*rofile.dat
+*.dat
+*.rec
build.7z
build.zip
--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -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 @@
//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 @@
//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 @@
//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 @@
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())
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -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 @@
bContinue = IsProfile();
//Set character
- time_counter = 0;//LoadTimeCounter();
+ time_counter = LoadTimeCounter();
if (time_counter && time_counter < 18000)
char_type = 1;
@@ -395,8 +396,8 @@
//Draw carets
PutCaret(0, 0);
- //if (time_counter)
- // PutTimeCounter(16, 8);
+ if (time_counter)
+ PutTimeCounter(16, 8);
PutFramePerSecound();
@@ -569,6 +570,7 @@
}
PutMapName(false);
+ PutTimeCounter(16, 8);
if (g_GameFlags & 2)
{
--- a/src/MycParam.cpp
+++ b/src/MycParam.cpp
@@ -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 @@
{{40, 60, 200}}
};
+int time_count;
+
void AddExpMyChar(int x)
{
int lv = gArmsData[gSelectedArms].level - 1;
@@ -339,5 +342,92 @@
PutBitmap3(&grcGame, x, y, &rcAir[1], 26);
else
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;
}
}
--- a/src/MycParam.h
+++ b/src/MycParam.h
@@ -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 PutActiveArmsList();
void PutMyLife(bool flash);
void PutMyAir(int x, int y);
+void PutTimeCounter(int x, int y);
+
+int LoadTimeCounter();