Previous 15994 Revisions Next

r2501 Tuesday 29th April, 2008 at 01:30:43 UTC by Nathan Woods
Cleanups & coding conventions
[src/mess/machine]applefdc.c

src/mess/machine/applefdc.c
r2500r2501
4343***************************************************************************/
4444
4545/* logging */
46#define LOG_IWM         0
47#define LOG_IWM_EXTRA   0
46#define LOG_APPLEFDC      0
47#define LOG_APPLEFDC_EXTRA   0
4848
4949
5050
r2500r2501
129129
130130
131131
132/* R. Nabet : Next two functions look more like a hack than a real feature of the IWM */
133/* I left them there because I had no idea what they intend to do.
134They never get called when booting the Mac Plus driver. */
132/*-------------------------------------------------
133    iwm_enable2 - hackish function
134-------------------------------------------------*/
135
135136static int iwm_enable2(void)
136137{
138   /* R. Nabet : This function looks more like a hack than a real feature of the IWM; */
139   /* it is not called from the Mac Plus driver */
137140   return (applefdc_lines & APPLEFDC_PH1) && (applefdc_lines & APPLEFDC_PH3);
138141}
139142
140143
141144
145/*-------------------------------------------------
146    iwm_readenable2handshake - hackish function
147-------------------------------------------------*/
148
142149static int iwm_readenable2handshake(void)
143150{
151   /* R. Nabet : This function looks more like a hack than a real feature of the IWM; */
152   /* it is not called from the Mac Plus driver */
153
144154   static int val = 0;
145155
146156   if (val++ > 3)
r2500r2501
151161
152162
153163
164/*-------------------------------------------------
165    applefdc_statusreg_r - reads the status register
166-------------------------------------------------*/
167
154168static int applefdc_statusreg_r(void)
155169{
156170   /* IWM status:
r2500r2501
175189
176190
177191
192/*-------------------------------------------------
193    iwm_modereg_w - changes the mode register
194-------------------------------------------------*/
195
178196static void iwm_modereg_w(int data)
179197{
180198   iwm_mode = data & 0x1f;   /* Write mode register */
181199
182   if (LOG_IWM_EXTRA)
200   if (LOG_APPLEFDC_EXTRA)
183201      logerror("iwm_modereg_w: iwm_mode=0x%02x\n", (int) iwm_mode);
184202}
185203
186204
187205
206/*-------------------------------------------------
207    applefdc_read_reg - reads a register
208-------------------------------------------------*/
209
188210static UINT8 applefdc_read_reg(int lines)
189211{
190212   UINT8 result = 0;
r2500r2501
204226             * 3.5 inch drives.  Eventually we should check to see if latch mode is
205227             * off
206228             */
207            if (LOG_IWM)
229            if (LOG_APPLEFDC)
208230            {
209231               if ((iwm_mode & IWM_MODE_LATCHMODE) == 0)
210232                  logerror("applefdc_read_reg(): latch mode off not implemented\n");
r2500r2501
234256
235257
236258
259/*-------------------------------------------------
260    applefdc_write_reg - writes a register
261-------------------------------------------------*/
262
237263static void applefdc_write_reg(UINT8 data)
238264{
239265   switch(applefdc_lines & (IWM_Q6 | IWM_Q7))
r2500r2501
250276             * 3.5 inch drives.  Eventually we should check to see if latch mode is
251277             * off
252278             */
253            if (LOG_IWM)
279            if (LOG_APPLEFDC)
254280            {
255281               if ((iwm_mode & IWM_MODE_LATCHMODE) == 0)
256282                  logerror("applefdc_write_reg(): latch mode off not implemented\n");
r2500r2501
265291
266292
267293
294/*-------------------------------------------------
295    TIMER_CALLBACK(iwm_turnmotor_onoff) - timer
296   callback for turning motor on or off
297-------------------------------------------------*/
298
268299static TIMER_CALLBACK(iwm_turnmotor_onoff)
269300{
270301   int status = param;
r2500r2501
289320   if (iwm_intf.set_enable_lines)
290321      iwm_intf.set_enable_lines(enable_lines);
291322
292   if (LOG_IWM_EXTRA)
323   if (LOG_APPLEFDC_EXTRA)
293324      logerror("iwm_turnmotor_onoff(): Turning motor %s\n", status ? "on" : "off");
294325}
295326
296327
297328
329/*-------------------------------------------------
330    iwm_access
331-------------------------------------------------*/
332
298333static void iwm_access(int offset)
299334{
300335   static const char *const lines[] =
r2500r2501
309344      "Q7"
310345   };
311346
312   if (LOG_IWM_EXTRA)
347   if (LOG_APPLEFDC_EXTRA)
313348   {
314349      logerror("iwm_access(): %s line %s\n",
315350         (offset & 1) ? "setting" : "clearing", lines[offset >> 1]);
r2500r2501
352387
353388
354389
390/*-------------------------------------------------
391    applefdc_r - reads a byte from the FDC
392-------------------------------------------------*/
393
355394READ8_HANDLER( applefdc_r )
356395{
357396   UINT8 result = 0;
358397
398   /* normalize offset */
359399   offset &= 15;
360400
361   if (LOG_IWM_EXTRA)
401   if (LOG_APPLEFDC_EXTRA)
362402      logerror("applefdc_r: offset=%i\n", offset);
363403
364404   iwm_access(offset);
r2500r2501
405445
406446
407447
448/*-------------------------------------------------
449    applefdc_w - writes a byte to the FDC
450-------------------------------------------------*/
451
408452WRITE8_HANDLER( applefdc_w )
409453{
454   /* normalize offset */
410455   offset &= 15;
411456
412   if (LOG_IWM_EXTRA)
457   if (LOG_APPLEFDC_EXTRA)
413458      logerror("applefdc_w: offset=%i data=0x%02x\n", offset, data);
414459
415460   iwm_access(offset);
r2500r2501
446491
447492
448493
494/*-------------------------------------------------
495    applefdc_w - writes a byte to the FDC
496-------------------------------------------------*/
497
449498UINT8 applefdc_get_lines(void)
450499{
451500   return applefdc_lines & 0x0f;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team