Previous 15994 Revisions Next

r6055 Monday 12th October, 2009 at 22:59:57 UTC by Angelo Salese
[PC98]: Added basic support for banked work ram & kludged Gate-A20 support
[src/mess/drivers]pc98.c

src/mess/drivers/pc98.c
r6054r6055
221221
222222static UINT32 *pc9801_vram;
223223static UINT32 *gfx_bitmap_ram;
224static UINT32 *work_ram_banked;
224225static UINT8 ems_bank;
226static UINT8 wram_bank;
225227
228
226229static VIDEO_START( pc9801 )
227230{
228231   gfx_bitmap_ram = auto_alloc_array(machine, UINT32, 0x18000*2);
232   work_ram_banked = auto_alloc_array(machine, UINT32, 0x2000*0xfe); //shouldn't be here
229233}
230234
231235/*
r6054r6055
395399
396400static WRITE8_HANDLER( ems_sel_w )
397401{
402//   printf("%02x %02x\n",offset,data);
403
404   if(offset == 1)
405   {
406      UINT8 *ROM = memory_region(space->machine, "cpudata");
407
408      if(data == 0x00 || data == 0x10)
409         memory_set_bankptr(space->machine, 1, &ROM[0x20000]);
410
411      if(data == 0x02 || data == 0x12)
412         memory_set_bankptr(space->machine, 1, &ROM[0x00000]);
413   }
414
398415   if(offset == 3)
399416   {
400417      if(data == 0x22)
r6054r6055
455472   }
456473}
457474
475static UINT8 gate_a20;
476
477static READ8_HANDLER( port_f0_r )
478{
479   if(offset == 0x02)
480      return (gate_a20 ^ 1) | 0x2e;
481   else if(offset == 0x06)
482      return (gate_a20 ^ 1) | 0x5e;
483
484   return 0x00;
485}
486
487static WRITE8_HANDLER( port_f0_w )
488{
489   if(offset == 0x00)
490   {
491      //cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE);
492   }
493
494   if(offset == 0x02)
495   {
496      gate_a20 = 1;
497      cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_A20, gate_a20);
498   }
499   if(offset == 0x06)
500   {
501      if(data == 0x02)
502      {
503         gate_a20 = 1;
504         cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_A20, gate_a20);
505      }
506      else if(data == 0x03)
507      {
508         gate_a20 = 0;
509         cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_A20, gate_a20);
510      }
511   }
512}
513
514static UINT8 wram_latch_reg;
515
516static READ8_HANDLER( wram_sel_r )
517{
518   return (wram_bank << 1) | wram_latch_reg;
519}
520
521static WRITE8_HANDLER( wram_sel_w )
522{
523   wram_bank = (data & 0xfe) >> 1;
524   wram_latch_reg = data & 1; //<- correct?
525   //printf("%02x\n",wram_bank);
526}
527
458528static READ32_HANDLER( gfx_bitmap_ram_r ) { return gfx_bitmap_ram[offset+ems_bank*0x18000/4]; }
459static WRITE32_HANDLER( gfx_bitmap_ram_w ) { gfx_bitmap_ram[offset+ems_bank*0x18000/4] = data; }
529static WRITE32_HANDLER( gfx_bitmap_ram_w ) { COMBINE_DATA(&gfx_bitmap_ram[offset+ems_bank*0x18000/4]); }
460530
531static READ32_HANDLER( wram_bank_r ) { return work_ram_banked[offset+wram_bank*0x2000/4]; }
532static WRITE32_HANDLER( wram_bank_w ) { COMBINE_DATA(&work_ram_banked[offset+wram_bank*0x2000/4]); }
533
534static READ32_HANDLER( wram_ide_r ) { return work_ram_banked[offset+4*0x2000/4]; } //todo: ide hookup & calculate the correct bank number here
535static WRITE32_HANDLER( wram_ide_w ) { COMBINE_DATA(&work_ram_banked[offset+4*0x2000/4]); }
536
461537static ADDRESS_MAP_START( pc9801_mem, ADDRESS_SPACE_PROGRAM, 32)
462   AM_RANGE(0x00000000, 0x0009ffff) AM_MIRROR(0x00100000) AM_RAM
538   AM_RANGE(0x00000000, 0x0007ffff) AM_RAM
539   AM_RANGE(0x00080000, 0x0009ffff) AM_READWRITE(wram_bank_r,wram_bank_w)
463540   AM_RANGE(0x000a0000, 0x000a3fff) AM_RAM AM_BASE(&pc9801_vram) //vram + attr
464541   AM_RANGE(0x000a4000, 0x000a4fff) AM_RAM //cg window
465542   AM_RANGE(0x000a8000, 0x000bffff) AM_READWRITE(gfx_bitmap_ram_r,gfx_bitmap_ram_w)
466   AM_RANGE(0x000e0000, 0x000fffff) AM_ROM AM_REGION("maincpu",0)
467   AM_RANGE(0xfffe0000, 0xffffffff) AM_ROM AM_REGION("maincpu",0)
543   AM_RANGE(0x000c0000, 0x000dffff) AM_READWRITE(wram_ide_r,wram_ide_w)
544   AM_RANGE(0x000e0000, 0x000fffff) AM_ROMBANK(1)
545   AM_RANGE(0xfffe0000, 0xffffffff) AM_ROMBANK(1)
468546ADDRESS_MAP_END
469547
470548
r6054r6055
491569   AM_RANGE(0x0070, 0x007f) AM_READWRITE8(port_70_r,port_70_w,0xffffffff) // crtc regs (even ports) / pit8253 (odd ports)
492570   AM_RANGE(0x00a0, 0x00a3) AM_READWRITE8(port_a0_r,port_a0_w,0xffffffff) // uPD7220 status & fifo (R) / param & cmd (W) slave (even ports)
493571//    AM_RANGE(0x00e0, 0x00ef) DMA
572   AM_RANGE(0x00f0, 0x00ff) AM_READWRITE8(port_f0_r,port_f0_w,0xffffffff)
494573   AM_RANGE(0x043c, 0x043f) AM_WRITE8(ems_sel_w,0xffffffff)
574   AM_RANGE(0x0460, 0x0463) AM_READWRITE8(wram_sel_r,wram_sel_w,0xffffffff)
495575
496576//   (and many more...)
497577ADDRESS_MAP_END
r6054r6055
518598   return r;
519599}
520600
601#include "cpu/i386/i386priv.h"
602
603
521604static MACHINE_RESET(pc9801)
522605{
606   UINT8 *ROM = memory_region(machine, "cpudata");
607
523608   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), irq_callback);
609
610   cputag_set_input_line(machine, "maincpu", INPUT_LINE_A20, 0);
611
612   gate_a20 = 0;
613   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), I386_EIP, 0xffff0+0x10000);
614
615   memory_set_bankptr(machine, 1, &ROM[0x20000]);
616
617   wram_bank = 0;
524618}
525619
526620static MACHINE_RESET(pc9821)
527621{
622   UINT8 *ROM = memory_region(machine, "cpudata");
528623   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), irq_callback);
624
625   cputag_set_input_line(machine, "maincpu", INPUT_LINE_A20, 0);
626
627   gate_a20 = 0;
628   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), I386_EIP, 0xffff0+0x10000);
629
630   memory_set_bankptr(machine, 1, &ROM[0x20000]);
631
632   wram_bank = 0;
529633}
530634
531635/*************************************************************
r6054r6055
817921
818922/* I strongly suspect this dump comes from a later machine, like an i386-based one, but I could be wrong... */
819923ROM_START( pc9801 )
820   ROM_REGION( 0x20000, "maincpu", 0 )
821   ROM_LOAD( "bios.rom", 0x00000, 0x18000, CRC(315d2703) SHA1(4f208d1dbb68373080d23bff5636bb6b71eb7565) )
822   ROM_LOAD( "itf.rom",  0x18000, 0x08000, CRC(c1815325) SHA1(a2fb11c000ed7c976520622cfb7940ed6ddc904e) )
924   ROM_REGION( 0x60000, "cpudata", ROMREGION_ERASEFF )
925   ROM_LOAD( "bios.rom", 0x08000, 0x18000, CRC(315d2703) SHA1(4f208d1dbb68373080d23bff5636bb6b71eb7565) )
926   ROM_LOAD( "itf.rom",  0x38000, 0x08000, CRC(c1815325) SHA1(a2fb11c000ed7c976520622cfb7940ed6ddc904e) )
823927
824928   /* where shall we load this? */
825929   ROM_REGION( 0x100000, "memory", 0 )
r6054r6055
840944ROM_END
841945
842946ROM_START( pc9821 )
843   ROM_REGION( 0x20000, "maincpu", 0 )
844   ROM_LOAD( "bios.rom", 0x00000, 0x18000, CRC(34a19a59) SHA1(2e92346727b0355bc1ec9a7ded1b444a4917f2b9) )
845   ROM_LOAD( "itf.rom",  0x00000, 0x08000, CRC(dd4c7bb8) SHA1(cf3aa193df2722899066246bccbed03f2e79a74a) )
947   ROM_REGION( 0x60000, "maincpu", ROMREGION_ERASEFF )
948   ROM_LOAD( "bios.rom", 0x08000, 0x18000, CRC(34a19a59) SHA1(2e92346727b0355bc1ec9a7ded1b444a4917f2b9) )
949   ROM_LOAD( "itf.rom",  0x38000, 0x08000, CRC(dd4c7bb8) SHA1(cf3aa193df2722899066246bccbed03f2e79a74a) )
846950
847951   ROM_REGION( 0x10000, "soundcpu", 0 )
848952   ROM_LOAD( "sound.rom", 0x0000, 0x4000, CRC(a21ef796) SHA1(34137c287c39c44300b04ee97c1e6459bb826b60) )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team