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