3 * (C) notaz, 2006-2008
\r
4 * (C) irixxxx, 2020-2023
\r
6 * This work is licensed under the terms of MAME license.
\r
7 * See COPYING file in the top-level directory.
\r
10 #include "pico_int.h"
\r
12 #define START_ROW 0 // which row of tiles to start rendering at?
\r
13 #define END_ROW 28 // ..end
\r
15 #define VSRAM 0 // 2-cell vscroll (broken for line based hscroll)
\r
16 #define INTERLACE 0 // interlace mode 2
\r
18 #define TILE_ROWS END_ROW-START_ROW
\r
20 // note: this is not implemented in ARM asm
\r
21 #if defined(DRAW2_OVERRIDE_LINE_WIDTH)
\r
22 #define LINE_WIDTH DRAW2_OVERRIDE_LINE_WIDTH
\r
24 #define LINE_WIDTH 328
\r
27 static unsigned char PicoDraw2FB_[LINE_WIDTH * (8+240+8) + 8];
\r
29 static u32 HighCache2A[2*41*(TILE_ROWS+1)+1+1]; // caches for high layers
\r
30 static u32 HighCache2B[2*41*(TILE_ROWS+1)+1+1];
\r
32 unsigned short *PicoCramHigh=PicoMem.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
\r
33 void (*PicoPrepareCram)(void) = NULL; // prepares PicoCramHigh for renderer to use
\r
36 // stuff available in asm:
\r
38 void BackFillFull(void *dst, int reg7, int lwidth);
\r
39 void DrawLayerFull(int plane, u32 *hcache, int planestart, int planeend,
\r
40 struct PicoEState *est);
\r
41 void DrawTilesFromCacheF(u32 *hc, struct PicoEState *est);
\r
42 void DrawWindowFull(int start, int end, int prio, struct PicoEState *est);
\r
43 void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est);
\r
47 static int TileXnormYnorm(unsigned char *pd,int addr,unsigned char pal, struct PicoEState *est)
\r
49 unsigned int pack=0; unsigned int t=0, blank = 1;
\r
50 unsigned short *vram = est->PicoMem_vram;
\r
54 if (est->rendstatus & PDRAW_INTERLACE) inc = 4;
\r
56 for(i=8; i; i--, addr+=inc, pd += est->Draw2Width) {
\r
57 pack=*(u32 *)(vram+addr); // Get 8 pixels
\r
60 t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);
\r
61 t=pack&0x00000f00; if (t) pd[1]=(unsigned char)((t>> 8)|pal);
\r
62 t=pack&0x000000f0; if (t) pd[2]=(unsigned char)((t>> 4)|pal);
\r
63 t=pack&0x0000000f; if (t) pd[3]=(unsigned char)((t )|pal);
\r
64 t=pack&0xf0000000; if (t) pd[4]=(unsigned char)((t>>28)|pal);
\r
65 t=pack&0x0f000000; if (t) pd[5]=(unsigned char)((t>>24)|pal);
\r
66 t=pack&0x00f00000; if (t) pd[6]=(unsigned char)((t>>20)|pal);
\r
67 t=pack&0x000f0000; if (t) pd[7]=(unsigned char)((t>>16)|pal);
\r
71 return blank; // Tile blank?
\r
74 static int TileXflipYnorm(unsigned char *pd,int addr,unsigned char pal, struct PicoEState *est)
\r
76 unsigned int pack=0; unsigned int t=0, blank = 1;
\r
77 unsigned short *vram = est->PicoMem_vram;
\r
81 if (est->rendstatus & PDRAW_INTERLACE) inc = 4;
\r
83 for(i=8; i; i--, addr+=inc, pd += est->Draw2Width) {
\r
84 pack=*(u32 *)(vram+addr); // Get 8 pixels
\r
87 t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);
\r
88 t=pack&0x00f00000; if (t) pd[1]=(unsigned char)((t>>20)|pal);
\r
89 t=pack&0x0f000000; if (t) pd[2]=(unsigned char)((t>>24)|pal);
\r
90 t=pack&0xf0000000; if (t) pd[3]=(unsigned char)((t>>28)|pal);
\r
91 t=pack&0x0000000f; if (t) pd[4]=(unsigned char)((t )|pal);
\r
92 t=pack&0x000000f0; if (t) pd[5]=(unsigned char)((t>> 4)|pal);
\r
93 t=pack&0x00000f00; if (t) pd[6]=(unsigned char)((t>> 8)|pal);
\r
94 t=pack&0x0000f000; if (t) pd[7]=(unsigned char)((t>>12)|pal);
\r
97 return blank; // Tile blank?
\r
100 static int TileXnormYflip(unsigned char *pd,int addr,unsigned char pal, struct PicoEState *est)
\r
102 unsigned int pack=0; unsigned int t=0, blank = 1;
\r
103 unsigned short *vram = est->PicoMem_vram;
\r
107 if (est->rendstatus & PDRAW_INTERLACE) inc = 4, addr += 16;
\r
110 for(i=8; i; i--, addr-=inc, pd += est->Draw2Width) {
\r
111 pack=*(u32 *)(vram+addr); // Get 8 pixels
\r
112 if(!pack) continue;
\r
114 t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);
\r
115 t=pack&0x00000f00; if (t) pd[1]=(unsigned char)((t>> 8)|pal);
\r
116 t=pack&0x000000f0; if (t) pd[2]=(unsigned char)((t>> 4)|pal);
\r
117 t=pack&0x0000000f; if (t) pd[3]=(unsigned char)((t )|pal);
\r
118 t=pack&0xf0000000; if (t) pd[4]=(unsigned char)((t>>28)|pal);
\r
119 t=pack&0x0f000000; if (t) pd[5]=(unsigned char)((t>>24)|pal);
\r
120 t=pack&0x00f00000; if (t) pd[6]=(unsigned char)((t>>20)|pal);
\r
121 t=pack&0x000f0000; if (t) pd[7]=(unsigned char)((t>>16)|pal);
\r
125 return blank; // Tile blank?
\r
128 static int TileXflipYflip(unsigned char *pd,int addr,unsigned char pal, struct PicoEState *est)
\r
130 unsigned int pack=0; unsigned int t=0, blank = 1;
\r
131 unsigned short *vram = est->PicoMem_vram;
\r
135 if (est->rendstatus & PDRAW_INTERLACE) inc = 4, addr += 16;
\r
138 for(i=8; i; i--, addr-=inc, pd += est->Draw2Width) {
\r
139 pack=*(u32 *)(vram+addr); // Get 8 pixels
\r
140 if(!pack) continue;
\r
142 t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);
\r
143 t=pack&0x00f00000; if (t) pd[1]=(unsigned char)((t>>20)|pal);
\r
144 t=pack&0x0f000000; if (t) pd[2]=(unsigned char)((t>>24)|pal);
\r
145 t=pack&0xf0000000; if (t) pd[3]=(unsigned char)((t>>28)|pal);
\r
146 t=pack&0x0000000f; if (t) pd[4]=(unsigned char)((t )|pal);
\r
147 t=pack&0x000000f0; if (t) pd[5]=(unsigned char)((t>> 4)|pal);
\r
148 t=pack&0x00000f00; if (t) pd[6]=(unsigned char)((t>> 8)|pal);
\r
149 t=pack&0x0000f000; if (t) pd[7]=(unsigned char)((t>>12)|pal);
\r
152 return blank; // Tile blank?
\r
156 // start: (tile_start<<16)|row_start, end: [same]
\r
157 static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)
\r
159 struct PicoVideo *pvid=&est->Pico->video;
\r
160 int nametab, nametab_step, trow, tilex, blank=-1, code;
\r
161 unsigned char *scrpos = est->Draw2FB;
\r
162 int scrstart = est->Draw2Start;
\r
163 int tile_start, tile_end; // in cells
\r
166 tile_start = start>>16;
\r
167 tile_end = end>>16;
\r
168 start = start<<16>>16;
\r
171 // Find name table line:
\r
172 if (!(est->rendstatus & PDRAW_32_COLS))
\r
174 nametab=(pvid->reg[3]&0x3c)<<9; // 40-cell mode
\r
175 nametab_step = 1<<6;
\r
179 nametab=(pvid->reg[3]&0x3e)<<9; // 32-cell mode
\r
180 nametab_step = 1<<5;
\r
181 if (est->rendstatus & PDRAW_BORDER_32)
\r
184 nametab += nametab_step*(start-scrstart);
\r
187 code=est->PicoMem_vram[nametab+tile_start];
\r
188 if ((code>>15) != prio) return; // hack: just assume that whole window uses same priority
\r
190 scrpos+=8*est->Draw2Width+8;
\r
191 scrpos+=8*est->Draw2Width*(start-scrstart);
\r
193 // do a window until we reach planestart row
\r
194 for(trow = start; trow < end; trow++, nametab+=nametab_step) { // current tile row
\r
195 for (tilex=tile_start; tilex<tile_end; tilex++)
\r
197 int code,addr,zero=0;
\r
198 // unsigned short *pal=NULL;
\r
201 code=est->PicoMem_vram[nametab+tilex];
\r
202 if (code==blank) continue;
\r
204 // Get tile address/2:
\r
206 if (est->rendstatus & PDRAW_INTERLACE)
\r
207 addr=(code&0x3ff)<<5;
\r
210 addr=(code&0x7ff)<<4;
\r
212 // pal=PicoCramHigh+((code>>9)&0x30);
\r
213 pal=(unsigned char)((code>>9)&0x30);
\r
215 switch((code>>11)&3) {
\r
216 case 0: zero=TileXnormYnorm(scrpos+(tilex<<3),addr,pal,est); break;
\r
217 case 1: zero=TileXflipYnorm(scrpos+(tilex<<3),addr,pal,est); break;
\r
218 case 2: zero=TileXnormYflip(scrpos+(tilex<<3),addr,pal,est); break;
\r
219 case 3: zero=TileXflipYflip(scrpos+(tilex<<3),addr,pal,est); break;
\r
221 if(zero) blank=code; // We know this tile is blank now
\r
224 scrpos += est->Draw2Width*8;
\r
229 static void DrawLayerFull(int plane, u32 *hcache, int planestart, int planeend,
\r
230 struct PicoEState *est)
\r
232 struct PicoVideo *pvid=&est->Pico->video;
\r
233 static char shift[4]={5,6,5,7}; // 32,64 or 128 sized tilemaps
\r
234 int width, height, ymask, htab;
\r
235 int nametab, hscroll=0, vscroll, cells;
\r
236 unsigned char *scrpos;
\r
237 int scrstart = est->Draw2Start;
\r
238 int blank=-1, xmask, nametab_row, trow;
\r
241 cells = (planeend>>16)-(planestart>>16);
\r
242 planestart = planestart<<16>>16;
\r
243 planeend = planeend<<16>>16;
\r
245 // Work out the Tiles to draw
\r
247 htab=pvid->reg[13]<<9; // Horizontal scroll table address
\r
248 // if ( pvid->reg[11]&2) htab+=Scanline<<1; // Offset by line
\r
249 // if ((pvid->reg[11]&1)==0) htab&=~0xf; // Offset by tile
\r
250 htab+=plane; // A or B
\r
252 if(!(pvid->reg[11]&3)) { // full screen scroll
\r
253 // Get horizontal scroll value
\r
254 hscroll=est->PicoMem_vram[htab&0x7fff];
\r
255 htab = 0; // this marks that we don't have to update scroll value
\r
258 // Work out the name table size: 32 64 or 128 tiles (0-3)
\r
259 width=pvid->reg[16];
\r
260 height=(width>>4)&3; width&=3;
\r
262 xmask=(1<<shift[width ])-1; // X Mask in tiles
\r
263 ymask=(height<<5)|0x1f; // Y Mask in tiles
\r
264 if(width == 1) ymask&=0x3f;
\r
265 else if(width>1) ymask =0x1f;
\r
267 // Find name table:
\r
268 if (plane==0) nametab=(pvid->reg[2]&0x38)<< 9; // A
\r
269 else nametab=(pvid->reg[4]&0x07)<<12; // B
\r
271 scrpos = est->Draw2FB;
\r
272 if ((~est->rendstatus & (PDRAW_BORDER_32|PDRAW_32_COLS)) == 0)
\r
274 scrpos+=8*est->Draw2Width*(planestart-scrstart);
\r
276 if((pvid->reg[11]&4)||(PicoMem.vsram[plane]&7))
\r
277 planeend++; // we (may) have vertically clipped tiles due to vscroll, so we need 1 more row
\r
278 for(trow = planestart; trow < planeend; trow++) { // current tile row
\r
279 int cellc=cells,tilex,dx,vsidx=0;
\r
281 // Get vertical scroll value:
\r
282 vscroll=PicoMem.vsram[plane];//&0x1ff;
\r
284 if ((est->rendstatus & PDRAW_32_COLS) && (pvid->reg[11]&4)) // H32 + 2-cell mode
\r
285 vscroll=PicoMem.vsram[plane+0x20];//&0x1ff;
\r
288 if (est->rendstatus & PDRAW_INTERLACE)
\r
291 nametab_row = nametab + (((trow+(vscroll>>3))&ymask)<<shift[width]); // pointer to nametable entries for this row
\r
293 // Find the tile row in the name table
\r
294 //ts.line=(vscroll+Scanline)&ymask;
\r
295 //ts.nametab+=(ts.line>>3)<<shift[width];
\r
297 // update hscroll if needed
\r
299 int htaddr=htab+(trow<<4);
\r
300 if(trow) htaddr-=(vscroll&7)<<1;
\r
301 hscroll=est->PicoMem_vram[htaddr&0x7fff];
\r
304 // Draw tiles across screen:
\r
305 tilex=(-hscroll)>>3;
\r
306 dx=((hscroll-1)&7)+1;
\r
307 if(dx != 8) cellc++, vsidx--; // have hscroll, do more cells
\r
309 for (; cellc; dx+=8,tilex++,cellc--)
\r
311 int code=0,addr=0,zero=0,scroff;
\r
312 // unsigned short *pal=NULL;
\r
316 if ((pvid->reg[11]&4) && !(vsidx&1)) { // 2-cell mode
\r
317 vscroll=PicoMem.vsram[vsidx+plane];//&0x1ff;
\r
319 if (est->rendstatus & PDRAW_INTERLACE)
\r
322 nametab_row = nametab + (((trow+(vscroll>>3))&ymask)<<shift[width]); // pointer to nametable entries for this row
\r
327 code=est->PicoMem_vram[nametab_row+(tilex&xmask)];
\r
328 if (code==blank) continue;
\r
330 if (code>>15) { // high priority tile
\r
331 *hcache++ = code|(dx<<16)|(trow<<27); // cache it
\r
332 *hcache++ = 8-(vscroll&7); // push y-offset to tilecache
\r
336 // Get tile address/2:
\r
338 if (est->rendstatus & PDRAW_INTERLACE)
\r
339 addr=(code&0x3ff)<<5;
\r
342 addr=(code&0x7ff)<<4;
\r
344 // pal=PicoCramHigh+((code>>9)&0x30);
\r
345 pal=(unsigned char)((code>>9)&0x30);
\r
347 scroff=(8-(vscroll&7))*est->Draw2Width;
\r
348 switch((code>>11)&3) {
\r
349 case 0: zero=TileXnormYnorm(scrpos+scroff+dx,addr,pal,est); break;
\r
350 case 1: zero=TileXflipYnorm(scrpos+scroff+dx,addr,pal,est); break;
\r
351 case 2: zero=TileXnormYflip(scrpos+scroff+dx,addr,pal,est); break;
\r
352 case 3: zero=TileXflipYflip(scrpos+scroff+dx,addr,pal,est); break;
\r
354 if(zero) blank=code; // We know this tile is blank now
\r
357 scrpos += est->Draw2Width*8;
\r
360 *hcache = 0; // terminate cache
\r
364 static void DrawTilesFromCacheF(u32 *hc, struct PicoEState *est)
\r
367 int addr, zero = 0, vscroll;
\r
368 unsigned int prevy=0xFFFFFFFF;
\r
369 // unsigned short *pal;
\r
371 short blank=-1; // The tile we know is blank
\r
372 unsigned char *scrpos = est->Draw2FB, *pd = 0;
\r
373 int scrstart = est->Draw2Start;
\r
375 if ((~est->rendstatus & (PDRAW_BORDER_32|PDRAW_32_COLS)) == 0)
\r
378 while((code=*hc++)) {
\r
379 vscroll=(*hc++ - START_ROW*8)*est->Draw2Width;
\r
380 if((short)code == blank) continue;
\r
383 if(((unsigned)code>>27) != prevy) {
\r
384 prevy = (unsigned)code>>27;
\r
385 pd = scrpos + (prevy-scrstart)*est->Draw2Width*8;
\r
388 // Get tile address/2:
\r
390 if (est->rendstatus & PDRAW_INTERLACE)
\r
391 addr=(code&0x3ff)<<5;
\r
394 addr=(code&0x7ff)<<4;
\r
395 // pal=PicoCramHigh+((code>>9)&0x30);
\r
396 pal=(unsigned char)((code>>9)&0x30);
\r
398 switch((code>>11)&3) {
\r
399 case 0: zero=TileXnormYnorm(pd+vscroll+((code>>16)&0x1ff),addr,pal,est); break;
\r
400 case 1: zero=TileXflipYnorm(pd+vscroll+((code>>16)&0x1ff),addr,pal,est); break;
\r
401 case 2: zero=TileXnormYflip(pd+vscroll+((code>>16)&0x1ff),addr,pal,est); break;
\r
402 case 3: zero=TileXflipYflip(pd+vscroll+((code>>16)&0x1ff),addr,pal,est); break;
\r
405 if(zero) blank=(short)code;
\r
410 // sx and sy are coords of virtual screen with 8pix borders on top and on left
\r
411 static void DrawSpriteFull(u32 *sprite, struct PicoEState *est)
\r
413 int width=0,height=0;
\r
414 // unsigned short *pal=NULL;
\r
416 int tile,code,tdeltax,tdeltay;
\r
417 unsigned char *scrpos;
\r
418 int scrstart = est->Draw2Start;
\r
424 if (est->rendstatus & PDRAW_INTERLACE)
\r
425 sy = ((sy>>1)&0x1ff)-0x78;
\r
428 sy=(sy&0x1ff)-0x78; // Y
\r
429 width=(height>>2)&3; height&=3;
\r
430 width++; height++; // Width and height in tiles
\r
433 sx=((code>>16)&0x1ff)-0x78; // X
\r
435 tile=code&0x7ff; // Tile number
\r
436 tdeltax=height; // Delta to increase tile by going right
\r
437 tdeltay=1; // Delta to increase tile by going down
\r
438 if (code&0x1000) { tile+=tdeltax-1; tdeltay=-tdeltay; } // Flip Y
\r
439 if (code&0x0800) { tile+=tdeltax*(width-1); tdeltax=-tdeltax; } // Flip X
\r
441 //delta<<=4; // Delta of address
\r
442 // pal=PicoCramHigh+((code>>9)&0x30); // Get palette pointer
\r
443 pal=(unsigned char)((code>>9)&0x30);
\r
445 // goto first vertically visible tile
\r
447 while(sy <= 0) { sy+=8; tile+=tdeltay; height--; }
\r
449 scrpos = est->Draw2FB;
\r
450 if ((~est->rendstatus & (PDRAW_BORDER_32|PDRAW_32_COLS)) == 0)
\r
452 scrpos+=sy*est->Draw2Width;
\r
454 for (; height > 0; height--, sy+=8, tile+=tdeltay)
\r
456 int w = width, x=sx, t=tile, s;
\r
458 if(sy >= END_ROW*8+8) return; // offscreen
\r
460 for (; w; w--,x+=8,t+=tdeltax)
\r
463 if(x>=328) break; // Offscreen
\r
465 t&=0x7fff; // Clip tile address
\r
467 if (est->rendstatus & PDRAW_INTERLACE)
\r
472 switch((code>>11)&3) {
\r
473 case 0: TileXnormYnorm(scrpos+x,t<<s,pal,est); break;
\r
474 case 1: TileXflipYnorm(scrpos+x,t<<s,pal,est); break;
\r
475 case 2: TileXnormYflip(scrpos+x,t<<s,pal,est); break;
\r
476 case 3: TileXflipYflip(scrpos+x,t<<s,pal,est); break;
\r
480 scrpos+=8*est->Draw2Width;
\r
486 static void DrawAllSpritesFull(int prio, int maxwidth, struct PicoEState *est)
\r
488 struct PicoVideo *pvid=&est->Pico->video;
\r
489 int table=0,maskrange=0;
\r
491 u32 *sprites[80]; // Sprites
\r
492 int y_min=START_ROW*8, y_max=END_ROW*8; // for a simple sprite masking
\r
493 int max_sprites = !(est->rendstatus & PDRAW_32_COLS) ? 80 : 64;
\r
495 if (est->rendstatus & PDRAW_30_ROWS)
\r
496 y_min += 8, y_max += 8;
\r
498 table=pvid->reg[5]&0x7f;
\r
499 if (!(est->rendstatus & PDRAW_32_COLS)) table&=0x7e; // Lowest bit 0 in 40-cell mode
\r
500 table<<=8; // Get sprite table address/2
\r
502 for (i = u = 0; u < max_sprites && link < max_sprites; u++)
\r
505 int code, code2, sx, sy, height;
\r
507 sprite=(u32 *)(est->PicoMem_vram+((table+(link<<2))&0x7ffc)); // Find sprite
\r
512 // check if it is not hidden vertically
\r
514 if (est->rendstatus & PDRAW_INTERLACE)
\r
515 sy = ((code>>1)&0x1ff)-0x80;
\r
518 sy = (code&0x1ff)-0x80;
\r
519 height = (((code>>24)&3)+1)<<3;
\r
520 if(sy+height <= y_min || sy > y_max) goto nextsprite;
\r
524 sx = (code2>>16)&0x1ff;
\r
526 int to = sy+height; // sy ~ from
\r
528 // try to merge with previous range
\r
529 if((maskrange>>16)+1 >= sy && (maskrange>>16) <= to && (maskrange&0xffff) < sy) sy = (maskrange&0xffff);
\r
530 else if((maskrange&0xffff)-1 <= to && (maskrange&0xffff) >= sy && (maskrange>>16) > to) to = (maskrange>>16);
\r
532 // support only very simple masking (top and bottom of screen)
\r
533 if(sy <= y_min && to+1 > y_min) y_min = to+1;
\r
534 else if(to >= y_max && sy-1 < y_max) y_max = sy-1;
\r
535 else maskrange=sy|(to<<16);
\r
541 if(((code2>>15)&1) != prio) goto nextsprite; // wrong priority
\r
543 // check if sprite is not hidden horizontally
\r
544 sx -= 0x78; // Get X coordinate + 8
\r
545 if(sx <= -8*3 || sx >= maxwidth) goto nextsprite;
\r
547 // sprite is good, save it's index
\r
548 sprites[i++]=sprite;
\r
551 // Find next sprite
\r
552 link=(code>>16)&0x7f;
\r
553 if(!link) break; // End of sprites
\r
556 // Go through sprites backwards:
\r
557 for (i--; i >= 0; i--)
\r
559 DrawSpriteFull(sprites[i], est);
\r
563 #ifndef _ASM_DRAW_C
\r
564 static void BackFillFull(unsigned char *dst, int reg7, int lwidth)
\r
569 // Start with a background color:
\r
574 for (i = 0, dst += 8*lwidth; i < (END_ROW-START_ROW)*8; i++, dst += lwidth)
\r
575 memset32(dst+8, back, 320/4);
\r
579 static void DrawDisplayFull(void)
\r
581 struct PicoEState *est = &Pico.est;
\r
582 struct PicoVideo *pvid=&est->Pico->video;
\r
583 int win, edge=0, hvwin=0; // LSb->MSb: hwin&plane, vwin&plane, full
\r
584 int scrstart=START_ROW, scrend = END_ROW; // our render area
\r
585 int planestart, planeend; // plane A start/end when window shares display with plane A (in tile rows or columns)
\r
586 int winstart, winend; // same for window
\r
587 int maxw, maxcolc; // max width and col cells
\r
589 if(est->rendstatus & PDRAW_32_COLS) {
\r
590 maxw = 264; maxcolc = 32;
\r
592 maxw = 328; maxcolc = 40;
\r
594 if(est->rendstatus & PDRAW_30_ROWS) {
\r
595 // In 240 line mode, the top and bottom 8 lines are omitted
\r
596 // since this renderer always renders 224 lines
\r
597 scrstart ++, scrend ++;
\r
599 est->Draw2Start = scrstart;
\r
601 planestart = scrstart, planeend = scrend;
\r
602 winstart = scrstart, winend = scrend;
\r
604 // horizontal window?
\r
605 if ((win=pvid->reg[0x12]))
\r
607 hvwin=1; // hwindow shares display with plane A
\r
610 // fullscreen window
\r
612 } else if(win < 0x80) {
\r
613 // window on the top
\r
614 if(edge <= scrstart) hvwin=0; // window not visible in our drawing region
\r
615 else if(edge >= scrend) hvwin=4;
\r
616 else planestart = winend = edge;
\r
617 } else if(win > 0x80) {
\r
618 // window at the bottom
\r
619 if(edge >= scrend) hvwin=0;
\r
620 else planeend = winstart = edge;
\r
624 // check for vertical window, but only if win is not fullscreen
\r
627 win=pvid->reg[0x11];
\r
631 else if(edge < (maxcolc>>1)) {
\r
632 // window is on the right
\r
634 planeend|=edge<<17;
\r
635 winstart|=edge<<17;
\r
636 winend|=maxcolc<<16;
\r
639 if(edge >= (maxcolc>>1)) hvwin=4;
\r
641 // window is on the left
\r
644 planestart|=edge<<17;
\r
645 planeend|=maxcolc<<16;
\r
650 if (hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; }
\r
652 HighCache2A[0] = HighCache2B[0] = 0;
\r
653 if (!(pvid->debug_p & PVD_KILL_B))
\r
654 DrawLayerFull(1, HighCache2B, scrstart, (maxcolc<<16)|scrend, est);
\r
655 if (!(pvid->debug_p & PVD_KILL_A)) switch (hvwin)
\r
658 // fullscreen window
\r
659 DrawWindowFull(scrstart, (maxcolc<<16)|scrend, 0, est);
\r
663 // we have plane A and both v and h windows
\r
664 DrawLayerFull(0, HighCache2A, planestart, planeend, est);
\r
665 DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0, est); // h
\r
666 DrawWindowFull((winstart&~0xff)|scrstart, (winend&~0xff)|scrend, 0, est); // v
\r
671 // both window and plane A visible, window is vertical XOR horizontal
\r
672 DrawLayerFull(0, HighCache2A, planestart, planeend, est);
\r
673 DrawWindowFull(winstart, winend, 0, est);
\r
677 // fullscreen plane A
\r
678 DrawLayerFull(0, HighCache2A, scrstart, (maxcolc<<16)|scrend, est);
\r
681 if (!(pvid->debug_p & PVD_KILL_S_LO))
\r
682 DrawAllSpritesFull(0, maxw, est);
\r
684 if (HighCache2B[0]) DrawTilesFromCacheF(HighCache2B, est);
\r
685 if (HighCache2A[0]) DrawTilesFromCacheF(HighCache2A, est);
\r
686 if (!(pvid->debug_p & PVD_KILL_A)) switch (hvwin)
\r
689 // fullscreen window
\r
690 DrawWindowFull(scrstart, (maxcolc<<16)|scrend, 1, est);
\r
694 // we have plane A and both v and h windows
\r
695 DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1, est); // h
\r
696 DrawWindowFull((winstart&~0xff)|scrstart, (winend&~0xff)|scrend, 1, est); // v
\r
701 // both window and plane A visible, window is vertical XOR horizontal
\r
702 DrawWindowFull(winstart, winend, 1, est);
\r
705 if (!(pvid->debug_p & PVD_KILL_S_HI))
\r
706 DrawAllSpritesFull(1, maxw, est);
\r
710 PICO_INTERNAL void PicoFrameFull(void)
\r
715 if (PicoPrepareCram) PicoPrepareCram();
\r
718 BackFillFull(Pico.est.Draw2FB, Pico.video.reg[7], Pico.est.Draw2Width);
\r
719 if (Pico.video.reg[1] & 0x40)
\r
722 // clear top and bottom 8 lines in 240 mode, since draw2 only does 224
\r
723 if (Pico.est.rendstatus & PDRAW_30_ROWS) {
\r
724 unsigned char *pd = Pico.est.Draw2FB;
\r
727 for (i = 8; i > 0; i--, pd += Pico.est.Draw2Width)
\r
728 memset32((int *)pd, 0xe0e0e0e0, 328/4);
\r
729 pd += Pico.est.Draw2Width*(END_ROW-START_ROW)*8;
\r
730 for (i = 8; i > 0; i--, pd += Pico.est.Draw2Width)
\r
731 memset32((int *)pd, 0xe0e0e0e0, 328/4);
\r
737 void PicoDraw2SetOutBuf(void *dest, int incr)
\r
740 Pico.est.Draw2FB = dest;
\r
741 Pico.est.Draw2Width = incr;
\r
743 Pico.est.Draw2FB = PicoDraw2FB_;
\r
744 Pico.est.Draw2Width = LINE_WIDTH;
\r
748 void PicoDraw2Init(void)
\r
750 PicoDraw2SetOutBuf(NULL, 0);
\r