34 void reset(EmuTime::param time);
35 void writeReg (
unsigned r, uint8_t v, EmuTime::param time);
36 void writeReg512(
unsigned r, uint8_t v, EmuTime::param time);
37 [[nodiscard]] uint8_t
readReg(
unsigned reg);
38 [[nodiscard]] uint8_t
peekReg(
unsigned reg)
const;
44 template<
typename Archive>
45 void serialize(Archive& ar,
unsigned version);
61 [[nodiscard]]
inline int op_calc(
unsigned phase,
unsigned lfo_am)
const;
62 inline void FM_KEYON(uint8_t key_set);
63 inline void FM_KEYOFF(uint8_t key_clr);
64 inline void advanceEnvelopeGenerator(
unsigned egCnt);
65 inline void advancePhaseGenerator(Channel& ch,
unsigned lfo_pm);
68 void calc_fc(
const Channel& ch);
72 void setFeedbackShift(uint8_t value) {
73 fb_shift = value ? 9 - value : 0;
76 template<
typename Archive>
77 void serialize(Archive& ar,
unsigned version);
82 int* connect{
nullptr};
83 std::array<int, 2> op1_out{0, 0};
91 std::span<const unsigned, SIN_LEN> waveTable;
100 uint8_t eg_sel_dr{0};
102 uint8_t eg_sel_rr{0};
125 void chan_calc(
unsigned lfo_am);
126 void chan_calc_ext(
unsigned lfo_am);
128 template<
typename Archive>
129 void serialize(Archive& ar,
unsigned version);
131 std::array<Slot, 2> slot;
135 unsigned ksl_base{0};
146 bool extended{
false};
152 [[nodiscard]]
float getAmplificationFactorImpl()
const override;
153 void generateChannels(std::span<float*> bufs,
unsigned num)
override;
155 void callback(uint8_t flag)
override;
157 void writeRegDirect(
unsigned r, uint8_t v, EmuTime::param time);
159 void setStatus(uint8_t flag);
160 void resetStatus(uint8_t flag);
161 void changeStatusMask(uint8_t flag);
164 [[nodiscard]]
inline unsigned genPhaseHighHat();
165 [[nodiscard]]
inline unsigned genPhaseSnare();
166 [[nodiscard]]
inline unsigned genPhaseCymbal();
168 void chan_calc_rhythm(
unsigned lfo_am);
169 void set_mul(
unsigned sl, uint8_t v);
170 void set_ksl_tl(
unsigned sl, uint8_t v);
171 void set_ar_dr(
unsigned sl, uint8_t v);
172 void set_sl_rr(
unsigned sl, uint8_t v);
173 bool checkMuteHelper();
175 [[nodiscard]]
inline bool isExtended(
unsigned ch)
const;
176 [[nodiscard]]
inline Channel& getFirstOfPair(
unsigned ch);
177 [[nodiscard]]
inline Channel& getSecondOfPair(
unsigned ch);
179 struct Debuggable final : SimpleDebuggable {
180 Debuggable(MSXMotherBoard& motherBoard,
const std::string& name);
181 [[nodiscard]] uint8_t
read(
unsigned address)
override;
182 void write(
unsigned address, uint8_t value, EmuTime::param time)
override;
186 static constexpr int R04_ST1 = 0x01;
187 static constexpr int R04_ST2 = 0x02;
188 static constexpr int R04_MASK_T2 = 0x20;
189 static constexpr int R04_MASK_T1 = 0x40;
190 static constexpr int R04_IRQ_RESET = 0x80;
193 static constexpr int STATUS_T2 = R04_MASK_T2;
194 static constexpr int STATUS_T1 = R04_MASK_T1;
196 const std::unique_ptr<EmuTimer> timer1;
197 const std::unique_ptr<EmuTimer> timer2;
201 std::array<int, 18> chanOut = {};
203 std::array<uint8_t, 512> reg = {};
204 std::array<Channel, 18> channel;
206 std::array<int, 18 * 4> pan;
209 unsigned noise_rng{1};
212 using LFOAMIndex = FixedPoint< 6>;
213 using LFOPMIndex = FixedPoint<10>;
214 LFOAMIndex lfo_am_cnt{0};
215 LFOPMIndex lfo_pm_cnt{0};
216 bool lfo_am_depth{
false};
217 uint8_t lfo_pm_depth_range{0};
221 bool OPL3_mode{
false};
225 uint8_t statusMask{0};
227 bool alreadySignaledNEW2{
false};
Debuggable(const Debuggable &)=delete
virtual byte read(unsigned address, EmuTime::param time)
void write(unsigned address, byte value) override
static constexpr int SIN_LEN
void reset(EmuTime::param time)
uint8_t peekStatus() const
void setMixLevel(uint8_t x, EmuTime::param time)
YMF262(const std::string &name, const DeviceConfig &config, bool isYMF278)
static constexpr int SIN_BITS
static constexpr int SIN_MASK
FixedPoint< 16 > FreqIndex
16.16 fixed point type for frequency calculations
void serialize(Archive &ar, unsigned version)
void writeReg(unsigned r, uint8_t v, EmuTime::param time)
uint8_t peekReg(unsigned reg) const
uint8_t readReg(unsigned reg)
void writeReg512(unsigned r, uint8_t v, EmuTime::param time)
This file implemented 3 utility functions:
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
IntHelper< IRQSource > IRQHelper