- some minor cleanup, including renaming some data structutrd in the OPL code.

This commit is contained in:
Christoph Oelckers 2017-04-17 00:46:27 +02:00
parent ba5721f98a
commit 79ed1f73e7
7 changed files with 33 additions and 24 deletions

View file

@ -87,7 +87,7 @@ OPLMIDIDevice::OPLMIDIDevice(const char *args)
uint8_t filehdr[8];
data.Read(filehdr, 8);
if (memcmp(filehdr, "#OPL_II#", 8)) I_Error("Corrupt GENMIDI lump");
data.Read(OPLinstruments, sizeof(genmidi_instr_t) * GENMIDI_NUM_TOTAL);
data.Read(OPLinstruments, sizeof(GenMidiInstrument) * GENMIDI_NUM_TOTAL);
SampleRate = (int)OPL_SAMPLE_RATE;
}

View file

@ -11,7 +11,7 @@ struct genmidi_op_t
uint8_t level;
} FORCE_PACKED;
struct genmidi_voice_t
struct GenMidiVoice
{
genmidi_op_t modulator;
uint8_t feedback;
@ -21,12 +21,12 @@ struct genmidi_voice_t
} FORCE_PACKED;
struct genmidi_instr_t
struct GenMidiInstrument
{
uint16_t flags;
uint8_t fine_tuning;
uint8_t fixed_note;
genmidi_voice_t voices[2];
GenMidiVoice voices[2];
} FORCE_PACKED;
#pragma pack(pop)

View file

@ -90,11 +90,11 @@ int musicBlock::replaceExistingVoice()
//
//----------------------------------------------------------------------------
void musicBlock::voiceKeyOn(uint32_t slot, uint32_t channo, genmidi_instr_t *instrument, uint32_t instrument_voice, uint32_t key, uint32_t volume)
void musicBlock::voiceKeyOn(uint32_t slot, uint32_t channo, GenMidiInstrument *instrument, uint32_t instrument_voice, uint32_t key, uint32_t volume)
{
struct OPLVoice *voice = &voices[slot];
auto &channel = oplchannels[channo];
genmidi_voice_t *gmvoice;
GenMidiVoice *gmvoice;
voice->index = channo;
voice->key = key;
@ -159,7 +159,7 @@ void musicBlock::noteOn(uint32_t channel, uint8_t key, int volume)
return;
}
uint32_t note;
genmidi_instr_t *instrument;
GenMidiInstrument *instrument;
// Percussion channel is treated differently.
if (channel == CHAN_PERCUSSION)

View file

@ -10,8 +10,8 @@ struct OPLVoice
unsigned int key; // The midi key that this voice is playing.
unsigned int note; // The note being played. This is normally the same as the key, but if the instrument is a fixed pitch instrument, it is different.
unsigned int note_volume; // The volume of the note being played on this channel.
genmidi_instr_t *current_instr; // Currently-loaded instrument data
genmidi_voice_t *current_instr_voice;// The voice number in the instrument to use. This is normally set to the instrument's first voice; if this is a double voice instrument, it may be the second one
GenMidiInstrument *current_instr; // Currently-loaded instrument data
GenMidiVoice *current_instr_voice;// The voice number in the instrument to use. This is normally set to the instrument's first voice; if this is a double voice instrument, it may be the second one
bool sustained;
int8_t fine_tuning;
int pitch;
@ -21,13 +21,10 @@ struct musicBlock {
musicBlock();
~musicBlock();
uint8_t *score;
uint8_t *scoredata;
int playingcount;
OPLChannel oplchannels[NUM_CHANNELS];
OPLio *io;
struct genmidi_instr_t OPLinstruments[GENMIDI_NUM_TOTAL];
struct GenMidiInstrument OPLinstruments[GENMIDI_NUM_TOTAL];
void changeModulation(uint32_t id, int value);
void changeSustain(uint32_t id, int value);
@ -50,9 +47,18 @@ protected:
int findFreeVoice();
int replaceExistingVoice();
void voiceKeyOn(uint32_t slot, uint32_t channo, genmidi_instr_t *instrument, uint32_t instrument_voice, uint32_t, uint32_t volume);
void voiceKeyOn(uint32_t slot, uint32_t channo, GenMidiInstrument *instrument, uint32_t instrument_voice, uint32_t, uint32_t volume);
int releaseVoice(uint32_t slot, uint32_t killed);
friend class Stat_opl;
};
enum ExtCtrl {
ctrlRPNHi,
ctrlRPNLo,
ctrlNRPNHi,
ctrlNRPNLo,
ctrlDataEntryHi,
ctrlDataEntryLo,
};

View file

@ -1,5 +1,5 @@
#include "critsec.h"
#include "muslib.h"
#include "musicblock.h"
class FileReader;
@ -18,6 +18,9 @@ protected:
virtual int PlayTick() = 0;
void OffsetSamples(float *buff, int count);
uint8_t *score;
uint8_t *scoredata;
int playingcount;
double NextTickIn;
double SamplesPerTick;
int NumChips;

View file

@ -353,7 +353,7 @@ static uint8_t volumetable[128] = {
120, 121, 121, 122, 122, 123, 123, 123,
124, 124, 125, 125, 126, 126, 127, 127};
void OPLio::WriteVolume(uint32_t channel, struct genmidi_voice_t *voice, uint32_t vol1, uint32_t vol2, uint32_t vol3)
void OPLio::WriteVolume(uint32_t channel, struct GenMidiVoice *voice, uint32_t vol1, uint32_t vol2, uint32_t vol3)
{
if (voice != nullptr)
{
@ -392,7 +392,7 @@ void OPLio::WriteVolume(uint32_t channel, struct genmidi_voice_t *voice, uint32_
//
//----------------------------------------------------------------------------
void OPLio::WritePan(uint32_t channel, struct genmidi_voice_t *voice, int pan)
void OPLio::WritePan(uint32_t channel, struct GenMidiVoice *voice, int pan)
{
if (voice != 0)
{
@ -418,7 +418,7 @@ void OPLio::WritePan(uint32_t channel, struct genmidi_voice_t *voice, int pan)
//
//----------------------------------------------------------------------------
void OPLio::WriteTremolo(uint32_t channel, struct genmidi_voice_t *voice, bool vibrato)
void OPLio::WriteTremolo(uint32_t channel, struct GenMidiVoice *voice, bool vibrato)
{
int val1 = voice->modulator.tremolo, val2 = voice->carrier.tremolo;
if (vibrato)
@ -478,7 +478,7 @@ void OPLio::LoadOperatorData(uint32_t channel, int op_index, genmidi_op_t *data,
//
//----------------------------------------------------------------------------
void OPLio::WriteInstrument(uint32_t channel, struct genmidi_voice_t *voice, bool vibrato)
void OPLio::WriteInstrument(uint32_t channel, struct GenMidiVoice *voice, bool vibrato)
{
bool modulating = (voice->feedback & 0x01) == 0;

View file

@ -54,7 +54,7 @@ enum
};
struct genmidi_voice_t;
struct GenMidiVoice;
struct OPLio
{
@ -64,10 +64,10 @@ struct OPLio
void LoadOperatorData(uint32_t channel, int op_index, genmidi_op_t *op_data, bool maxlevel, bool vibrato);
void WriteValue(uint32_t regbase, uint32_t channel, uint8_t value);
void WriteFrequency(uint32_t channel, uint32_t freq, uint32_t octave, uint32_t keyon);
void WriteVolume(uint32_t channel, genmidi_voice_t *voice, uint32_t v1, uint32_t v2, uint32_t v3);
void WritePan(uint32_t channel, genmidi_voice_t *voice, int pan);
void WriteTremolo(uint32_t channel, genmidi_voice_t *voice, bool vibrato);
void WriteInstrument(uint32_t channel, genmidi_voice_t *voice, bool vibrato);
void WriteVolume(uint32_t channel, GenMidiVoice *voice, uint32_t v1, uint32_t v2, uint32_t v3);
void WritePan(uint32_t channel, GenMidiVoice *voice, int pan);
void WriteTremolo(uint32_t channel, GenMidiVoice *voice, bool vibrato);
void WriteInstrument(uint32_t channel, GenMidiVoice *voice, bool vibrato);
void WriteInitState(bool opl3);
void MuteChannel(uint32_t chan);
void StopPlayback();