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/tape.h"
26 #include "kc/ctc3.h"
27 
28 #include "ui/ui.h"
29 
30 #include "libdbg/dbg.h"
31 
CTC3(void)32 CTC3::CTC3(void)
33 {
34 }
35 
~CTC3(void)36 CTC3::~CTC3(void)
37 {
38 }
39 
40 byte_t
in(word_t addr)41 CTC3::in(word_t addr)
42 {
43   DBG(2, form("KCemu/CTC/3/in",
44               "CTC3::in(): addr = %04x\n",
45               addr));
46 
47   switch (addr & 3)
48     {
49     case 0:
50       return c_in(0);
51     case 1:
52       return c_in(1);
53     case 2:
54       return c_in(2);
55     case 3:
56       return c_in(3);
57     }
58 
59   return 0; // shouldn't be reached
60 }
61 
62 void
out(word_t addr,byte_t val)63 CTC3::out(word_t addr, byte_t val)
64 {
65   DBG(2, form("KCemu/CTC/3/out",
66               "CTC3::out(): addr = %04x, val = %02x\n",
67               addr, val));
68   switch (addr & 3)
69     {
70     case 0:
71       c_out(0, val);
72       break;
73     case 1:
74       c_out(1, val);
75       break;
76     case 2:
77       c_out(2, val);
78       break;
79     case 3:
80       c_out(3, val);
81       break;
82     }
83 }
84 
85 bool
irq_0(void)86 CTC3::irq_0(void)
87 {
88   return false;
89 }
90 
91 bool
irq_1(void)92 CTC3::irq_1(void)
93 {
94   tape->tape_signal();
95   return true;
96 }
97 
98 bool
irq_2(void)99 CTC3::irq_2(void)
100 {
101   ui->flash(true);
102   return true;
103 }
104 
105 bool
irq_3(void)106 CTC3::irq_3(void)
107 {
108   return false;
109 }
110 
111 long
counter_value_0(void)112 CTC3::counter_value_0(void)
113 {
114   return 0;
115 }
116 
117 long
counter_value_1(void)118 CTC3::counter_value_1(void)
119 {
120   return 0;
121 }
122 
123 long
counter_value_2(void)124 CTC3::counter_value_2(void)
125 {
126   /*
127    *  CLK for channel 2 is 50 Hz
128    */
129   return CHANNEL_2_CLK;
130 }
131 
132 long
counter_value_3(void)133 CTC3::counter_value_3(void)
134 {
135   return 0;
136 }
137