split memories away from Pico
[picodrive.git] / pico / draw.c
index 5ecbca8..6408f20 100644 (file)
@@ -215,7 +215,7 @@ static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)
   {\r
     unsigned int pack;\r
 \r
-    code = Pico.vram[ts->nametab + (tilex & ts->xmask)];\r
+    code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)];\r
     if (code == blank)\r
       continue;\r
     if ((code >> 15) | (lflags & LF_FORCE)) { // high priority tile\r
@@ -235,7 +235,7 @@ static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)
       pal=((code>>9)&0x30)|sh;\r
     }\r
 \r
-    pack = *(unsigned int *)(Pico.vram + addr);\r
+    pack = *(unsigned int *)(PicoMem.vram + addr);\r
     if (!pack) {\r
       blank = code;\r
       continue;\r
@@ -274,7 +274,7 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
     //if((cell&1)==0)\r
     {\r
       int line,vscroll;\r
-      vscroll=Pico.vsram[(plane_sh&1)+(cell&~1)];\r
+      vscroll=PicoMem.vsram[(plane_sh&1)+(cell&~1)];\r
 \r
       // Find the line in the name table\r
       line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..\r
@@ -282,7 +282,7 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
       ty=(line&7)<<1; // Y-Offset into tile\r
     }\r
 \r
-    code=Pico.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];\r
+    code=PicoMem.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];\r
     if (code==blank) continue;\r
     if (code>>15) { // high priority tile\r
       int cval = code | (dx<<16) | (ty<<25);\r
@@ -300,7 +300,7 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
       pal=((code>>9)&0x30)|((plane_sh<<5)&0x40);\r
     }\r
 \r
-    pack = *(unsigned int *)(Pico.vram + addr);\r
+    pack = *(unsigned int *)(PicoMem.vram + addr);\r
     if (!pack) {\r
       blank = code;\r
       continue;\r
@@ -336,7 +336,7 @@ void DrawStripInterlace(struct TileStrip *ts)
   {\r
     unsigned int pack;\r
 \r
-    code=Pico.vram[ts->nametab+(tilex&ts->xmask)];\r
+    code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)];\r
     if (code==blank) continue;\r
     if (code>>15) { // high priority tile\r
       int cval = (code&0xfc00) | (dx<<16) | (ty<<25);\r
@@ -356,7 +356,7 @@ void DrawStripInterlace(struct TileStrip *ts)
       pal=((code>>9)&0x30);\r
     }\r
 \r
-    pack = *(unsigned int *)(Pico.vram + addr);\r
+    pack = *(unsigned int *)(PicoMem.vram + addr);\r
     if (!pack) {\r
       blank = code;\r
       continue;\r
@@ -409,11 +409,11 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,
   htab+=plane_sh&1; // A or B\r
 \r
   // Get horizontal scroll value, will be masked later\r
-  ts.hscroll=Pico.vram[htab&0x7fff];\r
+  ts.hscroll = PicoMem.vram[htab & 0x7fff];\r
 \r
   if((pvid->reg[12]&6) == 6) {\r
     // interlace mode 2\r
-    vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value\r
+    vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value\r
 \r
     // Find the line in the name table\r
     ts.line=(vscroll+(est->DrawScanline<<1))&((ymask<<1)|1);\r
@@ -426,7 +426,7 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,
     ts.line=ymask|(shift[width]<<24); // save some stuff instead of line\r
     DrawStripVSRam(&ts, plane_sh, cellskip);\r
   } else {\r
-    vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value\r
+    vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value\r
 \r
     // Find the line in the name table\r
     ts.line=(vscroll+est->DrawScanline)&ymask;\r
@@ -463,7 +463,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
 \r
   if (!(est->rendstatus & PDRAW_WND_DIFF_PRIO)) {\r
     // check the first tile code\r
-    code=Pico.vram[nametab+tilex];\r
+    code = PicoMem.vram[nametab + tilex];\r
     // if the whole window uses same priority (what is often the case), we may be able to skip this field\r
     if ((code>>15) != prio) return;\r
   }\r
@@ -480,7 +480,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
       int dx, addr;\r
       int pal;\r
 \r
-      code=Pico.vram[nametab+tilex];\r
+      code = PicoMem.vram[nametab + tilex];\r
       if (code==blank) continue;\r
       if ((code>>15) != prio) {\r
         est->rendstatus |= PDRAW_WND_DIFF_PRIO;\r
@@ -491,7 +491,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
       addr=(code&0x7ff)<<4;\r
       if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip\r
 \r
-      pack = *(unsigned int *)(Pico.vram + addr);\r
+      pack = *(unsigned int *)(PicoMem.vram + addr);\r
       if (!pack) {\r
         blank = code;\r
         continue;\r
@@ -512,7 +512,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
       int dx, addr;\r
       int pal;\r
 \r
-      code=Pico.vram[nametab+tilex];\r
+      code = PicoMem.vram[nametab + tilex];\r
       if(code==blank) continue;\r
       if((code>>15) != prio) {\r
         est->rendstatus |= PDRAW_WND_DIFF_PRIO;\r
@@ -533,7 +533,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
       addr=(code&0x7ff)<<4;\r
       if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip\r
 \r
-      pack = *(unsigned int *)(Pico.vram + addr);\r
+      pack = *(unsigned int *)(PicoMem.vram + addr);\r
       if (!pack) {\r
         blank = code;\r
         continue;\r
@@ -587,7 +587,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est
       addr = (code & 0x7ff) << 4;\r
       addr += code >> 25; // y offset into tile\r
 \r
-      pack = *(unsigned int *)(Pico.vram + addr);\r
+      pack = *(unsigned int *)(PicoMem.vram + addr);\r
       if (!pack) {\r
         blank = (short)code;\r
         continue;\r
@@ -615,7 +615,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est
       *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;\r
       *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;\r
 \r
-      pack = *(unsigned int *)(Pico.vram + addr);\r
+      pack = *(unsigned int *)(PicoMem.vram + addr);\r
       if (!pack)\r
         continue;\r
 \r
@@ -717,7 +717,7 @@ static void DrawSprite(int *sprite, int sh)
     if(sx<=0)   continue;\r
     if(sx>=328) break; // Offscreen\r
 \r
-    pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff));\r
+    pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
     fTileFunc(sx, pack, pal);\r
   }\r
 }\r
@@ -737,7 +737,7 @@ static NOINLINE void DrawTilesFromCacheForced(const int *hc)
 \r
     dx = (code >> 16) & 0x1ff;\r
     pal = ((code >> 9) & 0x30);\r
-    pack = *(unsigned int *)(Pico.vram + addr);\r
+    pack = *(unsigned int *)(PicoMem.vram + addr);\r
 \r
     if (code & 0x0800) TileFlip_and(dx, pack, pal);\r
     else               TileNorm_and(dx, pack, pal);\r
@@ -783,7 +783,7 @@ static void DrawSpriteInterlace(unsigned int *sprite)
     if(sx<=0)   continue;\r
     if(sx>=328) break; // Offscreen\r
 \r
-    pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff));\r
+    pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
     if (code & 0x0800) TileFlip(sx, pack, pal);\r
     else               TileNorm(sx, pack, pal);\r
   }\r
@@ -805,7 +805,7 @@ static NOINLINE void DrawAllSpritesInterlace(int pri, int sh)
     unsigned int *sprite;\r
     int code, sx, sy, height;\r
 \r
-    sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
+    sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
 \r
     // get sprite info\r
     code = sprite[0];\r
@@ -908,7 +908,7 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)
       if(sx<=0)   continue;\r
       if(sx>=328) break; // Offscreen\r
 \r
-      pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff));\r
+      pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
       fTileFunc(sx, pack, pal);\r
     }\r
   }\r
@@ -982,7 +982,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh)
       if(sx<=0)   continue;\r
       if(sx>=328) break; // Offscreen\r
 \r
-      pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff));\r
+      pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
       fTileFunc(sx, pack, pal);\r
     }\r
   }\r
@@ -1042,7 +1042,7 @@ static NOINLINE void PrepareSprites(int full)
       unsigned int *sprite;\r
       int code2, sx, sy, height;\r
 \r
-      sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
+      sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
 \r
       // parse sprite info\r
       code2 = sprite[1];\r
@@ -1095,7 +1095,7 @@ found:;
       unsigned int *sprite;\r
       int code, code2, sx, sy, hv, height, width;\r
 \r
-      sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
+      sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
 \r
       // parse sprite info\r
       code = sprite[0];\r
@@ -1219,7 +1219,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
 \r
   Pico.m.dirtyPal = 0;\r
 \r
-  spal = (void *)Pico.cram;\r
+  spal = (void *)PicoMem.cram;\r
   dpal = (void *)est->HighPal;\r
 \r
   for (i = 0; i < 0x40 / 2; i++) {\r
@@ -1301,9 +1301,9 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est)
     rs |= PDRAW_SONIC_MODE;\r
     est->rendstatus = rs;\r
     if (dirty_count == 3) {\r
-      blockcpy(est->HighPal, Pico.cram, 0x40*2);\r
+      blockcpy(est->HighPal, PicoMem.cram, 0x40*2);\r
     } else if (dirty_count == 11) {\r
-      blockcpy(est->HighPal+0x40, Pico.cram, 0x40*2);\r
+      blockcpy(est->HighPal+0x40, PicoMem.cram, 0x40*2);\r
     }\r
   }\r
 \r