aboutsummaryrefslogtreecommitdiff
path: root/utils/gen_adldata/file_formats/load_op2.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/gen_adldata/file_formats/load_op2.h')
-rw-r--r--utils/gen_adldata/file_formats/load_op2.h86
1 files changed, 39 insertions, 47 deletions
diff --git a/utils/gen_adldata/file_formats/load_op2.h b/utils/gen_adldata/file_formats/load_op2.h
index 0c56ef6..e43f17f 100644
--- a/utils/gen_adldata/file_formats/load_op2.h
+++ b/utils/gen_adldata/file_formats/load_op2.h
@@ -2,6 +2,9 @@
#define LOAD_OP2_H
#include "../progs_cache.h"
+#ifndef COMMON_H
+#include "common.h"
+#endif
#ifndef _MSC_VER
#define PACKED_STRUCT __attribute__((packed))
@@ -15,32 +18,32 @@
struct Doom_OPL2instrument
{
- unsigned char trem_vibr_1; /* OP 1: tremolo/vibrato/sustain/KSR/multi */
- unsigned char att_dec_1; /* OP 1: attack rate/decay rate */
- unsigned char sust_rel_1; /* OP 1: sustain level/release rate */
- unsigned char wave_1; /* OP 1: waveform select */
- unsigned char scale_1; /* OP 1: key scale level */
- unsigned char level_1; /* OP 1: output level */
- unsigned char feedback; /* feedback/AM-FM (both operators) */
- unsigned char trem_vibr_2; /* OP 2: tremolo/vibrato/sustain/KSR/multi */
- unsigned char att_dec_2; /* OP 2: attack rate/decay rate */
- unsigned char sust_rel_2; /* OP 2: sustain level/release rate */
- unsigned char wave_2; /* OP 2: waveform select */
- unsigned char scale_2; /* OP 2: key scale level */
- unsigned char level_2; /* OP 2: output level */
- unsigned char unused;
- short basenote; /* base note offset */
+ uint8_t trem_vibr_1; /* OP 1: tremolo/vibrato/sustain/KSR/multi */
+ uint8_t att_dec_1; /* OP 1: attack rate/decay rate */
+ uint8_t sust_rel_1; /* OP 1: sustain level/release rate */
+ uint8_t wave_1; /* OP 1: waveform select */
+ uint8_t scale_1; /* OP 1: key scale level */
+ uint8_t level_1; /* OP 1: output level */
+ uint8_t feedback; /* feedback/AM-FM (both operators) */
+ uint8_t trem_vibr_2; /* OP 2: tremolo/vibrato/sustain/KSR/multi */
+ uint8_t att_dec_2; /* OP 2: attack rate/decay rate */
+ uint8_t sust_rel_2; /* OP 2: sustain level/release rate */
+ uint8_t wave_2; /* OP 2: waveform select */
+ uint8_t scale_2; /* OP 2: key scale level */
+ uint8_t level_2; /* OP 2: output level */
+ uint8_t unused;
+ uint8_t basenote[2]; /* base note offset */
} PACKED_STRUCT;
struct Doom_opl_instr
{
- unsigned short flags;
+ uint8_t flags[2];
#define FL_FIXED_PITCH 0x0001 // note has fixed pitch (drum note)
-#define FL_UNKNOWN 0x0002 // ??? (used in instrument #65 only)
+#define FL_VIB_DELAY 0x0002 // vib_delay (used in instrument #65 only)
#define FL_DOUBLE_VOICE 0x0004 // use two voices instead of one
- unsigned char finetune;
- unsigned char note;
+ uint8_t finetune;
+ uint8_t note;
struct Doom_OPL2instrument patchdata[2];
} PACKED_STRUCT;
@@ -92,10 +95,11 @@ bool BankFormats::LoadDoom(BanksDump &db, const char *fn, unsigned bank, const s
snprintf(name2, 512, "%s%c%u", prefix, (gmno < 128 ? 'M' : 'P'), gmno & 127);
Doom_opl_instr &ins = *(Doom_opl_instr *) &data[offset2];
+ uint16_t flags = toSint16LE(ins.flags);
+
+ InstBuffer tmp[2] = {MakeNoSoundIns1(), MakeNoSoundIns1()};
+ int16_t noteOffset[2];
- insdata tmp[2] = {MakeNoSoundIns(), MakeNoSoundIns()};
- tmp[0].diff = false;
- tmp[1].diff = false;
for(size_t index = 0; index < 2; ++index)
{
const Doom_OPL2instrument &src = ins.patchdata[index];
@@ -110,40 +114,28 @@ bool BankFormats::LoadDoom(BanksDump &db, const char *fn, unsigned bank, const s
tmp[index].data[8] = src.scale_1 | src.level_1;
tmp[index].data[9] = src.scale_2 | src.level_2;
tmp[index].data[10] = src.feedback;
- tmp[index].finetune = int8_t(src.basenote + 12);
+ noteOffset[index] = toSint16LE(src.basenote) + 12;
inst.fbConn |= (uint_fast16_t(src.feedback) << (index == 1 ? 8 : 0));
- db.toOps(tmp[index], ops, index * 2);
+ db.toOps(tmp[index].d, ops, index * 2);
}
- struct ins tmp2;
- tmp2.notenum = ins.note;
- tmp2.pseudo4op = false;
- tmp2.real4op = false;
- tmp2.voice2_fine_tune = 0.0;
- tmp2.midi_velocity_offset = 0;
- tmp2.rhythmModeDrum = 0;
-
- while(tmp2.notenum && tmp2.notenum < 20)
+
+ uint8_t notenum = ins.note;
+
+ while(notenum && notenum < 20)
{
- tmp2.notenum += 12;
- tmp[0].finetune -= 12;
- tmp[1].finetune -= 12;
+ notenum += 12;
+ noteOffset[0] -= 12;
+ noteOffset[1] -= 12;
}
- inst.noteOffset1 = int8_t(tmp[0].finetune);
- inst.noteOffset2 = int8_t(tmp[1].finetune);
+ inst.noteOffset1 = noteOffset[0];
+ inst.noteOffset2 = noteOffset[1];
- if((ins.flags & FL_DOUBLE_VOICE) != 0)
+ if((flags & FL_DOUBLE_VOICE) != 0)
inst.instFlags |= BanksDump::InstrumentEntry::WOPL_Ins_4op | BanksDump::InstrumentEntry::WOPL_Ins_Pseudo4op;
- inst.percussionKeyNumber = tmp2.notenum;
+ inst.percussionKeyNumber = notenum;
inst.secondVoiceDetune = static_cast<char>(static_cast<int>(ins.finetune) - 128);
- if((ins.flags & FL_DOUBLE_VOICE) != 0)
- {
- tmp2.pseudo4op = true;
- // Simulate behavior of DMX second voice detune
- tmp2.voice2_fine_tune = (double)((ins.finetune >> 1) - 64) / 32.0;
- }
-
db.addInstrument(bnk, patchId, inst, ops, fn);
/*const Doom_OPL2instrument& A = ins.patchdata[0];