ref: 9cbaa0be00856ee439228779b9f787c78b43eb66
parent: 84626ea71009d5fb382526bbe1801462787f381f
parent: a5df6ebc72e0b2529e6d420058da266587373c89
author: Clownacy <[email protected]>
date: Wed Jan 8 08:16:21 EST 2020
Merge branch 'accurate' into portable
--- a/src/ArmsItem.cpp
+++ b/src/ArmsItem.cpp
@@ -14,18 +14,19 @@
#include "Sound.h"
#include "TextScr.h"
-int gArmsEnergyX = 16;
+ARMS gArmsData[ARMS_MAX];
+ITEM gItemData[ITEM_MAX];
int gSelectedArms;
int gSelectedItem;
-ARMS gArmsData[ARMS_MAX];
-ITEM gItemData[ITEM_MAX];
+static int gCampTitleY;
/// True if we're in the items section of the inventory (not in the weapons section) (only relevant when the inventory is open)
static BOOL gCampActive;
-static int gCampTitleY;
+int gArmsEnergyX = 16;
+
void ClearArmsData(void)
{
#ifdef FIX_BUGS
@@ -175,6 +176,8 @@
/// Update the inventory cursor
void MoveCampCursor(void)
{
+ BOOL bChange;
+
// Compute the current amount of weapons and items
int arms_num = 0;
int item_num = 0;
@@ -187,7 +190,7 @@
return; // Empty inventory
// True if we're currently changing cursor position
- BOOL bChange = FALSE;
+ bChange = FALSE;
if (!gCampActive)
{
@@ -300,6 +303,8 @@
/// Draw the inventory
void PutCampObject(void)
{
+ static unsigned int flash;
+
int i;
/// Rect for the current weapon
@@ -347,7 +352,6 @@
PutBitmap3(&rcView, (WINDOW_WIDTH / 2) - 112, gCampTitleY + 52, &rcTitle2, SURFACE_ID_TEXT_BOX);
// Draw arms cursor
- static unsigned int flash;
++flash;
if (gCampActive == FALSE)
@@ -410,7 +414,6 @@
int CampLoop(void)
{
- int arms_num;
char old_script_path[MAX_PATH];
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
@@ -428,7 +431,7 @@
gSelectedItem = 0;
// Compute current amount of weapons
- arms_num = 0;
+ int arms_num = 0;
while (gArmsData[arms_num].code != 0)
++arms_num;
--- a/src/Back.cpp
+++ b/src/Back.cpp
@@ -72,8 +72,7 @@
void PutBack(int fx, int fy)
{
- int x;
- int y;
+ int x, y;
RECT rect = {0, 0, gBack.partsW, gBack.partsH};
switch (gBack.type)
@@ -156,16 +155,13 @@
void PutFront(int fx, int fy)
{
- int x;
- int y;
- int xpos;
- int ypos;
- int x_1;
- int x_2;
- int y_1;
- int y_2;
+ int xpos, ypos;
RECT rcWater[2] = {{0, 0, 32, 16}, {0, 16, 32, 48}};
+
+ int x, y;
+ int x_1, x_2;
+ int y_1, y_2;
switch (gBack.type)
{
--- a/src/Boss.cpp
+++ b/src/Boss.cpp
@@ -38,6 +38,8 @@
char a = 0;
int b;
+ int side;
+
for (b = BOSS_MAX - 1; b >= 0; --b)
{
if (gBoss[b].cond & 0x80)
@@ -57,7 +59,6 @@
}
}
- int side;
if (gBoss[b].direct == 0)
side = gBoss[b].view.front;
else
@@ -218,8 +219,8 @@
void ActBossChar(void)
{
- int bos;
int code_char;
+ int bos;
if (!(gBoss[0].cond & 0x80))
return;
@@ -235,13 +236,12 @@
void HitBossMap(void)
{
+ int x, y;
+ unsigned char atrb[16];
+ int judg;
int offx[16];
int offy[16];
- unsigned char atrb[16];
- int b;
- int j;
- int x;
- int y;
+ int b, j;
offx[0] = 0;
offx[1] = 1;
@@ -279,8 +279,6 @@
for (b = 0; b < BOSS_MAX; ++b)
{
- int judg;
-
if (!(gBoss[b].cond & 0x80))
continue;
--- a/src/BossAlmo2.cpp
+++ b/src/BossAlmo2.cpp
@@ -178,8 +178,6 @@
static void ActBossCharA_Mini(NPCHAR *npc)
{
- int deg;
-
RECT rect[3] = {
{256, 0, 320, 40},
{256, 40, 320, 80},
@@ -186,6 +184,8 @@
{256, 80, 320, 120},
};
+ int deg;
+
if (npc->cond == 0)
return;
@@ -284,16 +284,14 @@
void ActBossChar_Undead(void)
{
- int i;
- int x;
- int y;
-
- static int life;
- static unsigned char flash;
-
NPCHAR *npc = gBoss;
+ static unsigned char flash;
BOOL bShock = FALSE;
+ int x, y;
+ int i;
+
+ static int life;
switch (npc->act_no)
{
--- a/src/BossBallos.cpp
+++ b/src/BossBallos.cpp
@@ -135,13 +135,11 @@
void ActBossChar_Ballos(void)
{
- static unsigned char flash;
+ NPCHAR *npc = gBoss;
+ static unsigned char flash;
int i;
- int x;
- int y;
-
- NPCHAR *npc = gBoss;
+ int x, y;
switch (npc->act_no)
{
--- a/src/BossFrog.cpp
+++ b/src/BossFrog.cpp
@@ -132,10 +132,9 @@
// Main boss AI
void ActBossChar_Frog(void)
{
- int i;
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
+ int i;
// Rects 1-4 are for when Balfrog is a frog, 5-8 for when he reverts into Balrog and goes into the ceiling
RECT rcLeft[9] = {
--- a/src/BossIronH.cpp
+++ b/src/BossIronH.cpp
@@ -11,10 +11,9 @@
void ActBossChar_Ironhead(void)
{
- static unsigned char flash;
int i;
-
NPCHAR *npc = gBoss;
+ static unsigned char flash;
switch (npc->act_no)
{
--- a/src/BossPress.cpp
+++ b/src/BossPress.cpp
@@ -10,12 +10,10 @@
void ActBossChar_Press(void)
{
+ NPCHAR *npc = gBoss;
static unsigned char flash;
-
int i;
int x;
-
- NPCHAR *npc = gBoss;
switch (npc->act_no)
{
--- a/src/BossTwinD.cpp
+++ b/src/BossTwinD.cpp
@@ -95,8 +95,7 @@
static void ActBossCharT_DragonHead(NPCHAR *npc)
{
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
RECT rcLeft[4] = {
{0, 80, 40, 112},
--- a/src/BossX.cpp
+++ b/src/BossX.cpp
@@ -212,8 +212,6 @@
static void ActBossChar03_02(NPCHAR *npc)
{
- int direct;
-
RECT rect[4] = {
{0, 128, 72, 160},
{72, 128, 144, 160},
@@ -221,8 +219,8 @@
{72, 160, 144, 192},
};
- int x;
- int y;
+ int direct;
+ int x, y;
switch (npc->act_no)
{
@@ -360,9 +358,8 @@
static void ActBossChar03_04(NPCHAR *npc)
{
+ int xm, ym;
unsigned char deg;
- int ym;
- int xm;
RECT rect[8] = {
{0, 192, 16, 208},
@@ -436,8 +433,6 @@
static void ActBossChar03_face(NPCHAR *npc)
{
- static unsigned char flash;
-
RECT rect[3] = {
{216, 0, 320, 48},
{216, 48, 320, 96},
@@ -444,6 +439,8 @@
{216, 144, 320, 192},
};
+ static unsigned char flash;
+
switch (npc->act_no)
{
case 0:
@@ -484,7 +481,6 @@
void ActBossChar_MonstX(void)
{
int i;
-
NPCHAR *npc = gBoss;
switch (npc->act_no)
--- a/src/BulHit.cpp
+++ b/src/BulHit.cpp
@@ -47,12 +47,12 @@
int JudgeHitBulletBlock2(int x, int y, unsigned char *atrb, BULLET *bul)
{
- int i;
- int workX;
- int workY;
- int hit = 0;
-
BOOL block[4];
+ int workX, workY;
+ int hit, i;
+
+ hit = 0;
+
if (bul->bbits & 0x40)
{
for (i = 0; i < 4; ++i)
@@ -324,11 +324,10 @@
void HitBulletMap(void)
{
- int i;
- int j;
- int x;
- int y;
+ int x, y;
unsigned char atrb[4];
+
+ int i, j;
for (i = 0; i < BULLET_MAX; ++i)
{
--- a/src/Bullet.cpp
+++ b/src/Bullet.cpp
@@ -12,56 +12,6 @@
#include "NpChar.h"
#include "Sound.h"
-BULLET_TABLE gBulTbl[46] =
-{
- {0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}},
- {4, 1, 20, 36, 4, 4, 2, 2, {8, 8, 8, 8}},
- {6, 1, 23, 36, 4, 4, 2, 2, {8, 8, 8, 8}},
- {8, 1, 30, 36, 4, 4, 2, 2, {8, 8, 8, 8}},
- {1, 1, 8, 32, 6, 6, 2, 2, {8, 8, 8, 8}},
- {2, 1, 12, 32, 6, 6, 2, 2, {8, 8, 8, 8}},
- {4, 1, 16, 32, 6, 6, 2, 2, {8, 8, 8, 8}},
- {2, 2, 100, 8, 8, 16, 4, 2, {8, 8, 8, 8}},
- {3, 2, 100, 8, 4, 4, 4, 2, {8, 8, 8, 8}},
- {3, 2, 100, 8, 4, 4, 4, 2, {8, 8, 8, 8}},
- {2, 1, 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}},
- {4, 1, 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}},
- {6, 1, 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}},
- {0, 10, 50, 40, 2, 2, 2, 2, {8, 8, 8, 8}},
- {0, 10, 70, 40, 4, 4, 4, 4, {8, 8, 8, 8}},
- {0, 10, 90, 40, 4, 4, 0, 0, {8, 8, 8, 8}},
- {1, 100, 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}},
- {1, 100, 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}},
- {1, 100, 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}},
- {1, 1, 20, 8, 2, 2, 2, 2, {4, 4, 4, 4}},
- {2, 1, 20, 8, 2, 2, 2, 2, {4, 4, 4, 4}},
- {2, 1, 20, 8, 4, 4, 4, 4, {4, 4, 4, 4}},
- {3, 1, 32, 32, 2, 2, 2, 2, {4, 4, 4, 4}},
- {0, 100, 0, 36, 8, 8, 8, 8, {12, 12, 12, 12}},
- {127, 1, 2, 4, 8, 4, 8, 4, {0, 0, 0, 0}},
- {15, 1, 30, 36, 8, 8, 4, 2, {8, 8, 8, 8}},
- {6, 3, 18, 36, 10, 10, 4, 2, {12, 12, 12, 12}},
- {1, 100, 30, 36, 6, 6, 4, 4, {12, 12, 12, 12}},
- {0, 10, 30, 40, 2, 2, 2, 2, {8, 8, 8, 8}},
- {0, 10, 40, 40, 4, 4, 4, 4, {8, 8, 8, 8}},
- {0, 10, 40, 40, 4, 4, 0, 0, {8, 8, 8, 8}},
- {2, 100, 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}},
- {2, 100, 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}},
- {2, 100, 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}},
- {4, 4, 20, 32, 4, 4, 3, 3, {8, 8, 24, 8}},
- {4, 2, 20, 32, 2, 2, 2, 2, {8, 8, 24, 8}},
- {1, 1, 20, 32, 2, 2, 2, 2, {8, 8, 24, 8}},
- {4, 4, 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}},
- {8, 8, 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}},
- {12, 12, 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}},
- {3, 100, 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}},
- {6, 100, 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}},
- {11, 100, 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}},
- {4, 4, 20, 32, 4, 4, 3, 3, {8, 8, 24, 8}},
- {0, 4, 4, 4, 0, 0, 0, 0, {0, 0, 0, 0}},
- {1, 1, 1, 36, 1, 1, 1, 1, {1, 1, 1, 1}}
-};
-
BULLET gBul[BULLET_MAX];
void InitBullet(void)
@@ -150,6 +100,56 @@
}
}
+BULLET_TABLE gBulTbl[46] =
+{
+ {0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}},
+ {4, 1, 20, 36, 4, 4, 2, 2, {8, 8, 8, 8}},
+ {6, 1, 23, 36, 4, 4, 2, 2, {8, 8, 8, 8}},
+ {8, 1, 30, 36, 4, 4, 2, 2, {8, 8, 8, 8}},
+ {1, 1, 8, 32, 6, 6, 2, 2, {8, 8, 8, 8}},
+ {2, 1, 12, 32, 6, 6, 2, 2, {8, 8, 8, 8}},
+ {4, 1, 16, 32, 6, 6, 2, 2, {8, 8, 8, 8}},
+ {2, 2, 100, 8, 8, 16, 4, 2, {8, 8, 8, 8}},
+ {3, 2, 100, 8, 4, 4, 4, 2, {8, 8, 8, 8}},
+ {3, 2, 100, 8, 4, 4, 4, 2, {8, 8, 8, 8}},
+ {2, 1, 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}},
+ {4, 1, 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}},
+ {6, 1, 20, 32, 2, 2, 2, 2, {8, 8, 8, 8}},
+ {0, 10, 50, 40, 2, 2, 2, 2, {8, 8, 8, 8}},
+ {0, 10, 70, 40, 4, 4, 4, 4, {8, 8, 8, 8}},
+ {0, 10, 90, 40, 4, 4, 0, 0, {8, 8, 8, 8}},
+ {1, 100, 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}},
+ {1, 100, 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}},
+ {1, 100, 100, 20, 16, 16, 0, 0, {0, 0, 0, 0}},
+ {1, 1, 20, 8, 2, 2, 2, 2, {4, 4, 4, 4}},
+ {2, 1, 20, 8, 2, 2, 2, 2, {4, 4, 4, 4}},
+ {2, 1, 20, 8, 4, 4, 4, 4, {4, 4, 4, 4}},
+ {3, 1, 32, 32, 2, 2, 2, 2, {4, 4, 4, 4}},
+ {0, 100, 0, 36, 8, 8, 8, 8, {12, 12, 12, 12}},
+ {127, 1, 2, 4, 8, 4, 8, 4, {0, 0, 0, 0}},
+ {15, 1, 30, 36, 8, 8, 4, 2, {8, 8, 8, 8}},
+ {6, 3, 18, 36, 10, 10, 4, 2, {12, 12, 12, 12}},
+ {1, 100, 30, 36, 6, 6, 4, 4, {12, 12, 12, 12}},
+ {0, 10, 30, 40, 2, 2, 2, 2, {8, 8, 8, 8}},
+ {0, 10, 40, 40, 4, 4, 4, 4, {8, 8, 8, 8}},
+ {0, 10, 40, 40, 4, 4, 0, 0, {8, 8, 8, 8}},
+ {2, 100, 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}},
+ {2, 100, 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}},
+ {2, 100, 100, 20, 12, 12, 0, 0, {0, 0, 0, 0}},
+ {4, 4, 20, 32, 4, 4, 3, 3, {8, 8, 24, 8}},
+ {4, 2, 20, 32, 2, 2, 2, 2, {8, 8, 24, 8}},
+ {1, 1, 20, 32, 2, 2, 2, 2, {8, 8, 24, 8}},
+ {4, 4, 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}},
+ {8, 8, 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}},
+ {12, 12, 30, 64, 6, 6, 3, 3, {8, 8, 8, 8}},
+ {3, 100, 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}},
+ {6, 100, 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}},
+ {11, 100, 30, 32, 6, 6, 3, 3, {4, 4, 4, 4}},
+ {4, 4, 20, 32, 4, 4, 3, 3, {8, 8, 24, 8}},
+ {0, 4, 4, 4, 0, 0, 0, 0, {0, 0, 0, 0}},
+ {1, 1, 1, 36, 1, 1, 1, 1, {1, 1, 1, 1}}
+};
+
void SetBullet(int no, int x, int y, int dir)
{
int i = 0;
@@ -246,6 +246,8 @@
void ActBullet_Frontia2(BULLET *bul, int level)
{
+ static unsigned int inc;
+
if (++bul->count1 > bul->life_count)
{
bul->cond = 0;
@@ -274,7 +276,6 @@
break;
}
- static unsigned int inc;
++inc;
switch (bul->direct)
@@ -372,10 +373,6 @@
void ActBullet_PoleStar(BULLET *bul, int level)
{
- RECT rect1[2];
- RECT rect2[2];
- RECT rect3[2];
-
if (++bul->count1 > bul->life_count)
{
bul->cond = 0;
@@ -450,14 +447,20 @@
bul->y += bul->ym;
}
- SET_RECT(rect1[0], 128, 32, 144, 48)
- SET_RECT(rect1[1], 144, 32, 160, 48)
+ RECT rect1[2] = {
+ {128, 32, 144, 48},
+ {144, 32, 160, 48},
+ };
- SET_RECT(rect2[0], 160, 32, 176, 48)
- SET_RECT(rect2[1], 176, 32, 192, 48)
+ RECT rect2[2] = {
+ {160, 32, 176, 48},
+ {176, 32, 192, 48},
+ };
- SET_RECT(rect3[0], 128, 48, 144, 64)
- SET_RECT(rect3[1], 144, 48, 160, 64)
+ RECT rect3[2] = {
+ {128, 48, 144, 64},
+ {144, 48, 160, 64},
+ };
//Set framerect
switch (level)
@@ -491,10 +494,6 @@
void ActBullet_FireBall(BULLET *bul, int level)
{
BOOL bBreak;
- RECT rect_left1[4];
- RECT rect_right1[4];
- RECT rect_left2[3];
- RECT rect_right2[3];
if (++bul->count1 > bul->life_count)
{
@@ -585,23 +584,31 @@
PlaySoundObject(34, 1);
}
- SET_RECT(rect_left1[0], 128, 0, 144, 16)
- SET_RECT(rect_left1[1], 144, 0, 160, 16)
- SET_RECT(rect_left1[2], 160, 0, 176, 16)
- SET_RECT(rect_left1[3], 176, 0, 192, 16)
+ RECT rect_left1[4] = {
+ {128, 0, 144, 16},
+ {144, 0, 160, 16},
+ {160, 0, 176, 16},
+ {176, 0, 192, 16},
+ };
- SET_RECT(rect_right1[0], 128, 16, 144, 32)
- SET_RECT(rect_right1[1], 144, 16, 160, 32)
- SET_RECT(rect_right1[2], 160, 16, 176, 32)
- SET_RECT(rect_right1[3], 176, 16, 192, 32)
+ RECT rect_right1[4] = {
+ {128, 16, 144, 32},
+ {144, 16, 160, 32},
+ {160, 16, 176, 32},
+ {176, 16, 192, 32},
+ };
- SET_RECT(rect_left2[0], 192, 16, 208, 32)
- SET_RECT(rect_left2[1], 208, 16, 224, 32)
- SET_RECT(rect_left2[2], 224, 16, 240, 32)
+ RECT rect_left2[3] = {
+ {192, 16, 208, 32},
+ {208, 16, 224, 32},
+ {224, 16, 240, 32},
+ };
- SET_RECT(rect_right2[0], 224, 16, 240, 32)
- SET_RECT(rect_right2[1], 208, 16, 224, 32)
- SET_RECT(rect_right2[2], 192, 16, 208, 32)
+ RECT rect_right2[3] = {
+ {224, 16, 240, 32},
+ {208, 16, 224, 32},
+ {192, 16, 208, 32},
+ };
++bul->ani_no;
@@ -734,6 +741,8 @@
{
BOOL bHit;
+ static unsigned int inc;
+
if (++bul->count1 > bul->life_count)
{
bul->cond = 0;
@@ -810,8 +819,6 @@
break;
}
- static unsigned int inc;
-
switch (++inc % 3)
{
case 0:
@@ -992,8 +999,6 @@
void ActBullet_Bubblin1(BULLET *bul)
{
- RECT rect[4];
-
if (bul->flag & 0x2FF)
{
bul->cond = 0;
@@ -1050,10 +1055,12 @@
SetCaret(bul->x, bul->y, 15, 0);
}
- SET_RECT(rect[0], 192, 0, 200, 8)
- SET_RECT(rect[1], 200, 0, 208, 8)
- SET_RECT(rect[2], 208, 0, 216, 8)
- SET_RECT(rect[3], 216, 0, 224, 8)
+ RECT rect[4] = {
+ {192, 0, 200, 8},
+ {200, 0, 208, 8},
+ {208, 0, 216, 8},
+ {216, 0, 224, 8},
+ };
if (++bul->ani_wait > 3)
{
@@ -1069,11 +1076,8 @@
void ActBullet_Bubblin2(BULLET *bul)
{
- BOOL bDelete;
- RECT rect[4];
+ BOOL bDelete = FALSE;
- bDelete = FALSE;
-
if (bul->direct == 0 && bul->flag & 1)
bDelete = TRUE;
if (bul->direct == 2 && bul->flag & 4)
@@ -1143,10 +1147,12 @@
SetCaret(bul->x, bul->y, 15, 0);
}
- SET_RECT(rect[0], 192, 8, 200, 16)
- SET_RECT(rect[1], 200, 8, 208, 16)
- SET_RECT(rect[2], 208, 8, 216, 16)
- SET_RECT(rect[3], 216, 8, 224, 16)
+ RECT rect[4] = {
+ {192, 8, 200, 16},
+ {200, 8, 208, 16},
+ {208, 8, 216, 16},
+ {216, 8, 224, 16},
+ };
if (++bul->ani_wait > 3)
{
@@ -1656,6 +1662,8 @@
{
BOOL bHit;
+ static unsigned int inc;
+
if (++bul->count1 > bul->life_count)
{
bul->cond = 0;
@@ -1736,8 +1744,6 @@
bul->ym = Random(-0x200, 0x200);
break;
}
-
- static unsigned int inc;
switch (++inc % 3)
{
--- a/src/Caret.cpp
+++ b/src/Caret.cpp
@@ -11,6 +11,27 @@
#define CARET_MAX 0x40
CARET gCrt[CARET_MAX];
+CARET_TABLE gCaretTable[18] = {
+ {0, 0},
+ {0x800, 0x800},
+ {0x1000, 0x1000},
+ {0x1000, 0x1000},
+ {0x1000, 0x1000},
+ {0x800, 0x800},
+ {0x1000, 0x1000},
+ {0x800, 0x800},
+ {0x1000, 0x1000},
+ {0x1000, 0x1000},
+ {0x3800, 0x1000},
+ {0x800, 0x800},
+ {0x2000, 0x2000},
+ {0x800, 0x800},
+ {0x2800, 0x2800},
+ {0x800, 0x800},
+ {0x2800, 0x800},
+ {0x6800, 0x800}
+};
+
void InitCaret(void)
{
memset(gCrt, 0, sizeof(gCrt));
@@ -467,28 +488,6 @@
else
crt->rect = rcLeft[1];
}
-
-// Tables
-CARET_TABLE gCaretTable[18] = {
- {0, 0},
- {0x800, 0x800},
- {0x1000, 0x1000},
- {0x1000, 0x1000},
- {0x1000, 0x1000},
- {0x800, 0x800},
- {0x1000, 0x1000},
- {0x800, 0x800},
- {0x1000, 0x1000},
- {0x1000, 0x1000},
- {0x3800, 0x1000},
- {0x800, 0x800},
- {0x2000, 0x2000},
- {0x800, 0x800},
- {0x2800, 0x2800},
- {0x800, 0x800},
- {0x2800, 0x800},
- {0x6800, 0x800}
-};
typedef void (*CARETFUNCTION)(CARET*);
CARETFUNCTION gpCaretFuncTbl[] =
--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -40,8 +40,8 @@
// Draw casts
void PutStripper(void)
{
- RECT rc;
int s;
+ RECT rc;
for (s = 0; s < MAX_STRIP; ++s)
{
@@ -69,8 +69,8 @@
// Create a cast object
void SetStripper(int x, int y, const char *text, int cast)
{
- RECT rc;
int s;
+ RECT rc;
for (s = 0; s < MAX_STRIP; ++s)
if (!(Strip[s].flag & 0x80))
@@ -99,8 +99,8 @@
// Regenerate cast text
void RestoreStripper(void)
{
- RECT rc;
int s;
+ RECT rc;
for (s = 0; s < MAX_STRIP; ++s)
{
@@ -161,6 +161,8 @@
ReloadBitmap_Resource(name, SURFACE_ID_CREDITS_IMAGE);
}
+const char *credit_script = "Credit.tsc";
+
// Initialize and release credits
void InitCreditScript(void)
{
@@ -179,11 +181,12 @@
}
}
-const char *credit_script = "Credit.tsc";
-
// Start playing credits
BOOL StartCreditScript(void)
{
+ FILE *fp;
+ char path[MAX_PATH];
+
// Clear previously existing credits data
if (Credit.pData != NULL)
{
@@ -192,7 +195,6 @@
}
// Open file
- char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, credit_script);
Credit.size = GetFileSizeLong(path);
@@ -204,7 +206,7 @@
if (Credit.pData == NULL)
return FALSE;
- FILE *fp = fopen(path, "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
{
free(Credit.pData);
@@ -441,6 +443,7 @@
// Scene of the island falling
int Scene_DownIsland(int mode)
{
+ ISLAND_SPRITE sprite;
int wait;
// Setup background
@@ -451,7 +454,6 @@
// Setup island
RECT rc_sprite = {160, 0, 200, 24};
- ISLAND_SPRITE sprite;
sprite.x = 168 * 0x200;
sprite.y = 64 * 0x200;
--- a/src/Fade.cpp
+++ b/src/Fade.cpp
@@ -42,8 +42,7 @@
void StartFadeOut(signed char dir)
{
- int x;
- int y;
+ int x, y;
gFade.mode = 2;
gFade.count = 0;
@@ -62,8 +61,7 @@
void StartFadeIn(signed char dir)
{
- int x;
- int y;
+ int x, y;
gFade.mode = 1;
gFade.count = 0;
@@ -84,8 +82,7 @@
void ProcFade(void)
{
- int x;
- int y;
+ int x, y;
switch (gFade.mode)
{
@@ -236,8 +233,7 @@
void PutFade(void)
{
- int x;
- int y;
+ int x, y;
RECT rect;
rect.top = 0;
--- a/src/Flash.cpp
+++ b/src/Flash.cpp
@@ -37,7 +37,7 @@
void ActFlash_Explosion(int flx, int fly)
{
- int left, right, top, bottom;
+ int left, top, right, bottom;
switch (flash.act_no)
{
--- a/src/Frame.cpp
+++ b/src/Frame.cpp
@@ -112,12 +112,13 @@
void SetFramePosition(int fx, int fy)
{
+ short map_w, map_l;
+
// End quake
gFrame.quake = 0;
gFrame.quake2 = 0;
// Move frame position
- short map_w, map_l;
GetMapData(0, &map_w, &map_l);
gFrame.x = fx;
@@ -186,11 +187,12 @@
void SetFrameMyChar(void)
{
- // Move frame position
int mc_x, mc_y;
+ short map_w, map_l;
+
+ // Move frame position
GetMyCharPosition(&mc_x, &mc_y);
- short map_w, map_l;
GetMapData(0, &map_w, &map_l);
gFrame.x = mc_x - ((WINDOW_WIDTH / 2) * 0x200);
--- a/src/Generic.cpp
+++ b/src/Generic.cpp
@@ -11,26 +11,28 @@
void GetCompileDate(int *year, int *month, int *day)
{
int i;
- const char *months[13];
- char month_string[0x10];
+ char strMonth[0x10];
- months[0] = "XXX";
- months[1] = "Jan";
- months[2] = "Feb";
- months[3] = "Mar";
- months[4] = "Apr";
- months[5] = "May";
- months[6] = "Jun";
- months[7] = "Jul";
- months[8] = "Aug";
- months[9] = "Sep";
- months[10] = "Oct";
- months[11] = "Nov";
- months[12] = "Dec";
- sscanf(__DATE__, "%s %d %d", month_string, day, year); // The expansion of __DATE__ is not reproductible. TODO : Think about changing this to be reproductible
+ const char *table[13] = {
+ "XXX",
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec",
+ };
+ sscanf(__DATE__, "%s %d %d", strMonth, day, year); // The expansion of __DATE__ is not reproductible. TODO : Think about changing this to be reproductible
+
for (i = 0; i < 12; ++i) // This being 12 instead of 13 might be a bug, but it works anyway by accident
- if (!memcmp(&month_string, months[i], 3))
+ if (!memcmp(&strMonth, table[i], 3))
break;
*month = i;
@@ -131,14 +133,17 @@
return FALSE;
}
+const char *extra_text = "(C)Pixel";
+
BOOL IsEnableBitmap(const char *path)
{
+ FILE *fp;
+ long len;
char str[16];
- static const char *extra_text = "(C)Pixel";
- const long len = (long)strlen(extra_text);
+ len = (long)strlen(extra_text);
- FILE *fp = fopen(path, "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
--- a/src/GenericLoad.cpp
+++ b/src/GenericLoad.cpp
@@ -155,9 +155,8 @@
BOOL LoadGenericData(void)
{
- char str[0x40];
- BOOL bError;
int pt_size;
+ BOOL bError;
MakeSurface_Resource("PIXEL", SURFACE_ID_PIXEL);
@@ -293,6 +292,8 @@
pt_size += MakePixToneObject(&gPtpTable[136], 1, 3);
pt_size += MakePixToneObject(&gPtpTable[137], 1, 6);
pt_size += MakePixToneObject(&gPtpTable[138], 1, 7);
+
+ char str[0x40];
sprintf(str, "PixTone = %d byte", pt_size);
// There must have been some kind of console print function here or something
return TRUE;
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -27,13 +27,13 @@
char gModulePath[MAX_PATH];
char gDataPath[MAX_PATH];
-int gJoystickButtonTable[8];
-
BOOL bFullscreen;
BOOL gbUseJoystick = FALSE;
-static BOOL bFps = FALSE;
+int gJoystickButtonTable[8];
+
static BOOL bActive = TRUE;
+static BOOL bFps = FALSE;
static int windowWidth;
static int windowHeight;
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -17,7 +17,7 @@
MAP_DATA gMap;
-static const char *code_pxma = "PXM";
+const char *code_pxma = "PXM";
BOOL InitMapData2(void)
{
@@ -27,19 +27,19 @@
BOOL LoadMapData2(const char *path_map)
{
- unsigned char dum;
+ FILE *fp;
+ char check[3];
+ char path[MAX_PATH];
// Get path
- char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, path_map);
// Open file
- FILE *fp = fopen(path, "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
// Make sure file begins with "PXM"
- char check[3];
fread(check, 1, 3, fp);
if (memcmp(check, code_pxma, 3))
@@ -48,6 +48,7 @@
return FALSE;
}
+ unsigned char dum;
fread(&dum, 1, 1, fp);
// Get width and height
gMap.width = File_ReadLE16(fp);
@@ -67,11 +68,13 @@
BOOL LoadAttributeData(const char *path_atrb)
{
- // Open file
+ FILE *fp;
char path[MAX_PATH];
+
+ // Open file
sprintf(path, "%s/%s", gDataPath, path_atrb);
- FILE *fp = fopen(path, "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
@@ -105,10 +108,12 @@
unsigned char GetAttribute(int x, int y)
{
+ size_t a;
+
if (x < 0 || y < 0 || x >= gMap.width || y >= gMap.length)
return 0;
- const size_t a = *(gMap.data + x + (y * gMap.width)); // Yes, the original code really does do this instead of a regular array access
+ a = *(gMap.data + x + (y * gMap.width)); // Yes, the original code really does do this instead of a regular array access
return gMap.atrb[a];
}
@@ -139,22 +144,18 @@
void PutStage_Back(int fx, int fy)
{
- int num_y;
- int put_x;
- int put_y;
- int i;
- int j;
- int offset;
- int atrb;
+ int i, j;
RECT rect;
- int num_x;
+ int offset;
// Get range to draw
- num_x = ((WINDOW_WIDTH + (16 - 1)) / 16) + 1;
- num_y = ((WINDOW_HEIGHT + (16 - 1)) / 16) + 1;
- put_x = ((fx / 0x200) + 8) / 16;
- put_y = ((fy / 0x200) + 8) / 16;
+ int num_x = ((WINDOW_WIDTH + (16 - 1)) / 16) + 1;
+ int num_y = ((WINDOW_HEIGHT + (16 - 1)) / 16) + 1;
+ int put_x = ((fx / 0x200) + 8) / 16;
+ int put_y = ((fy / 0x200) + 8) / 16;
+ int atrb;
+
for (j = put_y; j < put_y + num_y; ++j)
{
for (i = put_x; i < put_x + num_x; ++i)
@@ -180,22 +181,18 @@
void PutStage_Front(int fx, int fy)
{
RECT rcSnack = {256, 48, 272, 64};
- int num_y;
- int put_x;
- int put_y;
- int j;
- int i;
- int offset;
- int atrb;
+ int i, j;
RECT rect;
- int num_x;
+ int offset;
// Get range to draw
- num_x = ((WINDOW_WIDTH + (16 - 1)) / 16) + 1;
- num_y = ((WINDOW_HEIGHT + (16 - 1)) / 16) + 1;
- put_x = ((fx / 0x200) + 8) / 16;
- put_y = ((fy / 0x200) + 8) / 16;
+ int num_x = ((WINDOW_WIDTH + (16 - 1)) / 16) + 1;
+ int num_y = ((WINDOW_HEIGHT + (16 - 1)) / 16) + 1;
+ int put_x = ((fx / 0x200) + 8) / 16;
+ int put_y = ((fy / 0x200) + 8) / 16;
+ int atrb;
+
for (j = put_y; j < put_y + num_y; ++j)
{
for (i = put_x; i < put_x + num_x; ++i)
@@ -223,18 +220,20 @@
void PutMapDataVector(int fx, int fy)
{
+ int i, j;
+ RECT rect;
+ int offset;
+
+ int num_x;
int num_y;
int put_x;
int put_y;
- int i;
- int j;
- int offset;
+
+ static unsigned char count = 0;
+
int atrb;
- RECT rect;
- int num_x;
// Animate the wind
- static unsigned char count = 0;
count += 2;
// Get range to draw
--- a/src/MapName.cpp
+++ b/src/MapName.cpp
@@ -129,9 +129,9 @@
void RestoreMapName(void)
{
- int len = (int)strlen(gMapName.name);
+ int a = (int)strlen(gMapName.name);
CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
- PutText2(((160 - (len * 6)) / 2) + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
- PutText2(((160 - (len * 6)) / 2) + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
+ PutText2(((160 - (a * 6)) / 2) + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
+ PutText2(((160 - (a * 6)) / 2) + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
}
--- a/src/MiniMap.cpp
+++ b/src/MiniMap.cpp
@@ -14,8 +14,6 @@
#include "MyChar.h"
#include "Stage.h"
-char gMapping[0x80];
-
void WriteMiniMapLine(int line)
{
int x;
@@ -77,17 +75,18 @@
int MiniMapLoop(void)
{
- int f;
- int line;
- unsigned char my_wait;
-
- RECT rcMiniMap;
+ int f, line;
RECT rcView;
+ RECT rcMiniMap;
+ int my_x;
+ int my_y;
+ unsigned char my_wait;
RECT my_rect = {0, 57, 1, 58};
- int my_x = ((gMC.x / 0x200) + 8) / 16;
- int my_y = ((gMC.y / 0x200) + 8) / 16;
+ my_x = ((gMC.x / 0x200) + 8) / 16;
+ my_y = ((gMC.y / 0x200) + 8) / 16;
+
for (f = 0; f <= 8; ++f)
{
GetTrg();
@@ -210,6 +209,8 @@
return enum_ESCRETURN_continue;
}
+
+char gMapping[0x80];
BOOL IsMapping(void)
{
--- a/src/MyChar.cpp
+++ b/src/MyChar.cpp
@@ -19,9 +19,6 @@
MYCHAR gMC;
-int noise_no;
-unsigned int noise_freq;
-
void InitMyChar(void)
{
memset(&gMC, 0, sizeof(MYCHAR));
@@ -253,8 +250,7 @@
int dash2;
int resist;
- int a;
- int x;
+ int a, x;
if (gMC.cond & 2)
return;
@@ -933,6 +929,8 @@
void SetMyCharDirect(unsigned char dir)
{
+ int i;
+
if (dir == 3)
{
gMC.cond |= 1;
@@ -947,8 +945,6 @@
}
else
{
- int i;
-
for (i = 0; i < NPC_MAX; ++i)
if (gNPC[i].code_event == dir)
break;
@@ -989,6 +985,9 @@
{
gMC.cond &= ~1;
}
+
+int noise_no;
+unsigned int noise_freq;
void SetNoise(int no, int freq)
{
--- a/src/MycHit.cpp
+++ b/src/MycHit.cpp
@@ -409,10 +409,12 @@
void HitMyCharMap(void)
{
+ int x, y;
int i;
+ unsigned char atrb[4];
- int x = gMC.x / 0x10 / 0x200;
- int y = gMC.y / 0x10 / 0x200;
+ x = gMC.x / 0x10 / 0x200;
+ y = gMC.y / 0x10 / 0x200;
int offx[4];
int offy[4];
@@ -427,7 +429,6 @@
offy[2] = 1;
offy[3] = 1;
- unsigned char atrb[4];
for (i = 0; i < 4; ++i)
{
atrb[i] = GetAttribute(x + offx[i], y + offy[i]);
@@ -666,13 +667,13 @@
int JudgeHitMyCharNPC4(NPCHAR *npc)
{
// TODO: comment this
+ int hit = 0;
+
+ float fy1;
float fx1;
float fx2;
- float fy1;
float fy2;
- int hit = 0;
-
if (npc->x > gMC.x)
fx1 = (float)(npc->x - gMC.x);
else
@@ -768,7 +769,6 @@
void HitMyCharNpChar(void)
{
int i;
-
int hit = 0;
if (!(gMC.cond & 0x80) || gMC.cond & 2)
@@ -859,7 +859,6 @@
void HitMyCharBoss(void)
{
int b;
-
int hit = 0;
if (!(gMC.cond & 0x80) || gMC.cond & 2)
--- a/src/MycParam.cpp
+++ b/src/MycParam.cpp
@@ -37,8 +37,6 @@
{{40, 60, 200}}
};
-int time_count;
-
void AddExpMyChar(int x)
{
int lv = gArmsData[gSelectedArms].level - 1;
@@ -96,9 +94,11 @@
BOOL IsMaxExpMyChar(void)
{
+ int arms_code;
+
if (gArmsData[gSelectedArms].level == 3)
{
- int arms_code = gArmsData[gSelectedArms].code;
+ arms_code = gArmsData[gSelectedArms].code;
if (gArmsData[gSelectedArms].exp >= gArmsLevelTable[arms_code].exp[2])
return TRUE;
@@ -235,16 +235,8 @@
void PutArmsEnergy(BOOL flash)
{
- RECT rcExpBox;
- RECT rcExpVal;
- RECT rcExpMax;
- RECT rcExpFlash;
+ static unsigned char add_flash;
- int lv;
- int arms_code;
- int exp_now;
- int exp_next;
-
RECT rcPer = {72, 48, 80, 56};
RECT rcLv = {80, 80, 96, 88};
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
@@ -275,15 +267,15 @@
PutBitmap3(&rcView, gArmsEnergyX, 32, &rcLv, SURFACE_ID_TEXT_BOX);
PutNumber4(gArmsEnergyX - 8, 32, gArmsData[gSelectedArms].level, FALSE);
- SET_RECT(rcExpBox, 0, 72, 40, 80)
- SET_RECT(rcExpVal, 0, 80, 0, 88)
- SET_RECT(rcExpMax, 40, 72, 80, 80)
- SET_RECT(rcExpFlash, 40, 80, 80, 88)
+ RECT rcExpBox = {0, 72, 40, 80};
+ RECT rcExpVal = {0, 80, 0, 88};
+ RECT rcExpMax = {40, 72, 80, 80};
+ RECT rcExpFlash = {40, 80, 80, 88};
- lv = gArmsData[gSelectedArms].level - 1;
- arms_code = gArmsData[gSelectedArms].code;
- exp_now = gArmsData[gSelectedArms].exp;
- exp_next = gArmsLevelTable[arms_code].exp[lv];
+ int lv = gArmsData[gSelectedArms].level - 1;
+ int arms_code = gArmsData[gSelectedArms].code;
+ int exp_now = gArmsData[gSelectedArms].exp;
+ int exp_next = gArmsLevelTable[arms_code].exp[lv];
PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpBox, SURFACE_ID_TEXT_BOX);
@@ -301,7 +293,6 @@
PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpVal, SURFACE_ID_TEXT_BOX);
}
- static unsigned char add_flash;
if (gMC.exp_wait && ((add_flash++ / 2) % 2))
PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpFlash, SURFACE_ID_TEXT_BOX);
}
@@ -310,10 +301,9 @@
{
int x;
int a;
- int arms_num;
RECT rect = {0, 0, 0, 16};
- arms_num = 0;
+ int arms_num = 0;
while (gArmsData[arms_num].code != 0)
++arms_num;
@@ -399,6 +389,8 @@
}
}
+int time_count;
+
void PutTimeCounter(int x, int y)
{
RECT rcTime[3] = {
@@ -439,10 +431,11 @@
BOOL SaveTimeCounter(void)
{
- unsigned char *p;
int i;
-
+ unsigned char *p;
REC rec;
+ FILE *fp;
+ char path[MAX_PATH];
// Quit if player doesn't have the Nikumaru Counter
if (!(gMC.equip & 0x100))
@@ -449,10 +442,9 @@
return TRUE;
// Get last time
- char path[MAX_PATH];
sprintf(path, "%s/290.rec", gModulePath);
- FILE *fp = fopen(path, "rb");
+ fp = fopen(path, "rb");
if (fp)
{
// Read data
@@ -508,19 +500,19 @@
int LoadTimeCounter(void)
{
- unsigned char *p;
int i;
+ unsigned char *p;
+ REC rec;
+ FILE *fp;
+ char path[MAX_PATH];
// Open file
- char path[MAX_PATH];
sprintf(path, "%s/290.rec", gModulePath);
- FILE *fp = fopen(path, "rb");
+ fp = fopen(path, "rb");
if (!fp)
return 0;
- REC rec;
-
// Read data
rec.counter[0] = File_ReadLE32(fp);
rec.counter[1] = File_ReadLE32(fp);
@@ -548,9 +540,7 @@
time_count = 0;
return 0;
}
- else
- {
- time_count = rec.counter[0];
- return time_count;
- }
+
+ time_count = rec.counter[0];
+ return time_count;
}
--- a/src/NpChar.cpp
+++ b/src/NpChar.cpp
@@ -53,14 +53,13 @@
BOOL LoadEvent(const char *path_event)
{
+ int i, n;
FILE *fp;
int count;
- int i;
- int n;
- EVENT eve;
- char path[MAX_PATH];
char code[4];
+ EVENT eve;
+ char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, path_event);
fp = fopen(path, "rb");
@@ -195,8 +194,10 @@
void SetExpObjects(int x, int y, int exp)
{
+ int n;
int sub_exp;
- int n = 0x100;
+
+ n = 0x100;
while (exp)
{
while (n < NPC_MAX && gNPC[n].cond)
@@ -316,8 +317,10 @@
void VanishNpChar(NPCHAR *npc)
{
- int x = npc->x;
- int y = npc->y;
+ int x, y;
+
+ x = npc->x;
+ y = npc->y;
memset(npc, 0, sizeof(NPCHAR));
npc->count1 = 0;
npc->x = x;
@@ -335,12 +338,12 @@
int n;
signed char a = 0;
+ int side;
+
for (n = 0; n < NPC_MAX; ++n)
{
if (gNPC[n].cond & 0x80)
{
- int side;
-
if (gNPC[n].shock)
{
a = 2 * ((gNPC[n].shock / 2) % 2) - 1;
@@ -373,12 +376,13 @@
void ActNpChar(void)
{
int i;
+ int code_char;
for (i = 0; i < NPC_MAX; ++i)
{
if (gNPC[i].cond & 0x80)
{
- int code_char = gNPC[i].code_char;
+ code_char = gNPC[i].code_char;
gpNpcFuncTbl[code_char](&gNPC[i]);
--- a/src/NpcAct000.cpp
+++ b/src/NpcAct000.cpp
@@ -917,8 +917,7 @@
void ActNpc010(NPCHAR *npc)
{
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
switch (npc->act_no)
{
@@ -1075,8 +1074,7 @@
void ActNpc012(NPCHAR *npc)
{
int i;
- int x;
- int y;
+ int x, y;
switch (npc->act_no)
{
@@ -1429,8 +1427,6 @@
// Santa's Key
void ActNpc014(NPCHAR *npc)
{
- int i;
-
RECT rect[3] = {
{192, 0, 208, 16},
{208, 0, 224, 16},
@@ -1437,6 +1433,8 @@
{224, 0, 240, 16},
};
+ int i;
+
switch (npc->act_no)
{
case 0:
@@ -1474,8 +1472,6 @@
// Chest (closed)
void ActNpc015(NPCHAR *npc)
{
- int i;
-
RECT rcLeft[3] = {
{240, 0, 256, 16},
{256, 0, 272, 16},
@@ -1482,6 +1478,8 @@
{272, 0, 288, 16},
};
+ int i;
+
switch (npc->act_no)
{
case 0:
@@ -1533,8 +1531,6 @@
// Save point
void ActNpc016(NPCHAR *npc)
{
- int i;
-
RECT rect[8] = {
{96, 16, 112, 32},
{112, 16, 128, 32},
@@ -1545,6 +1541,8 @@
{192, 16, 208, 32},
{208, 16, 224, 32},
};
+
+ int i;
switch (npc->act_no)
{
--- a/src/NpcAct020.cpp
+++ b/src/NpcAct020.cpp
@@ -1096,10 +1096,9 @@
// Balrog (hover)
void ActNpc036(NPCHAR *npc)
{
- unsigned char deg;
- int ym;
- int xm;
int i;
+ unsigned char deg;
+ int xm, ym;
switch (npc->act_no)
{
--- a/src/NpcAct040.cpp
+++ b/src/NpcAct040.cpp
@@ -118,6 +118,8 @@
// Sue
void ActNpc042(NPCHAR *npc)
{
+ int n;
+
RECT rcLeft[13] = {
{0, 0, 16, 16},
{16, 0, 32, 16},
@@ -150,8 +152,6 @@
{160, 48, 176, 64},
};
- int n;
-
switch (npc->act_no)
{
case 0:
@@ -870,8 +870,7 @@
void ActNpc049(NPCHAR *npc)
{
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
if (npc->act_no >= 10 && npc->pNpc->code_char == 3)
{
@@ -1916,8 +1915,8 @@
if ((++npc->count2 % 8) == 0 && npc->x < gMC.x + (160 * 0x200) && npc->x > gMC.x - (160 * 0x200)) // TODO: Maybe do something about this for widescreen
{
unsigned char deg;
- int ym;
int xm;
+ int ym;
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
deg += (unsigned char)Random(-6, 6);
--- a/src/NpcAct060.cpp
+++ b/src/NpcAct060.cpp
@@ -199,6 +199,8 @@
// King
void ActNpc061(NPCHAR *npc)
{
+ int i;
+
RECT rcLeft[11] = {
{224, 32, 240, 48},
{240, 32, 256, 48},
@@ -226,8 +228,6 @@
{0, 0, 0, 0},
{112, 32, 128, 48},
};
-
- int i;
switch (npc->act_no)
{
--- a/src/NpcAct080.cpp
+++ b/src/NpcAct080.cpp
@@ -877,8 +877,7 @@
{
int i;
unsigned char deg;
- int xm;
- int ym;
+ int xm, ym;
RECT rcLeft[12] = {
{0, 0, 40, 40},
--- a/src/NpcAct100.cpp
+++ b/src/NpcAct100.cpp
@@ -1068,8 +1068,6 @@
// Press
void ActNpc114(NPCHAR *npc)
{
- int i;
-
RECT rcLeft[3] = {
{144, 112, 160, 136},
{160, 112, 176, 136},
@@ -1076,6 +1074,8 @@
{176, 112, 192, 136},
};
+ int i;
+
switch (npc->act_no)
{
case 0:
@@ -1521,6 +1521,8 @@
// Curly (boss)
void ActNpc118(NPCHAR *npc)
{
+ BOOL bUpper;
+
RECT rcLeft[9] = {
{0, 32, 32, 56},
{32, 32, 64, 56},
@@ -1545,7 +1547,7 @@
{160, 56, 192, 80},
};
- BOOL bUpper = FALSE;
+ bUpper = FALSE;
if (npc->direct == 0 && npc->x < gMC.x)
bUpper = TRUE;
--- a/src/NpcAct120.cpp
+++ b/src/NpcAct120.cpp
@@ -1090,8 +1090,7 @@
void ActNpc135(NPCHAR *npc)
{
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
RECT rcLeft[2] = {
{256, 32, 288, 64},
--- a/src/NpcAct140.cpp
+++ b/src/NpcAct140.cpp
@@ -764,9 +764,8 @@
// Critter (purple)
void ActNpc147(NPCHAR *npc)
{
+ int xm, ym;
unsigned char deg;
- int xm;
- int ym;
RECT rcLeft[6] = {
{0, 96, 16, 112},
@@ -1349,7 +1348,7 @@
npc->rect = rc;
}
-static const RECT grcKitL[21] = {
+const RECT grcKitL[21] = {
{0, 0, 24, 24},
{24, 0, 48, 24},
{48, 0, 72, 24},
@@ -1373,7 +1372,7 @@
{96, 48, 120, 72}
};
-static const RECT grcKitR[21] = {
+const RECT grcKitR[21] = {
{0, 24, 24, 48},
{24, 24, 48, 48},
{48, 24, 72, 48},
@@ -1624,8 +1623,7 @@
void ActNpc155(NPCHAR *npc)
{
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
if (npc->x > gMC.x + (((WINDOW_WIDTH / 2) + 160) * 0x200) || npc->x < gMC.x - (((WINDOW_WIDTH / 2) + 160) * 0x200) || npc->y > gMC.y + (((WINDOW_HEIGHT / 2) + 120) * 0x200) || npc->y < gMC.y - (((WINDOW_HEIGHT / 2) + 120) * 0x200))
return;
--- a/src/NpcAct160.cpp
+++ b/src/NpcAct160.cpp
@@ -1071,8 +1071,7 @@
void ActNpc173(NPCHAR *npc)
{
unsigned char deg;
- int xm;
- int ym;
+ int xm, ym;
RECT rcLeft[4] = {
{0, 128, 24, 152},
--- a/src/NpcAct180.cpp
+++ b/src/NpcAct180.cpp
@@ -19,8 +19,7 @@
// Curly AI
void ActNpc180(NPCHAR *npc)
{
- int xx;
- int yy;
+ int xx, yy;
RECT rcLeft[11] = {
{0, 96, 16, 112},
@@ -978,12 +977,12 @@
// Broken robot
void ActNpc190(NPCHAR *npc)
{
- int i;
-
RECT rect[2] = {
{192, 32, 208, 48},
{208, 32, 224, 48},
};
+
+ int i;
switch (npc->act_no)
{
--- a/src/NpcAct200.cpp
+++ b/src/NpcAct200.cpp
@@ -17,8 +17,7 @@
void ActNpc200(NPCHAR *npc)
{
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
RECT rcLeft[6] = {
{0, 0, 40, 40},
@@ -475,8 +474,8 @@
case 3:
switch (npc->act_wait)
{
- // Interestingly, this NPC counts down at 60 frames per second,
- // while the NPC322 (Deleet), counts at 50.
+ // Interestingly, this NPC counts down at 60 frames
+ // per second, while NPC322 (Deleet) counts at 50.
case 60 * 0:
SetNpChar(207, npc->x + (16 * 0x200), npc->y + (4 * 0x200), 0, 0, 0, NULL, 0x100);
break;
--- a/src/NpcAct220.cpp
+++ b/src/NpcAct220.cpp
@@ -1129,10 +1129,10 @@
// Gunfish projectile
void ActNpc237(NPCHAR *npc)
{
+ RECT rc = {312, 32, 320, 40};
+
int i;
BOOL bHit;
-
- RECT rc = {312, 32, 320, 40};
switch (npc->act_no)
{
--- a/src/NpcAct240.cpp
+++ b/src/NpcAct240.cpp
@@ -318,12 +318,14 @@
// Lava drop
void ActNpc244(NPCHAR *npc)
{
+ RECT rc = {96, 0, 104, 16};
+ BOOL bHit;
+
int i;
- RECT rc = {96, 0, 104, 16};
npc->ym += 0x40;
- BOOL bHit = FALSE;
+ bHit = FALSE;
if (npc->flag & 0xFF)
bHit = TRUE;
@@ -411,8 +413,6 @@
// Press (proximity)
void ActNpc246(NPCHAR *npc)
{
- int i;
-
RECT rcLeft[3] = {
{144, 112, 160, 136},
{160, 112, 176, 136},
@@ -419,6 +419,8 @@
{176, 112, 192, 136},
};
+ int i;
+
switch (npc->act_no)
{
case 0:
@@ -504,8 +506,7 @@
void ActNpc247(NPCHAR *npc)
{
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
RECT rcLeft[9] = {
{0, 0, 16, 16},
--- a/src/NpcAct260.cpp
+++ b/src/NpcAct260.cpp
@@ -186,8 +186,7 @@
void ActNpc263(NPCHAR *npc)
{
int deg;
- int xm;
- int ym;
+ int xm, ym;
RECT rcLeft[9] = {
{0, 0, 24, 32},
@@ -469,10 +468,9 @@
// Doctor red wave (projectile)
void ActNpc264(NPCHAR *npc)
{
+ RECT rc = {288, 0, 304, 16};
unsigned char deg;
- RECT rc = {288, 0, 304, 16};
-
if (npc->x < 0 || npc->x > gMap.width * 0x10 * 0x200)
{
VanishNpChar(npc);
@@ -597,8 +595,7 @@
{40, 160, 80, 208},
};
- int ym;
- int xm;
+ int xm, ym;
int i;
switch (npc->act_no)
@@ -1133,8 +1130,7 @@
void ActNpc268(NPCHAR *npc)
{
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
RECT rcLeft[10] = {
{0, 0, 40, 40},
@@ -1631,8 +1627,7 @@
};
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
switch (npc->act_no)
{
@@ -1825,8 +1820,7 @@
};
unsigned char deg;
- int ym;
- int xm;
+ int xm, ym;
switch (npc->act_no)
{
@@ -2158,12 +2152,12 @@
// Falling block (large)
void ActNpc279(NPCHAR *npc)
{
- int i;
-
RECT rc[2] = {
{0, 16, 32, 48},
{16, 0, 32, 16},
};
+
+ int i;
switch (npc->act_no)
{
--- a/src/NpcAct280.cpp
+++ b/src/NpcAct280.cpp
@@ -129,6 +129,7 @@
// Mini Undead Core (active)
void ActNpc282(NPCHAR *npc)
{
+ // Yes, Pixel spelt this wrong (should be 'rc')
RECT tc[3] = {
{256, 80, 320, 120},
{256, 0, 320, 40},
@@ -203,9 +204,7 @@
// Misery (transformed)
void ActNpc283(NPCHAR *npc)
{
- int x;
- int y;
- int direct;
+ int x, y, direct;
RECT rcLeft[11] = {
{0, 64, 32, 96},
@@ -966,6 +965,7 @@
void ActNpc285(NPCHAR *npc)
{
RECT rc = {232, 104, 248, 120};
+ unsigned char deg;
if (npc->x < 0 || npc->x > gMap.width * 0x10 * 0x200)
{
@@ -973,8 +973,6 @@
return;
}
- unsigned char deg;
-
switch (npc->act_no)
{
case 0:
@@ -1422,9 +1420,7 @@
// Quake + falling block generator
void ActNpc294(NPCHAR *npc)
{
- int x;
- int y;
- int dir;
+ int x, y, dir;
switch (npc->act_no)
{
@@ -1567,10 +1563,7 @@
// Cloud generator
void ActNpc296(NPCHAR *npc)
{
- int x;
- int y;
- int dir;
- int pri;
+ int x, y, dir, pri;
if (++npc->act_wait > 16)
{
--- a/src/NpcAct300.cpp
+++ b/src/NpcAct300.cpp
@@ -35,6 +35,8 @@
// Fish missile (Misery)
void ActNpc301(NPCHAR *npc)
{
+ int dir;
+
RECT rect[8] = {
{144, 0, 160, 16},
{160, 0, 176, 16},
@@ -46,8 +48,6 @@
{192, 16, 208, 32},
};
- int dir;
-
switch (npc->act_no)
{
case 0:
@@ -102,6 +102,8 @@
// Camera focus marker
void ActNpc302(NPCHAR *npc)
{
+ int n;
+
switch (npc->act_no)
{
case 10:
@@ -143,18 +145,16 @@
if (npc->direct != 0)
{
- int i;
-
- for (i = 0xAA; i < 0x200; ++i)
+ for (n = 0xAA; n < 0x200; ++n)
{
- if (gNPC[i].cond & 0x80 && gNPC[i].code_event == npc->direct)
+ if (gNPC[n].cond & 0x80 && gNPC[n].code_event == npc->direct)
{
- npc->pNpc = &gNPC[i];
+ npc->pNpc = &gNPC[n];
break;
}
}
- if (i == 0x200)
+ if (n == 0x200)
{
npc->cond = 0;
break;
@@ -401,6 +401,8 @@
// Stumpy
void ActNpc308(NPCHAR *npc)
{
+ unsigned char deg;
+
RECT rcLeft[2] = {
{128, 112, 144, 128},
{144, 112, 160, 128},
@@ -410,8 +412,6 @@
{128, 128, 144, 144},
{144, 128, 160, 144},
};
-
- unsigned char deg;
switch (npc->act_no)
{
--- a/src/NpcAct320.cpp
+++ b/src/NpcAct320.cpp
@@ -220,7 +220,7 @@
switch (npc->act_wait)
{
// Interestingly, this NPC counts down at 50 frames per second,
- // while the NPC206 (the Egg Corridor Counter Bomb), counts at 60.
+ // while NPC206 (the Egg Corridor Counter Bomb), counts at 60.
case 50 * 0:
SetNpChar(207, npc->x + (4 * 0x200), npc->y, 0, 0, 0, NULL, 0x180);
break;
@@ -801,13 +801,13 @@
// Ballos shockwave
void ActNpc332(NPCHAR *npc)
{
- int xm;
-
RECT rc[3] = {
{144, 96, 168, 120},
{168, 96, 192, 120},
{192, 96, 216, 120},
};
+
+ int xm;
switch (npc->act_no)
{
--- a/src/NpcAct340.cpp
+++ b/src/NpcAct340.cpp
@@ -592,7 +592,6 @@
void ActNpc342(NPCHAR *npc)
{
static int flash;
- unsigned char deg;
RECT rc[3] = {
{240, 48, 280, 88},
@@ -600,6 +599,8 @@
{280, 48, 320, 88},
};
+ unsigned char deg;
+
if (npc->act_no < 1000 && npc->pNpc->act_no >= 1000)
npc->act_no = 1000;
@@ -905,8 +906,6 @@
// Ballos skull projectile
void ActNpc345(NPCHAR *npc)
{
- int i;
-
RECT rc[4] = {
{128, 176, 144, 192},
{144, 176, 160, 192},
@@ -914,6 +913,8 @@
{176, 176, 192, 192},
};
+ int i;
+
switch (npc->act_no)
{
case 0:
@@ -974,10 +975,9 @@
// Ballos 4 orbiting platform
void ActNpc346(NPCHAR *npc)
{
+ RECT rc = {240, 0, 272, 16};
unsigned char deg;
- RECT rc = {240, 0, 272, 16};
-
if (npc->act_no < 1000 && npc->pNpc->act_no >= 1000)
npc->act_no = 1000;
@@ -1724,9 +1724,7 @@
// Invisible deathtrap wall
void ActNpc354(NPCHAR *npc)
{
- int i;
- int x;
- int y;
+ int i, x, y;
switch (npc->act_no)
{
--- a/src/NpcHit.cpp
+++ b/src/NpcHit.cpp
@@ -264,15 +264,15 @@
npc->flag |= hit;
}
-void HitNpCharMap()
+void HitNpCharMap(void)
{
- int judg, x, y;
+ int x, y;
+ int judg;
int offx[9];
int offy[9];
- int i;
- int j;
+ int i, j;
offx[0] = 0;
offx[1] = 1;
@@ -460,6 +460,8 @@
void LoseNpChar(NPCHAR *npc, BOOL bVanish)
{
+ int val;
+
// Play death sound
PlaySoundObject(npc->destroy_voice, 1);
@@ -482,8 +484,6 @@
// Create drop
if (npc->exp != 0)
{
- int val;
-
switch (Random(1, 5))
{
case 1:
@@ -534,8 +534,7 @@
void HitNpCharBullet(void)
{
- int n;
- int b;
+ int n, b;
BOOL bHit;
for (n = 0; n < NPC_MAX; ++n)
--- a/src/NpcTbl.cpp
+++ b/src/NpcTbl.cpp
@@ -10,67 +10,6 @@
#include "Generic.h"
#include "NpcAct.h"
-NPC_TABLE *gNpcTable;
-
-BOOL LoadNpcTable(const char *path)
-{
- FILE *fp;
- int n;
- int num;
- size_t size;
-
- size = GetFileSizeLong(path); // TODO - Investigate whether GetFileSizeLong actually returns an unsigned long or not
- if (size == -1)
- return FALSE;
-
- num = (int)(size / 0x18);
-
- gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE));
- if (gNpcTable == NULL)
- return FALSE;
-
- fp = fopen(path, "rb");
- if (fp == NULL)
- {
- free(gNpcTable);
- gNpcTable = NULL;
- return FALSE;
- }
-
- for (n = 0; n < num; ++n) // bits
- gNpcTable[n].bits = File_ReadLE16(fp);
- for (n = 0; n < num; ++n) // life
- gNpcTable[n].life = File_ReadLE16(fp);
- for (n = 0; n < num; ++n) // surf
- fread(&gNpcTable[n].surf, 1, 1, fp);
- for (n = 0; n < num; ++n) // destroy_voice
- fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
- for (n = 0; n < num; ++n) // hit_voice
- fread(&gNpcTable[n].hit_voice, 1, 1, fp);
- for (n = 0; n < num; ++n) // size
- fread(&gNpcTable[n].size, 1, 1, fp);
- for (n = 0; n < num; ++n) // exp
- gNpcTable[n].exp = File_ReadLE32(fp);
- for (n = 0; n < num; ++n) // damage
- gNpcTable[n].damage = File_ReadLE32(fp);
- for (n = 0; n < num; ++n) // hit
- fread(&gNpcTable[n].hit, 4, 1, fp);
- for (n = 0; n < num; ++n) // view
- fread(&gNpcTable[n].view, 4, 1, fp);
-
- fclose(fp);
- return TRUE;
-}
-
-void ReleaseNpcTable(void)
-{
- if (gNpcTable != NULL)
- {
- free(gNpcTable);
- gNpcTable = NULL;
- }
-}
-
// Npc function table
const NPCFUNCTION gpNpcFuncTbl[361] = {
ActNpc000,
@@ -435,3 +374,64 @@
ActNpc359,
ActNpc360,
};
+
+NPC_TABLE *gNpcTable;
+
+BOOL LoadNpcTable(const char *path)
+{
+ FILE *fp;
+ int n;
+ size_t size;
+ int num;
+
+ size = GetFileSizeLong(path); // TODO - Investigate whether GetFileSizeLong actually returns an unsigned long or not
+ if (size == -1)
+ return FALSE;
+
+ num = (int)(size / 0x18);
+
+ gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE));
+ if (gNpcTable == NULL)
+ return FALSE;
+
+ fp = fopen(path, "rb");
+ if (fp == NULL)
+ {
+ free(gNpcTable);
+ gNpcTable = NULL;
+ return FALSE;
+ }
+
+ for (n = 0; n < num; ++n) // bits
+ gNpcTable[n].bits = File_ReadLE16(fp);
+ for (n = 0; n < num; ++n) // life
+ gNpcTable[n].life = File_ReadLE16(fp);
+ for (n = 0; n < num; ++n) // surf
+ fread(&gNpcTable[n].surf, 1, 1, fp);
+ for (n = 0; n < num; ++n) // destroy_voice
+ fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
+ for (n = 0; n < num; ++n) // hit_voice
+ fread(&gNpcTable[n].hit_voice, 1, 1, fp);
+ for (n = 0; n < num; ++n) // size
+ fread(&gNpcTable[n].size, 1, 1, fp);
+ for (n = 0; n < num; ++n) // exp
+ gNpcTable[n].exp = File_ReadLE32(fp);
+ for (n = 0; n < num; ++n) // damage
+ gNpcTable[n].damage = File_ReadLE32(fp);
+ for (n = 0; n < num; ++n) // hit
+ fread(&gNpcTable[n].hit, 4, 1, fp);
+ for (n = 0; n < num; ++n) // view
+ fread(&gNpcTable[n].view, 4, 1, fp);
+
+ fclose(fp);
+ return TRUE;
+}
+
+void ReleaseNpcTable(void)
+{
+ if (gNpcTable != NULL)
+ {
+ free(gNpcTable);
+ gNpcTable = NULL;
+ }
+}
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -97,16 +97,8 @@
unsigned short organya_timer;
-ORGDATA org_data;
-
AudioBackend_Sound *lpORGANBUFFER[8][8][2] = {NULL};
-int gTrackVol[MAXTRACK];
-int gOrgVolume = 100;
-BOOL bFadeout = FALSE;
-BOOL g_mute[MAXTRACK]; // Used by the debug Mute menu
-
-
/////////////////////////////////////////////
//■オルガーニャ■■■■■■■■■■■■/////// (Organya)
/////////////////////
@@ -119,7 +111,7 @@
short oct_size;
} OCTWAVE;
-static const OCTWAVE oct_wave[8] =
+OCTWAVE oct_wave[8] =
{
{ 256, 1, 4 }, // 0 Oct
{ 256, 2, 8 }, // 1 Oct
@@ -187,7 +179,7 @@
return TRUE;
}
-static const short freq_tbl[12] = {262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494};
+short freq_tbl[12] = {262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494};
void ChangeOrganFrequency(unsigned char key, signed char track, long a)
{
@@ -199,7 +191,8 @@
AudioBackend_SetSoundFrequency(lpORGANBUFFER[track][j][i], ((oct_wave[j].wave_size * freq_tbl[key]) * oct_wave[j].oct_par) / 8 + (a - 1000)); // 1000を+αのデフォルト値とする (1000 is the default value for + α)
}
-const short pan_tbl[13] = {0, 43, 86, 129, 172, 215, 256, 297, 340, 383, 426, 469, 512};
+BOOL g_mute[MAXTRACK]; // Used by the debug Mute menu
+short pan_tbl[13] = {0, 43, 86, 129, 172, 215, 256, 297, 340, 383, 426, 469, 512};
unsigned char old_key[MAXTRACK] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // 再生中の音 (Sound being played)
unsigned char key_on[MAXTRACK]; // キースイッチ (Key switch)
unsigned char key_twin[MAXTRACK]; // 今使っているキー(連続時のノイズ防止の為に二つ用意) (Currently used keys (prepared for continuous noise prevention))
@@ -400,11 +393,11 @@
}
}
+ORGDATA org_data;
+
OrgData::OrgData(void)
{
- int i;
-
- for (i = 0; i < MAXTRACK; i++)
+ for (int i = 0; i < MAXTRACK; i++)
{
info.tdata[i].note_list = NULL;
info.tdata[i].note_p = NULL;
@@ -421,8 +414,7 @@
info.repeat_x = info.dot * info.line * 0;
info.end_x = info.dot * info.line * 255;
- int i;
- for (i = 0; i < MAXTRACK; i++)
+ for (int i = 0; i < MAXTRACK; i++)
{
info.tdata[i].freq = 1000;
info.tdata[i].wave_no = 0;
@@ -539,8 +531,8 @@
}
}
-static const char pass[7] = "Org-01";
-static const char pass2[7] = "Org-02"; // Pipi
+char pass[7] = "Org-01";
+char pass2[7] = "Org-02"; // Pipi
BOOL OrgData::InitMusicData(const char *path)
{
@@ -691,37 +683,41 @@
}
// Play data
-long play_p;
-NOTELIST *play_np[MAXTRACK];
+long PlayPos; // Called 'play_p' in the source code release
+NOTELIST *np[MAXTRACK];
long now_leng[MAXMELODY];
+int Volume = 100;
+int TrackVol[MAXTRACK];
+BOOL bFadeout = FALSE;
+
void OrgData::PlayData(void)
{
int i;
// Handle fading out
- if (bFadeout && gOrgVolume)
- gOrgVolume -= 2;
- if (gOrgVolume < 0)
- gOrgVolume = 0;
+ if (bFadeout && Volume)
+ Volume -= 2;
+ if (Volume < 0)
+ Volume = 0;
// メロディの再生 (Play melody)
for (i = 0; i < MAXMELODY; i++)
{
- if (play_np[i] != NULL && play_p == play_np[i]->x)
+ if (np[i] != NULL && PlayPos == np[i]->x)
{
- if (!g_mute[i] && play_np[i]->y != KEYDUMMY) // 音が来た。 (The sound has come.)
+ if (!g_mute[i] && np[i]->y != KEYDUMMY) // 音が来た。 (The sound has come.)
{
- PlayOrganObject(play_np[i]->y, -1, i, info.tdata[i].freq);
- now_leng[i] = play_np[i]->length;
+ PlayOrganObject(np[i]->y, -1, i, info.tdata[i].freq);
+ now_leng[i] = np[i]->length;
}
- if (play_np[i]->pan != PANDUMMY)
- ChangeOrganPan(play_np[i]->y, play_np[i]->pan, i);
- if (play_np[i]->volume != VOLDUMMY)
- gTrackVol[i] = play_np[i]->volume;
+ if (np[i]->pan != PANDUMMY)
+ ChangeOrganPan(np[i]->y, np[i]->pan, i);
+ if (np[i]->volume != VOLDUMMY)
+ TrackVol[i] = np[i]->volume;
- play_np[i] = play_np[i]->to; // 次の音符を指す (Points to the next note)
+ np[i] = np[i]->to; // 次の音符を指す (Points to the next note)
}
if (now_leng[i] == 0)
@@ -730,36 +726,36 @@
if (now_leng[i] > 0)
now_leng[i]--;
- if (play_np[i])
- ChangeOrganVolume(play_np[i]->y, gTrackVol[i] * gOrgVolume / 0x7F, i);
+ if (np[i])
+ ChangeOrganVolume(np[i]->y, TrackVol[i] * Volume / 0x7F, i);
}
// ドラムの再生 (Drum playback)
for (i = MAXMELODY; i < MAXTRACK; i++)
{
- if (play_np[i] != NULL && play_p == play_np[i]->x) // 音が来た。 (The sound has come.)
+ if (np[i] != NULL && PlayPos == np[i]->x) // 音が来た。 (The sound has come.)
{
- if (play_np[i]->y != KEYDUMMY && !g_mute[i]) // ならす (Tame)
- PlayDramObject(play_np[i]->y, 1, i - MAXMELODY);
+ if (np[i]->y != KEYDUMMY && !g_mute[i]) // ならす (Tame)
+ PlayDramObject(np[i]->y, 1, i - MAXMELODY);
- if (play_np[i]->pan != PANDUMMY)
- ChangeDramPan(play_np[i]->pan, i - MAXMELODY);
- if (play_np[i]->volume != VOLDUMMY)
- gTrackVol[i] = play_np[i]->volume;
+ if (np[i]->pan != PANDUMMY)
+ ChangeDramPan(np[i]->pan, i - MAXMELODY);
+ if (np[i]->volume != VOLDUMMY)
+ TrackVol[i] = np[i]->volume;
- play_np[i] = play_np[i]->to; // 次の音符を指す (Points to the next note)
+ np[i] = np[i]->to; // 次の音符を指す (Points to the next note)
}
- if (play_np[i])
- ChangeDramVolume(gTrackVol[i] * gOrgVolume / 0x7F, i - MAXMELODY);
+ if (np[i])
+ ChangeDramVolume(TrackVol[i] * Volume / 0x7F, i - MAXMELODY);
}
// Looping
- play_p++;
- if (play_p >= info.end_x)
+ PlayPos++;
+ if (PlayPos >= info.end_x)
{
- play_p = info.repeat_x;
- SetPlayPointer(play_p);
+ PlayPos = info.repeat_x;
+ SetPlayPointer(PlayPos);
}
}
@@ -767,12 +763,12 @@
{
for (int i = 0; i < MAXTRACK; i++)
{
- play_np[i] = info.tdata[i].note_list;
- while (play_np[i] != NULL && play_np[i]->x < x)
- play_np[i] = play_np[i]->to; // 見るべき音符を設定 (Set note to watch)
+ np[i] = info.tdata[i].note_list;
+ while (np[i] != NULL && np[i]->x < x)
+ np[i] = np[i]->to; // 見るべき音符を設定 (Set note to watch)
}
- play_p = x;
+ PlayPos = x;
}
// Start and end organya
@@ -798,7 +794,7 @@
if (!org_data.InitMusicData(name))
return FALSE;
- gOrgVolume = 100;
+ Volume = 100;
bFadeout = 0;
#ifdef FIX_BUGS
@@ -814,7 +810,7 @@
return;
org_data.SetPlayPointer(x);
- gOrgVolume = 100;
+ Volume = 100;
bFadeout = FALSE;
}
@@ -823,7 +819,7 @@
if (!audio_backend_initialised)
return 0 ;
- return play_p;
+ return PlayPos;
}
void PlayOrganyaMusic(void)
@@ -842,7 +838,7 @@
if (volume < 0 || volume > 100)
return FALSE;
- gOrgVolume = volume;
+ Volume = volume;
return TRUE;
}
--- a/src/PixTone.cpp
+++ b/src/PixTone.cpp
@@ -8,12 +8,14 @@
#include "Random.h"
-static signed char gWaveModelTable[6][0x100];
+signed char gWaveModelTable[6][0x100];
void MakeWaveTables(void)
{
- int i, a;
+ int i;
+ int a;
+
// Sine wave
for (i = 0; i < 0x100; ++i)
{
@@ -61,24 +63,28 @@
gWaveModelTable[5][i] = (signed char)(msvc_rand() & 0xFF) / 2;
}
+//BOOL wave_tables_made;
+
BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData)
{
int i;
- double dEnvelope;
+ int a, b, c, d;
+
double dPitch;
double dMain;
double dVolume;
- double d1;
- double d2;
- double d3;
- int a;
- int b;
- int c;
- int d;
+
+ double dEnvelope;
signed char envelopeTable[0x100];
+ double d1, d2, d3;
+
// The Linux port added a cute optimisation here, where MakeWaveTables is only called once during the game's execution
- MakeWaveTables();
+ //if (wave_tables_made != TRUE)
+ //{
+ MakeWaveTables();
+ // wave_tables_made = TRUE;
+ //}
memset(envelopeTable, 0, sizeof(envelopeTable));
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -41,9 +41,10 @@
BOOL SaveProfile(const char *name)
{
- PROFILE profile;
FILE *fp;
+ PROFILE profile;
const char *FLAG = "FLAG";
+
char path[MAX_PATH];
// Get path
@@ -121,9 +122,9 @@
BOOL LoadProfile(const char *name)
{
- char path[MAX_PATH];
- PROFILE profile;
FILE *fp;
+ PROFILE profile;
+ char path[MAX_PATH];
// Get path
if (name != NULL)
--- a/src/SelStage.cpp
+++ b/src/SelStage.cpp
@@ -14,8 +14,8 @@
PERMIT_STAGE gPermitStage[8];
-static int gSelectedStage;
-static int gStageSelectTitleY;
+int gSelectedStage;
+int gStageSelectTitleY;
void ClearPermitStage(void)
{
@@ -107,6 +107,9 @@
{
static unsigned int flash;
+ int i;
+ RECT rcStage;
+
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
RECT rcCur[2] = {
@@ -116,10 +119,8 @@
RECT rcTitle1 = {80, 64, 144, 72};
- int i;
int stage_num;
int stage_x;
- RECT rcStage;
if (gStageSelectTitleY > (WINDOW_HEIGHT / 2) - 74)
--gStageSelectTitleY;
--- a/src/Shoot.cpp
+++ b/src/Shoot.cpp
@@ -11,7 +11,6 @@
#include "Sound.h"
int empty;
-int spur_charge;
void ShootBullet_Frontia1(int level)
{
@@ -250,6 +249,7 @@
void ShootBullet_Machinegun1(int level)
{
int bul_no;
+ static int wait;
if (CountArmsBullet(4) > 4)
return;
@@ -355,7 +355,6 @@
}
else
{
- static int wait = 0;
++wait;
if (gMC.equip & 8)
@@ -896,6 +895,8 @@
}
}
+int spur_charge;
+
void ResetSpurCharge(void)
{
spur_charge = 0;
@@ -906,9 +907,9 @@
void ShootBullet_Spur(int level)
{
- static BOOL bMax;
- BOOL bShot;
int bul_no;
+ BOOL bShot;
+ static BOOL bMax;
bShot = FALSE;
@@ -1058,11 +1059,12 @@
void ShootBullet(void)
{
+ static int soft_rensha; // 'rensha' is Japanese for 'rapid-fire', apparently
+
if (empty != 0)
--empty;
// Only let the player shoot every 4 frames
- static int soft_rensha; // 'rensha' is Japanese for 'rapid-fire', apparently
if (soft_rensha != 0)
--soft_rensha;
--- a/src/Sound.cpp
+++ b/src/Sound.cpp
@@ -113,6 +113,8 @@
return TRUE;
}
+// Completely unused function for loading a .wav file as a sound effect.
+// Some say that sounds heard in CS Beta footage don't sound like PixTone...
BOOL LoadSoundObject(LPCSTR file_name, int no)
{
char path[MAX_PATH];
@@ -253,10 +255,9 @@
// TODO - The stack frame for this function is inaccurate
int MakePixToneObject(const PIXTONEPARAMETER *ptp, int ptp_num, int no)
{
- int i;
- int j;
- const PIXTONEPARAMETER *ptp_pointer;
int sample_count;
+ int i, j;
+ const PIXTONEPARAMETER *ptp_pointer;
unsigned char *pcm_buffer;
unsigned char *mixed_pcm_buffer;
--- a/src/Stage.cpp
+++ b/src/Stage.cpp
@@ -27,6 +27,9 @@
#endif
int gStageNo;
+MusicID gMusicNo;
+unsigned int gOldPos;
+MusicID gOldNo;
const STAGE_TABLE gTMT[95] = {
STAGE_ENTRY("0", "0", 4, "bk0", "Guest", "0", 0, "Null", "\x96\xB3"), // 無
@@ -128,9 +131,9 @@
BOOL TransferStage(int no, int w, int x, int y)
{
- BOOL bError;
- char path_dir[20];
char path[MAX_PATH];
+ char path_dir[20];
+ BOOL bError;
// Move character
SetMyCharPosition(x * 0x10 * 0x200, y * 0x10 * 0x200);
@@ -245,10 +248,6 @@
"TOROKO",
"WHITE"
};
-
-MusicID gMusicNo;
-unsigned int gOldPos;
-MusicID gOldNo;
void ChangeMusic(MusicID no)
{
--- a/src/Triangle.cpp
+++ b/src/Triangle.cpp
@@ -8,15 +8,13 @@
void InitTriangleTable(void)
{
int i;
- float a;
- float b;
// Sine
for (i = 0; i < 0x100; ++i)
- {
gSin[i] = (int)(sin(i * 6.2831998 / 256.0) * 512.0);
- }
+ float a, b;
+
// Tangent
for (i = 0; i < 0x21; ++i)
{
@@ -39,8 +37,8 @@
unsigned char GetArktan(int x, int y)
{
- unsigned char a;
short k;
+ unsigned char a;
x *= -1;
y *= -1;
--- a/src/ValueView.cpp
+++ b/src/ValueView.cpp
@@ -19,17 +19,11 @@
void SetValueView(int *px, int *py, int value)
{
- int index;
BOOL minus;
int v;
- int width;
- int dig[4];
- int fig[4];
- BOOL sw;
+
+ int index;
int i;
- RECT rect[20];
- RECT rcPlus;
- RECT rcMinus;
for (i = 0; i < VALUEVIEW_MAX; ++i)
{
@@ -77,6 +71,8 @@
// Get width
v = value;
+ int width;
+
if (value > 999)
width = 40;
else if (value > 99)
@@ -95,28 +91,32 @@
gVV[index].rect.right = 40;
gVV[index].rect.bottom = 8 * (index + 1);
- SET_RECT(rect[0], 0, 56, 8, 64);
- SET_RECT(rect[1], 8, 56, 16, 64);
- SET_RECT(rect[2], 16, 56, 24, 64);
- SET_RECT(rect[3], 24, 56, 32, 64);
- SET_RECT(rect[4], 32, 56, 40, 64);
- SET_RECT(rect[5], 40, 56, 48, 64);
- SET_RECT(rect[6], 48, 56, 56, 64);
- SET_RECT(rect[7], 56, 56, 64, 64);
- SET_RECT(rect[8], 64, 56, 72, 64);
- SET_RECT(rect[9], 72, 56, 80, 64);
- SET_RECT(rect[10], 0, 64, 8, 72);
- SET_RECT(rect[11], 8, 64, 16, 72);
- SET_RECT(rect[12], 16, 64, 24, 72);
- SET_RECT(rect[13], 24, 64, 32, 72);
- SET_RECT(rect[14], 32, 64, 40, 72);
- SET_RECT(rect[15], 40, 64, 48, 72);
- SET_RECT(rect[16], 48, 64, 56, 72);
- SET_RECT(rect[17], 56, 64, 64, 72);
- SET_RECT(rect[18], 64, 64, 72, 72);
- SET_RECT(rect[19], 72, 64, 80, 72);
+ RECT rect[20] = {
+ {0, 56, 8, 64},
+ {8, 56, 16, 64},
+ {16, 56, 24, 64},
+ {24, 56, 32, 64},
+ {32, 56, 40, 64},
+ {40, 56, 48, 64},
+ {48, 56, 56, 64},
+ {56, 56, 64, 64},
+ {64, 56, 72, 64},
+ {72, 56, 80, 64},
+ {0, 64, 8, 72},
+ {8, 64, 16, 72},
+ {16, 64, 24, 72},
+ {24, 64, 32, 72},
+ {32, 64, 40, 72},
+ {40, 64, 48, 72},
+ {48, 64, 56, 72},
+ {56, 64, 64, 72},
+ {64, 64, 72, 72},
+ {72, 64, 80, 72},
+ };
// Get digits
+ int dig[4];
+ int fig[4];
dig[0] = 1;
dig[1] = 10;
dig[2] = 100;
@@ -133,10 +133,10 @@
}
}
- sw = FALSE;
+ BOOL sw = FALSE;
- SET_RECT(rcPlus, 32, 48, 40, 56);
- SET_RECT(rcMinus, 40, 48, 48, 56);
+ RECT rcPlus = {32, 48, 40, 56};
+ RECT rcMinus = {40, 48, 48, 56};
// Draw value
CortBox2(&gVV[index].rect, 0x000000, SURFACE_ID_VALUE_VIEW);
@@ -182,8 +182,8 @@
void PutValueView(int flx, int fly)
{
- int v;
int offset_x;
+ int v;
for (v = 0; v < VALUEVIEW_MAX; ++v)
{
--- a/src/WindowsWrapper.h
+++ b/src/WindowsWrapper.h
@@ -20,10 +20,4 @@
long bottom;
};
-#define SET_RECT(rect, l, t, r, b) \
- rect.left = l; \
- rect.top = t; \
- rect.right = r; \
- rect.bottom = b;
-
#define MAX_PATH FILENAME_MAX