Previous 15994 Revisions Next

r6027 Friday 9th October, 2009 at 16:43:13 UTC by Angelo Salese
[PC98]: Added PIT, PIC and DMA basic hook-up, bios enters now into memory size check.
[src/mess/drivers]pc98.c

src/mess/drivers/pc98.c
r6026r6027
216216#include "cpu/i386/i386.h"
217217#include "machine/8255ppi.h"
218218#include "machine/pit8253.h"
219#include "machine/8237dma.h"
220#include "machine/pic8259.h"
219221
220222static UINT32 *pc9801_vram;
221223static UINT32 *gfx_bitmap_ram;
r6026r6027
408410   if(offset & 1)
409411   {
410412      logerror("pit port $70 R access %02x\n",offset >> 1);
411      return mame_rand(space->machine);//pit8253_r(devtag_get_device(space->machine, "pit8253"), (offset & 6) >> 1);
413      /* FIXME */
414      return pit8253_r(devtag_get_device(space->machine, "pit8253"), (offset & 6) >> 1);
412415   }
413416
414417   logerror("crtc port $70 R access %02x\n",offset >> 1);
r6026r6027
426429      logerror("crtc port $70 W access %02x %02x\n",offset >> 1,data);
427430}
428431
429/* FIXME */
430432static READ8_HANDLER( port_00_r )
431433{
432434   if(!(offset & 1))
433435   {
434436      logerror("pic8259 port $00 R access %02x\n",offset >> 1);
435      return mame_rand(space->machine);//pic8259_r(devtag_get_device(space->machine, "pic8259"), (offset & 6) >> 1);
437      return pic8259_r(devtag_get_device(space->machine, "pic8259_master"), (offset & 6) >> 1);
436438   }
437439
438   logerror("??? port $00 R access %02x\n",offset >> 1);
439   return 0xff;
440   //logerror("DMA port $00 R access %02x\n",offset >> 1);
441   return dma8237_r(devtag_get_device(space->machine, "dma8237_1"), (offset & 0x1e) >> 1);
440442}
441443
442444static WRITE8_HANDLER( port_00_w )
r6026r6027
444446   if(!(offset & 1))
445447   {
446448      logerror("pic8259 port $00 W access %02x %02x\n",offset >> 1,data);
447      //pic8259_w(devtag_get_device(space->machine, "pic8259"), (offset & 6) >> 1, data);
449      pic8259_w(devtag_get_device(space->machine, "pic8259_master"), (offset & 6) >> 1, data);
448450   }
449451   else
450      logerror("??? port $00 W access %02x %02x\n",offset >> 1,data);
452   {
453      //logerror("DMA port $00 W access %02x %02x\n",offset >> 1,data);
454      dma8237_w(devtag_get_device(space->machine, "dma8237_1"), (offset & 0x1e) >> 1, data);
455   }
451456}
452457
453458static READ32_HANDLER( gfx_bitmap_ram_r ) { return gfx_bitmap_ram[offset+ems_bank*0x18000/4]; }
r6026r6027
465470
466471
467472static ADDRESS_MAP_START( pc9801_io, ADDRESS_SPACE_IO, 32)
468   AM_RANGE(0x0000, 0x000f) AM_READWRITE8(port_00_r,port_00_w,0xffffffff) // pic8259 (even ports)
473   AM_RANGE(0x0000, 0x001f) AM_READWRITE8(port_00_r,port_00_w,0xffffffff) // pic8259 (even ports) / dma (odd ports)
469474//   AM_RANGE(0x0020, 0x0020) rtc
470475//   AM_RANGE(0x0022, 0x0022)
471476   AM_RANGE(0x0030, 0x0037) AM_READWRITE8(sys_port_r,sys_port_w,0xffffffff) // rs232c (even ports) / system ppi8255 (odd ports)
r6026r6027
501506   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_VBLANK )
502507INPUT_PORTS_END
503508
509static IRQ_CALLBACK(irq_callback)
510{
511   int r = 0;
512   //r = pic8259_acknowledge( devtag_get_device( machine, "pic8259_slave" ));
513   //if (r==0)
514   {
515      r = pic8259_acknowledge( devtag_get_device( device->machine, "pic8259_master" ))/2; //Explictly needs 0x10/2 on POST?
516      //printf("%02x ACK\n",r);
517   }
518   return r;
519}
504520
505521static MACHINE_RESET(pc9801)
506522{
523   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), irq_callback);
507524}
508525
509526static MACHINE_RESET(pc9821)
510527{
528   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), irq_callback);
511529}
512530
531/*************************************************************
532 *
533 * pic8259 configuration
534 *
535 *************************************************************/
536
537static PIC8259_SET_INT_LINE( pc98_master_set_int_line ) {
538   //printf("%02x\n",interrupt);
539   cputag_set_input_line(device->machine, "maincpu", 0, interrupt ? HOLD_LINE : CLEAR_LINE);
540}
541
542
543//static PIC8259_SET_INT_LINE( pc98_slave_set_int_line ) {
544//   pic8259_set_irq_line( devtag_get_device( machine, "pic8259_master" ), 2, interrupt);
545//}
546
547
548static const struct pic8259_interface pic8259_master_config = {
549   pc98_master_set_int_line
550};
551
552
553//static const struct pic8259_interface pic8259_slave_config = {
554//   pc98_slave_set_int_line
555//};
556
513557static VIDEO_START( pc9821 )
514558{
515559}
r6026r6027
540584
541585static READ8_DEVICE_HANDLER( pc98_porta_r )
542586{
543   printf("PPI Port A read\n");
587   //printf("PPI Port A read\n");
544588   return 0x00;
545589}
546590
r6026r6027
555599
556600static READ8_DEVICE_HANDLER( pc98_portc_r )
557601{
558   printf("PPI Port C read\n");
602   //printf("PPI Port C read\n");
559603   return 0x00;
560604}
561605
562606static WRITE8_DEVICE_HANDLER( pc98_porta_w )
563607{
564   printf("PPI Port A write %02x\n",data);
608   //printf("PPI Port A write %02x\n",data);
565609}
566610
567611static WRITE8_DEVICE_HANDLER( pc98_portb_w )
568612{
569   printf("PPI Port B write %02x\n",data);
613   //printf("PPI Port B write %02x\n",data);
570614}
571615
572616static WRITE8_DEVICE_HANDLER( pc98_portc_w )
573617{
574   printf("PPI Port C write %02x\n",data);
618   //printf("PPI Port C write %02x\n",data);
575619}
576620
577621static const ppi8255_interface ppi8255_intf =
r6026r6027
596640
597641static PIT8253_OUTPUT_CHANGED( pc_timer0_w )
598642{
599//   pic8259_set_irq_line(filetto_devices.pic8259_1, 0, state);
643   pic8259_set_irq_line(devtag_get_device( device->machine, "pic8259_master" ), 0, state);
600644}
601645
602646static const struct pit8253_config pit8253_config =
603647{
604648   {
605649      {
606         4772720/4,            /* heartbeat IRQ */
650         16000000/4,            /* heartbeat IRQ */
607651         pc_timer0_w
608652      }, {
609         4772720/4,            /* dram refresh */
653         16000000/4,            /* dram refresh */
610654         NULL
611655      }, {
612         4772720/4,            /* pio port c pin 4, and speaker polling enough */
656         16000000/4,            /* pio port c pin 4, and speaker polling enough */
613657         NULL
614658      }
615659   }
r6026r6027
623667      palette_set_color_rgb(machine, i+0x000, pal1bit(i >> 1), pal1bit(i >> 2), pal1bit(i >> 0));
624668}
625669
670static UINT8 dma_offset[2][4];
671
672#if 0
673static UINT8 at_pages[0x10];
674
675
676static READ8_HANDLER(at_page8_r)
677{
678   UINT8 data = at_pages[offset % 0x10];
679
680   switch(offset % 8) {
681   case 1:
682      data = dma_offset[(offset / 8) & 1][2];
683      break;
684   case 2:
685      data = dma_offset[(offset / 8) & 1][3];
686      break;
687   case 3:
688      data = dma_offset[(offset / 8) & 1][1];
689      break;
690   case 7:
691      data = dma_offset[(offset / 8) & 1][0];
692      break;
693   }
694   return data;
695}
696
697
698static WRITE8_HANDLER(at_page8_w)
699{
700   at_pages[offset % 0x10] = data;
701
702   switch(offset % 8) {
703   case 1:
704      dma_offset[(offset / 8) & 1][2] = data;
705      break;
706   case 2:
707      dma_offset[(offset / 8) & 1][3] = data;
708      break;
709   case 3:
710      dma_offset[(offset / 8) & 1][1] = data;
711      break;
712   case 7:
713      dma_offset[(offset / 8) & 1][0] = data;
714      break;
715   }
716}
717#endif
718
719static DMA8237_HRQ_CHANGED( pc_dma_hrq_changed )
720{
721   cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE);
722
723   /* Assert HLDA */
724   dma8237_set_hlda( device, state );
725}
726
727
728static DMA8237_MEM_READ( pc_dma_read_byte )
729{
730   const address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
731   offs_t page_offset = (((offs_t) dma_offset[0][channel]) << 16)
732      & 0xFF0000;
733
734   return memory_read_byte(space, page_offset + offset);
735}
736
737
738static DMA8237_MEM_WRITE( pc_dma_write_byte )
739{
740   const address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
741   offs_t page_offset = (((offs_t) dma_offset[0][channel]) << 16)
742      & 0xFF0000;
743
744   memory_write_byte(space, page_offset + offset, data);
745}
746
747
748static const struct dma8237_interface dma8237_1_config =
749{
750   XTAL_14_31818MHz/3,
751
752   pc_dma_hrq_changed,
753   pc_dma_read_byte,
754   pc_dma_write_byte,
755
756   { NULL, NULL, NULL, NULL },
757   { NULL, NULL, NULL, NULL },
758   NULL
759};
760
626761/* I suspect the dump for pc9801 comes from a i386 later model... the original machine would use a i8086 @ 5Mhz CPU (see notes at top) */
627762/* More investigations are required, but in the meanwhile I set a I386 as main CPU */
628763static MACHINE_DRIVER_START( pc9801 )
r6026r6027
636771   MDRV_PPI8255_ADD( "ppi8255_0", ppi8255_intf )
637772   MDRV_PPI8255_ADD( "ppi8255_1", printer_intf )
638773   MDRV_PIT8253_ADD( "pit8253", pit8253_config )
774   MDRV_DMA8237_ADD( "dma8237_1", dma8237_1_config )
775   MDRV_PIC8259_ADD( "pic8259_master", pic8259_master_config )
776//   MDRV_PIC8259_ADD( "pic8259_slave", pic8259_slave_config )
639777
640778   /* video hardware */
641779   MDRV_SCREEN_ADD("screen", RASTER)
642   MDRV_SCREEN_REFRESH_RATE(50)
780   MDRV_SCREEN_REFRESH_RATE(60)
643781   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
644782   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
645783   MDRV_SCREEN_SIZE(640, 480)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team