libsidplayfp 1.8.8
c64vic.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2018 Leandro Nini <drfiemost@users.sourceforge.net>
5 * Copyright 2007-2010 Antti Lankila
6 * Copyright 2001 Simon White
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#ifndef C64VIC_H
24#define C64VIC_H
25
26// The VIC emulation is very generic and here we need to effectively
27// wire it into the computer (like adding a chip to a PCB).
28
29#include "Banks/Bank.h"
30#include "c64/c64env.h"
31#include "sidendian.h"
32#include "VIC_II/mos656x.h"
33
34#ifdef DEBUG
35# include <iostream>
36#endif
37
43class c64vic: public MOS656X, public Bank
44{
45private:
46 c64env &m_env;
47
48protected:
49 void interrupt(bool state)
50 {
51 m_env.interruptIRQ (state);
52 }
53
54 void setBA(bool state)
55 {
56 m_env.setBA (state);
57 }
58
59public:
60 c64vic(c64env *env) :
61 MOS656X(&(env->context ())),
62 m_env(*env) {}
63
64 void poke(uint_least16_t address, uint8_t value)
65 {
66#ifdef DEBUG
67 //if (address == 0xD01A)
68 //{
69 // std::cout << std::hex << (int)address << ": " << (int)value << std::endl;
70 //}
71 if (address == 0xD020)
72 {
73 //std::cout << (int)(value && 0x0f) << std::endl;
74 const char* msg = 0;
75 if (value == 5 || value == 13) msg = "OK"; // Green
76 else if (value == 2 || value == 10) msg = "KO"; // Red
77 if (msg)
78 {
79 std::cout << std::endl << msg << std::endl;
80 }
81 }
82#endif
83 write(endian_16lo8(address), value);
84 }
85
86 uint8_t peek(uint_least16_t address)
87 {
88 return read(endian_16lo8(address));
89 }
90};
91
92#endif // C64VIC_H
Definition: Bank.h:33
Definition: mos656x.h:37
void write(uint_least8_t addr, uint8_t data)
Definition: mos656x.cpp:140
uint8_t read(uint_least8_t addr)
Definition: mos656x.cpp:104
Definition: c64env.h:38
Definition: c64vic.h:44
void poke(uint_least16_t address, uint8_t value)
Definition: c64vic.h:64
uint8_t peek(uint_least16_t address)
Definition: c64vic.h:86