libsidplayfp  2.0.2
c64cpu.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright (C) 2012-2019 Leandro Nini
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 C64CPU_H
22 #define C64CPU_H
23 
24 #include "c64/c64env.h"
25 #include "CPU/mos6510.h"
26 
27 #ifdef VICE_TESTSUITE
28 # include <iostream>
29 # include <cstdlib>
30 #endif
31 
32 #include "sidcxx11.h"
33 
34 #ifdef HAVE_CONFIG_H
35 # include "config.h"
36 #endif
37 
38 namespace libsidplayfp
39 {
40 
41 class c64cpu final : public MOS6510
42 {
43 private:
44  c64env &m_env;
45 
46 protected:
47  uint8_t cpuRead(uint_least16_t addr) override { return m_env.cpuRead(addr); }
48 
49  void cpuWrite(uint_least16_t addr, uint8_t data) override {
50 #ifdef VICE_TESTSUITE
51  // for VICE tests
52  if (addr == 0xd7ff)
53  {
54  if (data == 0)
55  {
56  std::cout << std::endl << "OK" << std::endl;
57  exit(EXIT_SUCCESS);
58  }
59  else if (data == 0xff)
60  {
61  std::cout << std::endl << "KO" << std::endl;
62  exit(EXIT_FAILURE);
63  }
64  }
65 #endif
66  m_env.cpuWrite(addr, data);
67  }
68 
69 public:
70  c64cpu (c64env &env) :
71  MOS6510(env.scheduler()),
72  m_env(env) {}
73 };
74 
75 }
76 
77 #endif // C64CPU_H
78 
libsidplayfp::MOS6510
Definition: mos6510.h:72
libsidplayfp::c64cpu::cpuWrite
void cpuWrite(uint_least16_t addr, uint8_t data) override
Definition: c64cpu.h:49
libsidplayfp::c64cpu
Definition: c64cpu.h:42
libsidplayfp::c64env
Definition: c64env.h:41
libsidplayfp::c64cpu::cpuRead
uint8_t cpuRead(uint_least16_t addr) override
Definition: c64cpu.h:47