Previous 15994 Revisions Next

r6249 Monday 2nd November, 2009 at 10:56:07 UTC by Curt Coder
[PC8801] Refactored to use the new I8255A device.
[src/mess/drivers]pc8801.c
[src/mess/includes]pc8801.h
[src/mess/machine]pc8801.c

src/mess/includes/pc8801.h
r6248r6249
1212
1313/*----------- defined in machine/pc8801.c -----------*/
1414
15extern const ppi8255_interface pc8801_8255_config_0;
16extern const ppi8255_interface pc8801_8255_config_1;
15extern const i8255a_interface pc8801_8255_config_0;
16extern const i8255a_interface pc8801_8255_config_1;
1717extern const upd765_interface pc8801_fdc_interface;
1818
1919WRITE8_HANDLER(pc8801_write_interrupt_level);
src/mess/machine/pc8801.c
r6248r6249
1616***************************************************************************/
1717
1818#include "driver.h"
19#include "machine/8255ppi.h"
19#include "machine/i8255a.h"
2020#include "includes/pc8801.h"
2121#include "machine/upd765.h"
2222#include "sound/beep.h"
r6248r6249
722722
723723/* 5 inch floppy drive */
724724
725static UINT8 load_8255_A(running_machine *machine, int chip)
725static UINT8 i8255_0_pc, i8255_1_pc;
726
727static READ8_DEVICE_HANDLER( cpu_8255_c_r )
726728{
727   return use_5FD ? ppi8255_get_port_b(devtag_get_device(machine, chip? "ppi8255_0" : "ppi8255_1" ) ) : 0xff;
729   return i8255_1_pc >> 4;
728730}
729731
730static UINT8 load_8255_B(running_machine *machine, int chip)
732static WRITE8_DEVICE_HANDLER( cpu_8255_c_w )
731733{
732   return use_5FD ? ppi8255_get_port_a(devtag_get_device(machine, chip? "ppi8255_0" : "ppi8255_1" ) ) : 0xff;
734   i8255_0_pc = data;
733735}
734736
735static UINT8 load_8255_C(running_machine *machine, int chip)
737I8255A_INTERFACE( pc8801_8255_config_0 )
736738{
737   UINT8 result = 0xFF;
738   UINT8 port_c;
739   DEVCB_DEVICE_HANDLER("ppi8255_1", i8255a_pb_r),   // Port A read
740   DEVCB_NULL,                     // Port B read
741   DEVCB_HANDLER(cpu_8255_c_r),      // Port C read
742   DEVCB_NULL,                     // Port A write
743   DEVCB_NULL,                     // Port B write
744   DEVCB_HANDLER(cpu_8255_c_w)         // Port C write
745};
739746
740   if (use_5FD)
741   {
742      port_c = ppi8255_get_port_c(devtag_get_device(machine, chip? "ppi8255_0" : "ppi8255_1" ) );
743      result = ((port_c >> 4) & 0x0F) | ((port_c << 4) & 0xF0);
744   }
745
746   /* NPW 11-Feb-2006 - This is a brutal no-good hack to work around bug #759
747     *
748     * The problem is that in MESS 0.96, a regression was introduced that
749     * prevented the PC8801 from booting up.  The source of this regression
750     * was the 8255 PPI rewrite.
751     *
752     * What seems to happen is CPU #0 does a write to 8255 #0 port C at PC=37CF
753     * and this causes a communication to be made to CPU #1.  Under the
754     * previous 8255 code, this write would not actually make it to the the
755     * slave CPU, CPU #1.  After examining the data sheet, all indications are
756     * that the new 8255 behavior is indeed correct.
757     *
758     * So what I'm doing is an ugly hack so that when the slave CPU #1 sees the
759     * value written to it, I actually change this to the previous value,
760     * cloaking the communication.  So the PC8801 now boots up, but hopefully
761     * a correct fix can be made.
762     */
763   if ((chip == 1) && (result == 0xF8))
764      result = 0xF0;
765
766   return result;
747static READ8_DEVICE_HANDLER( fdc_8255_c_r )
748{
749   return i8255_0_pc >> 4;
767750}
768751
769static READ8_DEVICE_HANDLER( load_8255_chip0_A )   { return load_8255_A(device->machine, 0); }
770static READ8_DEVICE_HANDLER( load_8255_chip1_A )   { return load_8255_A(device->machine, 1); }
771static READ8_DEVICE_HANDLER( load_8255_chip0_B )   { return load_8255_B(device->machine, 0); }
772static READ8_DEVICE_HANDLER( load_8255_chip1_B )   { return load_8255_B(device->machine, 1); }
773static READ8_DEVICE_HANDLER( load_8255_chip0_C )   { return load_8255_C(device->machine, 0); }
774static READ8_DEVICE_HANDLER( load_8255_chip1_C )   { return load_8255_C(device->machine, 1); }
775
776
777const ppi8255_interface pc8801_8255_config_0 =
752static WRITE8_DEVICE_HANDLER( fdc_8255_c_w )
778753{
779   DEVCB_HANDLER(load_8255_chip0_A),
780   DEVCB_HANDLER(load_8255_chip0_B),
781   DEVCB_HANDLER(load_8255_chip0_C),
782   DEVCB_NULL,
783   DEVCB_NULL,
784   DEVCB_NULL
785};
754   i8255_1_pc = data;
755}
786756
787const ppi8255_interface pc8801_8255_config_1 =
757I8255A_INTERFACE( pc8801_8255_config_1 )
788758{
789   DEVCB_HANDLER(load_8255_chip1_A),
790   DEVCB_HANDLER(load_8255_chip1_B),
791   DEVCB_HANDLER(load_8255_chip1_C),
792   DEVCB_NULL,
793   DEVCB_NULL,
794   DEVCB_NULL
759   DEVCB_DEVICE_HANDLER("ppi8255_0", i8255a_pb_r),   // Port A read
760   DEVCB_NULL,                     // Port B read
761   DEVCB_HANDLER(fdc_8255_c_r),      // Port C read
762   DEVCB_NULL,                     // Port A write
763   DEVCB_NULL,                     // Port B write
764   DEVCB_HANDLER(fdc_8255_c_w)         // Port C write
795765};
796766
797767READ8_HANDLER(pc8801fd_upd765_tc)
798768{
799  const device_config *fdc = devtag_get_device(space->machine, "upd765");
800  upd765_tc_w(fdc, 1);
801  upd765_tc_w(fdc, 0);
802  return 0;
803}
769   const device_config *fdc = devtag_get_device(space->machine, "upd765");
804770
805/* callback for /INT output from FDC */
806static WRITE_LINE_DEVICE_HANDLER( pc8801_fdc_interrupt )
807{
808    cputag_set_input_line(device->machine, "sub", 0, state ? HOLD_LINE : CLEAR_LINE);
809}
771   upd765_tc_w(fdc, 1);
772   upd765_tc_w(fdc, 0);
810773
811/* callback for /DRQ output from FDC */
812static UPD765_DMA_REQUEST( pc8801_fdc_dma_drq )
813{
774   return 0;
814775}
815776
816const upd765_interface pc8801_fdc_interface=
777const upd765_interface pc8801_fdc_interface =
817778{
818   DEVCB_LINE(pc8801_fdc_interrupt),
819   pc8801_fdc_dma_drq,
779   DEVCB_CPU_INPUT_LINE("sub", INPUT_LINE_IRQ0),
820780   NULL,
781   NULL,
821782   UPD765_RDY_PIN_CONNECTED,
822   {FLOPPY_0, FLOPPY_1, NULL, NULL}
783   { FLOPPY_0, FLOPPY_1, NULL, NULL }
823784};
824785
825786static void pc8801_init_5fd(running_machine *machine)
r6248r6249
830791   else
831792      cputag_resume(machine, "sub", SUSPEND_REASON_DISABLE);
832793   cpu_set_input_line_vector(cputag_get_cpu(machine, "sub"), 0, 0);
794   
795   logerror("READY 1\n");
833796   floppy_drive_set_motor_state(floppy_get_device(machine, 0), 1);
834797   floppy_drive_set_motor_state(floppy_get_device(machine, 1), 1);
835   floppy_drive_set_ready_state(floppy_get_device(machine, 0), 1,0);
836   floppy_drive_set_ready_state(floppy_get_device(machine, 1), 1,0);
798   floppy_drive_set_ready_state(floppy_get_device(machine, 0), 1, 1);
799   floppy_drive_set_ready_state(floppy_get_device(machine, 1), 1, 1);
837800}
838801
839802/*
src/mess/drivers/pc8801.c
r6248r6249
8585#include "cpu/z80/z80.h"
8686#include "cpu/v30mz/nec.h"
8787#include "sound/beep.h"
88#include "machine/8255ppi.h"
88#include "machine/i8255a.h"
8989#include "includes/pc8801.h"
9090#include "machine/upd765.h"
9191#include "devices/flopdrv.h"
r6248r6249
525525   AM_RANGE(0xf3, 0xf3) AM_NOP                            /* DMA floppy (unknown -- not yet) */
526526   AM_RANGE(0xf4, 0xf7) AM_NOP                              /* DMA 5'floppy (may be not released) */
527527   AM_RANGE(0xf8, 0xfb) AM_NOP                            /* DMA 8'floppy (unknown -- not yet) */
528   AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w )
528   AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE("ppi8255_0", i8255a_r, i8255a_w )
529529ADDRESS_MAP_END
530530
531531static ADDRESS_MAP_START( pc88va_mem, ADDRESS_SPACE_PROGRAM, 8 )
r6248r6249
551551   AM_RANGE(0xf8, 0xf8) AM_READ( pc8801fd_upd765_tc )
552552   AM_RANGE(0xfa, 0xfa) AM_DEVREAD("upd765", upd765_status_r )
553553   AM_RANGE(0xfb, 0xfb) AM_DEVREADWRITE("upd765", upd765_data_r, upd765_data_w )
554   AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w )
554   AM_RANGE(0xfc, 0xff) AM_DEVREADWRITE("ppi8255_1", i8255a_r, i8255a_w )
555555ADDRESS_MAP_END
556556
557557
r6248r6249
601601
602602   MDRV_MACHINE_RESET( pc88srl )
603603
604   MDRV_PPI8255_ADD( "ppi8255_0", pc8801_8255_config_0 )
604   MDRV_I8255A_ADD( "ppi8255_0", pc8801_8255_config_0 )
605605
606   MDRV_PPI8255_ADD( "ppi8255_1", pc8801_8255_config_1 )
606   MDRV_I8255A_ADD( "ppi8255_1", pc8801_8255_config_1 )
607607
608608   /* video hardware */
609609   MDRV_SCREEN_ADD("screen", RASTER)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team