37 void reset(EmuTime::param time);
38 void writeReg (
unsigned r, uint8_t v, EmuTime::param time);
39 void writeReg512(
unsigned r, uint8_t v, EmuTime::param time);
40 [[nodiscard]] uint8_t
readReg(
unsigned reg)
const;
41 [[nodiscard]] uint8_t
peekReg(
unsigned reg)
const;
47 template<
typename Archive>
48 void serialize(Archive& ar,
unsigned version);
64 [[nodiscard]]
int op_calc(
unsigned phase,
unsigned lfo_am)
const;
65 void FM_KEYON(uint8_t key_set);
66 void FM_KEYOFF(uint8_t key_clr);
67 void advanceEnvelopeGenerator(
unsigned egCnt);
68 void advancePhaseGenerator(
const Channel& ch,
unsigned lfo_pm);
71 void calc_fc(
const Channel& ch);
75 void setFeedbackShift(uint8_t value) {
76 fb_shift = value ? 9 - value : 0;
79 template<
typename Archive>
80 void serialize(Archive& ar,
unsigned version);
85 int* connect{
nullptr};
86 std::array<int, 2> op1_out{0, 0};
94 std::span<const unsigned, SIN_LEN> waveTable;
101 uint8_t eg_sel_ar{0};
103 uint8_t eg_sel_dr{0};
105 uint8_t eg_sel_rr{0};
128 void chan_calc(
unsigned lfo_am);
129 void chan_calc_ext(
unsigned lfo_am);
131 template<
typename Archive>
132 void serialize(Archive& ar,
unsigned version);
134 std::array<Slot, 2> slot;
138 unsigned ksl_base{0};
149 bool extended{
false};
155 [[nodiscard]]
float getAmplificationFactorImpl()
const override;
156 void generateChannels(std::span<float*> bufs,
unsigned num)
override;
158 void callback(uint8_t flag)
override;
160 void writeRegDirect(
unsigned r, uint8_t v, EmuTime::param time);
162 void setStatus(uint8_t flag);
163 void resetStatus(uint8_t flag);
164 void changeStatusMask(uint8_t flag);
167 [[nodiscard]]
unsigned genPhaseHighHat();
168 [[nodiscard]]
unsigned genPhaseSnare();
169 [[nodiscard]]
unsigned genPhaseCymbal();
171 void chan_calc_rhythm(
unsigned lfo_am);
172 void set_mul(
unsigned sl, uint8_t v);
173 void set_ksl_tl(
unsigned sl, uint8_t v);
174 void set_ar_dr(
unsigned sl, uint8_t v);
175 void set_sl_rr(
unsigned sl, uint8_t v);
176 [[nodiscard]]
bool checkMuteHelper()
const;
178 [[nodiscard]]
bool isExtended(
unsigned ch)
const;
179 [[nodiscard]] Channel& getFirstOfPair(
unsigned ch);
180 [[nodiscard]] Channel& getSecondOfPair(
unsigned ch);
182 struct Debuggable final : SimpleDebuggable {
183 Debuggable(MSXMotherBoard& motherBoard,
const std::string& name);
184 [[nodiscard]] uint8_t
read(
unsigned address)
override;
185 void write(
unsigned address, uint8_t value, EmuTime::param time)
override;
189 static constexpr int R04_ST1 = 0x01;
190 static constexpr int R04_ST2 = 0x02;
191 static constexpr int R04_MASK_T2 = 0x20;
192 static constexpr int R04_MASK_T1 = 0x40;
193 static constexpr int R04_IRQ_RESET = 0x80;
196 static constexpr int STATUS_T2 = R04_MASK_T2;
197 static constexpr int STATUS_T1 = R04_MASK_T1;
199 const std::unique_ptr<EmuTimer> timer1;
200 const std::unique_ptr<EmuTimer> timer2;
204 std::array<int, 18> chanOut = {};
206 std::array<uint8_t, 512> reg = {};
207 std::array<Channel, 18> channel;
209 std::array<int, 18 * 4> pan;
212 unsigned noise_rng{1};
215 using LFOAMIndex = FixedPoint< 6>;
216 using LFOPMIndex = FixedPoint<10>;
217 LFOAMIndex lfo_am_cnt{0};
218 LFOPMIndex lfo_pm_cnt{0};
219 bool lfo_am_depth{
false};
220 uint8_t lfo_pm_depth_range{0};
224 bool OPL3_mode{
false};
228 uint8_t statusMask{0};
230 bool alreadySignaledNEW2{
false};