Previous 15994 Revisions Next

r9672 Saturday 27th November, 2010 at 03:02:01 UTC by Barry Rodewald
[PCW] Improved printer MCU hookup.
[src/mess/drivers]pcw.c

src/mess/drivers/pcw.c
r9671r9672
130130static UINT8 pcw_printer_command;
131131static UINT8 pcw_printer_data;
132132static UINT8 pcw_printer_status;
133static UINT8 pcw_printer_headpos; // non-zero if not at left margin
133134
134135static UINT16 pcw_kb_scan_row;
135136
r9671r9672
385386   /* check interrupts */
386387   pcw_update_irqs(space->machine);
387388   /* return data */
388   LOG(("SYS: IRQ counter read, returning %02x\n",data));
389   //LOG(("SYS: IRQ counter read, returning %02x\n",data));
389390   return data;
390391}
391392
r9671r9672
677678{
678679   pcw_printer_data = data;
679680   upi41_master_w(space->machine->device("printer_mcu"),0,data);
680   logerror("PRN: Sent data %02x\n",data);
681   logerror("PRN [0xFC]: Sent command %02x\n",data);
681682}
682683
683684static WRITE8_HANDLER(pcw_printer_command_w)
684685{
685686   pcw_printer_command = data;
686687   upi41_master_w(space->machine->device("printer_mcu"),1,data);
687   logerror("PRN: Sent command %02x\n",data);
688   logerror("PRN [0xFD]: Sent command %02x\n",data);
688689}
689690
691// print error type
692// should return 0xF8 if there are no errors
693// 0 = underrun
694// 1 = printer controller RAM fault
695// 3 = bad command
696// 5 = print error
697// anything else = no printer
690698static  READ8_HANDLER(pcw_printer_data_r)
691699{
692//  pcw_printer_data = 0xf8;
693   pcw_printer_data = upi41_master_r(space->machine->device("printer_mcu"),0);
694   return pcw_printer_data;
700   return upi41_master_r(space->machine->device("printer_mcu"),0);
695701}
696702
703// printer status
704// bit 7 - bail bar in
705// bit 6 - not currently executing a command
706// bit 5 - always 0 for dot matrix printer (PCW8256/8512), 1 if a daisywheel printer(PCW9512)
707// bit 4 - print head is not at left margin
708// bit 3 - sheet feeder is present
709// bit 2 - paper is present
710// bit 1 - busy
711// bit 0 - controller fault
697712static  READ8_HANDLER(pcw_printer_status_r)
698713{
699   pcw_printer_status = upi41_master_r(space->machine->device("printer_mcu"),1);
700   return pcw_printer_status;
714   return upi41_master_r(space->machine->device("printer_mcu"),1);
701715}
702716
703#ifdef UNUSED_FUNCTION
704717/* MCU handlers */
705static READ8_HANDLER(mcu_printer_data_r)
718static READ8_HANDLER(mcu_printer_p1_r)
706719{
707   return pcw_printer_data;
720//   logerror("PRN: MCU reading data from P1\n");
721   return 0x00;
708722}
709723
710static WRITE8_HANDLER(mcu_printer_data_w)
724static WRITE8_HANDLER(mcu_printer_p1_w)
711725{
712   pcw_printer_data = data;
726   logerror("PRN: MCU writing %02x to P1\n",data);
713727}
714#endif
715728
716static READ8_HANDLER(mcu_printer_command_r)
729static READ8_HANDLER(mcu_printer_p2_r)
717730{
718   return pcw_printer_command;
731   UINT8 ret = 0x00;
732//   logerror("PRN: MCU reading data from P2\n");
733   ret |= 0x80;
734   return ret;
719735}
720736
737static WRITE8_HANDLER(mcu_printer_p2_w)
738{
739//   logerror("PRN: MCU writing %02x to P2\n",data);
740   if((data & 0x20) == 0)
741      pcw_printer_headpos = 1;  // move head
742   if((data & 0x10) == 0)
743      pcw_printer_headpos = 0;
744}
745
746// Paper sensor?
747static READ8_HANDLER(mcu_printer_t1_r)
748{
749   return 1;
750}
751
752// Print head location? (0 if at left margin, otherwise 1)
753static READ8_HANDLER(mcu_printer_t0_r)
754{
755   return pcw_printer_headpos;
756}
757
721758/*
722759 *  Keyboard MCU (i8048)
723760 *  P1 = keyboard scan row select (low 8 bits)
r9671r9672
837874   logerror("pcw9512 parallel w: offs: %04x data: %02x\n",offset,data);
838875}
839876
840static WRITE8_DEVICE_HANDLER(pcw_printer_output_w)
841{
842   // TODO: figure out the outputs and how it sends the initial Z80 code to the data bus.
843   logerror("PRN: MCU write to P7: offset %i, data %02x\n",offset,data);
844}
845
846877static ADDRESS_MAP_START(pcw_io, ADDRESS_SPACE_IO, 8)
847878   ADDRESS_MAP_GLOBAL_MASK(0xff)
848879   AM_RANGE(0x000, 0x07f) AM_READWRITE(pcw_fdc_r,               pcw_fdc_w)
r9671r9672
874905
875906/* i8041 MCU */
876907static ADDRESS_MAP_START(pcw_printer_io, ADDRESS_SPACE_IO, 8)
877   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READ(mcu_printer_command_r)
878//  AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(mcu_printer_data_r, mcu_printer_data_w)
879//  AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READ(mcu_printer_p2_r)
880   AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_DEVWRITE("printer_8243",i8243_prog_w)
908   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READWRITE(mcu_printer_p2_r,mcu_printer_p2_w)
909   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(mcu_printer_p1_r, mcu_printer_p1_w)
910   AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(mcu_printer_t1_r)
911   AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(mcu_printer_t0_r)
881912ADDRESS_MAP_END
882913
883914static ADDRESS_MAP_START(pcw_keyboard_io, ADDRESS_SPACE_IO, 8)
r9671r9672
933964   pcw_printer_status = 0xff;
934965   pcw_printer_command = 0xff;
935966   pcw_printer_data = 0x00;
967   pcw_printer_headpos = 0x00; // bring printer head to left margin
936968}
937969
938970static DRIVER_INIT(pcw)
r9671r9672
11721204   MDRV_CPU_ADD("keyboard_mcu", I8048, 5000000) // 5MHz
11731205   MDRV_CPU_IO_MAP(pcw_keyboard_io)
11741206
1175   MDRV_I8243_ADD("printer_8243", NULL, pcw_printer_output_w)
1176
11771207   MDRV_MACHINE_START(pcw)
11781208   MDRV_MACHINE_RESET(pcw)
11791209

Previous 15994 Revisions Next


© 1998-2018 The MESS Team