diff --git a/msvc2003/devilution/comparer-config.toml b/msvc2003/devilution/comparer-config.toml index 922dd4ff..a2fda3bd 100644 --- a/msvc2003/devilution/comparer-config.toml +++ b/msvc2003/devilution/comparer-config.toml @@ -614,6 +614,18 @@ addr = 0x41FE70 name = "PlaySoundObject" addr = 0x420640 +[[func]] +name = "TransferStage" +addr = 0x420BE0 + +[[func]] +name = "ChangeMusic" +addr = 0x420EE0 + +[[func]] +name = "ReCallMusic" +addr = 0x420F50 + [[func]] name = "InitStar" addr = 0x420FA0 diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 5473113a..ec80dd17 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -53,14 +53,14 @@ void SetUniqueParameter(NPCHAR *npc) npc->view.bottom = gNpcTable[code].view.bottom << 9; } -bool LoadEvent(const char *path_event) +BOOL LoadEvent(const char *path_event) { char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, path_event); FILE *fp = fopen(path, "rb"); if (fp == NULL) - return false; + return FALSE; //Read "PXE" check char code[4]; @@ -71,7 +71,7 @@ bool LoadEvent(const char *path_event) // The original game forgot to close the file here fclose(fp); #endif - return false; + return FALSE; } //Get amount of NPCs @@ -128,7 +128,7 @@ bool LoadEvent(const char *path_event) } 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) @@ -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]; @@ -254,7 +254,7 @@ bool SetBulletObject(int x, int y, int val) } if (!t) - return false; + return FALSE; n = Random(1, 10 * 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].exp = val; 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++) { @@ -294,11 +294,11 @@ bool SetLifeObject(int x, int y, int val) gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits; gNPC[n].exp = val; SetUniqueParameter(&gNPC[n]); - return true; + return TRUE; } } - return false; + return FALSE; } void VanishNpChar(NPCHAR *npc) diff --git a/src/NpChar.h b/src/NpChar.h index ac3e0886..79dde896 100644 --- a/src/NpChar.h +++ b/src/NpChar.h @@ -83,13 +83,13 @@ extern int gSuperXpos; extern int gSuperYpos; 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 SetDestroyNpChar(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); -bool SetBulletObject(int x, int y, int val); -bool SetLifeObject(int x, int y, int val); +BOOL SetBulletObject(int x, int y, int val); +BOOL SetLifeObject(int x, int y, int val); void VanishNpChar(NPCHAR *npc); void PutNpChar(int fx, int fy); void ActNpChar(); diff --git a/src/Stage.cpp b/src/Stage.cpp index 9c732c08..54bdbadb 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -132,7 +132,7 @@ const STAGE_TABLE gTMT[95] = { BOOL TransferStage(int no, int w, int x, int y) { //Move character - SetMyCharPosition(x << 13, y << 13); + SetMyCharPosition(x * 0x10 * 0x200, y * 0x10 * 0x200); BOOL bError = FALSE; @@ -166,7 +166,7 @@ BOOL TransferStage(int no, int w, int x, int y) bError = TRUE; //Load background - strcpy(path, gTMT[no].back); + sprintf(path, "%s", gTMT[no].back); if (!InitBack(path, gTMT[no].bkType)) bError = TRUE; @@ -183,28 +183,21 @@ BOOL TransferStage(int no, int w, int x, int y) bError = TRUE; if (bError) - { - printf("Failed to load stage %d\n", no); return FALSE; - } - else - { - //Load map name - ReadyMapName(gTMT[no].name); - StartTextScript(w); - SetFrameMyChar(); - ClearBullet(); - InitCaret(); - ClearValueView(); - ResetQuake(); - InitBossChar(gTMT[no].boss_no); - ResetFlash(); - gStageNo = no; - return TRUE; - } + //Load map name + ReadyMapName(gTMT[no].name); - return FALSE; + StartTextScript(w); + SetFrameMyChar(); + ClearBullet(); + InitCaret(); + ClearValueView(); + ResetQuake(); + InitBossChar(gTMT[no].boss_no); + ResetFlash(); + gStageNo = no; + return TRUE; } //Music @@ -264,22 +257,22 @@ int gMusicNo; void ChangeMusic(int no) { - if (!no || no != gMusicNo) - { - //Stop and keep track of old song - gOldPos = GetOrganyaPosition(); - gOldNo = gMusicNo; - StopOrganyaMusic(); + if (no && no == gMusicNo) + return; - //Load .org - LoadOrganya(gMusicTable[no]); + //Stop and keep track of old song + gOldPos = GetOrganyaPosition(); + gOldNo = gMusicNo; + StopOrganyaMusic(); - //Reset position, volume, and then play the song - ChangeOrganyaVolume(100); - SetOrganyaPosition(0); - PlayOrganyaMusic(); - gMusicNo = no; - } + //Load .org + LoadOrganya(gMusicTable[no]); + + //Reset position, volume, and then play the song + ChangeOrganyaVolume(100); + SetOrganyaPosition(0); + PlayOrganyaMusic(); + gMusicNo = no; } void ReCallMusic() diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 8d90f8bf..0b6ae794 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -112,7 +112,7 @@ void EncryptionBinaryData2(uint8_t *pData, int size) } //Load generic .tsc -bool LoadTextScript2(const char *name) +BOOL LoadTextScript2(const char *name) { //Get path char path[260]; @@ -120,12 +120,12 @@ bool LoadTextScript2(const char *name) gTS.size = GetFileSizeLong(path); if (gTS.size == -1) - return false; + return FALSE; //Open file FILE *fp = fopen(path, "rb"); if (fp == NULL) - return false; + return FALSE; //Read data fread(gTS.data, 1, gTS.size, fp); @@ -137,11 +137,11 @@ bool LoadTextScript2(const char *name) //Decrypt data EncryptionBinaryData2((uint8_t*)gTS.data, gTS.size); - return true; + return TRUE; } //Load stage .tsc -bool LoadTextScript_Stage(const char *name) +BOOL LoadTextScript_Stage(const char *name) { //Open Head.tsc char path[PATH_LENGTH]; @@ -149,11 +149,11 @@ bool LoadTextScript_Stage(const char *name) long head_size = GetFileSizeLong(path); if (head_size == -1) - return false; + return FALSE; FILE *fp = fopen(path, "rb"); if (fp == NULL) - return false; + return FALSE; //Read Head.tsc fread(gTS.data, 1, head_size, fp); @@ -166,11 +166,11 @@ bool LoadTextScript_Stage(const char *name) long body_size = GetFileSizeLong(path); if (body_size == -1) - return false; + return FALSE; fp = fopen(path, "rb"); if (fp == NULL) - return false; + return FALSE; //Read stage's tsc fread(&gTS.data[head_size], 1, body_size, fp); @@ -181,7 +181,7 @@ bool LoadTextScript_Stage(const char *name) //Set parameters gTS.size = head_size + body_size; strcpy(gTS.path, name); - return true; + return TRUE; } //Get current path diff --git a/src/TextScr.h b/src/TextScr.h index 90008c0e..0e7d11e3 100644 --- a/src/TextScr.h +++ b/src/TextScr.h @@ -60,8 +60,8 @@ struct TEXT_SCRIPT BOOL InitTextScript2(); void EndTextScript(); void EncryptionBinaryData2(uint8_t *pData, int size); -bool LoadTextScript2(const char *name); -bool LoadTextScript_Stage(const char *name); +BOOL LoadTextScript2(const char *name); +BOOL LoadTextScript_Stage(const char *name); void GetTextScriptPath(char *path); BOOL StartTextScript(int no); void StopTextScript();