ref: 0ec5d85d5620cbbf09033bd59726cd9b5a4ddd5b
parent: 531a6a0aeb416ee06b47d34e9c37d5f8d1a975e6
parent: 7e2e2c14060f62423b61c17ad314fadf95bded64
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sun Nov 17 13:30:44 EST 2019
Merge branch 'accurate' into portable
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
-NATIVECC = cc
-NATIVECXX = c++
-WINDRES = windres
-PKG_CONFIG = pkg-config
+NATIVECC ?= cc
+NATIVECXX ?= c++
+WINDRES ?= windres
+PKG_CONFIG ?= pkg-config
BUILD_DIRECTORY = game
ASSETS_DIRECTORY = assets
--- a/src/ArmsItem.cpp
+++ b/src/ArmsItem.cpp
@@ -26,7 +26,7 @@
static BOOL gCampActive;
static int gCampTitleY;
-void ClearArmsData()
+void ClearArmsData(void)
{
#ifdef FIX_BUGS
gSelectedArms = 0; // Should probably be done in order to avoid potential problems with the selected weapon being invalid (like is done in SubArmsData)
@@ -35,7 +35,7 @@
memset(gArmsData, 0, sizeof(gArmsData));
}
-void ClearItemData()
+void ClearItemData(void)
{
memset(gItemData, 0, sizeof(gItemData));
}
@@ -173,7 +173,7 @@
}
/// Update the inventory cursor
-void MoveCampCursor()
+void MoveCampCursor(void)
{
// Compute the current amount of weapons and items
int arms_num = 0;
@@ -186,10 +186,10 @@
if (arms_num == 0 && item_num == 0)
return; // Empty inventory
- /// True if we're currently changing cursor position
+ // True if we're currently changing cursor position
BOOL bChange = FALSE;
- if (gCampActive == FALSE)
+ if (!gCampActive)
{
// Handle selected weapon
if (gKeyTrg & gKeyLeft)
@@ -207,7 +207,7 @@
if (gKeyTrg & (gKeyUp | gKeyDown))
{
// If there are any items, we're changing to the items section, since the weapons section has only 1 row
- if (item_num)
+ if (item_num != 0)
gCampActive = TRUE;
bChange = TRUE;
@@ -228,7 +228,7 @@
if (gSelectedItem % 6 == 0)
gSelectedItem += 5;
else
- --gSelectedItem;
+ gSelectedItem -= 1;
bChange = TRUE;
}
@@ -236,11 +236,11 @@
if (gKeyTrg & gKeyRight)
{
if (gSelectedItem == item_num - 1)
- gSelectedItem = 6 * (gSelectedItem / 6); // Round down to multiple of 6
+ gSelectedItem = (gSelectedItem / 6) * 6; // Round down to multiple of 6
else if (gSelectedItem % 6 == 5)
gSelectedItem -= 5; // Loop around row
else
- ++gSelectedItem;
+ gSelectedItem += 1;
bChange = TRUE;
}
@@ -269,7 +269,7 @@
gSelectedItem = item_num - 1; // Don't allow selecting a non-existing item
if (gCampActive && gKeyTrg & gKeyOk)
- StartTextScript(gItemData[gSelectedItem].code + 6000);
+ StartTextScript(6000 + gItemData[gSelectedItem].code);
}
if (bChange)
@@ -279,8 +279,8 @@
// Switch to a weapon
PlaySoundObject(SND_SWITCH_WEAPON, 1);
- if (arms_num)
- StartTextScript(gArmsData[gSelectedArms].code + 1000);
+ if (arms_num != 0)
+ StartTextScript(1000 + gArmsData[gSelectedArms].code);
else
StartTextScript(1000);
}
@@ -289,8 +289,8 @@
// Switch to an item
PlaySoundObject(SND_YES_NO_CHANGE_CHOICE, 1);
- if (item_num)
- StartTextScript(gItemData[gSelectedItem].code + 5000);
+ if (item_num != 0)
+ StartTextScript(5000 + gItemData[gSelectedItem].code);
else
StartTextScript(5000);
}
@@ -298,7 +298,7 @@
}
/// Draw the inventory
-void PutCampObject()
+void PutCampObject(void)
{
int i;
@@ -333,18 +333,18 @@
RECT rcBoxBottom = {0, 16, 244, 24};
// Draw box
- PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, (WINDOW_HEIGHT - 224) / 2, &rcBoxTop, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, (WINDOW_WIDTH / 2) - 122, (WINDOW_HEIGHT / 2) - 112, &rcBoxTop, SURFACE_ID_TEXT_BOX);
for (i = 1; i < 18; ++i)
- PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, ((WINDOW_HEIGHT - 240) / 2) + (8 * (i + 1)), &rcBoxBody, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, ((WINDOW_HEIGHT - 240) / 2) + (8 * (i + 1)), &rcBoxBottom, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, (WINDOW_WIDTH / 2) - 122, ((WINDOW_HEIGHT / 2) - 120) + ((i + 1) * 8), &rcBoxBody, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, (WINDOW_WIDTH / 2) - 122, ((WINDOW_HEIGHT / 2) - 120) + ((i + 1) * 8), &rcBoxBottom, SURFACE_ID_TEXT_BOX);
// Move titles
- if (gCampTitleY > (WINDOW_HEIGHT - 208) / 2)
+ if (gCampTitleY > (WINDOW_HEIGHT / 2) - 104)
--gCampTitleY;
// Draw titles
- PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY, &rcTitle1, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY + 52, &rcTitle2, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, (WINDOW_WIDTH / 2) - 112, gCampTitleY, &rcTitle1, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, (WINDOW_WIDTH / 2) - 112, gCampTitleY + 52, &rcTitle2, SURFACE_ID_TEXT_BOX);
// Draw arms cursor
static unsigned int flash;
@@ -351,9 +351,9 @@
++flash;
if (gCampActive == FALSE)
- PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[(flash / 2) % 2], SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, (gSelectedArms * 40) + (WINDOW_WIDTH / 2) - 112, (WINDOW_HEIGHT / 2) - 96, &rcCur1[(flash / 2) % 2], SURFACE_ID_TEXT_BOX);
else
- PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[1], SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, (gSelectedArms * 40) + (WINDOW_WIDTH / 2) - 112, (WINDOW_HEIGHT / 2) - 96, &rcCur1[1], SURFACE_ID_TEXT_BOX);
// Draw weapons
for (i = 0; i < ARMS_MAX; ++i)
@@ -368,30 +368,30 @@
rcArms.bottom = rcArms.top + 16;
// Draw the icon, slash and "Lv"
- PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 192) / 2, &rcArms, SURFACE_ID_ARMS_IMAGE);
- PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 128) / 2, &rcPer, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 160) / 2, &rcLv, SURFACE_ID_TEXT_BOX);
- PutNumber4(40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 160) / 2, gArmsData[i].level, FALSE);
+ PutBitmap3(&rcView, (i * 40) + (WINDOW_WIDTH / 2) - 112, (WINDOW_HEIGHT / 2) - 96, &rcArms, SURFACE_ID_ARMS_IMAGE);
+ PutBitmap3(&rcView, (i * 40) + (WINDOW_WIDTH / 2) - 112, (WINDOW_HEIGHT / 2) - 64, &rcPer, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, (i * 40) + (WINDOW_WIDTH / 2) - 112, (WINDOW_HEIGHT / 2) - 80, &rcLv, SURFACE_ID_TEXT_BOX);
+ PutNumber4((i * 40) + (WINDOW_WIDTH / 2) - 112, (WINDOW_HEIGHT / 2) - 80, gArmsData[i].level, FALSE);
// Draw ammo
if (gArmsData[i].max_num)
{
- PutNumber4(40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 144) / 2, gArmsData[i].num, FALSE);
- PutNumber4(40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 128) / 2, gArmsData[i].max_num, FALSE);
+ PutNumber4((i * 40) + (WINDOW_WIDTH / 2) - 112, (WINDOW_HEIGHT / 2) - 72, gArmsData[i].num, FALSE);
+ PutNumber4((i * 40) + (WINDOW_WIDTH / 2) - 112, (WINDOW_HEIGHT / 2) - 64, gArmsData[i].max_num, FALSE);
}
else
{
// Weapon doesn't use ammunition
- PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT - 144) / 2, &rcNone, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT - 128) / 2, &rcNone, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, (i * 40) + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT / 2) - 72, &rcNone, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, (i * 40) + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT / 2) - 64, &rcNone, SURFACE_ID_TEXT_BOX);
}
}
// Draw items cursor
if (gCampActive == TRUE)
- PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[(flash / 2) % 2], SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, ((gSelectedItem % 6) * 32) + (WINDOW_WIDTH / 2) - 112, ((gSelectedItem / 6) * 16) + (WINDOW_HEIGHT / 2) - 44, &rcCur2[flash / 2 % 2], SURFACE_ID_TEXT_BOX);
else
- PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[1], SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, ((gSelectedItem % 6) * 32) + (WINDOW_WIDTH / 2) - 112, ((gSelectedItem / 6) * 16) + (WINDOW_HEIGHT / 2) - 44, &rcCur2[1], SURFACE_ID_TEXT_BOX);
for (i = 0; i < ITEM_MAX; ++i)
{
@@ -399,16 +399,16 @@
break; // Invalid item
// Get rect for next item
- rcItem.left = 32 * (gItemData[i].code % 8);
+ rcItem.left = (gItemData[i].code % 8) * 32;
rcItem.right = rcItem.left + 32;
- rcItem.top = 16 * (gItemData[i].code / 8);
+ rcItem.top = (gItemData[i].code / 8) * 16;
rcItem.bottom = rcItem.top + 16;
- PutBitmap3(&rcView, 32 * (i % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (i / 6) + (WINDOW_HEIGHT - 88) / 2, &rcItem, SURFACE_ID_ITEM_IMAGE);
+ PutBitmap3(&rcView, ((i % 6) * 32) + (WINDOW_WIDTH / 2) - 112, ((i / 6) * 16) + (WINDOW_HEIGHT / 2) - 44, &rcItem, SURFACE_ID_ITEM_IMAGE);
}
}
-int CampLoop()
+int CampLoop(void)
{
int arms_num;
char old_script_path[MAX_PATH];
@@ -421,7 +421,7 @@
// Load the inventory script
LoadTextScript2("ArmsItem.tsc");
- gCampTitleY = (WINDOW_HEIGHT - 192) / 2;
+ gCampTitleY = (WINDOW_HEIGHT / 2) - 96;
// Put the cursor on the first weapon
gCampActive = FALSE;
@@ -432,10 +432,10 @@
while (gArmsData[arms_num].code != 0)
++arms_num;
- if (arms_num)
- StartTextScript(gArmsData[gSelectedArms].code + 1000);
+ if (arms_num != 0)
+ StartTextScript(1000 + gArmsData[gSelectedArms].code);
else
- StartTextScript(gItemData[gSelectedItem].code + 5000);
+ StartTextScript(5000 + gItemData[gSelectedItem].code);
for (;;)
{
@@ -500,7 +500,9 @@
BOOL CheckItem(long a)
{
- for (int i = 0; i < ITEM_MAX; ++i)
+ int i;
+
+ for (i = 0; i < ITEM_MAX; ++i)
if (gItemData[i].code == a)
return TRUE; // Found
@@ -509,7 +511,9 @@
BOOL CheckArms(long a)
{
- for (int i = 0; i < ARMS_MAX; ++i)
+ int i;
+
+ for (i = 0; i < ARMS_MAX; ++i)
if (gArmsData[i].code == a)
return TRUE; // Found
@@ -542,9 +546,11 @@
return TRUE; // Always successfull
}
-void FullArmsEnergy()
+void FullArmsEnergy(void)
{
- for (int a = 0; a < ARMS_MAX; a++)
+ int a;
+
+ for (a = 0; a < ARMS_MAX; ++a)
{
if (gArmsData[a].code == 0)
continue; // Don't change empty weapons
@@ -553,7 +559,7 @@
}
}
-int RotationArms()
+int RotationArms(void)
{
// Get amount of weapons
int arms_num = 0;
@@ -585,7 +591,7 @@
return gArmsData[gSelectedArms].code;
}
-int RotationArmsRev()
+int RotationArmsRev(void)
{
// Get amount of weapons
int arms_num = 0;
@@ -598,7 +604,9 @@
ResetSpurCharge();
// Select previous valid weapon
- if (--gSelectedArms < 0)
+ --gSelectedArms;
+
+ if (gSelectedArms < 0)
gSelectedArms = arms_num - 1;
while (gSelectedArms < arms_num)
@@ -615,7 +623,7 @@
return gArmsData[gSelectedArms].code;
}
-void ChangeToFirstArms()
+void ChangeToFirstArms(void)
{
gSelectedArms = 0;
gArmsEnergyX = 32;
--- a/src/ArmsItem.h
+++ b/src/ArmsItem.h
@@ -55,10 +55,10 @@
/// Clear the weapons array, reverting it to the default state (no weapons) and adjust variables (initialize weapons basically)
-void ClearArmsData();
+void ClearArmsData(void);
/// Clear the item array, reverting it to the default state (no items) (initialize items basically)
-void ClearItemData();
+void ClearItemData(void);
/// Add code to the weapons, setting max_num as the max ammo, or find code and add max_num to its ammo. Fails if no space is available and the weapon isn't
@@ -80,7 +80,7 @@
/// Inventory loop. Returns mode.
-int CampLoop();
+int CampLoop(void);
/// Search for a in the items. Returns whether a was found
@@ -97,16 +97,16 @@
BOOL ChargeArmsEnergy(long num);
/// Set every weapons ammunition to its maximum ammunition
-void FullArmsEnergy();
+void FullArmsEnergy(void);
// "Rotation" means "Weapons currently owned by the player (present in the weapons array)"
/// Change the current weapon to the next one in the rotation. Returns the ID of the newly selected weapon
-int RotationArms();
+int RotationArms(void);
/// Change the current weapon to the previous one in the rotation. Returns the ID of the newly selected weapon
-int RotationArmsRev();
+int RotationArmsRev(void);
/// Change the current weapon to be the first one and play the usual rotation animation
-void ChangeToFirstArms();
+void ChangeToFirstArms(void);
--- a/src/Back.cpp
+++ b/src/Back.cpp
@@ -21,7 +21,7 @@
// TODO - Another function that has an incorrect stack frame
BOOL InitBack(const char *fName, int type)
{
- // Unused, hilariously
+ // Unused
color_black = GetCortBoxColor(RGB(0, 0, 0x10));
// Get width and height
@@ -45,20 +45,21 @@
fclose(fp);
// Set background stuff and load texture
- gBack.flag = 1;
+ gBack.flag = TRUE;
if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND))
return FALSE;
+
gBack.type = type;
- gWaterY = 0x1E0000;
+ gWaterY = 240 * 0x10 * 0x200;
return TRUE;
}
-void ActBack()
+void ActBack(void)
{
switch (gBack.type)
{
case 5:
- gBack.fx += 0xC00;
+ gBack.fx += 6 * 0x200;
break;
case 6:
@@ -85,15 +86,15 @@
break;
case 1:
- for (y = -(fy / 2 / 0x200 % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH)
- for (x = -(fx / 2 / 0x200 % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW)
+ for (y = -((fy / 2 / 0x200) % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH)
+ for (x = -((fx / 2 / 0x200) % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW)
PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND);
break;
case 2:
- for (y = -(fy / 0x200 % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH)
- for (x = -(fx / 0x200 % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW)
+ for (y = -((fy / 0x200) % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH)
+ for (x = -((fx / 0x200) % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW)
PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND);
break;
@@ -100,7 +101,7 @@
case 5:
for (y = -gBack.partsH; y < WINDOW_HEIGHT; y += gBack.partsH)
- for (x = -(gBack.fx / 0x200 % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW)
+ for (x = -((gBack.fx / 0x200) % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW)
PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND);
break;
@@ -120,7 +121,7 @@
PutBitmap4(&grcGame, 0, 88, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0;
- PutBitmap4(&grcGame, 320 - gBack.fx / 2 % 320, 88, &rect, SURFACE_ID_LEVEL_BACKGROUND);
+ PutBitmap4(&grcGame, 320 - ((gBack.fx / 2) % 320), 88, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.top = 123;
rect.bottom = 146;
@@ -129,7 +130,7 @@
PutBitmap4(&grcGame, 0, 123, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0;
- PutBitmap4(&grcGame, 320 - gBack.fx % 320, 123, &rect, SURFACE_ID_LEVEL_BACKGROUND);
+ PutBitmap4(&grcGame, 320 - (gBack.fx % 320), 123, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.top = 146;
rect.bottom = 176;
@@ -138,7 +139,7 @@
PutBitmap4(&grcGame, 0, 146, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0;
- PutBitmap4(&grcGame, 320 - 2 * gBack.fx % 320, 146, &rect, SURFACE_ID_LEVEL_BACKGROUND);
+ PutBitmap4(&grcGame, 320 - ((gBack.fx * 2) % 320), 146, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.top = 176;
rect.bottom = 240;
@@ -147,7 +148,7 @@
PutBitmap4(&grcGame, 0, 176, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0;
- PutBitmap4(&grcGame, 320 - 4 * gBack.fx % 320, 176, &rect, SURFACE_ID_LEVEL_BACKGROUND);
+ PutBitmap4(&grcGame, 320 - ((gBack.fx * 4) % 320), 176, &rect, SURFACE_ID_LEVEL_BACKGROUND);
break;
}
@@ -174,9 +175,9 @@
y_1 = 0;
y_2 = y_1 + 32;
- for (y = y_1; y < y_2; y++)
+ for (y = y_1; y < y_2; ++y)
{
- ypos = (y * 32 * 0x200) / 0x200 - fy / 0x200 + gWaterY / 0x200;
+ ypos = ((y * 32 * 0x200) / 0x200) - (fy / 0x200) + (gWaterY / 0x200);
if (ypos < -32)
continue;
@@ -184,9 +185,9 @@
if (ypos > WINDOW_HEIGHT)
break;
- for (x = x_1; x < x_2; x++)
+ for (x = x_1; x < x_2; ++x)
{
- xpos = (x * 32 * 0x200) / 0x200 - fx / 0x200;
+ xpos = ((x * 32 * 0x200) / 0x200) - (fx / 0x200);
PutBitmap3(&grcGame, xpos, ypos, &rcWater[1], SURFACE_ID_LEVEL_BACKGROUND);
if (y == 0)
PutBitmap3(&grcGame, xpos, ypos, &rcWater[0], SURFACE_ID_LEVEL_BACKGROUND);
@@ -193,5 +194,6 @@
}
}
+ break;
}
}
--- a/src/Back.h
+++ b/src/Back.h
@@ -4,7 +4,7 @@
struct BACK
{
- int flag;
+ BOOL flag; // Basically unused
int partsW;
int partsH;
int numX;
@@ -17,6 +17,6 @@
extern int gWaterY;
BOOL InitBack(const char *fName, int type);
-void ActBack();
+void ActBack(void);
void PutBack(int fx, int fy);
void PutFront(int fx, int fy);
--- a/src/Boss.cpp
+++ b/src/Boss.cpp
@@ -42,15 +42,15 @@
{
if (gBoss[b].cond & 0x80)
{
- if (gBoss[b].shock)
+ if (gBoss[b].shock != 0)
{
- a = 2 * (gBoss[b].shock / 2 % 2) - 1;
+ a = ((gBoss[b].shock / 2 % 2) * 2) - 1;
}
else
{
a = 0;
- if (gBoss[b].bits & NPC_SHOW_DAMAGE && gBoss[b].damage_view)
+ if (gBoss[b].bits & NPC_SHOW_DAMAGE && gBoss[b].damage_view != 0)
{
SetValueView(&gBoss[b].x, &gBoss[b].y, gBoss[b].damage_view);
gBoss[b].damage_view = 0;
@@ -65,8 +65,8 @@
PutBitmap3(
&grcGame,
- (gBoss[b].x - side) / 0x200 - fx / 0x200 + a,
- (gBoss[b].y - gBoss[b].view.top) / 0x200 - fy / 0x200,
+ ((gBoss[b].x - side) / 0x200) - (fx / 0x200) + a,
+ ((gBoss[b].y - gBoss[b].view.top) / 0x200) - (fy / 0x200),
&gBoss[b].rect,
SURFACE_ID_LEVEL_SPRITESET_2);
}
@@ -78,7 +78,7 @@
gBoss[0].act_no = a;
}
-void HitBossBullet()
+void HitBossBullet(void)
{
BOOL bHit;
int bul;
@@ -87,12 +87,12 @@
for (bos = 0; bos < BOSS_MAX; ++bos)
{
- if ((gBoss[bos].cond & 0x80) == 0)
+ if (!(gBoss[bos].cond & 0x80))
continue;
for (bul = 0; bul < BULLET_MAX; ++bul)
{
- if ((gBul[bul].cond & 0x80) == 0)
+ if (!(gBul[bul].cond & 0x80))
continue;
if (gBul[bul].damage == -1)
@@ -129,7 +129,7 @@
{
gBoss[bos_].life = bos_;
- if ((gMC.cond & 0x80) && gBoss[bos_].bits & NPC_EVENT_WHEN_KILLED)
+ if (gMC.cond & 0x80 && gBoss[bos_].bits & NPC_EVENT_WHEN_KILLED)
{
StartTextScript(gBoss[bos_].code_event);
}
@@ -168,7 +168,9 @@
gBoss[bos_].damage_view -= gBul[bul].damage;
}
- if (--gBul[bul].life < 1)
+ --gBul[bul].life;
+
+ if (gBul[bul].life < 1)
gBul[bul].cond = 0;
}
else if (gBul[bul].code_bullet == 13
@@ -182,7 +184,7 @@
}
else
{
- if ((gBul[bul].bbits & 0x10) == 0)
+ if (!(gBul[bul].bbits & 0x10))
{
SetCaret(gBul[bul].x, gBul[bul].y, 2, 2);
PlaySoundObject(31, 1);
@@ -195,9 +197,9 @@
}
}
-void ActBossChar_0()
+void ActBossChar_0(void)
{
- ;
+
}
BOSSFUNCTION gpBossFuncTbl[10] =
@@ -214,12 +216,12 @@
ActBossChar_Ballos
};
-void ActBossChar()
+void ActBossChar(void)
{
int bos;
int code_char;
- if ((gBoss[0].cond & 0x80) == 0)
+ if (!(gBoss[0].cond & 0x80))
return;
code_char = gBoss[0].code_char;
@@ -231,7 +233,7 @@
--gBoss[bos].shock;
}
-void HitBossMap()
+void HitBossMap(void)
{
int offx[16];
int offy[16];
@@ -279,7 +281,7 @@
{
int judg;
- if ((gBoss[b].cond & 0x80) == 0)
+ if (!(gBoss[b].cond & 0x80))
continue;
if (gBoss[b].bits & NPC_IGNORE_SOLIDITY)
--- a/src/Boss.h
+++ b/src/Boss.h
@@ -11,6 +11,6 @@
void InitBossChar(int code);
void PutBossChar(int fx, int fy);
void SetBossCharActNo(int a);
-void HitBossBullet();
-void ActBossChar();
-void HitBossMap();
+void HitBossBullet(void);
+void ActBossChar(void);
+void HitBossMap(void);
--- a/src/BossAlmo1.cpp
+++ b/src/BossAlmo1.cpp
@@ -26,11 +26,11 @@
npc->act_no = 11;
npc->ani_no = 2;
npc->bits = NPC_IGNORE_SOLIDITY;
- npc->view.front = 0x4800;
- npc->view.top = 0x7000;
+ npc->view.front = 36 * 0x200;
+ npc->view.top = 56 * 0x200;
// Fallthrough
case 11:
- npc->x = gBoss[0].x - 0x4800;
+ npc->x = gBoss[0].x - (36 * 0x200);
npc->y = gBoss[0].y;
break;
@@ -39,13 +39,15 @@
npc->act_wait = 112;
// Fallthrough
case 51:
- if (--npc->act_wait == 0)
+ --npc->act_wait;
+
+ if (npc->act_wait == 0)
{
npc->act_no = 100;
npc->ani_no = 3;
}
- npc->x = gBoss[0].x - 0x4800;
+ npc->x = gBoss[0].x - (36 * 0x200);
npc->y = gBoss[0].y;
break;
@@ -57,7 +59,7 @@
npc->rect = rect[npc->ani_no];
if (npc->act_no == 51)
- npc->rect.bottom = npc->act_wait + npc->rect.top;
+ npc->rect.bottom = npc->rect.top + npc->act_wait;
}
static void ActBossChar_Core_Tail(NPCHAR *npc)
@@ -74,11 +76,11 @@
npc->act_no = 11;
npc->ani_no = 0;
npc->bits = NPC_IGNORE_SOLIDITY;
- npc->view.front = 0x5800;
- npc->view.top = 0x7000;
+ npc->view.front = 44 * 0x200;
+ npc->view.top = 56 * 0x200;
// Fallthrough
case 11:
- npc->x = gBoss[0].x + 0x5800;
+ npc->x = gBoss[0].x + (44 * 0x200);
npc->y = gBoss[0].y;
break;
@@ -87,13 +89,15 @@
npc->act_wait = 112;
// Fallthrough
case 51:
- if (--npc->act_wait == 0)
+ --npc->act_wait;
+
+ if (npc->act_wait == 0)
{
npc->act_no = 100;
npc->ani_no = 2;
}
- npc->x = gBoss[0].x + 0x5800;
+ npc->x = gBoss[0].x + (44 * 0x200);
npc->y = gBoss[0].y;
break;
@@ -140,7 +144,9 @@
npc->x += (npc->tgt_x - npc->x) / 0x10;
npc->y += (npc->tgt_y - npc->y) / 0x10;
- if (++npc->act_wait > 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 50)
npc->ani_no = 0;
break;
@@ -150,7 +156,9 @@
npc->act_wait = 0;
// Fallthrough
case 121:
- if (++npc->act_wait / 2 % 2)
+ ++npc->act_wait;
+
+ if (npc->act_wait / 2 % 2)
npc->ani_no = 0;
else
npc->ani_no = 1;
@@ -164,7 +172,7 @@
npc->act_no = 131;
npc->ani_no = 2;
npc->act_wait = 0;
- npc->tgt_x = npc->x + (Random(0x18, 0x30) * 0x200);
+ npc->tgt_x = npc->x + (Random(24, 48) * 0x200);
npc->tgt_y = npc->y + (Random(-4, 4) * 0x200);
// Fallthrough
case 131:
@@ -171,7 +179,9 @@
npc->x += (npc->tgt_x - npc->x) / 0x10;
npc->y += (npc->tgt_y - npc->y) / 0x10;
- if (++npc->act_wait > 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 50)
{
npc->act_no = 140;
npc->ani_no = 0;
@@ -181,9 +191,9 @@
{
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
deg += (unsigned char)Random(-2, 2);
- ym = 2 * GetSin(deg);
- xm = 2 * GetCos(deg);
- SetNpChar(178, npc->x, npc->y, xm, ym, 0, 0, 0x100);
+ ym = GetSin(deg) * 2;
+ xm = GetCos(deg) * 2;
+ SetNpChar(178, npc->x, npc->y, xm, ym, 0, NULL, 0x100);
PlaySoundObject(39, 1);
}
@@ -210,8 +220,8 @@
break;
}
- if (npc->shock)
- npc->tgt_x += 0x400;
+ if (npc->shock != 0)
+ npc->tgt_x += 2 * 0x200;
npc->rect = rect[npc->ani_no];
}
@@ -222,22 +232,22 @@
{
case 0:
npc->x = gBoss[0].x;
- npc->y = gBoss[0].y - 0x4000;
+ npc->y = gBoss[0].y - (32 * 0x200);
break;
case 1:
- npc->x = gBoss[0].x + 0x3800;
+ npc->x = gBoss[0].x + (28 * 0x200);
npc->y = gBoss[0].y;
break;
case 2:
- npc->x = gBoss[0].x + 0x800;
- npc->y = gBoss[0].y + 0x4000;
+ npc->x = gBoss[0].x + (4 * 0x200);
+ npc->y = gBoss[0].y + (32 * 0x200);
break;
case 3:
- npc->x = gBoss[0].x - 0x3800;
- npc->y = gBoss[0].y + 0x800;
+ npc->x = gBoss[0].x - (28 * 0x200);
+ npc->y = gBoss[0].y + (4 * 0x200);
break;
}
}
@@ -261,8 +271,8 @@
npc->bits = (NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY | NPC_SHOW_DAMAGE);
npc->life = 650;
npc->hit_voice = 114;
- npc->x = 0x9A000;
- npc->y = 0x1C000;
+ npc->x = 77 * 0x10 * 0x200;
+ npc->y = 14 * 0x10 * 0x200;
npc->xm = 0;
npc->ym = 0;
npc->code_event = 1000;
@@ -278,28 +288,28 @@
gBoss[8].bits = (NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY);
gBoss[8].view.front = 0;
gBoss[8].view.top = 0;
- gBoss[8].hit.back = 0x5000;
- gBoss[8].hit.top = 0x2000;
- gBoss[8].hit.bottom = 0x2000;
+ gBoss[8].hit.back = 40 * 0x200;
+ gBoss[8].hit.top = 16 * 0x200;
+ gBoss[8].hit.bottom = 16 * 0x200;
gBoss[8].count1 = 0;
gBoss[9] = gBoss[8];
- gBoss[9].hit.back = 0x4800;
- gBoss[9].hit.top = 0x3000;
- gBoss[9].hit.bottom = 0x3000;
+ gBoss[9].hit.back = 36 * 0x200;
+ gBoss[9].hit.top = 24 * 0x200;
+ gBoss[9].hit.bottom = 24 * 0x200;
gBoss[9].count1 = 1;
gBoss[10] = gBoss[8];
- gBoss[10].hit.back = 0x5800;
- gBoss[10].hit.top = 0x1000;
- gBoss[10].hit.bottom = 0x1000;
+ gBoss[10].hit.back = 44 * 0x200;
+ gBoss[10].hit.top = 8 * 0x200;
+ gBoss[10].hit.bottom = 8 * 0x200;
gBoss[10].count1 = 2;
gBoss[11] = gBoss[8];
gBoss[11].cond |= 0x10;
- gBoss[11].hit.back = 0x2800;
- gBoss[11].hit.top = 0x2800;
- gBoss[11].hit.bottom = 0x2800;
+ gBoss[11].hit.back = 20 * 0x200;
+ gBoss[11].hit.top = 20 * 0x200;
+ gBoss[11].hit.bottom = 20 * 0x200;
gBoss[11].count1 = 3;
gBoss[1].cond = 0x80;
@@ -307,29 +317,29 @@
gBoss[1].bits = (NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY | NPC_SHOOTABLE);
gBoss[1].life = 1000;
gBoss[1].hit_voice = 54;
- gBoss[1].hit.back = 0x3000;
- gBoss[1].hit.top = 0x2000;
- gBoss[1].hit.bottom = 0x2000;
- gBoss[1].view.front = 0x4000;
- gBoss[1].view.top = 0x2800;
- gBoss[1].x = npc->x - 0x1000;
- gBoss[1].y = npc->y - 0x8000;
+ gBoss[1].hit.back = 24 * 0x200;
+ gBoss[1].hit.top = 16 * 0x200;
+ gBoss[1].hit.bottom = 16 * 0x200;
+ gBoss[1].view.front = 32 * 0x200;
+ gBoss[1].view.top = 20 * 0x200;
+ gBoss[1].x = npc->x - (8 * 0x200);
+ gBoss[1].y = npc->y - (64 * 0x200);
gBoss[2] = gBoss[1];
- gBoss[2].x = npc->x + 0x2000;
+ gBoss[2].x = npc->x + (16 * 0x200);
gBoss[2].y = npc->y;
gBoss[3] = gBoss[1];
- gBoss[3].x = npc->x - 0x1000;
- gBoss[3].y = npc->y + 0x8000;
+ gBoss[3].x = npc->x - (8 * 0x200);
+ gBoss[3].y = npc->y + (64 * 0x200);
gBoss[6] = gBoss[1];
- gBoss[6].x = npc->x - 0x6000;
- gBoss[6].y = npc->y - 0x4000;
+ gBoss[6].x = npc->x - (48 * 0x200);
+ gBoss[6].y = npc->y - (32 * 0x200);
gBoss[7] = gBoss[1];
- gBoss[7].x = npc->x - 0x6000;
- gBoss[7].y = npc->y + 0x4000;
+ gBoss[7].x = npc->x - (48 * 0x200);
+ gBoss[7].y = npc->y + (32 * 0x200);
break;
case 200:
@@ -343,7 +353,9 @@
npc->tgt_x = gMC.x;
npc->tgt_y = gMC.y;
- if (++npc->act_wait > 400)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 400)
{
++npc->count1;
PlaySoundObject(115, 1);
@@ -377,7 +389,7 @@
npc->tgt_x = gMC.x;
npc->tgt_y = gMC.y;
- if (npc->shock)
+ if (npc->shock != 0)
{
if (++flash / 2 % 2)
{
@@ -396,7 +408,9 @@
gBoss[5].ani_no = 0;
}
- if (++npc->act_wait % 100 == 1)
+ ++npc->act_wait;
+
+ if (npc->act_wait % 100 == 1)
{
gCurlyShoot_wait = Random(80, 100);
gCurlyShoot_x = gBoss[11].x;
@@ -404,7 +418,7 @@
}
if (npc->act_wait < 200 && npc->act_wait % 20 == 1)
- SetNpChar(179, npc->x + (Random(-0x30, -0x10) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), 0, 0, 0, 0, 0x100);
+ SetNpChar(179, npc->x + (Random(-48, -16) * 0x200), npc->y + (Random(-64, 64) * 0x200), 0, 0, 0, NULL, 0x100);
if (npc->act_wait > 400 || npc->life < npc->count2 - 200)
{
@@ -426,11 +440,11 @@
// Fallthrough
case 221:
++npc->act_wait;
- SetNpChar(199, gMC.x + (Random(-50, 150) * 0x200 * 2), gMC.y + (Random(-160, 160) * 0x200), 0, 0, 0, 0, 0x100);
+ SetNpChar(199, gMC.x + (Random(-50, 150) * 0x200 * 2), gMC.y + (Random(-160, 160) * 0x200), 0, 0, 0, NULL, 0x100);
gMC.xm -= 0x20;
gMC.cond |= 0x20;
- if (npc->shock)
+ if (npc->shock != 0)
{
if (++flash / 2 % 2)
{
@@ -452,9 +466,9 @@
if (npc->act_wait == 300 || npc->act_wait == 350 || npc->act_wait == 400)
{
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
- ym = 3 * GetSin(deg);
- xm = 3 * GetCos(deg);
- SetNpChar(218, npc->x - 0x5000, npc->y, xm, ym, 0, 0, 0x100);
+ ym = GetSin(deg) * 3;
+ xm = GetCos(deg) * 3;
+ SetNpChar(218, npc->x - (40 * 0x200), npc->y, xm, ym, 0, NULL, 0x100);
PlaySoundObject(101, 1);
}
@@ -486,7 +500,7 @@
SetQuake(20);
for (i = 0; i < 0x20; ++i)
- SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-128, 128) * 0x200), npc->y + (Random(-64, 64) * 0x200), Random(-128, 128) * 0x200, Random(-128, 128) * 0x200, 0, NULL, 0x100);
for (i = 0; i < 12; ++i)
gBoss[i].bits &= ~(NPC_INVULNERABLE | NPC_SHOOTABLE);
@@ -493,20 +507,22 @@
// Fallthrough
case 501:
- if (++npc->act_wait % 16)
- SetNpChar(4, npc->x + (Random(-0x40, 0x40) * 0x200), npc->y + (Random(-0x20, 0x20) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100);
+ ++npc->act_wait;
+ if (npc->act_wait % 16)
+ SetNpChar(4, npc->x + (Random(-64, 64) * 0x200), npc->y + (Random(-32, 32) * 0x200), Random(-128, 128) * 0x200, Random(-128, 128) * 0x200, 0, NULL, 0x100);
+
if (npc->act_wait / 2 % 2)
npc->x -= 0x200;
else
npc->x += 0x200;
- if (npc->x < 0x7E000)
+ if (npc->x < 63 * 0x10 * 0x200)
npc->x += 0x80;
else
npc->x -= 0x80;
- if (npc->y < 0x16000)
+ if (npc->y < 11 * 0x10 * 0x200)
npc->y += 0x80;
else
npc->y -= 0x80;
@@ -523,10 +539,12 @@
gBoss[11].bits &= ~NPC_INVULNERABLE;
// Fallthrough
case 601:
- if (++npc->act_wait / 2 % 2)
- npc->x -= 0x800;
+ ++npc->act_wait;
+
+ if (npc->act_wait / 2 % 2)
+ npc->x -= 4 * 0x200;
else
- npc->x += 0x800;
+ npc->x += 4 * 0x200;
break;
}
@@ -544,7 +562,7 @@
PlaySoundObject(26, 1);
for (i = 0; i < 8; ++i)
- SetNpChar(4, gBoss[4].x + (Random(-0x20, 0x10) * 0x200), gBoss[4].y, Random(-0x200, 0x200), Random(-0x100, 0x100), 0, 0, 0x100);
+ SetNpChar(4, gBoss[4].x + (Random(-32, 16) * 0x200), gBoss[4].y, Random(-0x200, 0x200), Random(-0x100, 0x100), 0, NULL, 0x100);
}
if (npc->act_no >= 200 && npc->act_no < 300)
@@ -568,9 +586,9 @@
break;
}
- if (npc->x < npc->tgt_x + 0x14000)
+ if (npc->x < npc->tgt_x + (10 * 0x10 * 0x200))
npc->xm += 4;
- if (npc->x > npc->tgt_x + 0x14000)
+ if (npc->x > npc->tgt_x + (10 * 0x10 * 0x200))
npc->xm -= 4;
if (npc->y < npc->tgt_y)
--- a/src/BossAlmo2.cpp
+++ b/src/BossAlmo2.cpp
@@ -27,11 +27,11 @@
npc->act_no = 11;
npc->ani_no = 2;
npc->bits = NPC_IGNORE_SOLIDITY;
- npc->view.front = 0x4800;
- npc->view.top = 0x7000;
+ npc->view.front = 36 * 0x200;
+ npc->view.top = 56 * 0x200;
// Fallthrough
case 11:
- npc->x = gBoss[0].x - 0x4800;
+ npc->x = gBoss[0].x - (36 * 0x200);
npc->y = gBoss[0].y;
break;
@@ -40,7 +40,9 @@
npc->act_wait = 112;
// Fallthrough
case 51:
- if (--npc->act_wait == 0)
+ --npc->act_wait;
+
+ if (npc->act_wait == 0)
{
npc->act_no = 100;
npc->ani_no = 3;
@@ -56,7 +58,7 @@
npc->rect = rect[npc->ani_no];
if (npc->act_no == 51)
- npc->rect.bottom = npc->act_wait + npc->rect.top;
+ npc->rect.bottom = npc->rect.top + npc->act_wait;
}
static void ActBossCharA_Tail(NPCHAR *npc)
@@ -73,11 +75,11 @@
npc->act_no = 11;
npc->ani_no = 0;
npc->bits = NPC_IGNORE_SOLIDITY;
- npc->view.front = 0x5800;
- npc->view.top = 0x7000;
+ npc->view.front = 44 * 0x200;
+ npc->view.top = 56 * 0x200;
// Fallthrough
case 11:
- npc->x = gBoss[0].x + 0x5800;
+ npc->x = gBoss[0].x + (44 * 0x200);
npc->y = gBoss[0].y;
break;
@@ -86,7 +88,9 @@
npc->act_wait = 112;
// Fallthrough
case 51:
- if (--npc->act_wait == 0)
+ --npc->act_wait;
+
+ if (npc->act_wait == 0)
{
npc->act_no = 100;
npc->ani_no = 2;
@@ -102,7 +106,7 @@
npc->rect = rect[npc->ani_no];
if (npc->act_no == 51)
- npc->rect.bottom = npc->act_wait + npc->rect.top;
+ npc->rect.bottom = npc->rect.top + npc->act_wait;
}
static void ActBossCharA_Face(NPCHAR *npc)
@@ -135,15 +139,17 @@
npc->act_wait = 100;
// Fallthrough
case 31:
- if (++npc->act_wait > 300)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 300)
npc->act_wait = 0;
- if (npc->act_wait > 250 && (npc->act_wait % 0x10) == 1)
+ if (npc->act_wait > 250 && npc->act_wait % 0x10 == 1)
PlaySoundObject(26, 1);
- if (npc->act_wait > 250 && (npc->act_wait % 0x10) == 7)
+ if (npc->act_wait > 250 && npc->act_wait % 0x10 == 7)
{
- SetNpChar(293, npc->x, npc->y, 0, 0, 0, 0, 0x80);
+ SetNpChar(293, npc->x, npc->y, 0, 0, 0, NULL, 0x80);
PlaySoundObject(101, 1);
}
@@ -150,7 +156,7 @@
if (npc->act_wait == 200)
PlaySoundObject(116, 1);
- if (npc->act_wait > 200 && npc->act_wait % 2)
+ if (npc->act_wait > 200 && npc->act_wait % 2 != 0)
npc->ani_no = 4;
else
npc->ani_no = 3;
@@ -158,12 +164,12 @@
break;
}
- npc->view.back = 0x4800;
- npc->view.front = 0x4800;
- npc->view.top = 0x2800;
+ npc->view.back = 36 * 0x200;
+ npc->view.front = 36 * 0x200;
+ npc->view.top = 20 * 0x200;
- npc->x = gBoss[0].x - 0x4800;
- npc->y = gBoss[0].y + 0x800;
+ npc->x = gBoss[0].x - (36 * 0x200);
+ npc->y = gBoss[0].y + (4 * 0x200);
npc->bits = NPC_IGNORE_SOLIDITY;
@@ -238,13 +244,13 @@
if (npc->act_no < 50)
{
- if (npc->count1)
+ if (npc->count1 != 0)
deg = npc->count2 + 0x80;
else
deg = npc->count2 + 0x180;
- npc->x = npc->pNpc->x - 0x1000 + 0x30 * GetCos(deg / 2);
- npc->y = npc->pNpc->y + 0x50 * GetSin(deg / 2);
+ npc->x = npc->pNpc->x - (8 * 0x200) + (GetCos(deg / 2) * 0x30);
+ npc->y = npc->pNpc->y + (GetSin(deg / 2) * 0x50);
}
npc->rect = rect[npc->ani_no];
@@ -256,22 +262,22 @@
{
case 0:
npc->x = gBoss[0].x;
- npc->y = gBoss[0].y - 0x4000;
+ npc->y = gBoss[0].y - (32 * 0x200);
break;
case 1:
- npc->x = gBoss[0].x + 0x3800;
+ npc->x = gBoss[0].x + (28 * 0x200);
npc->y = gBoss[0].y;
break;
case 2:
- npc->x = gBoss[0].x + 0x800;
- npc->y = gBoss[0].y + 0x4000;
+ npc->x = gBoss[0].x + (4 * 0x200);
+ npc->y = gBoss[0].y + (32 * 0x200);
break;
case 3:
- npc->x = gBoss[0].x - 0x3800;
- npc->y = gBoss[0].y + 0x800;
+ npc->x = gBoss[0].x - (28 * 0x200);
+ npc->y = gBoss[0].y + (4 * 0x200);
break;
}
}
@@ -298,8 +304,8 @@
npc->bits = (NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY | NPC_SHOW_DAMAGE);
npc->life = 700;
npc->hit_voice = 114;
- npc->x = 0x4A000;
- npc->y = 0xF000;
+ npc->x = 592 * 0x200;
+ npc->y = 120 * 0x200;
npc->xm = 0;
npc->ym = 0;
npc->code_event = 1000;
@@ -318,28 +324,28 @@
gBoss[8].bits = NPC_IGNORE_SOLIDITY;
gBoss[8].view.front = 0;
gBoss[8].view.top = 0;
- gBoss[8].hit.back = 0x5000;
- gBoss[8].hit.top = 0x2000;
- gBoss[8].hit.bottom = 0x2000;
+ gBoss[8].hit.back = 40 * 0x200;
+ gBoss[8].hit.top = 16 * 0x200;
+ gBoss[8].hit.bottom = 16 * 0x200;
gBoss[8].count1 = 0;
gBoss[9] = gBoss[8];
- gBoss[9].hit.back = 0x4800;
- gBoss[9].hit.top = 0x3000;
- gBoss[9].hit.bottom = 0x3000;
+ gBoss[9].hit.back = 36 * 0x200;
+ gBoss[9].hit.top = 24 * 0x200;
+ gBoss[9].hit.bottom = 24 * 0x200;
gBoss[9].count1 = 1;
gBoss[10] = gBoss[8];
- gBoss[10].hit.back = 0x5800;
- gBoss[10].hit.top = 0x1000;
- gBoss[10].hit.bottom = 0x1000;
+ gBoss[10].hit.back = 44 * 0x200;
+ gBoss[10].hit.top = 8 * 0x200;
+ gBoss[10].hit.bottom = 8 * 0x200;
gBoss[10].count1 = 2;
gBoss[11] = gBoss[8];
gBoss[11].cond |= 0x10;
- gBoss[11].hit.back = 0x2800;
- gBoss[11].hit.top = 0x2800;
- gBoss[11].hit.bottom = 0x2800;
+ gBoss[11].hit.back = 20 * 0x200;
+ gBoss[11].hit.top = 20 * 0x200;
+ gBoss[11].hit.bottom = 20 * 0x200;
gBoss[11].count1 = 3;
gBoss[1].cond = 0x80;
@@ -347,11 +353,11 @@
gBoss[1].bits = (NPC_IGNORE_SOLIDITY | NPC_SHOOTABLE);
gBoss[1].life = 1000;
gBoss[1].hit_voice = 54;
- gBoss[1].hit.back = 0x3000;
- gBoss[1].hit.top = 0x2000;
- gBoss[1].hit.bottom = 0x2000;
- gBoss[1].view.front = 0x4000;
- gBoss[1].view.top = 0x2800;
+ gBoss[1].hit.back = 24 * 0x200;
+ gBoss[1].hit.top = 16 * 0x200;
+ gBoss[1].hit.bottom = 16 * 0x200;
+ gBoss[1].view.front = 32 * 0x200;
+ gBoss[1].view.top = 20 * 0x200;
gBoss[1].pNpc = npc;
gBoss[2] = gBoss[1];
@@ -403,21 +409,24 @@
case 201:
++npc->act_wait;
- if ((npc->direct == 2 || npc->ani_no > 0 || npc->life < 200) && npc->act_wait > 200)
+ if (npc->direct == 2 || npc->ani_no > 0 || npc->life < 200)
{
- ++npc->count1;
- PlaySoundObject(115, 1);
-
- if (npc->life < 200)
+ if (npc->act_wait > 200)
{
- npc->act_no = 230;
- }
- else
- {
- if (npc->count1 > 2)
- npc->act_no = 220;
+ ++npc->count1;
+ PlaySoundObject(115, 1);
+
+ if (npc->life < 200)
+ {
+ npc->act_no = 230;
+ }
else
- npc->act_no = 210;
+ {
+ if (npc->count1 > 2)
+ npc->act_no = 220;
+ else
+ npc->act_no = 210;
+ }
}
}
@@ -437,7 +446,7 @@
case 211:
++flash;
- if (npc->shock && flash / 2 % 2)
+ if (npc->shock != 0 && flash / 2 % 2)
{
gBoss[4].ani_no = 1;
gBoss[5].ani_no = 1;
@@ -448,7 +457,9 @@
gBoss[5].ani_no = 0;
}
- if (++npc->act_wait % 100 == 1)
+ ++npc->act_wait;
+
+ if (npc->act_wait % 100 == 1)
{
gCurlyShoot_wait = Random(80, 100);
gCurlyShoot_x = gBoss[11].x;
@@ -458,10 +469,10 @@
if (npc->act_wait < 300)
{
if (npc->act_wait % 120 == 1)
- SetNpChar(288, npc->x - 0x4000, npc->y - 0x2000, 0, 0, 1, 0, 0x20);
+ SetNpChar(288, npc->x - (32 * 0x200), npc->y - (16 * 0x200), 0, 0, 1, NULL, 0x20);
if (npc->act_wait % 120 == 61)
- SetNpChar(288, npc->x - 0x4000, npc->y + 0x2000, 0, 0, 3, 0, 0x20);
+ SetNpChar(288, npc->x - (32 * 0x200), npc->y + (16 * 0x200), 0, 0, 3, NULL, 0x20);
}
if (npc->life < life - 50 || npc->act_wait > 400)
@@ -484,7 +495,9 @@
bShock = TRUE;
// Fallthrough
case 221:
- if (++npc->act_wait % 40 == 1)
+ ++npc->act_wait;
+
+ if (npc->act_wait % 40 == 1)
{
switch (Random(0, 3))
{
@@ -507,13 +520,13 @@
}
PlaySoundObject(25, 1);
- SetNpChar(285, x - 0x2000, y, 0, 0, 0, 0, 0x100);
- SetNpChar(285, x - 0x2000, y, 0, 0, 0x400, 0, 0x100);
+ SetNpChar(285, x - (16 * 0x200), y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(285, x - (16 * 0x200), y, 0, 0, 0x400, NULL, 0x100);
}
++flash;
- if (npc->shock && flash / 2 % 2)
+ if (npc->shock != 0 && flash / 2 % 2)
{
gBoss[4].ani_no = 1;
gBoss[5].ani_no = 1;
@@ -542,12 +555,12 @@
PlaySoundObject(25, 1);
- SetNpChar(285, gBoss[3].x - 0x2000, gBoss[3].y, 0, 0, 0, 0, 0x100);
- SetNpChar(285, gBoss[3].x - 0x2000, gBoss[3].y, 0, 0, 0x400, 0, 0x100);
- SetNpChar(285, gBoss[3].x, gBoss[3].y - 0x2000, 0, 0, 0, 0, 0x100);
- SetNpChar(285, gBoss[3].x, gBoss[3].y - 0x2000, 0, 0, 0x400, 0, 0x100);
- SetNpChar(285, gBoss[3].x, gBoss[3].y + 0x2000, 0, 0, 0, 0, 0x100);
- SetNpChar(285, gBoss[3].x, gBoss[3].y + 0x2000, 0, 0, 0x400, 0, 0x100);
+ SetNpChar(285, gBoss[3].x - (16 * 0x200), gBoss[3].y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(285, gBoss[3].x - (16 * 0x200), gBoss[3].y, 0, 0, 0x400, NULL, 0x100);
+ SetNpChar(285, gBoss[3].x, gBoss[3].y - (16 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(285, gBoss[3].x, gBoss[3].y - (16 * 0x200), 0, 0, 0x400, NULL, 0x100);
+ SetNpChar(285, gBoss[3].x, gBoss[3].y + (16 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(285, gBoss[3].x, gBoss[3].y + (16 * 0x200), 0, 0, 0x400, NULL, 0x100);
life = npc->life;
bShock = TRUE;
@@ -555,7 +568,7 @@
case 231:
++flash;
- if (npc->shock && flash / 2 % 2)
+ if (npc->shock != 0 && flash / 2 % 2)
{
gBoss[4].ani_no = 1;
gBoss[5].ani_no = 1;
@@ -574,10 +587,10 @@
}
if (npc->act_wait % 120 == 1)
- SetNpChar(288, npc->x - 0x4000, npc->y - 0x2000, 0, 0, 1, 0, 0x20);
+ SetNpChar(288, npc->x - (32 * 0x200), npc->y - (16 * 0x200), 0, 0, 1, NULL, 0x20);
if (npc->act_wait % 120 == 61)
- SetNpChar(288, npc->x - 0x4000, npc->y + 0x2000, 0, 0, 3, 0, 0x20);
+ SetNpChar(288, npc->x - (32 * 0x200), npc->y + (16 * 0x200), 0, 0, 3, NULL, 0x20);
break;
@@ -597,7 +610,7 @@
SetQuake(20);
for (i = 0; i < 100; ++i)
- SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0);
+ SetNpChar(4, npc->x + (Random(-128, 128) * 0x200), npc->y + (Random(-64, 64) * 0x200), Random(-128, 128) * 0x200, Random(-128, 128) * 0x200, 0, NULL, 0);
DeleteNpCharCode(282, 1);
gBoss[11].bits &= ~NPC_SHOOTABLE;
@@ -608,8 +621,8 @@
case 501:
++npc->act_wait;
- if (npc->act_wait % 0x10)
- SetNpChar(4, npc->x + (Random(-0x40, 0x40) * 0x200), npc->y + (Random(-0x20, 0x20) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100);
+ if (npc->act_wait % 0x10 != 0)
+ SetNpChar(4, npc->x + (Random(-64, 64) * 0x200), npc->y + (Random(-32, 32) * 0x200), Random(-128, 128) * 0x200, Random(-128, 128) * 0x200, 0, NULL, 0x100);
npc->x += 0x40;
npc->y += 0x80;
@@ -630,7 +643,7 @@
if (gBoss[0].act_wait % 8 == 0)
PlaySoundObject(44, 1);
- SetDestroyNpChar(gBoss[0].x + (Random(-0x48, 0x48) * 0x200), gBoss[0].y + (Random(-0x40, 0x40) * 0x200), 1, 1);
+ SetDestroyNpChar(gBoss[0].x + (Random(-72, 72) * 0x200), gBoss[0].y + (Random(-64, 64) * 0x200), 1, 1);
if (gBoss[0].act_wait > 100)
{
@@ -675,14 +688,14 @@
PlaySoundObject(26, 1);
for (i = 0; i < 8; ++i)
- SetNpChar(4, gBoss[4].x + (Random(-0x20, 0x10) * 0x200), gBoss[4].y, Random(-0x200, 0x200), Random(-0x100, 0x100), 0, 0, 0x100);
+ SetNpChar(4, gBoss[4].x + (Random(-32, 16) * 0x200), gBoss[4].y, Random(-0x200, 0x200), Random(-0x100, 0x100), 0, NULL, 0x100);
}
if (npc->act_no >= 200 && npc->act_no < 300)
{
- if (npc->x < 0x18000)
+ if (npc->x < 192 * 0x200)
npc->direct = 2;
- if (npc->x > (gMap.width - 4) * 0x2000)
+ if (npc->x > (gMap.width - 4) * 0x2000) // Pixel is inconsistent: the assembly code indicates he really used '0x2000' instead of '0x200 * 0x10', which he usually uses
npc->direct = 0;
if (npc->direct == 0)
@@ -697,14 +710,16 @@
case 211:
case 221:
case 231:
- if (++npc->count2 == 150)
+ ++npc->count2;
+
+ if (npc->count2 == 150)
{
npc->count2 = 0;
- SetNpChar(282, (gMap.width * 0x200 * 0x10) + 0x40, (Random(-1, 3) + 10) * 0x2000, 0, 0, 0, 0, 0x30);
+ SetNpChar(282, (gMap.width * 0x200 * 0x10) + 0x40, (Random(-1, 3) + 10) * 0x2000, 0, 0, 0, NULL, 0x30);
}
else if (npc->count2 == 75)
{
- SetNpChar(282, (gMap.width * 0x200 * 0x10) + 0x40, (Random(-3, 0) + 3) * 0x2000, 0, 0, 0, 0, 0x30);
+ SetNpChar(282, (gMap.width * 0x200 * 0x10) + 0x40, (Random(-3, 0) + 3) * 0x2000, 0, 0, 0, NULL, 0x30);
}
break;
--- a/src/BossBallos.cpp
+++ b/src/BossBallos.cpp
@@ -37,7 +37,9 @@
npc->ani_wait = 0;
// Fallthrough
case 101:
- if (++npc->ani_wait > 2)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 2)
{
npc->ani_wait = 0;
++npc->ani_no;
@@ -58,7 +60,9 @@
npc->ani_wait = 0;
// Fallthrough
case 201:
- if (++npc->ani_wait > 2)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 2)
{
npc->ani_wait = 0;
--npc->ani_no;
@@ -74,19 +78,19 @@
npc->ani_no = 4;
if (npc->direct == 0)
- SetDestroyNpChar(npc->x - 0x800, npc->y, 0x800, 10);
+ SetDestroyNpChar(npc->x - (4 * 0x200), npc->y, 0x800, 10);
else
- SetDestroyNpChar(npc->x + 0x800, npc->y, 0x800, 10);
+ SetDestroyNpChar(npc->x + (4 * 0x200), npc->y, 0x800, 10);
break;
}
if (npc->direct == 0)
- npc->x = gBoss[0].x - 0x3000;
+ npc->x = gBoss[0].x - (24 * 0x200);
else
- npc->x = gBoss[0].x + 0x3000;
+ npc->x = gBoss[0].x + (24 * 0x200);
- npc->y = gBoss[0].y - 0x4800;
+ npc->y = gBoss[0].y - (36 * 0x200);
if (npc->act_no >= 0 && npc->act_no < 300)
{
@@ -120,7 +124,7 @@
static void ActBossChar_HITAI(NPCHAR *npc) // "Hitai" = "forehead" or "brow" (according to Google Translate, anyway)
{
npc->x = gBoss[0].x;
- npc->y = gBoss[0].y - 0x5800;
+ npc->y = gBoss[0].y - (44 * 0x200);
}
static void ActBossChar_HARA(NPCHAR *npc) // "Hara" = "belly" or "stomach" (according to Google Translate, anyway)
@@ -147,13 +151,13 @@
npc->cond = 0x80;
npc->exp = 1;
npc->direct = 0;
- npc->x = 0x28000;
- npc->y = -0x8000;
+ npc->x = 320 * 0x200;
+ npc->y = -64 * 0x200;
npc->hit_voice = 54;
- npc->hit.front = 0x4000;
- npc->hit.top = 0x6000;
- npc->hit.back = 0x4000;
- npc->hit.bottom = 0x6000;
+ npc->hit.front = 32 * 0x200;
+ npc->hit.top = 48 * 0x200;
+ npc->hit.back = 32 * 0x200;
+ npc->hit.bottom = 48 * 0x200;
npc->bits = (NPC_IGNORE_SOLIDITY | NPC_SOLID_HARD | NPC_EVENT_WHEN_KILLED | NPC_SHOW_DAMAGE);
npc->size = 3;
npc->damage = 0;
@@ -165,14 +169,14 @@
gBoss[1].direct = 0;
gBoss[1].bits = NPC_IGNORE_SOLIDITY;
gBoss[1].life = 10000;
- gBoss[1].view.front = 0x1800;
+ gBoss[1].view.front = 12 * 0x200;
gBoss[1].view.top = 0;
- gBoss[1].view.back = 0x1800;
- gBoss[1].view.bottom = 0x2000;
- gBoss[1].hit.front = 0x1800;
+ gBoss[1].view.back = 12 * 0x200;
+ gBoss[1].view.bottom = 16 * 0x200;
+ gBoss[1].hit.front = 12 * 0x200;
gBoss[1].hit.top = 0;
- gBoss[1].hit.back = 0x1800;
- gBoss[1].hit.bottom = 0x2000;
+ gBoss[1].hit.back = 12 * 0x200;
+ gBoss[1].hit.bottom = 16 * 0x200;
gBoss[2] = gBoss[1];
gBoss[2].direct = 2;
@@ -180,28 +184,28 @@
// Initialize the body
gBoss[3].cond = 0x90;
gBoss[3].bits = (NPC_SOLID_SOFT | NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY);
- gBoss[3].view.front = 0x7800;
- gBoss[3].view.top = 0x7800;
- gBoss[3].view.back = 0x7800;
- gBoss[3].view.bottom = 0x7800;
- gBoss[3].hit.front = 0x6000;
- gBoss[3].hit.top = 0x3000;
- gBoss[3].hit.back = 0x6000;
- gBoss[3].hit.bottom = 0x4000;
+ gBoss[3].view.front = 60 * 0x200;
+ gBoss[3].view.top = 60 * 0x200;
+ gBoss[3].view.back = 60 * 0x200;
+ gBoss[3].view.bottom = 60 * 0x200;
+ gBoss[3].hit.front = 48 * 0x200;
+ gBoss[3].hit.top = 24 * 0x200;
+ gBoss[3].hit.back = 48 * 0x200;
+ gBoss[3].hit.bottom = 32 * 0x200;
gBoss[4].cond = 0x90;
gBoss[4].bits = (NPC_SOLID_SOFT | NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY);
- gBoss[4].hit.front = 0x4000;
- gBoss[4].hit.top = 0x1000;
- gBoss[4].hit.back = 0x4000;
- gBoss[4].hit.bottom = 0x1000;
+ gBoss[4].hit.front = 32 * 0x200;
+ gBoss[4].hit.top = 8 * 0x200;
+ gBoss[4].hit.back = 32 * 0x200;
+ gBoss[4].hit.bottom = 8 * 0x200;
gBoss[5].cond = 0x90;
gBoss[5].bits = (NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY | NPC_SOLID_HARD);
- gBoss[5].hit.front = 0x4000;
+ gBoss[5].hit.front = 32 * 0x200;
gBoss[5].hit.top = 0;
- gBoss[5].hit.back = 0x4000;
- gBoss[5].hit.bottom = 0x6000;
+ gBoss[5].hit.back = 32 * 0x200;
+ gBoss[5].hit.bottom = 48 * 0x200;
break;
case 100:
@@ -208,11 +212,13 @@
npc->act_no = 101;
npc->ani_no = 0;
npc->x = gMC.x;
- SetNpChar(333, gMC.x, 0x26000, 0, 0, 2, 0, 0x100);
+ SetNpChar(333, gMC.x, 304 * 0x200, 0, 0, 2, NULL, 0x100);
npc->act_wait = 0;
// Fallthrough
case 101:
- if (++npc->act_wait > 30)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 30)
npc->act_no = 102;
break;
@@ -224,9 +230,9 @@
npc->y += npc->ym;
- if (npc->y > 0x26000 - npc->hit.bottom)
+ if (npc->y > (304 * 0x200) - npc->hit.bottom)
{
- npc->y = 0x26000 - npc->hit.bottom;
+ npc->y = (304 * 0x200) - npc->hit.bottom;
npc->ym = 0;
npc->act_no = 103;
npc->act_wait = 0;
@@ -233,13 +239,13 @@
SetQuake2(30);
PlaySoundObject(44, 1);
- if (gMC.y > npc->y + 0x6000 && gMC.x < npc->x + 0x3000 && gMC.x > npc->x - 0x3000)
+ if (gMC.y > npc->y + (48 * 0x200) && gMC.x < npc->x + (24 * 0x200) && gMC.x > npc->x - (24 * 0x200))
DamageMyChar(16);
for (i = 0; i < 0x10; ++i)
{
x = npc->x + (Random(-40, 40) * 0x200);
- SetNpChar(4, x, npc->y + 0x5000, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, x, npc->y + (40 * 0x200), 0, 0, 0, NULL, 0x100);
}
if (gMC.flag & 8)
@@ -249,7 +255,9 @@
break;
case 103:
- if (++npc->act_wait == 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait == 50)
{
npc->act_no = 104;
gBoss[1].act_no = 100;
@@ -266,7 +274,7 @@
npc->act_no = 203;
npc->xm = 0;
++npc->count1;
- npc->hit.bottom = 0x6000;
+ npc->hit.bottom = 48 * 0x200;
npc->damage = 0;
if (npc->count1 % 3 == 0)
@@ -275,7 +283,9 @@
npc->act_wait = 50;
// Fallthrough
case 203:
- if (--npc->act_wait <= 0)
+ --npc->act_wait;
+
+ if (npc->act_wait <= 0)
{
npc->act_no = 204;
npc->ym = -0xC00;
@@ -289,9 +299,9 @@
break;
case 204:
- if (npc->x < 0xA000)
+ if (npc->x < 80 * 0x200)
npc->xm = 0x200;
- if (npc->x > 0x44000)
+ if (npc->x > 544 * 0x200)
npc->xm = -0x200;
npc->ym += 0x55;
@@ -301,14 +311,14 @@
npc->x += npc->xm;
npc->y += npc->ym;
- if (npc->y > 0x26000 - npc->hit.bottom)
+ if (npc->y > (304 * 0x200) - npc->hit.bottom)
{
- npc->y = 0x26000 - npc->hit.bottom;
+ npc->y = (304 * 0x200) - npc->hit.bottom;
npc->ym = 0;
npc->act_no = 201;
npc->act_wait = 0;
- if (gMC.y > npc->y + 0x7000)
+ if (gMC.y > npc->y + (56 * 0x200))
DamageMyChar(16);
if (gMC.flag & 8)
@@ -316,14 +326,14 @@
SetQuake2(30);
PlaySoundObject(26, 1);
- SetNpChar(332, npc->x - 0x1800, npc->y + 0x6800, 0, 0, 0, 0, 0x100);
- SetNpChar(332, npc->x + 0x1800, npc->y + 0x6800, 0, 0, 2, 0, 0x100);
+ SetNpChar(332, npc->x - (12 * 0x200), npc->y + (52 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(332, npc->x + (12 * 0x200), npc->y + (52 * 0x200), 0, 0, 2, NULL, 0x100);
PlaySoundObject(44, 1);
for (i = 0; i < 0x10; ++i)
{
x = npc->x + (Random(-40, 40) * 0x200);
- SetNpChar(4, x, npc->y + 0x5000, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, x, npc->y + (40 * 0x200), 0, 0, 0, NULL, 0x100);
}
}
@@ -346,9 +356,9 @@
npc->y += npc->ym;
- if (npc->y > 0x26000 - npc->hit.bottom)
+ if (npc->y > (304 * 0x200) - npc->hit.bottom)
{
- npc->y = 0x26000 - npc->hit.bottom;
+ npc->y = (304 * 0x200) - npc->hit.bottom;
npc->ym = 0;
npc->act_no = 222;
npc->act_wait = 0;
@@ -358,7 +368,7 @@
for (i = 0; i < 0x10; ++i)
{
x = npc->x + (Random(-40, 40) * 0x200);
- SetNpChar(4, x, npc->y + 0x5000, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, x, npc->y + (40 * 0x200), 0, 0, 0, NULL, 0x100);
}
if (gMC.flag & 8)
@@ -374,17 +384,19 @@
for (i = 0; i < 0x100; i += 0x40)
{
SetNpChar(342, npc->x, npc->y, 0, 0, i, npc, 90);
- SetNpChar(342, npc->x, npc->y, 0, 0, i + 544, npc, 90);
+ SetNpChar(342, npc->x, npc->y, 0, 0, i + 0x220, npc, 90);
}
SetNpChar(343, npc->x, npc->y, 0, 0, 0, npc, 0x18);
- SetNpChar(344, npc->x - 0x3000, npc->y - 0x4800, 0, 0, 0, npc, 0x20);
- SetNpChar(344, npc->x + 0x3000, npc->y - 0x4800, 0, 0, 2, npc, 0x20);
+ SetNpChar(344, npc->x - (24 * 0x200), npc->y - (36 * 0x200), 0, 0, 0, npc, 0x20);
+ SetNpChar(344, npc->x + (24 * 0x200), npc->y - (36 * 0x200), 0, 0, 2, npc, 0x20);
// Fallthrough
case 301:
- npc->y += (0x1C200 - npc->y) / 8;
+ npc->y += ((225 * 0x200) - npc->y) / 8;
- if (++npc->act_wait > 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 50)
{
npc->act_no = 310;
npc->act_wait = 0;
@@ -398,9 +410,9 @@
npc->ym = 0;
npc->x += npc->xm;
- if (npc->x < 0xDE00)
+ if (npc->x < 111 * 0x200)
{
- npc->x = 0xDE00;
+ npc->x = 111 * 0x200;
npc->act_no = 312;
}
@@ -412,9 +424,9 @@
npc->xm = 0;
npc->y += npc->ym;
- if (npc->y < 0xDE00)
+ if (npc->y < 111 * 0x200)
{
- npc->y = 0xDE00;
+ npc->y = 111 * 0x200;
npc->act_no = 313;
}
@@ -426,16 +438,16 @@
npc->ym = 0;
npc->x += npc->xm;
- if (npc->x > 0x40200)
+ if (npc->x > 513 * 0x200)
{
- npc->x = 0x40200;
+ npc->x = 513 * 0x200;
npc->act_no = 314;
}
- if (npc->count1)
+ if (npc->count1 != 0)
--npc->count1;
- if (npc->count1 == 0 && npc->x > 0x26000 && npc->x < 0x2A000)
+ if (npc->count1 == 0 && npc->x > 304 * 0x200 && npc->x < 336 * 0x200)
npc->act_no = 400;
break;
@@ -446,9 +458,9 @@
npc->xm = 0;
npc->y += npc->ym;
- if (npc->y > 0x1C200)
+ if (npc->y > 225 * 0x200)
{
- npc->y = 0x1C200;
+ npc->y = 225 * 0x200;
npc->act_no = 311;
}
@@ -462,9 +474,11 @@
DeleteNpCharCode(339, 0);
// Fallthrough
case 401:
- npc->y += (0x13E00 - npc->y) / 8;
+ npc->y += ((159 * 0x200) - npc->y) / 8;
- if (++npc->act_wait > 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 50)
{
npc->act_wait = 0;
npc->act_no = 410;
@@ -473,14 +487,16 @@
SetNpChar(346, npc->x, npc->y, 0, 0, i, npc, 0x50);
SetNpChar(343, npc->x, npc->y, 0, 0, 0, npc, 0x18);
- SetNpChar(344, npc->x - 0x3000, npc->y - 0x4800, 0, 0, 0, npc, 0x20);
- SetNpChar(344, npc->x + 0x3000, npc->y - 0x4800, 0, 0, 2, npc, 0x20);
+ SetNpChar(344, npc->x - (24 * 0x200), npc->y - (36 * 0x200), 0, 0, 0, npc, 0x20);
+ SetNpChar(344, npc->x + (24 * 0x200), npc->y - (36 * 0x200), 0, 0, 2, npc, 0x20);
}
break;
case 410:
- if (++npc->act_wait > 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 50)
{
npc->act_wait = 0;
npc->act_no = 411;
@@ -489,10 +505,12 @@
break;
case 411:
- if (++npc->act_wait % 30 == 1)
+ ++npc->act_wait;
+
+ if (npc->act_wait % 30 == 1)
{
- x = (2 * (npc->act_wait / 30) + 2) * 0x10 * 0x200;
- SetNpChar(348, x, 0x2A000, 0, 0, 0, 0, 0x180);
+ x = (((npc->act_wait / 30) * 2) + 2) * 0x10 * 0x200;
+ SetNpChar(348, x, 336 * 0x200, 0, 0, 0, NULL, 0x180);
}
if (npc->act_wait / 3 % 2)
@@ -516,11 +534,13 @@
{
x = npc->x + (Random(-60, 60) * 0x200);
y = npc->y + (Random(-60, 60) * 0x200);
- SetNpChar(4, x, y, 0, 0, 0, 0, 0);
+ SetNpChar(4, x, y, 0, 0, 0, NULL, 0);
}
// Fallthrough
case 421:
- if (++npc->ani_wait > 500)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 500)
{
npc->ani_wait = 0;
npc->act_no = 422;
@@ -529,7 +549,9 @@
break;
case 422:
- if (++npc->ani_wait > 200)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 200)
{
npc->ani_wait = 0;
npc->act_no = 423;
@@ -538,7 +560,9 @@
break;
case 423:
- if (++npc->ani_wait > 20)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 20)
{
npc->ani_wait = 0;
npc->act_no = 424;
@@ -547,7 +571,9 @@
break;
case 424:
- if (++npc->ani_wait > 200)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 200)
{
npc->ani_wait = 0;
npc->act_no = 425;
@@ -556,7 +582,9 @@
break;
case 425:
- if (++npc->ani_wait > 500)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 500)
{
npc->ani_wait = 0;
npc->act_no = 426;
@@ -565,7 +593,9 @@
break;
case 426:
- if (++npc->ani_wait > 200)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 200)
{
npc->ani_wait = 0;
npc->act_no = 427;
@@ -574,7 +604,9 @@
break;
case 427:
- if (++npc->ani_wait > 20)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 20)
{
npc->ani_wait = 0;
npc->act_no = 428;
@@ -583,7 +615,9 @@
break;
case 428:
- if (++npc->ani_wait > 200)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 200)
{
npc->ani_wait = 0;
npc->act_no = 421;
@@ -655,7 +689,9 @@
gBoss[4].bits |= NPC_SHOOTABLE;
gBoss[5].bits |= NPC_SHOOTABLE;
- if (++npc->act_wait > 300)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 300)
{
npc->act_wait = 0;
@@ -663,9 +699,9 @@
{
for (i = 0; i < 8; ++i)
{
- x = ((Random(-4, 4) + 156) * 0x200 * 0x10) / 4;
+ x = ((156 + Random(-4, 4)) * 0x200 * 0x10) / 4;
y = (Random(8, 68) * 0x200 * 0x10) / 4;
- SetNpChar(350, x, y, 0, 0, 0, 0, 0x100);
+ SetNpChar(350, x, y, 0, 0, 0, NULL, 0x100);
}
}
else
@@ -674,7 +710,7 @@
{
x = (Random(-4, 4) * 0x200 * 0x10) / 4;
y = (Random(8, 68) * 0x200 * 0x10) / 4;
- SetNpChar(350, x, y, 0, 0, 2, 0, 0x100);
+ SetNpChar(350, x, y, 0, 0, 2, NULL, 0x100);
}
}
}
@@ -681,11 +717,11 @@
if (npc->act_wait == 270 || npc->act_wait == 280 || npc->act_wait == 290)
{
- SetNpChar(353, npc->x, npc->y - 0x6800, 0, 0, 1, 0, 0x100);
+ SetNpChar(353, npc->x, npc->y - (52 * 0x200), 0, 0, 1, NULL, 0x100);
PlaySoundObject(39, 1);
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x, npc->y - 0x6800, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y - (52 * 0x200), 0, 0, 0, NULL, 0x100);
}
if (npc->life > 500)
@@ -694,7 +730,7 @@
{
x = npc->x + (Random(-40, 40) * 0x200);
y = npc->y + (Random(0, 40) * 0x200);
- SetNpChar(270, x, y, 0, 0, 3, 0, 0);
+ SetNpChar(270, x, y, 0, 0, 3, NULL, 0);
}
}
else
@@ -703,12 +739,12 @@
{
x = npc->x + (Random(-40, 40) * 0x200);
y = npc->y + (Random(0, 40) * 0x200);
- SetNpChar(270, x, y, 0, 0, 3, 0, 0);
+ SetNpChar(270, x, y, 0, 0, 3, NULL, 0);
}
}
}
- if (npc->shock)
+ if (npc->shock != 0)
{
if (++flash / 2 % 2)
gBoss[3].ani_no = 1;
--- a/src/BossFrog.cpp
+++ b/src/BossFrog.cpp
@@ -210,7 +210,9 @@
boss->act_wait = 0;
// Fallthrough
case BALFROG_FLICKER:
- if (++boss->act_wait / 2 % 2)
+ ++boss->act_wait;
+
+ if (boss->act_wait / 2 % 2)
boss->ani_no = BALFROG_SPRITE_MOUTH_OPEN_CROUCHING;
else
boss->ani_no = BALFROG_SPRITE_NOTHING;
@@ -224,7 +226,9 @@
boss->xm = 0;
// Fallthrough
case BALFROG_INITIALIZE_HOP_1:
- if (++boss->act_wait > SECONDS_TO_FRAMES(1))
+ ++boss->act_wait;
+
+ if (boss->act_wait > 50)
{
boss->act_no = BALFROG_INITIALIZE_HOP_2;
boss->ani_wait = 0;
@@ -234,7 +238,9 @@
break;
case BALFROG_INITIALIZE_HOP_2:
- if (++boss->ani_wait > 10)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 10)
{
boss->act_no = BALFROG_HOP;
boss->ani_wait = 0;
@@ -244,7 +250,9 @@
break;
case BALFROG_HOP:
- if (++boss->ani_wait > 4)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 4)
{
boss->act_no = BALFROG_MIDAIR;
boss->ani_no = BALFROG_SPRITE_JUMPING;
@@ -311,9 +319,10 @@
// Fallthrough
case BALFROG_LAND:
++boss->act_wait;
- boss->xm = 8 * boss->xm / 9;
- if (boss->act_wait > SECONDS_TO_FRAMES(1))
+ boss->xm = (boss->xm * 8) / 9;
+
+ if (boss->act_wait > 50)
{
boss->ani_no = BALFROG_SPRITE_MOUTH_BARELY_OPEN_CROUCHING;
boss->ani_wait = 0;
@@ -323,7 +332,9 @@
break;
case BALFROG_INITIALIZE_SHOOT:
- if (++boss->ani_wait > 4)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 4)
{
boss->act_no = BALFROG_SHOOT;
boss->act_wait = 0;
@@ -336,7 +347,7 @@
break;
case BALFROG_SHOOT:
- if (boss->shock)
+ if (boss->shock != 0)
{
if (boss->count2++ / 2 % 2)
boss->ani_no = BALFROG_SPRITE_MOUTH_OPEN_CROUCHING_FLASHING;
@@ -349,9 +360,11 @@
boss->ani_no = BALFROG_SPRITE_MOUTH_OPEN_CROUCHING;
}
- boss->xm = 10 * boss->xm / 11;
+ boss->xm = (boss->xm * 10) / 11;
- if (++boss->act_wait > 16)
+ ++boss->act_wait;
+
+ if (boss->act_wait > 16)
{
boss->act_wait = 0;
--boss->count1;
@@ -386,7 +399,9 @@
break;
case BALFROG_AFTER_SHOOT_WAIT:
- if (++boss->ani_wait > 10)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 10)
{
if (++gBoss[1].count1 > 2)
{
@@ -411,7 +426,9 @@
boss->xm = 0;
// Fallthrough
case BALFROG_INITIALIZE_LEAP_2:
- if (++boss->act_wait > SECONDS_TO_FRAMES(1))
+ ++boss->act_wait;
+
+ if (boss->act_wait > 50)
{
boss->act_no = BALFROG_INITIALIZE_LEAP_3;
boss->ani_wait = 0;
@@ -421,7 +438,9 @@
break;
case BALFROG_INITIALIZE_LEAP_3:
- if (++boss->ani_wait > 20)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 20)
{
boss->act_no = BALFROG_LEAP;
boss->ani_wait = 0;
@@ -431,7 +450,9 @@
break;
case BALFROG_LEAP:
- if (++boss->ani_wait > 4)
+ ++boss->ani_wait;
+
+ if (boss->ani_wait > 4)
{
boss->act_no = BALFROG_LEAP_MIDAIR;
boss->ani_no = BALFROG_SPRITE_JUMPING;
@@ -491,7 +512,9 @@
gBoss[2].cond = 0;
// Fallthrough
case BALFROG_DIE_FLASHING:
- if (++boss->act_wait % 5 == 0)
+ ++boss->act_wait;
+
+ if (boss->act_wait % 5 == 0)
SetNpChar(NPC_SMOKE, boss->x + PIXELS_TO_UNITS(Random(-12, 12)), boss->y + PIXELS_TO_UNITS(Random(-12, 12)), Random(-341, 341), Random(PIXELS_TO_UNITS(-3), 0), DIR_LEFT, NULL, 0x100);
if (boss->act_wait / 2 % 2)
@@ -499,7 +522,7 @@
else
boss->x += PIXELS_TO_UNITS(1);
- if (boss->act_wait > SECONDS_TO_FRAMES(2))
+ if (boss->act_wait > 100)
{
boss->act_wait = 0;
boss->act_no = BALFROG_REVERT;
@@ -508,7 +531,9 @@
break;
case BALFROG_REVERT:
- if (++boss->act_wait / 2 % 2)
+ ++boss->act_wait;
+
+ if (boss->act_wait / 2 % 2)
{
boss->view.front = PIXELS_TO_UNITS(20);
boss->view.top = PIXELS_TO_UNITS(12);
@@ -528,7 +553,7 @@
if (boss->act_wait % 9 == 0)
SetNpChar(NPC_SMOKE, boss->x + PIXELS_TO_UNITS(Random(-12, 12)), boss->y + PIXELS_TO_UNITS(Random(-12, 12)), Random(-341, 341), Random(PIXELS_TO_UNITS(-3), 0), DIR_LEFT, NULL, 0x100);
- if (boss->act_wait > SECONDS_TO_FRAMES(3))
+ if (boss->act_wait > 150)
{
boss->act_no = BALFROG_NOP_START;
boss->hit.bottom = PIXELS_TO_UNITS(12);
@@ -550,7 +575,9 @@
break;
case BALFROG_GO_INTO_CEILING:
- if (++boss->act_wait > 30)
+ ++boss->act_wait;
+
+ if (boss->act_wait > 30)
{
boss->ani_no = BALFROG_SPRITE_BALROG_JUMPING;
boss->ym = PIXELS_TO_UNITS(-5);
--- a/src/BossIronH.cpp
+++ b/src/BossIronH.cpp
@@ -23,17 +23,17 @@
npc->exp = 1;
npc->direct = 2;
npc->act_no = 100;
- npc->x = 0x14000;
- npc->y = 0x10000;
- npc->view.front = 0x5000;
- npc->view.top = 0x1800;
- npc->view.back = 0x3000;
- npc->view.bottom = 0x1800;
+ npc->x = 160 * 0x200;
+ npc->y = 128 * 0x200;
+ npc->view.front = 40 * 0x200;
+ npc->view.top = 12 * 0x200;
+ npc->view.back = 24 * 0x200;
+ npc->view.bottom = 12 * 0x200;
npc->hit_voice = 54;
- npc->hit.front = 0x2000;
- npc->hit.top = 0x1400;
- npc->hit.back = 0x2000;
- npc->hit.bottom = 0x1400;
+ npc->hit.front = 16 * 0x200;
+ npc->hit.top = 10 * 0x200;
+ npc->hit.back = 16 * 0x200;
+ npc->hit.bottom = 10 * 0x200;
npc->bits = (NPC_IGNORE_SOLIDITY | NPC_SHOOTABLE | NPC_EVENT_WHEN_KILLED | NPC_SHOW_DAMAGE);
npc->size = 3;
npc->damage = 10;
@@ -47,7 +47,9 @@
npc->act_wait = 0;
// Fallthrough
case 101:
- if (++npc->act_wait > 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 50)
{
npc->act_no = 250;
npc->act_wait = 0;
@@ -54,7 +56,7 @@
}
if (npc->act_wait % 4 == 0)
- SetNpChar(197, Random(15, 18) * 0x2000, Random(2, 13) * 0x2000, 0, 0, 0, 0, 0x100);
+ SetNpChar(197, Random(15, 18) * (16 * 0x200), Random(2, 13) * (16 * 0x200), 0, 0, 0, NULL, 0x100);
break;
@@ -63,13 +65,13 @@
if (npc->direct == 2)
{
- npc->x = 0x1E000;
+ npc->x = 240 * 0x200;
npc->y = gMC.y;
}
else
{
- npc->x = 0x5A000;
- npc->y = Random(2, 13) * 0x2000;
+ npc->x = 720 * 0x200;
+ npc->y = Random(2, 13) * (16 * 0x200);
}
npc->tgt_x = npc->x;
@@ -83,16 +85,16 @@
case 251:
if (npc->direct == 2)
{
- npc->tgt_x += 0x400;
+ npc->tgt_x += 2 * 0x200;
}
else
{
- npc->tgt_x -= 0x200;
+ npc->tgt_x -= 1 * 0x200;
if (npc->tgt_y < gMC.y)
- npc->tgt_y += 0x200;
+ npc->tgt_y += 1 * 0x200;
else
- npc->tgt_y -= 0x200;
+ npc->tgt_y -= 1 * 0x200;
}
if (npc->x < npc->tgt_x)
@@ -115,7 +117,7 @@
if (npc->direct == 2)
{
- if (npc->x > 0x5A000)
+ if (npc->x > 720 * 0x200)
{
npc->direct = 0;
npc->act_no = 100;
@@ -123,7 +125,7 @@
}
else
{
- if (npc->x < 0x22000)
+ if (npc->x < 272 * 0x200)
{
npc->direct = 2;
npc->act_no = 100;
@@ -130,13 +132,20 @@
}
}
- if (npc->direct == 0 && (++npc->act_wait == 300 || npc->act_wait == 310 || npc->act_wait == 320))
+ if (npc->direct == 0)
{
- PlaySoundObject(39, 1);
- SetNpChar(198, npc->x + 0x1400, npc->y + 0x200, Random(-3, 0) * 0x200, Random(-3, 3) * 0x200, 2, 0, 0x100);
+ ++npc->act_wait;
+
+ if (npc->act_wait == 300 || npc->act_wait == 310 || npc->act_wait == 320)
+ {
+ PlaySoundObject(39, 1);
+ SetNpChar(198, npc->x + (10 * 0x200), npc->y + (1 * 0x200), Random(-3, 0) * 0x200, Random(-3, 3) * 0x200, 2, NULL, 0x100);
+ }
}
- if (++npc->ani_wait > 2)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 2)
{
npc->ani_wait = 0;
++npc->ani_no;
@@ -157,7 +166,7 @@
SetQuake(20);
for (i = 0; i < 0x20; ++i)
- SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-128, 128) * 0x200), npc->y + (Random(-64, 64) * 0x200), Random(-128, 128) * 0x200, Random(-128, 128) * 0x200, 0, NULL, 0x100);
DeleteNpCharCode(197, 1);
DeleteNpCharCode(271, 1);
@@ -164,13 +173,13 @@
DeleteNpCharCode(272, 1);
// Fallthrough
case 1001:
- npc->tgt_x -= 0x200;
+ npc->tgt_x -= 1 * 0x200;
npc->x = npc->tgt_x + (Random(-1, 1) * 0x200);
npc->y = npc->tgt_y + (Random(-1, 1) * 0x200);
if (++npc->act_wait % 4 == 0)
- SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), Random(-0x80, 0x80) * 0x200, Random(-0x80, 0x80) * 0x200, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-128, 128) * 0x200), npc->y + (Random(-64, 64) * 0x200), Random(-128, 128) * 0x200, Random(-128, 128) * 0x200, 0, NULL, 0x100);
break;
}
@@ -199,7 +208,7 @@
{256, 48, 320, 72},
};
- if (npc->shock)
+ if (npc->shock != 0)
{
if (++flash / 2 % 2)
npc->rect = rc[npc->ani_no];
--- a/src/BossLife.cpp
+++ b/src/BossLife.cpp
@@ -60,27 +60,26 @@
if (*gBL.pLife < 1)
{
gBL.flag = FALSE;
+ return;
}
+
+ rcLife.right = (*gBL.pLife * 198) / gBL.max;
+
+ if (gBL.br > *gBL.pLife)
+ {
+ if (++gBL.count > 30)
+ --gBL.br;
+ }
else
{
- rcLife.right = 198 * *gBL.pLife / gBL.max;
+ gBL.count = 0;
+ }
- if (gBL.br > *gBL.pLife)
- {
- if (++gBL.count > 30)
- --gBL.br;
- }
- else
- {
- gBL.count = 0;
- }
+ rcBr.right = (gBL.br * 198) / gBL.max;
- rcBr.right = 198 * gBL.br / gBL.max;
-
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 256) / 2, WINDOW_HEIGHT - 20, &rcBox1, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 256) / 2, WINDOW_HEIGHT - 12, &rcBox2, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 176) / 2, WINDOW_HEIGHT - 16, &rcBr, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 176) / 2, WINDOW_HEIGHT - 16, &rcLife, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 240) / 2, WINDOW_HEIGHT - 16, &rcText, SURFACE_ID_TEXT_BOX);
- }
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 128, WINDOW_HEIGHT - 20, &rcBox1, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 128, WINDOW_HEIGHT - 12, &rcBox2, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 88, WINDOW_HEIGHT - 16, &rcBr, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 88, WINDOW_HEIGHT - 16, &rcLife, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 120, WINDOW_HEIGHT - 16, &rcText, SURFACE_ID_TEXT_BOX);
}
--- a/src/BossOhm.cpp
+++ b/src/BossOhm.cpp
@@ -13,7 +13,7 @@
#include "NpChar.h"
#include "Sound.h"
-static void ActBoss01_12()
+static void ActBoss01_12(void)
{
int i;
@@ -27,22 +27,22 @@
for (i = 1; i < 3; ++i)
{
- gBoss[i].y = (gBoss[0].y + gBoss[i + 2].y - 0x1000) / 2;
+ gBoss[i].y = (gBoss[0].y + gBoss[i + 2].y - (8 * 0x200)) / 2;
if (gBoss[i].direct == 0)
{
- gBoss[i].x = gBoss[0].x - 0x2000;
+ gBoss[i].x = gBoss[0].x - (16 * 0x200);
gBoss[i].rect = rcLeft[gBoss[i].ani_no];
}
else
{
gBoss[i].rect = rcRight[gBoss[i].ani_no];
- gBoss[i].x = gBoss[0].x + 0x2000;
+ gBoss[i].x = gBoss[0].x + (16 * 0x200);
}
}
}
-static void ActBoss01_34()
+static void ActBoss01_34(void)
{
int i;
@@ -67,25 +67,25 @@
gBoss[i].y = gBoss[0].y;
if (i == 3)
- gBoss[i].x = gBoss[0].x - 0x2000;
+ gBoss[i].x = gBoss[0].x - (16 * 0x200);
if (i == 4)
- gBoss[i].x = gBoss[0].x + 0x2000;
+ gBoss[i].x = gBoss[0].x + (16 * 0x200);
break;
case 3:
- gBoss[i].tgt_y = gBoss[0].y + 0x3000;
+ gBoss[i].tgt_y = gBoss[0].y + (24 * 0x200);
if (i == 3)
- gBoss[i].x = gBoss[0].x - 0x2000;
+ gBoss[i].x = gBoss[0].x - (16 * 0x200);
if (i == 4)
- gBoss[i].x = gBoss[0].x + 0x2000;
+ gBoss[i].x = gBoss[0].x + (16 * 0x200);
gBoss[i].y += (gBoss[i].tgt_y - gBoss[i].y) / 2;
break;
}
- if ((gBoss[i].flag & 8) || gBoss[i].y <= gBoss[i].tgt_y)
+ if (gBoss[i].flag & 8 || gBoss[i].y <= gBoss[i].tgt_y)
gBoss[i].ani_no = 0;
else
gBoss[i].ani_no = 1;
@@ -97,7 +97,7 @@
}
}
-static void ActBoss01_5()
+static void ActBoss01_5(void)
{
switch (gBoss[5].act_no)
{
@@ -104,10 +104,10 @@
case 0:
gBoss[5].bits |= (NPC_SOLID_SOFT | NPC_IGNORE_SOLIDITY);
- gBoss[5].hit.front = 0x2800;
- gBoss[5].hit.top = 0x4800;
- gBoss[5].hit.back = 0x2800;
- gBoss[5].hit.bottom = 0x2000;
+ gBoss[5].hit.front = 20 * 0x200;
+ gBoss[5].hit.top = 36 * 0x200;
+ gBoss[5].hit.back = 20 * 0x200;
+ gBoss[5].hit.bottom = 16 * 0x200;
gBoss[5].act_no = 1;
// Fallthrough
@@ -118,18 +118,18 @@
}
}
-void ActBossChar_Omega()
+void ActBossChar_Omega(void)
{
switch (gBoss[0].act_no)
{
case 0:
- gBoss[0].x = 0x1B6000;
- gBoss[0].y = 0x20000;
+ gBoss[0].x = 219 * 0x10 * 0x200;
+ gBoss[0].y = 16 * 0x10 * 0x200;
- gBoss[0].view.front = 0x5000;
- gBoss[0].view.top = 0x5000;
- gBoss[0].view.back = 0x5000;
- gBoss[0].view.bottom = 0x2000;
+ gBoss[0].view.front = 40 * 0x200;
+ gBoss[0].view.top = 40 * 0x200;
+ gBoss[0].view.back = 40 * 0x200;
+ gBoss[0].view.bottom = 16 * 0x200;
gBoss[0].tgt_x = gBoss[0].x;
gBoss[0].tgt_y = gBoss[0].y;
@@ -136,10 +136,10 @@
gBoss[0].hit_voice = 52;
- gBoss[0].hit.front = 0x1000;
- gBoss[0].hit.top = 0x3000;
- gBoss[0].hit.back = 0x1000;
- gBoss[0].hit.bottom = 0x2000;
+ gBoss[0].hit.front = 8 * 0x200;
+ gBoss[0].hit.top = 24 * 0x200;
+ gBoss[0].hit.back = 8 * 0x200;
+ gBoss[0].hit.bottom = 16 * 0x200;
gBoss[0].bits = (NPC_IGNORE_SOLIDITY | NPC_EVENT_WHEN_KILLED | NPC_SHOW_DAMAGE);
gBoss[0].size = 3;
@@ -149,10 +149,10 @@
gBoss[1].cond = 0x80;
- gBoss[1].view.front = 0x1800;
- gBoss[1].view.top = 0x1000;
- gBoss[1].view.back = 0x1800;
- gBoss[1].view.bottom = 0x1000;
+ gBoss[1].view.front = 12 * 0x200;
+ gBoss[1].view.top = 8 * 0x200;
+ gBoss[1].view.back = 12 * 0x200;
+ gBoss[1].view.bottom = 8 * 0x200;
gBoss[1].bits = NPC_IGNORE_SOLIDITY;
@@ -163,21 +163,21 @@
gBoss[3].cond = 0x80;
- gBoss[3].view.front = 0x3000;
- gBoss[3].view.top = 0x2000;
- gBoss[3].view.back = 0x2000;
- gBoss[3].view.bottom = 0x2000;
+ gBoss[3].view.front = 24 * 0x200;
+ gBoss[3].view.top = 16 * 0x200;
+ gBoss[3].view.back = 16 * 0x200;
+ gBoss[3].view.bottom = 16 * 0x200;
gBoss[3].hit_voice = 52;
- gBoss[3].hit.front = 0x1000;
- gBoss[3].hit.top = 0x1000;
- gBoss[3].hit.back = 0x1000;
- gBoss[3].hit.bottom = 0x1000;
+ gBoss[3].hit.front = 8 * 0x200;
+ gBoss[3].hit.top = 8 * 0x200;
+ gBoss[3].hit.back = 8 * 0x200;
+ gBoss[3].hit.bottom = 8 * 0x200;
gBoss[3].bits = NPC_IGNORE_SOLIDITY;
- gBoss[3].x = gBoss[0].x - 0x2000;
+ gBoss[3].x = gBoss[0].x - (16 * 0x200);
gBoss[3].y = gBoss[0].y;
gBoss[3].direct = 0;
@@ -184,7 +184,7 @@
gBoss[4] = gBoss[3];
gBoss[4].direct = 2;
- gBoss[3].x = gBoss[0].x + 0x2000;
+ gBoss[3].x = gBoss[0].x + (16 * 0x200);
gBoss[5].cond = 0x80;
break;
@@ -195,7 +195,7 @@
// Fallthrough
case 30:
SetQuake(2);
- gBoss[0].y -= 0x200;
+ gBoss[0].y -= 1 * 0x200;
if (++gBoss[0].act_wait % 4 == 0)
PlaySoundObject(26, 1);
@@ -217,23 +217,29 @@
gBoss[3].act_no = 3;
gBoss[4].act_no = 3;
- gBoss[5].hit.top = 0x2000;
+ gBoss[5].hit.top = 16 * 0x200;
}
+
break;
case 40:
- if (++gBoss[0].act_wait == 48)
+ ++gBoss[0].act_wait;
+
+ if (gBoss[0].act_wait == 48)
{
gBoss[0].act_wait = 0;
gBoss[0].act_no = 50;
gBoss[0].count1 = 0;
- gBoss[5].hit.top = 0x2000;
+ gBoss[5].hit.top = 16 * 0x200;
PlaySoundObject(102, 1);
}
+
break;
case 50: // Open mouth
- if (++gBoss[0].count1 > 2)
+ ++gBoss[0].count1;
+
+ if (gBoss[0].count1 > 2)
{
gBoss[0].count1 = 0;
++gBoss[0].count2;
@@ -244,18 +250,21 @@
gBoss[0].act_no = 60;
gBoss[0].act_wait = 0;
gBoss[0].bits |= NPC_SHOOTABLE;
- gBoss[0].hit.front = 0x2000;
- gBoss[0].hit.back = 0x2000;
+ gBoss[0].hit.front = 16 * 0x200;
+ gBoss[0].hit.back = 16 * 0x200;
}
+
break;
case 60: // Shoot out of mouth
- if (++gBoss[0].act_wait > 20 && gBoss[0].act_wait < 80 && !(gBoss[0].act_wait % 3))
+ ++gBoss[0].act_wait;
+
+ if (gBoss[0].act_wait > 20 && gBoss[0].act_wait < 80 && !(gBoss[0].act_wait % 3))
{
if (Random(0, 9) < 8)
- SetNpChar(48, gBoss[0].x, gBoss[0].y - 0x2000, Random(-0x100, 0x100), -0x333, 0, NULL, 0x100);
+ SetNpChar(48, gBoss[0].x, gBoss[0].y - (16 * 0x200), Random(-0x100, 0x100), -0x333, 0, NULL, 0x100);
else
- SetNpChar(48, gBoss[0].x, gBoss[0].y - 0x2000, Random(-0x100, 0x100), -0x333, 2, NULL, 0x100);
+ SetNpChar(48, gBoss[0].x, gBoss[0].y - (16 * 0x200), Random(-0x100, 0x100), -0x333, 2, NULL, 0x100);
PlaySoundObject(39, 1);
}
@@ -266,10 +275,13 @@
gBoss[0].act_no = 70;
PlaySoundObject(102, 1);
}
+
break;
case 70: // Close mouth
- if (++gBoss[0].count1 > 2)
+ ++gBoss[0].count1;
+
+ if (gBoss[0].count1 > 2)
{
gBoss[0].count1 = 0;
--gBoss[0].count2;
@@ -288,27 +300,33 @@
gBoss[0].bits &= ~NPC_SHOOTABLE;
- gBoss[0].hit.front = 0x3000;
- gBoss[0].hit.back = 0x3000;
- gBoss[5].hit.top = 0x4800;
+ gBoss[0].hit.front = 24 * 0x200;
+ gBoss[0].hit.back = 24 * 0x200;
+ gBoss[5].hit.top = 36 * 0x200;
gBoss[0].damage = 0;
}
+
break;
case 80:
- if (++gBoss[0].act_wait == 48)
+ ++gBoss[0].act_wait;
+
+ if (gBoss[0].act_wait == 48)
{
gBoss[0].act_wait = 0;
gBoss[0].act_no = 90;
}
+
break;
case 90: // Go back into the ground
SetQuake(2);
- gBoss[0].y += 0x200;
+ gBoss[0].y += 1 * 0x200;
- if (++gBoss[0].act_wait % 4 == 0)
+ ++gBoss[0].act_wait;
+
+ if (gBoss[0].act_wait % 4 == 0)
PlaySoundObject(26, 1);
if (gBoss[0].act_wait == 48)
@@ -316,21 +334,27 @@
gBoss[0].act_wait = 0;
gBoss[0].act_no = 100;
}
+
break;
case 100: // Move to proper position for coming out of the ground
- if (++gBoss[0].act_wait == 120)
+ ++gBoss[0].act_wait;
+
+ if (gBoss[0].act_wait == 120)
{
gBoss[0].act_wait = 0;
gBoss[0].act_no = 30;
- gBoss[0].x = gBoss[0].tgt_x + (Random(-0x40, 0x40) * 0x200);
+ gBoss[0].x = gBoss[0].tgt_x + (Random(-64, 64) * 0x200);
gBoss[0].y = gBoss[0].tgt_y;
}
+
break;
case 110:
- if (++gBoss[0].count1 > 2)
+ ++gBoss[0].count1;
+
+ if (gBoss[0].count1 > 2)
{
gBoss[0].count1 = 0;
++gBoss[0].count2;
@@ -340,13 +364,16 @@
{
gBoss[0].act_no = 120;
gBoss[0].act_wait = 0;
- gBoss[0].hit.front = 0x2000;
- gBoss[0].hit.back = 0x2000;
+ gBoss[0].hit.front = 16 * 0x200;
+ gBoss[0].hit.back = 16 * 0x200;
}
+
break;
case 120:
- if (++gBoss[0].act_wait == 50 || CountArmsBullet(6))
+ ++gBoss[0].act_wait;
+
+ if (gBoss[0].act_wait == 50 || CountArmsBullet(6))
{
gBoss[0].act_no = 130;
PlaySoundObject(102, 1);
@@ -356,13 +383,16 @@
if (gBoss[0].act_wait < 30 && !(gBoss[0].act_wait % 5))
{
- SetNpChar(48, gBoss[0].x, gBoss[0].y - 0x2000, Random(-341, 341), -0x333, 0, NULL, 0x100);
+ SetNpChar(48, gBoss[0].x, gBoss[0].y - (16 * 0x200), Random(-341, 341), -0x333, 0, NULL, 0x100);
PlaySoundObject(39, 1);
}
+
break;
case 130:
- if (++gBoss[0].count1 > 2)
+ ++gBoss[0].count1;
+
+ if (gBoss[0].count1 > 2)
{
gBoss[0].count1 = 0;
--gBoss[0].count2;
@@ -371,13 +401,13 @@
if (gBoss[0].count2 == 1)
gBoss[0].damage = 20;
- if (!gBoss[0].count2)
+ if (gBoss[0].count2 == 0)
{
gBoss[0].act_no = 140;
gBoss[0].bits |= NPC_SHOOTABLE;
- gBoss[0].hit.front = 0x2000;
- gBoss[0].hit.back = 0x2000;
+ gBoss[0].hit.front = 16 * 0x200;
+ gBoss[0].hit.back = 16 * 0x200;
gBoss[0].ym = -0x5FF;
@@ -391,8 +421,9 @@
gBoss[0].xm = -0x100;
gBoss[0].damage = 0;
- gBoss[5].hit.top = 0x4800;
+ gBoss[5].hit.top = 36 * 0x200;
}
+
break;
case 140:
@@ -414,7 +445,7 @@
gBoss[0].act_wait = 0;
gBoss[0].count1 = 0;
- gBoss[5].hit.top = 0x2000;
+ gBoss[5].hit.top = 16 * 0x200;
gBoss[5].damage = 0;
PlaySoundObject(26, 1);
@@ -422,12 +453,15 @@
SetQuake(30);
}
+
break;
case 150:
SetQuake(2);
- if (++gBoss[0].act_wait % 12 == 0)
+ ++gBoss[0].act_wait;
+
+ if (gBoss[0].act_wait % 12 == 0)
PlaySoundObject(52, 1);
SetDestroyNpChar(gBoss[0].x + (Random(-0x30, 0x30) * 0x200), gBoss[0].y + (Random(-0x30, 0x18) * 0x200), 1, 1);
@@ -439,12 +473,15 @@
SetFlash(gBoss[0].x, gBoss[0].y, 1);
PlaySoundObject(35, 1);
}
+
break;
case 160:
SetQuake(40);
- if (++gBoss[0].act_wait > 50)
+ ++gBoss[0].act_wait;
+
+ if (gBoss[0].act_wait > 50)
{
gBoss[0].cond = 0;
gBoss[1].cond = 0;
@@ -453,6 +490,7 @@
gBoss[4].cond = 0;
gBoss[5].cond = 0;
}
+
break;
}
--- a/src/BossOhm.h
+++ b/src/BossOhm.h
@@ -1,3 +1,3 @@
#pragma once
-void ActBossChar_Omega();
+void ActBossChar_Omega(void);
--- a/src/BossPress.cpp
+++ b/src/BossPress.cpp
@@ -26,15 +26,15 @@
npc->direct = 2;
npc->x = 0;
npc->y = 0;
- npc->view.front = 0x5000;
- npc->view.top = 0x7800;
- npc->view.back = 0x5000;
- npc->view.bottom = 0x7800;
+ npc->view.front = 40 * 0x200;
+ npc->view.top = 60 * 0x200;
+ npc->view.back = 40 * 0x200;
+ npc->view.bottom = 60 * 0x200;
npc->hit_voice = 54;
- npc->hit.front = 0x6200;
- npc->hit.top = 0x7800;
- npc->hit.back = 0x5000;
- npc->hit.bottom = 0x6000;
+ npc->hit.front = 49 * 0x200;
+ npc->hit.top = 60 * 0x200;
+ npc->hit.back = 40 * 0x200;
+ npc->hit.bottom = 48 * 0x200;
npc->bits = (NPC_IGNORE_SOLIDITY | NPC_SOLID_HARD | NPC_EVENT_WHEN_KILLED | NPC_SHOW_DAMAGE);
npc->size = 3;
npc->damage = 10;
@@ -52,21 +52,21 @@
case 10:
npc->act_no = 11;
- npc->x = 0x14000;
- npc->y = 0x9400;
+ npc->x = 160 * 0x200;
+ npc->y = 74 * 0x200;
break;
case 20:
npc->damage = 0;
npc->act_no = 21;
- npc->x = 0x14000;
- npc->y = 0x33A00;
+ npc->x = 160 * 0x200;
+ npc->y = 413 * 0x200;
npc->bits &= ~NPC_SOLID_HARD;
gBoss[1].cond = 0;
gBoss[2].cond = 0;
// Fallthrough
case 21:
- if ((++npc->act_wait % 0x10) == 0)
+ if (++npc->act_wait % 0x10 == 0)
SetDestroyNpChar(npc->x + (Random(-40, 40) * 0x200), npc->y + (Random(-60, 60) * 0x200), 1, 1);
break;
@@ -74,15 +74,15 @@
case 30:
npc->act_no = 31;
npc->ani_no = 2;
- npc->x = 0x14000;
- npc->y = 0x8000;
+ npc->x = 160 * 0x200;
+ npc->y = 64 * 0x200;
// Fallthrough
case 31:
- npc->y += 0x800;
+ npc->y += 4 * 0x200;
- if (npc->y >= 0x33A00)
+ if (npc->y >= 413 * 0x200)
{
- npc->y = 0x33A00;
+ npc->y = 413 * 0x200;
npc->ani_no = 0;
npc->act_no = 20;
PlaySoundObject(44, 1);
@@ -90,7 +90,7 @@
for (i = 0; i < 5; ++i)
{
x = npc->x + (Random(-40, 40) * 0x200);
- SetNpChar(4, x, npc->y + 0x7800, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, x, npc->y + (60 * 0x200), 0, 0, 0, NULL, 0x100);
}
}
@@ -103,10 +103,10 @@
npc->act_wait = -100;
gBoss[1].cond = 0x80;
- gBoss[1].hit.front = 0x1C00;
- gBoss[1].hit.back = 0x1C00;
- gBoss[1].hit.top = 0x1000;
- gBoss[1].hit.bottom = 0x1000;
+ gBoss[1].hit.front = 14 * 0x200;
+ gBoss[1].hit.back = 14 * 0x200;
+ gBoss[1].hit.top = 8 * 0x200;
+ gBoss[1].hit.bottom = 8 * 0x200;
gBoss[1].bits = (NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY);
gBoss[2] = gBoss[1];
@@ -113,15 +113,15 @@
gBoss[3].cond = 0x90;
gBoss[3].bits |= NPC_SHOOTABLE;
- gBoss[3].hit.front = 0xC00;
- gBoss[3].hit.back = 0xC00;
- gBoss[3].hit.top = 0x1000;
- gBoss[3].hit.bottom = 0x1000;
+ gBoss[3].hit.front = 6 * 0x200;
+ gBoss[3].hit.back = 6 * 0x200;
+ gBoss[3].hit.top = 8 * 0x200;
+ gBoss[3].hit.bottom = 8 * 0x200;
- SetNpChar(325, npc->x, npc->y + 0x7800, 0, 0, 0, 0, 0x100);
+ SetNpChar(325, npc->x, npc->y + (60 * 0x200), 0, 0, 0, NULL, 0x100);
// Fallthrough
case 101:
- if (npc->count2 > 1 && npc->life < 70 * npc->count2)
+ if (npc->count2 > 1 && npc->life < npc->count2 * 70)
{
--npc->count2;
@@ -134,15 +134,15 @@
}
if (++npc->act_wait == 81 || npc->act_wait == 241)
- SetNpChar(323, 0x6000, 0x1E000, 0, 0, 1, 0, 0x100);
+ SetNpChar(323, 48 * 0x200, 240 * 0x200, 0, 0, 1, NULL, 0x100);
if (npc->act_wait == 1 || npc->act_wait == 161)
- SetNpChar(323, 0x22000, 0x1E000, 0, 0, 1, 0, 0x100);
+ SetNpChar(323, 272 * 0x200, 240 * 0x200, 0, 0, 1, NULL, 0x100);
if (npc->act_wait >= 300)
{
npc->act_wait = 0;
- SetNpChar(325, npc->x, npc->y + 0x7800, 0, 0, 0, 0, 0x100);
+ SetNpChar(325, npc->x, npc->y + (60 * 0x200), 0, 0, 0, NULL, 0x100);
}
break;
@@ -158,7 +158,7 @@
DeleteNpCharCode(330, 1);
// Fallthrough
case 501:
- if ((++npc->act_wait % 0x10) == 0)
+ if (++npc->act_wait % 0x10 == 0)
{
PlaySoundObject(12, 1);
SetDestroyNpChar(npc->x + (Random(-40, 40) * 0x200), npc->y + (Random(-60, 60) * 0x200), 1, 1);
@@ -171,6 +171,7 @@
if (npc->act_wait > 100)
npc->act_no = 510;
+
break;
case 510:
@@ -178,7 +179,7 @@
npc->damage = 0x7F;
npc->y += npc->ym;
- if (npc->count1 == 0 && npc->y > 0x14000)
+ if (npc->count1 == 0 && npc->y > 160 * 0x200)
{
npc->count1 = 1;
npc->ym = -0x200;
@@ -187,25 +188,25 @@
for (i = 0; i < 7; ++i)
{
ChangeMapParts(i + 7, 14, 0);
- SetDestroyNpChar((i + 7) * 0x200 * 0x10, 0x1C000, 0, 0);
+ SetDestroyNpChar((i + 7) * 0x200 * 0x10, 224 * 0x200, 0, 0);
PlaySoundObject(12, 1);
}
}
- if (npc->y > 0x3C000)
+ if (npc->y > 480 * 0x200)
npc->act_no = 520;
break;
}
- gBoss[1].x = npc->x - 0x3000;
- gBoss[1].y = npc->y + 0x6800;
+ gBoss[1].x = npc->x - (24 * 0x200);
+ gBoss[1].y = npc->y + (52 * 0x200);
- gBoss[2].x = npc->x + 0x3000;
- gBoss[2].y = npc->y + 0x6800;
+ gBoss[2].x = npc->x + (24 * 0x200);
+ gBoss[2].y = npc->y + (52 * 0x200);
gBoss[3].x = npc->x;
- gBoss[3].y = npc->y + 0x5000;
+ gBoss[3].y = npc->y + (40 * 0x200);
RECT rc[3] = {
{0, 0, 80, 120},
@@ -219,7 +220,7 @@
{160, 120, 240, 240},
};
- if (npc->shock)
+ if (npc->shock != 0)
{
if (++flash / 2 % 2)
npc->rect = rc[npc->ani_no];
--- a/src/BossTwinD.cpp
+++ b/src/BossTwinD.cpp
@@ -31,8 +31,8 @@
case 0:
deg = ((npc->pNpc->count1 / 4) + npc->count1) % 0x100;
npc->act_no = 10;
- npc->x += npc->pNpc->x + GetCos(deg) * npc->pNpc->tgt_x;
- npc->y += npc->pNpc->y + GetSin(deg) * npc->pNpc->tgt_y;
+ npc->x += npc->pNpc->x + (GetCos(deg) * npc->pNpc->tgt_x);
+ npc->y += npc->pNpc->y + (GetSin(deg) * npc->pNpc->tgt_y);
// Fallthrough
case 10:
if (npc->x > gMC.x)
@@ -44,8 +44,9 @@
case 100:
deg = ((npc->pNpc->count1 / 4) + npc->count1) % 0x100;
- npc->tgt_x = npc->pNpc->x + GetCos(deg) * npc->pNpc->tgt_x;
- npc->tgt_y = npc->pNpc->y + GetSin(deg) * npc->pNpc->tgt_y;
+ npc->tgt_x = npc->pNpc->x + (GetCos(deg) * npc->pNpc->tgt_x);
+ npc->tgt_y = npc->pNpc->y + (GetSin(deg) * npc->pNpc->tgt_y);
+
npc->x += (npc->tgt_x - npc->x) / 8;
npc->y += (npc->tgt_y - npc->y) / 8;
@@ -62,8 +63,9 @@
// Fallthrough
case 1001:
deg = ((npc->pNpc->count1 / 4) + npc->count1) % 0x100;
- npc->tgt_x = npc->pNpc->x + GetCos(deg) * npc->pNpc->tgt_x;
- npc->tgt_y = npc->pNpc->y + GetSin(deg) * npc->pNpc->tgt_y;
+ npc->tgt_x = npc->pNpc->x + (GetCos(deg) * npc->pNpc->tgt_x);
+ npc->tgt_y = npc->pNpc->y + (GetSin(deg) * npc->pNpc->tgt_y);
+
npc->x += (npc->tgt_x - npc->x) / 8;
npc->y += (npc->tgt_y - npc->y) / 8;
@@ -122,12 +124,12 @@
case 200:
npc->bits &= ~NPC_SHOOTABLE;
npc->ani_no = 0;
- npc->hit.front = 0x2000;
+ npc->hit.front = 16 * 0x200;
npc->act_no = 201;
npc->count1 = Random(100, 200);
// Fallthrough
case 201:
- if (npc->count1)
+ if (npc->count1 != 0)
{
--npc->count1;
}
@@ -141,13 +143,15 @@
break;
case 210:
- if (++npc->act_wait == 3)
+ ++npc->act_wait;
+
+ if (npc->act_wait == 3)
npc->ani_no = 1;
if (npc->act_wait == 6)
{
npc->ani_no = 2;
- npc->hit.front = 0x1000;
+ npc->hit.front = 8 * 0x200;
npc->bits |= NPC_SHOOTABLE;
npc->count2 = 0;
}
@@ -158,7 +162,7 @@
npc->act_wait = 0;
}
- if (npc->shock)
+ if (npc->shock != 0)
++npc->count2;
if (npc->count2 > 10)
@@ -168,13 +172,15 @@
npc->act_no = 300;
npc->act_wait = 0;
npc->ani_no = 3;
- npc->hit.front = 0x2000;
+ npc->hit.front = 16 * 0x200;
}
break;
case 220:
- if (++npc->act_wait % 8 == 1)
+ ++npc->act_wait;
+
+ if (npc->act_wait % 8 == 1)
{
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
deg += (unsigned char)Random(-6, 6);
@@ -182,9 +188,9 @@
xm = GetCos(deg);
if (npc->direct == 0)
- SetNpChar(202, npc->x - 0x1000, npc->y, xm, ym, 0, 0, 0x100);
+ SetNpChar(202, npc->x - (8 * 0x200), npc->y, xm, ym, 0, NULL, 0x100);
else
- SetNpChar(202, npc->x + 0x1000, npc->y, xm, ym, 0, 0, 0x100);
+ SetNpChar(202, npc->x + (8 * 0x200), npc->y, xm, ym, 0, NULL, 0x100);
PlaySoundObject(33, 1);
}
@@ -195,7 +201,9 @@
break;
case 300:
- if (++npc->act_wait > 100)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 100)
npc->act_no = 200;
break;
@@ -204,17 +212,19 @@
npc->act_no = 401;
npc->act_wait = 0;
npc->ani_no = 0;
- npc->hit.front = 0x2000;
+ npc->hit.front = 16 * 0x200;
npc->bits &= ~NPC_SHOOTABLE;
// Fallthrough
case 401:
- if (++npc->act_wait == 3)
+ ++npc->act_wait;
+
+ if (npc->act_wait == 3)
npc->ani_no = 1;
if (npc->act_wait == 6)
{
npc->ani_no = 2;
- npc->hit.front = 0x1000;
+ npc->hit.front = 8 * 0x200;
npc->bits |= NPC_SHOOTABLE;
npc->count2 = 0;
}
@@ -227,9 +237,9 @@
xm = GetCos(deg);
if (npc->direct == 0)
- SetNpChar(202, npc->x - 0x1000, npc->y, xm, ym, 0, 0, 0x100);
+ SetNpChar(202, npc->x - (8 * 0x200), npc->y, xm, ym, 0, NULL, 0x100);
else
- SetNpChar(202, npc->x + 0x1000, npc->y, xm, ym, 0, 0, 0x100);
+ SetNpChar(202, npc->x + (8 * 0x200), npc->y, xm, ym, 0, NULL, 0x100);
PlaySoundObject(33, 1);
}
@@ -245,11 +255,11 @@
npc->direct = npc->pNpc->direct;
if (npc->direct == 0)
- npc->x = npc->pNpc->x - 0x800;
+ npc->x = npc->pNpc->x - (4 * 0x200);
else
- npc->x = npc->pNpc->x + 0x800;
+ npc->x = npc->pNpc->x + (4 * 0x200);
- npc->y = npc->pNpc->y - 0x1000;
+ npc->y = npc->pNpc->y - (8 * 0x200);
if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no];
@@ -268,17 +278,17 @@
npc->direct = 0;
npc->act_no = 10;
npc->exp = 0;
- npc->x = 0x14000;
- npc->y = 0x10000;
- npc->view.front = 0x1000;
- npc->view.top = 0x1000;
- npc->view.back = 0x10000;
- npc->view.bottom = 0x1000;
+ npc->x = 160 * 0x200;
+ npc->y = 128 * 0x200;
+ npc->view.front = 8 * 0x200;
+ npc->view.top = 8 * 0x200;
+ npc->view.back = 128 * 0x200;
+ npc->view.bottom = 8 * 0x200;
npc->hit_voice = 54;
- npc->hit.front = 0x1000;
- npc->hit.top = 0x1000;
- npc->hit.back = 0x1000;
- npc->hit.bottom = 0x1000;
+ npc->hit.front = 8 * 0x200;
+ npc->hit.top = 8 * 0x200;
+ npc->hit.back = 8 * 0x200;
+ npc->hit.bottom = 8 * 0x200;
npc->bits = NPC_IGNORE_SOLIDITY;
npc->bits |= NPC_EVENT_WHEN_KILLED;
npc->size = 3;
@@ -290,14 +300,14 @@
npc->tgt_y = 61;
gBoss[2].cond = 0x80;
- gBoss[2].view.back = 0x2800;
- gBoss[2].view.front = 0x2800;
- gBoss[2].view.top = 0x2000;
- gBoss[2].view.bottom = 0x2000;
- gBoss[2].hit.back = 0x1800;
- gBoss[2].hit.front = 0x1800;
- gBoss[2].hit.top = 0x1400;
- gBoss[2].hit.bottom = 0x1400;
+ gBoss[2].view.back = 20 * 0x200;
+ gBoss[2].view.front = 20 * 0x200;
+ gBoss[2].view.top = 16 * 0x200;
+ gBoss[2].view.bottom = 16 * 0x200;
+ gBoss[2].hit.back = 12 * 0x200;
+ gBoss[2].hit.front = 12 * 0x200;
+ gBoss[2].hit.top = 10 * 0x200;
+ gBoss[2].hit.bottom = 10 * 0x200;
gBoss[2].bits = (NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY);
gBoss[2].pNpc = &gBoss[3];
gBoss[2].cond |= 0x10;
@@ -304,14 +314,14 @@
gBoss[2].damage = 10;
gBoss[3].cond = 0x80;
- gBoss[3].view.back = 0x2800;
- gBoss[3].view.front = 0x2800;
- gBoss[3].view.top = 0x2800;
- gBoss[3].view.bottom = 0x2800;
- gBoss[3].hit.back = 0x1800;
- gBoss[3].hit.front = 0x1800;
- gBoss[3].hit.top = 0x400;
- gBoss[3].hit.bottom = 0x2000;
+ gBoss[3].view.back = 20 * 0x200;
+ gBoss[3].view.front = 20 * 0x200;
+ gBoss[3].view.top = 20 * 0x200;
+ gBoss[3].view.bottom = 20 * 0x200;
+ gBoss[3].hit.back = 12 * 0x200;
+ gBoss[3].hit.front = 12 * 0x200;
+ gBoss[3].hit.top = 2 * 0x200;
+ gBoss[3].hit.bottom = 16 * 0x200;
gBoss[3].bits = NPC_IGNORE_SOLIDITY;
gBoss[3].pNpc = npc;
gBoss[3].damage = 10;
@@ -337,9 +347,11 @@
break;
case 100:
- if (++npc->act_wait < 100)
+ ++npc->act_wait;
+
+ if (npc->act_wait < 100)
{
- ++npc->count1;
+ npc->count1 += 1;
}
else if (npc->act_wait < 120)
{
@@ -355,7 +367,7 @@
}
else if (npc->act_wait < npc->count2 + 60)
{
- ++npc->count1;
+ npc->count1 += 1;
}
else
{
@@ -371,9 +383,11 @@
break;
case 110:
- if (++npc->act_wait < 20)
+ ++npc->act_wait;
+
+ if (npc->act_wait < 20)
{
- --npc->count1;
+ npc->count1 -= 1;
}
else if (npc->act_wait < 60)
{
@@ -389,7 +403,7 @@
}
else if (npc->act_wait < npc->count2 + 60)
{
- --npc->count1;
+ npc->count1 -= 1;
}
else
{
@@ -416,7 +430,9 @@
break;
case 400:
- if (++npc->act_wait > 100)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 100)
{
npc->act_wait = 0;
npc->act_no = 401;
@@ -425,9 +441,11 @@
break;
case 401:
- if (++npc->act_wait < 100)
+ ++npc->act_wait;
+
+ if (npc->act_wait < 100)
{
- ++npc->count1;
+ npc->count1 += 1;
}
else if (npc->act_wait < 120)
{
@@ -443,7 +461,7 @@
}
else if (npc->act_wait < 560)
{
- ++npc->count1;
+ npc->count1 += 1;
}
else
{
@@ -470,10 +488,12 @@
// Fallthrough
case 1001:
- if (++npc->act_wait > 100)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 100)
npc->act_no = 1010;
- SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-70, 70) * 0x200), 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-0x80, 0x80) * 0x200), npc->y + (Random(-70, 70) * 0x200), 0, 0, 0, NULL, 0x100);
break;
case 1010:
--- a/src/BossX.cpp
+++ b/src/BossX.cpp
@@ -186,7 +186,7 @@
if ((npc->act_no == 103 || npc->act_no == 203) && npc->act_wait % 4 == 1)
PlaySoundObject(111, 1);
- if (npc->act_no >= 100 && gMC.y < npc->y + 0x800 && gMC.y > npc->y - 0x800)
+ if (npc->act_no >= 100 && gMC.y < npc->y + (4 * 0x200) && gMC.y > npc->y - (4 * 0x200))
{
npc->damage = 10;
npc->bits |= NPC_REAR_AND_TOP_DONT_HURT;
@@ -228,44 +228,43 @@
{
case 10:
npc->act_no = 11;
- npc->act_wait = 30 * npc->ani_no + 30;
+ npc->act_wait = (npc->ani_no * 30) + 30;
// Fallthrough
case 11:
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
+ break;
}
- else
- {
- switch (npc->ani_no)
- {
- case 0:
- direct = 3;
- x = -0x3C00;
- y = 0xC00;
- break;
- case 1:
- direct = 2;
- x = 0x3C00;
- y = 0xC00;
- break;
- case 2:
- direct = 0;
- x = -0x3C00;
- y = -0xC00;
- break;
- case 3:
- direct = 1;
- x = 0x3C00;
- y = -0xC00;
- break;
- }
- SetNpChar(158, npc->x + x, npc->y + y, 0, 0, direct, 0, 0x100);
- PlaySoundObject(39, 1);
- npc->act_wait = 120;
+ switch (npc->ani_no)
+ {
+ case 0:
+ direct = 3;
+ x = -30 * 0x200;
+ y = 6 * 0x200;
+ break;
+ case 1:
+ direct = 2;
+ x = 30 * 0x200;
+ y = 6 * 0x200;
+ break;
+ case 2:
+ direct = 0;
+ x = -30 * 0x200;
+ y = -6 * 0x200;
+ break;
+ case 3:
+ direct = 1;
+ x = 30 * 0x200;
+ y = -6 * 0x200;
+ break;
}
+ SetNpChar(158, npc->x + x, npc->y + y, 0, 0, direct, 0, 0x100);
+ PlaySoundObject(39, 1);
+ npc->act_wait = 120;
+
break;
}
@@ -280,11 +279,11 @@
switch (npc->act_no)
{
case 10:
- npc->tgt_x += 0x200;
+ npc->tgt_x += 1 * 0x200;
- if (npc->tgt_x > 0x4000)
+ if (npc->tgt_x > 32 * 0x200)
{
- npc->tgt_x = 0x4000;
+ npc->tgt_x = 32 * 0x200;
npc->act_no = 0;
gBoss[3].act_no = 10;
gBoss[4].act_no = 10;
@@ -295,7 +294,7 @@
break;
case 20:
- npc->tgt_x -= 0x200;
+ npc->tgt_x -= 1 * 0x200;
if (npc->tgt_x < 0)
{
@@ -310,11 +309,11 @@
break;
case 30:
- npc->tgt_x += 0x200;
+ npc->tgt_x += 1 * 0x200;
- if (npc->tgt_x > 0x2800)
+ if (npc->tgt_x > 20 * 0x200)
{
- npc->tgt_x = 0x2800;
+ npc->tgt_x = 20 * 0x200;
npc->act_no = 0;
gBoss[7].act_no = 10;
gBoss[13].act_no = 10;
@@ -326,7 +325,7 @@
break;
case 40:
- npc->tgt_x -= 0x200;
+ npc->tgt_x -= 1 * 0x200;
if (npc->tgt_x < 0)
{
@@ -348,13 +347,13 @@
if (npc->direct == 0)
{
npc->rect = rcLeft;
- npc->x = gBoss[0].x - 0x3000 - npc->tgt_x;
+ npc->x = gBoss[0].x - (24 * 0x200) - npc->tgt_x;
npc->y = gBoss[0].y;
}
else
{
npc->rect = rcRight;
- npc->x = gBoss[0].x + 0x3000 + npc->tgt_x;
+ npc->x = gBoss[0].x + (24 * 0x200) + npc->tgt_x;
npc->y = gBoss[0].y;
}
}
@@ -385,7 +384,7 @@
case 10:
npc->act_no = 11;
- npc->act_wait = 10 * npc->tgt_x + 40;
+ npc->act_wait = (npc->tgt_x * 10) + 40;
npc->bits |= NPC_SHOOTABLE;
// Fallthrough
case 11:
@@ -394,21 +393,21 @@
else
npc->ani_no = 0;
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
+ break;
}
- else
- {
- deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
- deg += (unsigned char)Random(-2, 2);
- ym = 3 * GetSin(deg);
- xm = 3 * GetCos(deg);
- SetNpChar(156, npc->x, npc->y, xm, ym, 0, 0, 0x100);
- PlaySoundObject(39, 1);
- npc->act_wait = 40;
- }
+ deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
+ deg += (unsigned char)Random(-2, 2);
+ ym = GetSin(deg) * 3;
+ xm = GetCos(deg) * 3;
+ SetNpChar(156, npc->x, npc->y, xm, ym, 0, NULL, 0x100);
+
+ PlaySoundObject(39, 1);
+ npc->act_wait = 40;
+
break;
}
@@ -415,20 +414,20 @@
switch (npc->tgt_x)
{
case 0:
- npc->x = gBoss[0].x - 0x2C00;
- npc->y = gBoss[0].y - 0x2000;
+ npc->x = gBoss[0].x - (22 * 0x200);
+ npc->y = gBoss[0].y - (16 * 0x200);
break;
case 1:
- npc->x = gBoss[0].x + 0x3800;
- npc->y = gBoss[0].y - 0x2000;
+ npc->x = gBoss[0].x + (28 * 0x200);
+ npc->y = gBoss[0].y - (16 * 0x200);
break;
case 2:
- npc->x = gBoss[0].x - 0x1E00;
- npc->y = gBoss[0].y + 0x1C00;
+ npc->x = gBoss[0].x - (15 * 0x200);
+ npc->y = gBoss[0].y + (14 * 0x200);
break;
case 3:
- npc->x = gBoss[0].x + 0x2200;
- npc->y = gBoss[0].y + 0x1C00;
+ npc->x = gBoss[0].x + (17 * 0x200);
+ npc->y = gBoss[0].y + (14 * 0x200);
break;
}
@@ -454,7 +453,7 @@
case 10:
npc->act_no = 11;
- npc->act_wait = 10 * npc->tgt_x + 40;
+ npc->act_wait = (npc->tgt_x * 10) + 40;
gBoss[0].bits |= NPC_SHOOTABLE;
// Fallthrough
case 11:
@@ -492,7 +491,7 @@
{
case 0:
npc->life = 1;
- npc->x = -0x28000;
+ npc->x = -320 * 0x200;
break;
case 1:
@@ -499,13 +498,13 @@
npc->life = 700;
npc->exp = 1;
npc->act_no = 1;
- npc->x = 0x100000;
- npc->y = 102400;
+ npc->x = 2048 * 0x200;
+ npc->y = 200 * 0x200;
npc->hit_voice = 54;
- npc->hit.front = 0x3000;
- npc->hit.top = 0x3000;
- npc->hit.back = 0x3000;
- npc->hit.bottom = 0x3000;
+ npc->hit.front = 24 * 0x200;
+ npc->hit.top = 24 * 0x200;
+ npc->hit.back = 24 * 0x200;
+ npc->hit.bottom = 24 * 0x200;
npc->bits = (NPC_IGNORE_SOLIDITY | NPC_EVENT_WHEN_KILLED | NPC_SHOW_DAMAGE);
npc->size = 3;
npc->code_event = 1000;
@@ -514,10 +513,10 @@
gBoss[1].cond = 0x80;
gBoss[1].size = 3;
gBoss[1].direct = 0;
- gBoss[1].view.front = 0x3000;
- gBoss[1].view.top = 0x3000;
- gBoss[1].view.back = 0x3000;
- gBoss[1].view.bottom = 0x3000;
+ gBoss[1].view.front = 24 * 0x200;
+ gBoss[1].view.top = 24 * 0x200;
+ gBoss[1].view.back = 24 * 0x200;
+ gBoss[1].view.bottom = 24 * 0x200;
gBoss[1].bits = NPC_IGNORE_SOLIDITY;
gBoss[2] = gBoss[1];
@@ -529,14 +528,14 @@
gBoss[3].hit_voice = 54;
gBoss[3].destroy_voice = 71;
gBoss[3].size = 2;
- gBoss[3].view.front = 0x1000;
- gBoss[3].view.top = 0x1000;
- gBoss[3].view.back = 0x1000;
- gBoss[3].view.bottom = 0x1000;
- gBoss[3].hit.front = 0xA00;
- gBoss[3].hit.back = 0xA00;
- gBoss[3].hit.top = 0xA00;
- gBoss[3].hit.bottom = 0xA00;
+ gBoss[3].view.front = 8 * 0x200;
+ gBoss[3].view.top = 8 * 0x200;
+ gBoss[3].view.back = 8 * 0x200;
+ gBoss[3].view.bottom = 8 * 0x200;
+ gBoss[3].hit.front = 5 * 0x200;
+ gBoss[3].hit.back = 5 * 0x200;
+ gBoss[3].hit.top = 5 * 0x200;
+ gBoss[3].hit.bottom = 5 * 0x200;
gBoss[3].bits = NPC_IGNORE_SOLIDITY;
gBoss[3].tgt_x = 0;
@@ -552,17 +551,17 @@
gBoss[6].life = 100;
gBoss[7].cond = 0x80;
- gBoss[7].x = 0x100000;
- gBoss[7].y = 0x19000;
- gBoss[7].view.front = 0x6800;
- gBoss[7].view.top = 0x3000;
- gBoss[7].view.back = 0x6800;
- gBoss[7].view.bottom = 0x3000;
+ gBoss[7].x = 2048 * 0x200;
+ gBoss[7].y = 200 * 0x200;
+ gBoss[7].view.front = 52 * 0x200;
+ gBoss[7].view.top = 24 * 0x200;
+ gBoss[7].view.back = 52 * 0x200;
+ gBoss[7].view.bottom = 24 * 0x200;
gBoss[7].hit_voice = 52;
- gBoss[7].hit.front = 0x1000;
- gBoss[7].hit.top = 0x3000;
- gBoss[7].hit.back = 0x1000;
- gBoss[7].hit.bottom = 0x2000;
+ gBoss[7].hit.front = 8 * 0x200;
+ gBoss[7].hit.top = 24 * 0x200;
+ gBoss[7].hit.back = 8 * 0x200;
+ gBoss[7].hit.bottom = 16 * 0x200;
gBoss[7].bits = NPC_IGNORE_SOLIDITY;
gBoss[7].size = 3;
gBoss[7].ani_no = 0;
@@ -570,62 +569,62 @@
gBoss[9].cond = 0x80;
gBoss[9].act_no = 0;
gBoss[9].direct = 1;
- gBoss[9].x = 0xF8000;
- gBoss[9].y = 0x12000;
- gBoss[9].view.front = 0x4800;
- gBoss[9].view.top = 0x1000;
- gBoss[9].view.back = 0x4800;
- gBoss[9].view.bottom = 0x3000;
+ gBoss[9].x = 1984 * 0x200;
+ gBoss[9].y = 144 * 0x200;
+ gBoss[9].view.front = 36 * 0x200;
+ gBoss[9].view.top = 8 * 0x200;
+ gBoss[9].view.back = 36 * 0x200;
+ gBoss[9].view.bottom = 24 * 0x200;
gBoss[9].hit_voice = 52;
- gBoss[9].hit.front = 0x3800;
- gBoss[9].hit.top = 0x1000;
- gBoss[9].hit.back = 0x3800;
- gBoss[9].hit.bottom = 0x2000;
+ gBoss[9].hit.front = 28 * 0x200;
+ gBoss[9].hit.top = 8 * 0x200;
+ gBoss[9].hit.back = 28 * 0x200;
+ gBoss[9].hit.bottom = 16 * 0x200;
gBoss[9].bits = (NPC_SOLID_SOFT | NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY | NPC_REAR_AND_TOP_DONT_HURT);
gBoss[9].size = 3;
gBoss[10] = gBoss[9];
- gBoss[10].x = 0x108000;
+ gBoss[10].x = 2112 * 0x200;
gBoss[11] = gBoss[9];
gBoss[11].direct = 3;
- gBoss[11].x = 0xF8000;
- gBoss[11].y = 0x20000;
- gBoss[11].view.top = 0x3000;
- gBoss[11].view.bottom = 0x1000;
- gBoss[11].hit.top = 0x2000;
- gBoss[11].hit.bottom = 0x1000;
+ gBoss[11].x = 1984 * 0x200;
+ gBoss[11].y = 256 * 0x200;
+ gBoss[11].view.top = 24 * 0x200;
+ gBoss[11].view.bottom = 8 * 0x200;
+ gBoss[11].hit.top = 16 * 0x200;
+ gBoss[11].hit.bottom = 8 * 0x200;
gBoss[12] = gBoss[11];
- gBoss[12].x = 0x108000;
+ gBoss[12].x = 2112 * 0x200;
gBoss[13] = gBoss[9];
gBoss[13].cond = 0x80;
- gBoss[13].view.top = 0x2000;
- gBoss[13].view.bottom = 0x2000;
- gBoss[13].view.front = 0x3C00;
- gBoss[13].view.back = 0x5400;
+ gBoss[13].view.top = 16 * 0x200;
+ gBoss[13].view.bottom = 16 * 0x200;
+ gBoss[13].view.front = 30 * 0x200;
+ gBoss[13].view.back = 42 * 0x200;
gBoss[13].count1 = 9;
gBoss[13].ani_no = 0;
gBoss[13].bits = NPC_IGNORE_SOLIDITY;
gBoss[14] = gBoss[13];
- gBoss[14].view.front = 0x5400;
- gBoss[14].view.back = 0x3C00;
+ gBoss[14].view.front = 42 * 0x200;
+ gBoss[14].view.back = 30 * 0x200;
gBoss[14].count1 = 10;
gBoss[14].ani_no = 1;
gBoss[14].bits = NPC_IGNORE_SOLIDITY;
gBoss[15] = gBoss[13];
- gBoss[15].view.top = 0x2000;
- gBoss[15].view.bottom = 0x2000;
+ gBoss[15].view.top = 16 * 0x200;
+ gBoss[15].view.bottom = 16 * 0x200;
gBoss[15].count1 = 11;
gBoss[15].ani_no = 2;
gBoss[15].bits = NPC_IGNORE_SOLIDITY;
gBoss[16] = gBoss[15];
- gBoss[16].view.front = 0x5400;
- gBoss[16].view.back = 0x3C00;
+ gBoss[16].view.front = 42 * 0x200;
+ gBoss[16].view.back = 30 * 0x200;
gBoss[16].count1 = 12;
gBoss[16].ani_no = 3;
gBoss[16].bits = NPC_IGNORE_SOLIDITY;
@@ -639,7 +638,9 @@
npc->count1 = 0;
// Fallthrough
case 11:
- if (++npc->act_wait > 100)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 100)
{
npc->act_wait = 0;
@@ -657,7 +658,9 @@
++npc->count1;
// Fallthrough
case 101:
- if (++npc->act_wait == 4)
+ ++npc->act_wait;
+
+ if (npc->act_wait == 4)
gBoss[9].act_no = 100;
if (npc->act_wait == 8)
gBoss[10].act_no = 100;
@@ -665,6 +668,7 @@
gBoss[11].act_no = 100;
if (npc->act_wait == 12)
gBoss[12].act_no = 100;
+
if (npc->act_wait > 120 && npc->count1 > 2)
npc->act_no = 300;
if (npc->act_wait > 121 && gMC.x > npc->x)
@@ -678,7 +682,9 @@
++npc->count1;
// Fallthrough
case 201:
- if (++npc->act_wait == 4)
+ ++npc->act_wait;
+
+ if (npc->act_wait == 4)
gBoss[9].act_no = 200;
if (npc->act_wait == 8)
gBoss[10].act_no = 200;
@@ -686,6 +692,7 @@
gBoss[11].act_no = 200;
if (npc->act_wait == 12)
gBoss[12].act_no = 200;
+
if (npc->act_wait > 120 && npc->count1 > 2)
npc->act_no = 400;
if (npc->act_wait > 121 && gMC.x < npc->x)
@@ -698,7 +705,9 @@
npc->act_no = 301;
// Fallthrough
case 301:
- if (++npc->act_wait == 4)
+ ++npc->act_wait;
+
+ if (npc->act_wait == 4)
gBoss[9].act_no = 300;
if (npc->act_wait == 8)
gBoss[10].act_no = 300;
@@ -706,6 +715,7 @@
gBoss[11].act_no = 300;
if (npc->act_wait == 12)
gBoss[12].act_no = 300;
+
if (npc->act_wait > 50)
{
if (gBoss[3].cond == 0 && gBoss[4].cond == 0 && gBoss[5].cond == 0 && gBoss[6].cond == 0)
@@ -713,6 +723,7 @@
else
npc->act_no = 500;
}
+
break;
case 400:
@@ -720,7 +731,9 @@
npc->act_no = 401;
// Fallthrough
case 401:
- if (++npc->act_wait == 4)
+ ++npc->act_wait;
+
+ if (npc->act_wait == 4)
gBoss[9].act_no = 400;
if (npc->act_wait == 8)
gBoss[10].act_no = 400;
@@ -728,6 +741,7 @@
gBoss[11].act_no = 400;
if (npc->act_wait == 12)
gBoss[12].act_no = 400;
+
if (npc->act_wait > 50)
{
if (gBoss[3].cond == 0 && gBoss[4].cond == 0 && gBoss[5].cond == 0 && gBoss[6].cond == 0)
@@ -745,7 +759,9 @@
gBoss[2].act_no = 10;
// Fallthrough
case 501:
- if (++npc->act_wait > 300)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 300)
{
npc->act_no = 502;
npc->act_wait = 0;
@@ -767,7 +783,9 @@
gBoss[2].act_no = 20;
// Fallthrough
case 503: // Exactly identical to case 603
- if (++npc->act_wait > 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 50)
{
if (npc->x > gMC.x)
npc->act_no = 100;
@@ -804,7 +822,9 @@
// Fallthrough
case 603: // Exactly identical to case 503
- if (++npc->act_wait > 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 50)
{
if (npc->x > gMC.x)
npc->act_no = 100;
@@ -820,7 +840,7 @@
if (++npc->act_wait % 8 == 0)
PlaySoundObject(52, 1);
- SetDestroyNpChar(npc->x + (Random(-0x48, 0x48) * 0x200), npc->y + (Random(-0x40, 0x40) * 0x200), 1, 1);
+ SetDestroyNpChar(npc->x + (Random(-72, 72) * 0x200), npc->y + (Random(-64, 64) * 0x200), 1, 1);
if (npc->act_wait > 100)
{
@@ -835,13 +855,15 @@
case 1001:
SetQuake(40);
- if (++npc->act_wait > 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 50)
{
for (i = 0; i < 20; ++i)
gBoss[i].cond = 0;
DeleteNpCharCode(158, 1);
- SetNpChar(159, npc->x, npc->y - 0x3000, 0, 0, 0, 0, 0);
+ SetNpChar(159, npc->x, npc->y - (24 * 0x200), 0, 0, 0, NULL, 0);
}
break;
@@ -852,7 +874,7 @@
ActBossChar03_01(&gBoss[11]);
ActBossChar03_01(&gBoss[12]);
- npc->x += ((gBoss[11].x + gBoss[10].x + gBoss[9].x + gBoss[12].x) / 4 - npc->x) / 16;
+ npc->x += (((gBoss[11].x + gBoss[10].x + gBoss[9].x + gBoss[12].x) / 4) - npc->x) / 0x10;
ActBossChar03_face(&gBoss[7]);
@@ -877,7 +899,7 @@
{
npc->act_no = 1000;
npc->act_wait = 0;
- npc->shock = 0x96;
+ npc->shock = 150;
gBoss[9].act_no = 300;
gBoss[10].act_no = 300;
gBoss[11].act_no = 300;
--- a/src/BulHit.cpp
+++ b/src/BulHit.cpp
@@ -13,6 +13,7 @@
PlaySoundObject(28, 1);
else
SetCaret(bul->x, bul->y, 2, 1);
+
bul->cond = 0;
SetCaret(bul->x, bul->y, 2, 2);
}
@@ -21,20 +22,23 @@
{
int i;
int hit = 0;
- if (bul->x - bul->blockXL < (0x10 * x + 8) * 0x200
- && bul->x + bul->blockXL > (0x10 * x - 8) * 0x200
- && bul->y - bul->blockYL < (0x10 * y + 8) * 0x200
- && bul->y + bul->blockYL > (0x10 * y - 8) * 0x200)
+ if (bul->x - bul->blockXL < ((x * 16) + 8) * 0x200
+ && bul->x + bul->blockXL > ((x * 16) - 8) * 0x200
+ && bul->y - bul->blockYL < ((y * 16) + 8) * 0x200
+ && bul->y + bul->blockYL > ((y * 16) - 8) * 0x200)
hit |= 0x200;
- if (hit && (bul->bbits & 0x60) && GetAttribute(x, y) == 0x43)
+ if (hit && bul->bbits & 0x60 && GetAttribute(x, y) == 0x43)
{
if (!(bul->bbits & 0x40))
bul->cond = 0;
+
SetCaret(bul->x, bul->y, 2, 0);
PlaySoundObject(12, 1);
- for (i = 0; i < 4; i++)
- SetNpChar(4, x * 0x200 * 0x10, y * 0x200 * 0x10, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, 0, 256);
+
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, x * 0x200 * 0x10, y * 0x200 * 0x10, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, NULL, 0x100);
+
ShiftMapParts(x, y);
}
@@ -48,15 +52,15 @@
int workY;
int hit = 0;
- int block[4];
+ BOOL block[4];
if (bul->bbits & 0x40)
{
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; ++i)
{
if (*atrb == 0x41 || *atrb == 0x61)
- block[i] = 1;
+ block[i] = TRUE;
else
- block[i] = 0;
+ block[i] = FALSE;
++atrb;
}
@@ -63,19 +67,19 @@
}
else
{
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; ++i)
{
if (*atrb == 0x41 || *atrb == 0x43 || *atrb == 0x61)
- block[i] = 1;
+ block[i] = TRUE;
else
- block[i] = 0;
+ block[i] = FALSE;
++atrb;
}
}
- workX = (0x10 * x + 8) * 0x200;
- workY = (0x10 * y + 8) * 0x200;
+ workX = ((x * 16) + 8) * 0x200;
+ workY = ((y * 16) + 8) * 0x200;
// Left wall
if (block[0] && block[2])
@@ -85,12 +89,12 @@
}
else if (block[0] && !block[2])
{
- if (bul->x - bul->blockXL < workX && bul->y - bul->blockYL < workY - 0x600)
+ if (bul->x - bul->blockXL < workX && bul->y - bul->blockYL < workY - (3 * 0x200))
hit |= 1;
}
else if (!block[0] && block[2])
{
- if (bul->x - bul->blockXL < workX && bul->y + bul->blockYL > workY + 0x600)
+ if (bul->x - bul->blockXL < workX && bul->y + bul->blockYL > workY + (3 * 0x200))
hit |= 1;
}
@@ -102,12 +106,12 @@
}
else if (block[1] && !block[3])
{
- if (bul->x + bul->blockXL > workX && bul->y - bul->blockYL < workY - 0x600)
+ if (bul->x + bul->blockXL > workX && bul->y - bul->blockYL < workY - (3 * 0x200))
hit |= 4;
}
else if (!block[1] && block[3])
{
- if (bul->x + bul->blockXL > workX && bul->y + bul->blockYL > workY + 0x600)
+ if (bul->x + bul->blockXL > workX && bul->y + bul->blockYL > workY + (3 * 0x200))
hit |= 4;
}
@@ -119,12 +123,12 @@
}
else if (block[0] && !block[1])
{
- if (bul->y - bul->blockYL < workY && bul->x - bul->blockXL < workX - 0x600)
+ if (bul->y - bul->blockYL < workY && bul->x - bul->blockXL < workX - (3 * 0x200))
hit |= 2;
}
else if (!block[0] && block[1])
{
- if (bul->y - bul->blockYL < workY && bul->x + bul->blockXL > workX + 0x600)
+ if (bul->y - bul->blockYL < workY && bul->x + bul->blockXL > workX + (3 * 0x200))
hit |= 2;
}
@@ -136,12 +140,12 @@
}
else if (block[2] && !block[3])
{
- if (bul->y + bul->blockYL > workY && bul->x - bul->blockXL < workX - 0x600)
+ if (bul->y + bul->blockYL > workY && bul->x - bul->blockXL < workX - (3 * 0x200))
hit |= 8;
}
else if (!block[2] && block[3])
{
- if (bul->y + bul->blockYL > workY && bul->x + bul->blockXL > workX + 0x600)
+ if (bul->y + bul->blockYL > workY && bul->x + bul->blockXL > workX + (3 * 0x200))
hit |= 8;
}
@@ -157,9 +161,10 @@
else if (hit & 8)
bul->y = workY - bul->blockYL;
}
- else if (hit & 0xF)
+ else
{
- Vanish(bul);
+ if (hit & 0xF)
+ Vanish(bul);
}
return hit;
@@ -168,17 +173,19 @@
int JudgeHitBulletTriangleA(int x, int y, BULLET *bul)
{
int hit = 0;
- if (bul->x < (0x10 * x + 8) * 0x200
- && bul->x > (0x10 * x - 8) * 0x200
- && bul->y - 0x400 < (y * 0x10 * 0x200) - (bul->x - x * 0x10 * 0x200) / 2 + 0x800
- && bul->y + 0x400 > (0x10 * y - 8) * 0x200)
+ if (bul->x < ((x * 16) + 8) * 0x200
+ && bul->x > ((x * 16) - 8) * 0x200
+ && bul->y - (2 * 0x200) < ((y * 16) * 0x200) - ((bul->x - ((x * 16) * 0x200)) / 2) + (4 * 0x200)
+ && bul->y + (2 * 0x200) > ((y * 16) - 8) * 0x200)
{
if (bul->bbits & 8)
- bul->y = (y * 0x10 * 0x200) - (bul->x - x * 0x10 * 0x200) / 2 + 0xC00;
+ bul->y = ((y * 16) * 0x200) - ((bul->x - ((x * 16) * 0x200)) / 2) + (6 * 0x200);
else
Vanish(bul);
+
hit |= 0x82;
}
+
return hit;
}
@@ -185,17 +192,19 @@
int JudgeHitBulletTriangleB(int x, int y, BULLET *bul)
{
int hit = 0;
- if (bul->x < (0x10 * x + 8) * 0x200
- && bul->x > (0x10 * x - 8) * 0x200
- && bul->y - 0x400 < (y * 0x10 * 0x200) - (bul->x - x * 0x10 * 0x200) / 2 - 0x800
- && bul->y + 0x400 > (0x10 * y - 8) * 0x200)
+ if (bul->x < ((x * 16) + 8) * 0x200
+ && bul->x > ((x * 16) - 8) * 0x200
+ && bul->y - (2 * 0x200) < ((y * 16) * 0x200) - ((bul->x - ((x * 16) * 0x200)) / 2) - (4 * 0x200)
+ && bul->y + (2 * 0x200) > ((y * 16) - 8) * 0x200)
{
if (bul->bbits & 8)
- bul->y = (y * 0x10 * 0x200) - (bul->x - x * 0x10 * 0x200) / 2 - 0x400;
+ bul->y = ((y * 16) * 0x200) - ((bul->x - ((x * 16) * 0x200)) / 2) - (2 * 0x200);
else
Vanish(bul);
+
hit |= 0x82;
}
+
return hit;
}
@@ -202,17 +211,19 @@
int JudgeHitBulletTriangleC(int x, int y, BULLET *bul)
{
int hit = 0;
- if (bul->x < (0x10 * x + 8) * 0x200
- && bul->x > (0x10 * x - 8) * 0x200
- && bul->y - 0x400 < (y * 0x10 * 0x200) + (bul->x - x * 0x10 * 0x200) / 2 - 0x800
- && bul->y + 0x400 > (0x10 * y - 8) * 0x200)
+ if (bul->x < ((x * 16) + 8) * 0x200
+ && bul->x > ((x * 16) - 8) * 0x200
+ && bul->y - (2 * 0x200) < ((y * 16) * 0x200) + ((bul->x - ((x * 16) * 0x200)) / 2) - (4 * 0x200)
+ && bul->y + (2 * 0x200) > ((y * 16) - 8) * 0x200)
{
if (bul->bbits & 8)
- bul->y = (y * 0x10 * 0x200) + (bul->x - x * 0x10 * 0x200) / 2 - 0x400;
+ bul->y = ((y * 16) * 0x200) + ((bul->x - ((x * 16) * 0x200)) / 2) - (2 * 0x200);
else
Vanish(bul);
+
hit |= 0x42;
}
+
return hit;
}
@@ -219,17 +230,19 @@
int JudgeHitBulletTriangleD(int x, int y, BULLET *bul)
{
int hit = 0;
- if (bul->x < (0x10 * x + 8) * 0x200
- && bul->x > (0x10 * x - 8) * 0x200
- && bul->y - 0x400 < (y * 0x10 * 0x200) + (bul->x - x * 0x10 * 0x200) / 2 + 0x800
- && bul->y + 0x400 > (0x10 * y - 8) * 0x200)
+ if (bul->x < ((x * 16) + 8) * 0x200
+ && bul->x > ((x * 16) - 8) * 0x200
+ && bul->y - (2 * 0x200) < ((y * 16) * 0x200) + ((bul->x - ((x * 16) * 0x200)) / 2) + (4 * 0x200)
+ && bul->y + (2 * 0x200) > ((y * 16) - 8) * 0x200)
{
if (bul->bbits & 8)
- bul->y = (y * 0x10 * 0x200) + (bul->x - x * 0x10 * 0x200) / 2 + 0xC00;
+ bul->y = ((y * 16) * 0x200) + ((bul->x - ((x * 16) * 0x200)) / 2) + (6 * 0x200);
else
Vanish(bul);
+
hit |= 0x42;
}
+
return hit;
}
@@ -236,17 +249,19 @@
int JudgeHitBulletTriangleE(int x, int y, BULLET *bul)
{
int hit = 0;
- if (bul->x < (0x10 * x + 8) * 0x200
- && bul->x - 0x200 > (0x10 * x - 8) * 0x200
- && bul->y + 0x400 > (y * 0x10 * 0x200) + (bul->x - x * 0x10 * 0x200) / 2 - 0x800
- && bul->y - 0x400 < (0x10 * y + 8) * 0x200)
+ if (bul->x < ((x * 16) + 8) * 0x200
+ && bul->x - (1 * 0x200) > ((x * 16) - 8) * 0x200
+ && bul->y + (2 * 0x200) > ((y * 16) * 0x200) + ((bul->x - ((x * 16) * 0x200)) / 2) - (4 * 0x200)
+ && bul->y - (2 * 0x200) < ((y * 16) + 8) * 0x200)
{
if (bul->bbits & 8)
- bul->y = (y * 0x10 * 0x200) + (bul->x - x * 0x10 * 0x200) / 2 - 0xC00;
+ bul->y = ((y * 16) * 0x200) + ((bul->x - ((x * 16) * 0x200)) / 2) - (6 * 0x200);
else
Vanish(bul);
+
hit |= 0x28;
}
+
return hit;
}
@@ -253,17 +268,19 @@
int JudgeHitBulletTriangleF(int x, int y, BULLET *bul)
{
int hit = 0;
- if (bul->x < (0x10 * x + 8) * 0x200
- && bul->x > (0x10 * x - 8) * 0x200
- && bul->y + 0x400 > (y * 0x10 * 0x200) + (bul->x - x * 0x10 * 0x200) / 2 + 0x800
- && bul->y - 0x400 < (0x10 * y + 8) * 0x200)
+ if (bul->x < ((x * 16) + 8) * 0x200
+ && bul->x > ((x * 16) - 8) * 0x200
+ && bul->y + (2 * 0x200) > ((y * 16) * 0x200) + ((bul->x - ((x * 16) * 0x200)) / 2) + (4 * 0x200)
+ && bul->y - (2 * 0x200) < ((y * 16) + 8) * 0x200)
{
if (bul->bbits & 8)
- bul->y = (y * 0x10 * 0x200) + (bul->x - x * 0x10 * 0x200) / 2 + 0x400;
+ bul->y = ((y * 16) * 0x200) + ((bul->x - ((x * 16) * 0x200)) / 2) + (2 * 0x200);
else
Vanish(bul);
+
hit |= 0x28;
}
+
return hit;
}
@@ -270,17 +287,19 @@
int JudgeHitBulletTriangleG(int x, int y, BULLET *bul)
{
int hit = 0;
- if (bul->x < (0x10 * x + 8) * 0x200
- && bul->x > (0x10 * x - 8) * 0x200
- && bul->y + 0x400 > (y * 0x10 * 0x200) - (bul->x - x * 0x10 * 0x200) / 2 + 0x800
- && bul->y - 0x400 < (0x10 * y + 8) * 0x200)
+ if (bul->x < ((x * 16) + 8) * 0x200
+ && bul->x > ((x * 16) - 8) * 0x200
+ && bul->y + (2 * 0x200) > ((y * 16) * 0x200) - ((bul->x - ((x * 16) * 0x200)) / 2) + (4 * 0x200)
+ && bul->y - (2 * 0x200) < ((y * 16) + 8) * 0x200)
{
if (bul->bbits & 8)
- bul->y = (y * 0x10 * 0x200) - (bul->x - x * 0x10 * 0x200) / 2 + 0x400;
+ bul->y = ((y * 16) * 0x200) - ((bul->x - ((x * 16) * 0x200)) / 2) + (2 * 0x200);
else
Vanish(bul);
+
hit |= 0x18;
}
+
return hit;
}
@@ -287,21 +306,23 @@
int JudgeHitBulletTriangleH(int x, int y, BULLET *bul)
{
int hit = 0;
- if (bul->x < (0x10 * x + 8) * 0x200
- && bul->x > (0x10 * x - 8) * 0x200
- && bul->y + 0x400 > (y * 0x10 * 0x200) - (bul->x - x * 0x10 * 0x200) / 2 - 0x800
- && bul->y - 0x400 < (0x10 * y + 8) * 0x200)
+ if (bul->x < ((x * 16) + 8) * 0x200
+ && bul->x > ((x * 16) - 8) * 0x200
+ && bul->y + (2 * 0x200) > ((y * 16) * 0x200) - ((bul->x - ((x * 16) * 0x200)) / 2) - (4 * 0x200)
+ && bul->y - (2 * 0x200) < ((y * 16) + 8) * 0x200)
{
if (bul->bbits & 8)
- bul->y = (y * 0x10 * 0x200) - (bul->x - x * 0x10 * 0x200) / 2 - 0xC00;
+ bul->y = ((y * 16) * 0x200) - ((bul->x - ((x * 16) * 0x200)) / 2) - (6 * 0x200);
else
Vanish(bul);
+
hit |= 0x18;
}
+
return hit;
}
-void HitBulletMap()
+void HitBulletMap(void)
{
int i;
int j;
@@ -309,12 +330,12 @@
int y;
unsigned char atrb[4];
- for (i = 0; i < BULLET_MAX; i++)
+ for (i = 0; i < BULLET_MAX; ++i)
{
int offx[4];
int offy[4];
- if ((gBul[i].cond & 0x80) == 0)
+ if (!(gBul[i].cond & 0x80))
continue;
x = gBul[i].x / 0x10 / 0x200;
@@ -340,14 +361,13 @@
if (gBul[i].bbits & 4)
{
- // Using "continue" here doesn't produce accurate assembly
- // TODO Figure out what Pixel actually did (it's unlikely he left the brackets empty)
+ // There probably used to be commented-out code here
}
else
{
- for (j = 0; j < 4; j++)
+ for (j = 0; j < 4; ++j)
{
- if ((gBul[i].cond & 0x80) == 0)
+ if (!(gBul[i].cond & 0x80))
continue;
switch (atrb[j])
@@ -359,34 +379,42 @@
case 0x64:
gBul[i].flag |= JudgeHitBulletBlock(x + offx[j], y + offy[j], &gBul[i]);
break;
+
case 0x50:
case 0x70:
gBul[i].flag |= JudgeHitBulletTriangleA(x + offx[j], y + offy[j], &gBul[i]);
break;
+
case 0x51:
case 0x71:
gBul[i].flag |= JudgeHitBulletTriangleB(x + offx[j], y + offy[j], &gBul[i]);
break;
+
case 0x52:
case 0x72:
gBul[i].flag |= JudgeHitBulletTriangleC(x + offx[j], y + offy[j], &gBul[i]);
break;
+
case 0x53:
case 0x73:
gBul[i].flag |= JudgeHitBulletTriangleD(x + offx[j], y + offy[j], &gBul[i]);
break;
+
case 0x54:
case 0x74:
gBul[i].flag |= JudgeHitBulletTriangleE(x + offx[j], y + offy[j], &gBul[i]);
break;
+
case 0x55:
case 0x75:
gBul[i].flag |= JudgeHitBulletTriangleF(x + offx[j], y + offy[j], &gBul[i]);
break;
+
case 0x56:
case 0x76:
gBul[i].flag |= JudgeHitBulletTriangleG(x + offx[j], y + offy[j], &gBul[i]);
break;
+
case 0x57:
case 0x77:
gBul[i].flag |= JudgeHitBulletTriangleH(x + offx[j], y + offy[j], &gBul[i]);
@@ -398,4 +426,3 @@
}
}
}
-
--- a/src/BulHit.h
+++ b/src/BulHit.h
@@ -1,3 +1,3 @@
#pragma once
-void HitBulletMap();
+void HitBulletMap(void);
--- a/src/Bullet.cpp
+++ b/src/Bullet.cpp
@@ -64,21 +64,23 @@
BULLET gBul[BULLET_MAX];
-void InitBullet()
+void InitBullet(void)
{
// Identical to ClearBullet
- for (int i = 0; i < BULLET_MAX; i++)
+ int i;
+
+ for (i = 0; i < BULLET_MAX; ++i)
gBul[i].cond = 0;
}
int CountArmsBullet(int arms_code)
{
+ int i;
int count = 0;
- for (int i = 0; i < BULLET_MAX; i++)
- {
+
+ for (i = 0; i < BULLET_MAX; ++i)
if (gBul[i].cond & 0x80 && (gBul[i].code_bullet + 2) / 3 == arms_code)
++count;
- }
return count;
}
@@ -85,12 +87,12 @@
int CountBulletNum(int bullet_code)
{
+ int i;
int count = 0;
- for (int i = 0; i < BULLET_MAX; i++)
- {
+
+ for (i = 0; i < BULLET_MAX; ++i)
if (gBul[i].cond & 0x80 && gBul[i].code_bullet == bullet_code)
++count;
- }
return count;
}
@@ -98,21 +100,19 @@
void DeleteBullet(int code)
{
int i;
- int unknown = 0; // Not the original name
- for (i = 0; i < BULLET_MAX; i++)
- {
- if (gBul[i].cond & 0x80)
- {
- if ((gBul[i].code_bullet + 2) / 3 == code)
+ int count = 0; // Guessed name. This is unused, and was optimised out of the Linux port.
+
+ for (i = 0; i < BULLET_MAX; ++i)
+ if (gBul[i].cond & 0x80 && (gBul[i].code_bullet + 2) / 3 == code)
gBul[i].cond = 0;
- }
- }
}
-void ClearBullet()
+void ClearBullet(void)
{
// Identical to InitBullet
- for (int i = 0; i < BULLET_MAX; i++)
+ int i;
+
+ for (i = 0; i < BULLET_MAX; ++i)
gBul[i].cond = 0;
}
@@ -121,7 +121,7 @@
int i;
int x, y;
- for (i = 0; i < BULLET_MAX; i++)
+ for (i = 0; i < BULLET_MAX; ++i)
{
if (gBul[i].cond & 0x80)
{
@@ -145,7 +145,7 @@
break;
}
- PutBitmap3(&grcGame, x / 0x200 - fx / 0x200, y / 0x200 - fy / 0x200, &gBul[i].rect, SURFACE_ID_BULLET);
+ PutBitmap3(&grcGame, (x / 0x200) - (fx / 0x200), (y / 0x200) - (fy / 0x200), &gBul[i].rect, SURFACE_ID_BULLET);
}
}
}
@@ -167,14 +167,14 @@
gBul[i].life = gBulTbl[no].life;
gBul[i].life_count = gBulTbl[no].life_count;
gBul[i].bbits = gBulTbl[no].bbits;
- gBul[i].enemyXL = gBulTbl[no].enemyXL << 9;
- gBul[i].enemyYL = gBulTbl[no].enemyYL << 9;
- gBul[i].blockXL = gBulTbl[no].blockXL << 9;
- gBul[i].blockYL = gBulTbl[no].blockYL << 9;
- gBul[i].view.back = gBulTbl[no].view.back << 9;
- gBul[i].view.front = gBulTbl[no].view.front << 9;
- gBul[i].view.top = gBulTbl[no].view.top << 9;
- gBul[i].view.bottom = gBulTbl[no].view.bottom << 9;
+ gBul[i].enemyXL = gBulTbl[no].enemyXL * 0x200;
+ gBul[i].enemyYL = gBulTbl[no].enemyYL * 0x200;
+ gBul[i].blockXL = gBulTbl[no].blockXL * 0x200;
+ gBul[i].blockYL = gBulTbl[no].blockYL * 0x200;
+ gBul[i].view.back = gBulTbl[no].view.back * 0x200;
+ gBul[i].view.front = gBulTbl[no].view.front * 0x200;
+ gBul[i].view.top = gBulTbl[no].view.top * 0x200;
+ gBul[i].view.bottom = gBulTbl[no].view.bottom * 0x200;
gBul[i].x = x;
gBul[i].y = y;
}
@@ -185,64 +185,63 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
+ return;
}
- else
+
+ if (bul->act_no == 0)
{
- if (bul->act_no == 0)
- {
- bul->ani_no = Random(0, 2);
- bul->act_no = 1;
+ bul->ani_no = Random(0, 2);
+ bul->act_no = 1;
- switch (bul->direct)
- {
- case 0:
- bul->xm = -0x600;
- break;
- case 1:
- bul->ym = -0x600;
- break;
- case 2:
- bul->xm = 0x600;
- break;
- case 3:
- bul->ym = 0x600;
- break;
- }
- }
- else
+ switch (bul->direct)
{
- bul->x += bul->xm;
- bul->y += bul->ym;
+ case 0:
+ bul->xm = -0x600;
+ break;
+ case 1:
+ bul->ym = -0x600;
+ break;
+ case 2:
+ bul->xm = 0x600;
+ break;
+ case 3:
+ bul->ym = 0x600;
+ break;
}
+ }
+ else
+ {
+ bul->x += bul->xm;
+ bul->y += bul->ym;
+ }
- if (++bul->ani_wait > 0)
- {
- bul->ani_wait = 0;
- ++bul->ani_no;
- }
+ if (++bul->ani_wait > 0)
+ {
+ bul->ani_wait = 0;
+ ++bul->ani_no;
+ }
- if (bul->ani_no > 3)
- bul->ani_no = 0;
+ if (bul->ani_no > 3)
+ bul->ani_no = 0;
- RECT rcLeft[4] = {
- {136, 80, 152, 80},
- {120, 80, 136, 96},
- {136, 64, 152, 80},
- {120, 64, 136, 80},
- };
+ RECT rcLeft[4] = {
+ {136, 80, 152, 80},
+ {120, 80, 136, 96},
+ {136, 64, 152, 80},
+ {120, 64, 136, 80},
+ };
- RECT rcRight[4] = {
- {120, 64, 136, 80},
- {136, 64, 152, 80},
- {120, 80, 136, 96},
- {136, 80, 152, 80},
- };
+ RECT rcRight[4] = {
+ {120, 64, 136, 80},
+ {136, 64, 152, 80},
+ {120, 80, 136, 96},
+ {136, 80, 152, 80},
+ };
- if (bul->direct == 0)
- bul->rect = rcLeft[bul->ani_no];
- else
- bul->rect = rcRight[bul->ani_no];
- }
+ if (bul->direct == 0)
+ bul->rect = rcLeft[bul->ani_no];
+ else
+ bul->rect = rcRight[bul->ani_no];
}
void ActBullet_Frontia2(BULLET *bul, int level)
@@ -251,125 +250,124 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
+ return;
}
- else
+
+ if (bul->act_no == 0)
{
- if (bul->act_no == 0)
+ bul->ani_no = Random(0, 2);
+ bul->act_no = 1;
+
+ switch (bul->direct)
{
- bul->ani_no = Random(0, 2);
- bul->act_no = 1;
+ case 0:
+ bul->xm = -0x200;
+ break;
+ case 1:
+ bul->ym = -0x200;
+ break;
+ case 2:
+ bul->xm = 0x200;
+ break;
+ case 3:
+ bul->ym = 0x200;
+ break;
+ }
- switch (bul->direct)
- {
- case 0:
- bul->xm = -0x200;
- break;
- case 1:
- bul->ym = -0x200;
- break;
- case 2:
- bul->xm = 0x200;
- break;
- case 3:
- bul->ym = 0x200;
- break;
- }
+ static unsigned int inc;
+ ++inc;
- static unsigned int inc;
- ++inc;
+ switch (bul->direct)
+ {
+ case 0:
+ case 2:
+ if (inc % 2)
+ bul->ym = 0x400;
+ else
+ bul->ym = -0x400;
- switch (bul->direct)
- {
- case 0:
- case 2:
- if (inc % 2)
+ break;
+
+ case 1:
+ case 3:
+ if (inc % 2)
+ bul->xm = 0x400;
+ else
+ bul->xm = -0x400;
+
+ break;
+ }
+ }
+ else
+ {
+ switch (bul->direct)
+ {
+ case 0:
+ bul->xm -= 0x80;
+ break;
+ case 1:
+ bul->ym -= 0x80;
+ break;
+ case 2:
+ bul->xm += 0x80;
+ break;
+ case 3:
+ bul->ym += 0x80;
+ break;
+ }
+
+ switch (bul->direct)
+ {
+ case 0:
+ case 2:
+ if (bul->count1 % 5 == 2)
+ {
+ if (bul->ym < 0)
bul->ym = 0x400;
else
bul->ym = -0x400;
+ }
- break;
+ break;
- case 1:
- case 3:
- if (inc % 2)
+ case 1u:
+ case 3u:
+ if (bul->count1 % 5 == 2)
+ {
+ if (bul->xm < 0)
bul->xm = 0x400;
else
bul->xm = -0x400;
+ }
- break;
- }
+ break;
}
- else
- {
- switch (bul->direct)
- {
- case 0:
- bul->xm -= 0x80;
- break;
- case 1:
- bul->ym -= 0x80;
- break;
- case 2:
- bul->xm += 0x80;
- break;
- case 3:
- bul->ym += 0x80;
- break;
- }
- switch (bul->direct)
- {
- case 0:
- case 2:
- if (bul->count1 % 5 == 2)
- {
- if (bul->ym < 0)
- bul->ym = 0x400;
- else
- bul->ym = -0x400;
- }
+ bul->x += bul->xm;
+ bul->y += bul->ym;
+ }
- break;
+ if (++bul->ani_wait > 0)
+ {
+ bul->ani_wait = 0;
+ ++bul->ani_no;
+ }
- case 1u:
- case 3u:
- if (bul->count1 % 5 == 2)
- {
- if (bul->xm < 0)
- bul->xm = 0x400;
- else
- bul->xm = -0x400;
- }
+ if (bul->ani_no > 2)
+ bul->ani_no = 0;
- break;
- }
+ RECT rect[3] = {
+ {192, 16, 208, 32},
+ {208, 16, 224, 32},
+ {224, 16, 240, 32},
+ };
- bul->x += bul->xm;
- bul->y += bul->ym;
- }
+ bul->rect = rect[bul->ani_no];
- if (++bul->ani_wait > 0)
- {
- bul->ani_wait = 0;
- ++bul->ani_no;
- }
-
- if (bul->ani_no > 2)
- bul->ani_no = 0;
-
- RECT rect[3] = {
- {192, 16, 208, 32},
- {208, 16, 224, 32},
- {224, 16, 240, 32},
- };
-
- bul->rect = rect[bul->ani_no];
-
- if (level == 2)
- SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, 0, 0x100);
- else
- SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no + 3, 0, 0x100);
- }
+ if (level == 2)
+ SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, NULL, 0x100);
+ else
+ SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no + 3, NULL, 0x100);
}
void ActBullet_PoleStar(BULLET *bul, int level)
@@ -382,111 +380,112 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
+ return;
}
- else
+
+ if (bul->act_no == 0)
{
- if (bul->act_no == 0)
- {
- bul->act_no = 1;
+ bul->act_no = 1;
- // Set speed
- switch (bul->direct)
- {
- case 0:
- bul->xm = -0x1000;
- break;
- case 1:
- bul->ym = -0x1000;
- break;
- case 2:
- bul->xm = 0x1000;
- break;
- case 3:
- bul->ym = 0x1000;
- break;
- }
-
- // Set hitbox
- switch (level)
- {
- case 1:
- switch (bul->direct)
- {
- case 0:
- bul->enemyYL = 0x400;
- break;
- case 1:
- bul->enemyXL = 0x400;
- break;
- case 2:
- bul->enemyYL = 0x400;
- break;
- case 3:
- bul->enemyXL = 0x400;
- break;
- }
- break;
- case 2:
- switch (bul->direct)
- {
- case 0:
- bul->enemyYL = 0x800;
- break;
- case 1:
- bul->enemyXL = 0x800;
- break;
- case 2:
- bul->enemyYL = 0x800;
- break;
- case 3:
- bul->enemyXL = 0x800;
- break;
- }
- break;
- }
- }
- else
+ // Set speed
+ switch (bul->direct)
{
- // Move
- bul->x += bul->xm;
- bul->y += bul->ym;
+ case 0:
+ bul->xm = -0x1000;
+ break;
+ case 1:
+ bul->ym = -0x1000;
+ break;
+ case 2:
+ bul->xm = 0x1000;
+ break;
+ case 3:
+ bul->ym = 0x1000;
+ break;
}
- SET_RECT(rect1[0], 128, 32, 144, 48)
- SET_RECT(rect1[1], 144, 32, 160, 48)
-
- SET_RECT(rect2[0], 160, 32, 176, 48)
- SET_RECT(rect2[1], 176, 32, 192, 48)
-
- SET_RECT(rect3[0], 128, 48, 144, 64)
- SET_RECT(rect3[1], 144, 48, 160, 64)
-
- //Set framerect
+ // Set hitbox
switch (level)
{
case 1:
- if (bul->direct == 1 || bul->direct == 3)
- bul->rect = rect1[1];
- else
- bul->rect = rect1[0];
-
+ switch (bul->direct)
+ {
+ case 0:
+ bul->enemyYL = 0x400;
+ break;
+ case 1:
+ bul->enemyXL = 0x400;
+ break;
+ case 2:
+ bul->enemyYL = 0x400;
+ break;
+ case 3:
+ bul->enemyXL = 0x400;
+ break;
+ }
break;
case 2:
- if (bul->direct == 1 || bul->direct == 3)
- bul->rect = rect2[1];
- else
- bul->rect = rect2[0];
-
+ switch (bul->direct)
+ {
+ case 0:
+ bul->enemyYL = 0x800;
+ break;
+ case 1:
+ bul->enemyXL = 0x800;
+ break;
+ case 2:
+ bul->enemyYL = 0x800;
+ break;
+ case 3:
+ bul->enemyXL = 0x800;
+ break;
+ }
break;
- case 3:
- if (bul->direct == 1 || bul->direct == 3)
- bul->rect = rect3[1];
- else
- bul->rect = rect3[0];
-
- break;
}
}
+ else
+ {
+ // Move
+ bul->x += bul->xm;
+ bul->y += bul->ym;
+ }
+
+ SET_RECT(rect1[0], 128, 32, 144, 48)
+ SET_RECT(rect1[1], 144, 32, 160, 48)
+
+ SET_RECT(rect2[0], 160, 32, 176, 48)
+ SET_RECT(rect2[1], 176, 32, 192, 48)
+
+ SET_RECT(rect3[0], 128, 48, 144, 64)
+ SET_RECT(rect3[1], 144, 48, 160, 64)
+
+ //Set framerect
+ switch (level)
+ {
+ case 1:
+ if (bul->direct == 1 || bul->direct == 3)
+ bul->rect = rect1[1];
+ else
+ bul->rect = rect1[0];
+
+ break;
+
+ case 2:
+ if (bul->direct == 1 || bul->direct == 3)
+ bul->rect = rect2[1];
+ else
+ bul->rect = rect2[0];
+
+ break;
+
+ case 3:
+ if (bul->direct == 1 || bul->direct == 3)
+ bul->rect = rect3[1];
+ else
+ bul->rect = rect3[0];
+
+ break;
+ }
}
void ActBullet_FireBall(BULLET *bul, int level)
@@ -501,135 +500,136 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
+ return;
}
- else
+
+ bBreak = FALSE;
+ if (bul->flag & 2 && bul->flag & 8)
+ bBreak = TRUE;
+ if (bul->flag & 1 && bul->flag & 4)
+ bBreak = TRUE;
+
+ if (bul->direct == 0 && bul->flag & 1)
+ bul->direct = 2;
+ if (bul->direct == 2 && bul->flag & 4)
+ bul->direct = 0;
+
+ if (bBreak)
{
- bBreak = FALSE;
- if (bul->flag & 2 && bul->flag & 8)
- bBreak = TRUE;
- if (bul->flag & 1 && bul->flag & 4)
- bBreak = TRUE;
+ bul->cond = 0;
+ SetCaret(bul->x, bul->y, 2, 0);
+ PlaySoundObject(28, 1);
+ return;
+ }
- if (!bul->direct && bul->flag & 1)
- bul->direct = 2;
- if (bul->direct == 2 && bul->flag & 4)
- bul->direct = 0;
+ if (bul->act_no == 0)
+ {
+ bul->act_no = 1;
- if (bBreak)
+ switch (bul->direct)
{
- bul->cond = 0;
- SetCaret(bul->x, bul->y, 2, 0);
- PlaySoundObject(28, 1);
- }
- else
- {
- if (bul->act_no == 0)
- {
- bul->act_no = 1;
+ case 0:
+ bul->xm = -0x400;
+ break;
- switch (bul->direct)
- {
- case 0:
- bul->xm = -0x400;
- break;
- case 1:
- bul->xm = gMC.xm;
+ case 1:
+ bul->xm = gMC.xm;
- if (gMC.xm < 0)
- bul->direct = 0;
- else
- bul->direct = 2;
+ if (gMC.xm < 0)
+ bul->direct = 0;
+ else
+ bul->direct = 2;
- if (gMC.direct == 0)
- bul->xm -= 0x80;
- else
- bul->xm += 0x80;
+ if (gMC.direct == 0)
+ bul->xm -= 0x80;
+ else
+ bul->xm += 0x80;
- bul->ym = -0x5FF;
- break;
- case 2:
- bul->xm = 0x400;
- break;
- case 3:
- bul->xm = gMC.xm;
+ bul->ym = -0x5FF;
+ break;
- if (gMC.xm < 0)
- bul->direct = 0;
- else
- bul->direct = 2;
+ case 2:
+ bul->xm = 0x400;
+ break;
- bul->ym = 0x5FF;
+ case 3:
+ bul->xm = gMC.xm;
- break;
- }
- }
- else
- {
- if (bul->flag & 8)
- bul->ym = -0x400;
- else if (bul->flag & 1)
- bul->xm = 0x400;
- else if (bul->flag & 4)
- bul->xm = -0x400;
+ if (gMC.xm < 0)
+ bul->direct = 0;
+ else
+ bul->direct = 2;
- bul->ym += 85;
- if (bul->ym > 0x3FF)
- bul->ym = 0x3FF;
+ bul->ym = 0x5FF;
- bul->x += bul->xm;
- bul->y += bul->ym;
+ break;
+ }
+ }
+ else
+ {
+ if (bul->flag & 8)
+ bul->ym = -0x400;
+ else if (bul->flag & 1)
+ bul->xm = 0x400;
+ else if (bul->flag & 4)
+ bul->xm = -0x400;
- if (bul->flag & 0xD)
- PlaySoundObject(34, 1);
- }
+ bul->ym += 85;
+ if (bul->ym > 0x3FF)
+ bul->ym = 0x3FF;
- 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)
+ bul->x += bul->xm;
+ bul->y += bul->ym;
- 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)
+ if (bul->flag & 0xD)
+ PlaySoundObject(34, 1);
+ }
- 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)
+ 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)
- 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)
+ 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)
- bul->ani_no++;
+ 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)
- if (level == 1)
- {
- if (bul->ani_no > 3)
- bul->ani_no = 0;
+ 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)
- if (bul->direct == 0)
- bul->rect = rect_left1[bul->ani_no];
- else
- bul->rect = rect_right1[bul->ani_no];
- }
- else
- {
- if (bul->ani_no > 2)
- bul->ani_no = 0;
+ ++bul->ani_no;
- if (bul->direct == 0)
- bul->rect = rect_left2[bul->ani_no];
- else
- bul->rect = rect_right2[bul->ani_no];
+ if (level == 1)
+ {
+ if (bul->ani_no > 3)
+ bul->ani_no = 0;
- if (level == 2)
- SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, 0, 0x100);
- else
- SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no + 3, 0, 0x100);
- }
- }
+ if (bul->direct == 0)
+ bul->rect = rect_left1[bul->ani_no];
+ else
+ bul->rect = rect_right1[bul->ani_no];
}
+ else
+ {
+ if (bul->ani_no > 2)
+ bul->ani_no = 0;
+
+ if (bul->direct == 0)
+ bul->rect = rect_left2[bul->ani_no];
+ else
+ bul->rect = rect_right2[bul->ani_no];
+
+ if (level == 2)
+ SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, NULL, 0x100);
+ else
+ SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no + 3, NULL, 0x100);
+ }
}
void ActBullet_MachineGun(BULLET *bul, int level)
@@ -661,70 +661,71 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
+ return;
}
- else
+
+ if (bul->act_no == 0)
{
- if (bul->act_no == 0)
+ switch (level)
{
- switch (level)
- {
- case 1:
- move = 0x1000;
- break;
- case 2:
- move = 0x1000;
- break;
- case 3:
- move = 0x1000;
- break;
- }
+ case 1:
+ move = 0x1000;
+ break;
+ case 2:
+ move = 0x1000;
+ break;
+ case 3:
+ move = 0x1000;
+ break;
+ }
- bul->act_no = 1;
+ bul->act_no = 1;
- switch (bul->direct)
- {
- case 0:
- bul->xm = -move;
- bul->ym = Random(-0xAA, 0xAA);
- break;
- case 1:
- bul->ym = -move;
- bul->xm = Random(-0xAA, 0xAA);
- break;
- case 2:
- bul->xm = move;
- bul->ym = Random(-0xAA, 0xAA);
- break;
- case 3:
- bul->ym = move;
- bul->xm = Random(-0xAA, 0xAA);
- break;
- }
+ switch (bul->direct)
+ {
+ case 0:
+ bul->xm = -move;
+ bul->ym = Random(-0xAA, 0xAA);
+ break;
+ case 1:
+ bul->ym = -move;
+ bul->xm = Random(-0xAA, 0xAA);
+ break;
+ case 2:
+ bul->xm = move;
+ bul->ym = Random(-0xAA, 0xAA);
+ break;
+ case 3:
+ bul->ym = move;
+ bul->xm = Random(-0xAA, 0xAA);
+ break;
}
- else
+ }
+ else
+ {
+ bul->x += bul->xm;
+ bul->y += bul->ym;
+
+ switch (level)
{
- bul->x += bul->xm;
- bul->y += bul->ym;
+ case 1:
+ bul->rect = rect1[bul->direct];
+ break;
- switch (level)
- {
- case 1:
- bul->rect = rect1[bul->direct];
- break;
- case 2:
- bul->rect = rect2[bul->direct];
+ case 2:
+ bul->rect = rect2[bul->direct];
- if (bul->direct == 1 || bul->direct == 3)
- SetNpChar(127, bul->x, bul->y, 0, 0, 1, 0, 256);
- else
- SetNpChar(127, bul->x, bul->y, 0, 0, 0, 0, 256);
+ if (bul->direct == 1 || bul->direct == 3)
+ SetNpChar(127, bul->x, bul->y, 0, 0, 1, NULL, 0x100);
+ else
+ SetNpChar(127, bul->x, bul->y, 0, 0, 0, NULL, 0x100);
- break;
- case 3:
- bul->rect = rect3[bul->direct];
- SetNpChar(128, bul->x, bul->y, 0, 0, bul->direct, 0, 256);
- break;
- }
+ break;
+
+ case 3:
+ bul->rect = rect3[bul->direct];
+ SetNpChar(128, bul->x, bul->y, 0, 0, bul->direct, NULL, 0x100);
+ break;
}
}
}
@@ -892,16 +893,16 @@
switch (bul->direct)
{
case 0:
- SetCaret(bul->x + 0x1000, bul->y, 7, 2);
+ SetCaret(bul->x + (8 * 0x200), bul->y, 7, 2);
break;
case 1:
- SetCaret(bul->x, bul->y + 0x1000, 7, 3);
+ SetCaret(bul->x, bul->y + (8 * 0x200), 7, 3);
break;
case 2:
- SetCaret(bul->x - 0x1000, bul->y, 7, 0);
+ SetCaret(bul->x - (8 * 0x200), bul->y, 7, 0);
break;
case 3:
- SetCaret(bul->x, bul->y - 0x1000, 7, 1);
+ SetCaret(bul->x, bul->y - (8 * 0x200), 7, 1);
break;
}
}
@@ -968,22 +969,23 @@
{
case 1:
if (bul->act_wait % 3 == 0)
- SetDestroyNpCharUp(bul->x + (Random(-16, 16) << 9), bul->y + (Random(-16, 16) << 9), bul->enemyXL, 2);
+ SetDestroyNpCharUp(bul->x + (Random(-16, 16) * 0x200), bul->y + (Random(-16, 16) * 0x200), bul->enemyXL, 2);
break;
case 2:
if (bul->act_wait % 3 == 0)
- SetDestroyNpCharUp(bul->x + (Random(-32, 32) << 9), bul->y + (Random(-32, 32) << 9), bul->enemyXL, 2);
+ SetDestroyNpCharUp(bul->x + (Random(-32, 32) * 0x200), bul->y + (Random(-32, 32) * 0x200), bul->enemyXL, 2);
break;
case 3:
if (bul->act_wait % 3 == 0)
- SetDestroyNpCharUp(bul->x + (Random(-40, 40) << 9), bul->y + (Random(-40, 40) << 9), bul->enemyXL, 2);
+ SetDestroyNpCharUp(bul->x + (Random(-40, 40) * 0x200), bul->y + (Random(-40, 40) * 0x200), bul->enemyXL, 2);
break;
}
if (--bul->act_wait < 0)
bul->cond = 0;
+
break;
}
}
@@ -996,74 +998,73 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 2, 0);
+ return;
}
- else
+
+ switch (bul->act_no)
{
- switch (bul->act_no)
- {
- case 0:
- bul->act_no = 1;
+ case 0:
+ bul->act_no = 1;
- switch (bul->direct)
- {
- case 0:
- bul->xm = -0x600;
- break;
- case 2:
- bul->xm = 0x600;
- break;
- case 1:
- bul->ym = -0x600;
- break;
- case 3:
- bul->ym = 0x600;
- break;
- }
+ switch (bul->direct)
+ {
+ case 0:
+ bul->xm = -0x600;
+ break;
+ case 2:
+ bul->xm = 0x600;
+ break;
+ case 1:
+ bul->ym = -0x600;
+ break;
+ case 3:
+ bul->ym = 0x600;
+ break;
+ }
- break;
- }
+ break;
+ }
- switch (bul->direct)
- {
- case 0:
- bul->xm += 42;
- break;
- case 2:
- bul->xm -= 42;
- break;
- case 1:
- bul->ym += 42;
- break;
- case 3:
- bul->ym -= 42;
- break;
- }
+ switch (bul->direct)
+ {
+ case 0:
+ bul->xm += 0x2A;
+ break;
+ case 2:
+ bul->xm -= 0x2A;
+ break;
+ case 1:
+ bul->ym += 0x2A;
+ break;
+ case 3:
+ bul->ym -= 0x2A;
+ break;
+ }
- bul->x += bul->xm;
- bul->y += bul->ym;
+ bul->x += bul->xm;
+ bul->y += bul->ym;
- if (++bul->act_wait > 40)
- {
- bul->cond = 0;
- SetCaret(bul->x, bul->y, 15, 0);
- }
+ if (++bul->act_wait > 40)
+ {
+ bul->cond = 0;
+ 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)
+ 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)
- if (++bul->ani_wait > 3)
- {
- bul->ani_wait = 0;
- ++bul->ani_no;
- }
+ if (++bul->ani_wait > 3)
+ {
+ bul->ani_wait = 0;
+ ++bul->ani_no;
+ }
- if (bul->ani_no > 3)
- bul->ani_no = 3;
+ if (bul->ani_no > 3)
+ bul->ani_no = 3;
- bul->rect = rect[bul->ani_no];
- }
+ bul->rect = rect[bul->ani_no];
}
void ActBullet_Bubblin2(BULLET *bul)
@@ -1086,78 +1087,77 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 2, 0);
+ return;
}
- else
+
+ switch (bul->act_no)
{
- switch (bul->act_no)
- {
- case 0:
- bul->act_no = 1;
+ case 0:
+ bul->act_no = 1;
- switch (bul->direct)
- {
- case 0:
- bul->xm = -0x600;
- bul->ym = Random(-0x100, 0x100);
- break;
- case 2:
- bul->xm = 0x600;
- bul->ym = Random(-0x100, 0x100);
- break;
- case 1:
- bul->ym = -0x600;
- bul->xm = Random(-0x100, 0x100);
- break;
- case 3:
- bul->ym = 0x600;
- bul->xm = Random(-0x100, 0x100);
- break;
- }
+ switch (bul->direct)
+ {
+ case 0:
+ bul->xm = -0x600;
+ bul->ym = Random(-0x100, 0x100);
+ break;
+ case 2:
+ bul->xm = 0x600;
+ bul->ym = Random(-0x100, 0x100);
+ break;
+ case 1:
+ bul->ym = -0x600;
+ bul->xm = Random(-0x100, 0x100);
+ break;
+ case 3:
+ bul->ym = 0x600;
+ bul->xm = Random(-0x100, 0x100);
+ break;
+ }
- break;
- }
+ break;
+ }
- switch (bul->direct)
- {
- case 0:
- bul->xm += 0x10;
- break;
- case 2:
- bul->xm -= 0x10;
- break;
- case 1:
- bul->ym += 0x10;
- break;
- case 3:
- bul->ym -= 0x10;
- break;
- }
+ switch (bul->direct)
+ {
+ case 0:
+ bul->xm += 0x10;
+ break;
+ case 2:
+ bul->xm -= 0x10;
+ break;
+ case 1:
+ bul->ym += 0x10;
+ break;
+ case 3:
+ bul->ym -= 0x10;
+ break;
+ }
- bul->x += bul->xm;
- bul->y += bul->ym;
+ bul->x += bul->xm;
+ bul->y += bul->ym;
- if (++bul->act_wait > 60)
- {
- bul->cond = 0;
- SetCaret(bul->x, bul->y, 15, 0);
- }
+ if (++bul->act_wait > 60)
+ {
+ bul->cond = 0;
+ 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)
+ 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)
- if (++bul->ani_wait > 3)
- {
- bul->ani_wait = 0;
- ++bul->ani_no;
- }
+ if (++bul->ani_wait > 3)
+ {
+ bul->ani_wait = 0;
+ ++bul->ani_no;
+ }
- if (bul->ani_no > 3)
- bul->ani_no = 3;
+ if (bul->ani_no > 3)
+ bul->ani_no = 3;
- bul->rect = rect[bul->ani_no];
- }
+ bul->rect = rect[bul->ani_no];
}
void ActBullet_Bubblin3(BULLET *bul)
@@ -1174,78 +1174,78 @@
SetBullet(22, bul->x, bul->y, 3);
else
SetBullet(22, bul->x, bul->y, gMC.direct);
+
+ return;
}
- else
+
+ switch (bul->act_no)
{
- switch (bul->act_no)
- {
- case 0:
- bul->act_no = 1;
+ case 0:
+ bul->act_no = 1;
- switch (bul->direct)
- {
- case 0:
- bul->xm = Random(-0x400, -0x200);
- bul->ym = (Random(-4, 4) * 0x200) / 2;
- break;
- case 2:
- bul->xm = Random(0x200, 0x400);
- bul->ym = (Random(-4, 4) * 0x200) / 2;
- break;
- case 1:
- bul->ym = Random(-0x400, -0x200);
- bul->xm = (Random(-4, 4) * 0x200) / 2;
- break;
- case 3:
- bul->ym = Random(0x80, 0x100);
- bul->xm = (Random(-4, 4) * 0x200) / 2;
- break;
- }
+ switch (bul->direct)
+ {
+ case 0:
+ bul->xm = Random(-0x400, -0x200);
+ bul->ym = (Random(-4, 4) * 0x200) / 2;
+ break;
+ case 2:
+ bul->xm = Random(0x200, 0x400);
+ bul->ym = (Random(-4, 4) * 0x200) / 2;
+ break;
+ case 1:
+ bul->ym = Random(-0x400, -0x200);
+ bul->xm = (Random(-4, 4) * 0x200) / 2;
+ break;
+ case 3:
+ bul->ym = Random(0x80, 0x100);
+ bul->xm = (Random(-4, 4) * 0x200) / 2;
+ break;
+ }
- break;
- }
+ break;
+ }
- if (bul->x < gMC.x)
- bul->xm += 0x20;
- if (bul->x > gMC.x)
- bul->xm -= 0x20;
+ if (bul->x < gMC.x)
+ bul->xm += 0x20;
+ if (bul->x > gMC.x)
+ bul->xm -= 0x20;
- if (bul->y < gMC.y)
- bul->ym += 0x20;
- if (bul->y > gMC.y)
- bul->ym -= 0x20;
+ if (bul->y < gMC.y)
+ bul->ym += 0x20;
+ if (bul->y > gMC.y)
+ bul->ym -= 0x20;
- if (bul->xm < 0 && bul->flag & 1)
- bul->xm = 0x400;
- if (bul->xm > 0 && bul->flag & 4)
- bul->xm = -0x400;
+ if (bul->xm < 0 && bul->flag & 1)
+ bul->xm = 0x400;
+ if (bul->xm > 0 && bul->flag & 4)
+ bul->xm = -0x400;
- if (bul->ym < 0 && bul->flag & 2)
- bul->ym = 0x400;
- if (bul->ym > 0 && bul->flag & 8)
- bul->ym = -0x400;
+ if (bul->ym < 0 && bul->flag & 2)
+ bul->ym = 0x400;
+ if (bul->ym > 0 && bul->flag & 8)
+ bul->ym = -0x400;
- bul->x += bul->xm;
- bul->y += bul->ym;
+ bul->x += bul->xm;
+ bul->y += bul->ym;
- RECT rect[4] = {
- {240, 16, 248, 24},
- {248, 16, 256, 24},
- {240, 24, 248, 32},
- {248, 24, 256, 32},
- };
+ RECT rect[4] = {
+ {240, 16, 248, 24},
+ {248, 16, 256, 24},
+ {240, 24, 248, 32},
+ {248, 24, 256, 32},
+ };
- if (++bul->ani_wait > 3)
- {
- bul->ani_wait = 0;
- ++bul->ani_no;
- }
+ if (++bul->ani_wait > 3)
+ {
+ bul->ani_wait = 0;
+ ++bul->ani_no;
+ }
- if (bul->ani_no > 3)
- bul->ani_no = 3;
+ if (bul->ani_no > 3)
+ bul->ani_no = 3;
- bul->rect = rect[bul->ani_no];
- }
+ bul->rect = rect[bul->ani_no];
}
void ActBullet_Spine(BULLET *bul)
@@ -1254,75 +1254,74 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
+ return;
}
- else
+
+ if (bul->act_no == 0)
{
- if (bul->act_no == 0)
- {
- bul->act_no = 1;
+ bul->act_no = 1;
- switch (bul->direct)
- {
- case 0:
- bul->xm = (-Random(10, 16) * 0x200) / 2;
- break;
- case 1:
- bul->ym = (-Random(10, 16) * 0x200) / 2;
- break;
- case 2:
- bul->xm = (Random(10, 16) * 0x200) / 2;
- break;
- case 3:
- bul->ym = (Random(10, 16) * 0x200) / 2;
- break;
- }
- }
- else
- {
- bul->x += bul->xm;
- bul->y += bul->ym;
- }
-
- if (++bul->ani_wait > 1)
- {
- bul->ani_wait = 0;
- ++bul->ani_no;
- }
-
- if (bul->ani_no > 1)
- bul->ani_no = 0;
-
- RECT rcLeft[2] = {
- {224, 0, 232, 8},
- {232, 0, 240, 8},
- };
-
- RECT rcRight[2] = {
- {224, 0, 232, 8},
- {232, 0, 240, 8},
- };
-
- RECT rcDown[2] = {
- {224, 8, 232, 16},
- {232, 8, 240, 16},
- };
-
switch (bul->direct)
{
case 0:
- bul->rect = rcLeft[bul->ani_no];
+ bul->xm = (-Random(10, 16) * 0x200) / 2;
break;
case 1:
- bul->rect = rcDown[bul->ani_no];
+ bul->ym = (-Random(10, 16) * 0x200) / 2;
break;
case 2:
- bul->rect = rcRight[bul->ani_no];
+ bul->xm = (Random(10, 16) * 0x200) / 2;
break;
case 3:
- bul->rect = rcDown[bul->ani_no];
+ bul->ym = (Random(10, 16) * 0x200) / 2;
break;
}
}
+ else
+ {
+ bul->x += bul->xm;
+ bul->y += bul->ym;
+ }
+
+ if (++bul->ani_wait > 1)
+ {
+ bul->ani_wait = 0;
+ ++bul->ani_no;
+ }
+
+ if (bul->ani_no > 1)
+ bul->ani_no = 0;
+
+ RECT rcLeft[2] = {
+ {224, 0, 232, 8},
+ {232, 0, 240, 8},
+ };
+
+ RECT rcRight[2] = {
+ {224, 0, 232, 8},
+ {232, 0, 240, 8},
+ };
+
+ RECT rcDown[2] = {
+ {224, 8, 232, 16},
+ {232, 8, 240, 16},
+ };
+
+ switch (bul->direct)
+ {
+ case 0:
+ bul->rect = rcLeft[bul->ani_no];
+ break;
+ case 1:
+ bul->rect = rcDown[bul->ani_no];
+ break;
+ case 2:
+ bul->rect = rcRight[bul->ani_no];
+ break;
+ case 3:
+ bul->rect = rcDown[bul->ani_no];
+ break;
+ }
}
void ActBullet_Sword1(BULLET *bul)
@@ -1331,69 +1330,68 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
+ return;
}
- else
- {
- if (bul->count1 == 3)
- bul->bbits &= ~4;
- if (bul->count1 % 5 == 1)
- PlaySoundObject(34, 1);
+ if (bul->count1 == 3)
+ bul->bbits &= ~4;
- if (bul->act_no == 0)
- {
- bul->act_no = 1;
+ if (bul->count1 % 5 == 1)
+ PlaySoundObject(34, 1);
- switch (bul->direct)
- {
- case 0:
- bul->xm = -0x800;
- break;
- case 1:
- bul->ym = -0x800;
- break;
- case 2:
- bul->xm = 0x800;
- break;
- case 3:
- bul->ym = 0x800;
- break;
- }
- }
- else
+ if (bul->act_no == 0)
+ {
+ bul->act_no = 1;
+
+ switch (bul->direct)
{
- bul->x += bul->xm;
- bul->y += bul->ym;
+ case 0:
+ bul->xm = -0x800;
+ break;
+ case 1:
+ bul->ym = -0x800;
+ break;
+ case 2:
+ bul->xm = 0x800;
+ break;
+ case 3:
+ bul->ym = 0x800;
+ break;
}
+ }
+ else
+ {
+ bul->x += bul->xm;
+ bul->y += bul->ym;
+ }
- RECT rcLeft[4] = {
- {0, 48, 16, 64},
- {16, 48, 32, 64},
- {32, 48, 48, 64},
- {48, 48, 64, 64},
- };
+ RECT rcLeft[4] = {
+ {0, 48, 16, 64},
+ {16, 48, 32, 64},
+ {32, 48, 48, 64},
+ {48, 48, 64, 64},
+ };
- RECT rcRight[4] = {
- {64, 48, 80, 64},
- {80, 48, 96, 64},
- {96, 48, 112, 64},
- {112, 48, 128, 64},
- };
+ RECT rcRight[4] = {
+ {64, 48, 80, 64},
+ {80, 48, 96, 64},
+ {96, 48, 112, 64},
+ {112, 48, 128, 64},
+ };
- if (++bul->ani_wait > 1)
- {
- bul->ani_wait = 0;
- ++bul->ani_no;
- }
+ if (++bul->ani_wait > 1)
+ {
+ bul->ani_wait = 0;
+ ++bul->ani_no;
+ }
- if (bul->ani_no > 3)
- bul->ani_no = 0;
+ if (bul->ani_no > 3)
+ bul->ani_no = 0;
- if (bul->direct == 0)
- bul->rect = rcLeft[bul->ani_no];
- else
- bul->rect = rcRight[bul->ani_no];
- }
+ if (bul->direct == 0)
+ bul->rect = rcLeft[bul->ani_no];
+ else
+ bul->rect = rcRight[bul->ani_no];
}
void ActBullet_Sword2(BULLET *bul)
@@ -1402,69 +1400,68 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
+ return;
}
- else
- {
- if (bul->count1 == 3)
- bul->bbits &= ~4;
- if (bul->count1 % 7 == 1)
- PlaySoundObject(106, 1);
+ if (bul->count1 == 3)
+ bul->bbits &= ~4;
- if (bul->act_no == 0)
- {
- bul->act_no = 1;
+ if (bul->count1 % 7 == 1)
+ PlaySoundObject(106, 1);
- switch (bul->direct)
- {
- case 0:
- bul->xm = -0x800;
- break;
- case 1:
- bul->ym = -0x800;
- break;
- case 2:
- bul->xm = 0x800;
- break;
- case 3:
- bul->ym = 0x800;
- break;
- }
- }
- else
+ if (bul->act_no == 0)
+ {
+ bul->act_no = 1;
+
+ switch (bul->direct)
{
- bul->x += bul->xm;
- bul->y += bul->ym;
+ case 0:
+ bul->xm = -0x800;
+ break;
+ case 1:
+ bul->ym = -0x800;
+ break;
+ case 2:
+ bul->xm = 0x800;
+ break;
+ case 3:
+ bul->ym = 0x800;
+ break;
}
+ }
+ else
+ {
+ bul->x += bul->xm;
+ bul->y += bul->ym;
+ }
- RECT rcLeft[4] = {
- {160, 48, 184, 72},
- {184, 48, 208, 72},
- {208, 48, 232, 72},
- {232, 48, 256, 72},
- };
+ RECT rcLeft[4] = {
+ {160, 48, 184, 72},
+ {184, 48, 208, 72},
+ {208, 48, 232, 72},
+ {232, 48, 256, 72},
+ };
- RECT rcRight[4] = {
- {160, 72, 184, 96},
- {184, 72, 208, 96},
- {208, 72, 232, 96},
- {232, 72, 256, 96},
- };
+ RECT rcRight[4] = {
+ {160, 72, 184, 96},
+ {184, 72, 208, 96},
+ {208, 72, 232, 96},
+ {232, 72, 256, 96},
+ };
- if (++bul->ani_wait > 1)
- {
- bul->ani_wait = 0;
- ++bul->ani_no;
- }
+ if (++bul->ani_wait > 1)
+ {
+ bul->ani_wait = 0;
+ ++bul->ani_no;
+ }
- if (bul->ani_no > 3)
- bul->ani_no = 0;
+ if (bul->ani_no > 3)
+ bul->ani_no = 0;
- if (bul->direct == 0)
- bul->rect = rcLeft[bul->ani_no];
- else
- bul->rect = rcRight[bul->ani_no];
- }
+ if (bul->direct == 0)
+ bul->rect = rcLeft[bul->ani_no];
+ else
+ bul->rect = rcRight[bul->ani_no];
}
void ActBullet_Sword3(BULLET *bul)
@@ -1591,12 +1588,12 @@
{
case 0:
bul->act_no = 1;
- bul->y -= 0x1800;
+ bul->y -= 12 * 0x200;
if (bul->direct == 0)
- bul->x += 0x2000;
+ bul->x += 16 * 0x200;
else
- bul->x -= 0x2000;
+ bul->x -= 16 * 0x200;
// Fallthrough
case 1:
if (++bul->ani_wait > 2)
@@ -1606,11 +1603,11 @@
}
if (bul->direct == 0)
- bul->x -= 0x400;
+ bul->x -= 2 * 0x200;
else
- bul->x += 0x400;
+ bul->x += 2 * 0x200;
- bul->y += 0x400;
+ bul->y += 2 * 0x200;
if (bul->ani_no == 1)
bul->damage = 2;
@@ -1823,16 +1820,16 @@
switch (bul->direct)
{
case 0:
- SetCaret(bul->x + 0x1000, bul->y, 7, 2);
+ SetCaret(bul->x + (8 * 0x200), bul->y, 7, 2);
break;
case 1:
- SetCaret(bul->x, bul->y + 0x1000, 7, 3);
+ SetCaret(bul->x, bul->y + (8 * 0x200), 7, 3);
break;
case 2:
- SetCaret(bul->x - 0x1000, bul->y, 7, 0);
+ SetCaret(bul->x - (8 * 0x200), bul->y, 7, 0);
break;
case 3:
- SetCaret(bul->x, bul->y - 0x1000, 7, 1);
+ SetCaret(bul->x, bul->y - (8 * 0x200), 7, 1);
break;
}
}
@@ -1917,234 +1914,232 @@
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
+ return;
}
- else
+
+ if (bul->act_no == 0)
{
- if (bul->act_no == 0)
- {
- bul->act_no = 1;
- bul->count1 = 0;
+ bul->act_no = 1;
+ bul->count1 = 0;
- switch (bul->direct)
- {
- case 0:
- bul->xm = -0x1000;
- break;
- case 1:
- bul->ym = -0x1000;
- break;
- case 2:
- bul->xm = 0x1000;
- break;
- case 3:
- bul->ym = 0x1000;
- break;
- }
-
- switch (level)
- {
- case 3:
- bul->xm /= 3;
- bul->ym /= 3;
- break;
- }
- }
- else
- {
- if (level == 1 && bul->count1 % 4 == 1)
- {
- switch (bul->direct)
- {
- case 0:
- SetNpChar(4, bul->x, bul->y, -0x200, Random(-0x200, 0x200), 2, 0, 0x100);
- break;
- case 1:
- SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), -0x200, 2, 0, 0x100);
- break;
- case 2:
- SetNpChar(4, bul->x, bul->y, 0x200, Random(-0x200, 0x200), 2, 0, 0x100);
- break;
- case 3:
- SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), 0x200, 2, 0, 0x100);
- break;
- }
- }
-
- bul->x += bul->xm;
- bul->y += bul->ym;
- }
-
- if (++bul->ani_no > 1)
- bul->ani_no = 0;
-
- RECT rcL[2] = {
- {0, 112, 32, 128},
- {0, 128, 32, 144},
- };
-
- RECT rcU[2] = {
- {32, 112, 48, 144},
- {48, 112, 64, 144},
- };
-
- RECT rcR[2] = {
- {64, 112, 96, 128},
- {64, 128, 96, 144},
- };
-
- RECT rcD[2] = {
- {96, 112, 112, 144},
- {112, 112, 128, 144},
- };
-
switch (bul->direct)
{
case 0:
- bul->rect = rcL[bul->ani_no];
+ bul->xm = -0x1000;
break;
case 1:
- bul->rect = rcU[bul->ani_no];
+ bul->ym = -0x1000;
break;
case 2:
- bul->rect = rcR[bul->ani_no];
+ bul->xm = 0x1000;
break;
case 3:
- bul->rect = rcD[bul->ani_no];
+ bul->ym = 0x1000;
break;
}
- bul->rect.top += 32 * ((level - 1) / 2);
- bul->rect.bottom += 32 * ((level - 1) / 2);
- bul->rect.left += (level - 1) % 2 << 7;
- bul->rect.right += (level - 1) % 2 << 7;
+ switch (level)
+ {
+ case 3:
+ bul->xm /= 3;
+ bul->ym /= 3;
+ break;
+ }
}
-}
-
-void ActBullet_Spur(BULLET *bul, int level)
-{
- if (++bul->count1 > bul->life_count)
- {
- bul->cond = 0;
- SetCaret(bul->x, bul->y, 3, 0);
- }
else
{
- if (bul->damage && bul->life != 100)
- bul->damage = 0;
-
- if (bul->act_no == 0)
+ if (level == 1 && bul->count1 % 4 == 1)
{
- bul->act_no = 1;
-
switch (bul->direct)
{
case 0:
- bul->xm = -0x1000;
+ SetNpChar(4, bul->x, bul->y, -0x200, Random(-0x200, 0x200), 2, NULL, 0x100);
break;
case 1:
- bul->ym = -0x1000;
+ SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), -0x200, 2, NULL, 0x100);
break;
case 2:
- bul->xm = 0x1000;
+ SetNpChar(4, bul->x, bul->y, 0x200, Random(-0x200, 0x200), 2, NULL, 0x100);
break;
case 3:
- bul->ym = 0x1000;
+ SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), 0x200, 2, NULL, 0x100);
break;
}
+ }
- switch (level)
- {
- case 1:
- switch (bul->direct)
- {
- case 0:
- bul->enemyYL = 0x400;
- break;
- case 1:
- bul->enemyXL = 0x400;
- break;
- case 2:
- bul->enemyYL = 0x400;
- break;
- case 3:
- bul->enemyXL = 0x400;
- break;
- }
+ bul->x += bul->xm;
+ bul->y += bul->ym;
+ }
- break;
+ if (++bul->ani_no > 1)
+ bul->ani_no = 0;
- case 2:
- switch (bul->direct)
- {
- case 0:
- bul->enemyYL = 0x800;
- break;
- case 1:
- bul->enemyXL = 0x800;
- break;
- case 2:
- bul->enemyYL = 0x800;
- break;
- case 3:
- bul->enemyXL = 0x800;
- break;
- }
+ RECT rcL[2] = {
+ {0, 112, 32, 128},
+ {0, 128, 32, 144},
+ };
- break;
- }
- }
- else
- {
- bul->x += bul->xm;
- bul->y += bul->ym;
- }
+ RECT rcU[2] = {
+ {32, 112, 48, 144},
+ {48, 112, 64, 144},
+ };
- RECT rect1[2] = {
- {128, 32, 144, 48},
- {144, 32, 160, 48},
- };
+ RECT rcR[2] = {
+ {64, 112, 96, 128},
+ {64, 128, 96, 144},
+ };
- RECT rect2[2] = {
- {160, 32, 176, 48},
- {176, 32, 192, 48},
- };
+ RECT rcD[2] = {
+ {96, 112, 112, 144},
+ {112, 112, 128, 144},
+ };
- RECT rect3[2] = {
- {128, 48, 144, 64},
- {144, 48, 160, 64},
- };
+ switch (bul->direct)
+ {
+ case 0:
+ bul->rect = rcL[bul->ani_no];
+ break;
+ case 1:
+ bul->rect = rcU[bul->ani_no];
+ break;
+ case 2:
+ bul->rect = rcR[bul->ani_no];
+ break;
+ case 3:
+ bul->rect = rcD[bul->ani_no];
+ break;
+ }
- bul->damage = bul->life;
+ bul->rect.top += ((level - 1) / 2) * 32;
+ bul->rect.bottom += ((level - 1) / 2) * 32;
+ bul->rect.left += ((level - 1) % 2) * 128;
+ bul->rect.right += ((level - 1) % 2) * 128;
+}
+void ActBullet_Spur(BULLET *bul, int level)
+{
+ if (++bul->count1 > bul->life_count)
+ {
+ bul->cond = 0;
+ SetCaret(bul->x, bul->y, 3, 0);
+ return;
+ }
+
+ if (bul->damage && bul->life != 100)
+ bul->damage = 0;
+
+ if (bul->act_no == 0)
+ {
+ bul->act_no = 1;
+
+ switch (bul->direct)
+ {
+ case 0:
+ bul->xm = -0x1000;
+ break;
+ case 1:
+ bul->ym = -0x1000;
+ break;
+ case 2:
+ bul->xm = 0x1000;
+ break;
+ case 3:
+ bul->ym = 0x1000;
+ break;
+ }
+
switch (level)
{
case 1:
- if (bul->direct == 1 || bul->direct == 3)
- bul->rect = rect1[1];
- else
- bul->rect = rect1[0];
+ switch (bul->direct)
+ {
+ case 0:
+ bul->enemyYL = 0x400;
+ break;
+ case 1:
+ bul->enemyXL = 0x400;
+ break;
+ case 2:
+ bul->enemyYL = 0x400;
+ break;
+ case 3:
+ bul->enemyXL = 0x400;
+ break;
+ }
break;
case 2:
- if (bul->direct == 1 || bul->direct == 3)
- bul->rect = rect2[1];
- else
- bul->rect = rect2[0];
+ switch (bul->direct)
+ {
+ case 0:
+ bul->enemyYL = 0x800;
+ break;
+ case 1:
+ bul->enemyXL = 0x800;
+ break;
+ case 2:
+ bul->enemyYL = 0x800;
+ break;
+ case 3:
+ bul->enemyXL = 0x800;
+ break;
+ }
break;
+ }
+ }
+ else
+ {
+ bul->x += bul->xm;
+ bul->y += bul->ym;
+ }
- case 3:
- if (bul->direct == 1 || bul->direct == 3)
- bul->rect = rect3[1];
- else
- bul->rect = rect3[0];
+ RECT rect1[2] = {
+ {128, 32, 144, 48},
+ {144, 32, 160, 48},
+ };
- break;
- }
+ RECT rect2[2] = {
+ {160, 32, 176, 48},
+ {176, 32, 192, 48},
+ };
- SetBullet(level + 39, bul->x, bul->y, bul->direct);
+ RECT rect3[2] = {
+ {128, 48, 144, 64},
+ {144, 48, 160, 64},
+ };
+
+ bul->damage = bul->life;
+
+ switch (level)
+ {
+ case 1:
+ if (bul->direct == 1 || bul->direct == 3)
+ bul->rect = rect1[1];
+ else
+ bul->rect = rect1[0];
+
+ break;
+
+ case 2:
+ if (bul->direct == 1 || bul->direct == 3)
+ bul->rect = rect2[1];
+ else
+ bul->rect = rect2[0];
+
+ break;
+
+ case 3:
+ if (bul->direct == 1 || bul->direct == 3)
+ bul->rect = rect3[1];
+ else
+ bul->rect = rect3[0];
+
+ break;
}
+
+ SetBullet(39 + level, bul->x, bul->y, bul->direct);
}
void ActBullet_SpurTail(BULLET *bul, int level)
@@ -2151,8 +2146,10 @@
{
if (++bul->count1 > 20)
bul->ani_no = bul->count1 - 20;
+
if (bul->ani_no > 2)
bul->cond = 0;
+
if (bul->damage && bul->life != 100)
bul->damage = 0;
@@ -2225,13 +2222,12 @@
if (++bul->count1 > bul->life_count)
{
bul->cond = 0;
+ return;
}
- else
- {
- bul->damage = 10000;
- bul->enemyXL = 0xC8000;
- bul->enemyYL = 0xC8000;
- }
+
+ bul->damage = 10000;
+ bul->enemyXL = 0xC8000;
+ bul->enemyYL = 0xC8000;
}
void ActBullet_Star(BULLET *bul)
@@ -2240,9 +2236,11 @@
bul->cond = 0;
}
-void ActBullet()
+void ActBullet(void)
{
- for (int i = 0; i < BULLET_MAX; i++)
+ int i;
+
+ for (i = 0; i < BULLET_MAX; ++i)
{
if (gBul[i].cond & 0x80)
{
@@ -2251,146 +2249,144 @@
gBul[i].cond = 0;
continue;
}
- else
+
+ switch (gBul[i].code_bullet)
{
- switch (gBul[i].code_bullet)
- {
- case 1:
- ActBullet_Frontia1(&gBul[i]);
- break;
- case 2:
- ActBullet_Frontia2(&gBul[i], 2);
- break;
- case 3:
- ActBullet_Frontia2(&gBul[i], 3);
- break;
- case 4:
- ActBullet_PoleStar(&gBul[i], 1);
- break;
- case 5:
- ActBullet_PoleStar(&gBul[i], 2);
- break;
- case 6:
- ActBullet_PoleStar(&gBul[i], 3);
- break;
- case 7:
- ActBullet_FireBall(&gBul[i], 1);
- break;
- case 8:
- ActBullet_FireBall(&gBul[i], 2);
- break;
- case 9:
- ActBullet_FireBall(&gBul[i], 3);
- break;
- case 10:
- ActBullet_MachineGun(&gBul[i], 1);
- break;
- case 11:
- ActBullet_MachineGun(&gBul[i], 2);
- break;
- case 12:
- ActBullet_MachineGun(&gBul[i], 3);
- break;
- case 13:
- ActBullet_Missile(&gBul[i], 1);
- break;
- case 14:
- ActBullet_Missile(&gBul[i], 2);
- break;
- case 15:
- ActBullet_Missile(&gBul[i], 3);
- break;
- case 16:
- ActBullet_Bom(&gBul[i], 1);
- break;
- case 17:
- ActBullet_Bom(&gBul[i], 2);
- break;
- case 18:
- ActBullet_Bom(&gBul[i], 3);
- break;
- case 19:
- ActBullet_Bubblin1(&gBul[i]);
- break;
- case 20:
- ActBullet_Bubblin2(&gBul[i]);
- break;
- case 21:
- ActBullet_Bubblin3(&gBul[i]);
- break;
- case 22:
- ActBullet_Spine(&gBul[i]);
- break;
- case 23:
- ActBullet_Edge(&gBul[i]);
- break;
- case 24:
- ActBullet_Drop(&gBul[i]);
- break;
- case 25:
- ActBullet_Sword1(&gBul[i]);
- break;
- case 26:
- ActBullet_Sword2(&gBul[i]);
- break;
- case 27:
- ActBullet_Sword3(&gBul[i]);
- break;
- case 28:
- ActBullet_SuperMissile(&gBul[i], 1);
- break;
- case 29:
- ActBullet_SuperMissile(&gBul[i], 2);
- break;
- case 30:
- ActBullet_SuperMissile(&gBul[i], 3);
- break;
- case 31:
- ActBullet_SuperBom(&gBul[i], 1);
- break;
- case 32:
- ActBullet_SuperBom(&gBul[i], 2);
- break;
- case 33:
- ActBullet_SuperBom(&gBul[i], 3);
- break;
- case 34: // Identical to case 43
- ActBullet_Nemesis(&gBul[i], 1);
- break;
- case 35:
- ActBullet_Nemesis(&gBul[i], 2);
- break;
- case 36:
- ActBullet_Nemesis(&gBul[i], 3);
- break;
- case 37:
- ActBullet_Spur(&gBul[i], 1);
- break;
- case 38:
- ActBullet_Spur(&gBul[i], 2);
- break;
- case 39:
- ActBullet_Spur(&gBul[i], 3);
- break;
- case 40:
- ActBullet_SpurTail(&gBul[i], 1);
- break;
- case 41:
- ActBullet_SpurTail(&gBul[i], 2);
- break;
- case 42:
- ActBullet_SpurTail(&gBul[i], 3);
- break;
- case 43: // Identical to case 34
- ActBullet_Nemesis(&gBul[i], 1);
- break;
- case 44:
- ActBullet_EnemyClear(&gBul[i]);
- break;
- case 45:
- ActBullet_Star(&gBul[i]);
- break;
- }
+ case 1:
+ ActBullet_Frontia1(&gBul[i]);
+ break;
+ case 2:
+ ActBullet_Frontia2(&gBul[i], 2);
+ break;
+ case 3:
+ ActBullet_Frontia2(&gBul[i], 3);
+ break;
+ case 4:
+ ActBullet_PoleStar(&gBul[i], 1);
+ break;
+ case 5:
+ ActBullet_PoleStar(&gBul[i], 2);
+ break;
+ case 6:
+ ActBullet_PoleStar(&gBul[i], 3);
+ break;
+ case 7:
+ ActBullet_FireBall(&gBul[i], 1);
+ break;
+ case 8:
+ ActBullet_FireBall(&gBul[i], 2);
+ break;
+ case 9:
+ ActBullet_FireBall(&gBul[i], 3);
+ break;
+ case 10:
+ ActBullet_MachineGun(&gBul[i], 1);
+ break;
+ case 11:
+ ActBullet_MachineGun(&gBul[i], 2);
+ break;
+ case 12:
+ ActBullet_MachineGun(&gBul[i], 3);
+ break;
+ case 13:
+ ActBullet_Missile(&gBul[i], 1);
+ break;
+ case 14:
+ ActBullet_Missile(&gBul[i], 2);
+ break;
+ case 15:
+ ActBullet_Missile(&gBul[i], 3);
+ break;
+ case 16:
+ ActBullet_Bom(&gBul[i], 1);
+ break;
+ case 17:
+ ActBullet_Bom(&gBul[i], 2);
+ break;
+ case 18:
+ ActBullet_Bom(&gBul[i], 3);
+ break;
+ case 19:
+ ActBullet_Bubblin1(&gBul[i]);
+ break;
+ case 20:
+ ActBullet_Bubblin2(&gBul[i]);
+ break;
+ case 21:
+ ActBullet_Bubblin3(&gBul[i]);
+ break;
+ case 22:
+ ActBullet_Spine(&gBul[i]);
+ break;
+ case 23:
+ ActBullet_Edge(&gBul[i]);
+ break;
+ case 24:
+ ActBullet_Drop(&gBul[i]);
+ break;
+ case 25:
+ ActBullet_Sword1(&gBul[i]);
+ break;
+ case 26:
+ ActBullet_Sword2(&gBul[i]);
+ break;
+ case 27:
+ ActBullet_Sword3(&gBul[i]);
+ break;
+ case 28:
+ ActBullet_SuperMissile(&gBul[i], 1);
+ break;
+ case 29:
+ ActBullet_SuperMissile(&gBul[i], 2);
+ break;
+ case 30:
+ ActBullet_SuperMissile(&gBul[i], 3);
+ break;
+ case 31:
+ ActBullet_SuperBom(&gBul[i], 1);
+ break;
+ case 32:
+ ActBullet_SuperBom(&gBul[i], 2);
+ break;
+ case 33:
+ ActBullet_SuperBom(&gBul[i], 3);
+ break;
+ case 34: // Identical to case 43
+ ActBullet_Nemesis(&gBul[i], 1);
+ break;
+ case 35:
+ ActBullet_Nemesis(&gBul[i], 2);
+ break;
+ case 36:
+ ActBullet_Nemesis(&gBul[i], 3);
+ break;
+ case 37:
+ ActBullet_Spur(&gBul[i], 1);
+ break;
+ case 38:
+ ActBullet_Spur(&gBul[i], 2);
+ break;
+ case 39:
+ ActBullet_Spur(&gBul[i], 3);
+ break;
+ case 40:
+ ActBullet_SpurTail(&gBul[i], 1);
+ break;
+ case 41:
+ ActBullet_SpurTail(&gBul[i], 2);
+ break;
+ case 42:
+ ActBullet_SpurTail(&gBul[i], 3);
+ break;
+ case 43: // Identical to case 34
+ ActBullet_Nemesis(&gBul[i], 1);
+ break;
+ case 44:
+ ActBullet_EnemyClear(&gBul[i]);
+ break;
+ case 45:
+ ActBullet_Star(&gBul[i]);
+ break;
}
}
}
@@ -2398,28 +2394,30 @@
BOOL IsActiveSomeBullet(void)
{
- for (int i = 0; i < 0x40; ++i)
+ int i;
+
+ for (i = 0; i < BULLET_MAX; ++i)
{
if (gBul[i].cond & 0x80)
{
switch (gBul[i].code_bullet)
{
- case 0xD:
- case 0xE:
- case 0xF:
- case 0x10:
- case 0x11:
- case 0x12:
- case 0x17:
- case 0x19:
- case 0x1A:
- case 0x1B:
- case 0x1C:
- case 0x1D:
- case 0x1E:
- case 0x1F:
- case 0x20:
- case 0x21:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ case 23:
+ case 25:
+ case 26:
+ case 27:
+ case 28:
+ case 29:
+ case 30:
+ case 31:
+ case 32:
+ case 33:
return TRUE;
}
}
--- a/src/Bullet.h
+++ b/src/Bullet.h
@@ -60,12 +60,12 @@
#define BULLET_MAX 0x40
extern BULLET gBul[BULLET_MAX];
-void InitBullet();
+void InitBullet(void);
int CountArmsBullet(int arms_code);
int CountBulletNum(int bullet_code);
void DeleteBullet(int code);
-void ClearBullet();
+void ClearBullet(void);
void PutBullet(int fx, int fy);
void SetBullet(int no, int x, int y, int dir);
-void ActBullet();
+void ActBullet(void);
BOOL IsActiveSomeBullet(void);
--- a/src/Caret.cpp
+++ b/src/Caret.cpp
@@ -11,7 +11,7 @@
#define CARET_MAX 0x40
CARET gCrt[CARET_MAX];
-void InitCaret()
+void InitCaret(void)
{
memset(gCrt, 0, sizeof(gCrt));
}
@@ -37,7 +37,7 @@
{88, 24, 96, 32},
};
- if (!crt->act_no)
+ if (crt->act_no == 0)
{
crt->act_no = 1;
crt->xm = Random(-0x400, 0x400);
@@ -165,7 +165,7 @@
crt->cond = 0;
}
- crt->rect = rect[3 * crt->direct + crt->ani_no];
+ crt->rect = rect[(crt->direct * 3) + crt->ani_no];
}
void ActCaret05(CARET *crt)
@@ -220,16 +220,16 @@
switch (crt->direct)
{
case 0:
- crt->x -= 0x400;
+ crt->x -= 2 * 0x200;
break;
case 1:
- crt->y -= 0x400;
+ crt->y -= 2 * 0x200;
break;
case 2:
- crt->x += 0x400;
+ crt->x += 2 * 0x200;
break;
case 3:
- crt->y += 0x400;
+ crt->y += 2 * 0x200;
break;
}
}
@@ -279,7 +279,7 @@
if (crt->direct == 0)
{
if (crt->ani_wait < 20)
- crt->y -= 0x400;
+ crt->y -= 2 * 0x200;
if (crt->ani_wait == 80)
crt->cond = 0;
@@ -287,7 +287,7 @@
else
{
if (crt->ani_wait < 20)
- crt->y -= 0x200;
+ crt->y -= 1 * 0x200;
if (crt->ani_wait == 80)
crt->cond = 0;
@@ -303,12 +303,12 @@
{
unsigned char deg;
- if (!crt->act_no)
+ if (crt->act_no == 0)
{
crt->act_no = 1;
deg = Random(0, 0xFF);
- crt->xm = 2 * GetCos(deg);
- crt->ym = 2 * GetSin(deg);
+ crt->xm = GetCos(deg) * 2;
+ crt->ym = GetSin(deg) * 2;
}
crt->x += crt->xm;
@@ -378,8 +378,8 @@
switch (crt->direct)
{
case 0:
- crt->xm = 4 * crt->xm / 5;
- crt->ym = 4 * crt->ym / 5;
+ crt->xm = (crt->xm * 4) / 5;
+ crt->ym = (crt->ym * 4) / 5;
break;
}
@@ -392,7 +392,7 @@
crt->rect = rcLeft[crt->ani_wait / 2 % 2];
if (crt->direct == 5)
- crt->x -= 0x800;
+ crt->x -= 4 * 0x200;
}
void ActCaret14(CARET *crt)
@@ -444,7 +444,7 @@
};
if (++crt->ani_wait < 10)
- crt->y -= 0x400;
+ crt->y -= 2 * 0x200;
if (crt->ani_wait == 40)
crt->cond = 0;
@@ -513,12 +513,12 @@
ActCaret17,
};
-void ActCaret()
+void ActCaret(void)
{
int i;
int code;
- for (i = 0; i < CARET_MAX; i++)
+ for (i = 0; i < CARET_MAX; ++i)
{
if (gCrt[i].cond & 0x80)
{
@@ -530,14 +530,16 @@
void PutCaret(int fx, int fy)
{
- for (int i = 0; i < CARET_MAX; i++)
+ int i;
+
+ for (i = 0; i < CARET_MAX; ++i)
{
if (gCrt[i].cond & 0x80)
{
PutBitmap3(
&grcGame,
- (gCrt[i].x - gCrt[i].view_left) / 0x200 - fx / 0x200,
- (gCrt[i].y - gCrt[i].view_top) / 0x200 - fy / 0x200,
+ ((gCrt[i].x - gCrt[i].view_left) / 0x200) - (fx / 0x200),
+ ((gCrt[i].y - gCrt[i].view_top) / 0x200) - (fy / 0x200),
&gCrt[i].rect,
SURFACE_ID_CARET);
}
@@ -547,7 +549,7 @@
void SetCaret(int x, int y, int code, int dir)
{
int c;
- for (c = 0; c < CARET_MAX; c++)
+ for (c = 0; c < CARET_MAX; ++c)
if (gCrt[c].cond == 0)
break;
--- a/src/Caret.h
+++ b/src/Caret.h
@@ -26,7 +26,7 @@
RECT rect;
};
-void InitCaret();
-void ActCaret();
+void InitCaret(void);
+void ActCaret(void);
void PutCaret(int fx, int fy);
void SetCaret(int x, int y, int code, int dir);
--- a/src/CommonDefines.h
+++ b/src/CommonDefines.h
@@ -10,9 +10,6 @@
#define TILES_TO_UNITS(x) ((int)((x) * (0x200 * 0x10)))
#define UNITS_TO_TILES(x) ((int)((x) / (0x200 * 0x10)))
-#define SECONDS_TO_FRAMES(x) ((int)((x) * 50))
-#define FRAMES_TO_SECONDS(x) ((int)((x) / 50))
-
enum Collisions
{
COLL_LEFT_WALL = 1, // Touching a left wall
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -46,7 +46,7 @@
fclose(fp);
// Check if version is not correct, and return if it failed
- if (strcmp(conf->proof, config_magic) != 0)
+ if (strcmp(conf->proof, config_magic))
{
memset(conf, 0, sizeof(CONFIG));
return FALSE;
@@ -64,7 +64,7 @@
// conf->display_mode = 1;
// Reset joystick settings (as these can't simply be set to 0)
- conf->bJoystick = 1;
+ conf->bJoystick = TRUE;
conf->joystick_button[0] = 2;
conf->joystick_button[1] = 1;
conf->joystick_button[2] = 5;
--- a/src/Config.h
+++ b/src/Config.h
@@ -10,7 +10,7 @@
long attack_button_mode;
long ok_button_mode;
long display_mode;
- long bJoystick;
+ BOOL bJoystick;
long joystick_button[8];
};
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -129,8 +129,10 @@
void EndDirectDraw(void)
{
+ int i;
+
// Release all surfaces
- for (int i = 0; i < SURFACE_ID_MAX; ++i)
+ for (i = 0; i < SURFACE_ID_MAX; ++i)
{
if (surf[i] != NULL)
{
@@ -553,6 +555,7 @@
int RestoreSurfaces(void) // Guessed function name - this doesn't exist in the Linux port
{
+ int s;
RECT rect;
int surfaces_regenerated = 0;
@@ -566,7 +569,7 @@
DummiedOutLogFunction(0x62);
}
- for (int s = 0; s < SURFACE_ID_MAX; ++s )
+ for (s = 0; s < SURFACE_ID_MAX; ++s)
{
if (surf[s] != NULL)
{
--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -23,9 +23,11 @@
ILLUSTRATION Illust;
// Update casts
-void ActionStripper()
+void ActionStripper(void)
{
- for (int s = 0; s < MAX_STRIP; s++)
+ int s;
+
+ for (s = 0; s < MAX_STRIP; ++s)
{
// Move up
if (Strip[s].flag & 0x80 && Credit.mode)
@@ -37,11 +39,12 @@
}
// Draw casts
-void PutStripper()
+void PutStripper(void)
{
RECT rc;
+ int s;
- for (int s = 0; s < MAX_STRIP; s++)
+ for (s = 0; s < MAX_STRIP; ++s)
{
if (Strip[s].flag & 0x80)
{
@@ -48,15 +51,15 @@
// Draw text
rc.left = 0;
rc.right = 320;
- rc.top = s * 0x10;
- rc.bottom = rc.top + 0x10;
+ rc.top = s * 16;
+ rc.bottom = rc.top + 16;
PutBitmap3(&grcFull, (Strip[s].x / 0x200) + ((WINDOW_WIDTH - 320) / 2), (Strip[s].y / 0x200), &rc, SURFACE_ID_CREDIT_CAST);
// Draw character
- rc.left = 24 * (Strip[s].cast % 13);
+ rc.left = (Strip[s].cast % 13) * 24;
rc.right = rc.left + 24;
- rc.top = 24 * (Strip[s].cast / 13);
+ rc.top = (Strip[s].cast / 13) * 24;
rc.bottom = rc.top + 24;
PutBitmap3(&grcFull, (Strip[s].x / 0x200) + ((WINDOW_WIDTH - 320) / 2) - 24, (Strip[s].y / 0x200) - 8, &rc, SURFACE_ID_CASTS);
@@ -70,7 +73,7 @@
RECT rc;
int s;
- for (s = 0; s < MAX_STRIP; s++)
+ for (s = 0; s < MAX_STRIP; ++s)
if (!(Strip[s].flag & 0x80))
break;
@@ -87,8 +90,8 @@
// Draw text
rc.left = 0;
rc.right = 320;
- rc.top = s * 0x10;
- rc.bottom = rc.top + 0x10;
+ rc.top = s * 16;
+ rc.bottom = rc.top + 16;
CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST);
PutText2(0, rc.top, text, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_CREDIT_CAST);
@@ -95,18 +98,19 @@
}
// Regenerate cast text
-void RestoreStripper()
+void RestoreStripper(void)
{
RECT rc;
+ int s;
- for (int s = 0; s < MAX_STRIP; s++)
+ for (s = 0; s < MAX_STRIP; ++s)
{
if (Strip[s].flag & 0x80)
{
rc.left = 0;
rc.right = 320;
- rc.top = s * 0x10;
- rc.bottom = rc.top + 0x10;
+ rc.top = s * 16;
+ rc.bottom = rc.top + 16;
CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST);
PutText2(0, rc.top, Strip[s].str, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_CREDIT_CAST);
@@ -115,16 +119,16 @@
}
// Handle the illustration
-void ActionIllust()
+void ActionIllust(void)
{
switch (Illust.act_no)
{
case 0: // Off-screen to the left
- Illust.x = -0x14000;
+ Illust.x = -160 * 0x200;
break;
case 1: // Move in from the left
- Illust.x += 0x5000;
+ Illust.x += 40 * 0x200;
if (Illust.x > 0)
Illust.x = 0;
break;
@@ -131,14 +135,14 @@
case 2: // Move out from the right
Illust.x -= 0x5000;
- if (Illust.x < -0x14000)
- Illust.x = -0x14000;
+ if (Illust.x < -160 * 0x200)
+ Illust.x = -160 * 0x200;
break;
}
}
// Draw illustration
-void PutIllust()
+void PutIllust(void)
{
RECT rcIllust = {0, 0, 160, 240};
#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240
@@ -159,7 +163,7 @@
}
// Initialize and release credits
-void InitCreditScript()
+void InitCreditScript(void)
{
// Clear script state and casts
memset(&Credit, 0, sizeof(CREDIT));
@@ -166,9 +170,9 @@
memset(Strip, 0, sizeof(Strip));
}
-void ReleaseCreditScript()
+void ReleaseCreditScript(void)
{
- if (Credit.pData)
+ if (Credit.pData != NULL)
{
// Free script data
free(Credit.pData);
@@ -179,10 +183,10 @@
const char *credit_script = "Credit.tsc";
// Start playing credits
-BOOL StartCreditScript()
+BOOL StartCreditScript(void)
{
// Clear previously existing credits data
- if (Credit.pData)
+ if (Credit.pData != NULL)
{
free(Credit.pData);
Credit.pData = NULL;
@@ -221,7 +225,7 @@
Credit.offset = 0;
Credit.wait = 0;
Credit.mode = 1;
- Illust.x = -0x14000;
+ Illust.x = -160 * 0x200;
Illust.act_no = 0;
// Modify cliprect
@@ -243,7 +247,7 @@
}
// Update credits
-void ActionCredit()
+void ActionCredit(void)
{
if (Credit.offset >= Credit.size)
return;
@@ -258,11 +262,12 @@
case 2:
if (--Credit.wait <= 0)
Credit.mode = 1;
+ break;
}
}
// Parse credits
-void ActionCredit_Read()
+void ActionCredit_Read(void)
{
int a, b, len;
char text[40];
@@ -429,7 +434,7 @@
}
// Slide illustration off-screen
-void CutCreditIllust()
+void CutCreditIllust(void)
{
Illust.act_no = 2;
}
@@ -437,8 +442,10 @@
// Scene of the island falling
int Scene_DownIsland(int mode)
{
+ int wait;
+
// Setup background
- RECT rc_frame = {(WINDOW_WIDTH - 160) / 2, (WINDOW_HEIGHT - 80) / 2, (WINDOW_WIDTH + 160) / 2, (WINDOW_HEIGHT + 80) / 2};
+ RECT rc_frame = {(WINDOW_WIDTH / 2) - 80, (WINDOW_HEIGHT / 2) - 40, (WINDOW_WIDTH / 2) + 80, (WINDOW_HEIGHT / 2) + 40};
RECT rc_sky = {0, 0, 160, 80};
RECT rc_ground = {160, 48, 320, 80};
@@ -446,10 +453,10 @@
RECT rc_sprite = {160, 0, 200, 24};
ISLAND_SPRITE sprite;
- sprite.x = 0x15000;
- sprite.y = 0x8000;
+ sprite.x = 168 * 0x200;
+ sprite.y = 64 * 0x200;
- for (int wait = 0; wait < 900; wait++)
+ for (wait = 0; wait < 900; ++wait)
{
// Get pressed keys
GetTrg();
@@ -500,9 +507,9 @@
// Draw scene
CortBox(&grcFull, 0);
- PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 80 + (WINDOW_HEIGHT - 240) / 2, &rc_sky, SURFACE_ID_LEVEL_SPRITESET_1);
- PutBitmap3(&rc_frame, sprite.x / 0x200 - 20 + (WINDOW_WIDTH - 320) / 2, sprite.y / 512 - 12 + (WINDOW_HEIGHT - 240) / 2, &rc_sprite, SURFACE_ID_LEVEL_SPRITESET_1);
- PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 128 + (WINDOW_HEIGHT - 240) / 2, &rc_ground, SURFACE_ID_LEVEL_SPRITESET_1);
+ PutBitmap3(&rc_frame, 80 + ((WINDOW_WIDTH - 320) / 2), 80 + ((WINDOW_HEIGHT - 240) / 2), &rc_sky, SURFACE_ID_LEVEL_SPRITESET_1);
+ PutBitmap3(&rc_frame, (sprite.x / 0x200) - 20 + ((WINDOW_WIDTH - 320) / 2), (sprite.y / 0x200) - 12 + ((WINDOW_HEIGHT - 240) / 2), &rc_sprite, SURFACE_ID_LEVEL_SPRITESET_1);
+ PutBitmap3(&rc_frame, 80 + ((WINDOW_WIDTH - 320) / 2), 128 + ((WINDOW_HEIGHT - 240) / 2), &rc_ground, SURFACE_ID_LEVEL_SPRITESET_1);
PutTimeCounter(16, 8);
// Draw window
--- a/src/Ending.h
+++ b/src/Ending.h
@@ -6,7 +6,7 @@
struct CREDIT
{
- int size;
+ long size;
char *pData;
int offset;
int wait;
@@ -37,19 +37,19 @@
#define MAX_STRIP ((WINDOW_HEIGHT / 16) + 1)
-void ActionStripper();
-void PutStripper();
+void ActionStripper(void);
+void PutStripper(void);
void SetStripper(int x, int y, const char *text, int cast);
-void RestoreStripper();
-void ActionIllust();
-void PutIllust();
+void RestoreStripper(void);
+void ActionIllust(void);
+void PutIllust(void);
void ReloadIllust(int a);
-void InitCreditScript();
-void ReleaseCreditScript();
-BOOL StartCreditScript();
-void ActionCredit();
-void ActionCredit_Read();
+void InitCreditScript(void);
+void ReleaseCreditScript(void);
+BOOL StartCreditScript(void);
+void ActionCredit(void);
+void ActionCredit_Read(void);
int GetScriptNumber(const char *text);
void SetCreditIllust(int a);
-void CutCreditIllust();
+void CutCreditIllust(void);
int Scene_DownIsland(int mode);
--- a/src/Escape.cpp
+++ b/src/Escape.cpp
@@ -34,7 +34,7 @@
// Draw screen
CortBox(&grcFull, 0x000000);
- PutBitmap3(&grcFull, (WINDOW_WIDTH - 208) / 2, (WINDOW_HEIGHT - 16) / 2, &rc, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) - 104, (WINDOW_HEIGHT / 2) - 8, &rc, SURFACE_ID_TEXT_BOX);
PutFramePerSecound();
if (!Flip_SystemTask())
--- a/src/Fade.cpp
+++ b/src/Fade.cpp
@@ -23,18 +23,18 @@
static FADE gFade;
static unsigned long mask_color;
-void InitFade()
+void InitFade(void)
{
memset(&gFade, 0, sizeof(FADE));
mask_color = GetCortBoxColor(RGB(0, 0, 0x20));
}
-void SetFadeMask()
+void SetFadeMask(void)
{
gFade.bMask = TRUE;
}
-void ClearFade()
+void ClearFade(void)
{
gFade.bMask = FALSE;
gFade.mode = 0;
@@ -42,14 +42,17 @@
void StartFadeOut(signed char dir)
{
+ int x;
+ int y;
+
gFade.mode = 2;
gFade.count = 0;
gFade.dir = dir;
gFade.bMask = FALSE;
- for (int y = 0; y < FADE_HEIGHT; y++)
+ for (y = 0; y < FADE_HEIGHT; ++y)
{
- for (int x = 0; x < FADE_WIDTH; x++)
+ for (x = 0; x < FADE_WIDTH; ++x)
{
gFade.ani_no[y][x] = 0;
gFade.flag[y][x] = FALSE;
@@ -67,9 +70,9 @@
gFade.dir = dir;
gFade.bMask = TRUE;
- for (y = 0; y < FADE_HEIGHT; y++)
+ for (y = 0; y < FADE_HEIGHT; ++y)
{
- for (x = 0; x < FADE_WIDTH; x++)
+ for (x = 0; x < FADE_WIDTH; ++x)
{
gFade.ani_no[y][x] = 15;
gFade.flag[y][x] = FALSE;
@@ -76,10 +79,10 @@
}
}
- x = x; // x is assigned to itself. Thanks, Pixel. (Most likely, the original code wasn't written the exact same way)
+ x = x; // This probably doesn't match the original source code, but it produces the same assembly
}
-void ProcFade()
+void ProcFade(void)
{
int x;
int y;
@@ -90,93 +93,65 @@
switch (gFade.dir)
{
case 0:
- for (y = 0; y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < FADE_WIDTH; x++)
- {
+ for (y = 0; y < FADE_HEIGHT; ++y)
+ for (x = 0; x < FADE_WIDTH; ++x)
if ((FADE_WIDTH - 1) - gFade.count == x)
gFade.flag[y][x] = TRUE;
- }
- }
+
break;
case 2:
- for (y = 0; y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < FADE_WIDTH; x++)
- {
+ for (y = 0; y < FADE_HEIGHT; ++y)
+ for (x = 0; x < FADE_WIDTH; ++x)
if (gFade.count == x)
gFade.flag[y][x] = TRUE;
- }
- }
+
break;
case 1:
- for (y = 0; y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < FADE_WIDTH; x++)
- {
+ for (y = 0; y < FADE_HEIGHT; ++y)
+ for (x = 0; x < FADE_WIDTH; ++x)
if ((FADE_HEIGHT - 1) - gFade.count == y)
gFade.flag[y][x] = TRUE;
- }
- }
+
break;
case 3:
- for (y = 0; y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < FADE_WIDTH; x++)
- {
+ for (y = 0; y < FADE_HEIGHT; ++y)
+ for (x = 0; x < FADE_WIDTH; ++x)
if (gFade.count == y)
gFade.flag[y][x] = TRUE;
- }
- }
+
break;
case 4:
- for (y = 0; y < (FADE_HEIGHT / 2); y++)
- {
- for (x = 0; x < (FADE_WIDTH / 2); x++)
- {
+ for (y = 0; y < (FADE_HEIGHT / 2); ++y)
+ for (x = 0; x < (FADE_WIDTH / 2); ++x)
if (gFade.count == x + y)
gFade.flag[y][x] = TRUE;
- }
- }
- for (y = 0; y < (FADE_HEIGHT / 2); y++)
- {
- for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
- {
+
+ for (y = 0; y < (FADE_HEIGHT / 2); ++y)
+ for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; ++x)
if (gFade.count == y + ((FADE_WIDTH - 1) - x))
gFade.flag[y][x] = TRUE;
- }
- }
- for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < (FADE_WIDTH / 2); x++)
- {
+
+ for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; ++y)
+ for (x = 0; x < (FADE_WIDTH / 2); ++x)
if (gFade.count == x + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = TRUE;
- }
- }
- for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
- {
- for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
- {
+
+ for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; ++y)
+ for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; ++x)
if (gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = TRUE;
- }
- }
+
break;
}
- for (y = 0; y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < FADE_WIDTH; x++)
- {
+ for (y = 0; y < FADE_HEIGHT; ++y)
+ for (x = 0; x < FADE_WIDTH; ++x)
if (gFade.ani_no[y][x] < 15 && gFade.flag[y][x])
++gFade.ani_no[y][x];
- }
- }
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
{
@@ -192,93 +167,65 @@
switch (gFade.dir)
{
case 0:
- for (y = 0; y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < FADE_WIDTH; x++)
- {
+ for (y = 0; y < FADE_HEIGHT; ++y)
+ for (x = 0; x < FADE_WIDTH; ++x)
if ((FADE_WIDTH - 1) - gFade.count == x)
gFade.flag[y][x] = TRUE;
- }
- }
+
break;
case 2:
- for (y = 0; y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < FADE_WIDTH; x++)
- {
+ for (y = 0; y < FADE_HEIGHT; ++y)
+ for (x = 0; x < FADE_WIDTH; ++x)
if (gFade.count == x)
gFade.flag[y][x] = TRUE;
- }
- }
+
break;
case 1:
- for (y = 0; y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < FADE_WIDTH; x++)
- {
+ for (y = 0; y < FADE_HEIGHT; ++y)
+ for (x = 0; x < FADE_WIDTH; ++x)
if ((FADE_HEIGHT - 1) - gFade.count == y)
gFade.flag[y][x] = TRUE;
- }
- }
+
break;
case 3:
- for (y = 0; y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < FADE_WIDTH; x++)
- {
+ for (y = 0; y < FADE_HEIGHT; ++y)
+ for (x = 0; x < FADE_WIDTH; ++x)
if (gFade.count == y)
gFade.flag[y][x] = TRUE;
- }
- }
+
break;
case 4:
- for (y = 0; y < (FADE_HEIGHT / 2); y++)
- {
- for (x = 0; x < (FADE_WIDTH / 2); x++)
- {
+ for (y = 0; y < (FADE_HEIGHT / 2); ++y)
+ for (x = 0; x < (FADE_WIDTH / 2); ++x)
if ((FADE_WIDTH - 1) - gFade.count == x + y)
gFade.flag[y][x] = TRUE;
- }
- }
- for (y = 0; y < (FADE_HEIGHT / 2); y++)
- {
- for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
- {
+
+ for (y = 0; y < (FADE_HEIGHT / 2); ++y)
+ for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; ++x)
if ((FADE_WIDTH - 1) - gFade.count == y + ((FADE_WIDTH - 1) - x))
gFade.flag[y][x] = TRUE;
- }
- }
- for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < (FADE_WIDTH / 2); x++)
- {
+
+ for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; ++y)
+ for (x = 0; x < (FADE_WIDTH / 2); ++x)
if ((FADE_WIDTH - 1) - gFade.count == x + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = TRUE;
- }
- }
- for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
- {
- for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
- {
+
+ for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; ++y)
+ for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; ++x)
if ((FADE_WIDTH - 1) - gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = TRUE;
- }
- }
+
break;
}
- for (y = 0; y < FADE_HEIGHT; y++)
- {
- for (x = 0; x < FADE_WIDTH; x++)
- {
+ for (y = 0; y < FADE_HEIGHT; ++y)
+ for (x = 0; x < FADE_WIDTH; ++x)
if (gFade.ani_no[y][x] > 0 && gFade.flag[y][x])
--gFade.ani_no[y][x];
- }
- }
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
gFade.mode = 0;
@@ -287,8 +234,11 @@
}
}
-void PutFade()
+void PutFade(void)
{
+ int x;
+ int y;
+
RECT rect;
rect.top = 0;
rect.bottom = 16;
@@ -302,18 +252,18 @@
if (gFade.mode == 0)
return;
- for (int y = 0; y < FADE_HEIGHT; y++)
+ for (y = 0; y < FADE_HEIGHT; ++y)
{
- for (int x = 0; x < FADE_WIDTH; x++)
+ for (x = 0; x < FADE_WIDTH; ++x)
{
- rect.left = 16 * gFade.ani_no[y][x];
+ rect.left = gFade.ani_no[y][x] * 16;
rect.right = rect.left + 16;
- PutBitmap3(&grcGame, 16 * x, 16 * y, &rect, SURFACE_ID_FADE);
+ PutBitmap3(&grcGame, x * 16, y * 16, &rect, SURFACE_ID_FADE);
}
}
}
-BOOL GetFadeActive()
+BOOL GetFadeActive(void)
{
if (gFade.mode == 0)
return FALSE;
--- a/src/Fade.h
+++ b/src/Fade.h
@@ -2,11 +2,11 @@
#include "WindowsWrapper.h"
-void InitFade();
-void SetFadeMask();
-void ClearFade();
+void InitFade(void);
+void SetFadeMask(void);
+void ClearFade(void);
void StartFadeOut(signed char dir);
void StartFadeIn(signed char dir);
-void ProcFade();
-void PutFade();
-BOOL GetFadeActive();
+void ProcFade(void);
+void PutFade(void);
+BOOL GetFadeActive(void);
--- a/src/Flags.cpp
+++ b/src/Flags.cpp
@@ -14,12 +14,12 @@
unsigned char gSkipFlag[8];
// Flag initializers
-void InitFlags()
+void InitFlags(void)
{
memset(gFlagNPC, 0, sizeof(gFlagNPC));
}
-void InitSkipFlags()
+void InitSkipFlags(void)
{
memset(gSkipFlag, 0, sizeof(gSkipFlag));
}
--- a/src/Flags.h
+++ b/src/Flags.h
@@ -5,8 +5,8 @@
extern unsigned char gFlagNPC[1000];
extern unsigned char gSkipFlag[8];
-void InitFlags();
-void InitSkipFlags();
+void InitFlags(void);
+void InitSkipFlags(void);
void SetNPCFlag(long a);
void CutNPCFlag(long a);
BOOL GetNPCFlag(long a);
--- a/src/Flash.cpp
+++ b/src/Flash.cpp
@@ -136,7 +136,7 @@
void ActFlash(int flx, int fly)
{
- if (flash.flag == FALSE)
+ if (!flash.flag)
return;
switch (flash.mode)
@@ -152,7 +152,7 @@
void PutFlash(void)
{
- if (flash.flag == FALSE)
+ if (!flash.flag)
return;
CortBox(&flash.rect1, gFlashColor);
--- a/src/Frame.cpp
+++ b/src/Frame.cpp
@@ -9,7 +9,7 @@
FRAME gFrame;
-void MoveFrame3()
+void MoveFrame3(void)
{
short map_w, map_l;
GetMapData(0, &map_w, &map_l);
@@ -18,8 +18,8 @@
if (g_GameFlags & 8)
{
// Use the original camera boundaries during the credits
- gFrame.x += (*gFrame.tgt_x - (320 * 0x100) - gFrame.x) / gFrame.wait;
- gFrame.y += (*gFrame.tgt_y - (240 * 0x100) - gFrame.y) / gFrame.wait;
+ gFrame.x += (*gFrame.tgt_x - (320 * 0x200 / 2) - gFrame.x) / gFrame.wait;
+ gFrame.y += (*gFrame.tgt_y - (240 * 0x200 / 2) - gFrame.y) / gFrame.wait;
if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
@@ -26,10 +26,10 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - 320) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - 320) * 0x200;
- if (gFrame.y > ((map_l - 1) * 0x10 - 240) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - 240) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - 320) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - 320) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - 240) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - 240) * 0x200;
gFrame.x -= ((WINDOW_WIDTH - 320) / 2) * 0x200;
gFrame.y -= ((WINDOW_HEIGHT - 240) / 2) * 0x200;
@@ -37,40 +37,40 @@
else
{
// Widescreen/tallscreen-safe behaviour
- if (map_w * 0x10 < WINDOW_WIDTH)
+ if (map_w * 16 < WINDOW_WIDTH)
{
- gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2);
+ gFrame.x = -(((WINDOW_WIDTH - ((map_w - 1) * 16)) * 0x200) / 2);
}
else
{
- gFrame.x += (*gFrame.tgt_x - (WINDOW_WIDTH * 0x100) - gFrame.x) / gFrame.wait;
+ gFrame.x += (*gFrame.tgt_x - (WINDOW_WIDTH * 0x200 / 2) - gFrame.x) / gFrame.wait;
if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
}
- if (map_l * 0x10 < WINDOW_HEIGHT)
+ if (map_l * 16 < WINDOW_HEIGHT)
{
- gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2);
+ gFrame.y = -(((WINDOW_HEIGHT - ((map_l - 1) * 16)) * 0x200) / 2);
}
else
{
- gFrame.y += (*gFrame.tgt_y - (WINDOW_HEIGHT * 0x100) - gFrame.y) / gFrame.wait;
+ gFrame.y += (*gFrame.tgt_y - (WINDOW_HEIGHT * 0x200 / 2) - gFrame.y) / gFrame.wait;
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
}
}
#else
// Vanilla behaviour
- gFrame.x += (*gFrame.tgt_x - (WINDOW_WIDTH * 0x100) - gFrame.x) / gFrame.wait;
- gFrame.y += (*gFrame.tgt_y - (WINDOW_HEIGHT * 0x100) - gFrame.y) / gFrame.wait;
+ gFrame.x += (*gFrame.tgt_x - (WINDOW_WIDTH * 0x200 / 2) - gFrame.x) / gFrame.wait;
+ gFrame.y += (*gFrame.tgt_y - (WINDOW_HEIGHT * 0x200 / 2) - gFrame.y) / gFrame.wait;
if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
@@ -77,10 +77,10 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200;
- if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
#endif
// Quake
@@ -97,7 +97,7 @@
--gFrame.quake;
}
- // This code exists in the Linux port, but not the Windows version
+ // This code exists in the Linux port (v1.0.0.4), but not the Windows version (v1.0.0.6)
/* if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
if (gFrame.y / 0x200 < 0)
@@ -133,10 +133,10 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - 320) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - 320) * 0x200;
- if (gFrame.y > ((map_l - 1) * 0x10 - 240) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - 240) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - 320) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - 320) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - 240) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - 240) * 0x200;
gFrame.x -= ((WINDOW_WIDTH - 320) / 2) * 0x200;
gFrame.y -= ((WINDOW_HEIGHT - 240) / 2) * 0x200;
@@ -144,9 +144,9 @@
else
{
// Widescreen/tallscreen-safe behaviour
- if (map_w * 0x10 < WINDOW_WIDTH)
+ if (map_w * 16 < WINDOW_WIDTH)
{
- gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2);
+ gFrame.x = -(((WINDOW_WIDTH - ((map_w - 1) * 16)) * 0x200) / 2);
}
else
{
@@ -153,13 +153,13 @@
if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
}
- if (map_l * 0x10 < WINDOW_HEIGHT)
+ if (map_l * 16 < WINDOW_HEIGHT)
{
- gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2);
+ gFrame.y = -(((WINDOW_HEIGHT - ((map_l - 1) * 16)) * 0x200) / 2);
}
else
{
@@ -166,8 +166,8 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
}
}
#else
@@ -177,14 +177,14 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200)
- gFrame.x = (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200;
- if (gFrame.y > (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200)
- gFrame.y = (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
#endif
}
-void SetFrameMyChar()
+void SetFrameMyChar(void)
{
// Move frame position
int mc_x, mc_y;
@@ -193,8 +193,8 @@
short map_w, map_l;
GetMapData(0, &map_w, &map_l);
- gFrame.x = mc_x - (WINDOW_WIDTH << 8);
- gFrame.y = mc_y - (WINDOW_HEIGHT << 8);
+ gFrame.x = mc_x - ((WINDOW_WIDTH / 2) * 0x200);
+ gFrame.y = mc_y - ((WINDOW_HEIGHT / 2) * 0x200);
// Keep in bounds
#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240
@@ -206,10 +206,10 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - 320) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - 320) * 0x200;
- if (gFrame.y > ((map_l - 1) * 0x10 - 240) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - 240) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - 320) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - 320) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - 240) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - 240) * 0x200;
gFrame.x -= ((WINDOW_WIDTH - 320) / 2) * 0x200;
gFrame.y -= ((WINDOW_HEIGHT - 240) / 2) * 0x200;
@@ -217,9 +217,9 @@
else
{
// Widescreen/tallscreen-safe behaviour
- if (map_w * 0x10 < WINDOW_WIDTH)
+ if (map_w * 16 < WINDOW_WIDTH)
{
- gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2);
+ gFrame.x = -(((WINDOW_WIDTH - ((map_w - 1) * 16)) * 0x200) / 2);
}
else
{
@@ -226,13 +226,13 @@
if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
}
- if (map_l * 0x10 < WINDOW_HEIGHT)
+ if (map_l * 16 < WINDOW_HEIGHT)
{
- gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2);
+ gFrame.y = -(((WINDOW_HEIGHT - ((map_l - 1) * 16)) * 0x200) / 2);
}
else
{
@@ -239,8 +239,8 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
}
}
#else
@@ -250,10 +250,10 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200)
- gFrame.x = (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200;
- if (gFrame.y > (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200)
- gFrame.y = (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
#endif
}
@@ -267,7 +267,7 @@
void SetFrameTargetNpChar(int event, int wait)
{
int i;
- for (i = 0; i < NPC_MAX; i++)
+ for (i = 0; i < NPC_MAX; ++i)
if (gNPC[i].code_event == event)
break;
@@ -296,7 +296,7 @@
gFrame.quake2 = time;
}
-void ResetQuake()
+void ResetQuake(void)
{
gFrame.quake = 0;
gFrame.quake2 = 0;
--- a/src/Frame.h
+++ b/src/Frame.h
@@ -13,13 +13,13 @@
extern FRAME gFrame;
-void MoveFrame3();
+void MoveFrame3(void);
void GetFramePosition(int *fx, int *fy);
void SetFramePosition(int fx, int fy);
-void SetFrameMyChar();
+void SetFrameMyChar(void);
void SetFrameTargetMyChar(int wait);
void SetFrameTargetNpChar(int event, int wait);
void SetFrameTargetBoss(int no, int wait);
void SetQuake(int time);
void SetQuake2(int time);
-void ResetQuake();
+void ResetQuake(void);
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -55,7 +55,7 @@
int Random(int min, int max)
{
const int range = max - min + 1;
- return min + msvc_rand() % range;
+ return (msvc_rand() % range) + min;
}
void PutNumber4(int x, int y, int value, BOOL bZero)
@@ -394,19 +394,19 @@
CortBox(&grcGame, back_color);
// Draw version
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 120) / 2, WINDOW_HEIGHT - 24, &rcVersion, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 8) / 2, WINDOW_HEIGHT - 24, &rcPeriod, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 60, WINDOW_HEIGHT - 24, &rcVersion, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 4, WINDOW_HEIGHT - 24, &rcPeriod, SURFACE_ID_TEXT_BOX);
- PutNumber4((WINDOW_WIDTH - 40) / 2, WINDOW_HEIGHT - 24, v1, FALSE);
- PutNumber4((WINDOW_WIDTH - 8) / 2, WINDOW_HEIGHT - 24, v2, FALSE);
- PutNumber4((WINDOW_WIDTH + 24) / 2, WINDOW_HEIGHT - 24, v3, FALSE);
- PutNumber4((WINDOW_WIDTH + 56) / 2, WINDOW_HEIGHT - 24, v4, FALSE);
+ PutNumber4((WINDOW_WIDTH / 2) - 20, WINDOW_HEIGHT - 24, v1, FALSE);
+ PutNumber4((WINDOW_WIDTH / 2) - 4, WINDOW_HEIGHT - 24, v2, FALSE);
+ PutNumber4((WINDOW_WIDTH / 2) + 12, WINDOW_HEIGHT - 24, v3, FALSE);
+ PutNumber4((WINDOW_WIDTH / 2) + 28, WINDOW_HEIGHT - 24, v4, FALSE);
// Draw main title
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 144) / 2, 40, &rcTitle, SURFACE_ID_TITLE);
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 16) / 2, &rcNew, SURFACE_ID_TITLE);
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 56) / 2, &rcContinue, SURFACE_ID_TITLE);
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 160) / 2, WINDOW_HEIGHT - 48, &rcPixel, SURFACE_ID_PIXEL);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 72, 40, &rcTitle, SURFACE_ID_TITLE);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 24, (WINDOW_HEIGHT / 2) + 8, &rcNew, SURFACE_ID_TITLE);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 24, (WINDOW_HEIGHT / 2) + 28, &rcContinue, SURFACE_ID_TITLE);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 80, WINDOW_HEIGHT - 48, &rcPixel, SURFACE_ID_PIXEL);
// Draw character cursor
switch (char_type)
@@ -434,15 +434,15 @@
}
if (!bContinue)
- char_y = (WINDOW_HEIGHT + 14) / 2;
+ char_y = (WINDOW_HEIGHT / 2) + 7;
else
- char_y = (WINDOW_HEIGHT + 54) / 2;
+ char_y = (WINDOW_HEIGHT / 2) + 27;
// Pixel being redundant
if (!bContinue)
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 88) / 2, char_y, &char_rc, char_surf);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 44, char_y, &char_rc, char_surf);
else
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 88) / 2, char_y, &char_rc, char_surf);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 44, char_y, &char_rc, char_surf);
// Draw carets
PutCaret(0, 0);
@@ -509,7 +509,7 @@
if (bContinue)
{
- if (!LoadProfile(NULL) && !InitializeGame()) // ...Shouldn't that '&&' be a '||'?
+ if (!LoadProfile(NULL) && !InitializeGame())
return 0;
}
else
@@ -656,7 +656,7 @@
{
PutMyLife(TRUE);
PutArmsEnergy(TRUE);
- PutMyAir((WINDOW_WIDTH - 80) / 2, (WINDOW_HEIGHT - 32) / 2);
+ PutMyAir((WINDOW_WIDTH / 2) - 40, (WINDOW_HEIGHT / 2) - 16);
PutActiveArmsList();
}
--- a/src/Generic.cpp
+++ b/src/Generic.cpp
@@ -147,7 +147,7 @@
fread(str, 1, len, fp);
fclose(fp);
- if (memcmp(str, extra_text, len) != 0)
+ if (memcmp(str, extra_text, len))
return FALSE;
else
return TRUE;
--- a/src/GenericLoad.cpp
+++ b/src/GenericLoad.cpp
@@ -153,7 +153,7 @@
{1, 1000, {0, 20.0, 0, 0}, {0, 0.0, 0, 0}, {0, 0.0, 0, 0}, 0, 64, 0, 128, 0, 255, 0}
};
-BOOL LoadGenericData()
+BOOL LoadGenericData(void)
{
char str[0x40];
BOOL bError;
@@ -192,112 +192,108 @@
MakeSurface_Resource("CREDIT01", SURFACE_ID_CREDITS_IMAGE);
if (bError)
- {
return FALSE;
- }
- else
- {
- MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_SCREEN_GRAB, TRUE);
- MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_BACKGROUND, FALSE);
- MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_MAP, TRUE);
- MakeSurface_Generic(320, 240, SURFACE_ID_CASTS, FALSE);
- MakeSurface_Generic(256, 256, SURFACE_ID_LEVEL_TILESET, FALSE);
- MakeSurface_Generic(160, 16, SURFACE_ID_ROOM_NAME, FALSE);
- MakeSurface_Generic(40, 240, SURFACE_ID_VALUE_VIEW, FALSE);
- MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_1, FALSE);
- MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_2, FALSE);
- MakeSurface_Generic(320, 16 * MAX_STRIP, SURFACE_ID_CREDIT_CAST, FALSE);
- pt_size = 0;
- pt_size += MakePixToneObject(&gPtpTable[0], 2, 32);
- pt_size += MakePixToneObject(&gPtpTable[2], 2, 33);
- pt_size += MakePixToneObject(&gPtpTable[4], 2, 34);
- pt_size += MakePixToneObject(&gPtpTable[6], 1, 15);
- pt_size += MakePixToneObject(&gPtpTable[7], 1, 24);
- pt_size += MakePixToneObject(&gPtpTable[8], 1, 23);
- pt_size += MakePixToneObject(&gPtpTable[9], 2, 50);
- pt_size += MakePixToneObject(&gPtpTable[11], 2, 51);
- pt_size += MakePixToneObject(&gPtpTable[33], 1, 1);
- pt_size += MakePixToneObject(&gPtpTable[38], 1, 2);
- pt_size += MakePixToneObject(&gPtpTable[56], 1, 29);
- pt_size += MakePixToneObject(&gPtpTable[61], 1, 43);
- pt_size += MakePixToneObject(&gPtpTable[62], 3, 44);
- pt_size += MakePixToneObject(&gPtpTable[65], 1, 45);
- pt_size += MakePixToneObject(&gPtpTable[66], 1, 46);
- pt_size += MakePixToneObject(&gPtpTable[68], 1, 47);
- pt_size += MakePixToneObject(&gPtpTable[49], 3, 35);
- pt_size += MakePixToneObject(&gPtpTable[52], 3, 39);
- pt_size += MakePixToneObject(&gPtpTable[13], 2, 52);
- pt_size += MakePixToneObject(&gPtpTable[28], 2, 53);
- pt_size += MakePixToneObject(&gPtpTable[15], 2, 70);
- pt_size += MakePixToneObject(&gPtpTable[17], 2, 71);
- pt_size += MakePixToneObject(&gPtpTable[19], 2, 72);
- pt_size += MakePixToneObject(&gPtpTable[30], 1, 5);
- pt_size += MakePixToneObject(&gPtpTable[32], 1, 11);
- pt_size += MakePixToneObject(&gPtpTable[35], 1, 4);
- pt_size += MakePixToneObject(&gPtpTable[46], 2, 25);
- pt_size += MakePixToneObject(&gPtpTable[48], 1, 27);
- pt_size += MakePixToneObject(&gPtpTable[54], 2, 28);
- pt_size += MakePixToneObject(&gPtpTable[39], 1, 14);
- pt_size += MakePixToneObject(&gPtpTable[23], 2, 16);
- pt_size += MakePixToneObject(&gPtpTable[25], 3, 17);
- pt_size += MakePixToneObject(&gPtpTable[34], 1, 18);
- pt_size += MakePixToneObject(&gPtpTable[36], 2, 20);
- pt_size += MakePixToneObject(&gPtpTable[31], 1, 22);
- pt_size += MakePixToneObject(&gPtpTable[41], 2, 26);
- pt_size += MakePixToneObject(&gPtpTable[43], 1, 21);
- pt_size += MakePixToneObject(&gPtpTable[44], 2, 12);
- pt_size += MakePixToneObject(&gPtpTable[57], 2, 38);
- pt_size += MakePixToneObject(&gPtpTable[59], 1, 31);
- pt_size += MakePixToneObject(&gPtpTable[60], 1, 42);
- pt_size += MakePixToneObject(&gPtpTable[69], 1, 48);
- pt_size += MakePixToneObject(&gPtpTable[70], 2, 49);
- pt_size += MakePixToneObject(&gPtpTable[72], 1, 100);
- pt_size += MakePixToneObject(&gPtpTable[73], 3, 101);
- pt_size += MakePixToneObject(&gPtpTable[76], 2, 54);
- pt_size += MakePixToneObject(&gPtpTable[78], 2, 102);
- pt_size += MakePixToneObject(&gPtpTable[80], 2, 103);
- pt_size += MakePixToneObject(&gPtpTable[81], 1, 104);
- pt_size += MakePixToneObject(&gPtpTable[82], 1, 105);
- pt_size += MakePixToneObject(&gPtpTable[83], 2, 106);
- pt_size += MakePixToneObject(&gPtpTable[85], 1, 107);
- pt_size += MakePixToneObject(&gPtpTable[86], 1, 30);
- pt_size += MakePixToneObject(&gPtpTable[87], 1, 108);
- pt_size += MakePixToneObject(&gPtpTable[88], 1, 109);
- pt_size += MakePixToneObject(&gPtpTable[89], 1, 110);
- pt_size += MakePixToneObject(&gPtpTable[90], 1, 111);
- pt_size += MakePixToneObject(&gPtpTable[91], 1, 112);
- pt_size += MakePixToneObject(&gPtpTable[92], 1, 113);
- pt_size += MakePixToneObject(&gPtpTable[93], 2, 114);
- pt_size += MakePixToneObject(&gPtpTable[95], 2, 150);
- pt_size += MakePixToneObject(&gPtpTable[97], 2, 151);
- pt_size += MakePixToneObject(&gPtpTable[99], 1, 152);
- pt_size += MakePixToneObject(&gPtpTable[100], 1, 153);
- pt_size += MakePixToneObject(&gPtpTable[101], 2, 154);
- pt_size += MakePixToneObject(&gPtpTable[111], 2, 155);
- pt_size += MakePixToneObject(&gPtpTable[103], 2, 56);
- pt_size += MakePixToneObject(&gPtpTable[105], 2, 40);
- pt_size += MakePixToneObject(&gPtpTable[105], 2, 41);
- pt_size += MakePixToneObject(&gPtpTable[107], 2, 37);
- pt_size += MakePixToneObject(&gPtpTable[109], 2, 57);
- pt_size += MakePixToneObject(&gPtpTable[113], 3, 115);
- pt_size += MakePixToneObject(&gPtpTable[116], 1, 104);
- pt_size += MakePixToneObject(&gPtpTable[117], 3, 116);
- pt_size += MakePixToneObject(&gPtpTable[120], 2, 58);
- pt_size += MakePixToneObject(&gPtpTable[122], 2, 55);
- pt_size += MakePixToneObject(&gPtpTable[124], 2, 117);
- pt_size += MakePixToneObject(&gPtpTable[126], 1, 59);
- pt_size += MakePixToneObject(&gPtpTable[127], 1, 60);
- pt_size += MakePixToneObject(&gPtpTable[128], 1, 61);
- pt_size += MakePixToneObject(&gPtpTable[129], 2, 62);
- pt_size += MakePixToneObject(&gPtpTable[131], 2, 63);
- pt_size += MakePixToneObject(&gPtpTable[133], 2, 64);
- pt_size += MakePixToneObject(&gPtpTable[135], 1, 65);
- pt_size += MakePixToneObject(&gPtpTable[136], 1, 3);
- pt_size += MakePixToneObject(&gPtpTable[137], 1, 6);
- pt_size += MakePixToneObject(&gPtpTable[138], 1, 7);
- sprintf(str, "PixTone = %d byte", pt_size);
- // There must have been some kind of console print function here or something
- return TRUE;
- }
+ MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_SCREEN_GRAB, TRUE);
+ MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_BACKGROUND, FALSE);
+ MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_MAP, TRUE);
+ MakeSurface_Generic(320, 240, SURFACE_ID_CASTS, FALSE);
+ MakeSurface_Generic(256, 256, SURFACE_ID_LEVEL_TILESET, FALSE);
+ MakeSurface_Generic(160, 16, SURFACE_ID_ROOM_NAME, FALSE);
+ MakeSurface_Generic(40, 240, SURFACE_ID_VALUE_VIEW, FALSE);
+ MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_1, FALSE);
+ MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_2, FALSE);
+ MakeSurface_Generic(320, 16 * (MAX_STRIP - 1), SURFACE_ID_CREDIT_CAST, FALSE);
+
+ pt_size = 0;
+ pt_size += MakePixToneObject(&gPtpTable[0], 2, 32);
+ pt_size += MakePixToneObject(&gPtpTable[2], 2, 33);
+ pt_size += MakePixToneObject(&gPtpTable[4], 2, 34);
+ pt_size += MakePixToneObject(&gPtpTable[6], 1, 15);
+ pt_size += MakePixToneObject(&gPtpTable[7], 1, 24);
+ pt_size += MakePixToneObject(&gPtpTable[8], 1, 23);
+ pt_size += MakePixToneObject(&gPtpTable[9], 2, 50);
+ pt_size += MakePixToneObject(&gPtpTable[11], 2, 51);
+ pt_size += MakePixToneObject(&gPtpTable[33], 1, 1);
+ pt_size += MakePixToneObject(&gPtpTable[38], 1, 2);
+ pt_size += MakePixToneObject(&gPtpTable[56], 1, 29);
+ pt_size += MakePixToneObject(&gPtpTable[61], 1, 43);
+ pt_size += MakePixToneObject(&gPtpTable[62], 3, 44);
+ pt_size += MakePixToneObject(&gPtpTable[65], 1, 45);
+ pt_size += MakePixToneObject(&gPtpTable[66], 1, 46);
+ pt_size += MakePixToneObject(&gPtpTable[68], 1, 47);
+ pt_size += MakePixToneObject(&gPtpTable[49], 3, 35);
+ pt_size += MakePixToneObject(&gPtpTable[52], 3, 39);
+ pt_size += MakePixToneObject(&gPtpTable[13], 2, 52);
+ pt_size += MakePixToneObject(&gPtpTable[28], 2, 53);
+ pt_size += MakePixToneObject(&gPtpTable[15], 2, 70);
+ pt_size += MakePixToneObject(&gPtpTable[17], 2, 71);
+ pt_size += MakePixToneObject(&gPtpTable[19], 2, 72);
+ pt_size += MakePixToneObject(&gPtpTable[30], 1, 5);
+ pt_size += MakePixToneObject(&gPtpTable[32], 1, 11);
+ pt_size += MakePixToneObject(&gPtpTable[35], 1, 4);
+ pt_size += MakePixToneObject(&gPtpTable[46], 2, 25);
+ pt_size += MakePixToneObject(&gPtpTable[48], 1, 27);
+ pt_size += MakePixToneObject(&gPtpTable[54], 2, 28);
+ pt_size += MakePixToneObject(&gPtpTable[39], 1, 14);
+ pt_size += MakePixToneObject(&gPtpTable[23], 2, 16);
+ pt_size += MakePixToneObject(&gPtpTable[25], 3, 17);
+ pt_size += MakePixToneObject(&gPtpTable[34], 1, 18);
+ pt_size += MakePixToneObject(&gPtpTable[36], 2, 20);
+ pt_size += MakePixToneObject(&gPtpTable[31], 1, 22);
+ pt_size += MakePixToneObject(&gPtpTable[41], 2, 26);
+ pt_size += MakePixToneObject(&gPtpTable[43], 1, 21);
+ pt_size += MakePixToneObject(&gPtpTable[44], 2, 12);
+ pt_size += MakePixToneObject(&gPtpTable[57], 2, 38);
+ pt_size += MakePixToneObject(&gPtpTable[59], 1, 31);
+ pt_size += MakePixToneObject(&gPtpTable[60], 1, 42);
+ pt_size += MakePixToneObject(&gPtpTable[69], 1, 48);
+ pt_size += MakePixToneObject(&gPtpTable[70], 2, 49);
+ pt_size += MakePixToneObject(&gPtpTable[72], 1, 100);
+ pt_size += MakePixToneObject(&gPtpTable[73], 3, 101);
+ pt_size += MakePixToneObject(&gPtpTable[76], 2, 54);
+ pt_size += MakePixToneObject(&gPtpTable[78], 2, 102);
+ pt_size += MakePixToneObject(&gPtpTable[80], 2, 103);
+ pt_size += MakePixToneObject(&gPtpTable[81], 1, 104);
+ pt_size += MakePixToneObject(&gPtpTable[82], 1, 105);
+ pt_size += MakePixToneObject(&gPtpTable[83], 2, 106);
+ pt_size += MakePixToneObject(&gPtpTable[85], 1, 107);
+ pt_size += MakePixToneObject(&gPtpTable[86], 1, 30);
+ pt_size += MakePixToneObject(&gPtpTable[87], 1, 108);
+ pt_size += MakePixToneObject(&gPtpTable[88], 1, 109);
+ pt_size += MakePixToneObject(&gPtpTable[89], 1, 110);
+ pt_size += MakePixToneObject(&gPtpTable[90], 1, 111);
+ pt_size += MakePixToneObject(&gPtpTable[91], 1, 112);
+ pt_size += MakePixToneObject(&gPtpTable[92], 1, 113);
+ pt_size += MakePixToneObject(&gPtpTable[93], 2, 114);
+ pt_size += MakePixToneObject(&gPtpTable[95], 2, 150);
+ pt_size += MakePixToneObject(&gPtpTable[97], 2, 151);
+ pt_size += MakePixToneObject(&gPtpTable[99], 1, 152);
+ pt_size += MakePixToneObject(&gPtpTable[100], 1, 153);
+ pt_size += MakePixToneObject(&gPtpTable[101], 2, 154);
+ pt_size += MakePixToneObject(&gPtpTable[111], 2, 155);
+ pt_size += MakePixToneObject(&gPtpTable[103], 2, 56);
+ pt_size += MakePixToneObject(&gPtpTable[105], 2, 40);
+ pt_size += MakePixToneObject(&gPtpTable[105], 2, 41);
+ pt_size += MakePixToneObject(&gPtpTable[107], 2, 37);
+ pt_size += MakePixToneObject(&gPtpTable[109], 2, 57);
+ pt_size += MakePixToneObject(&gPtpTable[113], 3, 115);
+ pt_size += MakePixToneObject(&gPtpTable[116], 1, 104);
+ pt_size += MakePixToneObject(&gPtpTable[117], 3, 116);
+ pt_size += MakePixToneObject(&gPtpTable[120], 2, 58);
+ pt_size += MakePixToneObject(&gPtpTable[122], 2, 55);
+ pt_size += MakePixToneObject(&gPtpTable[124], 2, 117);
+ pt_size += MakePixToneObject(&gPtpTable[126], 1, 59);
+ pt_size += MakePixToneObject(&gPtpTable[127], 1, 60);
+ pt_size += MakePixToneObject(&gPtpTable[128], 1, 61);
+ pt_size += MakePixToneObject(&gPtpTable[129], 2, 62);
+ pt_size += MakePixToneObject(&gPtpTable[131], 2, 63);
+ pt_size += MakePixToneObject(&gPtpTable[133], 2, 64);
+ pt_size += MakePixToneObject(&gPtpTable[135], 1, 65);
+ pt_size += MakePixToneObject(&gPtpTable[136], 1, 3);
+ pt_size += MakePixToneObject(&gPtpTable[137], 1, 6);
+ pt_size += MakePixToneObject(&gPtpTable[138], 1, 7);
+ sprintf(str, "PixTone = %d byte", pt_size);
+ // There must have been some kind of console print function here or something
+ return TRUE;
}
--- a/src/GenericLoad.h
+++ b/src/GenericLoad.h
@@ -2,4 +2,4 @@
#include "WindowsWrapper.h"
-BOOL LoadGenericData();
+BOOL LoadGenericData(void);
--- a/src/Input.cpp
+++ b/src/Input.cpp
@@ -39,8 +39,10 @@
// The original name for this function is unknown
BOOL HookAllDirectInputDevices(void)
{
+ int i;
+
// Open first available joystick
- for (int i = 0; i < SDL_NumJoysticks(); i++)
+ for (i = 0; i < SDL_NumJoysticks(); ++i)
{
joystick = SDL_JoystickOpen(i);
--- a/src/KeyControl.cpp
+++ b/src/KeyControl.cpp
@@ -18,7 +18,7 @@
long gKeyRight = KEY_RIGHT;
long gKeyDown = KEY_DOWN;
-void GetTrg()
+void GetTrg(void)
{
static int key_old;
gKeyTrg = gKey ^ key_old;
--- a/src/KeyControl.h
+++ b/src/KeyControl.h
@@ -52,4 +52,4 @@
extern long gKeyRight;
extern long gKeyDown;
-void GetTrg();
+void GetTrg(void);
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -158,7 +158,7 @@
}
// Set gamepad inputs
- for (i = 0; i < 8; i++)
+ for (i = 0; i < 8; ++i)
{
switch (conf.joystick_button[i])
{
@@ -277,7 +277,7 @@
// Draw loading screen
CortBox(&rcFull, 0x000000);
- PutBitmap3(&rcFull, (WINDOW_WIDTH - 64) / 2, (WINDOW_HEIGHT - 8) / 2, &rcLoading, SURFACE_ID_LOADING);
+ PutBitmap3(&rcFull, (WINDOW_WIDTH / 2) - 32, (WINDOW_HEIGHT / 2) - 4, &rcLoading, SURFACE_ID_LOADING);
// Draw to screen
if (!Flip_SystemTask())
@@ -287,35 +287,33 @@
SDL_DestroyWindow(window);
return 1;
}
- else
- {
- // Initialize sound
- InitDirectSound();
- // Initialize joystick
- if (conf.bJoystick && InitDirectInput())
- {
- ResetJoystickStatus();
- gbUseJoystick = TRUE;
- }
+ // Initialize sound
+ InitDirectSound();
- // Initialize stuff
- InitTextObject(conf.font_name);
- InitTriangleTable();
+ // Initialize joystick
+ if (conf.bJoystick && InitDirectInput())
+ {
+ ResetJoystickStatus();
+ gbUseJoystick = TRUE;
+ }
- // Run game code
- Game();
+ // Initialize stuff
+ InitTextObject(conf.font_name);
+ InitTriangleTable();
- // End stuff
- EndTextObject();
- EndDirectSound();
- EndDirectDraw();
+ // Run game code
+ Game();
- SDL_FreeCursor(cursor);
- SDL_FreeSurface(cursor_surface);
- SDL_DestroyWindow(window);
- }
+ // End stuff
+ EndTextObject();
+ EndDirectSound();
+ EndDirectDraw();
+ SDL_FreeCursor(cursor);
+ SDL_FreeSurface(cursor_surface);
+ SDL_DestroyWindow(window);
+
return 1;
}
@@ -601,13 +599,11 @@
gKey &= ~gKeyDown;
// Clear held buttons
- for (i = 0; i < 8; i++)
+ for (i = 0; i < 8; ++i)
gKey &= ~gJoystickButtonTable[i];
// Set held buttons
- for (i = 0; i < 8; i++)
- {
+ for (i = 0; i < 8; ++i)
if (status.bButton[i])
gKey |= gJoystickButtonTable[i];
- }
}
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -19,7 +19,7 @@
static const char *code_pxma = "PXM";
-BOOL InitMapData2()
+BOOL InitMapData2(void)
{
gMap.data = (unsigned char*)malloc(PXM_BUFFER_SIZE);
return TRUE;
@@ -42,33 +42,27 @@
char check[3];
fread(check, 1, 3, fp);
- if (memcmp(check, code_pxma, 3) != 0)
+ if (memcmp(check, code_pxma, 3))
{
fclose(fp);
return FALSE;
}
- else
- {
- fread(&dum, 1, 1, fp);
- // Get width and height
- gMap.width = File_ReadLE16(fp);
- gMap.length = File_ReadLE16(fp);
- if (gMap.data == NULL)
- {
- fclose(fp);
- return FALSE;
- }
- else
- {
- // Read tile data
- fread(gMap.data, 1, gMap.length * gMap.width, fp);
- fclose(fp);
- return TRUE;
- }
+ fread(&dum, 1, 1, fp);
+ // Get width and height
+ gMap.width = File_ReadLE16(fp);
+ gMap.length = File_ReadLE16(fp);
+
+ if (gMap.data == NULL)
+ {
+ fclose(fp);
+ return FALSE;
}
- return FALSE;
+ // Read tile data
+ fread(gMap.data, 1, gMap.width * gMap.length, fp);
+ fclose(fp);
+ return TRUE;
}
BOOL LoadAttributeData(const char *path_atrb)
@@ -82,17 +76,17 @@
return FALSE;
// Read data
- fread(gMap.atrb, 1, 0x100, fp);
+ fread(gMap.atrb, 1, sizeof(gMap.atrb), fp);
fclose(fp);
return TRUE;
}
-void EndMapData()
+void EndMapData(void)
{
free(gMap.data);
}
-void ReleasePartsImage()
+void ReleasePartsImage(void)
{
ReleaseSurface(SURFACE_ID_LEVEL_TILESET);
}
@@ -99,11 +93,13 @@
void GetMapData(unsigned char **data, short *mw, short *ml)
{
- if (data)
+ if (data != NULL)
*data = gMap.data;
- if (mw)
+
+ if (mw != NULL)
*mw = gMap.width;
- if (ml)
+
+ if (ml != NULL)
*ml = gMap.length;
}
@@ -112,7 +108,7 @@
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
+ const size_t 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];
}
@@ -128,13 +124,15 @@
BOOL ChangeMapParts(int x, int y, unsigned char no)
{
+ int i;
+
if (*(gMap.data + x + (y * gMap.width)) == no)
return FALSE;
*(gMap.data + x + (y * gMap.width)) = no;
- for (int i = 0; i < 3; i++)
- SetNpChar(4, x * 0x200 * 0x10, y * 0x200 * 0x10, 0, 0, 0, 0, 0);
+ for (i = 0; i < 3; ++i)
+ SetNpChar(4, x * 0x200 * 0x10, y * 0x200 * 0x10, 0, 0, 0, NULL, 0);
return TRUE;
}
@@ -154,15 +152,15 @@
// 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;
+ put_x = ((fx / 0x200) + 8) / 16;
+ put_y = ((fy / 0x200) + 8) / 16;
- for (j = put_y; j < put_y + num_y; j++)
+ for (j = put_y; j < put_y + num_y; ++j)
{
- for (i = put_x; i < put_x + num_x; i++)
+ for (i = put_x; i < put_x + num_x; ++i)
{
// Get attribute
- offset = i + j * gMap.width;
+ offset = (j * gMap.width) + i;
atrb = GetAttribute(i, j);
if (atrb >= 0x20)
@@ -169,12 +167,12 @@
continue;
// Draw tile
- rect.left = 16 * (gMap.data[offset] % 16);
- rect.top = 16 * (gMap.data[offset] / 16);
+ rect.left = (gMap.data[offset] % 16) * 16;
+ rect.top = (gMap.data[offset] / 16) * 16;
rect.right = rect.left + 16;
rect.bottom = rect.top + 16;
- PutBitmap3(&grcGame, (i * 16 - 8) - (fx / 0x200), (j * 16 - 8) - (fy / 0x200), &rect, SURFACE_ID_LEVEL_TILESET);
+ PutBitmap3(&grcGame, ((i * 16) - 8) - (fx / 0x200), ((j * 16) - 8) - (fy / 0x200), &rect, SURFACE_ID_LEVEL_TILESET);
}
}
}
@@ -195,15 +193,15 @@
// 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;
+ put_x = ((fx / 0x200) + 8) / 16;
+ put_y = ((fy / 0x200) + 8) / 16;
- for (j = put_y; j < put_y + num_y; j++)
+ for (j = put_y; j < put_y + num_y; ++j)
{
- for (i = put_x; i < put_x + num_x; i++)
+ for (i = put_x; i < put_x + num_x; ++i)
{
// Get attribute
- offset = i + j * gMap.width;
+ offset = (j * gMap.width) + i;
atrb = GetAttribute(i, j);
if (atrb < 0x40 || atrb >= 0x80)
@@ -210,15 +208,15 @@
continue;
// Draw tile
- rect.left = 16 * (gMap.data[offset] % 16);
- rect.top = 16 * (gMap.data[offset] / 16);
+ rect.left = (gMap.data[offset] % 16) * 16;
+ rect.top = (gMap.data[offset] / 16) * 16;
rect.right = rect.left + 16;
rect.bottom = rect.top + 16;
- PutBitmap3(&grcGame, (i * 16 - 8) - (fx / 0x200), (j * 16 - 8) - (fy / 0x200), &rect, SURFACE_ID_LEVEL_TILESET);
+ PutBitmap3(&grcGame, ((i * 16) - 8) - (fx / 0x200), ((j * 16) - 8) - (fy / 0x200), &rect, SURFACE_ID_LEVEL_TILESET);
if (atrb == 0x43)
- PutBitmap3(&grcGame, (i * 16 - 8) - (fx / 0x200), (j * 16 - 8) - (fy / 0x200), &rcSnack, SURFACE_ID_NPC_SYM);
+ PutBitmap3(&grcGame, ((i * 16) - 8) - (fx / 0x200), ((j * 16) - 8) - (fy / 0x200), &rcSnack, SURFACE_ID_NPC_SYM);
}
}
}
@@ -242,15 +240,15 @@
// 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;
+ put_x = ((fx / 0x200) + 8) / 16;
+ put_y = ((fy / 0x200) + 8) / 16;
- for (j = put_y; j < put_y + num_y; j++)
+ for (j = put_y; j < put_y + num_y; ++j)
{
- for (i = put_x; i < put_x + num_x; i++)
+ for (i = put_x; i < put_x + num_x; ++i)
{
// Get attribute
- offset = i + j * gMap.width;
+ offset = (j * gMap.width) + i;
atrb = GetAttribute(i, j);
if (atrb != 0x80
@@ -272,6 +270,7 @@
rect.top = 48;
rect.bottom = rect.top + 16;
break;
+
case 129:
case 161:
rect.left = 224;
@@ -279,6 +278,7 @@
rect.top = 48 + (count % 16);
rect.bottom = rect.top + 16;
break;
+
case 130:
case 162:
rect.left = 240 - (count % 16);
@@ -286,6 +286,7 @@
rect.top = 48;
rect.bottom = rect.top + 16;
break;
+
case 131:
case 163:
rect.left = 224;
@@ -295,7 +296,7 @@
break;
}
- PutBitmap3(&grcGame, (i * 16 - 8) - (fx / 0x200), (j * 16 - 8) - (fy / 0x200), &rect, SURFACE_ID_CARET);
+ PutBitmap3(&grcGame, ((i * 16) - 8) - (fx / 0x200), ((j * 16) - 8) - (fy / 0x200), &rect, SURFACE_ID_CARET);
}
}
}
--- a/src/Map.h
+++ b/src/Map.h
@@ -2,21 +2,21 @@
#include "WindowsWrapper.h"
-struct MAP_DATA
+typedef struct MAP_DATA
{
unsigned char *data;
- unsigned char atrb[0x101]; //Why is this 257 bytes?
+ unsigned char atrb[0x100];
short width;
short length;
-};
+} MAP_DATA;
extern MAP_DATA gMap;
-BOOL InitMapData2();
+BOOL InitMapData2(void);
BOOL LoadMapData2(const char *path_map);
BOOL LoadAttributeData(const char *path_atrb);
-void EndMapData();
-void ReleasePartsImage();
+void EndMapData(void);
+void ReleasePartsImage(void);
void GetMapData(unsigned char **data, short *mw, short *ml);
unsigned char GetAttribute(int x, int y);
void DeleteMapParts(int x, int y);
--- a/src/MapName.cpp
+++ b/src/MapName.cpp
@@ -6,6 +6,13 @@
#include "Draw.h"
#include "WindowsWrapper.h"
+typedef struct MAP_NAME
+{
+ BOOL flag;
+ int wait;
+ char name[0x20];
+} MAP_NAME;
+
MAP_NAME gMapName;
RECT rc = { 0, 0, 160, 12 };
@@ -67,7 +74,7 @@
};
// Reset map name flags
- gMapName.flag = 0;
+ gMapName.flag = FALSE;
gMapName.wait = 0;
if (!strcmp(str, "u"))
@@ -84,13 +91,13 @@
// Draw the text to the surface
a = (int)strlen(gMapName.name);
CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
- PutText2((160 - 6 * a) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
- PutText2((160 - 6 * a) / 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);
}
void PutMapName(BOOL bMini)
{
- // 'unused_rect' isn't the original name. The Linux port optimised this out, so there's no name for it.
+ // 'unused_rect' isn't the original name. The Linux port optimised this out, so there's no known name for it.
RECT unused_rect = {0, 0, 160, 16};
if (bMini)
@@ -103,28 +110,28 @@
rcBack.bottom = 24;
CortBox(&rcBack, 0x000000);
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, 10, &rc, SURFACE_ID_ROOM_NAME);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 86, 10, &rc, SURFACE_ID_ROOM_NAME);
}
else if (gMapName.flag)
{
// MNA
- PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, (WINDOW_HEIGHT - 80) / 2, &rc, SURFACE_ID_ROOM_NAME);
+ PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 86, (WINDOW_HEIGHT / 2) - 40, &rc, SURFACE_ID_ROOM_NAME);
if (++gMapName.wait > 160)
- gMapName.flag = 0;
+ gMapName.flag = FALSE;
}
}
-void StartMapName()
+void StartMapName(void)
{
- gMapName.flag = 1;
+ gMapName.flag = TRUE;
gMapName.wait = 0;
}
-void RestoreMapName()
+void RestoreMapName(void)
{
int len = (int)strlen(gMapName.name);
CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
- PutText2((160 - 6 * len) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
- PutText2((160 - 6 * len) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), 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);
}
--- a/src/MapName.h
+++ b/src/MapName.h
@@ -2,14 +2,7 @@
#include "WindowsWrapper.h"
-struct MAP_NAME
-{
- int flag;
- int wait;
- char name[0x20];
-};
-
void ReadyMapName(const char *str);
void PutMapName(BOOL bMini);
-void StartMapName();
-void RestoreMapName();
+void StartMapName(void);
+void RestoreMapName(void);
--- a/src/MiniMap.cpp
+++ b/src/MiniMap.cpp
@@ -28,11 +28,11 @@
{243, 24, 244, 25},
};
- for (x = 0; x < gMap.width; x++)
+ for (x = 0; x < gMap.width; ++x)
{
a = GetAttribute(x, line);
- // Yup. This really is an if/else chain.
+ // Yup, this really is an if/else chain.
// No switch here.
if (a == 0)
Surface2Surface(x, line, &rcLevel[0], SURFACE_ID_MAP, SURFACE_ID_TEXT_BOX);
@@ -75,7 +75,7 @@
}
}
-int MiniMapLoop()
+int MiniMapLoop(void)
{
int f;
int line;
@@ -85,10 +85,10 @@
RECT rcView;
RECT my_rect = {0, 57, 1, 58};
- int my_x = (gMC.x / 0x200 + 8) / 16;
- int my_y = (gMC.y / 0x200 + 8) / 16;
+ int my_x = ((gMC.x / 0x200) + 8) / 16;
+ int my_y = ((gMC.y / 0x200) + 8) / 16;
- for (f = 0; f <= 8; f++)
+ for (f = 0; f <= 8; ++f)
{
GetTrg();
@@ -105,10 +105,10 @@
PutBitmap4(&grcGame, 0, 0, &grcGame, SURFACE_ID_SCREEN_GRAB);
- rcView.left = (WINDOW_WIDTH / 2) - gMap.width * f / 8 / 2;
- rcView.right = (WINDOW_WIDTH / 2) + gMap.width * f / 8 / 2;
- rcView.top = (WINDOW_HEIGHT / 2) - gMap.length * f / 8 / 2;
- rcView.bottom = (WINDOW_HEIGHT / 2) + gMap.length * f / 8 / 2;
+ rcView.left = (WINDOW_WIDTH / 2) - (((gMap.width * f) / 8) / 2);
+ rcView.right = (WINDOW_WIDTH / 2) + (((gMap.width * f) / 8) / 2);
+ rcView.top = (WINDOW_HEIGHT / 2) - (((gMap.length * f) / 8) / 2);
+ rcView.bottom = (WINDOW_HEIGHT / 2) + (((gMap.length * f) / 8) / 2);
PutMapName(TRUE);
CortBox(&rcView, 0);
@@ -133,7 +133,7 @@
{
GetTrg();
- if ((gKeyCancel | gKeyOk) & gKeyTrg)
+ if (gKeyTrg & (gKeyOk | gKeyCancel))
break;
if (gKey & KEY_ESCAPE)
@@ -153,12 +153,14 @@
if (line < gMap.length)
{
WriteMiniMapLine(line);
- line++;
+ ++line;
}
+ // I guess Pixel duplicated this block of code because he
+ // wanted the minimap to draw faster?
if (line < gMap.length)
{
WriteMiniMapLine(line);
- line++;
+ ++line;
}
PutBitmap3(&grcGame, rcView.left + 1, rcView.top + 1, &rcMiniMap, SURFACE_ID_MAP);
@@ -190,10 +192,10 @@
PutBitmap4(&grcGame, 0, 0, &grcGame, SURFACE_ID_SCREEN_GRAB);
- rcView.left = (WINDOW_WIDTH / 2) - gMap.width * f / 8 / 2;
- rcView.right = (WINDOW_WIDTH / 2) + gMap.width * f / 8 / 2;
- rcView.top = (WINDOW_HEIGHT / 2) - gMap.length * f / 8 / 2;
- rcView.bottom = (WINDOW_HEIGHT / 2) + gMap.length * f / 8 / 2;
+ rcView.left = (WINDOW_WIDTH / 2) - (((gMap.width * f) / 8) / 2);
+ rcView.right = (WINDOW_WIDTH / 2) + (((gMap.width * f) / 8) / 2);
+ rcView.top = (WINDOW_HEIGHT / 2) - (((gMap.length * f) / 8) / 2);
+ rcView.bottom = (WINDOW_HEIGHT / 2) + (((gMap.length * f) / 8) / 2);
PutMapName(TRUE);
CortBox(&rcView, 0);
@@ -206,15 +208,15 @@
return 1;
}
-BOOL IsMapping()
+BOOL IsMapping(void)
{
- if (gMapping[gStageNo] == FALSE)
+ if (!gMapping[gStageNo])
return FALSE;
else
return TRUE;
}
-void StartMapping()
+void StartMapping(void)
{
memset(gMapping, FALSE, sizeof(gMapping));
}
--- a/src/MiniMap.h
+++ b/src/MiniMap.h
@@ -4,7 +4,7 @@
extern char gMapping[0x80];
-int MiniMapLoop();
-BOOL IsMapping();
-void StartMapping();
+int MiniMapLoop(void);
+BOOL IsMapping(void);
+void StartMapping(void);
void SetMapping(int a);
--- a/src/MyChar.cpp
+++ b/src/MyChar.cpp
@@ -22,21 +22,21 @@
int noise_no;
unsigned int noise_freq;
-void InitMyChar()
+void InitMyChar(void)
{
memset(&gMC, 0, sizeof(MYCHAR));
gMC.cond = 0x80;
gMC.direct = 2;
- gMC.view.back = 0x1000;
- gMC.view.top = 0x1000;
- gMC.view.front = 0x1000;
- gMC.view.bottom = 0x1000;
+ gMC.view.back = 8 * 0x200;
+ gMC.view.top = 8 * 0x200;
+ gMC.view.front = 8 * 0x200;
+ gMC.view.bottom = 8 * 0x200;
- gMC.hit.back = 0xA00;
- gMC.hit.top = 0x1000;
- gMC.hit.front = 0xA00;
- gMC.hit.bottom = 0x1000;
+ gMC.hit.back = 5 * 0x200;
+ gMC.hit.top = 8 * 0x200;
+ gMC.hit.front = 5 * 0x200;
+ gMC.hit.bottom = 8 * 0x200;
gMC.life = 3;
gMC.max_life = 3;
@@ -84,7 +84,7 @@
{
gMC.ani_no = 11;
}
- else if (gKey & gKeyUp && (gKeyRight | gKeyLeft) & gKey && bKey)
+ else if (gKey & gKeyUp && gKey & (gKeyLeft | gKeyRight) && bKey)
{
gMC.cond |= 4;
@@ -91,6 +91,7 @@
if (++gMC.ani_wait > 4)
{
gMC.ani_wait = 0;
+
if (++gMC.ani_no == 7 || gMC.ani_no == 9)
PlaySoundObject(24, 1);
}
@@ -98,7 +99,7 @@
if (gMC.ani_no > 9 || gMC.ani_no < 6)
gMC.ani_no = 6;
}
- else if ((gKeyRight | gKeyLeft) & gKey && bKey)
+ else if (gKey & (gKeyLeft | gKeyRight) && bKey)
{
gMC.cond |= 4;
@@ -105,6 +106,7 @@
if (++gMC.ani_wait > 4)
{
gMC.ani_wait = 0;
+
if (++gMC.ani_no == 2 || gMC.ani_no == 4)
PlaySoundObject(24, 1);
}
@@ -163,13 +165,13 @@
{
int arms_offset_y;
- if ((gMC.cond & 0x80) == 0 || (gMC.cond & 2))
+ if (!(gMC.cond & 0x80) || gMC.cond & 2)
return;
// Draw weapon
- gMC.rect_arms.left = 24 * (gArmsData[gSelectedArms].code % 13);
+ gMC.rect_arms.left = (gArmsData[gSelectedArms].code % 13) * 24;
gMC.rect_arms.right = gMC.rect_arms.left + 24;
- gMC.rect_arms.top = 96 * (gArmsData[gSelectedArms].code / 13);
+ gMC.rect_arms.top = (gArmsData[gSelectedArms].code / 13) * 96;
gMC.rect_arms.bottom = gMC.rect_arms.top + 16;
if (gMC.direct == 2)
@@ -201,19 +203,19 @@
if (gMC.direct == 0)
PutBitmap3(
&grcGame,
- (gMC.x - gMC.view.front) / 0x200 - fx / 0x200 - 8,
- (gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y,
+ ((gMC.x - gMC.view.front) / 0x200) - (fx / 0x200) - 8,
+ ((gMC.y - gMC.view.top) / 0x200) - (fy / 0x200) + arms_offset_y,
&gMC.rect_arms,
SURFACE_ID_ARMS);
else
PutBitmap3(
&grcGame,
- (gMC.x - gMC.view.front) / 0x200 - fx / 0x200,
- (gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y,
+ ((gMC.x - gMC.view.front) / 0x200) - (fx / 0x200),
+ ((gMC.y - gMC.view.top) / 0x200) - (fy / 0x200) + arms_offset_y,
&gMC.rect_arms,
SURFACE_ID_ARMS);
- if ((gMC.shock / 2) % 2)
+ if (gMC.shock / 2 % 2)
return;
// Draw player
@@ -224,7 +226,7 @@
rect.bottom += 32;
}
- PutBitmap3(&grcGame, (gMC.x - gMC.view.front) / 0x200 - fx / 0x200, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200, &rect, SURFACE_ID_MY_CHAR);
+ PutBitmap3(&grcGame, ((gMC.x - gMC.view.front) / 0x200) - (fx / 0x200), ((gMC.y - gMC.view.top) / 0x200) - (fy / 0x200), &rect, SURFACE_ID_MY_CHAR);
// Draw air tank
RECT rcBubble[2] = {
@@ -234,9 +236,9 @@
++gMC.bubble;
if (gMC.equip & 0x10 && gMC.flag & 0x100)
- PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble / 2) % 2], SURFACE_ID_CARET);
+ PutBitmap3(&grcGame, (gMC.x / 0x200) - 12 - (fx / 0x200), (gMC.y / 0x200) - 12 - (fy / 0x200), &rcBubble[gMC.bubble / 2 % 2], SURFACE_ID_CARET);
else if (gMC.unit == 1)
- PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble / 2) % 2], SURFACE_ID_CARET);
+ PutBitmap3(&grcGame, (gMC.x / 0x200) - 12 - (fx / 0x200), (gMC.y / 0x200) - 12 - (fy / 0x200), &rcBubble[gMC.bubble / 2 % 2], SURFACE_ID_CARET);
}
void ActMyChar_Normal(BOOL bKey)
@@ -281,7 +283,7 @@
}
// Don't create "?" effect
- gMC.ques = 0;
+ gMC.ques = FALSE;
// If can't control player, stop boosting
if (!bKey)
@@ -309,14 +311,14 @@
// Move in direction held
if (bKey)
{
- if (gKeyTrg == gKeyDown && gKey == gKeyDown && (gMC.cond & 1) == 0 && (g_GameFlags & 4) == 0)
+ if (gKeyTrg == gKeyDown && gKey == gKeyDown && !(gMC.cond & 1) && !(g_GameFlags & 4))
{
gMC.cond |= 1;
- gMC.ques = 1;
+ gMC.ques = TRUE;
}
else if (gKey == gKeyDown)
{
-
+ // There probably used to be commented-out code here
}
else
{
@@ -356,12 +358,13 @@
// Start boosting
if (bKey)
{
- if (gMC.equip & 0x21 && gKeyTrg & gKeyJump && gMC.boost_cnt)
+ if (gMC.equip & 0x21 && gKeyTrg & gKeyJump && gMC.boost_cnt != 0)
{
// Booster 0.8
if (gMC.equip & 1)
{
gMC.boost_sw = 1;
+
if (gMC.ym > 0x100)
gMC.ym /= 2;
}
@@ -415,7 +418,7 @@
}
// Slow down when stopped boosting (Booster 2.0)
- if (gMC.equip & 0x20 && gMC.boost_sw && (!(gKey & gKeyJump) || !gMC.boost_cnt))
+ if (gMC.equip & 0x20 && gMC.boost_sw != 0 && (!(gKey & gKeyJump) || gMC.boost_cnt == 0))
{
if (gMC.boost_sw == 1)
gMC.xm /= 2;
@@ -424,7 +427,7 @@
}
// Stop boosting
- if (!gMC.boost_cnt || !(gKey & gKeyJump))
+ if (gMC.boost_cnt == 0 || !(gKey & gKeyJump))
gMC.boost_sw = 0;
}
@@ -437,17 +440,17 @@
else
gMC.up = FALSE;
- if (gKey & gKeyDown && (gMC.flag & 8) == 0)
+ if (gKey & gKeyDown && !(gMC.flag & 8))
gMC.down = TRUE;
else
gMC.down = FALSE;
- if (gKeyTrg & gKeyJump
- && (gMC.flag & 8 || gMC.flag & 0x10 || gMC.flag & 0x20))
+ if (gKeyTrg & gKeyJump && (gMC.flag & 8 || gMC.flag & 0x10 || gMC.flag & 0x20))
{
if (gMC.flag & 0x2000)
{
- // Another weird empty case needed for accurate assembly
+ // Another weird empty case needed for accurate assembly.
+ // There probably used to be some commented-out code here.
}
else
{
@@ -458,11 +461,11 @@
}
// Stop interacting when moved
- if (bKey && (gKeyShot | gKeyJump | gKeyUp | gKeyRight | gKeyLeft) & gKey)
+ if (bKey && gKey & (gKeyLeft | gKeyRight | gKeyUp | gKeyJump | gKeyShot))
gMC.cond &= ~1;
// Booster losing fuel
- if (gMC.boost_sw && gMC.boost_cnt)
+ if (gMC.boost_sw != 0 && gMC.boost_cnt != 0)
--gMC.boost_cnt;
// Wind / current forces
@@ -476,7 +479,7 @@
gMC.ym += 0x55;
// Booster 2.0 forces and effects
- if (gMC.equip & 0x20 && gMC.boost_sw)
+ if (gMC.equip & 0x20 && gMC.boost_sw != 0)
{
if (gMC.boost_sw == 1)
{
@@ -485,7 +488,7 @@
gMC.ym = -0x100;
// Move in direction facing
- if (!gMC.direct)
+ if (gMC.direct == 0)
gMC.xm -= 0x20;
if (gMC.direct == 2)
gMC.xm += 0x20;
@@ -493,10 +496,10 @@
// Boost particles (and sound)
if (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1)
{
- if (!gMC.direct)
- SetCaret(gMC.x + 0x400, gMC.y + 0x400, 7, 2);
+ if (gMC.direct == 0)
+ SetCaret(gMC.x + (2 * 0x200), gMC.y + (2 * 0x200), 7, 2);
if (gMC.direct == 2)
- SetCaret(gMC.x - 0x400, gMC.y + 0x400, 7, 0);
+ SetCaret(gMC.x - (2 * 0x200), gMC.y + (2 * 0x200), 7, 0);
PlaySoundObject(113, 1);
}
@@ -509,7 +512,7 @@
// Boost particles (and sound)
if (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1)
{
- SetCaret(gMC.x, gMC.y + 0xC00, 7, 3);
+ SetCaret(gMC.x, gMC.y + (6 * 0x200), 7, 3);
PlaySoundObject(113, 1);
}
}
@@ -516,7 +519,7 @@
else if (gMC.boost_sw == 3 && (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1))
{
// Boost particles (and sound)
- SetCaret(gMC.x, gMC.y - 0xC00, 7, 1);
+ SetCaret(gMC.x, gMC.y - (6 * 0x200), 7, 1);
PlaySoundObject(113, 1);
}
}
@@ -526,14 +529,14 @@
gMC.ym += gravity1;
}
// Booster 0.8
- else if (gMC.equip & 1 && gMC.boost_sw && gMC.ym > -0x400)
+ else if (gMC.equip & 1 && gMC.boost_sw != 0 && gMC.ym > -0x400)
{
// Upwards force
gMC.ym -= 0x20;
- if (!(gMC.boost_cnt % 3))
+ if (gMC.boost_cnt % 3 == 0)
{
- SetCaret(gMC.x, gMC.hit.bottom / 2 + gMC.y, 7, 3);
+ SetCaret(gMC.x, gMC.y + (gMC.hit.bottom / 2), 7, 3);
PlaySoundObject(113, 1);
}
@@ -569,13 +572,13 @@
if (0)
{
- // There used to be an if here that didn't do anything, but the compiler optimised it out.
- // We only know this was here because empty ifs mess with the register usage.
+ // There used to be an if-statement here that didn't do anything, but the compiler optimised it out.
+ // We only know this was here because empty if-statements affect the register usage.
// Since there's no code, we have no idea what the original condition actually was.
}
// Limit speed
- if ((gMC.flag & 0x100) && (gMC.flag & 0xF000) == 0)
+ if (gMC.flag & 0x100 && !(gMC.flag & 0xF000))
{
if (gMC.xm < -0x2FF)
gMC.xm = -0x2FF;
@@ -602,17 +605,18 @@
if (!gMC.sprash && gMC.flag & 0x100)
{
int dir;
+
if (gMC.flag & 0x800)
dir = 2;
else
dir = 0;
- if ((gMC.flag & 8) == 0 && gMC.ym > 0x200)
+ if (!(gMC.flag & 8) && gMC.ym > 0x200)
{
- for (a = 0; a < 8; a++)
+ for (a = 0; a < 8; ++a)
{
x = gMC.x + (Random(-8, 8) * 0x200);
- SetNpChar(73, x, gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80) - gMC.ym / 2, dir, 0, 0);
+ SetNpChar(73, x, gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80) - (gMC.ym / 2), dir, NULL, 0);
}
PlaySoundObject(56, 1);
@@ -621,10 +625,10 @@
{
if (gMC.xm > 0x200 || gMC.xm < -0x200)
{
- for (a = 0; a < 8; a++)
+ for (a = 0; a < 8; ++a)
{
x = gMC.x + (Random(-8, 8) * 0x200);
- SetNpChar(73, x, gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80), dir, 0, 0);
+ SetNpChar(73, x, gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80), dir, NULL, 0);
}
PlaySoundObject(56, 1);
@@ -631,11 +635,11 @@
}
}
- gMC.sprash = 1;
+ gMC.sprash = TRUE;
}
if (!(gMC.flag & 0x100))
- gMC.sprash = 0;
+ gMC.sprash = FALSE;
// Spike damage
if (gMC.flag & 0x400)
@@ -697,7 +701,7 @@
if (bKey)
{
- if (gKey & (gKeyRight | gKeyLeft))
+ if (gKey & (gKeyLeft | gKeyRight))
{
if (gKey & gKeyLeft)
gMC.xm -= 0x100;
@@ -718,7 +722,7 @@
gMC.xm += 0x80;
}
- if (gKey & (gKeyDown | gKeyUp))
+ if (gKey & (gKeyUp | gKeyDown))
{
if (gKey & gKeyUp)
gMC.ym -= 0x100;
@@ -759,7 +763,7 @@
if (gMC.ym < -0x200 && gMC.flag & 2)
SetCaret(gMC.x, gMC.y - gMC.hit.top, 13, 5);
if (gMC.ym > 0x200 && gMC.flag & 8)
- SetCaret(gMC.x, gMC.hit.bottom + gMC.y, 13, 5);
+ SetCaret(gMC.x, gMC.y + gMC.hit.bottom, 13, 5);
if (gMC.xm > 0x400)
gMC.xm = 0x400;
@@ -771,7 +775,7 @@
if (gMC.ym < -0x400)
gMC.ym = -0x400;
- if ((gKey & (gKeyUp | gKeyLeft)) == (gKeyLeft | gKeyUp))
+ if ((gKey & (gKeyLeft | gKeyUp)) == (gKeyLeft | gKeyUp))
{
if (gMC.xm < -780)
gMC.xm = -780;
@@ -779,7 +783,7 @@
gMC.ym = -780;
}
- if ((gKey & (gKeyUp | gKeyRight)) == (gKeyRight | gKeyUp))
+ if ((gKey & (gKeyRight | gKeyUp)) == (gKeyRight | gKeyUp))
{
if (gMC.xm > 780)
gMC.xm = 780;
@@ -787,7 +791,7 @@
gMC.ym = -780;
}
- if ((gKey & (gKeyDown | gKeyLeft)) == (gKeyLeft | gKeyDown))
+ if ((gKey & (gKeyLeft | gKeyDown)) == (gKeyLeft | gKeyDown))
{
if (gMC.xm < -780)
gMC.xm = -780;
@@ -795,7 +799,7 @@
gMC.ym = 780;
}
- if ((gKey & (gKeyDown | gKeyRight)) == (gKeyRight | gKeyDown))
+ if ((gKey & (gKeyRight | gKeyDown)) == (gKeyRight | gKeyDown))
{
if (gMC.xm > 780)
gMC.xm = 780;
@@ -807,7 +811,7 @@
gMC.y += gMC.ym;
}
-void AirProcess()
+void AirProcess(void)
{
if (gMC.equip & 0x10)
{
@@ -816,7 +820,7 @@
}
else
{
- if ((gMC.flag & 0x100) == 0)
+ if (!(gMC.flag & 0x100))
{
gMC.air = 1000;
}
@@ -848,9 +852,10 @@
{
gMC.air_get = 60;
}
- else if (gMC.air_get)
+ else
{
- --gMC.air_get;
+ if (gMC.air_get != 0)
+ --gMC.air_get;
}
}
}
@@ -857,17 +862,17 @@
void ActMyChar(BOOL bKey)
{
- if ((gMC.cond & 0x80) == 0)
+ if (!(gMC.cond & 0x80))
return;
- if (gMC.exp_wait)
+ if (gMC.exp_wait != 0)
--gMC.exp_wait;
- if (gMC.shock)
+ if (gMC.shock != 0)
{
--gMC.shock;
}
- else if (gMC.exp_count)
+ else if (gMC.exp_count != 0)
{
SetValueView(&gMC.x, &gMC.y, gMC.exp_count);
gMC.exp_count = 0;
@@ -878,6 +883,7 @@
case 0:
if (!(g_GameFlags & 4) && bKey)
AirProcess();
+
ActMyChar_Normal(bKey);
break;
@@ -915,12 +921,12 @@
gMC.y = y;
}
-void ZeroMyCharXMove()
+void ZeroMyCharXMove(void)
{
gMC.xm = 0;
}
-int GetUnitMyChar()
+int GetUnitMyChar(void)
{
return gMC.unit;
}
@@ -942,7 +948,8 @@
else
{
int i;
- for (i = 0; i < NPC_MAX; i++)
+
+ for (i = 0; i < NPC_MAX; ++i)
if (gNPC[i].code_event == dir)
break;
@@ -965,9 +972,9 @@
gMC.unit = a;
}
-void PitMyChar()
+void PitMyChar(void)
{
- gMC.y += 0x4000;
+ gMC.y += 2 * 0x10 * 0x200; // Shove player two tiles down. I wonder what this was meant for?
}
void EquipItem(int flag, BOOL b)
@@ -978,7 +985,7 @@
gMC.equip &= ~flag;
}
-void ResetCheck()
+void ResetCheck(void)
{
gMC.cond &= ~1;
}
@@ -1003,7 +1010,7 @@
}
}
-void CutNoise()
+void CutNoise(void)
{
noise_no = 0;
PlaySoundObject(40, 0);
@@ -1011,7 +1018,7 @@
PlaySoundObject(58, 0);
}
-void ResetNoise()
+void ResetNoise(void)
{
switch (noise_no)
{
@@ -1028,7 +1035,7 @@
}
}
-void SleepNoise()
+void SleepNoise(void)
{
PlaySoundObject(40, 0);
PlaySoundObject(41, 0);
--- a/src/MyChar.h
+++ b/src/MyChar.h
@@ -2,6 +2,9 @@
#include "WindowsWrapper.h"
+// TODO - When I add bitmask constants for gMC.flags...
+// 0x100 is a 'player is underwater' flag
+
struct MYCHAR
{
unsigned char cond;
@@ -52,8 +55,8 @@
int lifeBr_count;
int air;
int air_get;
- signed char sprash;
- signed char ques;
+ signed char sprash; // This is explicitly a char, but used like a BOOL
+ signed char ques; // Same for this variable as well
signed char boost_sw;
int boost_cnt;
};
@@ -60,7 +63,7 @@
extern MYCHAR gMC;
-void InitMyChar();
+void InitMyChar(void);
void AnimationMyChar(BOOL bKey);
void ShowMyChar(BOOL bShow);
void PutMyChar(int fx, int fy);
@@ -69,14 +72,14 @@
void GetMyCharPosition(int *x, int *y);
void SetMyCharPosition(int x, int y);
void MoveMyChar(int x, int y);
-void ZeroMyCharXMove();
-int GetUnitMyChar();
+void ZeroMyCharXMove(void);
+int GetUnitMyChar(void);
void SetMyCharDirect(unsigned char dir);
void ChangeMyUnit(unsigned char a);
-void PitMyChar();
+void PitMyChar(void);
void EquipItem(int flag, BOOL b);
-void ResetCheck();
+void ResetCheck(void);
void SetNoise(int no, int freq);
-void CutNoise();
-void ResetNoise();
-void SleepNoise();
+void CutNoise(void);
+void ResetNoise(void);
+void SleepNoise(void);
--- a/src/MycHit.cpp
+++ b/src/MycHit.cpp
@@ -14,12 +14,12 @@
#include "Sound.h"
#include "TextScr.h"
-void ResetMyCharFlag()
+void ResetMyCharFlag(void)
{
gMC.flag = 0;
}
-void PutlittleStar()
+void PutlittleStar(void)
{
if (!(gMC.cond & 2) && gMC.ym < -0x200)
{
@@ -407,7 +407,7 @@
return hit;
}
-void HitMyCharMap()
+void HitMyCharMap(void)
{
int i;
@@ -428,7 +428,7 @@
offy[3] = 1;
unsigned char atrb[4];
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; ++i)
{
atrb[i] = GetAttribute(x + offx[i], y + offy[i]);
@@ -581,7 +581,7 @@
}
}
- if (gMC.y > gWaterY + 0x800)
+ if (gMC.y > gWaterY + (4 * 0x200))
gMC.flag |= 0x100;
}
@@ -589,8 +589,8 @@
{
int hit = 0;
- if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom - 0x600
- && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top + 0x600
+ if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom - (3 * 0x200)
+ && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top + (3 * 0x200)
&& gMC.x - gMC.hit.back < npc->x + npc->hit.back
&& gMC.x - gMC.hit.back > npc->x)
{
@@ -599,8 +599,8 @@
hit |= 1;
}
- if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom - 0x600
- && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top + 0x600
+ if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom - (3 * 0x200)
+ && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top + (3 * 0x200)
&& gMC.x + gMC.hit.back - 0x200 > npc->x - npc->hit.back
&& gMC.x + gMC.hit.back - 0x200 < npc->x)
{
@@ -609,8 +609,8 @@
hit |= 4;
}
- if (gMC.x - gMC.hit.back < npc->x + npc->hit.back - 0x600
- && gMC.x + gMC.hit.back > npc->x - npc->hit.back + 0x600
+ if (gMC.x - gMC.hit.back < npc->x + npc->hit.back - (3 * 0x200)
+ && gMC.x + gMC.hit.back > npc->x - npc->hit.back + (3 * 0x200)
&& gMC.y - gMC.hit.top < npc->y + npc->hit.bottom
&& gMC.y - gMC.hit.top > npc->y)
{
@@ -619,10 +619,10 @@
hit |= 2;
}
- if (gMC.x - gMC.hit.back < npc->x + npc->hit.back - 0x600
- && gMC.x + gMC.hit.back > npc->x - npc->hit.back + 0x600
+ if (gMC.x - gMC.hit.back < npc->x + npc->hit.back - (3 * 0x200)
+ && gMC.x + gMC.hit.back > npc->x - npc->hit.back + (3 * 0x200)
&& gMC.y + gMC.hit.bottom > npc->y - npc->hit.top
- && gMC.hit.bottom + gMC.y < npc->y + 0x600)
+ && gMC.hit.bottom + gMC.y < npc->y + (3 * 0x200))
{
if (npc->bits & NPC_BOUNCY)
{
@@ -637,6 +637,7 @@
hit |= 8;
}
}
+
return hit;
}
@@ -644,18 +645,18 @@
{
if (npc->direct == 0)
{
- if (gMC.x + 0x400 > npc->x - npc->hit.front
- && gMC.x - 0x400 < npc->x + npc->hit.back
- && gMC.y + 0x400 > npc->y - npc->hit.top
- && gMC.y - 0x400 < npc->y + npc->hit.bottom)
+ if (gMC.x + (2 * 0x200) > npc->x - npc->hit.front
+ && gMC.x - (2 * 0x200) < npc->x + npc->hit.back
+ && gMC.y + (2 * 0x200) > npc->y - npc->hit.top
+ && gMC.y - (2 * 0x200) < npc->y + npc->hit.bottom)
return 1;
}
else
{
- if (gMC.x + 0x400 > npc->x - npc->hit.back
- && gMC.x - 0x400 < npc->x + npc->hit.front
- && gMC.y + 0x400 > npc->y - npc->hit.top
- && gMC.y - 0x400 < npc->y + npc->hit.bottom)
+ if (gMC.x + (2 * 0x200) > npc->x - npc->hit.back
+ && gMC.x - (2 * 0x200) < npc->x + npc->hit.front
+ && gMC.y + (2 * 0x200) > npc->y - npc->hit.top
+ && gMC.y - (2 * 0x200) < npc->y + npc->hit.bottom)
return 1;
}
@@ -698,7 +699,7 @@
{
if (gMC.ym < npc->ym)
{
- gMC.y = npc->hit.bottom + npc->y + gMC.hit.top + 0x200;
+ gMC.y = npc->y + npc->hit.bottom + gMC.hit.top + 0x200;
gMC.ym = npc->ym;
}
else
@@ -710,9 +711,9 @@
hit |= 2;
}
- if (gMC.y + gMC.hit.bottom > npc->y - npc->hit.top && gMC.hit.bottom + gMC.y < npc->y + 0x600)
+ if (gMC.y + gMC.hit.bottom > npc->y - npc->hit.top && gMC.hit.bottom + gMC.y < npc->y + (3 * 0x200))
{
- if (gMC.ym - npc->ym > 0x400)
+ if (gMC.ym - npc->ym > 2 * 0x200)
PlaySoundObject(23, 1);
if (gMC.unit == 1)
@@ -744,7 +745,7 @@
if (gMC.xm < npc->xm)
gMC.xm = npc->xm;
- gMC.x = npc->hit.back + npc->x + gMC.hit.back;
+ gMC.x = npc->x + npc->hit.back + gMC.hit.back;
hit |= 1;
}
@@ -764,18 +765,18 @@
return hit;
}
-void HitMyCharNpChar()
+void HitMyCharNpChar(void)
{
int i;
int hit = 0;
- if ((gMC.cond & 0x80) == 0 || (gMC.cond & 2))
+ if (!(gMC.cond & 0x80) || gMC.cond & 2)
return;
- for (i = 0; i < NPC_MAX; i++)
+ for (i = 0; i < NPC_MAX; ++i)
{
- if ((gNPC[i].cond & 0x80) == 0)
+ if (!(gNPC[i].cond & 0x80))
continue;
hit = 0;
@@ -796,7 +797,7 @@
}
// Special NPCs (pickups)
- if (hit && gNPC[i].code_char == 1)
+ if (hit != 0 && gNPC[i].code_char == 1)
{
PlaySoundObject(14, 1);
AddExpMyChar(gNPC[i].exp);
@@ -803,7 +804,7 @@
gNPC[i].cond = 0;
}
- if (hit && gNPC[i].code_char == 86)
+ if (hit != 0 && gNPC[i].code_char == 86)
{
PlaySoundObject(42, 1);
AddBulletMyChar(gNPC[i].code_event, gNPC[i].exp);
@@ -810,7 +811,7 @@
gNPC[i].cond = 0;
}
- if (hit && gNPC[i].code_char == 87)
+ if (hit != 0 && gNPC[i].code_char == 87)
{
PlaySoundObject(20, 1);
AddLifeMyChar(gNPC[i].exp);
@@ -818,11 +819,11 @@
}
// Run event on contact
- if ((g_GameFlags & 4) == 0 && hit && gNPC[i].bits & NPC_EVENT_WHEN_TOUCHED)
+ if (!(g_GameFlags & 4) && hit != 0 && gNPC[i].bits & NPC_EVENT_WHEN_TOUCHED)
StartTextScript(gNPC[i].code_event);
// NPC damage
- if (g_GameFlags & 2 && (gNPC[i].bits & NPC_INTERACTABLE) == 0)
+ if (g_GameFlags & 2 && !(gNPC[i].bits & NPC_INTERACTABLE))
{
if (gNPC[i].bits & NPC_REAR_AND_TOP_DONT_HURT)
{
@@ -835,7 +836,7 @@
if (hit & 2 && gNPC[i].ym > 0)
DamageMyChar(gNPC[i].damage);
}
- else if (hit && gNPC[i].damage && !(g_GameFlags & 4))
+ else if (hit != 0 && gNPC[i].damage && !(g_GameFlags & 4))
{
DamageMyChar(gNPC[i].damage);
}
@@ -842,11 +843,11 @@
}
// Interaction
- if ((g_GameFlags & 4) == 0 && hit && gMC.cond & 1 && gNPC[i].bits & NPC_INTERACTABLE)
+ if (!(g_GameFlags & 4) && hit != 0 && gMC.cond & 1 && gNPC[i].bits & NPC_INTERACTABLE)
{
StartTextScript(gNPC[i].code_event);
gMC.xm = 0;
- gMC.ques = 0;
+ gMC.ques = FALSE;
}
}
@@ -855,16 +856,18 @@
SetCaret(gMC.x, gMC.y, 9, 0);
}
-void HitMyCharBoss()
+void HitMyCharBoss(void)
{
+ int b;
+
int hit = 0;
- if ((gMC.cond & 0x80) == 0 || (gMC.cond & 2))
+ if (!(gMC.cond & 0x80) || gMC.cond & 2)
return;
- for (int b = 0; b < BOSS_MAX; b++)
+ for (b = 0; b < BOSS_MAX; ++b)
{
- if ((gBoss[b].cond & 0x80) == 0)
+ if (!(gBoss[b].cond & 0x80))
continue;
hit = 0;
@@ -884,10 +887,10 @@
hit = JudgeHitMyCharNPC3(&gBoss[b]);
}
- if (!(g_GameFlags & 4) && hit && gBoss[b].bits & NPC_EVENT_WHEN_TOUCHED)
+ if (!(g_GameFlags & 4) && hit != 0 && gBoss[b].bits & NPC_EVENT_WHEN_TOUCHED)
{
StartTextScript(gBoss[b].code_event);
- gMC.ques = 0;
+ gMC.ques = FALSE;
}
if (gBoss[b].bits & NPC_REAR_AND_TOP_DONT_HURT)
@@ -897,16 +900,16 @@
if (hit & 1 && gBoss[b].xm > 0)
DamageMyChar(gBoss[b].damage);
}
- else if (hit && gBoss[b].damage && !(g_GameFlags & 4))
+ else if (hit != 0 && gBoss[b].damage != 0 && !(g_GameFlags & 4))
{
DamageMyChar(gBoss[b].damage);
}
- if (!(g_GameFlags & 4) && hit && (gMC.cond & 1) && gBoss[b].bits & NPC_INTERACTABLE)
+ if (!(g_GameFlags & 4) && hit != 0 && gMC.cond & 1 && gBoss[b].bits & NPC_INTERACTABLE)
{
StartTextScript(gBoss[b].code_event);
gMC.xm = 0;
- gMC.ques = 0;
+ gMC.ques = FALSE;
}
}
--- a/src/MycHit.h
+++ b/src/MycHit.h
@@ -1,6 +1,6 @@
#pragma once
-void ResetMyCharFlag();
-void HitMyCharMap();
-void HitMyCharNpChar();
-void HitMyCharBoss();
+void ResetMyCharFlag(void);
+void HitMyCharMap(void);
+void HitMyCharNpChar(void);
+void HitMyCharBoss(void);
--- a/src/MycParam.cpp
+++ b/src/MycParam.cpp
@@ -88,13 +88,13 @@
}
}
-void ZeroExpMyChar()
+void ZeroExpMyChar(void)
{
gArmsData[gSelectedArms].level = 1;
gArmsData[gSelectedArms].exp = 0;
}
-BOOL IsMaxExpMyChar()
+BOOL IsMaxExpMyChar(void)
{
if (gArmsData[gSelectedArms].level == 3)
{
@@ -110,10 +110,10 @@
void DamageMyChar(int damage)
{
#ifdef FIX_BUGS
- if ((g_GameFlags & 2) == 0)
+ if (!(g_GameFlags & 2))
#else
// I'm preeeetty sure this is a typo. The Linux port optimised it out.
- if ((g_GameFlags | 2) == 0)
+ if (!(g_GameFlags | 2))
#endif
return;
@@ -127,7 +127,8 @@
if (gMC.unit == 1)
{
- // Another weird case where there *has* to be an empty 'if' here to produce the same assembly
+ // Another weird case where there *has* to be an empty 'if' here to produce the same assembly.
+ // Chances are there used to be some commented-out code here.
}
else
{
@@ -144,7 +145,7 @@
if (gMC.equip & 4)
gArmsData[gSelectedArms].exp -= damage;
else
- gArmsData[gSelectedArms].exp -= 2 * damage;
+ gArmsData[gSelectedArms].exp -= damage * 2;
while (gArmsData[gSelectedArms].exp < 0)
{
@@ -179,9 +180,11 @@
}
}
-void ZeroArmsEnergy_All()
+void ZeroArmsEnergy_All(void)
{
- for (int a = 0; a < ARMS_MAX; a++)
+ int a;
+
+ for (a = 0; a < ARMS_MAX; a++)
{
gArmsData[a].level = 1;
gArmsData[a].exp = 0;
@@ -190,9 +193,10 @@
void AddBulletMyChar(int no, int val)
{
- int a = 0;
+ int a;
// Missile Launcher
+ a = 0;
while (a < ARMS_MAX && gArmsData[a].code != 5)
++a;
@@ -289,8 +293,8 @@
}
else
{
- if (exp_next)
- rcExpVal.right += 40 * exp_now / exp_next;
+ if (exp_next != 0)
+ rcExpVal.right += (exp_now * 40) / exp_next;
else
rcExpVal.right = 0;
@@ -302,7 +306,7 @@
PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpFlash, SURFACE_ID_TEXT_BOX);
}
-void PutActiveArmsList()
+void PutActiveArmsList(void)
{
int x;
int a;
@@ -316,23 +320,23 @@
if (arms_num == 0)
return;
- for (a = 0; a < arms_num; a++)
+ for (a = 0; a < arms_num; ++a)
{
// Get X position to draw at
- x = 16 * (a - gSelectedArms) + gArmsEnergyX;
+ x = ((a - gSelectedArms) * 16) + gArmsEnergyX;
if (x < 8)
- x += 48 + (16 * arms_num);
+ x += 48 + (arms_num * 16);
else if (x >= 24)
x += 48;
- if (x >= 72 + (16 * (arms_num - 1)))
- x -= 48 + (16 * arms_num);
+ if (x >= 72 + ((arms_num - 1) * 16))
+ x -= 48 + (arms_num * 16);
if (x < 72 && x >= 24)
x -= 48;
// Draw icon
- rect.left = 16 * gArmsData[a].code;
+ rect.left = gArmsData[a].code * 16;
rect.right = rect.left + 16;
PutBitmap3(&grcGame, x, 16, &rect, SURFACE_ID_ARMS_IMAGE);
}
@@ -344,7 +348,7 @@
RECT rcLife = {0, 24, 232, 32};
RECT rcBr = {0, 32, 232, 40};
- if (flash == TRUE && (gMC.shock / 2) % 2)
+ if (flash == TRUE && gMC.shock / 2 % 2)
return;
if (gMC.lifeBr < gMC.life)
@@ -362,8 +366,8 @@
// Draw bar
rcCase.right = 64;
- rcLife.right = 40 * gMC.life / gMC.max_life - 1;
- rcBr.right = 40 * gMC.lifeBr / gMC.max_life - 1;
+ rcLife.right = ((gMC.life * 40) / gMC.max_life) - 1;
+ rcBr.right = ((gMC.lifeBr * 40) / gMC.max_life) - 1;
PutBitmap3(&grcGame, 16, 40, &rcCase, SURFACE_ID_TEXT_BOX);
PutBitmap3(&grcGame, 40, 40, &rcBr, SURFACE_ID_TEXT_BOX);
@@ -381,7 +385,7 @@
if (gMC.equip & 0x10)
return;
- if (gMC.air_get)
+ if (gMC.air_get != 0)
{
// Draw how much air is left
if (gMC.air_get % 6 < 4)
@@ -433,7 +437,7 @@
}
}
-BOOL SaveTimeCounter()
+BOOL SaveTimeCounter(void)
{
unsigned char *p;
int i;
@@ -473,7 +477,7 @@
}
// Save new time
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; ++i)
{
rec.counter[i] = time_count;
rec.random[i] = Random(0, 250) + i;
@@ -502,7 +506,7 @@
return TRUE;
}
-int LoadTimeCounter()
+int LoadTimeCounter(void)
{
unsigned char *p;
int i;
@@ -529,7 +533,7 @@
fclose(fp);
// Decode from checksum
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; ++i)
{
p = (unsigned char*)&rec.counter[i];
p[0] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i]) : (rec.random[i] / 2);
--- a/src/MycParam.h
+++ b/src/MycParam.h
@@ -16,17 +16,17 @@
extern ARMS_LEVEL gArmsLevelTable[14];
void AddExpMyChar(int x);
-void ZeroExpMyChar();
-BOOL IsMaxExpMyChar();
+void ZeroExpMyChar(void);
+BOOL IsMaxExpMyChar(void);
void DamageMyChar(int damage);
-void ZeroArmsEnergy_All();
+void ZeroArmsEnergy_All(void);
void AddBulletMyChar(int no, int val);
void AddLifeMyChar(int x);
void AddMaxLifeMyChar(int val);
void PutArmsEnergy(BOOL flash);
-void PutActiveArmsList();
+void PutActiveArmsList(void);
void PutMyLife(BOOL flash);
void PutMyAir(int x, int y);
void PutTimeCounter(int x, int y);
-BOOL SaveTimeCounter();
-int LoadTimeCounter();
+BOOL SaveTimeCounter(void);
+int LoadTimeCounter(void);
--- a/src/NpChar.cpp
+++ b/src/NpChar.cpp
@@ -27,7 +27,7 @@
const char *gPassPixEve = "PXE";
-void InitNpChar()
+void InitNpChar(void)
{
memset(gNPC, 0, sizeof(gNPC));
}
@@ -41,14 +41,14 @@
npc->damage = gNpcTable[code].damage;
npc->size = gNpcTable[code].size;
npc->life = gNpcTable[code].life;
- npc->hit.front = gNpcTable[code].hit.front << 9;
- npc->hit.back = gNpcTable[code].hit.back << 9;
- npc->hit.top = gNpcTable[code].hit.top << 9;
- npc->hit.bottom = gNpcTable[code].hit.bottom << 9;
- npc->view.front = gNpcTable[code].view.front << 9;
- npc->view.back = gNpcTable[code].view.back << 9;
- npc->view.top = gNpcTable[code].view.top << 9;
- npc->view.bottom = gNpcTable[code].view.bottom << 9;
+ npc->hit.front = gNpcTable[code].hit.front * 0x200;
+ npc->hit.back = gNpcTable[code].hit.back * 0x200;
+ npc->hit.top = gNpcTable[code].hit.top * 0x200;
+ npc->hit.bottom = gNpcTable[code].hit.bottom * 0x200;
+ npc->view.front = gNpcTable[code].view.front * 0x200;
+ npc->view.back = gNpcTable[code].view.back * 0x200;
+ npc->view.top = gNpcTable[code].view.top * 0x200;
+ npc->view.bottom = gNpcTable[code].view.bottom * 0x200;
}
BOOL LoadEvent(const char *path_event)
@@ -58,8 +58,9 @@
int i;
int n;
EVENT eve;
-
char path[MAX_PATH];
+ char code[4];
+
sprintf(path, "%s/%s", gDataPath, path_event);
fp = fopen(path, "rb");
@@ -67,7 +68,6 @@
return FALSE;
// Read "PXE" check
- char code[4];
fread(code, 1, 4, fp);
if (memcmp(code, gPassPixEve, 3) != 0)
{
@@ -85,7 +85,7 @@
memset(gNPC, 0, sizeof(gNPC));
n = 170;
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; ++i)
{
// Get data from file
eve.x = File_ReadLE16(fp);
@@ -124,7 +124,7 @@
}
// Increase index
- n++;
+ ++n;
}
fclose(fp);
@@ -157,12 +157,16 @@
void SetDestroyNpChar(int x, int y, int w, int num)
{
+ int i;
+ int offset_x;
+ int offset_y;
+
// Create smoke
w /= 0x200;
- for (int i = 0; i < num; i++)
+ for (i = 0; i < num; ++i)
{
- int offset_x = Random(-w, w) * 0x200;
- int offset_y = Random(-w, w) * 0x200;
+ offset_x = Random(-w, w) * 0x200;
+ offset_y = Random(-w, w) * 0x200;
SetNpChar(4, x + offset_x, y + offset_y, 0, 0, 0, NULL, 0x100);
}
@@ -172,12 +176,16 @@
void SetDestroyNpCharUp(int x, int y, int w, int num)
{
+ int i;
+ int offset_x;
+ int offset_y;
+
// Create smoke
w /= 0x200;
- for (int i = 0; i < num; i++)
+ for (i = 0; i < num; ++i)
{
- int offset_x = Random(-w, w) * 0x200;
- int offset_y = Random(-w, w) * 0x200;
+ offset_x = Random(-w, w) * 0x200;
+ offset_y = Random(-w, w) * 0x200;
SetNpChar(4, x + offset_x, y + offset_y, 0, 0, 1, NULL, 0x100);
}
@@ -324,12 +332,15 @@
void PutNpChar(int fx, int fy)
{
+ int n;
signed char a = 0;
- for (int n = 0; n < NPC_MAX; ++n)
+ 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;
@@ -344,7 +355,6 @@
}
}
- int side;
if (gNPC[n].direct == 0)
side = gNPC[n].view.front;
else
@@ -360,9 +370,11 @@
}
}
-void ActNpChar()
+void ActNpChar(void)
{
- for (int i = 0; i < NPC_MAX; ++i)
+ int i;
+
+ for (i = 0; i < NPC_MAX; ++i)
{
if (gNPC[i].cond & 0x80)
{
@@ -378,7 +390,9 @@
void ChangeNpCharByEvent(int code_event, int code_char, int dir)
{
- for (int n = 0; n < NPC_MAX; n++)
+ int n;
+
+ for (n = 0; n < NPC_MAX; ++n)
{
if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
@@ -420,9 +434,11 @@
void ChangeCheckableNpCharByEvent(int code_event, int code_char, int dir)
{
- for (int n = 0; n < NPC_MAX; n++)
+ int n;
+
+ for (n = 0; n < NPC_MAX; ++n)
{
- if ((gNPC[n].cond & 0x80) != 0 && gNPC[n].code_event == code_event)
+ if (!(gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
gNPC[n].bits &= ~(NPC_SOLID_SOFT | NPC_IGNORE_TILE_44 | NPC_INVULNERABLE | NPC_IGNORE_SOLIDITY | NPC_BOUNCY | NPC_SHOOTABLE | NPC_SOLID_HARD | NPC_REAR_AND_TOP_DONT_HURT | NPC_SHOW_DAMAGE); // Clear these flags
gNPC[n].bits |= NPC_INTERACTABLE;
@@ -573,7 +589,9 @@
void DeleteNpCharEvent(int code)
{
- for (int i = 0; i < NPC_MAX; i++)
+ int i;
+
+ for (i = 0; i < NPC_MAX; ++i)
{
if ((gNPC[i].cond & 0x80) && gNPC[i].code_event == code)
{
@@ -585,7 +603,9 @@
void DeleteNpCharCode(int code, BOOL bSmoke)
{
- for (int n = 0; n < NPC_MAX; n++)
+ int n;
+
+ for (n = 0; n < NPC_MAX; ++n)
{
if ((gNPC[n].cond & 0x80) && gNPC[n].code_char == code)
{
@@ -623,7 +643,9 @@
BOOL IsNpCharCode(int code)
{
- for (int i = 0; i < NPC_MAX; ++i)
+ int i;
+
+ for (i = 0; i < NPC_MAX; ++i)
if ((gNPC[i].cond & 0x80) && gNPC[i].code_char == code)
return TRUE;
@@ -633,6 +655,7 @@
BOOL GetNpCharAlive(int code_event)
{
int i;
+
for (i = 0; i < NPC_MAX; ++i)
if ((gNPC[i].cond & 0x80) && gNPC[i].code_event == code_event)
break;
@@ -643,14 +666,14 @@
return FALSE;
}
-int CountAliveNpChar()
+int CountAliveNpChar(void)
{
+ int n;
int count = 0;
- for (int n = 0; n < NPC_MAX; ++n)
- {
+
+ for (n = 0; n < NPC_MAX; ++n)
if (gNPC[n].cond & 0x80)
++count;
- }
return count;
}
--- a/src/NpChar.h
+++ b/src/NpChar.h
@@ -118,7 +118,7 @@
extern int gSuperXpos;
extern int gSuperYpos;
-void InitNpChar();
+void InitNpChar(void);
BOOL LoadEvent(const char *path_event);
void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index);
void SetDestroyNpChar(int x, int y, int w, int num);
@@ -128,7 +128,7 @@
BOOL SetLifeObject(int x, int y, int val);
void VanishNpChar(NPCHAR *npc);
void PutNpChar(int fx, int fy);
-void ActNpChar();
+void ActNpChar(void);
void ChangeNpCharByEvent(int code_event, int code_char, int dir);
void ChangeCheckableNpCharByEvent(int code_event, int code_char, int dir);
void SetNpCharActionNo(int code_event, int act_no, int dir);
@@ -139,4 +139,4 @@
void GetNpCharPosition(int *x, int *y, int i);
BOOL IsNpCharCode(int code);
BOOL GetNpCharAlive(int code_event);
-int CountAliveNpChar();
+int CountAliveNpChar(void);
--- a/src/NpcAct000.cpp
+++ b/src/NpcAct000.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Back.h"
@@ -22,7 +24,7 @@
npc->act_no = 1;
if (npc->direct == 2)
- npc->y += 0x2000;
+ npc->y += 16 * 0x200;
}
npc->rect = rect;
@@ -48,7 +50,7 @@
npc->xm -= 8;
// Destroy when off-screen
- if (npc->x < 0xA000)
+ if (npc->x < 80 * 0x200)
npc->cond = 0;
#ifdef FIX_BUGS
@@ -91,9 +93,9 @@
// Gravity
if (npc->flag & 0x100)
- npc->ym += 21;
+ npc->ym += 0x15;
else
- npc->ym += 42;
+ npc->ym += 0x2A;
// Bounce off walls
if (npc->flag & 1 && npc->xm < 0)
@@ -118,7 +120,7 @@
{
PlaySoundObject(45, 1);
if (++npc->count2 > 2)
- npc->y -= 0x200;
+ npc->y -= 1 * 0x200;
}
else
{
@@ -160,6 +162,7 @@
if (npc->ani_wait > 2)
{
npc->ani_wait = 0;
+
if (++npc->ani_no > 5)
npc->ani_no = 0;
}
@@ -169,6 +172,7 @@
if (npc->ani_wait > 2)
{
npc->ani_wait = 0;
+
if (--npc->ani_no < 0)
npc->ani_no = 5;
}
@@ -177,7 +181,7 @@
npc->rect = rect[npc->ani_no];
// Size
- if (npc->act_no)
+ if (npc->act_no != 0)
{
switch (npc->exp)
{
@@ -201,10 +205,8 @@
// Blink after 400 frames
if (npc->count1 > 400)
- {
if (npc->count1 / 2 % 2)
npc->rect = rcNo;
- }
}
// Behemoth
@@ -260,10 +262,11 @@
npc->act_no = 1;
npc->ani_no = 4;
}
+
break;
case 1: // Shot
- npc->xm = 7 * npc->xm / 8;
+ npc->xm = (npc->xm * 7) / 8;
if (++npc->count1 > 40)
{
@@ -304,9 +307,10 @@
if (npc->ani_no > 6)
{
npc->ani_no = 5;
- // These three lines are missing in the Linux port. Could this be because it's based on an older version?
+ // These three lines are missing in the Linux port, because it's based on v1.0.0.4:
+ // https://www.cavestory.org/forums/threads/version-1-0-0-5-really-different-than-1-0-0-6.102/#post-3231
PlaySoundObject(26, 1);
- SetNpChar(4, npc->x, npc->y + 0x600, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y + (3 * 0x200), 0, 0, 0, NULL, 0x100);
SetQuake(8);
}
break;
@@ -328,7 +332,7 @@
npc->rect = rcRight[npc->ani_no];
}
-// Dead enemy (make sure damage shown doesn't teleport to a new loaded npc)
+// Dead enemy (to make sure the damage-value doesn't teleport to a newly-loaded NPC)
void ActNpc003(NPCHAR *npc)
{
if (++npc->count1 > 100)
@@ -383,8 +387,8 @@
else
{
// Slight drag
- npc->xm = 20 * npc->xm / 21;
- npc->ym = 20 * npc->ym / 21;
+ npc->xm = (npc->xm * 20) / 21;
+ npc->ym = (npc->ym * 20) / 21;
// Move
npc->x += npc->xm;
@@ -395,7 +399,7 @@
if (++npc->ani_wait > 4)
{
npc->ani_wait = 0;
- npc->ani_no++;
+ ++npc->ani_no;
}
// Set framerect
@@ -433,7 +437,7 @@
switch (npc->act_no)
{
case 0: // Initialize
- npc->y += 0x600;
+ npc->y += 3 * 0x200;
npc->act_no = 1;
// Fallthrough
case 1: // Waiting
@@ -444,7 +448,7 @@
npc->direct = 2;
// Open eyes near player
- if (npc->act_wait >= 8 && npc->x - 0xE000 < gMC.x && npc->x + 0xE000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0xA000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (112 * 0x200) < gMC.x && npc->x + (112 * 0x200) > gMC.x && npc->y - (80 * 0x200) < gMC.y && npc->y + (80 * 0x200) > gMC.y)
{
npc->ani_no = 1;
}
@@ -465,12 +469,13 @@
}
// Jump if player is nearby
- if (npc->act_wait >= 8 && npc->x - 0x6000 < gMC.x && npc->x + 0x6000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0x6000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (48 * 0x200) < gMC.x && npc->x + (48 * 0x200) > gMC.x && npc->y - (80 * 0x200) < gMC.y && npc->y + (48 * 0x200) > gMC.y)
{
npc->act_no = 2;
npc->ani_no = 0;
npc->act_wait = 0;
}
+
break;
case 2: // Going to jump
@@ -490,6 +495,7 @@
else
npc->xm = 0x100;
}
+
break;
case 3: // Jumping
@@ -502,6 +508,7 @@
npc->act_no = 1;
PlaySoundObject(23, 1);
}
+
break;
}
@@ -675,7 +682,7 @@
case 1:
npc->xm -= 0x40;
- if (npc->x < gMC.x - 0x18000)
+ if (npc->x < gMC.x - (192 * 0x200))
npc->act_no = 2;
if (npc->flag & 1)
@@ -689,7 +696,7 @@
case 2:
npc->xm += 0x40;
- if (npc->x > gMC.x + 0x18000)
+ if (npc->x > gMC.x + (192 * 0x200))
npc->act_no = 1;
if (npc->flag & 4)
@@ -744,7 +751,7 @@
switch (npc->act_no)
{
case 0:
- if (gMC.x < npc->x + 0x2000 && gMC.x > npc->x - 0x2000)
+ if (gMC.x < npc->x + (16 * 0x200) && gMC.x > npc->x - (16 * 0x200))
{
npc->bits |= NPC_SHOOTABLE;
npc->ym = -0x100;
@@ -754,12 +761,12 @@
if (npc->direct == 0)
{
- npc->x = gMC.x + 0x20000;
+ npc->x = gMC.x + (256 * 0x200);
npc->xm = -0x2FF;
}
else
{
- npc->x = gMC.x - 0x20000;
+ npc->x = gMC.x - (256 * 0x200);
npc->xm = 0x2FF;
}
}
@@ -858,7 +865,7 @@
if (npc->flag & 8)
{
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
npc->act_no = 2;
npc->ani_no = 1;
@@ -906,7 +913,7 @@
npc->rect = rect_right[npc->ani_no];
}
-// Balrog (shooting) (super-secret version from prototype)
+// Balrog (shooting) (super-secret unused version from the prototype)
void ActNpc010(NPCHAR *npc)
{
unsigned char deg;
@@ -935,11 +942,11 @@
--npc->count1;
npc->act_wait = 0;
- deg = GetArktan(npc->x - gMC.x, npc->y + 0x800 - gMC.y);
+ deg = GetArktan(npc->x - gMC.x, npc->y + (4 * 0x200) - gMC.y);
deg += (unsigned char)Random(-0x10, 0x10);
ym = GetSin(deg);
xm = GetCos(deg);
- SetNpChar(11, npc->x, npc->y + 0x800, xm, ym, 0, 0, 0x100);
+ SetNpChar(11, npc->x, npc->y + (4 * 0x200), xm, ym, 0, NULL, 0x100);
PlaySoundObject(39, 1);
@@ -968,7 +975,7 @@
if (npc->flag & 5)
npc->xm = 0;
- if (npc->y + 0x2000 < gMC.y)
+ if (npc->y + (16 * 0x200) < gMC.y)
npc->damage = 5;
else
npc->damage = 0;
@@ -1158,7 +1165,7 @@
npc->count1 = 0;
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
PlaySoundObject(72, 1);
// Fallthrough
@@ -1169,9 +1176,9 @@
++npc->act_wait;
if (++npc->count1 / 2 % 2)
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
else
- npc->x -= 0x200;
+ npc->x -= 1 * 0x200;
if (npc->act_wait > 100)
{
@@ -1286,9 +1293,9 @@
// Fallthrough
case 81:
if (++npc->count1 / 2 % 2)
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
else
- npc->x -= 0x200;
+ npc->x -= 1 * 0x200;
npc->ani_no = 5;
npc->xm = 0;
@@ -1330,7 +1337,7 @@
SetQuake2(10);
}
- if (npc->y < -0x4000)
+ if (npc->y < -32 * 0x200)
{
npc->code_char = 0;
SetQuake(30);
@@ -1341,7 +1348,7 @@
}
if (npc->tgt_x && Random(0, 10) == 0)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
if (npc->ym > 0x5FF)
npc->ym = 0x5FF;
@@ -1422,6 +1429,8 @@
// Santa's Key
void ActNpc014(NPCHAR *npc)
{
+ int i;
+
RECT rect[3] = {
{192, 0, 208, 16},
{208, 0, 224, 16},
@@ -1437,11 +1446,11 @@
{
npc->ym = -0x200;
- for (int i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
}
- break;
+ break;
}
if (++npc->ani_wait > 1)
@@ -1465,6 +1474,8 @@
// Chest (closed)
void ActNpc015(NPCHAR *npc)
{
+ int i;
+
RECT rcLeft[3] = {
{240, 0, 256, 16},
{256, 0, 272, 16},
@@ -1481,8 +1492,8 @@
{
npc->ym = -0x200;
- for (int i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
}
// Fallthrough
@@ -1522,6 +1533,8 @@
// Save point
void ActNpc016(NPCHAR *npc)
{
+ int i;
+
RECT rect[8] = {
{96, 16, 112, 32},
{112, 16, 128, 32},
@@ -1544,8 +1557,8 @@
npc->bits &= ~NPC_INTERACTABLE;
npc->ym = -0x200;
- for (int i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
}
// Fallthrough
@@ -1583,6 +1596,7 @@
};
int a;
+
switch (npc->act_no)
{
case 0:
@@ -1593,7 +1607,7 @@
npc->ym = -0x200;
for (a = 0; a < 4; ++a)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
}
// Fallthrough
@@ -1650,6 +1664,8 @@
// Door
void ActNpc018(NPCHAR *npc)
{
+ int i;
+
RECT rect[2] = {
{224, 16, 240, 40},
{192, 112, 208, 136},
@@ -1666,8 +1682,8 @@
break;
case 1:
- for (int i = 0; i < 4; i++)
- SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
npc->act_no = 0;
npc->rect = rect[0];
@@ -1684,9 +1700,9 @@
{
case 0:
for (i = 0; i < 0x10; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
- npc->y += 0x1400;
+ npc->y += 10 * 0x200;
npc->act_no = 1;
npc->ani_no = 3;
npc->ym = -0x100;
--- a/src/NpcAct020.cpp
+++ b/src/NpcAct020.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Caret.h"
@@ -44,7 +46,7 @@
npc->act_no = 1;
if (npc->direct == 2)
- npc->y += 0x2000;
+ npc->y += 16 * 0x200;
}
RECT rect = {224, 40, 240, 48};
@@ -126,11 +128,11 @@
switch (npc->act_no)
{
case 0:
- npc->y += 0x600;
+ npc->y += 3 * 0x200;
npc->act_no = 1;
// Fallthrough
case 1:
- if (npc->act_wait >= 8 && npc->x - 0x10000 < gMC.x && npc->x + 0x10000 > gMC.x && npc->y - 0x10000 < gMC.y && npc->y + 0x6000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (128 * 0x200) < gMC.x && npc->x + (128 * 0x200) > gMC.x && npc->y - (128 * 0x200) < gMC.y && npc->y + (48 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -154,7 +156,7 @@
npc->act_wait = 0;
}
- if (npc->act_wait >= 8 && npc->x - 0xC000 < gMC.x && npc->x + 0xC000 > gMC.x && npc->y - 0xC000 < gMC.y && npc->y + 0x6000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (96 * 0x200) < gMC.x && npc->x + (96 * 0x200) > gMC.x && npc->y - (96 * 0x200) < gMC.y && npc->y + (48 * 0x200) > gMC.y)
{
npc->act_no = 2;
npc->ani_no = 0;
@@ -210,22 +212,21 @@
npc->act_no = 5;
npc->ani_no = 2;
npc->xm /= 2;
+ break;
}
- else
- {
- if (npc->act_wait % 4 == 1)
- PlaySoundObject(110, 1);
- if (++npc->ani_wait > 0)
- {
- npc->ani_wait = 0;
- ++npc->ani_no;
- }
+ if (npc->act_wait % 4 == 1)
+ PlaySoundObject(110, 1);
- if (npc->ani_no > 5)
- npc->ani_no = 3;
+ if (++npc->ani_wait > 0)
+ {
+ npc->ani_wait = 0;
+ ++npc->ani_no;
}
+ if (npc->ani_no > 5)
+ npc->ani_no = 3;
+
break;
case 5:
@@ -295,7 +296,7 @@
npc->act_no = 1;
npc->ani_no = 0;
npc->ani_wait = 0;
- npc->x += 0x1000;
+ npc->x += 8 * 0x200;
// Fallthrough
case 1:
if (++npc->act_wait > 150)
@@ -309,7 +310,7 @@
case 2: // Identical to case 4
if (++npc->act_wait <= 0x40)
{
- npc->y -= 0x200;
+ npc->y -= 1 * 0x200;
}
else
{
@@ -331,7 +332,7 @@
case 4: // Identical to case 2
if (++npc->act_wait <= 0x40)
{
- npc->y -= 0x200;
+ npc->y -= 1 * 0x200;
}
else
{
@@ -353,7 +354,7 @@
case 6:
if (++npc->act_wait <= 0x40)
{
- npc->y += 0x200;
+ npc->y += 1 * 0x200;
}
else
{
@@ -375,7 +376,7 @@
case 8:
if (++npc->act_wait <= 0x40)
{
- npc->y += 0x200;
+ npc->y += 1 * 0x200;
}
else
{
@@ -418,12 +419,12 @@
deg = Random(0, 0xFF);
npc->xm = GetCos(deg);
deg += 0x40;
- npc->tgt_x = npc->x + 8 * GetCos(deg);
+ npc->tgt_x = npc->x + (GetCos(deg) * 8);
deg = Random(0, 0xFF);
npc->ym = GetSin(deg);
deg += 0x40;
- npc->tgt_y = npc->y + 8 * GetSin(deg);
+ npc->tgt_y = npc->y + (GetSin(deg) * 8);
npc->act_no = 1;
npc->count1 = 120;
@@ -457,16 +458,15 @@
if (npc->count1 < 120)
{
++npc->count1;
+ break;
}
- else
+
+ if (npc->x - (8 * 0x200) < gMC.x && npc->x + (8 * 0x200) > gMC.x && npc->y < gMC.y && npc->y + (96 * 0x200) > gMC.y)
{
- if (npc->x - 0x1000 < gMC.x && npc->x + 0x1000 > gMC.x && npc->y < gMC.y && npc->y + 0xC000 > gMC.y)
- {
- npc->xm /= 2;
- npc->ym = 0;
- npc->act_no = 3;
- npc->bits &= ~NPC_IGNORE_SOLIDITY;
- }
+ npc->xm /= 2;
+ npc->ym = 0;
+ npc->act_no = 3;
+ npc->bits &= ~NPC_IGNORE_SOLIDITY;
}
break;
@@ -561,11 +561,11 @@
switch (npc->act_no)
{
case 0:
- npc->y += 0x600;
+ npc->y += 3 * 0x200;
npc->act_no = 1;
// Fallthrough
case 1:
- if (npc->act_wait >= 8 && npc->x - 0x10000 < gMC.x && npc->x + 0x10000 > gMC.x && npc->y - 0x10000 < gMC.y && npc->y + 0x6000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (128 * 0x200) < gMC.x && npc->x + (128 * 0x200) > gMC.x && npc->y - (128 * 0x200) < gMC.y && npc->y + (48 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -589,7 +589,7 @@
npc->act_wait = 0;
}
- if (npc->act_wait >= 8 && npc->x - 0xC000 < gMC.x && npc->x + 0xC000 > gMC.x && npc->y - 0xC000 < gMC.y && npc->y + 0x6000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (96 * 0x200) < gMC.x && npc->x + (96 * 0x200) > gMC.x && npc->y - (96 * 0x200) < gMC.y && npc->y + (48 * 0x200) > gMC.y)
{
npc->act_no = 2;
npc->ani_no = 0;
@@ -603,7 +603,7 @@
{
npc->act_no = 3;
npc->ani_no = 2;
- npc->ym = -1228;
+ npc->ym = -0x4CC;
PlaySoundObject(30, 1);
if (npc->x > gMC.x)
@@ -645,25 +645,24 @@
npc->act_no = 5;
npc->ani_no = 2;
npc->xm /= 2;
+ break;
}
- else
- {
- if (npc->act_wait % 4 == 1)
- PlaySoundObject(109, 1);
- if (npc->flag & 8)
- npc->ym = -0x200;
+ if (npc->act_wait % 4 == 1)
+ PlaySoundObject(109, 1);
- if (++npc->ani_wait > 0)
- {
- npc->ani_wait = 0;
- ++npc->ani_no;
- }
+ if (npc->flag & 8)
+ npc->ym = -0x200;
- if (npc->ani_no > 5)
- npc->ani_no = 3;
+ if (++npc->ani_wait > 0)
+ {
+ npc->ani_wait = 0;
+ ++npc->ani_no;
}
+ if (npc->ani_no > 5)
+ npc->ani_no = 3;
+
break;
case 5:
@@ -739,7 +738,7 @@
npc->ani_wait = 0;
// Fallthrough
case 1:
- if (npc->x - 0x6000 < gMC.x && npc->x + 0x6000 > gMC.x && npc->y - 0x6000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (48 * 0x200) < gMC.x && npc->x + (48 * 0x200) > gMC.x && npc->y - (48 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
npc->ani_no = 1;
else
npc->ani_no = 0;
@@ -797,7 +796,7 @@
if (npc->act_no == 0)
{
npc->act_no = 1;
- npc->y += 0x2000;
+ npc->y += 16 * 0x200;
npc->ani_no = 2;
}
@@ -804,7 +803,7 @@
if (++npc->act_wait > 100)
{
npc->act_wait = 0;
- SetCaret(npc->x, npc->y - 0x400, 5, 0);
+ SetCaret(npc->x, npc->y - (2 * 0x200), 5, 0);
}
}
@@ -843,7 +842,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x1000 < gMC.x && npc->x + 0x1000 > gMC.x && npc->y - 0x1000 < gMC.y && npc->y + 0xC000 > gMC.y)
+ if (npc->x - (8 * 0x200) < gMC.x && npc->x + (8 * 0x200) > gMC.x && npc->y - (8 * 0x200) < gMC.y && npc->y + (96 * 0x200) > gMC.y)
{
npc->ani_no = 0;
npc->act_no = 3;
@@ -863,7 +862,7 @@
case 3:
npc->ani_no = 0;
- if (npc->shock || npc->x - 0x2800 > gMC.x || npc->x + 0x2800 < gMC.x)
+ if (npc->shock || npc->x - (20 * 0x200) > gMC.x || npc->x + (20 * 0x200) < gMC.x)
{
npc->ani_no = 1;
npc->ani_wait = 0;
@@ -878,10 +877,10 @@
if (npc->ym > 0x5FF)
npc->ym = 0x5FF;
- if (++npc->act_wait < 20 && (npc->flag & 8) == 0)
+ if (++npc->act_wait < 20 && !(npc->flag & 8))
break;
- if (npc->flag & 8 || npc->y > gMC.y - 0x2000)
+ if (npc->flag & 8 || npc->y > gMC.y - (16 * 0x200))
{
npc->ani_wait = 0;
npc->ani_no = 2;
@@ -1040,9 +1039,9 @@
if (npc->shock)
{
if (npc->direct == 0)
- SetNpChar(103, npc->x - 0x1000, npc->y + 0x1000, 0, 0, npc->direct, 0, 0x100);
+ SetNpChar(103, npc->x - (8 * 0x200), npc->y + (8 * 0x200), 0, 0, npc->direct, NULL, 0x100);
else
- SetNpChar(103, npc->x + 0x1000, npc->y + 0x1000, 0, 0, npc->direct, 0, 0x100);
+ SetNpChar(103, npc->x + (8 * 0x200), npc->y + (8 * 0x200), 0, 0, npc->direct, NULL, 0x100);
npc->ani_no = 1;
npc->act_no = 2;
@@ -1124,12 +1123,12 @@
--npc->count1;
npc->act_wait = 0;
- deg = GetArktan(npc->x - gMC.x, npc->y + 0x800 - gMC.y);
- deg += (unsigned char)Random(-16, 16);
+ deg = GetArktan(npc->x - gMC.x, npc->y + (4 * 0x200) - gMC.y);
+ deg += (unsigned char)Random(-0x10, 0x10);
ym = GetSin(deg);
xm = GetCos(deg);
- SetNpChar(11, npc->x, npc->y + 0x800, xm, ym, 0, 0, 0x100);
+ SetNpChar(11, npc->x, npc->y + 0x800, xm, ym, 0, NULL, 0x100);
PlaySoundObject(39, 1);
if (npc->count1 == 0)
@@ -1204,7 +1203,7 @@
break;
case 6:
- if (npc->y + 0x2000 < gMC.y)
+ if (npc->y + (16 * 0x200) < gMC.y)
npc->damage = 10;
else
npc->damage = 0;
@@ -1220,10 +1219,10 @@
npc->damage = 0;
for (i = 0; i < 8; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
for (i = 0; i < 8; ++i)
- SetNpChar(33, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-0x400, 0x400), Random(-0x400, 0), 0, 0, 0x100);
+ SetNpChar(33, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-0x400, 0x400), Random(-0x400, 0), 0, NULL, 0x100);
}
break;
--- a/src/NpcAct040.cpp
+++ b/src/NpcAct040.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Caret.h"
@@ -48,7 +50,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x4000 < gMC.x && npc->x + 0x4000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (32 * 0x200) < gMC.x && npc->x + (32 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -82,9 +84,9 @@
npc->ani_no = 2;
if (npc->direct == 0)
- npc->x -= 0x200;
+ npc->x -= 1 * 0x200;
else
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
break;
@@ -107,7 +109,7 @@
if (npc->act_no == 0)
{
++npc->act_no;
- npc->y -= 0x2000; // Move a tile up
+ npc->y -= 1 * 0x10 * 0x200; // Move one tile up
}
npc->rect = rect;
@@ -281,10 +283,8 @@
npc->act_no = 0;
break;
}
- else
- {
- npc->pNpc = &gNPC[n];
- }
+
+ npc->pNpc = &gNPC[n];
// Fallthrough
case 14:
if (npc->pNpc->direct == 0)
@@ -293,27 +293,27 @@
npc->direct = 0;
if (npc->pNpc->direct == 0)
- npc->x = npc->pNpc->x - 0xC00;
+ npc->x = npc->pNpc->x - (6 * 0x200);
else
- npc->x = npc->pNpc->x + 0xC00;
+ npc->x = npc->pNpc->x + (6 * 0x200);
- npc->y = npc->pNpc->y + 0x800;
+ npc->y = npc->pNpc->y + (4 * 0x200);
if (npc->pNpc->ani_no == 2 || npc->pNpc->ani_no == 4)
- npc->y -= 0x200;
+ npc->y -= 1 * 0x200;
break;
case 15:
npc->act_no = 16;
- SetNpChar(257, npc->x + 0x10000, npc->y, 0, 0, 0, 0, 0);
- SetNpChar(257, npc->x + 0x10000, npc->y, 0, 0, 2, 0, 0x80);
+ SetNpChar(257, npc->x + (128 * 0x200), npc->y, 0, 0, 0, NULL, 0);
+ SetNpChar(257, npc->x + (128 * 0x200), npc->y, 0, 0, 2, NULL, 0x80);
npc->xm = 0;
npc->ani_no = 0;
// Fallthrough
case 16:
- gSuperXpos = npc->x - 0x3000;
- gSuperYpos = npc->y - 0x1000;
+ gSuperXpos = npc->x - (24 * 0x200);
+ gSuperYpos = npc->y - (8 * 0x200);
break;
case 17:
@@ -320,7 +320,7 @@
npc->xm = 0;
npc->ani_no = 12;
gSuperXpos = npc->x;
- gSuperYpos = npc->y - 0x1000;
+ gSuperYpos = npc->y - (8 * 0x200);
break;
case 20:
@@ -343,7 +343,7 @@
else
npc->xm = 0x400;
- if (npc->x < gMC.x - 0x1000)
+ if (npc->x < gMC.x - (8 * 0x200))
{
npc->direct = 2;
npc->act_no = 0;
@@ -412,7 +412,7 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x2000;
+ npc->y -= 1 * 0x10 * 0x200;
break;
}
@@ -566,9 +566,11 @@
if (npc->life <= 100)
{
- for (int i = 0; i < 10; ++i)
- SetNpChar(45, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+ int i;
+ for (i = 0; i < 10; ++i)
+ SetNpChar(45, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+
SetDestroyNpChar(npc->x, npc->y, npc->view.back, 8);
PlaySoundObject(25, 1);
npc->cond = 0;
@@ -714,7 +716,7 @@
npc->bits &= ~NPC_IGNORE_SOLIDITY;
// Fallthrough
case 1:
- if (gMC.x > npc->x - 0x1000 && gMC.x < npc->x + 0x1000 && gMC.y > npc->y && gMC.y < npc->y + 0x1000)
+ if (gMC.x > npc->x - (8 * 0x200) && gMC.x < npc->x + (8 * 0x200) && gMC.y > npc->y && gMC.y < npc->y + (8 * 0x200))
{
npc->act_no = 2;
npc->act_wait = 0;
@@ -722,10 +724,10 @@
}
if (npc->x < gMC.x)
- npc->x += 0x400;
+ npc->x += 2 * 0x200;
if (npc->x > gMC.x)
- npc->x -= 0x400;
+ npc->x -= 2 * 0x200;
break;
@@ -763,7 +765,7 @@
case 4:
npc->bits |= NPC_IGNORE_SOLIDITY;
- npc->y += 0x200;
+ npc->y += 1 * 0x200;
if (++npc->act_wait == 32)
{
@@ -894,7 +896,7 @@
switch (npc->act_no)
{
case 0:
- if (npc->pNpc)
+ if (npc->pNpc != NULL)
npc->act_no = 10;
else
npc->act_no = 1;
@@ -906,7 +908,7 @@
npc->act_no = 3;
npc->ani_no = 2;
- if (npc->count2)
+ if (npc->count2 != 0)
{
if (npc->direct == 0)
npc->xm = -0x200;
@@ -947,7 +949,7 @@
}
else
{
- if (npc->x - 0x10000 < gMC.x && npc->x + 0x10000 > gMC.x && npc->y - 0xC000 < gMC.y && npc->y + 0xC000 > gMC.y)
+ if (npc->x - (128 * 0x200) < gMC.x && npc->x + (128 * 0x200) > gMC.x && npc->y - (96 * 0x200) < gMC.y && npc->y + (96 * 0x200) > gMC.y)
{
npc->act_no = 11;
npc->act_wait = 0;
@@ -960,10 +962,10 @@
case 11:
if (++npc->act_wait == 30 || npc->act_wait == 35)
{
- deg = GetArktan(npc->x - gMC.x, npc->y + 0x800 - gMC.y);
- ym = 2 * GetSin(deg);
- xm = 2 * GetCos(deg);
- SetNpChar(50, npc->x, npc->y, xm, ym, 0, 0, 0x100);
+ deg = GetArktan(npc->x - gMC.x, npc->y + (4 * 0x200) - gMC.y);
+ ym = GetSin(deg) * 2;
+ xm = GetCos(deg) * 2;
+ SetNpChar(50, npc->x, npc->y, xm, ym, 0, NULL, 0x100);
PlaySoundObject(39, 1);
}
@@ -980,7 +982,7 @@
if (npc->act_no >= 10)
{
npc->x = npc->pNpc->x;
- npc->y = npc->pNpc->y + 0x2000;
+ npc->y = npc->pNpc->y + (16 * 0x200);
npc->direct = npc->pNpc->direct;
--npc->pNpc->count1;
}
@@ -1017,9 +1019,7 @@
{
case 0:
if (npc->direct == 2)
- {
npc->act_no = 2;
- }
// Fallthrough
case 1:
npc->x += npc->xm;
@@ -1117,7 +1117,7 @@
switch (npc->act_no)
{
case 0:
- if (npc->x - (WINDOW_WIDTH * 0x200) < gMC.x && npc->x + (WINDOW_WIDTH * 0x200) > gMC.x && npc->y - (WINDOW_WIDTH * 0x200) < gMC.y && npc->y + (WINDOW_WIDTH * 0x200) > gMC.y)
+ if (npc->x - (((WINDOW_WIDTH / 2) + 160) * 0x200) < gMC.x && npc->x + (((WINDOW_WIDTH / 2) + 160) * 0x200) > gMC.x && npc->y - (((WINDOW_HEIGHT / 2) + 200) * 0x200) < gMC.y && npc->y + (((WINDOW_HEIGHT / 2) + 200) * 0x200) > gMC.y)
{
npc->tgt_x = npc->x;
npc->tgt_y = npc->y;
@@ -1131,7 +1131,9 @@
SetNpChar(49, 0, 0, 0, 0, 0, npc, 0);
}
else
+ {
break;
+ }
// Fallthrough
case 1:
@@ -1163,7 +1165,7 @@
else
npc->direct = 2;
- if (npc->y > gMC.y + 0x4000)
+ if (npc->y > gMC.y + (32 * 0x200))
{
if (gMC.x < npc->x)
npc->xm += 0x10;
@@ -1235,13 +1237,13 @@
{
npc->ani_no = 4;
}
- else if (npc->act_no == 2 && npc->y < gMC.y - 0x4000)
+ else if (npc->act_no == 2 && npc->y < gMC.y - (32 * 0x200))
{
npc->ani_no = 0;
}
else
{
- if (npc->act_no)
+ if (npc->act_no != 0)
{
if (++npc->ani_wait > 1)
{
@@ -1271,6 +1273,8 @@
// Skullstep leg
void ActNpc053(NPCHAR *npc)
{
+ unsigned char deg;
+
RECT rcLeft[2] = {
{0, 128, 24, 144},
{24, 128, 48, 144},
@@ -1288,7 +1292,6 @@
return;
}
- unsigned char deg;
switch (npc->act_no)
{
case 0:
@@ -1298,19 +1301,19 @@
case 1:
if (npc->direct == 0 && npc->flag & 0x20)
{
- npc->pNpc->y -= 0x400;
+ npc->pNpc->y -= 2 * 0x200;
npc->pNpc->ym -= 0x100;
}
if (npc->direct == 2 && npc->flag & 0x10)
{
- npc->pNpc->y -= 0x400;
+ npc->pNpc->y -= 2 * 0x200;
npc->pNpc->ym -= 0x100;
}
if (npc->flag & 8)
{
- npc->pNpc->y -= 0x400;
+ npc->pNpc->y -= 2 * 0x200;
npc->pNpc->ym -= 0x100;
if (npc->pNpc->direct == 0)
@@ -1322,11 +1325,14 @@
deg = (unsigned char)npc->xm + (unsigned char)npc->pNpc->count2;
npc->x = npc->pNpc->x + npc->count1 * GetCos(deg);
npc->y = npc->pNpc->y + npc->count1 * GetSin(deg);
+
npc->direct = npc->pNpc->direct;
+
break;
}
npc->direct = npc->pNpc->direct;
+
if (deg >= 20 && deg <= 108)
npc->ani_no = 0;
else
@@ -1354,6 +1360,7 @@
};
unsigned char deg;
+
switch (npc->act_no)
{
case 0:
@@ -1374,7 +1381,7 @@
if (npc->flag & 8)
{
- npc->xm = 3 * npc->xm / 4;
+ npc->xm = (npc->xm * 3) / 4;
if (++npc->act_wait > 60)
{
@@ -1490,9 +1497,9 @@
npc->ani_no = 1;
if (npc->direct == 0)
- npc->x -= 0x200;
+ npc->x -= 1 * 0x200;
else
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
break;
@@ -1572,7 +1579,7 @@
break;
case 2:
- if (npc->x < gMC.x && npc->x > gMC.x - 0x20000 && npc->y < gMC.y + 0x1000 && npc->y > gMC.y - 0x1000)
+ if (npc->x < gMC.x && npc->x > gMC.x - (16 * 0x10 * 0x200) && npc->y < gMC.y + (8 * 0x200) && npc->y > gMC.y - (8 * 0x200))
{
npc->act_no = 3;
npc->ani_wait = 0;
@@ -1613,7 +1620,7 @@
break;
case 4:
- if (npc->x < gMC.x + 0x20000 && npc->x > gMC.x && npc->y < gMC.y + 0x1000 && npc->y > gMC.y - 0x1000)
+ if (npc->x < gMC.x + (16 * 0x10 * 0x200) && npc->x > gMC.x && npc->y < gMC.y + (8 * 0x200) && npc->y > gMC.y - (8 * 0x200))
{
npc->act_no = 1;
npc->ani_wait = 0;
@@ -1633,6 +1640,7 @@
void ActNpc057(NPCHAR *npc)
{
unsigned char deg;
+
switch (npc->act_no)
{
case 0:
@@ -1639,12 +1647,12 @@
deg = Random(0, 0xFF);
npc->xm = GetCos(deg);
deg += 0x40;
- npc->tgt_x = npc->x + 8 * GetCos(deg);
+ npc->tgt_x = npc->x + (GetCos(deg) * 8);
deg = Random(0, 0xFF);
npc->ym = GetSin(deg);
deg += 0x40;
- npc->tgt_y = npc->y + 8 * GetSin(deg);
+ npc->tgt_y = npc->y + (GetSin(deg) * 8);
npc->act_no = 1;
npc->count1 = 120;
@@ -1698,7 +1706,7 @@
else
npc->direct = 2;
- if (npc->y > gMC.y + 0x6000)
+ if (npc->y > gMC.y + (48 * 0x200))
{
if (gMC.x < npc->x)
npc->xm += 0x10;
@@ -1806,7 +1814,7 @@
switch (npc->act_no)
{
case 0:
- if (gMC.x < npc->x + 0x2000 && gMC.x > npc->x - 0x2000)
+ if (gMC.x < npc->x + (16 * 0x200) && gMC.x > npc->x - (16 * 0x200))
{
npc->bits |= NPC_SHOOTABLE;
npc->ym = -0x100;
@@ -1820,26 +1828,26 @@
if (npc->direct == 0)
{
- npc->x = gMC.x + 0x20000;
+ npc->x = gMC.x + (16 * 0x10 * 0x200);
npc->xm = -0x2FF;
}
else
{
- npc->x = gMC.x - 0x20000;
+ npc->x = gMC.x - (16 * 0x10 * 0x200);
npc->xm = 0x2FF;
}
+
+ return;
}
- else
- {
- npc->rect.right = 0;
- npc->damage = 0;
- npc->xm = 0;
- npc->ym = 0;
- npc->bits &= ~NPC_SHOOTABLE;
- }
- break;
+ npc->rect.right = 0;
+ npc->damage = 0;
+ npc->xm = 0;
+ npc->ym = 0;
+ npc->bits &= ~NPC_SHOOTABLE;
+ return;
+
case 1:
if (npc->x > gMC.x)
{
@@ -1884,7 +1892,7 @@
npc->y += npc->ym;
}
- if (gMC.x > npc->x + 0x32000 || gMC.x < npc->x - 0x32000) // TODO: Maybe do something about this for widescreen
+ if (gMC.x > npc->x + (400 * 0x200) || gMC.x < npc->x - (400 * 0x200)) // TODO: Maybe do something about this for widescreen
{
npc->act_no = 0;
npc->xm = 0;
@@ -1892,53 +1900,57 @@
npc->x = npc->tgt_x;
npc->rect.right = 0;
npc->damage = 0;
- break;
+ return;
}
- if (npc->act_no) // This is always true
- {
- if (npc->act_wait < 150)
- ++npc->act_wait;
+ break;
+ }
- if (npc->act_wait == 150)
- {
- if ((++npc->count2 % 8) == 0 && npc->x < gMC.x + 0x14000 && npc->x > gMC.x - 0x14000) // TODO: Maybe do something about this for tallscreen
- {
- unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
- deg += (unsigned char)Random(-6, 6);
- int ym = 2 * GetSin(deg);
- int xm = 2 * GetCos(deg);
- SetNpChar(84, npc->x, npc->y, xm, ym, 0, 0, 0x100);
- PlaySoundObject(39, 1);
- }
+ if (npc->act_no != 0) // This is always true
+ {
+ if (npc->act_wait < 150)
+ ++npc->act_wait;
- if (npc->count2 > 8)
- {
- npc->act_wait = 0;
- npc->count2 = 0;
- }
- }
+ if (npc->act_wait == 150)
+ {
+ 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;
+
+ deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
+ deg += (unsigned char)Random(-6, 6);
+ ym = GetSin(deg) * 2;
+ xm = GetCos(deg) * 2;
+ SetNpChar(84, npc->x, npc->y, xm, ym, 0, NULL, 0x100);
+ PlaySoundObject(39, 1);
}
- if (++npc->ani_wait > 1)
+ if (npc->count2 > 8)
{
- npc->ani_wait = 0;
- ++npc->ani_no;
+ npc->act_wait = 0;
+ npc->count2 = 0;
}
+ }
+ }
- if (npc->ani_no > 1)
- npc->ani_no = 0;
+ if (++npc->ani_wait > 1)
+ {
+ npc->ani_wait = 0;
+ ++npc->ani_no;
+ }
- if (npc->act_wait > 120 && npc->act_wait / 2 % 2 == 1 && npc->ani_no == 1)
- npc->ani_no = 2;
+ if (npc->ani_no > 1)
+ npc->ani_no = 0;
- if (npc->direct == 0)
- npc->rect = rcLeft[npc->ani_no];
- else
- npc->rect = rcRight[npc->ani_no];
+ if (npc->act_wait > 120 && npc->act_wait / 2 % 2 == 1 && npc->ani_no == 1)
+ npc->ani_no = 2;
- break;
- }
+ if (npc->direct == 0)
+ npc->rect = rcLeft[npc->ani_no];
+ else
+ npc->rect = rcRight[npc->ani_no];
}
// Eye door
@@ -1956,9 +1968,8 @@
case 0:
npc->act_no = 1;
// Fallthrough
-
case 1:
- if (npc->x - 0x8000 < gMC.x && npc->x + 0x8000 > gMC.x && npc->y - 0x8000 < gMC.y && npc->y + 0x8000 > gMC.y)
+ if (npc->x - (64 * 0x200) < gMC.x && npc->x + (64 * 0x200) > gMC.x && npc->y - (64 * 0x200) < gMC.y && npc->y + (64 * 0x200) > gMC.y)
{
npc->act_no = 2;
npc->ani_wait = 0;
@@ -1979,11 +1990,15 @@
break;
case 3:
- if (npc->x - 0x8000 < gMC.x && npc->x + 0x8000 > gMC.x && npc->y - 0x8000 < gMC.y && npc->y + 0x8000 > gMC.y)
- break;
-
- npc->act_no = 4;
- npc->ani_wait = 0;
+ if (npc->x - (64 * 0x200) < gMC.x && npc->x + (64 * 0x200) > gMC.x && npc->y - (64 * 0x200) < gMC.y && npc->y + (64 * 0x200) > gMC.y)
+ {
+ // There probably used to be some commented-out code here
+ }
+ else
+ {
+ npc->act_no = 4;
+ npc->ani_wait = 0;
+ }
break;
--- a/src/NpcAct060.cpp
+++ b/src/NpcAct060.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "CommonDefines.h"
@@ -55,7 +57,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x2000 < gMC.x && npc->x + 0x2000 > gMC.x && npc->y - 0x2000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (16 * 0x200) < gMC.x && npc->x + (16 * 0x200) > gMC.x && npc->y - (16 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -130,7 +132,7 @@
else
npc->xm = 0x100;
- if (npc->act_wait++ && npc->flag & 8)
+ if (npc->act_wait++ != 0 && npc->flag & 8)
npc->act_no = 3;
break;
@@ -142,7 +144,7 @@
npc->ym = -0x200;
// Fallthrough
case 9:
- if (npc->act_wait++ && npc->flag & 8)
+ if (npc->act_wait++ != 0 && npc->flag & 8)
npc->act_no = 0;
break;
@@ -161,7 +163,7 @@
break;
case 11:
- if (npc->act_wait++ && npc->flag & 8)
+ if (npc->act_wait++ != 0 && npc->flag & 8)
{
npc->act_no = 12;
npc->ani_no = 7;
@@ -273,7 +275,7 @@
else
npc->xm = 0x200;
- if (npc->act_wait++ && npc->flag & 8)
+ if (npc->act_wait++ != 0 && npc->flag & 8)
npc->act_no = 5;
break;
@@ -369,7 +371,7 @@
if (++npc->act_wait > 100)
{
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
npc->act_no = 50;
npc->surf = SURFACE_ID_NPC_SYM;
@@ -433,13 +435,12 @@
switch (npc->act_no)
{
case 0:
- npc->x -= 0x800;
- npc->y += 0x2000;
+ npc->x -= 4 * 0x200;
+ npc->y += 16 * 0x200;
npc->act_no = 1;
npc->ani_no = 0;
npc->ani_wait = 0;
// Fallthrough
-
case 1:
if (++npc->ani_wait > 2)
{
@@ -536,7 +537,7 @@
else
npc->xm = 0x100;
- if (npc->act_wait++ && npc->flag & 8)
+ if (npc->act_wait++ != 0 && npc->flag & 8)
npc->act_no = 2;
break;
@@ -593,7 +594,7 @@
else
npc->xm = 0x100;
- if (npc->act_wait++ && npc->flag & 8)
+ if (npc->act_wait++ != 0 && npc->flag & 8)
{
npc->act_no = 5;
npc->bits |= NPC_INTERACTABLE;
@@ -644,7 +645,7 @@
switch (npc->act_no)
{
case 0: // Initialize
- npc->y += 0x600;
+ npc->y += 3 * 0x200;
npc->act_no = 1;
// Fallthrough
case 1: // Waiting
@@ -658,7 +659,7 @@
++npc->tgt_x;
// Open eyes near player
- if (npc->act_wait >= 8 && npc->x - 0xE000 < gMC.x && npc->x + 0xE000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0xA000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (112 * 0x200) < gMC.x && npc->x + (112 * 0x200) > gMC.x && npc->y - (80 * 0x200) < gMC.y && npc->y + (80 * 0x200) > gMC.y)
{
npc->ani_no = 1;
}
@@ -679,7 +680,7 @@
}
// Jump if player is nearby
- if (npc->act_wait >= 8 && npc->tgt_x >= 100 && npc->x - 0x8000 < gMC.x && npc->x + 0x8000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0x6000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->tgt_x >= 100 && npc->x - (64 * 0x200) < gMC.x && npc->x + (64 * 0x200) > gMC.x && npc->y - (80 * 0x200) < gMC.y && npc->y + (48 * 0x200) > gMC.y)
{
npc->act_no = 2;
npc->ani_no = 0;
@@ -823,8 +824,6 @@
{
case 0:
int a;
- unsigned char deg;
-
for (a = 0; a < 0x200; ++a)
if (gNPC[a].code_event == 1000)
break;
@@ -835,9 +834,12 @@
npc->tgt_x = gNPC[a].x;
npc->tgt_y = gNPC[a].y;
npc->count1 = a;
+
+ unsigned char deg;
deg = GetArktan(npc->x - npc->tgt_x, npc->y - npc->tgt_y);
- npc->xm = 2 * GetCos(deg);
- npc->ym = 2 * GetSin(deg);
+ npc->xm = GetCos(deg) * 2;
+ npc->ym = GetSin(deg) * 2;
+
npc->act_no = 1;
// Fallthrough
case 1:
@@ -850,7 +852,7 @@
if (npc->ani_no > 1)
npc->ani_no = 0;
- if (npc->x - 0x600 < npc->tgt_x && npc->x + 0x600 > npc->tgt_x && npc->y - 0x600 < npc->tgt_y && npc->y + 0x600 > npc->tgt_y)
+ if (npc->x - (3 * 0x200) < npc->tgt_x && npc->x + (3 * 0x200) > npc->tgt_x && npc->y - (3 * 0x200) < npc->tgt_y && npc->y + (3 * 0x200) > npc->tgt_y)
{
npc->act_no = 2;
npc->ani_no = 2;
@@ -869,7 +871,7 @@
if (npc->ym < -0x5FF)
npc->ym = -0x5FF;
- if (npc->y < -0x1000)
+ if (npc->y < -8 * 0x200)
npc->cond = 0;
if (++npc->ani_wait > 3)
@@ -957,7 +959,7 @@
if (++npc->act_wait == 30)
{
PlaySoundObject(21, 1);
- SetNpChar(66, npc->x, npc->y - 0x2000, 0, 0, 0, npc, 0);
+ SetNpChar(66, npc->x, npc->y - (16 * 0x200), 0, 0, 0, npc, 0);
}
if (npc->act_wait == 50)
@@ -974,7 +976,7 @@
case 21:
npc->ym -= 0x20;
- if (npc->y < -0x1000)
+ if (npc->y < -8 * 0x200)
npc->cond = 0;
break;
@@ -1033,7 +1035,7 @@
if (npc->act_no == 11)
{
- if (npc->ani_wait)
+ if (npc->ani_wait != 0)
{
--npc->ani_wait;
npc->ani_no = 1;
@@ -1049,7 +1051,7 @@
if (npc->act_no == 14)
{
- if (npc->ani_wait)
+ if (npc->ani_wait != 0)
{
--npc->ani_wait;
npc->ani_no = 3;
@@ -1069,7 +1071,7 @@
npc->rect = rcRight[npc->ani_no];
if (npc->act_no == 1 && npc->ani_wait < 32)
- npc->rect.bottom = ++npc->ani_wait / 2 + npc->rect.bottom - 16;
+ npc->rect.bottom = (++npc->ani_wait / 2) + npc->rect.bottom - 16;
}
// Balrog (running)
@@ -1119,32 +1121,32 @@
else
npc->xm += 0x10;
- if (npc->act_wait >= 8 && npc->x - 0x1800 < gMC.x && npc->x + 0x1800 > gMC.x && npc->y - 0x1800 < gMC.y && npc->y + 0x1000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (12 * 0x200) < gMC.x && npc->x + (12 * 0x200) > gMC.x && npc->y - (12 * 0x200) < gMC.y && npc->y + (8 * 0x200) > gMC.y)
{
npc->act_no = 10;
npc->ani_no = 5;
gMC.cond |= 2;
DamageMyChar(2);
+ break;
}
- else
- {
- ++npc->act_wait;
- if (npc->flag & 5 || npc->act_wait > 75)
- {
- npc->act_no = 9;
- npc->ani_no = 0;
- }
- else if ((npc->count1 % 3) == 0 && npc->act_wait > 25)
- {
- npc->act_no = 4;
- npc->ani_no = 7;
- npc->ym = -0x400;
- }
+ ++npc->act_wait;
+ if (npc->flag & 5 || npc->act_wait > 75)
+ {
+ npc->act_no = 9;
+ npc->ani_no = 0;
break;
}
+ if ((npc->count1 % 3) == 0 && npc->act_wait > 25)
+ {
+ npc->act_no = 4;
+ npc->ani_no = 7;
+ npc->ym = -0x400;
+ break;
+ }
+
break;
case 4:
@@ -1156,7 +1158,7 @@
PlaySoundObject(26, 1);
}
- if (npc->act_wait >= 8 && npc->x - 0x1800 < gMC.x && npc->x + 0x1800 > gMC.x && npc->y - 0x1800 < gMC.y && npc->y + 0x1000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (12 * 0x200) < gMC.x && npc->x + (12 * 0x200) > gMC.x && npc->y - (12 * 0x200) < gMC.y && npc->y + (8 * 0x200) > gMC.y)
{
npc->act_no = 10;
npc->ani_no = 5;
@@ -1167,9 +1169,9 @@
break;
case 9:
- npc->xm = 4 * npc->xm / 5;
+ npc->xm = (npc->xm * 4) / 5;
- if (npc->xm)
+ if (npc->xm != 0)
break;
npc->act_no = 0;
@@ -1180,9 +1182,9 @@
gMC.x = npc->x;
gMC.y = npc->y;
- npc->xm = 4 * npc->xm / 5;
+ npc->xm = (npc->xm * 4) / 5;
- if (npc->xm)
+ if (npc->xm != 0)
break;
npc->act_no = 11;
@@ -1216,8 +1218,8 @@
if (npc->direct == 0)
{
- gMC.x += 0x800;
- gMC.y -= 0x1000;
+ gMC.x += 4 * 0x200;
+ gMC.y -= 8 * 0x200;
gMC.xm = 0x5FF;
gMC.ym = -0x200;
gMC.direct = 2;
@@ -1225,8 +1227,8 @@
}
else
{
- gMC.x -= 0x800;
- gMC.y -= 0x1000;
+ gMC.x -= 4 * 0x200;
+ gMC.y -= 8 * 0x200;
gMC.xm = -0x5FF;
gMC.ym = -0x200;
gMC.direct = 0;
@@ -1323,24 +1325,22 @@
npc->act_no = 2;
npc->act_wait = 0;
npc->ani_no = 1;
+ break;
}
- else
+
+ if (Random(0, 150) == 1)
{
- if (Random(0, 150) == 1)
- {
- if (npc->direct == 0)
- npc->direct = 2;
- else
- npc->direct = 0;
- }
+ if (npc->direct == 0)
+ npc->direct = 2;
+ else
+ npc->direct = 0;
+ }
- if (Random(0, 150) == 1)
- {
- npc->act_no = 3;
- npc->act_wait = 50;
- npc->ani_no = 0;
- }
-
+ if (Random(0, 150) == 1)
+ {
+ npc->act_no = 3;
+ npc->act_wait = 50;
+ npc->ani_no = 0;
break;
}
@@ -1524,12 +1524,12 @@
return;
}
- if (gMC.x < npc->x + (WINDOW_WIDTH * 0x200) && gMC.x > npc->x - (WINDOW_WIDTH * 0x200) && gMC.y < npc->y + (WINDOW_HEIGHT * 0x200) && gMC.y > npc->y - (WINDOW_HEIGHT * 0x200))
+ if (gMC.x < npc->x + (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.x > npc->x - (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.y < npc->y + (((WINDOW_HEIGHT / 2) + 120) * 0x200) && gMC.y > npc->y - (((WINDOW_HEIGHT / 2) + 120) * 0x200))
{
if (++npc->act_no % 2)
- SetNpChar(73, npc->x, npc->y, 2 * Random(-0x200, 0x200), 3 * Random(-0x200, 0x80), 0, 0, 0x100);
+ SetNpChar(73, npc->x, npc->y, Random(-0x200, 0x200) * 2, Random(-0x200, 0x80) * 3, 0, NULL, 0x100);
- SetNpChar(73, npc->x, npc->y, 2 * Random(-0x200, 0x200), 3 * Random(-0x200, 0x80), 0, 0, 0x100);
+ SetNpChar(73, npc->x, npc->y, Random(-0x200, 0x200) * 2, Random(-0x200, 0x80) * 3, 0, NULL, 0x100);
}
}
@@ -1691,7 +1691,7 @@
npc->ani_wait = 0;
// Fallthrough
case 1:
- if (npc->x - 0x6000 < gMC.x && npc->x + 0x6000 > gMC.x && npc->y - 0x6000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (48 * 0x200) < gMC.x && npc->x + (48 * 0x200) > gMC.x && npc->y - (48 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
npc->ani_no = 1;
else
npc->ani_no = 0;
@@ -1705,7 +1705,7 @@
// Flowers
void ActNpc076(NPCHAR *npc)
{
- npc->rect.left = 16 * npc->code_event;
+ npc->rect.left = npc->code_event * 16;
npc->rect.top = 0;
npc->rect.right = npc->rect.left + 16;
npc->rect.bottom = 16;
@@ -1800,7 +1800,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x4000 < gMC.x && npc->x + 0x4000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (32 * 0x200) < gMC.x && npc->x + (32 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
--- a/src/NpcAct080.cpp
+++ b/src/NpcAct080.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Back.h"
@@ -42,12 +44,12 @@
npc->bits &= ~NPC_SHOOTABLE;
npc->act_no = 1;
npc->damage = 0;
- npc->hit.front = 0x800;
+ npc->hit.front = 4 * 0x200;
// Fallthrough
case 1:
npc->ani_no = 0;
- if (npc->x - 0x10000 < gMC.x && npc->x + 0x10000 > gMC.x && npc->y - 0x6000 < gMC.y && npc->y + 0x4000 > gMC.y)
+ if (npc->x - (128 * 0x200) < gMC.x && npc->x + (128 * 0x200) > gMC.x && npc->y - (48 * 0x200) < gMC.y && npc->y + (32 * 0x200) > gMC.y)
{
npc->ani_wait = 0;
npc->act_no = 2;
@@ -78,9 +80,9 @@
if (npc->ani_no > 3)
npc->ani_no = 0;
- if (npc->x - 0x2000 < gMC.x && npc->x + 0x2000 > gMC.x)
+ if (npc->x - (16 * 0x200) < gMC.x && npc->x + (16 * 0x200) > gMC.x)
{
- npc->hit.front = 0x2400;
+ npc->hit.front = (18 * 0x200);
npc->act_wait = 0;
npc->act_no = 3;
npc->bits |= NPC_SHOOTABLE;
@@ -157,6 +159,7 @@
if (npc->ym < -0x5FF)
npc->ym = -0x5FF;
#else
+ // Caps npc->xm instead of npc->ym
if (npc->ym > 0x5FF)
npc->xm = 0x5FF;
if (npc->ym < -0x5FF)
@@ -207,24 +210,22 @@
npc->act_no = 2;
npc->act_wait = 0;
npc->ani_no = 1;
+ break;
}
- else
+
+ if (Random(0, 150) == 1)
{
- if (Random(0, 150) == 1)
- {
- if (npc->direct == 0)
- npc->direct = 2;
- else
- npc->direct = 0;
- }
+ if (npc->direct == 0)
+ npc->direct = 2;
+ else
+ npc->direct = 0;
+ }
- if (Random(0, 150) == 1)
- {
- npc->act_no = 3;
- npc->act_wait = 50;
- npc->ani_no = 0;
- }
-
+ if (Random(0, 150) == 1)
+ {
+ npc->act_no = 3;
+ npc->act_wait = 50;
+ npc->ani_no = 0;
break;
}
@@ -353,7 +354,7 @@
if (++npc->act_wait == 30)
{
PlaySoundObject(21, 1);
- SetNpChar(66, npc->x, npc->y - 0x2000, 0, 0, 0, npc, 0);
+ SetNpChar(66, npc->x, npc->y - (16 * 0x200), 0, 0, 0, npc, 0);
}
if (npc->act_wait == 50)
@@ -370,7 +371,7 @@
case 21:
npc->ym -= 0x20;
- if (npc->y < -0x1000)
+ if (npc->y < -8 * 0x200)
npc->cond = 0;
break;
@@ -440,7 +441,7 @@
case 30:
case 40:
case 50:
- SetNpChar(11, npc->x + 0x1000, npc->y - 0x1000, 0x600, Random(-0x200, 0), 0, 0, 0x100);
+ SetNpChar(11, npc->x + (8 * 0x200), npc->y - (8 * 0x200), 0x600, Random(-0x200, 0), 0, NULL, 0x100);
PlaySoundObject(33, 1);
break;
}
@@ -484,7 +485,7 @@
if (npc->act_no == 11)
{
- if (npc->ani_wait)
+ if (npc->ani_wait != 0)
{
--npc->ani_wait;
npc->ani_no = 1;
@@ -500,7 +501,7 @@
if (npc->act_no == 14)
{
- if (npc->ani_wait)
+ if (npc->ani_wait != 0)
{
--npc->ani_wait;
npc->ani_no = 3;
@@ -688,7 +689,7 @@
case 0:
npc->ani_no = 0;
- if (npc->x - 0x1000 < gMC.x && npc->x + 0x1000 > gMC.x && npc->y - 0x2000 < gMC.y && npc->y + 0x1000 > gMC.y)
+ if (npc->x - (8 * 0x200) < gMC.x && npc->x + (8 * 0x200) > gMC.x && npc->y - (16 * 0x200) < gMC.y && npc->y + (8 * 0x200) > gMC.y)
{
PlaySoundObject(43, 1);
npc->act_no = 1;
@@ -747,11 +748,11 @@
npc->xm -= 8;
- if (npc->x < 0xA000)
+ if (npc->x < 80 * 0x200)
npc->cond = 0;
- if (npc->x < -0x600)
- npc->x = -0x600;
+ if (npc->x < -3 * 0x200)
+ npc->x = -3 * 0x200;
if (npc->flag & 1)
npc->xm = 0x100;
@@ -828,11 +829,11 @@
npc->xm -= 8;
- if (npc->x < 0xA000)
+ if (npc->x < 80 * 0x200)
npc->cond = 0;
- if (npc->x < -0x600)
- npc->x = -0x600;
+ if (npc->x < -3 * 0x200)
+ npc->x = -3 * 0x200;
if (npc->flag & 1)
npc->xm = 0x100;
@@ -941,6 +942,7 @@
if (++npc->count1 < 3 || npc->life > 150)
{
npc->count2 = 0;
+
if (gMC.x < npc->x)
npc->direct = 0;
else
@@ -989,7 +991,7 @@
npc->ym = -0x400;
npc->act_no = 7;
npc->act_wait = 0;
- npc->xm = 3 * npc->xm / 2;
+ npc->xm = (npc->xm * 3) / 2;
npc->damage = 2;
break;
}
@@ -997,12 +999,12 @@
{
if (npc->direct == 0)
{
- if (npc->x - 0x3000 < gMC.x)
+ if (npc->x - (24 * 0x200) < gMC.x)
npc->act_no = 4;
}
else
{
- if (npc->x + 0x3000 > gMC.x)
+ if (npc->x + (24 * 0x200) > gMC.x)
npc->act_no = 4;
}
}
@@ -1023,7 +1025,7 @@
npc->ani_no = 7;
PlaySoundObject(70, 1);
npc->damage = 5;
- npc->hit.front = 0x3000;
+ npc->hit.front = 24 * 0x200;
npc->hit.top = 1;
}
@@ -1035,8 +1037,8 @@
npc->act_no = 0;
npc->ani_no = 0;
npc->damage = 0;
- npc->hit.front = 0x1000;
- npc->hit.top = 0x2000;
+ npc->hit.front = 8 * 0x200;
+ npc->hit.top = 16 * 0x200;
}
break;
@@ -1051,7 +1053,7 @@
npc->damage = 0;
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
}
break;
@@ -1087,9 +1089,9 @@
deg = 0xF8;
deg += (unsigned char)Random(-0x10, 0x10);
- ym = 3 * GetSin(deg);
- xm = 3 * GetCos(deg);
- SetNpChar(11, npc->x, npc->y + 0x800, xm, ym, 0, 0, 0x100);
+ ym = GetSin(deg) * 3;
+ xm = GetCos(deg) * 3;
+ SetNpChar(11, npc->x, npc->y + (4 * 0x200), xm, ym, 0, NULL, 0x100);
PlaySoundObject(12, 1);
}
@@ -1152,7 +1154,7 @@
npc->direct = 2;
for (i = 0; i < 8; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
npc->act_no = 1;
// Fallthrough
@@ -1164,7 +1166,7 @@
}
if (npc->act_wait % 5 == 0)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
if (npc->direct == 0)
npc->rect = rcLeft[0];
@@ -1180,16 +1182,16 @@
if (++npc->act_wait / 2 % 2 && npc->act_wait < 100)
{
npc->ani_no = 0;
- npc->view.back = 0x2800;
- npc->view.front = 0x2800;
- npc->view.top = 0x2800;
+ npc->view.back = 20 * 0x200;
+ npc->view.front = 20 * 0x200;
+ npc->view.top = 20 * 0x200;
}
else
{
npc->ani_no = 1;
- npc->view.back = 0x1800;
- npc->view.front = 0x1800;
- npc->view.top = 0x1000;
+ npc->view.back = 12 * 0x200;
+ npc->view.front = 12 * 0x200;
+ npc->view.top = 8 * 0x200;
}
if (npc->act_wait > 150)
@@ -1200,7 +1202,7 @@
}
if (npc->act_wait % 9 == 0)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no];
@@ -1251,7 +1253,7 @@
if (npc->act_no == 0)
{
++npc->act_no;
- npc->y += 0x10 * 0x200;
+ npc->y += 16 * 0x200;
}
npc->rect = rect;
@@ -1269,8 +1271,8 @@
switch (npc->act_no)
{
case 0:
- npc->x -= 0x800;
- npc->y += 0x2000;
+ npc->x -= 4 * 0x200;
+ npc->y += 16 * 0x200;
npc->act_no = 1;
npc->ani_no = 0;
npc->ani_wait = 0;
@@ -1362,7 +1364,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x4000 < gMC.x && npc->x + 0x4000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (32 * 0x200) < gMC.x && npc->x + (32 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -1397,9 +1399,9 @@
npc->ani_no = 2;
if (npc->direct == 0)
- npc->x -= 0x200;
+ npc->x -= 1 * 0x200;
else
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
break;
@@ -1529,7 +1531,7 @@
npc->direct = 0;
}
- if (npc->count1)
+ if (npc->count1 != 0)
{
--npc->count1;
@@ -1735,13 +1737,13 @@
if (npc->ani_no > 2)
npc->ani_no = 0;
- if (gMC.x > npc->x - (WINDOW_WIDTH * 0x200) && gMC.x < npc->x + (WINDOW_WIDTH * 0x200) && gMC.y > npc->y - (WINDOW_HEIGHT * 0x200) && gMC.y < npc->y + (WINDOW_HEIGHT * 0x200))
+ if (gMC.x > npc->x - (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.x < npc->x + (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.y > npc->y - (((WINDOW_HEIGHT / 2) + 120) * 0x200) && gMC.y < npc->y + (((WINDOW_HEIGHT / 2) + 120) * 0x200))
{
if (Random(0, 5) == 1)
- SetNpChar(199, npc->x, npc->y + (Random(-8, 8) * 0x200), 0, 0, 0, 0, 0x100);
+ SetNpChar(199, npc->x, npc->y + (Random(-8, 8) * 0x200), 0, 0, 0, NULL, 0x100);
}
- if (gMC.y < npc->y + 0x1000 && gMC.y > npc->y - 0x1000 && gMC.x < npc->x && gMC.x > npc->x - 0xC000)
+ if (gMC.y < npc->y + (8 * 0x200) && gMC.y > npc->y - (8 * 0x200) && gMC.x < npc->x && gMC.x > npc->x - (96 * 0x200))
{
gMC.xm -= 0x88;
gMC.cond |= 0x20;
@@ -1785,13 +1787,13 @@
if (npc->ani_no > 2)
npc->ani_no = 0;
- if (gMC.x > npc->x - (WINDOW_WIDTH * 0x200) && gMC.x < npc->x + (WINDOW_WIDTH * 0x200) && gMC.y > npc->y - (WINDOW_HEIGHT * 0x200) && gMC.y < npc->y + (WINDOW_HEIGHT * 0x200))
+ if (gMC.x > npc->x - (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.x < npc->x + (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.y > npc->y - (((WINDOW_HEIGHT / 2) + 120) * 0x200) && gMC.y < npc->y + (((WINDOW_HEIGHT / 2) + 120) * 0x200))
{
if (Random(0, 5) == 1)
- SetNpChar(199, npc->x + (Random(-8, 8) * 0x200), npc->y, 0, 0, 1, 0, 0x100);
+ SetNpChar(199, npc->x + (Random(-8, 8) * 0x200), npc->y, 0, 0, 1, NULL, 0x100);
}
- if (gMC.x < npc->x + 0x1000 && gMC.x > npc->x - 0x1000 && gMC.y < npc->y && gMC.y > npc->y - 0xC000)
+ if (gMC.x < npc->x + (8 * 0x200) && gMC.x > npc->x - (8 * 0x200) && gMC.y < npc->y && gMC.y > npc->y - (96 * 0x200))
gMC.ym -= 0x88;
break;
@@ -1832,13 +1834,13 @@
if (npc->ani_no > 2)
npc->ani_no = 0;
- if (gMC.x > npc->x - (WINDOW_WIDTH * 0x200) && gMC.x < npc->x + (WINDOW_WIDTH * 0x200) && gMC.y > npc->y - (WINDOW_HEIGHT * 0x200) && gMC.y < npc->y + (WINDOW_HEIGHT * 0x200))
+ if (gMC.x > npc->x - (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.x < npc->x + (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.y > npc->y - (((WINDOW_HEIGHT / 2) + 120) * 0x200) && gMC.y < npc->y + (((WINDOW_HEIGHT / 2) + 120) * 0x200))
{
if (Random(0, 5) == 1)
- SetNpChar(199, npc->x, npc->y + (Random(-8, 8) * 0x200), 0, 0, 2, 0, 0x100);
+ SetNpChar(199, npc->x, npc->y + (Random(-8, 8) * 0x200), 0, 0, 2, NULL, 0x100);
}
- if (gMC.y < npc->y + 0x1000 && gMC.y > npc->y - 0x1000 && gMC.x < npc->x + 0xC000 && gMC.x > npc->x)
+ if (gMC.y < npc->y + (8 * 0x200) && gMC.y > npc->y - (8 * 0x200) && gMC.x < npc->x + (96 * 0x200) && gMC.x > npc->x)
{
gMC.xm += 0x88;
gMC.cond |= 0x20;
@@ -1882,13 +1884,13 @@
if (npc->ani_no > 2)
npc->ani_no = 0;
- if (gMC.x > npc->x - (WINDOW_WIDTH * 0x200) && gMC.x < npc->x + (WINDOW_WIDTH * 0x200) && gMC.y > npc->y - (WINDOW_HEIGHT * 0x200) && gMC.y < npc->y + (WINDOW_HEIGHT * 0x200))
+ if (gMC.x > npc->x - (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.x < npc->x + (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.y > npc->y - (((WINDOW_HEIGHT / 2) + 120) * 0x200) && gMC.y < npc->y + (((WINDOW_HEIGHT / 2) + 120) * 0x200))
{
if (Random(0, 5) == 1)
- SetNpChar(199, npc->x + (Random(-8, 8) * 0x200), npc->y, 0, 0, 3, 0, 0x100);
+ SetNpChar(199, npc->x + (Random(-8, 8) * 0x200), npc->y, 0, 0, 3, NULL, 0x100);
}
- if (gMC.x < npc->x + 0x1000 && gMC.x > npc->x - 0x1000 && gMC.y < npc->y + 0xC000 && gMC.y > npc->y)
+ if (gMC.x < npc->x + (8 * 0x200) && gMC.x > npc->x - (8 * 0x200) && gMC.y < npc->y + (96 * 0x200) && gMC.y > npc->y)
gMC.ym += 0x88;
break;
--- a/src/NpcAct100.cpp
+++ b/src/NpcAct100.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Bullet.h"
@@ -21,7 +23,7 @@
switch (npc->act_no)
{
case 0:
- npc->y += 0x2000;
+ npc->y += 16 * 0x200;
npc->act_no = 1;
break;
}
@@ -66,7 +68,7 @@
if (npc->act_no == 0)
{
npc->act_no = 1;
- npc->y += 0x1000;
+ npc->y += 8 * 0x200;
}
if (++npc->ani_wait > 0)
@@ -136,6 +138,8 @@
// Frog
void ActNpc104(NPCHAR *npc)
{
+ BOOL bJump;
+
RECT rcLeft[3] = {
{0, 112, 32, 144},
{32, 112, 64, 144},
@@ -168,10 +172,8 @@
npc->act_no = 3;
break;
}
- else
- {
- npc->bits &= ~NPC_IGNORE_SOLIDITY;
- }
+
+ npc->bits &= ~NPC_IGNORE_SOLIDITY;
// Fallthrough
case 1:
++npc->act_wait;
@@ -246,7 +248,7 @@
break;
}
- BOOL bJump = FALSE;
+ bJump = FALSE;
if (npc->act_no < 10 && npc->act_no != 3 && npc->act_wait > 10)
{
@@ -253,9 +255,10 @@
if (npc->shock)
bJump = TRUE;
- if (npc->x < gMC.x - 0x14000 || npc->x > gMC.x + 0x14000 || npc->y < gMC.y - 0x8000 || npc->y > gMC.y + 0x8000)
+ if (npc->x < gMC.x - (160 * 0x200) || npc->x > gMC.x + (160 * 0x200) || npc->y < gMC.y - (64 * 0x200) || npc->y > gMC.y + (64 * 0x200))
{
- // For some reason this blank space is needed for the function to compile accurately
+ // This blank space is needed for the function to produce the same assembly.
+ // Chances are there used to be some commented-out code here.
}
else
{
@@ -309,7 +312,7 @@
npc->cond = 0;
if (npc->act_wait < 5)
- npc->y -= 0x200;
+ npc->y -= 1 * 0x200;
npc->rect = rect[npc->ani_no];
}
@@ -320,7 +323,7 @@
switch (npc->act_no)
{
case 0:
- SetNpChar(105, npc->x, npc->y - 0x1000, 0, 0, 0, 0, 0x180);
+ SetNpChar(105, npc->x, npc->y - (8 * 0x200), 0, 0, 0, NULL, 0x180);
npc->act_no = 1;
break;
}
@@ -347,7 +350,7 @@
npc->ani_wait = 0;
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
// Fallthrough
case 11:
@@ -384,12 +387,12 @@
case 15:
if (npc->act_wait / 2 % 2)
{
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
PlaySoundObject(11, 1);
}
else
{
- npc->x -= 0x200;
+ npc->x -= 1 * 0x200;
}
if (++npc->act_wait > 50)
@@ -404,7 +407,7 @@
PlaySoundObject(12, 1);
for (i = 0; i < 8; ++i)
- SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
// Fallthrough
case 17:
@@ -438,7 +441,7 @@
PlaySoundObject(12, 1);
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
}
break;
@@ -546,7 +549,7 @@
switch (npc->act_no)
{
case 0:
- if (--npc->act_wait)
+ if (--npc->act_wait != 0)
npc->act_no = 1;
npc->ani_no = 0;
@@ -560,7 +563,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x4000 < gMC.x && npc->x + 0x4000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (32 * 0x200) < gMC.x && npc->x + (32 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -584,7 +587,7 @@
PlaySoundObject(12, 1);
for (i = 0; i < 8; ++i)
- SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
break;
}
@@ -604,6 +607,8 @@
// Puchi
void ActNpc110(NPCHAR *npc)
{
+ BOOL bJump;
+
RECT rcLeft[3] = {
{96, 128, 112, 144},
{112, 128, 128, 144},
@@ -626,7 +631,7 @@
if (npc->direct == 4)
{
- if (Random(0, 1) != 0)
+ if (Random(0, 1))
npc->direct = 0;
else
npc->direct = 2;
@@ -637,10 +642,8 @@
break;
}
- else
- {
- npc->bits &= ~NPC_IGNORE_SOLIDITY;
- }
+
+ npc->bits &= ~NPC_IGNORE_SOLIDITY;
// Fallthrough
case 1:
++npc->act_wait;
@@ -715,7 +718,7 @@
break;
}
- BOOL bJump = FALSE;
+ bJump = FALSE;
if (npc->act_no < 10 && npc->act_no != 3 && npc->act_wait > 10)
{
@@ -722,9 +725,10 @@
if (npc->shock)
bJump = TRUE;
- if (npc->x < gMC.x - 0x14000 || npc->x > gMC.x + 0x14000 || npc->y < gMC.y - 0x8000 || npc->y > gMC.y + 0x8000)
+ if (npc->x < gMC.x - (160 * 0x200) || npc->x > gMC.x + (160 * 0x200) || npc->y < gMC.y - (64 * 0x200) || npc->y > gMC.y + (64 * 0x200))
{
- // For some reason this blank space is needed for the function to compile accurately
+ // This blank space is needed for the function to produce the same assembly.
+ // Chances are there used to be some commented-out code here.
}
else
{
@@ -782,7 +786,7 @@
case 0:
npc->act_no = 1;
npc->ani_no = 0;
- npc->y -= 0x2000;
+ npc->y -= 16 * 0x200;
break;
case 1:
@@ -798,7 +802,7 @@
case 2:
if (npc->ym > 0)
- npc->hit.bottom = 0x2000;
+ npc->hit.bottom = 16 * 0x200;
if (npc->flag & 8)
{
@@ -837,6 +841,7 @@
else
npc->rect = rcRight[npc->ani_no];
+ // Use a different sprite if the player is wearing the Mimiga Mask
if (gMC.equip & 0x40)
{
npc->rect.top += 32;
@@ -845,7 +850,7 @@
if (npc->act_no == 4)
{
- npc->rect.bottom = npc->rect.top + npc->act_wait / 4;
+ npc->rect.bottom = npc->rect.top + (npc->act_wait / 4);
if (npc->act_wait / 2 % 2)
++npc->rect.left;
@@ -871,8 +876,8 @@
npc->act_no = 1;
npc->ani_no = 0;
npc->ani_wait = 0;
- npc->x += 0x2000;
- npc->y += 0x1000;
+ npc->x += 16 * 0x200;
+ npc->y += 8 * 0x200;
PlaySoundObject(29, 1);
// Fallthrough
case 1:
@@ -889,7 +894,7 @@
{
npc->act_no = 3;
npc->ani_no = 1;
- npc->hit.bottom = 0x1000;
+ npc->hit.bottom = 8 * 0x200;
}
break;
@@ -913,6 +918,7 @@
else
npc->rect = rcRight[npc->ani_no];
+ // Use a different sprite if the player is wearing the Mimiga Mask
if (gMC.equip & 0x40)
{
npc->rect.top += 32;
@@ -921,7 +927,7 @@
if (npc->act_no == 1)
{
- npc->rect.bottom = npc->rect.top + npc->act_wait / 4;
+ npc->rect.bottom = npc->rect.top + (npc->act_wait / 4);
if (npc->act_wait / 2 % 2)
++npc->rect.left;
@@ -993,9 +999,9 @@
npc->ani_no = 2;
if (npc->direct == 0)
- npc->x -= 0x200;
+ npc->x -= 1 * 0x200;
else
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
break;
@@ -1007,9 +1013,9 @@
npc->act_no = 31;
npc->ani_no = 0;
npc->ani_wait = 0;
- npc->hit.bottom = 0x2000;
- npc->x -= 0x2000;
- npc->y += 0x1000;
+ npc->hit.bottom = 16 * 0x200;
+ npc->x -= 16 * 0x200;
+ npc->y += 8 * 0x200;
PlaySoundObject(29, 1);
// Fallthrough
case 31:
@@ -1026,7 +1032,7 @@
{
npc->act_no = 33;
npc->ani_no = 1;
- npc->hit.bottom = 0x1000;
+ npc->hit.bottom = 8 * 0x200;
}
break;
@@ -1052,7 +1058,7 @@
if (npc->act_no == 31)
{
- npc->rect.bottom = npc->rect.top + npc->act_wait / 4;
+ npc->rect.bottom = npc->rect.top + (npc->act_wait / 4);
if (npc->act_wait / 2 % 2)
++npc->rect.left;
@@ -1062,6 +1068,8 @@
// Press
void ActNpc114(NPCHAR *npc)
{
+ int i;
+
RECT rcLeft[3] = {
{144, 112, 160, 136},
{160, 112, 176, 136},
@@ -1072,16 +1080,20 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x800;
+ npc->y -= 4 * 0x200;
// Fallthrough
case 1:
if (npc->flag & 8)
- break;
+ {
+ // Chances are there used to be commented-out code here
+ }
+ else
+ {
+ npc->act_no = 10;
+ npc->ani_wait = 0;
+ npc->ani_no = 1;
+ }
- npc->act_no = 10;
- npc->ani_wait = 0;
- npc->ani_no = 1;
-
break;
case 10:
@@ -1109,8 +1121,8 @@
{
if (npc->ani_no > 1)
{
- for (int i = 0; i < 4; ++i)
- SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
PlaySoundObject(26, 1);
SetQuake(10);
@@ -1166,7 +1178,7 @@
npc->count1 = 0;
// Fallthrough
case 1:
- if (gMC.x < npc->x + 0xC000 && gMC.x > npc->x - 0xC000 && gMC.y < npc->y + 0x4000 && gMC.y > npc->y - 0xC000)
+ if (gMC.x < npc->x + (96 * 0x200) && gMC.x > npc->x - (96 * 0x200) && gMC.y < npc->y + (32 * 0x200) && gMC.y > npc->y - (96 * 0x200))
npc->act_no = 10;
if (npc->shock)
@@ -1241,7 +1253,7 @@
npc->ani_wait = 0;
npc->damage = 0;
- if (gMC.x > npc->x + 0x12000 || gMC.x < npc->x - 0x12000 || gMC.y > npc->y + 0x6000 || gMC.y < npc->y - 0x12000)
+ if (gMC.x > npc->x + (144 * 0x200) || gMC.x < npc->x - (144 * 0x200) || gMC.y > npc->y + (48 * 0x200) || gMC.y < npc->y - (144 * 0x200))
npc->act_no = 0;
}
@@ -1249,7 +1261,7 @@
case 30:
for (i = 0; i < 8; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
npc->ani_no = 0;
npc->act_no = 0;
@@ -1353,14 +1365,14 @@
case 3:
if (0)
{
- // There used to be an if here that didn't do anything, but the compiler optimised it out.
- // We only know this was here because empty ifs mess with the register usage.
+ // There used to be an if-statement here that didn't do anything, but the compiler optimised it out.
+ // We only know this was here because empty if-statements affect the assembly's register usage.
// Since there's no code, we have no idea what the original condition actually was.
}
if (0)
{
- // Another empty if
+ // Another empty if-statement
}
npc->act_no = 4;
@@ -1395,8 +1407,8 @@
case 6:
if (0)
{
- // There used to be an if here that didn't do anything, but the compiler optimised it out.
- // We only know this was here because empty ifs mess with the register usage.
+ // There used to be an if-statement here that didn't do anything, but the compiler optimised it out.
+ // We only know this was here because empty if-statements affect the assembly's register usage.
// Since there's no code, we have no idea what the original condition actually was.
}
@@ -1425,11 +1437,11 @@
npc->ani_no = 1;
if (npc->direct == 0)
- npc->x -= 0x200;
+ npc->x -= 1 * 0x200;
else
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
- if (gMC.x < npc->x + 0x2800 && gMC.x > npc->x - 0x2800)
+ if (gMC.x < npc->x + (20 * 0x200) && gMC.x > npc->x - (20 * 0x200))
npc->act_no = 0;
break;
@@ -1459,7 +1471,7 @@
npc->ym += 0x40;
- if (npc->act_wait++ && npc->flag & 8)
+ if (npc->act_wait++ != 0 && npc->flag & 8)
npc->act_no = 32;
break;
@@ -1562,7 +1574,7 @@
npc->bits &= ~NPC_INVULNERABLE;
// Fallthrough
case 11:
- if (npc->act_wait)
+ if (npc->act_wait != 0)
--npc->act_wait;
else
npc->act_no = 13;
@@ -1594,7 +1606,7 @@
else
npc->xm += 0x40;
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
}
@@ -1614,7 +1626,7 @@
else
npc->direct = 2;
- npc->xm = 8 * npc->xm / 9;
+ npc->xm = (npc->xm * 8) / 9;
if (++npc->ani_no > 1)
npc->ani_no = 0;
@@ -1635,13 +1647,13 @@
if (bUpper)
{
npc->ani_no = 2;
- SetNpChar(123, npc->x, npc->y - 0x1000, 0, 0, 1, 0, 0x100);
+ SetNpChar(123, npc->x, npc->y - (8 * 0x200), 0, 0, 1, NULL, 0x100);
}
else
{
npc->ani_no = 0;
- SetNpChar(123, npc->x - 0x1000, npc->y + 0x800, 0, 0, 0, 0, 0x100);
- npc->x += 0x200;
+ SetNpChar(123, npc->x - (8 * 0x200), npc->y + (4 * 0x200), 0, 0, 0, NULL, 0x100);
+ npc->x += 1 * 0x200;
}
}
else
@@ -1649,13 +1661,13 @@
if (bUpper)
{
npc->ani_no = 2;
- SetNpChar(123, npc->x, npc->y - 0x1000, 0, 0, 1, 0, 0x100);
+ SetNpChar(123, npc->x, npc->y - (8 * 0x200), 0, 0, 1, NULL, 0x100);
}
else
{
npc->ani_no = 0;
- SetNpChar(123, npc->x + 0x1000, npc->y + 0x800, 0, 0, 2, 0, 0x100);
- npc->x -= 0x200;
+ SetNpChar(123, npc->x + (8 * 0x200), npc->y + (4 * 0x200), 0, 0, 2, NULL, 0x100);
+ npc->x -= 1 * 0x200;
}
}
}
--- a/src/NpcAct120.cpp
+++ b/src/NpcAct120.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stdio.h>
+
#include "WindowsWrapper.h"
#include "Bullet.h"
@@ -121,7 +123,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x4000 < gMC.x && npc->x + 0x4000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (32 * 0x200) < gMC.x && npc->x + (32 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -148,7 +150,7 @@
npc->damage = 0;
// Fallthrough
case 11:
- if (npc->act_wait)
+ if (npc->act_wait != 0)
--npc->act_wait;
else
npc->act_no = 13;
@@ -179,7 +181,7 @@
else
npc->xm += 0x40;
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
}
@@ -362,8 +364,8 @@
{
case 0:
npc->act_no = 1;
- npc->x += 0x1000;
- npc->y += 0x1000;
+ npc->x += 8 * 0x200;
+ npc->y += 8 * 0x200;
// Fallthrough
case 1:
npc->bits &= ~NPC_IGNORE_SOLIDITY;
@@ -414,9 +416,9 @@
PlaySoundObject(70, 1);
if (npc->direct == 0)
- SetNpChar(87, npc->x, npc->y, 0, 0, 2, 0, 0);
+ SetNpChar(87, npc->x, npc->y, 0, 0, 2, NULL, 0);
else
- SetNpChar(86, npc->x, npc->y, 0, 0, 2, 0, 0);
+ SetNpChar(86, npc->x, npc->y, 0, 0, 2, NULL, 0);
npc->cond = 0;
}
@@ -468,7 +470,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0xC000 < gMC.x && npc->x + 0xC000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (96 * 0x200) < gMC.x && npc->x + (96 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -476,7 +478,7 @@
npc->direct = 2;
}
- if (npc->x - 0x4000 < gMC.x && npc->x + 0x4000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (32 * 0x200) < gMC.x && npc->x + (32 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 2;
@@ -633,13 +635,13 @@
if (npc->direct == 0 || npc->direct == 2)
{
- npc->view.front = 0x800;
- npc->view.top = 0x1000;
+ npc->view.front = 4 * 0x200;
+ npc->view.top = 8 * 0x200;
}
else
{
- npc->view.front = 0x1000;
- npc->view.top = 0x800;
+ npc->view.front = 8 * 0x200;
+ npc->view.top = 4 * 0x200;
}
}
@@ -693,6 +695,7 @@
if (++npc->ani_wait > 1)
{
npc->ani_wait = 0;
+
if (++npc->ani_no > 2)
npc->cond = 0;
}
@@ -699,7 +702,7 @@
npc->y += npc->ym;
- npc->rect = rect[3 * npc->direct + npc->ani_no];
+ npc->rect = rect[(npc->direct * 3) + npc->ani_no];
}
// Puppy (sitting, wagging tail)
@@ -735,7 +738,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x8000 < gMC.x && npc->x + 0x8000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (64 * 0x200) < gMC.x && npc->x + (64 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (++npc->ani_wait > 3)
{
@@ -747,7 +750,7 @@
npc->ani_no = 2;
}
- if (npc->x - 0xC000 < gMC.x && npc->x + 0xC000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (96 * 0x200) < gMC.x && npc->x + (96 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -845,7 +848,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x8000 < gMC.x && npc->x + 0x8000 > gMC.x && npc->y - 0x2000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (64 * 0x200) < gMC.x && npc->x + (64 * 0x200) > gMC.x && npc->y - (16 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (++npc->ani_wait > 4)
{
@@ -1018,7 +1021,7 @@
npc->bits |= NPC_INVULNERABLE;
// Fallthrough
case 1:
- if (gMC.x > npc->x - 0x28000 && gMC.x < npc->x + 0x28000 && gMC.y > npc->y - 0x14000 && gMC.y < npc->y + 0x8000) // TODO: Maybe do something about this for widescreen/tallscreen?
+ if (gMC.x > npc->x - (320 * 0x200) && gMC.x < npc->x + (320 * 0x200) && gMC.y > npc->y - (160 * 0x200) && gMC.y < npc->y + (64 * 0x200)) // TODO: Maybe do something about this for widescreen/tallscreen?
{
npc->act_no = 10;
npc->bits |= NPC_SHOOTABLE;
@@ -1100,7 +1103,7 @@
{288, 64, 320, 96},
};
- if (gMC.x < npc->x - 0x2C000 || gMC.x > npc->x + 0x2C000 || gMC.y < npc->y - 0x14000 || gMC.y > npc->y + 0x8000)
+ if (gMC.x < npc->x - (352 * 0x200) || gMC.x > npc->x + (352 * 0x200) || gMC.y < npc->y - (160 * 0x200) || gMC.y > npc->y + (64 * 0x200))
npc->act_no = 0;
switch (npc->act_no)
@@ -1110,7 +1113,7 @@
npc->xm = 0;
// Fallthrough
case 1:
- if (gMC.x > npc->x - 0x28000 && gMC.x < npc->x + 0x28000 && gMC.y > npc->y - 0x14000 && gMC.y < npc->y + 0x8000)
+ if (gMC.x > npc->x - (320 * 0x200) && gMC.x < npc->x + (320 * 0x200) && gMC.y > npc->y - (160 * 0x200) && gMC.y < npc->y + (64 * 0x200))
npc->act_no = 10;
if (npc->flag & 8)
@@ -1154,10 +1157,10 @@
if (npc->ym > 0 && npc->count1 == 0)
{
++npc->count1;
- deg = GetArktan(npc->x - gMC.x, npc->y + 0x800 - gMC.y);
- ym = 2 * GetSin(deg);
- xm = 2 * GetCos(deg);
- SetNpChar(50, npc->x, npc->y, xm, ym, 0, 0, 0x180);
+ deg = GetArktan(npc->x - gMC.x, npc->y + (4 * 0x200) - gMC.y);
+ ym = GetSin(deg) * 2;
+ xm = GetCos(deg) * 2;
+ SetNpChar(50, npc->x, npc->y, xm, ym, 0, NULL, 0x180);
PlaySoundObject(39, 1);
}
@@ -1242,16 +1245,16 @@
else
npc->direct = 2;
- npc->y = gMC.y - 0x1400;
+ npc->y = gMC.y - (10 * 0x200);
if (npc->direct == 0)
{
- npc->x = gMC.x + 0x800;
+ npc->x = gMC.x + (4 * 0x200);
npc->rect = rcLeft[npc->ani_no];
}
else
{
- npc->x = gMC.x - 0x800;
+ npc->x = gMC.x - (4 * 0x200);
npc->rect = rcRight[npc->ani_no];
}
@@ -1267,7 +1270,7 @@
npc->rect = rc;
}
-// Large door (door)
+// Large door
void ActNpc138(NPCHAR *npc)
{
RECT rcLeft = {96, 112, 112, 136};
@@ -1281,12 +1284,12 @@
if (npc->direct == 0)
{
npc->rect = rcLeft;
- npc->x += 0x1000;
+ npc->x += 8 * 0x200;
}
else
{
npc->rect = rcRight;
- npc->x -= 0x1000;
+ npc->x -= 8 * 0x200;
}
npc->tgt_x = npc->x;
@@ -1342,7 +1345,7 @@
npc->act_no = 1;
npc->xm = 0;
npc->ym = 0;
- npc->y -= 0x1000;
+ npc->y -= 8 * 0x200;
// Fallthrough
case 1:
if (npc->flag & 8)
@@ -1384,7 +1387,7 @@
npc->act_no = 21;
npc->act_wait = 0;
npc->ani_no = 2;
- npc->tgt_y = npc->y - 0x4000;
+ npc->tgt_y = npc->y - (32 * 0x200);
// Fallthrough
case 21:
if (npc->y < npc->tgt_y)
@@ -1403,7 +1406,7 @@
npc->act_no = 31;
npc->xm = 0;
npc->ym = 0;
- npc->act_wait = 2 * (npc->rect.bottom - npc->rect.top);
+ npc->act_wait = (npc->rect.bottom - npc->rect.top) * 2;
PlaySoundObject(29, 1);
// Fallthrough
case 31:
@@ -1442,7 +1445,7 @@
if (npc->act_no == 31 || npc->act_no == 41)
{
- npc->rect.bottom = npc->rect.top + npc->act_wait / 2;
+ npc->rect.bottom = npc->rect.top + (npc->act_wait / 2);
if (npc->act_wait / 2 % 2)
++npc->rect.left;
--- a/src/NpcAct140.cpp
+++ b/src/NpcAct140.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Bullet.h"
@@ -93,7 +95,7 @@
break;
case 10:
- npc->bits = npc->bits; // Redundant line
+ npc->bits = npc->bits; // Chances are this line isn't accurate to the original source code, but it produces the same assembly
npc->act_no = 11;
npc->ani_no = 0;
npc->ani_wait = 0;
@@ -118,7 +120,7 @@
if (CountArmsBullet(6) || CountArmsBullet(3) > 3)
npc->act_no = 20;
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
}
@@ -201,7 +203,7 @@
break;
case 26:
- npc->xm = 8 * npc->xm / 9;
+ npc->xm = (npc->xm * 8) / 9;
if (++npc->act_wait > 20)
{
@@ -248,7 +250,7 @@
npc->damage = 0;
for (i = 0; i < 8; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
break;
@@ -265,7 +267,7 @@
break;
case 102:
- npc->xm = 8 * npc->xm / 9;
+ npc->xm = (npc->xm * 8) / 9;
if (++npc->act_wait > 50)
{
@@ -334,7 +336,7 @@
if (++npc->act_wait > 100)
{
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
npc->cond = 0;
}
@@ -343,7 +345,7 @@
}
if (npc->act_no > 100 && npc->act_no < 105 && npc->act_wait % 9 == 0)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
npc->ym += 0x20;
@@ -380,11 +382,11 @@
// Fallthrough
case 1:
if (npc->pNpc->direct == 0)
- npc->x = npc->pNpc->x + 0x1400;
+ npc->x = npc->pNpc->x + (10 * 0x200);
else
- npc->x = npc->pNpc->x - 0x1400;
+ npc->x = npc->pNpc->x - (10 * 0x200);
- npc->y = npc->pNpc->y - 0x1000;
+ npc->y = npc->pNpc->y - (8 * 0x200);
if (npc->pNpc->act_no == 24 || npc->pNpc->act_no == 52)
{
@@ -391,15 +393,15 @@
npc->act_no = 10;
if (npc->pNpc->direct == 0)
- npc->x = npc->pNpc->x - 0x2000;
+ npc->x = npc->pNpc->x - (16 * 0x200);
else
- npc->x = npc->pNpc->x + 0x2000;
+ npc->x = npc->pNpc->x + (16 * 0x200);
npc->y = npc->pNpc->y;
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
- npc->ym = 4 * GetSin(deg);
- npc->xm = 4 * GetCos(deg);
+ npc->ym = GetSin(deg) * 4;
+ npc->xm = GetCos(deg) * 4;
PlaySoundObject(39, 1);
}
@@ -415,14 +417,14 @@
PlaySoundObject(12, 1);
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x, npc->y, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, NULL, 0x100);
+
+ break;
}
- else
- {
- npc->x += npc->xm;
- npc->y += npc->ym;
- }
+ npc->x += npc->xm;
+ npc->y += npc->ym;
+
break;
case 20:
@@ -432,7 +434,7 @@
if (++npc->act_wait > 4)
{
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x, npc->y, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, NULL, 0x100);
npc->code_char = 142;
npc->ani_no = 0;
@@ -660,7 +662,7 @@
if (npc->act_wait / 2 % 2)
npc->x = npc->tgt_x;
else
- npc->x = npc->tgt_x + 0x200;
+ npc->x = npc->tgt_x + (1 * 0x200);
}
}
@@ -694,9 +696,9 @@
}
if (npc->direct == 0)
- npc->x = npc->pNpc->x - 0x1400;
+ npc->x = npc->pNpc->x - (10 * 0x200);
else
- npc->x = npc->pNpc->x + 0x1400;
+ npc->x = npc->pNpc->x + (10 * 0x200);
npc->y = npc->pNpc->y;
@@ -787,11 +789,11 @@
switch (npc->act_no)
{
case 0:
- npc->y += 0x600;
+ npc->y += 3 * 0x200;
npc->act_no = 1;
// Fallthrough
case 1:
- if (npc->act_wait >= 8 && npc->x - 0xC000 < gMC.x && npc->x + 0xC000 > gMC.x && npc->y - 0xC000 < gMC.y && npc->y + 0x4000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (96 * 0x200) < gMC.x && npc->x + (96 * 0x200) > gMC.x && npc->y - (96 * 0x200) < gMC.y && npc->y + (32 * 0x200) > gMC.y)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -815,7 +817,7 @@
npc->act_wait = 0;
}
- if (npc->act_wait >= 8 && npc->x - 0x6000 < gMC.x && npc->x + 0x6000 > gMC.x && npc->y - 0xC000 < gMC.y && npc->y + 0x4000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (48 * 0x200) < gMC.x && npc->x + (48 * 0x200) > gMC.x && npc->y - (96 * 0x200) < gMC.y && npc->y + (32 * 0x200) > gMC.y)
{
npc->act_no = 2;
npc->ani_no = 0;
@@ -865,35 +867,35 @@
npc->damage = 3;
npc->act_no = 5;
npc->ani_no = 2;
+ break;
}
- else
- {
- if (npc->act_wait % 4 == 1)
- PlaySoundObject(109, 1);
- if (npc->flag & 8)
- npc->ym = -0x200;
+ if (npc->act_wait % 4 == 1)
+ PlaySoundObject(109, 1);
- if (npc->act_wait % 30 == 6)
- {
- deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
- deg += (unsigned char)Random(-6, 6);
- ym = 3 * GetSin(deg);
- xm = 3 * GetCos(deg);
- SetNpChar(148, npc->x, npc->y, xm, ym, 0, 0, 0x100);
- PlaySoundObject(39, 1);
- }
+ if (npc->flag & 8)
+ npc->ym = -0x200;
- if (++npc->ani_wait > 0)
- {
- npc->ani_wait = 0;
- ++npc->ani_no;
- }
+ if (npc->act_wait % 30 == 6)
+ {
+ deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
+ deg += (unsigned char)Random(-6, 6);
+ ym = GetSin(deg) * 3;
+ xm = GetCos(deg) * 3;
- if (npc->ani_no > 5)
- npc->ani_no = 3;
+ SetNpChar(148, npc->x, npc->y, xm, ym, 0, NULL, 0x100);
+ PlaySoundObject(39, 1);
}
+ if (++npc->ani_wait > 0)
+ {
+ npc->ani_wait = 0;
+ ++npc->ani_no;
+ }
+
+ if (npc->ani_no > 5)
+ npc->ani_no = 3;
+
break;
case 5:
@@ -980,8 +982,8 @@
switch (npc->act_no)
{
case 0:
- npc->x += 0x1000;
- npc->y += 0x1000;
+ npc->x += 8 * 0x200;
+ npc->y += 8 * 0x200;
if (npc->direct == 0)
npc->act_no = 10;
@@ -998,7 +1000,7 @@
npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
npc->damage = 0;
- if (gMC.x < npc->x + 0x3200 && gMC.x > npc->x - 0x32000 && gMC.y < npc->y + 0x3200 && gMC.y > npc->y - 0x3200)
+ if (gMC.x < npc->x + (25 * 0x200) && gMC.x > npc->x - (25 * 0x10 * 0x200) && gMC.y < npc->y + (25 * 0x200) && gMC.y > npc->y - (25 * 0x200))
{
npc->act_no = 11;
npc->act_wait = 0;
@@ -1019,24 +1021,24 @@
PlaySoundObject(26, 1);
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x - 0x2000, npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x - (16 * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
+
+ break;
}
+
+ if (gMC.flag & 1)
+ {
+ npc->bits |= NPC_REAR_AND_TOP_DONT_HURT;
+ npc->damage = 100;
+ }
else
{
- if (gMC.flag & 1)
- {
- npc->bits |= NPC_REAR_AND_TOP_DONT_HURT;
- npc->damage = 100;
- }
- else
- {
- npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
- npc->damage = 0;
- }
-
- npc->xm -= 0x20;
+ npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
+ npc->damage = 0;
}
+ npc->xm -= 0x20;
+
break;
case 20:
@@ -1043,7 +1045,7 @@
npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
npc->damage = 0;
- if (gMC.x > npc->x - 0x3200 && gMC.x < npc->x + 0x32000 && gMC.y < npc->y + 0x3200 && gMC.y > npc->y - 0x3200)
+ if (gMC.x > npc->x - (25 * 0x200) && gMC.x < npc->x + (25 * 0x10 * 0x200) && gMC.y < npc->y + (25 * 0x200) && gMC.y > npc->y - (25 * 0x200))
{
npc->act_no = 21;
npc->act_wait = 0;
@@ -1064,24 +1066,24 @@
PlaySoundObject(26, 1);
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + 0x2000, npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (16 * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
+
+ break;
}
+
+ if (gMC.flag & 4)
+ {
+ npc->bits |= NPC_REAR_AND_TOP_DONT_HURT;
+ npc->damage = 100;
+ }
else
{
- if (gMC.flag & 4)
- {
- npc->bits |= NPC_REAR_AND_TOP_DONT_HURT;
- npc->damage = 100;
- }
- else
- {
- npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
- npc->damage = 0;
- }
-
- npc->xm += 0x20;
+ npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
+ npc->damage = 0;
}
+ npc->xm += 0x20;
+
break;
}
@@ -1146,8 +1148,8 @@
case 10:
npc->act_no = 11;
- for (i = 0; i < 4; i++)
- SetNpChar(4, npc->x, npc->y, Random(-0x155, 0x155), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, npc->x, npc->y, Random(-0x155, 0x155), Random(-0x600, 0), 0, NULL, 0x100);
PlaySoundObject(71, 1);
// Fallthrough
@@ -1182,9 +1184,9 @@
npc->ani_no = 3;
if (npc->direct == 0)
- npc->x -= 0x200;
+ npc->x -= 1 * 0x200;
else
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
break;
@@ -1220,6 +1222,7 @@
if (npc->ani_no > 6)
npc->ani_no = 3;
+
break;
case 80:
@@ -1267,12 +1270,13 @@
if (npc->act_no == 21)
{
- npc->rect.bottom = npc->act_wait / 4 + npc->rect.top;
+ npc->rect.bottom = npc->rect.top + (npc->act_wait / 4);
if (npc->act_wait / 2 % 2)
++npc->rect.left;
}
+ // Use a different sprite if the player is wearing the Mimiga Mask
if (gMC.equip & 0x40)
{
npc->rect.top += 32;
@@ -1336,7 +1340,7 @@
{
case 0:
if (npc->direct == 2)
- npc->y += 0x2000;
+ npc->y += 16 * 0x200;
npc->act_no = 1;
break;
@@ -1396,7 +1400,7 @@
// Gaudi
void ActNpc153(NPCHAR *npc)
{
- if (npc->x > gMC.x + (WINDOW_WIDTH * 0x200) || npc->x < gMC.x - (WINDOW_WIDTH * 0x200) || npc->y > gMC.y + (WINDOW_HEIGHT * 0x200) || npc->y < gMC.y - (WINDOW_HEIGHT * 0x200))
+ 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;
switch (npc->act_no)
@@ -1405,7 +1409,7 @@
npc->act_no = 1;
npc->xm = 0;
npc->ani_no = 0;
- npc->y += 0x600;
+ npc->y += 3 * 0x200;
// Fallthrough
case 1:
if (Random(0, 100) == 1)
@@ -1458,7 +1462,7 @@
else
npc->xm = 0x200;
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
}
@@ -1475,7 +1479,7 @@
npc->ym = -0x5FF;
npc->act_no = 20;
- if ((gMC.cond & 2) == 0)
+ if (!(gMC.cond & 2))
PlaySoundObject(30, 1);
}
else if (npc->direct == 2 && npc->flag & 4)
@@ -1484,7 +1488,7 @@
npc->ym = -0x5FF;
npc->act_no = 20;
- if ((gMC.cond & 2) == 0)
+ if (!(gMC.cond & 2))
PlaySoundObject(30, 1);
}
@@ -1518,7 +1522,7 @@
npc->act_wait = 0;
npc->xm = 0;
- if ((gMC.cond & 2) == 0)
+ if (!(gMC.cond & 2))
PlaySoundObject(23, 1);
}
@@ -1586,7 +1590,7 @@
break;
case 2:
- npc->xm = 8 * npc->xm / 9;
+ npc->xm = (npc->xm * 8) / 9;
if (++npc->ani_wait > 3)
{
@@ -1619,10 +1623,13 @@
// Gaudi (flying)
void ActNpc155(NPCHAR *npc)
{
- if (npc->x > gMC.x + (WINDOW_WIDTH * 0x200) || npc->x < gMC.x - (WINDOW_WIDTH * 0x200) || npc->y > gMC.y + (WINDOW_HEIGHT * 0x200) || npc->y < gMC.y - (WINDOW_HEIGHT * 0x200))
+ unsigned char deg;
+ int ym;
+ int xm;
+
+ 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;
- unsigned char deg;
switch (npc->act_no)
{
case 0:
@@ -1629,12 +1636,12 @@
deg = Random(0, 0xFF);
npc->xm = GetCos(deg);
deg += 0x40;
- npc->tgt_x = npc->x + 8 * GetCos(deg);
+ npc->tgt_x = npc->x + (GetCos(deg) * 8);
deg = Random(0, 0xFF);
npc->ym = GetSin(deg);
deg += 0x40;
- npc->tgt_y = npc->y + 8 * GetSin(deg);
+ npc->tgt_y = npc->y + (GetSin(deg) * 8);
npc->act_no = 1;
npc->count1 = 120;
@@ -1645,7 +1652,7 @@
if (++npc->ani_no > 15)
npc->ani_no = 14;
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
}
@@ -1665,11 +1672,11 @@
{
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
deg += (unsigned char)Random(-6, 6);
- const int ym = 3 * GetSin(deg);
- const int xm = 3 * GetCos(deg);
- SetNpChar(156, npc->x, npc->y, xm, ym, 0, 0, 0x100);
+ ym = GetSin(deg) * 3;
+ xm = GetCos(deg) * 3;
+ SetNpChar(156, npc->x, npc->y, xm, ym, 0, NULL, 0x100);
- if ((gMC.cond & 2) == 0)
+ if (!(gMC.cond & 2))
PlaySoundObject(39, 1);
npc->act_no = 1;
@@ -1759,8 +1766,8 @@
switch (npc->act_no)
{
case 0:
- npc->x += 0x1000;
- npc->y += 0x1000;
+ npc->x += 8 * 0x200;
+ npc->y += 8 * 0x200;
if (npc->direct == 0)
npc->act_no = 10;
@@ -1770,6 +1777,7 @@
npc->xm = 0;
npc->ym = 0;
npc->bits |= NPC_SOLID_HARD;
+
break;
case 10:
@@ -1776,7 +1784,7 @@
npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
npc->damage = 0;
- if (gMC.y < npc->y + 0x3200 && gMC.y > npc->y - 0x32000 && gMC.x < npc->x + 0x3200 && gMC.x > npc->x - 0x3200)
+ if (gMC.y < npc->y + (25 * 0x200) && gMC.y > npc->y - (25 * 0x10 * 0x200) && gMC.x < npc->x + (25 * 0x200) && gMC.x > npc->x - (25 * 0x200))
{
npc->act_no = 11;
npc->act_wait = 0;
@@ -1797,24 +1805,24 @@
PlaySoundObject(26, 1);
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y - 0x2000, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y - (16 * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
+
+ break;
}
+
+ if (gMC.flag & 2)
+ {
+ npc->bits |= NPC_REAR_AND_TOP_DONT_HURT;
+ npc->damage = 100;
+ }
else
{
- if (gMC.flag & 2)
- {
- npc->bits |= NPC_REAR_AND_TOP_DONT_HURT;
- npc->damage = 100;
- }
- else
- {
- npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
- npc->damage = 0;
- }
-
- npc->ym -= 0x20;
+ npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
+ npc->damage = 0;
}
+ npc->ym -= 0x20;
+
break;
case 20:
@@ -1821,7 +1829,7 @@
npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
npc->damage = 0;
- if (gMC.y > npc->y - 0x3200 && gMC.y < npc->y + 0x32000 && gMC.x < npc->x + 0x3200 && gMC.x > npc->x - 0x3200)
+ if (gMC.y > npc->y - (25 * 0x200) && gMC.y < npc->y + (25 * 0x10 * 0x200) && gMC.x < npc->x + (25 * 0x200) && gMC.x > npc->x - (25 * 0x200))
{
npc->act_no = 21;
npc->act_wait = 0;
@@ -1842,24 +1850,24 @@
PlaySoundObject(26, 1);
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + 0x2000, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (16 * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
+
+ break;
}
+
+ if (gMC.flag & 8)
+ {
+ npc->bits |= NPC_REAR_AND_TOP_DONT_HURT;
+ npc->damage = 100;
+ }
else
{
- if (gMC.flag & 8)
- {
- npc->bits |= NPC_REAR_AND_TOP_DONT_HURT;
- npc->damage = 100;
- }
- else
- {
- npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
- npc->damage = 0;
- }
-
- npc->ym += 0x20;
+ npc->bits &= ~NPC_REAR_AND_TOP_DONT_HURT;
+ npc->damage = 0;
}
+ npc->ym += 0x20;
+
break;
}
@@ -1877,6 +1885,8 @@
// Fish Missile
void ActNpc158(NPCHAR *npc)
{
+ int dir;
+
RECT rect[8] = {
{0, 224, 16, 240},
{16, 224, 32, 240},
@@ -1917,7 +1927,7 @@
npc->ym = 2 * GetSin(npc->count1);
npc->y += npc->ym;
npc->x += npc->xm;
- const int dir = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
+ dir = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
if (dir < npc->count1)
{
@@ -1969,7 +1979,7 @@
npc->act_no = 1;
for (i = 0; i < 8; ++i)
- SetNpChar(4, npc->x + (Random(-16, 16) * 0x200), npc->y + (Random(-16, 16) * 0x200), Random(-341, 341), Random(-341, 341), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-16, 16) * 0x200), npc->y + (Random(-16, 16) * 0x200), Random(-341, 341), Random(-341, 341), 0, NULL, 0x100);
// Fallthrough
case 1:
if (++npc->act_wait > 50)
@@ -1989,7 +1999,7 @@
++npc->act_wait;
npc->ym += 0x40;
- if (npc->y > 0x50000)
+ if (npc->y > 40 * 0x10 * 0x200)
npc->cond = 0;
break;
@@ -2001,5 +2011,5 @@
npc->rect = rect;
if (npc->act_wait % 8 == 1)
- SetNpChar(4, npc->x + (Random(-16, 16) * 0x200), npc->y + (Random(-16, 16) * 0x200), Random(-341, 341), Random(-341, 341), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-16, 16) * 0x200), npc->y + (Random(-16, 16) * 0x200), Random(-341, 341), Random(-341, 341), 0, NULL, 0x100);
}
--- a/src/NpcAct160.cpp
+++ b/src/NpcAct160.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Caret.h"
@@ -32,7 +34,7 @@
npc->ym = 0xA00;
- if (npc->y < 0x10000)
+ if (npc->y < 128 * 0x200)
{
++npc->count1;
}
@@ -52,7 +54,7 @@
DeleteNpCharCode(161, 1);
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
npc->act_no = 3;
npc->act_wait = 0;
@@ -69,7 +71,7 @@
break;
case 3:
- npc->damage = 20; // Overriden by the following line
+ npc->damage = 20; // Overwritten by the following line
npc->damage = 0;
if (++npc->act_wait > 24)
@@ -87,7 +89,7 @@
if (npc->shock % 2 == 1)
{
- SetNpChar(161, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-0x600, 0x600), Random(-0x600, 0x600), 0, 0, 0x100);
+ SetNpChar(161, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-0x600, 0x600), Random(-0x600, 0x600), 0, NULL, 0x100);
if (++npc->count1 > 30)
{
@@ -114,7 +116,7 @@
case 6:
gSuperXpos = gMC.x;
- gSuperYpos = 0x320000;
+ gSuperYpos = 400 * 0x10 * 0x200;
if (++npc->count1 > 110)
{
@@ -247,7 +249,7 @@
PlaySoundObject(72, 1);
for (i = 0; i < 10; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-0x600, 0x600), Random(-0x600, 0x600), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-0x600, 0x600), Random(-0x600, 0x600), 0, NULL, 0x100);
if (npc->x > gMC.x)
npc->direct = 0;
@@ -263,9 +265,11 @@
npc->act_no = 1;
// Fallthrough
case 1:
- if (++npc->count1 % 4 == 0)
- SetNpChar(161, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), 0, 0, 0, 0, 0x100);
+ ++npc->count1;
+ if (npc->count1 % 4 == 0)
+ SetNpChar(161, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), 0, 0, 0, NULL, 0x100);
+
if (npc->count1 > 160)
{
npc->count1 = 0;
@@ -278,7 +282,9 @@
case 2:
SetQuake(2);
- if (++npc->count1 <= 240)
+ ++npc->count1;
+
+ if (npc->count1 <= 240)
{
if (npc->direct == 0)
npc->rect = rect_left;
@@ -298,7 +304,7 @@
}
if (npc->count1 % 3 == 2)
- SetNpChar(161, npc->x + (Random(-12, 12) * 0x200), npc->y - 0x1800, Random(-0x200, 0x200), 0x100, 0, 0, 0x100);
+ SetNpChar(161, npc->x + (Random(-12, 12) * 0x200), npc->y - (12 * 0x200), Random(-0x200, 0x200), 0x100, 0, NULL, 0x100);
if (npc->count1 % 4 == 2)
PlaySoundObject(21, 1);
@@ -317,7 +323,7 @@
}
gSuperXpos = npc->x;
- gSuperYpos = -0x7D000;
+ gSuperYpos = -1000 * 0x200;
}
// Dr Gero
@@ -429,7 +435,7 @@
npc->y += 10 * 0x200;
// Fallthrough
case 1:
- if (npc->direct == 2 && gMC.x > npc->x - (0x20 * 0x200) && gMC.x < npc->x + (0x20 * 0x200) && gMC.y > npc->y - (0x10 * 0x200) && gMC.y < npc->y + (0x10 * 0x200))
+ if (npc->direct == 2 && gMC.x > npc->x - (32 * 0x200) && gMC.x < npc->x + (32 * 0x200) && gMC.y > npc->y - (16 * 0x200) && gMC.y < npc->y + (16 * 0x200))
npc->ani_no = 1;
else
npc->ani_no = 0;
@@ -484,6 +490,8 @@
// Professor Booster (falling)
void ActNpc167(NPCHAR *npc)
{
+ int i;
+
RECT rect[3] = {
{304, 0, 320, 16},
{304, 16, 320, 32},
@@ -519,8 +527,8 @@
if (++npc->act_wait > 100)
{
- for (int i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
npc->cond = 0;
}
@@ -552,7 +560,7 @@
npc->x = npc->tgt_x;
if (npc->act_wait / 3 % 2)
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
break;
@@ -601,7 +609,7 @@
npc->direct = 2;
// Fallthrough
case 1:
- if (--npc->act_wait)
+ if (--npc->act_wait != 0)
break;
npc->act_no = 2;
@@ -615,7 +623,9 @@
npc->ani_wait = 0;
// Fallthrough
case 3:
- if (++npc->ani_wait > 3)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 3)
{
npc->ani_wait = 0;
++npc->ani_no;
@@ -632,53 +642,52 @@
else
npc->xm += 0x20;
- if (npc->act_wait >= 8 && npc->x - 0x1800 < gMC.x && npc->x + 0x1800 > gMC.x && npc->y - 0x1800 < gMC.y && npc->y + 0x1000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (12 * 0x200) < gMC.x && npc->x + (12 * 0x200) > gMC.x && npc->y - (12 * 0x200) < gMC.y && npc->y + (8 * 0x200) > gMC.y)
{
npc->act_no = 10;
npc->ani_no = 5;
gMC.cond |= 2;
DamageMyChar(5);
+ break;
}
- else
+
+ ++npc->act_wait;
+
+ if (npc->act_wait > 75)
{
- if (++npc->act_wait > 75)
+ npc->act_no = 9;
+ npc->ani_no = 0;
+ break;
+ }
+
+ if (npc->flag & 5)
+ {
+ if (npc->count2 < 5)
{
- npc->act_no = 9;
- npc->ani_no = 0;
+ ++npc->count2;
}
else
{
- if (npc->flag & 5)
- {
- if (npc->count2 < 5)
- {
- ++npc->count2;
- }
- else
- {
- npc->act_no = 4;
- npc->act_wait = 0;
- npc->ani_no = 7;
- npc->ym = -0x5FF;
- }
- }
- else
- {
- npc->count2 = 0;
- }
-
- if (npc->count1 % 2 == 0 && npc->act_wait > 25)
- {
- npc->act_no = 4;
- npc->act_wait = 0;
- npc->ani_no = 7;
- npc->ym = -0x5FF;
- }
-
- break;
+ npc->act_no = 4;
+ npc->act_wait = 0;
+ npc->ani_no = 7;
+ npc->ym = -0x5FF;
}
}
+ else
+ {
+ npc->count2 = 0;
+ }
+ if (npc->count1 % 2 == 0 && npc->act_wait > 25)
+ {
+ npc->act_no = 4;
+ npc->act_wait = 0;
+ npc->ani_no = 7;
+ npc->ym = -0x5FF;
+ break;
+ }
+
break;
case 4:
@@ -692,7 +701,7 @@
if (npc->act_wait < 30 && npc->act_wait % 6 == 1)
{
PlaySoundObject(39, 1);
- SetNpChar(170, npc->x, npc->y, 0, 0, npc->direct, 0, 0x100);
+ SetNpChar(170, npc->x, npc->y, 0, 0, npc->direct, NULL, 0x100);
}
if (npc->flag & 8)
@@ -703,7 +712,7 @@
PlaySoundObject(26, 1);
}
- if (npc->act_wait >= 8 && npc->x - 0x1800 < gMC.x && npc->x + 0x1800 > gMC.x && npc->y - 0x1800 < gMC.y && npc->y + 0x1000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (12 * 0x200) < gMC.x && npc->x + (12 * 0x200) > gMC.x && npc->y - (12 * 0x200) < gMC.y && npc->y + (8 * 0x200) > gMC.y)
{
npc->act_no = 10;
npc->ani_no = 5;
@@ -714,9 +723,9 @@
break;
case 9:
- npc->xm = 4 * npc->xm / 5;
+ npc->xm = (npc->xm * 4) / 5;
- if (npc->xm)
+ if (npc->xm != 0)
break;
npc->act_no = 0;
@@ -726,9 +735,9 @@
gMC.x = npc->x;
gMC.y = npc->y;
- npc->xm = 4 * npc->xm / 5;
+ npc->xm = (npc->xm * 4) / 5;
- if (npc->xm)
+ if (npc->xm != 0)
break;
npc->act_no = 11;
@@ -741,7 +750,9 @@
gMC.x = npc->x;
gMC.y = npc->y;
- if (++npc->ani_wait > 2)
+ ++npc->ani_wait;
+
+ if (npc->ani_wait > 2)
{
npc->ani_wait = 0;
++npc->ani_no;
@@ -750,7 +761,9 @@
if (npc->ani_no > 6)
npc->ani_no = 5;
- if (++npc->act_wait > 100)
+ ++npc->act_wait;
+
+ if (npc->act_wait > 100)
npc->act_no = 20;
break;
@@ -761,8 +774,8 @@
if (npc->direct == 0)
{
- gMC.x += 0x800;
- gMC.y -= 0x1000;
+ gMC.x += 4 * 0x200;
+ gMC.y -= 8 * 0x200;
gMC.xm = 0x5FF;
gMC.ym = -0x200;
gMC.direct = 2;
@@ -770,8 +783,8 @@
}
else
{
- gMC.x -= 0x800;
- gMC.y -= 0x1000;
+ gMC.x -= 4 * 0x200;
+ gMC.y -= 8 * 0x200;
gMC.xm = -0x5FF;
gMC.ym = -0x200;
gMC.direct = 0;
@@ -783,7 +796,9 @@
npc->ani_no = 7;
// Fallthrough
case 21:
- if (++npc->act_wait < 50)
+ ++npc->act_wait;
+
+ if (npc->act_wait < 50)
break;
npc->act_no = 0;
@@ -881,7 +896,7 @@
npc->xm -= 0x20;
if (npc->count1 % 3 == 1)
- SetCaret(npc->x + 0x1000, npc->y, 7, 2);
+ SetCaret(npc->x + (8 * 0x200), npc->y, 7, 2);
}
else
{
@@ -888,7 +903,7 @@
npc->xm += 0x20;
if (npc->count1 % 3 == 1)
- SetCaret(npc->x - 0x1000, npc->y, 7, 0);
+ SetCaret(npc->x - (8 * 0x200), npc->y, 7, 0);
}
if (npc->count1 < 50)
@@ -949,7 +964,7 @@
npc->tgt_y = npc->y;
// Fallthrough
case 1:
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
}
@@ -983,18 +998,18 @@
if (npc->direct == 0)
{
- if (gMC.y < npc->y + 0xA000 && gMC.y > npc->y - 0xA000 && gMC.x < npc->x && gMC.x > npc->x - 0x14000)
+ if (gMC.y < npc->y + (80 * 0x200) && gMC.y > npc->y - (80 * 0x200) && gMC.x < npc->x && gMC.x > npc->x - (160 * 0x200))
++npc->count1;
}
else
{
- if (gMC.y < npc->y + 0xA000 && gMC.y > npc->y - 0xA000 && gMC.x < npc->x + 0x14000 && gMC.x > npc->x)
+ if (gMC.y < npc->y + (80 * 0x200) && gMC.y > npc->y - (80 * 0x200) && gMC.x < npc->x + (160 * 0x200) && gMC.x > npc->x)
++npc->count1;
}
if (npc->count1 > 20)
{
- SetNpChar(172, npc->x, npc->y, 0, 0, npc->direct, 0, 0x100);
+ SetNpChar(172, npc->x, npc->y, 0, 0, npc->direct, NULL, 0x100);
npc->count1 = -100;
gCurlyShoot_wait = Random(80, 100);
gCurlyShoot_x = npc->x;
@@ -1035,9 +1050,9 @@
npc->ani_no = 0;
if (npc->direct == 0)
- npc->x -= 0x200;
+ npc->x -= 1 * 0x200;
else
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
if (npc->flag & 1 || npc->flag & 4)
{
@@ -1073,7 +1088,7 @@
{72, 152, 96, 176},
};
- if (npc->x > gMC.x + (WINDOW_WIDTH * 0x200) || npc->x < gMC.x - (WINDOW_WIDTH * 0x200) || npc->y > gMC.y + (WINDOW_HEIGHT * 0x200) || npc->y < gMC.y - (WINDOW_HEIGHT * 0x200))
+ 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;
switch (npc->act_no)
@@ -1092,7 +1107,7 @@
}
else
{
- if (npc->x - 0x18000 < gMC.x && npc->x + 0x18000 > gMC.x && npc->y - 0x14000 < gMC.y && npc->y + 0x14000 > gMC.y)
+ if (npc->x - (192 * 0x200) < gMC.x && npc->x + (192 * 0x200) > gMC.x && npc->y - (160 * 0x200) < gMC.y && npc->y + (160 * 0x200) > gMC.y)
{
npc->act_no = 10;
npc->act_wait = 0;
@@ -1153,10 +1168,11 @@
{
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
deg += (unsigned char)Random(-6, 6);
- ym = 3 * GetSin(deg);
- xm = 3 * GetCos(deg);
- SetNpChar(174, npc->x, npc->y, xm, ym, 0, 0, 0x100);
+ ym = GetSin(deg) * 3;
+ xm = GetCos(deg) * 3;
+ SetNpChar(174, npc->x, npc->y, xm, ym, 0, NULL, 0x100);
+
PlaySoundObject(39, 1);
npc->ani_no = 3;
@@ -1223,6 +1239,7 @@
void ActNpc174(NPCHAR *npc)
{
BOOL bHit;
+
switch (npc->act_no)
{
case 0:
@@ -1385,12 +1402,12 @@
case 1:
if (npc->direct == 0)
{
- if (npc->x < gMC.x + 0x14000 && npc->x > gMC.x - 0x14000 && npc->y < gMC.y + 0x14000 && npc->y > gMC.y - 0x2000)
+ if (npc->x < gMC.x + (160 * 0x200) && npc->x > gMC.x - (160 * 0x200) && npc->y < gMC.y + (160 * 0x200) && npc->y > gMC.y - (16 * 0x200))
++npc->count1;
}
else
{
- if (npc->x < gMC.x + 0x14000 && npc->x > gMC.x - 0x14000 && npc->y < gMC.y + 0x2000 && npc->y > gMC.y - 0x14000)
+ if (npc->x < gMC.x + (160 * 0x200) && npc->x > gMC.x - (160 * 0x200) && npc->y < gMC.y + (16 * 0x200) && npc->y > gMC.y - (160 * 0x200))
++npc->count1;
}
@@ -1425,9 +1442,9 @@
}
if (npc->direct == 0)
- SetNpChar(177, npc->x, npc->y - 0x1000, 0, 0, 0, 0, 0x100);
+ SetNpChar(177, npc->x, npc->y - (8 * 0x200), 0, 0, 0, NULL, 0x100);
else
- SetNpChar(177, npc->x, npc->y + 0x1000, 0, 0, 2, 0, 0x100);
+ SetNpChar(177, npc->x, npc->y + (8 * 0x200), 0, 0, 2, NULL, 0x100);
PlaySoundObject(39, 1);
@@ -1474,7 +1491,7 @@
npc->ym = 0x600;
// Fallthrough
case 1:
- if (npc->y < gMC.y + 0x2000 && npc->y > gMC.y - 0x2000)
+ if (npc->y < gMC.y + (16 * 0x200) && npc->y > gMC.y - (16 * 0x200))
{
npc->act_no = 10;
@@ -1486,8 +1503,8 @@
else
npc->direct = 2;
- npc->xm = 2 * (0x200 * Random(0, 1) - 0x100);
- npc->ym = 2 * (0x200 * Random(0, 1) - 0x100);
+ npc->xm = ((Random(0, 1) * 0x200) - 0x100) * 2;
+ npc->ym = ((Random(0, 1) * 0x200) - 0x100) * 2;
}
break;
@@ -1511,9 +1528,9 @@
}
if (npc->direct == 0)
- npc->tgt_x -= 0x200;
+ npc->tgt_x -= 1 * 0x200;
else
- npc->tgt_x += 0x200;
+ npc->tgt_x += 1 * 0x200;
break;
}
--- a/src/NpcAct180.cpp
+++ b/src/NpcAct180.cpp
@@ -19,6 +19,9 @@
// Curly AI
void ActNpc180(NPCHAR *npc)
{
+ int xx;
+ int yy;
+
RECT rcLeft[11] = {
{0, 96, 16, 112},
{16, 96, 32, 112},
@@ -47,11 +50,11 @@
{144, 112, 160, 128},
};
- if (npc->y < gMC.y - 0x14000)
+ if (npc->y < gMC.y - (10 * 0x10 * 0x200))
{
- if (npc->y < 0x20000)
+ if (npc->y < 16 * 0x10 * 0x200)
{
- npc->tgt_x = 0x280000;
+ npc->tgt_x = 320 * 0x10 * 0x200;
npc->tgt_y = npc->y;
}
else
@@ -62,7 +65,7 @@
}
else
{
- if (gCurlyShoot_wait)
+ if (gCurlyShoot_wait != 0)
{
npc->tgt_x = gCurlyShoot_x;
npc->tgt_y = gCurlyShoot_y;
@@ -123,10 +126,10 @@
case 100:
npc->ani_no = 0;
- npc->xm = 7 * npc->xm / 8;
+ npc->xm = (npc->xm * 7) / 8;
npc->count1 = 0;
- if (npc->x > npc->tgt_x + 0x2000)
+ if (npc->x > npc->tgt_x + (16 * 0x200))
{
npc->act_no = 200;
npc->ani_no = 1;
@@ -133,7 +136,7 @@
npc->direct = 0;
npc->act_wait = Random(20, 60);
}
- else if (npc->x < npc->tgt_x - 0x2000)
+ else if (npc->x < npc->tgt_x - (16 * 0x200))
{
npc->act_no = 300;
npc->ani_no = 1;
@@ -184,7 +187,7 @@
break;
}
- if (gCurlyShoot_wait)
+ if (gCurlyShoot_wait != 0)
--gCurlyShoot_wait;
if (gCurlyShoot_wait == 70)
@@ -203,8 +206,8 @@
npc->act_no = 310;
}
- int xx = npc->x - npc->tgt_x;
- int yy = npc->y - npc->tgt_y;
+ xx = npc->x - npc->tgt_x;
+ yy = npc->y - npc->tgt_y;
if (xx < 0)
xx *= -1;
@@ -211,7 +214,7 @@
if (npc->act_no == 100)
{
- if (xx + 0x400 < yy)
+ if (xx + (2 * 0x200) < yy)
npc->ani_no = 5;
else
npc->ani_no = 0;
@@ -219,7 +222,7 @@
if (npc->act_no == 210 || npc->act_no == 310)
{
- if (xx + 0x400 < yy)
+ if (xx + (2 * 0x200) < yy)
npc->ani_no = 6;
else
npc->ani_no = 1;
@@ -229,7 +232,7 @@
{
++npc->ani_wait;
- if (xx + 0x400 < yy)
+ if (xx + (2 * 0x200) < yy)
npc->ani_no = 6 + (npc->ani_wait / 4 % 4);
else
npc->ani_no = 1 + (npc->ani_wait / 4 % 4);
@@ -261,7 +264,7 @@
if (npc->act_no >= 100 && npc->act_no < 500)
{
- if (npc->x < gMC.x - 0xA000 || npc->x > gMC.x + 0xA000)
+ if (npc->x < gMC.x - (80 * 0x200) || npc->x > gMC.x + (80 * 0x200))
{
#ifdef FIX_BUGS
if (npc->flag & 5)
@@ -289,7 +292,7 @@
npc->x += npc->xm;
npc->y += npc->ym;
- if (npc->act_no >= 100 && (npc->flag & 8) == 0)
+ if (npc->act_no >= 100 && !(npc->flag & 8))
{
switch (npc->ani_no)
{
@@ -297,7 +300,7 @@
break;
default:
- if (xx + 0x400 < yy)
+ if (xx + (2 * 0x200) < yy)
npc->ani_no = 6;
else
npc->ani_no = 1;
@@ -333,12 +336,12 @@
if (npc->pNpc->direct == 0)
{
npc->direct = 0;
- npc->x = npc->pNpc->x - 0x1000;
+ npc->x = npc->pNpc->x - (8 * 0x200);
}
else
{
npc->direct = 2;
- npc->x = npc->pNpc->x + 0x1000;
+ npc->x = npc->pNpc->x + (8 * 0x200);
}
npc->y = npc->pNpc->y;
@@ -357,12 +360,12 @@
npc->x = npc->pNpc->x;
}
- npc->y = npc->pNpc->y - 0x1400;
+ npc->y = npc->pNpc->y - (10 * 0x200);
npc->ani_no = 1;
}
if (npc->pNpc->ani_no == 1 || npc->pNpc->ani_no == 3 || npc->pNpc->ani_no == 6 || npc->pNpc->ani_no == 8)
- npc->y -= 0x200;
+ npc->y -= 1 * 0x200;
switch (npc->act_no)
{
@@ -383,13 +386,13 @@
{
if (npc->direct == 0)
{
- SetBullet(12, npc->x - 0x800, npc->y + 0x600, 0);
- SetCaret(npc->x - 0x800, npc->y + 0x600, 3, 0);
+ SetBullet(12, npc->x - (4 * 0x200), npc->y + (3 * 0x200), 0);
+ SetCaret(npc->x - (4 * 0x200), npc->y + (3 * 0x200), 3, 0);
}
else
{
- SetBullet(12, npc->x + 0x800, npc->y + 0x600, 2);
- SetCaret(npc->x + 0x800, npc->y + 0x600, 3, 0);
+ SetBullet(12, npc->x + (4 * 0x200), npc->y + (3 * 0x200), 2);
+ SetCaret(npc->x + (4 * 0x200), npc->y + (3 * 0x200), 3, 0);
}
}
else
@@ -396,13 +399,13 @@
{
if (npc->direct == 0)
{
- SetBullet(12, npc->x - 0x400, npc->y - 0x800, 1);
- SetCaret(npc->x - 0x400, npc->y - 0x800, 3, 0);
+ SetBullet(12, npc->x - (2 * 0x200), npc->y - (4 * 0x200), 1);
+ SetCaret(npc->x - (2 * 0x200), npc->y - (4 * 0x200), 3, 0);
}
else
{
- SetBullet(12, npc->x + 0x400, npc->y - 0x800, 1);
- SetCaret(npc->x + 0x400, npc->y - 0x800, 3, 0);
+ SetBullet(12, npc->x + (2 * 0x200), npc->y - (4 * 0x200), 1);
+ SetCaret(npc->x + (2 * 0x200), npc->y - (4 * 0x200), 3, 0);
}
}
}
@@ -440,12 +443,12 @@
if (npc->pNpc->direct == 0)
{
npc->direct = 0;
- npc->x = npc->pNpc->x - 0x1000;
+ npc->x = npc->pNpc->x - (8 * 0x200);
}
else
{
npc->direct = 2;
- npc->x = npc->pNpc->x + 0x1000;
+ npc->x = npc->pNpc->x + (8 * 0x200);
}
npc->y = npc->pNpc->y;
@@ -464,12 +467,12 @@
npc->x = npc->pNpc->x;
}
- npc->y = npc->pNpc->y - 0x1400;
+ npc->y = npc->pNpc->y - (10 * 0x200);
npc->ani_no = 1;
}
if (npc->pNpc->ani_no == 1 || npc->pNpc->ani_no == 3 || npc->pNpc->ani_no == 6 || npc->pNpc->ani_no == 8)
- npc->y -= 0x200;
+ npc->y -= 1 * 0x200;
switch (npc->act_no)
{
@@ -490,13 +493,13 @@
{
if (npc->direct == 0)
{
- SetBullet(6, npc->x - 0x800, npc->y + 0x600, 0);
- SetCaret(npc->x - 0x800, npc->y + 0x600, 3, 0);
+ SetBullet(6, npc->x - (4 * 0x200), npc->y + (3 * 0x200), 0);
+ SetCaret(npc->x - (4 * 0x200), npc->y + (3 * 0x200), 3, 0);
}
else
{
- SetBullet(6, npc->x + 0x800, npc->y + 0x600, 2);
- SetCaret(npc->x + 0x800, npc->y + 0x600, 3, 0);
+ SetBullet(6, npc->x + (4 * 0x200), npc->y + (3 * 0x200), 2);
+ SetCaret(npc->x + (4 * 0x200), npc->y + (3 * 0x200), 3, 0);
}
}
else
@@ -503,13 +506,13 @@
{
if (npc->direct == 0)
{
- SetBullet(6, npc->x - 0x400, npc->y - 0x800, 1);
- SetCaret(npc->x - 0x400, npc->y - 0x800, 3, 0);
+ SetBullet(6, npc->x - (2 * 0x200), npc->y - (4 * 0x200), 1);
+ SetCaret(npc->x - (2 * 0x200), npc->y - (4 * 0x200), 3, 0);
}
else
{
- SetBullet(6, npc->x + 0x400, npc->y - 0x800, 1);
- SetCaret(npc->x + 0x400, npc->y - 0x800, 3, 0);
+ SetBullet(6, npc->x + (2 * 0x200), npc->y - (4 * 0x200), 1);
+ SetCaret(npc->x + (2 * 0x200), npc->y - (4 * 0x200), 3, 0);
}
}
}
@@ -564,9 +567,11 @@
npc->rect.right = 0;
}
-// Shutter Big
+// Big Shutter
void ActNpc184(NPCHAR *npc)
{
+ int i;
+
RECT rc[4] = {
{0, 64, 32, 96},
{32, 64, 64, 96},
@@ -578,8 +583,8 @@
{
case 0:
npc->act_no = 1;
- npc->x += 0x1000;
- npc->y += 0x1000;
+ npc->x += 8 * 0x200;
+ npc->y += 8 * 0x200;
break;
case 10:
@@ -615,8 +620,8 @@
break;
case 20:
- for (int i = 0; i < 4; i++)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + 0x2000, Random(-0x155, 0x155), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (16 * 0x200), Random(-0x155, 0x155), Random(-0x600, 0), 0, NULL, 0x100);
npc->act_no = 1;
break;
@@ -634,7 +639,7 @@
npc->rect = rc[npc->ani_no];
}
-// Shutter Small
+// Small Shutter
void ActNpc185(NPCHAR *npc)
{
RECT rc = {96, 64, 112, 96};
@@ -643,7 +648,7 @@
{
case 0:
npc->act_no = 1;
- npc->y += 0x1000;
+ npc->y += 8 * 0x200;
break;
case 10:
@@ -671,11 +676,12 @@
npc->y += 0x80;
break;
}
+
++npc->act_wait;
break;
case 20:
- npc->y -= 0x3000;
+ npc->y -= 24 * 0x200;
npc->act_no = 1;
break;
}
@@ -726,6 +732,7 @@
npc->y += 0x80;
break;
}
+
++npc->act_wait;
break;
}
@@ -832,8 +839,8 @@
if (npc->pNpc->code_char == 187 && npc->pNpc->cond & 0x80)
{
deg = (npc->pNpc->count1 + npc->count1) % 0x100;
- npc->x = npc->pNpc->x + 20 * GetSin(deg);
- npc->y = npc->pNpc->y + 0x20 * GetCos(deg);
+ npc->x = npc->pNpc->x + (GetSin(deg) * 20);
+ npc->y = npc->pNpc->y + (GetCos(deg) * 0x20);
}
else
{
@@ -941,6 +948,7 @@
npc->x += npc->xm;
npc->y += npc->ym;
+
break;
}
@@ -986,8 +994,8 @@
case 10:
PlaySoundObject(72, 1);
- for (i = 0; i < 8; i++)
- SetNpChar(4, npc->x, npc->y + (Random(-8, 8) * 0x200), Random(-8, -2) * 0x200, Random(-3, 3) * 0x200, 0, 0, 0x100);
+ for (i = 0; i < 8; ++i)
+ SetNpChar(4, npc->x, npc->y + (Random(-8, 8) * 0x200), Random(-8, -2) * 0x200, Random(-3, 3) * 0x200, 0, NULL, 0x100);
npc->cond = 0;
break;
@@ -1067,7 +1075,7 @@
npc->y += npc->ym;
- if (npc->y < 0x8000 || gSuperYpos)
+ if (npc->y < 64 * 0x200 || gSuperYpos != 0)
{
npc->act_no = 21;
npc->act_wait = 0;
@@ -1090,6 +1098,7 @@
}
gWaterY = npc->y;
+
npc->rect.right = 0;
npc->rect.bottom = 0;
}
@@ -1101,18 +1110,18 @@
{
case 0:
npc->act_no = 1;
- npc->view.back = 0x2000;
- npc->view.front = 0x2000;
- npc->view.top = 0x1000;
- npc->view.bottom = 0x1000;
+ npc->view.back = 16 * 0x200;
+ npc->view.front = 16 * 0x200;
+ npc->view.top = 8 * 0x200;
+ npc->view.bottom = 8 * 0x200;
break;
case 10:
npc->act_no = 11;
npc->ani_no = 1;
- npc->view.top = 0x2000;
- npc->view.bottom = 0x2000;
- npc->y -= 0xA00;
+ npc->view.top = 16 * 0x200;
+ npc->view.bottom = 16 * 0x200;
+ npc->y -= 5 * 0x200;
break;
case 20:
@@ -1156,7 +1165,7 @@
npc->act_no = 41;
npc->act_wait = 2;
npc->direct = 0;
- npc->y -= 0x6000;
+ npc->y -= 48 * 0x200;
npc->xm = -0x1000;
// Fallthrough
case 41:
@@ -1206,8 +1215,8 @@
{
case 0:
npc->act_no = 1;
- npc->y = npc->y; // Redundant line
- npc->x += 0x3000;
+ npc->y = npc->y; // This line probably isn't accurate to the original source code, but it produces the same assembly
+ npc->x += 24 * 0x200;
break;
}
@@ -1222,7 +1231,7 @@
if (npc->act_no == 0)
{
npc->act_no = 1;
- npc->y += 0x800;
+ npc->y += 4 * 0x200;
}
npc->rect = rc;
@@ -1241,10 +1250,10 @@
RECT rcLeft = {112, 64, 144, 80};
RECT rcRight = {112, 80, 144, 96};
- npc->x -= 0xC00;
+ npc->x -= 6 * 0x200;
- if (npc->x <= 0x26000)
- npc->x += 0x2C000;
+ if (npc->x <= 19 * 0x10 * 0x200)
+ npc->x += 22 * 0x10 * 0x200;
if (npc->direct == 0)
npc->rect = rcLeft;
@@ -1300,7 +1309,7 @@
if (npc->ani_no > 3)
npc->ani_no = 2;
- if (npc->x < 0x6000)
+ if (npc->x < 48 * 0x200)
{
npc->destroy_voice = 0;
LoseNpChar(npc, 1);
--- a/src/NpcAct200.cpp
+++ b/src/NpcAct200.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Bullet.h"
@@ -65,7 +67,7 @@
if (npc->count1)
--npc->count1;
- if (npc->count1 == 0 && gMC.x > npc->x - 0xE000 && gMC.x < npc->x + 0xE000)
+ if (npc->count1 == 0 && gMC.x > npc->x - (112 * 0x200) && gMC.x < npc->x + (112 * 0x200))
npc->act_no = 20;
break;
@@ -101,21 +103,21 @@
if (++npc->act_wait < 40 && npc->act_wait % 8 == 1)
{
if (npc->direct == 0)
- deg = GetArktan(npc->x - 0x1C00 - npc->tgt_x, npc->y - npc->tgt_y);
+ deg = GetArktan(npc->x - (14 * 0x200) - npc->tgt_x, npc->y - npc->tgt_y);
else
- deg = GetArktan(npc->x + 0x1C00 - npc->tgt_x, npc->y - npc->tgt_y);
+ deg = GetArktan(npc->x + (14 * 0x200) - npc->tgt_x, npc->y - npc->tgt_y);
deg += (unsigned char)Random(-6, 6);
- ym = 3 * GetSin(deg);
- xm = 3 * GetCos(deg);
+ ym = GetSin(deg) * 3;
+ xm = GetCos(deg) * 3;
if (npc->direct == 0)
- SetNpChar(202, npc->x - 0x1C00, npc->y, xm, ym, 0, 0, 0x100);
+ SetNpChar(202, npc->x - (14 * 0x200), npc->y, xm, ym, 0, NULL, 0x100);
else
- SetNpChar(202, npc->x + 0x1C00, npc->y, xm, ym, 0, 0, 0x100);
+ SetNpChar(202, npc->x + (14 * 0x200), npc->y, xm, ym, 0, NULL, 0x100);
- if ((gMC.cond & 2) == 0)
+ if (!(gMC.cond & 2))
PlaySoundObject(33, 1);
}
@@ -210,7 +212,7 @@
switch (npc->act_no)
{
case 0:
- npc->y += 0x600;
+ npc->y += 3 * 0x200;
npc->act_no = 1;
// Fallthrough
case 1:
@@ -219,7 +221,7 @@
else
npc->direct = 2;
- if (npc->act_wait >= 8 && npc->x - 0xE000 < gMC.x && npc->x + 0xE000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0xA000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (112 * 0x200) < gMC.x && npc->x + (112 * 0x200) > gMC.x && npc->y - (80 * 0x200) < gMC.y && npc->y + (80 * 0x200) > gMC.y)
{
npc->ani_no = 1;
}
@@ -238,7 +240,7 @@
npc->act_wait = 0;
}
- if (npc->act_wait >= 8 && npc->x - 0x6000 < gMC.x && npc->x + 0x6000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0x6000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (48 * 0x200) < gMC.x && npc->x + (48 * 0x200) > gMC.x && npc->y - (80 * 0x200) < gMC.y && npc->y + (48 * 0x200) > gMC.y)
{
npc->act_no = 2;
npc->ani_no = 0;
@@ -254,7 +256,7 @@
npc->ani_no = 2;
npc->ym = -0x5FF;
- if ((gMC.cond & 2) == 0)
+ if (!(gMC.cond & 2))
PlaySoundObject(30, 1);
if (npc->direct == 0)
@@ -273,7 +275,7 @@
npc->ani_no = 0;
npc->act_no = 1;
- if ((gMC.cond & 2) == 0)
+ if (!(gMC.cond & 2))
PlaySoundObject(23, 1);
}
@@ -308,13 +310,14 @@
npc->tgt_x = npc->x;
// Fallthrough
case 1:
- if (gMC.x > npc->x - 0x1800 && gMC.x < npc->x + 0x1800 && gMC.y > npc->y)
+ if (gMC.x > npc->x - (12 * 0x200) && gMC.x < npc->x + (12 * 0x200) && gMC.y > npc->y)
npc->act_no = 2;
+
break;
case 2:
if (++npc->act_wait / 6 % 2)
- npc->x = npc->tgt_x - 0x200;
+ npc->x = npc->tgt_x - (1 * 0x200);
else
npc->x = npc->tgt_x;
@@ -323,6 +326,7 @@
npc->act_no = 3;
npc->ani_no = 1;
}
+
break;
case 3:
@@ -330,7 +334,7 @@
if (npc->flag & 0xFF)
{
- if ((gMC.cond & 2) == 0)
+ if (!(gMC.cond & 2))
PlaySoundObject(12, 1);
SetDestroyNpChar(npc->x, npc->y, npc->view.back, 4);
@@ -362,10 +366,10 @@
case 0:
npc->act_no = 1;
npc->tgt_x = npc->x;
- npc->y += 0x800;
+ npc->y += 4 * 0x200;
// Fallthrough
case 1:
- if (gMC.x > npc->x - 0x1800 && gMC.x < npc->x + 0x1800 && gMC.y > npc->y)
+ if (gMC.x > npc->x - (12 * 0x200) && gMC.x < npc->x + (12 * 0x200) && gMC.y > npc->y)
npc->act_no = 2;
break;
@@ -372,7 +376,7 @@
case 2:
if (++npc->act_wait / 6 % 2)
- npc->x = npc->tgt_x - 0x200;
+ npc->x = npc->tgt_x - (1 * 0x200);
else
npc->x = npc->tgt_x;
@@ -454,7 +458,7 @@
break;
case 2:
- if (gMC.x > npc->x - 0xA000 && gMC.x < npc->x + 0xA000)
+ if (gMC.x > npc->x - (80 * 0x200) && gMC.x < npc->x + (80 * 0x200))
{
npc->act_wait = 0;
npc->act_no = 3;
@@ -471,31 +475,33 @@
case 3:
switch (npc->act_wait)
{
+ // Interestingly, this NPC counts down at 60 frames per second,
+ // while the NPC322 (Deleet), counts at 50.
case 60 * 0:
- SetNpChar(207, npc->x + 0x2000, npc->y + 0x800, 0, 0, 0, 0, 0x100);
+ SetNpChar(207, npc->x + (16 * 0x200), npc->y + (4 * 0x200), 0, 0, 0, NULL, 0x100);
break;
case 60 * 1:
- SetNpChar(207, npc->x + 0x2000, npc->y + 0x800, 0, 0, 1, 0, 0x100);
+ SetNpChar(207, npc->x + (16 * 0x200), npc->y + (4 * 0x200), 0, 0, 1, NULL, 0x100);
break;
case 60 * 2:
- SetNpChar(207, npc->x + 0x2000, npc->y + 0x800, 0, 0, 2, 0, 0x100);
+ SetNpChar(207, npc->x + (16 * 0x200), npc->y + (4 * 0x200), 0, 0, 2, NULL, 0x100);
break;
case 60 * 3:
- SetNpChar(207, npc->x + 0x2000, npc->y + 0x800, 0, 0, 3, 0, 0x100);
+ SetNpChar(207, npc->x + (16 * 0x200), npc->y + (4 * 0x200), 0, 0, 3, NULL, 0x100);
break;
case 60 * 4:
- SetNpChar(207, npc->x + 0x2000, npc->y + 0x800, 0, 0, 4, 0, 0x100);
+ SetNpChar(207, npc->x + (16 * 0x200), npc->y + (4 * 0x200), 0, 0, 4, NULL, 0x100);
break;
case 60 * 5:
- npc->hit.back = 0x10000;
- npc->hit.front = 0x10000;
- npc->hit.top = 0xC800;
- npc->hit.bottom = 0xC800;
+ npc->hit.back = 128 * 0x200;
+ npc->hit.front = 128 * 0x200;
+ npc->hit.top = 100 * 0x200;
+ npc->hit.bottom = 100 * 0x200;
npc->damage = 30;
PlaySoundObject(35, 1);
SetDestroyNpChar(npc->x, npc->y, 0x10000, 100);
@@ -561,7 +567,7 @@
PlaySoundObject(43, 1);
// Fallthrough
case 1:
- npc->x += 0x200;
+ npc->x += 1 * 0x200;
if (++npc->act_wait > 8)
{
@@ -602,7 +608,7 @@
switch (npc->act_no)
{
case 0:
- if (gMC.x < npc->x + 0x2000 && gMC.x > npc->x - 0x2000)
+ if (gMC.x < npc->x + (16 * 0x200) && gMC.x > npc->x - (16 * 0x200))
{
npc->bits |= NPC_SHOOTABLE;
npc->ym = -0x200;
@@ -616,24 +622,23 @@
if (npc->direct == 0)
{
- npc->x = gMC.x + 0x20000;
+ npc->x = gMC.x + (256 * 0x200);
npc->xm = -0x2FF;
}
else
{
- npc->x = gMC.x - 0x20000;
+ npc->x = gMC.x - (256 * 0x200);
npc->xm = 0x2FF;
}
+
+ return;
}
- else
- {
- npc->rect.right = 0;
- npc->damage = 0;
- npc->xm = 0;
- npc->ym = 0;
- npc->bits &= ~NPC_SHOOTABLE;
- }
+ npc->rect.right = 0;
+ npc->damage = 0;
+ npc->xm = 0;
+ npc->ym = 0;
+ npc->bits &= ~NPC_SHOOTABLE;
return;
case 1:
@@ -679,7 +684,7 @@
npc->y += npc->ym;
}
- if (gMC.x > npc->x + 0x32000 || gMC.x < npc->x - 0x32000)
+ if (gMC.x > npc->x + (400 * 0x200) || gMC.x < npc->x - (400 * 0x200))
{
npc->act_no = 0;
npc->xm = 0;
@@ -693,7 +698,7 @@
break;
}
- if (npc->act_no)
+ if (npc->act_no != 0)
{
if (npc->act_wait < 150)
++npc->act_wait;
@@ -700,13 +705,17 @@
if (npc->act_wait == 150)
{
- if (++npc->count2 % 8 == 0 && npc->x < gMC.x + 0x14000 && npc->x > gMC.x - 0x14000)
+ if (++npc->count2 % 8 == 0 && npc->x < gMC.x + (160 * 0x200) && npc->x > gMC.x - (160 * 0x200))
{
- unsigned char deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
+ unsigned char deg;
+ int xm;
+ int ym;
+
+ deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
deg += (unsigned char)Random(-6, 6);
- const int ym = 3 * GetSin(deg);
- const int xm = 3 * GetCos(deg);
- SetNpChar(209, npc->x, npc->y, xm, ym, 0, 0, 0x100);
+ ym = GetSin(deg) * 3;
+ xm = GetCos(deg) * 3;
+ SetNpChar(209, npc->x, npc->y, xm, ym, 0, NULL, 0x100);
PlaySoundObject(39, 1);
}
@@ -789,7 +798,7 @@
switch (npc->act_no)
{
case 0:
- if (gMC.x < npc->x + 0x2000 && gMC.x > npc->x - 0x2000)
+ if (gMC.x < npc->x + (16 * 0x200) && gMC.x > npc->x - (16 * 0x200))
{
npc->bits |= NPC_SHOOTABLE;
npc->ym = -0x200;
@@ -799,12 +808,12 @@
if (npc->direct == 0)
{
- npc->x = gMC.x + 0x20000;
+ npc->x = gMC.x + (256 * 0x200);
npc->xm = -0x2FF;
}
else
{
- npc->x = gMC.x - 0x20000;
+ npc->x = gMC.x - (256 * 0x200);
npc->xm = 0x2FF;
}
}
@@ -903,7 +912,7 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x800;
+ npc->y -= 4 * 0x200;
// Fallthrough
case 1:
if (++npc->ani_wait > 30)
@@ -921,8 +930,8 @@
npc->act_no = 11;
npc->ani_no = 2;
npc->ani_wait = 0;
- npc->tgt_y = npc->y - 0x2000;
- npc->tgt_x = npc->x - 0xC00;
+ npc->tgt_y = npc->y - (16 * 0x200);
+ npc->tgt_x = npc->x - (6 * 0x200);
npc->ym = 0;
npc->bits |= NPC_IGNORE_SOLIDITY;
// Fallthrough
@@ -990,6 +999,7 @@
npc->rect = rcRight[npc->ani_no];
+ // Use different sprite if player is wearing the Mimiga Mask
if (gMC.equip & 0x40)
{
if (npc->ani_no > 1)
@@ -1024,12 +1034,12 @@
npc->tgt_y = npc->y;
// Fallthrough
case 1:
- if (gMC.y > npc->y - 0x1000 && gMC.y < npc->y + 0x1000)
+ if (gMC.y > npc->y - (8 * 0x200) && gMC.y < npc->y + (8 * 0x200))
{
if (npc->direct == 0)
- npc->y -= 0x1E000;
+ npc->y -= 240 * 0x200;
else
- npc->y += 0x1E000;
+ npc->y += 240 * 0x200;
npc->act_no = 10;
npc->act_wait = 0;
@@ -1090,7 +1100,7 @@
if (++npc->act_wait % 5 == 1)
{
- SetNpChar(214, npc->x, npc->y, (Random(2, 12) * 0x200) / 4, Random(-0x200, 0x200), 0, 0, 0x100);
+ SetNpChar(214, npc->x, npc->y, (Random(2, 12) * 0x200) / 4, Random(-0x200, 0x200), 0, NULL, 0x100);
PlaySoundObject(21, 1);
}
@@ -1128,12 +1138,13 @@
if (npc->ani_no > 6)
npc->ani_no = 4;
- if (gMC.y < npc->tgt_y + 0x1E000 && gMC.y > npc->tgt_y - 0x1E000)
+ if (gMC.y < npc->tgt_y + (240 * 0x200) && gMC.y > npc->tgt_y - (240 * 0x200))
{
npc->act_no = 20;
npc->act_wait = 0;
npc->ani_no = 4;
}
+
break;
}
@@ -1159,7 +1170,7 @@
else
npc->y += npc->ym;
- if (gMC.y > npc->tgt_y + 0x1E000 || gMC.y < npc->tgt_y - 0x1E000)
+ if (gMC.y > npc->tgt_y + (240 * 0x200) || gMC.y < npc->tgt_y - (240 * 0x200))
npc->act_no = 40;
}
@@ -1228,7 +1239,7 @@
npc->bits &= ~NPC_IGNORE_SOLIDITY;
// Fallthrough
case 1:
- if (gMC.x > npc->x - 0x1800 && gMC.x < npc->x + 0x1800 && gMC.y > npc->y && gMC.y < npc->y + 0x1000)
+ if (gMC.x > npc->x - (12 * 0x200) && gMC.x < npc->x + (12 * 0x200) && gMC.y > npc->y && gMC.y < npc->y + (8 * 0x200))
{
npc->act_no = 15;
npc->act_wait = 0;
@@ -1279,7 +1290,7 @@
case 40:
npc->bits |= NPC_IGNORE_SOLIDITY;
- npc->y += 0x200;
+ npc->y += 1 * 0x200;
if (++npc->act_wait == 32)
{
@@ -1394,7 +1405,7 @@
npc->ani_no = 3;
if (++npc->act_wait / 2 % 2)
- npc->x = npc->tgt_x + 0x200;
+ npc->x = npc->tgt_x + (1 * 0x200);
else
npc->x = npc->tgt_x;
@@ -1485,11 +1496,11 @@
if (npc->direct == 0)
{
if (Random(0, 40) == 1)
- SetNpChar(4, npc->x + (Random(-20, 20) * 0x200), npc->y, 0, -0x200, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-20, 20) * 0x200), npc->y, 0, -0x200, 0, NULL, 0x100);
}
else
{
- SetNpChar(199, npc->x + (Random(-0xA0, 0xA0) * 0x200), npc->y + (Random(-0x80, 0x80) * 0x200), 0, 0, 2, 0, 0x100);
+ SetNpChar(199, npc->x + (Random(-0xA0, 0xA0) * 0x200), npc->y + (Random(-0x80, 0x80) * 0x200), 0, 0, 2, NULL, 0x100);
}
npc->rect = rc;
--- a/src/NpcAct220.cpp
+++ b/src/NpcAct220.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Caret.h"
@@ -168,7 +170,7 @@
if (npc->act_no == 0)
{
++npc->act_no;
- npc->y -= 0x1000;
+ npc->y -= 8 * 0x200;
}
npc->rect = rc;
@@ -220,7 +222,7 @@
break;
}
- if (npc->act_no < 2 && gMC.y < npc->y + 0x2000 && gMC.y > npc->y - 0x2000)
+ if (npc->act_no < 2 && gMC.y < npc->y + (16 * 0x200) && gMC.y > npc->y - (16 * 0x200))
{
if (gMC.x < npc->x)
npc->direct = 0;
@@ -274,7 +276,7 @@
break;
}
- if (npc->act_no < 2 && gMC.y < npc->y + 0x2000 && gMC.y > npc->y - 0x2000)
+ if (npc->act_no < 2 && gMC.y < npc->y + (16 * 0x200) && gMC.y > npc->y - (16 * 0x200))
{
if (gMC.x < npc->x)
npc->direct = 0;
@@ -392,6 +394,7 @@
npc->ani_no = 2;
++npc->act_wait;
+
break;
case 20:
@@ -438,7 +441,7 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x1000;
+ npc->y -= 8 * 0x200;
// Fallthrough
case 1:
npc->xm = 0;
@@ -526,7 +529,7 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x2000;
+ npc->y -= 16 * 0x200;
break;
}
@@ -548,8 +551,8 @@
{
case 0:
npc->act_no = 1;
- npc->x -= 0x2000;
- npc->y -= 0x2000;
+ npc->x -= 16 * 0x200;
+ npc->y -= 16 * 0x200;
break;
}
@@ -604,7 +607,7 @@
for (i = 0; i < 10; ++i)
{
- SetNpChar(4, npc->x + (Random(-16, 16) * 0x200), npc->y + (Random(-8, 8) * 0x200), 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-16, 16) * 0x200), npc->y + (Random(-8, 8) * 0x200), 0, 0, 0, NULL, 0x100);
PlaySoundObject(12, 1); // Wait, it does this in a loop?
}
// Fallthrough
@@ -614,9 +617,9 @@
++npc->act_wait;
if (npc->act_wait % 2 == 0)
- SetCaret(npc->x - 0x1400, npc->y + 0x1000, 7, 3);
+ SetCaret(npc->x - (10 * 0x200), npc->y + (8 * 0x200), 7, 3);
if (npc->act_wait % 2 == 1)
- SetCaret(npc->x + 0x1400, npc->y + 0x1000, 7, 3);
+ SetCaret(npc->x + (10 * 0x200), npc->y + (8 * 0x200), 7, 3);
if (npc->act_wait % 4 == 1)
PlaySoundObject(34, 1);
@@ -630,7 +633,7 @@
for (i = 0; i < 6; ++i)
{
- SetNpChar(4, npc->x + (Random(-16, 16) * 0x200), npc->y + (Random(-8, 8) * 0x200), 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-16, 16) * 0x200), npc->y + (Random(-8, 8) * 0x200), 0, 0, 0, NULL, 0x100);
PlaySoundObject(12, 1);
}
}
@@ -644,9 +647,11 @@
if (npc->ym < 0)
{
if (npc->act_wait % 8 == 0)
- SetCaret(npc->x - 0x1400, npc->y + 0x1000, 7, 3);
+ SetCaret(npc->x - (10 * 0x200), npc->y + (8 * 0x200), 7, 3);
+
if (npc->act_wait % 8 == 4)
- SetCaret(npc->x + 0x1400, npc->y + 0x1000, 7, 3);
+ SetCaret(npc->x + (10 * 0x200), npc->y + (8 * 0x200), 7, 3);
+
if (npc->act_wait % 16 == 1)
PlaySoundObject(34, 1);
}
@@ -750,10 +755,12 @@
{
case 0:
npc->act_no = 1;
+
deg = Random(0, 0xFF);
npc->xm = GetCos(deg);
deg = Random(0, 0xFF);
npc->ym = GetSin(deg);
+
npc->count1 = 120;
npc->count2 = Random(-0x20, 0x20) * 0x200;
// Fallthrough
@@ -788,16 +795,15 @@
if (npc->count1 < 120)
{
++npc->count1;
+ break;
}
- else
+
+ if (npc->x - (8 * 0x200) < gMC.x && npc->x + (8 * 0x200) > gMC.x && npc->y < gMC.y && npc->y + (176 * 0x200) > gMC.y)
{
- if (npc->x - 0x1000 < gMC.x && npc->x + 0x1000 > gMC.x && npc->y < gMC.y && npc->y + 0x16000 > gMC.y)
- {
- npc->xm /= 4;
- npc->ym = 0;
- npc->act_no = 3;
- npc->bits &= ~NPC_IGNORE_SOLIDITY;
- }
+ npc->xm /= 4;
+ npc->ym = 0;
+ npc->act_no = 3;
+ npc->bits &= ~NPC_IGNORE_SOLIDITY;
}
break;
@@ -870,7 +876,7 @@
{
case 0:
npc->act_no = 1;
- npc->y += 0x2000;
+ npc->y += 16 * 0x200;
break;
}
@@ -976,9 +982,9 @@
npc->y += npc->ym;
if (npc->ani_no == 2)
- npc->hit.top = 0xA00;
+ npc->hit.top = 5 * 0x200;
else
- npc->hit.top = 0x800;
+ npc->hit.top = 4 * 0x200;
if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no];
@@ -1017,7 +1023,7 @@
npc->ym = 0;
// Fallthrough
case 1:
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
}
@@ -1035,7 +1041,7 @@
else
npc->direct = 0;
- if (gMC.x < npc->x + 0x10000 && gMC.x > npc->x - 0x10000 && gMC.y < npc->y + 0x4000 && gMC.y > npc->y - 0x14000)
+ if (gMC.x < npc->x + (128 * 0x200) && gMC.x > npc->x - (128 * 0x200) && gMC.y < npc->y + (32 * 0x200) && gMC.y > npc->y - (160 * 0x200))
++npc->act_wait;
if (npc->act_wait > 80)
@@ -1085,9 +1091,9 @@
PlaySoundObject(39, 1);
if (npc->direct == 0)
- SetNpChar(237, npc->x - 0x1000, npc->y - 0x1000, -0x400, -0x400, 0, 0, 0x100);
+ SetNpChar(237, npc->x - (8 * 0x200), npc->y - (8 * 0x200), -0x400, -0x400, 0, NULL, 0x100);
else
- SetNpChar(237, npc->x + 0x1000, npc->y - 0x1000, 0x400, -0x400, 0, 0, 0x100);
+ SetNpChar(237, npc->x + (8 * 0x200), npc->y - (8 * 0x200), 0x400, -0x400, 0, NULL, 0x100);
}
if (++npc->ani_wait > 1)
@@ -1124,6 +1130,7 @@
void ActNpc237(NPCHAR *npc)
{
int i;
+ BOOL bHit;
RECT rc = {312, 32, 320, 40};
@@ -1133,11 +1140,13 @@
npc->act_no = 1;
// Fallthrough
case 1:
- BOOL bHit = FALSE;
+ bHit = FALSE;
+
++npc->act_wait;
if (npc->flag & 0xFF)
bHit = TRUE;
+
if (npc->act_wait > 10 && npc->flag & 0x100)
bHit = TRUE;
@@ -1167,6 +1176,8 @@
// Press (sideways)
void ActNpc238(NPCHAR *npc)
{
+ int i;
+
RECT rc[3] = {
{184, 200, 208, 216},
{208, 200, 232, 216},
@@ -1179,11 +1190,11 @@
npc->act_no = 1;
npc->tgt_x = npc->x;
npc->tgt_y = npc->y;
- npc->view.front = 0x2000;
- npc->view.back = 0x1000;
+ npc->view.front = 16 * 0x200;
+ npc->view.back = 8 * 0x200;
// Fallthrough
case 1:
- if (npc->direct == 0 && gMC.x < npc->x && gMC.x > npc->x - 0x18000 && gMC.y > npc->y - 0x800 && gMC.y < npc->y + 0x1000)
+ if (npc->direct == 0 && gMC.x < npc->x && gMC.x > npc->x - (192 * 0x200) && gMC.y > npc->y - (4 * 0x200) && gMC.y < npc->y + (8 * 0x200))
{
npc->act_no = 10;
npc->act_wait = 0;
@@ -1190,7 +1201,7 @@
npc->ani_no = 2;
}
- if (npc->direct == 2 && gMC.x > npc->x && gMC.x < npc->x + 0x18000 && gMC.y > npc->y - 0x800 && gMC.y < npc->y + 0x1000)
+ if (npc->direct == 2 && gMC.x > npc->x && gMC.x < npc->x + (192 * 0x200) && gMC.y > npc->y - (4 * 0x200) && gMC.y < npc->y + (8 * 0x200))
{
npc->act_no = 10;
npc->act_wait = 0;
@@ -1203,9 +1214,9 @@
npc->damage = 0x7F;
if (npc->direct == 0)
- npc->x -= 0xC00;
+ npc->x -= 6 * 0x200;
else
- npc->x += 0xC00;
+ npc->x += 6 * 0x200;
if (++npc->act_wait == 8)
{
@@ -1212,9 +1223,9 @@
npc->act_no = 20;
npc->act_wait = 0;
- for (int i = 0; i < 4; ++i)
+ for (i = 0; i < 4; ++i)
{
- SetNpChar(4, npc->x + (Random(-16, 16) * 0x200), npc->y + (Random(-8, 8) * 0x200), 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-16, 16) * 0x200), npc->y + (Random(-8, 8) * 0x200), 0, 0, 0, NULL, 0x100);
PlaySoundObject(12, 1);
}
}
@@ -1244,19 +1255,19 @@
}
if (npc->direct == 0)
- npc->x += 0x800;
+ npc->x += 4 * 0x200;
else
- npc->x -= 0x800;
+ npc->x -= 4 * 0x200;
break;
}
if (npc->direct == 0 && gMC.x < npc->x)
- npc->hit.back = 0x2000;
+ npc->hit.back = 16 * 0x200;
else if (npc->direct == 2 && gMC.x > npc->x)
- npc->hit.back = 0x2000;
+ npc->hit.back = 16 * 0x200;
else
- npc->hit.back = 0x1000;
+ npc->hit.back = 8 * 0x200;
npc->rect = rc[npc->ani_no];
}
@@ -1274,15 +1285,15 @@
if (npc->direct == 0)
{
- npc->x += 0x1000;
- npc->y += 0x2000;
+ npc->x += 8 * 0x200;
+ npc->y += 16 * 0x200;
}
else
{
- npc->view.front = 0x3000;
- npc->view.back = 0x3000;
- npc->view.top = 0x1000;
- npc->view.back = 0x3000;
+ npc->view.front = 24 * 0x200;
+ npc->view.back = 24 * 0x200;
+ npc->view.top = 8 * 0x200;
+ npc->view.back = 24 * 0x200;
}
break;
--- a/src/NpcAct240.cpp
+++ b/src/NpcAct240.cpp
@@ -134,7 +134,7 @@
switch (npc->act_no)
{
case 0:
- npc->y += 0x600;
+ npc->y += 3 * 0x200;
npc->act_no = 1;
// Fallthrough
case 1:
@@ -143,7 +143,7 @@
else
npc->direct = 2;
- if (npc->act_wait >= 8 && npc->x - 0x12000 < gMC.x && npc->x + 0x12000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0xA000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (144 * 0x200) < gMC.x && npc->x + (144 * 0x200) > gMC.x && npc->y - (80 * 0x200) < gMC.y && npc->y + (80 * 0x200) > gMC.y)
{
npc->ani_no = 1;
}
@@ -162,7 +162,7 @@
npc->act_wait = 0;
}
- if (npc->act_wait >= 8 && npc->x - 0xC000 < gMC.x && npc->x + 0xC000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0xC000 > gMC.y)
+ if (npc->act_wait >= 8 && npc->x - (96 * 0x200) < gMC.x && npc->x + (96 * 0x200) > gMC.x && npc->y - (80 * 0x200) < gMC.y && npc->y + (96 * 0x200) > gMC.y)
{
npc->act_no = 2;
npc->ani_no = 0;
@@ -231,7 +231,7 @@
npc->act_wait = Random(0, 50);
// Fallthrough
case 1:
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
break;
@@ -301,7 +301,7 @@
npc->act_wait = Random(0, 500);
// Fallthrough
case 1:
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
}
@@ -308,7 +308,7 @@
else
{
npc->act_no = 0;
- SetNpChar(242, npc->x, npc->y + (Random(-0x20, 0x20) * 0x200), 0, 0, npc->direct, 0, 0x100);
+ SetNpChar(242, npc->x, npc->y + (Random(-0x20, 0x20) * 0x200), 0, 0, npc->direct, NULL, 0x100);
}
break;
@@ -334,9 +334,9 @@
if (bHit)
{
for (i = 0; i < 3; ++i)
- SetCaret(npc->x, npc->y + 0x800, 1, 2);
+ SetCaret(npc->x, npc->y + (4 * 0x200), 1, 2);
- if (npc->x > gMC.x - 0x20000 && npc->x < gMC.x + 0x20000 && npc->y > gMC.y - 0x14000 && npc->y < gMC.y + 0x14000)
+ if (npc->x > gMC.x - (256 * 0x200) && npc->x < gMC.x + (256 * 0x200) && npc->y > gMC.y - (160 * 0x200) && npc->y < gMC.y + (160 * 0x200))
PlaySoundObject(21, 1);
npc->cond = 0;
@@ -372,7 +372,7 @@
case 1:
npc->ani_no = 0;
- if (npc->act_wait)
+ if (npc->act_wait != 0)
{
--npc->act_wait;
return;
@@ -394,7 +394,7 @@
npc->ani_no = 0;
npc->act_no = 1;
npc->act_wait = npc->code_flag;
- SetNpChar(244, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+ SetNpChar(244, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
}
break;
@@ -411,6 +411,8 @@
// Press (proximity)
void ActNpc246(NPCHAR *npc)
{
+ int i;
+
RECT rcLeft[3] = {
{144, 112, 160, 136},
{160, 112, 176, 136},
@@ -421,10 +423,10 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x800;
+ npc->y -= 4 * 0x200;
// Fallthrough
case 1:
- if (gMC.x < npc->x + 0x1000 && gMC.x > npc->x - 0x1000 && gMC.y > npc->y + 0x1000 && gMC.y < npc->y + 0x10000)
+ if (gMC.x < npc->x + (8 * 0x200) && gMC.x > npc->x - (8 * 0x200) && gMC.y > npc->y + (8 * 0x200) && gMC.y < npc->y + (128 * 0x200))
npc->act_no = 5;
break;
@@ -432,7 +434,8 @@
case 5:
if (npc->flag & 8)
{
- // Another place where this blank space is needed for ASM-accuracy
+ // Another place where this blank space is needed for ASM-accuracy.
+ // Chances are there used to be commented-out code here.
}
else
{
@@ -468,8 +471,8 @@
{
if (npc->ani_no > 1)
{
- for (int i = 0; i < 4; ++i)
- SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
PlaySoundObject(26, 1);
SetQuake(10);
@@ -532,8 +535,8 @@
{
case 0:
npc->act_no = 1;
- npc->y += 0xC00;
- npc->tgt_y = 0x8000;
+ npc->y += 6 * 0x200;
+ npc->tgt_y = 64 * 0x200;
// Fallthrough
case 1:
if (Random(0, 120) == 10)
@@ -649,9 +652,10 @@
{
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
deg += (unsigned char)Random(-4, 4);
- ym = 4 * GetSin(deg);
- xm = 4 * GetCos(deg);
- SetNpChar(248, npc->x, npc->y + 0x800, xm, ym, 0, 0, 0x100);
+ ym = GetSin(deg) * 4;
+ xm = GetCos(deg) * 4;
+
+ SetNpChar(248, npc->x, npc->y + (4 * 0x200), xm, ym, 0, NULL, 0x100);
PlaySoundObject(34, 1);
}
@@ -666,8 +670,8 @@
case 113:
if (++npc->act_wait == 10)
{
- ym = gMC.y - 0x8000;
- SetNpChar(279, gMC.x, ym, 0, 0, 1, 0, 0x100);
+ ym = gMC.y - (64 * 0x200);
+ SetNpChar(279, gMC.x, ym, 0, 0, 1, NULL, 0x100);
}
if (npc->act_wait > 30)
@@ -682,17 +686,20 @@
npc->act_no = 151;
npc->act_wait = 0;
npc->ani_no = 7;
- SetNpChar(249, npc->x, npc->y, 0, 0, 0, 0, 0x100);
- SetNpChar(249, npc->x, npc->y, 0, 0, 2, 0, 0x100);
+
+ SetNpChar(249, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(249, npc->x, npc->y, 0, 0, 2, NULL, 0x100);
+
npc->tgt_x = Random(9, 31) * 0x200 * 0x10;
npc->tgt_y = Random(5, 7) * 0x200 * 0x10;
+
PlaySoundObject(29, 1);
// Fallthrough
case 151:
if (++npc->act_wait == 42)
{
- SetNpChar(249, npc->tgt_x + 0x2000, npc->tgt_y, 0, 0, 0, 0, 0x100);
- SetNpChar(249, npc->tgt_x - 0x2000, npc->tgt_y, 0, 0, 2, 0, 0x100);
+ SetNpChar(249, npc->tgt_x + (16 * 0x200), npc->tgt_y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(249, npc->tgt_x - (16 * 0x200), npc->tgt_y, 0, 0, 2, NULL, 0x100);
}
if (npc->act_wait > 50)
@@ -715,7 +722,7 @@
SetNpChar(252, 0, 0, 0, 0, 0xC0, npc, 0x100);
}
- if (gMC.x < npc->x - 0xE000 || gMC.x > npc->x + 0xE000)
+ if (gMC.x < npc->x - (112 * 0x200) || gMC.x > npc->x + (112 * 0x200))
npc->act_no = 160;
else
npc->act_no = 100;
@@ -746,7 +753,7 @@
if (++npc->act_wait % 24 == 0)
{
- SetNpChar(250, npc->x, npc->y + 0x800, 0, 0, 0, 0, 0x100);
+ SetNpChar(250, npc->x, npc->y + (4 * 0x200), 0, 0, 0, NULL, 0x100);
PlaySoundObject(34, 1);
}
@@ -763,18 +770,22 @@
npc->act_no = 1001;
npc->act_wait = 0;
npc->ani_no = 4;
+
npc->tgt_x = npc->x;
npc->tgt_y = npc->y;
+
npc->xm = 0;
npc->ym = 0;
+
DeleteNpCharCode(252, 1);
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
// Fallthrough
case 1001:
if (++npc->act_wait / 2 % 2)
- npc->x = npc->tgt_x + 0x200;
+ npc->x = npc->tgt_x + (1 * 0x200);
else
npc->x = npc->tgt_x;
@@ -860,12 +871,12 @@
if (npc->direct == 0)
{
npc->rect = rc[0];
- npc->x -= 1024;
+ npc->x -= 2 * 0x200;
}
else
{
npc->rect = rc[1];
- npc->x += 1024;
+ npc->x += 2 * 0x200;
}
}
@@ -919,7 +930,7 @@
if (npc->ani_no > 1)
npc->ani_no = 0;
- if (gMC.x > npc->x - 0x1000 && gMC.x < npc->x + 0x1000 && gMC.y > npc->y)
+ if (gMC.x > npc->x - (8 * 0x200) && gMC.x < npc->x + (8 * 0x200) && gMC.y > npc->y)
npc->act_no = 10;
break;
@@ -931,7 +942,7 @@
case 11:
if (++npc->act_wait > 10)
{
- SetNpChar(251, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+ SetNpChar(251, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
PlaySoundObject(101, 1);
npc->cond = 0;
return;
@@ -963,7 +974,7 @@
if (++npc->ani_no > 1)
npc->ani_no = 0;
- npc->y += 0x1000;
+ npc->y += 8 * 0x200;
if (npc->flag & 0xFF)
{
@@ -1012,8 +1023,8 @@
if (npc->act_wait < 192)
++npc->act_wait;
- npc->x = npc->pNpc->x + npc->act_wait * GetCos(deg) / 4;
- npc->y = npc->pNpc->y + npc->act_wait * GetSin(deg) / 4;
+ npc->x = npc->pNpc->x + (GetCos(deg) * npc->act_wait) / 4;
+ npc->y = npc->pNpc->y + (GetSin(deg) * npc->act_wait) / 4;
if (npc->pNpc->act_no == 151)
{
@@ -1048,9 +1059,9 @@
if (npc->flag & 0xFF)
{
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
npc->cond = 0;
}
@@ -1121,8 +1132,8 @@
{
case 0:
npc->act_no = 1;
- SetNpChar(255, npc->x + 0x2400, npc->y - 0x7200, 0, 0, 0, npc, 0x100);
- SetNpChar(255, npc->x - 0x4000, npc->y - 0x6800, 0, 0, 2, npc, 0x100);
+ SetNpChar(255, npc->x + (18 * 0x200), npc->y - (57 * 0x200), 0, 0, 0, npc, 0x100);
+ SetNpChar(255, npc->x - (32 * 0x200), npc->y - (52 * 0x200), 0, 0, 2, npc, 0x100);
break;
case 20:
@@ -1133,14 +1144,14 @@
case 30:
npc->act_no = 21;
- SetNpChar(223, npc->x - 0x1600, npc->y - 0x1C00, 0, 0, 0, 0, 0x100);
+ SetNpChar(223, npc->x - (11 * 0x200), npc->y - (14 * 0x200), 0, 0, 0, NULL, 0x100);
break;
case 40:
npc->act_no = 21;
- SetNpChar(223, npc->x - 0x1200, npc->y - 0x1C00, 0, 0, 0, 0, 0x100);
- SetNpChar(40, npc->x - 0x2C00, npc->y - 0x1C00, 0, 0, 0, 0, 0x100);
- SetNpChar(93, npc->x - 0x4600, npc->y - 0x1C00, 0, 0, 0, 0, 0x100);
+ SetNpChar(223, npc->x - (9 * 0x200), npc->y - (14 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(40, npc->x - (22 * 0x200), npc->y - (14 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(93, npc->x - (35 * 0x200), npc->y - (14 * 0x200), 0, 0, 0, NULL, 0x100);
break;
}
@@ -1174,13 +1185,13 @@
if (npc->direct == 0)
{
- npc->view.front = 0x7000;
- npc->view.back = 0x7000;
+ npc->view.front = (56 * 0x200);
+ npc->view.back = (56 * 0x200);
}
else
{
- npc->view.front = 0x5000;
- npc->view.back = 0x5000;
+ npc->view.front = (40 * 0x200);
+ npc->view.back = (40 * 0x200);
}
// Fallthrough
case 1:
@@ -1201,13 +1212,13 @@
if (npc->direct == 0)
{
- npc->x = npc->pNpc->x + 0x2400;
- npc->y = npc->pNpc->y - 0x7200;
+ npc->x = npc->pNpc->x + (18 * 0x200);
+ npc->y = npc->pNpc->y - (57 * 0x200);
}
else
{
- npc->x = npc->pNpc->x - 0x4000;
- npc->y = npc->pNpc->y - 0x6800;
+ npc->x = npc->pNpc->x - (32 * 0x200);
+ npc->y = npc->pNpc->y - (52 * 0x200);
}
if (npc->direct == 0)
@@ -1233,7 +1244,7 @@
case 0:
gSuperXpos = 0;
npc->act_no = 1;
- npc->y -= 0x1000;
+ npc->y -= 8 * 0x200;
// Fallthrough
case 1:
npc->ani_no = 0;
@@ -1272,8 +1283,8 @@
case 40:
npc->act_no = 41;
- SetNpChar(257, npc->x - 0x1C00, npc->y - 0x2000, 0, 0, 0, 0, 0x100);
- SetNpChar(257, npc->x - 0x1C00, npc->y - 0x2000, 0, 0, 2, 0, 0xAA);
+ SetNpChar(257, npc->x - (14 * 0x200), npc->y - (16 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(257, npc->x - (14 * 0x200), npc->y - (16 * 0x200), 0, 0, 2, NULL, 0xAA);
// Fallthrough
case 41:
npc->ani_no = 4;
@@ -1322,7 +1333,7 @@
npc->act_no = 1;
// Fallthrough
case 1:
- if (gSuperXpos)
+ if (gSuperXpos != 0)
npc->act_no = 10;
break;
@@ -1350,6 +1361,7 @@
npc->x += npc->xm;
npc->y += npc->ym;
+
break;
}
@@ -1395,16 +1407,16 @@
else
npc->direct = 2;
- npc->y = gMC.y - 0x800;
+ npc->y = gMC.y - (4 * 0x200);
if (npc->direct == 0)
{
- npc->x = gMC.x + 0x600;
+ npc->x = gMC.x + (3 * 0x200);
npc->rect = rcLeft;
}
else
{
- npc->x = gMC.x - 0x600;
+ npc->x = gMC.x - (3 * 0x200);
npc->rect = rcRight;
}
@@ -1422,7 +1434,7 @@
break;
case 11:
- if (npc->y < 0x8000)
+ if (npc->y < (64 * 0x200))
npc->ym = 0x20;
npc->x += npc->xm;
--- a/src/NpcAct260.cpp
+++ b/src/NpcAct260.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Caret.h"
@@ -58,7 +60,7 @@
case 10:
npc->act_no = 11;
npc->ani_no = 2;
- SetNpChar(87, npc->x, npc->y - 0x2000, 0, 0, 0, 0, 0x100);
+ SetNpChar(87, npc->x, npc->y - (16 * 0x200), 0, 0, 0, NULL, 0x100);
break;
}
@@ -90,8 +92,8 @@
switch (npc->act_no)
{
case 0:
- npc->x -= 0x200;
- npc->y -= 0x400;
+ npc->x -= 1 * 0x200;
+ npc->y -= 2 * 0x200;
npc->act_no = 1;
npc->ani_no = 0;
npc->ani_wait = 0;
@@ -143,8 +145,8 @@
switch (npc->act_no)
{
case 0:
- npc->x -= 0x200;
- npc->y -= 0x400;
+ npc->x -= 1 * 0x200;
+ npc->y -= 2 * 0x200;
npc->act_no = 1;
npc->ani_no = 0;
npc->ani_wait = 0;
@@ -215,7 +217,7 @@
{
case 0:
npc->act_no = 1;
- npc->y += 0x1000;
+ npc->y += 8 * 0x200;
npc->ani_no = 3;
break;
@@ -271,13 +273,13 @@
if (npc->direct == 0)
{
- SetNpChar(264, npc->x - 0x2000, npc->y, 0, 0, 0, 0, 0x100);
- SetNpChar(264, npc->x - 0x2000, npc->y, 0, 0, 0x400, 0, 0x100);
+ SetNpChar(264, npc->x - (16 * 0x200), npc->y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(264, npc->x - (16 * 0x200), npc->y, 0, 0, 0x400, NULL, 0x100);
}
else
{
- SetNpChar(264, npc->x + 0x2000, npc->y, 0, 0, 2, 0, 0x100);
- SetNpChar(264, npc->x + 0x2000, npc->y, 0, 0, 2 + 0x400, 0, 0x100);
+ SetNpChar(264, npc->x + (16 * 0x200), npc->y, 0, 0, 2, NULL, 0x100);
+ SetNpChar(264, npc->x + (16 * 0x200), npc->y, 0, 0, 2 + 0x400, NULL, 0x100);
}
}
@@ -317,9 +319,9 @@
for (deg = 8; deg < 0x100; deg += 0x10)
{
- xm = 2 * GetCos(deg);
- ym = 2 * GetSin(deg);
- SetNpChar(266, npc->x, npc->y, xm, ym, 0, 0, 0x100);
+ xm = GetCos(deg) * 2;
+ ym = GetSin(deg) * 2;
+ SetNpChar(266, npc->x, npc->y, xm, ym, 0, NULL, 0x100);
}
}
@@ -422,7 +424,7 @@
if (++npc->act_wait / 2 % 2)
npc->x = npc->tgt_x;
else
- npc->x = npc->tgt_x + 0x200;
+ npc->x = npc->tgt_x + (1 * 0x200);
break;
}
@@ -456,11 +458,11 @@
{
npc->rect.top += npc->act_wait;
npc->rect.bottom -= npc->act_wait;
- npc->view.top = (16 - npc->act_wait) << 9;
+ npc->view.top = (16 - npc->act_wait) * 0x200;
}
else
{
- npc->view.top = 0x2000;
+ npc->view.top = 16 * 0x200;
}
}
@@ -501,10 +503,10 @@
npc->tgt_x += npc->xm;
- npc->x = npc->tgt_x + npc->act_wait * GetCos(deg) / 2 / 4;
- npc->y = npc->tgt_y + npc->act_wait * GetSin(deg) / 2;
+ npc->x = npc->tgt_x + (GetCos(deg) * npc->act_wait) / 2 / 4;
+ npc->y = npc->tgt_y + (GetSin(deg) * npc->act_wait) / 2;
- SetNpChar(265, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+ SetNpChar(265, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
break;
}
@@ -560,7 +562,7 @@
npc->rect = rc[npc->ani_no];
if (++npc->act_wait % 4 == 1)
- SetNpChar(265, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+ SetNpChar(265, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
if (npc->act_wait > 250)
VanishNpChar(npc);
@@ -608,9 +610,9 @@
npc->direct = 2;
if (npc->direct == 0)
- npc->x = gSuperXpos - 0xC00;
+ npc->x = gSuperXpos - (6 * 0x200);
else
- npc->x = gSuperXpos + 0xC00;
+ npc->x = gSuperXpos + (6 * 0x200);
npc->y = gSuperYpos;
// Fallthrough
@@ -680,7 +682,7 @@
{
if (npc->life < npc->count2 - 20)
{
- if (gMC.flag & 8 && gMC.x > npc->x - 0x6000 && gMC.x < npc->x + 0x6000 && npc->ani_no != 6)
+ if (gMC.flag & 8 && gMC.x > npc->x - (48 * 0x200) && gMC.x < npc->x + (48 * 0x200) && npc->ani_no != 6)
{
npc->ani_no = 6;
DamageMyChar(5);
@@ -694,7 +696,7 @@
gMC.xm = 0x5FF;
for (i = 0; i < 100; ++i)
- SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y + (Random(-0x10, 0x10) * 0x200), 3 * Random(-0x200, 0x200), 3 * Random(-0x200, 0x200), 3, 0, 0xAA);
+ SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y + (Random(-0x10, 0x10) * 0x200), Random(-0x200, 0x200) * 3, Random(-0x200, 0x200) * 3, 3, NULL, 0xAA);
}
}
else
@@ -804,7 +806,7 @@
npc->ani_no = 3;
++npc->act_wait;
- npc->xm = 7 * npc->xm / 8;
+ npc->xm = (npc->xm * 7) / 8;
npc->ym += 0x80;
if (npc->act_wait > 10)
@@ -823,12 +825,12 @@
if (npc->act_wait > 20 && npc->act_wait % 3 == 1)
{
ym = Random(-0x200, 0x200);
- xm = 4 * Random(0x100, 0x200);
+ xm = Random(0x100, 0x200) * 4;
if (npc->direct == 0)
- SetNpChar(269, npc->x - 0x1000, npc->y - 0x800, -xm, ym, 0, 0, 0x100);
+ SetNpChar(269, npc->x - 0x1000, npc->y - 0x800, -xm, ym, 0, NULL, 0x100);
else
- SetNpChar(269, npc->x + 0x1000, npc->y - 0x800, xm, ym, 2, 0, 0x100);
+ SetNpChar(269, npc->x + 0x1000, npc->y - 0x800, xm, ym, 2, NULL, 0x100);
PlaySoundObject(39, 1);
}
@@ -929,7 +931,7 @@
if (npc->ani_no > 5)
npc->ani_no = 4;
- if (gMC.y > npc->y && gMC.x > npc->x - 0x1000 && gMC.x < npc->x + 0x1000)
+ if (gMC.y > npc->y && gMC.x > npc->x - (8 * 0x200) && gMC.x < npc->x + (8 * 0x200))
{
npc->act_no = 16;
npc->ym = 0x5FF;
@@ -958,15 +960,15 @@
npc->ani_no = 0;
npc->tgt_x = gMC.x;
- npc->tgt_y = gMC.y - 0x4000;
+ npc->tgt_y = gMC.y - (32 * 0x200);
- if (npc->tgt_y < 0x8000)
- npc->tgt_y = 0x8000;
+ if (npc->tgt_y < (64 * 0x200))
+ npc->tgt_y = (64 * 0x200);
- if (npc->tgt_x < 0x8000)
- npc->tgt_x = 0x8000;
- if (npc->tgt_x > 0x48000)
- npc->tgt_x = 0x48000;
+ if (npc->tgt_x < (64 * 0x200))
+ npc->tgt_x = (64 * 0x200);
+ if (npc->tgt_x > (576 * 0x200))
+ npc->tgt_x = (576 * 0x200);
}
break;
@@ -1030,7 +1032,7 @@
if (++npc->act_wait / 2 % 2)
npc->x = npc->tgt_x;
else
- npc->x = npc->tgt_x + 0x200;
+ npc->x = npc->tgt_x + (1 * 0x200);
break;
@@ -1039,7 +1041,7 @@
npc->act_wait = 0;
npc->ani_no = 9;
npc->tgt_x = npc->x;
- npc->y += 0x2000;
+ npc->y += 16 * 0x200;
npc->bits |= NPC_IGNORE_SOLIDITY;
// Fallthrough
case 511:
@@ -1051,7 +1053,7 @@
if (npc->act_wait / 2 % 2)
npc->x = npc->tgt_x;
else
- npc->x = npc->tgt_x + 0x200;
+ npc->x = npc->tgt_x + (1 * 0x200);
if (npc->act_wait > 352)
{
@@ -1063,7 +1065,7 @@
case 520:
npc->damage = 0;
- gSuperYpos = -0x4000;
+ gSuperYpos = -32 * 0x200;
break;
}
@@ -1089,23 +1091,19 @@
if (npc->act_no >= 512)
{
-
+ // There probably used to be some commented-out code here
}
+ else if (npc->act_no < 510)
+ {
+ if (npc->act_no != 102 && npc->act_no != 103 && Random(0, 3) == 2)
+ SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y + (Random(-8, 4) * 0x200), npc->xm, 0, 3, 0, 0x100);
+ }
else
{
- if (npc->act_no < 510)
- {
- if (npc->act_no != 102 && npc->act_no != 103 && Random(0, 3) == 2)
- SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y + (Random(-8, 4) * 0x200), npc->xm, 0, 3, 0, 0x100);
- }
- else
- {
- SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - (((336 - npc->act_wait) / 8) * 0x200), Random(-0x200, 0x200), 2 * Random(-0x200, 0), 3, 0, 0xAA);
- SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - ((336 - npc->act_wait) / 8 * 0x200), Random(-0x200, 0x200), 2 * Random(-0x200, 0), 3, 0, 0xAA);
- SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - ((336 - npc->act_wait) / 8 * 0x200), 0, 2 * Random(-0x200, 0), 3, 0, 0xAA);
- SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - ((336 - npc->act_wait) / 8 * 0x200), 0, 2 * Random(-0x200, 0), 3, 0, 0xAA);
-
- }
+ SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - (((336 - npc->act_wait) / 8) * 0x200), Random(-0x200, 0x200), Random(-0x200, 0) * 2, 3, NULL, 0xAA);
+ SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - (((336 - npc->act_wait) / 8) * 0x200), Random(-0x200, 0x200), Random(-0x200, 0) * 2, 3, NULL, 0xAA);
+ SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - (((336 - npc->act_wait) / 8) * 0x200), 0, 2 * Random(-0x200, 0), 3, NULL, 0xAA);
+ SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - (((336 - npc->act_wait) / 8) * 0x200), 0, 2 * Random(-0x200, 0), 3, NULL, 0xAA);
}
if (npc->direct == 0)
@@ -1116,8 +1114,8 @@
if (npc->act_no == 511)
{
npc->rect.top += npc->act_wait / 8;
- npc->view.top = (44 - npc->act_wait / 8) * 0x200;
- npc->view.bottom = 0x800;
+ npc->view.top = (44 - (npc->act_wait / 8)) * 0x200;
+ npc->view.bottom = 4 * 0x200;
}
else if (npc->act_no == 101 || npc->act_no == 103)
{
@@ -1127,7 +1125,7 @@
}
else
{
- npc->view.top = 0x3800;
+ npc->view.top = 28 * 0x200;
}
}
@@ -1164,7 +1162,7 @@
{280, 40, 320, 80},
};
- if (npc->x < gMC.x - 0x28000 || npc->x > gMC.x + 0x28000 || npc->y < gMC.y - 0x1E000 || npc->y > gMC.y + 0x1E000)
+ if (npc->x < gMC.x - (320 * 0x200) || npc->x > gMC.x + (320 * 0x200) || npc->y < gMC.y - (240 * 0x200) || npc->y > gMC.y + (240 * 0x200))
npc->act_no = 1;
switch (npc->act_no)
@@ -1171,7 +1169,7 @@
{
case 0:
npc->act_no = 1;
- npc->y += 0x1000;
+ npc->y += 8 * 0x200;
// Fallthrough
case 1:
if (++npc->ani_wait > 20)
@@ -1183,8 +1181,12 @@
if (npc->ani_no > 1)
npc->ani_no = 0;
- // This line makes absolutely no sense
- if (npc->x < gMC.x + 0xE000 && npc->x > gMC.x - 0xE000 && npc->x < gMC.x + 0x6000 && npc->x > gMC.x - 0xE000)
+#ifdef FIX_BUGS
+ if (npc->x < gMC.x + (112 * 0x200) && npc->x > gMC.x - (112 * 0x200) && npc->y < gMC.y + (48 * 0x200) && npc->y > gMC.y - (112 * 0x200))
+#else
+ // Instead of checking the X and Y coordinates, this checks the X coordinates twice
+ if (npc->x < gMC.x + (112 * 0x200) && npc->x > gMC.x - (112 * 0x200) && npc->x < gMC.x + (48 * 0x200) && npc->x > gMC.x - (112 * 0x200))
+#endif
npc->act_no = 10;
if (npc->shock)
@@ -1209,7 +1211,7 @@
else
npc->xm = 0x200;
- if (npc->x < gMC.x + 0x8000 && npc->x > gMC.x - 0x8000)
+ if (npc->x < gMC.x + (64 * 0x200) && npc->x > gMC.x - (64 * 0x200))
{
npc->act_no = 20;
npc->act_wait = 0;
@@ -1297,9 +1299,9 @@
deg = 0xF8;
deg += (unsigned char)Random(-0x10, 0x10);
- ym = 5 * GetSin(deg);
- xm = 5 * GetCos(deg);
- SetNpChar(11, npc->x, npc->y + 0x800, xm, ym, 0, 0, 0x100);
+ ym = GetSin(deg) * 5;
+ xm = GetCos(deg) * 5;
+ SetNpChar(11, npc->x, npc->y + (4 * 0x200), xm, ym, 0, NULL, 0x100);
PlaySoundObject(12, 1);
}
@@ -1434,11 +1436,12 @@
npc->act_no = 1;
npc->bits |= NPC_IGNORE_SOLIDITY;
- npc->xm = 3 * Random(-0x200, 0x200);
- npc->ym = 3 * Random(-0x200, 0x200);
+ npc->xm = Random(-0x200, 0x200) * 3;
+ npc->ym = Random(-0x200, 0x200) * 3;
npc->count1 = Random(0x10, 0x33);
npc->count2 = Random(0x80, 0x100);
+
break;
}
@@ -1472,74 +1475,75 @@
// Ironhead block
void ActNpc271(NPCHAR *npc)
{
- if (npc->xm < 0 && npc->x < -0x2000)
+ int a;
+
+ if (npc->xm < 0 && npc->x < -16 * 0x200)
{
VanishNpChar(npc);
+ return;
}
- else
+
+ if (npc->xm > 0 && npc->x > (gMap.width * 0x200 * 0x10) + (1 * 0x200 * 0x10))
{
- if (npc->xm > 0 && npc->x > gMap.width * 0x200 * 0x10 + 0x200 * 0x10)
- {
- VanishNpChar(npc);
- }
- else
- {
- if (npc->act_no == 0)
- {
- npc->act_no = 1;
- int a = Random(0, 9);
+ VanishNpChar(npc);
+ return;
+ }
- if (a == 9)
- {
- npc->rect.left = 0;
- npc->rect.right = 0x20;
- npc->rect.top = 0x40;
- npc->rect.bottom = 0x60;
+ if (npc->act_no == 0)
+ {
+ npc->act_no = 1;
- npc->view.front = 0x2000;
- npc->view.back = 0x2000;
- npc->view.top = 0x2000;
- npc->view.bottom = 0x2000;
+ a = Random(0, 9);
- npc->hit.front = 0x1800;
- npc->hit.back = 0x1800;
- npc->hit.top = 0x1800;
- npc->hit.bottom = 0x1800;
- }
- else
- {
- npc->rect.left = (a % 3) * 16 + 7 * 16;
- npc->rect.top = (a / 3) * 16;
- npc->rect.right = npc->rect.left + 16;
- npc->rect.bottom = npc->rect.top + 16;
- }
+ if (a == 9)
+ {
+ npc->rect.left = 0;
+ npc->rect.right = 0x20;
+ npc->rect.top = 0x40;
+ npc->rect.bottom = 0x60;
- if (npc->direct == 0)
- npc->xm = -2 * Random(0x100, 0x200);
- else
- npc->xm = 2 * Random(0x100, 0x200);
+ npc->view.front = 16 * 0x200;
+ npc->view.back = 16 * 0x200;
+ npc->view.top = 16 * 0x200;
+ npc->view.bottom = 16 * 0x200;
- npc->ym = Random(-0x200, 0x200);
- }
+ npc->hit.front = 12 * 0x200;
+ npc->hit.back = 12 * 0x200;
+ npc->hit.top = 12 * 0x200;
+ npc->hit.bottom = 12 * 0x200;
+ }
+ else
+ {
+ npc->rect.left = ((a % 3) * 16) + (7 * 16);
+ npc->rect.top = (a / 3) * 16;
+ npc->rect.right = npc->rect.left + 16;
+ npc->rect.bottom = npc->rect.top + 16;
+ }
- if (npc->ym < 0 && npc->y - npc->hit.top < 0x1000)
- {
- npc->ym *= -1;
- SetCaret(npc->x, npc->y - 0x1000, 13, 0);
- SetCaret(npc->x, npc->y - 0x1000, 13, 0);
- }
+ if (npc->direct == 0)
+ npc->xm = Random(0x100, 0x200) * -2;
+ else
+ npc->xm = Random(0x100, 0x200) * 2;
- if (npc->ym > 0 && npc->y + npc->hit.bottom > 0x1D000)
- {
- npc->ym *= -1;
- SetCaret(npc->x, npc->y + 0x1000, 13, 0);
- SetCaret(npc->x, npc->y + 0x1000, 13, 0);
- }
+ npc->ym = Random(-0x200, 0x200);
+ }
- npc->x += npc->xm;
- npc->y += npc->ym;
- }
+ if (npc->ym < 0 && npc->y - npc->hit.top < 8 * 0x200)
+ {
+ npc->ym *= -1;
+ SetCaret(npc->x, npc->y - (8 * 0x200), 13, 0);
+ SetCaret(npc->x, npc->y - (8 * 0x200), 13, 0);
}
+
+ if (npc->ym > 0 && npc->y + npc->hit.bottom > 232 * 0x200)
+ {
+ npc->ym *= -1;
+ SetCaret(npc->x, npc->y + (8 * 0x200), 13, 0);
+ SetCaret(npc->x, npc->y + (8 * 0x200), 13, 0);
+ }
+
+ npc->x += npc->xm;
+ npc->y += npc->ym;
}
// Ironhead block generator
@@ -1559,7 +1563,7 @@
else
{
npc->act_no = 0;
- SetNpChar(271, npc->x, npc->y + (Random(-32, 32) * 0x200), 0, 0, npc->direct, 0, 0x100);
+ SetNpChar(271, npc->x, npc->y + (Random(-32, 32) * 0x200), 0, 0, npc->direct, NULL, 0x100);
}
break;
@@ -1586,9 +1590,9 @@
if (npc->flag & 0xFF)
{
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
VanishNpChar(npc);
return;
}
@@ -1634,7 +1638,7 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x1000;
+ npc->y -= 8 * 0x200;
npc->tgt_x = npc->x;
// Fallthrough
case 1:
@@ -1691,10 +1695,10 @@
if (npc->count1 == 0)
{
++npc->count1;
- deg = GetArktan(npc->x - gMC.x, npc->y - 0x1400 - gMC.y);
- ym = 4 * GetSin(deg);
- xm = 4 * GetCos(deg);
- SetNpChar(273, npc->x, npc->y - 0x1400, xm, ym, 0, 0, 0x100);
+ deg = GetArktan(npc->x - gMC.x, npc->y - (10 * 0x200) - gMC.y);
+ ym = GetSin(deg) * 4;
+ xm = GetCos(deg) * 4;
+ SetNpChar(273, npc->x, npc->y - (10 * 0x200), xm, ym, 0, NULL, 0x100);
PlaySoundObject(39, 1);
}
}
@@ -1759,7 +1763,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x8000 < gMC.x && npc->x + 0x8000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
+ if (npc->x - (64 * 0x200) < gMC.x && npc->x + (64 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y)
{
if (++npc->ani_wait > 3)
{
@@ -1828,7 +1832,7 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x1000;
+ npc->y -= 8 * 0x200;
// Fallthrough
case 1:
npc->xm = 0;
@@ -1867,22 +1871,22 @@
case 30:
case 40:
case 50:
- {
npc->ani_no = 4;
+
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y);
- ym = 4 * GetSin(deg);
- xm = 4 * GetCos(deg);
- SetNpChar(277, npc->x, npc->y, xm, ym, 0, 0, 0x100);
+ ym = GetSin(deg) * 4;
+ xm = GetCos(deg) * 4;
+
+ SetNpChar(277, npc->x, npc->y, xm, ym, 0, NULL, 0x100);
PlaySoundObject(39, 1);
+
break;
- }
+
case 34:
case 44:
case 54:
- {
npc->ani_no = 3;
break;
- }
}
if (npc->act_wait > 60)
@@ -1901,6 +1905,7 @@
npc->act_wait = 0;
npc->ani_no = 5;
npc->ym = -0x5FF;
+
if (npc->x < gMC.x)
npc->xm = 0x100;
else
@@ -1915,21 +1920,21 @@
case 30:
case 40:
case 50:
- {
npc->ani_no = 6;
- deg = GetArktan(npc->x - gMC.x, npc->y - 0x1400 - gMC.y);
- ym = 4 * GetSin(deg);
- xm = 4 * GetCos(deg);
- SetNpChar(277, npc->x, npc->y - 0x1400, xm, ym, 0, 0, 0x100);
+
+ deg = GetArktan(npc->x - gMC.x, npc->y - (10 * 0x200) - gMC.y);
+ ym = GetSin(deg) * 4;
+ xm = GetCos(deg) * 4;
+
+ SetNpChar(277, npc->x, npc->y - (10 * 0x200), xm, ym, 0, NULL, 0x100);
PlaySoundObject(39, 1);
+
break;
- }
+
case 34:
case 44:
- {
npc->ani_no = 5;
break;
- }
}
if (npc->act_wait > 53)
@@ -1971,7 +1976,7 @@
break;
case 51:
- npc->xm = 7 * npc->xm / 8;
+ npc->xm = (npc->xm * 7) / 8;
npc->ani_no = 8;
break;
}
@@ -2017,9 +2022,9 @@
if (npc->flag & 0xFF)
{
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
VanishNpChar(npc);
return;
}
@@ -2049,7 +2054,7 @@
{24, 120, 32, 128},
};
- RECT rcKodomo[2] = {
+ RECT rcKodomo[2] = { // Japanese for 'child'
{32, 120, 40, 128},
{40, 120, 48, 128},
};
@@ -2101,7 +2106,7 @@
// Fallthrough
case 11:
- if (npc->direct == 0 && (npc->flag & 1))
+ if (npc->direct == 0 && npc->flag & 1)
npc->direct = 2;
else if (npc->direct == 2 && npc->flag & 4)
npc->direct = 0;
@@ -2153,6 +2158,8 @@
// Falling block (large)
void ActNpc279(NPCHAR *npc)
{
+ int i;
+
RECT rc[2] = {
{0, 16, 32, 48},
{16, 0, 32, 16},
@@ -2173,14 +2180,17 @@
npc->act_no = 100;
npc->bits |= NPC_INVULNERABLE;
npc->ani_no = 1;
- npc->view.back = 0x1000;
- npc->view.front = 0x1000;
- npc->view.top = 0x1000;
- npc->view.bottom = 0x1000;
- npc->hit.back = 0x1000;
- npc->hit.front = 0x1000;
- npc->hit.top = 0x1000;
- npc->hit.bottom = 0x1000;
+
+ npc->view.back = 8 * 0x200;
+ npc->view.front = 8 * 0x200;
+ npc->view.top = 8 * 0x200;
+ npc->view.bottom = 8 * 0x200;
+
+ npc->hit.back = 8 * 0x200;
+ npc->hit.front = 8 * 0x200;
+ npc->hit.top = 8 * 0x200;
+ npc->hit.bottom = 8 * 0x200;
+
break;
case 1:
@@ -2212,7 +2222,7 @@
if (npc->ym > 0x700)
npc->ym = 0x700;
- if (npc->y > 0x10000)
+ if (npc->y > 128 * 0x200)
npc->bits &= ~NPC_IGNORE_SOLIDITY;
if (npc->flag & 8)
@@ -2223,8 +2233,8 @@
PlaySoundObject(26, 1);
SetQuake(10);
- for (int i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + 0x2000, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 4; ++i)
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (16 * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
}
break;
--- a/src/NpcAct280.cpp
+++ b/src/NpcAct280.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Boss.h"
@@ -30,7 +32,7 @@
npc->act_no = 1;
npc->ani_no = 0;
npc->ani_wait = 0;
- npc->x += 0xC00;
+ npc->x += 6 * 0x200;
npc->tgt_x = npc->x;
PlaySoundObject(29, 1);
// Fallthrough
@@ -78,7 +80,7 @@
if (npc->act_wait / 2 % 2)
npc->x = npc->tgt_x;
else
- npc->x = npc->tgt_x + 0x200;
+ npc->x = npc->tgt_x + (1 * 0x200);
}
}
@@ -100,7 +102,7 @@
case 11:
++npc->act_wait;
- SetNpChar(270, npc->x, npc->y + 0x10000, 0, 0, 2, npc, 0x100);
+ SetNpChar(270, npc->x, npc->y + (128 * 0x200), 0, 0, 2, npc, 0x100);
if (npc->act_wait > 150)
npc->act_no = 12;
@@ -147,7 +149,7 @@
case 20:
npc->xm = -0x200;
- if (npc->x < -0x8000)
+ if (npc->x < -64 * 0x200)
npc->cond = 0;
if (npc->tgt_y < npc->y)
@@ -160,9 +162,9 @@
if (npc->ym < -0x100)
npc->ym = -0x100;
- if (gMC.flag & 8 && gMC.y < npc->y - 0x800 && gMC.x > npc->x - 0x3000 && gMC.x < npc->x + 0x3000)
+ if (gMC.flag & 8 && gMC.y < npc->y - (4 * 0x200) && gMC.x > npc->x - (24 * 0x200) && gMC.x < npc->x + (24 * 0x200))
{
- npc->tgt_y = 0x12000;
+ npc->tgt_y = 144 * 0x200;
npc->ani_no = 2;
}
else if (npc->ani_no != 1)
@@ -170,22 +172,22 @@
npc->ani_no = 0;
}
- if (gMC.flag & 1 && gMC.x < npc->x - npc->hit.back && gMC.x > npc->x - npc->hit.back - 0x1000 && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top && gMC.y - gMC.hit.top < npc->y + npc->hit.bottom)
+ if (gMC.flag & 1 && gMC.x < npc->x - npc->hit.back && gMC.x > npc->x - npc->hit.back - (8 * 0x200) && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top && gMC.y - gMC.hit.top < npc->y + npc->hit.bottom)
{
npc->bits &= ~NPC_SOLID_HARD;
npc->ani_no = 1;
}
- else if (gMC.flag & 4 && gMC.x > npc->x + npc->hit.back && gMC.x < npc->x + npc->hit.back + 0x1000 && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top && gMC.y - gMC.hit.top < npc->y + npc->hit.bottom)
+ else if (gMC.flag & 4 && gMC.x > npc->x + npc->hit.back && gMC.x < npc->x + npc->hit.back + (8 * 0x200) && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top && gMC.y - gMC.hit.top < npc->y + npc->hit.bottom)
{
npc->bits &= ~NPC_SOLID_HARD;
npc->ani_no = 1;
}
- else if (gMC.flag & 2 && gMC.y < npc->y - npc->hit.top && gMC.y > npc->y - npc->hit.top - 0x1000 && gMC.x + gMC.hit.front > npc->x - npc->hit.back && gMC.x - gMC.hit.back < npc->x + npc->hit.front)
+ else if (gMC.flag & 2 && gMC.y < npc->y - npc->hit.top && gMC.y > npc->y - npc->hit.top - (8 * 0x200) && gMC.x + gMC.hit.front > npc->x - npc->hit.back && gMC.x - gMC.hit.back < npc->x + npc->hit.front)
{
npc->bits &= ~NPC_SOLID_HARD;
npc->ani_no = 1;
}
- else if (gMC.flag & 8 && gMC.y > npc->y + npc->hit.bottom - 0x800 && gMC.y < npc->y + npc->hit.bottom + 0x1800 && gMC.x + gMC.hit.front > npc->x - npc->hit.back - 0x800 && gMC.x - gMC.hit.back < npc->x + npc->hit.front + 0x800)
+ else if (gMC.flag & 8 && gMC.y > npc->y + npc->hit.bottom - (4 * 0x200) && gMC.y < npc->y + npc->hit.bottom + (12 * 0x200) && gMC.x + gMC.hit.front > npc->x - npc->hit.back - (4 * 0x200) && gMC.x - gMC.hit.back < npc->x + npc->hit.front + (4 * 0x200))
{
npc->bits &= ~NPC_SOLID_HARD;
npc->ani_no = 1;
@@ -201,6 +203,10 @@
// Misery (transformed)
void ActNpc283(NPCHAR *npc)
{
+ int x;
+ int y;
+ int direct;
+
RECT rcLeft[11] = {
{0, 64, 32, 96},
{32, 64, 64, 96},
@@ -232,14 +238,11 @@
if (npc->act_no < 100 && (gBoss[0].cond == 0 || npc->life < 400))
npc->act_no = 100;
- int x;
- int y;
- int direct;
switch (npc->act_no)
{
case 0:
npc->act_no = 1;
- npc->y -= 0x1000;
+ npc->y -= 8 * 0x200;
PlaySoundObject(29, 1);
// Fallthrough
case 1:
@@ -353,7 +356,7 @@
PlaySoundObject(103, 1);
- if (gMC.y < 0x14000)
+ if (gMC.y < 160 * 0x200)
npc->count2 = 290;
else
npc->count2 = 289;
@@ -377,18 +380,18 @@
y = npc->y + (Random(-0x40, 0x40) * 0x200);
}
- if (x < 0x4000)
- x = 0x4000;
+ if (x < 32 * 0x200)
+ x = 32 * 0x200;
if (x > (gMap.width - 2) * 0x200 * 0x10)
x = (gMap.width - 2) * 0x200 * 0x10;
- if (y < 0x4000)
- y = 0x4000;
+ if (y < 32 * 0x200)
+ y = 32 * 0x200;
if (y > (gMap.length - 2) * 0x200 * 0x10)
y = (gMap.length - 2) * 0x200 * 0x10;
PlaySoundObject(39, 1);
- SetNpChar(npc->count2, x, y, 0, 0, 0, 0, 0x100);
+ SetNpChar(npc->count2, x, y, 0, 0, 0, NULL, 0x100);
}
if (npc->act_wait > 50)
@@ -447,7 +450,7 @@
{
if (npc->direct == 0)
{
- x = npc->x + 0x1400;
+ x = npc->x + (10 * 0x200);
y = npc->y;
switch (npc->act_wait / 6 % 4)
@@ -471,7 +474,7 @@
}
else
{
- x = npc->x - 0x1400;
+ x = npc->x - (10 * 0x200);
y = npc->y;
switch (npc->act_wait / 6 % 4)
@@ -495,7 +498,7 @@
}
PlaySoundObject(39, 1);
- SetNpChar(301, x, y, 0, 0, direct, 0, 0x100);
+ SetNpChar(301, x, y, 0, 0, direct, NULL, 0x100);
}
}
else if (npc->act_wait % 24 == 1)
@@ -502,7 +505,7 @@
{
if (npc->direct == 0)
{
- x = npc->x + 0x1400;
+ x = npc->x + (10 * 0x200);
y = npc->y;
switch (npc->act_wait / 6 % 4)
@@ -526,7 +529,7 @@
}
else
{
- x = npc->x - 0x1400;
+ x = npc->x - (10 * 0x200);
y = npc->y;
switch (npc->act_wait / 6 % 4)
@@ -550,7 +553,7 @@
}
PlaySoundObject(39, 1);
- SetNpChar(301, x, y, 0, 0, direct, 0, 0x100);
+ SetNpChar(301, x, y, 0, 0, direct, NULL, 0x100);
}
if (npc->act_wait > 50)
@@ -557,6 +560,7 @@
{
npc->act_no = 42;
npc->act_wait = 0;
+
if (npc->x > gMC.x)
npc->direct = 0;
else
@@ -580,15 +584,15 @@
npc->bits |= NPC_IGNORE_SOLIDITY;
npc->ym = -0x200;
npc->shock += 50;
- npc->hit.bottom = 0x1800;
+ npc->hit.bottom = 12 * 0x200;
++gBoss[0].ani_no;
// Fallthrough
case 101:
npc->ym += 0x20;
- if (npc->y > 0x1B000 - npc->hit.bottom)
+ if (npc->y > (216 * 0x200) - npc->hit.bottom)
{
- npc->y = 0x1B000 - npc->hit.bottom;
+ npc->y = (216 * 0x200) - npc->hit.bottom;
npc->act_no = 102;
npc->ani_no = 10;
npc->xm = 0;
@@ -614,6 +618,8 @@
// Sue (transformed)
void ActNpc284(NPCHAR *npc)
{
+ unsigned char deg;
+
RECT rcLeft[13] = {
{0, 128, 32, 160},
{32, 128, 64, 160},
@@ -649,13 +655,11 @@
if (npc->act_no < 100 && (gBoss[0].cond == 0|| npc->life < 500))
npc->act_no = 100;
- unsigned char deg;
-
switch (npc->act_no)
{
case 0:
npc->act_no = 1;
- npc->y -= 0x800;
+ npc->y -= 4 * 0x200;
PlaySoundObject(29, 1);
npc->count2 = npc->life;
// Fallthrough
@@ -662,16 +666,16 @@
case 1:
if (++npc->act_wait / 2 % 2)
{
- npc->view.top = 0x2000;
- npc->view.back = 0x2000;
- npc->view.front = 0x2000;
+ npc->view.top = 16 * 0x200;
+ npc->view.back = 16 * 0x200;
+ npc->view.front = 16 * 0x200;
npc->ani_no = 11;
}
else
{
- npc->view.top = 0x600;
- npc->view.back = 0x1000;
- npc->view.front = 0x1000;
+ npc->view.top = 3 * 0x200;
+ npc->view.back = 8 * 0x200;
+ npc->view.front = 8 * 0x200;
npc->ani_no = 12;
}
@@ -683,9 +687,9 @@
case 10:
npc->act_no = 11;
npc->ani_no = 11;
- npc->view.top = 0x2000;
- npc->view.back = 0x2000;
- npc->view.front = 0x2000;
+ npc->view.top = 16 * 0x200;
+ npc->view.back = 16 * 0x200;
+ npc->view.front = 16 * 0x200;
DeleteNpCharCode(257, 1);
break;
@@ -699,8 +703,8 @@
npc->bits &= ~NPC_IGNORE_SOLIDITY;
// Fallthrough
case 21:
- npc->xm = 7 * npc->xm / 8;
- npc->ym = 7 * npc->ym / 8;
+ npc->xm = (npc->xm * 7) / 8;
+ npc->ym = (npc->ym * 7) / 8;
if (++npc->ani_wait > 20)
{
@@ -765,9 +769,9 @@
npc->bits &= ~NPC_SHOOTABLE;
if (gMC.x < npc->x)
- npc->tgt_x = gMC.x - 0x14000;
+ npc->tgt_x = gMC.x - (160 * 0x200);
else
- npc->tgt_x = gMC.x + 0x14000;
+ npc->tgt_x = gMC.x + (160 * 0x200);
npc->tgt_y = gMC.y;
@@ -843,13 +847,9 @@
// Fallthrough
case 35:
if (++npc->act_wait > 20 && npc->shock)
- {
npc->act_no = 40;
- }
else if (npc->act_wait > 50 || npc->flag & 5)
- {
npc->act_no = 20;
- }
if (++npc->ani_wait > 1)
{
@@ -873,8 +873,8 @@
npc->bits &= ~NPC_IGNORE_SOLIDITY;
// Fallthrough
case 41:
- npc->xm = 7 * npc->xm / 8;
- npc->ym = 7 * npc->ym / 8;
+ npc->xm = (npc->xm * 7) / 8;
+ npc->ym = (npc->ym * 7) / 8;
if (++npc->act_wait > 6)
{
@@ -937,9 +937,9 @@
case 101:
npc->ym += 0x20;
- if (npc->y > 0x1B000 - npc->hit.bottom)
+ if (npc->y > (216 * 0x200) - npc->hit.bottom)
{
- npc->y = 0x1B000 - npc->hit.bottom;
+ npc->y = (216 * 0x200) - npc->hit.bottom;
npc->act_no = 102;
npc->ani_no = 10;
npc->xm = 0;
@@ -1000,10 +1000,12 @@
npc->tgt_x += npc->xm;
- npc->x = npc->tgt_x + 4 * GetCos(deg);
- npc->y = npc->tgt_y + 6 * GetSin(deg);
+ npc->x = npc->tgt_x + (GetCos(deg) * 4);
+ npc->y = npc->tgt_y + (GetSin(deg) * 6);
- SetNpChar(286, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+ SetNpChar(286, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
+
+ break;
}
npc->rect = rc;
@@ -1050,8 +1052,8 @@
}
else
{
- npc->xm = 20 * npc->xm / 21;
- npc->ym = 20 * npc->ym / 21;
+ npc->xm = (npc->xm * 20) / 21;
+ npc->ym = (npc->ym * 20) / 21;
npc->x += npc->xm;
npc->y += npc->ym;
@@ -1129,10 +1131,10 @@
else
npc->xm = 0x400;
- npc->view.back = 0x1800;
- npc->view.front = 0x1800;
- npc->view.top = 0x1800;
- npc->view.bottom = 0x1800;
+ npc->view.back = 12 * 0x200;
+ npc->view.front = 12 * 0x200;
+ npc->view.top = 12 * 0x200;
+ npc->view.bottom = 12 * 0x200;
// Fallthrough
case 3:
if (++npc->ani_no > 4)
@@ -1141,12 +1143,12 @@
if (++npc->act_wait % 4 == 1)
{
if (npc->direct == 1)
- SetNpChar(287, npc->x, npc->y, 0, 0x400, 0, 0, 0x100);
+ SetNpChar(287, npc->x, npc->y, 0, 0x400, 0, NULL, 0x100);
else
- SetNpChar(287, npc->x, npc->y, 0, -0x400, 0, 0, 0x100);
+ SetNpChar(287, npc->x, npc->y, 0, -0x400, 0, NULL, 0x100);
}
- if (npc->x < 0x200 * 0x10 || npc->x > (gMap.width * 0x200 * 0x10) - 0x200 * 0x10)
+ if (npc->x < 1 * 0x200 * 0x10 || npc->x > (gMap.width * 0x200 * 0x10) - (1 * 0x200 * 0x10))
npc->cond = 0;
break;
@@ -1188,8 +1190,8 @@
if (++npc->act_wait > 16)
{
npc->act_no = 10;
- npc->view.top = 0x1000;
- npc->view.bottom = 0x1000;
+ npc->view.top = 8 * 0x200;
+ npc->view.bottom = 8 * 0x200;
npc->damage = 2;
npc->bits |= NPC_SHOOTABLE;
}
@@ -1261,8 +1263,8 @@
if (npc->act_no == 1)
{
- npc->rect.top += 8 - npc->act_wait / 2;
- npc->rect.bottom -= npc->act_wait / 2 + 8;
+ npc->rect.top += 8 - (npc->act_wait / 2);
+ npc->rect.bottom -= 8 + (npc->act_wait / 2);
npc->view.top = (npc->act_wait * 0x200) / 2;
npc->view.bottom = (npc->act_wait * 0x200) / 2;
}
@@ -1298,8 +1300,8 @@
if (++npc->act_wait > 16)
{
npc->act_no = 10;
- npc->view.top = 0x1000;
- npc->view.bottom = 0x1000;
+ npc->view.top = 8 * 0x200;
+ npc->view.bottom = 8 * 0x200;
npc->damage = 2;
npc->bits |= NPC_SHOOTABLE;
npc->tgt_y = npc->y;
@@ -1347,8 +1349,8 @@
if (npc->act_no == 1)
{
- npc->rect.top += 8 - npc->act_wait / 2;
- npc->rect.bottom -= npc->act_wait / 2 + 8;
+ npc->rect.top += 8 - (npc->act_wait / 2);
+ npc->rect.bottom -= 8 + (npc->act_wait / 2);
npc->view.top = (npc->act_wait * 0x200) / 2;
npc->view.bottom = (npc->act_wait * 0x200) / 2;
}
@@ -1404,11 +1406,11 @@
if (++npc->ani_no > 1)
npc->ani_no = 0;
- SetNpChar(4, npc->x + (Random(0, 0x10) * 0x200), npc->y + (Random(-0x10, 0x10) * 0x200), 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(0, 0x10) * 0x200), npc->y + (Random(-0x10, 0x10) * 0x200), 0, 0, 0, NULL, 0x100);
- npc->x -= 0x1000;
+ npc->x -= 8 * 0x200;
- if (npc->x < -0x4000)
+ if (npc->x < -32 * 0x200)
npc->cond = 0;
break;
@@ -1440,17 +1442,17 @@
if (gMC.equip & 0x20)
{
- npc->x = gMC.x + 0x8000;
+ npc->x = gMC.x + (64 * 0x200);
- if (npc->x < 0x34000)
- npc->x = 0x34000;
+ if (npc->x < 416 * 0x200)
+ npc->x = 416 * 0x200;
}
else
{
- npc->x = gMC.x + 0xC000;
+ npc->x = gMC.x + (96 * 0x200);
- if (npc->x < 0x2E000)
- npc->x = 0x2E000;
+ if (npc->x < 368 * 0x200)
+ npc->x = 368 * 0x200;
}
if (npc->x > (gMap.width - 10) * 0x200 * 0x10)
@@ -1463,7 +1465,7 @@
else
x = npc->x + (Random(-11, 11) * 0x200 * 0x10);
- y = gMC.y - 0x1C000;
+ y = gMC.y - (224 * 0x200);
if (Random(0, 10) % 2) // Because just doing 'Random(0, 1)' is too hard
dir = 0;
@@ -1470,7 +1472,7 @@
else
dir = 2;
- SetNpChar(279, x, y, 0, 0, dir, 0, 0x100);
+ SetNpChar(279, x, y, 0, 0, dir, NULL, 0x100);
npc->act_wait = Random(0, 15);
}
@@ -1498,50 +1500,50 @@
{
case 0:
npc->ym = -1000;
- npc->view.back = 0xD000;
- npc->view.front = 0xD000;
+ npc->view.back = 104 * 0x200;
+ npc->view.front = 104 * 0x200;
break;
case 1:
npc->ym = -0x800;
- npc->view.back = 0x7000;
- npc->view.front = 0x7000;
+ npc->view.back = 56 * 0x200;
+ npc->view.front = 56 * 0x200;
break;
case 2:
npc->ym = -0x400;
- npc->view.back = 0x4000;
- npc->view.front = 0x4000;
+ npc->view.back = 32 * 0x200;
+ npc->view.front = 32 * 0x200;
break;
case 3:
npc->ym = -0x200;
- npc->view.back = 0x2800;
- npc->view.front = 0x2800;
+ npc->view.back = 20 * 0x200;
+ npc->view.front = 20 * 0x200;
break;
case 4:
npc->xm = -0x400;
- npc->view.back = 0xD000;
- npc->view.front = 0xD000;
+ npc->view.back = 104 * 0x200;
+ npc->view.front = 104 * 0x200;
break;
case 5:
npc->xm = -0x200;
- npc->view.back = 0x7000;
- npc->view.front = 0x7000;
+ npc->view.back = 56 * 0x200;
+ npc->view.front = 56 * 0x200;
break;
case 6:
npc->xm = -0x100;
- npc->view.back = 0x4000;
- npc->view.front = 0x4000;
+ npc->view.back = 32 * 0x200;
+ npc->view.front = 32 * 0x200;
break;
case 7:
npc->xm = -0x80;
- npc->view.back = 0x2800;
- npc->view.front = 0x2800;
+ npc->view.back = 20 * 0x200;
+ npc->view.front = 20 * 0x200;
break;
}
@@ -1550,10 +1552,12 @@
case 1:
npc->x += npc->xm;
npc->y += npc->ym;
- if (npc->x < -0x8000)
+
+ if (npc->x < -64 * 0x200)
npc->cond = 0;
- if (npc->y < -0x4000)
+ if (npc->y < -32 * 0x200)
npc->cond = 0;
+
break;
}
@@ -1596,7 +1600,7 @@
x = Random(-10, 10) * 0x200 * 0x10 + npc->x;
y = npc->y;
- SetNpChar(295, x, y, 0, 0, dir, 0, pri);
+ SetNpChar(295, x, y, 0, 0, dir, NULL, pri);
}
else
{
@@ -1621,7 +1625,7 @@
x = npc->x;
y = Random(-7, 7) * 0x200 * 0x10 + npc->y;
- SetNpChar(295, x, y, 0, 0, dir + 4, 0, pri);
+ SetNpChar(295, x, y, 0, 0, dir + 4, NULL, pri);
}
}
}
@@ -1631,8 +1635,8 @@
{
RECT rc = {112, 48, 0x80, 64};
- npc->x = npc->pNpc->x + 0x2000;
- npc->y = npc->pNpc->y + 0x1000;
+ npc->x = npc->pNpc->x + (16 * 0x200);
+ npc->y = npc->pNpc->y + (8 * 0x200);
npc->rect = rc;
}
@@ -1655,7 +1659,7 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x1000;
+ npc->y -= 8 * 0x200;
// Fallthrough
case 1:
@@ -1760,7 +1764,7 @@
{
npc->ani_no = 1;
npc->act_wait = 25;
- npc->y -= 1600;
+ npc->y -= 0x40 * (50 / 2);
}
else
{
--- a/src/NpcAct300.cpp
+++ b/src/NpcAct300.cpp
@@ -23,11 +23,11 @@
if (npc->act_no == 0)
{
npc->act_no = 1;
- npc->y += 0xC00;
+ npc->y += 6 * 0x200;
}
if (++npc->ani_wait % 8 == 1)
- SetCaret(npc->x + (Random(-8, 8) * 0x200), npc->y + 0x1000, 13, 1);
+ SetCaret(npc->x + (Random(-8, 8) * 0x200), npc->y + (8 * 0x200), 13, 1);
npc->rect = rc;
}
@@ -55,8 +55,8 @@
npc->count1 = npc->direct;
// Fallthrough
case 1:
- npc->xm = 2 * GetCos(npc->count1);
- npc->ym = 2 * GetSin(npc->count1);
+ npc->xm = GetCos(npc->count1) * 2;
+ npc->ym = GetSin(npc->count1) * 2;
npc->y += npc->ym;
npc->x += npc->xm;
@@ -106,7 +106,7 @@
{
case 10:
npc->x = gMC.x;
- npc->y = gMC.y - 0x4000;
+ npc->y = gMC.y - 32 * 0x200;
break;
case 20:
@@ -113,19 +113,19 @@
switch (npc->direct)
{
case 0:
- npc->x -= 0x400;
+ npc->x -= 2 * 0x200;
break;
case 1:
- npc->y -= 0x400;
+ npc->y -= 2 * 0x200;
break;
case 2:
- npc->x += 0x400;
+ npc->x += 2 * 0x200;
break;
case 3:
- npc->y += 0x400;
+ npc->y += 2 * 0x200;
break;
}
@@ -135,15 +135,16 @@
case 30:
npc->x = gMC.x;
- npc->y = gMC.y + 0xA000;
+ npc->y = gMC.y + (80 * 0x200);
break;
case 100:
npc->act_no = 101;
- if (npc->direct)
+ if (npc->direct != 0)
{
int i;
+
for (i = 0xAA; i < 0x200; ++i)
{
if (gNPC[i].cond & 0x80 && gNPC[i].code_event == npc->direct)
@@ -191,12 +192,12 @@
if (npc->pNpc->direct == 0)
{
npc->direct = 0;
- npc->x = npc->pNpc->x - 0x1000;
+ npc->x = npc->pNpc->x - (8 * 0x200);
}
else
{
npc->direct = 2;
- npc->x = npc->pNpc->x + 0x1000;
+ npc->x = npc->pNpc->x + (8 * 0x200);
}
npc->y = npc->pNpc->y;
@@ -204,7 +205,7 @@
// Animation
npc->ani_no = 0;
if (npc->pNpc->ani_no == 3 || npc->pNpc->ani_no == 5)
- npc->y -= 0x200;
+ npc->y -= 1 * 0x200;
// Set framerect
if (npc->direct == 0)
@@ -227,7 +228,7 @@
{
case 0:
npc->act_no = 1;
- npc->y += 5120;
+ npc->y += 10 * 0x200;
// Fallthrough
case 1:
npc->ani_no = 0;
@@ -250,9 +251,7 @@
if (npc->ani_no > 3)
npc->ani_no = 2;
- break;
- default:
break;
}
@@ -276,7 +275,7 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x2000;
+ npc->y -= 16 * 0x200;
npc->ani_wait = Random(0, 6);
// Fallthrough
@@ -289,6 +288,7 @@
if (npc->ani_no > 1)
npc->ani_no = 0;
+
break;
}
@@ -317,7 +317,7 @@
npc->act_no = 1;
npc->ani_no = 0;
npc->ani_wait = 0;
- npc->y += 0x800;
+ npc->y += 4 * 0x200;
// Fallthrough
case 1:
if (Random(0, 120) == 10)
@@ -326,6 +326,7 @@
npc->act_wait = 0;
npc->ani_no = 1;
}
+
break;
case 2:
@@ -334,6 +335,7 @@
npc->act_no = 1;
npc->ani_no = 0;
}
+
break;
}
@@ -359,8 +361,8 @@
switch (npc->act_no)
{
case 0:
- npc->x += 0x200;
- npc->y -= 0x400;
+ npc->x += 1 * 0x200;
+ npc->y -= 2 * 0x200;
npc->act_no = 1;
npc->ani_no = 0;
npc->ani_wait = 0;
@@ -372,6 +374,7 @@
npc->act_wait = 0;
npc->ani_no = 1;
}
+
break;
case 2:
@@ -380,6 +383,7 @@
npc->act_no = 1;
npc->ani_no = 0;
}
+
break;
}
@@ -415,7 +419,7 @@
npc->act_no = 1;
// Fallthrough
case 1:
- if (gMC.x < npc->x + 0x1E000 && gMC.x > npc->x - 0x1E000 && gMC.y < npc->y + 0x18000 && gMC.y > npc->y - 0x18000)
+ if (gMC.x < npc->x + (240 * 0x200) && gMC.x > npc->x - (240 * 0x200) && gMC.y < npc->y + (192 * 0x200) && gMC.y > npc->y - (192 * 0x200))
npc->act_no = 10;
break;
@@ -445,7 +449,7 @@
npc->ani_no = 0;
}
- if (gMC.x > npc->x + 0x28000 || gMC.x < npc->x - 0x28000 || gMC.y > npc->y + 0x1E000 || gMC.y < npc->y - 0x1E000)
+ if (gMC.x > npc->x + (320 * 0x200) || gMC.x < npc->x - (320 * 0x200) || gMC.y > npc->y + (240 * 0x200) || gMC.y < npc->y - (240 * 0x200))
npc->act_no = 0;
break;
@@ -456,8 +460,8 @@
deg = (unsigned char)GetArktan(npc->x - gMC.x, npc->y - gMC.y);
deg += (unsigned char)Random(-3, 3);
- npc->ym2 = 2 * GetSin(deg);
- npc->xm2 = 2 * GetCos(deg);
+ npc->ym2 = GetSin(deg) * 2;
+ npc->xm2 = GetCos(deg) * 2;
if (npc->xm2 < 0)
npc->direct = 0;
@@ -524,7 +528,7 @@
case 1:
if (npc->direct == 0)
{
- if (gMC.x > npc->x - 0x24000 && gMC.x < npc->x - 0x22000)
+ if (gMC.x > npc->x - (288 * 0x200) && gMC.x < npc->x - (272 * 0x200))
{
npc->act_no = 10;
break;
@@ -532,7 +536,7 @@
}
else
{
- if (gMC.x < npc->x + 0x24000 && gMC.x > npc->x + 0x22000)
+ if (gMC.x < npc->x + (288 * 0x200) && gMC.x > npc->x + (272 * 0x200))
{
npc->act_no = 10;
break;
@@ -644,7 +648,7 @@
npc->ani_no = 0;
- if (gMC.x > npc->x - 0x10000 && gMC.x < npc->x + 0x10000 && gMC.y > npc->y - 0x10000 && gMC.y < npc->y + 0x2000)
+ if (gMC.x > npc->x - (128 * 0x200) && gMC.x < npc->x + (128 * 0x200) && gMC.y > npc->y - (128 * 0x200) && gMC.y < npc->y + (16 * 0x200))
npc->act_no = 10;
break;
@@ -694,7 +698,7 @@
if (++npc->act_wait > 50)
npc->act_no = 10;
- if (npc->x < gMC.x + 0x5000 && npc->x > gMC.x - 0x5000)
+ if (npc->x < gMC.x + (40 * 0x200) && npc->x > gMC.x - (40 * 0x200))
{
npc->ym = -0x300;
npc->xm /= 2;
@@ -791,12 +795,12 @@
case 1:
if (npc->direct == 0)
{
- if (gMC.x > npc->x - 0x28000 && gMC.x < npc->x && gMC.y > npc->y - 0x14000 && gMC.y < npc->y + 0x14000)
+ if (gMC.x > npc->x - (320 * 0x200) && gMC.x < npc->x && gMC.y > npc->y - (160 * 0x200) && gMC.y < npc->y + (160 * 0x200))
npc->act_no = 10;
}
else
{
- if (gMC.x > npc->x && gMC.x < npc->x + 0x28000 && gMC.y > npc->y - 0x14000 && gMC.y < npc->y + 0x14000)
+ if (gMC.x > npc->x && gMC.x < npc->x + (320 * 0x200) && gMC.y > npc->y - (160 * 0x200) && gMC.y < npc->y + (160 * 0x200))
npc->act_no = 10;
}
@@ -811,7 +815,7 @@
else
npc->direct = 2;
- if (gMC.x > npc->x - 0x1C000 && gMC.x < npc->x + 0x1C000 && gMC.y > npc->y - 0x1000)
+ if (gMC.x > npc->x - (224 * 0x200) && gMC.x < npc->x + (224 * 0x200) && gMC.y > npc->y - (8 * 0x200))
{
npc->ani_no = 1;
npc->count1 = 0;
@@ -855,9 +859,9 @@
if (npc->count1 == 0)
{
if (npc->direct == 0)
- SetNpChar(312, npc->x, npc->y, -0x600, 0, 0, 0, 0x100);
+ SetNpChar(312, npc->x, npc->y, -0x600, 0, 0, NULL, 0x100);
else
- SetNpChar(312, npc->x, npc->y, 0x600, 0, 2, 0, 0x100);
+ SetNpChar(312, npc->x, npc->y, 0x600, 0, 2, NULL, 0x100);
npc->ani_no = 3;
}
@@ -864,9 +868,9 @@
else
{
if (npc->direct == 0)
- SetNpChar(312, npc->x, npc->y, -0x600, -0x600, 0, 0, 0x100);
+ SetNpChar(312, npc->x, npc->y, -0x600, -0x600, 0, NULL, 0x100);
else
- SetNpChar(312, npc->x, npc->y, 0x600, -0x600, 2, 0, 0x100);
+ SetNpChar(312, npc->x, npc->y, 0x600, -0x600, 2, NULL, 0x100);
npc->ani_no = 6;
}
@@ -886,7 +890,7 @@
if (++npc->act_wait > 150)
npc->act_no = 10;
- if (gMC.x < npc->x - 0x2C000 || gMC.x > npc->x + 0x2C000 || gMC.y < npc->y - 0x1E000 || gMC.y > npc->y + 0x1E000)
+ if (gMC.x < npc->x - (352 * 0x200) || gMC.x > npc->x + (352 * 0x200) || gMC.y < npc->y - (240 * 0x200) || gMC.y > npc->y + (240 * 0x200))
{
npc->act_no = 40;
npc->act_wait = 0;
@@ -1067,7 +1071,7 @@
npc->act_no = 1;
npc->ani_no = 0;
npc->ani_wait = 0;
- npc->y += 0x800;
+ npc->y += 4 * 0x200;
// Fallthrough
case 1:
npc->ym += 0x40;
@@ -1079,7 +1083,7 @@
npc->ani_no = 1;
}
- if (npc->x - 0x4000 < gMC.x && npc->x + 0x4000 > gMC.x)
+ if (npc->x - (32 * 0x200) < gMC.x && npc->x + (32 * 0x200) > gMC.x)
{
if (npc->x > gMC.x)
npc->direct = 0;
@@ -1146,7 +1150,7 @@
case 130:
npc->ym += 0x80;
- if (npc->y > 0x10000)
+ if (npc->y > 128 * 0x200)
npc->bits &= ~NPC_IGNORE_SOLIDITY;
if (npc->xm < 0 && npc->flag & 1)
@@ -1174,7 +1178,7 @@
npc->xm = 0;
}
- if (npc->count1 > 4 && gMC.y < npc->y + 0x800)
+ if (npc->count1 > 4 && gMC.y < npc->y + (4 * 0x200))
{
npc->act_no = 200;
npc->act_wait = 0;
@@ -1236,7 +1240,7 @@
npc->ani_no = 6;
if (++npc->act_wait % 6 == 0)
- SetNpChar(314, Random(4, 16) * 0x200 * 0x10, 0x200 * 0x10, 0, 0, 0, 0, 0x100);
+ SetNpChar(314, Random(4, 16) * 0x200 * 0x10, 1 * 0x200 * 0x10, 0, 0, 0, NULL, 0x100);
if (npc->act_wait > 30)
{
@@ -1267,7 +1271,7 @@
else
npc->xm = 0x400;
- if (gMC.x > npc->x - 0x800 && gMC.x < npc->x + 0x800)
+ if (gMC.x > npc->x - (4 * 0x200) && gMC.x < npc->x + (4 * 0x200))
{
npc->act_no = 310;
npc->act_wait = 0;
@@ -1298,7 +1302,7 @@
if (++npc->ani_no > 13)
npc->ani_no = 12;
- if (npc->y < 0x2000)
+ if (npc->y < (16 * 0x200))
npc->act_no = 330;
break;
@@ -1315,7 +1319,7 @@
npc->ani_no = 12;
if (++npc->act_wait % 6 == 0)
- SetNpChar(315, Random(4, 16) * 0x200 * 0x10, 0, 0, 0, 0, 0, 0x100);
+ SetNpChar(315, Random(4, 16) * 0x200 * 0x10, 0, 0, 0, 0, NULL, 0x100);
if (npc->act_wait > 30)
{
@@ -1343,7 +1347,7 @@
if (++npc->act_wait % 2)
npc->x = npc->tgt_x;
else
- npc->x = npc->tgt_x + 0x200;
+ npc->x = npc->tgt_x + (1 * 0x200);
break;
}
@@ -1397,11 +1401,13 @@
if (npc->ym > 0x700)
npc->ym = 0x700;
- if (npc->y > 0x10000)
+ if (npc->y > 128 * 0x200)
npc->bits &= ~NPC_IGNORE_SOLIDITY;
if (npc->flag & 8)
{
+ int i;
+
npc->ym = -0x200;
npc->act_no = 110;
npc->bits |= NPC_IGNORE_SOLIDITY;
@@ -1408,8 +1414,8 @@
PlaySoundObject(12, 1);
SetQuake(10);
- for (int i = 0; i < 2; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + 0x2000, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ for (i = 0; i < 2; ++i)
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (16 * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
}
break;
@@ -1468,7 +1474,7 @@
npc->ani_no = 3;
npc->ym += 0x80;
- if (npc->y > 0x10000)
+ if (npc->y > 128 * 0x200)
{
npc->act_no = 130;
npc->bits &= ~NPC_IGNORE_SOLIDITY;
@@ -1610,9 +1616,9 @@
npc->damage = 0;
npc->act_no = 1;
npc->ani_no = 0;
- npc->view.front = 0x1800;
- npc->view.back = 0x1800;
- npc->view.top = 0x1800;
+ npc->view.front = 12 * 0x200;
+ npc->view.back = 12 * 0x200;
+ npc->view.top = 12 * 0x200;
npc->ym = -0x200;
if (npc->direct == 0)
@@ -1687,7 +1693,7 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x1000;
+ npc->y -= 8 * 0x200;
npc->tgt_x = npc->x;
// Fallthrough
case 1:
@@ -1711,10 +1717,8 @@
if (npc->ani_no > 1)
npc->ani_no = 0;
- if (gMC.x > npc->x - 0x28000 && gMC.x < npc->x + 0x28000 && gMC.y > npc->y - 0x14000 && gMC.y < npc->y + 0x14000 && ++npc->count1 > 50)
- {
+ if (gMC.x > npc->x - (320 * 0x200) && gMC.x < npc->x + (320 * 0x200) && gMC.y > npc->y - (160 * 0x200) && gMC.y < npc->y + (160 * 0x200) && ++npc->count1 > 50)
npc->act_no = 10;
- }
break;
@@ -1849,12 +1853,12 @@
switch (npc->act_no)
{
case 0:
- npc->y = npc->pNpc->y + 0x1400;
+ npc->y = npc->pNpc->y + (10 * 0x200);
if (npc->pNpc->direct == 0)
- npc->x = npc->pNpc->x + 0xE00;
+ npc->x = npc->pNpc->x + (7 * 0x200);
else
- npc->x = npc->pNpc->x - 0xE00;
+ npc->x = npc->pNpc->x - (7 * 0x200);
if (npc->pNpc->code_char == 318)
{
@@ -1868,7 +1872,7 @@
npc->act_no = 2;
npc->act_wait = 0;
npc->ym = -0x400;
- npc->y = npc->pNpc->y - 0x800;
+ npc->y = npc->pNpc->y - (4 * 0x200);
if (npc->pNpc->direct == 0)
npc->xm = -0x400;
--- a/src/NpcAct320.cpp
+++ b/src/NpcAct320.cpp
@@ -42,7 +42,7 @@
if (gMC.up)
{
npc->tgt_x = gMC.x;
- npc->tgt_y = gMC.y - 0x1400;
+ npc->tgt_y = gMC.y - (10 * 0x200);
npc->ani_no = 1;
}
else
@@ -51,13 +51,13 @@
if (gMC.direct == 0)
{
- npc->tgt_x = gMC.x + 0xE00;
- npc->tgt_y = gMC.y - 0x600;
+ npc->tgt_x = gMC.x + (7 * 0x200);
+ npc->tgt_y = gMC.y - (3 * 0x200);
}
else
{
- npc->tgt_x = gMC.x - 0xE00;
- npc->tgt_y = gMC.y - 0x600;
+ npc->tgt_x = gMC.x - (7 * 0x200);
+ npc->tgt_y = gMC.y - (3 * 0x200);
}
}
}
@@ -66,13 +66,13 @@
if (gMC.up)
{
npc->tgt_x = gMC.x;
- npc->tgt_y = gMC.y + 0x1000;
+ npc->tgt_y = gMC.y + (8 * 0x200);
npc->ani_no = 2;
}
else if (gMC.down)
{
npc->tgt_x = gMC.x;
- npc->tgt_y = gMC.y - 0x1000;
+ npc->tgt_y = gMC.y - (8 * 0x200);
npc->ani_no = 1;
}
else
@@ -81,13 +81,13 @@
if (gMC.direct == 0)
{
- npc->tgt_x = gMC.x + 0xE00;
- npc->tgt_y = gMC.y - 0x600;
+ npc->tgt_x = gMC.x + (7 * 0x200);
+ npc->tgt_y = gMC.y - (3 * 0x200);
}
else
{
- npc->tgt_x = gMC.x - 0xE00;
- npc->tgt_y = gMC.y - 0x600;
+ npc->tgt_x = gMC.x - (7 * 0x200);
+ npc->tgt_y = gMC.y - (3 * 0x200);
}
}
}
@@ -96,7 +96,7 @@
npc->y += (npc->tgt_y - npc->y) / 2;
if (gMC.ani_no % 2)
- npc->y -= 0x200;
+ npc->y -= 1 * 0x200;
if (gMC.direct == 0)
npc->rect = rcRight[npc->ani_no];
@@ -129,12 +129,12 @@
case 0:
if (gMC.direct == 0)
{
- npc->x = npc->pNpc->x + 0x1000;
+ npc->x = npc->pNpc->x + (8 * 0x200);
direct = 2;
}
else
{
- npc->x = npc->pNpc->x - 0x1000;
+ npc->x = npc->pNpc->x - (8 * 0x200);
direct = 0;
}
@@ -148,7 +148,7 @@
npc->x = npc->pNpc->x;
direct = 1;
- npc->y = npc->pNpc->y - 0x1400;
+ npc->y = npc->pNpc->y - (10 * 0x200);
break;
case 2:
@@ -158,7 +158,7 @@
npc->x = npc->pNpc->x;
direct = 3;
- npc->y = npc->pNpc->y + 0x1400;
+ npc->y = npc->pNpc->y + (10 * 0x200);
break;
}
@@ -201,9 +201,9 @@
npc->act_no = 1;
if (npc->direct == 0)
- npc->y += 0x1000;
+ npc->y += 8 * 0x200;
else
- npc->x += 0x1000;
+ npc->x += 8 * 0x200;
// Fallthrough
case 1:
if (npc->shock)
@@ -219,31 +219,33 @@
switch (npc->act_wait)
{
- case 0:
- SetNpChar(207, npc->x + 0x800, npc->y, 0, 0, 0, 0, 0x180);
+ // Interestingly, this NPC counts down at 50 frames per second,
+ // while the 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;
- case 50:
- SetNpChar(207, npc->x + 0x800, npc->y, 0, 0, 1, 0, 0x180);
+ case 50 * 1:
+ SetNpChar(207, npc->x + (4 * 0x200), npc->y, 0, 0, 1, NULL, 0x180);
break;
- case 100:
- SetNpChar(207, npc->x + 0x800, npc->y, 0, 0, 2, 0, 0x180);
+ case 50 * 2:
+ SetNpChar(207, npc->x + (4 * 0x200), npc->y, 0, 0, 2, NULL, 0x180);
break;
- case 150:
- SetNpChar(207, npc->x + 0x800, npc->y, 0, 0, 3, 0, 0x180);
+ case 50 * 3:
+ SetNpChar(207, npc->x + (4 * 0x200), npc->y, 0, 0, 3, NULL, 0x180);
break;
- case 200:
- SetNpChar(207, npc->x + 0x800, npc->y, 0, 0, 4, 0, 0x180);
+ case 50 * 4:
+ SetNpChar(207, npc->x + (4 * 0x200), npc->y, 0, 0, 4, NULL, 0x180);
break;
- case 250:
- npc->hit.back = 0x6000;
- npc->hit.front = 0x6000;
- npc->hit.top = 0x6000;
- npc->hit.bottom = 0x6000;
+ case 50 * 5:
+ npc->hit.back = 48 * 0x200;
+ npc->hit.front = 48 * 0x200;
+ npc->hit.top = 48 * 0x200;
+ npc->hit.bottom = 48 * 0x200;
npc->damage = 12;
PlaySoundObject(26, 1);
SetDestroyNpChar(npc->x, npc->y, 0x6000, 40);
@@ -251,13 +253,13 @@
if (npc->direct == 0)
{
- DeleteMapParts(npc->x / 0x200 / 0x10, (npc->y - 0x1000) / 0x200 / 0x10);
- DeleteMapParts(npc->x / 0x200 / 0x10, (npc->y + 0x1000) / 0x200 / 0x10);
+ DeleteMapParts(npc->x / 0x200 / 0x10, (npc->y - (8 * 0x200)) / 0x200 / 0x10);
+ DeleteMapParts(npc->x / 0x200 / 0x10, (npc->y + (8 * 0x200)) / 0x200 / 0x10);
}
else
{
- DeleteMapParts((npc->x - 0x1000) / 0x200 / 0x10, npc->y / 0x200 / 0x10);
- DeleteMapParts((npc->x + 0x1000) / 0x200 / 0x10, npc->y / 0x200 / 0x10);
+ DeleteMapParts((npc->x - (8 * 0x200)) / 0x200 / 0x10, npc->y / 0x200 / 0x10);
+ DeleteMapParts((npc->x + (8 * 0x200)) / 0x200 / 0x10, npc->y / 0x200 / 0x10);
}
npc->cond |= 8;
@@ -327,22 +329,22 @@
switch (npc->direct)
{
case 0:
- if (npc->x <= gMC.x + 0x4000)
+ if (npc->x <= gMC.x + (32 * 0x200))
npc->act_no = 10;
break;
case 2:
- if (npc->x >= gMC.x - 0x4000)
+ if (npc->x >= gMC.x - (32 * 0x200))
npc->act_no = 10;
break;
case 1:
- if (npc->y <= gMC.y + 0x4000)
+ if (npc->y <= gMC.y + (32 * 0x200))
npc->act_no = 10;
break;
case 3:
- if (npc->y >= gMC.y - 0x4000)
+ if (npc->y >= gMC.y - (32 * 0x200))
npc->act_no = 10;
break;
}
@@ -359,7 +361,7 @@
npc->bits |= NPC_SHOOTABLE;
npc->bits &= ~NPC_IGNORE_SOLIDITY;
npc->damage = 5;
- npc->view.top = 0x1000;
+ npc->view.top = 8 * 0x200;
}
npc->rect = rc[npc->ani_no];
@@ -376,7 +378,7 @@
// Fallthrough
case 11:
if (++npc->act_wait % 50 == 1)
- SetNpChar(323, npc->x, npc->y, 0, 0, npc->direct, 0, 0x100);
+ SetNpChar(323, npc->x, npc->y, 0, 0, npc->direct, NULL, 0x100);
if (npc->act_wait > 351)
npc->act_no = 0;
@@ -420,10 +422,10 @@
npc->ani_wait = 0;
npc->ani_no = 3;
npc->damage = 10;
- npc->view.front = 0x1000;
- npc->view.top = 0x1800;
+ npc->view.front = 8 * 0x200;
+ npc->view.top = 12 * 0x200;
PlaySoundObject(101, 1);
- SetDestroyNpChar(npc->x, npc->y + 0xA800, 0, 3);
+ SetDestroyNpChar(npc->x, npc->y + (84 * 0x200), 0, 3);
}
break;
@@ -447,7 +449,7 @@
npc->rect = rc[npc->ani_no];
}
-// Sue/Itoh becoming humans
+// Sue/Itoh becoming human
void ActNpc326(NPCHAR *npc)
{
switch (npc->act_no)
@@ -454,8 +456,8 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x1000;
- npc->x += 0x2000;
+ npc->y -= 8 * 0x200;
+ npc->x += 16 * 0x200;
npc->ani_no = 0;
// Fallthrough
case 1:
@@ -465,23 +467,22 @@
npc->act_wait = 0;
break;
}
+
+ if (npc->direct == 0)
+ {
+ if (npc->act_wait == 30)
+ npc->ani_no = 1;
+ if (npc->act_wait == 40)
+ npc->ani_no = 0;
+ }
else
{
- if (npc->direct == 0)
- {
- if (npc->act_wait == 30)
- npc->ani_no = 1;
- if (npc->act_wait == 40)
- npc->ani_no = 0;
- }
- else
- {
- if (npc->act_wait == 50)
- npc->ani_no = 1;
- if (npc->act_wait == 60)
- npc->ani_no = 0;
- }
+ if (npc->act_wait == 50)
+ npc->ani_no = 1;
+ if (npc->act_wait == 60)
+ npc->ani_no = 0;
}
+
break;
case 10:
@@ -497,13 +498,12 @@
break;
}
+
+ if (npc->act_wait / 2 % 2)
+ npc->ani_no = 2;
else
- {
- if (npc->act_wait / 2 % 2)
- npc->ani_no = 2;
- else
- npc->ani_no = 3;
- }
+ npc->ani_no = 3;
+
break;
case 15:
@@ -529,9 +529,9 @@
npc->ani_no = 6;
if (npc->direct == 0)
- SetNpChar(327, npc->x, npc->y - 0x2000, 0, 0, 0, npc, 0x100);
+ SetNpChar(327, npc->x, npc->y - (16 * 0x200), 0, 0, 0, npc, 0x100);
else
- SetNpChar(327, npc->x, npc->y - 0x1000, 0, 0, 0, npc, 0x100);
+ SetNpChar(327, npc->x, npc->y - (8 * 0x200), 0, 0, 0, npc, 0x100);
break;
}
@@ -604,7 +604,7 @@
{
case 0:
if (npc->act_wait < 4)
- npc->y -= 0x400;
+ npc->y -= 2 * 0x200;
if (npc->pNpc->ani_no == 7)
{
@@ -878,7 +878,7 @@
npc->ani_no = 1;
if (npc->direct == 0 && npc->act_wait == 20)
- SetNpChar(146, npc->tgt_x, npc->tgt_y, 0, 0, 0, 0, 0x100);
+ SetNpChar(146, npc->tgt_x, npc->tgt_y, 0, 0, 0, NULL, 0x100);
if (npc->act_wait > 40)
npc->cond = 0;
@@ -910,13 +910,13 @@
if (npc->direct == 0)
{
- npc->x += 0x1400;
- npc->y -= 0x2400;
+ npc->x += 10 * 0x200;
+ npc->y -= 18 * 0x200;
}
else
{
- npc->x = gMC.x - 0x1400;
- npc->y = gMC.y - 0x400;
+ npc->x = gMC.x - (10 * 0x200);
+ npc->y = gMC.y - (2 * 0x200);
}
// Fallthrough
case 10:
@@ -1029,7 +1029,7 @@
{
case 0:
npc->act_no = 1;
- npc->y -= 0x1000;
+ npc->y -= 8 * 0x200;
// Fallthrough
case 1:
npc->xm = 0;
@@ -1076,8 +1076,8 @@
{
case 0:
npc->act_no = 1;
- npc->view.top = 0x1000;
- npc->view.bottom = 0x1000;
+ npc->view.top = 8 * 0x200;
+ npc->view.bottom = 8 * 0x200;
npc->damage = 3;
npc->bits |= NPC_SHOOTABLE;
npc->tgt_y = npc->y;
@@ -1143,7 +1143,7 @@
else
{
npc->act_no = 0;
- SetNpChar(338, npc->x, npc->y + (Random(-0x10, 0x10) * 0x200), 0, 0, npc->direct, 0, 0x100);
+ SetNpChar(338, npc->x, npc->y + (Random(-0x10, 0x10) * 0x200), 0, 0, npc->direct, NULL, 0x100);
}
break;
--- a/src/NpcAct340.cpp
+++ b/src/NpcAct340.cpp
@@ -1,5 +1,7 @@
#include "NpcAct.h"
+#include <stddef.h>
+
#include "WindowsWrapper.h"
#include "Caret.h"
@@ -28,9 +30,9 @@
npc->cond = 0x80;
npc->exp = 1;
npc->direct = 0;
- npc->y -= 0xC00;
+ npc->y -= 6 * 0x200;
npc->damage = 0;
- SetNpChar(341, npc->x, npc->y - 0x2000, 0, 0, 0, npc, 0x100);
+ SetNpChar(341, npc->x, npc->y - (16 * 0x200), 0, 0, 0, npc, 0x100);
break;
case 10:
@@ -129,7 +131,7 @@
if (++npc->act_wait > 20)
{
- if (gMC.y < npc->y + 0x1800)
+ if (gMC.y < npc->y + (12 * 0x200))
npc->act_no = 220;
else
npc->act_no = 230;
@@ -181,7 +183,7 @@
PlaySoundObject(26, 1);
}
- if (npc->count1 < 4 && gMC.x > npc->x - 0x2000 && gMC.x < npc->x + 0x2000)
+ if (npc->count1 < 4 && gMC.x > npc->x - (16 * 0x200) && gMC.x < npc->x + (16 * 0x200))
npc->act_no = 201;
break;
@@ -219,9 +221,9 @@
else
npc->ani_no = 9;
- if (npc->y < 0x6000)
+ if (npc->y < (48 * 0x200))
{
- npc->y = 0x6000;
+ npc->y = (48 * 0x200);
npc->ym = 0;
npc->act_no = 222;
npc->act_wait = 0;
@@ -230,16 +232,16 @@
for (i = 0; i < 8; ++i)
{
x = npc->x + (Random(-0x10, 0x10) * 0x200);
- SetNpChar(4, x, npc->y - 0x1400, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, x, npc->y - (10 * 0x200), 0, 0, 0, NULL, 0x100);
}
- SetNpChar(332, npc->x - 0x1800, npc->y - 0x1800, 0, 0, 0, 0, 0x100);
- SetNpChar(332, npc->x + 0x1800, npc->y - 0x1800, 0, 0, 2, 0, 0x100);
+ SetNpChar(332, npc->x - (12 * 0x200), npc->y - (12 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(332, npc->x + (12 * 0x200), npc->y - (12 * 0x200), 0, 0, 2, NULL, 0x100);
SetQuake2(10);
PlaySoundObject(26, 1);
}
- if (npc->count1 < 4 && gMC.y > npc->y - 0x2000 && gMC.y < npc->y + 0x2000)
+ if (npc->count1 < 4 && gMC.y > npc->y - (16 * 0x200) && gMC.y < npc->y + (16 * 0x200))
npc->act_no = 201;
break;
@@ -291,16 +293,16 @@
for (i = 0; i < 8; ++i)
{
x = npc->x + (Random(-0x10, 0x10) * 0x200);
- SetNpChar(4, x, npc->y + 0x1400, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, x, npc->y + (10 * 0x200), 0, 0, 0, NULL, 0x100);
}
- SetNpChar(332, npc->x - 0x1800, npc->y + 0x1800, 0, 0, 0, 0, 0x100);
- SetNpChar(332, npc->x + 0x1800, npc->y + 0x1800, 0, 0, 2, 0, 0x100);
+ SetNpChar(332, npc->x - (12 * 0x200), npc->y + (12 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(332, npc->x + (12 * 0x200), npc->y + (12 * 0x200), 0, 0, 2, NULL, 0x100);
SetQuake2(10);
PlaySoundObject(26, 1);
}
- if (npc->count1 < 4 && gMC.y > npc->y - 0x2000 && gMC.y < npc->y + 0x2000)
+ if (npc->count1 < 4 && gMC.y > npc->y - (16 * 0x200) && gMC.y < npc->y + (16 * 0x200))
npc->act_no = 201;
break;
@@ -362,17 +364,17 @@
npc->act_wait = 0;
npc->ym = -0x600;
- if (npc->x > 0x28000)
+ if (npc->x > 320 * 0x200)
{
npc->direct = 2;
npc->tgt_x = gMC.x;
- npc->tgt_y = 0x16000;
+ npc->tgt_y = 176 * 0x200;
}
else
{
npc->direct = 0;
npc->tgt_x = gMC.x;
- npc->tgt_y = 0x16000;
+ npc->tgt_y = 176 * 0x200;
}
npc->ani_wait = 0;
@@ -413,7 +415,7 @@
if (npc->act_wait > 200 && npc->act_wait % 40 == 1)
{
npc->ani_wait = 0;
- SetNpChar(333, gMC.x, 0x26000, 0, 0, 0, 0, 0x100);
+ SetNpChar(333, gMC.x, 304 * 0x200, 0, 0, 0, NULL, 0x100);
}
if (npc->act_wait > 480)
@@ -435,7 +437,7 @@
if (npc->act_wait > 50 && npc->act_wait % 10 == 1)
{
x = ((4 * npc->act_wait - 200) / 10 + 2) * 0x200 * 0x10;
- SetNpChar(333, x, 0x26000, 0, 0, 0, 0, 0x100);
+ SetNpChar(333, x, 304 * 0x200, 0, 0, 0, NULL, 0x100);
}
if (npc->act_wait > 140)
@@ -605,7 +607,7 @@
{
case 0:
npc->act_no = 10;
- npc->count1 = 2 * (npc->direct & 0xFF);
+ npc->count1 = (npc->direct & 0xFF) * 2;
npc->direct >>= 8;
npc->count2 = 0xC0;
npc->damage = 14;
@@ -748,6 +750,7 @@
case 41:
if (npc->flag & 1)
npc->xm = 0x100;
+
if (npc->flag & 4)
npc->xm = -0x100;
@@ -807,8 +810,8 @@
case 0:
if (npc->count1 == 140)
{
- SetNpChar(4, npc->x + 0x1000, npc->y + 0x1800, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x - 0x1000, npc->y + 0x1800, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (8 * 0x200), npc->y + 0x1800, 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x - (8 * 0x200), npc->y + 0x1800, 0, 0, 0, NULL, 0x100);
PlaySoundObject(26, 1);
}
break;
@@ -816,8 +819,8 @@
case 1:
if (npc->count1 == 268)
{
- SetNpChar(4, npc->x - 0x1800, npc->y + 0x1000, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x - 0x1800, npc->y - 0x1000, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x - (12 * 0x200), npc->y + (8 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x - (12 * 0x200), npc->y - (8 * 0x200), 0, 0, 0, NULL, 0x100);
PlaySoundObject(26, 1);
}
break;
@@ -825,9 +828,9 @@
case 2:
if (npc->count1 == 396)
{
- SetNpChar(4, npc->x + 0x1000, npc->y - 0x1800, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x - 0x1000, npc->y - 0x1800, 0, 0, 0, 0, 0x100);
- SetNpChar(345, npc->x - 0x1000, npc->y - 0x1800, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (8 * 0x200), npc->y - (12 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x - (8 * 0x200), npc->y - (12 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(345, npc->x - (8 * 0x200), npc->y - (12 * 0x200), 0, 0, 0, NULL, 0x100);
PlaySoundObject(26, 1);
}
break;
@@ -835,8 +838,8 @@
case 3:
if (npc->count1 == 12)
{
- SetNpChar(4, npc->x + 0x1800, npc->y + 0x1000, 0, 0, 0, 0, 0x100);
- SetNpChar(4, npc->x + 0x1800, npc->y - 0x1000, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x + (12 * 0x200), npc->y + (8 * 0x200), 0, 0, 0, NULL, 0x100);
+ SetNpChar(4, npc->x + (12 * 0x200), npc->y - (8 * 0x200), 0, 0, 0, NULL, 0x100);
PlaySoundObject(26, 1);
}
break;
@@ -885,18 +888,18 @@
if (npc->direct == 0)
{
npc->rect = rc[0];
- npc->x = npc->pNpc->x - 0x3000;
+ npc->x = npc->pNpc->x - (24 * 0x200);
}
else
{
npc->rect = rc[1];
- npc->x = npc->pNpc->x + 0x3000;
+ npc->x = npc->pNpc->x + (24 * 0x200);
}
if (++npc->act_wait > 100)
npc->cond = 0;
- npc->y = npc->pNpc->y - 0x4800;
+ npc->y = npc->pNpc->y - (36 * 0x200);
}
// Ballos skull projectile
@@ -922,11 +925,11 @@
if (npc->ym > 0x700)
npc->ym = 0x700;
- if (npc->y > 0x10000)
+ if (npc->y > 128 * 0x200)
npc->bits &= ~NPC_IGNORE_SOLIDITY;
if (npc->act_wait++ / 2 % 2)
- SetNpChar(4, npc->x, npc->y, 0, 0, 0, 0, 0x100);
+ SetNpChar(4, npc->x, npc->y, 0, 0, 0, NULL, 0x100);
if (npc->flag & 8)
{
@@ -937,7 +940,7 @@
SetQuake(10);
for (i = 0; i < 4; ++i)
- SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + 0x2000, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100);
+ SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (16 * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100);
}
break;
@@ -982,7 +985,7 @@
{
case 0:
npc->act_no = 10;
- npc->count1 = 4 * npc->direct;
+ npc->count1 = npc->direct * 4;
npc->count2 = 192;
npc->ani_no = 0;
// Fallthrough
@@ -1076,7 +1079,7 @@
deg = npc->count1 / 4;
npc->tgt_x = npc->pNpc->x + npc->count2 * GetCos(deg) / 4;
- npc->tgt_y = npc->pNpc->y + 0x2000 + npc->count2 * GetSin(deg) / 4;
+ npc->tgt_y = npc->pNpc->y + (16 * 0x200) + npc->count2 * GetSin(deg) / 4;
npc->xm = npc->tgt_x - npc->x;
@@ -1115,7 +1118,7 @@
case 1:
npc->ani_no = 0;
- if (gMC.y < npc->y + 0x10000 && gMC.y > npc->y - 0x10000)
+ if (gMC.y < npc->y + (128 * 0x200) && gMC.y > npc->y - (128 * 0x200))
{
npc->act_no = 10;
npc->act_wait = 0;
@@ -1153,17 +1156,14 @@
npc->ym = 0;
break;
}
- else
- {
- npc->xm -= 42;
- if (npc->xm < -0x5FF)
- npc->xm = -0x5FF;
+ npc->xm -= 42;
- npc->x += npc->xm;
- npc->y += npc->ym;
- }
+ if (npc->xm < -0x5FF)
+ npc->xm = -0x5FF;
+ npc->x += npc->xm;
+ npc->y += npc->ym;
break;
case 13:
@@ -1237,9 +1237,9 @@
npc->act_no = 1;
if (npc->direct == 0)
- npc->x += 0x1000;
+ npc->x += 8 * 0x200;
if (npc->direct == 2)
- npc->y += 0x2000;
+ npc->y += 16 * 0x200;
}
npc->rect = rect;
@@ -1274,13 +1274,13 @@
npc->act_no = 1;
if (npc->direct == 0)
- npc->tgt_x = npc->x - 0x10000;
+ npc->tgt_x = npc->x - (128 * 0x200);
else
- npc->tgt_x = npc->x + 0x10000;
+ npc->tgt_x = npc->x + (128 * 0x200);
npc->tgt_y = npc->y;
- npc->ym = 2 * Random(-0x200, 0x200);
- npc->xm = 2 * Random(-0x200, 0x200);
+ npc->ym = Random(-0x200, 0x200) * 2;
+ npc->xm = Random(-0x200, 0x200) * 2;
// Fallthrough
case 1:
if (++npc->ani_wait > 1)
@@ -1322,7 +1322,7 @@
if (++npc->act_wait > 300)
npc->act_no = 30;
- if (gMC.x < npc->x + 0xE000 && gMC.x > npc->x - 0xE000 && gMC.y < npc->y + 0x2000 && gMC.y > npc->y - 0x2000)
+ if (gMC.x < npc->x + (112 * 0x200) && gMC.x > npc->x - (112 * 0x200) && gMC.y < npc->y + (16 * 0x200) && gMC.y > npc->y - (16 * 0x200))
npc->act_no = 30;
break;
@@ -1344,9 +1344,9 @@
npc->ani_no = 5;
if (npc->direct == 0)
- SetNpChar(312, npc->x, npc->y, -0x800, 0, 0, 0, 0x199);
+ SetNpChar(312, npc->x, npc->y, -0x800, 0, 0, NULL, 0x199);
else
- SetNpChar(312, npc->x, npc->y, 0x800, 0, 2, 0, 0x199);
+ SetNpChar(312, npc->x, npc->y, 0x800, 0, 2, NULL, 0x199);
}
break;
@@ -1450,8 +1450,8 @@
case 0:
npc->act_no = 1;
npc->ani_no = npc->direct / 10;
- npc->x += 0x1000;
- npc->y += 0x1800;
+ npc->x += 8 * 0x200;
+ npc->y += 12 * 0x200;
break;
case 10:
@@ -1468,7 +1468,7 @@
case 11:
if (npc->life <= 900)
{
- SetNpChar(351, npc->x - 0x1000, npc->y - 0x1800, 0, 0, 10 * (npc->ani_no + 4), 0, 0);
+ SetNpChar(351, npc->x - (8 * 0x200), npc->y - (12 * 0x200), 0, 0, (npc->ani_no + 4) * 10, NULL, 0);
npc->cond |= 8;
}
@@ -1513,7 +1513,7 @@
case 4:
case 9:
case 12:
- npc->view.top = 0x2000;
+ npc->view.top = 16 * 0x200;
break;
}
@@ -1520,9 +1520,9 @@
// Balrog
if (npc->count1 == 9)
{
- npc->view.back = 0x2800;
- npc->view.front = 0x2800;
- npc->x -= 0x200;
+ npc->view.back = 20 * 0x200;
+ npc->view.front = 20 * 0x200;
+ npc->x -= 1 * 0x200;
}
// Spawn King's sword
@@ -1577,7 +1577,7 @@
{48, 0, 64, 16}
};
- npc->rect = rc[npc->ani_no + 2 * npc->count1];
+ npc->rect = rc[npc->ani_no + (npc->count1 * 2)];
}
// Bute with sword (flying)
@@ -1645,7 +1645,7 @@
}
npc->rect = rc[npc->ani_no];
- return;
+ break;
case 10:
npc->act_no = 11;
@@ -1653,7 +1653,7 @@
npc->bits |= NPC_SHOOTABLE;
npc->bits &= ~NPC_IGNORE_SOLIDITY;
npc->damage = 5;
- npc->view.top = 0x1000;
+ npc->view.top = 8 * 0x200;
// Fallthrough
case 11:
if (npc->x > gMC.x)
@@ -1661,7 +1661,7 @@
else
npc->direct = 2;
- if (gMC.y - 0x3000 > npc->y)
+ if (gMC.y - (24 * 0x200) > npc->y)
{
if (npc->direct == 0)
npc->xm2 += 0x10;
@@ -1731,7 +1731,7 @@
switch (npc->act_no)
{
case 0:
- npc->hit.bottom = 0x23000;
+ npc->hit.bottom = 280 * 0x200;
break;
case 10:
@@ -1739,9 +1739,9 @@
npc->act_wait = 0;
if (npc->direct == 0)
- npc->x += 0x2000;
+ npc->x += 16 * 0x200;
else
- npc->x -= 0x2000;
+ npc->x -= 16 * 0x200;
// Fallthrough
case 11:
if (++npc->act_wait > 100)
@@ -1752,14 +1752,14 @@
PlaySoundObject(12, 1);
if (npc->direct == 0)
- npc->x -= 0x2000;
+ npc->x -= 16 * 0x200;
else
- npc->x += 0x2000;
+ npc->x += 16 * 0x200;
for (i = 0; i < 20; ++i)
{
- x = npc->x / 0x200 / 0x10;
- y = i + npc->y / 0x200 / 0x10;
+ x = (npc->x / 0x200 / 0x10);
+ y = (npc->y / 0x200 / 0x10) + i;
ChangeMapParts(x, y, 109);
}
}
@@ -1786,29 +1786,29 @@
case 0:
npc->surf = SURFACE_ID_MY_CHAR;
npc->ani_no = 0;
- npc->x = npc->pNpc->x - 0x1C00;
- npc->y = npc->pNpc->y + 0x1400;
+ npc->x = npc->pNpc->x - (14 * 0x200);
+ npc->y = npc->pNpc->y + (10 * 0x200);
break;
case 1:
npc->surf = SURFACE_ID_NPC_REGU;
npc->ani_no = 1;
- npc->x = npc->pNpc->x + 0x1C00;
- npc->y = npc->pNpc->y + 0x1400;
+ npc->x = npc->pNpc->x + (14 * 0x200);
+ npc->y = npc->pNpc->y + (10 * 0x200);
break;
case 2:
npc->surf = SURFACE_ID_MY_CHAR;
npc->ani_no = 2;
- npc->x = npc->pNpc->x - 0xE00;
- npc->y = npc->pNpc->y - 0x2600;
+ npc->x = npc->pNpc->x - (7 * 0x200);
+ npc->y = npc->pNpc->y - (19 * 0x200);
break;
case 3:
npc->surf = SURFACE_ID_NPC_REGU;
npc->ani_no = 3;
- npc->x = npc->pNpc->x + 0x800;
- npc->y = npc->pNpc->y - 0x2600;
+ npc->x = npc->pNpc->x + (4 * 0x200);
+ npc->y = npc->pNpc->y - (19 * 0x200);
break;
}
@@ -1831,8 +1831,8 @@
case 0:
npc->act_no = 11;
npc->ani_wait = 0;
- npc->tgt_y = npc->y - 0x2000;
- npc->tgt_x = npc->x - 0xC00;
+ npc->tgt_y = npc->y - (16 * 0x200);
+ npc->tgt_x = npc->x - (6 * 0x200);
npc->ym = 0;
SetNpChar(355, 0, 0, 0, 0, 3, npc, 0xAA);
SetNpChar(355, 0, 0, 0, 0, 2, npc, 0xAA);
@@ -1865,7 +1865,7 @@
npc->x += npc->xm;
npc->y += npc->ym;
- if (npc->x > 0x78000)
+ if (npc->x > 60 * 0x10 * 0x200)
npc->act_no = 22;
break;
@@ -1971,11 +1971,11 @@
if (gMC.x < npc->x + (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.x > npc->x - (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.y < npc->y + (((WINDOW_HEIGHT / 2) + 200) * 0x200) && gMC.y > npc->y - (((WINDOW_HEIGHT / 2) + 40) * 0x200) && Random(0, 100) == 2)
{
x = npc->x + (Random(-6, 6) * 0x200);
- SetNpChar(73, x, npc->y - 0xE00, 0, 0, 0, 0, 0);
+ SetNpChar(73, x, npc->y - (7 * 0x200), 0, 0, 0, 0, 0);
}
}
-// Thank you
+// "Thank you" message at the end of the credits
void ActNpc360(NPCHAR *npc)
{
RECT rc = {0, 176, 48, 184};
@@ -1983,8 +1983,8 @@
if (npc->act_no == 0)
{
++npc->act_no;
- npc->x -= 0x1000;
- npc->y -= 0x1000;
+ npc->x -= 8 * 0x200;
+ npc->y -= 8 * 0x200;
}
npc->rect = rc;
--- a/src/NpcHit.cpp
+++ b/src/NpcHit.cpp
@@ -294,9 +294,9 @@
offy[7] = 2;
offy[8] = 2;
- for (i = 0; i < NPC_MAX; i++)
+ for (i = 0; i < NPC_MAX; ++i)
{
- if ((gNPC[i].cond & 0x80) == 0)
+ if (!(gNPC[i].cond & 0x80))
continue;
if (gNPC[i].bits & NPC_IGNORE_SOLIDITY)
@@ -317,7 +317,7 @@
gNPC[i].flag = 0;
- for (j = 0; j < judg; j++)
+ for (j = 0; j < judg; ++j)
{
switch (GetAttribute(x + offx[j], y + offy[j]))
{
@@ -480,7 +480,7 @@
}
// Create drop
- if (npc->exp)
+ if (npc->exp != 0)
{
int val;
@@ -511,6 +511,7 @@
default:
// Spawn weapon energy
SetExpObjects(npc->x, npc->y, npc->exp);
+ break;
}
}
@@ -531,23 +532,23 @@
}
}
-void HitNpCharBullet()
+void HitNpCharBullet(void)
{
int n;
int b;
BOOL bHit;
- for (n = 0; n < NPC_MAX; n++)
+ for (n = 0; n < NPC_MAX; ++n)
{
- if ((gNPC[n].cond & 0x80) == 0)
+ if (!(gNPC[n].cond & 0x80))
continue;
if (gNPC[n].bits & NPC_SHOOTABLE && gNPC[n].bits & NPC_INTERACTABLE)
continue;
- for (b = 0; b < BULLET_MAX; b++)
+ for (b = 0; b < BULLET_MAX; ++b)
{
- if ((gBul[b].cond & 0x80) == 0)
+ if (!(gBul[b].cond & 0x80))
continue;
if (gBul[b].damage == -1)
@@ -611,7 +612,7 @@
{
// Strange empty case that's needed for accurate assembly
}
- else if ((gBul[b].bbits & 0x10) == 0)
+ else if (!(gBul[b].bbits & 0x10))
{
// Hit invulnerable NPC
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 2, 2);
@@ -628,4 +629,3 @@
LoseNpChar(&gNPC[n], TRUE);
}
}
-
--- a/src/NpcHit.h
+++ b/src/NpcHit.h
@@ -14,6 +14,6 @@
void JudgeHitNpCharTriangleG(NPCHAR *npc, int x, int y);
void JudgeHitNpCharTriangleH(NPCHAR *npc, int x, int y);
void JudgeHitNpCharWater(NPCHAR *npc, int x, int y);
-void HitNpCharMap();
+void HitNpCharMap(void);
void LoseNpChar(NPCHAR *npc, BOOL bVanish);
-void HitNpCharBullet();
+void HitNpCharBullet(void);
--- a/src/NpcTbl.cpp
+++ b/src/NpcTbl.cpp
@@ -15,15 +15,15 @@
BOOL LoadNpcTable(const char *path)
{
FILE *fp;
- long n;
- long num;
- long size;
+ int n;
+ int num;
+ size_t size;
- size = GetFileSizeLong(path);
+ size = GetFileSizeLong(path); // TODO - Investigate whether GetFileSizeLong actually returns an unsigned long or not
if (size == -1)
return FALSE;
- num = size / 0x18;
+ num = (int)(size / 0x18);
gNpcTable = (NPC_TABLE*)malloc(num * sizeof(NPC_TABLE));
if (gNpcTable == NULL)
@@ -37,25 +37,25 @@
return FALSE;
}
- for (n = 0; n < num; n++) // bits
+ for (n = 0; n < num; ++n) // bits
gNpcTable[n].bits = File_ReadLE16(fp);
- for (n = 0; n < num; n++) // life
+ for (n = 0; n < num; ++n) // life
gNpcTable[n].life = File_ReadLE16(fp);
- for (n = 0; n < num; n++) // surf
+ for (n = 0; n < num; ++n) // surf
fread(&gNpcTable[n].surf, 1, 1, fp);
- for (n = 0; n < num; n++) // destroy_voice
+ for (n = 0; n < num; ++n) // destroy_voice
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
- for (n = 0; n < num; n++) // hit_voice
+ for (n = 0; n < num; ++n) // hit_voice
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
- for (n = 0; n < num; n++) // size
+ for (n = 0; n < num; ++n) // size
fread(&gNpcTable[n].size, 1, 1, fp);
- for (n = 0; n < num; n++) // exp
+ for (n = 0; n < num; ++n) // exp
gNpcTable[n].exp = File_ReadLE32(fp);
- for (n = 0; n < num; n++) // damage
+ for (n = 0; n < num; ++n) // damage
gNpcTable[n].damage = File_ReadLE32(fp);
- for (n = 0; n < num; n++) // hit
+ for (n = 0; n < num; ++n) // hit
fread(&gNpcTable[n].hit, 4, 1, fp);
- for (n = 0; n < num; n++) // view
+ for (n = 0; n < num; ++n) // view
fread(&gNpcTable[n].view, 4, 1, fp);
fclose(fp);
@@ -62,9 +62,9 @@
return TRUE;
}
-void ReleaseNpcTable()
+void ReleaseNpcTable(void)
{
- if (gNpcTable)
+ if (gNpcTable != NULL)
{
free(gNpcTable);
gNpcTable = NULL;
@@ -72,8 +72,7 @@
}
// Npc function table
-NPCFUNCTION gpNpcFuncTbl[361] =
-{
+const NPCFUNCTION gpNpcFuncTbl[361] = {
ActNpc000,
ActNpc001,
ActNpc002,
--- a/src/NpcTbl.h
+++ b/src/NpcTbl.h
@@ -29,8 +29,8 @@
extern NPC_TABLE *gNpcTable;
BOOL LoadNpcTable(const char *path);
-void ReleaseNpcTable();
+void ReleaseNpcTable(void);
-//NPC Function table
+// NPC Function table
typedef void (*NPCFUNCTION)(NPCHAR*);
-extern NPCFUNCTION gpNpcFuncTbl[];
+extern const NPCFUNCTION gpNpcFuncTbl[];
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -400,7 +400,7 @@
}
}
-OrgData::OrgData()
+OrgData::OrgData(void)
{
int i;
@@ -695,7 +695,7 @@
NOTELIST *play_np[MAXTRACK];
long now_leng[MAXMELODY];
-void OrgData::PlayData()
+void OrgData::PlayData(void)
{
int i;
@@ -846,7 +846,7 @@
return TRUE;
}
-void StopOrganyaMusic()
+void StopOrganyaMusic(void)
{
if (!audio_backend_initialised)
return;
@@ -864,12 +864,12 @@
// Sleep(100); // TODO - Emulate this
}
-void SetOrganyaFadeout()
+void SetOrganyaFadeout(void)
{
bFadeout = TRUE;
}
-void EndOrganya()
+void EndOrganya(void)
{
if (!audio_backend_initialised)
return;
--- a/src/Organya.h
+++ b/src/Organya.h
@@ -11,15 +11,15 @@
extern BOOL g_mute[MAXTRACK]; // Used by the debug Mute menu
BOOL MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi);
-void OrganyaPlayData();
+void OrganyaPlayData(void);
void SetPlayPointer(long x);
BOOL LoadOrganya(const char *name);
void SetOrganyaPosition(unsigned int x);
-unsigned int GetOrganyaPosition();
-void PlayOrganyaMusic();
+unsigned int GetOrganyaPosition(void);
+void PlayOrganyaMusic(void);
BOOL ChangeOrganyaVolume(signed int volume);
-void StopOrganyaMusic();
-void SetOrganyaFadeout();
+void StopOrganyaMusic(void);
+void SetOrganyaFadeout(void);
BOOL StartOrganya(const char *wave_filename);
-void EndOrganya();
+void EndOrganya(void);
void UpdateOrganya(void);
--- a/src/PixTone.cpp
+++ b/src/PixTone.cpp
@@ -8,7 +8,7 @@
#include "Random.h"
-static signed char gWaveModelTable[6][256];
+static signed char gWaveModelTable[6][0x100];
void MakeWaveTables(void)
{
@@ -15,7 +15,7 @@
int i, a;
// Sine wave
- for (i = 0; i < 256; ++i)
+ for (i = 0; i < 0x100; ++i)
{
gWaveModelTable[0][i] = (signed char)(sin(i * 6.283184 / 256.0) * 64.0);
a = gWaveModelTable[0][i];
@@ -57,7 +57,7 @@
// White noise wave
msvc_srand(0);
- for (i = 0; i < 256; ++i)
+ for (i = 0; i < 0x100; ++i)
gWaveModelTable[5][i] = (signed char)(msvc_rand() & 0xFF) / 2;
}
@@ -109,7 +109,7 @@
}
dEnvelope = ptp->pointCy;
- while (i < 256)
+ while (i < 0x100)
{
envelopeTable[i] = (signed char)dEnvelope;
dEnvelope = (double)dEnvelope - ptp->pointCy / (double)(256 - ptp->pointCx);
@@ -137,9 +137,9 @@
for (i = 0; i < ptp->size; ++i)
{
- a = (int)dMain % 256;
- b = (int)dPitch % 256;
- c = (int)dVolume % 256;
+ a = (int)dMain % 0x100;
+ b = (int)dPitch % 0x100;
+ c = (int)dVolume % 0x100;
d = (int)((double)(i * 0x100) / ptp->size);
pData[i] = gWaveModelTable[ptp->oMain.model][a]
* ptp->oMain.top
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -25,16 +25,17 @@
const char *gDefaultName = "Profile.dat";
const char *gProfileCode = "Do041220";
-BOOL IsProfile()
+BOOL IsProfile(void)
{
char path[MAX_PATH];
sprintf(path, "%s/%s", gModulePath, gDefaultName);
- FILE *fp = fopen(path, "rb");
- if (fp == NULL)
+ FILE *file = fopen(path, "rb");
+
+ if (file == NULL)
return FALSE;
- fclose(fp);
+ fclose(file);
return TRUE;
}
@@ -46,7 +47,7 @@
char path[MAX_PATH];
// Get path
- if (name)
+ if (name != NULL)
sprintf(path, "%s/%s", gModulePath, name);
else
sprintf(path, "%s/%s", gModulePath, gDefaultName);
@@ -120,18 +121,18 @@
BOOL LoadProfile(const char *name)
{
- // Get path
char path[MAX_PATH];
+ PROFILE profile;
+ FILE *fp;
- if (name)
+ // Get path
+ if (name != NULL)
sprintf(path, "%s", name);
else
sprintf(path, "%s/%s", gModulePath, gDefaultName);
// Open file
- PROFILE profile;
-
- FILE *fp = fopen(path, "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
@@ -213,9 +214,9 @@
gMC.x = profile.x;
gMC.y = profile.y;
- gMC.rect_arms.left = 24 * (gArmsData[gSelectedArms].code % 10);
+ gMC.rect_arms.left = (gArmsData[gSelectedArms].code % 10) * 24;
gMC.rect_arms.right = gMC.rect_arms.left + 24;
- gMC.rect_arms.top = 32 * (gArmsData[gSelectedArms].code / 10);
+ gMC.rect_arms.top = (gArmsData[gSelectedArms].code / 10) * 32;
gMC.rect_arms.bottom = gMC.rect_arms.top + 16;
// Reset stuff
@@ -227,6 +228,7 @@
InitStar();
ClearValueView();
gCurlyShoot_wait = 0;
+
return TRUE;
}
--- a/src/Profile.h
+++ b/src/Profile.h
@@ -31,7 +31,7 @@
unsigned char flags[1000];
};
-BOOL IsProfile();
+BOOL IsProfile(void);
BOOL SaveProfile(const char *name);
BOOL LoadProfile(const char *name);
BOOL InitializeGame(void);
--- a/src/SelStage.cpp
+++ b/src/SelStage.cpp
@@ -19,12 +19,13 @@
void ClearPermitStage(void)
{
- memset(gPermitStage, 0, 0x40);
+ memset(gPermitStage, 0, sizeof(gPermitStage));
}
BOOL AddPermitStage(int index, int event)
{
int i = 0;
+
while (i < 8)
{
if (gPermitStage[i].index == index)
@@ -48,6 +49,7 @@
BOOL SubPermitStage(int index)
{
int i;
+
for (i = 0; i < 8; ++i)
if (gPermitStage[i].index == index)
break;
@@ -59,10 +61,8 @@
#endif
return FALSE;
- for (i += 1; i < 8; ++i)
- {
+ for (++i; i < 8; ++i)
gPermitStage[i - 1] = gPermitStage[i];
- }
gPermitStage[i - 1].index = 0;
gPermitStage[i - 1].event = 0;
@@ -72,11 +72,14 @@
void MoveStageSelectCursor(void)
{
- int stage_num = 0;
+ int stage_num;
+ int stage_x;
+
+ stage_num = 0;
while (gPermitStage[stage_num].index != 0)
++stage_num;
- int stage_x = (WINDOW_WIDTH - 40 * stage_num) / 2; // Unused
+ stage_x = (WINDOW_WIDTH - (stage_num * 40)) / 2; // Unused
if (stage_num == 0)
return;
@@ -93,10 +96,10 @@
if (gSelectedStage > stage_num - 1)
gSelectedStage = 0;
- if ((gKeyLeft | gKeyRight) & gKeyTrg)
+ if (gKeyTrg & (gKeyLeft | gKeyRight))
StartTextScript(gPermitStage[gSelectedStage].index + 1000);
- if ((gKeyLeft | gKeyRight) & gKeyTrg)
+ if (gKeyTrg & (gKeyLeft | gKeyRight))
PlaySoundObject(1, 1);
}
@@ -129,11 +132,11 @@
++flash;
- if (stage_num)
+ if (stage_num != 0)
{
- stage_x = (WINDOW_WIDTH - 40 * stage_num) / 2;
+ stage_x = (WINDOW_WIDTH - (stage_num * 40)) / 2;
- PutBitmap3(&rcView, stage_x + 40 * gSelectedStage, (WINDOW_HEIGHT / 2) - 56, &rcCur[(flash >> 1) % 2], SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&rcView, stage_x + (gSelectedStage * 40), (WINDOW_HEIGHT / 2) - 56, &rcCur[flash / 2 % 2], SURFACE_ID_TEXT_BOX);
for (i = 0; i < 8; ++i)
{
@@ -140,12 +143,12 @@
if (gPermitStage[i].index == 0)
break;
- rcStage.left = 32 * (gPermitStage[i].index % 8);
+ rcStage.left = (gPermitStage[i].index % 8) * 32;
rcStage.right = rcStage.left + 32;
- rcStage.top = 16 * (gPermitStage[i].index / 8);
+ rcStage.top = (gPermitStage[i].index / 8) * 16;
rcStage.bottom = rcStage.top + 16;
- PutBitmap3(&rcView, stage_x + 40 * i, (WINDOW_HEIGHT / 2) - 56, &rcStage, SURFACE_ID_STAGE_ITEM);
+ PutBitmap3(&rcView, stage_x + (i * 40), (WINDOW_HEIGHT / 2) - 56, &rcStage, SURFACE_ID_STAGE_ITEM);
}
}
}
--- a/src/Shoot.cpp
+++ b/src/Shoot.cpp
@@ -22,9 +22,11 @@
case 1:
bul_no = 1;
break;
+
case 2:
bul_no = 2;
break;
+
case 3:
bul_no = 3;
break;
@@ -45,13 +47,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x600, gMC.y - 0x1400, 1);
- SetCaret(gMC.x - 0x600, gMC.y - 0x1400, 3, 0);
+ SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y - (10 * 0x200), 1);
+ SetCaret(gMC.x - (3 * 0x200), gMC.y - (10 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x600, gMC.y - 0x1400, 1);
- SetCaret(gMC.x + 0x600, gMC.y - 0x1400, 3, 0);
+ SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y - (10 * 0x200), 1);
+ SetCaret(gMC.x + (3 * 0x200), gMC.y - (10 * 0x200), 3, 0);
}
}
else if (gMC.down)
@@ -58,13 +60,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x600, gMC.y + 0x1400, 3);
- SetCaret(gMC.x - 0x600, gMC.y + 0x1400, 3, 0);
+ SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y + (10 * 0x200), 3);
+ SetCaret(gMC.x - (3 * 0x200), gMC.y + (10 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x600, gMC.y + 0x1400, 3);
- SetCaret(gMC.x + 0x600, gMC.y + 0x1400, 3, 0);
+ SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y + (10 * 0x200), 3);
+ SetCaret(gMC.x + (3 * 0x200), gMC.y + (10 * 0x200), 3, 0);
}
}
else
@@ -71,13 +73,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0xC00, gMC.y + 0x400, 0);
- SetCaret(gMC.x - 0x1800, gMC.y + 0x400, 3, 0);
+ SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y + (2 * 0x200), 0);
+ SetCaret(gMC.x - (12 * 0x200), gMC.y + (2 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x400, 2);
- SetCaret(gMC.x + 0x1800, gMC.y + 0x400, 3, 0);
+ SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y + (2 * 0x200), 2);
+ SetCaret(gMC.x + (12 * 0x200), gMC.y + (2 * 0x200), 3, 0);
}
}
@@ -89,14 +91,17 @@
void ShootBullet_PoleStar(int level)
{
int bul_no;
+
switch (level)
{
case 1:
bul_no = 4;
break;
+
case 2:
bul_no = 5;
break;
+
case 3:
bul_no = 6;
break;
@@ -117,13 +122,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0x1000, 1);
- SetCaret(gMC.x - 0x200, gMC.y - 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1000, 1);
- SetCaret(gMC.x + 0x200, gMC.y - 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 3, 0);
}
}
else if (gMC.down)
@@ -130,13 +135,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x1000, 3);
- SetCaret(gMC.x - 0x200, gMC.y + 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1000, 3);
- SetCaret(gMC.x + 0x200, gMC.y + 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3, 0);
}
}
else
@@ -143,13 +148,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0xC00, gMC.y + 0x600, 0);
- SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0);
+ SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y + (3 * 0x200), 0);
+ SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x600, 2);
- SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0);
+ SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y + (3 * 0x200), 2);
+ SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 3, 0);
}
}
@@ -170,16 +175,21 @@
case 1:
if (CountArmsBullet(3) > 1)
return;
+
bul_no = 7;
break;
+
case 2:
if (CountArmsBullet(3) > 2)
return;
+
bul_no = 8;
break;
+
case 3:
if (CountArmsBullet(3) > 3)
return;
+
bul_no = 9;
break;
}
@@ -196,13 +206,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x800, gMC.y - 0x1000, 1);
- SetCaret(gMC.x - 0x800, gMC.y - 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x - (4 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x - (4 * 0x200), gMC.y - (8 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x800, gMC.y - 0x1000, 1);
- SetCaret(gMC.x + 0x800, gMC.y - 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x + (4 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x + (4 * 0x200), gMC.y - (8 * 0x200), 3, 0);
}
}
else if (gMC.down)
@@ -209,13 +219,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x800, gMC.y + 0x1000, 3);
- SetCaret(gMC.x - 0x800, gMC.y + 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x - (4 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x - (4 * 0x200), gMC.y + (8 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x800, gMC.y + 0x1000, 3);
- SetCaret(gMC.x + 0x800, gMC.y + 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x + (4 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x + (4 * 0x200), gMC.y + (8 * 0x200), 3, 0);
}
}
else
@@ -222,13 +232,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0xC00, gMC.y + 0x400, 0);
- SetCaret(gMC.x - 0x1800, gMC.y + 0x400, 3, 0);
+ SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y + (2 * 0x200), 0);
+ SetCaret(gMC.x - (12 * 0x200), gMC.y + (2 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x400, 2);
- SetCaret(gMC.x + 0x1800, gMC.y + 0x400, 3, 0);
+ SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y + (2 * 0x200), 2);
+ SetCaret(gMC.x + (12 * 0x200), gMC.y + (2 * 0x200), 3, 0);
}
}
@@ -239,19 +249,21 @@
void ShootBullet_Machinegun1(int level)
{
+ int bul_no;
+
if (CountArmsBullet(4) > 4)
return;
- int bul_no;
-
switch (level)
{
case 1:
bul_no = 10;
break;
+
case 2:
bul_no = 11;
break;
+
case 3:
bul_no = 12;
break;
@@ -279,75 +291,73 @@
return;
}
- else
+
+ if (gMC.up)
{
- if (gMC.up)
- {
- if (level == 3)
- gMC.ym += 0x100;
+ if (level == 3)
+ gMC.ym += 0x100;
- if (gMC.direct == 0)
- {
- SetBullet(bul_no, gMC.x - 0x600, gMC.y - 0x1000, 1);
- SetCaret(gMC.x - 0x600, gMC.y - 0x1000, 3, 0);
- }
- else
- {
- SetBullet(bul_no, gMC.x + 0x600, gMC.y - 0x1000, 1);
- SetCaret(gMC.x + 0x600, gMC.y - 0x1000, 3, 0);
- }
+ if (gMC.direct == 0)
+ {
+ SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x - (3 * 0x200), gMC.y - (8 * 0x200), 3, 0);
}
- else if (gMC.down)
+ else
{
- if (level == 3)
- {
- if (gMC.ym > 0)
- gMC.ym /= 2;
+ SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x + (3 * 0x200), gMC.y - (8 * 0x200), 3, 0);
+ }
+ }
+ else if (gMC.down)
+ {
+ if (level == 3)
+ {
+ if (gMC.ym > 0)
+ gMC.ym /= 2;
- if (gMC.ym > -0x400)
- {
- gMC.ym -= 0x200;
- if (gMC.ym < -0x400)
- gMC.ym = -0x400;
- }
- }
-
- if (gMC.direct == 0)
+ if (gMC.ym > -0x400)
{
- SetBullet(bul_no, gMC.x - 0x600, gMC.y + 0x1000, 3);
- SetCaret(gMC.x - 0x600, gMC.y + 0x1000, 3, 0);
+ gMC.ym -= 0x200;
+ if (gMC.ym < -0x400)
+ gMC.ym = -0x400;
}
- else
- {
- SetBullet(bul_no, gMC.x + 0x600, gMC.y + 0x1000, 3);
- SetCaret(gMC.x + 0x600, gMC.y + 0x1000, 3, 0);
- }
}
+
+ if (gMC.direct == 0)
+ {
+ SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x - (3 * 0x200), gMC.y + (8 * 0x200), 3, 0);
+ }
else
{
- if (gMC.direct == 0)
- {
- SetBullet(bul_no, gMC.x - 0x1800, gMC.y + 0x600, 0);
- SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0);
- }
- else
- {
- SetBullet(bul_no, gMC.x + 0x1800, gMC.y + 0x600, 2);
- SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0);
- }
+ SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x + (3 * 0x200), gMC.y + (8 * 0x200), 3, 0);
}
-
- if (level == 3)
- PlaySoundObject(49, 1);
+ }
+ else
+ {
+ if (gMC.direct == 0)
+ {
+ SetBullet(bul_no, gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), 0);
+ SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), 3, 0);
+ }
else
- PlaySoundObject(32, 1);
+ {
+ SetBullet(bul_no, gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 2);
+ SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 3, 0);
+ }
}
+
+ if (level == 3)
+ PlaySoundObject(49, 1);
+ else
+ PlaySoundObject(32, 1);
}
else
{
static int wait = 0;
-
++wait;
+
if (gMC.equip & 8)
{
if (wait > 1)
@@ -378,9 +388,11 @@
case 1:
bul_no = 28;
break;
+
case 2:
bul_no = 29;
break;
+
case 3:
bul_no = 30;
break;
@@ -424,9 +436,11 @@
case 1:
bul_no = 13;
break;
+
case 2:
bul_no = 14;
break;
+
case 3:
bul_no = 15;
break;
@@ -484,13 +498,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0x1000, 1);
- SetCaret(gMC.x - 0x200, gMC.y - 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1000, 1);
- SetCaret(gMC.x + 0x200, gMC.y - 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 3, 0);
}
}
else if (gMC.down)
@@ -497,13 +511,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x1000, 3);
- SetCaret(gMC.x - 0x200, gMC.y + 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1000, 3);
- SetCaret(gMC.x + 0x200, gMC.y + 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3, 0);
}
}
else
@@ -510,13 +524,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0xC00, gMC.y, 0);
- SetCaret(gMC.x - 0x1800, gMC.y, 3, 0);
+ SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y, 0);
+ SetCaret(gMC.x - (12 * 0x200), gMC.y, 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0xC00, gMC.y, 2);
- SetCaret(gMC.x + 0x1800, gMC.y, 3, 0);
+ SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y, 2);
+ SetCaret(gMC.x + (12 * 0x200), gMC.y, 3, 0);
}
}
}
@@ -539,17 +553,17 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0x1000, 1);
- SetCaret(gMC.x - 0x200, gMC.y - 0x1000, 3, 0);
- SetBullet(bul_no, gMC.x + 0x600, gMC.y, 1);
- SetBullet(bul_no, gMC.x - 0x600, gMC.y, 1);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 3, 0);
+ SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y, 1);
+ SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y, 1);
}
else
{
- SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1000, 1);
- SetCaret(gMC.x + 0x200, gMC.y - 0x1000, 3, 0);
- SetBullet(bul_no, gMC.x + 0x600, gMC.y, 1);
- SetBullet(bul_no, gMC.x - 0x600, gMC.y, 1);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 3, 0);
+ SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y, 1);
+ SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y, 1);
}
}
else if (gMC.down)
@@ -556,17 +570,17 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x1000, 3);
- SetCaret(gMC.x - 0x200, gMC.y + 0x1000, 3, 0);
- SetBullet(bul_no, gMC.x + 0x600, gMC.y, 3);
- SetBullet(bul_no, gMC.x - 0x600, gMC.y, 3);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3, 0);
+ SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y, 3);
+ SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y, 3);
}
else
{
- SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1000, 3);
- SetCaret(gMC.x + 0x200, gMC.y + 0x1000, 3, 0);
- SetBullet(bul_no, gMC.x - 0x600, gMC.y, 3);
- SetBullet(bul_no, gMC.x + 0x600, gMC.y, 3);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3, 0);
+ SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y, 3);
+ SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y, 3);
}
}
else
@@ -573,17 +587,17 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0xC00, gMC.y + 0x200, 0);
- SetCaret(gMC.x - 0x1800, gMC.y + 0x200, 3, 0);
- SetBullet(bul_no, gMC.x, gMC.y - 0x1000, 0);
- SetBullet(bul_no, gMC.x + 0x800, gMC.y - 0x200, 0);
+ SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y + (1 * 0x200), 0);
+ SetCaret(gMC.x - (12 * 0x200), gMC.y + (1 * 0x200), 3, 0);
+ SetBullet(bul_no, gMC.x, gMC.y - (8 * 0x200), 0);
+ SetBullet(bul_no, gMC.x + (4 * 0x200), gMC.y - (1 * 0x200), 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x200, 2);
- SetCaret(gMC.x + 0x1800, gMC.y + 0x200, 3, 0);
- SetBullet(bul_no, gMC.x, gMC.y - 0x1000, 2);
- SetBullet(bul_no, gMC.x - 0x800, gMC.y - 0x200, 2);
+ SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y + (1 * 0x200), 2);
+ SetCaret(gMC.x + (12 * 0x200), gMC.y + (1 * 0x200), 3, 0);
+ SetBullet(bul_no, gMC.x, gMC.y - (8 * 0x200), 2);
+ SetBullet(bul_no, gMC.x - (4 * 0x200), gMC.y - (1 * 0x200), 2);
}
}
}
@@ -613,50 +627,48 @@
return;
}
- else
+
+ if (gMC.up)
{
- if (gMC.up)
+ if (gMC.direct == 0)
{
- if (gMC.direct == 0)
- {
- SetBullet(19, gMC.x - 0x200, gMC.y - 0x400, 1);
- SetCaret(gMC.x - 0x200, gMC.y - 0x400, 3, 0);
- }
- else
- {
- SetBullet(19, gMC.x + 0x200, gMC.y - 0x400, 1);
- SetCaret(gMC.x + 0x200, gMC.y - 0x400, 3, 0);
- }
+ SetBullet(19, gMC.x - (1 * 0x200), gMC.y - (2 * 0x200), 1);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y - (2 * 0x200), 3, 0);
}
- else if (gMC.down)
+ else
{
- if (gMC.direct == 0)
- {
- SetBullet(19, gMC.x - 0x200, gMC.y + 0x400, 3);
- SetCaret(gMC.x - 0x200, gMC.y + 0x400, 3, 0);
- }
- else
- {
- SetBullet(19, gMC.x + 0x200, gMC.y + 0x400, 3);
- SetCaret(gMC.x + 0x200, gMC.y + 0x400, 3, 0);
- }
+ SetBullet(19, gMC.x + (1 * 0x200), gMC.y - (2 * 0x200), 1);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y - (2 * 0x200), 3, 0);
}
+ }
+ else if (gMC.down)
+ {
+ if (gMC.direct == 0)
+ {
+ SetBullet(19, gMC.x - (1 * 0x200), gMC.y + (2 * 0x200), 3);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y + (2 * 0x200), 3, 0);
+ }
else
{
- if (gMC.direct == 0)
- {
- SetBullet(19, gMC.x - 0xC00, gMC.y + 0x600, 0);
- SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0);
- }
- else
- {
- SetBullet(19, gMC.x + 0xC00, gMC.y + 0x600, 2);
- SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0);
- }
+ SetBullet(19, gMC.x + (1 * 0x200), gMC.y + (2 * 0x200), 3);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y + (2 * 0x200), 3, 0);
}
-
- PlaySoundObject(48, 1);
}
+ else
+ {
+ if (gMC.direct == 0)
+ {
+ SetBullet(19, gMC.x - (6 * 0x200), gMC.y + (3 * 0x200), 0);
+ SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), 3, 0);
+ }
+ else
+ {
+ SetBullet(19, gMC.x + (6 * 0x200), gMC.y + (3 * 0x200), 2);
+ SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 3, 0);
+ }
+ }
+
+ PlaySoundObject(48, 1);
}
else if (++wait > 20)
{
@@ -696,50 +708,48 @@
return;
}
- else
+
+ if (gMC.up)
{
- if (gMC.up)
+ if (gMC.direct == 0)
{
- if (gMC.direct == 0)
- {
- SetBullet(level, gMC.x - 0x600, gMC.y - 0x1000, 1);
- SetCaret(gMC.x - 0x600, gMC.y - 0x2000, 3, 0);
- }
- else
- {
- SetBullet(level, gMC.x + 0x600, gMC.y - 0x1000, 1);
- SetCaret(gMC.x + 0x600, gMC.y - 0x2000, 3, 0);
- }
+ SetBullet(level, gMC.x - (3 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x - (3 * 0x200), gMC.y - (16 * 0x200), 3, 0);
}
- else if (gMC.down)
+ else
{
- if (gMC.direct == 0)
- {
- SetBullet(level, gMC.x - 0x600, gMC.y + 0x1000, 3);
- SetCaret(gMC.x - 0x600, gMC.y + 0x2000, 3, 0);
- }
- else
- {
- SetBullet(level, gMC.x + 0x600, gMC.y + 0x1000, 3);
- SetCaret(gMC.x + 0x600, gMC.y + 0x2000, 3, 0);
- }
+ SetBullet(level, gMC.x + (3 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x + (3 * 0x200), gMC.y - (16 * 0x200), 3, 0);
}
+ }
+ else if (gMC.down)
+ {
+ if (gMC.direct == 0)
+ {
+ SetBullet(level, gMC.x - (3 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x - (3 * 0x200), gMC.y + (16 * 0x200), 3, 0);
+ }
else
{
- if (gMC.direct == 0)
- {
- SetBullet(level, gMC.x - 0xC00, gMC.y + 0x600, 0);
- SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0);
- }
- else
- {
- SetBullet(level, gMC.x + 0xC00, gMC.y + 0x600, 2);
- SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0);
- }
+ SetBullet(level, gMC.x + (3 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x + (3 * 0x200), gMC.y + (16 * 0x200), 3, 0);
}
-
- PlaySoundObject(48, 1);
}
+ else
+ {
+ if (gMC.direct == 0)
+ {
+ SetBullet(level, gMC.x - (6 * 0x200), gMC.y + (3 * 0x200), 0);
+ SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), 3, 0);
+ }
+ else
+ {
+ SetBullet(level, gMC.x + (6 * 0x200), gMC.y + (3 * 0x200), 2);
+ SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 3, 0);
+ }
+ }
+
+ PlaySoundObject(48, 1);
}
else if (++wait > 1)
{
@@ -750,19 +760,21 @@
void ShootBullet_Sword(int level)
{
+ int bul_no;
+
if (CountArmsBullet(9) > 0)
return;
- int bul_no;
-
switch (level)
{
case 1:
bul_no = 25;
break;
+
case 2:
bul_no = 26;
break;
+
case 3:
bul_no = 27;
break;
@@ -773,23 +785,23 @@
if (gMC.up)
{
if (gMC.direct == 0)
- SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x800, 1);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (4 * 0x200), 1);
else
- SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x800, 1);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y + (4 * 0x200), 1);
}
else if (gMC.down)
{
if (gMC.direct == 0)
- SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0xC00, 3);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (6 * 0x200), 3);
else
- SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0xC00, 3);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y - (6 * 0x200), 3);
}
else
{
if (gMC.direct == 0)
- SetBullet(bul_no, gMC.x + 0xC00, gMC.y - 0x600, 0);
+ SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y - (3 * 0x200), 0);
else
- SetBullet(bul_no, gMC.x - 0xC00, gMC.y - 0x600, 2);
+ SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y - (3 * 0x200), 2);
}
PlaySoundObject(34, 1);
@@ -805,9 +817,11 @@
case 1:
bul_no = 34;
break;
+
case 2:
bul_no = 35;
break;
+
case 3:
bul_no = 36;
break;
@@ -828,13 +842,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0x1800, 1);
- SetCaret(gMC.x - 0x200, gMC.y - 0x1800, 3, 0);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (12 * 0x200), 1);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y - (12 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1800, 1);
- SetCaret(gMC.x + 0x200, gMC.y - 0x1800, 3, 0);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y - (12 * 0x200), 1);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y - (12 * 0x200), 3, 0);
}
}
else if (gMC.down)
@@ -841,13 +855,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x1800, 3);
- SetCaret(gMC.x - 0x200, gMC.y + 0x1800, 3, 0);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (12 * 0x200), 3);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y + (12 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1800, 3);
- SetCaret(gMC.x + 0x200, gMC.y + 0x1800, 3, 0);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y + (12 * 0x200), 3);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y + (12 * 0x200), 3, 0);
}
}
else
@@ -854,13 +868,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x2C00, gMC.y + 0x600, 0);
- SetCaret(gMC.x - 0x2000, gMC.y + 0x600, 3, 0);
+ SetBullet(bul_no, gMC.x - (22 * 0x200), gMC.y + (3 * 0x200), 0);
+ SetCaret(gMC.x - (16 * 0x200), gMC.y + (3 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x2C00, gMC.y + 0x600, 2);
- SetCaret(gMC.x + 0x2000, gMC.y + 0x600, 3, 0);
+ SetBullet(bul_no, gMC.x + (22 * 0x200), gMC.y + (3 * 0x200), 2);
+ SetCaret(gMC.x + (16 * 0x200), gMC.y + (3 * 0x200), 3, 0);
}
}
@@ -869,9 +883,11 @@
case 1:
PlaySoundObject(117, 1);
break;
+
case 2:
PlaySoundObject(49, 1);
break;
+
case 3:
PlaySoundObject(60, 1);
break;
@@ -933,7 +949,7 @@
if (IsMaxExpMyChar())
{
- if (bMax == FALSE)
+ if (!bMax)
{
bMax = TRUE;
PlaySoundObject(65, 1);
@@ -953,9 +969,11 @@
bul_no = 6;
bShot = FALSE;
break;
+
case 2:
bul_no = 37;
break;
+
case 3:
if (bMax)
bul_no = 39;
@@ -980,13 +998,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0x1000, 1);
- SetCaret(gMC.x - 0x200, gMC.y - 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1000, 1);
- SetCaret(gMC.x + 0x200, gMC.y - 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 1);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 3, 0);
}
}
else if (gMC.down)
@@ -993,13 +1011,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x1000, 3);
- SetCaret(gMC.x - 0x200, gMC.y + 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1000, 3);
- SetCaret(gMC.x + 0x200, gMC.y + 0x1000, 3, 0);
+ SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3);
+ SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3, 0);
}
}
else
@@ -1006,13 +1024,13 @@
{
if (gMC.direct == 0)
{
- SetBullet(bul_no, gMC.x - 0xC00, gMC.y + 0x600, 0);
- SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0);
+ SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y + (3 * 0x200), 0);
+ SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), 3, 0);
}
else
{
- SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x600, 2);
- SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0);
+ SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y + (3 * 0x200), 2);
+ SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 3, 0);
}
}
@@ -1021,12 +1039,15 @@
case 6:
PlaySoundObject(49, 1);
break;
+
case 37:
PlaySoundObject(62, 1);
break;
+
case 38:
PlaySoundObject(63, 1);
break;
+
case 39:
PlaySoundObject(64, 1);
break;
@@ -1035,24 +1056,25 @@
}
}
-void ShootBullet()
+void ShootBullet(void)
{
- if (empty)
+ if (empty != 0)
--empty;
- //Only let the player shoot every 4 frames
+ // Only let the player shoot every 4 frames
static int soft_rensha; // 'rensha' is Japanese for 'rapid-fire', apparently
- if (soft_rensha)
+ if (soft_rensha != 0)
--soft_rensha;
if (gKeyTrg & gKeyShot)
{
- if (soft_rensha)
+ if (soft_rensha != 0)
return;
+
soft_rensha = 4;
}
- //Run functions
+ // Run functions
if (gMC.cond & 2)
return;
@@ -1061,18 +1083,23 @@
case 1:
ShootBullet_Frontia1(gArmsData[gSelectedArms].level);
break;
+
case 2:
ShootBullet_PoleStar(gArmsData[gSelectedArms].level);
break;
+
case 3:
ShootBullet_FireBall(gArmsData[gSelectedArms].level);
break;
+
case 4:
ShootBullet_Machinegun1(gArmsData[gSelectedArms].level);
break;
+
case 5:
ShootBullet_Missile(gArmsData[gSelectedArms].level, FALSE);
break;
+
case 7:
switch (gArmsData[gSelectedArms].level)
{
@@ -1079,9 +1106,11 @@
case 1:
ShootBullet_Bubblin1();
break;
+
case 2:
ShootBullet_Bubblin2(2);
break;
+
case 3:
ShootBullet_Bubblin2(3);
break;
@@ -1088,6 +1117,7 @@
}
break;
+
case 9:
switch (gArmsData[gSelectedArms].level)
{
@@ -1094,9 +1124,11 @@
case 1:
ShootBullet_Sword(1);
break;
+
case 2:
ShootBullet_Sword(2);
break;
+
case 3:
ShootBullet_Sword(3);
break;
@@ -1103,12 +1135,15 @@
}
break;
+
case 10:
ShootBullet_Missile(gArmsData[gSelectedArms].level, TRUE);
break;
+
case 12:
ShootBullet_Nemesis(gArmsData[gSelectedArms].level);
break;
+
case 13:
ShootBullet_Spur(gArmsData[gSelectedArms].level);
break;
--- a/src/Shoot.h
+++ b/src/Shoot.h
@@ -1,4 +1,4 @@
#pragma once
void ResetSpurCharge(void);
-void ShootBullet();
+void ShootBullet(void);
--- a/src/Stage.cpp
+++ b/src/Stage.cpp
@@ -128,17 +128,19 @@
BOOL TransferStage(int no, int w, int x, int y)
{
- //Move character
+ BOOL bError;
+ char path_dir[20];
+ char path[MAX_PATH];
+
+ // Move character
SetMyCharPosition(x * 0x10 * 0x200, y * 0x10 * 0x200);
- BOOL bError = FALSE;
+ bError = FALSE;
- //Get path
- char path_dir[20];
+ // Get path
strcpy(path_dir, "Stage");
- //Load tileset
- char path[MAX_PATH];
+ // Load tileset
sprintf(path, "%s/Prt%s", path_dir, gTMT[no].parts);
if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_TILESET))
bError = TRUE;
@@ -147,30 +149,30 @@
if (!LoadAttributeData(path))
bError = TRUE;
- //Load tilemap
+ // Load tilemap
sprintf(path, "%s/%s.pxm", path_dir, gTMT[no].map);
if (!LoadMapData2(path))
bError = TRUE;
- //Load NPCs
+ // Load NPCs
sprintf(path, "%s/%s.pxe", path_dir, gTMT[no].map);
if (!LoadEvent(path))
bError = TRUE;
- //Load script
+ // Load script
sprintf(path, "%s/%s.tsc", path_dir, gTMT[no].map);
if (!LoadTextScript_Stage(path))
bError = TRUE;
- //Load background
+ // Load background
sprintf(path, "%s", gTMT[no].back);
if (!InitBack(path, gTMT[no].bkType))
bError = TRUE;
- //Get path
+ // Get path
strcpy(path_dir, "Npc");
- //Load NPC sprite sheets
+ // Load NPC sprite sheets
sprintf(path, "%s/Npc%s", path_dir, gTMT[no].npc);
if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_SPRITESET_1))
bError = TRUE;
@@ -182,7 +184,7 @@
if (bError)
return FALSE;
- //Load map name
+ // Load map name
ReadyMapName(gTMT[no].name);
StartTextScript(w);
@@ -194,12 +196,12 @@
InitBossChar(gTMT[no].boss_no);
ResetFlash();
gStageNo = no;
+
return TRUE;
}
-//Music
-const char *gMusicTable[42] =
-{
+// Music
+const char *gMusicTable[42] = {
"XXXX",
"WANPAKU",
"ANZEN",
@@ -253,15 +255,15 @@
if (no != MUS_SILENCE && no == gMusicNo)
return;
- //Stop and keep track of old song
+ // Stop and keep track of old song
gOldPos = GetOrganyaPosition();
gOldNo = gMusicNo;
StopOrganyaMusic();
- //Load .org
+ // Load .org
LoadOrganya(gMusicTable[no]);
- //Reset position, volume, and then play the song
+ // Reset position, volume, and then play the song
ChangeOrganyaVolume(100);
SetOrganyaPosition(0);
PlayOrganyaMusic();
@@ -268,15 +270,15 @@
gMusicNo = no;
}
-void ReCallMusic()
+void ReCallMusic(void)
{
- //Stop old song
+ // Stop old song
StopOrganyaMusic();
- //Load .org that was playing before
+ // Load .org that was playing before
LoadOrganya(gMusicTable[gOldNo]);
- //Reset position, volume, and then play the song
+ // Reset position, volume, and then play the song
SetOrganyaPosition(gOldPos);
ChangeOrganyaVolume(100);
PlayOrganyaMusic();
--- a/src/Stage.h
+++ b/src/Stage.h
@@ -65,4 +65,4 @@
BOOL TransferStage(int no, int w, int x, int y);
void ChangeMusic(MusicID no);
-void ReCallMusic();
+void ReCallMusic(void);
--- a/src/Star.cpp
+++ b/src/Star.cpp
@@ -27,12 +27,12 @@
RECT rect;
} star[3];
-void InitStar()
+void InitStar(void)
{
- //Clear stars
+ // Clear stars
memset(star, 0, sizeof(star));
- //Position
+ // Position
star[0].x = gMC.x;
star[0].y = gMC.y;
@@ -42,7 +42,7 @@
star[2].x = gMC.x;
star[2].y = gMC.y;
- //Speed
+ // Speed
star[0].xm = 0x400;
star[0].ym = -0x200;
@@ -53,15 +53,17 @@
star[2].ym = 0x200;
}
-void ActStar()
+void ActStar(void)
{
+ int i;
static int a;
- a++;
+
+ ++a;
a %= 3;
- for (int i = 0; i < 3; i++)
+ for (i = 0; i < 3; ++i)
{
- if (i)
+ if (i != 0)
{
if (star[i - 1].x < star[i].x)
star[i].xm -= 0x80;
@@ -117,6 +119,8 @@
void PutStar(int fx, int fy)
{
+ int i;
+
RECT rc[3] = {
{192, 0, 200, 8},
{192, 8, 200, 16},
@@ -126,12 +130,10 @@
if (gMC.cond & 2)
return;
- if ((gMC.equip & 0x80) == 0)
+ if (!(gMC.equip & 0x80))
return;
- for (int i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; ++i)
if (i < gMC.star)
- PutBitmap3(&grcGame, star[i].x / 0x200 - fx / 0x200 - 4, star[i].y / 0x200 - fy / 0x200 - 4, &rc[i], SURFACE_ID_MY_CHAR);
- }
+ PutBitmap3(&grcGame, (star[i].x / 0x200) - (fx / 0x200) - 4, (star[i].y / 0x200) - (fy / 0x200) - 4, &rc[i], SURFACE_ID_MY_CHAR);
}
--- a/src/Star.h
+++ b/src/Star.h
@@ -1,5 +1,5 @@
#pragma once
-void InitStar();
-void ActStar();
+void InitStar(void);
+void ActStar(void);
void PutStar(int fx, int fy);
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -33,12 +33,12 @@
#include "Stage.h"
#include "Tags.h"
-#define IS_COMMAND(c1, c2, c3) (gTS.data[gTS.p_read + 1] == (c1) && gTS.data[gTS.p_read + 2] == (c2) && gTS.data[gTS.p_read + 3] == (c3))
-
#define TSC_BUFFER_SIZE 0x5000
#define TEXT_LEFT (WINDOW_WIDTH / 2 - 108)
+#define IS_COMMAND(c1, c2, c3) (gTS.data[gTS.p_read + 1] == (c1) && gTS.data[gTS.p_read + 2] == (c2) && gTS.data[gTS.p_read + 3] == (c3))
+
TEXT_SCRIPT gTS;
int gNumberTextScript[4];
@@ -50,25 +50,27 @@
static unsigned long nod_color;
#endif
-//Initialize and end tsc
-BOOL InitTextScript2()
+// Initialize and end tsc
+BOOL InitTextScript2(void)
{
+ int i;
+
#ifdef FIX_BUGS
nod_color = GetCortBoxColor(RGB(0xFF, 0xFF, 0xFE));
#endif
- //Clear flags
+ // Clear flags
gTS.mode = 0;
- g_GameFlags &= ~0x04;
+ g_GameFlags &= ~4;
- //Create line surfaces
- for (int i = 0; i < 4; i++)
- MakeSurface_Generic(gRect_line.right, gRect_line.bottom, (SurfaceID)(i + SURFACE_ID_TEXT_LINE1), FALSE);
+ // Create line surfaces
+ for (i = 0; i < 4; ++i)
+ MakeSurface_Generic(gRect_line.right, gRect_line.bottom, (SurfaceID)(SURFACE_ID_TEXT_LINE1 + i), FALSE);
- //Clear text
+ // Clear text
memset(text, 0, sizeof(text));
- //Allocate script buffer
+ // Allocate script buffer
gTS.data = (char*)malloc(TSC_BUFFER_SIZE);
if (gTS.data == NULL)
@@ -77,44 +79,47 @@
return TRUE;
}
-void EndTextScript()
+void EndTextScript(void)
{
- //Free TSC buffer
+ int i;
+
+ // Free TSC buffer
free(gTS.data);
- //Release buffers
+ // Release buffers
ReleaseSurface(SURFACE_ID_TEXT_BOX);
- for (int i = 0; i < 4; i++)
- ReleaseSurface((SurfaceID)(i + SURFACE_ID_TEXT_LINE1));
+ for (i = 0; i < 4; ++i)
+ ReleaseSurface((SurfaceID)(SURFACE_ID_TEXT_LINE1 + i));
}
-//Decrypt .tsc
-void EncryptionBinaryData2(unsigned char *pData, int size)
+// Decrypt .tsc
+void EncryptionBinaryData2(unsigned char *pData, long size)
{
int val1;
int work;
int i;
+ int half;
- int half = size / 2;
+ half = size / 2;
if (pData[half] == 0)
val1 = -7;
else
- val1 = (pData[half] % 256) * -1;
+ val1 = (pData[half] % 0x100) * -1;
- for (i = 0; i < size; i++)
+ for (i = 0; i < size; ++i)
{
work = pData[i];
work += val1;
if (i != half)
- pData[i] = work % 256;
+ pData[i] = work % 0x100;
}
}
-//Load generic .tsc
+// Load generic .tsc
BOOL LoadTextScript2(const char *name)
{
- //Get path
+ // Get path
char path[260];
sprintf(path, "%s/%s", gDataPath, name);
@@ -122,28 +127,29 @@
if (gTS.size == -1)
return FALSE;
- //Open file
+ // Open file
FILE *fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
- //Read data
+ // Read data
fread(gTS.data, 1, gTS.size, fp);
gTS.data[gTS.size] = 0;
fclose(fp);
- //Set path
+ // Set path
strcpy(gTS.path, name);
- //Decrypt data
+ // Decrypt data
EncryptionBinaryData2((unsigned char*)gTS.data, gTS.size);
+
return TRUE;
}
-//Load stage .tsc
+// Load stage .tsc
BOOL LoadTextScript_Stage(const char *name)
{
- //Open Head.tsc
+ // Open Head.tsc
char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, "Head.tsc");
@@ -155,13 +161,13 @@
if (fp == NULL)
return FALSE;
- //Read Head.tsc
+ // Read Head.tsc
fread(gTS.data, 1, head_size, fp);
EncryptionBinaryData2((unsigned char*)gTS.data, head_size);
gTS.data[head_size] = 0;
fclose(fp);
- //Open stage's .tsc
+ // Open stage's .tsc
sprintf(path, "%s/%s", gDataPath, name);
long body_size = GetFileSizeLong(path);
@@ -172,25 +178,26 @@
if (fp == NULL)
return FALSE;
- //Read stage's tsc
+ // Read stage's tsc
fread(&gTS.data[head_size], 1, body_size, fp);
EncryptionBinaryData2((unsigned char*)&gTS.data[head_size], body_size);
gTS.data[head_size + body_size] = 0;
fclose(fp);
- //Set parameters
+ // Set parameters
gTS.size = head_size + body_size;
strcpy(gTS.path, name);
+
return TRUE;
}
-//Get current path
+// Get current path
void GetTextScriptPath(char *path)
{
strcpy(path, gTS.path);
}
-//Get 4 digit number from TSC data
+// Get 4 digit number from TSC data
int GetTextScriptNo(int a)
{
int b = 0;
@@ -201,10 +208,12 @@
return b;
}
-//Start TSC event
+// Start TSC event
BOOL StartTextScript(int no)
{
- //Reset state
+ //int i;
+
+ // Reset state
gTS.mode = 1;
g_GameFlags |= 5;
gTS.line = 0;
@@ -224,26 +233,26 @@
gTS.rcText.bottom = gTS.rcText.top + 48;
/* This is present in the Linux port, but not the Windows version (1.0.0.6, at least)
- //Clear text lines
- for (int i = 0; i < 4; i++)
+ // Clear text lines
+ for (i = 0; i < 4; ++i)
{
- gTS.ypos_line[i] = 16 * i;
- CortBox2(&gRect_line, 0x000000, (SurfaceID)(i + SURFACE_ID_TEXT_LINE1));
+ gTS.ypos_line[i] = i * 16;
+ CortBox2(&gRect_line, 0x000000, (SurfaceID)(SURFACE_ID_TEXT_LINE1 + i));
memset(text[i], 0, sizeof(text[0]));
}*/
- //Find where event starts
+ // Find where event starts
gTS.p_read = 0;
while (1)
{
- //Check if we are still in the proper range
+ // Check if we are still in the proper range
if (gTS.data[gTS.p_read] == '\0')
return FALSE;
- //Check if we are at an event
+ // Check if we are at an event
if (gTS.data[gTS.p_read] == '#')
{
- //Check if this is our event
+ // Check if this is our event
int event_no = GetTextScriptNo(++gTS.p_read);
if (no == event_no)
@@ -255,7 +264,7 @@
++gTS.p_read;
}
- //Advance until new-line
+ // Advance until new-line
while (gTS.data[gTS.p_read] != '\n')
++gTS.p_read;
++gTS.p_read;
@@ -265,34 +274,36 @@
BOOL JumpTextScript(int no)
{
- //Set state
+ int i;
+
+ // Set state
gTS.mode = 1;
- g_GameFlags |= 4u;
+ g_GameFlags |= 4;
gTS.line = 0;
gTS.p_write = 0;
gTS.wait = 4;
gTS.wait_beam = 0;
- //Clear text lines
- for (int i = 0; i < 4; i++)
+ // Clear text lines
+ for (i = 0; i < 4; ++i)
{
- gTS.ypos_line[i] = 16 * i;
- CortBox2(&gRect_line, 0x000000, (SurfaceID)(i + SURFACE_ID_TEXT_LINE1));
+ gTS.ypos_line[i] = i * 16;
+ CortBox2(&gRect_line, 0x000000, (SurfaceID)(SURFACE_ID_TEXT_LINE1 + i));
memset(text[i], 0, sizeof(text[0]));
}
- //Find where event starts
+ // Find where event starts
gTS.p_read = 0;
while(1)
{
- //Check if we are still in the proper range
+ // Check if we are still in the proper range
if (gTS.data[gTS.p_read] == '\0')
return FALSE;
- //Check if we are at an event
+ // Check if we are at an event
if (gTS.data[gTS.p_read] == '#')
{
- //Check if this is our event
+ // Check if this is our event
int event_no = GetTextScriptNo(++gTS.p_read);
if (no == event_no)
@@ -304,7 +315,7 @@
++gTS.p_read;
}
- //Advance until new-line
+ // Advance until new-line
while (gTS.data[gTS.p_read] != '\n')
++gTS.p_read;
++gTS.p_read;
@@ -312,10 +323,10 @@
return TRUE;
}
-//End event
-void StopTextScript()
+// End event
+void StopTextScript(void)
{
- //End TSC and reset flags
+ // End TSC and reset flags
gTS.mode = 0;
g_GameFlags &= ~4;
g_GameFlags |= 3;
@@ -322,19 +333,19 @@
gTS.flags = 0;
}
-//Prepare a new line
-void CheckNewLine()
+// Prepare a new line
+void CheckNewLine(void)
{
if (gTS.ypos_line[gTS.line % 4] == 48)
{
gTS.mode = 3;
g_GameFlags |= 4;
- CortBox2(&gRect_line, 0, (SurfaceID)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1));
+ CortBox2(&gRect_line, 0, (SurfaceID)(SURFACE_ID_TEXT_LINE1 + (gTS.line % 4)));
memset(text[gTS.line % 4], 0, sizeof(text[0]));
}
}
-//Type a number into the text buffer
+// Type a number into the text buffer
void SetNumberTextScript(int index)
{
int a;
@@ -344,25 +355,25 @@
int offset;
char str[5];
- //Get digit table
+ // Get digit table
int table[3];
table[0] = 1000;
table[1] = 100;
table[2] = 10;
- //Get number to print
+ // Get number to print
a = gNumberTextScript[index];
bZero = FALSE;
offset = 0;
- //Trim leading zeroes
- for (i = 0; i < 3; i++)
+ // Trim leading zeroes
+ for (i = 0; i < 3; ++i)
{
- if (a / table[i] || bZero != FALSE)
+ if (a / table[i] || bZero)
{
b = a / table[i];
- str[offset] = (char)b + '0';
+ str[offset] = '0' + (char)b;
bZero = TRUE;
a -= b * table[i];
++offset;
@@ -369,46 +380,48 @@
}
}
- //Set last digit of string, and add null terminator
- str[offset] = (char)a + '0';
- str[offset + 1] = 0;
+ // Set last digit of string, and add null terminator
+ str[offset] = '0' + (char)a;
+ str[offset + 1] = '\0';
- //Append number to line
- PutText2(6 * gTS.p_write, 0, str, RGB(0xFF, 0xFF, 0xFE), (SurfaceID)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1));
+ // Append number to line
+ PutText2(gTS.p_write * 6, 0, str, RGB(0xFF, 0xFF, 0xFE), (SurfaceID)(SURFACE_ID_TEXT_LINE1 + (gTS.line % 4)));
strcat(text[gTS.line % 4], str);
- //Play sound and reset blinking cursor
+ // Play sound and reset blinking cursor
PlaySoundObject(2, 1);
gTS.wait_beam = 0;
- //Check if should move to next line (prevent a memory overflow, come on guys, this isn't a leftover of pixel trying to make text wrapping)
- gTS.p_write += (unsigned int)strlen(str);
+ // Check if should move to next line (prevent a memory overflow, come on guys, this isn't a leftover of pixel trying to make text wrapping)
+ gTS.p_write += (int)strlen(str);
if (gTS.p_write >= 35)
{
gTS.p_write = 0;
- gTS.line++;
+ ++gTS.line;
CheckNewLine();
}
}
-//Clear text lines
-void ClearTextLine()
+// Clear text lines
+void ClearTextLine(void)
{
+ int i;
+
gTS.line = 0;
gTS.p_write = 0;
gTS.offsetY = 0;
- for (int i = 0; i < 4; i++)
+ for (i = 0; i < 4; ++i)
{
- gTS.ypos_line[i] = 16 * i;
- CortBox2(&gRect_line, 0x000000, (SurfaceID)(i + SURFACE_ID_TEXT_LINE1));
+ gTS.ypos_line[i] = i * 16;
+ CortBox2(&gRect_line, 0x000000, (SurfaceID)(SURFACE_ID_TEXT_LINE1 + i));
memset(text[i], 0, sizeof(text[0]));
}
}
-//Draw textbox and whatever else
-void PutTextScript()
+// Draw textbox and whatever else
+void PutTextScript(void)
{
RECT rcFace;
RECT rcItemBox1;
@@ -428,7 +441,7 @@
if ((gTS.flags & 1) == 0)
return;
- //Set textbox position
+ // Set textbox position
if (gTS.flags & 0x20)
{
gTS.rcText.top = 32;
@@ -440,7 +453,7 @@
gTS.rcText.bottom = gTS.rcText.top + 48;
}
- //Draw textbox
+ // Draw textbox
if (gTS.flags & 2)
{
RECT rcFrame1 = {0, 0, 244, 8};
@@ -448,14 +461,14 @@
RECT rcFrame3 = {0, 16, 244, 24};
PutBitmap3(&grcFull, WINDOW_WIDTH / 2 - 122, gTS.rcText.top - 10, &rcFrame1, SURFACE_ID_TEXT_BOX);
- for (i = 1; i < 7; i++)
- PutBitmap3(&grcFull, WINDOW_WIDTH / 2 - 122, 8 * i + gTS.rcText.top - 10, &rcFrame2, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcFull, WINDOW_WIDTH / 2 - 122, 8 * i + gTS.rcText.top - 10, &rcFrame3, SURFACE_ID_TEXT_BOX);
+ for (i = 1; i < 7; ++i)
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) - 122, (i * 8) + gTS.rcText.top - 10, &rcFrame2, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) - 122, (i * 8) + gTS.rcText.top - 10, &rcFrame3, SURFACE_ID_TEXT_BOX);
}
- //Draw face picture
- rcFace.left = 48 * (gTS.face % 6);
- rcFace.top = 48 * (gTS.face / 6);
+ // Draw face picture
+ rcFace.left = (gTS.face % 6) * 48;
+ rcFace.top = (gTS.face / 6) * 48;
rcFace.right = rcFace.left + 48;
rcFace.bottom = rcFace.top + 48;
@@ -471,19 +484,19 @@
PutBitmap3(&gTS.rcText, gTS.face_x / 0x200, gTS.rcText.top - 3, &rcFace, SURFACE_ID_FACE);
#endif
- //Draw text
- if (gTS.face)
+ // Draw text
+ if (gTS.face != 0)
text_offset = 56;
else
text_offset = 0;
- for (i = 0; i < 4; i++)
- PutBitmap3(&gTS.rcText, text_offset + TEXT_LEFT, gTS.offsetY + gTS.ypos_line[i] + gTS.rcText.top, &gRect_line, (SurfaceID)(i + SURFACE_ID_TEXT_LINE1));
+ for (i = 0; i < 4; ++i)
+ PutBitmap3(&gTS.rcText, TEXT_LEFT + text_offset, gTS.offsetY + gTS.ypos_line[i] + gTS.rcText.top, &gRect_line, (SurfaceID)(SURFACE_ID_TEXT_LINE1 + i));
- //Draw NOD cursor
+ // Draw NOD cursor
if ((gTS.wait_beam++ % 20 > 12) && gTS.mode == 2)
{
- rect.left = TEXT_LEFT + 6 * gTS.p_write + text_offset;
+ rect.left = TEXT_LEFT + (gTS.p_write * 6) + text_offset;
rect.top = gTS.ypos_line[gTS.line % 4] + gTS.rcText.top + gTS.offsetY;
rect.right = rect.left + 5;
rect.bottom = rect.top + 11;
@@ -494,7 +507,7 @@
// the way Pixel would do it (he only calls GetCortBoxColor
// once, during init functions, so our fix does it that way
// instead).
- //CortBox(&rect, GetCortBoxColor(RGB(0xFF, 0xFF, 0xFE));
+ // CortBox(&rect, GetCortBoxColor(RGB(0xFF, 0xFF, 0xFE));
#else
// This accidentally uses a BGR value directly, without
// running it though GetCortBoxColor first
@@ -502,7 +515,7 @@
#endif
}
- //Draw GIT
+ // Draw GIT
SET_RECT(rcItemBox1, 0, 0, 72, 16)
SET_RECT(rcItemBox2, 0, 8, 72, 24)
SET_RECT(rcItemBox3, 240, 0, 244, 8)
@@ -509,14 +522,14 @@
SET_RECT(rcItemBox4, 240, 8, 244, 16)
SET_RECT(rcItemBox5, 240, 16, 244, 24)
- if (gTS.item)
+ if (gTS.item != 0)
{
- PutBitmap3(&grcFull, (WINDOW_WIDTH - 80) / 2, WINDOW_HEIGHT - 112, &rcItemBox1, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcFull, (WINDOW_WIDTH - 80) / 2, WINDOW_HEIGHT - 96, &rcItemBox2, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 112, &rcItemBox3, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 104, &rcItemBox4, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 96, &rcItemBox4, SURFACE_ID_TEXT_BOX);
- PutBitmap3(&grcFull, (WINDOW_WIDTH + 64) / 2, WINDOW_HEIGHT - 88, &rcItemBox5, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) - 40, WINDOW_HEIGHT - 112, &rcItemBox1, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) - 40, WINDOW_HEIGHT - 96, &rcItemBox2, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) + 32, WINDOW_HEIGHT - 112, &rcItemBox3, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) + 32, WINDOW_HEIGHT - 104, &rcItemBox4, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) + 32, WINDOW_HEIGHT - 96, &rcItemBox4, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) + 32, WINDOW_HEIGHT - 88, &rcItemBox5, SURFACE_ID_TEXT_BOX);
if (gTS.item_y < WINDOW_HEIGHT - 104)
++gTS.item_y;
@@ -523,11 +536,11 @@
if (gTS.item < 1000)
{
- rect.left = 16 * (gTS.item % 16);
+ rect.left = (gTS.item % 16) * 16;
rect.right = rect.left + 16;
- rect.top = 16 * (gTS.item / 16);
+ rect.top = (gTS.item / 16) * 16;
rect.bottom = rect.top + 16;
- PutBitmap3(&grcFull, (WINDOW_WIDTH - 24) / 2, gTS.item_y, &rect, SURFACE_ID_ARMS_IMAGE);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) - 12, gTS.item_y, &rect, SURFACE_ID_ARMS_IMAGE);
}
else
{
@@ -535,11 +548,11 @@
rect.right = rect.left + 32;
rect.top = 16 * ((gTS.item - 1000) / 8);
rect.bottom = rect.top + 16;
- PutBitmap3(&grcFull, (WINDOW_WIDTH - 40) / 2, gTS.item_y, &rect, SURFACE_ID_ITEM_IMAGE);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) - 20, gTS.item_y, &rect, SURFACE_ID_ITEM_IMAGE);
}
}
- //Draw Yes / No selection
+ // Draw Yes / No selection
SET_RECT(rect_yesno, 152, 48, 244, 80)
SET_RECT(rect_cur, 112, 88, 128, 104)
@@ -550,14 +563,14 @@
else
i = WINDOW_HEIGHT - 96;
- PutBitmap3(&grcFull, (WINDOW_WIDTH + 112) / 2, i, &rect_yesno, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcFull, (WINDOW_WIDTH / 2) + 56, i, &rect_yesno, SURFACE_ID_TEXT_BOX);
if (gTS.wait == 16)
- PutBitmap3(&grcFull, 41 * gTS.select + (WINDOW_WIDTH + 102) / 2, WINDOW_HEIGHT - 86, &rect_cur, SURFACE_ID_TEXT_BOX);
+ PutBitmap3(&grcFull, (gTS.select * 41) + (WINDOW_WIDTH / 2) + 51, WINDOW_HEIGHT - 86, &rect_cur, SURFACE_ID_TEXT_BOX);
}
}
-//Parse TSC
-int TextScriptProc()
+// Parse TSC
+int TextScriptProc(void)
{
BOOL bExit;
char c[3];
@@ -569,11 +582,11 @@
switch (gTS.mode)
{
- case 1: //PARSE
- //Type out (faster if ok or cancel are held)
+ case 1: // PARSE
+ // Type out (faster if ok or cancel are held)
++gTS.wait;
- if (!(g_GameFlags & 2) && (gKeyCancel | gKeyOk) & gKey)
+ if (!(g_GameFlags & 2) && gKey & (gKeyOk | gKeyCancel))
gTS.wait += 4;
if (gTS.wait < 4)
@@ -581,10 +594,10 @@
gTS.wait = 0;
- //Parsing time
+ // Parsing time
bExit = FALSE;
- while (bExit == FALSE)
+ while (!bExit)
{
if (gTS.data[gTS.p_read] == '<')
{
@@ -702,6 +715,7 @@
w = GetTextScriptNo(gTS.p_read + 9);
x = GetTextScriptNo(gTS.p_read + 14);
y = GetTextScriptNo(gTS.p_read + 19);
+
if (!TransferStage(z, w, x, y))
{
#ifdef JAPANESE
@@ -1114,7 +1128,7 @@
x = GetTextScriptNo(gTS.p_read + 9);
y = GetTextScriptNo(gTS.p_read + 14);
z = GetTextScriptNo(gTS.p_read + 19);
- SetNpChar(w, x * 0x200 * 0x10, y * 0x200 * 0x10, 0, 0, z, 0, 0x100);
+ SetNpChar(w, x * 0x200 * 0x10, y * 0x200 * 0x10, 0, 0, z, NULL, 0x100);
gTS.p_read += 23;
}
else if (IS_COMMAND('M','N','P'))
@@ -1145,7 +1159,7 @@
{
z = GetTextScriptNo(gTS.p_read + 4);
- if (z)
+ if (z != 0)
StartBossLife(z);
else
StartBossLife2();
@@ -1187,7 +1201,7 @@
else if (IS_COMMAND('F','A','C'))
{
z = GetTextScriptNo(gTS.p_read + 4);
- if (gTS.face != (signed char)z)
+ if (gTS.face != (signed char)z) // Not sure why these casts are here, but they're needed for the same assembly code to be produced
{
gTS.face = (signed char)z;
gTS.face_x = (WINDOW_WIDTH / 2 - 156) * 0x200;
@@ -1272,7 +1286,7 @@
{
if (gTS.data[gTS.p_read] == '\r')
{
- //Go to new-line
+ // Go to new-line
gTS.p_read += 2;
gTS.p_write = 0;
@@ -1284,12 +1298,12 @@
}
else if (gTS.flags & 0x10)
{
- //SAT/CAT/TUR printing
+ // SAT/CAT/TUR printing
x = gTS.p_read;
- //Break if reaches command, or new-line
+ // Break if reaches command, or new-line
while (gTS.data[x] != '<' && gTS.data[x] != '\r')
{
- //Skip if SHIFT-JIS
+ // Skip if SHIFT-JIS
if (gTS.data[x] & 0x80)
++x;
@@ -1296,22 +1310,22 @@
++x;
}
- //Get text to copy
+ // Get text to copy
y = x - gTS.p_read;
memcpy(str, &gTS.data[gTS.p_read], y);
- str[y] = 0;
+ str[y] = '\0';
gTS.p_write = x;
- //Print text
- PutText2(0, 0, str, RGB(0xFF, 0xFF, 0xFE), (SurfaceID)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1));
+ // Print text
+ PutText2(0, 0, str, RGB(0xFF, 0xFF, 0xFE), (SurfaceID)(SURFACE_ID_TEXT_LINE1 + (gTS.line % 4)));
#ifdef FIX_BUGS
strcpy(text[gTS.line % 4], str);
#else
- sprintf(text[gTS.line % 4], str); // No point to using an sprintf here, and it makes Clang mad
+ sprintf(text[gTS.line % 4], str); // No point in using an sprintf here, and it makes Clang mad
#endif
- //Check if should move to next line (prevent a memory overflow, come on guys, this isn't a leftover of pixel trying to make text wrapping)
+ // Check if should move to next line (prevent a memory overflow, come on guys, this isn't a leftover of pixel trying to make text wrapping)
gTS.p_read += y;
if (gTS.p_write >= 35)
@@ -1321,7 +1335,7 @@
}
else
{
- //Get text to print
+ // Get text to print
c[0] = gTS.data[gTS.p_read];
if (c[0] & 0x80)
@@ -1334,14 +1348,14 @@
c[1] = '\0';
}
- //Print text
+ // Print text
if (c[0] == '=')
{
- Surface2Surface(6 * gTS.p_write, 2, &rcSymbol, (SurfaceID)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1), SURFACE_ID_TEXT_BOX);
+ Surface2Surface(gTS.p_write * 6, 2, &rcSymbol, (SurfaceID)(SURFACE_ID_TEXT_LINE1 + (gTS.line % 4)), SURFACE_ID_TEXT_BOX);
}
else
{
- PutText2(6 * gTS.p_write, 0, c, RGB(0xFF, 0xFF, 0xFE), (SurfaceID)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1));
+ PutText2(gTS.p_write * 6, 0, c, RGB(0xFF, 0xFF, 0xFE), (SurfaceID)(SURFACE_ID_TEXT_LINE1 + (gTS.line % 4)));
}
strcat(text[gTS.line % 4], c);
@@ -1348,7 +1362,7 @@
PlaySoundObject(2, 1);
gTS.wait_beam = 0;
- //Offset read and write positions
+ // Offset read and write positions
if (c[0] & 0x80)
{
gTS.p_read += 2;
@@ -1356,8 +1370,8 @@
}
else
{
- gTS.p_read++;
- gTS.p_write++;
+ gTS.p_read += 1;
+ gTS.p_write += 1;
}
if (gTS.p_write >= 35)
@@ -1374,17 +1388,17 @@
}
break;
- case 2: //NOD
- if ((gKeyCancel | gKeyOk) & gKeyTrg)
+ case 2: // NOD
+ if (gKeyTrg & (gKeyOk | gKeyCancel))
gTS.mode = 1;
break;
- case 3: //NEW LINE
- for (i = 0; i < 4; i++)
+ case 3: // NEW LINE
+ for (i = 0; i < 4; ++i)
{
gTS.ypos_line[i] -= 4;
- if (!gTS.ypos_line[i])
+ if (gTS.ypos_line[i] == 0)
gTS.mode = 1;
if (gTS.ypos_line[i] == -16)
@@ -1392,7 +1406,7 @@
}
break;
- case 4: //WAI
+ case 4: // WAI
if (gTS.wait_next == 9999)
break;
@@ -1406,7 +1420,7 @@
gTS.wait_beam = 0;
break;
- case 5: //FAI/FAO
+ case 5: // FAI/FAO
if (GetFadeActive())
break;
@@ -1413,21 +1427,23 @@
gTS.mode = 1;
gTS.wait_beam = 0;
break;
- case 7: //WAS
+
+ case 7: // WAS
if ((gMC.flag & 8) == 0)
- break;
+ break;
gTS.mode = 1;
gTS.wait_beam = 0;
break;
- case 6: //YNJ
+
+ case 6: // YNJ
if (gTS.wait < 16)
{
- gTS.wait++;
+ ++gTS.wait;
}
else
{
- //Select option
+ // Select option
if (gKeyTrg & gKeyOk)
{
PlaySoundObject(18, 1);
@@ -1442,13 +1458,13 @@
gTS.wait_beam = 0;
}
}
- //Yes
+ // Yes
else if (gKeyTrg & gKeyLeft)
{
gTS.select = 0;
PlaySoundObject(1, 1);
}
- //No
+ // No
else if (gKeyTrg & gKeyRight)
{
gTS.select = 1;
@@ -1462,14 +1478,17 @@
g_GameFlags &= ~4;
else
g_GameFlags |= 4;
+
return 1;
}
-void RestoreTextScript()
+void RestoreTextScript(void)
{
- for (int i = 0; i < 4; ++i)
+ int i;
+
+ for (i = 0; i < 4; ++i)
{
- CortBox2(&gRect_line, 0x000000, (SurfaceID)(i + SURFACE_ID_TEXT_LINE1));
- PutText2(0, 0, text[i], RGB(0xFF, 0xFF, 0xFE), (SurfaceID)(i + SURFACE_ID_TEXT_LINE1));
+ CortBox2(&gRect_line, 0x000000, (SurfaceID)(SURFACE_ID_TEXT_LINE1 + i));
+ PutText2(0, 0, text[i], RGB(0xFF, 0xFF, 0xFE), (SurfaceID)(SURFACE_ID_TEXT_LINE1 + i));
}
}
--- a/src/TextScr.h
+++ b/src/TextScr.h
@@ -4,63 +4,63 @@
struct TEXT_SCRIPT
{
- //Path (reload when exit teleporter menu/inventory)
+ // Path (reload when exit teleporter menu/inventory)
char path[MAX_PATH];
- //Script buffer
- int size;
+ // Script buffer
+ long size;
char *data;
- //Mode (ex. NOD, WAI)
+ // Mode (ex. NOD, WAI)
signed char mode;
- //Flags
+ // Flags
signed char flags;
- //Current positions (read position in buffer, x position in line)
- unsigned int p_read;
+ // Current positions (read position in buffer, x position in line)
+ int p_read;
int p_write;
- //Current line to write to
+ // Current line to write to
int line;
- //Line y positions
+ // Line y positions
int ypos_line[4];
- //Event stuff
+ // Event stuff
int wait;
int wait_next;
int next_event;
- //Yes/no selected
+ // Yes/no selected
signed char select;
- //Current face
+ // Current face
int face;
int face_x;
- //Current item
+ // Current item
int item;
int item_y;
- //Text rect
+ // Text rect
RECT rcText;
- //..?
+ // ..?
int offsetY;
- //NOD cursor blink
+ // NOD cursor blink
unsigned char wait_beam;
};
-BOOL InitTextScript2();
-void EndTextScript();
-void EncryptionBinaryData2(unsigned char *pData, int size);
+BOOL InitTextScript2(void);
+void EndTextScript(void);
+void EncryptionBinaryData2(unsigned char *pData, long size);
BOOL LoadTextScript2(const char *name);
BOOL LoadTextScript_Stage(const char *name);
void GetTextScriptPath(char *path);
BOOL StartTextScript(int no);
-void StopTextScript();
-void PutTextScript();
-int TextScriptProc();
-void RestoreTextScript();
+void StopTextScript(void);
+void PutTextScript(void);
+int TextScriptProc(void);
+void RestoreTextScript(void);
--- a/src/Triangle.cpp
+++ b/src/Triangle.cpp
@@ -5,19 +5,19 @@
int gSin[0x100];
short gTan[0x21];
-void InitTriangleTable()
+void InitTriangleTable(void)
{
int i;
float a;
float b;
- //Sine
+ // Sine
for (i = 0; i < 0x100; ++i)
{
gSin[i] = (int)(sin(i * 6.2831998 / 256.0) * 512.0);
}
- //Tangent
+ // Tangent
for (i = 0; i < 0x21; ++i)
{
a = (float)(i * 6.2831855f / 256.0f);
@@ -39,10 +39,13 @@
unsigned char GetArktan(int x, int y)
{
+ unsigned char a;
+ short k;
+
x *= -1;
y *= -1;
- unsigned char a = 0;
- short k;
+
+ a = 0;
if (x > 0)
{
--- a/src/Triangle.h
+++ b/src/Triangle.h
@@ -1,6 +1,6 @@
#pragma once
-void InitTriangleTable();
+void InitTriangleTable(void);
int GetSin(unsigned char deg);
int GetCos(unsigned char deg);
unsigned char GetArktan(int x, int y);
--- a/src/ValueView.cpp
+++ b/src/ValueView.cpp
@@ -6,10 +6,11 @@
#include "ValueView.h"
#define VALUEVIEW_MAX 0x10
+
VALUEVIEW gVV[VALUEVIEW_MAX];
int gVVIndex;
-void ClearValueView()
+void ClearValueView(void)
{
memset(gVV, 0, sizeof(gVV));
gVVIndex = 0;
@@ -26,7 +27,7 @@
BOOL sw;
int i;
- for (i = 0; i < VALUEVIEW_MAX; i++)
+ for (i = 0; i < VALUEVIEW_MAX; ++i)
{
if (gVV[i].flag && gVV[i].px == px)
{
@@ -41,8 +42,10 @@
if (i == VALUEVIEW_MAX)
{
index = gVVIndex++;
+
if (gVVIndex == VALUEVIEW_MAX)
gVVIndex = 0;
+
gVV[index].count = 0;
gVV[index].offset_y = 0;
gVV[index].value = value;
@@ -50,12 +53,13 @@
else
{
index = i;
- gVV[i].count = 32;
+
+ gVV[index].count = 32;
gVV[index].value += value;
value = gVV[index].value;
}
- //Get if negative or not
+ // Get if negative or not
if (value < 0)
{
value *= -1;
@@ -66,7 +70,7 @@
minus = FALSE;
}
- //Get width
+ // Get width
v = value;
if (value > 999)
@@ -78,7 +82,7 @@
else
width = 16;
- //Set properties
+ // Set properties
gVV[index].flag = TRUE;
gVV[index].px = px;
gVV[index].py = py;
@@ -110,15 +114,16 @@
{72, 64, 80, 72},
};
- //Get digits
+ // Get digits
dig[0] = 1;
dig[1] = 10;
dig[2] = 100;
dig[3] = 1000;
- for (i = 3; i >= 0; i--)
+ for (i = 3; i >= 0; --i)
{
fig[i] = 0;
+
while (v >= dig[i])
{
v -= dig[i];
@@ -131,7 +136,7 @@
RECT rcPlus = {32, 48, 40, 56};
RECT rcMinus = {40, 48, 48, 56};
- //Draw value
+ // Draw value
CortBox2(&gVV[index].rect, 0x000000, SURFACE_ID_VALUE_VIEW);
if (minus)
@@ -141,7 +146,7 @@
for (i = 3; i >= 0; i--)
{
- if (sw == FALSE && i != 0 && fig[i] == 0)
+ if (!sw && i != 0 && fig[i] == 0)
continue;
sw = TRUE;
@@ -149,13 +154,15 @@
if (minus)
fig[i] += 10;
- Surface2Surface((3 - i) * 8 + 8, gVV[index].rect.top, &rect[fig[i]], 29, 26);
+ Surface2Surface(((3 - i) * 8) + 8, gVV[index].rect.top, &rect[fig[i]], SURFACE_ID_VALUE_VIEW, SURFACE_ID_TEXT_BOX);
}
}
-void ActValueView()
+void ActValueView(void)
{
- for (int v = 0; v < VALUEVIEW_MAX; v++)
+ int v;
+
+ for (v = 0; v < VALUEVIEW_MAX; ++v)
{
if (gVV[v].flag == FALSE)
continue;
@@ -176,7 +183,7 @@
int v;
int offset_x;
- for (v = 0; v < VALUEVIEW_MAX; v++)
+ for (v = 0; v < VALUEVIEW_MAX; ++v)
{
if (gVV[v].flag == FALSE)
continue;
@@ -185,8 +192,8 @@
PutBitmap3(
&grcGame,
- (*gVV[v].px) / 0x200 - offset_x - flx / 0x200,
- (*gVV[v].py) / 0x200 + gVV[v].offset_y / 0x200 - 4 - fly / 0x200,
+ (*gVV[v].px / 0x200) - offset_x - (flx / 0x200),
+ (*gVV[v].py / 0x200) + (gVV[v].offset_y / 0x200) - 4 - (fly / 0x200),
&gVV[v].rect,
SURFACE_ID_VALUE_VIEW);
}
--- a/src/ValueView.h
+++ b/src/ValueView.h
@@ -13,7 +13,7 @@
RECT rect;
};
-void ClearValueView();
+void ClearValueView(void);
void SetValueView(int *px, int *py, int value);
-void ActValueView();
+void ActValueView(void);
void PutValueView(int flx, int fly);
--
⑨