From 0f87d1ee8f5baf42e36fb2b4e26d8780fd79a9ee Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 28 Jan 2019 10:14:32 +0000 Subject: [PATCH 1/9] Added bunch of First Cave objects --- Makefile | 2 + src/NpcAct.h | 9 +++ src/NpcAct000.cpp | 2 + src/NpcAct020.cpp | 29 +++++++ src/NpcAct060.cpp | 191 ++++++++++++++++++++++++++++++++++++++++++++++ src/NpcAct200.cpp | 24 ++++++ src/NpcTbl.cpp | 8 +- 7 files changed, 261 insertions(+), 4 deletions(-) create mode 100644 src/NpcAct060.cpp create mode 100644 src/NpcAct200.cpp diff --git a/Makefile b/Makefile index 34111235..1a196823 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,8 @@ SOURCES = \ MycParam \ NpcAct000 \ NpcAct020 \ + NpcAct060 \ + NpcAct200 \ NpChar \ NpcHit \ NpcTbl \ diff --git a/src/NpcAct.h b/src/NpcAct.h index aee50daa..c0c4277f 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -1,4 +1,7 @@ +#pragma once + #include "NpChar.h" + void ActNpc000(NPCHAR *npc); void ActNpc001(NPCHAR *npc); void ActNpc002(NPCHAR *npc); @@ -12,6 +15,12 @@ void ActNpc016(NPCHAR *npc); void ActNpc017(NPCHAR *npc); void ActNpc018(NPCHAR *npc); +void ActNpc020(NPCHAR *npc); void ActNpc021(NPCHAR *npc); void ActNpc032(NPCHAR *npc); + +void ActNpc064(NPCHAR *npc); +void ActNpc065(NPCHAR *npc); + +void ActNpc211(NPCHAR *npc); diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 260d541c..9a956ab2 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -1,5 +1,7 @@ #include "WindowsWrapper.h" +#include "NpcAct.h" + #include "MyChar.h" #include "NpChar.h" #include "Game.h" diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index 4075ba9d..b5439ff2 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -1,5 +1,7 @@ #include "WindowsWrapper.h" +#include "NpcAct.h" + #include "MyChar.h" #include "NpChar.h" #include "Game.h" @@ -7,6 +9,33 @@ #include "Back.h" #include "Triangle.h" +//Computer +void ActNpc020(NPCHAR *npc) +{ + RECT rcLeft[1]; + RECT rcRight[3]; + + rcLeft[0] = {288, 16, 320, 40}; + + rcRight[0] = {288, 40, 320, 64}; + rcRight[1] = {288, 40, 320, 64}; + rcRight[2] = {288, 64, 320, 88}; + + if (++npc->ani_wait > 3) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 0; + + if (npc->direct == 0) + npc->rect = rcLeft[0]; + else + npc->rect = rcRight[npc->ani_no]; +} + //Chest (open) void ActNpc021(NPCHAR *npc) { diff --git a/src/NpcAct060.cpp b/src/NpcAct060.cpp new file mode 100644 index 00000000..2f0d9426 --- /dev/null +++ b/src/NpcAct060.cpp @@ -0,0 +1,191 @@ +#include "WindowsWrapper.h" + +#include "NpcAct.h" + +#include "MyChar.h" +#include "NpChar.h" +#include "Game.h" +#include "Sound.h" +#include "Back.h" +#include "Triangle.h" + +//First Cave Critter +void ActNpc064(NPCHAR *npc) +{ + RECT rcLeft[3]; + RECT rcRight[3]; + + rcLeft[0] = {0, 0, 16, 16}; + rcLeft[1] = {16, 0, 32, 16}; + rcLeft[2] = {32, 0, 48, 16}; + + rcRight[0] = {0, 16, 16, 32}; + rcRight[1] = {16, 16, 32, 32}; + rcRight[2] = {32, 16, 48, 32}; + + switch (npc->act_no) + { + case 0: //Init + npc->y += 0x600; + npc->act_no = 1; + + case 1: //Waiting + //Look at player + if (npc->x <= gMC.x) + npc->direct = 2; + else + npc->direct = 0; + + if (npc->tgt_x < 100) + ++npc->tgt_x; + + //Open eyes near player + if (npc->act_wait < 8 || npc->x - 0xE000 >= gMC.x || npc->x + 0xE000 <= gMC.x || npc->y - 0xA000 >= gMC.y || npc->y + 0xA000 <= gMC.y) + { + if (npc->act_wait < 8) + ++npc->act_wait; + npc->ani_no = 0; + } + else + { + npc->ani_no = 1; + } + + //Jump if attacked + if (npc->shock) + { + npc->act_no = 2; + npc->ani_no = 0; + npc->act_wait = 0; + } + + //Jump if player is nearby + if (npc->act_wait >= 8 && npc->tgt_x >= 100 && npc->x - 0x8000 < gMC.x && npc->x + 0x8000 > gMC.x && npc->y - 0xA000 < gMC.y && npc->y + 0x6000 > gMC.y) + { + npc->act_no = 2; + npc->ani_no = 0; + npc->act_wait = 0; + } + break; + + case 2: //Going to jump + if (++npc->act_wait > 8) + { + //Set jump state + npc->act_no = 3; + npc->ani_no = 2; + + //Jump + npc->ym = -0x5FF; + PlaySoundObject(30, 1); + + //Jump in facing direction + if (npc->direct) + npc->xm = 0x100; + else + npc->xm = -0x100; + } + break; + + case 3: //Jumping + //Land + if (npc->flag & 8) + { + npc->xm = 0; + npc->act_wait = 0; + npc->ani_no = 0; + npc->act_no = 1; + PlaySoundObject(23, 1); + } + break; + } + + //Gravity + npc->ym += 0x40; + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + + //Move + npc->x += npc->xm; + npc->y += npc->ym; + + //Set framerect + if (npc->direct == 0) + npc->rect = rcLeft[npc->ani_no]; + else + npc->rect = rcRight[npc->ani_no]; +} + + +//First Cave Bat +void ActNpc065(NPCHAR *npc) +{ + switch (npc->act_no) + { + case 0: + npc->tgt_x = npc->x; + npc->tgt_y = npc->y; + npc->count1 = 120; + npc->act_no = 1; + npc->act_wait = Random(0, 50); + // Fallthrough + + case 1: + if (++npc->act_wait >= 50) + { + npc->act_wait = 0; + npc->act_no = 2; + npc->ym = 0x300; + } + + break; + + case 2: + if (gMC.x >= npc->x) + npc->direct = 2; + else + npc->direct = 0; + + if (npc->tgt_y < npc->y) + npc->ym -= 0x10; + if (npc->tgt_y > npc->y) + npc->ym += 0x10; + if (npc->ym > 0x300) + npc->ym = 0x300; + if (npc->ym < -0x300) + npc->ym = -0x300; + + break; + } + + npc->x += npc->xm; + npc->y += npc->ym; + + RECT rect_left[4]; + RECT rect_right[4]; + + rect_left[0] = {32, 32, 48, 48}; + rect_left[1] = {48, 32, 64, 48}; + rect_left[2] = {64, 32, 80, 48}; + rect_left[3] = {80, 32, 96, 48}; + + rect_right[0] = {32, 48, 48, 64}; + rect_right[1] = {48, 48, 64, 64}; + rect_right[2] = {64, 48, 80, 64}; + rect_right[3] = {80, 48, 96, 64}; + + if (++npc->ani_wait > 1) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 2) + npc->ani_no = 0; + + if (npc->direct == 0) + npc->rect = rect_left[npc->ani_no]; + else + npc->rect = rect_right[npc->ani_no]; +} + \ No newline at end of file diff --git a/src/NpcAct200.cpp b/src/NpcAct200.cpp new file mode 100644 index 00000000..27606a48 --- /dev/null +++ b/src/NpcAct200.cpp @@ -0,0 +1,24 @@ +#include "WindowsWrapper.h" + +#include "NpcAct.h" + +#include "MyChar.h" +#include "NpChar.h" +#include "Game.h" +#include "Sound.h" +#include "Back.h" +#include "Triangle.h" + +//Spikes (small) +void ActNpc211(NPCHAR *npc) +{ + RECT rects[4]; + + rects[0] = {256, 200, 272, 216}; + rects[1] = {272, 200, 288, 216}; + rects[2] = {288, 200, 304, 216}; + rects[3] = {304, 200, 320, 216}; + + npc->rect = rects[npc->code_event]; +} + \ No newline at end of file diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index 227fdb2a..c3dd2779 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -76,7 +76,7 @@ NPCFUNCTION gpNpcFuncTbl[] = ActNpc017, ActNpc018, nullptr, - nullptr, + ActNpc020, ActNpc021, nullptr, nullptr, @@ -120,6 +120,8 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, nullptr, + ActNpc064, + ActNpc065, nullptr, nullptr, nullptr, @@ -265,9 +267,7 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, nullptr, - nullptr, - nullptr, - nullptr, + ActNpc211, nullptr, nullptr, nullptr, From 56d249283dcc74a1ae4dc3c83b0518d4a15183d9 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 28 Jan 2019 10:15:27 +0000 Subject: [PATCH 2/9] Made NPC000 use a switchcase --- src/NpcAct000.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/NpcAct000.cpp b/src/NpcAct000.cpp index 9a956ab2..641b7306 100644 --- a/src/NpcAct000.cpp +++ b/src/NpcAct000.cpp @@ -15,12 +15,15 @@ void ActNpc000(NPCHAR *npc) RECT rect[1]; rect[0] = {0x00, 0x00, 0x10, 0x10}; - if (!npc->act_no) + switch (npc->act_no) { - npc->act_no = 1; + case 0: + npc->act_no = 1; - if (npc->direct == 2) - npc->y += 0x2000; + if (npc->direct == 2) + npc->y += 0x2000; + + break; } npc->rect = rect[0]; From daa858f09cac0319b6699c3d55780bb2d8a3c001 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 28 Jan 2019 11:11:35 +0000 Subject: [PATCH 3/9] More First Cave objects (also Kazuma's shelter ones) --- Makefile | 2 + src/NpcAct.h | 12 +++++ src/NpcAct020.cpp | 69 +++++++++++++++++++++++++++- src/NpcAct040.cpp | 75 ++++++++++++++++++++++++++++++ src/NpcAct060.cpp | 115 +++++++++++++++++++++++++++++++++++++++++++++- src/NpcAct200.cpp | 1 - src/NpcAct340.cpp | 18 ++++++++ src/NpcTbl.cpp | 15 +++--- 8 files changed, 296 insertions(+), 11 deletions(-) create mode 100644 src/NpcAct040.cpp create mode 100644 src/NpcAct340.cpp diff --git a/Makefile b/Makefile index 1a196823..9d2f51c2 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,10 @@ SOURCES = \ MycParam \ NpcAct000 \ NpcAct020 \ + NpcAct040 \ NpcAct060 \ NpcAct200 \ + NpcAct340 \ NpChar \ NpcHit \ NpcTbl \ diff --git a/src/NpcAct.h b/src/NpcAct.h index c0c4277f..3564a298 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -17,10 +17,22 @@ void ActNpc018(NPCHAR *npc); void ActNpc020(NPCHAR *npc); void ActNpc021(NPCHAR *npc); +void ActNpc022(NPCHAR *npc); +void ActNpc023(NPCHAR *npc); + +void ActNpc039(NPCHAR *npc); + +void ActNpc059(NPCHAR *npc); + +void ActNpc062(NPCHAR *npc); void ActNpc032(NPCHAR *npc); void ActNpc064(NPCHAR *npc); void ActNpc065(NPCHAR *npc); +void ActNpc073(NPCHAR *npc); + void ActNpc211(NPCHAR *npc); + +void ActNpc359(NPCHAR *npc); diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index b5439ff2..fadd16a2 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -57,6 +57,56 @@ void ActNpc021(NPCHAR *npc) npc->rect = rect[0]; } +//Teleporter +void ActNpc022(NPCHAR *npc) +{ + RECT rect[2]; + + rect[0] = {240, 16, 264, 48}; + rect[1] = {248, 152, 272, 184}; + + switch (npc->act_no) + { + case 0: + npc->ani_no = 0; + break; + + case 1: + if (++npc->ani_no > 1) + npc->ani_no = 0; + + break; + } + + npc->rect = rect[npc->ani_no]; +} + +//Teleporter lights +void ActNpc023(NPCHAR *npc) +{ + RECT rect[8]; + + rect[0] = {264, 16, 288, 20}; + rect[1] = {264, 20, 288, 24}; + rect[2] = {264, 24, 288, 28}; + rect[3] = {264, 28, 288, 32}; + rect[4] = {264, 32, 288, 36}; + rect[5] = {264, 36, 288, 40}; + rect[6] = {264, 40, 288, 44}; + rect[7] = {264, 44, 288, 48}; + + if (++npc->ani_wait > 1) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 7) + npc->ani_no = 0; + + npc->rect = rect[npc->ani_no]; +} + //Life capsule void ActNpc032(NPCHAR *npc) { @@ -74,4 +124,21 @@ void ActNpc032(NPCHAR *npc) npc->ani_no = 0; npc->rect = rect[npc->ani_no]; -} \ No newline at end of file +} + +//Save sign +void ActNpc039(NPCHAR *npc) +{ + RECT rect[2]; + + rect[0] = {224, 64, 240, 80}; + rect[1] = {240, 64, 256, 80}; + + if (npc->direct == 0) + npc->ani_no = 0; + else + npc->ani_no = 1; + + npc->rect = rect[npc->ani_no]; +} +>>>>>>> More First Cave objects (also Kazuma's shelter ones) diff --git a/src/NpcAct040.cpp b/src/NpcAct040.cpp new file mode 100644 index 00000000..3b58c384 --- /dev/null +++ b/src/NpcAct040.cpp @@ -0,0 +1,75 @@ +#include "WindowsWrapper.h" + +#include "NpcAct.h" + +#include "MyChar.h" +#include "NpChar.h" +#include "Game.h" +#include "Sound.h" +#include "Back.h" +#include "Triangle.h" + +//Eye door +void ActNpc059(NPCHAR *npc) +{ + RECT rcLeft[4]; + + rcLeft[0] = {224, 16, 240, 40}; + rcLeft[1] = {208, 80, 224, 104}; + rcLeft[2] = {224, 80, 240, 104}; + rcLeft[3] = {240, 80, 256, 104}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + // Fallthrough + + case 1: + if (npc->x - 0x8000 < gMC.x && npc->x + 0x8000 > gMC.x && npc->y - 0x8000 < gMC.y && npc->y + 0x8000 > gMC.y) + { + npc->act_no = 2; + npc->ani_wait = 0; + } + + break; + + case 2: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no == 2) + npc->act_no = 3; + + break; + + case 3: + if (npc->x - 0x8000 >= gMC.x || npc->x + 0x8000 <= gMC.x || npc->y - 0x8000 >= gMC.y || npc->y + 0x8000 <= gMC.y) + { + npc->act_no = 4; + npc->ani_wait = 0; + } + + break; + + case 4: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + --npc->ani_no; + } + + if (npc->ani_no == 0) + npc->act_no = 1; + + break; + } + + if (npc->shock) + npc->rect = rcLeft[3]; + else + npc->rect = rcLeft[npc->ani_no]; +} diff --git a/src/NpcAct060.cpp b/src/NpcAct060.cpp index 2f0d9426..3522bcba 100644 --- a/src/NpcAct060.cpp +++ b/src/NpcAct060.cpp @@ -8,6 +8,75 @@ #include "Sound.h" #include "Back.h" #include "Triangle.h" +#include "Map.h" + +//Kazuma at computer +void ActNpc062(NPCHAR *npc) +{ + RECT rcLeft[3]; + + rcLeft[0] = {272, 192, 288, 216}; + rcLeft[1] = {288, 192, 304, 216}; + rcLeft[2] = {304, 192, 320, 216}; + + switch ( npc->act_no ) + { + case 0: + npc->x -= 0x800; + npc->y += 0x2000; + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + // Fallthrough + + case 1: + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 1) + npc->ani_no = 0; + + if (Random(0, 80) == 1) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + if (Random(0, 120) == 10) + { + npc->act_no = 3; + npc->act_wait = 0; + npc->ani_no = 2; + } + + break; + + case 2: + if (++npc->act_wait > 40) + { + npc->act_no = 3; + npc->act_wait = 0; + npc->ani_no = 2; + } + + break; + + case 3: + if (++npc->act_wait > 80) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + } + + npc->rect = rcLeft[npc->ani_no]; +} //First Cave Critter void ActNpc064(NPCHAR *npc) @@ -116,7 +185,6 @@ void ActNpc064(NPCHAR *npc) npc->rect = rcRight[npc->ani_no]; } - //First Cave Bat void ActNpc065(NPCHAR *npc) { @@ -188,4 +256,47 @@ void ActNpc065(NPCHAR *npc) else npc->rect = rect_right[npc->ani_no]; } - \ No newline at end of file + +//Water droplet +void ActNpc073(NPCHAR *npc) +{ + RECT rect[5]; + + rect[0] = {72, 16, 74, 18}; + rect[1] = {74, 16, 76, 18}; + rect[2] = {76, 16, 78, 18}; + rect[3] = {78, 16, 80, 18}; + rect[4] = {80, 16, 82, 18}; + + npc->ym += 0x20; + npc->ani_no = Random(0, 4); + + if (npc->ym > 0x5FF) + npc->ym = 0x5FF; + + npc->x += npc->xm; + npc->y += npc->ym; + + npc->rect = rect[npc->ani_no]; + + if (npc->direct == 2) + { + npc->rect.top += 2; + npc->rect.bottom += 2; + } + + if (++npc->act_wait > 10) + { + if (npc->flag & 1) + npc->cond = 0; + if (npc->flag & 4) + npc->cond = 0; + if (npc->flag & 8) + npc->cond = 0; + if (npc->flag & 0x100) + npc->cond = 0; + } + + if (npc->y > gMap.length * 0x10 * 0x200) + npc->cond = 0; +} diff --git a/src/NpcAct200.cpp b/src/NpcAct200.cpp index 27606a48..478419a0 100644 --- a/src/NpcAct200.cpp +++ b/src/NpcAct200.cpp @@ -21,4 +21,3 @@ void ActNpc211(NPCHAR *npc) npc->rect = rects[npc->code_event]; } - \ No newline at end of file diff --git a/src/NpcAct340.cpp b/src/NpcAct340.cpp new file mode 100644 index 00000000..c608752b --- /dev/null +++ b/src/NpcAct340.cpp @@ -0,0 +1,18 @@ +#include "WindowsWrapper.h" + +#include "NpcAct.h" + +#include "CommonDefines.h" +#include "MyChar.h" +#include "NpChar.h" +#include "Game.h" +#include "Sound.h" +#include "Back.h" +#include "Triangle.h" + +//Water droplet generator +void ActNpc359(NPCHAR *npc) +{ + if (gMC.x < npc->x + (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.x > npc->x - (((WINDOW_WIDTH / 2) + 160) * 0x200) && gMC.y < npc->y + (((WINDOW_HEIGHT / 2) + 200) * 0x200) && gMC.y > npc->y - (((WINDOW_HEIGHT / 2) + 40) * 0x200) && Random(0, 100) == 2) + SetNpChar(73, npc->x + (Random(-6, 6) * 0x200), npc->y - 0xE00, 0, 0, 0, 0, 0); +} diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index c3dd2779..3ec44444 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -54,7 +54,7 @@ void ReleaseNpcTable() } //Npc function table -NPCFUNCTION gpNpcFuncTbl[] = +NPCFUNCTION gpNpcFuncTbl[361] = { ActNpc000, ActNpc001, @@ -78,6 +78,8 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, ActNpc020, ActNpc021, + ActNpc022, + ActNpc023, nullptr, nullptr, nullptr, @@ -93,6 +95,7 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, nullptr, + ActNpc039, nullptr, nullptr, nullptr, @@ -112,13 +115,10 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, nullptr, + ActNpc059, nullptr, nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, + ActNpc062, nullptr, ActNpc064, ActNpc065, @@ -129,7 +129,7 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, nullptr, - nullptr, + ActNpc073, nullptr, nullptr, nullptr, @@ -415,5 +415,6 @@ NPCFUNCTION gpNpcFuncTbl[] = nullptr, nullptr, nullptr, + ActNpc359, nullptr, }; From 1b733b6a1fcb50d4a45c845dd86dcbbab2a16862 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 28 Jan 2019 11:37:53 +0000 Subject: [PATCH 4/9] More First Cave objects. Also added opening objects. --- Makefile | 2 + src/NpcAct.h | 6 ++ src/NpcAct020.cpp | 20 ++++++ src/NpcAct280.cpp | 153 ++++++++++++++++++++++++++++++++++++++++++++++ src/NpcAct300.cpp | 32 ++++++++++ src/NpcTbl.cpp | 8 +-- 6 files changed, 217 insertions(+), 4 deletions(-) create mode 100644 src/NpcAct280.cpp create mode 100644 src/NpcAct300.cpp diff --git a/Makefile b/Makefile index 9d2f51c2..caf0a4e3 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,8 @@ SOURCES = \ NpcAct040 \ NpcAct060 \ NpcAct200 \ + NpcAct280 \ + NpcAct300 \ NpcAct340 \ NpChar \ NpcHit \ diff --git a/src/NpcAct.h b/src/NpcAct.h index 3564a298..919f4e1c 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -20,6 +20,8 @@ void ActNpc021(NPCHAR *npc); void ActNpc022(NPCHAR *npc); void ActNpc023(NPCHAR *npc); +void ActNpc032(NPCHAR *npc); + void ActNpc039(NPCHAR *npc); void ActNpc059(NPCHAR *npc); @@ -35,4 +37,8 @@ void ActNpc073(NPCHAR *npc); void ActNpc211(NPCHAR *npc); +void ActNpc298(NPCHAR *npc); +void ActNpc299(NPCHAR *npc); +void ActNpc300(NPCHAR *npc); + void ActNpc359(NPCHAR *npc); diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index fadd16a2..7b957da2 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -126,6 +126,26 @@ void ActNpc032(NPCHAR *npc) npc->rect = rect[npc->ani_no]; } +//Life capsule +void ActNpc032(NPCHAR *npc) +{ + RECT rect[2]; + + rect[0] = {32, 96, 48, 112}; + rect[1] = {48, 96, 64, 112}; + + if (++npc->ani_wait > 2) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if ( npc->ani_no > 1 ) + npc->ani_no = 0; + + npc->rect = rect[npc->ani_no]; +} + //Save sign void ActNpc039(NPCHAR *npc) { diff --git a/src/NpcAct280.cpp b/src/NpcAct280.cpp new file mode 100644 index 00000000..583e4c9d --- /dev/null +++ b/src/NpcAct280.cpp @@ -0,0 +1,153 @@ +#include "WindowsWrapper.h" + +#include "NpcAct.h" + +#include "MyChar.h" +#include "NpChar.h" +#include "Game.h" +#include "Sound.h" +#include "Back.h" +#include "Triangle.h" + +//Doctor (opening) +void ActNpc298(NPCHAR *npc) +{ + RECT rc[8]; + + rc[0] = {72, 128, 88, 160}; + rc[1] = {88, 128, 104, 160}; + rc[2] = {104, 128, 120, 160}; + rc[3] = {72, 128, 88, 160}; + rc[4] = {120, 128, 136, 160}; + rc[5] = {72, 128, 88, 160}; + rc[6] = {104, 160, 120, 192}; + rc[7] = {120, 160, 136, 192}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->y -= 0x1000; + // Fallthrough + + case 1: + npc->ani_no = 0; + break; + + case 10: + npc->act_no = 11; + npc->ani_no = 0; + npc->ani_wait = 0; + npc->count1 = 0; + // Fallthrough + + case 11: + if (++npc->ani_wait > 6) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 1) + { + npc->ani_no = 0; + + if (++npc->count1 > 7) + { + npc->ani_no = 0; + npc->act_no = 1; + } + } + + break; + + case 20: + npc->act_no = 21; + npc->ani_no = 2; + npc->ani_wait = 0; + // Fallthrough + + case 21: + if (++npc->ani_wait > 10) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if ( npc->ani_no > 5 ) + npc->ani_no = 2; + + npc->x += 0x100; + + break; + + case 30: + npc->ani_no = 6; + break; + + case 40: + npc->act_no = 41; + npc->ani_no = 6; + npc->ani_wait = 0; + npc->count1 = 0; + // Fallthrough + + case 41: + if (++npc->ani_wait > 6) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 7) + { + npc->ani_no = 6; + + if (++npc->count1 > 7) + { + npc->ani_no = 6; + npc->act_no = 30; + } + } + + break; + } + + npc->rect = rc[npc->ani_no]; +} + +//Balrog/Misery (opening) +void ActNpc299(NPCHAR *npc) +{ + RECT rc[2]; + + rc[0] = {0, 0, 48, 48}; + rc[1] = {48, 0, 96, 48}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + + if (npc->direct == 0) + { + npc->ani_no = 1; + npc->act_wait = 25; + npc->y -= 1600; + } + else + { + npc->ani_no = 0; + npc->act_wait = 0; + } + + break; + } + + if (++npc->act_wait / 50 % 2) + npc->y += 0x40; + else + npc->y -= 0x40; + + npc->rect = rc[npc->ani_no]; +} diff --git a/src/NpcAct300.cpp b/src/NpcAct300.cpp new file mode 100644 index 00000000..fae6fa90 --- /dev/null +++ b/src/NpcAct300.cpp @@ -0,0 +1,32 @@ +#include "WindowsWrapper.h" + +#include "NpcAct.h" + +#include "MyChar.h" +#include "NpChar.h" +#include "Game.h" +#include "Sound.h" +#include "Back.h" +#include "Triangle.h" +#include "Caret.h" + +//Demon crown (opening) +void ActNpc300(NPCHAR *npc) +{ + RECT rc[1]; + + rc[0] = {192, 80, 208, 96}; + + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->y += 0xC00; + break; + } + + if (++npc->ani_wait % 8 == 1) + SetCaret(npc->x + (Random(-8, 8) * 0x200), npc->y + 0x1000, 13, 1); + + npc->rect = rc[0]; +} diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index 3ec44444..b7eaaf16 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -86,7 +86,7 @@ NPCFUNCTION gpNpcFuncTbl[361] = nullptr, nullptr, nullptr, - nullptr, + ActNpc032, nullptr, nullptr, nullptr, @@ -354,9 +354,9 @@ NPCFUNCTION gpNpcFuncTbl[361] = nullptr, nullptr, nullptr, - nullptr, - nullptr, - nullptr, + ActNpc298, + ActNpc299, + ActNpc300, nullptr, nullptr, nullptr, From a26f4b4bce273d36825a3bcf201e0c6cd904de80 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 28 Jan 2019 11:56:48 +0000 Subject: [PATCH 5/9] More First Cave objects --- Makefile | 1 + src/NpcAct.h | 6 ++++ src/NpcAct020.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++++++ src/NpcAct100.cpp | 20 ++++++++++++ src/NpcTbl.cpp | 6 ++-- 5 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 src/NpcAct100.cpp diff --git a/Makefile b/Makefile index caf0a4e3..f60a9b81 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,7 @@ SOURCES = \ NpcAct020 \ NpcAct040 \ NpcAct060 \ + NpcAct100 \ NpcAct200 \ NpcAct280 \ NpcAct300 \ diff --git a/src/NpcAct.h b/src/NpcAct.h index 919f4e1c..8c50ce08 100644 --- a/src/NpcAct.h +++ b/src/NpcAct.h @@ -20,8 +20,12 @@ void ActNpc021(NPCHAR *npc); void ActNpc022(NPCHAR *npc); void ActNpc023(NPCHAR *npc); +void ActNpc030(NPCHAR *npc); + void ActNpc032(NPCHAR *npc); +void ActNpc037(NPCHAR *npc); + void ActNpc039(NPCHAR *npc); void ActNpc059(NPCHAR *npc); @@ -35,6 +39,8 @@ void ActNpc065(NPCHAR *npc); void ActNpc073(NPCHAR *npc); +void ActNpc119(NPCHAR *npc); + void ActNpc211(NPCHAR *npc); void ActNpc298(NPCHAR *npc); diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index 7b957da2..fd5bcbc5 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -8,6 +8,7 @@ #include "Sound.h" #include "Back.h" #include "Triangle.h" +#include "Caret.h" //Computer void ActNpc020(NPCHAR *npc) @@ -107,6 +108,66 @@ void ActNpc023(NPCHAR *npc) npc->rect = rect[npc->ani_no]; } +//Gunsmith +void ActNpc030(NPCHAR *npc) +{ + RECT rc[3]; + + rc[0] = {48, 0, 64, 16}; + rc[1] = {48, 16, 64, 32}; + rc[2] = {0, 32, 16, 48}; + + if (npc->direct != 0) + { + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->y += 0x2000; + npc->ani_no = 2; + break; + } + + if (++npc->act_wait > 100) + { + npc->act_wait = 0; + SetCaret(npc->x, npc->y - 0x400, 5, 0); + } + } + else + { + switch (npc->act_no) + { + case 0: + npc->act_no = 1; + npc->ani_no = 0; + npc->ani_wait = 0; + // Fallthrough + + case 1: + if (Random(0, 120) == 10) + { + npc->act_no = 2; + npc->act_wait = 0; + npc->ani_no = 1; + } + + break; + + case 2: + if (++npc->act_wait > 8) + { + npc->act_no = 1; + npc->ani_no = 0; + } + + break; + } + } + + npc->rect = rc[npc->ani_no]; +} + //Life capsule void ActNpc032(NPCHAR *npc) { @@ -146,6 +207,26 @@ void ActNpc032(NPCHAR *npc) npc->rect = rect[npc->ani_no]; } +//Signpost +void ActNpc037(NPCHAR *npc) +{ + RECT rect[2]; + + rect[0] = {192, 64, 208, 80}; + rect[1] = {208, 64, 224, 80}; + + if (++npc->ani_wait > 1) + { + npc->ani_wait = 0; + ++npc->ani_no; + } + + if (npc->ani_no > 1) + npc->ani_no = 0; + + npc->rect = rect[npc->ani_no]; +} + //Save sign void ActNpc039(NPCHAR *npc) { diff --git a/src/NpcAct100.cpp b/src/NpcAct100.cpp new file mode 100644 index 00000000..3c4b8f2f --- /dev/null +++ b/src/NpcAct100.cpp @@ -0,0 +1,20 @@ +#include "WindowsWrapper.h" + +#include "NpcAct.h" + +#include "MyChar.h" +#include "NpChar.h" +#include "Game.h" +#include "Sound.h" +#include "Back.h" +#include "Triangle.h" + +//Table and chair +void ActNpc119(NPCHAR *npc) +{ + RECT rc[1]; + + rc[0] = {248, 184, 272, 200}; + + npc->rect = rc[0]; +} diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index b7eaaf16..f97117c8 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -86,6 +86,8 @@ NPCFUNCTION gpNpcFuncTbl[361] = nullptr, nullptr, nullptr, + ActNpc030, + nullptr, ActNpc032, nullptr, nullptr, @@ -93,7 +95,7 @@ NPCFUNCTION gpNpcFuncTbl[361] = ActNpc032, nullptr, nullptr, - nullptr, + ActNpc037, nullptr, ActNpc039, nullptr, @@ -175,7 +177,7 @@ NPCFUNCTION gpNpcFuncTbl[361] = nullptr, nullptr, nullptr, - nullptr, + ActNpc119, nullptr, nullptr, nullptr, From 676b0f5894a183254eae96f03d05f811305ee36b Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 28 Jan 2019 14:08:41 +0000 Subject: [PATCH 6/9] Misc Linux fixes --- src/PixTone.cpp | 4 ++-- src/Sound.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PixTone.cpp b/src/PixTone.cpp index 52c1d7a4..7cd05e14 100644 --- a/src/PixTone.cpp +++ b/src/PixTone.cpp @@ -152,7 +152,7 @@ bool MakePixelWaveData(const std::vector& pxtData, uint8_t *data) const int v2 = (int)(uint64_t)pitchOffset % 256; //Input data - data[i] = envelopeTable[(unsigned __int64)((long double)(i << 8) / pxtData[1])] + data[i] = envelopeTable[(uint64_t)((long double)(i << 8) / pxtData[1])] * (pxtData[4] * gWaveModelTable[(size_t)pxtData[2]][a] / 0x40 @@ -167,7 +167,7 @@ bool MakePixelWaveData(const std::vector& pxtData, uint8_t *data) long double newMainOffset; if (gWaveModelTable[(size_t)pxtData[6]][v2] >= 0) newMainOffset = (mainFreq * 2) - * (long double)gWaveModelTable[(size_t)pxtData[6]][(signed int)(unsigned __int64)pitchOffset % 256] + * (long double)gWaveModelTable[(size_t)pxtData[6]][(signed int)(uint64_t)pitchOffset % 256] * pxtData[8] / 64.0 / 64.0 diff --git a/src/Sound.h b/src/Sound.h index 0ffb0ecb..3c02e75f 100644 --- a/src/Sound.h +++ b/src/Sound.h @@ -1,4 +1,5 @@ #pragma once +#include #include class SOUNDBUFFER From 50dd0a40764b3741d7844cd5138ab2fa4e3de714 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 28 Jan 2019 14:09:13 +0000 Subject: [PATCH 7/9] Correct filename capitalisation in stage.tbl This was breaking compatibility with Linux's case-sensitive filesystem --- build/data/stage.tbl | Bin 19000 -> 19000 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/build/data/stage.tbl b/build/data/stage.tbl index f21517d6d9a42a1f9c82f3bd14506b2af0dbef32..3282b582232bb66956037b531d0a7bf5c8cc5e66 100644 GIT binary patch delta 547 zcmYk3O(+Cm9L9Tx*%3BdyFSA1yxR^DWm(_W*MY1k%2kb_R#6;XoTT<5*5jhMNSOoK zdM}QYnhWLNXv=|IC>J-%|D9c}n$PF`zrW{sX08s{)d9XQJb=+9tqejmtf*%W*-DVl_C!6l(>UV2DmG zzC&)#Y*=D9+jS|TJP?K&N#b^h%XeykyT~#P{1~zhE^AdB8jCWsk!MqHk!k#<&f=n3 z(^P9^d@Y$~b$Eoh)n#^w_e>XFP{IN@8siM3xtJPD~Ga_F!o7hXJsGSV` E0@h!@=l}o! delta 544 zcmYk2JxGE<7{|FcUz1WA)C%qW5Z?qr$R|0;xlcu;! zdXaG3b*|QRooD1o|4Np>S!YBUR#qWnD>IY#Y}ybmKciLDdBs7CGWL!lGEZU6szbwR z5KMH~cW2?tm8Xh2Iy883uk*8U0y~%nPZJG9l_m*%=_O)VsWQndLQ7F`==@tHgFT;M zlx8&{g5Bi<*`K$V#l0iA@_M1E_|QK*_zQUJ#}Hwl>5<{WI1rwVzUKfnx(yBw%Vu%& zIA3R8c#5D01b6xpJZ>bwp4Q=JuJBLUiI&k+O+_xDqgIH=a`^Bv)}e#`n|b^w2rvAx z1m3mS5NSS>Dm+tJQz5%Vkk=()c6V6-C~k=9lrCae_(?n@zQ60tLM`Qo&k-HAk{<)q sI?1)@H1tv$IT%>uxs_|{pZR+!fd~9>qdYXoY)^~Kw?Sm5W$ Date: Mon, 28 Jan 2019 17:27:12 +0000 Subject: [PATCH 8/9] Merged stage table back into the code --- build/data/stage.tbl | Bin 19000 -> 0 bytes build/data/stage.tbl.jp | Bin 19000 -> 0 bytes src/Game.cpp | 3 +- src/MapName.cpp | 2 +- src/MapName.h | 2 +- src/Stage.cpp | 147 ++++++++++++++++++++++++++++------------ src/Stage.h | 2 - 7 files changed, 106 insertions(+), 50 deletions(-) delete mode 100644 build/data/stage.tbl delete mode 100644 build/data/stage.tbl.jp diff --git a/build/data/stage.tbl b/build/data/stage.tbl deleted file mode 100644 index 3282b582232bb66956037b531d0a7bf5c8cc5e66..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19000 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 diff --git a/build/data/stage.tbl.jp b/build/data/stage.tbl.jp deleted file mode 100644 index 0a8310468cd4c5d7c8da0eae8b4f911297ad5762..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19000 zcmdU1TW=dh6do?6@GtlUs6fSg>?BRnxN)6`6c7!YW=V`4Z`nAZ^08*6~cxe$50!jr6eS$}xP%DH$2=ND)@!D~c^?ct*>sXK%ujkCpoNvx$&N(yA z34#AkV6u2r(Wi5`*QrH!p$NvoZ>txte+J$TNolvRfI4aV)1bpcik8SF@{6vyQ*0cv zZ}}xTvHVi7Tl&s0&A{v|#KGtxj#Iwt77Q~8p~paLk#Ux?dE?uPAkWKp|k?9TdXWhV&$mg+vNKcmJv^-P2S=!mp{Jv*~Bkg%GgzJfYY`(Yg?k3#k z1jE5}yBqSLemD3r_%yh;Z}p>(3`aVzHuUIgdo4D8myJPjtY=EMuT7P%?#&u~U~%I3 zoSR2DY~&F?Zhu}5%CffgD1c@Q%LkL*{G#z?Md*orR3}S+RewipQ2R(_6W%2-f{i?w z-Y~k5FDkFQDBqSz6)$#nZA`BQW(Nv0ASvw)j=j7#*sXlsF$ZBdlEpcwSG~b;M$XE9 zS=NzB^~LH+2mP?fYk@R`Roy4Poj2ss$j?p8Fgw@uXFA|-HTA^KE$Tij?npWL3vu%( zmJianq&`!*)zKCkueO)2;}gp{lZ$@-a>qBrMjO8ycMhTR+RggfFV$5eC(K{z zwM-b_wu?(x{g&HDvwo#^4^sw`$u7AlvL7${t}|~2a!ip}y`7CQ?0bbF^AzG(?S6gd z`c2S72quq)UIB;I6TPb5+`4AW1Veai{}^!#Imfh#sv)|8gYF-4QpN3cIRYwi%m(`% zKZgXW{qD3n$8j#0yRkW_eO$Xpq#?v9$DcubGJ3dw;9e7+k3s@L<)Qsm?e)s{fKe;G z0s+?lMX$6@41jfL$^)LOF}<>q2jD@ISPfazkx#Ud2b+W1N25*+!wM@LlVB}Ed0 zpKBa_;C&l;u(h(YkKH=bKQ@P^$Bh%&9CkPyu$p%E0m3WM%0C%(akTF(Et~ML{X^Gx5e}REBYs`!M5>5YBFKgSs^dUI$gLce>&_eDu=uK7#4@K~ABbzH*s50-y09z^XvIdv9d z#KBiiH68A?4IEg*LF$a{;0 zS>Vumf}?z?;*vO#`75ovsLs$09MnGQFV}96a~y_4%L}+&tNJd}D~hA`AUI3xV{$HA z1ZtydmKO?_fuSE)3Y*9c!b2-|{xRhG@NS_{_piz-c7F}rFJbnP_OlBpIna8g&(%;~ zi?c5QGi(fT;1y;1uj>q8sl@TMt>B}z(bb;-A55=Cv&CW_IOebpcf|3oTvhj$%EsSD zX?RQ?jr{{GmW`eFV*eO)@~}|H=wUq(_hNpR?t?ehOQw76EmdRkIIZ>%R2Z_c4>kt2 zF2yNwR81hvKGNAsE)rNMk0Z7ZU5C?mGQe#BRzr5DaE}lN?!)v7zpc*ITFL`H*}1bj zrEfHt2he)OewP~iyw*JZ9);u3H~aRwM;>hSirv4W=O2+-qYdnSyE~<;{?YeZEjIFq zeZRdm8TiB=QwVozJO_@NnssVC3bPODcLDz`67^R)P6Yd)jo)Q{mC@w;peyb5a4%^$Xh4Cgm3 zme?Gcei9f+H*iqB>H-e+JIEsX9}=N`;5d=3H?6~M+^fAG?81DI$s?ii6I8#lIsZ^K zF!+x@8gl?ce`0HEMwnsrWHR?>ma{+e> z_pq@K7MD;Q9oFw~6Z5-i4^a=vb{IhOJ6nt41@(i@8Nu9Y2!ZpWMk*74#(v2#NkOhd}rtU$-D<{ St_#tVdjRVnRF=pM_kRH(&R;tK diff --git a/src/Game.cpp b/src/Game.cpp index 1209e9bb..1a953ed4 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -594,7 +594,7 @@ bool Game() char path[PATH_LENGTH]; sprintf(path, "%s/npc.tbl", gDataPath); - if (LoadNpcTable(path) && InitStageTable()) + if (LoadNpcTable(path)) { InitTextScript2(); InitSkipFlags(); @@ -614,7 +614,6 @@ bool Game() EndMapData(); EndTextScript(); - ReleaseStageTable(); ReleaseNpcTable(); ReleaseCreditScript(); } diff --git a/src/MapName.cpp b/src/MapName.cpp index e8d70e9a..0db417a6 100644 --- a/src/MapName.cpp +++ b/src/MapName.cpp @@ -8,7 +8,7 @@ MAP_NAME gMapName; RECT rc = { 0, 0, 160, 12 }; -void ReadyMapName(char *str) +void ReadyMapName(const char *str) { //Reset map name flags gMapName.flag = 0; diff --git a/src/MapName.h b/src/MapName.h index c9f651c2..ea5e4415 100644 --- a/src/MapName.h +++ b/src/MapName.h @@ -6,7 +6,7 @@ struct MAP_NAME char name[0x20]; }; -void ReadyMapName(char *str); +void ReadyMapName(const char *str); void PutMapName(bool bMini); void StartMapName(); void RestoreMapName(); diff --git a/src/Stage.cpp b/src/Stage.cpp index 05ce86c3..b9e6fe25 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -19,52 +19,111 @@ #include "Back.h" #include "Stage.h" -STAGE_TABLE *gTMT; +#ifdef JAPANESE +#define STAGE_ENTRY(parts, map, bkType, back, npc, boss, boss_no, name_en, name_jp) {parts, map, bkType, back, npc, boss, boss_no, name_jp} +#else +#define STAGE_ENTRY(parts, map, bkType, back, npc, boss, boss_no, name_en, name_jp) {parts, map, bkType, back, npc, boss, boss_no, name_en} +#endif + int gStageNo; -//Stage table functions -bool InitStageTable() -{ - //Get path - char path[PATH_LENGTH]; - sprintf(path, "%s/stage.tbl", gDataPath); - - //Open file - SDL_RWops *fp = SDL_RWFromFile(path, "rb"); - - if (!fp) - return false; - - //Get amount of stages and allocate stage data - size_t stages = SDL_RWsize(fp) / 0xC8; - gTMT = (STAGE_TABLE*)calloc(stages, sizeof(STAGE_TABLE)); - - //Read data - for (size_t i = 0; i < stages; i++) - { - SDL_RWread(fp, &gTMT[i].parts, 1, 0x20); - SDL_RWread(fp, &gTMT[i].map, 1, 0x20); - gTMT[i].bkType = SDL_ReadLE32(fp); - SDL_RWread(fp, &gTMT[i].back, 1, 0x20); - SDL_RWread(fp, &gTMT[i].npc, 1, 0x20); - SDL_RWread(fp, &gTMT[i].boss, 1, 0x20); - gTMT[i].boss_no = SDL_ReadU8(fp); - SDL_RWread(fp, &gTMT[i].name, 1, 0x20); - - //Padding (3 bytes) - uint8_t nul[3]; - SDL_RWread(fp, &nul, 1, 3); - } - - SDL_RWclose(fp); - return true; -} - -void ReleaseStageTable() -{ - free(gTMT); - gTMT = nullptr; -} +const STAGE_TABLE gTMT[95] = { + STAGE_ENTRY("0", "0", 4, "bk0", "Guest", "0", 0, "Null", "無"), + STAGE_ENTRY("Pens", "Pens1", 1, "bkBlue", "Guest", "0", 0, "Arthur's House", "アーサーの家"), + STAGE_ENTRY("Eggs", "Eggs", 1, "bkGreen", "Eggs1", "Ravil", 0, "Egg Corridor", "タマゴ回廊"), + STAGE_ENTRY("EggX", "EggX", 4, "bk0", "Eggs1", "0", 0, "Egg No. 00", "タマゴ No.00"), + STAGE_ENTRY("EggIn", "Egg6", 4, "bk0", "Eggs1", "0", 0, "Egg No. 06", "タマゴ No.06"), + STAGE_ENTRY("Store", "EggR", 4, "bk0", "Eggs1", "0", 0, "Egg Observation Room", "タマゴ監視室"), + STAGE_ENTRY("Weed", "Weed", 1, "bkBlue", "Weed", "0", 0, "Grasstown", "クサムラ"), + STAGE_ENTRY("Barr", "Santa", 4, "bk0", "Weed", "0", 0, "Santa's House", "サンタの家"), + STAGE_ENTRY("Barr", "Chako", 1, "bkBlue", "Guest", "0", 0, "Chaco's House", "チャコの家"), + STAGE_ENTRY("Maze", "MazeI", 4, "bk0", "Maze", "0", 0, "Labyrinth I", "迷宮I"), + STAGE_ENTRY("Sand", "Sand", 1, "bkGreen", "Sand", "Omg", 1, "Sand Zone", "砂区"), + STAGE_ENTRY("Mimi", "Mimi", 1, "bkBlue", "Guest", "0", 0, "Mimiga Village", "ミミガーの村"), + STAGE_ENTRY("Cave", "Cave", 4, "bk0", "Cemet", "0", 0, "First Cave", "最初の洞窟"), + STAGE_ENTRY("Cave", "Start", 4, "bk0", "Cemet", "0", 0, "Start Point", "スタート地点"), + STAGE_ENTRY("Mimi", "Barr", 4, "bk0", "Cemet", "Bllg", 0, "Shack", "バラック小屋"), + STAGE_ENTRY("Mimi", "Pool", 1, "bkBlue", "Guest", "0", 0, "Reservoir", "貯水池"), + STAGE_ENTRY("Mimi", "Cemet", 4, "bk0", "Cemet", "0", 0, "Graveyard", "はかば"), + STAGE_ENTRY("Mimi", "Plant", 1, "bkGreen", "Plant", "0", 0, "Yamashita Farm", "山下農園"), + STAGE_ENTRY("Store", "Shelt", 4, "bk0", "Eggs1", "0", 0, "Shelter", "シェルター"), + STAGE_ENTRY("Pens", "Comu", 1, "bkBlue", "Guest", "0", 0, "Assembly Hall", "集会場"), + STAGE_ENTRY("Mimi", "MiBox", 4, "bk0", "0", "0", 0, "Save Point", "セーブポイント"), + STAGE_ENTRY("Store", "EgEnd1", 4, "bk0", "0", "0", 0, "Side Room", "タマゴ回廊の個室"), + STAGE_ENTRY("Store", "Cthu", 4, "bk0", "0", "0", 0, "Cthulhu's Abode", "クトゥルーの住処"), + STAGE_ENTRY("EggIn", "Egg1", 4, "bk0", "Eggs1", "0", 0, "Egg No. 01", "タマゴ No.01"), + STAGE_ENTRY("Pens", "Pens2", 1, "bkBlue", "Guest", "0", 0, "Arthur's House", "アーサーの家"), + STAGE_ENTRY("Barr", "Malco", 1, "bkBlue", "Weed", "Bllg", 0, "Power Room", "電源室"), + STAGE_ENTRY("Barr", "WeedS", 1, "bkBlue", "0", "0", 0, "Save Point", "セーブポイント"), + STAGE_ENTRY("Store", "WeedD", 1, "bkBlue", "0", "0", 0, "Execution Chamber", "処刑室"), + STAGE_ENTRY("Weed", "Frog", 2, "bkGreen", "Weed", "Frog", 2, "Gum", "ガム"), + STAGE_ENTRY("Sand", "Curly", 4, "bk0", "Sand", "Curly", 0, "Sand Zone Residence", "砂区駐在所"), + STAGE_ENTRY("Pens", "WeedB", 1, "bkBlue", "Ravil", "0", 0, "Grasstown Hut", "クサムラの小屋"), + STAGE_ENTRY("River", "Stream", 5, "bkBlue", "Stream", "IronH", 5, "Main Artery", "大動脈"), + STAGE_ENTRY("Pens", "CurlyS", 4, "bk0", "Sand", "Curly", 0, "Small Room", "小部屋"), + STAGE_ENTRY("Barr", "Jenka1", 4, "bk0", "Sand", "Bllg", 0, "Jenka's House", "ジェンカの家"), + STAGE_ENTRY("Sand", "Dark", 1, "bkBlack", "Sand", "0", 0, "Deserted House", "廃屋"), + STAGE_ENTRY("Gard", "Gard", 1, "bkGard", "Toro", "Bllg", 0, "Sand Zone Storehouse", "砂区倉庫"), + STAGE_ENTRY("Barr", "Jenka2", 4, "bk0", "Sand", "Bllg", 0, "Jenka's House", "ジェンカの家"), + STAGE_ENTRY("Sand", "SandE", 1, "bkGreen", "Sand", "Bllg", 0, "Sand Zone", "砂区"), + STAGE_ENTRY("Maze", "MazeH", 4, "bk0", "Maze", "0", 0, "Labyrinth H", "迷宮H"), + STAGE_ENTRY("Maze", "MazeW", 1, "bkMaze", "Maze", "X", 3, "Labyrinth W", "迷宮W"), + STAGE_ENTRY("Maze", "MazeO", 4, "bk0", "Guest", "0", 0, "Camp", "キャンプ"), + STAGE_ENTRY("Maze", "MazeD", 4, "bk0", "Guest", "Dark", 0, "Clinic Ruins", "診療所跡"), + STAGE_ENTRY("Store", "MazeA", 4, "bk0", "Maze", "0", 0, "Labyrinth Shop", "迷宮の店"), + STAGE_ENTRY("Maze", "MazeB", 1, "bkBlue", "Maze", "0", 0, "Labyrinth B", "迷宮B"), + STAGE_ENTRY("Maze", "MazeS", 2, "bkGray", "Maze", "Bllg", 0, "Boulder Chamber", "大石の塞ぐ所"), + STAGE_ENTRY("Maze", "MazeM", 1, "bkRed", "Maze", "0", 0, "Labyrinth M", "迷宮M"), + STAGE_ENTRY("Cave", "Drain", 3, "bkWater", "Cemet", "0", 0, "Dark Place", "暗い所"), + STAGE_ENTRY("Almond", "Almond", 3, "bkWater", "Cemet", "Almo1", 4, "Core", "コア"), + STAGE_ENTRY("River", "River", 2, "bkGreen", "Weed", "0", 0, "Waterway", "水路"), + STAGE_ENTRY("Eggs", "Eggs2", 1, "bkGreen", "Eggs2", "0", 0, "Egg Corridor?", "タマゴ回廊?"), + STAGE_ENTRY("Store", "Cthu2", 4, "bk0", "Eggs1", "0", 0, "Cthulhu's Abode?", "クトゥルーの住処?"), + STAGE_ENTRY("Store", "EggR2", 4, "bk0", "Eggs1", "TwinD", 6, "Egg Observation Room?", "タマゴ監視室?"), + STAGE_ENTRY("EggX", "EggX2", 4, "bk0", "Eggs1", "0", 0, "Egg No. 00", "タマゴ No.00"), + STAGE_ENTRY("Oside", "Oside", 6, "bkMoon", "Moon", "0", 0, "Outer Wall", "外壁"), + STAGE_ENTRY("Store", "EgEnd2", 4, "bk0", "Eggs1", "0", 0, "Side Room", "タマゴ回廊の個室"), + STAGE_ENTRY("Store", "Itoh", 2, "bkBlue", "Guest", "0", 0, "Storehouse", "倉庫"), + STAGE_ENTRY("Cent", "Cent", 1, "bkGreen", "Guest", "Cent", 0, "Plantation", "大農園"), + STAGE_ENTRY("Jail", "Jail1", 4, "bk0", "Guest", "Cent", 0, "Jail No. 1", "第1牢"), + STAGE_ENTRY("Jail", "Momo", 4, "bk0", "Guest", "0", 0, "Hideout", "カクレガ"), + STAGE_ENTRY("Jail", "lounge", 4, "bk0", "Guest", "0", 0, "Rest Area", "休憩所"), + STAGE_ENTRY("Store", "CentW", 4, "bk0", "Guest", "Cent", 0, "Teleporter", "転送室"), + STAGE_ENTRY("Store", "Jail2", 4, "bk0", "Guest", "Cent", 0, "Jail No. 2", "第2牢"), + STAGE_ENTRY("White", "Blcny1", 7, "bkFog", "Ravil", "Heri", 0, "Balcony", "バルコニー"), + STAGE_ENTRY("Jail", "Priso1", 4, "bkGray", "Red", "0", 0, "Final Cave", "最後の洞窟"), + STAGE_ENTRY("White", "Ring1", 7, "bkFog", "Guest", "Miza", 0, "Throne Room", "王の玉座"), + STAGE_ENTRY("White", "Ring2", 7, "bkFog", "Guest", "Dr", 0, "The King's Table", "王の食卓"), + STAGE_ENTRY("Pens", "Prefa1", 4, "bk0", "0", "0", 0, "Prefab Building", "プレハブ"), + STAGE_ENTRY("Jail", "Priso2", 4, "bkGray", "Red", "0", 0, "Last Cave (Hidden)", "最後の洞窟・裏"), + STAGE_ENTRY("White", "Ring3", 4, "bk0", "Miza", "Almo2", 7, "Black Space", "黒い広間"), + STAGE_ENTRY("Pens", "Little", 2, "bkBlue", "Guest", "0", 0, "Little House", "リトル家"), + STAGE_ENTRY("White", "Blcny2", 7, "bkFog", "Ravil", "Heri", 0, "Balcony", "バルコニー"), + STAGE_ENTRY("Fall", "Fall", 1, "bkFall", "Guest", "Heri", 0, "Fall", "落下"), + STAGE_ENTRY("White", "Kings", 4, "bk0", "Kings", "0", 0, "u", "u"), + STAGE_ENTRY("Pens", "Pixel", 1, "bkBlue", "Guest", "0", 0, "Waterway Cabin", "水路の小部屋"), + STAGE_ENTRY("Maze", "e_Maze", 1, "bkMaze", "Guest", "Maze", 3, "", ""), + STAGE_ENTRY("Barr", "e_Jenk", 4, "bk0", "Sand", "Bllg", 0, "", ""), + STAGE_ENTRY("Barr", "e_Malc", 1, "bkBlue", "Weed", "Bllg", 0, "", ""), + STAGE_ENTRY("Mimi", "e_Ceme", 4, "bk0", "Plant", "0", 0, "", ""), + STAGE_ENTRY("Fall", "e_Sky", 1, "bkFall", "Guest", "Heri", 0, "", ""), + STAGE_ENTRY("Pens", "Prefa2", 4, "bk0", "0", "0", 0, "Prefab House", "プレハブ"), + STAGE_ENTRY("Hell", "Hell1", 2, "bkRed", "Hell", "0", 0, "Sacred Ground - B1", "聖域地下1階"), + STAGE_ENTRY("Hell", "Hell2", 2, "bkRed", "Hell", "0", 0, "Sacred Ground - B2", "聖域地下2階"), + STAGE_ENTRY("Hell", "Hell3", 1, "bkRed", "Hell", "Press", 8, "Sacred Ground - B3", "聖域地下3階"), + STAGE_ENTRY("Cave", "Mapi", 2, "bk0", "Cemet", "0", 0, "Storage", "物置"), + STAGE_ENTRY("Hell", "Hell4", 4, "bk0", "Hell", "0", 0, "Passage?", "通路?"), + STAGE_ENTRY("Hell", "Hell42", 4, "bk0", "Hell", "Press", 8, "Passage?", "通路?"), + STAGE_ENTRY("Hell", "Statue", 1, "bkBlue", "0", "Cent", 0, "Statue Chamber", "石像の間"), + STAGE_ENTRY("Hell", "Ballo1", 2, "bkBlue", "Priest", "Ballos", 9, "Seal Chamber", "封印の間"), + STAGE_ENTRY("White", "Ostep", 7, "bkFog", "0", "0", 0, "Corridor", "わたり廊下"), + STAGE_ENTRY("Labo", "e_Labo", 4, "bk0", "Guest", "0", 0, "", ""), + STAGE_ENTRY("Cave", "Pole", 4, "bk0", "Guest", "0", 0, "Hermit Gunsmith", "はぐれ銃鍛冶"), + STAGE_ENTRY("0", "Island", 4, "bk0", "Island", "0", 0, "", ""), + STAGE_ENTRY("Hell", "Ballo2", 2, "bkBlue", "Priest", "Bllg", 9, "Seal Chamber", "封印の間"), + STAGE_ENTRY("White", "e_Blcn", 7, "bkFog", "Miza", "0", 9, "", ""), + STAGE_ENTRY("Oside", "Clock", 6, "bkMoon", "Moon", "0", 0, "Clock Room", "時計屋"), +}; bool TransferStage(int no, int w, int x, int y) { diff --git a/src/Stage.h b/src/Stage.h index 2fe80b7e..ded03930 100644 --- a/src/Stage.h +++ b/src/Stage.h @@ -12,8 +12,6 @@ struct STAGE_TABLE char name[0x20]; }; -bool InitStageTable(); -void ReleaseStageTable(); bool TransferStage(int no, int w, int x, int y); void ChangeMusic(int no); void ReCallMusic(); From f003626290079abfc3faab3d05e333beaff06aa5 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 28 Jan 2019 17:43:55 +0000 Subject: [PATCH 9/9] Fuck the diffing algoritm --- src/NpcAct020.cpp | 20 -------------------- src/NpcTbl.cpp | 2 -- 2 files changed, 22 deletions(-) diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index fd5bcbc5..4a45ea6e 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -168,25 +168,6 @@ void ActNpc030(NPCHAR *npc) npc->rect = rc[npc->ani_no]; } -//Life capsule -void ActNpc032(NPCHAR *npc) -{ - RECT rect[2]; - rect[0] = {32, 96, 48, 112}; - rect[1] = {48, 96, 64, 112}; - - if (++npc->ani_wait > 2) - { - npc->ani_wait = 0; - ++npc->ani_no; - } - - if (npc->ani_no > 1) - npc->ani_no = 0; - - npc->rect = rect[npc->ani_no]; -} - //Life capsule void ActNpc032(NPCHAR *npc) { @@ -242,4 +223,3 @@ void ActNpc039(NPCHAR *npc) npc->rect = rect[npc->ani_no]; } ->>>>>>> More First Cave objects (also Kazuma's shelter ones) diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index f97117c8..d4631d08 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -92,8 +92,6 @@ NPCFUNCTION gpNpcFuncTbl[361] = nullptr, nullptr, nullptr, - ActNpc032, - nullptr, nullptr, ActNpc037, nullptr,