Previous 15994 Revisions Next

r3473 Monday 20th October, 2008 at 10:24:21 UTC by Robbbert
[SUPER80] Added Centronics printer.
[src/mess/drivers]super80.c

src/mess/drivers/super80.c
r3472r3473
88#include "devices/cassette.h"
99#include "devices/z80bin.h"
1010#include "sound/speaker.h"
11#include "machine/centroni.h"
12#include "devices/printer.h"
1113
1214static UINT8 super80_mhz=2;   /* state of bit 2 of port F0 */
1315static UINT16 vidpg=0xfe00;   /* Home position of video page being displayed */
r3472r3473
414416
415417static UINT8 cass_data[]={ 0, 0, 0, 0 };
416418
417/* this timer runs at 200khz and does 1 job:
418   1. Emulate the 2 chips in the cassette input circuit
419/*   This timer runs at 200khz and emulates the 2 chips in the cassette input circuit
420   They are U79 CD4046BCN PLL chip and U1 LM311P op-amp. U79 converts a frequency to a voltage,
421   and U1 amplifies that voltage to digital levels. U1 has a trimpot connected, to set the midpoint.
419422
420Reasons why it is necessary:
421   1. This "emulates" U79 CD4046BCN PLL chip and U1 LM311P op-amp. U79 converts a frequency to a voltage,
422   and U1 amplifies that voltage to digital levels. U1 has a trimpot connected, to set the midpoint. */
423   The MDS homebrew input circuit consists of 2 op-amps followed by a D-flipflop.
424   My "read-any-system" cassette circuit was a CA3140 op-amp, the smarts being done in software.
423425
426   bit 0 = original system (U79 and U1)
427   bit 1 = MDS fast system
428   bit 2 = CA3140 */
429
424430static TIMER_CALLBACK( super80_timer )
425431{
426432   UINT8 cass_ws=0;
r3472r3473
430436
431437   if (cass_ws != cass_data[0])
432438   {
433      if (cass_ws) cass_data[3] ^= 2;
439      if (cass_ws) cass_data[3] ^= 2;                  // the MDS flipflop
434440      cass_data[0] = cass_ws;
435441      cass_data[2] = ((cass_data[1] < 0x40) ? 1 : 0) | cass_ws | cass_data[3];
436442      cass_data[1] = 0;
437443   }
438444}
439445
446/*************************************** PRINTER ********************************************************/
447
448/* The Super80 had an optional I/O card that plugged into the S-100 slot. The card had facility for running
449   an 8-bit Centronics printer, and a serial device at 300, 600, or 1200 baud. The I/O address range
450   was selectable via 4 dipswitches. The serial parameters (baud rate, parity, stop bits, etc) was
451   chosen with more dipswitches. Regretably, no parameters could be set by software. Currently, the
452   Centronics printer is emulated; the serial side of things may be done later, as will the dipswitches.
453
454   The most commonly used I/O range is DC-DE (DC = centronics, DD = serial data, DE = serial control
455   All the home-brew roms use this, except for super80e which uses BC-BE (which we don't support yet). */
456
457static void super80_printer_handshake_in(int number, int data, int mask)
458{
459   if (mask & CENTRONICS_ACKNOWLEDGE)
460   {
461      if (data & CENTRONICS_ACKNOWLEDGE)
462      {
463      }
464   }
465}
466
467static const CENTRONICS_CONFIG super80_cent_config[1]={
468   {
469      PRINTER_CENTRONICS,
470      super80_printer_handshake_in
471   },
472};
473
474static const device_config *printer_device(running_machine *machine)
475{
476   return device_list_find_by_tag(machine->config->devicelist, PRINTER, "printer");
477}
478
479
440480/**************************** I/O PORTS *****************************************************************/
441481
442482static READ8_HANDLER( super80v_11_r )
r3472r3473
447487      return 0;
448488}
449489
490static READ8_HANDLER( super80_dc_r )
491{
492   UINT8 data=0x7f;
493
494   /* bit 7 = printer busy
495   0 = printer is not busy */
496
497   if (printer_is_ready(printer_device(machine))==0 )
498      data |= 0x80;
499
500   return data;
501}
502
450503static READ8_HANDLER( super80_f2_r )
451504{
452505   UINT8 data = input_port_read(machine, "DSW") & 0xf0;   // dip switches on pcb
453   data |= cass_data[2];         // bit 0 = output of U1, bit 2 = current wave_state
506   data |= cass_data[2];         // bit 0 = output of U1, bit 1 = MDS cass state, bit 2 = current wave_state
454507   data |= 0x08;            // bit 3 - not used
455508   return data;
456509}
r3472r3473
467520   if ((mc6845_ind > 8) && (mc6845_ind < 12)) mc6845_cursor_configure();      /* adjust cursor shape */
468521}
469522
523static WRITE8_HANDLER( super80_dc_w )
524{
525   /* hardware strobe driven from port select, bit 7..0 = data */
526   centronics_write_handshake(0, CENTRONICS_SELECT | CENTRONICS_NO_RESET, CENTRONICS_SELECT| CENTRONICS_NO_RESET);
527   centronics_write_handshake(0, 1, CENTRONICS_STROBE);
528   centronics_write_data(0, data);
529   centronics_write_handshake(0, 0, CENTRONICS_STROBE);
530}
531
470532static UINT8 last_data;
471533
472534static WRITE8_HANDLER( super80_f0_w )
r3472r3473
476538   if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1);      /* bit 5 - LED - scroll lock led is used */
477539   speaker_level_w(0, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
478540   super80_mhz = (data & 4) ? 1 : 2;            /* bit 2 - video on/off */
479   if (bits & 0x02) cassette_motor( machine, data & 2 ? 1 : 0);      /* bit 1 - cassette motor */
480   if (bits & 0x01) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
541   if (bits & 2) cassette_motor( machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
542   if (bits & 1) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
481543
482544   last_data = data;
483545}
r3472r3473
488550
489551   if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1);      /* bit 5 - LED - scroll lock led is used */
490552   speaker_level_w(0, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
491   if (bits & 0x02) cassette_motor( machine, data & 2 ? 1 : 0);      /* bit 1 - cassette motor */
492   if (bits & 0x01) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
553   if (bits & 2) cassette_motor( machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
554   if (bits & 1) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
493555
494556   last_data = data;
495557}
r3472r3473
502564   super80v_rom_pcg = data & 0x10;               /* bit 4 - bankswitch gfx rom or pcg */
503565   speaker_level_w(0, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
504566   super80v_vid_col = data & 4;               /* bit 2 - bankswitch video or colour ram */
505   if (bits & 0x02) cassette_motor( machine, data & 2 ? 1 : 0);      /* bit 1 - cassette motor */
506   if (bits & 0x01) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
567   if (bits & 2) cassette_motor( machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
568   if (bits & 1) cassette_output(cassette_device_image(machine), (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
507569
508570   last_data = data;
509571}
r3472r3473
553615static ADDRESS_MAP_START( super80_io, ADDRESS_SPACE_IO, 8 )
554616   ADDRESS_MAP_GLOBAL_MASK(0xff)
555617   ADDRESS_MAP_UNMAP_HIGH
618   AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w)
556619   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80_f0_w)
557620   AM_RANGE(0xe1, 0xe1) AM_MIRROR(0x14) AM_WRITE(super80_f1_w)
558621   AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r)
r3472r3473
567630   ADDRESS_MAP_UNMAP_HIGH
568631   AM_RANGE(0x10, 0x10) AM_WRITE(super80v_10_w)
569632   AM_RANGE(0x11, 0x11) AM_READWRITE(super80v_11_r, super80v_11_w)
633   AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w)
570634   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80r_f0_w)
571635   AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r)
572636   AM_RANGE(0xf8, 0xf8) AM_MIRROR(0x04) AM_READWRITE(super80_f8_r,super80_f8_w)
r3472r3473
580644   ADDRESS_MAP_UNMAP_HIGH
581645   AM_RANGE(0x10, 0x10) AM_WRITE(super80v_10_w)
582646   AM_RANGE(0x11, 0x11) AM_READWRITE(super80v_11_r, super80v_11_w)
647   AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w)
583648   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80v_f0_w)
584649   AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r)
585650   AM_RANGE(0xf8, 0xf8) AM_MIRROR(0x04) AM_READWRITE(super80_f8_r,super80_f8_w)
r3472r3473
9351000static MACHINE_RESET( super80 )
9361001{
9371002   super80_z80pio = device_list_find_by_tag( machine->config->devicelist, Z80PIO, "z80pio" );
1003   centronics_config(0, super80_cent_config);
1004   /* assumption: select is tied low */
1005   centronics_write_handshake(0, CENTRONICS_SELECT | CENTRONICS_NO_RESET, CENTRONICS_SELECT| CENTRONICS_NO_RESET);
9381006   timer_set(ATTOTIME_IN_USEC(10), NULL, 0, super80_reset);
9391007   memory_set_bank(1, 1);
9401008}
r3472r3473
9741042   MDRV_SOUND_ADD("speaker", SPEAKER, 0)
9751043   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
9761044
1045   /* printer */
1046   MDRV_DEVICE_ADD("printer", PRINTER)
1047
9771048   /* quickload */
9781049   MDRV_Z80BIN_QUICKLOAD_ADD(default, 1)
9791050
r3472r3473
10271098   MDRV_SOUND_ADD("speaker", SPEAKER, 0)
10281099   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
10291100
1101   /* printer */
1102   MDRV_DEVICE_ADD("printer", PRINTER)
1103
10301104   /* quickload */
10311105   MDRV_Z80BIN_QUICKLOAD_ADD(default, 1)
10321106

Previous 15994 Revisions Next


© 1998-2018 The MESS Team