Diff for /np2/i286c/i286c.c between versions 1.11 and 1.19

version 1.11, 2003/12/01 10:45:46 version 1.19, 2003/12/26 03:41:05
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 #include        "i286.h"  #include        "cpucore.h"
 #include        "i286c.h"  #include        "i286c.h"
 #include        "v30patch.h"  #include        "v30patch.h"
 #include        "memory.h"  
 #include        "pccore.h"  #include        "pccore.h"
 #include        "iocore.h"  #include        "iocore.h"
 #include        "dmap.h"  #include        "dmap.h"
Line 11 Line 10
   
         I286CORE        i286core;          I286CORE        i286core;
   
 const BYTE iflags[256] = {                                      // Z_FLAG, S_FLAG, P_FLAG  const UINT8 iflags[512] = {                                     // Z_FLAG, S_FLAG, P_FLAG
                         0x44, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00,                          0x44, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00,
                         0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,                          0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,
                         0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,                          0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,
Line 43  const BYTE iflags[256] = {     // Z_FLAG Line 42  const BYTE iflags[256] = {     // Z_FLAG
                         0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,                          0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,
                         0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,                          0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,
                         0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,                          0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,
                         0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84};                          0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,
                           0x45, 0x01, 0x01, 0x05, 0x01, 0x05, 0x05, 0x01,
                           0x01, 0x05, 0x05, 0x01, 0x05, 0x01, 0x01, 0x05,
                           0x01, 0x05, 0x05, 0x01, 0x05, 0x01, 0x01, 0x05,
                           0x05, 0x01, 0x01, 0x05, 0x01, 0x05, 0x05, 0x01,
                           0x01, 0x05, 0x05, 0x01, 0x05, 0x01, 0x01, 0x05,
                           0x05, 0x01, 0x01, 0x05, 0x01, 0x05, 0x05, 0x01,
                           0x05, 0x01, 0x01, 0x05, 0x01, 0x05, 0x05, 0x01,
                           0x01, 0x05, 0x05, 0x01, 0x05, 0x01, 0x01, 0x05,
                           0x01, 0x05, 0x05, 0x01, 0x05, 0x01, 0x01, 0x05,
                           0x05, 0x01, 0x01, 0x05, 0x01, 0x05, 0x05, 0x01,
                           0x05, 0x01, 0x01, 0x05, 0x01, 0x05, 0x05, 0x01,
                           0x01, 0x05, 0x05, 0x01, 0x05, 0x01, 0x01, 0x05,
                           0x05, 0x01, 0x01, 0x05, 0x01, 0x05, 0x05, 0x01,
                           0x01, 0x05, 0x05, 0x01, 0x05, 0x01, 0x01, 0x05,
                           0x01, 0x05, 0x05, 0x01, 0x05, 0x01, 0x01, 0x05,
                           0x05, 0x01, 0x01, 0x05, 0x01, 0x05, 0x05, 0x01,
                           0x81, 0x85, 0x85, 0x81, 0x85, 0x81, 0x81, 0x85,
                           0x85, 0x81, 0x81, 0x85, 0x81, 0x85, 0x85, 0x81,
                           0x85, 0x81, 0x81, 0x85, 0x81, 0x85, 0x85, 0x81,
                           0x81, 0x85, 0x85, 0x81, 0x85, 0x81, 0x81, 0x85,
                           0x85, 0x81, 0x81, 0x85, 0x81, 0x85, 0x85, 0x81,
                           0x81, 0x85, 0x85, 0x81, 0x85, 0x81, 0x81, 0x85,
                           0x81, 0x85, 0x85, 0x81, 0x85, 0x81, 0x81, 0x85,
                           0x85, 0x81, 0x81, 0x85, 0x81, 0x85, 0x85, 0x81,
                           0x85, 0x81, 0x81, 0x85, 0x81, 0x85, 0x85, 0x81,
                           0x81, 0x85, 0x85, 0x81, 0x85, 0x81, 0x81, 0x85,
                           0x81, 0x85, 0x85, 0x81, 0x85, 0x81, 0x81, 0x85,
                           0x85, 0x81, 0x81, 0x85, 0x81, 0x85, 0x85, 0x81,
                           0x81, 0x85, 0x85, 0x81, 0x85, 0x81, 0x81, 0x85,
                           0x85, 0x81, 0x81, 0x85, 0x81, 0x85, 0x85, 0x81,
                           0x85, 0x81, 0x81, 0x85, 0x81, 0x85, 0x85, 0x81,
                           0x81, 0x85, 0x85, 0x81, 0x85, 0x81, 0x81, 0x85};
   
   
 // ----  // ----
   
         BYTE    _szpcflag8[0x200];  
   
 #if !defined(MEMOPTIMIZE)  #if !defined(MEMOPTIMIZE)
         BYTE    _szpflag16[0x10000];          UINT8   _szpflag16[0x10000];
 #endif  #endif
   
 #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2)  #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2)
         BYTE    *_reg8_b53[256];          UINT8   *_reg8_b53[256];
         BYTE    *_reg8_b20[256];          UINT8   *_reg8_b20[256];
 #endif  #endif
 #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2)  #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2)
         UINT16  *_reg16_b53[256];          UINT16  *_reg16_b53[256];
         UINT16  *_reg16_b20[256];          UINT16  *_reg16_b20[256];
 #endif  #endif
   
 void i286_initialize(void) {  void i286c_initialize(void) {
   
         UINT    i;          UINT    i;
         UINT    bit;          UINT    bit;
         BYTE    f;          REG8    f;
   
         for (i=0; i<0x100; i++) {  
                 f = P_FLAG;  
                 for (bit=0x80; bit; bit>>=1) {  
                         if (i & bit) {  
                                 f ^= P_FLAG;  
                         }  
                 }  
                 if (!(i & 0xff)) {  
                         f |= Z_FLAG;  
                 }  
                 if (i & 0x80) {  
                         f |= S_FLAG;  
                 }  
                 _szpcflag8[i+0x000] = f;  
                 _szpcflag8[i+0x100] = f | C_FLAG;  
         }  
   
 #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2)  #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2)
         for (i=0; i<0x100; i++) {          for (i=0; i<0x100; i++) {
Line 95  void i286_initialize(void) { Line 107  void i286_initialize(void) {
                 pos = ((i & 0x20)?0:1);                  pos = ((i & 0x20)?0:1);
 #endif  #endif
                 pos += ((i >> 3) & 3) * 2;                  pos += ((i >> 3) & 3) * 2;
                 _reg8_b53[i] = ((BYTE *)&I286_REG) + pos;                  _reg8_b53[i] = ((UINT8 *)&I286_REG) + pos;
 #if defined(BYTESEX_LITTLE)  #if defined(BYTESEX_LITTLE)
                 pos = ((i & 0x4)?1:0);                  pos = ((i & 0x4)?1:0);
 #else  #else
                 pos = ((i & 0x4)?0:1);                  pos = ((i & 0x4)?0:1);
 #endif  #endif
                 pos += (i & 3) * 2;                  pos += (i & 3) * 2;
                 _reg8_b20[i] = ((BYTE *)&I286_REG) + pos;                  _reg8_b20[i] = ((UINT8 *)&I286_REG) + pos;
 #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2)  #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2)
                 _reg16_b53[i] = ((UINT16 *)&I286_REG) + ((i >> 3) & 7);                  _reg16_b53[i] = ((UINT16 *)&I286_REG) + ((i >> 3) & 7);
                 _reg16_b20[i] = ((UINT16 *)&I286_REG) + (i & 7);                  _reg16_b20[i] = ((UINT16 *)&I286_REG) + (i & 7);
Line 130  void i286_initialize(void) { Line 142  void i286_initialize(void) {
 #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2)  #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2)
         i286cea_initialize();          i286cea_initialize();
 #endif  #endif
         v30init();          v30cinit();
 }  }
   
 void i286_reset(void) {  void i286c_reset(void) {
   
         i286_initialize();          ZeroMemory(&I286_STAT, sizeof(I286_STAT));
         ZeroMemory(&i286core.s, sizeof(i286core.s));          I286_CS = 0xf000;
         I286_CS = 0x1fc0;          CS_BASE = 0xf0000;
         CS_BASE = 0x1fc00;          I286_IP = 0xfff0;
         i286core.s.adrsmask = 0xfffff;          I286_ADRSMASK = 0xfffff;
 }  }
   
 void i286_resetprefetch(void) {  void i286c_shut(void) {
   
           I286_MSW = 0;
   
           I286_ES = 0;
           I286_CS = 0xf000;
           I286_SS = 0;
           I286_DS = 0;
   
           ES_BASE = 0;
           CS_BASE = 0xf0000;
           SS_BASE = 0;
           DS_BASE = 0;
           SS_FIX = 0;
           DS_FIX = 0;
   
           I286_IP = 0xfff0;
           I286_ADRSMASK = 0xfffff;
 }  }
   
 void CPUCALL i286_intnum(UINT vect, REG16 IP) {  void CPUCALL i286c_intnum(UINT vect, REG16 IP) {
   
 const BYTE      *ptr;  const BYTE      *ptr;
   
Line 156  const BYTE *ptr; Line 185  const BYTE *ptr;
         I286_FLAG &= ~(T_FLAG | I_FLAG);          I286_FLAG &= ~(T_FLAG | I_FLAG);
         I286_TRAP = 0;          I286_TRAP = 0;
   
         ptr = I286_MEM + (vect * 4);          ptr = mem + (vect * 4);
         I286_IP = LOADINTELWORD(ptr+0);                         // real mode!          I286_IP = LOADINTELWORD(ptr+0);                         // real mode!
         I286_CS = LOADINTELWORD(ptr+2);                         // real mode!          I286_CS = LOADINTELWORD(ptr+2);                         // real mode!
         CS_BASE = I286_CS << 4;          CS_BASE = I286_CS << 4;
         I286_WORKCLOCK(20);          I286_WORKCLOCK(20);
 }  }
   
 void CPUCALL i286_interrupt(BYTE vect) {  void CPUCALL i286c_interrupt(REG8 vect) {
   
         UINT    op;          UINT    op;
 const BYTE      *ptr;  const BYTE      *ptr;
Line 179  const BYTE *ptr; Line 208  const BYTE *ptr;
         I286_FLAG &= ~(T_FLAG | I_FLAG);          I286_FLAG &= ~(T_FLAG | I_FLAG);
         I286_TRAP = 0;          I286_TRAP = 0;
   
         ptr = I286_MEM + (vect * 4);          ptr = mem + (vect * 4);
         I286_IP = LOADINTELWORD(ptr+0);                         // real mode!          I286_IP = LOADINTELWORD(ptr + 0);                       // real mode!
         I286_CS = LOADINTELWORD(ptr+2);                         // real mode!          I286_CS = LOADINTELWORD(ptr + 2);                       // real mode!
         CS_BASE = I286_CS << 4;          CS_BASE = I286_CS << 4;
         I286_WORKCLOCK(20);          I286_WORKCLOCK(20);
 }  }
   
 void i286(void) {  void i286c(void) {
   
         UINT    opcode;          UINT    opcode;
   
Line 195  void i286(void) { Line 224  void i286(void) {
                         GET_PCBYTE(opcode);                          GET_PCBYTE(opcode);
                         i286op[opcode]();                          i286op[opcode]();
                         if (I286_TRAP) {                          if (I286_TRAP) {
                                 i286_interrupt(1);                                  i286c_interrupt(1);
                         }                          }
                         dmap_i286();                          dmap_i286();
                 } while(I286_REMCLOCK > 0);                  } while(I286_REMCLOCK > 0);
Line 215  void i286(void) { Line 244  void i286(void) {
         }          }
 }  }
   
 void i286_step(void) {  void i286c_step(void) {
   
         UINT    opcode;          UINT    opcode;
   
Line 233  void i286_step(void) { Line 262  void i286_step(void) {
 }  }
   
   
   UINT32 i286c_selector(UINT sel) {
   
           I286DTR *dtr;
           UINT32  addr;
           UINT32  ret;
   
           dtr = (sel & 4)?&I286_LDTRC:&I286_GDTR;
           addr = (dtr->base24 << 16) + dtr->base + (sel & (~7));
           ret = i286_memoryread_w(addr+2);
           ret += i286_memoryread(addr+4) << 16;
           TRACEOUT(("selector idx=%x %s rpl=%d - real addr = %.6x",
                                           (sel >> 3), (sel & 4)?"LDT":"GDT", sel & 3, ret));
           return(ret);
   }
   
   
 // ---- test  // ---- test
   
 #if defined(I286C_TEST)  #if defined(I286C_TEST)
Line 241  BYTE BYTESZPF(UINT r) { Line 286  BYTE BYTESZPF(UINT r) {
         if (r & (~0xff)) {          if (r & (~0xff)) {
                 TRACEOUT(("BYTESZPF bound error: %x", r));                  TRACEOUT(("BYTESZPF bound error: %x", r));
         }          }
         return(_szpcflag8[r & 0xff]);          return(iflags[r & 0xff]);
 }  }
   
 BYTE BYTESZPCF(UINT r) {  BYTE BYTESZPCF(UINT r) {
Line 249  BYTE BYTESZPCF(UINT r) { Line 294  BYTE BYTESZPCF(UINT r) {
         if (r & (~0x1ff)) {          if (r & (~0x1ff)) {
                 TRACEOUT(("BYTESZPCF bound error: %x", r));                  TRACEOUT(("BYTESZPCF bound error: %x", r));
         }          }
         return(_szpcflag8[r & 0x1ff]);          return(iflags[r & 0x1ff]);
 }  }
   
 BYTE WORDSZPF(UINT32 r) {  BYTE WORDSZPF(UINT32 r) {
Line 261  BYTE WORDSZPF(UINT32 r) { Line 306  BYTE WORDSZPF(UINT32 r) {
                 TRACEOUT(("WORDSZPF bound error: %x", r));                  TRACEOUT(("WORDSZPF bound error: %x", r));
         }          }
         f1 = _szpflag16[r & 0xffff];          f1 = _szpflag16[r & 0xffff];
         f2 = _szpcflag8[r & 0xff] & P_FLAG;          f2 = iflags[r & 0xff] & P_FLAG;
         f2 += (r)?0:Z_FLAG;          f2 += (r)?0:Z_FLAG;
         f2 += (r >> 8) & S_FLAG;          f2 += (r >> 8) & S_FLAG;
         if (f1 != f2) {          if (f1 != f2) {
Line 281  BYTE WORDSZPCF(UINT32 r) { Line 326  BYTE WORDSZPCF(UINT32 r) {
         f1 = (r >> 16) & 1;          f1 = (r >> 16) & 1;
         f1 += _szpflag16[LOW16(r)];          f1 += _szpflag16[LOW16(r)];
   
         f2 = _szpcflag8[r & 0xff] & P_FLAG;          f2 = iflags[r & 0xff] & P_FLAG;
         f2 += (LOW16(r))?0:Z_FLAG;          f2 += (LOW16(r))?0:Z_FLAG;
         f2 += (r >> 8) & S_FLAG;          f2 += (r >> 8) & S_FLAG;
         f2 += (r >> 16) & 1;          f2 += (r >> 16) & 1;

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


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