1 /*
2 * c64fastiec.c - Fast IEC bus handling for the C64.
3 *
4 * Written by
5 * Andreas Boose <viceteam@t-online.de>
6 *
7 * This file is part of VICE, the Versatile Commodore Emulator.
8 * See README for copyright notice.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 * 02111-1307 USA.
24 *
25 */
26
27 #include "vice.h"
28
29 #include "c64fastiec.h"
30 #include "c64.h"
31 #include "cia.h"
32 #include "via.h"
33 #include "drive.h"
34 #include "drivetypes.h"
35 #include "iecdrive.h"
36 #include "maincpu.h"
37 #include "types.h"
38 #include "drive/iec/cmdhd.h"
39
40
41 /* Fast IEC for C64 with burst mod */
42
43 static int fast_drive_direction[NUM_DISK_UNITS];
44 int burst_mod;
45
set_burst_mod(int mode,void * param)46 int set_burst_mod(int mode, void *param)
47 {
48 switch (mode) {
49 case BURST_MOD_NONE:
50 case BURST_MOD_CIA1:
51 case BURST_MOD_CIA2:
52 break;
53 default:
54 return -1;
55 }
56
57 burst_mod = mode;
58 return 0;
59 }
60
c64fastiec_init(void)61 void c64fastiec_init(void)
62 {
63 unsigned int dnr;
64
65 for (dnr = 0; dnr < NUM_DISK_UNITS; dnr++) {
66 fast_drive_direction[dnr] = 1;
67 }
68 }
69
c64fastiec_fast_cpu_write(uint8_t data)70 void c64fastiec_fast_cpu_write(uint8_t data)
71 {
72 unsigned int dnr;
73
74 for (dnr = 0; dnr < NUM_DISK_UNITS; dnr++) {
75 diskunit_context_t *unit = diskunit_context[dnr];
76
77 if (unit->enable) {
78 drive_cpu_execute_one(unit, maincpu_clk);
79 switch (unit->type) {
80 case DRIVE_TYPE_1570:
81 case DRIVE_TYPE_1571:
82 case DRIVE_TYPE_1571CR:
83 ciacore_set_sdr(unit->cia1571, data);
84 break;
85 case DRIVE_TYPE_1581:
86 ciacore_set_sdr(unit->cia1581, data);
87 break;
88 case DRIVE_TYPE_2000:
89 case DRIVE_TYPE_4000:
90 viacore_set_sr(unit->via4000, data);
91 break;
92 case DRIVE_TYPE_CMDHD:
93 viacore_set_sr(unit->cmdhd->via10, data);
94 break;
95 }
96 }
97 }
98 }
99
iec_fast_drive_write(uint8_t data,unsigned int dnr)100 void iec_fast_drive_write(uint8_t data, unsigned int dnr)
101 {
102 if (fast_drive_direction[dnr]) {
103 switch (burst_mod) {
104 case BURST_MOD_CIA1:
105 ciacore_set_sdr(machine_context.cia1, data);
106 break;
107 case BURST_MOD_CIA2:
108 ciacore_set_sdr(machine_context.cia2, data);
109 break;
110 }
111 }
112 }
113
iec_fast_drive_direction(int direction,unsigned int dnr)114 void iec_fast_drive_direction(int direction, unsigned int dnr)
115 {
116 /* 0: input */
117 fast_drive_direction[dnr] = direction;
118 }
119