shithub: cstory

Download patch

ref: b7d01aae3fe5a528209b2f1c3cfc1d906475158d
parent: 3e34136f699d679d217653faf1893621cc986ac8
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Aug 21 14:26:20 EDT 2019

Overhauled the Music ID enum

This should be ASM-accurate, since SurfaceID was

--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -316,7 +316,7 @@
 				++Credit.offset;
 				a = GetScriptNumber(&Credit.pData[Credit.offset]);
 				Credit.offset += 4;
-				ChangeMusic(a);
+				ChangeMusic((MusicID)a);
 				return;
 
 			case '~': // Start fading out music
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -121,7 +121,7 @@
 	InitFade();
 	InitFlash();
 	InitBossLife();
-	ChangeMusic(0);
+	ChangeMusic(MUS_SILENCE);
 	TransferStage(72, 100, 3, 3);
 	SetFrameTargetMyChar(16);
 	SetFadeMask();
@@ -315,15 +315,15 @@
 
 	// Set music to character's specific music
 	if (char_type == 1)
-		ChangeMusic(mus_RunningHell);
+		ChangeMusic(MUS_RUNNING_HELL);
 	else if (char_type == 2)
-		ChangeMusic(mus_TorokosTheme);
+		ChangeMusic(MUS_TOROKOS_THEME);
 	else if (char_type == 3)
-		ChangeMusic(mus_White);
+		ChangeMusic(MUS_WHITE);
 	else if (char_type == 4)
-		ChangeMusic(mus_Safety);
+		ChangeMusic(MUS_SAFETY);
 	else
-		ChangeMusic(mus_CaveStory);
+		ChangeMusic(MUS_CAVE_STORY);
 
 	// Reset cliprect, flags, and give the player the Nikumaru counter
 	grcGame.left = 0;
@@ -454,7 +454,7 @@
 			return 0;
 	}
 
-	ChangeMusic(0);
+	ChangeMusic(MUS_SILENCE);
 
 	// Black screen when option is selected
 	wait = SDL_GetTicks();	// The original version used GetTickCount instead
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -160,7 +160,7 @@
 #else
 	fread(profile.code, 8, 1, fp);
 	profile.stage = File_ReadLE32(fp);
-	profile.music = File_ReadLE32(fp);
+	profile.music = (MusicID)File_ReadLE32(fp);
 	profile.x = File_ReadLE32(fp);
 	profile.y = File_ReadLE32(fp);
 	profile.direct = File_ReadLE32(fp);
--- a/src/Profile.h
+++ b/src/Profile.h
@@ -4,12 +4,13 @@
 
 #include "ArmsItem.h"
 #include "SelStage.h"
+#include "Stage.h"
 
 struct PROFILE
 {
 	char code[8];
 	int stage;
-	int music;
+	MusicID music;
 	int x;
 	int y;
 	int direct;
--- a/src/Sound.h
+++ b/src/Sound.h
@@ -43,53 +43,6 @@
 		double samplePosition;
 };
 
-//Music ID enum
-enum MUSIC_IDS
-{
-	mus_Silence = 0x0,
-	mus_MischievousRobot = 0x1,
-	mus_Safety = 0x2,
-	mus_GameOver = 0x3,
-	mus_Gravity = 0x4,
-	mus_OnToGrasstown = 0x5,
-	mus_Meltdown2 = 0x6,
-	mus_EyesOfFlame = 0x7,
-	mus_Gestation = 0x8,
-	mus_MimigaTown = 0x9,
-	mus_GetItem = 0xA,
-	mus_BalrogsTheme = 0xB,
-	mus_Cemetary = 0xC,
-	mus_Plant = 0xD,
-	mus_Pulse = 0xE,
-	mus_Victory = 0xF,
-	mus_GetLifeCapsule = 0x10,
-	mus_Tyrant = 0x11,
-	mus_Run = 0x12,
-	mus_Jenka1 = 0x13,
-	mus_LabyrinthFight = 0x14,
-	mus_Access = 0x15,
-	mus_Oppression = 0x16,
-	mus_Geothermal = 0x17,
-	mus_CaveStory = 0x18,
-	mus_Moonsong = 0x19,
-	mus_Herosend = 0x1A,
-	mus_ScorchingBack = 0x1B,
-	mus_Quiet = 0x1C,
-	mus_FinalCave = 0x1D,
-	mus_Balcony = 0x1E,
-	mus_Charge = 0x1F,
-	mus_LastBattle = 0x20,
-	mus_TheWayBackHome = 0x21,
-	mus_Zombie = 0x22,
-	mus_BreakDown = 0x23,
-	mus_RunningHell = 0x24,
-	mus_Jenka2 = 0x25,
-	mus_LivingWaterway = 0x26,
-	mus_SealChamber = 0x27,
-	mus_TorokosTheme = 0x28,
-	mus_White = 0x29
-};
-
 #define SE_MAX 160	// According to the Organya source code release, this is the real name for this constant
 extern SOUNDBUFFER* lpSECONDARYBUFFER[SE_MAX];
 
--- a/src/Stage.cpp
+++ b/src/Stage.cpp
@@ -250,10 +250,10 @@
 };
 
 unsigned int gOldPos;
-int gOldNo;
-int gMusicNo;
+MusicID gOldNo;
+MusicID gMusicNo;
 
-void ChangeMusic(int no)
+void ChangeMusic(MusicID no)
 {
 	if (no && no == gMusicNo)
 		return;
--- a/src/Stage.h
+++ b/src/Stage.h
@@ -2,6 +2,52 @@
 
 #include "WindowsWrapper.h"
 
+enum MusicID
+{
+	MUS_SILENCE = 0x0,
+	MUS_MISCHIEVOUS_ROBOT = 0x1,
+	MUS_SAFETY = 0x2,
+	MUS_GAME_OVER = 0x3,
+	MUS_GRAVITY = 0x4,
+	MUS_ON_TO_GRASSTOWN = 0x5,
+	MUS_MELTDOWN2 = 0x6,
+	MUS_EYES_OF_FLAME = 0x7,
+	MUS_GESTATION = 0x8,
+	MUS_MIMIGA_TOWN = 0x9,
+	MUS_GOT_ITEM = 0xA,
+	MUS_BALROGS_THEME = 0xB,
+	MUS_CEMETERY = 0xC,
+	MUS_PLANT = 0xD,
+	MUS_PULSE = 0xE,
+	MUS_VICTORY = 0xF,
+	MUS_GET_HEART_TANK = 0x10,
+	MUS_TYRANT = 0x11,
+	MUS_RUN = 0x12,
+	MUS_JENKA1 = 0x13,
+	MUS_LABYRINTH_FIGHT = 0x14,
+	MUS_ACCESS = 0x15,
+	MUS_OPPRESSION = 0x16,
+	MUS_GEOTHERMAL = 0x17,
+	MUS_CAVE_STORY = 0x18,
+	MUS_MOONSONG = 0x19,
+	MUS_HEROS_END = 0x1A,
+	MUS_SCORCHING_BACK = 0x1B,
+	MUS_QUIET = 0x1C,
+	MUS_LAST_CAVE = 0x1D,
+	MUS_BALCONY = 0x1E,
+	MUS_CHARGE = 0x1F,
+	MUS_LAST_BATTLE = 0x20,
+	MUS_THE_WAY_BACK_HOME = 0x21,
+	MUS_ZOMBIE = 0x22,
+	MUS_BREAK_DOWN = 0x23,
+	MUS_RUNNING_HELL = 0x24,
+	MUS_JENKA2 = 0x25,
+	MUS_LIVING_WATERWAY = 0x26,
+	MUS_SEAL_CHAMBER = 0x27,
+	MUS_TOROKOS_THEME = 0x28,
+	MUS_WHITE = 0x29
+};
+
 struct STAGE_TABLE
 {
 	char parts[0x20];
@@ -15,8 +61,8 @@
 };
 
 extern int gStageNo;
-extern int gMusicNo;
+extern MusicID gMusicNo;
 
 BOOL TransferStage(int no, int w, int x, int y);
-void ChangeMusic(int no);
+void ChangeMusic(MusicID no);
 void ReCallMusic();
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -1036,7 +1036,7 @@
 					else if (IS_COMMAND('C','M','U'))
 					{
 						z = GetTextScriptNo(gTS.p_read + 4);
-						ChangeMusic(z);
+						ChangeMusic((MusicID)z);
 						gTS.p_read += 8;
 					}
 					else if (IS_COMMAND('F','M','U'))