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 <ctype.h>
21
22 #include "kc/system.h"
23
24 #include "kc/kc.h"
25 #include "kc/z80.h"
26 #include "kc/fdc7.h"
27
28 #include "libdbg/dbg.h"
29
FDC7(void)30 FDC7::FDC7(void)
31 {
32 }
33
~FDC7(void)34 FDC7::~FDC7(void)
35 {
36 }
37
38 long long
get_counter()39 FDC7::get_counter()
40 {
41 return z80->getCounter();
42 }
43
44 void
add_callback(unsigned long long offset,Callback * cb,void * data)45 FDC7::add_callback(unsigned long long offset, Callback *cb, void *data)
46 {
47 z80->addCallback(offset, cb, data);
48 }
49
50 /*
51 * Documentation from Volker...
52 *
53 * ; FDC-Ports:
54 * ; ----------
55 *
56 * 'ROBOTRON'
57 *
58 * FDCD equ 98h ; FDC Datenregister
59 * FDCC equ 99h ; FDC Steueregister
60 * FDCZ equ 0A0h ; FDC Zusatzregister
61 * ; 5 4 3 2 1 0
62 * ; x x 0 0 x x
63 * ; | | | |
64 * ; | | | Motor Laufwerk 0 ein/aus
65 * ; | | Motor Laufwerk 1 ein/aus
66 * ; | Terminal Count aktivieren/deakt.
67 * ; FDC Reset
68 *
69 * ELSE Rossendorf
70 *
71 * FDCD equ 10h ; FDC Datenregister
72 * FDCC equ 11h ; FDC Steueregister
73 * FDCZ equ 12h ; FDC Zusatzregister
74 * ; 5 4 3 2 1 0
75 * ; x x 0 0 x x
76 * ; | | | |
77 * ; | | | Motor Laufwerk 0 ein/aus
78 * ; | | Motor Laufwerk 1 ein/aus
79 * ; | Terminal Count aktivieren/deakt.
80 * ; FDC Reset
81 *
82 */
83 byte_t
in(word_t addr)84 FDC7::in(word_t addr)
85 {
86 byte_t val = 0;
87
88 switch (addr & 0xff)
89 {
90 case 0x98: // CPM-Z9 module (Data Register, ROBOTRON module)
91 case 0x10: // CPM-Z9 module (Data Register, Rossendorf module)
92 val = get_msr();
93 break;
94 case 0x99: // CPM-Z9 module (Status Register, ROBOTRON module)
95 case 0x11: // CPM-Z9 module (Status Register, Rossendorf module)
96 val = in_data(addr);
97 break;
98 case 0xa0: // CPM-Z9 module (Extra Register, ROBOTRON module)
99 case 0x12: // CPM-Z9 module (Extra Register, Rossendorf module)
100 break;
101 default:
102 DBG(2, form("KCemu/FDC/in_unhandled",
103 "FDC::in(): addr = %04x\n",
104 addr));
105 break;
106 }
107
108 return val;
109 }
110
111 void
out(word_t addr,byte_t val)112 FDC7::out(word_t addr, byte_t val)
113 {
114 switch (addr & 0xff)
115 {
116 case 0x98: // CPM-Z9 module (Data Register, ROBOTRON module)
117 case 0x10: // CPM-Z9 module (Data Register, Rossendorf module)
118 write_byte(val);
119 break;
120 case 0x99: // CPM-Z9 module (Status Register, ROBOTRON module)
121 case 0x11: // CPM-Z9 module (Status Register, Rossendorf module)
122 out_data(addr, val);
123 break;
124 case 0xa0: // CPM-Z9 module (Extra Register, ROBOTRON module)
125 case 0x12: // CPM-Z9 module (Extra Register, Rossendorf module)
126 set_terminal_count((val & 0x10) == 0x10);
127
128 if ((val & 0x20) == 0x20)
129 ; // RESET
130
131 break;
132 default:
133 DBG(2, form("KCemu/FDC/out_unhandled",
134 "FDC::out(): addr = %04x, val = %02x [%c]\n",
135 addr, val, isprint(val) ? val : '.'));
136 break;
137 }
138 }
139