|
|
| version 1.2, 2003/10/20 13:45:09 | version 1.4, 2004/02/02 01:40:59 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "memory.h" | #include "cpucore.h" |
| #include "egcmem.h" | |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "gdc_pset.h" | #include "gdc_pset.h" |
| Line 15 static void MEMCALL _nop(GDCPSET pset, U | Line 16 static void MEMCALL _nop(GDCPSET pset, U |
| static void MEMCALL _replace(GDCPSET pset, UINT addr, UINT bit) { | static void MEMCALL _replace(GDCPSET pset, UINT addr, UINT bit) { |
| vramupdate[addr] |= pset->update; | vramupdate[addr] |= pset->update.b[0]; |
| if (pset->pattern & 0x8000) { | if (pset->pattern & 0x8000) { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| pset->pattern++; | pset->pattern++; |
| pset->base[addr] |= (0x80 >> bit); | pset->base.ptr[addr] |= (0x80 >> bit); |
| } | } |
| else { | else { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| pset->base[addr] &= ~(0x80 >> bit); | pset->base.ptr[addr] &= ~(0x80 >> bit); |
| } | } |
| } | } |
| Line 32 static void MEMCALL _complemnt(GDCPSET p | Line 33 static void MEMCALL _complemnt(GDCPSET p |
| if (pset->pattern & 0x8000) { | if (pset->pattern & 0x8000) { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| pset->pattern++; | pset->pattern++; |
| vramupdate[addr] |= pset->update; | vramupdate[addr] |= pset->update.b[0]; |
| pset->base[addr] ^= (0x80 >> bit); | pset->base.ptr[addr] ^= (0x80 >> bit); |
| } | } |
| else { | else { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| Line 45 static void MEMCALL _clear(GDCPSET pset, | Line 46 static void MEMCALL _clear(GDCPSET pset, |
| if (pset->pattern & 0x8000) { | if (pset->pattern & 0x8000) { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| pset->pattern++; | pset->pattern++; |
| vramupdate[addr] |= pset->update; | vramupdate[addr] |= pset->update.b[0]; |
| pset->base[addr] &= ~(0x80 >> bit); | pset->base.ptr[addr] &= ~(0x80 >> bit); |
| } | } |
| else { | else { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| Line 58 static void MEMCALL _set(GDCPSET pset, U | Line 59 static void MEMCALL _set(GDCPSET pset, U |
| if (pset->pattern & 0x8000) { | if (pset->pattern & 0x8000) { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| pset->pattern++; | pset->pattern++; |
| vramupdate[addr] |= pset->update; | vramupdate[addr] |= pset->update.b[0]; |
| pset->base[addr] |= (0x80 >> bit); | pset->base.ptr[addr] |= (0x80 >> bit); |
| } | } |
| else { | else { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| } | } |
| } | } |
| static void MEMCALL _tdw(GDCPSET pset, UINT addr, UINT bit) { | |
| // ---- grcg | |
| static void MEMCALL withtdw(GDCPSET pset, UINT addr, UINT bit) { | |
| BYTE *ptr; | BYTE *ptr; |
| if (pset->pattern & 0x8000) { | if (pset->pattern & 0x8000) { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| pset->pattern++; | pset->pattern++; |
| vramupdate[addr] |= pset->update; | addr &= ~1; |
| ptr = pset->base + addr; | |
| ptr[VRAM_B] = grcg.tile[0].b[0]; | *(UINT16 *)(vramupdate + addr) |= pset->update.w; |
| ptr[VRAM_R] = grcg.tile[1].b[0]; | ptr = pset->base.ptr + addr; |
| ptr[VRAM_G] = grcg.tile[2].b[0]; | *(UINT16 *)(ptr + VRAM_B) = grcg.tile[0].w; |
| ptr[VRAM_E] = grcg.tile[3].b[0]; | *(UINT16 *)(ptr + VRAM_R) = grcg.tile[1].w; |
| *(UINT16 *)(ptr + VRAM_G) = grcg.tile[2].w; | |
| *(UINT16 *)(ptr + VRAM_E) = grcg.tile[3].w; | |
| } | } |
| else { | else { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| Line 86 static void MEMCALL _tdw(GDCPSET pset, U | Line 92 static void MEMCALL _tdw(GDCPSET pset, U |
| (void)bit; | (void)bit; |
| } | } |
| static void MEMCALL _rmw(GDCPSET pset, UINT addr, UINT bit) { | static void MEMCALL withrmw(GDCPSET pset, UINT addr, UINT bit) { |
| BYTE *ptr; | BYTE *ptr; |
| BYTE data; | BYTE data; |
| Line 95 static void MEMCALL _rmw(GDCPSET pset, U | Line 101 static void MEMCALL _rmw(GDCPSET pset, U |
| if (pset->pattern & 0x8000) { | if (pset->pattern & 0x8000) { |
| pset->pattern <<= 1; | pset->pattern <<= 1; |
| pset->pattern++; | pset->pattern++; |
| vramupdate[addr] |= pset->update; | vramupdate[addr] |= pset->update.b[0]; |
| ptr = pset->base + addr; | ptr = pset->base.ptr + addr; |
| data = (0x80 >> bit); | data = (0x80 >> bit); |
| mask = ~data; | mask = ~data; |
| ptr[VRAM_B] &= mask; | ptr[VRAM_B] &= mask; |
| Line 113 static void MEMCALL _rmw(GDCPSET pset, U | Line 119 static void MEMCALL _rmw(GDCPSET pset, U |
| } | } |
| } | } |
| static const GDCPSFN psettbl[] = { | |
| _replace, _complemnt, _clear, _set, | // ---- egc |
| _replace, _complemnt, _clear, _set, | |
| _tdw, _tdw, _nop, _tdw, | static void MEMCALL withegc(GDCPSET pset, UINT addr, UINT bit) { |
| _rmw, _rmw, _nop, _rmw}; | |
| REG16 data; | |
| if (pset->pattern & 0x8000) { | |
| pset->pattern <<= 1; | |
| pset->pattern++; | |
| data = (0x80 >> bit); | |
| if (addr & 1) { | |
| addr &= ~1; | |
| data <<= 8; | |
| } | |
| egc_write_w(pset->base.addr + addr, data); | |
| } | |
| else { | |
| pset->pattern <<= 1; | |
| } | |
| } | |
| static const GDCPSFN psettbl[] = {_replace, _complemnt, _clear, _set}; | |
| // ---- | // ---- |
| void MEMCALL gdcpset_prepare(GDCPSET pset, UINT32 csrw, UINT16 pat, BYTE op) { | void MEMCALL gdcpset_prepare(GDCPSET pset, UINT32 csrw, REG16 pat, REG8 op) { |
| BYTE *base; | BYTE *base; |
| BYTE update; | BYTE update; |
| base = mem; | if (vramop.operate & VOP_EGCBIT) { |
| if (!gdcs.access) { | pset->func = withegc; |
| update = 1; | pset->base.addr = vramplaneseg[(csrw >> 14) & 3]; |
| } | } |
| else { | else { |
| base += VRAM_STEP; | base = mem; |
| update = 2; | if (!gdcs.access) { |
| } | update = 1; |
| op &= 3; | } |
| if (!(grcg.gdcwithgrcg & 0x8)) { | else { |
| base += vramplaneseg[(csrw >> 14) & 3]; | base += VRAM_STEP; |
| } | update = 2; |
| else { | } |
| op += grcg.gdcwithgrcg; | op &= 3; |
| if (!(grcg.gdcwithgrcg & 0x8)) { | |
| pset->func = psettbl[op]; | |
| pset->base.ptr = base + vramplaneseg[(csrw >> 14) & 3]; | |
| } | |
| else { | |
| pset->func = (grcg.gdcwithgrcg & 0x4)?withrmw:withtdw; | |
| pset->base.ptr = base; | |
| } | |
| gdcs.grphdisp |= update; | |
| pset->update.b[0] = update; | |
| pset->update.b[1] = update; | |
| } | } |
| gdcs.grphdisp |= update; | |
| pset->func = psettbl[op]; | |
| pset->base = base; | |
| pset->pattern = pat; | pset->pattern = pat; |
| pset->update = update; | |
| pset->x = (UINT16)((((csrw & 0x3fff) % 40) << 4) + ((csrw >> 20) & 0x0f)); | pset->x = (UINT16)((((csrw & 0x3fff) % 40) << 4) + ((csrw >> 20) & 0x0f)); |
| pset->y = (UINT16)((csrw & 0x3fff) / 40); | pset->y = (UINT16)((csrw & 0x3fff) / 40); |
| pset->dots = 0; | pset->dots = 0; |