Skip to content

Commit 5487c19

Browse files
authored
Merge pull request #296 from Oreo639/use-enums
Use enums instead of defines for synth settings
2 parents 47dc41c + 93f8690 commit 5487c19

4 files changed

Lines changed: 43 additions & 30 deletions

File tree

src/GameSrc/Headers/wrapper.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,24 @@ extern char comments[NUM_SAVE_SLOTS][SAVE_COMMENT_LEN];
8181
save_game_name[7] = '0' + (game_num & 7); \
8282
}
8383

84+
enum TEMP_STR_ {
85+
REF_STR_Renderer = 0x10000000,
86+
REF_STR_Software,
87+
REF_STR_OpenGL,
88+
89+
REF_STR_MousLook = 0x11000000,
90+
REF_STR_MousNorm,
91+
REF_STR_MousInv,
92+
93+
REF_STR_Seqer = 0x20000000,
94+
REF_STR_ADLMIDI,
95+
REF_STR_NativeMI,
96+
#ifdef USE_FLUIDSYNTH
97+
REF_STR_FluidSyn,
98+
#endif // USE_FLUIDSYNTH
99+
REF_STR_MidiOut = 0x2fffffff,
100+
101+
REF_STR_MidiOutX = 0x30000000 // 0x30000000-0x3fffffff are MIDI outputs
102+
};
103+
84104
#endif // __WRAPPER_H

src/GameSrc/wrapper.c

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -358,24 +358,8 @@ uchar fv;
358358
// override get_temp_string() to support hard-coded custom strings without
359359
// providing an actual resource file
360360

361-
#define REF_STR_Renderer 0x10000000
362-
#define REF_STR_Software 0x10000001
363-
#define REF_STR_OpenGL 0x10000002
364-
365-
#define REF_STR_MousLook 0x11000000
366-
#define REF_STR_MousNorm 0x11000001
367-
#define REF_STR_MousInv 0x11000002
368-
369-
#define REF_STR_Seqer 0x20000000
370-
#define REF_STR_ADLMIDI 0x20000001
371-
#define REF_STR_NativeMI 0x20000002
372-
#define REF_STR_FluidSyn 0x20000003 // this has to be last because it is optional
373-
#define REF_STR_MidiOut 0x2fffffff
374-
375-
#define REF_STR_MidiOutX 0x30000000 // 0x30000000-0x3fffffff are MIDI outputs
376-
377-
#define MIDI_OUT_BUFFER_SIZE 1024
378-
static char MIDI_OUT_BUFFER[MIDI_OUT_BUFFER_SIZE];
361+
#define MIDI_OUT_STR_SIZE 1024
362+
static char MIDI_STR_BUFFER[MIDI_OUT_STR_SIZE];
379363

380364
static char *_get_temp_string(int num) {
381365
switch (num) {
@@ -390,17 +374,19 @@ static char *_get_temp_string(int num) {
390374
case REF_STR_Seqer: return "Midi Player";
391375
case REF_STR_ADLMIDI: return "ADLMIDI";
392376
case REF_STR_NativeMI: return "Native MIDI";
377+
#ifdef USE_FLUIDSYNTH
393378
case REF_STR_FluidSyn: return "FluidSynth";
379+
#endif
394380

395381
case REF_STR_MidiOut: return "Midi Output";
396382
}
397383

398384
if (num >= REF_STR_MidiOutX && num <= (REF_STR_MidiOutX | 0x0fffffff))
399385
{
400386
const unsigned int midiOutputIndex = (unsigned int)num - REF_STR_MidiOutX;
401-
MIDI_OUT_BUFFER[0] = '\0';
402-
GetOutputNameXMI(midiOutputIndex, &MIDI_OUT_BUFFER[0], MIDI_OUT_BUFFER_SIZE);
403-
return &MIDI_OUT_BUFFER[0];
387+
MIDI_STR_BUFFER[0] = '\0';
388+
GetOutputNameXMI(midiOutputIndex, &MIDI_STR_BUFFER[0], MIDI_OUT_STR_SIZE);
389+
return &MIDI_STR_BUFFER[0];
404390
}
405391

406392
return get_temp_string(num);
@@ -1492,14 +1478,9 @@ void soundopt_screen_init() {
14921478
i++;
14931479
#endif
14941480

1495-
#ifdef USE_FLUIDSYNTH
1496-
const uchar numSynths = 3;
1497-
#else
1498-
const uchar numSynths = 2;
1499-
#endif
15001481
standard_button_rect(&r, i, 2, 2, 5);
15011482
multi_init(i, 'p', REF_STR_Seqer, REF_STR_ADLMIDI, ID_NULL,
1502-
sizeof(gShockPrefs.soMidiBackend), &gShockPrefs.soMidiBackend, numSynths, seqer_dealfunc, &r);
1483+
sizeof(gShockPrefs.soMidiBackend), &gShockPrefs.soMidiBackend, OPT_SEQ_Max, seqer_dealfunc, &r);
15031484
i++;
15041485
/* standard button is too narrow, so use a slider instead
15051486
const unsigned int numMidiOutputs = GetOutputCountXMI();

src/MacSrc/Prefs.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,15 @@ extern ShockPrefs gShockPrefs;
7171
void SetDefaultPrefs(void);
7272
OSErr LoadPrefs(void);
7373
OSErr SavePrefs(void);
74+
75+
//-------------------
76+
// Enums
77+
//-------------------
78+
enum OPT_SEQ_ { // Must be in the same order as in wraper.h
79+
OPT_SEQ_ADLMIDI = 0,
80+
OPT_SEQ_NativeMI,
81+
#ifdef USE_FLUIDSYNTH
82+
OPT_SEQ_FluidSyn,
83+
#endif // USE_FLUIDSYNTH
84+
OPT_SEQ_Max
85+
};

src/MacSrc/Xmi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,20 +661,20 @@ void InitDecXMI(void)
661661

662662
switch (gShockPrefs.soMidiBackend)
663663
{
664-
case 0: // adlmidi
664+
case OPT_SEQ_ADLMIDI: // adlmidi
665665
{
666666
INFO("Creating ADLMIDI device");
667667
musicdev = CreateMusicDevice(Music_AdlMidi);
668668
}
669669
break;
670-
case 1: // native midi
670+
case OPT_SEQ_NativeMI: // native midi
671671
{
672672
INFO("Creating native MIDI device");
673673
musicdev = CreateMusicDevice(Music_Native);
674674
}
675675
break;
676676
#ifdef USE_FLUIDSYNTH
677-
case 2: // fluidsynth
677+
case OPT_SEQ_FluidSyn: // fluidsynth
678678
{
679679
INFO("Creating FluidSynth MIDI device");
680680
musicdev = CreateMusicDevice(Music_FluidSynth);

0 commit comments

Comments
 (0)