|
|
| version 1.17, 2003/12/25 20:30:22 | version 1.28, 2005/03/18 06:49:16 |
|---|---|
| Line 4 | Line 4 |
| #include "v30patch.h" | #include "v30patch.h" |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "dmap.h" | #include "dmax86.h" |
| #include "i286c.mcr" | #include "i286c.mcr" |
| #if defined(ENABLE_TRAP) | |
| #include "steptrap.h" | |
| #endif | |
| I286CORE i286core; | I286CORE i286core; |
| Line 94 const UINT8 iflags[512] = { // Z_FLA | Line 97 const UINT8 iflags[512] = { // Z_FLA |
| void i286c_initialize(void) { | void i286c_initialize(void) { |
| #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2) | |
| UINT i; | UINT i; |
| UINT bit; | #endif |
| REG8 f; | |
| #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2) | #if !defined(MEMOPTIMIZE) || (MEMOPTIMIZE < 2) |
| for (i=0; i<0x100; i++) { | for (i=0; i<0x100; i++) { |
| Line 124 void i286c_initialize(void) { | Line 127 void i286c_initialize(void) { |
| #if !defined(MEMOPTIMIZE) | #if !defined(MEMOPTIMIZE) |
| for (i=0; i<0x10000; i++) { | for (i=0; i<0x10000; i++) { |
| REG8 f; | |
| UINT bit; | |
| f = P_FLAG; | f = P_FLAG; |
| for (bit=0x80; bit; bit>>=1) { | for (bit=0x80; bit; bit>>=1) { |
| if (i & bit) { | if (i & bit) { |
| Line 143 void i286c_initialize(void) { | Line 148 void i286c_initialize(void) { |
| i286cea_initialize(); | i286cea_initialize(); |
| #endif | #endif |
| v30cinit(); | v30cinit(); |
| ZeroMemory(&i286core, sizeof(i286core)); | |
| } | } |
| void i286c_reset(void) { | void i286c_deinitialize(void) { |
| if (CPU_EXTMEM) { | |
| _MFREE(CPU_EXTMEM); | |
| CPU_EXTMEM = NULL; | |
| CPU_EXTMEMSIZE = 0; | |
| } | |
| } | |
| static void i286c_initreg(void) { | |
| ZeroMemory(&I286_STAT, sizeof(I286_STAT)); | |
| I286_CS = 0xf000; | I286_CS = 0xf000; |
| CS_BASE = 0xf0000; | CS_BASE = 0xf0000; |
| I286_IP = 0xfff0; | I286_IP = 0xfff0; |
| I286_ADRSMASK = 0xfffff; | I286_ADRSMASK = 0xfffff; |
| } | } |
| void i286c_reset(void) { | |
| ZeroMemory(&i286core.s, sizeof(i286core.s)); | |
| i286c_initreg(); | |
| } | |
| void i286c_shut(void) { | void i286c_shut(void) { |
| I286_MSW = 0; | ZeroMemory(&i286core.s, offsetof(I286STAT, cpu_type)); |
| i286c_initreg(); | |
| } | |
| I286_ES = 0; | void i286c_setextsize(UINT32 size) { |
| I286_CS = 0xf000; | |
| I286_SS = 0; | |
| I286_DS = 0; | |
| ES_BASE = 0; | if (CPU_EXTMEMSIZE != size) { |
| CS_BASE = 0xf0000; | UINT8 *extmem; |
| SS_BASE = 0; | extmem = CPU_EXTMEM; |
| DS_BASE = 0; | if (extmem != NULL) { |
| SS_FIX = 0; | _MFREE(extmem); |
| DS_FIX = 0; | extmem = NULL; |
| } | |
| if (size != 0) { | |
| extmem = (UINT8 *)_MALLOC(size + 16, "EXTMEM"); | |
| } | |
| if (extmem != NULL) { | |
| CPU_EXTMEM = extmem; | |
| CPU_EXTMEMSIZE = size; | |
| CPU_EXTMEMBASE = CPU_EXTMEM - 0x100000; | |
| CPU_EXTLIMIT16 = min(size + 0x100000, 0xf00000); | |
| #if defined(CPU_EXTLIMIT) | |
| CPU_EXTLIMIT = size + 0x100000; | |
| #endif | |
| } | |
| else { | |
| CPU_EXTMEM = NULL; | |
| CPU_EXTMEMSIZE = 0; | |
| CPU_EXTMEMBASE = NULL; | |
| CPU_EXTLIMIT16 = 0; | |
| #if defined(CPU_EXTLIMIT) | |
| CPU_EXTLIMIT = 0; | |
| #endif | |
| } | |
| } | |
| i286core.e.ems[0] = mem + 0xc0000; | |
| i286core.e.ems[1] = mem + 0xc4000; | |
| i286core.e.ems[2] = mem + 0xc8000; | |
| i286core.e.ems[3] = mem + 0xcc000; | |
| } | |
| I286_IP = 0xfff0; | void i286c_setemm(UINT frame, UINT32 addr) { |
| I286_ADRSMASK = 0xfffff; | |
| UINT8 *ptr; | |
| frame &= 3; | |
| if (addr < USE_HIMEM) { | |
| ptr = mem + addr; | |
| } | |
| else if ((addr - 0x100000 + 0x4000) <= CPU_EXTMEMSIZE) { | |
| ptr = CPU_EXTMEM + (addr - 0x100000); | |
| } | |
| else { | |
| ptr = mem + 0xc0000 + (frame << 14); | |
| } | |
| i286core.e.ems[frame] = ptr; | |
| } | } |
| void CPUCALL i286c_intnum(UINT vect, REG16 IP) { | void CPUCALL i286c_intnum(UINT vect, REG16 IP) { |
| const BYTE *ptr; | const UINT8 *ptr; |
| REGPUSH0(REAL_FLAGREG) | REGPUSH0(REAL_FLAGREG) |
| REGPUSH0(I286_CS) | REGPUSH0(I286_CS) |
| Line 195 const BYTE *ptr; | Line 256 const BYTE *ptr; |
| void CPUCALL i286c_interrupt(REG8 vect) { | void CPUCALL i286c_interrupt(REG8 vect) { |
| UINT op; | UINT op; |
| const BYTE *ptr; | const UINT8 *ptr; |
| op = i286_memoryread(I286_IP + CS_BASE); | op = i286_memoryread(I286_IP + CS_BASE); |
| if (op == 0xf4) { // hlt | if (op == 0xf4) { // hlt |
| Line 221 void i286c(void) { | Line 282 void i286c(void) { |
| if (I286_TRAP) { | if (I286_TRAP) { |
| do { | do { |
| #if defined(ENABLE_TRAP) | |
| steptrap(CPU_CS, CPU_IP); | |
| #endif | |
| GET_PCBYTE(opcode); | GET_PCBYTE(opcode); |
| i286op[opcode](); | i286op[opcode](); |
| if (I286_TRAP) { | if (I286_TRAP) { |
| i286c_interrupt(1); | i286c_interrupt(1); |
| } | } |
| dmap_i286(); | dmax86(); |
| } while(I286_REMCLOCK > 0); | } while(I286_REMCLOCK > 0); |
| } | } |
| else if (dmac.working) { | else if (dmac.working) { |
| do { | do { |
| #if defined(ENABLE_TRAP) | |
| steptrap(CPU_CS, CPU_IP); | |
| #endif | |
| GET_PCBYTE(opcode); | GET_PCBYTE(opcode); |
| i286op[opcode](); | i286op[opcode](); |
| dmap_i286(); | dmax86(); |
| } while(I286_REMCLOCK > 0); | } while(I286_REMCLOCK > 0); |
| } | } |
| else { | else { |
| do { | do { |
| #if defined(ENABLE_TRAP) | |
| steptrap(CPU_CS, CPU_IP); | |
| #endif | |
| GET_PCBYTE(opcode); | GET_PCBYTE(opcode); |
| i286op[opcode](); | i286op[opcode](); |
| } while(I286_REMCLOCK > 0); | } while(I286_REMCLOCK > 0); |
| Line 258 void i286c_step(void) { | Line 328 void i286c_step(void) { |
| if (I286_OV) { | if (I286_OV) { |
| I286_FLAG |= (O_FLAG); | I286_FLAG |= (O_FLAG); |
| } | } |
| dmap_i286(); | dmax86(); |
| } | } |
| // ---- test | // ---- test |
| #if defined(I286C_TEST) | #if defined(I286C_TEST) |
| BYTE BYTESZPF(UINT r) { | UINT8 BYTESZPF(UINT r) { |
| if (r & (~0xff)) { | if (r & (~0xff)) { |
| TRACEOUT(("BYTESZPF bound error: %x", r)); | TRACEOUT(("BYTESZPF bound error: %x", r)); |
| Line 273 BYTE BYTESZPF(UINT r) { | Line 343 BYTE BYTESZPF(UINT r) { |
| return(iflags[r & 0xff]); | return(iflags[r & 0xff]); |
| } | } |
| BYTE BYTESZPCF(UINT r) { | UINT8 BYTESZPCF(UINT r) { |
| if (r & (~0x1ff)) { | if (r & (~0x1ff)) { |
| TRACEOUT(("BYTESZPCF bound error: %x", r)); | TRACEOUT(("BYTESZPCF bound error: %x", r)); |
| Line 281 BYTE BYTESZPCF(UINT r) { | Line 351 BYTE BYTESZPCF(UINT r) { |
| return(iflags[r & 0x1ff]); | return(iflags[r & 0x1ff]); |
| } | } |
| BYTE WORDSZPF(UINT32 r) { | UINT8 WORDSZPF(UINT32 r) { |
| BYTE f1; | UINT8 f1; |
| BYTE f2; | UINT8 f2; |
| if (r & (~0xffff)) { | if (r & (~0xffff)) { |
| TRACEOUT(("WORDSZPF bound error: %x", r)); | TRACEOUT(("WORDSZPF bound error: %x", r)); |
| Line 299 BYTE WORDSZPF(UINT32 r) { | Line 369 BYTE WORDSZPF(UINT32 r) { |
| return(f1); | return(f1); |
| } | } |
| BYTE WORDSZPCF(UINT32 r) { | UINT8 WORDSZPCF(UINT32 r) { |
| BYTE f1; | UINT8 f1; |
| BYTE f2; | UINT8 f2; |
| if ((r & 0xffff0000) && (!(r & 0x00010000))) { | if ((r & 0xffff0000) && (!(r & 0x00010000))) { |
| TRACEOUT(("WORDSZPCF bound error: %x", r)); | TRACEOUT(("WORDSZPCF bound error: %x", r)); |