2020-05-05 01:14:51 +00:00
|
|
|
//
|
|
|
|
// OPLBase.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 03/05/2020.
|
|
|
|
// Copyright © 2020 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2020-05-05 01:14:51 +00:00
|
|
|
|
|
|
|
#include "../../../Outputs/Speaker/Implementation/SampleSource.hpp"
|
|
|
|
#include "../../../Concurrency/AsyncTaskQueue.hpp"
|
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Yamaha::OPL {
|
2020-05-05 01:14:51 +00:00
|
|
|
|
2024-02-08 20:21:47 +00:00
|
|
|
template <typename Child, bool stereo> class OPLBase: public ::Outputs::Speaker::SampleSource<Child, stereo> {
|
2020-05-05 01:14:51 +00:00
|
|
|
public:
|
|
|
|
void write(uint16_t address, uint8_t value) {
|
|
|
|
if(address & 1) {
|
|
|
|
static_cast<Child *>(this)->write_register(selected_register_, value);
|
|
|
|
} else {
|
|
|
|
selected_register_ = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2022-07-16 18:41:04 +00:00
|
|
|
OPLBase(Concurrency::AsyncTaskQueue<false> &task_queue) : task_queue_(task_queue) {}
|
2020-05-05 01:14:51 +00:00
|
|
|
|
2022-07-16 18:41:04 +00:00
|
|
|
Concurrency::AsyncTaskQueue<false> &task_queue_;
|
2020-05-05 01:14:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t selected_register_ = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|