1 /*
2 * KCemu -- The emulator for the KC85 homecomputer series and much more.
3 * Copyright (C) 1997-2010 Torsten Paul
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include <iostream>
21 #include <iomanip>
22
23 #include "kc/system.h"
24
25 #include "kc/kc.h"
26 #include "kc/ctc_dio.h"
27
28 #include "libdbg/dbg.h"
29
CTC_DIO(void)30 CTC_DIO::CTC_DIO(void)
31 {
32 }
33
~CTC_DIO(void)34 CTC_DIO::~CTC_DIO(void)
35 {
36 }
37
38 byte_t
in(word_t addr)39 CTC_DIO::in(word_t addr)
40 {
41 DBG(2, form("KCemu/CTC/DIO/in",
42 "CTC_DIO::in(): addr = %04x\n",
43 addr));
44
45 switch (addr & 3)
46 {
47 case 0:
48 return c_in(0);
49 case 1:
50 return c_in(1);
51 case 2:
52 return c_in(2);
53 case 3:
54 return c_in(3);
55 }
56
57 return 0; // shouldn't be reached
58 }
59
60 void
out(word_t addr,byte_t val)61 CTC_DIO::out(word_t addr, byte_t val)
62 {
63 DBG(2, form("KCemu/CTC/DIO/out",
64 "CTC_DIO::out(): addr = %04x, val = %02x\n",
65 addr, val));
66 switch (addr & 3)
67 {
68 case 0:
69 c_out(0, val);
70 break;
71 case 1:
72 c_out(1, val);
73 break;
74 case 2:
75 c_out(2, val);
76 break;
77 case 3:
78 c_out(3, val);
79 break;
80 }
81 }
82
83 bool
irq_0(void)84 CTC_DIO::irq_0(void)
85 {
86 DBG(2, form("KCemu/CTC_DIO/irq/0",
87 "CTC::irq_0()\n"));
88 trigger(1);
89 return true;
90 }
91
92 bool
irq_1(void)93 CTC_DIO::irq_1(void)
94 {
95 DBG(2, form("KCemu/CTC_DIO/irq/1",
96 "CTC::irq_1()\n"));
97 return true;
98 }
99
100 bool
irq_2(void)101 CTC_DIO::irq_2(void)
102 {
103 DBG(2, form("KCemu/CTC_DIO/irq/2",
104 "CTC::irq_2()\n"));
105 return true;
106 }
107
108 bool
irq_3(void)109 CTC_DIO::irq_3(void)
110 {
111 DBG(2, form("KCemu/CTC_DIO/irq/3",
112 "CTC::irq_3()\n"));
113 return true;
114 }
115
116 long
counter_value_0(void)117 CTC_DIO::counter_value_0(void)
118 {
119 return 0;
120 }
121
122 long
counter_value_1(void)123 CTC_DIO::counter_value_1(void)
124 {
125 return 0;
126 }
127
128 long
counter_value_2(void)129 CTC_DIO::counter_value_2(void)
130 {
131 return 0;
132 }
133
134 long
counter_value_3(void)135 CTC_DIO::counter_value_3(void)
136 {
137 return 0;
138 }
139
140 void
trigger_irq(int channel)141 CTC_DIO::trigger_irq(int channel)
142 {
143 CTC_Base::trigger_irq(channel);
144 }
145
146 void
add_callback(unsigned long long offset,Callback * cb,void * data)147 CTC_DIO::add_callback(unsigned long long offset, Callback *cb, void *data)
148 {
149 CTC_Base::add_callback(offset, cb, data);
150 }
151