Previous 199869 Revisions Next

r26033 Thursday 7th November, 2013 at 12:10:34 UTC by Dirk Best
Move DIABLO31 drive definitions to alto2.h for now. Clean up ROM loading, input port (keyboard) definitions and more
[/branches/alto2/src/emu/cpu/alto2]a2disk.c a2drive.c a2emu.c a2ksec.c a2kwd.c a2mem.c a2part.c alto2.c alto2.h

branches/alto2/src/emu/cpu/alto2/a2emu.c
r26032r26033
509509   LOG((0,2,"   ACDEST<-; mux (rsel:%#o %s)\n", m_rsel, r_name[m_rsel]));
510510}
511511
512#if   DEBUG
512#if   ALTO2_DEBUG
513513void alto2_cpu_device::bitblt_info()
514514{
515515   static const char *type_name[4] = {"bitmap","complement","and gray","gray"};
r26032r26033
560560{
561561   UINT16 r = (A2_BIT32(m_bus,16,0) << 3) | A2_GET32(m_bus,16,5,7);
562562
563#if   DEBUG
563#if   ALTO2_DEBUG
564564   if (ll[task_emu].level > 1) {
565565      char dasm[64];
566566      dbg_dasm(dasm, sizeof(dasm), 0, m_r[6], m_bus);
r26032r26033
568568      /* disassembled instruction */
569569      LOG((0,2,"      %06o: %06o %s\n", m_mem_mar, m_bus, dasm));
570570   }
571#endif   /* DEBUG */
571#endif   /* ALTO2_DEBUG */
572572
573573   /* special logging of some opcodes */
574574   switch (m_bus) {
r26032r26033
602602         m_r[rsel_ac2], m_r[rsel_ac3]));
603603      break;
604604   case op_BITBLT:
605#if   DEBUG
605#if   ALTO2_DEBUG
606606      bitblt_info();
607607#endif
608608      break;
branches/alto2/src/emu/cpu/alto2/a2disk.c
r26032r26033
143143   RWC_WRITE2
144144};
145145
146#if   DEBUG
146#if   ALTO2_DEBUG
147147/** @brief human readable names for the KADR<- modes */
148148static const char *rwc_name[4] = {"read", "check", "write", "write2"};
149149#endif
150150
151151#if   JKFF_FUNCTION
152152
153#if   DEBUG
153#if   ALTO2_DEBUG
154154static const char *jkff_name;
155155/** @brief macro to set the name of a FF in DEBUG=1 builds only */
156156#define   DEBUG_NAME(x)   jkff_name = x
r26032r26033
22812281   }
22822282
22832283   /* KSTAT[0-3] update the current sector in the kstat field */
2284   PUT_KSTAT_SECTOR(m_dsk.kstat, drive_sector(unit) ^ DRIVE_SECTOR_MASK);
2284   PUT_KSTAT_SECTOR(m_dsk.kstat, drive_sector(unit) ^ DIABLO_DRIVE_SECTOR_MASK);
22852285
22862286   /* clear input and output shift registers (?) */
22872287   m_dsk.shiftin = 0;
branches/alto2/src/emu/cpu/alto2/alto2.c
r26032r26033
2727
2828alto2_cpu_device::alto2_cpu_device(const machine_config& mconfig, const char* tag, device_t* owner, UINT32 clock) :
2929   cpu_device(mconfig, ALTO2, "Xerox Alto-II", tag, owner, clock, "alto2", __FILE__),
30   m_ucode_config("program", ENDIANNESS_BIG, 8, 32, 0),
31   m_ram_config("io", ENDIANNESS_BIG, 8, 16, 0)
30   m_ucode_config("program", ENDIANNESS_BIG, 32, 32, 0),
31   m_ram_config("io", ENDIANNESS_BIG, 16, 16, 0)
3232{
3333}
3434
r26032r26033
7474}
7575
7676// FIXME
77void alto2_cpu_device::fatal(int level, const char *format, ...)
77#if   ALTO2_DEBUG
78void alto2_cpu_device::logprintf(int type, int level, const char* format, ...)
7879{
79   va_list ap;
80   va_start(ap, format);
81   fatalerror(format, ap);
82   va_end(ap);
8380}
81#endif
8482
85#if 0
8683// FIXME
87void alto2_cpu_device::init_mrt(int task)
84void alto2_cpu_device::fatal(int exitcode, const char *format, ...)
8885{
89
86   va_list ap;
87   va_start(ap, format);
88   emu_fatalerror error(exitcode, format, ap);
89   va_end(ap);
9090}
9191
92// FIXME
93int alto2_cpu_device::drive_ready_0(int unit)
94{
95   return 0;
96}
97
98// FIXME
99int alto2_cpu_device::drive_sector_mark_0(int unit)
100{
101   return 0;
102}
103
104// FIxME
105void alto2_cpu_device::drive_egate(int unit, int gate)
106{
107
108}
109
110// FIXME
111void alto2_cpu_device::drive_wrgate(int unit, int gate)
112{
113
114}
115
116// FIXME
117void alto2_cpu_device::drive_rdgate(int unit, int gate)
118{
119
120}
121
122// FIXME
123int alto2_cpu_device::drive_bits_per_sector() const
124{
125   return 0;
126}
127
128// FIXME
129attotime alto2_cpu_device::drive_bit_time(int unit)
130{
131   return attotime::from_double(0);
132}
133
134// FIXME
135void alto2_cpu_device::drive_wrdata(int unit, int index, int wrdata)
136{
137
138}
139
140// FIXME
141int alto2_cpu_device::drive_rddata(int unit, int index)
142{
143   return 0;
144}
145
146// FIXME
147int alto2_cpu_device::drive_rdclk(int unit, int index)
148{
149   return 0;
150}
151
152// FIXME
153int alto2_cpu_device::drive_sector(int unit)
154{
155   return 0;
156}
157
158// FIXME
159void alto2_cpu_device::drive_strobe(int unit, int cylinder, int restore, int strobe)
160{
161
162}
163#endif
164
16592/** @brief task names */
16693const char* alto2_cpu_device::task_name(int task)
16794{
r26032r26033
435362 */
436363void alto2_cpu_device::bs_read_md_0()
437364{
438#if   DEBUG
365#if   ALTO2_DEBUG
439366   UINT32 mar = m_mem.mar;
440367#endif
441368   UINT16 md = read_mem();
r26032r26033
837764 */
838765void alto2_cpu_device::f2_load_md_1()
839766{
840#if   DEBUG
767#if   ALTO2_DEBUG
841768   UINT16 mar = m_mem.mar;
842769#endif
843770   if (MIR_F1(m_mir) == f1_load_mar) {
branches/alto2/src/emu/cpu/alto2/alto2.h
r26032r26033
1515#ifndef _CPU_ALTO2_H_
1616#define _CPU_ALTO2_H
1717
18#ifndef   DEBUG
19#define   DEBUG         0
20#endif
18#define   ALTO2_TAG "alto2"
2119
22#if   DEBUG
23extern 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
2722#endif
2823
2924//extern void fatal(int level, const char* format, ...);
r26032r26033
7671#define   ALTO2_UCODE_SIZE      ((ALTO2_UCODE_ROM_PAGES + ALTO2_UCODE_RAM_PAGES) * ALTO2_UCODE_PAGE_SIZE)   //!< total number of words of microcode
7772#define   ALTO2_UCODE_RAM_BASE   (ALTO2_UCODE_ROM_PAGES * ALTO2_UCODE_PAGE_SIZE)   //!< base offset for the RAM page(s)
7873#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
8077
8178/**
8279 * @brief start value for the horizontal line counter
r26032r26033
235232   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
236233
237234private:
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
238242   void fatal(int level, const char *format, ...);
239243
240244   address_space_config m_ucode_config;
r26032r26033
729733   int m_unload_time;                        //!< unload word time accu
730734   int m_unload_word;                        //!< unload word number
731735
732   static const char *task_name(int task);      //!< human readable task names
736   static const char *task_name(int task);         //!< human readable task names
733737   static const char *r_name(UINT8 reg);         //!< human readable register names
734738   static const char *aluf_name(UINT8 aluf);      //!< human readable ALU function names
735739   static const char *bs_name(UINT8 bs);         //!< human readable bus source names
r26032r26033
12701274   // ************************************************
12711275   // diablo31 drive stuff
12721276   // ************************************************
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)
12811286   //! 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)
12831341
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
12851438   int m_unit_selected;                        //!< selected drive unit
12861439   int m_head_selected;                        //!< selected drive head
12871440   a2cb m_sector_callback;                        //!< callback to call at the start of each sector
12881441   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
12891445   int drive_bits_per_sector() const;               //!< return number of bitclk edges for a sector
12901446   const char* drive_description(int unit);         //!< return a pointer to a drive's description
12911447   const char* drive_basename(int unit);            //!< return a pointer to a drive's image basename
r26032r26033
16901846   /** @brief set non-zero to incorporate the Hamming code and Parity check */
16911847   #define   ALTO2_HAMMING_CHECK   1
16921848
1693   #define   ALTO2_IO_PAGE_SIZE   01000
1694   #define   ALTO2_IO_PAGE_BASE   0177000
1695
16961849   enum {
16971850      ALTO2_MEM_NONE,
16981851      ALTO2_MEM_ODD   = (1 << 0),
r26032r26033
17241877      UINT16 mesr;                  //!< memory error status register
17251878      UINT16 mecr;                  //!< memory error control register
17261879
1727#if   DEBUG
1880#if   ALTO2_DEBUG
17281881      void (*watch_read)(int mar, int md);   //!< watch read function (debugging)
17291882      void (*watch_write)(int mar, int md);   //!< watch write function (debugging)
17301883#endif
r26032r26033
19812134   void init_ether(int task);                  //!< 007 initialize ethernet task
19822135
19832136   // 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
19842139   void init_mrt(int task);                  //!< 010 initialize memory refresh task
19852140
19862141   // display word task
branches/alto2/src/emu/cpu/alto2/a2part.c
r26032r26033
99 *****************************************************************************/
1010#include "alto2.h"
1111
12/** @brief called by the CPU when the parity task becomes active */
12//! called by the CPU when the parity task becomes active
1313void alto2_cpu_device::activate_part()
1414{
1515   /* TODO: what do we do here ? */
1616   m_task_wakeup &= ~(1 << m_task);
1717}
1818
19/**
20 * @brief parity task slots initialization
21 */
19//! parity task slots initialization
2220void alto2_cpu_device::init_part(int task)
2321{
2422   m_active_callback[task] = &alto2_cpu_device::activate_part;
branches/alto2/src/emu/cpu/alto2/a2drive.c
r26032r26033
99 *****************************************************************************/
1010#include "alto2.h"
1111
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)
1912#define   MFROBL         34      //!< from the microcode: disk header preamble is 34 words
2013#define   MFRRDL         21      //!< from the microcode: disk header read delay is 21 words
2114#define   MIRRDL         4      //!< from the microcode: interrecord read delay is 4 words
2215#define   MIROBL         3      //!< from the microcode: disk interrecord preamble is 3 words
2316#define   MRPAL         3      //!< from the microcode: disk read postamble length is 3 words
2417#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
7418
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
12419/** @brief end of the guard zone at the beginning of a sector (wild guess!) */
12520#define   GUARD_ZONE_BITS   (16*32)
12621
r26032r26033
13732#define   RDBIT(bits,src) ((bits[(src)/32] >> ((src) % 32)) & 1)
13833
13934/**
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 */
148typedef 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 */
166typedef 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
244static 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
264static 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/**
28635 * @brief calculate the sector from the logical block address
28736 *
28837 * Modifies drive's page by calculating the logical
r26032r26033
29039 *
29140 * @param unit unit number
29241 */
293static void drive_get_sector(int unit)
42void alto2_cpu_device::drive_get_sector(int unit)
29443{
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)
29746      fatal(1, "invalid unit %d in call to drive_get_sector()\n", unit);
29847
29948   /* If there's no image, just reset the page number */
r26032r26033
30150      d->page = -1;
30251      return;
30352   }
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));
30755      d->page = -1;
30856      return;
30957   }
r26032r26033
439187 * @param unit drive unit number (0 or 1)
440188 * @param page page number (0 to DRIVE_PAGES-1)
441189 */
442static void expand_sector(int unit, int page)
190void alto2_cpu_device::expand_sector(int unit, int page)
443191{
444   diablo_drive_t *d = &drive[unit];
192   diablo_drive_t *d = m_drive[unit];
445193   diablo_sector_t *s;
446194   UINT32 *bits;
447195   size_t dst;
448196
449   if (unit < 0 || unit >= DRIVE_MAX)
197   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
450198      fatal(1, "invalid unit %d in call to expand_sector()\n", unit);
451199
452   if (page < 0 || page >= DRIVE_PAGES)
200   if (page < 0 || page >= DIABLO_DRIVE_PAGES)
453201      return;
454202
455203   /* already expanded this sector? */
r26032r26033
457205      return;
458206
459207   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));
462209      return;
463210   }
464211
r26032r26033
466213   s = &d->image[page];
467214
468215   /* allocate a bits image */
469   bits = (UINT32 *)calloc(400, sizeof(UINT32));
216   bits = (UINT32 *)auto_alloc_array(machine(), UINT32, 400);
470217   if (!bits) {
471218      fatal(1, "failed to malloc(%d) bytes bits for drive #%d page #%d\n",
472219         sizeof(bits), unit, page);
r26032r26033
517264
518265}
519266
520#if   DEBUG
267#if   ALTO2_DEBUG
521268static void drive_dump_ascii(UINT8 *src, size_t size)
522269{
523270   size_t offs;
r26032r26033
698445}
699446
700447/**
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
702449 */
703static void squeeze_sector(int unit)
450void alto2_cpu_device::squeeze_sector(int unit)
704451{
705   diablo_drive_t *d = &drive[unit];
452   diablo_drive_t *d = m_drive[unit];
706453   diablo_sector_t *s;
707454   UINT32 *bits;
708455   size_t src;
709456   int cksum_header, cksum_label, cksum_data;
710457
711   if (unit < 0 || unit >= DRIVE_MAX)
458   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
712459      fatal(1, "invalid unit %d in call to squeeze_sector()\n", unit);
713460
714461   if (d->rdfirst >= 0) {
r26032r26033
745492   d->wrfirst = -1;
746493   d->wrlast = -1;
747494
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));
751497      return;
752498   }
753499
r26032r26033
759505
760506   /* no bits to write? */
761507   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));
764509      return;
765510   }
766511
r26032r26033
778523      src, src / 32, src % 32));
779524   src = squeeze_record(bits, src, s->header, sizeof(s->header));
780525   src = squeeze_cksum(bits, src, &cksum_header);
781#if   DEBUG
526#if   ALTO2_DEBUG
782527   dump_record(s->header, 0, sizeof(s->header), "header", 0);
783528#endif
784529
r26032r26033
790535      src, src / 32, src % 32));
791536   src = squeeze_record(bits, src, s->label, sizeof(s->label));
792537   src = squeeze_cksum(bits, src, &cksum_label);
793#if   DEBUG
538#if   ALTO2_DEBUG
794539   dump_record(s->label, 0, sizeof(s->label), "label", 0);
795540#endif
796541
r26032r26033
802547      src, src / 32, src % 32));
803548   src = squeeze_record(bits, src, s->data, sizeof(s->data));
804549   src = squeeze_cksum(bits, src, &cksum_data);
805#if   DEBUG
550#if   ALTO2_DEBUG
806551   dump_record(s->data, 0, sizeof(s->data), "data", 1);
807552#endif
808553
r26032r26033
812557   cksum_data ^= cksum(s->data, sizeof(s->data), 0521);
813558
814559   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));
818562#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);
821564#endif
822565   }
823566}
r26032r26033
829572 */
830573int alto2_cpu_device::drive_bits_per_sector() const
831574{
832   return SECTOR_WORDS * 32;
575   return DIABLO_SECTOR_WORDS * 32;
833576}
834577
835578/**
r26032r26033
840583 */
841584const char* alto2_cpu_device::drive_description(int unit)
842585{
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)
845588      fatal(1, "invalid unit %d in call to drive_description()\n", unit);
846589   return d->description;
847590}
r26032r26033
854597 */
855598const char* alto2_cpu_device::drive_basename(int unit)
856599{
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)
859602      fatal(1, "invalid unit %d in call to drive_description()\n", unit);
860603   return d->basename;
861604}
r26032r26033
870613 */
871614int alto2_cpu_device::drive_unit(int unit)
872615{
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)
875618      fatal(1, "invalid unit %d in call to drive_unit()\n", unit);
876619   return d->unit;
877620}
r26032r26033
884627 */
885628attotime alto2_cpu_device::drive_rotation_time(int unit)
886629{
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)
889632      fatal(1, "invalid unit %d in call to drive_rotation_time()\n", unit);
890633   return d->rotation_time;
891634}
r26032r26033
898641 */
899642attotime alto2_cpu_device::drive_bit_time(int unit)
900643{
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)
903646      fatal(1, "invalid unit %d in call to drive_bit_time()\n", unit);
904647   return d->bit_time;
905648}
r26032r26033
912655 */
913656int alto2_cpu_device::drive_seek_read_write_0(int unit)
914657{
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)
917660      fatal(1, "invalid unit %d in call to drive_seek_read_write_0()\n", unit);
918661   return d->s_r_w_0;
919662}
r26032r26033
926669 */
927670int alto2_cpu_device::drive_ready_0(int unit)
928671{
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)
931674      fatal(1, "invalid unit %d in call to drive_ready_0()\n", unit);
932675   return d->ready_0;
933676}
r26032r26033
942685 */
943686int alto2_cpu_device::drive_sector_mark_0(int unit)
944687{
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)
947690      fatal(1, "invalid unit %d in call to drive_sector_mark_0()\n", unit);
948691   /* no sector marks while seeking (?) */
949692   if (d->s_r_w_0)
r26032r26033
960703 */
961704int alto2_cpu_device::drive_addx_acknowledge_0(int unit)
962705{
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)
965708      fatal(1, "invalid unit %d in call to drive_addx_acknowledge_0()\n", unit);
966709   return d->addx_acknowledge_0;
967710}
r26032r26033
974717 */
975718int alto2_cpu_device::drive_log_addx_interlock_0(int unit)
976719{
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)
979722      fatal(1, "invalid unit %d in call to drive_log_addx_interlock_0()\n", unit);
980723   return d->log_addx_interlock_0;
981724}
r26032r26033
988731 */
989732int alto2_cpu_device::drive_seek_incomplete_0(int unit)
990733{
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)
993736      fatal(1, "invalid unit %d in call to drive_addx_acknowledge_0()\n", unit);
994737   return d->seek_incomplete_0;
995738}
r26032r26033
1004747 */
1005748int alto2_cpu_device::drive_cylinder(int unit)
1006749{
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)
1009752      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;
1011754}
1012755
1013756/**
r26032r26033
1020763 */
1021764int alto2_cpu_device::drive_head(int unit)
1022765{
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)
1025768      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;
1027770}
1028771
1029772/**
r26032r26033
1039782 */
1040783int alto2_cpu_device::drive_sector(int unit)
1041784{
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)
1044787      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;
1046789}
1047790
1048791/**
r26032r26033
1056799 */
1057800int alto2_cpu_device::drive_page(int unit)
1058801{
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)
1061804      fatal(1, "invalid unit %d in call to drive_page()\n", unit);
1062805   return d->page;
1063806}
r26032r26033
1070813 */
1071814void alto2_cpu_device::drive_select(int unit, int head)
1072815{
1073   diablo_drive_t *d = &drive[unit];
816   diablo_drive_t *d = m_drive[unit];
1074817
1075   if (unit < 0 || unit >= DRIVE_MAX)
818   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
1076819      fatal(1, "invalid unit %d in call to drive_select()\n", unit);
1077820
1078821   if (unit != m_unit_selected || head != m_head_selected) {
r26032r26033
1103846   }
1104847
1105848   /* 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;
1107850   if (head != d->head) {
1108851      d->head = head;
1109852      LOG((log_DRV,1,"   HEAD %d select on unit %d\n", head, unit));
r26032r26033
1123866 */
1124867void alto2_cpu_device::drive_strobe(int unit, int cylinder, int restore, int strobe)
1125868{
1126   diablo_drive_t *d = &drive[unit];
869   diablo_drive_t *d = m_drive[unit];
1127870   int seekto = restore ? 0 : cylinder;
1128871
1129   if (unit < 0 || unit >= DRIVE_MAX)
872   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
1130873      fatal(1, "invalid unit %d in call to drive_strobe()\n", unit);
1131874
1132875   if (strobe == 1) {
r26032r26033
1162905   } else {
1163906      /* increment cylinder */
1164907      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;
1167910         d->log_addx_interlock_0 = 1;   /* deassert the log address interlock */
1168911         d->seek_incomplete_0 = 1;   /* deassert seek incomplete */
1169912         d->addx_acknowledge_0 = 0;   /* assert address acknowledge  */
r26032r26033
1197940 */
1198941void alto2_cpu_device::drive_egate(int unit, int gate)
1199942{
1200   diablo_drive_t *d = &drive[unit];
943   diablo_drive_t *d = m_drive[unit];
1201944   d->egate_0 = gate;
1202945}
1203946
r26032r26033
1209952 */
1210953void alto2_cpu_device::drive_wrgate(int unit, int gate)
1211954{
1212   diablo_drive_t *d = &drive[unit];
955   diablo_drive_t *d = m_drive[unit];
1213956   d->wrgate_0 = gate;
1214957}
1215958
r26032r26033
1221964 */
1222965void alto2_cpu_device::drive_rdgate(int unit, int gate)
1223966{
1224   diablo_drive_t *d = &drive[unit];
967   diablo_drive_t *d = m_drive[unit];
1225968   d->rdgate_0 = gate;
1226969}
1227970
r26032r26033
1245988 */
1246989void alto2_cpu_device::drive_wrdata(int unit, int index, int wrdata)
1247990{
1248   diablo_drive_t *d = &drive[unit];
991   diablo_drive_t *d = m_drive[unit];
1249992   UINT32 *bits;
1250993
1251994   if (d->wrgate_0) {
r26032r26033
12961039 */
12971040int alto2_cpu_device::drive_rddata(int unit, int index)
12981041{
1299   diablo_drive_t *d = &drive[unit];
1042   diablo_drive_t *d = m_drive[unit];
13001043   UINT32 *bits;
13011044   int bit = 0;
13021045
r26032r26033
13481091 */
13491092int alto2_cpu_device::drive_rdclk(int unit, int index)
13501093{
1351   diablo_drive_t *d = &drive[unit];
1094   diablo_drive_t *d = m_drive[unit];
13521095   UINT32 *bits;
13531096   int clk;
13541097
r26032r26033
13991142 */
14001143int alto2_cpu_device::debug_read_sync(int unit, int page, int offs)
14011144{
1402   diablo_drive_t *d = &drive[unit];
1145   diablo_drive_t *d = m_drive[unit];
14031146   UINT32 *bits;
14041147   UINT32 accu;
14051148
r26032r26033
14111154      return 0;
14121155
14131156   /* 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)
14151158      return 0;
14161159
14171160   bits = d->bits[page];
r26032r26033
14451188 */
14461189int alto2_cpu_device::debug_read_sec(int unit, int page, int offs)
14471190{
1448   diablo_drive_t *d = &drive[unit];
1191   diablo_drive_t *d = m_drive[unit];
14491192   UINT32 *bits;
14501193   int i, clks, word;
14511194
r26032r26033
14571200      return 0177777;
14581201
14591202   /* 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)
14611204      return 0177777;
14621205
14631206   bits = d->bits[page];
r26032r26033
14881231{
14891232   (void)ptr;
14901233   int unit = m_unit_selected;
1491   diablo_drive_t *d = &drive[unit];
1234   diablo_drive_t *d = m_drive[unit];
14921235
14931236   LOG((log_DRV,5, "   next sector (unit #%d sector %d)\n", unit, d->sector));
1237   (void)d;
14941238
1495   /* deassert sector mark after pulse width */
14961239   switch (arg) {
14971240   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 */
15001243      sector_mark_1(unit);
15011244      break;
15021245   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 */
15041248      sector_mark_0(unit);
15051249      break;
15061250   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);
15081253      /* call the sector_callback, if any */
15091254      if (m_sector_callback)
15101255         ((*this).*m_sector_callback)(unit);
r26032r26033
15181263 */
15191264void alto2_cpu_device::sector_mark_1(int unit)
15201265{
1521   diablo_drive_t *d = &drive[unit];
1266   diablo_drive_t *d = m_drive[unit];
15221267
15231268   LOG((log_DRV,5, "   sector mark 1 (unit #%d sector %d)\n", unit, d->sector));
15241269   /* set sector mark to 1 */
r26032r26033
15321277 */
15331278void alto2_cpu_device::sector_mark_0(int unit)
15341279{
1535   diablo_drive_t *d = &drive[unit];
1280   diablo_drive_t *d = m_drive[unit];
15361281
15371282   LOG((log_DRV,5,"   sector mark 0 (unit #%d sector %d)\n", unit, d->sector));
15381283
r26032r26033
15481293   d->wrlast = -1;
15491294
15501295   /* count sectors */
1551   d->sector = (d->sector + 1) % DRIVE_SPT;
1296   d->sector = (d->sector + 1) % DIABLO_DRIVE_SPT;
15521297   drive_get_sector(unit);
15531298}
1299
1300#if   0   // FIXME: unused loading of the disk image
15541301/**
15551302 * @brief pass down command line arguments to the drive emulation
15561303 *
r26032r26033
16111358   if (unit == DRIVE_MAX)
16121359      return -1;
16131360
1614   d = &drive[unit];
1361   d = reinterpret_cast<diablo_drive_t *>(m_drive[unit]);
16151362
16161363   snprintf(d->basename, sizeof(d->basename), "%s", basename);
16171364
r26032r26033
17221469
17231470   return 0;
17241471}
1472#endif
17251473
17261474/**
17271475 * @brief initialize the disk drive context and insert a disk word timer
r26032r26033
17361484      fatal(1, "sizeof(sector_t) is not %d (%d)\n",
17371485         267 * 2, sizeof(diablo_sector_t));
17381486
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;
17411491
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 */
17471500      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 */
17491502
17501503      /* reset the disk drive's address */
17511504      d->cylinder = 0;
r26032r26033
17651518
17661519   m_sector_callback = 0;
17671520   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);
17691522}
branches/alto2/src/emu/cpu/alto2/a2mem.c
r26032r26033
670670      m_mem.md = ((*this).*mmio_read_fn[base_addr - ALTO2_IO_PAGE_BASE])(base_addr);
671671      LOG((0,6,"   MD = MMIO[%#o] (%#o)\n", base_addr, m_mem.md));
672672      m_mem.access = ALTO2_MEM_NONE;
673#if   DEBUG
673#if   ALTO2_DEBUG
674674      if (m_mem.watch_read)
675675         (*m_mem.watch_read)(m_mem.mar, m_mem.md);
676676#endif
r26032r26033
685685   m_mem.md = (m_mem.mar & ALTO2_MEM_ODD) ? GET_ODD(m_mem.rmdd) : GET_EVEN(m_mem.rmdd);
686686   LOG((0,6,"   MD = RAM[%#o] (%#o)\n", mem.mar, mem.md));
687687
688#if   DEBUG
688#if   ALTO2_DEBUG
689689   if (m_mem.watch_read)
690690      (*m_mem.watch_read)(m_mem.mar, m_mem.md);
691691#endif
r26032r26033
726726      LOG((0,6, "   MMIO[%#o] = MD (%#o)\n", base_addr, m_mem.md));
727727      ((*this).*mmio_write_fn[base_addr - ALTO2_IO_PAGE_BASE])(base_addr, m_mem.md);
728728      m_mem.access = ALTO2_MEM_NONE;
729#if   DEBUG
729#if   ALTO2_DEBUG
730730      if (m_mem.watch_write)
731731         ((*this).*m_mem.watch_write)(m_mem.mar, m_mem.md);
732732#endif
r26032r26033
747747      m_mem.ram[m_mem.mar/2] = m_mem.wmdd;
748748#endif
749749
750#if   DEBUG
750#if   ALTO2_DEBUG
751751   if (m_mem.watch_write)
752752      ((*this).*m_mem.watch_write)(m_mem.mar, m_mem.md);
753753#endif
branches/alto2/src/emu/cpu/alto2/a2ksec.c
r26032r26033
1010#include "alto2.h"
1111
1212/** @brief block the disk sector task */
13void alto2_cpu_device::f1_ksec_block_0(void)
13void alto2_cpu_device::f1_ksec_block_0()
1414{
1515   LOG((0,2,"   BLOCK %s\n", task_name(m_task)));
1616   disk_block(m_task);
branches/alto2/src/emu/cpu/alto2/a2kwd.c
r26032r26033
99 *****************************************************************************/
1010#include "alto2.h"
1111
12/**
13 * @brief block the disk word task
14 */
12//! f1_kwd_block early: block the disk word task
1513void alto2_cpu_device::f1_kwd_block_0()
1614{
1715   LOG((0,2,"   BLOCK %s\n", task_name(m_task)));
1816   disk_block(m_task);
1917}
2018
21/**
22 * @brief disk word task slot initialization
23 */
19//! disk word task slot initialization
2420void alto2_cpu_device::init_kwd(int task)
2521{
2622   set_bs(task, bs_kwd_read_kstat,      &alto2_cpu_device::bs_read_kstat_0, 0);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team