mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-19 23:32:28 +00:00
114 lines
3.3 KiB
C++
114 lines
3.3 KiB
C++
//
|
|
// OPL2.cpp
|
|
// Clock Signal
|
|
//
|
|
// Created by Thomas Harte on 02/04/2020.
|
|
// Copyright © 2020 Thomas Harte. all rights reserved.
|
|
//
|
|
|
|
#include "OPL2.hpp"
|
|
|
|
namespace {
|
|
|
|
/*
|
|
|
|
Credit for the fixed register lists goes to Nuke.YKT; I found them at:
|
|
https://siliconpr0n.org/archive/doku.php?id=vendor:yamaha:opl2#ym2413_instrument_rom
|
|
|
|
The arrays below begin with channel 1, each line is a single channel and the
|
|
format per channel is, from first byte to eighth:
|
|
|
|
Bytes 1 and 2:
|
|
Registers 1 and 2, i.e. modulator and carrier
|
|
amplitude modulation select, vibrato select, etc.
|
|
|
|
Byte 3:
|
|
b7, b6: modulator key scale level
|
|
b5...b0: modulator total level (inverted)
|
|
|
|
Byte 4:
|
|
b7: carrier key scale level
|
|
b3...b0: feedback level and waveform selects as per register 4
|
|
|
|
Bytes 5, 6:
|
|
Registers 4 and 5, i.e. decay and attack rate, modulator and carrier.
|
|
|
|
Bytes 7, 8:
|
|
Registers 6 and 6, i.e. decay-sustain level and release rate, modulator and carrier.
|
|
|
|
*/
|
|
|
|
constexpr uint8_t opll_patch_set[] = {
|
|
0x71, 0x61, 0x1e, 0x17, 0xd0, 0x78, 0x00, 0x17,
|
|
0x13, 0x41, 0x1a, 0x0d, 0xd8, 0xf7, 0x23, 0x13,
|
|
0x13, 0x01, 0x99, 0x00, 0xf2, 0xc4, 0x11, 0x23,
|
|
0x31, 0x61, 0x0e, 0x07, 0xa8, 0x64, 0x70, 0x27,
|
|
0x32, 0x21, 0x1e, 0x06, 0xe0, 0x76, 0x00, 0x28,
|
|
0x31, 0x22, 0x16, 0x05, 0xe0, 0x71, 0x00, 0x18,
|
|
0x21, 0x61, 0x1d, 0x07, 0x82, 0x81, 0x10, 0x07,
|
|
0x23, 0x21, 0x2d, 0x14, 0xa2, 0x72, 0x00, 0x07,
|
|
0x61, 0x61, 0x1b, 0x06, 0x64, 0x65, 0x10, 0x17,
|
|
0x41, 0x61, 0x0b, 0x18, 0x85, 0xf7, 0x71, 0x07,
|
|
0x13, 0x01, 0x83, 0x11, 0xfa, 0xe4, 0x10, 0x04,
|
|
0x17, 0xc1, 0x24, 0x07, 0xf8, 0xf8, 0x22, 0x12,
|
|
0x61, 0x50, 0x0c, 0x05, 0xc2, 0xf5, 0x20, 0x42,
|
|
0x01, 0x01, 0x55, 0x03, 0xc9, 0x95, 0x03, 0x02,
|
|
0x61, 0x41, 0x89, 0x03, 0xf1, 0xe4, 0x40, 0x13,
|
|
};
|
|
|
|
constexpr uint8_t vrc7_patch_set[] = {
|
|
0x03, 0x21, 0x05, 0x06, 0xe8, 0x81, 0x42, 0x27,
|
|
0x13, 0x41, 0x14, 0x0d, 0xd8, 0xf6, 0x23, 0x12,
|
|
0x11, 0x11, 0x08, 0x08, 0xfa, 0xb2, 0x20, 0x12,
|
|
0x31, 0x61, 0x0c, 0x07, 0xa8, 0x64, 0x61, 0x27,
|
|
0x32, 0x21, 0x1e, 0x06, 0xe1, 0x76, 0x01, 0x28,
|
|
0x02, 0x01, 0x06, 0x00, 0xa3, 0xe2, 0xf4, 0xf4,
|
|
0x21, 0x61, 0x1d, 0x07, 0x82, 0x81, 0x11, 0x07,
|
|
0x23, 0x21, 0x22, 0x17, 0xa2, 0x72, 0x01, 0x17,
|
|
0x35, 0x11, 0x25, 0x00, 0x40, 0x73, 0x72, 0x01,
|
|
0xb5, 0x01, 0x0f, 0x0f, 0xa8, 0xa5, 0x51, 0x02,
|
|
0x17, 0xc1, 0x24, 0x07, 0xf8, 0xf8, 0x22, 0x12,
|
|
0x71, 0x23, 0x11, 0x06, 0x65, 0x74, 0x18, 0x16,
|
|
0x01, 0x02, 0xd3, 0x05, 0xc9, 0x95, 0x03, 0x02,
|
|
0x61, 0x63, 0x0c, 0x00, 0x94, 0xc0, 0x33, 0xf6,
|
|
0x21, 0x72, 0x0d, 0x00, 0xc1, 0xd5, 0x56, 0x06,
|
|
};
|
|
|
|
constexpr uint8_t percussion_patch_set[] = {
|
|
0x01, 0x01, 0x18, 0x0f, 0xdf, 0xf8, 0x6a, 0x6d,
|
|
0x01, 0x01, 0x00, 0x00, 0xc8, 0xd8, 0xa7, 0x48,
|
|
0x05, 0x01, 0x00, 0x00, 0xf8, 0xaa, 0x59, 0x55,
|
|
};
|
|
|
|
}
|
|
|
|
using namespace Yamaha;
|
|
|
|
OPL2::OPL2(Personality personality, Concurrency::DeferringAsyncTaskQueue &task_queue): task_queue_(task_queue) {
|
|
(void)opll_patch_set;
|
|
(void)vrc7_patch_set;
|
|
(void)percussion_patch_set;
|
|
}
|
|
|
|
bool OPL2::is_zero_level() {
|
|
return true;
|
|
}
|
|
|
|
void OPL2::get_samples(std::size_t number_of_samples, std::int16_t *target) {
|
|
// TODO.
|
|
}
|
|
|
|
void OPL2::set_sample_volume_range(std::int16_t range) {
|
|
// TODO.
|
|
}
|
|
|
|
void OPL2::write(uint16_t address, uint8_t value) {
|
|
// TODO.
|
|
printf("OPL2 write: %02x to %d\n", value, address&1);
|
|
}
|
|
|
|
uint8_t OPL2::read(uint16_t address) {
|
|
// TODO.
|
|
return 0xff;
|
|
}
|