From 6fd6a416cde2aaf8a62480cf83748dbdecd4762f Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 15 Jul 2020 16:35:05 +0100 Subject: [PATCH 01/18] Fix another out-of-bounds array access This one involves the Spur. --- src/Bullet.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Bullet.cpp b/src/Bullet.cpp index 68a369ea..0850735f 100644 --- a/src/Bullet.cpp +++ b/src/Bullet.cpp @@ -2179,7 +2179,12 @@ void ActBullet_SpurTail(BULLET *bul, int level) bul->ani_no = bul->count1 - 20; if (bul->ani_no > 2) + { bul->cond = 0; + #ifdef FIX_BUGS + return; // Avoid accessing the RECT arrays with an out-of-bounds index + #endif + } if (bul->damage && bul->life != 100) bul->damage = 0; From ea9952c2d0ca432566410d8bd806b906e02f1e93 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 8 Jul 2020 21:46:14 +0100 Subject: [PATCH 02/18] Clean-up PixTone code a little This is still ASM-accurate --- src/PixTone.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PixTone.cpp b/src/PixTone.cpp index b069c2c0..3dad3604 100644 --- a/src/PixTone.cpp +++ b/src/PixTone.cpp @@ -154,12 +154,12 @@ BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData) + 128; if (gWaveModelTable[ptp->oPitch.model][b] < 0) - dMain = d1 - d1 * 0.5 * -gWaveModelTable[ptp->oPitch.model][b] * ptp->oPitch.top / 64.0 / 64.0 + dMain; + dMain += d1 - d1 * 0.5 * -gWaveModelTable[ptp->oPitch.model][b] * ptp->oPitch.top / 64.0 / 64.0; else - dMain = d1 + d1 * 2.0 * gWaveModelTable[ptp->oPitch.model][b] * ptp->oPitch.top / 64.0 / 64.0 + dMain; + dMain += d1 + d1 * 2.0 * gWaveModelTable[ptp->oPitch.model][b] * ptp->oPitch.top / 64.0 / 64.0; - dPitch = dPitch + d2; - dVolume = dVolume + d3; + dPitch += d2; + dVolume += d3; } return TRUE; From 6a1d49d6b17175dd09699f03e9a61086f6dcb028 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 8 Jul 2020 21:46:30 +0100 Subject: [PATCH 03/18] Fix sound enum typo --- src/BossFrog.cpp | 2 +- src/Sound.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BossFrog.cpp b/src/BossFrog.cpp index 318c7ce7..c7c5b157 100644 --- a/src/BossFrog.cpp +++ b/src/BossFrog.cpp @@ -385,7 +385,7 @@ void ActBossChar_Frog(void) else SetNpChar(NPC_PROJECTILE_BALFROG_SPITBALL, boss->x + 2 * (0x200 * 0x10), boss->y - 8 * 0x200, xm, ym, DIR_LEFT, NULL, 0x100); - PlaySoundObject(SND_ENEMY_SHOOT_PROJETILE, SOUND_MODE_PLAY); + PlaySoundObject(SND_ENEMY_SHOOT_PROJECTILE, SOUND_MODE_PLAY); if (boss->count1 == 0 || boss->life < boss->tgt_x - 90) { diff --git a/src/Sound.h b/src/Sound.h index e0157701..bd018394 100644 --- a/src/Sound.h +++ b/src/Sound.h @@ -22,7 +22,7 @@ enum SoundEffectNames SND_SILLY_EXPLOSION = 25, SND_LARGE_OBJECT_HIT_GROUND = 26, // To be continued - SND_ENEMY_SHOOT_PROJETILE = 39, + SND_ENEMY_SHOOT_PROJECTILE = 39, // To be continued SND_BEHEMOTH_LARGE_HURT = 52, // To be continued From 98c2a8880e96486c58aa5c85616f9dba7ef7400c Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 8 Jul 2020 21:48:28 +0100 Subject: [PATCH 04/18] Convert NPC 0's rects to decimal --- src/NpcAct000.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 72c45a14..95660a27 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -17,7 +17,7 @@ // Null void ActNpc000(NPCHAR *npc) { - RECT rect = {0x00, 0x00, 0x10, 0x10}; + RECT rect = {0, 0, 16, 16}; if (npc->act_no == 0) { From b016b22a1e8fc341e0786869ceb5f99ea9cbf258 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 8 Jul 2020 22:57:59 +0100 Subject: [PATCH 05/18] Do some NPC documentation --- src/NpcAct000.cpp | 88 ++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 95660a27..bddce69c 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -144,12 +144,12 @@ void ActNpc001(NPCHAR *npc) // Get framerects RECT rect[6] = { - {0x00, 0x10, 0x10, 0x20}, - {0x10, 0x10, 0x20, 0x20}, - {0x20, 0x10, 0x30, 0x20}, - {0x30, 0x10, 0x40, 0x20}, - {0x40, 0x10, 0x50, 0x20}, - {0x50, 0x10, 0x60, 0x20}, + { 0, 16, 16, 32}, + {16, 16, 32, 32}, + {32, 16, 48, 32}, + {48, 16, 64, 32}, + {64, 16, 80, 32}, + {80, 16, 96, 32}, }; RECT rcNo = {0, 0, 0, 0}; @@ -214,21 +214,21 @@ void ActNpc002(NPCHAR *npc) { // Rects RECT rcLeft[7] = { - {32, 0, 64, 24}, - {0, 0, 32, 24}, - {32, 0, 64, 24}, - {64, 0, 96, 24}, - {96, 0, 128, 24}, + { 32, 0, 64, 24}, + { 0, 0, 32, 24}, + { 32, 0, 64, 24}, + { 64, 0, 96, 24}, + { 96, 0, 128, 24}, {128, 0, 160, 24}, {160, 0, 192, 24}, }; RECT rcRight[7] = { - {32, 24, 64, 48}, - {0, 24, 32, 48}, - {32, 24, 64, 48}, - {64, 24, 96, 48}, - {96, 24, 128, 48}, + { 32, 24, 64, 48}, + { 0, 24, 32, 48}, + { 32, 24, 64, 48}, + { 64, 24, 96, 48}, + { 96, 24, 128, 48}, {128, 24, 160, 48}, {160, 24, 192, 48}, }; @@ -346,20 +346,20 @@ void ActNpc003(NPCHAR *npc) void ActNpc004(NPCHAR *npc) { RECT rcLeft[8] = { - {16, 0, 17, 1}, - {16, 0, 32, 16}, - {32, 0, 48, 16}, - {48, 0, 64, 16}, - {64, 0, 80, 16}, - {80, 0, 96, 16}, - {96, 0, 112, 16}, + { 16, 0, 17, 1}, + { 16, 0, 32, 16}, + { 32, 0, 48, 16}, + { 48, 0, 64, 16}, + { 64, 0, 80, 16}, + { 80, 0, 96, 16}, + { 96, 0, 112, 16}, {112, 0, 128, 16}, }; RECT rcUp[8] = { - {16, 0, 17, 1}, - {80, 48, 96, 64}, - {0, 128, 16, 144}, + {16, 0, 17, 1}, + {80, 48, 96, 64}, + { 0, 128, 16, 144}, {16, 128, 32, 144}, {32, 128, 48, 144}, {48, 128, 64, 144}, @@ -423,13 +423,13 @@ void ActNpc004(NPCHAR *npc) void ActNpc005(NPCHAR *npc) { RECT rcLeft[3] = { - {0, 48, 16, 64}, + { 0, 48, 16, 64}, {16, 48, 32, 64}, {32, 48, 48, 64}, }; RECT rcRight[3] = { - {0, 64, 16, 80}, + { 0, 64, 16, 80}, {16, 64, 32, 80}, {32, 64, 48, 80}, }; @@ -532,7 +532,7 @@ void ActNpc005(NPCHAR *npc) void ActNpc006(NPCHAR *npc) { RECT rcLeft[5] = { - {0, 80, 16, 96}, + { 0, 80, 16, 96}, {16, 80, 32, 96}, {32, 80, 48, 96}, {48, 80, 64, 96}, @@ -540,7 +540,7 @@ void ActNpc006(NPCHAR *npc) }; RECT rcRight[5] = { - {0, 96, 16, 112}, + { 0, 96, 16, 112}, {16, 96, 32, 112}, {32, 96, 48, 112}, {48, 96, 64, 112}, @@ -656,21 +656,21 @@ void ActNpc006(NPCHAR *npc) void ActNpc007(NPCHAR *npc) { RECT rcLeft[3] = { - {256, 64, 288, 80}, - {256, 80, 288, 96}, + {256, 64, 288, 80}, + {256, 80, 288, 96}, {256, 96, 288, 112}, }; RECT rcRight[3] = { - {288, 64, 320, 80}, - {288, 80, 320, 96}, + {288, 64, 320, 80}, + {288, 80, 320, 96}, {288, 96, 320, 112}, }; switch (npc->act_no) { case 0: - npc->x = gMC.x; + npc->x = gMC.x; // Spawn beneath player if (npc->direct == 0) npc->act_no = 1; @@ -679,12 +679,14 @@ void ActNpc007(NPCHAR *npc) break; - case 1: + case 1: // Going left npc->xm -= 0x40; + // Turn around if far enough away from the player if (npc->x < gMC.x - (192 * 0x200)) npc->act_no = 2; + // Turn around if touching a wall if (npc->flag & 1) { npc->xm = 0; @@ -693,12 +695,14 @@ void ActNpc007(NPCHAR *npc) break; - case 2: + case 2: // Going right npc->xm += 0x40; + // Turn around if far enough away from the player if (npc->x > gMC.x + (192 * 0x200)) npc->act_no = 1; + // Turn around if touching a wall if (npc->flag & 4) { npc->xm = 0; @@ -708,27 +712,33 @@ void ActNpc007(NPCHAR *npc) break; } + // Face direction Bazil is moving if (npc->xm < 0) npc->direct = 0; else npc->direct = 2; + // Cap speed if (npc->xm > 0x5FF) npc->xm = 0x5FF; if (npc->xm < -0x5FF) npc->xm = -0x5FF; + // Apply momentum npc->x += npc->xm; + // Increment animation if (++npc->ani_wait > 1) { npc->ani_wait = 0; ++npc->ani_no; } + // Loop animation if (npc->ani_no > 2) npc->ani_no = 0; + // Update sprite if (npc->direct == 0) npc->rect = rcLeft[npc->ani_no]; else @@ -739,12 +749,12 @@ void ActNpc007(NPCHAR *npc) void ActNpc008(NPCHAR *npc) { RECT rcLeft[2] = { - {80, 80, 96, 96}, + {80, 80, 96, 96}, {96, 80, 112, 96}, }; RECT rcRight[2] = { - {80, 96, 96, 112}, + {80, 96, 96, 112}, {96, 96, 112, 112}, }; From a18be9c450ad1ed61b396c0026310284580bc0da Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 5 Aug 2020 19:30:13 +0100 Subject: [PATCH 06/18] Document background stuff a little more --- src/Back.cpp | 37 +++++++++++++++++++------------------ src/Back.h | 14 +++++++++++++- src/NpcAct000.cpp | 2 +- src/NpcAct080.cpp | 4 ++-- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/Back.cpp b/src/Back.cpp index c01a448a..a7729569 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -16,10 +16,9 @@ static unsigned long color_black; // TODO - Another function that has an incorrect stack frame BOOL InitBack(const char *fName, int type) { - // Unused - color_black = GetCortBoxColor(RGB(0, 0, 0x10)); + color_black = GetCortBoxColor(RGB(0, 0, 0x10)); // Unused. This may have once been used by background type 4 (the solid black background) - // Get width and height + // We're not actually loading the bitmap here - we're just reading its width/height and making sure it's really a BMP file char path[MAX_PATH]; sprintf(path, "%s\\%s.pbm", gDataPath, fName); @@ -27,15 +26,15 @@ BOOL InitBack(const char *fName, int type) if (fp == NULL) return FALSE; - // This is ridiculously platform-dependant: + // This code is ridiculously platform-dependant: // It should break on big-endian CPUs, and platforms where short isn't 16-bit and long isn't 32-bit. - unsigned short bmp_header_buffer[7]; // These names aren't the original. This ruins the stack frame layout. + unsigned short bmp_header_buffer[7]; // The original names for these variables are unknown. This ruins the stack frame layout. unsigned long bmp_header_buffer2[10]; fread(bmp_header_buffer, 14, 1, fp); // Check if this is a valid bitmap file - if (bmp_header_buffer[0] != 0x4D42) // 'MB' (we use hex to prevent a compiler warning) + if (bmp_header_buffer[0] != 0x4D42) // 'MB' (we use hex here to prevent a compiler warning) { #ifdef FIX_BUGS // The original game forgets to close fp @@ -47,11 +46,13 @@ BOOL InitBack(const char *fName, int type) fread(bmp_header_buffer2, 40, 1, fp); fclose(fp); + // Get bitmap width and height gBack.partsW = bmp_header_buffer2[1]; gBack.partsH = bmp_header_buffer2[2]; - // Set background stuff and load texture - gBack.flag = TRUE; + gBack.flag = TRUE; // This variable is otherwise unused + + // *Now* we actually load the bitmap if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND)) return FALSE; @@ -64,12 +65,12 @@ void ActBack(void) { switch (gBack.type) { - case 5: + case BACKGROUND_TYPE_AUTOSCROLL: gBack.fx += 6 * 0x200; break; - case 6: - case 7: + case BACKGROUND_TYPE_OUTSIDE_WITH_WIND: + case BACKGROUND_TYPE_OUTSIDE: ++gBack.fx; gBack.fx %= 640; break; @@ -83,36 +84,36 @@ void PutBack(int fx, int fy) switch (gBack.type) { - case 0: + case BACKGROUND_TYPE_STATIONARY: for (y = 0; y < WINDOW_HEIGHT; y += gBack.partsH) for (x = 0; x < WINDOW_WIDTH; x += gBack.partsW) PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND); break; - case 1: + case BACKGROUND_TYPE_MOVE_DISTANT: 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: + case BACKGROUND_TYPE_MOVE_NEAR: 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; - case 5: + case BACKGROUND_TYPE_AUTOSCROLL: for (y = -gBack.partsH; y < WINDOW_HEIGHT; y += gBack.partsH) for (x = -((gBack.fx / 0x200) % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW) PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND); break; - case 6: - case 7: + case BACKGROUND_TYPE_OUTSIDE_WITH_WIND: + case BACKGROUND_TYPE_OUTSIDE: rect.top = 0; rect.bottom = 88; rect.left = 0; @@ -171,7 +172,7 @@ void PutFront(int fx, int fy) switch (gBack.type) { - case 3: + case BACKGROUND_TYPE_WATER: x_1 = fx / (32 * 0x200); x_2 = x_1 + (((WINDOW_WIDTH + (32 - 1)) / 32) + 1); y_1 = 0; diff --git a/src/Back.h b/src/Back.h index f10ccb0b..68ff03e8 100644 --- a/src/Back.h +++ b/src/Back.h @@ -2,9 +2,21 @@ #include "WindowsWrapper.h" +enum +{ + BACKGROUND_TYPE_STATIONARY = 0, // Doesn't move at all + BACKGROUND_TYPE_MOVE_DISTANT = 1, // Moves at half the speed of the foreground + BACKGROUND_TYPE_MOVE_NEAR = 2, // Moves at the same speed as the foreground + BACKGROUND_TYPE_WATER = 3, // No background - draws a water foreground layer instead + BACKGROUND_TYPE_BLACK = 4, // No background - just black + BACKGROUND_TYPE_AUTOSCROLL = 5, // Constantly scrolls to the left (used by Ironhead) + BACKGROUND_TYPE_OUTSIDE_WITH_WIND = 6, // Fancy parallax scrolling, items are blown to the left (used by bkMoon) + BACKGROUND_TYPE_OUTSIDE = 7, // Fancy parallax scrolling (used by bkFog) +}; + typedef struct BACK { - BOOL flag; // Basically unused + BOOL flag; // Unused - purpose unknown int partsW; int partsH; int numX; diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index bddce69c..5811ce1d 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -34,7 +34,7 @@ void ActNpc000(NPCHAR *npc) void ActNpc001(NPCHAR *npc) { // In wind - if (gBack.type == 5 || gBack.type == 6) + if (gBack.type == BACKGROUND_TYPE_AUTOSCROLL || gBack.type == BACKGROUND_TYPE_OUTSIDE_WITH_WIND) { if (npc->act_no == 0) { diff --git a/src/NpcAct080.cpp b/src/NpcAct080.cpp index e557a4a2..7732d7c4 100644 --- a/src/NpcAct080.cpp +++ b/src/NpcAct080.cpp @@ -737,7 +737,7 @@ void ActNpc086(NPCHAR *npc) npc->ani_no = 0; } - if (gBack.type == 5 || gBack.type == 6) + if (gBack.type == BACKGROUND_TYPE_AUTOSCROLL || gBack.type == BACKGROUND_TYPE_OUTSIDE_WITH_WIND) { if (npc->act_no == 0) { @@ -818,7 +818,7 @@ void ActNpc087(NPCHAR *npc) npc->ani_no = 0; } - if (gBack.type == 5 || gBack.type == 6) + if (gBack.type == BACKGROUND_TYPE_AUTOSCROLL || gBack.type == BACKGROUND_TYPE_OUTSIDE_WITH_WIND) { if (npc->act_no == 0) { From 02295489d234c33fd68a0150b01fa726c393efc1 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 5 Aug 2020 19:42:18 +0100 Subject: [PATCH 07/18] More background documentation --- src/Back.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Back.cpp b/src/Back.cpp index a7729569..fbe44788 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -77,6 +77,7 @@ void ActBack(void) } } +/// Draw background background elements void PutBack(int fx, int fy) { int x, y; @@ -114,12 +115,14 @@ void PutBack(int fx, int fy) case BACKGROUND_TYPE_OUTSIDE_WITH_WIND: case BACKGROUND_TYPE_OUTSIDE: + // Draw sky rect.top = 0; rect.bottom = 88; rect.left = 0; rect.right = 320; PutBitmap4(&grcGame, 0, 0, &rect, SURFACE_ID_LEVEL_BACKGROUND); + // Draw first cloud layer rect.top = 88; rect.bottom = 123; rect.left = gBack.fx / 2; @@ -129,6 +132,7 @@ void PutBack(int fx, int fy) rect.left = 0; PutBitmap4(&grcGame, 320 - ((gBack.fx / 2) % 320), 88, &rect, SURFACE_ID_LEVEL_BACKGROUND); + // Draw second cloud layer rect.top = 123; rect.bottom = 146; rect.left = gBack.fx % 320; @@ -138,6 +142,7 @@ void PutBack(int fx, int fy) rect.left = 0; PutBitmap4(&grcGame, 320 - (gBack.fx % 320), 123, &rect, SURFACE_ID_LEVEL_BACKGROUND); + // Draw third cloud layer rect.top = 146; rect.bottom = 176; rect.left = 2 * gBack.fx % 320; @@ -147,6 +152,7 @@ void PutBack(int fx, int fy) rect.left = 0; PutBitmap4(&grcGame, 320 - ((gBack.fx * 2) % 320), 146, &rect, SURFACE_ID_LEVEL_BACKGROUND); + // Draw fourth cloud layer rect.top = 176; rect.bottom = 240; rect.left = 4 * gBack.fx % 320; @@ -160,6 +166,7 @@ void PutBack(int fx, int fy) } } +/// Draw background foreground elements - only the water background type makes use of this void PutFront(int fx, int fy) { int xpos, ypos; From 8adf5934036660e01c4a00128d2efa655eca9872 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 5 Aug 2020 19:51:06 +0100 Subject: [PATCH 08/18] Caret documentation/cleanup --- src/Caret.cpp | 61 +++++++++++++++++++++++++++++++++++++-------------- src/Caret.h | 29 ------------------------ 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/Caret.cpp b/src/Caret.cpp index e34a89ec..88e4dfc6 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -8,27 +8,54 @@ #include "Game.h" #include "Triangle.h" +#define CARET_MAX 0x40 + +struct CARET +{ + int cond; + int code; + int direct; + int x; + int y; + int xm; + int ym; + int act_no; + int act_wait; + int ani_no; + int ani_wait; + int view_left; + int view_top; + RECT rect; +}; + +struct CARET_TABLE +{ + int view_left; + int view_top; +}; + CARET gCrt[CARET_MAX]; +// Sprite offsets CARET_TABLE gCaretTable[18] = { {0, 0}, - {0x800, 0x800}, - {0x1000, 0x1000}, - {0x1000, 0x1000}, - {0x1000, 0x1000}, - {0x800, 0x800}, - {0x1000, 0x1000}, - {0x800, 0x800}, - {0x1000, 0x1000}, - {0x1000, 0x1000}, - {0x3800, 0x1000}, - {0x800, 0x800}, - {0x2000, 0x2000}, - {0x800, 0x800}, - {0x2800, 0x2800}, - {0x800, 0x800}, - {0x2800, 0x800}, - {0x6800, 0x800} + { 4 * 0x200, 4 * 0x200}, + { 8 * 0x200, 8 * 0x200}, + { 8 * 0x200, 8 * 0x200}, + { 8 * 0x200, 8 * 0x200}, + { 4 * 0x200, 4 * 0x200}, + { 8 * 0x200, 8 * 0x200}, + { 4 * 0x200, 4 * 0x200}, + { 8 * 0x200, 8 * 0x200}, + { 8 * 0x200, 8 * 0x200}, + {28 * 0x200, 8 * 0x200}, + { 4 * 0x200, 4 * 0x200}, + {16 * 0x200, 16 * 0x200}, + { 4 * 0x200, 4 * 0x200}, + {20 * 0x200, 20 * 0x200}, + { 4 * 0x200, 4 * 0x200}, + {20 * 0x200, 4 * 0x200}, + {52 * 0x200, 4 * 0x200} }; void InitCaret(void) diff --git a/src/Caret.h b/src/Caret.h index 9aeca983..26e6a510 100644 --- a/src/Caret.h +++ b/src/Caret.h @@ -2,35 +2,6 @@ #include "WindowsWrapper.h" -#define CARET_MAX 0x40 - -struct CARET_TABLE -{ - int view_left; - int view_top; -}; - -struct CARET -{ - int cond; - int code; - int direct; - int x; - int y; - int xm; - int ym; - int act_no; - int act_wait; - int ani_no; - int ani_wait; - int view_left; - int view_top; - RECT rect; -}; - -extern CARET gCrt[CARET_MAX]; -extern CARET_TABLE gCaretTable[18]; - void InitCaret(void); void ActCaret(void); void PutCaret(int fx, int fy); From d41b3993f507b5b20a020be795222bbd7bc79ddc Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 5 Aug 2020 20:55:50 +0100 Subject: [PATCH 09/18] Document caret stuff some more --- src/Caret.cpp | 121 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 49 deletions(-) diff --git a/src/Caret.cpp b/src/Caret.cpp index 88e4dfc6..e054f109 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -38,24 +38,24 @@ CARET gCrt[CARET_MAX]; // Sprite offsets CARET_TABLE gCaretTable[18] = { - {0, 0}, - { 4 * 0x200, 4 * 0x200}, - { 8 * 0x200, 8 * 0x200}, - { 8 * 0x200, 8 * 0x200}, - { 8 * 0x200, 8 * 0x200}, - { 4 * 0x200, 4 * 0x200}, - { 8 * 0x200, 8 * 0x200}, - { 4 * 0x200, 4 * 0x200}, - { 8 * 0x200, 8 * 0x200}, - { 8 * 0x200, 8 * 0x200}, - {28 * 0x200, 8 * 0x200}, - { 4 * 0x200, 4 * 0x200}, - {16 * 0x200, 16 * 0x200}, - { 4 * 0x200, 4 * 0x200}, - {20 * 0x200, 20 * 0x200}, - { 4 * 0x200, 4 * 0x200}, - {20 * 0x200, 4 * 0x200}, - {52 * 0x200, 4 * 0x200} + {0, 0}, // Null + { 4 * 0x200, 4 * 0x200}, // Bubble + { 8 * 0x200, 8 * 0x200}, // Projectile dissipation + { 8 * 0x200, 8 * 0x200}, // Shoot + { 8 * 0x200, 8 * 0x200}, // Snake after-image? This doesn't seem to be used. + { 4 * 0x200, 4 * 0x200}, // 'Zzz' - snoring + { 8 * 0x200, 8 * 0x200}, // Duplicate of the Snake after-image + { 4 * 0x200, 4 * 0x200}, // Exhaust (used by the Booster and hoverbike) + { 8 * 0x200, 8 * 0x200}, // Drowned Quote + { 8 * 0x200, 8 * 0x200}, // The '?' that appears when you press the down key + {28 * 0x200, 8 * 0x200}, // 'Level Up!' + { 4 * 0x200, 4 * 0x200}, // Red hurt particles (used by bosses and invisible hidden pickups) + {16 * 0x200, 16 * 0x200}, // Missile Launcher explosion flash + { 4 * 0x200, 4 * 0x200}, // Dust particles (used when Quote jumps into the ceiling) + {20 * 0x200, 20 * 0x200}, // Broken (unknown and unused) + { 4 * 0x200, 4 * 0x200}, // Tiny version of the projectile dissipation effect + {20 * 0x200, 4 * 0x200}, // 'Empty!' + {52 * 0x200, 4 * 0x200} // 'PUSH JUMP KEY!' (unused) }; void InitCaret(void) @@ -63,16 +63,18 @@ void InitCaret(void) memset(gCrt, 0, sizeof(gCrt)); } +// Null void ActCaret00(CARET *crt) { (void)crt; } +// Bubble void ActCaret01(CARET *crt) { RECT rcLeft[4] = { - {0, 64, 8, 72}, - {8, 64, 16, 72}, + { 0, 64, 8, 72}, + { 8, 64, 16, 72}, {16, 64, 24, 72}, {24, 64, 32, 72}, }; @@ -114,10 +116,11 @@ void ActCaret01(CARET *crt) crt->rect = rcRight[crt->ani_no]; } +// Projectile dissipation void ActCaret02(CARET *crt) { RECT rect_left[4] = { - {0, 32, 16, 48}, + { 0, 32, 16, 48}, {16, 32, 32, 48}, {32, 32, 48, 48}, {48, 32, 64, 48}, @@ -131,7 +134,7 @@ void ActCaret02(CARET *crt) }; RECT rect_up[3] = { - {0, 32, 16, 48}, + { 0, 32, 16, 48}, {32, 32, 48, 48}, {16, 32, 32, 48}, }; @@ -187,10 +190,11 @@ void ActCaret02(CARET *crt) } } +// Shoot void ActCaret03(CARET *crt) { RECT rect[4] = { - {0, 48, 16, 64}, + { 0, 48, 16, 64}, {16, 48, 32, 64}, {32, 48, 48, 64}, {48, 48, 64, 64}, @@ -212,19 +216,21 @@ void ActCaret03(CARET *crt) crt->rect = rect[crt->ani_no]; } +// Snake after-image? This doesn't seem to be used. void ActCaret04(CARET *crt) { RECT rect[9] = { - {64, 32, 80, 48}, - {80, 32, 96, 48}, + // Left + {64, 32, 80, 48}, + {80, 32, 96, 48}, {96, 32, 112, 48}, - - {64, 48, 80, 64}, - {80, 48, 96, 64}, + // Up + {64, 48, 80, 64}, + {80, 48, 96, 64}, {96, 48, 112, 64}, - - {64, 64, 80, 80}, - {80, 64, 96, 80}, + // Right + {64, 64, 80, 80}, + {80, 64, 96, 80}, {96, 64, 112, 80}, }; @@ -244,6 +250,7 @@ void ActCaret04(CARET *crt) crt->rect = rect[(crt->direct * 3) + crt->ani_no]; } +// 'Zzz' - snoring void ActCaret05(CARET *crt) { RECT rect[7] = { @@ -276,15 +283,18 @@ void ActCaret05(CARET *crt) crt->rect = rect[crt->ani_no]; } +// No ActCaret06... + +// Exhaust (used by the Booster and hoverbike) void ActCaret07(CARET *crt) { RECT rcLeft[7] = { - {56, 0, 64, 8}, - {64, 0, 72, 8}, - {72, 0, 80, 8}, - {80, 0, 88, 8}, - {88, 0, 96, 8}, - {96, 0, 104, 8}, + { 56, 0, 64, 8}, + { 64, 0, 72, 8}, + { 72, 0, 80, 8}, + { 80, 0, 88, 8}, + { 88, 0, 96, 8}, + { 96, 0, 104, 8}, {104, 0, 112, 8}, }; @@ -320,6 +330,7 @@ void ActCaret07(CARET *crt) } } +// Drowned Quote void ActCaret08(CARET *crt) { RECT rcLeft = {16, 80, 32, 96}; @@ -331,6 +342,7 @@ void ActCaret08(CARET *crt) crt->rect = rcRight; } +// The '?' that appears when you press the down key void ActCaret09(CARET *crt) { RECT rcLeft = {0, 80, 16, 96}; @@ -348,15 +360,16 @@ void ActCaret09(CARET *crt) crt->rect = rcRight; } +// 'Level Up!' void ActCaret10(CARET *crt) { RECT rcLeft[2] = { - {0, 0, 56, 16}, + {0, 0, 56, 16}, {0, 16, 56, 32}, }; RECT rcRight[2] = { - {0, 96, 56, 112}, + {0, 96, 56, 112}, {0, 112, 56, 128}, }; @@ -385,6 +398,7 @@ void ActCaret10(CARET *crt) crt->rect = rcRight[crt->ani_wait / 2 % 2]; } +// Red hurt particles (used by bosses and invisible hidden pickups) void ActCaret11(CARET *crt) { unsigned char deg; @@ -401,12 +415,12 @@ void ActCaret11(CARET *crt) crt->y += crt->ym; RECT rcRight[7] = { - {56, 8, 64, 16}, - {64, 8, 72, 16}, - {72, 8, 80, 16}, - {80, 8, 88, 16}, - {88, 8, 96, 16}, - {96, 8, 104, 16}, + { 56, 8, 64, 16}, + { 64, 8, 72, 16}, + { 72, 8, 80, 16}, + { 80, 8, 88, 16}, + { 88, 8, 96, 16}, + { 96, 8, 104, 16}, {104, 8, 112, 16}, }; @@ -426,6 +440,7 @@ void ActCaret11(CARET *crt) crt->rect = rcRight[crt->ani_no]; } +// Missile Launcher explosion flash void ActCaret12(CARET *crt) { RECT rcLeft[2] = { @@ -449,6 +464,7 @@ void ActCaret12(CARET *crt) crt->rect = rcLeft[crt->ani_no]; } +// Particles used when Quote jumps into the ceiling void ActCaret13(CARET *crt) { RECT rcLeft[2] = { @@ -493,8 +509,12 @@ void ActCaret13(CARET *crt) crt->x -= 4 * 0x200; } +// Broken (unknown and unused) void ActCaret14(CARET *crt) { + // These rects are invalid. + // However, notably, there are 5 unused 40x40 sprites at the bottom of Caret.pbm. + // Perhaps those were originally at these coordinates. RECT rect[5] = { {0, 96, 40, 136}, {40, 96, 80, 136}, @@ -519,11 +539,12 @@ void ActCaret14(CARET *crt) crt->rect = rect[crt->ani_no]; } +// Tiny version of the projectile dissipation effect void ActCaret15(CARET *crt) { RECT rcLeft[4] = { - {0, 72, 8, 80}, - {8, 72, 16, 80}, + { 0, 72, 8, 80}, + { 8, 72, 16, 80}, {16, 72, 24, 80}, {24, 72, 32, 80}, }; @@ -544,10 +565,11 @@ void ActCaret15(CARET *crt) crt->rect = rcLeft[crt->ani_no]; } +// 'Empty!' void ActCaret16(CARET *crt) { RECT rcLeft[2] = { - {104, 96, 144, 104}, + {104, 96, 144, 104}, {104, 104, 144, 112}, }; @@ -560,6 +582,7 @@ void ActCaret16(CARET *crt) crt->rect = rcLeft[crt->ani_wait / 2 % 2]; } +// 'PUSH JUMP KEY!' (unused) void ActCaret17(CARET *crt) { RECT rcLeft[2] = { @@ -585,7 +608,7 @@ CARETFUNCTION gpCaretFuncTbl[18] = ActCaret03, ActCaret04, ActCaret05, - ActCaret04, + ActCaret04, // Interestingly, this slot is a duplicate ActCaret07, ActCaret08, ActCaret09, From a3692d1c40568de767d06a47b85490b8e3e89af2 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 5 Aug 2020 21:45:59 +0100 Subject: [PATCH 10/18] Add Caret enums --- src/Boss.cpp | 9 +-- src/BulHit.cpp | 7 ++- src/Bullet.cpp | 71 ++++++++++++------------ src/Caret.cpp | 47 ++++++++-------- src/Caret.h | 22 ++++++++ src/CommonDefines.h | 3 +- src/MyChar.cpp | 19 ++++--- src/MycHit.cpp | 9 +-- src/MycParam.cpp | 4 +- src/NpChar.cpp | 5 +- src/NpcAct000.cpp | 5 +- src/NpcAct020.cpp | 7 ++- src/NpcAct040.cpp | 6 +- src/NpcAct080.cpp | 6 +- src/NpcAct100.cpp | 5 +- src/NpcAct120.cpp | 9 +-- src/NpcAct140.cpp | 12 ++-- src/NpcAct160.cpp | 20 +++---- src/NpcAct180.cpp | 21 +++---- src/NpcAct200.cpp | 9 +-- src/NpcAct220.cpp | 11 ++-- src/NpcAct240.cpp | 7 ++- src/NpcAct260.cpp | 9 +-- src/NpcAct300.cpp | 5 +- src/NpcAct320.cpp | 5 +- src/NpcAct340.cpp | 2 +- src/NpcHit.cpp | 9 +-- src/Shoot.cpp | 131 ++++++++++++++++++++++---------------------- 28 files changed, 259 insertions(+), 216 deletions(-) diff --git a/src/Boss.cpp b/src/Boss.cpp index b88acc2d..d59b7f68 100644 --- a/src/Boss.cpp +++ b/src/Boss.cpp @@ -15,6 +15,7 @@ #include "BossX.h" #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Draw.h" #include "Map.h" #include "MyChar.h" @@ -158,9 +159,9 @@ void HitBossBullet(void) { if (gBoss[bos].shock < 14) { - SetCaret(gBul[bul].x, gBul[bul].y, 11, 0); - SetCaret(gBul[bul].x, gBul[bul].y, 11, 0); - SetCaret(gBul[bul].x, gBul[bul].y, 11, 0); + SetCaret(gBul[bul].x, gBul[bul].y, CARET_HURT_PARTICLES, DIR_LEFT); + SetCaret(gBul[bul].x, gBul[bul].y, CARET_HURT_PARTICLES, DIR_LEFT); + SetCaret(gBul[bul].x, gBul[bul].y, CARET_HURT_PARTICLES, DIR_LEFT); PlaySoundObject(gBoss[bos_].hit_voice, SOUND_MODE_PLAY); } @@ -187,7 +188,7 @@ void HitBossBullet(void) { if (!(gBul[bul].bbits & 0x10)) { - SetCaret(gBul[bul].x, gBul[bul].y, 2, 2); + SetCaret(gBul[bul].x, gBul[bul].y, CARET_PROJECTILE_DISSIPATION, DIR_RIGHT); PlaySoundObject(31, SOUND_MODE_PLAY); gBul[bul].cond = 0; continue; diff --git a/src/BulHit.cpp b/src/BulHit.cpp index 814cf079..41982c42 100644 --- a/src/BulHit.cpp +++ b/src/BulHit.cpp @@ -6,6 +6,7 @@ #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Game.h" #include "Map.h" #include "NpChar.h" @@ -16,10 +17,10 @@ static void Vanish(BULLET *bul) if (bul->code_bullet != 37 && bul->code_bullet != 38 && bul->code_bullet != 39) PlaySoundObject(28, SOUND_MODE_PLAY); else - SetCaret(bul->x, bul->y, 2, 1); + SetCaret(bul->x, bul->y, CARET_PROJECTILE_DISSIPATION, DIR_UP); bul->cond = 0; - SetCaret(bul->x, bul->y, 2, 2); + SetCaret(bul->x, bul->y, CARET_PROJECTILE_DISSIPATION, DIR_RIGHT); } int JudgeHitBulletBlock(int x, int y, BULLET *bul) @@ -37,7 +38,7 @@ int JudgeHitBulletBlock(int x, int y, BULLET *bul) if (!(bul->bbits & 0x40)) bul->cond = 0; - SetCaret(bul->x, bul->y, 2, 0); + SetCaret(bul->x, bul->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); PlaySoundObject(12, SOUND_MODE_PLAY); for (i = 0; i < 4; ++i) diff --git a/src/Bullet.cpp b/src/Bullet.cpp index 0850735f..55ba282b 100644 --- a/src/Bullet.cpp +++ b/src/Bullet.cpp @@ -7,6 +7,7 @@ #include "Draw.h" #include "Caret.h" +#include "CommonDefines.h" #include "Game.h" #include "KeyControl.h" #include "MyChar.h" @@ -204,7 +205,7 @@ void ActBullet_Frontia1(BULLET *bul) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -271,7 +272,7 @@ void ActBullet_Frontia2(BULLET *bul, int level) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -396,7 +397,7 @@ void ActBullet_PoleStar(BULLET *bul, int level) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -518,7 +519,7 @@ void ActBullet_FireBall(BULLET *bul, int level) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -536,7 +537,7 @@ void ActBullet_FireBall(BULLET *bul, int level) if (bBreak) { bul->cond = 0; - SetCaret(bul->x, bul->y, 2, 0); + SetCaret(bul->x, bul->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); PlaySoundObject(28, SOUND_MODE_PLAY); return; } @@ -687,7 +688,7 @@ void ActBullet_MachineGun(BULLET *bul, int level) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -766,7 +767,7 @@ void ActBullet_Missile(BULLET *bul, int level) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -919,17 +920,17 @@ void ActBullet_Missile(BULLET *bul, int level) switch (bul->direct) { - case 0: - SetCaret(bul->x + (8 * 0x200), bul->y, 7, 2); + case DIR_LEFT: + SetCaret(bul->x + (8 * 0x200), bul->y, CARET_EXHAUST, DIR_RIGHT); break; - case 1: - SetCaret(bul->x, bul->y + (8 * 0x200), 7, 3); + case DIR_UP: + SetCaret(bul->x, bul->y + (8 * 0x200), CARET_EXHAUST, DIR_DOWN); break; - case 2: - SetCaret(bul->x - (8 * 0x200), bul->y, 7, 0); + case DIR_RIGHT: + SetCaret(bul->x - (8 * 0x200), bul->y, CARET_EXHAUST, DIR_LEFT); break; - case 3: - SetCaret(bul->x, bul->y - (8 * 0x200), 7, 1); + case DIR_DOWN: + SetCaret(bul->x, bul->y - (8 * 0x200), CARET_EXHAUST, DIR_UP); break; } } @@ -1022,7 +1023,7 @@ void ActBullet_Bubblin1(BULLET *bul) if (bul->flag & 0x2FF) { bul->cond = 0; - SetCaret(bul->x, bul->y, 2, 0); + SetCaret(bul->x, bul->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); return; } @@ -1072,7 +1073,7 @@ void ActBullet_Bubblin1(BULLET *bul) if (++bul->act_wait > 40) { bul->cond = 0; - SetCaret(bul->x, bul->y, 15, 0); + SetCaret(bul->x, bul->y, CARET_PROJECTILE_DISSIPATION_TINY, DIR_LEFT); } RECT rect[4] = { @@ -1110,7 +1111,7 @@ void ActBullet_Bubblin2(BULLET *bul) if (bDelete) { bul->cond = 0; - SetCaret(bul->x, bul->y, 2, 0); + SetCaret(bul->x, bul->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); return; } @@ -1164,7 +1165,7 @@ void ActBullet_Bubblin2(BULLET *bul) if (++bul->act_wait > 60) { bul->cond = 0; - SetCaret(bul->x, bul->y, 15, 0); + SetCaret(bul->x, bul->y, CARET_PROJECTILE_DISSIPATION_TINY, DIR_LEFT); } RECT rect[4] = { @@ -1191,7 +1192,7 @@ void ActBullet_Bubblin3(BULLET *bul) if (++bul->act_wait > 100 || !(gKey & gKeyShot)) { bul->cond = 0; - SetCaret(bul->x, bul->y, 2, 0); + SetCaret(bul->x, bul->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); PlaySoundObject(100, SOUND_MODE_PLAY); if (gMC.up) @@ -1279,7 +1280,7 @@ void ActBullet_Spine(BULLET *bul) if (++bul->count1 > bul->life_count || bul->flag & 8) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -1355,7 +1356,7 @@ void ActBullet_Sword1(BULLET *bul) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -1425,7 +1426,7 @@ void ActBullet_Sword2(BULLET *bul) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -1560,7 +1561,7 @@ void ActBullet_Sword3(BULLET *bul) if (bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -1692,7 +1693,7 @@ void ActBullet_SuperMissile(BULLET *bul, int level) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -1850,17 +1851,17 @@ void ActBullet_SuperMissile(BULLET *bul, int level) switch (bul->direct) { - case 0: - SetCaret(bul->x + (8 * 0x200), bul->y, 7, 2); + case DIR_LEFT: + SetCaret(bul->x + (8 * 0x200), bul->y, CARET_EXHAUST, DIR_RIGHT); break; - case 1: - SetCaret(bul->x, bul->y + (8 * 0x200), 7, 3); + case DIR_UP: + SetCaret(bul->x, bul->y + (8 * 0x200), CARET_EXHAUST, DIR_DOWN); break; - case 2: - SetCaret(bul->x - (8 * 0x200), bul->y, 7, 0); + case DIR_RIGHT: + SetCaret(bul->x - (8 * 0x200), bul->y, CARET_EXHAUST, DIR_LEFT); break; - case 3: - SetCaret(bul->x, bul->y - (8 * 0x200), 7, 1); + case DIR_DOWN: + SetCaret(bul->x, bul->y - (8 * 0x200), CARET_EXHAUST, DIR_UP); break; } } @@ -1944,7 +1945,7 @@ void ActBullet_Nemesis(BULLET *bul, int level) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } @@ -2052,7 +2053,7 @@ void ActBullet_Spur(BULLET *bul, int level) if (++bul->count1 > bul->life_count) { bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + SetCaret(bul->x, bul->y, CARET_SHOOT, DIR_LEFT); return; } diff --git a/src/Caret.cpp b/src/Caret.cpp index e054f109..5b940caf 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -4,6 +4,7 @@ #include "WindowsWrapper.h" +#include "CommonDefines.h" #include "Draw.h" #include "Game.h" #include "Triangle.h" @@ -38,24 +39,24 @@ CARET gCrt[CARET_MAX]; // Sprite offsets CARET_TABLE gCaretTable[18] = { - {0, 0}, // Null - { 4 * 0x200, 4 * 0x200}, // Bubble - { 8 * 0x200, 8 * 0x200}, // Projectile dissipation - { 8 * 0x200, 8 * 0x200}, // Shoot - { 8 * 0x200, 8 * 0x200}, // Snake after-image? This doesn't seem to be used. - { 4 * 0x200, 4 * 0x200}, // 'Zzz' - snoring - { 8 * 0x200, 8 * 0x200}, // Duplicate of the Snake after-image - { 4 * 0x200, 4 * 0x200}, // Exhaust (used by the Booster and hoverbike) - { 8 * 0x200, 8 * 0x200}, // Drowned Quote - { 8 * 0x200, 8 * 0x200}, // The '?' that appears when you press the down key - {28 * 0x200, 8 * 0x200}, // 'Level Up!' - { 4 * 0x200, 4 * 0x200}, // Red hurt particles (used by bosses and invisible hidden pickups) - {16 * 0x200, 16 * 0x200}, // Missile Launcher explosion flash - { 4 * 0x200, 4 * 0x200}, // Dust particles (used when Quote jumps into the ceiling) - {20 * 0x200, 20 * 0x200}, // Broken (unknown and unused) - { 4 * 0x200, 4 * 0x200}, // Tiny version of the projectile dissipation effect - {20 * 0x200, 4 * 0x200}, // 'Empty!' - {52 * 0x200, 4 * 0x200} // 'PUSH JUMP KEY!' (unused) + {0, 0}, // CARET_NULL + { 4 * 0x200, 4 * 0x200}, // CARET_BUBBLE + { 8 * 0x200, 8 * 0x200}, // CARET_PROJECTILE_DISSIPATION + { 8 * 0x200, 8 * 0x200}, // CARET_SHOOT + { 8 * 0x200, 8 * 0x200}, // CARET_SNAKE_AFTERIMAGE + { 4 * 0x200, 4 * 0x200}, // CARET_ZZZ + { 8 * 0x200, 8 * 0x200}, // CARET_SNAKE_AFTERIMAGE_DUPLICATE + { 4 * 0x200, 4 * 0x200}, // CARET_EXHAUST + { 8 * 0x200, 8 * 0x200}, // CARET_DROWNED_QUOTE + { 8 * 0x200, 8 * 0x200}, // CARET_QUESTION_MARK + {28 * 0x200, 8 * 0x200}, // CARET_LEVEL_UP + { 4 * 0x200, 4 * 0x200}, // CARET_HURT_PARTICLES + {16 * 0x200, 16 * 0x200}, // CARET_EXPLOSION + { 4 * 0x200, 4 * 0x200}, // CARET_TINY_PARTICLES + {20 * 0x200, 20 * 0x200}, // CARET_UNKNOWN + { 4 * 0x200, 4 * 0x200}, // CARET_PROJECTILE_DISSIPATION_TINY + {20 * 0x200, 4 * 0x200}, // CARET_EMPTY + {52 * 0x200, 4 * 0x200} // CARET_PUSH_JUMP_KEY }; void InitCaret(void) @@ -464,7 +465,7 @@ void ActCaret12(CARET *crt) crt->rect = rcLeft[crt->ani_no]; } -// Particles used when Quote jumps into the ceiling +// Particles used when Quote jumps into the ceiling, and also used by the Demon Crown and Ballos's puppy void ActCaret13(CARET *crt) { RECT rcLeft[2] = { @@ -478,12 +479,12 @@ void ActCaret13(CARET *crt) switch (crt->direct) { - case 0: + case DIR_LEFT: crt->xm = Random(-0x600, 0x600); crt->ym = Random(-0x200, 0x200); break; - case 1: + case DIR_UP: crt->ym = -0x200 * Random(1, 3); break; } @@ -491,7 +492,7 @@ void ActCaret13(CARET *crt) switch (crt->direct) { - case 0: + case DIR_LEFT: crt->xm = (crt->xm * 4) / 5; crt->ym = (crt->ym * 4) / 5; break; @@ -505,7 +506,7 @@ void ActCaret13(CARET *crt) crt->rect = rcLeft[crt->ani_wait / 2 % 2]; - if (crt->direct == 5) + if (crt->direct == DIR_OTHER) crt->x -= 4 * 0x200; } diff --git a/src/Caret.h b/src/Caret.h index 26e6a510..7ae09837 100644 --- a/src/Caret.h +++ b/src/Caret.h @@ -2,6 +2,28 @@ #include "WindowsWrapper.h" +enum +{ + CARET_NULL = 0, + CARET_BUBBLE = 1, + CARET_PROJECTILE_DISSIPATION = 2, + CARET_SHOOT = 3, + CARET_SNAKE_AFTERIMAGE = 4, + CARET_ZZZ = 5, + CARET_SNAKE_AFTERIMAGE_DUPLICATE = 6, + CARET_EXHAUST = 7, + CARET_DROWNED_QUOTE = 8, + CARET_QUESTION_MARK = 9, + CARET_LEVEL_UP = 10, + CARET_HURT_PARTICLES = 11, + CARET_EXPLOSION = 12, + CARET_TINY_PARTICLES = 13, + CARET_UNKNOWN = 14, + CARET_PROJECTILE_DISSIPATION_TINY = 15, + CARET_EMPTY = 16, + CARET_PUSH_JUMP_KEY = 17 +}; + void InitCaret(void); void ActCaret(void); void PutCaret(int fx, int fy); diff --git a/src/CommonDefines.h b/src/CommonDefines.h index f7eb3da3..26b75099 100644 --- a/src/CommonDefines.h +++ b/src/CommonDefines.h @@ -18,7 +18,8 @@ enum Direction DIR_UP = 1, DIR_RIGHT = 2, DIR_DOWN = 3, - DIR_AUTO = 4 + DIR_AUTO = 4, + DIR_OTHER = 5 }; struct OTHER_RECT // The original name for this struct is unknown diff --git a/src/MyChar.cpp b/src/MyChar.cpp index 6722321e..0d90b194 100644 --- a/src/MyChar.cpp +++ b/src/MyChar.cpp @@ -7,6 +7,7 @@ #include "ArmsItem.h" #include "Caret.h" +#include "CommonDefines.h" #include "Draw.h" #include "Flags.h" #include "Game.h" @@ -494,9 +495,9 @@ void ActMyChar_Normal(BOOL bKey) if (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1) { if (gMC.direct == 0) - SetCaret(gMC.x + (2 * 0x200), gMC.y + (2 * 0x200), 7, 2); + SetCaret(gMC.x + (2 * 0x200), gMC.y + (2 * 0x200), CARET_EXHAUST, DIR_RIGHT); if (gMC.direct == 2) - SetCaret(gMC.x - (2 * 0x200), gMC.y + (2 * 0x200), 7, 0); + SetCaret(gMC.x - (2 * 0x200), gMC.y + (2 * 0x200), CARET_EXHAUST, DIR_LEFT); PlaySoundObject(113, SOUND_MODE_PLAY); } @@ -509,14 +510,14 @@ void ActMyChar_Normal(BOOL bKey) // Boost particles (and sound) if (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1) { - SetCaret(gMC.x, gMC.y + (6 * 0x200), 7, 3); + SetCaret(gMC.x, gMC.y + (6 * 0x200), CARET_EXHAUST, DIR_DOWN); PlaySoundObject(113, SOUND_MODE_PLAY); } } else if (gMC.boost_sw == 3 && (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1)) { // Boost particles (and sound) - SetCaret(gMC.x, gMC.y - (6 * 0x200), 7, 1); + SetCaret(gMC.x, gMC.y - (6 * 0x200), CARET_EXHAUST, DIR_UP); PlaySoundObject(113, SOUND_MODE_PLAY); } } @@ -533,7 +534,7 @@ void ActMyChar_Normal(BOOL bKey) if (gMC.boost_cnt % 3 == 0) { - SetCaret(gMC.x, gMC.y + (gMC.hit.bottom / 2), 7, 3); + SetCaret(gMC.x, gMC.y + (gMC.hit.bottom / 2), CARET_EXHAUST, DIR_DOWN); PlaySoundObject(113, SOUND_MODE_PLAY); } @@ -758,9 +759,9 @@ void ActMyChar_Stream(BOOL bKey) } if (gMC.ym < -0x200 && gMC.flag & 2) - SetCaret(gMC.x, gMC.y - gMC.hit.top, 13, 5); + SetCaret(gMC.x, gMC.y - gMC.hit.top, CARET_TINY_PARTICLES, DIR_OTHER); if (gMC.ym > 0x200 && gMC.flag & 8) - SetCaret(gMC.x, gMC.y + gMC.hit.bottom, 13, 5); + SetCaret(gMC.x, gMC.y + gMC.hit.bottom, CARET_TINY_PARTICLES, DIR_OTHER); if (gMC.xm > 0x400) gMC.xm = 0x400; @@ -836,9 +837,9 @@ void AirProcess(void) StartTextScript(41); if (gMC.direct == 0) - SetCaret(gMC.x, gMC.y, 8, 0); + SetCaret(gMC.x, gMC.y, CARET_DROWNED_QUOTE, DIR_LEFT); else - SetCaret(gMC.x, gMC.y, 8, 2); + SetCaret(gMC.x, gMC.y, CARET_DROWNED_QUOTE, DIR_RIGHT); gMC.cond &= ~0x80; } diff --git a/src/MycHit.cpp b/src/MycHit.cpp index 2477b440..9eceb00c 100644 --- a/src/MycHit.cpp +++ b/src/MycHit.cpp @@ -5,6 +5,7 @@ #include "Back.h" #include "Boss.h" #include "Caret.h" +#include "CommonDefines.h" #include "Game.h" #include "KeyControl.h" #include "Map.h" @@ -24,8 +25,8 @@ static void PutlittleStar(void) if (!(gMC.cond & 2) && gMC.ym < -0x200) { PlaySoundObject(3, SOUND_MODE_PLAY); - SetCaret(gMC.x, gMC.y - gMC.hit.top, 13, 0); - SetCaret(gMC.x, gMC.y - gMC.hit.top, 13, 0); + SetCaret(gMC.x, gMC.y - gMC.hit.top, CARET_TINY_PARTICLES, DIR_LEFT); + SetCaret(gMC.x, gMC.y - gMC.hit.top, CARET_TINY_PARTICLES, DIR_LEFT); } } @@ -853,7 +854,7 @@ void HitMyCharNpChar(void) // Create question mark when NPC hasn't been interacted with if (gMC.ques) - SetCaret(gMC.x, gMC.y, 9, 0); + SetCaret(gMC.x, gMC.y, CARET_QUESTION_MARK, DIR_LEFT); } void HitMyCharBoss(void) @@ -913,5 +914,5 @@ void HitMyCharBoss(void) } if (gMC.ques) - SetCaret(gMC.x, gMC.y, 9, 0); + SetCaret(gMC.x, gMC.y, CARET_QUESTION_MARK, DIR_LEFT); } diff --git a/src/MycParam.cpp b/src/MycParam.cpp index 7273da9c..20385f29 100644 --- a/src/MycParam.cpp +++ b/src/MycParam.cpp @@ -67,7 +67,7 @@ void AddExpMyChar(int x) if (gArmsData[gSelectedArms].code != 13) { PlaySoundObject(27, SOUND_MODE_PLAY); - SetCaret(gMC.x, gMC.y, 10, 0); + SetCaret(gMC.x, gMC.y, CARET_LEVEL_UP, DIR_LEFT); } } } @@ -157,7 +157,7 @@ void DamageMyChar(int damage) gArmsData[gSelectedArms].exp = gArmsLevelTable[arms_code].exp[lv] + gArmsData[gSelectedArms].exp; if (gMC.life > 0 && gArmsData[gSelectedArms].code != 13) - SetCaret(gMC.x, gMC.y, 10, 2); + SetCaret(gMC.x, gMC.y, CARET_LEVEL_UP, DIR_RIGHT); } else { diff --git a/src/NpChar.cpp b/src/NpChar.cpp index cdd802b1..934400c6 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -8,6 +8,7 @@ #include "ArmsItem.h" #include "Caret.h" +#include "CommonDefines.h" #include "Draw.h" #include "Flags.h" #include "Game.h" @@ -164,7 +165,7 @@ void SetDestroyNpChar(int x, int y, int w, int num) } // Flash effect - SetCaret(x, y, 12, 0); + SetCaret(x, y, CARET_EXPLOSION, DIR_LEFT); } void SetDestroyNpCharUp(int x, int y, int w, int num) @@ -183,7 +184,7 @@ void SetDestroyNpCharUp(int x, int y, int w, int num) } // Flash effect - SetCaret(x, y, 12, 0); + SetCaret(x, y, CARET_EXPLOSION, DIR_LEFT); } void SetExpObjects(int x, int y, int exp) diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 5811ce1d..b4e8f107 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -6,6 +6,7 @@ #include "Back.h" #include "Caret.h" +#include "CommonDefines.h" #include "Frame.h" #include "Game.h" #include "Map.h" @@ -1051,7 +1052,7 @@ void ActNpc011(NPCHAR *npc) if (npc->flag & 0xFF) { npc->cond = 0; - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } npc->y += npc->ym; @@ -1075,7 +1076,7 @@ void ActNpc011(NPCHAR *npc) if (++npc->count1 > 150) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } } diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index 30911cbd..ef5e26d8 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -5,6 +5,7 @@ #include "WindowsWrapper.h" #include "Caret.h" +#include "CommonDefines.h" #include "Game.h" #include "Frame.h" #include "MyChar.h" @@ -803,7 +804,7 @@ void ActNpc030(NPCHAR *npc) if (++npc->act_wait > 100) { npc->act_wait = 0; - SetCaret(npc->x, npc->y - (2 * 0x200), 5, 0); + SetCaret(npc->x, npc->y - (2 * 0x200), CARET_ZZZ, DIR_LEFT); } } @@ -970,7 +971,7 @@ void ActNpc033(NPCHAR *npc) { if (npc->flag & 5) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } else if (npc->flag & 8) @@ -1000,7 +1001,7 @@ void ActNpc033(NPCHAR *npc) if (++npc->act_wait > 250) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } } diff --git a/src/NpcAct040.cpp b/src/NpcAct040.cpp index 8971b050..0f9314b6 100644 --- a/src/NpcAct040.cpp +++ b/src/NpcAct040.cpp @@ -819,7 +819,7 @@ void ActNpc048(NPCHAR *npc) if (++npc->count1 > 2 || npc->direct == 2) { VanishNpChar(npc); - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } else { @@ -856,7 +856,7 @@ void ActNpc048(NPCHAR *npc) if (++npc->act_wait > 750) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } @@ -1064,7 +1064,7 @@ void ActNpc050(NPCHAR *npc) { if (++npc->count1 > 1) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } } diff --git a/src/NpcAct080.cpp b/src/NpcAct080.cpp index 7732d7c4..8932ad4d 100644 --- a/src/NpcAct080.cpp +++ b/src/NpcAct080.cpp @@ -637,7 +637,7 @@ void ActNpc084(NPCHAR *npc) { if (npc->flag & 0xFF) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } @@ -664,7 +664,7 @@ void ActNpc084(NPCHAR *npc) if (++npc->count1 > 300) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } } @@ -1410,7 +1410,7 @@ void ActNpc093(NPCHAR *npc) if (++npc->act_wait > 200) { npc->act_wait = 0; - SetCaret(npc->x, npc->y, 5, 0); + SetCaret(npc->x, npc->y, CARET_ZZZ, DIR_LEFT); } break; diff --git a/src/NpcAct100.cpp b/src/NpcAct100.cpp index 50eb8483..31af6bc8 100644 --- a/src/NpcAct100.cpp +++ b/src/NpcAct100.cpp @@ -6,6 +6,7 @@ #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Frame.h" #include "Game.h" #include "MyChar.h" @@ -500,7 +501,7 @@ void ActNpc108(NPCHAR *npc) { if (npc->flag & 0xFF) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } @@ -526,7 +527,7 @@ void ActNpc108(NPCHAR *npc) if (++npc->count1 > 300) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } } diff --git a/src/NpcAct120.cpp b/src/NpcAct120.cpp index 269dee15..cd21959e 100644 --- a/src/NpcAct120.cpp +++ b/src/NpcAct120.cpp @@ -7,6 +7,7 @@ #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Frame.h" #include "Game.h" #include "KeyControl.h" @@ -75,7 +76,7 @@ void ActNpc121(NPCHAR *npc) if (++npc->act_wait > 100) { npc->act_wait = 0; - SetCaret(npc->x, npc->y, 5, 0); + SetCaret(npc->x, npc->y, CARET_ZZZ, DIR_LEFT); } } } @@ -285,7 +286,7 @@ void ActNpc123(NPCHAR *npc) { case 0: npc->act_no = 1; - SetCaret(npc->x, npc->y, 3, 0); + SetCaret(npc->x, npc->y, CARET_SHOOT, DIR_LEFT); PlaySoundObject(32, SOUND_MODE_PLAY); switch (npc->direct) @@ -345,7 +346,7 @@ void ActNpc123(NPCHAR *npc) if (bBreak) { - SetCaret(npc->x, npc->y, 2, 2); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_RIGHT); PlaySoundObject(28, SOUND_MODE_PLAY); npc->cond = 0; } @@ -819,7 +820,7 @@ void ActNpc131(NPCHAR *npc) if (++npc->act_wait > 100) { npc->act_wait = 0; - SetCaret(npc->x, npc->y, 5, 0); + SetCaret(npc->x, npc->y, CARET_ZZZ, DIR_LEFT); } if (npc->direct == 0) diff --git a/src/NpcAct140.cpp b/src/NpcAct140.cpp index eb589523..c3873690 100644 --- a/src/NpcAct140.cpp +++ b/src/NpcAct140.cpp @@ -413,7 +413,7 @@ void ActNpc141(NPCHAR *npc) { npc->act_no = 20; npc->act_wait = 0; - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); PlaySoundObject(12, SOUND_MODE_PLAY); for (i = 0; i < 4; ++i) @@ -952,7 +952,7 @@ void ActNpc148(NPCHAR *npc) { if (npc->flag & 0xFF) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } @@ -971,7 +971,7 @@ void ActNpc148(NPCHAR *npc) if (++npc->count1 > 300) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } } @@ -1734,7 +1734,7 @@ void ActNpc156(NPCHAR *npc) { if (npc->flag & 0xFF) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } @@ -1754,7 +1754,7 @@ void ActNpc156(NPCHAR *npc) if (++npc->count1 > 300) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } } @@ -1956,7 +1956,7 @@ void ActNpc158(NPCHAR *npc) if (++npc->ani_wait > 2) { npc->ani_wait = 0; - SetCaret(npc->x, npc->y, 7, 4); + SetCaret(npc->x, npc->y, CARET_EXHAUST, DIR_AUTO); } npc->ani_no = (npc->count1 + 0x10) / 0x20; diff --git a/src/NpcAct160.cpp b/src/NpcAct160.cpp index 017f69de..5080c0bc 100644 --- a/src/NpcAct160.cpp +++ b/src/NpcAct160.cpp @@ -896,14 +896,14 @@ void ActNpc170(NPCHAR *npc) npc->xm -= 0x20; if (npc->count1 % 3 == 1) - SetCaret(npc->x + (8 * 0x200), npc->y, 7, 2); + SetCaret(npc->x + (8 * 0x200), npc->y, CARET_EXHAUST, DIR_RIGHT); } else { npc->xm += 0x20; if (npc->count1 % 3 == 1) - SetCaret(npc->x - (8 * 0x200), npc->y, 7, 0); + SetCaret(npc->x - (8 * 0x200), npc->y, CARET_EXHAUST, DIR_LEFT); } if (npc->count1 < 50) @@ -1056,7 +1056,7 @@ void ActNpc172(NPCHAR *npc) if (npc->flag & 1 || npc->flag & 4) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); VanishNpChar(npc); return; } @@ -1294,7 +1294,7 @@ void ActNpc174(NPCHAR *npc) { if (++npc->count1 > 1) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } } @@ -1474,7 +1474,7 @@ void ActNpc177(NPCHAR *npc) if (npc->flag & 0xFF) { - SetCaret(npc->x, npc->y, 3, 0); + SetCaret(npc->x, npc->y, CARET_SHOOT, DIR_LEFT); npc->cond = 0; return; } @@ -1521,7 +1521,7 @@ void ActNpc177(NPCHAR *npc) if (++npc->act_wait > 300) { - SetCaret(npc->x, npc->y, 3, 0); + SetCaret(npc->x, npc->y, CARET_SHOOT, DIR_LEFT); npc->cond = 0; return; } @@ -1564,7 +1564,7 @@ void ActNpc178(NPCHAR *npc) { if (npc->flag & 0xFF) { - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); npc->cond = 0; } @@ -1599,7 +1599,7 @@ void ActNpc178(NPCHAR *npc) if (++npc->count1 > 150) { VanishNpChar(npc); - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } } @@ -1609,7 +1609,7 @@ void ActNpc179(NPCHAR *npc) if (npc->flag & 0xFF) { npc->cond = 0; - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } npc->xm -= 0x20; @@ -1641,6 +1641,6 @@ void ActNpc179(NPCHAR *npc) if (++npc->count1 > 300) { VanishNpChar(npc); - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } } diff --git a/src/NpcAct180.cpp b/src/NpcAct180.cpp index 4ddf760a..0b630116 100644 --- a/src/NpcAct180.cpp +++ b/src/NpcAct180.cpp @@ -7,6 +7,7 @@ #include "Back.h" #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Flags.h" #include "Frame.h" #include "Game.h" @@ -386,12 +387,12 @@ void ActNpc181(NPCHAR *npc) if (npc->direct == 0) { SetBullet(12, npc->x - (4 * 0x200), npc->y + (3 * 0x200), 0); - SetCaret(npc->x - (4 * 0x200), npc->y + (3 * 0x200), 3, 0); + SetCaret(npc->x - (4 * 0x200), npc->y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(12, npc->x + (4 * 0x200), npc->y + (3 * 0x200), 2); - SetCaret(npc->x + (4 * 0x200), npc->y + (3 * 0x200), 3, 0); + SetCaret(npc->x + (4 * 0x200), npc->y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -399,12 +400,12 @@ void ActNpc181(NPCHAR *npc) if (npc->direct == 0) { SetBullet(12, npc->x - (2 * 0x200), npc->y - (4 * 0x200), 1); - SetCaret(npc->x - (2 * 0x200), npc->y - (4 * 0x200), 3, 0); + SetCaret(npc->x - (2 * 0x200), npc->y - (4 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(12, npc->x + (2 * 0x200), npc->y - (4 * 0x200), 1); - SetCaret(npc->x + (2 * 0x200), npc->y - (4 * 0x200), 3, 0); + SetCaret(npc->x + (2 * 0x200), npc->y - (4 * 0x200), CARET_SHOOT, DIR_LEFT); } } } @@ -493,12 +494,12 @@ void ActNpc182(NPCHAR *npc) if (npc->direct == 0) { SetBullet(6, npc->x - (4 * 0x200), npc->y + (3 * 0x200), 0); - SetCaret(npc->x - (4 * 0x200), npc->y + (3 * 0x200), 3, 0); + SetCaret(npc->x - (4 * 0x200), npc->y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(6, npc->x + (4 * 0x200), npc->y + (3 * 0x200), 2); - SetCaret(npc->x + (4 * 0x200), npc->y + (3 * 0x200), 3, 0); + SetCaret(npc->x + (4 * 0x200), npc->y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -506,12 +507,12 @@ void ActNpc182(NPCHAR *npc) if (npc->direct == 0) { SetBullet(6, npc->x - (2 * 0x200), npc->y - (4 * 0x200), 1); - SetCaret(npc->x - (2 * 0x200), npc->y - (4 * 0x200), 3, 0); + SetCaret(npc->x - (2 * 0x200), npc->y - (4 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(6, npc->x + (2 * 0x200), npc->y - (4 * 0x200), 1); - SetCaret(npc->x + (2 * 0x200), npc->y - (4 * 0x200), 3, 0); + SetCaret(npc->x + (2 * 0x200), npc->y - (4 * 0x200), CARET_SHOOT, DIR_LEFT); } } } @@ -1184,9 +1185,9 @@ void ActNpc192(NPCHAR *npc) PlaySoundObject(34, SOUND_MODE_PLAY); if (npc->direct == 0) - SetCaret(npc->x + (10 * 0x200), npc->y + (10 * 0x200), 7, 2); + SetCaret(npc->x + (10 * 0x200), npc->y + (10 * 0x200), CARET_EXHAUST, DIR_RIGHT); else - SetCaret(npc->x - (10 * 0x200), npc->y + (10 * 0x200), 7, 0); + SetCaret(npc->x - (10 * 0x200), npc->y + (10 * 0x200), CARET_EXHAUST, DIR_LEFT); } RECT rcLeft[2] = { diff --git a/src/NpcAct200.cpp b/src/NpcAct200.cpp index 66b2862a..e4ab9281 100644 --- a/src/NpcAct200.cpp +++ b/src/NpcAct200.cpp @@ -6,6 +6,7 @@ #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Frame.h" #include "Game.h" #include "MyChar.h" @@ -163,7 +164,7 @@ void ActNpc202(NPCHAR *npc) if (npc->flag & 0xFF) { npc->cond = 0; - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } npc->y += npc->ym; @@ -189,7 +190,7 @@ void ActNpc202(NPCHAR *npc) if (++npc->count1 > 300) { npc->cond = 0; - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } } @@ -750,7 +751,7 @@ void ActNpc209(NPCHAR *npc) if (npc->flag & 0xFF) { npc->cond = 0; - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } npc->y += npc->ym; @@ -777,7 +778,7 @@ void ActNpc209(NPCHAR *npc) if (++npc->count1 > 300) { npc->cond = 0; - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } } diff --git a/src/NpcAct220.cpp b/src/NpcAct220.cpp index ece414e1..9b88d564 100644 --- a/src/NpcAct220.cpp +++ b/src/NpcAct220.cpp @@ -5,6 +5,7 @@ #include "WindowsWrapper.h" #include "Caret.h" +#include "CommonDefines.h" #include "Game.h" #include "MyChar.h" #include "NpChar.h" @@ -617,9 +618,9 @@ void ActNpc231(NPCHAR *npc) ++npc->act_wait; if (npc->act_wait % 2 == 0) - SetCaret(npc->x - (10 * 0x200), npc->y + (8 * 0x200), 7, 3); + SetCaret(npc->x - (10 * 0x200), npc->y + (8 * 0x200), CARET_EXHAUST, DIR_DOWN); if (npc->act_wait % 2 == 1) - SetCaret(npc->x + (10 * 0x200), npc->y + (8 * 0x200), 7, 3); + SetCaret(npc->x + (10 * 0x200), npc->y + (8 * 0x200), CARET_EXHAUST, DIR_DOWN); if (npc->act_wait % 4 == 1) PlaySoundObject(34, SOUND_MODE_PLAY); @@ -647,10 +648,10 @@ void ActNpc231(NPCHAR *npc) if (npc->ym < 0) { if (npc->act_wait % 8 == 0) - SetCaret(npc->x - (10 * 0x200), npc->y + (8 * 0x200), 7, 3); + SetCaret(npc->x - (10 * 0x200), npc->y + (8 * 0x200), CARET_EXHAUST, DIR_DOWN); if (npc->act_wait % 8 == 4) - SetCaret(npc->x + (10 * 0x200), npc->y + (8 * 0x200), 7, 3); + SetCaret(npc->x + (10 * 0x200), npc->y + (8 * 0x200), CARET_EXHAUST, DIR_DOWN); if (npc->act_wait % 16 == 1) PlaySoundObject(34, SOUND_MODE_PLAY); @@ -1153,7 +1154,7 @@ void ActNpc237(NPCHAR *npc) if (bHit) { for (i = 0; i < 5; ++i) - SetCaret(npc->x, npc->y, 1, 0); + SetCaret(npc->x, npc->y, CARET_BUBBLE, DIR_LEFT); PlaySoundObject(21, SOUND_MODE_PLAY); npc->cond = 0; diff --git a/src/NpcAct240.cpp b/src/NpcAct240.cpp index 747eeb2b..c4eb698b 100644 --- a/src/NpcAct240.cpp +++ b/src/NpcAct240.cpp @@ -5,6 +5,7 @@ #include "WindowsWrapper.h" #include "Caret.h" +#include "CommonDefines.h" #include "Frame.h" #include "Game.h" #include "Map.h" @@ -338,7 +339,7 @@ void ActNpc244(NPCHAR *npc) if (bHit) { for (i = 0; i < 3; ++i) - SetCaret(npc->x, npc->y + (4 * 0x200), 1, 2); + SetCaret(npc->x, npc->y + (4 * 0x200), CARET_BUBBLE, DIR_RIGHT); 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, SOUND_MODE_PLAY); @@ -831,7 +832,7 @@ void ActNpc248(NPCHAR *npc) if (npc->flag & 0xFF) { npc->cond = 0; - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } npc->y += npc->ym; @@ -856,7 +857,7 @@ void ActNpc248(NPCHAR *npc) if (++npc->count1 > 300) { npc->cond = 0; - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } } diff --git a/src/NpcAct260.cpp b/src/NpcAct260.cpp index f88d6af2..f58b5c3b 100644 --- a/src/NpcAct260.cpp +++ b/src/NpcAct260.cpp @@ -5,6 +5,7 @@ #include "WindowsWrapper.h" #include "Caret.h" +#include "CommonDefines.h" #include "Frame.h" #include "Game.h" #include "Map.h" @@ -1527,15 +1528,15 @@ void ActNpc271(NPCHAR *npc) 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); + SetCaret(npc->x, npc->y - (8 * 0x200), CARET_TINY_PARTICLES, DIR_LEFT); + SetCaret(npc->x, npc->y - (8 * 0x200), CARET_TINY_PARTICLES, DIR_LEFT); } 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); + SetCaret(npc->x, npc->y + (8 * 0x200), CARET_TINY_PARTICLES, DIR_LEFT); + SetCaret(npc->x, npc->y + (8 * 0x200), CARET_TINY_PARTICLES, DIR_LEFT); } npc->x += npc->xm; diff --git a/src/NpcAct300.cpp b/src/NpcAct300.cpp index 86898d4d..8bbe1e8d 100644 --- a/src/NpcAct300.cpp +++ b/src/NpcAct300.cpp @@ -7,6 +7,7 @@ #include "Boss.h" #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Frame.h" #include "Game.h" #include "Map.h" @@ -27,7 +28,7 @@ void ActNpc300(NPCHAR *npc) } if (++npc->ani_wait % 8 == 1) - SetCaret(npc->x + (Random(-8, 8) * 0x200), npc->y + (8 * 0x200), 13, 1); + SetCaret(npc->x + (Random(-8, 8) * 0x200), npc->y + (8 * 0x200), CARET_TINY_PARTICLES, DIR_UP); npc->rect = rc; } @@ -89,7 +90,7 @@ void ActNpc301(NPCHAR *npc) if (++npc->ani_wait > 2) { npc->ani_wait = 0; - SetCaret(npc->x, npc->y, 7, 4); + SetCaret(npc->x, npc->y, CARET_EXHAUST, DIR_AUTO); } npc->ani_no = (npc->count1 + 0x10) / 0x20; diff --git a/src/NpcAct320.cpp b/src/NpcAct320.cpp index 68fd5bbc..029cfb94 100644 --- a/src/NpcAct320.cpp +++ b/src/NpcAct320.cpp @@ -6,6 +6,7 @@ #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Frame.h" #include "Game.h" #include "KeyControl.h" @@ -167,7 +168,7 @@ void ActNpc321(NPCHAR *npc) if (g_GameFlags & 2 && CountBulletNum(43) < 2 && gKeyTrg & gKeyShot) { SetBullet(43, npc->pNpc->x, npc->pNpc->y, direct); - SetCaret(npc->pNpc->x, npc->pNpc->y, 3, 0); + SetCaret(npc->pNpc->x, npc->pNpc->y, CARET_SHOOT, DIR_LEFT); PlaySoundObject(117, SOUND_MODE_PLAY); } @@ -767,7 +768,7 @@ void ActNpc331(NPCHAR *npc) if (npc->flag & 8) { npc->cond = 0; - SetCaret(npc->x, npc->y, 2, 0); + SetCaret(npc->x, npc->y, CARET_PROJECTILE_DISSIPATION, DIR_LEFT); } break; diff --git a/src/NpcAct340.cpp b/src/NpcAct340.cpp index 6666effc..6fbd8800 100644 --- a/src/NpcAct340.cpp +++ b/src/NpcAct340.cpp @@ -1917,7 +1917,7 @@ void ActNpc357(NPCHAR *npc) } if (npc->act_wait % 8 == 1) - SetCaret(npc->x + (Random(-8, 8) * 0x200), npc->y + 0x1000, 13, 1); + SetCaret(npc->x + (Random(-8, 8) * 0x200), npc->y + 0x1000, CARET_TINY_PARTICLES, DIR_UP); } // Misery (stood in the wind during the credits) diff --git a/src/NpcHit.cpp b/src/NpcHit.cpp index 1ec75c15..a08f82d6 100644 --- a/src/NpcHit.cpp +++ b/src/NpcHit.cpp @@ -5,6 +5,7 @@ #include "Back.h" #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Flags.h" #include "Game.h" #include "Map.h" @@ -591,9 +592,9 @@ void HitNpCharBullet(void) { if (gNPC[n].shock < 14) { - SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0); - SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0); - SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0); + SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, CARET_HURT_PARTICLES, DIR_LEFT); + SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, CARET_HURT_PARTICLES, DIR_LEFT); + SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, CARET_HURT_PARTICLES, DIR_LEFT); PlaySoundObject(gNPC[n].hit_voice, SOUND_MODE_PLAY); gNPC[n].shock = 16; } @@ -614,7 +615,7 @@ void HitNpCharBullet(void) 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); + SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, CARET_PROJECTILE_DISSIPATION, DIR_RIGHT); PlaySoundObject(31, SOUND_MODE_PLAY); gBul[b].life = 0; continue; diff --git a/src/Shoot.cpp b/src/Shoot.cpp index 6ebcfac5..a9701e42 100644 --- a/src/Shoot.cpp +++ b/src/Shoot.cpp @@ -5,6 +5,7 @@ #include "ArmsItem.h" #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "KeyControl.h" #include "MyChar.h" #include "MycParam.h" @@ -47,12 +48,12 @@ void ShootBullet_Frontia1(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y - (10 * 0x200), 1); - SetCaret(gMC.x - (3 * 0x200), gMC.y - (10 * 0x200), 3, 0); + SetCaret(gMC.x - (3 * 0x200), gMC.y - (10 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y - (10 * 0x200), 1); - SetCaret(gMC.x + (3 * 0x200), gMC.y - (10 * 0x200), 3, 0); + SetCaret(gMC.x + (3 * 0x200), gMC.y - (10 * 0x200), CARET_SHOOT, DIR_LEFT); } } else if (gMC.down) @@ -60,12 +61,12 @@ void ShootBullet_Frontia1(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y + (10 * 0x200), 3); - SetCaret(gMC.x - (3 * 0x200), gMC.y + (10 * 0x200), 3, 0); + SetCaret(gMC.x - (3 * 0x200), gMC.y + (10 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y + (10 * 0x200), 3); - SetCaret(gMC.x + (3 * 0x200), gMC.y + (10 * 0x200), 3, 0); + SetCaret(gMC.x + (3 * 0x200), gMC.y + (10 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -73,12 +74,12 @@ void ShootBullet_Frontia1(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y + (2 * 0x200), 0); - SetCaret(gMC.x - (12 * 0x200), gMC.y + (2 * 0x200), 3, 0); + SetCaret(gMC.x - (12 * 0x200), gMC.y + (2 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y + (2 * 0x200), 2); - SetCaret(gMC.x + (12 * 0x200), gMC.y + (2 * 0x200), 3, 0); + SetCaret(gMC.x + (12 * 0x200), gMC.y + (2 * 0x200), CARET_SHOOT, DIR_LEFT); } } @@ -122,12 +123,12 @@ void ShootBullet_PoleStar(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); } } else if (gMC.down) @@ -135,12 +136,12 @@ void ShootBullet_PoleStar(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -148,12 +149,12 @@ void ShootBullet_PoleStar(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y + (3 * 0x200), 0); - SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), 3, 0); + SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y + (3 * 0x200), 2); - SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 3, 0); + SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } } @@ -206,12 +207,12 @@ void ShootBullet_FireBall(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (4 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x - (4 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x - (4 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (4 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x + (4 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x + (4 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); } } else if (gMC.down) @@ -219,12 +220,12 @@ void ShootBullet_FireBall(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (4 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x - (4 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x - (4 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (4 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x + (4 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x + (4 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -232,12 +233,12 @@ void ShootBullet_FireBall(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y + (2 * 0x200), 0); - SetCaret(gMC.x - (12 * 0x200), gMC.y + (2 * 0x200), 3, 0); + SetCaret(gMC.x - (12 * 0x200), gMC.y + (2 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y + (2 * 0x200), 2); - SetCaret(gMC.x + (12 * 0x200), gMC.y + (2 * 0x200), 3, 0); + SetCaret(gMC.x + (12 * 0x200), gMC.y + (2 * 0x200), CARET_SHOOT, DIR_LEFT); } } @@ -285,7 +286,7 @@ void ShootBullet_Machinegun1(int level) if (empty == 0) { - SetCaret(gMC.x, gMC.y, 16, 0); + SetCaret(gMC.x, gMC.y, CARET_EMPTY, DIR_LEFT); empty = 50; } @@ -300,12 +301,12 @@ void ShootBullet_Machinegun1(int level) 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); + SetCaret(gMC.x - (3 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x + (3 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x + (3 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); } } else if (gMC.down) @@ -326,12 +327,12 @@ void ShootBullet_Machinegun1(int level) 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); + SetCaret(gMC.x - (3 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x + (3 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x + (3 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -339,12 +340,12 @@ void ShootBullet_Machinegun1(int level) 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); + SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 2); - SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 3, 0); + SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } } @@ -486,7 +487,7 @@ void ShootBullet_Missile(int level, BOOL bSuper) if (empty == 0) { - SetCaret(gMC.x, gMC.y, 16, 0); + SetCaret(gMC.x, gMC.y, CARET_EMPTY, DIR_LEFT); empty = 50; } @@ -498,12 +499,12 @@ void ShootBullet_Missile(int level, BOOL bSuper) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); } } else if (gMC.down) @@ -511,12 +512,12 @@ void ShootBullet_Missile(int level, BOOL bSuper) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -524,12 +525,12 @@ void ShootBullet_Missile(int level, BOOL bSuper) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y, 0); - SetCaret(gMC.x - (12 * 0x200), gMC.y, 3, 0); + SetCaret(gMC.x - (12 * 0x200), gMC.y, CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y, 2); - SetCaret(gMC.x + (12 * 0x200), gMC.y, 3, 0); + SetCaret(gMC.x + (12 * 0x200), gMC.y, CARET_SHOOT, DIR_LEFT); } } } @@ -541,7 +542,7 @@ void ShootBullet_Missile(int level, BOOL bSuper) if (empty == 0) { - SetCaret(gMC.x, gMC.y, 16, 0); + SetCaret(gMC.x, gMC.y, CARET_EMPTY, DIR_LEFT); empty = 50; } @@ -553,14 +554,14 @@ void ShootBullet_Missile(int level, BOOL bSuper) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); 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 + (1 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y, 1); SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y, 1); } @@ -570,14 +571,14 @@ void ShootBullet_Missile(int level, BOOL bSuper) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); 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 + (1 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); SetBullet(bul_no, gMC.x - (3 * 0x200), gMC.y, 3); SetBullet(bul_no, gMC.x + (3 * 0x200), gMC.y, 3); } @@ -587,14 +588,14 @@ void ShootBullet_Missile(int level, BOOL bSuper) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y + (1 * 0x200), 0); - SetCaret(gMC.x - (12 * 0x200), gMC.y + (1 * 0x200), 3, 0); + SetCaret(gMC.x - (12 * 0x200), gMC.y + (1 * 0x200), CARET_SHOOT, DIR_LEFT); 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 + (6 * 0x200), gMC.y + (1 * 0x200), 2); - SetCaret(gMC.x + (12 * 0x200), gMC.y + (1 * 0x200), 3, 0); + SetCaret(gMC.x + (12 * 0x200), gMC.y + (1 * 0x200), CARET_SHOOT, DIR_LEFT); SetBullet(bul_no, gMC.x, gMC.y - (8 * 0x200), 2); SetBullet(bul_no, gMC.x - (4 * 0x200), gMC.y - (1 * 0x200), 2); } @@ -620,7 +621,7 @@ void ShootBullet_Bubblin1(void) if (empty == 0) { - SetCaret(gMC.x, gMC.y, 16, 0); + SetCaret(gMC.x, gMC.y, CARET_EMPTY, DIR_LEFT); empty = 50; } @@ -632,12 +633,12 @@ void ShootBullet_Bubblin1(void) if (gMC.direct == 0) { SetBullet(19, gMC.x - (1 * 0x200), gMC.y - (2 * 0x200), 1); - SetCaret(gMC.x - (1 * 0x200), gMC.y - (2 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y - (2 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(19, gMC.x + (1 * 0x200), gMC.y - (2 * 0x200), 1); - SetCaret(gMC.x + (1 * 0x200), gMC.y - (2 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y - (2 * 0x200), CARET_SHOOT, DIR_LEFT); } } else if (gMC.down) @@ -645,12 +646,12 @@ void ShootBullet_Bubblin1(void) 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); + SetCaret(gMC.x - (1 * 0x200), gMC.y + (2 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(19, gMC.x + (1 * 0x200), gMC.y + (2 * 0x200), 3); - SetCaret(gMC.x + (1 * 0x200), gMC.y + (2 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y + (2 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -658,12 +659,12 @@ void ShootBullet_Bubblin1(void) 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); + SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(19, gMC.x + (6 * 0x200), gMC.y + (3 * 0x200), 2); - SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 3, 0); + SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } } @@ -701,7 +702,7 @@ void ShootBullet_Bubblin2(int level) if (empty == 0) { - SetCaret(gMC.x, gMC.y, 16, 0); + SetCaret(gMC.x, gMC.y, CARET_EMPTY, DIR_LEFT); empty = 50; } @@ -713,12 +714,12 @@ void ShootBullet_Bubblin2(int level) if (gMC.direct == 0) { SetBullet(level, gMC.x - (3 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x - (3 * 0x200), gMC.y - (16 * 0x200), 3, 0); + SetCaret(gMC.x - (3 * 0x200), gMC.y - (16 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(level, gMC.x + (3 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x + (3 * 0x200), gMC.y - (16 * 0x200), 3, 0); + SetCaret(gMC.x + (3 * 0x200), gMC.y - (16 * 0x200), CARET_SHOOT, DIR_LEFT); } } else if (gMC.down) @@ -726,12 +727,12 @@ void ShootBullet_Bubblin2(int level) 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); + SetCaret(gMC.x - (3 * 0x200), gMC.y + (16 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(level, gMC.x + (3 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x + (3 * 0x200), gMC.y + (16 * 0x200), 3, 0); + SetCaret(gMC.x + (3 * 0x200), gMC.y + (16 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -739,12 +740,12 @@ void ShootBullet_Bubblin2(int level) 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); + SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(level, gMC.x + (6 * 0x200), gMC.y + (3 * 0x200), 2); - SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 3, 0); + SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } } @@ -842,12 +843,12 @@ void ShootBullet_Nemesis(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (12 * 0x200), 1); - SetCaret(gMC.x - (1 * 0x200), gMC.y - (12 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y - (12 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y - (12 * 0x200), 1); - SetCaret(gMC.x + (1 * 0x200), gMC.y - (12 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y - (12 * 0x200), CARET_SHOOT, DIR_LEFT); } } else if (gMC.down) @@ -855,12 +856,12 @@ void ShootBullet_Nemesis(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (12 * 0x200), 3); - SetCaret(gMC.x - (1 * 0x200), gMC.y + (12 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y + (12 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y + (12 * 0x200), 3); - SetCaret(gMC.x + (1 * 0x200), gMC.y + (12 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y + (12 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -868,12 +869,12 @@ void ShootBullet_Nemesis(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (22 * 0x200), gMC.y + (3 * 0x200), 0); - SetCaret(gMC.x - (16 * 0x200), gMC.y + (3 * 0x200), 3, 0); + SetCaret(gMC.x - (16 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (22 * 0x200), gMC.y + (3 * 0x200), 2); - SetCaret(gMC.x + (16 * 0x200), gMC.y + (3 * 0x200), 3, 0); + SetCaret(gMC.x + (16 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } } @@ -1000,12 +1001,12 @@ void ShootBullet_Spur(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 1); - SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y - (8 * 0x200), CARET_SHOOT, DIR_LEFT); } } else if (gMC.down) @@ -1013,12 +1014,12 @@ void ShootBullet_Spur(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x - (1 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3); - SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), 3, 0); + SetCaret(gMC.x + (1 * 0x200), gMC.y + (8 * 0x200), CARET_SHOOT, DIR_LEFT); } } else @@ -1026,12 +1027,12 @@ void ShootBullet_Spur(int level) if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - (6 * 0x200), gMC.y + (3 * 0x200), 0); - SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), 3, 0); + SetCaret(gMC.x - (12 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } else { SetBullet(bul_no, gMC.x + (6 * 0x200), gMC.y + (3 * 0x200), 2); - SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), 3, 0); + SetCaret(gMC.x + (12 * 0x200), gMC.y + (3 * 0x200), CARET_SHOOT, DIR_LEFT); } } From a305151302c38ca50aaf208ad72cca8e4c8c3c12 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 5 Aug 2020 21:47:50 +0100 Subject: [PATCH 11/18] Apply some direction macros --- src/Caret.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Caret.cpp b/src/Caret.cpp index 5b940caf..75be00be 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -111,7 +111,7 @@ void ActCaret01(CARET *crt) } } - if (crt->direct == 0) + if (crt->direct == DIR_LEFT) crt->rect = rcLeft[crt->ani_no]; else crt->rect = rcRight[crt->ani_no]; @@ -142,7 +142,7 @@ void ActCaret02(CARET *crt) switch (crt->direct) { - case 0: + case DIR_LEFT: crt->ym -= 0x10; crt->y += crt->ym; @@ -163,7 +163,7 @@ void ActCaret02(CARET *crt) crt->rect = rect_left[crt->ani_no]; break; - case 2: + case DIR_RIGHT: if (++crt->ani_wait > 2) { crt->ani_wait = 0; @@ -181,7 +181,7 @@ void ActCaret02(CARET *crt) crt->rect = rect_right[crt->ani_no]; break; - case 1: + case DIR_UP: crt->rect = rect_up[++crt->ani_wait / 2 % 3]; if (crt->ani_wait > 24) @@ -316,16 +316,16 @@ void ActCaret07(CARET *crt) switch (crt->direct) { - case 0: + case DIR_LEFT: crt->x -= 2 * 0x200; break; - case 1: + case DIR_UP: crt->y -= 2 * 0x200; break; - case 2: + case DIR_RIGHT: crt->x += 2 * 0x200; break; - case 3: + case DIR_DOWN: crt->y += 2 * 0x200; break; } @@ -337,7 +337,7 @@ void ActCaret08(CARET *crt) RECT rcLeft = {16, 80, 32, 96}; RECT rcRight = {32, 80, 48, 96}; - if (crt->direct == 0) + if (crt->direct == DIR_LEFT) crt->rect = rcLeft; else crt->rect = rcRight; @@ -355,7 +355,7 @@ void ActCaret09(CARET *crt) if (crt->ani_wait == 32) crt->cond = 0; - if (crt->direct == 0) + if (crt->direct == DIR_LEFT) crt->rect = rcLeft; else crt->rect = rcRight; @@ -376,7 +376,7 @@ void ActCaret10(CARET *crt) ++crt->ani_wait; - if (crt->direct == 0) + if (crt->direct == DIR_LEFT) { if (crt->ani_wait < 20) crt->y -= 2 * 0x200; @@ -393,7 +393,7 @@ void ActCaret10(CARET *crt) crt->cond = 0; } - if (crt->direct == 0) + if (crt->direct == DIR_LEFT) crt->rect = rcLeft[crt->ani_wait / 2 % 2]; else crt->rect = rcRight[crt->ani_wait / 2 % 2]; From 4c758bb9261d783a439b650f8d84a08df349e7c8 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 5 Aug 2020 22:03:51 +0100 Subject: [PATCH 12/18] Apply more direction macros --- src/Bullet.cpp | 390 ++++++++++++++++++++++++------------------------- 1 file changed, 195 insertions(+), 195 deletions(-) diff --git a/src/Bullet.cpp b/src/Bullet.cpp index 55ba282b..0c864968 100644 --- a/src/Bullet.cpp +++ b/src/Bullet.cpp @@ -79,19 +79,19 @@ void PutBullet(int fx, int fy) { switch (gBul[i].direct) { - case 0: + case DIR_LEFT: x = gBul[i].x - gBul[i].view.front; y = gBul[i].y - gBul[i].view.top; break; - case 1: + case DIR_UP: x = gBul[i].x - gBul[i].view.top; y = gBul[i].y - gBul[i].view.front; break; - case 2: + case DIR_RIGHT: x = gBul[i].x - gBul[i].view.back; y = gBul[i].y - gBul[i].view.top; break; - case 3: + case DIR_DOWN: x = gBul[i].x - gBul[i].view.top; y = gBul[i].y - gBul[i].view.back; break; @@ -216,16 +216,16 @@ void ActBullet_Frontia1(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x600; break; - case 1: + case DIR_UP: bul->ym = -0x600; break; - case 2: + case DIR_RIGHT: bul->xm = 0x600; break; - case 3: + case DIR_DOWN: bul->ym = 0x600; break; } @@ -259,7 +259,7 @@ void ActBullet_Frontia1(BULLET *bul) {136, 80, 152, 80}, }; - if (bul->direct == 0) + if (bul->direct == DIR_LEFT) bul->rect = rcLeft[bul->ani_no]; else bul->rect = rcRight[bul->ani_no]; @@ -283,16 +283,16 @@ void ActBullet_Frontia2(BULLET *bul, int level) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x200; break; - case 1: + case DIR_UP: bul->ym = -0x200; break; - case 2: + case DIR_RIGHT: bul->xm = 0x200; break; - case 3: + case DIR_DOWN: bul->ym = 0x200; break; } @@ -301,8 +301,8 @@ void ActBullet_Frontia2(BULLET *bul, int level) switch (bul->direct) { - case 0: - case 2: + case DIR_LEFT: + case DIR_RIGHT: if (inc % 2) bul->ym = 0x400; else @@ -310,8 +310,8 @@ void ActBullet_Frontia2(BULLET *bul, int level) break; - case 1: - case 3: + case DIR_UP: + case DIR_DOWN: if (inc % 2) bul->xm = 0x400; else @@ -324,24 +324,24 @@ void ActBullet_Frontia2(BULLET *bul, int level) { switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm -= 0x80; break; - case 1: + case DIR_UP: bul->ym -= 0x80; break; - case 2: + case DIR_RIGHT: bul->xm += 0x80; break; - case 3: + case DIR_DOWN: bul->ym += 0x80; break; } switch (bul->direct) { - case 0: - case 2: + case DIR_LEFT: + case DIR_RIGHT: if (bul->count1 % 5 == 2) { if (bul->ym < 0) @@ -352,8 +352,8 @@ void ActBullet_Frontia2(BULLET *bul, int level) break; - case 1u: - case 3u: + case DIR_UP: + case DIR_DOWN: if (bul->count1 % 5 == 2) { if (bul->xm < 0) @@ -408,16 +408,16 @@ void ActBullet_PoleStar(BULLET *bul, int level) // Set speed switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x1000; break; - case 1: + case DIR_UP: bul->ym = -0x1000; break; - case 2: + case DIR_RIGHT: bul->xm = 0x1000; break; - case 3: + case DIR_DOWN: bul->ym = 0x1000; break; } @@ -428,16 +428,16 @@ void ActBullet_PoleStar(BULLET *bul, int level) case 1: switch (bul->direct) { - case 0: + case DIR_LEFT: bul->enemyYL = 0x400; break; - case 1: + case DIR_UP: bul->enemyXL = 0x400; break; - case 2: + case DIR_RIGHT: bul->enemyYL = 0x400; break; - case 3: + case DIR_DOWN: bul->enemyXL = 0x400; break; } @@ -445,16 +445,16 @@ void ActBullet_PoleStar(BULLET *bul, int level) case 2: switch (bul->direct) { - case 0: + case DIR_LEFT: bul->enemyYL = 0x800; break; - case 1: + case DIR_UP: bul->enemyXL = 0x800; break; - case 2: + case DIR_RIGHT: bul->enemyYL = 0x800; break; - case 3: + case DIR_DOWN: bul->enemyXL = 0x800; break; } @@ -487,7 +487,7 @@ void ActBullet_PoleStar(BULLET *bul, int level) switch (level) { case 1: - if (bul->direct == 1 || bul->direct == 3) + if (bul->direct == DIR_UP || bul->direct == DIR_DOWN) bul->rect = rect1[1]; else bul->rect = rect1[0]; @@ -495,7 +495,7 @@ void ActBullet_PoleStar(BULLET *bul, int level) break; case 2: - if (bul->direct == 1 || bul->direct == 3) + if (bul->direct == DIR_UP || bul->direct == DIR_DOWN) bul->rect = rect2[1]; else bul->rect = rect2[0]; @@ -503,7 +503,7 @@ void ActBullet_PoleStar(BULLET *bul, int level) break; case 3: - if (bul->direct == 1 || bul->direct == 3) + if (bul->direct == DIR_UP || bul->direct == DIR_DOWN) bul->rect = rect3[1]; else bul->rect = rect3[0]; @@ -529,10 +529,10 @@ void ActBullet_FireBall(BULLET *bul, int level) 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 (bul->direct == DIR_LEFT && bul->flag & 1) + bul->direct = DIR_RIGHT; + if (bul->direct == DIR_RIGHT && bul->flag & 4) + bul->direct = DIR_LEFT; if (bBreak) { @@ -548,19 +548,19 @@ void ActBullet_FireBall(BULLET *bul, int level) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x400; break; - case 1: + case DIR_UP: bul->xm = gMC.xm; if (gMC.xm < 0) - bul->direct = 0; + bul->direct = DIR_LEFT; else - bul->direct = 2; + bul->direct = DIR_RIGHT; - if (gMC.direct == 0) + if (gMC.direct == DIR_LEFT) bul->xm -= 0x80; else bul->xm += 0x80; @@ -568,17 +568,17 @@ void ActBullet_FireBall(BULLET *bul, int level) bul->ym = -0x5FF; break; - case 2: + case DIR_RIGHT: bul->xm = 0x400; break; - case 3: + case DIR_DOWN: bul->xm = gMC.xm; if (gMC.xm < 0) - bul->direct = 0; + bul->direct = DIR_LEFT; else - bul->direct = 2; + bul->direct = DIR_RIGHT; bul->ym = 0x5FF; @@ -638,7 +638,7 @@ void ActBullet_FireBall(BULLET *bul, int level) if (bul->ani_no > 3) bul->ani_no = 0; - if (bul->direct == 0) + if (bul->direct == DIR_LEFT) bul->rect = rect_left1[bul->ani_no]; else bul->rect = rect_right1[bul->ani_no]; @@ -648,7 +648,7 @@ void ActBullet_FireBall(BULLET *bul, int level) if (bul->ani_no > 2) bul->ani_no = 0; - if (bul->direct == 0) + if (bul->direct == DIR_LEFT) bul->rect = rect_left2[bul->ani_no]; else bul->rect = rect_right2[bul->ani_no]; @@ -711,19 +711,19 @@ void ActBullet_MachineGun(BULLET *bul, int level) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -move; bul->ym = Random(-0xAA, 0xAA); break; - case 1: + case DIR_UP: bul->ym = -move; bul->xm = Random(-0xAA, 0xAA); break; - case 2: + case DIR_RIGHT: bul->xm = move; bul->ym = Random(-0xAA, 0xAA); break; - case 3: + case DIR_DOWN: bul->ym = move; bul->xm = Random(-0xAA, 0xAA); break; @@ -743,10 +743,10 @@ void ActBullet_MachineGun(BULLET *bul, int level) case 2: bul->rect = rect2[bul->direct]; - if (bul->direct == 1 || bul->direct == 3) - SetNpChar(127, bul->x, bul->y, 0, 0, 1, NULL, 0x100); + if (bul->direct == DIR_UP || bul->direct == DIR_DOWN) + SetNpChar(127, bul->x, bul->y, 0, 0, DIR_UP, NULL, 0x100); else - SetNpChar(127, bul->x, bul->y, 0, 0, 0, NULL, 0x100); + SetNpChar(127, bul->x, bul->y, 0, 0, DIR_LEFT, NULL, 0x100); break; @@ -775,21 +775,21 @@ void ActBullet_Missile(BULLET *bul, int level) if (bul->life != 10) bHit = TRUE; - if (bul->direct == 0 && bul->flag & 1) + if (bul->direct == DIR_LEFT && bul->flag & 1) bHit = TRUE; - if (bul->direct == 2 && bul->flag & 4) + if (bul->direct == DIR_RIGHT && bul->flag & 4) bHit = TRUE; - if (bul->direct == 1 && bul->flag & 2) + if (bul->direct == DIR_UP && bul->flag & 2) bHit = TRUE; - if (bul->direct == 3 && bul->flag & 8) + if (bul->direct == DIR_DOWN && bul->flag & 8) bHit = TRUE; - if (bul->direct == 0 && bul->flag & 0x80) + if (bul->direct == DIR_LEFT && bul->flag & 0x80) bHit = TRUE; - if (bul->direct == 0 && bul->flag & 0x20) + if (bul->direct == DIR_LEFT && bul->flag & 0x20) bHit = TRUE; - if (bul->direct == 2 && bul->flag & 0x40) + if (bul->direct == DIR_RIGHT && bul->flag & 0x40) bHit = TRUE; - if (bul->direct == 2 && bul->flag & 0x10) + if (bul->direct == DIR_RIGHT && bul->flag & 0x10) bHit = TRUE; if (bHit) @@ -805,12 +805,12 @@ void ActBullet_Missile(BULLET *bul, int level) switch (bul->direct) { - case 0: - case 2: + case DIR_LEFT: + case DIR_RIGHT: bul->tgt_y = bul->y; break; - case 1: - case 3: + case DIR_UP: + case DIR_DOWN: bul->tgt_x = bul->x; break; } @@ -819,8 +819,8 @@ void ActBullet_Missile(BULLET *bul, int level) { switch (bul->direct) { - case 0: - case 2: + case DIR_LEFT: + case DIR_RIGHT: if (bul->y > gMC.y) bul->ym = 0x100; else @@ -829,8 +829,8 @@ void ActBullet_Missile(BULLET *bul, int level) bul->xm = Random(-0x200, 0x200); break; - case 1: - case 3: + case DIR_UP: + case DIR_DOWN: if (bul->x > gMC.x) bul->xm = 0x100; else @@ -861,16 +861,16 @@ void ActBullet_Missile(BULLET *bul, int level) case 1: switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm += -bul->ani_no; break; - case 1: + case DIR_UP: bul->ym += -bul->ani_no; break; - case 2: + case DIR_RIGHT: bul->xm += bul->ani_no; break; - case 3: + case DIR_DOWN: bul->ym += bul->ani_no; break; } @@ -879,8 +879,8 @@ void ActBullet_Missile(BULLET *bul, int level) { switch (bul->direct) { - case 0: - case 2: + case DIR_LEFT: + case DIR_RIGHT: if (bul->y < bul->tgt_y) bul->ym += 0x20; else @@ -888,8 +888,8 @@ void ActBullet_Missile(BULLET *bul, int level) break; - case 1: - case 3: + case DIR_UP: + case DIR_DOWN: if (bul->x < bul->tgt_x) bul->xm += 0x20; else @@ -1034,16 +1034,16 @@ void ActBullet_Bubblin1(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x600; break; - case 2: + case DIR_RIGHT: bul->xm = 0x600; break; - case 1: + case DIR_UP: bul->ym = -0x600; break; - case 3: + case DIR_DOWN: bul->ym = 0x600; break; } @@ -1053,16 +1053,16 @@ void ActBullet_Bubblin1(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm += 0x2A; break; - case 2: + case DIR_RIGHT: bul->xm -= 0x2A; break; - case 1: + case DIR_UP: bul->ym += 0x2A; break; - case 3: + case DIR_DOWN: bul->ym -= 0x2A; break; } @@ -1099,13 +1099,13 @@ void ActBullet_Bubblin2(BULLET *bul) { BOOL bDelete = FALSE; - if (bul->direct == 0 && bul->flag & 1) + if (bul->direct == DIR_LEFT && bul->flag & 1) bDelete = TRUE; - if (bul->direct == 2 && bul->flag & 4) + if (bul->direct == DIR_RIGHT && bul->flag & 4) bDelete = TRUE; - if (bul->direct == 1 && bul->flag & 2) + if (bul->direct == DIR_UP && bul->flag & 2) bDelete = TRUE; - if (bul->direct == 3 && bul->flag & 8) + if (bul->direct == DIR_DOWN && bul->flag & 8) bDelete = TRUE; if (bDelete) @@ -1122,19 +1122,19 @@ void ActBullet_Bubblin2(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x600; bul->ym = Random(-0x100, 0x100); break; - case 2: + case DIR_RIGHT: bul->xm = 0x600; bul->ym = Random(-0x100, 0x100); break; - case 1: + case DIR_UP: bul->ym = -0x600; bul->xm = Random(-0x100, 0x100); break; - case 3: + case DIR_DOWN: bul->ym = 0x600; bul->xm = Random(-0x100, 0x100); break; @@ -1145,16 +1145,16 @@ void ActBullet_Bubblin2(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm += 0x10; break; - case 2: + case DIR_RIGHT: bul->xm -= 0x10; break; - case 1: + case DIR_UP: bul->ym += 0x10; break; - case 3: + case DIR_DOWN: bul->ym -= 0x10; break; } @@ -1196,9 +1196,9 @@ void ActBullet_Bubblin3(BULLET *bul) PlaySoundObject(100, SOUND_MODE_PLAY); if (gMC.up) - SetBullet(22, bul->x, bul->y, 1); + SetBullet(22, bul->x, bul->y, DIR_UP); else if (gMC.down) - SetBullet(22, bul->x, bul->y, 3); + SetBullet(22, bul->x, bul->y, DIR_DOWN); else SetBullet(22, bul->x, bul->y, gMC.direct); @@ -1212,19 +1212,19 @@ void ActBullet_Bubblin3(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = Random(-0x400, -0x200); bul->ym = (Random(-4, 4) * 0x200) / 2; break; - case 2: + case DIR_RIGHT: bul->xm = Random(0x200, 0x400); bul->ym = (Random(-4, 4) * 0x200) / 2; break; - case 1: + case DIR_UP: bul->ym = Random(-0x400, -0x200); bul->xm = (Random(-4, 4) * 0x200) / 2; break; - case 3: + case DIR_DOWN: bul->ym = Random(0x80, 0x100); bul->xm = (Random(-4, 4) * 0x200) / 2; break; @@ -1290,16 +1290,16 @@ void ActBullet_Spine(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = (-Random(10, 16) * 0x200) / 2; break; - case 1: + case DIR_UP: bul->ym = (-Random(10, 16) * 0x200) / 2; break; - case 2: + case DIR_RIGHT: bul->xm = (Random(10, 16) * 0x200) / 2; break; - case 3: + case DIR_DOWN: bul->ym = (Random(10, 16) * 0x200) / 2; break; } @@ -1336,16 +1336,16 @@ void ActBullet_Spine(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->rect = rcLeft[bul->ani_no]; break; - case 1: + case DIR_UP: bul->rect = rcDown[bul->ani_no]; break; - case 2: + case DIR_RIGHT: bul->rect = rcRight[bul->ani_no]; break; - case 3: + case DIR_DOWN: bul->rect = rcDown[bul->ani_no]; break; } @@ -1372,16 +1372,16 @@ void ActBullet_Sword1(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x800; break; - case 1: + case DIR_UP: bul->ym = -0x800; break; - case 2: + case DIR_RIGHT: bul->xm = 0x800; break; - case 3: + case DIR_DOWN: bul->ym = 0x800; break; } @@ -1415,7 +1415,7 @@ void ActBullet_Sword1(BULLET *bul) if (bul->ani_no > 3) bul->ani_no = 0; - if (bul->direct == 0) + if (bul->direct == DIR_LEFT) bul->rect = rcLeft[bul->ani_no]; else bul->rect = rcRight[bul->ani_no]; @@ -1442,16 +1442,16 @@ void ActBullet_Sword2(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x800; break; - case 1: + case DIR_UP: bul->ym = -0x800; break; - case 2: + case DIR_RIGHT: bul->xm = 0x800; break; - case 3: + case DIR_DOWN: bul->ym = 0x800; break; } @@ -1485,7 +1485,7 @@ void ActBullet_Sword2(BULLET *bul) if (bul->ani_no > 3) bul->ani_no = 0; - if (bul->direct == 0) + if (bul->direct == DIR_LEFT) bul->rect = rcLeft[bul->ani_no]; else bul->rect = rcRight[bul->ani_no]; @@ -1523,16 +1523,16 @@ void ActBullet_Sword3(BULLET *bul) case 1: switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x800; break; - case 1: + case DIR_UP: bul->ym = -0x800; break; - case 2: + case DIR_RIGHT: bul->xm = 0x800; break; - case 3: + case DIR_DOWN: bul->ym = 0x800; break; } @@ -1591,16 +1591,16 @@ void ActBullet_Sword3(BULLET *bul) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->rect = rcLeft[bul->ani_no]; break; - case 1: + case DIR_UP: bul->rect = rcUp[bul->ani_no]; break; - case 2: + case DIR_RIGHT: bul->rect = rcRight[bul->ani_no]; break; - case 3: + case DIR_DOWN: bul->rect = rcDown[bul->ani_no]; break; } @@ -1617,7 +1617,7 @@ void ActBullet_Edge(BULLET *bul) bul->act_no = 1; bul->y -= 12 * 0x200; - if (bul->direct == 0) + if (bul->direct == DIR_LEFT) bul->x += 16 * 0x200; else bul->x -= 16 * 0x200; @@ -1629,7 +1629,7 @@ void ActBullet_Edge(BULLET *bul) ++bul->ani_no; } - if (bul->direct == 0) + if (bul->direct == DIR_LEFT) bul->x -= 2 * 0x200; else bul->x += 2 * 0x200; @@ -1668,7 +1668,7 @@ void ActBullet_Edge(BULLET *bul) {96, 88, 120, 112}, }; - if (bul->direct == 0) + if (bul->direct == DIR_LEFT) bul->rect = rcLeft[bul->ani_no]; else bul->rect = rcRight[bul->ani_no]; @@ -1701,21 +1701,21 @@ void ActBullet_SuperMissile(BULLET *bul, int level) if (bul->life != 10) bHit = TRUE; - if (bul->direct == 0 && bul->flag & 1) + if (bul->direct == DIR_LEFT && bul->flag & 1) bHit = TRUE; - if (bul->direct == 2 && bul->flag & 4) + if (bul->direct == DIR_RIGHT && bul->flag & 4) bHit = TRUE; - if (bul->direct == 1 && bul->flag & 2) + if (bul->direct == DIR_UP && bul->flag & 2) bHit = TRUE; - if (bul->direct == 3 && bul->flag & 8) + if (bul->direct == DIR_DOWN && bul->flag & 8) bHit = TRUE; - if (bul->direct == 0 && bul->flag & 0x80) + if (bul->direct == DIR_LEFT && bul->flag & 0x80) bHit = TRUE; - if (bul->direct == 0 && bul->flag & 0x20) + if (bul->direct == DIR_LEFT && bul->flag & 0x20) bHit = TRUE; - if (bul->direct == 2 && bul->flag & 0x40) + if (bul->direct == DIR_RIGHT && bul->flag & 0x40) bHit = TRUE; - if (bul->direct == 2 && bul->flag & 0x10) + if (bul->direct == DIR_RIGHT && bul->flag & 0x10) bHit = TRUE; if (bHit) @@ -1731,15 +1731,15 @@ void ActBullet_SuperMissile(BULLET *bul, int level) switch (bul->direct) { - case 0: - case 2: + case DIR_LEFT: + case DIR_RIGHT: bul->tgt_y = bul->y; bul->enemyXL = 0x1000; bul->blockXL = 0x1000; break; - case 1: - case 3: + case DIR_UP: + case DIR_DOWN: bul->tgt_x = bul->x; bul->enemyYL = 0x1000; bul->blockYL = 0x1000; @@ -1750,8 +1750,8 @@ void ActBullet_SuperMissile(BULLET *bul, int level) { switch (bul->direct) { - case 0: - case 2: + case DIR_LEFT: + case DIR_RIGHT: if (bul->y > gMC.y) bul->ym = 0x100; else @@ -1760,8 +1760,8 @@ void ActBullet_SuperMissile(BULLET *bul, int level) bul->xm = Random(-0x200, 0x200); break; - case 1: - case 3: + case DIR_UP: + case DIR_DOWN: if (bul->x > gMC.x) bul->xm = 0x100; else @@ -1792,16 +1792,16 @@ void ActBullet_SuperMissile(BULLET *bul, int level) case 1: switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm += -bul->ani_no; break; - case 1: + case DIR_UP: bul->ym += -bul->ani_no; break; - case 2: + case DIR_RIGHT: bul->xm += bul->ani_no; break; - case 3: + case DIR_DOWN: bul->ym += bul->ani_no; break; } @@ -1810,16 +1810,16 @@ void ActBullet_SuperMissile(BULLET *bul, int level) { switch (bul->direct) { - case 0: - case 2: + case DIR_LEFT: + case DIR_RIGHT: if (bul->y < bul->tgt_y) bul->ym += 0x40; else bul->ym -= 0x40; break; - case 1: - case 3: + case DIR_UP: + case DIR_DOWN: if (bul->x < bul->tgt_x) bul->xm += 0x40; else @@ -1956,16 +1956,16 @@ void ActBullet_Nemesis(BULLET *bul, int level) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x1000; break; - case 1: + case DIR_UP: bul->ym = -0x1000; break; - case 2: + case DIR_RIGHT: bul->xm = 0x1000; break; - case 3: + case DIR_DOWN: bul->ym = 0x1000; break; } @@ -1984,16 +1984,16 @@ void ActBullet_Nemesis(BULLET *bul, int level) { switch (bul->direct) { - case 0: + case DIR_LEFT: SetNpChar(4, bul->x, bul->y, -0x200, Random(-0x200, 0x200), 2, NULL, 0x100); break; - case 1: + case DIR_UP: SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), -0x200, 2, NULL, 0x100); break; - case 2: + case DIR_RIGHT: SetNpChar(4, bul->x, bul->y, 0x200, Random(-0x200, 0x200), 2, NULL, 0x100); break; - case 3: + case DIR_DOWN: SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), 0x200, 2, NULL, 0x100); break; } @@ -2028,16 +2028,16 @@ void ActBullet_Nemesis(BULLET *bul, int level) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->rect = rcL[bul->ani_no]; break; - case 1: + case DIR_UP: bul->rect = rcU[bul->ani_no]; break; - case 2: + case DIR_RIGHT: bul->rect = rcR[bul->ani_no]; break; - case 3: + case DIR_DOWN: bul->rect = rcD[bul->ani_no]; break; } @@ -2066,16 +2066,16 @@ void ActBullet_Spur(BULLET *bul, int level) switch (bul->direct) { - case 0: + case DIR_LEFT: bul->xm = -0x1000; break; - case 1: + case DIR_UP: bul->ym = -0x1000; break; - case 2: + case DIR_RIGHT: bul->xm = 0x1000; break; - case 3: + case DIR_DOWN: bul->ym = 0x1000; break; } @@ -2085,16 +2085,16 @@ void ActBullet_Spur(BULLET *bul, int level) case 1: switch (bul->direct) { - case 0: + case DIR_LEFT: bul->enemyYL = 0x400; break; - case 1: + case DIR_UP: bul->enemyXL = 0x400; break; - case 2: + case DIR_RIGHT: bul->enemyYL = 0x400; break; - case 3: + case DIR_DOWN: bul->enemyXL = 0x400; break; } @@ -2104,16 +2104,16 @@ void ActBullet_Spur(BULLET *bul, int level) case 2: switch (bul->direct) { - case 0: + case DIR_LEFT: bul->enemyYL = 0x800; break; - case 1: + case DIR_UP: bul->enemyXL = 0x800; break; - case 2: + case DIR_RIGHT: bul->enemyYL = 0x800; break; - case 3: + case DIR_DOWN: bul->enemyXL = 0x800; break; } @@ -2147,7 +2147,7 @@ void ActBullet_Spur(BULLET *bul, int level) switch (level) { case 1: - if (bul->direct == 1 || bul->direct == 3) + if (bul->direct == DIR_UP || bul->direct == DIR_DOWN) bul->rect = rect1[1]; else bul->rect = rect1[0]; @@ -2155,7 +2155,7 @@ void ActBullet_Spur(BULLET *bul, int level) break; case 2: - if (bul->direct == 1 || bul->direct == 3) + if (bul->direct == DIR_UP || bul->direct == DIR_DOWN) bul->rect = rect2[1]; else bul->rect = rect2[0]; @@ -2163,7 +2163,7 @@ void ActBullet_Spur(BULLET *bul, int level) break; case 3: - if (bul->direct == 1 || bul->direct == 3) + if (bul->direct == DIR_UP || bul->direct == DIR_DOWN) bul->rect = rect3[1]; else bul->rect = rect3[0]; @@ -2229,7 +2229,7 @@ void ActBullet_SpurTail(BULLET *bul, int level) switch (level) { case 1: - if (bul->direct == 0 || bul->direct == 2) + if (bul->direct == DIR_LEFT || bul->direct == DIR_RIGHT) bul->rect = rc_h_lv1[bul->ani_no]; else bul->rect = rc_v_lv1[bul->ani_no]; @@ -2237,7 +2237,7 @@ void ActBullet_SpurTail(BULLET *bul, int level) break; case 2: - if (bul->direct == 0 || bul->direct == 2) + if (bul->direct == DIR_LEFT || bul->direct == DIR_RIGHT) bul->rect = rc_h_lv2[bul->ani_no]; else bul->rect = rc_v_lv2[bul->ani_no]; @@ -2245,7 +2245,7 @@ void ActBullet_SpurTail(BULLET *bul, int level) break; case 3: - if (bul->direct == 0 || bul->direct == 2) + if (bul->direct == DIR_LEFT || bul->direct == DIR_RIGHT) bul->rect = rc_h_lv3[bul->ani_no]; else bul->rect = rc_v_lv3[bul->ani_no]; From 90d57b7d1bdfdefe9bcaa6b1e3820da05477f7d0 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 5 Aug 2020 22:06:53 +0100 Subject: [PATCH 13/18] More direction macros --- src/Bullet.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Bullet.cpp b/src/Bullet.cpp index 0c864968..cbba5918 100644 --- a/src/Bullet.cpp +++ b/src/Bullet.cpp @@ -794,7 +794,7 @@ void ActBullet_Missile(BULLET *bul, int level) if (bHit) { - SetBullet(level + 15, bul->x, bul->y, 0); + SetBullet(level + 15, bul->x, bul->y, DIR_LEFT); bul->cond = 0; } @@ -1550,9 +1550,9 @@ void ActBullet_Sword3(BULLET *bul) PlaySoundObject(106, SOUND_MODE_PLAY); if (++bul->count1 % 2) - SetBullet(23, bul->x, bul->y, 0); + SetBullet(23, bul->x, bul->y, DIR_LEFT); else - SetBullet(23, bul->x, bul->y, 2); + SetBullet(23, bul->x, bul->y, DIR_RIGHT); } if (++bul->count1 == 5) @@ -1577,9 +1577,9 @@ void ActBullet_Sword3(BULLET *bul) PlaySoundObject(106, SOUND_MODE_PLAY); if (Random(0, 1) % 2) - SetBullet(23, bul->x + (Random(-0x40, 0x40) * 0x200), bul->y + (Random(-0x40, 0x40) * 0x200), 0); + SetBullet(23, bul->x + (Random(-0x40, 0x40) * 0x200), bul->y + (Random(-0x40, 0x40) * 0x200), DIR_LEFT); else - SetBullet(23, bul->x + (Random(-0x40, 0x40) * 0x200), bul->y + (Random(-0x40, 0x40) * 0x200), 2); + SetBullet(23, bul->x + (Random(-0x40, 0x40) * 0x200), bul->y + (Random(-0x40, 0x40) * 0x200), DIR_RIGHT); } if (bul->act_wait > 50) @@ -1720,7 +1720,7 @@ void ActBullet_SuperMissile(BULLET *bul, int level) if (bHit) { - SetBullet(level + 30, bul->x, bul->y, 0); + SetBullet(level + 30, bul->x, bul->y, DIR_LEFT); bul->cond = 0; } @@ -1985,16 +1985,16 @@ void ActBullet_Nemesis(BULLET *bul, int level) switch (bul->direct) { case DIR_LEFT: - SetNpChar(4, bul->x, bul->y, -0x200, Random(-0x200, 0x200), 2, NULL, 0x100); + SetNpChar(4, bul->x, bul->y, -0x200, Random(-0x200, 0x200), DIR_RIGHT, NULL, 0x100); break; case DIR_UP: - SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), -0x200, 2, NULL, 0x100); + SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), -0x200, DIR_RIGHT, NULL, 0x100); break; case DIR_RIGHT: - SetNpChar(4, bul->x, bul->y, 0x200, Random(-0x200, 0x200), 2, NULL, 0x100); + SetNpChar(4, bul->x, bul->y, 0x200, Random(-0x200, 0x200), DIR_RIGHT, NULL, 0x100); break; case DIR_DOWN: - SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), 0x200, 2, NULL, 0x100); + SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), 0x200, DIR_RIGHT, NULL, 0x100); break; } } From d12ee0813f59299bf1cebf13d72cfe22985c9de4 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 5 Aug 2020 22:09:05 +0100 Subject: [PATCH 14/18] Remove some trailing commas --- src/Back.h | 2 +- src/Caret.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Back.h b/src/Back.h index 68ff03e8..aa5efad1 100644 --- a/src/Back.h +++ b/src/Back.h @@ -11,7 +11,7 @@ enum BACKGROUND_TYPE_BLACK = 4, // No background - just black BACKGROUND_TYPE_AUTOSCROLL = 5, // Constantly scrolls to the left (used by Ironhead) BACKGROUND_TYPE_OUTSIDE_WITH_WIND = 6, // Fancy parallax scrolling, items are blown to the left (used by bkMoon) - BACKGROUND_TYPE_OUTSIDE = 7, // Fancy parallax scrolling (used by bkFog) + BACKGROUND_TYPE_OUTSIDE = 7 // Fancy parallax scrolling (used by bkFog) }; typedef struct BACK diff --git a/src/Caret.cpp b/src/Caret.cpp index 75be00be..057b58d7 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -620,7 +620,7 @@ CARETFUNCTION gpCaretFuncTbl[18] = ActCaret14, ActCaret15, ActCaret16, - ActCaret17, + ActCaret17 }; void ActCaret(void) From a2ecd752717febcda3bcb91e3a06a2ab7ce94202 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 11 Aug 2020 00:06:25 +0100 Subject: [PATCH 15/18] Restore an original struct name This was buried in the Linux port --- src/Input.cpp | 2 +- src/Input.h | 4 ++-- src/Main.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Input.cpp b/src/Input.cpp index 86905b6a..95e3a2a9 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -161,7 +161,7 @@ BOOL CALLBACK EnumDevices_Callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) return DIENUM_STOP; } -BOOL GetJoystickStatus(JOYSTICK_STATUS *status) +BOOL GetJoystickStatus(DIRECTINPUTSTATUS *status) { DIJOYSTATE joystate; diff --git a/src/Input.h b/src/Input.h index feaf9178..6f733486 100644 --- a/src/Input.h +++ b/src/Input.h @@ -2,7 +2,7 @@ #include "WindowsWrapper.h" -struct JOYSTICK_STATUS +struct DIRECTINPUTSTATUS { BOOL bLeft; BOOL bRight; @@ -13,5 +13,5 @@ struct JOYSTICK_STATUS void ReleaseDirectInput(void); BOOL InitDirectInput(HINSTANCE hinst, HWND hWnd); -BOOL GetJoystickStatus(JOYSTICK_STATUS *status); +BOOL GetJoystickStatus(DIRECTINPUTSTATUS *status); BOOL ResetJoystickStatus(void); diff --git a/src/Main.cpp b/src/Main.cpp index c1a19d1b..2acff283 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -775,7 +775,7 @@ BOOL SystemTask(void) void JoystickProc(void) { int i; - JOYSTICK_STATUS status; + DIRECTINPUTSTATUS status; if (!GetJoystickStatus(&status)) return; From e41d4472ec1dd7b4bd4312982ebddfc78b86f1b2 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 11 Aug 2020 00:09:17 +0100 Subject: [PATCH 16/18] Another authentic struct name --- src/Config.cpp | 12 ++++++------ src/Config.h | 6 +++--- src/Main.cpp | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Config.cpp b/src/Config.cpp index 4c2d6d69..20606385 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -10,10 +10,10 @@ const char* const gConfigName = "Config.dat"; const char* const gProof = "DOUKUTSU20041206"; -BOOL LoadConfigData(CONFIG *conf) +BOOL LoadConfigData(CONFIGDATA *conf) { // Clear old configuration data - memset(conf, 0, sizeof(CONFIG)); + memset(conf, 0, sizeof(CONFIGDATA)); // Get path char path[MAX_PATH]; @@ -25,7 +25,7 @@ BOOL LoadConfigData(CONFIG *conf) return FALSE; // Read data - size_t fread_result = fread(conf, sizeof(CONFIG), 1, fp); // Not the original name + size_t fread_result = fread(conf, sizeof(CONFIGDATA), 1, fp); // Not the original name // Close file fclose(fp); @@ -33,17 +33,17 @@ BOOL LoadConfigData(CONFIG *conf) // Check if version is not correct, and return if it failed if (fread_result != 1 || strcmp(conf->proof, gProof)) { - memset(conf, 0, sizeof(CONFIG)); + memset(conf, 0, sizeof(CONFIGDATA)); return FALSE; } return TRUE; } -void DefaultConfigData(CONFIG *conf) +void DefaultConfigData(CONFIGDATA *conf) { // Clear old configuration data - memset(conf, 0, sizeof(CONFIG)); + memset(conf, 0, sizeof(CONFIGDATA)); // Fun fact: The Linux port added this line: // conf->display_mode = 1; diff --git a/src/Config.h b/src/Config.h index a62d3559..d80dd5c8 100644 --- a/src/Config.h +++ b/src/Config.h @@ -2,7 +2,7 @@ #include "WindowsWrapper.h" -struct CONFIG +struct CONFIGDATA { char proof[0x20]; char font_name[0x40]; @@ -17,5 +17,5 @@ struct CONFIG extern const char* const gConfigName; extern const char* const gProof; -BOOL LoadConfigData(CONFIG *conf); -void DefaultConfigData(CONFIG *conf); +BOOL LoadConfigData(CONFIGDATA *conf); +void DefaultConfigData(CONFIGDATA *conf); diff --git a/src/Main.cpp b/src/Main.cpp index 2acff283..f98b41b1 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -125,7 +125,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine strcpy(gDataPath, gModulePath); strcat(gDataPath, "\\data"); - CONFIG conf; + CONFIGDATA conf; if (!LoadConfigData(&conf)) DefaultConfigData(&conf); From c8e1e7aa0abd8805536678a9cd520dd6d696b50f Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 11 Aug 2020 00:13:35 +0100 Subject: [PATCH 17/18] Another authentic struct name --- src/Profile.cpp | 12 ++++++------ src/Profile.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Profile.cpp b/src/Profile.cpp index 2b78a369..c12a3bfb 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -40,7 +40,7 @@ BOOL IsProfile(void) BOOL SaveProfile(const char *name) { FILE *fp; - PROFILE profile; + PROFILEDATA profile; const char *FLAG = "FLAG"; char path[MAX_PATH]; @@ -57,7 +57,7 @@ BOOL SaveProfile(const char *name) return FALSE; // Set up profile - memset(&profile, 0, sizeof(PROFILE)); + memset(&profile, 0, sizeof(PROFILEDATA)); memcpy(profile.code, gProfileCode, sizeof(profile.code)); memcpy(profile.FLAG, FLAG, sizeof(profile.FLAG)); profile.stage = gStageNo; @@ -80,7 +80,7 @@ BOOL SaveProfile(const char *name) memcpy(profile.flags, gFlagNPC, sizeof(profile.flags)); // Write to file - fwrite(&profile, sizeof(PROFILE), 1, fp); + fwrite(&profile, sizeof(PROFILEDATA), 1, fp); fclose(fp); return TRUE; @@ -89,7 +89,7 @@ BOOL SaveProfile(const char *name) BOOL LoadProfile(const char *name) { FILE *fp; - PROFILE profile; + PROFILEDATA profile; char path[MAX_PATH]; // Get path @@ -115,8 +115,8 @@ BOOL LoadProfile(const char *name) // Read data fseek(fp, 0, SEEK_SET); - memset(&profile, 0, sizeof(PROFILE)); - fread(&profile, sizeof(PROFILE), 1, fp); + memset(&profile, 0, sizeof(PROFILEDATA)); + fread(&profile, sizeof(PROFILEDATA), 1, fp); fclose(fp); // Set things diff --git a/src/Profile.h b/src/Profile.h index 7dd6ad0c..c7e0650f 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -6,7 +6,7 @@ #include "SelStage.h" #include "Stage.h" -typedef struct PROFILE +typedef struct PROFILEDATA { char code[8]; int stage; @@ -29,7 +29,7 @@ typedef struct PROFILE signed char permit_mapping[0x80]; char FLAG[4]; unsigned char flags[1000]; -} PROFILE; +} PROFILEDATA; extern const char* const gDefaultName; extern const char* const gProfileCode; From 20cbb8cc733f10d5156cf8fa6f2e165d0a3fccbb Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sat, 29 Aug 2020 17:03:26 +0100 Subject: [PATCH 18/18] Unlist the dead branches, and reformat the readme Now actually readable in a text editor --- README.md | 68 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 933cb8ae..b63977c6 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,12 @@ ## Table of Contents -This repo has multiple branches: +This repo has two main branches: Branch | Description --------|-------- -[accurate](https://www.github.com/Clownacy/CSE2/tree/accurate) | The main decompilation branch. The code intended to be as close to the original as possible, down to all the bugs and platform-dependencies. +[accurate](https://www.github.com/Clownacy/CSE2/tree/accurate) | The main decompilation branch. The code is intended to be as close to the original as possible, down to all the bugs and platform-dependencies. [portable](https://www.github.com/Clownacy/CSE2/tree/portable) | This branch ports the engine away from WinAPI and DirectX, and addresses numerous portability issues, allowing it to run on other platforms. -[enhanced-lite](https://www.github.com/Clownacy/CSE2/tree/enhanced-lite) | Based on the `portable` branch, this branch is **intended for modders**, and adds several enhancements and features to the engine. -[enhanced](https://www.github.com/Clownacy/CSE2/tree/enhanced) | Based on the `enhanced-lite` branch, this branch is **intended for players**, and adds further enhancements and features to the engine. -[emscripten](https://www.github.com/Clownacy/CSE2/tree/emscripten) | Modifies the engine to build with Emscripten, [allowing it to run in web browsers](http://sonicresearch.org/clownacy/cave.html) (no longer maintained). -[wii](https://www.github.com/Clownacy/CSE2/tree/wii) | Ports the engine to the Nintendo Wii (no longer maintained). # CSE2 @@ -21,31 +17,58 @@ CSE2 is a decompilation of Cave Story. ## Background -When Pixel made Cave Story, he compiled the original Windows EXE with no optimisations. This left the generated assembly code extremely verbose and easy to read. It also made the code very decompiler-friendly, since the assembly could be mapped directly back to the original C(++) code. +When Pixel made Cave Story, he compiled the original Windows EXE with no +optimisations. This left the generated assembly code extremely verbose and easy +to read. It also made the code very decompiler-friendly, since the assembly +could be mapped directly back to the original C(++) code. -Technically, this alone made a decompilation feasible, as was the case for [the Super Mario 64 decompilation project](https://github.com/n64decomp/sm64) - however, there was more to be found... +Technically, this alone made a decompilation feasible, as was the case for [the +Super Mario 64 decompilation project](https://github.com/n64decomp/sm64) - +however, there was more to be found... -In 2007, a Linux port of Cave Story was made by Peter Mackay and Simon Parzer. Details about it can be found on [Peter's old blog](https://web.archive.org/web/20070911202919/http://aaiiee.wordpress.com:80/). This port received an update in 2011, including two shiny new executables. What Peter and Simon didn't realise was that they left huge amounts of debugging information in these executables, including the names of every C++ source file, as well as the variables, functions, and structs they contained. +In 2007, a Linux port of Cave Story was made by Peter Mackay and Simon Parzer. +Details about it can be found on [Peter's old blog](https://web.archive.org/web/20070911202919/http://aaiiee.wordpress.com:80/). +This port received an update in 2011, including two shiny new executables. What +Peter and Simon didn't realise was that they left huge amounts of debugging +information in these executables, including the names of every C++ source file, +as well as the variables, functions, and structs they contained. -This was a goldmine of information about not just the game's inner-workings, but its _source code._ This is the same lucky-break [the Diablo decompilation project](https://github.com/diasurgical/devilution) had. With it, much of the game's code was pre-documented and explained _for_ us, saving us the effort of doing it ourselves. In fact, the combination of easy-to-decompile code, and a near-full set of function/variable names, reduced much of the decompilation process to mere copy-paste. +This was a goldmine of information about not just the game's inner-workings, but +its _source code._ This is the same lucky-break [the Diablo decompilation project](https://github.com/diasurgical/devilution) +had. With it, much of the game's code was pre-documented and explained _for_ us, +saving us the effort of doing it ourselves. In fact, the combination of +easy-to-decompile code, and a near-full set of function/variable names, reduced +much of the decompilation process to mere copy-paste. -To top it all off, some of Cave Story's original source code would eventually see the light of day... +To top it all off, some of Cave Story's original source code would eventually +see the light of day... -In early 2018, the Organya music engine was [released on GitHub](https://github.com/shbow/organya) by an old friend of Pixel's. On top of providing an insight into Pixel's coding style, this helped with figuring out one of the most complex parts of Cave Story's codebase. +In early 2018, the Organya music engine was [released on GitHub](https://github.com/shbow/organya) +by an old friend of Pixel's. On top of providing an insight into Pixel's coding +style, this helped with figuring out one of the most complex parts of Cave +Story's codebase. -And... that's it! It's not often that a game this decompilable comes along, so I'm glad that Cave Story was one of them. [Patching a dusty old executable from 2004 has its downsides](https://github.com/Clownacy/Cave-Story-Mod-Loader/blob/master/src/mods/graphics_enhancement/widescreen/patch_camera.c). +And... that's it! It's not often that a game this decompilable comes along, so +I'm glad that Cave Story was one of them. [Patching a dusty old executable from 2004 has its downsides](https://github.com/Clownacy/Cave-Story-Mod-Loader/blob/master/src/mods/graphics_enhancement/widescreen/patch_camera.c). ## Building ### Visual Studio .NET 2003 -Project files for Visual Studio .NET 2003 are available, and can be found in the 'vs2003' folder. +Project files for Visual Studio .NET 2003 are available, and can be found in the +'vs2003' folder. -As proven by the original `Doukutsu.exe`'s [Rich Header](http://bytepointer.com/articles/the_microsoft_rich_header.htm), Pixel used Visual Studio .NET 2003 to compile Cave Story. This means these project files allow us to check the accuracy of the decompilation by comparing the generated assembly code to that of the original executable. The tool for this can be found in the 'devilution' folder. +As proven by the original `Doukutsu.exe`'s [Rich Header](http://bytepointer.com/articles/the_microsoft_rich_header.htm), +Pixel used Visual Studio .NET 2003 to compile Cave Story. This means these +project files allow us to check the accuracy of the decompilation by comparing +the generated assembly code to that of the original executable. The tool for +this can be found in the 'devilution' folder. ### CMake (Visual Studio & MinGW-w64) -Switch to the terminal (Visual Studio users should open the [Developer Command Prompt](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs)) and `cd` into this folder. After that, generate the files for your build system with: +Switch to the terminal (Visual Studio users should open the [Developer Command Prompt](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs)) +and `cd` into this folder. After that, generate the files for your build system +with: ``` cmake -B build -DCMAKE_BUILD_TYPE=Release @@ -71,9 +94,11 @@ You can then compile CSE2 with this command: cmake --build build --config Release ``` -If you're a Visual Studio user, you can open the generated `CSE2.sln` file instead, which can be found in the `build` folder. +If you're a Visual Studio user, you can open the generated `CSE2.sln` file +instead, which can be found in the `build` folder. -Once built, the executable can be found in the `game_english`/`game_japanese` folder, depending on the selected language. +Once built, the executable can be found in the `game_english`/`game_japanese` +folder, depending on the selected language. ### Makefile (MinGW-w64) \[deprecated - use CMake instead\] @@ -89,8 +114,11 @@ Name | Function You can pass your own compiler flags by defining `CXXFLAGS`. -Once built, the executable can be found in the `game_english`/`game_japanese` folder, depending on the selected language. +Once built, the executable can be found in the `game_english`/`game_japanese` +folder, depending on the selected language. ## Licensing -Being a decompilation, the majority of the code in this project belongs to Daisuke "Pixel" Amaya - not us. We've yet to agree on a licence for our own code. +Being a decompilation, the majority of the code in this project belongs to +Daisuke "Pixel" Amaya - not us. We've yet to agree on a licence for our own +code.