\r
\r
// videoport.c\r
+extern unsigned SATaddr, SATmask;\r
+static __inline void UpdateSAT(u32 a, u32 d)\r
+{\r
+ unsigned num = (a-SATaddr) >> 3;\r
+\r
+ Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
+ if (!(a & 4) && num < 128) {\r
+ ((u16 *)&VdpSATCache[num])[(a&3) >> 1] = d;\r
+ }\r
+}\r
+static __inline void VideoWriteVRAM(u32 a, u16 d)\r
+{\r
+ PicoMem.vram [(u16)a >> 1] = d;\r
+\r
+ if (!((u16)(a^SATaddr) & SATmask))\r
+ UpdateSAT(a, d);\r
+}\r
+\r
PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d);\r
PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a);\r
unsigned char PicoVideoRead8DataH(void);\r
extern const unsigned short vdpsl2cyc_32[], vdpsl2cyc_40[];\r
\r
static int blankline; // display disabled for this line\r
-static unsigned sat; // VRAM addr of sprite attribute table\r
-static int satxbits; // index bits in SAT address\r
+\r
+unsigned SATaddr, SATmask; // VRAM addr of sprite attribute table\r
\r
int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask) = NULL;\r
\r
if (Pico.video.addr < Pico.video.reg[0xf]) Pico.video.addr_u ^= 1;\r
}\r
\r
-static __inline void UpdateSAT(u32 a, u32 d)\r
-{\r
- unsigned num = (a-sat) >> 3;\r
-\r
- Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
- if (!(a & 4) && num < 128) {\r
- ((u16 *)&VdpSATCache[num])[(a&3) >> 1] = d;\r
- }\r
-}\r
-\r
static NOINLINE void VideoWriteVRAM128(u32 a, u16 d)\r
{\r
// nasty\r
u32 b = ((a & 2) >> 1) | ((a & 0x400) >> 9) | (a & 0x3FC) | ((a & 0x1F800) >> 1);\r
\r
((u8 *)PicoMem.vram)[b] = d;\r
- if (!((u16)(b^sat) >> satxbits))\r
+ if (!((u16)(b^SATaddr) & SATmask))\r
Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
\r
- if (!((u16)(a^sat) >> satxbits))\r
- UpdateSAT(a, d);\r
-}\r
-\r
-static void VideoWriteVRAM(u32 a, u16 d)\r
-{\r
- PicoMem.vram [(u16)a >> 1] = d;\r
-\r
- if (!((u16)(a^sat) >> satxbits))\r
+ if (!((u16)(a^SATaddr) & SATmask))\r
UpdateSAT(a, d);\r
}\r
\r
r = PicoMem.vram;\r
if (inc == 2 && !(a & 1) && (a >> 16) == ((a + len*2) >> 16) &&\r
(source & ~mask) == ((source + len-1) & ~mask) &&\r
- (a << 16 >= (sat+0x280) << 16 || (a + len*2) << 16 <= sat << 16))\r
+ (a << 16 >= (SATaddr+0x280)<<16 || (a + len*2) << 16 <= SATaddr<<16))\r
{\r
// most used DMA mode\r
memcpy((char *)r + a, base + (source & mask), len * 2);\r
for (; len; len--)\r
{\r
vr[(u16)a] = vr[(u16)(source++)];\r
- if (!((u16)(a^sat) >> satxbits))\r
+ if (!((u16)(a^SATaddr) & SATmask))\r
UpdateSAT(a, ((u16 *)vr)[(u16)a >> 1]);\r
// AutoIncrement\r
a = (a+inc) & ~0x20000;\r
// Write upper byte to adjacent address\r
// (here we are byteswapped, so address is already 'adjacent')\r
vr[(u16)a] = high;\r
- if (!((u16)(a^sat) >> satxbits))\r
+ if (!((u16)(a^SATaddr) & SATmask))\r
UpdateSAT(a, ((u16 *)vr)[(u16)a >> 1]);\r
\r
// Increment address register\r
default:\r
return;\r
}\r
- sat = ((pvid->reg[5]&0x7f) << 9) | ((pvid->reg[6]&0x20) << 11);\r
- satxbits = 9;\r
+ SATaddr = ((pvid->reg[5]&0x7f) << 9) | ((pvid->reg[6]&0x20) << 11);\r
+ SATmask = ~0x1ff;\r
if (Pico.video.reg[12]&1)\r
- sat &= ~0x200, satxbits = 10; // H40, zero lowest SAT bit\r
- //elprintf(EL_STATUS, "spritep moved to %04x", sat);\r
+ SATaddr &= ~0x200, SATmask &= ~0x200; // H40, zero lowest SAT bit\r
+ //elprintf(EL_STATUS, "spritep moved to %04x", SATaddr);\r
return;\r
\r
update_irq:\r
Pico.m.dma_xfers = 0;\r
}\r
\r
- sat = ((pv->reg[5]&0x7f) << 9) | ((pv->reg[6]&0x20) << 11);\r
- satxbits = 9;\r
+ SATaddr = ((pv->reg[5]&0x7f) << 9) | ((pv->reg[6]&0x20) << 11);\r
+ SATmask = ~0x1ff;\r
if (pv->reg[12]&1)\r
- sat &= ~0x200, satxbits = 10; // H40, zero lowest SAT bit\r
+ SATaddr &= ~0x200, SATmask &= ~0x200; // H40, zero lowest SAT bit\r
\r
// rebuild SAT cache XXX wrong since cache and memory can differ\r
for (l = 0; l < 80; l++) {\r
- *((u16 *)VdpSATCache + 2*l ) = PicoMem.vram[(sat>>1) + l*4 ];\r
- *((u16 *)VdpSATCache + 2*l+1) = PicoMem.vram[(sat>>1) + l*4 + 1];\r
+ *((u16 *)VdpSATCache + 2*l ) = PicoMem.vram[(SATaddr>>1) + l*4 ];\r
+ *((u16 *)VdpSATCache + 2*l+1) = PicoMem.vram[(SATaddr>>1) + l*4 + 1];\r
}\r
}\r
\r