1 |
|
/* |
2 |
|
* sony.cpp - Replacement .Sony driver (floppy drives) |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2000 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
42 |
|
#define DEBUG 0 |
43 |
|
#include "debug.h" |
44 |
|
|
45 |
+ |
|
46 |
+ |
// Check for inserted disks by polling? |
47 |
|
#ifdef AMIGA |
48 |
< |
#define DISK_INSERT_CHECK 1 // Check for inserted disks (problem: on most hardware, disks are not ejected and automatically remounted) |
48 |
> |
#define DISK_INSERT_CHECK 1 |
49 |
|
#else |
50 |
|
#define DISK_INSERT_CHECK 0 |
51 |
|
#endif |
125 |
|
uint32 SonyDiskIconAddr; |
126 |
|
uint32 SonyDriveIconAddr; |
127 |
|
|
128 |
< |
// Flag: accRun called for the first time, run PatchAfterStartup() |
129 |
< |
static bool periodic_first_time = false; |
128 |
> |
// Flag: Control(accRun) has been called, interrupt routine is now active |
129 |
> |
static bool acc_run_called = false; |
130 |
|
|
131 |
|
|
132 |
|
/* |
218 |
|
|
219 |
|
|
220 |
|
/* |
221 |
+ |
* Mount volumes for which the to_be_mounted flag is set |
222 |
+ |
* (called during interrupt time) |
223 |
+ |
*/ |
224 |
+ |
|
225 |
+ |
static void mount_mountable_volumes(void) |
226 |
+ |
{ |
227 |
+ |
DriveInfo *info = first_drive_info; |
228 |
+ |
while (info != NULL) { |
229 |
+ |
|
230 |
+ |
#if DISK_INSERT_CHECK |
231 |
+ |
// Disk in drive? |
232 |
+ |
if (!ReadMacInt8(info->status + dsDiskInPlace)) { |
233 |
+ |
|
234 |
+ |
// No, check if disk was inserted |
235 |
+ |
if (SysIsDiskInserted(info->fh)) |
236 |
+ |
SonyMountVolume(info->fh); |
237 |
+ |
} |
238 |
+ |
#endif |
239 |
+ |
|
240 |
+ |
// Mount disk if flagged |
241 |
+ |
if (info->to_be_mounted) { |
242 |
+ |
D(bug(" mounting drive %d\n", info->num)); |
243 |
+ |
M68kRegisters r; |
244 |
+ |
r.d[0] = info->num; |
245 |
+ |
r.a[0] = 7; // diskEvent |
246 |
+ |
Execute68kTrap(0xa02f, &r); // PostEvent() |
247 |
+ |
info->to_be_mounted = false; |
248 |
+ |
} |
249 |
+ |
|
250 |
+ |
info = info->next; |
251 |
+ |
} |
252 |
+ |
} |
253 |
+ |
|
254 |
+ |
|
255 |
+ |
/* |
256 |
|
* Driver Open() routine |
257 |
|
*/ |
258 |
|
|
263 |
|
// Set up DCE |
264 |
|
WriteMacInt32(dce + dCtlPosition, 0); |
265 |
|
WriteMacInt16(dce + dCtlQHdr + qFlags, ReadMacInt16(dce + dCtlQHdr + qFlags) & 0xff00 | 3); // Version number, must be >=3 or System 8 will replace us |
266 |
< |
periodic_first_time = true; |
266 |
> |
acc_run_called = false; |
267 |
|
|
268 |
|
// Install driver again with refnum -2 (HD20) |
269 |
|
uint32 utab = ReadMacInt32(0x11c); |
391 |
|
case 9: // Track cache |
392 |
|
return noErr; |
393 |
|
|
394 |
< |
case 65: { // Periodic action ("insert" disks on startup and check for disk changes) |
395 |
< |
DriveInfo *info = first_drive_info; |
396 |
< |
while (info != NULL) { |
397 |
< |
|
398 |
< |
// Disk in drive? |
362 |
< |
if (!ReadMacInt8(info->status + dsDiskInPlace)) { |
363 |
< |
|
364 |
< |
#if DISK_INSERT_CHECK |
365 |
< |
// No, check if disk was inserted |
366 |
< |
if (SysIsDiskInserted(info->fh)) |
367 |
< |
SonyMountVolume(info->fh); |
368 |
< |
#endif |
369 |
< |
} |
370 |
< |
|
371 |
< |
// Mount disk if flagged |
372 |
< |
if (info->to_be_mounted) { |
373 |
< |
D(bug(" mounting drive %d\n", info->num)); |
374 |
< |
M68kRegisters r; |
375 |
< |
r.d[0] = info->num; |
376 |
< |
r.a[0] = 7; // diskEvent |
377 |
< |
Execute68kTrap(0xa02f, &r); // PostEvent() |
378 |
< |
info->to_be_mounted = false; |
379 |
< |
} |
380 |
< |
|
381 |
< |
info = info->next; |
382 |
< |
} |
383 |
< |
if (periodic_first_time) { |
384 |
< |
periodic_first_time = false; |
385 |
< |
PatchAfterStartup(); // Install patches after system startup |
386 |
< |
} |
394 |
> |
case 65: // Periodic action (accRun, "insert" disks on startup) |
395 |
> |
mount_mountable_volumes(); |
396 |
> |
PatchAfterStartup(); // Install patches after system startup |
397 |
> |
WriteMacInt16(dce + dCtlFlags, ReadMacInt16(dce + dCtlFlags) & ~0x2000); // Disable periodic action |
398 |
> |
acc_run_called = true; |
399 |
|
return noErr; |
388 |
– |
} |
400 |
|
} |
401 |
|
|
402 |
|
// Drive valid? |
449 |
|
WriteMacInt32(pb + csParam, 0x0104); // External drive |
450 |
|
return noErr; |
451 |
|
|
452 |
< |
case 'SC': { // Format and write to disk |
452 |
> |
case 0x5343: { // Format and write to disk ('SC'), used by DiskCopy |
453 |
|
if (!ReadMacInt8(info->status + dsDiskInPlace)) |
454 |
|
return offLinErr; |
455 |
|
if (info->read_only) |
496 |
|
return paramErr; |
497 |
|
|
498 |
|
case 8: // Get drive status |
499 |
< |
memcpy(Mac2HostAddr(pb + csParam), Mac2HostAddr(info->status), 22); |
499 |
> |
Mac2Mac_memcpy(pb + csParam, info->status, 22); |
500 |
|
return noErr; |
501 |
|
|
502 |
|
case 10: // Get disk type |
503 |
|
WriteMacInt32(pb + csParam, ReadMacInt32(info->status + dsMFMDrive) & 0xffffff00 | 0xfe); |
504 |
|
return noErr; |
505 |
|
|
506 |
< |
case 'DV': // Duplicator version supported |
506 |
> |
case 0x4456: // Duplicator version supported ('DV') |
507 |
|
WriteMacInt16(pb + csParam, 0x0410); |
508 |
|
return noErr; |
509 |
|
|
510 |
< |
case 'SC': // Get address header format byte |
510 |
> |
case 0x5343: // Get address header format byte ('SC') |
511 |
|
WriteMacInt8(pb + csParam, 0x22); // 512 bytes/sector |
512 |
|
return noErr; |
513 |
|
|
516 |
|
return statusErr; |
517 |
|
} |
518 |
|
} |
519 |
+ |
|
520 |
+ |
|
521 |
+ |
/* |
522 |
+ |
* Driver interrupt routine (1Hz) - check for volumes to be mounted |
523 |
+ |
*/ |
524 |
+ |
|
525 |
+ |
void SonyInterrupt(void) |
526 |
+ |
{ |
527 |
+ |
if (!acc_run_called) |
528 |
+ |
return; |
529 |
+ |
|
530 |
+ |
mount_mountable_volumes(); |
531 |
+ |
} |