Diff for /np2/i386c/memory.c between versions 1.11 and 1.16

version 1.11, 2004/02/29 03:10:03 version 1.16, 2004/03/04 17:36:05
Line 736  void MEMCALL i286_vram_dispatch(UINT fun Line 736  void MEMCALL i286_vram_dispatch(UINT fun
 const VACCTBL   *vacc;  const VACCTBL   *vacc;
   
         vacc = vacctbl + (func & 0x0f);          vacc = vacctbl + (func & 0x0f);
 #if defined(SUPPORT_PC9821  #if defined(SUPPORT_PC9821)
         if (!(func & 0x20)) {          if (!(func & 0x20)) {
 #endif  #endif
                 memfn.rd8[0xa8000 >> 15] = vacc->rd8;                  memfn.rd8[0xa8000 >> 15] = vacc->rd8;
Line 796  REG8 MEMCALL i286_memoryread(UINT32 addr Line 796  REG8 MEMCALL i286_memoryread(UINT32 addr
   
         UINT32  pos;          UINT32  pos;
   
         addr &= CPU_ADRSMASK;  
         if (addr < I286_MEMREADMAX) {          if (addr < I286_MEMREADMAX) {
                 return(mem[addr]);                  return(mem[addr]);
         }          }
         else if (addr >= USE_HIMEM) {          else if (addr >= USE_HIMEM) {
                 pos = addr - 0x100000;                  pos = (addr & CPU_ADRSMASK) - 0x100000;
                 if (pos < CPU_EXTMEMSIZE) {                  if (pos < CPU_EXTMEMSIZE) {
                         return(CPU_EXTMEM[pos]);                          return(CPU_EXTMEM[pos]);
                 }                  }
Line 827  REG16 MEMCALL i286_memoryread_w(UINT32 a Line 826  REG16 MEMCALL i286_memoryread_w(UINT32 a
         UINT32  pos;          UINT32  pos;
         REG16   ret;          REG16   ret;
   
         addr &= CPU_ADRSMASK;  
         if (addr < (I286_MEMREADMAX - 1)) {          if (addr < (I286_MEMREADMAX - 1)) {
                 return(LOADINTELWORD(mem + addr));                  return(LOADINTELWORD(mem + addr));
         }          }
         else if ((addr + 1) & 0x7fff) {                         // non 32kb boundary          else if ((addr + 1) & 0x7fff) {                         // non 32kb boundary
                 if (addr >= USE_HIMEM) {                  if (addr >= USE_HIMEM) {
                         pos = addr - 0x100000;                          pos = (addr & CPU_ADRSMASK) - 0x100000;
                         if (pos < CPU_EXTMEMSIZE) {                          if (pos < CPU_EXTMEMSIZE) {
                                 return(LOADINTELWORD(CPU_EXTMEM + pos));                                  return(LOADINTELWORD(CPU_EXTMEM + pos));
                         }                          }
Line 863  UINT32 MEMCALL i286_memoryread_d(UINT32  Line 861  UINT32 MEMCALL i286_memoryread_d(UINT32 
         UINT32  pos;          UINT32  pos;
         UINT32  ret;          UINT32  ret;
   
         addr &= CPU_ADRSMASK;  
         if (addr < (I286_MEMREADMAX - 3)) {          if (addr < (I286_MEMREADMAX - 3)) {
                 return(LOADINTELDWORD(mem + addr));                  return(LOADINTELDWORD(mem + addr));
         }          }
         else if (addr >= USE_HIMEM) {          else if (addr >= USE_HIMEM) {
                 pos = addr - 0x100000;                  pos = (addr & CPU_ADRSMASK) - 0x100000;
                 if ((pos + 3) < CPU_EXTMEMSIZE) {                  if ((pos + 3) < CPU_EXTMEMSIZE) {
                         return(LOADINTELDWORD(CPU_EXTMEM + pos));                          return(LOADINTELDWORD(CPU_EXTMEM + pos));
                 }                  }
Line 889  void MEMCALL i286_memorywrite(UINT32 add Line 886  void MEMCALL i286_memorywrite(UINT32 add
   
         UINT32  pos;          UINT32  pos;
   
         addr &= CPU_ADRSMASK;  
         if (addr < I286_MEMWRITEMAX) {          if (addr < I286_MEMWRITEMAX) {
                 mem[addr] = (BYTE)value;                  mem[addr] = (BYTE)value;
         }          }
         else if (addr >= USE_HIMEM) {          else if (addr >= USE_HIMEM) {
                 pos = addr - 0x100000;                  pos = (addr & CPU_ADRSMASK) - 0x100000;
                 if (pos < CPU_EXTMEMSIZE) {                  if (pos < CPU_EXTMEMSIZE) {
                         CPU_EXTMEM[pos] = (BYTE)value;                          CPU_EXTMEM[pos] = (BYTE)value;
                 }                  }
Line 906  void MEMCALL i286_memorywrite(UINT32 add Line 902  void MEMCALL i286_memorywrite(UINT32 add
                         mem9821_w(addr, value);                          mem9821_w(addr, value);
                 }                  }
 #endif  #endif
                 else {  
                         TRACEOUT(("mem_w %x %x", addr, value));  
                 }  
         }          }
         else {          else {
                 memfn.wr8[(addr >> 15) & 0x1f](addr, value);                  memfn.wr8[(addr >> 15) & 0x1f](addr, value);
Line 919  void MEMCALL i286_memorywrite_w(UINT32 a Line 912  void MEMCALL i286_memorywrite_w(UINT32 a
   
         UINT32  pos;          UINT32  pos;
   
         addr &= CPU_ADRSMASK;  
         if (addr < (I286_MEMWRITEMAX - 1)) {          if (addr < (I286_MEMWRITEMAX - 1)) {
                 STOREINTELWORD(mem + addr, value);                  STOREINTELWORD(mem + addr, value);
         }          }
         else if ((addr + 1) & 0x7fff) {                         // non 32kb boundary          else if ((addr + 1) & 0x7fff) {                         // non 32kb boundary
                 if (addr >= USE_HIMEM) {                  if (addr >= USE_HIMEM) {
                         pos = addr - 0x100000;                          pos = (addr & CPU_ADRSMASK) - 0x100000;
                         if (pos < CPU_EXTMEMSIZE) {                          if (pos < CPU_EXTMEMSIZE) {
                                 STOREINTELWORD(CPU_EXTMEM + pos, value);                                  STOREINTELWORD(CPU_EXTMEM + pos, value);
                         }                          }
Line 952  void MEMCALL i286_memorywrite_d(UINT32 a Line 944  void MEMCALL i286_memorywrite_d(UINT32 a
   
         UINT32  pos;          UINT32  pos;
   
         addr &= CPU_ADRSMASK;  
         if (addr < (I286_MEMWRITEMAX - 3)) {          if (addr < (I286_MEMWRITEMAX - 3)) {
                 STOREINTELDWORD(mem + addr, value);                  STOREINTELDWORD(mem + addr, value);
                 return;                  return;
         }          }
         else if (addr >= USE_HIMEM) {          else if (addr >= USE_HIMEM) {
                 pos = addr - 0x100000;                  pos = (addr & CPU_ADRSMASK) - 0x100000;
                 if ((pos + 3) < CPU_EXTMEMSIZE) {                  if ((pos + 3) < CPU_EXTMEMSIZE) {
                         STOREINTELDWORD(CPU_EXTMEM + pos, value);                          STOREINTELDWORD(CPU_EXTMEM + pos, value);
                         return;                          return;
Line 975  void MEMCALL i286_memorywrite_d(UINT32 a Line 966  void MEMCALL i286_memorywrite_d(UINT32 a
         }          }
 }  }
   
 #ifdef NP2_MEMORY_ASM  #if 0
 REG8 MEMCALL i286_membyte_read(UINT seg, UINT off) {  REG8 MEMCALL i286_membyte_read(UINT seg, UINT off) {
   
         UINT32  address;          UINT32  address;
Line 1027  void MEMCALL i286_memword_write(UINT seg Line 1018  void MEMCALL i286_memword_write(UINT seg
                 i286_memorywrite_w(address, value);                  i286_memorywrite_w(address, value);
         }          }
 }  }
 #endif /* NP2_MEMORY_ASM */  #endif
   
 void MEMCALL i286_memstr_read(UINT seg, UINT off, void *dat, UINT leng) {  void MEMCALL memp_read(UINT32 address, void *dat, UINT leng) {
   
         BYTE    *out;          BYTE *out = (BYTE *)dat;
         UINT32  adrs;          UINT pos;
         UINT    size;          UINT diff;
   
         out = (BYTE *)dat;          /* fast memory access */
         adrs = seg << 4;          if (address + leng < I286_MEMREADMAX) {
         off = LOW16(off);                  CopyMemory(dat, mem + address, leng);
         if ((I286_MEMREADMAX >= 0x10000) &&                  return;
                 (adrs < (I286_MEMREADMAX - 0x10000))) {          } else if (address >= USE_HIMEM) {
                 if (leng) {                  pos = (address & CPU_ADRSMASK) - 0x100000;
                         size = 0x10000 - off;                  if (pos + leng < CPU_EXTMEMSIZE) {
                         if (size >= leng) {                          CopyMemory(dat, CPU_EXTMEM + pos, leng);
                                 CopyMemory(out, mem + adrs + off, leng);                          return;
                                 return;  
                         }  
                         CopyMemory(out, mem + adrs + off, size);  
                         out += size;  
                         leng -= size;  
                 }  
                 while(leng >= 0x10000) {  
                         CopyMemory(out, mem + adrs, 0x10000);  
                         out += 0x10000;  
                         leng -= 0x10000;  
                 }                  }
                 if (leng) {                  if (pos < CPU_EXTMEMSIZE) {
                         CopyMemory(out, mem + adrs, leng);                          diff = CPU_EXTMEMSIZE - pos;
                           CopyMemory(out, CPU_EXTMEM + pos, diff);
                           out += diff;
                           leng -= diff;
                           address += diff;
                 }                  }
         }          }
         else {  
                 while(leng--) {          /* slow memory access */
                         *out++ = i286_memoryread(adrs + off);          while (leng-- > 0) {
                         off = LOW16(off + 1);                  *out++ = i286_memoryread(address++);
                 }  
         }          }
 }  }
   
 void MEMCALL i286_memstr_write(UINT seg, UINT off, const void *dat, UINT leng) {  void MEMCALL memp_write(UINT32 address, const void *dat, UINT leng) {
   
         BYTE    *out;          const BYTE *out = (BYTE *)dat;
         UINT32  adrs;          UINT pos;
         UINT    size;          UINT diff;
   
         out = (BYTE *)dat;          /* fast memory access */
         adrs = seg << 4;          if (address + leng < I286_MEMREADMAX) {
         off = LOW16(off);                  CopyMemory(mem + address, dat, leng);
         if ((I286_MEMWRITEMAX >= 0x10000) &&                  return;
                 (adrs < (I286_MEMWRITEMAX - 0x10000))) {          } else if (address >= USE_HIMEM) {
                 if (leng) {                  pos = (address & CPU_ADRSMASK) - 0x100000;
                         size = 0x10000 - off;                  if (pos + leng < CPU_EXTMEMSIZE) {
                         if (size >= leng) {                          CopyMemory(CPU_EXTMEM + pos, dat, leng);
                                 CopyMemory(mem + adrs + off, out, leng);                          return;
                                 return;  
                         }  
                         CopyMemory(mem + adrs + off, out, size);  
                         out += size;  
                         leng -= size;  
                 }  
                 while(leng >= 0x10000) {  
                         CopyMemory(mem + adrs, out, 0x10000);  
                         out += 0x10000;  
                         leng -= 0x10000;  
                 }                  }
                 if (leng) {                  if (pos < CPU_EXTMEMSIZE) {
                         CopyMemory(mem + adrs, out, leng);                          diff = CPU_EXTMEMSIZE - pos;
                           CopyMemory(CPU_EXTMEM + pos, dat, diff);
                           out += diff;
                           leng -= diff;
                           address += diff;
                 }                  }
         }          }
         else {  
                 while(leng--) {          /* slow memory access */
                         i286_memorywrite(adrs + off, *out++);          while (leng-- > 0) {
                         off = LOW16(off + 1);                  i286_memorywrite(address++, *out++);
                 }  
         }          }
 }  }
   
 void MEMCALL i286_memx_read(UINT32 address, void *dat, UINT leng) {  
   
         if ((address + leng) < I286_MEMREADMAX) {  // ---- Logical Space (BIOS)
                 CopyMemory(dat, mem + address, leng);  
         }  static UINT32 physicaladdr(UINT32 addr) {
         else {  
                 BYTE *out = (BYTE *)dat;          UINT32  pde;
                 if (address < I286_MEMREADMAX) {          UINT32  pte;
                         CopyMemory(out, mem + address, I286_MEMREADMAX - address);  
                         out += I286_MEMREADMAX - address;          if (CPU_STAT_PAGING) {
                         leng -= I286_MEMREADMAX - address;                  pde = i286_memoryread_d(CPU_STAT_PDE_BASE + ((addr >> 20) & 0xffc));
                         address = I286_MEMREADMAX;                  if (!(pde & CPU_PDE_PRESENT)) {
                           goto retdummy;
                 }                  }
                 while(leng--) {                  pte = cpu_memoryread_d((pde & CPU_PDE_BASEADDR_MASK) + ((addr >> 10) & 0xffc));
                         *out++ = i286_memoryread(address++);                  if (!(pte & CPU_PTE_PRESENT)) {
                           goto retdummy;
                 }                  }
                   addr = (pte & CPU_PTE_BASEADDR_MASK) + (addr & 0x00000fff);
         }          }
           return(addr);
   
   retdummy:
           return(0x01000000);             // てきとーにメモリが存在しない場所
 }  }
   
 void MEMCALL i286_memx_write(UINT32 address, const void *dat, UINT leng) {  void MEMCALL meml_readstr(UINT seg, UINT off, void *dat, UINT leng) {
   
 const BYTE      *out;          UINT32  adrs;
           UINT    size;
   
         if ((address + leng) < I286_MEMWRITEMAX) {          while(leng) {
                 CopyMemory(mem + address, dat, leng);                  off = LOW16(off);
                   adrs = (seg << 4) + off;
                   size = 0x1000 - (adrs & 0xfff);
                   size = min(size, leng);
                   size = min(size, 0x10000 - off);
                   memp_read(physicaladdr(adrs), dat, size);
                   off += size;
                   dat = ((BYTE *)dat) + size;
                   leng -= size;
         }          }
         else {  }
                 out = (BYTE *)dat;  
                 if (address < I286_MEMWRITEMAX) {  void MEMCALL meml_writestr(UINT seg, UINT off, const void *dat, UINT leng) {
                         CopyMemory(mem + address, out, I286_MEMWRITEMAX - address);  
                         out += I286_MEMWRITEMAX - address;          UINT32  adrs;
                         leng -= I286_MEMWRITEMAX - address;          UINT    size;
                         address = I286_MEMWRITEMAX;  
                 }          while(leng) {
                 while(leng--) {                  off = LOW16(off);
                         i286_memorywrite(address++, *out++);                  adrs = (seg << 4) + off;
                 }                  size = 0x1000 - (adrs & 0xfff);
                   size = min(size, leng);
                   size = min(size, 0x10000 - off);
                   memp_write(physicaladdr(adrs), dat, size);
                   off += size;
                   dat = ((BYTE *)dat) + size;
                   leng -= size;
         }          }
 }  }
   
   void MEMCALL meml_read(UINT32 address, void *dat, UINT leng) {
   
           UINT    size;
   
           while(leng) {
                   size = 0x1000 - (address & 0xfff);
                   size = min(size, leng);
                   memp_read(physicaladdr(address), dat, size);
                   address += size;
                   dat = ((BYTE *)dat) + size;
                   leng -= size;
           }
   }
   
   void MEMCALL meml_write(UINT32 address, const void *dat, UINT leng) {
   
           UINT    size;
   
           while(leng) {
                   size = 0x1000 - (address & 0xfff);
                   size = min(size, leng);
                   memp_write(physicaladdr(address), dat, size);
                   address += size;
                   dat = ((BYTE *)dat) + size;
                   leng -= size;
           }
   }
   
 #endif  #endif
   

Removed from v.1.11  
changed lines
  Added in v.1.16


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