Skip to content

Commit

Permalink
Not yet working MT32 initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
viti95 committed Dec 8, 2024
1 parent 19226c2 commit 32fe806
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 0 deletions.
2 changes: 2 additions & 0 deletions FASTDOOM/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ int debugCardPort;
boolean debugCardReverse;
boolean nearSprites;
boolean monoSound;
boolean mt32;
boolean noMelt;
boolean uncappedFPS;
boolean highResTimer;
Expand Down Expand Up @@ -1702,6 +1703,7 @@ void D_DoomMain(void)
M_CheckParmOptional("-mono", &monoSound);
M_CheckParmOptional("-near", &nearSprites);
M_CheckParmOptional("-nomelt", &noMelt);
M_CheckParmOptional("-mt32", &mt32);
M_CheckParmOptional("-slowbus", &busSpeed);
M_CheckParmOptional("-vsync", &waitVsync);
M_CheckParmOptional("-uncapped", &uncappedFPS);
Expand Down
39 changes: 39 additions & 0 deletions FASTDOOM/dmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,45 @@ int MUS_RegisterSong(void *data)
mus_data = data;
return 0;
}

char mt32file[13] = "MTGM.MID";

int MUS_LoadMT32(void)
{
FILE *mid;
unsigned int midlen;

if (mid_data)
{
Z_Free(mid_data);
}

mid = fopen(mt32file, "rb");
if (!mid)
{
return 0;
}
fseek(mid, 0, SEEK_END);
midlen = ftell(mid);
rewind(mid);
mid_data = Z_MallocUnowned(midlen, PU_STATIC);
if (!mid_data)
{
fclose(mid);
return 0;
}
fread(mid_data, 1, midlen, mid);
fclose(mid);
mus_data = mid_data;
return 0;

}

int MUS_SongPlaying()
{
return MUSIC_SongPlaying();
}

int MUS_ChainSong(int handle, int next)
{
mus_loop = (next == handle);
Expand Down
2 changes: 2 additions & 0 deletions FASTDOOM/dmx.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ void GUS_Shutdown(void);

void TSM_Remove(void);
int MUS_RegisterSong(void *data);
int MUS_LoadMT32(void);
int MUS_ChainSong(int handle, int next);
void MUS_PlaySong(int handle, int volume);
int MUS_SongPlaying();
int SFX_PlayPatch(void *vdata, int sep, int vol);
void SFX_StopPatch(int handle);
int SFX_Playing(int handle);
Expand Down
1 change: 1 addition & 0 deletions FASTDOOM/doomstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ extern int debugCardPort;
extern boolean debugCardReverse;
extern boolean nearSprites;
extern boolean monoSound;
extern boolean mt32;
extern boolean noMelt;

extern boolean reverseStereo;
Expand Down
16 changes: 16 additions & 0 deletions FASTDOOM/i_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,22 @@ void I_StartupSound(void)
printf(" calling ASS_Init\n");

ASS_Init(SND_TICRATE, snd_MusicDevice, snd_SfxDevice);

// Init MT-32
if (mt32) {
// Load MIDI
MUS_LoadMT32();

// Play MIDI
MUS_ChainSong(0, -1);
MUS_PlaySong(0, snd_MusicVolume);

// Release MIDI
while(MUS_SongPlaying())
{
// wait
}
}
}
//
// I_ShutdownSound
Expand Down
11 changes: 11 additions & 0 deletions FASTDOOM/ns_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,17 @@ void MIDI_SetTempo(int tempo)
_MIDI_FPSecondsPerTick = (1 << TIME_PRECISION) / tickspersecond;
}

/*---------------------------------------------------------------------
Function: MIDI_SongPlaying
Returns whether a song is playing or not.
---------------------------------------------------------------------*/

int MIDI_SongPlaying(void)
{
return( _MIDI_SongActive);
}

/*---------------------------------------------------------------------
Function: MIDI_InitEMIDI
Expand Down
1 change: 1 addition & 0 deletions FASTDOOM/ns_midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ void MIDI_PauseSong(void);
void MIDI_StopSong(void);
int MIDI_PlaySong(unsigned char *song, int loopflag);
void MIDI_SetTempo(int tempo);
int MIDI_SongPlaying(void);

#endif
5 changes: 5 additions & 0 deletions FASTDOOM/ns_music.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ int MUSIC_StopSong(
return (MUSIC_Ok);
}

int MUSIC_SongPlaying(void)
{
return(MIDI_SongPlaying());
}

/*---------------------------------------------------------------------
Function: MUSIC_PlaySong
Expand Down
1 change: 1 addition & 0 deletions FASTDOOM/ns_music.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ int MUSIC_Shutdown(void);
void MUSIC_SetVolume(int volume);
void MUSIC_Continue(void);
void MUSIC_Pause(void);
int MUSIC_SongPlaying(void);
int MUSIC_StopSong(void);
int MUSIC_PlaySong(unsigned char *song, int loopflag);

Expand Down
Binary file added MTGM.MID
Binary file not shown.

0 comments on commit 32fe806

Please sign in to comment.