Made Stage.cpp ASM-accurate
This commit is contained in:
parent
666269029d
commit
f8d4ae7014
6 changed files with 66 additions and 61 deletions
|
@ -614,6 +614,18 @@ addr = 0x41FE70
|
||||||
name = "PlaySoundObject"
|
name = "PlaySoundObject"
|
||||||
addr = 0x420640
|
addr = 0x420640
|
||||||
|
|
||||||
|
[[func]]
|
||||||
|
name = "TransferStage"
|
||||||
|
addr = 0x420BE0
|
||||||
|
|
||||||
|
[[func]]
|
||||||
|
name = "ChangeMusic"
|
||||||
|
addr = 0x420EE0
|
||||||
|
|
||||||
|
[[func]]
|
||||||
|
name = "ReCallMusic"
|
||||||
|
addr = 0x420F50
|
||||||
|
|
||||||
[[func]]
|
[[func]]
|
||||||
name = "InitStar"
|
name = "InitStar"
|
||||||
addr = 0x420FA0
|
addr = 0x420FA0
|
||||||
|
|
|
@ -53,14 +53,14 @@ void SetUniqueParameter(NPCHAR *npc)
|
||||||
npc->view.bottom = gNpcTable[code].view.bottom << 9;
|
npc->view.bottom = gNpcTable[code].view.bottom << 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadEvent(const char *path_event)
|
BOOL LoadEvent(const char *path_event)
|
||||||
{
|
{
|
||||||
char path[PATH_LENGTH];
|
char path[PATH_LENGTH];
|
||||||
sprintf(path, "%s/%s", gDataPath, path_event);
|
sprintf(path, "%s/%s", gDataPath, path_event);
|
||||||
|
|
||||||
FILE *fp = fopen(path, "rb");
|
FILE *fp = fopen(path, "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
//Read "PXE" check
|
//Read "PXE" check
|
||||||
char code[4];
|
char code[4];
|
||||||
|
@ -71,7 +71,7 @@ bool LoadEvent(const char *path_event)
|
||||||
// The original game forgot to close the file here
|
// The original game forgot to close the file here
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get amount of NPCs
|
//Get amount of NPCs
|
||||||
|
@ -128,7 +128,7 @@ bool LoadEvent(const char *path_event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index)
|
void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index)
|
||||||
|
@ -235,7 +235,7 @@ void SetExpObjects(int x, int y, int exp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetBulletObject(int x, int y, int val)
|
BOOL SetBulletObject(int x, int y, int val)
|
||||||
{
|
{
|
||||||
int tamakazu_ari[10];
|
int tamakazu_ari[10];
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ bool SetBulletObject(int x, int y, int val)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!t)
|
if (!t)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
n = Random(1, 10 * t);
|
n = Random(1, 10 * t);
|
||||||
int bullet_no = tamakazu_ari[n % t];
|
int bullet_no = tamakazu_ari[n % t];
|
||||||
|
@ -272,14 +272,14 @@ bool SetBulletObject(int x, int y, int val)
|
||||||
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
|
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
|
||||||
gNPC[n].exp = val;
|
gNPC[n].exp = val;
|
||||||
SetUniqueParameter(&gNPC[n]);
|
SetUniqueParameter(&gNPC[n]);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetLifeObject(int x, int y, int val)
|
BOOL SetLifeObject(int x, int y, int val)
|
||||||
{
|
{
|
||||||
for (int n = 0x100; n < NPC_MAX; n++)
|
for (int n = 0x100; n < NPC_MAX; n++)
|
||||||
{
|
{
|
||||||
|
@ -294,11 +294,11 @@ bool SetLifeObject(int x, int y, int val)
|
||||||
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
|
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
|
||||||
gNPC[n].exp = val;
|
gNPC[n].exp = val;
|
||||||
SetUniqueParameter(&gNPC[n]);
|
SetUniqueParameter(&gNPC[n]);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VanishNpChar(NPCHAR *npc)
|
void VanishNpChar(NPCHAR *npc)
|
||||||
|
|
|
@ -83,13 +83,13 @@ extern int gSuperXpos;
|
||||||
extern int gSuperYpos;
|
extern int gSuperYpos;
|
||||||
|
|
||||||
void InitNpChar();
|
void InitNpChar();
|
||||||
bool LoadEvent(const char *path_event);
|
BOOL LoadEvent(const char *path_event);
|
||||||
void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index);
|
void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index);
|
||||||
void SetDestroyNpChar(int x, int y, int w, int num);
|
void SetDestroyNpChar(int x, int y, int w, int num);
|
||||||
void SetDestroyNpCharUp(int x, int y, int w, int num);
|
void SetDestroyNpCharUp(int x, int y, int w, int num);
|
||||||
void SetExpObjects(int x, int y, int exp);
|
void SetExpObjects(int x, int y, int exp);
|
||||||
bool SetBulletObject(int x, int y, int val);
|
BOOL SetBulletObject(int x, int y, int val);
|
||||||
bool SetLifeObject(int x, int y, int val);
|
BOOL SetLifeObject(int x, int y, int val);
|
||||||
void VanishNpChar(NPCHAR *npc);
|
void VanishNpChar(NPCHAR *npc);
|
||||||
void PutNpChar(int fx, int fy);
|
void PutNpChar(int fx, int fy);
|
||||||
void ActNpChar();
|
void ActNpChar();
|
||||||
|
|
|
@ -132,7 +132,7 @@ const STAGE_TABLE gTMT[95] = {
|
||||||
BOOL TransferStage(int no, int w, int x, int y)
|
BOOL TransferStage(int no, int w, int x, int y)
|
||||||
{
|
{
|
||||||
//Move character
|
//Move character
|
||||||
SetMyCharPosition(x << 13, y << 13);
|
SetMyCharPosition(x * 0x10 * 0x200, y * 0x10 * 0x200);
|
||||||
|
|
||||||
BOOL bError = FALSE;
|
BOOL bError = FALSE;
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ BOOL TransferStage(int no, int w, int x, int y)
|
||||||
bError = TRUE;
|
bError = TRUE;
|
||||||
|
|
||||||
//Load background
|
//Load background
|
||||||
strcpy(path, gTMT[no].back);
|
sprintf(path, "%s", gTMT[no].back);
|
||||||
if (!InitBack(path, gTMT[no].bkType))
|
if (!InitBack(path, gTMT[no].bkType))
|
||||||
bError = TRUE;
|
bError = TRUE;
|
||||||
|
|
||||||
|
@ -183,28 +183,21 @@ BOOL TransferStage(int no, int w, int x, int y)
|
||||||
bError = TRUE;
|
bError = TRUE;
|
||||||
|
|
||||||
if (bError)
|
if (bError)
|
||||||
{
|
|
||||||
printf("Failed to load stage %d\n", no);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Load map name
|
|
||||||
ReadyMapName(gTMT[no].name);
|
|
||||||
|
|
||||||
StartTextScript(w);
|
//Load map name
|
||||||
SetFrameMyChar();
|
ReadyMapName(gTMT[no].name);
|
||||||
ClearBullet();
|
|
||||||
InitCaret();
|
|
||||||
ClearValueView();
|
|
||||||
ResetQuake();
|
|
||||||
InitBossChar(gTMT[no].boss_no);
|
|
||||||
ResetFlash();
|
|
||||||
gStageNo = no;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
StartTextScript(w);
|
||||||
|
SetFrameMyChar();
|
||||||
|
ClearBullet();
|
||||||
|
InitCaret();
|
||||||
|
ClearValueView();
|
||||||
|
ResetQuake();
|
||||||
|
InitBossChar(gTMT[no].boss_no);
|
||||||
|
ResetFlash();
|
||||||
|
gStageNo = no;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Music
|
//Music
|
||||||
|
@ -264,22 +257,22 @@ int gMusicNo;
|
||||||
|
|
||||||
void ChangeMusic(int no)
|
void ChangeMusic(int no)
|
||||||
{
|
{
|
||||||
if (!no || no != gMusicNo)
|
if (no && no == gMusicNo)
|
||||||
{
|
return;
|
||||||
//Stop and keep track of old song
|
|
||||||
gOldPos = GetOrganyaPosition();
|
|
||||||
gOldNo = gMusicNo;
|
|
||||||
StopOrganyaMusic();
|
|
||||||
|
|
||||||
//Load .org
|
//Stop and keep track of old song
|
||||||
LoadOrganya(gMusicTable[no]);
|
gOldPos = GetOrganyaPosition();
|
||||||
|
gOldNo = gMusicNo;
|
||||||
|
StopOrganyaMusic();
|
||||||
|
|
||||||
//Reset position, volume, and then play the song
|
//Load .org
|
||||||
ChangeOrganyaVolume(100);
|
LoadOrganya(gMusicTable[no]);
|
||||||
SetOrganyaPosition(0);
|
|
||||||
PlayOrganyaMusic();
|
//Reset position, volume, and then play the song
|
||||||
gMusicNo = no;
|
ChangeOrganyaVolume(100);
|
||||||
}
|
SetOrganyaPosition(0);
|
||||||
|
PlayOrganyaMusic();
|
||||||
|
gMusicNo = no;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReCallMusic()
|
void ReCallMusic()
|
||||||
|
|
|
@ -112,7 +112,7 @@ void EncryptionBinaryData2(uint8_t *pData, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load generic .tsc
|
//Load generic .tsc
|
||||||
bool LoadTextScript2(const char *name)
|
BOOL LoadTextScript2(const char *name)
|
||||||
{
|
{
|
||||||
//Get path
|
//Get path
|
||||||
char path[260];
|
char path[260];
|
||||||
|
@ -120,12 +120,12 @@ bool LoadTextScript2(const char *name)
|
||||||
|
|
||||||
gTS.size = GetFileSizeLong(path);
|
gTS.size = GetFileSizeLong(path);
|
||||||
if (gTS.size == -1)
|
if (gTS.size == -1)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
//Open file
|
//Open file
|
||||||
FILE *fp = fopen(path, "rb");
|
FILE *fp = fopen(path, "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
//Read data
|
//Read data
|
||||||
fread(gTS.data, 1, gTS.size, fp);
|
fread(gTS.data, 1, gTS.size, fp);
|
||||||
|
@ -137,11 +137,11 @@ bool LoadTextScript2(const char *name)
|
||||||
|
|
||||||
//Decrypt data
|
//Decrypt data
|
||||||
EncryptionBinaryData2((uint8_t*)gTS.data, gTS.size);
|
EncryptionBinaryData2((uint8_t*)gTS.data, gTS.size);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load stage .tsc
|
//Load stage .tsc
|
||||||
bool LoadTextScript_Stage(const char *name)
|
BOOL LoadTextScript_Stage(const char *name)
|
||||||
{
|
{
|
||||||
//Open Head.tsc
|
//Open Head.tsc
|
||||||
char path[PATH_LENGTH];
|
char path[PATH_LENGTH];
|
||||||
|
@ -149,11 +149,11 @@ bool LoadTextScript_Stage(const char *name)
|
||||||
|
|
||||||
long head_size = GetFileSizeLong(path);
|
long head_size = GetFileSizeLong(path);
|
||||||
if (head_size == -1)
|
if (head_size == -1)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
FILE *fp = fopen(path, "rb");
|
FILE *fp = fopen(path, "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
//Read Head.tsc
|
//Read Head.tsc
|
||||||
fread(gTS.data, 1, head_size, fp);
|
fread(gTS.data, 1, head_size, fp);
|
||||||
|
@ -166,11 +166,11 @@ bool LoadTextScript_Stage(const char *name)
|
||||||
|
|
||||||
long body_size = GetFileSizeLong(path);
|
long body_size = GetFileSizeLong(path);
|
||||||
if (body_size == -1)
|
if (body_size == -1)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
fp = fopen(path, "rb");
|
fp = fopen(path, "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return false;
|
return FALSE;
|
||||||
|
|
||||||
//Read stage's tsc
|
//Read stage's tsc
|
||||||
fread(&gTS.data[head_size], 1, body_size, fp);
|
fread(&gTS.data[head_size], 1, body_size, fp);
|
||||||
|
@ -181,7 +181,7 @@ bool LoadTextScript_Stage(const char *name)
|
||||||
//Set parameters
|
//Set parameters
|
||||||
gTS.size = head_size + body_size;
|
gTS.size = head_size + body_size;
|
||||||
strcpy(gTS.path, name);
|
strcpy(gTS.path, name);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get current path
|
//Get current path
|
||||||
|
|
|
@ -60,8 +60,8 @@ struct TEXT_SCRIPT
|
||||||
BOOL InitTextScript2();
|
BOOL InitTextScript2();
|
||||||
void EndTextScript();
|
void EndTextScript();
|
||||||
void EncryptionBinaryData2(uint8_t *pData, int size);
|
void EncryptionBinaryData2(uint8_t *pData, int size);
|
||||||
bool LoadTextScript2(const char *name);
|
BOOL LoadTextScript2(const char *name);
|
||||||
bool LoadTextScript_Stage(const char *name);
|
BOOL LoadTextScript_Stage(const char *name);
|
||||||
void GetTextScriptPath(char *path);
|
void GetTextScriptPath(char *path);
|
||||||
BOOL StartTextScript(int no);
|
BOOL StartTextScript(int no);
|
||||||
void StopTextScript();
|
void StopTextScript();
|
||||||
|
|
Loading…
Add table
Reference in a new issue