1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-12 08:30:05 +00:00
CLK/Components/OPx/Implementation/OPLBase.hpp

36 lines
821 B
C++
Raw Normal View History

//
// OPLBase.hpp
// Clock Signal
//
// Created by Thomas Harte on 03/05/2020.
// Copyright © 2020 Thomas Harte. All rights reserved.
//
#pragma once
#include "../../../Outputs/Speaker/Implementation/BufferSource.hpp"
#include "../../../Concurrency/AsyncTaskQueue.hpp"
2023-05-10 21:02:18 +00:00
namespace Yamaha::OPL {
template <typename Child, bool stereo> class OPLBase: public ::Outputs::Speaker::BufferSource<Child, stereo> {
2024-11-30 22:21:00 +00:00
public:
void write(const uint16_t address, const uint8_t value) {
if(address & 1) {
static_cast<Child *>(this)->write_register(selected_register_, value);
} else {
selected_register_ = value;
}
2024-11-30 22:21:00 +00:00
}
2024-11-30 22:21:00 +00:00
protected:
OPLBase(Concurrency::AsyncTaskQueue<false> &task_queue) : task_queue_(task_queue) {}
2024-11-30 22:21:00 +00:00
Concurrency::AsyncTaskQueue<false> &task_queue_;
2024-11-30 22:21:00 +00:00
private:
uint8_t selected_register_ = 0;
};
}