Previous 15994 Revisions Next

r6749 Friday 25th December, 2009 at 10:53:19 UTC by Miodrag Milanović
[TI990] Converted tape controller to device and connected magnetic tape to it.
[src/mess/drivers]ti990_10.c
[src/mess/machine]990_tap.c 990_tap.h

src/mess/machine/990_tap.c
r6748r6749
3333#include "990_tap.h"
3434#include "image.h"
3535
36static void update_interrupt(running_machine *machine);
36static void update_interrupt(const device_config *device);
3737
3838#define MAX_TAPE_UNIT 4
3939
r6748r6749
4545   unsigned int wp : 1;   /* TRUE if tape is write-protected */
4646} tape_unit_t;
4747
48typedef struct tpc_t
48typedef struct _tap_990_t tap_990_t;
49struct _tap_990_t
4950{
5051   UINT16 w[8];
5152
52   void (*interrupt_callback)(running_machine *machine, int state);
53
53   const ti990_tpc_interface *intf;
54   
5455   tape_unit_t t[MAX_TAPE_UNIT];
55} tpc_t;
56};
5657
58typedef struct _ti990_tape_t ti990_tape_t;
59struct _ti990_tape_t
60{
61   int dummy;
62};
63
5764enum
5865{
5966   w0_offline         = 0x8000,
r6748r6749
103110   0xf3ff      /* Don't overwrite reserved bits */
104111};
105112
106static tpc_t tpc;
113int tape_get_id(const device_config *image)
114{
115   int drive =0;
116   if (strcmp(image->tag, "tape0") == 0) drive = 0;
117   if (strcmp(image->tag, "tape1") == 0) drive = 1;
118   if (strcmp(image->tag, "tape2") == 0) drive = 2;
119   if (strcmp(image->tag, "tape3") == 0) drive = 3;
120   return drive;
121}
107122
123/*****************************************************************************
124    INLINE FUNCTIONS
125*****************************************************************************/
126INLINE tap_990_t *get_safe_token(const device_config *device)
127{
128   assert(device != NULL);
129   assert(device->token != NULL);
108130
131   return (tap_990_t *)device->token;
132}
133
109134DEVICE_START( ti990_tape )
110135{
111136   tape_unit_t *t;
112   int id = image_index_in_device(device);
113
114   assert ((id >= 0) && (id < MAX_TAPE_UNIT));
115
116   t = &tpc.t[id];
137   tap_990_t *tpc = get_safe_token(device->owner);
138   int id = tape_get_id(device);
139   
140   t = &tpc->t[id];
117141   memset(t, 0, sizeof(*t));
118142
119143   t->img = device;
r6748r6749
122146   t->eot = 0;
123147}
124148
125#ifdef UNUSED_FUNCTION
126DEVICE_STOP( ti990_tape )
127{
128   d->img = NULL;
129}
130#endif
131
132149/*
133150    Open a tape image
134151*/
135152DEVICE_IMAGE_LOAD( ti990_tape )
136153{
137154   tape_unit_t *t;
138   int id = image_index_in_device(image);
139
140
141   if ((id < 0) || (id >= MAX_TAPE_UNIT))
142      return INIT_FAIL;
143
144   t = &tpc.t[id];
155   tap_990_t *tpc = get_safe_token(image->owner);
156   int id = tape_get_id(image);
157   
158   t = &tpc->t[id];
145159   memset(t, 0, sizeof(*t));
146160
147161   /* tell whether the image is writable */
r6748r6749
158172DEVICE_IMAGE_UNLOAD( ti990_tape )
159173{
160174   tape_unit_t *t;
161   int id = image_index_in_device(image);
175   tap_990_t *tpc = get_safe_token(image->owner);
176   int id = tape_get_id(image);
162177
163   if ((id < 0) || (id >= MAX_TAPE_UNIT))
164      return;
165
166   t = &tpc.t[id];
178   t = &tpc->t[id];
167179   t->wp = 1;
168180   t->bot = 0;
169181   t->eot = 0;
170182}
171183
172184/*
173    Init the tape controller core
174*/
175void ti990_tpc_init(running_machine *machine, void (*interrupt_callback)(running_machine *machine, int state))
176{
177   memset(tpc.w, 0, sizeof(tpc.w));
178   /* The PE bit is always set for the MT3200 (but not MT1600) */
179   /* According to MT3200 manual, w7 bit #4 (reserved) is always set */
180   tpc.w[7] = w7_idle /*| w7_PE_format*/ | 0x0800;
181
182   tpc.interrupt_callback = interrupt_callback;
183
184   update_interrupt(machine);
185}
186
187/*
188185    Parse the tape select lines, and return the corresponding tape unit.
189186    (-1 if none)
190187*/
191static int cur_tape_unit(void)
188static int cur_tape_unit(const device_config *device)
192189{
193190   int reply;
191   tap_990_t *tpc = get_safe_token(device);
194192
195
196   if (tpc.w[6] & w6_unit0_sel)
193   if (tpc->w[6] & w6_unit0_sel)
197194      reply = 0;
198   else if (tpc.w[6] & w6_unit1_sel)
195   else if (tpc->w[6] & w6_unit1_sel)
199196      reply = 1;
200   else if (tpc.w[6] & w6_unit2_sel)
197   else if (tpc->w[6] & w6_unit2_sel)
201198      reply = 2;
202   else if (tpc.w[6] & w6_unit3_sel)
199   else if (tpc->w[6] & w6_unit3_sel)
203200      reply = 3;
204201   else
205202      reply = -1;
r6748r6749
213210/*
214211    Update interrupt state
215212*/
216static void update_interrupt(running_machine *machine)
213static void update_interrupt(const device_config *device)
217214{
218   if (tpc.interrupt_callback)
219      (*tpc.interrupt_callback)(machine, (tpc.w[7] & w7_idle)
220                           && (((tpc.w[7] & w7_int_enable) && (tpc.w[7] & (w7_complete | w7_error)))
221                              || ((tpc.w[0] & ~(tpc.w[0] >> 4)) & w0_rewind_mask)));
215   tap_990_t *tpc = get_safe_token(device);
216   if (tpc->intf->interrupt_callback)
217      (*tpc->intf->interrupt_callback)(device->machine, (tpc->w[7] & w7_idle)
218                           && (((tpc->w[7] & w7_int_enable) && (tpc->w[7] & (w7_complete | w7_error)))
219                              || ((tpc->w[0] & ~(tpc->w[0] >> 4)) & w0_rewind_mask)));
222220}
223221
224222/*
225223    Handle the read binary forward command: read the next record on tape.
226224*/
227static void cmd_read_binary_forward(running_machine *machine)
225static void cmd_read_binary_forward(const device_config *device)
228226{
229227   UINT8 buffer[256];
230228   int reclen;
r6748r6749
238236   int bytes_to_read;
239237   int bytes_read;
240238   int i;
239   tap_990_t *tpc = get_safe_token(device);
240   int tap_sel = cur_tape_unit(device);
241241
242   int tap_sel = cur_tape_unit();
243
244242   if (tap_sel == -1)
245243   {
246244      /* No idea what to report... */
247      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
248      update_interrupt(machine);
245      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
246      update_interrupt(device);
249247      return;
250248   }
251   else if (! image_exists(tpc.t[tap_sel].img))
249   else if (! image_exists(tpc->t[tap_sel].img))
252250   {   /* offline */
253      tpc.w[0] |= w0_offline;
254      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
255      update_interrupt(machine);
251      tpc->w[0] |= w0_offline;
252      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
253      update_interrupt(device);
256254      return;
257255   }
258256#if 0
259257   else if (0)
260258   {   /* rewind in progress */
261      tpc.w[0] |= 0x80 >> tap_sel;
262      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
263      update_interrupt(machine);
259      tpc->w[0] |= 0x80 >> tap_sel;
260      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
261      update_interrupt(device);
264262      return;
265263   }
266264#endif
267265
268   tpc.t[tap_sel].bot = 0;
266   tpc->t[tap_sel].bot = 0;
269267
270   dma_address = ((((int) tpc.w[6]) << 16) | tpc.w[5]) & 0x1ffffe;
271   char_count = tpc.w[4];
272   read_offset = tpc.w[3];
268   dma_address = ((((int) tpc->w[6]) << 16) | tpc->w[5]) & 0x1ffffe;
269   char_count = tpc->w[4];
270   read_offset = tpc->w[3];
273271
274   bytes_read = image_fread(tpc.t[tap_sel].img, buffer, 4);
272   bytes_read = image_fread(tpc->t[tap_sel].img, buffer, 4);
275273   if (bytes_read != 4)
276274   {
277275      if (bytes_read == 0)
278276      {   /* legitimate EOF */
279         tpc.t[tap_sel].eot = 1;
280         tpc.w[0] |= w0_EOT;   /* or should it be w0_command_timeout? */
281         tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
282         update_interrupt(machine);
277         tpc->t[tap_sel].eot = 1;
278         tpc->w[0] |= w0_EOT;   /* or should it be w0_command_timeout? */
279         tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
280         update_interrupt(device);
283281         goto update_registers;
284282      }
285283      else
r6748r6749
287285         /* No idea what to report... */
288286         /* eject tape to avoid catastrophes */
289287         logerror("Tape error\n");
290         image_unload(tpc.t[tap_sel].img);
291         tpc.w[0] |= w0_offline;
292         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
293         update_interrupt(machine);
288         image_unload(tpc->t[tap_sel].img);
289         tpc->w[0] |= w0_offline;
290         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
291         update_interrupt(device);
294292         goto update_registers;
295293      }
296294   }
r6748r6749
300298      logerror("Tape error\n");
301299      logerror("Tape format looks gooofy\n");
302300      /* eject tape to avoid catastrophes */
303      image_unload(tpc.t[tap_sel].img);
304      tpc.w[0] |= w0_offline;
305      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
306      update_interrupt(machine);
301      image_unload(tpc->t[tap_sel].img);
302      tpc->w[0] |= w0_offline;
303      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
304      update_interrupt(device);
307305      goto update_registers;
308306   }
309307
r6748r6749
311309   if (reclen == 0)
312310   {
313311      logerror("read binary forward: found EOF, requested %d\n", char_count);
314      tpc.w[0] |= w0_EOF;
315      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
316      update_interrupt(machine);
312      tpc->w[0] |= w0_EOF;
313      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
314      update_interrupt(device);
317315      goto update_registers;
318316   }
319317
r6748r6749
324322   /* skip up to read_offset bytes */
325323   chunk_len = (read_offset > rec_count) ? rec_count : read_offset;
326324
327   if (image_fseek(tpc.t[tap_sel].img, chunk_len, SEEK_CUR))
325   if (image_fseek(tpc->t[tap_sel].img, chunk_len, SEEK_CUR))
328326   {   /* eject tape */
329327      logerror("Tape error\n");
330      image_unload(tpc.t[tap_sel].img);
331      tpc.w[0] |= w0_offline;
332      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
333      update_interrupt(machine);
328      image_unload(tpc->t[tap_sel].img);
329      tpc->w[0] |= w0_offline;
330      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
331      update_interrupt(device);
334332      goto update_registers;
335333   }
336334
r6748r6749
338336   read_offset -= chunk_len;
339337   if (read_offset)
340338   {
341      tpc.w[0] |= w0_EOR;
342      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
343      update_interrupt(machine);
339      tpc->w[0] |= w0_EOR;
340      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
341      update_interrupt(device);
344342      goto skip_trailer;
345343   }
346344
r6748r6749
350348   for (; chunk_len>0; )
351349   {
352350      bytes_to_read = (chunk_len < sizeof(buffer)) ? chunk_len : sizeof(buffer);
353      bytes_read = image_fread(tpc.t[tap_sel].img, buffer, bytes_to_read);
351      bytes_read = image_fread(tpc->t[tap_sel].img, buffer, bytes_to_read);
354352
355353      if (bytes_read & 1)
356354      {
r6748r6749
360358      /* DMA */
361359      for (i=0; i<bytes_read; i+=2)
362360      {
363         memory_write_word_16be(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),dma_address, (((int) buffer[i]) << 8) | buffer[i+1]);
361         memory_write_word_16be(cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM),dma_address, (((int) buffer[i]) << 8) | buffer[i+1]);
364362         dma_address = (dma_address + 2) & 0x1ffffe;
365363      }
366364
r6748r6749
371369      if (bytes_read != bytes_to_read)
372370      {   /* eject tape */
373371         logerror("Tape error\n");
374         image_unload(tpc.t[tap_sel].img);
375         tpc.w[0] |= w0_offline;
376         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
377         update_interrupt(machine);
372         image_unload(tpc->t[tap_sel].img);
373         tpc->w[0] |= w0_offline;
374         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
375         update_interrupt(device);
378376         goto update_registers;
379377      }
380378   }
381379
382380   if (char_count)
383381   {
384      tpc.w[0] |= w0_EOR;
385      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
386      update_interrupt(machine);
382      tpc->w[0] |= w0_EOR;
383      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
384      update_interrupt(device);
387385      goto skip_trailer;
388386   }
389387
390388   if (rec_count)
391389   {   /* skip end of record */
392      if (image_fseek(tpc.t[tap_sel].img, rec_count, SEEK_CUR))
390      if (image_fseek(tpc->t[tap_sel].img, rec_count, SEEK_CUR))
393391      {   /* eject tape */
394392         logerror("Tape error\n");
395         image_unload(tpc.t[tap_sel].img);
396         tpc.w[0] |= w0_offline;
397         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
398         update_interrupt(machine);
393         image_unload(tpc->t[tap_sel].img);
394         tpc->w[0] |= w0_offline;
395         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
396         update_interrupt(device);
399397         goto update_registers;
400398      }
401399   }
402400
403401skip_trailer:
404   if (image_fread(tpc.t[tap_sel].img, buffer, 4) != 4)
402   if (image_fread(tpc->t[tap_sel].img, buffer, 4) != 4)
405403   {   /* eject tape */
406404      logerror("Tape error\n");
407      image_unload(tpc.t[tap_sel].img);
408      tpc.w[0] |= w0_offline;
409      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
410      update_interrupt(machine);
405      image_unload(tpc->t[tap_sel].img);
406      tpc->w[0] |= w0_offline;
407      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
408      update_interrupt(device);
411409      goto update_registers;
412410   }
413411
414412   if (reclen != ((((int) buffer[1]) << 8) | buffer[0]))
415413   {   /* eject tape */
416414      logerror("Tape error\n");
417      image_unload(tpc.t[tap_sel].img);
418      tpc.w[0] |= w0_offline;
419      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
420      update_interrupt(machine);
415      image_unload(tpc->t[tap_sel].img);
416      tpc->w[0] |= w0_offline;
417      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
418      update_interrupt(device);
421419      goto update_registers;
422420   }
423421   if (buffer[2] || buffer[3])
r6748r6749
425423      logerror("Tape error\n");
426424      logerror("Tape format looks gooofy\n");
427425      /* eject tape to avoid catastrophes */
428      image_unload(tpc.t[tap_sel].img);
429      tpc.w[0] |= w0_offline;
430      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
431      update_interrupt(machine);
426      image_unload(tpc->t[tap_sel].img);
427      tpc->w[0] |= w0_offline;
428      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
429      update_interrupt(device);
432430      goto update_registers;
433431   }
434432
435   if (! (tpc.w[7] & w7_error))
433   if (! (tpc->w[7] & w7_error))
436434   {
437      tpc.w[7] |= w7_idle | w7_complete;
438      update_interrupt(machine);
435      tpc->w[7] |= w7_idle | w7_complete;
436      update_interrupt(device);
439437   }
440438
441439update_registers:
442   tpc.w[1] = rec_count & 0xffff;
443   tpc.w[2] = (rec_count >> 8) & 0xff;
444   tpc.w[3] = read_offset;
445   tpc.w[4] = char_count;
446   tpc.w[5] = (dma_address >> 1) & 0xffff;
447   tpc.w[6] = (tpc.w[6] & 0xffe0) | ((dma_address >> 17) & 0xf);
440   tpc->w[1] = rec_count & 0xffff;
441   tpc->w[2] = (rec_count >> 8) & 0xff;
442   tpc->w[3] = read_offset;
443   tpc->w[4] = char_count;
444   tpc->w[5] = (dma_address >> 1) & 0xffff;
445   tpc->w[6] = (tpc->w[6] & 0xffe0) | ((dma_address >> 17) & 0xf);
448446}
449447
450448/*
451449    Handle the record skip forward command: skip a specified number of records.
452450*/
453static void cmd_record_skip_forward(running_machine *machine)
451static void cmd_record_skip_forward(const device_config *device)
454452{
455453   UINT8 buffer[4];
456454   int reclen;
457455
458456   int record_count;
459457   int bytes_read;
458   tap_990_t *tpc = get_safe_token(device);
459   int tap_sel = cur_tape_unit(device);
460460
461   int tap_sel = cur_tape_unit();
462
463461   if (tap_sel == -1)
464462   {
465463      /* No idea what to report... */
466      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
467      update_interrupt(machine);
464      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
465      update_interrupt(device);
468466      return;
469467   }
470   else if (! image_exists(tpc.t[tap_sel].img))
468   else if (! image_exists(tpc->t[tap_sel].img))
471469   {   /* offline */
472      tpc.w[0] |= w0_offline;
473      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
474      update_interrupt(machine);
470      tpc->w[0] |= w0_offline;
471      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
472      update_interrupt(device);
475473      return;
476474   }
477475#if 0
478476   else if (0)
479477   {   /* rewind in progress */
480      tpc.w[0] |= 0x80 >> tap_sel;
481      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
482      update_interrupt(machine);
478      tpc->w[0] |= 0x80 >> tap_sel;
479      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
480      update_interrupt(device);
483481      return;
484482   }
485483#endif
486484
487   record_count = tpc.w[4];
485   record_count = tpc->w[4];
488486
489487   if (record_count)
490      tpc.t[tap_sel].bot = 0;
488      tpc->t[tap_sel].bot = 0;
491489
492490   while (record_count > 0)
493491   {
494      bytes_read = image_fread(tpc.t[tap_sel].img, buffer, 4);
492      bytes_read = image_fread(tpc->t[tap_sel].img, buffer, 4);
495493      if (bytes_read != 4)
496494      {
497495         if (bytes_read == 0)
498496         {   /* legitimate EOF */
499            tpc.t[tap_sel].eot = 1;
500            tpc.w[0] |= w0_EOT;   /* or should it be w0_command_timeout? */
501            tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
502            update_interrupt(machine);
497            tpc->t[tap_sel].eot = 1;
498            tpc->w[0] |= w0_EOT;   /* or should it be w0_command_timeout? */
499            tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
500            update_interrupt(device);
503501            goto update_registers;
504502         }
505503         else
506504         {   /* illegitimate EOF */
507505            /* No idea what to report... */
508506            /* eject tape to avoid catastrophes */
509            image_unload(tpc.t[tap_sel].img);
510            tpc.w[0] |= w0_offline;
511            tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
512            update_interrupt(machine);
507            image_unload(tpc->t[tap_sel].img);
508            tpc->w[0] |= w0_offline;
509            tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
510            update_interrupt(device);
513511            goto update_registers;
514512         }
515513      }
r6748r6749
518516      {   /* no idea what these bytes mean */
519517         logerror("Tape format looks gooofy\n");
520518         /* eject tape to avoid catastrophes */
521         image_unload(tpc.t[tap_sel].img);
522         tpc.w[0] |= w0_offline;
523         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
524         update_interrupt(machine);
519         image_unload(tpc->t[tap_sel].img);
520         tpc->w[0] |= w0_offline;
521         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
522         update_interrupt(device);
525523         goto update_registers;
526524      }
527525
r6748r6749
529527      if (reclen == 0)
530528      {
531529         logerror("record skip forward: found EOF\n");
532         tpc.w[0] |= w0_EOF;
533         tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
534         update_interrupt(machine);
530         tpc->w[0] |= w0_EOF;
531         tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
532         update_interrupt(device);
535533         goto update_registers;
536534      }
537535
538536      /* skip record data */
539      if (image_fseek(tpc.t[tap_sel].img, reclen, SEEK_CUR))
537      if (image_fseek(tpc->t[tap_sel].img, reclen, SEEK_CUR))
540538      {   /* eject tape */
541         image_unload(tpc.t[tap_sel].img);
542         tpc.w[0] |= w0_offline;
543         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
544         update_interrupt(machine);
539         image_unload(tpc->t[tap_sel].img);
540         tpc->w[0] |= w0_offline;
541         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
542         update_interrupt(device);
545543         goto update_registers;
546544      }
547545
548      if (image_fread(tpc.t[tap_sel].img, buffer, 4) != 4)
546      if (image_fread(tpc->t[tap_sel].img, buffer, 4) != 4)
549547      {   /* eject tape */
550         image_unload(tpc.t[tap_sel].img);
551         tpc.w[0] |= w0_offline;
552         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
553         update_interrupt(machine);
548         image_unload(tpc->t[tap_sel].img);
549         tpc->w[0] |= w0_offline;
550         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
551         update_interrupt(device);
554552         goto update_registers;
555553      }
556554
557555      if (reclen != ((((int) buffer[1]) << 8) | buffer[0]))
558556      {   /* eject tape */
559         image_unload(tpc.t[tap_sel].img);
560         tpc.w[0] |= w0_offline;
561         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
562         update_interrupt(machine);
557         image_unload(tpc->t[tap_sel].img);
558         tpc->w[0] |= w0_offline;
559         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
560         update_interrupt(device);
563561         goto update_registers;
564562      }
565563      if (buffer[2] || buffer[3])
566564      {   /* no idea what these bytes mean */
567565         logerror("Tape format looks gooofy\n");
568566         /* eject tape to avoid catastrophes */
569         image_unload(tpc.t[tap_sel].img);
570         tpc.w[0] |= w0_offline;
571         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
572         update_interrupt(machine);
567         image_unload(tpc->t[tap_sel].img);
568         tpc->w[0] |= w0_offline;
569         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
570         update_interrupt(device);
573571         goto update_registers;
574572      }
575573
576574      record_count--;
577575   }
578576
579   tpc.w[7] |= w7_idle | w7_complete;
580   update_interrupt(machine);
577   tpc->w[7] |= w7_idle | w7_complete;
578   update_interrupt(device);
581579
582580update_registers:
583   tpc.w[4] = record_count;
581   tpc->w[4] = record_count;
584582}
585583
586584/*
587585    Handle the record skip reverse command: skip a specified number of records backwards.
588586*/
589static void cmd_record_skip_reverse(running_machine *machine)
587static void cmd_record_skip_reverse(const device_config *device)
590588{
591589   UINT8 buffer[4];
592590   int reclen;
r6748r6749
594592   int record_count;
595593
596594   int bytes_read;
595   tap_990_t *tpc = get_safe_token(device);
596   int tap_sel = cur_tape_unit(device);
597597
598   int tap_sel = cur_tape_unit();
599
600598   if (tap_sel == -1)
601599   {
602600      /* No idea what to report... */
603      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
604      update_interrupt(machine);
601      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
602      update_interrupt(device);
605603      return;
606604   }
607   else if (! image_exists(tpc.t[tap_sel].img))
605   else if (! image_exists(tpc->t[tap_sel].img))
608606   {   /* offline */
609      tpc.w[0] |= w0_offline;
610      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
611      update_interrupt(machine);
607      tpc->w[0] |= w0_offline;
608      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
609      update_interrupt(device);
612610      return;
613611   }
614612#if 0
615613   else if (0)
616614   {   /* rewind in progress */
617      tpc.w[0] |= 0x80 >> tap_sel;
618      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
619      update_interrupt(machine);
615      tpc->w[0] |= 0x80 >> tap_sel;
616      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
617      update_interrupt(device);
620618      return;
621619   }
622620#endif
623621
624   record_count = tpc.w[4];
622   record_count = tpc->w[4];
625623
626624   if (record_count)
627      tpc.t[tap_sel].eot = 0;
625      tpc->t[tap_sel].eot = 0;
628626
629627   while (record_count > 0)
630628   {
631      if (image_ftell(tpc.t[tap_sel].img) == 0)
629      if (image_ftell(tpc->t[tap_sel].img) == 0)
632630      {   /* bot */
633         tpc.t[tap_sel].bot = 1;
634         tpc.w[0] |= w0_BOT;
635         tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
636         update_interrupt(machine);
631         tpc->t[tap_sel].bot = 1;
632         tpc->w[0] |= w0_BOT;
633         tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
634         update_interrupt(device);
637635         goto update_registers;
638636      }
639      if (image_fseek(tpc.t[tap_sel].img, -4, SEEK_CUR))
637      if (image_fseek(tpc->t[tap_sel].img, -4, SEEK_CUR))
640638      {   /* eject tape */
641         image_unload(tpc.t[tap_sel].img);
642         tpc.w[0] |= w0_offline;
643         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
644         update_interrupt(machine);
639         image_unload(tpc->t[tap_sel].img);
640         tpc->w[0] |= w0_offline;
641         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
642         update_interrupt(device);
645643         goto update_registers;
646644      }
647      bytes_read = image_fread(tpc.t[tap_sel].img, buffer, 4);
645      bytes_read = image_fread(tpc->t[tap_sel].img, buffer, 4);
648646      if (bytes_read != 4)
649647      {
650648         /* illegitimate EOF */
651649         /* No idea what to report... */
652650         /* eject tape to avoid catastrophes */
653         image_unload(tpc.t[tap_sel].img);
654         tpc.w[0] |= w0_offline;
655         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
656         update_interrupt(machine);
651         image_unload(tpc->t[tap_sel].img);
652         tpc->w[0] |= w0_offline;
653         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
654         update_interrupt(device);
657655         goto update_registers;
658656      }
659657      reclen = (((int) buffer[1]) << 8) | buffer[0];
r6748r6749
661659      {   /* no idea what these bytes mean */
662660         logerror("Tape format looks gooofy\n");
663661         /* eject tape to avoid catastrophes */
664         image_unload(tpc.t[tap_sel].img);
665         tpc.w[0] |= w0_offline;
666         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
667         update_interrupt(machine);
662         image_unload(tpc->t[tap_sel].img);
663         tpc->w[0] |= w0_offline;
664         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
665         update_interrupt(device);
668666         goto update_registers;
669667      }
670668
r6748r6749
672670      if (reclen == 0)
673671      {
674672         logerror("record skip reverse: found EOF\n");
675         if (image_fseek(tpc.t[tap_sel].img, -4, SEEK_CUR))
673         if (image_fseek(tpc->t[tap_sel].img, -4, SEEK_CUR))
676674         {   /* eject tape */
677            image_unload(tpc.t[tap_sel].img);
678            tpc.w[0] |= w0_offline;
679            tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
680            update_interrupt(machine);
675            image_unload(tpc->t[tap_sel].img);
676            tpc->w[0] |= w0_offline;
677            tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
678            update_interrupt(device);
681679            goto update_registers;
682680         }
683         tpc.w[0] |= w0_EOF;
684         tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
685         update_interrupt(machine);
681         tpc->w[0] |= w0_EOF;
682         tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
683         update_interrupt(device);
686684         goto update_registers;
687685      }
688686
689      if (image_fseek(tpc.t[tap_sel].img, -reclen-8, SEEK_CUR))
687      if (image_fseek(tpc->t[tap_sel].img, -reclen-8, SEEK_CUR))
690688      {   /* eject tape */
691         image_unload(tpc.t[tap_sel].img);
692         tpc.w[0] |= w0_offline;
693         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
694         update_interrupt(machine);
689         image_unload(tpc->t[tap_sel].img);
690         tpc->w[0] |= w0_offline;
691         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
692         update_interrupt(device);
695693         goto update_registers;
696694      }
697695
698      if (image_fread(tpc.t[tap_sel].img, buffer, 4) != 4)
696      if (image_fread(tpc->t[tap_sel].img, buffer, 4) != 4)
699697      {   /* eject tape */
700         image_unload(tpc.t[tap_sel].img);
701         tpc.w[0] |= w0_offline;
702         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
703         update_interrupt(machine);
698         image_unload(tpc->t[tap_sel].img);
699         tpc->w[0] |= w0_offline;
700         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
701         update_interrupt(device);
704702         goto update_registers;
705703      }
706704      if (reclen != ((((int) buffer[1]) << 8) | buffer[0]))
707705      {   /* eject tape */
708         image_unload(tpc.t[tap_sel].img);
709         tpc.w[0] |= w0_offline;
710         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
711         update_interrupt(machine);
706         image_unload(tpc->t[tap_sel].img);
707         tpc->w[0] |= w0_offline;
708         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
709         update_interrupt(device);
712710         goto update_registers;
713711      }
714712      if (buffer[2] || buffer[3])
715713      {   /* no idea what these bytes mean */
716714         logerror("Tape format looks gooofy\n");
717715         /* eject tape to avoid catastrophes */
718         image_unload(tpc.t[tap_sel].img);
719         tpc.w[0] |= w0_offline;
720         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
721         update_interrupt(machine);
716         image_unload(tpc->t[tap_sel].img);
717         tpc->w[0] |= w0_offline;
718         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
719         update_interrupt(device);
722720         goto update_registers;
723721      }
724722
725      if (image_fseek(tpc.t[tap_sel].img, -4, SEEK_CUR))
723      if (image_fseek(tpc->t[tap_sel].img, -4, SEEK_CUR))
726724      {   /* eject tape */
727         image_unload(tpc.t[tap_sel].img);
728         tpc.w[0] |= w0_offline;
729         tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
730         update_interrupt(machine);
725         image_unload(tpc->t[tap_sel].img);
726         tpc->w[0] |= w0_offline;
727         tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
728         update_interrupt(device);
731729         goto update_registers;
732730      }
733731
734732      record_count--;
735733   }
736734
737   tpc.w[7] |= w7_idle | w7_complete;
738   update_interrupt(machine);
735   tpc->w[7] |= w7_idle | w7_complete;
736   update_interrupt(device);
739737
740738update_registers:
741   tpc.w[4] = record_count;
739   tpc->w[4] = record_count;
742740}
743741
744742/*
745743    Handle the rewind command: rewind to BOT.
746744*/
747static void cmd_rewind(running_machine *machine)
745static void cmd_rewind(const device_config *device)
748746{
749   int tap_sel = cur_tape_unit();
747   tap_990_t *tpc = get_safe_token(device);
748   int tap_sel = cur_tape_unit(device);
750749
751750   if (tap_sel == -1)
752751   {
753752      /* No idea what to report... */
754      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
755      update_interrupt(machine);
753      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
754      update_interrupt(device);
756755      return;
757756   }
758   else if (! image_exists(tpc.t[tap_sel].img))
757   else if (! image_exists(tpc->t[tap_sel].img))
759758   {   /* offline */
760      tpc.w[0] |= w0_offline;
761      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
762      update_interrupt(machine);
759      tpc->w[0] |= w0_offline;
760      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
761      update_interrupt(device);
763762      return;
764763   }
765764#if 0
766765   else if (0)
767766   {   /* rewind in progress */
768      tpc.w[0] |= 0x80 >> tap_sel;
769      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
770      update_interrupt(machine);
767      tpc->w[0] |= 0x80 >> tap_sel;
768      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
769      update_interrupt(device);
771770      return;
772771   }
773772#endif
774773
775   tpc.t[tap_sel].eot = 0;
774   tpc->t[tap_sel].eot = 0;
776775
777   if (image_fseek(tpc.t[tap_sel].img, 0, SEEK_SET))
776   if (image_fseek(tpc->t[tap_sel].img, 0, SEEK_SET))
778777   {   /* eject tape */
779      image_unload(tpc.t[tap_sel].img);
780      tpc.w[0] |= w0_offline;
781      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
782      update_interrupt(machine);
778      image_unload(tpc->t[tap_sel].img);
779      tpc->w[0] |= w0_offline;
780      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
781      update_interrupt(device);
783782      return;
784783   }
785   tpc.t[tap_sel].bot = 1;
784   tpc->t[tap_sel].bot = 1;
786785
787   tpc.w[7] |= w7_idle | w7_complete;
788   update_interrupt(machine);
786   tpc->w[7] |= w7_idle | w7_complete;
787   update_interrupt(device);
789788}
790789
791790/*
792791    Handle the rewind and offline command: disable the tape unit.
793792*/
794static void cmd_rewind_and_offline(running_machine *machine)
793static void cmd_rewind_and_offline(const device_config *device)
795794{
796   int tap_sel = cur_tape_unit();
795   tap_990_t *tpc = get_safe_token(device);
796   int tap_sel = cur_tape_unit(device);
797797
798798   if (tap_sel == -1)
799799   {
800800      /* No idea what to report... */
801      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
802      update_interrupt(machine);
801      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
802      update_interrupt(device);
803803      return;
804804   }
805   else if (! image_exists(tpc.t[tap_sel].img))
805   else if (! image_exists(tpc->t[tap_sel].img))
806806   {   /* offline */
807      tpc.w[0] |= w0_offline;
808      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
809      update_interrupt(machine);
807      tpc->w[0] |= w0_offline;
808      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
809      update_interrupt(device);
810810      return;
811811   }
812812#if 0
813813   else if (0)
814814   {   /* rewind in progress */
815      tpc.w[0] |= 0x80 >> tap_sel;
816      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
817      update_interrupt(machine);
815      tpc->w[0] |= 0x80 >> tap_sel;
816      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
817      update_interrupt(device);
818818      return;
819819   }
820820#endif
821821
822822   /* eject tape */
823   image_unload(tpc.t[tap_sel].img);
823   image_unload(tpc->t[tap_sel].img);
824824
825   tpc.w[7] |= w7_idle | w7_complete;
826   update_interrupt(machine);
825   tpc->w[7] |= w7_idle | w7_complete;
826   update_interrupt(device);
827827}
828828
829829/*
830830    Handle the read transport status command: return the current tape status.
831831*/
832static void read_transport_status(running_machine *machine)
832static void read_transport_status(const device_config *device)
833833{
834   int tap_sel = cur_tape_unit();
834   tap_990_t *tpc = get_safe_token(device);
835   int tap_sel = cur_tape_unit(device);
835836
836837   if (tap_sel == -1)
837838   {
838839      /* No idea what to report... */
839      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
840      update_interrupt(machine);
840      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
841      update_interrupt(device);
841842   }
842   else if (! image_exists(tpc.t[tap_sel].img))
843   else if (! image_exists(tpc->t[tap_sel].img))
843844   {   /* offline */
844      tpc.w[0] |= w0_offline;
845      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
846      update_interrupt(machine);
845      tpc->w[0] |= w0_offline;
846      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
847      update_interrupt(device);
847848   }
848849#if 0
849850   else if (0)
850851   {   /* rewind in progress */
851      tpc.w[0] |= /*...*/;
852      tpc.w[7] |= w7_idle | w7_error | w7_tape_error;
853      update_interrupt(machine);
852      tpc->w[0] |= /*...*/;
853      tpc->w[7] |= w7_idle | w7_error | w7_tape_error;
854      update_interrupt(device);
854855   }
855856#endif
856857   else
857858   {   /* no particular error condition */
858      if (tpc.t[tap_sel].bot)
859         tpc.w[0] |= w0_BOT;
860      if (tpc.t[tap_sel].eot)
861         tpc.w[0] |= w0_EOT;
862      if (tpc.t[tap_sel].wp)
863         tpc.w[0] |= w0_write_ring;
864      tpc.w[7] |= w7_idle | w7_complete;
865      update_interrupt(machine);
859      if (tpc->t[tap_sel].bot)
860         tpc->w[0] |= w0_BOT;
861      if (tpc->t[tap_sel].eot)
862         tpc->w[0] |= w0_EOT;
863      if (tpc->t[tap_sel].wp)
864         tpc->w[0] |= w0_write_ring;
865      tpc->w[7] |= w7_idle | w7_complete;
866      update_interrupt(device);
866867   }
867868}
868869
869870/*
870871    Parse command code and execute the command.
871872*/
872static void execute_command(running_machine *machine)
873static void execute_command(const device_config *device)
873874{
874875   /* hack */
875   tpc.w[0] &= 0xff;
876   tap_990_t *tpc = get_safe_token(device);
877   tpc->w[0] &= 0xff;
876878
877   switch ((tpc.w[6] & w6_command) >> 8)
879   switch ((tpc->w[6] & w6_command) >> 8)
878880   {
879881   case 0x00:
880882   case 0x0C:
881883   case 0x0E:
882884      /* NOP */
883885      logerror("NOP\n");
884      tpc.w[7] |= w7_idle | w7_complete;
885      update_interrupt(machine);
886      tpc->w[7] |= w7_idle | w7_complete;
887      update_interrupt(device);
886888      break;
887889   case 0x01:
888890      /* buffer sync: means nothing under emulation */
889891      logerror("buffer sync\n");
890      tpc.w[7] |= w7_idle | w7_complete;
891      update_interrupt(machine);
892      tpc->w[7] |= w7_idle | w7_complete;
893      update_interrupt(device);
892894      break;
893895   case 0x02:
894896      /* write EOF - not emulated */
895897      logerror("write EOF\n");
896898      /* ... */
897      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
898      update_interrupt(machine);
899      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
900      update_interrupt(device);
899901      break;
900902   case 0x03:
901903      /* record skip reverse - not fully tested */
902904      logerror("record skip reverse\n");
903      cmd_record_skip_reverse(machine);
905      cmd_record_skip_reverse(device);
904906      break;
905907   case 0x04:
906908      /* read binary forward */
907909      logerror("read binary forward\n");
908      cmd_read_binary_forward(machine);
910      cmd_read_binary_forward(device);
909911      break;
910912   case 0x05:
911913      /* record skip forward - not tested */
912914      logerror("record skip forward\n");
913      cmd_record_skip_forward(machine);
915      cmd_record_skip_forward(device);
914916      break;
915917   case 0x06:
916918      /* write binary forward - not emulated */
917919      logerror("write binary forward\n");
918920      /* ... */
919      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
920      update_interrupt(machine);
921      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
922      update_interrupt(device);
921923      break;
922924   case 0x07:
923925      /* erase - not emulated */
924926      logerror("erase\n");
925927      /* ... */
926      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
927      update_interrupt(machine);
928      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
929      update_interrupt(device);
928930      break;
929931   case 0x08:
930932   case 0x09:
931933      /* read transport status */
932934      logerror("read transport status\n");
933      read_transport_status(machine);
935      read_transport_status(device);
934936      break;
935937   case 0x0A:
936938      /* rewind - not tested */
937939      logerror("rewind\n");
938      cmd_rewind(machine);
940      cmd_rewind(device);
939941      break;
940942   case 0x0B:
941943      /* rewind and offline - not tested */
942944      logerror("rewind and offline\n");
943      cmd_rewind_and_offline(machine);
945      cmd_rewind_and_offline(device);
944946      break;
945947   case 0x0F:
946948      /* extended control and status - not emulated */
947949      logerror("extended control and status\n");
948950      /* ... */
949      tpc.w[7] |= w7_idle | w7_error | w7_hard_error;
950      update_interrupt(machine);
951      tpc->w[7] |= w7_idle | w7_error | w7_hard_error;
952      update_interrupt(device);
951953      break;
952954   }
953955}
r6748r6749
956958/*
957959    Read one register in TPCS space
958960*/
959READ16_HANDLER(ti990_tpc_r)
961READ16_DEVICE_HANDLER(ti990_tpc_r)
960962{
963   tap_990_t *tpc = get_safe_token(device);
961964   if ((offset >= 0) && (offset < 8))
962      return tpc.w[offset];
965      return tpc->w[offset];
963966   else
964967      return 0;
965968}
r6748r6749
967970/*
968971    Write one register in TPCS space.  Execute command if w7_idle is cleared.
969972*/
970WRITE16_HANDLER(ti990_tpc_w)
973WRITE16_DEVICE_HANDLER(ti990_tpc_w)
971974{
975   tap_990_t *tpc = get_safe_token(device);
972976   if ((offset >= 0) && (offset < 8))
973977   {
974978      /* write protect if a command is in progress */
975      if (tpc.w[7] & w7_idle)
979      if (tpc->w[7] & w7_idle)
976980      {
977         UINT16 old_data = tpc.w[offset];
981         UINT16 old_data = tpc->w[offset];
978982
979983         /* Only write writable bits AND honor byte accesses (ha!) */
980         tpc.w[offset] = (tpc.w[offset] & ((~w_mask[offset]) | mem_mask)) | (data & w_mask[offset] & ~mem_mask);
984         tpc->w[offset] = (tpc->w[offset] & ((~w_mask[offset]) | mem_mask)) | (data & w_mask[offset] & ~mem_mask);
981985
982986         if ((offset == 0) || (offset == 7))
983            update_interrupt(space->machine);
987            update_interrupt(device);
984988
985989         if ((offset == 7) && (old_data & w7_idle) && ! (data & w7_idle))
986990         {   /* idle has been cleared: start command execution */
987            execute_command(space->machine);
991            execute_command(device);
988992         }
989993      }
990994   }
991995}
996
997DEVICE_GET_INFO( ti990_tape )
998{
999   switch (state)
1000   {
1001      /* --- the following bits of info are returned as 64-bit signed integers --- */
1002      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                    break;
1003      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(ti990_tape_t);                        break;
1004      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                     break;
1005      case DEVINFO_INT_IMAGE_TYPE:               info->i = IO_MAGTAPE;                               break;
1006      case DEVINFO_INT_IMAGE_READABLE:            info->i = 1;                                     break;
1007      case DEVINFO_INT_IMAGE_WRITEABLE:            info->i = 1;                                    break;
1008      case DEVINFO_INT_IMAGE_CREATABLE:            info->i = 0;                                     break;     
1009
1010      /* --- the following bits of info are returned as pointers to data or functions --- */
1011      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(ti990_tape);                break;
1012      case DEVINFO_FCT_IMAGE_LOAD:               info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(ti990_tape);       break;
1013      case DEVINFO_FCT_IMAGE_UNLOAD:               info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(ti990_tape);       break;
1014     
1015      case DEVINFO_STR_IMAGE_FILE_EXTENSIONS:         strcpy(info->s, "tap");                            break;
1016      /* --- the following bits of info are returned as NULL-terminated strings --- */
1017      case DEVINFO_STR_NAME:                     strcpy(info->s, "TI990 Magnetic Tape");         break;
1018      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Magnetic Tape");               break;
1019      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
1020      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
1021      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
1022   }
1023}
1024#define TI990_TAPE      DEVICE_GET_INFO_NAME(ti990_tape)
1025
1026#define MDRV_TI990_TAPE_ADD(_tag)   \
1027   MDRV_DEVICE_ADD((_tag),  TI990_TAPE, 0)
1028
1029   
1030static MACHINE_DRIVER_START( tap_990 )
1031   MDRV_TI990_TAPE_ADD("tape0")
1032   MDRV_TI990_TAPE_ADD("tape1")
1033   MDRV_TI990_TAPE_ADD("tape2")
1034   MDRV_TI990_TAPE_ADD("tape3")
1035MACHINE_DRIVER_END
1036
1037/*
1038    Init the tape controller core
1039*/
1040DEVICE_START(tap_990)
1041{
1042   tap_990_t *tpc = get_safe_token(device);
1043   /* verify that we have an interface assigned */
1044   assert(device->static_config != NULL);
1045   
1046   /* copy interface pointer */
1047   tpc->intf = device->static_config;
1048   
1049   memset(tpc->w, 0, sizeof(tpc->w));
1050   /* The PE bit is always set for the MT3200 (but not MT1600) */
1051   /* According to MT3200 manual, w7 bit #4 (reserved) is always set */
1052   tpc->w[7] = w7_idle /*| w7_PE_format*/ | 0x0800;
1053
1054   update_interrupt(device);
1055}
1056
1057
1058DEVICE_GET_INFO( tap_990 )
1059{
1060   switch (state)
1061   {
1062      /* --- the following bits of info are returned as 64-bit signed integers --- */
1063      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                    break;
1064      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(tap_990_t);                        break;
1065      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                     break;
1066
1067      /* --- the following bits of info are returned as pointers --- */
1068      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_DRIVER_NAME(tap_990);      break;
1069
1070      /* --- the following bits of info are returned as pointers to data or functions --- */
1071      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(tap_990);               break;
1072      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
1073
1074      /* --- the following bits of info are returned as NULL-terminated strings --- */
1075      case DEVINFO_STR_NAME:                     strcpy(info->s, "Generic TI990 Tape Controller");                        break;
1076      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "TI990 Tape Controller");                        break;
1077      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
1078      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
1079      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
1080   }
1081}
1082
src/mess/machine/990_tap.h
r6748r6749
11/*
22    990_tap.h: include file for 990_tap.c
33*/
4extern READ16_DEVICE_HANDLER(ti990_tpc_r);
5extern WRITE16_DEVICE_HANDLER(ti990_tpc_w);
46
5DEVICE_START( ti990_tape );
6DEVICE_IMAGE_LOAD( ti990_tape );
7DEVICE_IMAGE_UNLOAD( ti990_tape );
7/***************************************************************************
8    TYPE DEFINITIONS
9***************************************************************************/
810
9void ti990_tpc_init(running_machine *machine, void (*interrupt_callback)(running_machine *machine, int state));
11typedef struct _ti990_tpc_interface ti990_tpc_interface;
12struct _ti990_tpc_interface
13{
14   void (*interrupt_callback)(running_machine *machine, int state);
15};
16/***************************************************************************
17    MACROS
18***************************************************************************/
1019
11extern READ16_HANDLER(ti990_tpc_r);
12extern WRITE16_HANDLER(ti990_tpc_w);
20#define TI990_TAPE_CTRL      DEVICE_GET_INFO_NAME(tap_990)
1321
22#define MDRV_TI990_TAPE_CTRL_ADD(_tag, _intrf)   \
23   MDRV_DEVICE_ADD((_tag),  TI990_TAPE_CTRL, 0)\
24   MDRV_DEVICE_CONFIG(_intrf)
25
26/***************************************************************************
27    FUNCTION PROTOTYPES
28***************************************************************************/
29
30DEVICE_GET_INFO(tap_990);
src/mess/drivers/ti990_10.c
r6748r6749
8181   MACHINE_START_CALL( ti990_hdc );
8282}
8383
84
8584static MACHINE_RESET( ti990_10 )
8685{
8786   ti990_hold_load(machine);
8887
8988   ti990_reset_int();
9089
91   ti990_tpc_init(machine, ti990_set_int9);
9290   ti990_hdc_init(machine, ti990_set_int13);
9391}
9492
r6748r6749
158156   AM_RANGE(0x100000, 0x1ff7ff) AM_NOP      /* free TILINE space */
159157   AM_RANGE(0x1ff800, 0x1ff81f) AM_READWRITE(ti990_hdc_r, ti990_hdc_w)   /* disk controller TPCS */
160158   AM_RANGE(0x1ff820, 0x1ff87f) AM_NOP      /* free TPCS */
161   AM_RANGE(0x1ff880, 0x1ff89f) AM_READWRITE(ti990_tpc_r, ti990_tpc_w)   /* tape controller TPCS */
159   AM_RANGE(0x1ff880, 0x1ff89f) AM_DEVREADWRITE("tpc",ti990_tpc_r, ti990_tpc_w)   /* tape controller TPCS */
162160   AM_RANGE(0x1ff8a0, 0x1ffbff) AM_NOP      /* free TPCS */
163161   AM_RANGE(0x1ffc00, 0x1fffff) AM_ROM      /* LOAD ROM */
164162
r6748r6749
191189   ti990_set_int2
192190};
193191
192static const ti990_tpc_interface ti990_tpc =
193{
194   ti990_set_int9
195};
194196
195
196197static MACHINE_DRIVER_START(ti990_10)
197198   /* basic machine hardware */
198199   /* TI990/10 CPU @ 4.0(???) MHz */
r6748r6749
227228   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
228229
229230   MDRV_IMPORT_FROM( ti990_hdc )
231   
232   MDRV_TI990_TAPE_CTRL_ADD("tpc",ti990_tpc)
230233MACHINE_DRIVER_END
231234
232235
r6748r6749
289292   VDT911_KEY_PORTS
290293INPUT_PORTS_END
291294
292
293static void ti990_10_cassette_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
294{
295   /* cassette */
296   switch(state)
297   {
298      /* --- the following bits of info are returned as 64-bit signed integers --- */
299      case MESS_DEVINFO_INT_TYPE:                     info->i = IO_MAGTAPE; break;
300      case MESS_DEVINFO_INT_READABLE:                  info->i = 1; break;
301      case MESS_DEVINFO_INT_WRITEABLE:                  info->i = 1; break;
302      case MESS_DEVINFO_INT_CREATABLE:                  info->i = 0; break;
303      case MESS_DEVINFO_INT_COUNT:                     info->i = 4; break;
304
305      /* --- the following bits of info are returned as pointers to data or functions --- */
306      case MESS_DEVINFO_PTR_START:                     info->start = DEVICE_START_NAME(ti990_tape); break;
307      case MESS_DEVINFO_PTR_LOAD:                     info->load = DEVICE_IMAGE_LOAD_NAME(ti990_tape); break;
308      case MESS_DEVINFO_PTR_UNLOAD:                  info->unload = DEVICE_IMAGE_UNLOAD_NAME(ti990_tape); break;
309
310      /* --- the following bits of info are returned as NULL-terminated strings --- */
311      case MESS_DEVINFO_STR_FILE_EXTENSIONS:            strcpy(info->s = device_temp_str(), "tap"); break;
312   }
313}
314
315static SYSTEM_CONFIG_START(ti990_10)
316   CONFIG_DEVICE(ti990_10_cassette_getinfo)
317SYSTEM_CONFIG_END
318
319295/*    YEAR  NAME        PARENT  COMPAT  MACHINE     INPUT       INIT        CONFIG      COMPANY                 FULLNAME */
320COMP( 1975,   ti990_10,   0,      0,      ti990_10,   ti990_10,   ti990_10,   ti990_10,   "Texas Instruments",   "TI Model 990/10 Minicomputer System" , GAME_NOT_WORKING )
296COMP( 1975,   ti990_10,   0,      0,      ti990_10,   ti990_10,   ti990_10,   0,   "Texas Instruments",   "TI Model 990/10 Minicomputer System" , GAME_NOT_WORKING )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team