1 /*
2 * upd765.c - Copyright (c) 2001, 2006, 2007 Olivier Poncet
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include "upd765.h"
25
26 static void gdev_upd765_reset(GdevUPD765 *upd765);
27 static void gdev_upd765_clock(GdevUPD765 *upd765);
28
G_DEFINE_TYPE(GdevUPD765,gdev_upd765,GDEV_TYPE_DEVICE)29 G_DEFINE_TYPE(GdevUPD765, gdev_upd765, GDEV_TYPE_DEVICE)
30
31 /**
32 * GdevUPD765::class_init()
33 *
34 * @param upd765_class specifies the GdevUPD765 class
35 */
36 static void gdev_upd765_class_init(GdevUPD765Class *upd765_class)
37 {
38 GdevDeviceClass *device_class = GDEV_DEVICE_CLASS(upd765_class);
39
40 device_class->reset = (GdevDeviceProc) gdev_upd765_reset;
41 device_class->clock = (GdevDeviceProc) gdev_upd765_clock;
42 }
43
44 /**
45 * GdevUPD765::init()
46 *
47 * @param upd765 specifies the GdevUPD765 instance
48 */
gdev_upd765_init(GdevUPD765 * upd765)49 static void gdev_upd765_init(GdevUPD765 *upd765)
50 {
51 upd765->fdc = NULL; /* Floppy Disc Controller */
52 upd765->fdd[0] = NULL; /* Floppy Disc Drive #0 */
53 upd765->fdd[1] = NULL; /* Floppy Disc Drive #1 */
54 upd765->fdd[2] = NULL; /* Floppy Disc Drive #2 */
55 upd765->fdd[3] = NULL; /* Floppy Disc Drive #3 */
56 gdev_upd765_reset(upd765);
57 }
58
59 /**
60 * GdevUPD765::reset()
61 *
62 * @param upd765 specifies the GdevUPD765 instance
63 */
gdev_upd765_reset(GdevUPD765 * upd765)64 static void gdev_upd765_reset(GdevUPD765 *upd765)
65 {
66 }
67
68 /**
69 * GdevUPD765::clock()
70 *
71 * @param upd765 specifies the GdevUPD765 instance
72 */
gdev_upd765_clock(GdevUPD765 * upd765)73 static void gdev_upd765_clock(GdevUPD765 *upd765)
74 {
75 }
76
77 /**
78 * GdevUPD765::new()
79 *
80 * @return the GdevUPD765 instance
81 */
gdev_upd765_new(void)82 GdevUPD765 *gdev_upd765_new(void)
83 {
84 return(g_object_new(GDEV_TYPE_UPD765, NULL));
85 }
86
87 /**
88 * GdevUPD765::set_fdc()
89 *
90 * @param upd765 specifies the GdevUPD765 instance
91 * @param fdc765 specifies the GdevFDC765 instance
92 */
gdev_upd765_set_fdc(GdevUPD765 * upd765,GdevFDC765 * fdc765)93 void gdev_upd765_set_fdc(GdevUPD765 *upd765, GdevFDC765 *fdc765)
94 {
95 upd765->fdc = fdc765;
96 fdc765->upd765 = upd765;
97 }
98
99 /**
100 * GdevUPD765::set_fdd()
101 *
102 * @param upd765 specifies the GdevUPD765 instance
103 * @param fdd765 specifies the GdevFDD765 instance
104 */
gdev_upd765_set_fdd(GdevUPD765 * upd765,GdevFDD765 * fdd765,guint8 drive)105 void gdev_upd765_set_fdd(GdevUPD765 *upd765, GdevFDD765 *fdd765, guint8 drive)
106 {
107 upd765->fdd[drive] = fdd765;
108 fdd765->upd765 = upd765;
109 if((upd765->fdc != NULL)
110 && (upd765->fdc->impl != NULL)) {
111 if((upd765->fdd[drive] != NULL)
112 && (upd765->fdd[drive]->impl != NULL)) {
113 upd765->fdc->impl->fdc_drive[drive] = upd765->fdd[drive]->impl;
114 }
115 else {
116 upd765->fdc->impl->fdc_drive[drive] = NULL;
117 }
118 }
119 }
120
121 /**
122 * GdevUPD765::set_motor()
123 *
124 * @param upd765 specifies the GdevUPD765 instance
125 */
gdev_upd765_set_motor(GdevUPD765 * upd765,guint8 data)126 void gdev_upd765_set_motor(GdevUPD765 *upd765, guint8 data)
127 {
128 if(upd765->fdc->impl != NULL) {
129 fdc_set_motor(upd765->fdc->impl, data);
130 }
131 }
132