Previous 15994 Revisions Next

r8062 Monday 17th May, 2010 at 15:20:54 UTC by Fabio Priuli
Modified pc8801 extRAM allocation. This might fix bug 1952.
[src/mess/machine]pc8801.c

src/mess/machine/pc8801.c
r8061r8062
3232static int port32_save;
3333static int text_window;
3434static int extmem_mode=-1;
35static unsigned char *extRAM=NULL;
35static UINT8 *extRAM;
36static int extRAM_size;
3637static void *ext_bank_80[4],*ext_bank_88[256];
3738static UINT8 extmem_ctrl[2];
3839
r8061r8062
486487  pc8801_update_bank(space->machine);
487488}
488489
490// FIXME: shouldn't we use ram device in place of the below code?
489491static void pc8801_init_bank(running_machine *machine, int hireso)
490492{
491493   int i,j;
r8061r8062
500502   port71_save=0xff;
501503   port32_save=0x80;
502504   mainROM = memory_region(machine, "maincpu");
503   pc8801_mainRAM = auto_alloc_array(machine, UINT8, 0x10000);
504   memset(pc8801_mainRAM, 0, 0x10000);
505   pc8801_mainRAM = auto_alloc_array_clear(machine, UINT8, 0x10000);
505506
506507   extmem_ctrl[0]=extmem_ctrl[1]=0;
507508   pc8801_update_bank(machine);
508509   pc8801_video_init(machine, hireso);
509510
510  if(extmem_mode!=input_port_read(machine, "MEM")) {
511    extmem_mode=input_port_read(machine, "MEM");
512    if(extRAM!=NULL) {
513      free(extRAM);
514      extRAM=NULL;
515    }
516    for(i=0;i<4;i++) ext_bank_80[i]=NULL;
517    for(i=0;i<256;i++) ext_bank_88[i]=NULL;
518    num80=num88=numIO=0;
519    switch(extmem_mode) {
520    case 0x00: /* none */
521      break;
522    case 0x01: /* 32KB(PC-8012-02 x 1) */
523      num80=1;
524      break;
525    case 0x02: /* 64KB(PC-8012-02 x 2) */
526      num80=2;
527      break;
528    case 0x03: /* 128KB(PC-8012-02 x 4) */
529      num80=4;
530      break;
531    case 0x04: /* 128KB(PC-8801-02N x 1) */
532      num88=1;
533      break;
534    case 0x05: /* 256KB(PC-8801-02N x 2) */
535      num88=2;
536      break;
537    case 0x06: /* 512KB(PC-8801-02N x 4) */
538      num88=4;
539      break;
540    case 0x07: /* 1M(PIO-8234H-1M x 1) */
541      numIO=1;
542      break;
543    case 0x08: /* 2M(PIO-8234H-2M x 1) */
544      numIO=2;
545      break;
546    case 0x09: /* 4M(PIO-8234H-2M x 2) */
547      numIO=4;
548      break;
549    case 0x0a: /* 8M(PIO-8234H-2M x 4) */
550      numIO=8;
551      break;
552    case 0x0b: /* 1.1M(PIO-8234H-1M x 1 + PC-8801-02N x 1) */
553      num88=1;
554      numIO=1;
555      break;
556    case 0x0c: /* 2.1M(PIO-8234H-2M x 1 + PC-8801-02N x 1) */
557      num88=1;
558      numIO=2;
559      break;
560    case 0x0d: /* 4.1M(PIO-8234H-2M x 2 + PC-8801-02N x 1) */
561      num88=1;
562      numIO=4;
563      break;
564    default:
565      logerror("pc8801 : illegal extension memory mode.\n");
566      return;
567    }
568    if(num80!=0 || num88!=0 || numIO!=0) {
569      extRAM=(UINT8*)malloc(num80*0x8000+num88*0x20000+numIO*0x100000);
570      e=extRAM;
571      for(i=0;i<num80;i++) {
572   ext_bank_80[i]=e;
573   e+=0x8000;
574      }
575      for(i=0;i<num88*4;i++) {
576   for(j=i;j<256;j+=16) {
577     ext_bank_88[j]=e;
511   if (extmem_mode != input_port_read(machine, "MEM"))
512   {
513      extmem_mode = input_port_read(machine, "MEM");
514
515      // reset all the bank-related quantities
516      memset(extRAM, 0, extRAM_size);
517
518      for (i = 0; i < 4; i++)
519         ext_bank_80[i] = NULL;
520
521      for (i = 0; i < 256; i++)
522         ext_bank_88[i] = NULL;
523
524      num80 = num88 = numIO = 0;
525
526      // set up the required number of banks
527      switch (extmem_mode)
528      {
529         case 0x00: /* none */
530            break;
531         case 0x01: /* 32KB(PC-8012-02 x 1) */
532            num80 = 1;
533            break;
534         case 0x02: /* 64KB(PC-8012-02 x 2) */
535            num80 = 2;
536            break;
537         case 0x03: /* 128KB(PC-8012-02 x 4) */
538            num80 = 4;
539            break;
540         case 0x04: /* 128KB(PC-8801-02N x 1) */
541            num88 = 1;
542            break;
543         case 0x05: /* 256KB(PC-8801-02N x 2) */
544            num88 = 2;
545            break;
546         case 0x06: /* 512KB(PC-8801-02N x 4) */
547            num88 = 4;
548            break;
549         case 0x07: /* 1M(PIO-8234H-1M x 1) */
550            numIO = 1;
551            break;
552         case 0x08: /* 2M(PIO-8234H-2M x 1) */
553            numIO = 2;
554            break;
555         case 0x09: /* 4M(PIO-8234H-2M x 2) */
556            numIO = 4;
557            break;
558         case 0x0a: /* 8M(PIO-8234H-2M x 4) */
559            numIO = 8;
560            break;
561         case 0x0b: /* 1.1M(PIO-8234H-1M x 1 + PC-8801-02N x 1) */
562            num88 = 1;
563            numIO = 1;
564            break;
565         case 0x0c: /* 2.1M(PIO-8234H-2M x 1 + PC-8801-02N x 1) */
566            num88 = 1;
567            numIO = 2;
568            break;
569         case 0x0d: /* 4.1M(PIO-8234H-2M x 2 + PC-8801-02N x 1) */
570            num88 = 1;
571            numIO = 4;
572            break;
573         default:
574            logerror("pc8801 : illegal extension memory mode.\n");
575            return;
576      }
577
578      // point the banks to the correct memory
579      if (num80 != 0 || num88 != 0 || numIO != 0)
580      {
581         e = extRAM;
582
583         for (i = 0; i < num80; i++)
584         {
585            ext_bank_80[i] = e;
586            e += 0x8000;
587         }
588 
589         for (i = 0; i < num88 * 4; i++)
590         {
591            for (j = i; j < 256; j += 16)
592            {
593               ext_bank_88[j] = e;
594            }
595            e += 0x8000;
596         }
597
598         if (num88 == 0)
599         {
600            for (i = 0; i < numIO * 32; i++)
601            {
602               ext_bank_88[(i & 0x07) | ((i & 0x18) << 1) | ((i & 0x20) >> 2) | (i & 0xc0)] = e;
603               e += 0x8000;
604            }
605         }
606         else
607         {
608            for (i = 0; i < numIO * 32; i++)
609            {
610               ext_bank_88[(i & 0x07) | ((i & 0x78) << 1) | 0x08] = e;
611               e += 0x8000;
612            }
613         }
614      }
578615   }
579   e+=0x8000;
580      }
581      if(num88==0) {
582   for(i=0;i<numIO*32;i++) {
583     ext_bank_88[(i&0x07)|((i&0x18)<<1)|((i&0x20)>>2)|(i&0xc0)]=e;
584     e+=0x8000;
585   }
586      } else {
587   for(i=0;i<numIO*32;i++) {
588     ext_bank_88[(i&0x07)|((i&0x78)<<1)|0x08]=e;
589     e+=0x8000;
590   }
591      }
592    }
593  }
594616}
595617
596618static void fix_V1V2(void)
r8061r8062
632654   running_device *speaker = devtag_get_device(machine, "beep");
633655   int a;
634656
635   a=input_port_read(machine, "CFG");
657   // old code was allocating/freeing a smaller region depending on the "MEM" config,
658   // but I guess this was the reason of bug #1952. So we now allocate the maximum
659   // possible amount of extended RAM, and then we only use the amount we need.
660   // eventually, we should convert the driver to use the ram device, imho.
661   extRAM_size = 4 * 0x8000 + 4 * 0x20000 + 8 * 0x100000;
662   extRAM = auto_alloc_array_clear(machine, UINT8, extRAM_size);
663
664   a = input_port_read(machine, "CFG");
636665   is_Nbasic = ((a&0x01)==0x00);
637666   is_V2mode = ((a&0x02)==0x00);
638667   pc88sr_is_highspeed = ((a&0x04)!=0x00);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team