00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef C64CIA_H
00024 #define C64CIA_H
00025
00026
00027
00028
00029 #include "Banks/Bank.h"
00030 #include "sidplayfp/c64/c64env.h"
00031 #include "sidplayfp/sidendian.h"
00032 #include "CIA/mos6526.h"
00033
00039 class c64cia1: public MOS6526, public Bank
00040 {
00041 private:
00042 c64env &m_env;
00043 uint_least16_t last_ta;
00044 uint8_t lp;
00045
00046 protected:
00047 void interrupt(bool state)
00048 {
00049 m_env.interruptIRQ (state);
00050 }
00051
00052 void portB()
00053 {
00054 const uint8_t lp = (prb | ~ddrb) & 0x10;
00055 if (lp != this->lp)
00056 {
00057 m_env.lightpen();
00058 this->lp = lp;
00059 }
00060 }
00061
00062 public:
00063 c64cia1(c64env *env) :
00064 MOS6526(&(env->context ())),
00065 m_env(*env) {}
00066
00067 void poke(uint_least16_t address, uint8_t value)
00068 {
00069 write(endian_16lo8(address), value);
00070
00071
00072 if (address == 0xDC04 || address == 0xDC05)
00073 {
00074 if (timerA.getTimer() != 0)
00075 last_ta = timerA.getTimer();
00076 }
00077 }
00078
00079 uint8_t peek(uint_least16_t address)
00080 {
00081 return read(endian_16lo8(address));
00082 }
00083
00084 const char *error() const { return ""; }
00085
00086 void reset()
00087 {
00088 last_ta = 0;
00089 lp = 0x10;
00090 MOS6526::reset ();
00091 }
00092
00093 uint_least16_t getTimerA() const { return last_ta; }
00094 };
00095
00101 class c64cia2: public MOS6526, public Bank
00102 {
00103 private:
00104 c64env &m_env;
00105
00106 protected:
00107 void interrupt(bool state)
00108 {
00109 if (state)
00110 m_env.interruptNMI ();
00111 }
00112
00113 public:
00114 c64cia2(c64env *env) :
00115 MOS6526(&(env->context ())),
00116 m_env(*env) {}
00117
00118 void poke(uint_least16_t address, uint8_t value)
00119 {
00120 write(address, value);
00121 }
00122
00123 uint8_t peek(uint_least16_t address)
00124 {
00125 return read(address);
00126 }
00127
00128 const char *error() const { return ""; }
00129 };
00130
00131 #endif // C64CIA_H