Merge pull request #23 from Clownacy/master

Loads of First Cave/Kazuma shelter/opening objects
This commit is contained in:
Cucky 2019-01-28 12:45:42 -05:00 committed by GitHub
commit 3158273cea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 980 additions and 77 deletions

View file

@ -58,6 +58,13 @@ SOURCES = \
MycParam \
NpcAct000 \
NpcAct020 \
NpcAct040 \
NpcAct060 \
NpcAct100 \
NpcAct200 \
NpcAct280 \
NpcAct300 \
NpcAct340 \
NpChar \
NpcHit \
NpcTbl \

Binary file not shown.

Binary file not shown.

View file

@ -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();
}

View file

@ -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;

View file

@ -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();

View file

@ -1,4 +1,7 @@
#pragma once
#include "NpChar.h"
void ActNpc000(NPCHAR *npc);
void ActNpc001(NPCHAR *npc);
void ActNpc002(NPCHAR *npc);
@ -12,6 +15,36 @@ void ActNpc016(NPCHAR *npc);
void ActNpc017(NPCHAR *npc);
void ActNpc018(NPCHAR *npc);
void ActNpc020(NPCHAR *npc);
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);
void ActNpc062(NPCHAR *npc);
void ActNpc032(NPCHAR *npc);
void ActNpc064(NPCHAR *npc);
void ActNpc065(NPCHAR *npc);
void ActNpc073(NPCHAR *npc);
void ActNpc119(NPCHAR *npc);
void ActNpc211(NPCHAR *npc);
void ActNpc298(NPCHAR *npc);
void ActNpc299(NPCHAR *npc);
void ActNpc300(NPCHAR *npc);
void ActNpc359(NPCHAR *npc);

View file

@ -1,5 +1,7 @@
#include "WindowsWrapper.h"
#include "NpcAct.h"
#include "MyChar.h"
#include "NpChar.h"
#include "Game.h"
@ -13,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];

View file

@ -1,11 +1,41 @@
#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"
//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)
@ -28,21 +58,168 @@ 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];
}
//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)
{
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];
}
//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)
{
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];
}

75
src/NpcAct040.cpp Normal file
View file

@ -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];
}

302
src/NpcAct060.cpp Normal file
View file

@ -0,0 +1,302 @@
#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 "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)
{
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];
}
//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;
}

20
src/NpcAct100.cpp Normal file
View file

@ -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];
}

23
src/NpcAct200.cpp Normal file
View file

@ -0,0 +1,23 @@
#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];
}

153
src/NpcAct280.cpp Normal file
View file

@ -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];
}

32
src/NpcAct300.cpp Normal file
View file

@ -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];
}

18
src/NpcAct340.cpp Normal file
View file

@ -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);
}

View file

@ -54,7 +54,7 @@ void ReleaseNpcTable()
}
//Npc function table
NPCFUNCTION gpNpcFuncTbl[] =
NPCFUNCTION gpNpcFuncTbl[361] =
{
ActNpc000,
ActNpc001,
@ -76,24 +76,26 @@ NPCFUNCTION gpNpcFuncTbl[] =
ActNpc017,
ActNpc018,
nullptr,
nullptr,
ActNpc020,
ActNpc021,
ActNpc022,
ActNpc023,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
ActNpc030,
nullptr,
ActNpc032,
nullptr,
nullptr,
nullptr,
nullptr,
ActNpc037,
nullptr,
ActNpc039,
nullptr,
nullptr,
nullptr,
@ -113,9 +115,13 @@ NPCFUNCTION gpNpcFuncTbl[] =
nullptr,
nullptr,
nullptr,
ActNpc059,
nullptr,
nullptr,
ActNpc062,
nullptr,
ActNpc064,
ActNpc065,
nullptr,
nullptr,
nullptr,
@ -123,6 +129,7 @@ NPCFUNCTION gpNpcFuncTbl[] =
nullptr,
nullptr,
nullptr,
ActNpc073,
nullptr,
nullptr,
nullptr,
@ -168,6 +175,7 @@ NPCFUNCTION gpNpcFuncTbl[] =
nullptr,
nullptr,
nullptr,
ActNpc119,
nullptr,
nullptr,
nullptr,
@ -259,6 +267,7 @@ NPCFUNCTION gpNpcFuncTbl[] =
nullptr,
nullptr,
nullptr,
ActNpc211,
nullptr,
nullptr,
nullptr,
@ -345,6 +354,9 @@ NPCFUNCTION gpNpcFuncTbl[] =
nullptr,
nullptr,
nullptr,
ActNpc298,
ActNpc299,
ActNpc300,
nullptr,
nullptr,
nullptr,
@ -403,17 +415,6 @@ NPCFUNCTION gpNpcFuncTbl[] =
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
ActNpc359,
nullptr,
};

View file

@ -152,7 +152,7 @@ bool MakePixelWaveData(const std::vector<double>& 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<double>& 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

View file

@ -1,4 +1,5 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
class SOUNDBUFFER

View file

@ -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)
{

View file

@ -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();