-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFloppyController.cpp
More file actions
206 lines (192 loc) · 5.65 KB
/
FloppyController.cpp
File metadata and controls
206 lines (192 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/* ES40 emulator.
* Copyright (C) 2007 by the ES40 Emulator Project
*
* WWW : http://sourceforge.net/projects/es40
* E-mail : camiel@camicom.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Although this is not required, the author would appreciate being notified of,
* and receiving any modifications you may make to the source code that might serve
* the general public.
*/
/**
* \file
* Contains the code for the emulated Floppy Controller devices.
*
* X-1.11 Camiel Vanderhoeven 30-DEC-2007
* Print file id on initialization.
*
* X-1.10 Camiel Vanderhoeven 11-DEC-2007
* Don't claim IO port 3f6 as this is in use by the IDE controller.
*
* X-1.9 Camiel Vanderhoeven 10-DEC-2007
* Use configurator.
*
* X-1.8 Camiel Vanderhoeven 31-MAR-2007
* Added old changelog comments.
*
* X-1.7 Brian Wheeler 13-FEB-2007
* Formatting.
*
* X-1.6 Camiel Vanderhoeven 12-FEB-2007
* Added comments.
*
* X-1.5 Camiel Vanderhoeven 9-FEB-2007
* Added comments.
*
* X-1.4 Brian Wheeler 3-FEB-2007
* Formatting.
*
* X-1.3 Brian Wheeler 3-FEB-2007
* 64-bit literals made compatible with Linux/GCC/glibc.
*
* X-1.2 Brian Wheeler 3-FEB-2007
* Includes are now case-correct (necessary on Linux)
*
* X-1.1 Camiel Vanderhoeven 19-JAN-2007
* Initial version in CVS.
*
* \author Camiel Vanderhoeven (camiel@camicom.com / http://www.camicom.com)
**/
#include "StdAfx.h"
#include "FloppyController.h"
#include "System.h"
/**
* Constructor.
**/
CFloppyController::CFloppyController(CConfigurator * cfg, CSystem * c, int id) : CSystemComponent(cfg,c)
{
c->RegisterMemory(this, 0, X64(00000801fc0003f0) - (0x80 * id), 6);
c->RegisterMemory(this, 1, X64(00000801fc0003f7) - (0x80 * id), 1);
iMode = 0;
iID = id;
iActiveRegister = 0;
iRegisters[0x00] = 0x28;
iRegisters[0x01] = 0x9c;
iRegisters[0x02] = 0x88;
iRegisters[0x03] = 0x78;
iRegisters[0x04] = 0x00;
iRegisters[0x05] = 0x00;
iRegisters[0x06] = 0xff;
iRegisters[0x07] = 0x00;
iRegisters[0x08] = 0x00;
iRegisters[0x09] = 0x00;
iRegisters[0x0a] = 0x00;
iRegisters[0x0b] = 0x00;
iRegisters[0x0c] = 0x00;
iRegisters[0x0d] = 0x03;
iRegisters[0x0e] = 0x02;
iRegisters[0x0f] = 0x00;
iRegisters[0x10] = 0x00;
iRegisters[0x11] = 0x00;
iRegisters[0x12] = 0x00;
iRegisters[0x13] = 0x00;
iRegisters[0x14] = 0x00;
iRegisters[0x15] = 0x00;
iRegisters[0x16] = 0x00;
iRegisters[0x17] = 0x00;
iRegisters[0x18] = 0x00;
iRegisters[0x19] = 0x00;
iRegisters[0x1a] = 0x00;
iRegisters[0x1b] = 0x00;
iRegisters[0x1c] = 0x00;
iRegisters[0x1d] = 0x00;
iRegisters[0x1e] = 0x3c;
iRegisters[0x1f] = 0x00;
iRegisters[0x20] = 0x3c;
iRegisters[0x21] = 0x3c;
iRegisters[0x22] = 0x3d;
iRegisters[0x23] = 0x00;
iRegisters[0x24] = 0x00;
iRegisters[0x25] = 0x00;
iRegisters[0x26] = 0x00;
iRegisters[0x27] = 0x00;
iRegisters[0x28] = 0x00;
iRegisters[0x29] = 0x00;
printf("%s: $Id: FloppyController.cpp,v 1.11 2007/12/30 15:10:22 iamcamiel Exp $\n",devid_string);
}
/**
* Destructor.
**/
CFloppyController::~CFloppyController()
{
}
void CFloppyController::WriteMem(int index, u64 address, int dsize, u64 data)
{
if (index==1)
address += 7;
switch (address)
{
case 0:
switch (data&0xff)
{
case 0x55:
// if (iMode==1)
// printf("Entering configuration mode for floppy controller %d\n", iID);
if (iMode==0 || iMode==1)
iMode++;
break;
case 0xaa:
// if (iMode==2)
// printf("Leaving configuration mode for floppy controller %d\n", iID);
iMode=0;
break;
default:
if (iMode==2)
iActiveRegister = (int)(data&0xff);
// else
// printf("Unknown command: %02x on floppy port %d\n",(u32)(data&0xff),(u32)address);
}
break;
case 1:
if (iMode==2)
{
if (iActiveRegister < 0x2a)
iRegisters[iActiveRegister] = (u8)(data&0xff);
// else
// printf("Unknown floppy register: %02x\n",iActiveRegister);
}
// else
// printf("Unknown command: %02x on floppy port %d\n",(u32)(data&0xff),(u32)address);
break;
// default:
// printf("Unknown command: %02x on floppy port %d\n",(u32)(data&0xff),(u32)address);
}
}
u64 CFloppyController::ReadMem(int index, u64 address, int dsize)
{
if (index==1)
address += 7;
switch (address)
{
case 1:
if (iMode==2)
{
if (iActiveRegister < 0x2a)
return (u64)(iRegisters[iActiveRegister]);
}
break;
case 4: //3f4 floppy main status register
return 0x80; // floppy ready
break;
case 5: //3f5 floppy command status register
return 0;
break;
default:
printf("Unknown read access on floppy port %d\n",(u32)address);
}
return 0;
}