Diff for /np2/bios/bios.c between versions 1.64 and 1.74

version 1.64, 2004/05/22 10:46:42 version 1.74, 2005/03/05 06:02:28
Line 20 Line 20
   
 #define BIOS_SIMULATE  #define BIOS_SIMULATE
   
         BOOL    biosrom = FALSE;  
   
 static const char neccheck[] = "Copyright (C) 1983 by NEC Corporation";  static const char neccheck[] = "Copyright (C) 1983 by NEC Corporation";
   
 typedef struct {  typedef struct {
Line 58  const IODATA *pterm; Line 56  const IODATA *pterm;
         gdc_biosreset();          gdc_biosreset();
   
         p = iodata;          p = iodata;
         pterm = iodata + (sizeof(iodata) / sizeof(IODATA));          pterm = iodata + NELEMENTS(iodata);
         while(p < pterm) {          while(p < pterm) {
                 iocore_out8(p->port, p->data);                  iocore_out8(p->port, p->data);
                 p++;                  p++;
Line 84  static void bios_memclear(void) { Line 82  static void bios_memclear(void) {
   
 static void bios_reinitbyswitch(void) {  static void bios_reinitbyswitch(void) {
   
         BYTE    prxcrt;          UINT8   prxcrt;
         BYTE    prxdupd;          UINT8   prxdupd;
         BYTE    biosflag;          UINT8   biosflag;
         UINT8   boot;          UINT8   boot;
   
         if (!(np2cfg.dipsw[2] & 0x80)) {          if (!(np2cfg.dipsw[2] & 0x80)) {
Line 134  static void bios_reinitbyswitch(void) { Line 132  static void bios_reinitbyswitch(void) {
                 biosflag |= 0x40;                  biosflag |= 0x40;
         }          }
         mem[MEMB_BIOS_FLAG1] = biosflag;          mem[MEMB_BIOS_FLAG1] = biosflag;
         mem[MEMB_EXPMMSZ] = (BYTE)(pccore.extmem << 3);          mem[MEMB_EXPMMSZ] = (UINT8)(pccore.extmem << 3);
         mem[MEMB_CRT_RASTER] = 0x0f;          mem[MEMB_CRT_RASTER] = 0x0f;
   
         // FDD initialize          // FDD initialize
Line 149  static void bios_reinitbyswitch(void) { Line 147  static void bios_reinitbyswitch(void) {
                 fddbios_equip(0, TRUE);                  fddbios_equip(0, TRUE);
                 mem[MEMB_BIOS_FLAG0] &= ~0x02;                  mem[MEMB_BIOS_FLAG0] &= ~0x02;
         }          }
           mem[MEMB_F2HD_MODE] = 0xff;
         mem[MEMB_F2DD_MODE] = 0xff;          mem[MEMB_F2DD_MODE] = 0xff;
   
 #if defined(SUPPORT_CRT31KHZ)  #if defined(SUPPORT_CRT31KHZ)
         mem[MEMB_CRT_BIOS] = 0x80;          mem[MEMB_CRT_BIOS] |= 0x80;
 #endif  #endif
 #if defined(SUPPORT_PC9821)  #if defined(SUPPORT_PC9821)
           mem[MEMB_CRT_BIOS] |= 0x04;             // 05/02/03
         mem[0x45c] = 0x40;          mem[0x45c] = 0x40;
 #endif  #endif
   
Line 192  static void bios_screeninit(void) { Line 192  static void bios_screeninit(void) {
         bios0x18_0a(al);          bios0x18_0a(al);
 }  }
   
   static void setbiosseed(UINT8 *ptr, UINT size, UINT seedpos) {
   
           UINT8   x;
           UINT8   y;
           UINT    i;
   
           x = 0;
           y = 0;
           for (i=0; i<size; i+=2) {
                   x += ptr[i + 0];
                   y += ptr[i + 1];
           }
           ptr[seedpos + 0] -= x;
           ptr[seedpos + 1] -= y;
   }
   
 void bios_initialize(void) {  void bios_initialize(void) {
   
         char    path[MAX_PATH];          BOOL    biosrom;
           OEMCHAR path[MAX_PATH];
         FILEH   fh;          FILEH   fh;
         UINT    i;          UINT    i;
         UINT32  tmp;          UINT32  tmp;
         UINT    pos;          UINT    pos;
   
         biosrom = FALSE;          biosrom = FALSE;
         getbiospath(path, str_biosrom, sizeof(path));          getbiospath(path, str_biosrom, NELEMENTS(path));
         fh = file_open_rb(path);          fh = file_open_rb(path);
         if (fh != FILEH_INVALID) {          if (fh != FILEH_INVALID) {
                 biosrom = (file_read(fh, mem + 0x0e8000, 0x18000) == 0x18000);                  biosrom = (file_read(fh, mem + 0x0e8000, 0x18000) == 0x18000);
Line 210  void bios_initialize(void) { Line 226  void bios_initialize(void) {
         }          }
         if (biosrom) {          if (biosrom) {
                 TRACEOUT(("load bios.rom"));                  TRACEOUT(("load bios.rom"));
                   pccore.rom |= PCROM_BIOS;
                 // PnP BIOSを潰す                  // PnP BIOSを潰す
                 for (i=0; i<0x10000; i+=0x10) {                  for (i=0; i<0x10000; i+=0x10) {
                         tmp = LOADINTELDWORD(mem + 0xf0000 + i);                          tmp = LOADINTELDWORD(mem + 0xf0000 + i);
                         if (tmp == 0x506e5024) {                          if (tmp == 0x506e5024) {
                                 TRACEOUT(("found PnP BIOS at %.5x", 0xf0000 + i));                                  TRACEOUT(("found PnP BIOS at %.5x", 0xf0000 + i));
                                 STOREINTELDWORD(mem + 0xf0000 + i, 0x32504e24);                                  mem[0xf0000 + i] = 0x6e;
                                   mem[0xf0002 + i] = 0x24;
                                   break;
                         }                          }
                 }                  }
         }          }
         else {          else {
                 CopyMemory(mem + 0x0e8000, nosyscode, sizeof(nosyscode));                  CopyMemory(mem + 0x0e8000, nosyscode, sizeof(nosyscode));
                   if ((!biosrom) && (!(pccore.model & PCMODEL_EPSON))) {
                           CopyMemory(mem + 0xe8dd8, neccheck, 0x25);
                           pos = LOADINTELWORD(itfrom + 2);
                           CopyMemory(mem + 0xf538e, itfrom + pos, 0x27);
                   }
                   setbiosseed(mem + 0x0e8000, 0x10000, 0xb1f0);
         }          }
   
 #if defined(SUPPORT_PC9821)  #if defined(SUPPORT_PC9821)
         getbiospath(path, "bios9821.rom", sizeof(path));          getbiospath(path, OEMTEXT("bios9821.rom"), sizeof(path));
         fh = file_open_rb(path);          fh = file_open_rb(path);
         if (fh != FILEH_INVALID) {          if (fh != FILEH_INVALID) {
                 if (file_read(fh, mem + 0x0d8000, 0x2000) == 0x2000) {                  if (file_read(fh, mem + 0x0d8000, 0x2000) == 0x2000) {
Line 234  void bios_initialize(void) { Line 259  void bios_initialize(void) {
                 }                  }
                 file_close(fh);                  file_close(fh);
         }          }
   #if defined(BIOS_SIMULATE)
           mem[0xf8e80] = 0x98;
           mem[0xf8e81] = 0x21;
           mem[0xf8e82] = 0x1f;
           mem[0xf8e83] = 0x20;    // Model Number?
           mem[0xf8e84] = 0x2c;
           mem[0xf8e85] = 0xb0;
   
           // mem[0xf8eaf] = 0x21;         // <- これって何だっけ?
   #endif
 #endif  #endif
   
 #if defined(BIOS_SIMULATE)  #if defined(BIOS_SIMULATE)
Line 256  void bios_initialize(void) { Line 291  void bios_initialize(void) {
         mem[0xffff0] = 0xea;          mem[0xffff0] = 0xea;
         STOREINTELDWORD(mem + 0xffff1, 0xfd800000);          STOREINTELDWORD(mem + 0xffff1, 0xfd800000);
   
         if ((!biosrom) && (!(pccore.model & PCMODEL_EPSON))) {  
                 CopyMemory(mem + 0xe8dd8, neccheck, 0x25);  
                 pos = LOADINTELWORD(itfrom + 2);  
                 CopyMemory(mem + 0xf538e, itfrom + pos, 0x27);  
         }  
   
         CopyMemory(mem + 0x0fd800 + 0x0e00, keytable[0], 0x300);          CopyMemory(mem + 0x0fd800 + 0x0e00, keytable[0], 0x300);
   
         CopyMemory(mem + ITF_ADRS, itfrom, sizeof(itfrom));          CopyMemory(mem + ITF_ADRS, itfrom, sizeof(itfrom));
Line 273  void bios_initialize(void) { Line 302  void bios_initialize(void) {
         else if ((pccore.model & PCMODELMASK) == PCMODEL_VM) {          else if ((pccore.model & PCMODELMASK) == PCMODEL_VM) {
                 mem[ITF_ADRS + 0x7ff1] = 0x08;                  mem[ITF_ADRS + 0x7ff1] = 0x08;
         }          }
           setbiosseed(mem + 0x0f8000, 0x08000, 0x7ffe);
 #else  #else
         fh = file_open_c("itf.rom");          fh = file_open_c("itf.rom");
         if (fh != FILEH_INVALID) {          if (fh != FILEH_INVALID) {
Line 300  static void bios_itfcall(void) { Line 330  static void bios_itfcall(void) {
   
         if (!np2cfg.ITF_WORK) {          if (!np2cfg.ITF_WORK) {
                 for (i=0; i<8; i++) {                  for (i=0; i<8; i++) {
                         mem[MEMB_MSW + (i*4)] = msw_default[i];                          mem[MEMX_MSW + (i*4)] = msw_default[i];
                 }                  }
                 CPU_FLAGL |= C_FLAG;                  CPU_FLAGL |= C_FLAG;
         }          }
Line 400  UINT MEMCALL biosfunc(UINT32 adrs) { Line 430  UINT MEMCALL biosfunc(UINT32 adrs) {
                 case BIOS_BASE + BIOSOFST_CMT:                  case BIOS_BASE + BIOSOFST_CMT:
                         CPU_REMCLOCK -= 200;                          CPU_REMCLOCK -= 200;
                         bios0x1a_cmt();                          bios0x1a_cmt();
                         return(1);                          return(0);                                                                                      // return(1);
   
                 case BIOS_BASE + BIOSOFST_PRT:                  case BIOS_BASE + BIOSOFST_PRT:
                         CPU_REMCLOCK -= 200;                          CPU_REMCLOCK -= 200;
Line 425  UINT MEMCALL biosfunc(UINT32 adrs) { Line 455  UINT MEMCALL biosfunc(UINT32 adrs) {
   
                 case BIOS_BASE + BIOSOFST_WAIT:                  case BIOS_BASE + BIOSOFST_WAIT:
                         CPU_STI;                          CPU_STI;
   #if 1
                           return(bios0x1b_wait());                                                                // ver0.78
   #else
                         if (fddmtr.busy) {                          if (fddmtr.busy) {
                                 CPU_IP--;                                  CPU_IP--;
                                 CPU_REMCLOCK = -1;                                  CPU_REMCLOCK = -1;
                         }                          }
                         else {                          else {
                                 if (fdc.chgreg & 1) {                                  if (fdc.chgreg & 1) {
                                         if (!(mem[0x0055e] & (0x01 << fdc.us))) {                                          if (!(mem[MEMB_DISK_INTL] & (0x01 << fdc.us))) {
                                                 CPU_IP--;                                                  CPU_IP--;
                                                 CPU_REMCLOCK -= 1000;                                                  CPU_REMCLOCK -= 1000;
                                         }                                          }
                                 }                                  }
                                 else {                                  else {
                                         if (!(mem[0x0055f] & (0x10 << fdc.us))) {                                          if (!(mem[MEMB_DISK_INTH] & (0x10 << fdc.us))) {
                                                 CPU_IP--;                                                  CPU_IP--;
                                                 CPU_REMCLOCK -= 1000;                                                  CPU_REMCLOCK -= 1000;
                                         }                                          }
                                 }                                  }
                         }                          }
                         return(1);                          return(1);
   #endif
   
                 case 0xfffe8:                                   // ブートストラップロード                  case 0xfffe8:                                   // ブートストラップロード
                         CPU_REMCLOCK -= 2000;                          CPU_REMCLOCK -= 2000;
Line 462  UINT MEMCALL biosfunc(UINT32 adrs) { Line 496  UINT MEMCALL biosfunc(UINT32 adrs) {
                         return(0);                          return(0);
         }          }
   
         if ((adrs >= 0xf9a00) && (adrs < 0x0f9a44)) {          if ((adrs >= 0xf9950) && (adrs <= 0x0f9990) && (!(adrs & 3))) {
                 if (!(adrs & 3)) {                  CPU_REMCLOCK -= 500;
                         CPU_REMCLOCK -= 500;                  bios_lio((REG8)((adrs - 0xf9950) >> 2));
                         bios_lio((REG8)((adrs - 0xf9a00) >> 2));          }
                 }          else if (adrs == 0xf9994) {
                 else {                  if (nevent_iswork(NEVENT_GDCSLAVE)) {
                         if (nevent_iswork(NEVENT_GDCSLAVE)) {                          CPU_IP--;
                                 CPU_IP--;                          CPU_REMCLOCK = -1;
                                 CPU_REMCLOCK = -1;                          return(1);
                                 return(1);  
                         }  
                 }                  }
                 return(0);  
         }          }
         return(0);          return(0);
 }  }

Removed from v.1.64  
changed lines
  Added in v.1.74


RetroPC.NET-CVS <cvs@retropc.net>