// This is part of Pico Library\r
\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
+// (c) Copyright 2007, Grazvydas "notaz" Ignotas\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
\r
\r
#include "PicoInt.h"\r
-#include <assert.h>\r
-#ifndef __GNUC__\r
-#pragma warning (disable:4706) // Disable assignment within conditional\r
-#endif\r
\r
// port_config.h include must define these 2 defines:\r
// #define START_ROW 1 // which row of tiles to start rendering at?\r
\r
#define USE_CACHE\r
\r
+// note: this is not implemented in ARM asm\r
+#if defined(DRAW2_OVERRIDE_LINE_WIDTH)\r
+#define LINE_WIDTH DRAW2_OVERRIDE_LINE_WIDTH\r
+#else\r
+#define LINE_WIDTH 328\r
+#endif\r
\r
-extern unsigned char *framebuff; // in format (8+320)x(8+224+8) (eights for borders)\r
int currpri = 0;\r
\r
-static int HighCacheA[41*(TILE_ROWS+1)+1+1]; // caches for high layers\r
-static int HighCacheB[41*(TILE_ROWS+1)+1+1];\r
+static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers\r
+static int HighCache2B[41*(TILE_ROWS+1)+1+1];\r
\r
unsigned short *PicoCramHigh=Pico.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)\r
void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use\r
unsigned int pack=0; unsigned int t=0, blank = 1;\r
int i;\r
\r
- for(i=8; i; i--, addr+=2, pd += 320+8) {\r
+ for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) {\r
pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
if(!pack) continue;\r
\r
unsigned int pack=0; unsigned int t=0, blank = 1;\r
int i;\r
\r
- for(i=8; i; i--, addr+=2, pd += 320+8) {\r
+ for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) {\r
pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
if(!pack) continue;\r
\r
int i;\r
\r
addr+=14;\r
- for(i=8; i; i--, addr-=2, pd += 320+8) {\r
+ for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) {\r
pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
if(!pack) continue;\r
\r
int i;\r
\r
addr+=14;\r
- for(i=8; i; i--, addr-=2, pd += 320+8) {\r
+ for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) {\r
pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
if(!pack) continue;\r
\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
int nametab, nametab_step, trow, tilex, blank=-1, code;\r
- unsigned char *scrpos = framebuff;\r
+ unsigned char *scrpos = PicoDraw2FB;\r
int tile_start, tile_end; // in cells\r
\r
// parse ranges\r
code=Pico.vram[nametab+tile_start];\r
if ((code>>15) != prio) return; // hack: just assume that whole window uses same priority\r
\r
- scrpos+=8*328+8;\r
- scrpos+=8*328*(start-START_ROW);\r
+ scrpos+=8*LINE_WIDTH+8;\r
+ scrpos+=8*LINE_WIDTH*(start-START_ROW);\r
\r
// do a window until we reach planestart row\r
for(trow = start; trow < end; trow++, nametab+=nametab_step) { // current tile row\r
if(zero) blank=code; // We know this tile is blank now\r
}\r
\r
- scrpos += 328*8;\r
+ scrpos += LINE_WIDTH*8;\r
}\r
}\r
\r
height=(width>>4)&3; width&=3;\r
\r
xmask=(1<<shift[width ])-1; // X Mask in tiles\r
- ymask=(height<<5)|0x1f; // Y Mask in tiles\r
- if(width == 1) ymask&=0x3f;\r
- else if(width>1) ymask =0x1f;\r
+ ymask=(height<<5)|0x1f; // Y Mask in tiles\r
+ if(width == 1) ymask&=0x3f;\r
+ else if(width>1) ymask =0x1f;\r
\r
// Find name table:\r
if (plane==0) nametab=(pvid->reg[2]&0x38)<< 9; // A\r
else nametab=(pvid->reg[4]&0x07)<<12; // B\r
\r
- scrpos = framebuff;\r
- scrpos+=8*328*(planestart-START_ROW);\r
+ scrpos = PicoDraw2FB;\r
+ scrpos+=8*LINE_WIDTH*(planestart-START_ROW);\r
\r
// Get vertical scroll value:\r
vscroll=Pico.vsram[plane]&0x1ff;\r
- scrpos+=(8-(vscroll&7))*328;\r
+ scrpos+=(8-(vscroll&7))*LINE_WIDTH;\r
if(vscroll&7) planeend++; // we have vertically clipped tiles due to vscroll, so we need 1 more row\r
\r
*hcache++ = 8-(vscroll&7); // push y-offset to tilecache\r
if(zero) blank=code; // We know this tile is blank now\r
}\r
\r
- scrpos += 328*8;\r
+ scrpos += LINE_WIDTH*8;\r
}\r
\r
*hcache = 0; // terminate cache\r
// unsigned short *pal;\r
unsigned char pal;\r
short blank=-1; // The tile we know is blank\r
- unsigned char *scrpos = framebuff, *pd = 0;\r
+ unsigned char *scrpos = PicoDraw2FB, *pd = 0;\r
\r
// *hcache++ = code|(dx<<16)|(trow<<27); // cache it\r
- scrpos+=(*hc++)*328 - START_ROW*328*8;\r
+ scrpos+=(*hc++)*LINE_WIDTH - START_ROW*LINE_WIDTH*8;\r
\r
while((code=*hc++)) {\r
if((short)code == blank) continue;\r
// y pos\r
if(((unsigned)code>>27) != prevy) {\r
prevy = (unsigned)code>>27;\r
- pd = scrpos + prevy*328*8;\r
+ pd = scrpos + prevy*LINE_WIDTH*8;\r
}\r
\r
// Get tile address/2:\r
// goto first vertically visible tile\r
while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; }\r
\r
- scrpos = framebuff;\r
- scrpos+=(sy-START_ROW*8)*328;\r
+ scrpos = PicoDraw2FB;\r
+ scrpos+=(sy-START_ROW*8)*LINE_WIDTH;\r
\r
for (; height > 0; height--, sy+=8, tile+=tdeltay)\r
{\r
}\r
}\r
\r
- scrpos+=8*328;\r
+ scrpos+=8*LINE_WIDTH;\r
}\r
}\r
#endif\r
#ifndef _ASM_DRAW_C\r
static void BackFillFull(int reg7)\r
{\r
- unsigned int back, i;\r
- unsigned int *p=(unsigned int *)framebuff;\r
+ unsigned int back;\r
\r
// Start with a background color:\r
// back=PicoCramHigh[reg7&0x3f];\r
back|=back<<8;\r
back|=back<<16;\r
\r
- for(i = (8+320)*(8+(END_ROW-START_ROW)*8)/16; i; i--) {\r
- *p++ = back; // do 16 pixels per iteration\r
- *p++ = back;\r
- *p++ = back;\r
- *p++ = back;\r
- }\r
+ memset32((int *)PicoDraw2FB, back, LINE_WIDTH*(8+(END_ROW-START_ROW)*8)/4);\r
}\r
#endif\r
\r
if(hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; }\r
\r
currpri = 0;\r
- DrawLayerFull(1, HighCacheB, START_ROW, (maxcolc<<16)|END_ROW);\r
+ DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW);\r
switch(hvwin) {\r
case 4:\r
// fullscreen window\r
DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0);\r
- HighCacheA[1] = 0;\r
+ HighCache2A[1] = 0;\r
break;\r
\r
case 3:\r
// we have plane A and both v and h windows\r
- DrawLayerFull(0, HighCacheA, planestart, planeend);\r
+ DrawLayerFull(0, HighCache2A, planestart, planeend);\r
DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0); // h\r
DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0); // v\r
break;\r
case 2:\r
case 1:\r
// both window and plane A visible, window is vertical XOR horizontal\r
- DrawLayerFull(0, HighCacheA, planestart, planeend);\r
+ DrawLayerFull(0, HighCache2A, planestart, planeend);\r
DrawWindowFull(winstart, winend, 0);\r
break;\r
\r
default:\r
// fullscreen plane A\r
- DrawLayerFull(0, HighCacheA, START_ROW, (maxcolc<<16)|END_ROW);\r
+ DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW);\r
break;\r
}\r
DrawAllSpritesFull(0, maxw);\r
\r
#ifdef USE_CACHE\r
- if(HighCacheB[1]) DrawTilesFromCacheF(HighCacheB);\r
- if(HighCacheA[1]) DrawTilesFromCacheF(HighCacheA);\r
+ if(HighCache2B[1]) DrawTilesFromCacheF(HighCache2B);\r
+ if(HighCache2A[1]) DrawTilesFromCacheF(HighCache2A);\r
switch(hvwin) {\r
case 4:\r
// fullscreen window\r
}\r
\r
\r
-void PicoFrameFull()\r
+PICO_INTERNAL void PicoFrameFull()\r
{\r
// prepare cram?\r
if(PicoPrepareCram) PicoPrepareCram();\r