|
|
| version 1.7, 2003/12/22 01:44:59 | version 1.10, 2005/05/20 13:59:46 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "cpucore.h" | #include "cpucore.h" |
| #include "egcmem.h" | |
| #include "pccore.h" | |
| #include "iocore.h" | |
| #include "vram.h" | |
| #include "font.h" | |
| #define USE_HIMEM 0x110000 | #define USE_HIMEM 0x110000 |
| REG8 MEMCALL i286_membyte_read(UINT seg, UINT off) { | void MEMCALL memp_reads(UINT32 address, void *dat, UINT leng) { |
| UINT32 address; | if ((address + leng) < I286_MEMREADMAX) { |
| CopyMemory(dat, mem + address, leng); | |
| address = (seg << 4) + LOW16(off); | |
| if (address < I286_MEMREADMAX) { | |
| return(mem[address]); | |
| } | |
| else { | |
| return(i286_memoryread(address)); | |
| } | |
| } | |
| REG16 MEMCALL i286_memword_read(UINT seg, UINT off) { | |
| UINT32 address; | |
| address = (seg << 4) + LOW16(off); | |
| if (address < (I286_MEMREADMAX - 1)) { | |
| return(LOADINTELWORD(mem + address)); | |
| } | } |
| else { | else { |
| return(i286_memoryread_w(address)); | UINT8 *out = (UINT8 *)dat; |
| if (address < I286_MEMREADMAX) { | |
| CopyMemory(out, mem + address, I286_MEMREADMAX - address); | |
| out += I286_MEMREADMAX - address; | |
| leng -= I286_MEMREADMAX - address; | |
| address = I286_MEMREADMAX; | |
| } | |
| while(leng--) { | |
| *out++ = memp_read8(address++); | |
| } | |
| } | } |
| } | } |
| void MEMCALL i286_membyte_write(UINT seg, UINT off, REG8 value) { | void MEMCALL memp_writes(UINT32 address, const void *dat, UINT leng) { |
| UINT32 address; | const UINT8 *out; |
| address = (seg << 4) + LOW16(off); | if ((address + leng) < I286_MEMWRITEMAX) { |
| if (address < I286_MEMWRITEMAX) { | CopyMemory(mem + address, dat, leng); |
| mem[address] = (BYTE)value; | |
| } | } |
| else { | else { |
| i286_memorywrite(address, value); | out = (UINT8 *)dat; |
| if (address < I286_MEMWRITEMAX) { | |
| CopyMemory(mem + address, out, I286_MEMWRITEMAX - address); | |
| out += I286_MEMWRITEMAX - address; | |
| leng -= I286_MEMWRITEMAX - address; | |
| address = I286_MEMWRITEMAX; | |
| } | |
| while(leng--) { | |
| memp_write8(address++, *out++); | |
| } | |
| } | } |
| } | } |
| void MEMCALL i286_memword_write(UINT seg, UINT off, REG16 value) { | |
| UINT32 address; | |
| address = (seg << 4) + LOW16(off); | |
| if (address < (I286_MEMWRITEMAX - 1)) { | |
| STOREINTELWORD(mem + address, value); | |
| } | |
| else { | |
| i286_memorywrite_w(address, value); | |
| } | |
| } | |
| void MEMCALL i286_memstr_read(UINT seg, UINT off, void *dat, UINT leng) { | void MEMCALL memr_reads(UINT seg, UINT off, void *dat, UINT leng) { |
| BYTE *out; | UINT8 *out; |
| UINT32 adrs; | UINT32 adrs; |
| UINT size; | UINT size; |
| out = (BYTE *)dat; | out = (UINT8 *)dat; |
| adrs = seg << 4; | adrs = seg << 4; |
| off = LOW16(off); | off = LOW16(off); |
| if ((I286_MEMREADMAX >= 0x10000) && | if ((I286_MEMREADMAX >= 0x10000) && |
| Line 93 void MEMCALL i286_memstr_read(UINT seg, | Line 77 void MEMCALL i286_memstr_read(UINT seg, |
| } | } |
| else { | else { |
| while(leng--) { | while(leng--) { |
| *out++ = i286_memoryread(adrs + off); | *out++ = memp_read8(adrs + off); |
| off = LOW16(off + 1); | off = LOW16(off + 1); |
| } | } |
| } | } |
| } | } |
| void MEMCALL i286_memstr_write(UINT seg, UINT off, | void MEMCALL memr_writes(UINT seg, UINT off, const void *dat, UINT leng) { |
| const void *dat, UINT leng) { | |
| BYTE *out; | UINT8 *out; |
| UINT32 adrs; | UINT32 adrs; |
| UINT size; | UINT size; |
| out = (BYTE *)dat; | out = (UINT8 *)dat; |
| adrs = seg << 4; | adrs = seg << 4; |
| off = LOW16(off); | off = LOW16(off); |
| if ((I286_MEMWRITEMAX >= 0x10000) && | if ((I286_MEMWRITEMAX >= 0x10000) && |
| Line 132 void MEMCALL i286_memstr_write(UINT seg, | Line 115 void MEMCALL i286_memstr_write(UINT seg, |
| } | } |
| else { | else { |
| while(leng--) { | while(leng--) { |
| i286_memorywrite(adrs + off, *out++); | memp_write8(adrs + off, *out++); |
| off = LOW16(off + 1); | off = LOW16(off + 1); |
| } | } |
| } | } |
| } | } |
| void MEMCALL i286_memx_read(UINT32 address, void *dat, UINT leng) { | |
| if ((address + leng) < I286_MEMREADMAX) { | |
| CopyMemory(dat, mem + address, leng); | |
| } | |
| else { | |
| BYTE *out = (BYTE *)dat; | |
| if (address < I286_MEMREADMAX) { | |
| CopyMemory(out, mem + address, I286_MEMREADMAX - address); | |
| out += I286_MEMREADMAX - address; | |
| leng -= I286_MEMREADMAX - address; | |
| address = I286_MEMREADMAX; | |
| } | |
| while(leng--) { | |
| *out++ = i286_memoryread(address++); | |
| } | |
| } | |
| } | |
| void MEMCALL i286_memx_write(UINT32 address, const void *dat, UINT leng) { | |
| const BYTE *out; | |
| if ((address + leng) < I286_MEMWRITEMAX) { | |
| CopyMemory(mem + address, dat, leng); | |
| } | |
| else { | |
| out = (BYTE *)dat; | |
| if (address < I286_MEMWRITEMAX) { | |
| CopyMemory(mem + address, out, I286_MEMWRITEMAX - address); | |
| out += I286_MEMWRITEMAX - address; | |
| leng -= I286_MEMWRITEMAX - address; | |
| address = I286_MEMWRITEMAX; | |
| } | |
| while(leng--) { | |
| i286_memorywrite(address++, *out++); | |
| } | |
| } | |
| } | |