Debian Codegraph @

BambooTracker/chip/ymfm/ymfm_2608.hpp

raw
1 /*
2 * Copyright (C) 2022 Rerrah
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use,
8 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following
11 * conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 #pragma once
27
28 #include "../2608_interface.hpp"
29 #include <vector>
30 #include <memory>
31 #include "ymfm.h"
32 #include "ymfm_opn.h"
33
34 namespace chip
35 {
36 class Ymfm2608 final : public Ym2608Interface
37 {
38 public:
39 ~Ymfm2608() override;
40 int startDevice(int clock, int& rateSsg, uint32_t dramSize) override;
41 void stopDevice() override;
42 void resetDevice() override;
43 void writeAddressToPortA(uint8_t address) override;
44 void writeAddressToPortB(uint8_t address) override;
45 void writeDataToPortA(uint8_t data) override;
46 void writeDataToPortB(uint8_t data) override;
47 uint8_t readData() override;
48 void updateStream(sample** outputs, int nSamples) override;
49 void updateSsgStream(sample** outputs, int nSamples) override;
50
51 private:
52 class YmfmInterface final : public ymfm::ymfm_interface
53 {
54 public:
55 YmfmInterface(uint32_t dramSize);
56 uint8_t ymfm_external_read(ymfm::access_class type, uint32_t address) override;
57 void ymfm_external_write(ymfm::access_class type, uint32_t address, uint8_t data) override;
58
59 private:
60 std::vector<uint8_t> dram_;
61 };
62
63 std::unique_ptr<ymfm::ym2608> ymfm_;
64 std::unique_ptr<YmfmInterface> ymfmIntf_;
65 };
66 }