Update the timing for the delays and also create the Write method on the HAL to choreograph the writing process in the YMF262 and create the Set_OPL_Mode , and also created the YMF262-Types.hpp to hold types used by the YMF262

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2026-06-03 14:13:50 -03:00
parent 17b754c864
commit ec589d929a
2 changed files with 18 additions and 4 deletions

View File

@ -3,12 +3,13 @@
#include <cstdint> #include <cstdint>
#include "GPIO.hpp" #include "GPIO.hpp"
#include "YMF262-Types.hpp"
template <class GPIOPolicy> template <class GPIOPolicy>
class YMF262_HAL{ class YMF262_HAL{
private: private:
GPIOPolicy _gpio; GPIOPolicy& _gpio;
uint32_t _t_icw_ticks; uint32_t _t_icw_ticks;
uint32_t _t_as_ticks; uint32_t _t_as_ticks;
uint32_t _t_ah_ticks; uint32_t _t_ah_ticks;
@ -40,9 +41,9 @@ class YMF262_HAL{
public: public:
YMF262_HAL(GPIOPolicy policy, uint32_t opl_clock, uint32_t cpu_clock){ YMF262_HAL(GPIOPolicy& policy, uint32_t opl_clock, uint32_t cpu_clock):_gpio(policy){
_t_icw_ticks = (400 * cpu_clock) / opl_clock; _t_icw_ticks = 400 * (cpu_clock/ opl_clock);
_t_recovery_ticks = (32 * cpu_clock) / opl_clock; _t_recovery_ticks = 32 * (cpu_clock / opl_clock);
double ticks_per_ns = (double)cpu_clock / 1.0e9; double ticks_per_ns = (double)cpu_clock / 1.0e9;
_t_as_ticks = (uint32_t)(10 * ticks_per_ns); _t_as_ticks = (uint32_t)(10 * ticks_per_ns);
_t_ah_ticks = (uint32_t)(10 * ticks_per_ns); _t_ah_ticks = (uint32_t)(10 * ticks_per_ns);
@ -61,6 +62,10 @@ class YMF262_HAL{
write_bus(bank,Port::DATA,data); write_bus(bank,Port::DATA,data);
}; };
void set_OPL_Mode(OPLMode mode){
write(Bank::BANK_1, 0x105, (mode == OPLMode::OPL3) ? 0x01 : 0x00);
};
}; };
#endif #endif

View File

@ -0,0 +1,9 @@
#ifndef YMF262_MODES_HPP
#define YMF262_MODES_HPP
enum class OPLMode{
OPL3,
OPL2
};
#endif