libsidplayfp  2.11.0
c64sid.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2013-2024 Leandro Nini <drfiemost@users.sourceforge.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef C64SID_H
22 #define C64SID_H
23 
24 #include "Banks/Bank.h"
25 
26 #include "sidcxx11.h"
27 
28 #include <algorithm>
29 #include <iterator>
30 #include <cstring>
31 #include <stdint.h>
32 
33 namespace libsidplayfp
34 {
35 
39 class c64sid : public Bank
40 {
41 private:
42  uint8_t lastpoke[0x20];
43 
44 protected:
45  virtual ~c64sid() = default;
46 
47  virtual uint8_t read(uint_least8_t addr) = 0;
48  virtual void writeReg(uint_least8_t addr, uint8_t data) = 0;
49 
50 public:
51  virtual void reset(uint8_t volume) = 0;
52 
53  void reset()
54  {
55  std::fill(std::begin(lastpoke), std::end(lastpoke), 0);
56  reset(0);
57  }
58 
59  // Bank functions
60  void poke(uint_least16_t address, uint8_t value) override
61  {
62  lastpoke[address & 0x1f] = value;
63  writeReg(address & 0x1f, value);
64  }
65  uint8_t peek(uint_least16_t address) override { return read(address & 0x1f); }
66 
67  void getStatus(uint8_t regs[0x20]) const { std::memcpy(regs, lastpoke, 0x20); }
68 };
69 
70 }
71 
72 #endif // C64SID_H
Definition: Bank.h:36
Definition: c64sid.h:40
void poke(uint_least16_t address, uint8_t value) override
Definition: c64sid.h:60
uint8_t peek(uint_least16_t address) override
Definition: c64sid.h:65