--- np2/i286c/memory.c 2003/12/08 17:57:29 1.11 +++ np2/i286c/memory.c 2003/12/22 01:44:59 1.15 @@ -1,6 +1,5 @@ #include "compiler.h" #include "cpucore.h" -#include "memory.h" #include "egcmem.h" #include "pccore.h" #include "iocore.h" @@ -8,7 +7,11 @@ #include "font.h" -#define USE_HIMEM + BYTE mem[0x200000]; + + +#define USE_HIMEM 0x10fff0 + #if defined(TRACE) #define MEMORY_DEBUG #endif @@ -22,7 +25,7 @@ static void MEMCALL i286_wt(UINT32 addre static void MEMCALL tram_wt(UINT32 address, REG8 value) { - CPU_REMCLOCK -= vramop.tramwait; + CPU_REMCLOCK -= MEMWAIT_TRAM; if (address < 0xa2000) { mem[address] = (BYTE)value; tramupdate[LOW12(address >> 1)] = 1; @@ -54,7 +57,7 @@ static void MEMCALL tram_wt(UINT32 addre static void MEMCALL vram_w0(UINT32 address, REG8 value) { - CPU_REMCLOCK -= vramop.vramwait; + CPU_REMCLOCK -= MEMWAIT_VRAM; mem[address] = (BYTE)value; vramupdate[LOW15(address)] |= 1; gdcs.grphdisp |= 1; @@ -62,7 +65,7 @@ static void MEMCALL vram_w0(UINT32 addre static void MEMCALL vram_w1(UINT32 address, REG8 value) { - CPU_REMCLOCK -= vramop.vramwait; + CPU_REMCLOCK -= MEMWAIT_VRAM; mem[address + VRAM_STEP] = (BYTE)value; vramupdate[LOW15(address)] |= 2; gdcs.grphdisp |= 2; @@ -73,7 +76,7 @@ static void MEMCALL grcg_rmw0(UINT32 add REG8 mask; BYTE *vram; - CPU_REMCLOCK -= vramop.grcgwait; + CPU_REMCLOCK -= MEMWAIT_GRCG; mask = ~value; address = LOW15(address); vramupdate[address] |= 1; @@ -102,7 +105,7 @@ static void MEMCALL grcg_rmw1(UINT32 add REG8 mask; BYTE *vram; - CPU_REMCLOCK -= vramop.grcgwait; + CPU_REMCLOCK -= MEMWAIT_GRCG; mask = ~value; address = LOW15(address); vramupdate[address] |= 2; @@ -130,7 +133,7 @@ static void MEMCALL grcg_tdw0(UINT32 add BYTE *vram; - CPU_REMCLOCK -= vramop.grcgwait; + CPU_REMCLOCK -= MEMWAIT_GRCG; address = LOW15(address); vramupdate[address] |= 1; gdcs.grphdisp |= 1; @@ -154,7 +157,7 @@ static void MEMCALL grcg_tdw1(UINT32 add BYTE *vram; - CPU_REMCLOCK -= vramop.grcgwait; + CPU_REMCLOCK -= MEMWAIT_GRCG; address = LOW15(address); vramupdate[address] |= 2; gdcs.grphdisp |= 2; @@ -176,6 +179,7 @@ static void MEMCALL grcg_tdw1(UINT32 add static void MEMCALL egc_wt(UINT32 address, REG8 value) { + CPU_REMCLOCK -= MEMWAIT_GRCG; egc_write(address, value); } @@ -200,7 +204,7 @@ static REG8 MEMCALL i286_rd(UINT32 addre static REG8 MEMCALL tram_rd(UINT32 address) { - CPU_REMCLOCK -= vramop.tramwait; + CPU_REMCLOCK -= MEMWAIT_TRAM; if (address < 0xa4000) { return(mem[address]); } @@ -217,13 +221,13 @@ static REG8 MEMCALL tram_rd(UINT32 addre static REG8 MEMCALL vram_r0(UINT32 address) { - CPU_REMCLOCK -= vramop.vramwait; + CPU_REMCLOCK -= MEMWAIT_VRAM; return(mem[address]); } static REG8 MEMCALL vram_r1(UINT32 address) { - CPU_REMCLOCK -= vramop.vramwait; + CPU_REMCLOCK -= MEMWAIT_VRAM; return(mem[address + VRAM_STEP]); } @@ -232,7 +236,7 @@ static REG8 MEMCALL grcg_tcr0(UINT32 add const BYTE *vram; REG8 ret; - CPU_REMCLOCK -= vramop.grcgwait; + CPU_REMCLOCK -= MEMWAIT_GRCG; vram = mem + LOW15(address); ret = 0; if (!(grcg.modereg & 1)) { @@ -255,7 +259,7 @@ static REG8 MEMCALL grcg_tcr1(UINT32 add const BYTE *vram; REG8 ret; - CPU_REMCLOCK -= vramop.grcgwait; + CPU_REMCLOCK -= MEMWAIT_GRCG; ret = 0; vram = mem + LOW15(address); if (!(grcg.modereg & 1)) { @@ -275,6 +279,7 @@ const BYTE *vram; static REG8 MEMCALL egc_rd(UINT32 address) { + CPU_REMCLOCK -= MEMWAIT_GRCG; return(egc_read(address)); } @@ -304,6 +309,7 @@ static void MEMCALL i286w_wt(UINT32 addr static void MEMCALL tramw_wt(UINT32 address, REG16 value) { + CPU_REMCLOCK -= MEMWAIT_TRAM; if (address < 0xa1fff) { STOREINTELWORD(mem + address, value); tramupdate[LOW12(address >> 1)] = 1; @@ -349,7 +355,7 @@ static void MEMCALL tramw_wt(UINT32 addr #define GRCGW_NON(page) { \ - CPU_REMCLOCK -= vramop.vramwait; \ + CPU_REMCLOCK -= MEMWAIT_VRAM; \ STOREINTELWORD(mem + address + VRAM_STEP*(page), value); \ vramupdate[LOW15(address)] |= (1 << page); \ vramupdate[LOW15(address + 1)] |= (1 << page); \ @@ -358,7 +364,7 @@ static void MEMCALL tramw_wt(UINT32 addr #define GRCGW_RMW(page) { \ BYTE *vram; \ - CPU_REMCLOCK -= vramop.grcgwait; \ + CPU_REMCLOCK -= MEMWAIT_GRCG; \ address = LOW15(address); \ vramupdate[address] |= (1 << page); \ vramupdate[address + 1] |= (1 << page); \ @@ -404,7 +410,7 @@ static void MEMCALL tramw_wt(UINT32 addr #define GRCGW_TDW(page) { \ BYTE *vram; \ - CPU_REMCLOCK -= vramop.grcgwait; \ + CPU_REMCLOCK -= MEMWAIT_GRCG; \ address = LOW15(address); \ vramupdate[address] |= (1 << page); \ vramupdate[address + 1] |= (1 << page); \ @@ -438,6 +444,7 @@ static void MEMCALL grcgw_tdw1(UINT32 ad static void MEMCALL egcw_wt(UINT32 address, REG16 value) { + CPU_REMCLOCK -= MEMWAIT_GRCG; if (!(address & 1)) { egc_write_w(address, value); } @@ -486,7 +493,7 @@ static REG16 MEMCALL i286w_rd(UINT32 add static REG16 MEMCALL tramw_rd(UINT32 address) { - CPU_REMCLOCK -= vramop.tramwait; + CPU_REMCLOCK -= MEMWAIT_TRAM; if (address < (0xa4000 - 1)) { return(LOADINTELWORD(mem + address)); } @@ -515,13 +522,13 @@ static REG16 MEMCALL tramw_rd(UINT32 add static REG16 MEMCALL vramw_r0(UINT32 address) { - CPU_REMCLOCK -= vramop.vramwait; + CPU_REMCLOCK -= MEMWAIT_VRAM; return(LOADINTELWORD(mem + address)); } static REG16 MEMCALL vramw_r1(UINT32 address) { - CPU_REMCLOCK -= vramop.vramwait; + CPU_REMCLOCK -= MEMWAIT_VRAM; return(LOADINTELWORD(mem + address + VRAM_STEP)); } @@ -530,7 +537,7 @@ static REG16 MEMCALL grcgw_tcr0(UINT32 a BYTE *vram; REG16 ret; - CPU_REMCLOCK -= vramop.grcgwait; + CPU_REMCLOCK -= MEMWAIT_GRCG; ret = 0; vram = mem + LOW15(address); if (!(grcg.modereg & 1)) { @@ -553,7 +560,7 @@ static REG16 MEMCALL grcgw_tcr1(UINT32 a BYTE *vram; REG16 ret; - CPU_REMCLOCK -= vramop.grcgwait; + CPU_REMCLOCK -= MEMWAIT_GRCG; ret = 0; vram = mem + LOW15(address); if (!(grcg.modereg & 1)) { @@ -575,6 +582,7 @@ static REG16 MEMCALL egcw_rd(UINT32 addr REG16 ret; + CPU_REMCLOCK -= MEMWAIT_GRCG; if (!(address & 1)) { return(egc_read_w(address)); } @@ -747,7 +755,7 @@ static REG8 MEMCALL _i286_memoryread(UIN return(mem[address]); } #if defined(USE_HIMEM) - else if (address >= 0x10fff0) { + else if (address >= USE_HIMEM) { address -= 0x100000; if (address < CPU_EXTMEMSIZE) { return(CPU_EXTMEM[address]); @@ -770,9 +778,9 @@ static REG16 MEMCALL _i286_memoryread_w( return(LOADINTELWORD(mem + address)); } #if defined(USE_HIMEM) - else if (address >= (0x10fff0 - 1)) { + else if (address >= (USE_HIMEM - 1)) { address -= 0x100000; - if (address == (0x00fff0 - 1)) { + if (address == (USE_HIMEM - 0x100000 - 1)) { ret = mem[0x100000 + address]; } else if (address < CPU_EXTMEMSIZE) { @@ -830,7 +838,7 @@ REG8 MEMCALL i286_memoryread(UINT32 addr return(mem[address]); } #if defined(USE_HIMEM) - else if (address >= 0x10fff0) { + else if (address >= USE_HIMEM) { address -= 0x100000; if (address < CPU_EXTMEMSIZE) { return(CPU_EXTMEM[address]); @@ -853,9 +861,9 @@ REG16 MEMCALL i286_memoryread_w(UINT32 a return(LOADINTELWORD(mem + address)); } #if defined(USE_HIMEM) - else if (address >= (0x10fff0 - 1)) { + else if (address >= (USE_HIMEM - 1)) { address -= 0x100000; - if (address == (0x00fff0 - 1)) { + if (address == (USE_HIMEM - 0x100000 - 1)) { ret = mem[0x100000 + address]; } else if (address < CPU_EXTMEMSIZE) { @@ -892,7 +900,7 @@ void MEMCALL i286_memorywrite(UINT32 add mem[address] = (BYTE)value; } #if defined(USE_HIMEM) - else if (address >= 0x10fff0) { + else if (address >= USE_HIMEM) { address -= 0x100000; if (address < CPU_EXTMEMSIZE) { CPU_EXTMEM[address] = (BYTE)value; @@ -910,9 +918,9 @@ void MEMCALL i286_memorywrite_w(UINT32 a STOREINTELWORD(mem + address, value); } #if defined(USE_HIMEM) - else if (address >= (0x10fff0 - 1)) { + else if (address >= (USE_HIMEM - 1)) { address -= 0x100000; - if (address == (0x00fff0 - 1)) { + if (address == (USE_HIMEM - 0x100000 - 1)) { mem[address] = (BYTE)value; } else if (address < CPU_EXTMEMSIZE) { @@ -938,7 +946,7 @@ REG8 MEMCALL i286_membyte_read(UINT seg, UINT32 address; - address = (seg << 4) + off; + address = (seg << 4) + LOW16(off); if (address < I286_MEMREADMAX) { return(mem[address]); } @@ -951,7 +959,7 @@ REG16 MEMCALL i286_memword_read(UINT seg UINT32 address; - address = (seg << 4) + off; + address = (seg << 4) + LOW16(off); if (address < (I286_MEMREADMAX - 1)) { return(LOADINTELWORD(mem + address)); } @@ -964,7 +972,7 @@ void MEMCALL i286_membyte_write(UINT seg UINT32 address; - address = (seg << 4) + off; + address = (seg << 4) + LOW16(off); if (address < I286_MEMWRITEMAX) { mem[address] = (BYTE)value; } @@ -977,7 +985,7 @@ void MEMCALL i286_memword_write(UINT seg UINT32 address; - address = (seg << 4) + off; + address = (seg << 4) + LOW16(off); if (address < (I286_MEMWRITEMAX - 1)) { STOREINTELWORD(mem + address, value); } @@ -994,6 +1002,7 @@ void MEMCALL i286_memstr_read(UINT seg, out = (BYTE *)dat; adrs = seg << 4; + off = LOW16(off); if ((I286_MEMREADMAX >= 0x10000) && (adrs < (I286_MEMREADMAX - 0x10000))) { if (leng) { @@ -1032,6 +1041,7 @@ void MEMCALL i286_memstr_write(UINT seg, out = (BYTE *)dat; adrs = seg << 4; + off = LOW16(off); if ((I286_MEMWRITEMAX >= 0x10000) && (adrs < (I286_MEMWRITEMAX - 0x10000))) { if (leng) {