--- np2/i286c/memory.c 2003/11/29 00:36:00 1.5 +++ np2/i286c/memory.c 2003/12/01 17:13:36 1.8 @@ -9,13 +9,13 @@ #define USE_HIMEM -#define MEMORY_DEBUG +// #define MEMORY_DEBUG // ---- 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 +193,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 +283,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 +296,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 +461,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 +478,7 @@ static REG16 MEMCALL i286w_rd(UINT32 add BYTE *ptr; - ptr = mem + (address & extmem.adrsmask); + ptr = mem + (address & i286core.s.adrsmask); return(LOADINTELWORD(ptr)); } @@ -543,7 +543,7 @@ static REG16 MEMCALL grcgw_tcr0(UINT32 a if (!(grcg.modereg & 8)) { ret |= LOADINTELWORD(vram + VRAM0_E) ^ grcg.tile[3].w; } - return(~ret); + return((UINT16)~ret); } static REG16 MEMCALL grcgw_tcr1(UINT32 address) { @@ -592,15 +592,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,9 +797,10 @@ 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", r)); + TRACEOUT(("error i286_memoryread %x %x", address, r)); } return(r); } @@ -802,7 +811,7 @@ REG16 MEMCALL i286_memoryread_w(UINT32 a r = _i286_memoryread_w(address); if (r & 0xffff0000) { - TRACEOUT(("error i286_memoryread_w %x", r)); + TRACEOUT(("error i286_memoryread_w %x %x", address, r)); } return(r); }