1 // This is part of Pico Library
\r
3 // (c) Copyright 2004 Dave, All rights reserved.
\r
4 // (c) Copyright 2006 notaz, All rights reserved.
\r
5 // Free for non-commercial use.
\r
7 // For commercial use, separate licencing terms must be obtained.
\r
10 #include "PicoInt.h"
\r
12 #pragma warning (disable:4706) // Disable assignment within conditional
\r
15 int (*PicoScan)(unsigned int num, void *data)=NULL;
\r
17 unsigned short DefOutBuff[320*2];
\r
18 unsigned char HighCol[8+320+8];
\r
19 static int HighCacheA[41+1]; // caches for high layers
\r
20 static int HighCacheB[41+1];
\r
21 static int HighCacheS[80+1]; // and sprites
\r
22 static int HighPreSpr[80*2+1]; // slightly preprocessed sprites
\r
23 char HighSprZ[320+8+8]; // Z-buffer for accurate sprites and shadow/hilight mode
\r
24 // (if bit 7 == 0, sh caused by tile; if bit 6 == 0 pixel must be shadowed, else hilighted, if bit5 == 1)
\r
25 // lsb->msb: moved sprites, all window tiles don't use same priority, accurate sprites (copied from PicoOpt), interlace
\r
26 // dirty sprites, sonic mode
\r
28 void *DrawLineDest=DefOutBuff; // pointer to dest buffer where to draw this line to
\r
29 int Scanline=0; // Scanline
\r
31 static int SpriteBlocks;
\r
32 //unsigned short ppt[] = { 0x0f11, 0x0ff1, 0x01f1, 0x011f, 0x01ff, 0x0f1f, 0x0f0e, 0x0e7c };
\r
36 int nametab; // Position in VRAM of name table (for this tile line)
\r
37 int line; // Line number in pixels 0x000-0x3ff within the virtual tilemap
\r
38 int hscroll; // Horizontal scroll value in pixels for the line
\r
39 int xmask; // X-Mask (0x1f - 0x7f) for horizontal wraparound in the tilemap
\r
40 int *hc; // cache for high tile codes and their positions
\r
41 int cells; // cells (tiles) to draw (32 col mode doesn't need to update whole 320)
\r
44 // stuff available in asm:
\r
46 void DrawWindow(int tstart, int tend, int prio, int sh);
\r
47 void BackFill(int reg7, int sh);
\r
48 void DrawSprite(int *sprite, int **hc, int sh);
\r
49 void DrawTilesFromCache(int *hc, int sh);
\r
50 void DrawSpritesFromCache(int *hc, int sh);
\r
51 void DrawLayer(int plane, int *hcache, int maxcells, int sh);
\r
52 void FinalizeLineBGR444(int sh);
\r
53 void FinalizeLineRGB555(int sh);
\r
54 void blockcpy_or(void *dst, void *src, size_t n, int pat);
\r
57 void blockcpy_or(void *dst, void *src, size_t n, int pat)
\r
59 unsigned char *pd = dst, *ps = src;
\r
61 *pd++ = (unsigned char) (*ps++ | pat);
\r
66 static int TileNorm(int sx,int addr,int pal)
\r
68 unsigned char *pd = HighCol+sx;
\r
69 unsigned int pack=0; unsigned int t=0;
\r
71 pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
74 t=pack&0x0000f000; if (t) pd[0]=(unsigned char)(pal|(t>>12));
\r
75 t=pack&0x00000f00; if (t) pd[1]=(unsigned char)(pal|(t>> 8));
\r
76 t=pack&0x000000f0; if (t) pd[2]=(unsigned char)(pal|(t>> 4));
\r
77 t=pack&0x0000000f; if (t) pd[3]=(unsigned char)(pal|(t ));
\r
78 t=pack&0xf0000000; if (t) pd[4]=(unsigned char)(pal|(t>>28));
\r
79 t=pack&0x0f000000; if (t) pd[5]=(unsigned char)(pal|(t>>24));
\r
80 t=pack&0x00f00000; if (t) pd[6]=(unsigned char)(pal|(t>>20));
\r
81 t=pack&0x000f0000; if (t) pd[7]=(unsigned char)(pal|(t>>16));
\r
85 return 1; // Tile blank
\r
88 static int TileFlip(int sx,int addr,int pal)
\r
90 unsigned char *pd = HighCol+sx;
\r
91 unsigned int pack=0; unsigned int t=0;
\r
93 pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
96 t=pack&0x000f0000; if (t) pd[0]=(unsigned char)(pal|(t>>16));
\r
97 t=pack&0x00f00000; if (t) pd[1]=(unsigned char)(pal|(t>>20));
\r
98 t=pack&0x0f000000; if (t) pd[2]=(unsigned char)(pal|(t>>24));
\r
99 t=pack&0xf0000000; if (t) pd[3]=(unsigned char)(pal|(t>>28));
\r
100 t=pack&0x0000000f; if (t) pd[4]=(unsigned char)(pal|(t ));
\r
101 t=pack&0x000000f0; if (t) pd[5]=(unsigned char)(pal|(t>> 4));
\r
102 t=pack&0x00000f00; if (t) pd[6]=(unsigned char)(pal|(t>> 8));
\r
103 t=pack&0x0000f000; if (t) pd[7]=(unsigned char)(pal|(t>>12));
\r
106 return 1; // Tile blank
\r
110 // tile renderers for hacky operator sprite support
\r
111 #define sh_pix(x) \
\r
113 else if(t==0xe) pd[x]=(unsigned char)((pd[x]&0x3f)|0x80); /* hilight */ \
\r
114 else if(t==0xf) pd[x]=(unsigned char)((pd[x]&0x3f)|0xc0); /* shadow */ \
\r
115 else pd[x]=(unsigned char)(pal|t)
\r
117 #ifndef _ASM_DRAW_C
\r
118 static int TileNormSH(int sx,int addr,int pal)
\r
120 unsigned int pack=0; unsigned int t=0;
\r
121 unsigned char *pd = HighCol+sx;
\r
123 pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
126 t=(pack&0x0000f000)>>12; sh_pix(0);
\r
127 t=(pack&0x00000f00)>> 8; sh_pix(1);
\r
128 t=(pack&0x000000f0)>> 4; sh_pix(2);
\r
129 t=(pack&0x0000000f) ; sh_pix(3);
\r
130 t=(pack&0xf0000000)>>28; sh_pix(4);
\r
131 t=(pack&0x0f000000)>>24; sh_pix(5);
\r
132 t=(pack&0x00f00000)>>20; sh_pix(6);
\r
133 t=(pack&0x000f0000)>>16; sh_pix(7);
\r
137 return 1; // Tile blank
\r
140 static int TileFlipSH(int sx,int addr,int pal)
\r
142 unsigned int pack=0; unsigned int t=0;
\r
143 unsigned char *pd = HighCol+sx;
\r
145 pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
148 t=(pack&0x000f0000)>>16; sh_pix(0);
\r
149 t=(pack&0x00f00000)>>20; sh_pix(1);
\r
150 t=(pack&0x0f000000)>>24; sh_pix(2);
\r
151 t=(pack&0xf0000000)>>28; sh_pix(3);
\r
152 t=(pack&0x0000000f) ; sh_pix(4);
\r
153 t=(pack&0x000000f0)>> 4; sh_pix(5);
\r
154 t=(pack&0x00000f00)>> 8; sh_pix(6);
\r
155 t=(pack&0x0000f000)>>12; sh_pix(7);
\r
158 return 1; // Tile blank
\r
162 static int TileNormZ(int sx,int addr,int pal,int zval)
\r
164 unsigned int pack=0; unsigned int t=0;
\r
165 unsigned char *pd = HighCol+sx;
\r
166 char *zb = HighSprZ+sx;
\r
167 int collision = 0, zb_s;
\r
169 pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
172 t=pack&0x0000f000; if(t) { zb_s=zb[0]; if(zb_s) collision=1; if(zval>zb_s) { pd[0]=(unsigned char)(pal|(t>>12)); zb[0]=(char)zval; } }
\r
173 t=pack&0x00000f00; if(t) { zb_s=zb[1]; if(zb_s) collision=1; if(zval>zb_s) { pd[1]=(unsigned char)(pal|(t>> 8)); zb[1]=(char)zval; } }
\r
174 t=pack&0x000000f0; if(t) { zb_s=zb[2]; if(zb_s) collision=1; if(zval>zb_s) { pd[2]=(unsigned char)(pal|(t>> 4)); zb[2]=(char)zval; } }
\r
175 t=pack&0x0000000f; if(t) { zb_s=zb[3]; if(zb_s) collision=1; if(zval>zb_s) { pd[3]=(unsigned char)(pal|(t )); zb[3]=(char)zval; } }
\r
176 t=pack&0xf0000000; if(t) { zb_s=zb[4]; if(zb_s) collision=1; if(zval>zb_s) { pd[4]=(unsigned char)(pal|(t>>28)); zb[4]=(char)zval; } }
\r
177 t=pack&0x0f000000; if(t) { zb_s=zb[5]; if(zb_s) collision=1; if(zval>zb_s) { pd[5]=(unsigned char)(pal|(t>>24)); zb[5]=(char)zval; } }
\r
178 t=pack&0x00f00000; if(t) { zb_s=zb[6]; if(zb_s) collision=1; if(zval>zb_s) { pd[6]=(unsigned char)(pal|(t>>20)); zb[6]=(char)zval; } }
\r
179 t=pack&0x000f0000; if(t) { zb_s=zb[7]; if(zb_s) collision=1; if(zval>zb_s) { pd[7]=(unsigned char)(pal|(t>>16)); zb[7]=(char)zval; } }
\r
180 if(collision) Pico.video.status|=0x20;
\r
184 return 1; // Tile blank
\r
187 static int TileFlipZ(int sx,int addr,int pal,int zval)
\r
189 unsigned int pack=0; unsigned int t=0;
\r
190 unsigned char *pd = HighCol+sx;
\r
191 char *zb = HighSprZ+sx;
\r
192 int collision = 0, zb_s;
\r
194 pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
197 t=pack&0x000f0000; if(t) { zb_s=zb[0]&0x1f; if(zb_s) collision=1; if(zval>zb_s) { pd[0]=(unsigned char)(pal|(t>>16)); zb[0]=(char)zval; } }
\r
198 t=pack&0x00f00000; if(t) { zb_s=zb[1]&0x1f; if(zb_s) collision=1; if(zval>zb_s) { pd[1]=(unsigned char)(pal|(t>>20)); zb[1]=(char)zval; } }
\r
199 t=pack&0x0f000000; if(t) { zb_s=zb[2]&0x1f; if(zb_s) collision=1; if(zval>zb_s) { pd[2]=(unsigned char)(pal|(t>>24)); zb[2]=(char)zval; } }
\r
200 t=pack&0xf0000000; if(t) { zb_s=zb[3]&0x1f; if(zb_s) collision=1; if(zval>zb_s) { pd[3]=(unsigned char)(pal|(t>>28)); zb[3]=(char)zval; } }
\r
201 t=pack&0x0000000f; if(t) { zb_s=zb[4]&0x1f; if(zb_s) collision=1; if(zval>zb_s) { pd[4]=(unsigned char)(pal|(t )); zb[4]=(char)zval; } }
\r
202 t=pack&0x000000f0; if(t) { zb_s=zb[5]&0x1f; if(zb_s) collision=1; if(zval>zb_s) { pd[5]=(unsigned char)(pal|(t>> 4)); zb[5]=(char)zval; } }
\r
203 t=pack&0x00000f00; if(t) { zb_s=zb[6]&0x1f; if(zb_s) collision=1; if(zval>zb_s) { pd[6]=(unsigned char)(pal|(t>> 8)); zb[6]=(char)zval; } }
\r
204 t=pack&0x0000f000; if(t) { zb_s=zb[7]&0x1f; if(zb_s) collision=1; if(zval>zb_s) { pd[7]=(unsigned char)(pal|(t>>12)); zb[7]=(char)zval; } }
\r
205 if(collision) Pico.video.status|=0x20;
\r
208 return 1; // Tile blank
\r
212 #define sh_pixZ(x) \
\r
214 if(zb[x]) collision=1; \
\r
216 if (t==0xe) { pd[x]=(unsigned char)((pd[x]&0x3f)|0x80); /* hilight */ } \
\r
217 else if(t==0xf) { pd[x]=(unsigned char)((pd[x]&0x3f)|0xc0); /* shadow */ } \
\r
218 else { zb[x]=(char)zval; pd[x]=(unsigned char)(pal|t); } \
\r
222 static int TileNormZSH(int sx,int addr,int pal,int zval)
\r
224 unsigned int pack=0; unsigned int t=0;
\r
225 unsigned char *pd = HighCol+sx;
\r
226 char *zb = HighSprZ+sx;
\r
229 pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
232 t=(pack&0x0000f000)>>12; sh_pixZ(0);
\r
233 t=(pack&0x00000f00)>> 8; sh_pixZ(1);
\r
234 t=(pack&0x000000f0)>> 4; sh_pixZ(2);
\r
235 t=(pack&0x0000000f) ; sh_pixZ(3);
\r
236 t=(pack&0xf0000000)>>28; sh_pixZ(4);
\r
237 t=(pack&0x0f000000)>>24; sh_pixZ(5);
\r
238 t=(pack&0x00f00000)>>20; sh_pixZ(6);
\r
239 t=(pack&0x000f0000)>>16; sh_pixZ(7);
\r
240 if(collision) Pico.video.status|=0x20;
\r
244 return 1; // Tile blank
\r
247 static int TileFlipZSH(int sx,int addr,int pal,int zval)
\r
249 unsigned int pack=0; unsigned int t=0;
\r
250 unsigned char *pd = HighCol+sx;
\r
251 char *zb = HighSprZ+sx;
\r
254 pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
257 t=(pack&0x000f0000)>>16; sh_pixZ(0);
\r
258 t=(pack&0x00f00000)>>20; sh_pixZ(1);
\r
259 t=(pack&0x0f000000)>>24; sh_pixZ(2);
\r
260 t=(pack&0xf0000000)>>28; sh_pixZ(3);
\r
261 t=(pack&0x0000000f) ; sh_pixZ(4);
\r
262 t=(pack&0x000000f0)>> 4; sh_pixZ(5);
\r
263 t=(pack&0x00000f00)>> 8; sh_pixZ(6);
\r
264 t=(pack&0x0000f000)>>12; sh_pixZ(7);
\r
265 if(collision) Pico.video.status|=0x20;
\r
268 return 1; // Tile blank
\r
271 // --------------------------------------------
\r
273 #ifndef _ASM_DRAW_C
\r
274 static void DrawStrip(struct TileStrip *ts, int sh)
\r
276 int tilex=0,dx=0,ty=0,code=0,addr=0,cells;
\r
277 int oldcode=-1,blank=-1; // The tile we know is blank
\r
280 // Draw tiles across screen:
\r
281 tilex=(-ts->hscroll)>>3;
\r
282 ty=(ts->line&7)<<1; // Y-Offset into tile
\r
283 dx=((ts->hscroll-1)&7)+1;
\r
285 if(dx != 8) cells++; // have hscroll, need to draw 1 cell more
\r
287 for (; cells; dx+=8,tilex++,cells--)
\r
291 code=Pico.vram[ts->nametab+(tilex&ts->xmask)];
\r
292 if (code==blank) continue;
\r
293 if (code>>15) { // high priority tile
\r
294 int cval = code | (dx<<16) | (ty<<25);
\r
295 if(code&0x1000) cval^=7<<26;
\r
296 *ts->hc++ = cval; // cache it
\r
300 if (code!=oldcode) {
\r
302 // Get tile address/2:
\r
303 addr=(code&0x7ff)<<4;
\r
305 if (code&0x1000) addr^=0xe; // Y-flip
\r
307 // pal=Pico.cram+((code>>9)&0x30);
\r
308 pal=((code>>9)&0x30)|(sh<<6);
\r
311 if (code&0x0800) zero=TileFlip(dx,addr,pal);
\r
312 else zero=TileNorm(dx,addr,pal);
\r
314 if (zero) blank=code; // We know this tile is blank now
\r
317 // terminate the cache list
\r
323 #ifndef _ASM_DRAW_C
\r
326 void DrawStripVSRam(struct TileStrip *ts, int plane)
\r
328 int tilex=0,dx=0,ty=0,code=0,addr=0,cell=0,nametabadd=0;
\r
329 int oldcode=-1,blank=-1; // The tile we know is blank
\r
330 int pal=0,scan=Scanline;
\r
332 // Draw tiles across screen:
\r
333 tilex=(-ts->hscroll)>>3;
\r
334 dx=((ts->hscroll-1)&7)+1;
\r
337 cell--; // have hscroll, start with negative cell
\r
338 // also calculate intial VS stuff
\r
339 vscroll=Pico.vsram[plane];
\r
341 // Find the line in the name table
\r
342 line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..
\r
343 nametabadd=(line>>3)<<(ts->line>>24); // .. and shift[width]
\r
344 ty=(line&7)<<1; // Y-Offset into tile
\r
347 for (; cell < ts->cells; dx+=8,tilex++,cell++)
\r
353 vscroll=Pico.vsram[plane+(cell&~1)];
\r
355 // Find the line in the name table
\r
356 line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..
\r
357 nametabadd=(line>>3)<<(ts->line>>24); // .. and shift[width]
\r
358 ty=(line&7)<<1; // Y-Offset into tile
\r
361 code=Pico.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];
\r
362 if (code==blank) continue;
\r
363 if (code>>15) { // high priority tile
\r
364 int cval = code | (dx<<16) | (ty<<25);
\r
365 if(code&0x1000) cval^=7<<26;
\r
366 *ts->hc++ = cval; // cache it
\r
370 if (code!=oldcode) {
\r
372 // Get tile address/2:
\r
373 addr=(code&0x7ff)<<4;
\r
374 if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
\r
376 // pal=Pico.cram+((code>>9)&0x30);
\r
377 pal=((code>>9)&0x30);
\r
380 if (code&0x0800) zero=TileFlip(dx,addr,pal);
\r
381 else zero=TileNorm(dx,addr,pal);
\r
383 if (zero) blank=code; // We know this tile is blank now
\r
386 // terminate the cache list
\r
390 #ifndef _ASM_DRAW_C
\r
393 void DrawStripInterlace(struct TileStrip *ts)
\r
395 int tilex=0,dx=0,ty=0,code=0,addr=0,cells;
\r
396 int oldcode=-1,blank=-1; // The tile we know is blank
\r
399 // Draw tiles across screen:
\r
400 tilex=(-ts->hscroll)>>3;
\r
401 ty=(ts->line&15)<<1; // Y-Offset into tile
\r
402 dx=((ts->hscroll-1)&7)+1;
\r
404 if(dx != 8) cells++; // have hscroll, need to draw 1 cell more
\r
406 for (; cells; dx+=8,tilex++,cells--)
\r
410 code=Pico.vram[ts->nametab+(tilex&ts->xmask)];
\r
411 if (code==blank) continue;
\r
412 if (code>>15) { // high priority tile
\r
413 int cval = (code&0xfc00) | (dx<<16) | (ty<<25);
\r
414 cval|=(code&0x3ff)<<1;
\r
415 if(code&0x1000) cval^=0xf<<26;
\r
416 *ts->hc++ = cval; // cache it
\r
420 if (code!=oldcode) {
\r
422 // Get tile address/2:
\r
423 addr=(code&0x7ff)<<5;
\r
424 if (code&0x1000) addr+=30-ty; else addr+=ty; // Y-flip
\r
426 // pal=Pico.cram+((code>>9)&0x30);
\r
427 pal=((code>>9)&0x30);
\r
430 if (code&0x0800) zero=TileFlip(dx,addr,pal);
\r
431 else zero=TileNorm(dx,addr,pal);
\r
433 if (zero) blank=code; // We know this tile is blank now
\r
436 // terminate the cache list
\r
440 // --------------------------------------------
\r
442 #ifndef _ASM_DRAW_C
\r
443 static void DrawLayer(int plane, int *hcache, int maxcells, int sh)
\r
445 struct PicoVideo *pvid=&Pico.video;
\r
446 const char shift[4]={5,6,5,7}; // 32,64 or 128 sized tilemaps (2 is invalid)
\r
447 struct TileStrip ts;
\r
448 int width, height, ymask;
\r
454 // Work out the TileStrip to draw
\r
456 // Work out the name table size: 32 64 or 128 tiles (0-3)
\r
457 width=pvid->reg[16];
\r
458 height=(width>>4)&3; width&=3;
\r
460 ts.xmask=(1<<shift[width])-1; // X Mask in tiles (0x1f-0x7f)
\r
461 ymask=(height<<8)|0xff; // Y Mask in pixels
\r
462 if(width == 1) ymask&=0x1ff;
\r
463 else if(width>1) ymask =0x0ff;
\r
465 // Find name table:
\r
466 if (plane==0) ts.nametab=(pvid->reg[2]&0x38)<< 9; // A
\r
467 else ts.nametab=(pvid->reg[4]&0x07)<<12; // B
\r
469 htab=pvid->reg[13]<<9; // Horizontal scroll table address
\r
470 if ( pvid->reg[11]&2) htab+=Scanline<<1; // Offset by line
\r
471 if ((pvid->reg[11]&1)==0) htab&=~0xf; // Offset by tile
\r
472 htab+=plane; // A or B
\r
474 // Get horizontal scroll value, will be masked later
\r
475 ts.hscroll=Pico.vram[htab&0x7fff];
\r
477 if((pvid->reg[12]&6) == 6) {
\r
478 // interlace mode 2
\r
479 vscroll=Pico.vsram[plane]; // Get vertical scroll value
\r
481 // Find the line in the name table
\r
482 ts.line=(vscroll+(Scanline<<1))&((ymask<<1)|1);
\r
483 ts.nametab+=(ts.line>>4)<<shift[width];
\r
485 DrawStripInterlace(&ts);
\r
486 } else if( pvid->reg[11]&4) {
\r
487 // shit, we have 2-cell column based vscroll
\r
488 // luckily this doesn't happen too often
\r
489 ts.line=ymask|(shift[width]<<24); // save some stuff instead of line
\r
490 DrawStripVSRam(&ts, plane);
\r
492 vscroll=Pico.vsram[plane]; // Get vertical scroll value
\r
494 // Find the line in the name table
\r
495 ts.line=(vscroll+Scanline)&ymask;
\r
496 ts.nametab+=(ts.line>>3)<<shift[width];
\r
498 DrawStrip(&ts, sh);
\r
503 // --------------------------------------------
\r
505 // tstart & tend are tile pair numbers
\r
506 static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache
\r
508 struct PicoVideo *pvid=&Pico.video;
\r
509 int tilex=0,ty=0,nametab,code=0;
\r
510 int blank=-1; // The tile we know is blank
\r
512 // Find name table line:
\r
513 if (pvid->reg[12]&1)
\r
515 nametab=(pvid->reg[3]&0x3c)<<9; // 40-cell mode
\r
516 nametab+=(Scanline>>3)<<6;
\r
520 nametab=(pvid->reg[3]&0x3e)<<9; // 32-cell mode
\r
521 nametab+=(Scanline>>3)<<5;
\r
527 ty=(Scanline&7)<<1; // Y-Offset into tile
\r
529 if(!(rendstatus&2)) {
\r
530 // check the first tile code
\r
531 code=Pico.vram[nametab+tilex];
\r
532 // if the whole window uses same priority (what is often the case), we may be able to skip this field
\r
533 if((code>>15) != prio) return;
\r
536 // Draw tiles across screen:
\r
537 for (; tilex < tend; tilex++)
\r
542 code=Pico.vram[nametab+tilex];
\r
543 if(code==blank) continue;
\r
544 if((code>>15) != prio) {
\r
549 pal=((code>>9)&0x30);
\r
552 int tmp, *zb = (int *)(HighCol+8+(tilex<<3));
\r
555 if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000;
\r
556 if(!(tmp&0x00800000)) tmp&=~0x00c00000; if(!(tmp&0x80000000)) tmp&=~0xc0000000;
\r
557 *zb++=tmp; tmp = *zb;
\r
558 if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000;
\r
559 if(!(tmp&0x00800000)) tmp&=~0x00c00000; if(!(tmp&0x80000000)) tmp&=~0xc0000000;
\r
566 // Get tile address/2:
\r
567 addr=(code&0x7ff)<<4;
\r
568 if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
\r
570 if (code&0x0800) zero=TileFlip(8+(tilex<<3),addr,pal);
\r
571 else zero=TileNorm(8+(tilex<<3),addr,pal);
\r
573 if (zero) blank=code; // We know this tile is blank now
\r
576 // terminate the cache list
\r
580 // --------------------------------------------
\r
582 static void DrawTilesFromCache(int *hc, int sh)
\r
584 int code, addr, zero, dx;
\r
586 short blank=-1; // The tile we know is blank
\r
588 // *ts->hc++ = code | (dx<<16) | (ty<<25); // cache it
\r
590 while((code=*hc++)) {
\r
591 if(!sh && (short)code == blank) continue;
\r
593 // Get tile address/2:
\r
594 addr=(code&0x7ff)<<4;
\r
595 addr+=(unsigned int)code>>25; // y offset into tile
\r
596 dx=(code>>16)&0x1ff;
\r
598 unsigned char *zb = HighCol+dx;
\r
599 if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++;
\r
600 if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++;
\r
601 if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++;
\r
602 if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++;
\r
605 pal=((code>>9)&0x30);
\r
607 if (code&0x0800) zero=TileFlip(dx,addr,pal);
\r
608 else zero=TileNorm(dx,addr,pal);
\r
610 if(zero) blank=(short)code;
\r
614 // --------------------------------------------
\r
616 // Index + 0 : hhhhvvvv ab--hhvv yyyyyyyy yyyyyyyy // a: offscreen h, b: offs. v, h: horiz. size
\r
617 // Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
\r
619 static void DrawSprite(int *sprite, int **hc, int sh)
\r
621 int width=0,height=0;
\r
624 int tile=0,delta=0;
\r
626 int (*fTileFunc)(int sx,int addr,int pal);
\r
628 // parse the sprite data
\r
633 height=(sy>>24)&7; // Width and height in tiles
\r
634 sy=(sy<<16)>>16; // Y
\r
636 row=Scanline-sy; // Row of the sprite we are on
\r
638 if (code&0x1000) row=(height<<3)-1-row; // Flip Y
\r
640 tile=code&0x7ff; // Tile number
\r
641 tile+=row>>3; // Tile number increases going down
\r
642 delta=height; // Delta to increase tile by going right
\r
643 if (code&0x0800) { tile+=delta*(width-1); delta=-delta; } // Flip X
\r
645 tile<<=4; tile+=(row&7)<<1; // Tile address
\r
647 if(code&0x8000) { // high priority - cache it
\r
648 *(*hc)++ = (tile<<16)|((code&0x0800)<<5)|((sx<<6)&0x0000ffc0)|((code>>9)&0x30)|((sprite[0]>>16)&0xf);
\r
650 delta<<=4; // Delta of address
\r
651 pal=((code>>9)&0x30)|(sh<<6);
\r
653 if(sh && (code&0x6000) == 0x6000) {
\r
654 if(code&0x0800) fTileFunc=TileFlipSH;
\r
655 else fTileFunc=TileNormSH;
\r
657 if(code&0x0800) fTileFunc=TileFlip;
\r
658 else fTileFunc=TileNorm;
\r
661 for (; width; width--,sx+=8,tile+=delta)
\r
663 if(sx<=0) continue;
\r
664 if(sx>=328) break; // Offscreen
\r
666 tile&=0x7fff; // Clip tile address
\r
667 fTileFunc(sx,tile,pal);
\r
674 // Index + 0 : hhhhvvvv s---hhvv yyyyyyyy yyyyyyyy // s: skip flag, h: horiz. size
\r
675 // Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
\r
677 static void DrawSpriteZ(int pack, int pack2, int shpri, int sprio)
\r
679 int width=0,height=0;
\r
682 int tile=0,delta=0;
\r
684 int (*fTileFunc)(int sx,int addr,int pal,int zval);
\r
686 // parse the sprite data
\r
688 sy=(pack <<16)>>16; // Y
\r
690 height=(pack>>24)&7; // Width and height in tiles
\r
692 row=Scanline-sy; // Row of the sprite we are on
\r
694 if (pack2&0x1000) row=(height<<3)-1-row; // Flip Y
\r
696 tile=pack2&0x7ff; // Tile number
\r
697 tile+=row>>3; // Tile number increases going down
\r
698 delta=height; // Delta to increase tile by going right
\r
699 if (pack2&0x0800) { tile+=delta*(width-1); delta=-delta; } // Flip X
\r
701 tile<<=4; tile+=(row&7)<<1; // Tile address
\r
702 delta<<=4; // Delta of address
\r
703 pal=((pack2>>9)&0x30);
\r
704 if((shpri&1)&&!(shpri&2)) pal|=0x40;
\r
707 if((pack2&0x6000) != 0x6000) shpri = 0;
\r
708 shpri |= (pack2&0x0800)>>10;
\r
711 case 0: fTileFunc=TileNormZ; break;
\r
712 case 1: fTileFunc=TileNormZSH; break;
\r
713 case 2: fTileFunc=TileFlipZ; break;
\r
714 case 3: fTileFunc=TileFlipZSH; break;
\r
717 for (; width; width--,sx+=8,tile+=delta)
\r
719 if(sx<=0) continue;
\r
720 if(sx>=328) break; // Offscreen
\r
722 tile&=0x7fff; // Clip tile address
\r
723 fTileFunc(sx,tile,pal,sprio);
\r
727 static void DrawSpriteInterlace(unsigned int *sprite)
\r
729 int width=0,height=0;
\r
732 int tile=0,delta=0;
\r
735 // parse the sprite data
\r
738 sy=(sy&0x3ff)-0x100; // Y
\r
739 width=(height>>2)&3; height&=3;
\r
740 width++; height++; // Width and height in tiles
\r
742 row=(Scanline<<1)-sy; // Row of the sprite we are on
\r
745 sx=((code>>16)&0x1ff)-0x78; // X
\r
747 if (code&0x1000) row^=(16<<height)-1; // Flip Y
\r
749 tile=code&0x3ff; // Tile number
\r
750 tile+=row>>4; // Tile number increases going down
\r
751 delta=height; // Delta to increase tile by going right
\r
752 if (code&0x0800) { tile+=delta*(width-1); delta=-delta; } // Flip X
\r
754 tile<<=5; tile+=(row&15)<<1; // Tile address
\r
756 delta<<=5; // Delta of address
\r
757 pal=((code>>9)&0x30); // Get palette pointer
\r
759 for (; width; width--,sx+=8,tile+=delta)
\r
761 if(sx<=0) continue;
\r
762 if(sx>=328) break; // Offscreen
\r
764 tile&=0x7fff; // Clip tile address
\r
765 if (code&0x0800) TileFlip(sx,tile,pal);
\r
766 else TileNorm(sx,tile,pal);
\r
771 static void DrawAllSpritesInterlace(int pri, int maxwidth)
\r
773 struct PicoVideo *pvid=&Pico.video;
\r
774 int i,u,table,link=0,sline=Scanline<<1;
\r
775 unsigned int *sprites[80]; // Sprite index
\r
777 table=pvid->reg[5]&0x7f;
\r
778 if (pvid->reg[12]&1) table&=0x7e; // Lowest bit 0 in 40-cell mode
\r
779 table<<=8; // Get sprite table address/2
\r
781 for (i=u=0; u < 80 && i < 21; u++)
\r
783 unsigned int *sprite;
\r
784 int code, sx, sy, height;
\r
786 sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
\r
791 if(((sx>>15)&1) != pri) goto nextsprite; // wrong priority sprite
\r
793 // check if it is on this line
\r
794 sy = (code&0x3ff)-0x100;
\r
795 height = (((code>>24)&3)+1)<<4;
\r
796 if(sline < sy || sline >= sy+height) goto nextsprite; // no
\r
798 // check if sprite is not hidden offscreen
\r
799 sx = (sx>>16)&0x1ff;
\r
800 sx -= 0x78; // Get X coordinate + 8
\r
801 if(sx <= -8*3 || sx >= maxwidth) goto nextsprite;
\r
803 // sprite is good, save it's pointer
\r
804 sprites[i++]=sprite;
\r
807 // Find next sprite
\r
808 link=(code>>16)&0x7f;
\r
809 if(!link) break; // End of sprites
\r
812 // Go through sprites backwards:
\r
813 for (i-- ;i>=0; i--)
\r
814 DrawSpriteInterlace(sprites[i]);
\r
818 #ifndef _ASM_DRAW_C
\r
819 static void DrawSpritesFromCache(int *hc, int sh)
\r
821 int code, tile, sx, delta, width;
\r
823 int (*fTileFunc)(int sx,int addr,int pal);
\r
825 // *(*hc)++ = (tile<<16)|((code&0x0800)<<5)|((sx<<6)&0x0000ffc0)|((code>>9)&0x30)|((sprite[0]>>24)&0xf);
\r
827 while((code=*hc++)) {
\r
830 width=delta>>2; delta&=3;
\r
831 width++; delta++; // Width and height in tiles
\r
832 if (code&0x10000) delta=-delta; // Flip X
\r
834 tile=((unsigned int)code>>17)<<1;
\r
835 sx=(code<<16)>>22; // sx can be negative (start offscreen), so sign extend
\r
837 if(sh && pal == 0x30) { //
\r
838 if(code&0x10000) fTileFunc=TileFlipSH;
\r
839 else fTileFunc=TileNormSH;
\r
841 if(code&0x10000) fTileFunc=TileFlip;
\r
842 else fTileFunc=TileNorm;
\r
845 for (; width; width--,sx+=8,tile+=delta)
\r
847 if(sx<=0) continue;
\r
848 if(sx>=328) break; // Offscreen
\r
850 tile&=0x7fff; // Clip tile address
\r
851 fTileFunc(sx,tile,pal);
\r
858 // Index + 0 : ----hhvv -lllllll -------y yyyyyyyy
\r
859 // Index + 4 : -------x xxxxxxxx pccvhnnn nnnnnnnn
\r
861 // Index + 0 : hhhhvvvv ab--hhvv yyyyyyyy yyyyyyyy // a: offscreen h, b: offs. v, h: horiz. size
\r
862 // Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
\r
864 static void PrepareSprites(int full)
\r
866 struct PicoVideo *pvid=&Pico.video;
\r
867 int u=0,link=0,sblocks=0;
\r
869 int *pd = HighPreSpr;
\r
871 table=pvid->reg[5]&0x7f;
\r
872 if (pvid->reg[12]&1) table&=0x7e; // Lowest bit 0 in 40-cell mode
\r
873 table<<=8; // Get sprite table address/2
\r
878 // updates: tilecode, sx
\r
879 for (u=0; u < 80 && (pack = *pd); u++, pd+=2)
\r
881 unsigned int *sprite;
\r
882 int code, code2, sx, sy, skip=0;
\r
884 sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
\r
886 // parse sprite info
\r
889 code2 &= ~0xfe000000;
\r
890 code2 -= 0x00780000; // Get X coordinate + 8 in upper 16 bits
\r
893 if((sx <= 8-((pack>>28)<<3) && sx >= -0x76) || sx >= 328) skip=1<<23;
\r
894 else if ((sy = (pack<<16)>>16) < 240 && sy > -32) {
\r
895 int sbl = (2<<(pack>>28))-1;
\r
896 sblocks |= sbl<<(sy>>3);
\r
899 *pd = (pack&~(1<<23))|skip;
\r
902 // Find next sprite
\r
903 link=(code>>16)&0x7f;
\r
904 if(!link) break; // End of sprites
\r
906 SpriteBlocks |= sblocks;
\r
910 for (; u < 80; u++)
\r
912 unsigned int *sprite;
\r
913 int code, code2, sx, sy, hv, height, width, skip=0, sx_min;
\r
915 sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
\r
917 // parse sprite info
\r
919 sy = (code&0x1ff)-0x80;
\r
920 hv = (code>>24)&0xf;
\r
923 if(sy > 240 || sy + (height<<3) <= 0) skip|=1<<22;
\r
927 sx = (code2>>16)&0x1ff;
\r
928 sx -= 0x78; // Get X coordinate + 8
\r
929 sx_min = 8-(width<<3);
\r
931 if((sx <= sx_min && sx >= -0x76) || sx >= 328) skip|=1<<23;
\r
932 else if (sx > sx_min && !skip) {
\r
933 int sbl = (2<<height)-1;
\r
935 if(shi < 0) shi=0; // negative sy
\r
936 sblocks |= sbl<<shi;
\r
939 *pd++ = (width<<28)|(height<<24)|skip|(hv<<16)|((unsigned short)sy);
\r
940 *pd++ = (sx<<16)|((unsigned short)code2);
\r
942 // Find next sprite
\r
943 link=(code>>16)&0x7f;
\r
944 if(!link) break; // End of sprites
\r
946 SpriteBlocks = sblocks;
\r
947 *pd = 0; // terminate
\r
951 static void DrawAllSprites(int *hcache, int maxwidth, int prio, int sh)
\r
954 int sx1seen=0; // sprite with x coord 1 or 0 seen
\r
955 int ntiles = 0; // tile counter for sprite limit emulation
\r
956 int *sprites[40]; // Sprites to draw in fast mode
\r
957 int *ps, pack, rs = rendstatus, scan=Scanline;
\r
960 DrawAllSpritesInterlace(prio, maxwidth);
\r
964 //dprintf("PrepareSprites(%i) [%i]", (rs>>4)&1, scan);
\r
965 PrepareSprites(rs&0x10);
\r
966 rendstatus=rs&~0x11;
\r
968 if (!(SpriteBlocks & (1<<(scan>>3)))) return;
\r
970 if(((rs&4)||sh)&&prio==0)
\r
971 memset(HighSprZ, 0, 328);
\r
972 if(!(rs&4)&&prio) {
\r
973 if(hcache[0]) DrawSpritesFromCache(hcache, sh);
\r
979 // Index + 0 : hhhhvvvv ab--hhvv yyyyyyyy yyyyyyyy // a: offscreen h, b: offs. v, h: horiz. size
\r
980 // Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
\r
982 for(i=u=n=0; (pack = *ps) && n < 20; ps+=2, u++)
\r
984 int sx, sy, row, pack2;
\r
986 if(pack & 0x00400000) continue;
\r
991 sy = (pack <<16)>>16;
\r
994 //dprintf("x: %i y: %i %ix%i", sx, sy, (pack>>28)<<3, (pack>>21)&0x38);
\r
996 if(sx == -0x77) sx1seen|=1; // for masking mode 2
\r
998 // check if it is on this line
\r
999 if(row < 0 || row >= ((pack>>21)&0x38)) continue; // no
\r
1000 n++; // number of sprites on this line (both visible and hidden, max is 20) [broken]
\r
1003 ntiles += pack>>28;
\r
1004 if(ntiles > 40) break;
\r
1006 if(pack & 0x00800000) continue;
\r
1008 // masking sprite?
\r
1010 if(!(sx1seen&1) || sx1seen==3) {
\r
1011 break; // this sprite is not drawn and remaining sprites are masked
\r
1013 if((sx1seen>>8) == 0) sx1seen=(i+1)<<8;
\r
1016 else if(sx == -0x77) {
\r
1017 // masking mode2 (Outrun, Galaxy Force II, Shadow of the beast)
\r
1018 if(sx1seen>>8) { i=(sx1seen>>8)-1; break; } // seen both 0 and 1
\r
1023 // accurate sprites
\r
1024 //dprintf("P:%i",((sx>>15)&1));
\r
1026 // might need to skip this sprite
\r
1027 if((pack2&0x8000) ^ (prio<<15)) continue;
\r
1028 DrawSpriteZ(pack,pack2,sh|(prio<<1),(char)(0x1f-n));
\r
1032 // sprite is good, save it's pointer
\r
1036 // Go through sprites backwards:
\r
1038 for (i--; i>=0; i--)
\r
1039 DrawSprite(sprites[i],&hcache,sh);
\r
1041 // terminate cache list
\r
1047 // --------------------------------------------
\r
1049 #ifndef _ASM_DRAW_C
\r
1050 static void BackFill(int reg7, int sh)
\r
1052 unsigned int back=0;
\r
1053 unsigned int *pd=NULL,*end=NULL;
\r
1055 // Start with a blank scanline (background colour):
\r
1061 pd= (unsigned int *)(HighCol+8);
\r
1062 end=(unsigned int *)(HighCol+8+320);
\r
1064 do { pd[0]=pd[1]=pd[2]=pd[3]=back; pd+=4; } while (pd<end);
\r
1068 // --------------------------------------------
\r
1070 unsigned short HighPal[0x100];
\r
1072 #ifndef _ASM_DRAW_C
\r
1073 static void FinalizeLineBGR444(int sh)
\r
1075 unsigned short *pd=DrawLineDest;
\r
1076 unsigned char *ps=HighCol+8;
\r
1077 unsigned short *pal=Pico.cram;
\r
1080 if (Pico.video.reg[12]&1) {
\r
1083 if(!(PicoOpt&0x100)) pd+=32;
\r
1089 if(Pico.m.dirtyPal) {
\r
1090 blockcpy(pal, Pico.cram, 0x40*2);
\r
1091 // shadowed pixels
\r
1092 for(i = 0x3f; i >= 0; i--)
\r
1093 pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x0777);
\r
1094 // hilighted pixels
\r
1095 for(i = 0x3f; i >= 0; i--) {
\r
1096 t=pal[i]&0xeee;t+=0x444;if(t&0x10)t|=0xe;if(t&0x100)t|=0xe0;if(t&0x1000)t|=0xe00;t&=0xeee;
\r
1097 pal[0x80|i]=(unsigned short)t;
\r
1099 Pico.m.dirtyPal = 0;
\r
1103 for(i = 0; i < len; i++)
\r
1104 pd[i] = pal[ps[i]];
\r
1108 static void FinalizeLineRGB555(int sh)
\r
1110 unsigned short *pd=DrawLineDest;
\r
1111 unsigned char *ps=HighCol+8;
\r
1112 unsigned short *pal=HighPal;
\r
1113 int len, i, t, dirtyPal = Pico.m.dirtyPal;
\r
1116 unsigned short *ppal=Pico.cram;
\r
1117 for(i = 0x3f; i >= 0; i--)
\r
1118 pal[i] = (unsigned short) (((ppal[i]&0x00f)<<12)|((ppal[i]&0x0f0)<<3)|((ppal[i]&0xf00)>>7));
\r
1119 Pico.m.dirtyPal = 0;
\r
1122 if (Pico.video.reg[12]&1) {
\r
1125 if(!(PicoOpt&0x100)) pd+=32;
\r
1131 // shadowed pixels
\r
1132 for(i = 0x3f; i >= 0; i--)
\r
1133 pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x738e);
\r
1134 // hilighted pixels
\r
1135 for(i = 0x3f; i >= 0; i--) {
\r
1136 t=pal[i]&0xe71c;t+=0x4208;if(t&0x20)t|=0x1c;if(t&0x800)t|=0x700;if(t&0x10000)t|=0xe000;t&=0xe71c;
\r
1137 pal[0x80|i]=(unsigned short)t;
\r
1142 for(i = 0; i < len; i++)
\r
1143 pd[i] = pal[ps[i]];
\r
1147 static void FinalizeLine8bit(int sh)
\r
1149 unsigned char *pd=DrawLineDest;
\r
1150 int len, rs = rendstatus;
\r
1151 static int dirty_count;
\r
1153 if (!sh && Pico.m.dirtyPal == 1 && Scanline < 222) {
\r
1154 // a hack for mid-frame palette changes
\r
1157 else dirty_count++;
\r
1160 if (dirty_count == 3) {
\r
1161 blockcpy(HighPal, Pico.cram, 0x40*2);
\r
1162 } else if (dirty_count == 11) {
\r
1163 blockcpy(HighPal+0x40, Pico.cram, 0x40*2);
\r
1167 if (Pico.video.reg[12]&1) {
\r
1170 if(!(PicoOpt&0x100)) pd+=32;
\r
1174 if (!sh && rs & 0x20) {
\r
1175 if (dirty_count >= 11) {
\r
1176 blockcpy_or(pd, HighCol+8, len, 0x80);
\r
1178 blockcpy_or(pd, HighCol+8, len, 0x40);
\r
1181 blockcpy(pd, HighCol+8, len);
\r
1185 void (*FinalizeLine)(int sh) = FinalizeLineBGR444;
\r
1187 // --------------------------------------------
\r
1189 static int DrawDisplay(int sh)
\r
1191 struct PicoVideo *pvid=&Pico.video;
\r
1192 int win=0,edge=0,hvwind=0;
\r
1193 int maxw, maxcells;
\r
1195 if(pvid->reg[12]&1) {
\r
1196 maxw = 328; maxcells = 40;
\r
1198 maxw = 264; maxcells = 32;
\r
1201 // Find out if the window is on this line:
\r
1202 win=pvid->reg[0x12];
\r
1203 edge=(win&0x1f)<<3;
\r
1205 if (win&0x80) { if (Scanline>=edge) hvwind=1; }
\r
1206 else { if (Scanline< edge) hvwind=1; }
\r
1208 if(!hvwind) { // we might have a vertical window here
\r
1209 win=pvid->reg[0x11];
\r
1212 if(!edge) hvwind=1;
\r
1213 else if(edge < (maxcells>>1)) hvwind=2;
\r
1216 else if(edge < (maxcells>>1)) hvwind=2;
\r
1221 DrawLayer(1, HighCacheB, maxcells, sh);
\r
1223 DrawWindow(0, maxcells>>1, 0, sh); // HighCacheAW
\r
1224 else if(hvwind == 2) {
\r
1225 // ahh, we have vertical window
\r
1226 DrawLayer(0, HighCacheA, (win&0x80) ? edge<<1 : maxcells, sh);
\r
1227 DrawWindow((win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh); // HighCacheW
\r
1229 DrawLayer(0, HighCacheA, maxcells, sh);
\r
1230 DrawAllSprites(HighCacheS, maxw, 0, sh);
\r
1232 if(HighCacheB[0]) DrawTilesFromCache(HighCacheB, sh);
\r
1234 DrawWindow(0, maxcells>>1, 1, sh);
\r
1235 else if(hvwind == 2) {
\r
1236 if(HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh);
\r
1237 DrawWindow((win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 1, sh);
\r
1239 if(HighCacheA[0]) DrawTilesFromCache(HighCacheA, sh);
\r
1240 DrawAllSprites(HighCacheS, maxw, 1, sh);
\r
1246 static int Skip=0;
\r
1248 void PicoFrameStart()
\r
1250 // prepare to do this frame
\r
1251 rendstatus = (PicoOpt&0x80)>>5; // accurate sprites
\r
1253 Pico.video.status &= ~0x0020;
\r
1254 else Pico.video.status |= 0x0020; // sprite collision
\r
1255 if((Pico.video.reg[12]&6) == 6) rendstatus |= 8; // interlace mode
\r
1256 if(Pico.m.dirtyPal) Pico.m.dirtyPal = 2; // reset dirty if needed
\r
1258 PrepareSprites(1);
\r
1262 int PicoLine(int scan)
\r
1265 if (Skip>0) { Skip--; return 0; } // Skip rendering lines
\r
1268 sh=(Pico.video.reg[0xC]&8)>>3; // shadow/hilight?
\r
1271 BackFill(Pico.video.reg[7], sh);
\r
1272 if (Pico.video.reg[1]&0x40)
\r
1276 //if (SpriteBlocks & (1<<(scan>>3))) for (sh=0; sh < 30; sh++) DrawLineDest[sh] = 0xf;
\r
1278 Skip=PicoScan(Scanline,DrawLineDest);
\r
1284 void PicoDrawSetColorFormat(int which)
\r
1287 FinalizeLine = FinalizeLine8bit;
\r
1288 else if (which == 1)
\r
1289 FinalizeLine = FinalizeLineRGB555;
\r
1290 else FinalizeLine = FinalizeLineBGR444;
\r