branches/alto2/src/emu/cpu/alto2/alto2.h
| r26032 | r26033 | |
| 15 | 15 | #ifndef _CPU_ALTO2_H_ |
| 16 | 16 | #define _CPU_ALTO2_H |
| 17 | 17 | |
| 18 | | #ifndef DEBUG |
| 19 | | #define DEBUG 0 |
| 20 | | #endif |
| 18 | #define ALTO2_TAG "alto2" |
| 21 | 19 | |
| 22 | | #if DEBUG |
| 23 | | extern void logprintf(int type, int level, const char* format, ...); |
| 24 | | #define LOG(x) logprintf x |
| 25 | | #else |
| 26 | | #define LOG(x) |
| 20 | #ifndef ALTO2_DEBUG |
| 21 | #define ALTO2_DEBUG 0 |
| 27 | 22 | #endif |
| 28 | 23 | |
| 29 | 24 | //extern void fatal(int level, const char* format, ...); |
| r26032 | r26033 | |
| 76 | 71 | #define ALTO2_UCODE_SIZE ((ALTO2_UCODE_ROM_PAGES + ALTO2_UCODE_RAM_PAGES) * ALTO2_UCODE_PAGE_SIZE) //!< total number of words of microcode |
| 77 | 72 | #define ALTO2_UCODE_RAM_BASE (ALTO2_UCODE_ROM_PAGES * ALTO2_UCODE_PAGE_SIZE) //!< base offset for the RAM page(s) |
| 78 | 73 | #define ALTO2_CONST_SIZE 256 //!< number words in the constant ROM |
| 79 | | #define ALTO2_RAM_SIZE 262144 //!< size of main memory in bytes |
| 74 | #define ALTO2_RAM_SIZE 0200000 //!< size of main memory in words |
| 75 | #define ALTO2_IO_PAGE_BASE 0177000 //!< base address of the memory mapped io range |
| 76 | #define ALTO2_IO_PAGE_SIZE 01000 //!< size of the memory mapped io range |
| 80 | 77 | |
| 81 | 78 | /** |
| 82 | 79 | * @brief start value for the horizontal line counter |
| r26032 | r26033 | |
| 235 | 232 | virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options); |
| 236 | 233 | |
| 237 | 234 | private: |
| 235 | #if ALTO2_DEBUG |
| 236 | void logprintf(int type, int level, const char* format, ...); |
| 237 | # define LOG(x) logprintf x |
| 238 | #else |
| 239 | # define LOG(x) |
| 240 | #endif |
| 241 | |
| 238 | 242 | void fatal(int level, const char *format, ...); |
| 239 | 243 | |
| 240 | 244 | address_space_config m_ucode_config; |
| r26032 | r26033 | |
| 729 | 733 | int m_unload_time; //!< unload word time accu |
| 730 | 734 | int m_unload_word; //!< unload word number |
| 731 | 735 | |
| 732 | | static const char *task_name(int task); //!< human readable task names |
| 736 | static const char *task_name(int task); //!< human readable task names |
| 733 | 737 | static const char *r_name(UINT8 reg); //!< human readable register names |
| 734 | 738 | static const char *aluf_name(UINT8 aluf); //!< human readable ALU function names |
| 735 | 739 | static const char *bs_name(UINT8 bs); //!< human readable bus source names |
| r26032 | r26033 | |
| 1270 | 1274 | // ************************************************ |
| 1271 | 1275 | // diablo31 drive stuff |
| 1272 | 1276 | // ************************************************ |
| 1273 | | static const int DRIVE_MAX = 2; //!< max number of drive units |
| 1274 | | static const int DRIVE_CYLINDERS = 203; //!< number of cylinders per drive |
| 1275 | | static const int DRIVE_CYLINDER_MASK = 0777; //!< bit maks for cylinder number (9 bits) |
| 1276 | | static const int DRIVE_SPT = 12; //!< number of sectors per track |
| 1277 | | static const int DRIVE_SECTOR_MASK = 017; //!< bit maks for cylinder number (4 bits) |
| 1278 | | static const int DRIVE_HEADS = 2; //!< number of heads per drive |
| 1279 | | static const int DRIVE_PAGES = 203*2*12; //!< number of pages per drive |
| 1280 | | static const int DRIVE_HEAD_MASK = 1; //!< bit maks for cylinder number (4 bits) |
| 1277 | #define DIABLO31 1 |
| 1278 | static const int DIABLO_DRIVE_MAX = 2; //!< max number of drive units |
| 1279 | static const int DIABLO_DRIVE_CYLINDERS = 203; //!< number of cylinders per drive |
| 1280 | static const int DIABLO_DRIVE_CYLINDER_MASK = 0777; //!< bit maks for cylinder number (9 bits) |
| 1281 | static const int DIABLO_DRIVE_SPT = 12; //!< number of sectors per track |
| 1282 | static const int DIABLO_DRIVE_SECTOR_MASK = 017; //!< bit maks for cylinder number (4 bits) |
| 1283 | static const int DIABLO_DRIVE_HEADS = 2; //!< number of heads per drive |
| 1284 | static const int DIABLO_DRIVE_PAGES = 203*2*12; //!< number of pages per drive |
| 1285 | static const int DIABLO_DRIVE_HEAD_MASK = 1; //!< bit maks for cylinder number (4 bits) |
| 1281 | 1286 | //! convert a cylinder/head/sector to a logical block address (page) |
| 1282 | | static inline int DRIVE_PAGE(int c,int h,int s) { return (c * DRIVE_HEADS + h) * DRIVE_SPT + s; } |
| 1287 | static inline int DRIVE_PAGE(int c,int h,int s) { return (c * DIABLO_DRIVE_HEADS + h) * DIABLO_DRIVE_SPT + s; } |
| 1288 | /** |
| 1289 | * @brief description of the sector layout |
| 1290 | * <PRE> |
| 1291 | * |
| 1292 | * xx.x msec sector mark pulses |
| 1293 | * -+ +-------------------------------------------------------------------------------+ +-- |
| 1294 | * | | | | |
| 1295 | * +---+ +---+ |
| 1296 | * |
| 1297 | * | | |
| 1298 | * |
| 1299 | * +------+----+------+-----+------+----+-------+-----+------+----+-------+-----+------+ |
| 1300 | * | PRE- |SYNC|HEADER|CKSUM| PRE- |SYNC| LABEL |CKSUM| PRE- |SYNC| DATA |CKSUM| POST | |
| 1301 | * |AMBLE1| 1 | | 1 |AMBLE2| 2 | | 2 |AMBLE3| 3 | | 3 |AMBLE | |
| 1302 | * +------+----+------+-----+------+----+-------+-----+------+----+-------+-----+------+ |
| 1303 | * |
| 1304 | * | | |
| 1305 | * |
| 1306 | * +-----------------------------------------------------------------------------------+ |
| 1307 | * | | |
| 1308 | * ---+ +---- |
| 1309 | * FORMAT WRITE GATE FOR INITIALIZING |
| 1310 | * | | |
| 1311 | * |
| 1312 | * | +------------------------------+ |
| 1313 | * | | |
| 1314 | * ---|----------------------------------------------------+ +---- |
| 1315 | * WRITE GATE FOR DATA XFER (*) |
| 1316 | * | | |
| 1317 | * |
| 1318 | * | +-----------------------+-+------------------------------+ |
| 1319 | * | | | may be continuous (?) | |
| 1320 | * ------------------------------+ +-+ +---- |
| 1321 | * ??? WRITE GATE FOR LABEL AND DATA XFER (*) |
| 1322 | * | | |
| 1323 | * |
| 1324 | * | +--------------------+ +---------------------+ +----------------------------+ |
| 1325 | * | | | | | | |
| 1326 | * -------+ +---+ +---+ +---- |
| 1327 | * READ GATE FOR INITIALIZING OR DATA XFER (**) |
| 1328 | * |
| 1329 | * |
| 1330 | * (*) Enable should be delayed 1 byte/word time from last bit of checks sum. |
| 1331 | * (**) Read Gate should be enabled half way through the preamble area. This |
| 1332 | * ensures reading a zero field for data separator synchronization. |
| 1333 | * |
| 1334 | * </PRE> |
| 1335 | */ |
| 1336 | static const int DIABLO_PAGENO_WORDS = 1; //!< number of words in a page number (this doesn't really belong here) |
| 1337 | static const int DIABLO_HEADER_WORDS = 2; //!< number of words in a header (this doesn't really belong here) |
| 1338 | static const int DIABLO_LABEL_WORDS = 8; //!< number of words in a label (this doesn't really belong here) |
| 1339 | static const int DIABLO_DATA_WORDS = 256; //!< number of data words (this doesn't really belong here) |
| 1340 | static const int DIABLO_CKSUM_WORDS = 1; //!< number of words for a checksum (this doesn't really belong here) |
| 1283 | 1341 | |
| 1284 | | void* m_drive[2]; //!< private drive data |
| 1342 | #if DIABLO31 |
| 1343 | /** @brief DIABLO 31 rotation time is approx. 40ms */ |
| 1344 | #define DIABLO_ROTATION_TIME attotime::from_msec(39.9999) |
| 1345 | |
| 1346 | /** @brief DIABLO 31 sector time */ |
| 1347 | #define DIABLO_SECTOR_TIME attotime::from_msec(39.9999/DIABLO_DRIVE_SPT) |
| 1348 | |
| 1349 | /** @brief DIABLO 31 bit clock is 3330kHz ~= 300ns per bit |
| 1350 | * ~= 133333 bits/track (?) |
| 1351 | * ~= 11111 bits/sector |
| 1352 | * ~= 347 words/sector |
| 1353 | */ |
| 1354 | #define DIABLO_BIT_TIME(bits) attotime::from_nsec(300*(bits)) |
| 1355 | |
| 1356 | /** @brief DIABLO 31 possible sector words */ |
| 1357 | #define DIABLO_SECTOR_WORDS 347 |
| 1358 | |
| 1359 | /** @brief pulse width of sector mark before the next sector begins */ |
| 1360 | #define DIABLO_SECTOR_MARK_PULSE_PRE DIABLO_BIT_TIME(16) |
| 1361 | |
| 1362 | /** @brief pulse width of sector mark after the next sector began */ |
| 1363 | #define DIABLO_SECTOR_MARK_PULSE_POST DIABLO_BIT_TIME(16) |
| 1364 | |
| 1365 | #else /* DIABLO31 */ |
| 1366 | |
| 1367 | /** @brief DIABLO 44 rotation time is approx. 25ms */ |
| 1368 | #define DIABLO_ROTATION_TIME attotime::from_msec(25) |
| 1369 | |
| 1370 | /** @brief DIABLO 44 sector time */ |
| 1371 | #define DIABLO_SECTOR_TIME attotime::from_msec(25/DIABLO_DRIVE_SPT) |
| 1372 | |
| 1373 | /** @brief DIABLO 44 bit clock is 5000kHz ~= 200ns per bit |
| 1374 | * ~= 125184 bits/track (?) |
| 1375 | * ~= 10432 bits/sector |
| 1376 | * ~= 325 words/sector |
| 1377 | */ |
| 1378 | #define DIABLO_BIT_TIME attotime::from_nsec(200) |
| 1379 | |
| 1380 | /** @brief DIABLO 44 possible sector words */ |
| 1381 | #define DIABLO_SECTOR_WORDS 325 |
| 1382 | |
| 1383 | /** @brief pulse width of sector mark before the next sector begins */ |
| 1384 | #define DIABLO_SECTOR_MARK_PULSE_PRE DIABLO_BIT_TIME(16) |
| 1385 | |
| 1386 | /** @brief pulse width of sector mark after the next sector began */ |
| 1387 | #define DIABLO_SECTOR_MARK_PULSE_POST DIABLO_BIT_TIME(16) |
| 1388 | #endif |
| 1389 | |
| 1390 | /** |
| 1391 | * @brief format of the cooked disk image sectors, i.e. pure data |
| 1392 | * |
| 1393 | * The available images are a multiple of 267 words per sector, |
| 1394 | * 1 word page number |
| 1395 | * 2 words header |
| 1396 | * 8 words label |
| 1397 | * 256 words data |
| 1398 | */ |
| 1399 | typedef struct { |
| 1400 | UINT8 pageno[2*DIABLO_PAGENO_WORDS]; //!< sector page number |
| 1401 | UINT8 header[2*DIABLO_HEADER_WORDS]; //!< sector header words |
| 1402 | UINT8 label[2*DIABLO_LABEL_WORDS]; //!< sector label words |
| 1403 | UINT8 data[2*DIABLO_DATA_WORDS]; //!< sector data words |
| 1404 | } diablo_sector_t; |
| 1405 | |
| 1406 | /** |
| 1407 | * @brief Structure of the disk drive context (2 drives or packs per system) |
| 1408 | */ |
| 1409 | typedef struct { |
| 1410 | diablo_sector_t *image; //!< disk image, made up of 203 x 2 x 12 sectors |
| 1411 | int unit; //!< drive unit number (0 or 1) |
| 1412 | char description[32]; //!< description of the drive(s) |
| 1413 | char basename[80]; //!< basename of the drive image |
| 1414 | int packs; //!< number of packs in drive (1 or 2) |
| 1415 | attotime rotation_time; //!< rotation time |
| 1416 | attotime bit_time; //!< bit time in atto seconds |
| 1417 | int s_r_w_0; //!< drive seek/read/write signal (active 0) |
| 1418 | int ready_0; //!< drive ready signal (active 0) |
| 1419 | int sector_mark_0; //!< sector mark (0 if new sector) |
| 1420 | int addx_acknowledge_0; //!< address acknowledge, i.e. seek successful (active 0) |
| 1421 | int log_addx_interlock_0; //!< log address interlock, i.e. seek in progress (active 0) |
| 1422 | int seek_incomplete_0; //!< seek incomplete, i.e. seek in progress (active 0) |
| 1423 | int egate_0; //!< erase gate |
| 1424 | int wrgate_0; //!< write gate |
| 1425 | int rdgate_0; //!< read gate |
| 1426 | int cylinder; //!< current cylinder number |
| 1427 | int head; //!< current head (track) number on cylinder |
| 1428 | int sector; //!< current sector number in track |
| 1429 | UINT32 *bits[DIABLO_DRIVE_CYLINDERS * DIABLO_DRIVE_HEADS * DIABLO_DRIVE_SPT]; //!< sectors expanded to bits |
| 1430 | int page; //!< current page = (cylinder * HEADS + head) * SPT + sector |
| 1431 | int rdfirst; //!< set to first bit of a sector that is read from |
| 1432 | int rdlast; //!< set to last bit of a sector that was read from |
| 1433 | int wrfirst; //!< set to non-zero if a sector is written to |
| 1434 | int wrlast; //!< set to last bit of a sector that was written to |
| 1435 | } diablo_drive_t; |
| 1436 | |
| 1437 | diablo_drive_t* m_drive[2]; //!< per drive data |
| 1285 | 1438 | int m_unit_selected; //!< selected drive unit |
| 1286 | 1439 | int m_head_selected; //!< selected drive head |
| 1287 | 1440 | a2cb m_sector_callback; //!< callback to call at the start of each sector |
| 1288 | 1441 | emu_timer* m_sector_timer; //!< sector timer |
| 1442 | void drive_get_sector(int unit); //!< calculate the sector from the logical block address |
| 1443 | void expand_sector(int unit, int page); //!< Expand a sector into an array of clock and data bits |
| 1444 | void squeeze_sector(int unit); //!< Squeeze a array of clock and data bits into a sector's data |
| 1289 | 1445 | int drive_bits_per_sector() const; //!< return number of bitclk edges for a sector |
| 1290 | 1446 | const char* drive_description(int unit); //!< return a pointer to a drive's description |
| 1291 | 1447 | const char* drive_basename(int unit); //!< return a pointer to a drive's image basename |
| r26032 | r26033 | |
| 1690 | 1846 | /** @brief set non-zero to incorporate the Hamming code and Parity check */ |
| 1691 | 1847 | #define ALTO2_HAMMING_CHECK 1 |
| 1692 | 1848 | |
| 1693 | | #define ALTO2_IO_PAGE_SIZE 01000 |
| 1694 | | #define ALTO2_IO_PAGE_BASE 0177000 |
| 1695 | | |
| 1696 | 1849 | enum { |
| 1697 | 1850 | ALTO2_MEM_NONE, |
| 1698 | 1851 | ALTO2_MEM_ODD = (1 << 0), |
| r26032 | r26033 | |
| 1724 | 1877 | UINT16 mesr; //!< memory error status register |
| 1725 | 1878 | UINT16 mecr; //!< memory error control register |
| 1726 | 1879 | |
| 1727 | | #if DEBUG |
| 1880 | #if ALTO2_DEBUG |
| 1728 | 1881 | void (*watch_read)(int mar, int md); //!< watch read function (debugging) |
| 1729 | 1882 | void (*watch_write)(int mar, int md); //!< watch write function (debugging) |
| 1730 | 1883 | #endif |
| r26032 | r26033 | |
| 1981 | 2134 | void init_ether(int task); //!< 007 initialize ethernet task |
| 1982 | 2135 | |
| 1983 | 2136 | // memory refresh task |
| 2137 | void f1_mrt_block_0(); //!< f1_mrt_block early: block the display word task |
| 2138 | void mrt_activate(); //!< called by the CPU when MRT becomes active |
| 1984 | 2139 | void init_mrt(int task); //!< 010 initialize memory refresh task |
| 1985 | 2140 | |
| 1986 | 2141 | // display word task |
branches/alto2/src/emu/cpu/alto2/a2drive.c
| r26032 | r26033 | |
| 9 | 9 | *****************************************************************************/ |
| 10 | 10 | #include "alto2.h" |
| 11 | 11 | |
| 12 | | #define DIABLO31 1 |
| 13 | | |
| 14 | | #define PAGENO_WORDS 1 //!< number of words in a page number (this doesn't really belong here) |
| 15 | | #define HEADER_WORDS 2 //!< number of words in a header (this doesn't really belong here) |
| 16 | | #define LABEL_WORDS 8 //!< number of words in a label (this doesn't really belong here) |
| 17 | | #define DATA_WORDS 256 //!< number of data words (this doesn't really belong here) |
| 18 | | #define CKSUM_WORDS 1 //!< number of words for a checksum (this doesn't really belong here) |
| 19 | 12 | #define MFROBL 34 //!< from the microcode: disk header preamble is 34 words |
| 20 | 13 | #define MFRRDL 21 //!< from the microcode: disk header read delay is 21 words |
| 21 | 14 | #define MIRRDL 4 //!< from the microcode: interrecord read delay is 4 words |
| 22 | 15 | #define MIROBL 3 //!< from the microcode: disk interrecord preamble is 3 words |
| 23 | 16 | #define MRPAL 3 //!< from the microcode: disk read postamble length is 3 words |
| 24 | 17 | #define MWPAL 5 //!< from the microcode: disk write postamble length is 5 words |
| 25 | | /** |
| 26 | | * @brief description of the sector layout |
| 27 | | * <PRE> |
| 28 | | * |
| 29 | | * xx.x msec sector mark pulses |
| 30 | | * -+ +-------------------------------------------------------------------------------+ +-- |
| 31 | | * | | | | |
| 32 | | * +---+ +---+ |
| 33 | | * |
| 34 | | * | | |
| 35 | | * |
| 36 | | * +------+----+------+-----+------+----+-------+-----+------+----+-------+-----+------+ |
| 37 | | * | PRE- |SYNC|HEADER|CKSUM| PRE- |SYNC| LABEL |CKSUM| PRE- |SYNC| DATA |CKSUM| POST | |
| 38 | | * |AMBLE1| 1 | | 1 |AMBLE2| 2 | | 2 |AMBLE3| 3 | | 3 |AMBLE | |
| 39 | | * +------+----+------+-----+------+----+-------+-----+------+----+-------+-----+------+ |
| 40 | | * |
| 41 | | * | | |
| 42 | | * |
| 43 | | * +-----------------------------------------------------------------------------------+ |
| 44 | | * | | |
| 45 | | * ---+ +---- |
| 46 | | * FORMAT WRITE GATE FOR INITIALIZING |
| 47 | | * | | |
| 48 | | * |
| 49 | | * | +------------------------------+ |
| 50 | | * | | |
| 51 | | * ---|----------------------------------------------------+ +---- |
| 52 | | * WRITE GATE FOR DATA XFER (*) |
| 53 | | * | | |
| 54 | | * |
| 55 | | * | +-----------------------+-+------------------------------+ |
| 56 | | * | | | may be continuous (?) | |
| 57 | | * ------------------------------+ +-+ +---- |
| 58 | | * ??? WRITE GATE FOR LABEL AND DATA XFER (*) |
| 59 | | * | | |
| 60 | | * |
| 61 | | * | +--------------------+ +---------------------+ +----------------------------+ |
| 62 | | * | | | | | | |
| 63 | | * -------+ +---+ +---+ +---- |
| 64 | | * READ GATE FOR INITIALIZING OR DATA XFER (**) |
| 65 | | * |
| 66 | | * |
| 67 | | * (*) Enable should be delayed 1 byte/word time from last bit of checks sum. |
| 68 | | * (**) Read Gate should be enabled half way through the preamble area. This |
| 69 | | * ensures reading a zero field for data separator synchronization. |
| 70 | | * |
| 71 | | * </PRE> |
| 72 | | */ |
| 73 | | #if DIABLO31 |
| 74 | 18 | |
| 75 | | /** @brief DIABLO 31 rotation time is approx. 40ms */ |
| 76 | | #define ROTATION_TIME attotime::from_msec(39.9999) |
| 77 | | |
| 78 | | /** @brief DIABLO 31 sector time */ |
| 79 | | #define SECTOR_TIME attotime::from_msec(39.9999/DRIVE_SPT) |
| 80 | | |
| 81 | | /** @brief DIABLO 31 bit clock is 3330kHz ~= 300ns per bit |
| 82 | | * ~= 133333 bits/track (?) |
| 83 | | * ~= 11111 bits/sector |
| 84 | | * ~= 347 words/sector |
| 85 | | */ |
| 86 | | #define BIT_TIME(bits) attotime::from_nsec(300*(bits)) |
| 87 | | |
| 88 | | /** @brief DIABLO 31 possible sector words */ |
| 89 | | #define SECTOR_WORDS (int)(SECTOR_TIME / BIT_TIME(1) / 32) |
| 90 | | |
| 91 | | |
| 92 | | /** @brief pulse width of sector mark before the next sector begins */ |
| 93 | | #define SECTOR_MARK_PULSE_PRE BIT_TIME(16) |
| 94 | | |
| 95 | | /** @brief pulse width of sector mark after the next sector began */ |
| 96 | | #define SECTOR_MARK_PULSE_POST BIT_TIME(16) |
| 97 | | |
| 98 | | #else /* DIABLO31 */ |
| 99 | | |
| 100 | | /** @brief DIABLO 44 rotation time is approx. 25ms */ |
| 101 | | #define ROTATION_TIME attotime::from_msec(25) |
| 102 | | |
| 103 | | /** @brief DIABLO 44 sector time */ |
| 104 | | #define SECTOR_TIME attotime::from_msec(25/DRIVE_SPT) |
| 105 | | |
| 106 | | /** @brief DIABLO 44 bit clock is 5000kHz ~= 200ns per bit |
| 107 | | * ~= 125184 bits/track (?) |
| 108 | | * ~= 10432 bits/sector |
| 109 | | * ~= 325 words/sector |
| 110 | | */ |
| 111 | | #define BIT_TIME attotime::from_nsec(200) |
| 112 | | |
| 113 | | /** @brief DIABLO 44 possible sector words */ |
| 114 | | #define SECTOR_WORDS (int)(SECTOR_TIME / BIT_TIME / 32) |
| 115 | | |
| 116 | | /** @brief pulse width of sector mark before the next sector begins */ |
| 117 | | #define SECTOR_MARK_PULSE_PRE (16 * BIT_TIME) |
| 118 | | |
| 119 | | /** @brief pulse width of sector mark after the next sector began */ |
| 120 | | #define SECTOR_MARK_PULSE_POST (16 * BIT_TIME) |
| 121 | | #endif |
| 122 | | |
| 123 | | |
| 124 | 19 | /** @brief end of the guard zone at the beginning of a sector (wild guess!) */ |
| 125 | 20 | #define GUARD_ZONE_BITS (16*32) |
| 126 | 21 | |
| r26032 | r26033 | |
| 137 | 32 | #define RDBIT(bits,src) ((bits[(src)/32] >> ((src) % 32)) & 1) |
| 138 | 33 | |
| 139 | 34 | /** |
| 140 | | * @brief format of the cooked disk image sectors, i.e. pure data |
| 141 | | * |
| 142 | | * The available images are a multiple of 267 words per sector, |
| 143 | | * 1 word page number |
| 144 | | * 2 words header |
| 145 | | * 8 words label |
| 146 | | * 256 words data |
| 147 | | */ |
| 148 | | typedef struct { |
| 149 | | /** @brief sector page number */ |
| 150 | | UINT8 pageno[2*PAGENO_WORDS]; |
| 151 | | |
| 152 | | /** @brief sector header words */ |
| 153 | | UINT8 header[2*HEADER_WORDS]; |
| 154 | | |
| 155 | | /** @brief sector label words */ |
| 156 | | UINT8 label[2*LABEL_WORDS]; |
| 157 | | |
| 158 | | /** @brief sector data words */ |
| 159 | | UINT8 data[2*DATA_WORDS]; |
| 160 | | } diablo_sector_t; |
| 161 | | |
| 162 | | |
| 163 | | /** |
| 164 | | * @brief Structure of the disk drive context (2 drives or packs per system) |
| 165 | | */ |
| 166 | | typedef struct { |
| 167 | | /** @brief disk image, made up of 203 x 2 x 12 sectors */ |
| 168 | | diablo_sector_t *image; |
| 169 | | |
| 170 | | /** @brief drive unit number (0 or 1) */ |
| 171 | | int unit; |
| 172 | | |
| 173 | | /** @brief description of the drive(s) */ |
| 174 | | char description[32]; |
| 175 | | |
| 176 | | /** @brief basename of the drive image */ |
| 177 | | char basename[80]; |
| 178 | | |
| 179 | | /** @brief number of packs in drive (1 or 2) */ |
| 180 | | int packs; |
| 181 | | |
| 182 | | /** @brief rotation time */ |
| 183 | | attotime rotation_time; |
| 184 | | |
| 185 | | /** @brief bit time in atto seconds */ |
| 186 | | attotime bit_time; |
| 187 | | |
| 188 | | /** @brief drive seek/read/write signal (active 0) */ |
| 189 | | int s_r_w_0; |
| 190 | | |
| 191 | | /** @brief drive ready signal (active 0) */ |
| 192 | | int ready_0; |
| 193 | | |
| 194 | | /** @brief sector mark (0 if new sector) */ |
| 195 | | int sector_mark_0; |
| 196 | | |
| 197 | | /** @brief address acknowledge, i.e. seek successful (active 0) */ |
| 198 | | int addx_acknowledge_0; |
| 199 | | |
| 200 | | /** @brief log address interlock, i.e. seek in progress (active 0) */ |
| 201 | | int log_addx_interlock_0; |
| 202 | | |
| 203 | | /** @brief seek incomplete, i.e. seek in progress (active 0) */ |
| 204 | | int seek_incomplete_0; |
| 205 | | |
| 206 | | /** @brief erase gate */ |
| 207 | | int egate_0; |
| 208 | | |
| 209 | | /** @brief write gate */ |
| 210 | | int wrgate_0; |
| 211 | | |
| 212 | | /** @brief read gate */ |
| 213 | | int rdgate_0; |
| 214 | | |
| 215 | | /** @brief current cylinder number */ |
| 216 | | int cylinder; |
| 217 | | |
| 218 | | /** @brief current head (track) number on cylinder */ |
| 219 | | int head; |
| 220 | | |
| 221 | | /** @brief current sector number in track */ |
| 222 | | int sector; |
| 223 | | |
| 224 | | /** @brief sectors expanded to bits */ |
| 225 | | UINT32 *bits[DRIVE_CYLINDERS * DRIVE_HEADS * DRIVE_SPT]; |
| 226 | | |
| 227 | | /** @brief current page = (cylinder * HEADS + head) * SPT + sector */ |
| 228 | | int page; |
| 229 | | |
| 230 | | /** @brief set to first bit of a sector that is read from */ |
| 231 | | int rdfirst; |
| 232 | | |
| 233 | | /** @brief set to last bit of a sector that was read from */ |
| 234 | | int rdlast; |
| 235 | | |
| 236 | | /** @brief set to non-zero if a sector is written to */ |
| 237 | | int wrfirst; |
| 238 | | |
| 239 | | /** @brief set to last bit of a sector that was written to */ |
| 240 | | int wrlast; |
| 241 | | } diablo_drive_t; |
| 242 | | |
| 243 | | #if DIABLO31 |
| 244 | | static diablo_drive_t drive[DRIVE_MAX] = { |
| 245 | | { |
| 246 | | NULL, |
| 247 | | 0, |
| 248 | | "DIABLO31", "", |
| 249 | | 1, |
| 250 | | ROTATION_TIME, |
| 251 | | BIT_TIME, |
| 252 | | 0, |
| 253 | | },{ |
| 254 | | NULL, |
| 255 | | 1, |
| 256 | | "DIABLO31", "", |
| 257 | | 1, |
| 258 | | ROTATION_TIME, |
| 259 | | BIT_TIME, |
| 260 | | 0, |
| 261 | | } |
| 262 | | }; |
| 263 | | #else |
| 264 | | static drive_t drive[DRIVE_MAX] = { |
| 265 | | { |
| 266 | | NULL, |
| 267 | | 0, |
| 268 | | "DIABLO44", "", |
| 269 | | 1, |
| 270 | | ROTATION_TIME, |
| 271 | | BIT_TIME, |
| 272 | | 0, |
| 273 | | },{ |
| 274 | | NULL, |
| 275 | | 1, |
| 276 | | "DIABLO44", "", |
| 277 | | 1, |
| 278 | | ROTATION_TIME, |
| 279 | | BIT_TIME, |
| 280 | | 0, |
| 281 | | } |
| 282 | | }; |
| 283 | | #endif |
| 284 | | |
| 285 | | /** |
| 286 | 35 | * @brief calculate the sector from the logical block address |
| 287 | 36 | * |
| 288 | 37 | * Modifies drive's page by calculating the logical |
| r26032 | r26033 | |
| 290 | 39 | * |
| 291 | 40 | * @param unit unit number |
| 292 | 41 | */ |
| 293 | | static void drive_get_sector(int unit) |
| 42 | void alto2_cpu_device::drive_get_sector(int unit) |
| 294 | 43 | { |
| 295 | | diablo_drive_t *d = &drive[unit]; |
| 296 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 44 | diablo_drive_t *d = m_drive[unit]; |
| 45 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 297 | 46 | fatal(1, "invalid unit %d in call to drive_get_sector()\n", unit); |
| 298 | 47 | |
| 299 | 48 | /* If there's no image, just reset the page number */ |
| r26032 | r26033 | |
| 301 | 50 | d->page = -1; |
| 302 | 51 | return; |
| 303 | 52 | } |
| 304 | | if (d->cylinder < 0 || d->cylinder >= DRIVE_CYLINDERS) { |
| 305 | | LOG((log_DRV,9," DRIVE C/H/S:%d/%d/%d => invalid cylinder\n", |
| 306 | | d->cylinder, d->head, d->sector)); |
| 53 | if (d->cylinder < 0 || d->cylinder >= DIABLO_DRIVE_CYLINDERS) { |
| 54 | LOG((log_DRV,9," DRIVE C/H/S:%d/%d/%d => invalid cylinder\n", d->cylinder, d->head, d->sector)); |
| 307 | 55 | d->page = -1; |
| 308 | 56 | return; |
| 309 | 57 | } |
| r26032 | r26033 | |
| 439 | 187 | * @param unit drive unit number (0 or 1) |
| 440 | 188 | * @param page page number (0 to DRIVE_PAGES-1) |
| 441 | 189 | */ |
| 442 | | static void expand_sector(int unit, int page) |
| 190 | void alto2_cpu_device::expand_sector(int unit, int page) |
| 443 | 191 | { |
| 444 | | diablo_drive_t *d = &drive[unit]; |
| 192 | diablo_drive_t *d = m_drive[unit]; |
| 445 | 193 | diablo_sector_t *s; |
| 446 | 194 | UINT32 *bits; |
| 447 | 195 | size_t dst; |
| 448 | 196 | |
| 449 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 197 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 450 | 198 | fatal(1, "invalid unit %d in call to expand_sector()\n", unit); |
| 451 | 199 | |
| 452 | | if (page < 0 || page >= DRIVE_PAGES) |
| 200 | if (page < 0 || page >= DIABLO_DRIVE_PAGES) |
| 453 | 201 | return; |
| 454 | 202 | |
| 455 | 203 | /* already expanded this sector? */ |
| r26032 | r26033 | |
| 457 | 205 | return; |
| 458 | 206 | |
| 459 | 207 | if (-1 == page || !d->image) { |
| 460 | | LOG((log_DRV,0," no sector for #%d: %d/%d/%d\n", |
| 461 | | d->unit, d->cylinder, d->head, d->sector)); |
| 208 | LOG((log_DRV,0," no sector for #%d: %d/%d/%d\n", d->unit, d->cylinder, d->head, d->sector)); |
| 462 | 209 | return; |
| 463 | 210 | } |
| 464 | 211 | |
| r26032 | r26033 | |
| 466 | 213 | s = &d->image[page]; |
| 467 | 214 | |
| 468 | 215 | /* allocate a bits image */ |
| 469 | | bits = (UINT32 *)calloc(400, sizeof(UINT32)); |
| 216 | bits = (UINT32 *)auto_alloc_array(machine(), UINT32, 400); |
| 470 | 217 | if (!bits) { |
| 471 | 218 | fatal(1, "failed to malloc(%d) bytes bits for drive #%d page #%d\n", |
| 472 | 219 | sizeof(bits), unit, page); |
| r26032 | r26033 | |
| 517 | 264 | |
| 518 | 265 | } |
| 519 | 266 | |
| 520 | | #if DEBUG |
| 267 | #if ALTO2_DEBUG |
| 521 | 268 | static void drive_dump_ascii(UINT8 *src, size_t size) |
| 522 | 269 | { |
| 523 | 270 | size_t offs; |
| r26032 | r26033 | |
| 698 | 445 | } |
| 699 | 446 | |
| 700 | 447 | /** |
| 701 | | * @brief squeeze a array of clock and data bits into a sector's data |
| 448 | * @brief Squeeze a array of clock and data bits into a sector's data |
| 702 | 449 | */ |
| 703 | | static void squeeze_sector(int unit) |
| 450 | void alto2_cpu_device::squeeze_sector(int unit) |
| 704 | 451 | { |
| 705 | | diablo_drive_t *d = &drive[unit]; |
| 452 | diablo_drive_t *d = m_drive[unit]; |
| 706 | 453 | diablo_sector_t *s; |
| 707 | 454 | UINT32 *bits; |
| 708 | 455 | size_t src; |
| 709 | 456 | int cksum_header, cksum_label, cksum_data; |
| 710 | 457 | |
| 711 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 458 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 712 | 459 | fatal(1, "invalid unit %d in call to squeeze_sector()\n", unit); |
| 713 | 460 | |
| 714 | 461 | if (d->rdfirst >= 0) { |
| r26032 | r26033 | |
| 745 | 492 | d->wrfirst = -1; |
| 746 | 493 | d->wrlast = -1; |
| 747 | 494 | |
| 748 | | if (d->page < 0 || d->page >= DRIVE_PAGES) { |
| 749 | | LOG((log_DRV,0," no sector for #%d: %d/%d/%d\n", |
| 750 | | d->unit, d->cylinder, d->head, d->sector)); |
| 495 | if (d->page < 0 || d->page >= DIABLO_DRIVE_PAGES) { |
| 496 | LOG((log_DRV,0," no sector for #%d: %d/%d/%d\n", d->unit, d->cylinder, d->head, d->sector)); |
| 751 | 497 | return; |
| 752 | 498 | } |
| 753 | 499 | |
| r26032 | r26033 | |
| 759 | 505 | |
| 760 | 506 | /* no bits to write? */ |
| 761 | 507 | if (!bits) { |
| 762 | | LOG((log_DRV,0," no sector for #%d: %d/%d/%d\n", |
| 763 | | d->unit, d->cylinder, d->head, d->sector)); |
| 508 | LOG((log_DRV,0," no sector for #%d: %d/%d/%d\n", d->unit, d->cylinder, d->head, d->sector)); |
| 764 | 509 | return; |
| 765 | 510 | } |
| 766 | 511 | |
| r26032 | r26033 | |
| 778 | 523 | src, src / 32, src % 32)); |
| 779 | 524 | src = squeeze_record(bits, src, s->header, sizeof(s->header)); |
| 780 | 525 | src = squeeze_cksum(bits, src, &cksum_header); |
| 781 | | #if DEBUG |
| 526 | #if ALTO2_DEBUG |
| 782 | 527 | dump_record(s->header, 0, sizeof(s->header), "header", 0); |
| 783 | 528 | #endif |
| 784 | 529 | |
| r26032 | r26033 | |
| 790 | 535 | src, src / 32, src % 32)); |
| 791 | 536 | src = squeeze_record(bits, src, s->label, sizeof(s->label)); |
| 792 | 537 | src = squeeze_cksum(bits, src, &cksum_label); |
| 793 | | #if DEBUG |
| 538 | #if ALTO2_DEBUG |
| 794 | 539 | dump_record(s->label, 0, sizeof(s->label), "label", 0); |
| 795 | 540 | #endif |
| 796 | 541 | |
| r26032 | r26033 | |
| 802 | 547 | src, src / 32, src % 32)); |
| 803 | 548 | src = squeeze_record(bits, src, s->data, sizeof(s->data)); |
| 804 | 549 | src = squeeze_cksum(bits, src, &cksum_data); |
| 805 | | #if DEBUG |
| 550 | #if ALTO2_DEBUG |
| 806 | 551 | dump_record(s->data, 0, sizeof(s->data), "data", 1); |
| 807 | 552 | #endif |
| 808 | 553 | |
| r26032 | r26033 | |
| 812 | 557 | cksum_data ^= cksum(s->data, sizeof(s->data), 0521); |
| 813 | 558 | |
| 814 | 559 | if (cksum_header || cksum_label || cksum_data) { |
| 815 | | #if DEBUG |
| 816 | | LOG((log_DRV,0," cksum check - header:%06o label:%06o data:%06o\n", |
| 817 | | cksum_header, cksum_label, cksum_data)); |
| 560 | #if ALTO2_DEBUG |
| 561 | LOG((log_DRV,0," cksum check - header:%06o label:%06o data:%06o\n", cksum_header, cksum_label, cksum_data)); |
| 818 | 562 | #else |
| 819 | | printf(" cksum check - header:%06o label:%06o data:%06o\n", |
| 820 | | cksum_header, cksum_label, cksum_data); |
| 563 | printf(" cksum check - header:%06o label:%06o data:%06o\n", cksum_header, cksum_label, cksum_data); |
| 821 | 564 | #endif |
| 822 | 565 | } |
| 823 | 566 | } |
| r26032 | r26033 | |
| 829 | 572 | */ |
| 830 | 573 | int alto2_cpu_device::drive_bits_per_sector() const |
| 831 | 574 | { |
| 832 | | return SECTOR_WORDS * 32; |
| 575 | return DIABLO_SECTOR_WORDS * 32; |
| 833 | 576 | } |
| 834 | 577 | |
| 835 | 578 | /** |
| r26032 | r26033 | |
| 840 | 583 | */ |
| 841 | 584 | const char* alto2_cpu_device::drive_description(int unit) |
| 842 | 585 | { |
| 843 | | diablo_drive_t *d = &drive[unit]; |
| 844 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 586 | diablo_drive_t *d = m_drive[unit]; |
| 587 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 845 | 588 | fatal(1, "invalid unit %d in call to drive_description()\n", unit); |
| 846 | 589 | return d->description; |
| 847 | 590 | } |
| r26032 | r26033 | |
| 854 | 597 | */ |
| 855 | 598 | const char* alto2_cpu_device::drive_basename(int unit) |
| 856 | 599 | { |
| 857 | | diablo_drive_t *d = &drive[unit]; |
| 858 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 600 | diablo_drive_t *d = m_drive[unit]; |
| 601 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 859 | 602 | fatal(1, "invalid unit %d in call to drive_description()\n", unit); |
| 860 | 603 | return d->basename; |
| 861 | 604 | } |
| r26032 | r26033 | |
| 870 | 613 | */ |
| 871 | 614 | int alto2_cpu_device::drive_unit(int unit) |
| 872 | 615 | { |
| 873 | | diablo_drive_t *d = &drive[unit]; |
| 874 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 616 | diablo_drive_t *d = m_drive[unit]; |
| 617 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 875 | 618 | fatal(1, "invalid unit %d in call to drive_unit()\n", unit); |
| 876 | 619 | return d->unit; |
| 877 | 620 | } |
| r26032 | r26033 | |
| 884 | 627 | */ |
| 885 | 628 | attotime alto2_cpu_device::drive_rotation_time(int unit) |
| 886 | 629 | { |
| 887 | | diablo_drive_t *d = &drive[unit]; |
| 888 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 630 | diablo_drive_t *d = m_drive[unit]; |
| 631 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 889 | 632 | fatal(1, "invalid unit %d in call to drive_rotation_time()\n", unit); |
| 890 | 633 | return d->rotation_time; |
| 891 | 634 | } |
| r26032 | r26033 | |
| 898 | 641 | */ |
| 899 | 642 | attotime alto2_cpu_device::drive_bit_time(int unit) |
| 900 | 643 | { |
| 901 | | diablo_drive_t *d = &drive[unit]; |
| 902 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 644 | diablo_drive_t *d = m_drive[unit]; |
| 645 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 903 | 646 | fatal(1, "invalid unit %d in call to drive_bit_time()\n", unit); |
| 904 | 647 | return d->bit_time; |
| 905 | 648 | } |
| r26032 | r26033 | |
| 912 | 655 | */ |
| 913 | 656 | int alto2_cpu_device::drive_seek_read_write_0(int unit) |
| 914 | 657 | { |
| 915 | | diablo_drive_t *d = &drive[unit]; |
| 916 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 658 | diablo_drive_t *d = m_drive[unit]; |
| 659 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 917 | 660 | fatal(1, "invalid unit %d in call to drive_seek_read_write_0()\n", unit); |
| 918 | 661 | return d->s_r_w_0; |
| 919 | 662 | } |
| r26032 | r26033 | |
| 926 | 669 | */ |
| 927 | 670 | int alto2_cpu_device::drive_ready_0(int unit) |
| 928 | 671 | { |
| 929 | | diablo_drive_t *d = &drive[unit]; |
| 930 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 672 | diablo_drive_t *d = m_drive[unit]; |
| 673 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 931 | 674 | fatal(1, "invalid unit %d in call to drive_ready_0()\n", unit); |
| 932 | 675 | return d->ready_0; |
| 933 | 676 | } |
| r26032 | r26033 | |
| 942 | 685 | */ |
| 943 | 686 | int alto2_cpu_device::drive_sector_mark_0(int unit) |
| 944 | 687 | { |
| 945 | | diablo_drive_t *d = &drive[unit]; |
| 946 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 688 | diablo_drive_t *d = m_drive[unit]; |
| 689 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 947 | 690 | fatal(1, "invalid unit %d in call to drive_sector_mark_0()\n", unit); |
| 948 | 691 | /* no sector marks while seeking (?) */ |
| 949 | 692 | if (d->s_r_w_0) |
| r26032 | r26033 | |
| 960 | 703 | */ |
| 961 | 704 | int alto2_cpu_device::drive_addx_acknowledge_0(int unit) |
| 962 | 705 | { |
| 963 | | diablo_drive_t *d = &drive[unit]; |
| 964 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 706 | diablo_drive_t *d = m_drive[unit]; |
| 707 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 965 | 708 | fatal(1, "invalid unit %d in call to drive_addx_acknowledge_0()\n", unit); |
| 966 | 709 | return d->addx_acknowledge_0; |
| 967 | 710 | } |
| r26032 | r26033 | |
| 974 | 717 | */ |
| 975 | 718 | int alto2_cpu_device::drive_log_addx_interlock_0(int unit) |
| 976 | 719 | { |
| 977 | | diablo_drive_t *d = &drive[unit]; |
| 978 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 720 | diablo_drive_t *d = m_drive[unit]; |
| 721 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 979 | 722 | fatal(1, "invalid unit %d in call to drive_log_addx_interlock_0()\n", unit); |
| 980 | 723 | return d->log_addx_interlock_0; |
| 981 | 724 | } |
| r26032 | r26033 | |
| 988 | 731 | */ |
| 989 | 732 | int alto2_cpu_device::drive_seek_incomplete_0(int unit) |
| 990 | 733 | { |
| 991 | | diablo_drive_t *d = &drive[unit]; |
| 992 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 734 | diablo_drive_t *d = m_drive[unit]; |
| 735 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 993 | 736 | fatal(1, "invalid unit %d in call to drive_addx_acknowledge_0()\n", unit); |
| 994 | 737 | return d->seek_incomplete_0; |
| 995 | 738 | } |
| r26032 | r26033 | |
| 1004 | 747 | */ |
| 1005 | 748 | int alto2_cpu_device::drive_cylinder(int unit) |
| 1006 | 749 | { |
| 1007 | | diablo_drive_t *d = &drive[unit]; |
| 1008 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 750 | diablo_drive_t *d = m_drive[unit]; |
| 751 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 1009 | 752 | fatal(1, "invalid unit %d in call to drive_cylinder()\n", unit); |
| 1010 | | return d->cylinder ^ DRIVE_CYLINDER_MASK; |
| 753 | return d->cylinder ^ DIABLO_DRIVE_CYLINDER_MASK; |
| 1011 | 754 | } |
| 1012 | 755 | |
| 1013 | 756 | /** |
| r26032 | r26033 | |
| 1020 | 763 | */ |
| 1021 | 764 | int alto2_cpu_device::drive_head(int unit) |
| 1022 | 765 | { |
| 1023 | | diablo_drive_t *d = &drive[unit]; |
| 1024 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 766 | diablo_drive_t *d = m_drive[unit]; |
| 767 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 1025 | 768 | fatal(1, "invalid unit %d in call to drive_head()\n", unit); |
| 1026 | | return d->head ^ DRIVE_HEAD_MASK; |
| 769 | return d->head ^ DIABLO_DRIVE_HEAD_MASK; |
| 1027 | 770 | } |
| 1028 | 771 | |
| 1029 | 772 | /** |
| r26032 | r26033 | |
| 1039 | 782 | */ |
| 1040 | 783 | int alto2_cpu_device::drive_sector(int unit) |
| 1041 | 784 | { |
| 1042 | | diablo_drive_t *d = &drive[unit]; |
| 1043 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 785 | diablo_drive_t *d = m_drive[unit]; |
| 786 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 1044 | 787 | fatal(1, "invalid unit %d in call to drive_sector()\n", unit); |
| 1045 | | return d->sector ^ DRIVE_SECTOR_MASK; |
| 788 | return d->sector ^ DIABLO_DRIVE_SECTOR_MASK; |
| 1046 | 789 | } |
| 1047 | 790 | |
| 1048 | 791 | /** |
| r26032 | r26033 | |
| 1056 | 799 | */ |
| 1057 | 800 | int alto2_cpu_device::drive_page(int unit) |
| 1058 | 801 | { |
| 1059 | | diablo_drive_t *d = &drive[unit]; |
| 1060 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 802 | diablo_drive_t *d = m_drive[unit]; |
| 803 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 1061 | 804 | fatal(1, "invalid unit %d in call to drive_page()\n", unit); |
| 1062 | 805 | return d->page; |
| 1063 | 806 | } |
| r26032 | r26033 | |
| 1070 | 813 | */ |
| 1071 | 814 | void alto2_cpu_device::drive_select(int unit, int head) |
| 1072 | 815 | { |
| 1073 | | diablo_drive_t *d = &drive[unit]; |
| 816 | diablo_drive_t *d = m_drive[unit]; |
| 1074 | 817 | |
| 1075 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 818 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 1076 | 819 | fatal(1, "invalid unit %d in call to drive_select()\n", unit); |
| 1077 | 820 | |
| 1078 | 821 | if (unit != m_unit_selected || head != m_head_selected) { |
| r26032 | r26033 | |
| 1103 | 846 | } |
| 1104 | 847 | |
| 1105 | 848 | /* Note: head select input is active low (0: selects head 1, 1: selects head 0) */ |
| 1106 | | head = head & DRIVE_HEAD_MASK; |
| 849 | head = head & DIABLO_DRIVE_HEAD_MASK; |
| 1107 | 850 | if (head != d->head) { |
| 1108 | 851 | d->head = head; |
| 1109 | 852 | LOG((log_DRV,1," HEAD %d select on unit %d\n", head, unit)); |
| r26032 | r26033 | |
| 1123 | 866 | */ |
| 1124 | 867 | void alto2_cpu_device::drive_strobe(int unit, int cylinder, int restore, int strobe) |
| 1125 | 868 | { |
| 1126 | | diablo_drive_t *d = &drive[unit]; |
| 869 | diablo_drive_t *d = m_drive[unit]; |
| 1127 | 870 | int seekto = restore ? 0 : cylinder; |
| 1128 | 871 | |
| 1129 | | if (unit < 0 || unit >= DRIVE_MAX) |
| 872 | if (unit < 0 || unit >= DIABLO_DRIVE_MAX) |
| 1130 | 873 | fatal(1, "invalid unit %d in call to drive_strobe()\n", unit); |
| 1131 | 874 | |
| 1132 | 875 | if (strobe == 1) { |
| r26032 | r26033 | |
| 1162 | 905 | } else { |
| 1163 | 906 | /* increment cylinder */ |
| 1164 | 907 | d->cylinder += 1; |
| 1165 | | if (d->cylinder >= DRIVE_CYLINDERS) { |
| 1166 | | d->cylinder = DRIVE_CYLINDERS - 1; |
| 908 | if (d->cylinder >= DIABLO_DRIVE_CYLINDERS) { |
| 909 | d->cylinder = DIABLO_DRIVE_CYLINDERS - 1; |
| 1167 | 910 | d->log_addx_interlock_0 = 1; /* deassert the log address interlock */ |
| 1168 | 911 | d->seek_incomplete_0 = 1; /* deassert seek incomplete */ |
| 1169 | 912 | d->addx_acknowledge_0 = 0; /* assert address acknowledge */ |
| r26032 | r26033 | |
| 1197 | 940 | */ |
| 1198 | 941 | void alto2_cpu_device::drive_egate(int unit, int gate) |
| 1199 | 942 | { |
| 1200 | | diablo_drive_t *d = &drive[unit]; |
| 943 | diablo_drive_t *d = m_drive[unit]; |
| 1201 | 944 | d->egate_0 = gate; |
| 1202 | 945 | } |
| 1203 | 946 | |
| r26032 | r26033 | |
| 1209 | 952 | */ |
| 1210 | 953 | void alto2_cpu_device::drive_wrgate(int unit, int gate) |
| 1211 | 954 | { |
| 1212 | | diablo_drive_t *d = &drive[unit]; |
| 955 | diablo_drive_t *d = m_drive[unit]; |
| 1213 | 956 | d->wrgate_0 = gate; |
| 1214 | 957 | } |
| 1215 | 958 | |
| r26032 | r26033 | |
| 1221 | 964 | */ |
| 1222 | 965 | void alto2_cpu_device::drive_rdgate(int unit, int gate) |
| 1223 | 966 | { |
| 1224 | | diablo_drive_t *d = &drive[unit]; |
| 967 | diablo_drive_t *d = m_drive[unit]; |
| 1225 | 968 | d->rdgate_0 = gate; |
| 1226 | 969 | } |
| 1227 | 970 | |
| r26032 | r26033 | |
| 1245 | 988 | */ |
| 1246 | 989 | void alto2_cpu_device::drive_wrdata(int unit, int index, int wrdata) |
| 1247 | 990 | { |
| 1248 | | diablo_drive_t *d = &drive[unit]; |
| 991 | diablo_drive_t *d = m_drive[unit]; |
| 1249 | 992 | UINT32 *bits; |
| 1250 | 993 | |
| 1251 | 994 | if (d->wrgate_0) { |
| r26032 | r26033 | |
| 1296 | 1039 | */ |
| 1297 | 1040 | int alto2_cpu_device::drive_rddata(int unit, int index) |
| 1298 | 1041 | { |
| 1299 | | diablo_drive_t *d = &drive[unit]; |
| 1042 | diablo_drive_t *d = m_drive[unit]; |
| 1300 | 1043 | UINT32 *bits; |
| 1301 | 1044 | int bit = 0; |
| 1302 | 1045 | |
| r26032 | r26033 | |
| 1348 | 1091 | */ |
| 1349 | 1092 | int alto2_cpu_device::drive_rdclk(int unit, int index) |
| 1350 | 1093 | { |
| 1351 | | diablo_drive_t *d = &drive[unit]; |
| 1094 | diablo_drive_t *d = m_drive[unit]; |
| 1352 | 1095 | UINT32 *bits; |
| 1353 | 1096 | int clk; |
| 1354 | 1097 | |
| r26032 | r26033 | |
| 1399 | 1142 | */ |
| 1400 | 1143 | int alto2_cpu_device::debug_read_sync(int unit, int page, int offs) |
| 1401 | 1144 | { |
| 1402 | | diablo_drive_t *d = &drive[unit]; |
| 1145 | diablo_drive_t *d = m_drive[unit]; |
| 1403 | 1146 | UINT32 *bits; |
| 1404 | 1147 | UINT32 accu; |
| 1405 | 1148 | |
| r26032 | r26033 | |
| 1411 | 1154 | return 0; |
| 1412 | 1155 | |
| 1413 | 1156 | /* check for invalid page */ |
| 1414 | | if (page < 0 || page >= DRIVE_CYLINDERS * DRIVE_HEADS * DRIVE_SPT) |
| 1157 | if (page < 0 || page >= DIABLO_DRIVE_CYLINDERS * DIABLO_DRIVE_HEADS * DIABLO_DRIVE_SPT) |
| 1415 | 1158 | return 0; |
| 1416 | 1159 | |
| 1417 | 1160 | bits = d->bits[page]; |
| r26032 | r26033 | |
| 1445 | 1188 | */ |
| 1446 | 1189 | int alto2_cpu_device::debug_read_sec(int unit, int page, int offs) |
| 1447 | 1190 | { |
| 1448 | | diablo_drive_t *d = &drive[unit]; |
| 1191 | diablo_drive_t *d = m_drive[unit]; |
| 1449 | 1192 | UINT32 *bits; |
| 1450 | 1193 | int i, clks, word; |
| 1451 | 1194 | |
| r26032 | r26033 | |
| 1457 | 1200 | return 0177777; |
| 1458 | 1201 | |
| 1459 | 1202 | /* check for invalid page */ |
| 1460 | | if (page < 0 || page >= DRIVE_CYLINDERS * DRIVE_HEADS * DRIVE_SPT) |
| 1203 | if (page < 0 || page >= DIABLO_DRIVE_CYLINDERS * DIABLO_DRIVE_HEADS * DIABLO_DRIVE_SPT) |
| 1461 | 1204 | return 0177777; |
| 1462 | 1205 | |
| 1463 | 1206 | bits = d->bits[page]; |
| r26032 | r26033 | |
| 1488 | 1231 | { |
| 1489 | 1232 | (void)ptr; |
| 1490 | 1233 | int unit = m_unit_selected; |
| 1491 | | diablo_drive_t *d = &drive[unit]; |
| 1234 | diablo_drive_t *d = m_drive[unit]; |
| 1492 | 1235 | |
| 1493 | 1236 | LOG((log_DRV,5, " next sector (unit #%d sector %d)\n", unit, d->sector)); |
| 1237 | (void)d; |
| 1494 | 1238 | |
| 1495 | | /* deassert sector mark after pulse width */ |
| 1496 | 1239 | switch (arg) { |
| 1497 | 1240 | case 0: |
| 1498 | | /* next sector starting soon now */ |
| 1499 | | m_sector_timer->adjust(SECTOR_MARK_PULSE_PRE, 1); |
| 1241 | m_sector_timer->adjust(DIABLO_SECTOR_MARK_PULSE_PRE, 1); |
| 1242 | /* deassert sector mark */ |
| 1500 | 1243 | sector_mark_1(unit); |
| 1501 | 1244 | break; |
| 1502 | 1245 | case 1: |
| 1503 | | m_sector_timer->adjust(SECTOR_MARK_PULSE_POST, 2); |
| 1246 | m_sector_timer->adjust(DIABLO_SECTOR_MARK_PULSE_POST, 2); |
| 1247 | /* assert sector mark */ |
| 1504 | 1248 | sector_mark_0(unit); |
| 1505 | 1249 | break; |
| 1506 | 1250 | case 2: |
| 1507 | | m_sector_timer->adjust(SECTOR_TIME - SECTOR_MARK_PULSE_PRE, 0); |
| 1251 | /* next sector starting soon now */ |
| 1252 | m_sector_timer->adjust(DIABLO_SECTOR_TIME - DIABLO_SECTOR_MARK_PULSE_PRE, 0); |
| 1508 | 1253 | /* call the sector_callback, if any */ |
| 1509 | 1254 | if (m_sector_callback) |
| 1510 | 1255 | ((*this).*m_sector_callback)(unit); |
| r26032 | r26033 | |
| 1518 | 1263 | */ |
| 1519 | 1264 | void alto2_cpu_device::sector_mark_1(int unit) |
| 1520 | 1265 | { |
| 1521 | | diablo_drive_t *d = &drive[unit]; |
| 1266 | diablo_drive_t *d = m_drive[unit]; |
| 1522 | 1267 | |
| 1523 | 1268 | LOG((log_DRV,5, " sector mark 1 (unit #%d sector %d)\n", unit, d->sector)); |
| 1524 | 1269 | /* set sector mark to 1 */ |
| r26032 | r26033 | |
| 1532 | 1277 | */ |
| 1533 | 1278 | void alto2_cpu_device::sector_mark_0(int unit) |
| 1534 | 1279 | { |
| 1535 | | diablo_drive_t *d = &drive[unit]; |
| 1280 | diablo_drive_t *d = m_drive[unit]; |
| 1536 | 1281 | |
| 1537 | 1282 | LOG((log_DRV,5," sector mark 0 (unit #%d sector %d)\n", unit, d->sector)); |
| 1538 | 1283 | |
| r26032 | r26033 | |
| 1548 | 1293 | d->wrlast = -1; |
| 1549 | 1294 | |
| 1550 | 1295 | /* count sectors */ |
| 1551 | | d->sector = (d->sector + 1) % DRIVE_SPT; |
| 1296 | d->sector = (d->sector + 1) % DIABLO_DRIVE_SPT; |
| 1552 | 1297 | drive_get_sector(unit); |
| 1553 | 1298 | } |
| 1299 | |
| 1300 | #if 0 // FIXME: unused loading of the disk image |
| 1554 | 1301 | /** |
| 1555 | 1302 | * @brief pass down command line arguments to the drive emulation |
| 1556 | 1303 | * |
| r26032 | r26033 | |
| 1611 | 1358 | if (unit == DRIVE_MAX) |
| 1612 | 1359 | return -1; |
| 1613 | 1360 | |
| 1614 | | d = &drive[unit]; |
| 1361 | d = reinterpret_cast<diablo_drive_t *>(m_drive[unit]); |
| 1615 | 1362 | |
| 1616 | 1363 | snprintf(d->basename, sizeof(d->basename), "%s", basename); |
| 1617 | 1364 | |
| r26032 | r26033 | |
| 1722 | 1469 | |
| 1723 | 1470 | return 0; |
| 1724 | 1471 | } |
| 1472 | #endif |
| 1725 | 1473 | |
| 1726 | 1474 | /** |
| 1727 | 1475 | * @brief initialize the disk drive context and insert a disk word timer |
| r26032 | r26033 | |
| 1736 | 1484 | fatal(1, "sizeof(sector_t) is not %d (%d)\n", |
| 1737 | 1485 | 267 * 2, sizeof(diablo_sector_t)); |
| 1738 | 1486 | |
| 1739 | | for (i = 0; i < DRIVE_MAX; i++) { |
| 1740 | | diablo_drive_t *d = &drive[i]; |
| 1487 | for (i = 0; i < DIABLO_DRIVE_MAX; i++) { |
| 1488 | // FIXME: use MAME resource system(?) |
| 1489 | diablo_drive_t *d = reinterpret_cast<diablo_drive_t *>(auto_alloc_clear(machine(), diablo_drive_t)); |
| 1490 | m_drive[i] = d; |
| 1741 | 1491 | |
| 1742 | | d->unit = i; /* set the unit number */ |
| 1743 | | d->s_r_w_0 = 1; /* seek/read/write not ready */ |
| 1744 | | d->ready_0 = 1; /* drive is not ready */ |
| 1745 | | d->sector_mark_0 = 1; /* sector mark clear */ |
| 1746 | | d->addx_acknowledge_0 = 1; /* drive address acknowledge is not active */ |
| 1492 | d->unit = i; /* set the unit number */ |
| 1493 | snprintf(d->description, sizeof(d->description), "DIABLO31"); |
| 1494 | d->rotation_time = DIABLO_ROTATION_TIME; |
| 1495 | d->bit_time = DIABLO_BIT_TIME(1); |
| 1496 | d->s_r_w_0 = 1; /* seek/read/write not ready */ |
| 1497 | d->ready_0 = 1; /* drive is not ready */ |
| 1498 | d->sector_mark_0 = 1; /* sector mark clear */ |
| 1499 | d->addx_acknowledge_0 = 1; /* drive address acknowledge is not active */ |
| 1747 | 1500 | d->log_addx_interlock_0 = 1; /* drive log address interlock is not active */ |
| 1748 | | d->seek_incomplete_0 = 1; /* drive seek incomplete is not active */ |
| 1501 | d->seek_incomplete_0 = 1; /* drive seek incomplete is not active */ |
| 1749 | 1502 | |
| 1750 | 1503 | /* reset the disk drive's address */ |
| 1751 | 1504 | d->cylinder = 0; |
| r26032 | r26033 | |
| 1765 | 1518 | |
| 1766 | 1519 | m_sector_callback = 0; |
| 1767 | 1520 | m_sector_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(alto2_cpu_device::drive_next_sector),this)); |
| 1768 | | m_sector_timer->adjust(SECTOR_TIME - SECTOR_MARK_PULSE_PRE, 0); |
| 1521 | m_sector_timer->adjust(DIABLO_SECTOR_TIME - DIABLO_SECTOR_MARK_PULSE_PRE, 0); |
| 1769 | 1522 | } |