--- np2/i286c/memory.c 2003/11/29 03:38:26 1.6 +++ np2/i286c/memory.c 2003/12/03 07:59:57 1.9 @@ -9,13 +9,15 @@ #define USE_HIMEM -// #define MEMORY_DEBUG +#if defined(TRACE) +#define MEMORY_DEBUG +#endif // ---- write byte static void MEMCALL i286_wt(UINT32 address, REG8 value) { - mem[address & extmem.adrsmask] = (BYTE)value; + mem[address & i286core.s.adrsmask] = (BYTE)value; } static void MEMCALL tram_wt(UINT32 address, REG8 value) { @@ -193,7 +195,7 @@ static void MEMCALL i286_wn(UINT32 addre static REG8 MEMCALL i286_rd(UINT32 address) { - return(mem[address & extmem.adrsmask]); + return(mem[address & i286core.s.adrsmask]); } static REG8 MEMCALL tram_rd(UINT32 address) { @@ -283,7 +285,7 @@ static REG8 MEMCALL emmc_rd(UINT32 addre static REG8 MEMCALL i286_itf(UINT32 address) { - if (itf.bank) { + if (i286core.s.itfbank) { address = ITF_ADRS + LOW15(address); } return(mem[address]); @@ -296,7 +298,7 @@ static void MEMCALL i286w_wt(UINT32 addr BYTE *ptr; - ptr = mem + (address & extmem.adrsmask); + ptr = mem + (address & i286core.s.adrsmask); STOREINTELWORD(ptr, value); } @@ -461,7 +463,7 @@ static void MEMCALL emmcw_wt(UINT32 addr } else { extmem.pageptr[(address >> 14) & 3][0x3fff] = (BYTE)value; - extmem.pageptr[((address + 1)>> 14) & 3][0] = (BYTE)(value >> 8); + extmem.pageptr[((address + 1) >> 14) & 3][0] = (BYTE)(value >> 8); } } @@ -478,7 +480,7 @@ static REG16 MEMCALL i286w_rd(UINT32 add BYTE *ptr; - ptr = mem + (address & extmem.adrsmask); + ptr = mem + (address & i286core.s.adrsmask); return(LOADINTELWORD(ptr)); } @@ -592,15 +594,23 @@ static REG16 MEMCALL egcw_rd(UINT32 addr static REG16 MEMCALL emmcw_rd(UINT32 address) { - BYTE *ptr; +const BYTE *ptr; + REG16 ret; - ptr = extmem.pageptr[(address >> 14) & 3] + LOW14(address); - return(LOADINTELWORD(ptr)); + if ((address & 0x3fff) != 0x3fff) { + ptr = extmem.pageptr[(address >> 14) & 3] + LOW14(address); + return(LOADINTELWORD(ptr)); + } + else { + ret = extmem.pageptr[(address >> 14) & 3][0x3fff]; + ret += extmem.pageptr[((address + 1) >> 14) & 3][0] << 8; + return(ret); + } } static REG16 MEMCALL i286w_itf(UINT32 address) { - if (itf.bank) { + if (i286core.s.itfbank) { address = ITF_ADRS + LOW15(address); } return(LOADINTELWORD(mem + address)); @@ -789,6 +799,7 @@ static REG16 MEMCALL _i286_memoryread_w( REG8 MEMCALL i286_memoryread(UINT32 address) { REG8 r; + r = _i286_memoryread(address); if (r & 0xffffff00) { TRACEOUT(("error i286_memoryread %x %x", address, r));