libsidplayfp 2.5.1
c64sid.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2013-2021 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 <cstring>
29#include <stdint.h>
30
31namespace libsidplayfp
32{
33
37class c64sid : public Bank
38{
39private:
40 uint8_t lastpoke[0x20];
41
42protected:
43 virtual ~c64sid() {}
44
45 virtual uint8_t read(uint_least8_t addr) = 0;
46 virtual void write(uint_least8_t addr, uint8_t data) = 0;
47
48public:
49 virtual void reset(uint8_t volume) = 0;
50
51 void reset() { memset(lastpoke, 0, 0x20); reset(0); }
52
53 // Bank functions
54 void poke(uint_least16_t address, uint8_t value) override
55 {
56 lastpoke[address & 0x1f] = value;
57 write(address & 0x1f, value);
58 }
59 uint8_t peek(uint_least16_t address) override { return read(address & 0x1f); }
60
61 void getStatus(uint8_t regs[0x20]) const { memcpy(regs, lastpoke, 0x20); }
62};
63
64}
65
66#endif // C64SID_H
Definition Bank.h:36
Definition c64sid.h:38
void poke(uint_least16_t address, uint8_t value) override
Definition c64sid.h:54
uint8_t peek(uint_least16_t address) override
Definition c64sid.h:59