draw2.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /*
  2. * tile renderer
  3. * (C) notaz, 2006-2008
  4. *
  5. * This work is licensed under the terms of MAME license.
  6. * See COPYING file in the top-level directory.
  7. */
  8. #include "pico_int.h"
  9. #define START_ROW 0 // which row of tiles to start rendering at?
  10. #define END_ROW 28 // ..end
  11. #define TILE_ROWS END_ROW-START_ROW
  12. // note: this is not implemented in ARM asm
  13. #if defined(DRAW2_OVERRIDE_LINE_WIDTH)
  14. #define LINE_WIDTH DRAW2_OVERRIDE_LINE_WIDTH
  15. #else
  16. #define LINE_WIDTH 328
  17. #endif
  18. static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];
  19. unsigned char *PicoDraw2FB = PicoDraw2FB_;
  20. static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers
  21. static int HighCache2B[41*(TILE_ROWS+1)+1+1];
  22. unsigned short *PicoCramHigh=Pico.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
  23. void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use
  24. // stuff available in asm:
  25. #ifdef _ASM_DRAW_C
  26. void BackFillFull(int reg7);
  27. void DrawLayerFull(int plane, int *hcache, int planestart, int planeend);
  28. void DrawTilesFromCacheF(int *hc);
  29. void DrawWindowFull(int start, int end, int prio);
  30. void DrawSpriteFull(unsigned int *sprite);
  31. #else
  32. static int TileXnormYnorm(unsigned char *pd,int addr,unsigned char pal)
  33. {
  34. unsigned int pack=0; unsigned int t=0, blank = 1;
  35. int i;
  36. for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) {
  37. pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
  38. if(!pack) continue;
  39. t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);
  40. t=pack&0x00000f00; if (t) pd[1]=(unsigned char)((t>> 8)|pal);
  41. t=pack&0x000000f0; if (t) pd[2]=(unsigned char)((t>> 4)|pal);
  42. t=pack&0x0000000f; if (t) pd[3]=(unsigned char)((t )|pal);
  43. t=pack&0xf0000000; if (t) pd[4]=(unsigned char)((t>>28)|pal);
  44. t=pack&0x0f000000; if (t) pd[5]=(unsigned char)((t>>24)|pal);
  45. t=pack&0x00f00000; if (t) pd[6]=(unsigned char)((t>>20)|pal);
  46. t=pack&0x000f0000; if (t) pd[7]=(unsigned char)((t>>16)|pal);
  47. blank = 0;
  48. }
  49. return blank; // Tile blank?
  50. }
  51. static int TileXflipYnorm(unsigned char *pd,int addr,unsigned char pal)
  52. {
  53. unsigned int pack=0; unsigned int t=0, blank = 1;
  54. int i;
  55. for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) {
  56. pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
  57. if(!pack) continue;
  58. t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);
  59. t=pack&0x00f00000; if (t) pd[1]=(unsigned char)((t>>20)|pal);
  60. t=pack&0x0f000000; if (t) pd[2]=(unsigned char)((t>>24)|pal);
  61. t=pack&0xf0000000; if (t) pd[3]=(unsigned char)((t>>28)|pal);
  62. t=pack&0x0000000f; if (t) pd[4]=(unsigned char)((t )|pal);
  63. t=pack&0x000000f0; if (t) pd[5]=(unsigned char)((t>> 4)|pal);
  64. t=pack&0x00000f00; if (t) pd[6]=(unsigned char)((t>> 8)|pal);
  65. t=pack&0x0000f000; if (t) pd[7]=(unsigned char)((t>>12)|pal);
  66. blank = 0;
  67. }
  68. return blank; // Tile blank?
  69. }
  70. static int TileXnormYflip(unsigned char *pd,int addr,unsigned char pal)
  71. {
  72. unsigned int pack=0; unsigned int t=0, blank = 1;
  73. int i;
  74. addr+=14;
  75. for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) {
  76. pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
  77. if(!pack) continue;
  78. t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);
  79. t=pack&0x00000f00; if (t) pd[1]=(unsigned char)((t>> 8)|pal);
  80. t=pack&0x000000f0; if (t) pd[2]=(unsigned char)((t>> 4)|pal);
  81. t=pack&0x0000000f; if (t) pd[3]=(unsigned char)((t )|pal);
  82. t=pack&0xf0000000; if (t) pd[4]=(unsigned char)((t>>28)|pal);
  83. t=pack&0x0f000000; if (t) pd[5]=(unsigned char)((t>>24)|pal);
  84. t=pack&0x00f00000; if (t) pd[6]=(unsigned char)((t>>20)|pal);
  85. t=pack&0x000f0000; if (t) pd[7]=(unsigned char)((t>>16)|pal);
  86. blank = 0;
  87. }
  88. return blank; // Tile blank?
  89. }
  90. static int TileXflipYflip(unsigned char *pd,int addr,unsigned char pal)
  91. {
  92. unsigned int pack=0; unsigned int t=0, blank = 1;
  93. int i;
  94. addr+=14;
  95. for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) {
  96. pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
  97. if(!pack) continue;
  98. t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);
  99. t=pack&0x00f00000; if (t) pd[1]=(unsigned char)((t>>20)|pal);
  100. t=pack&0x0f000000; if (t) pd[2]=(unsigned char)((t>>24)|pal);
  101. t=pack&0xf0000000; if (t) pd[3]=(unsigned char)((t>>28)|pal);
  102. t=pack&0x0000000f; if (t) pd[4]=(unsigned char)((t )|pal);
  103. t=pack&0x000000f0; if (t) pd[5]=(unsigned char)((t>> 4)|pal);
  104. t=pack&0x00000f00; if (t) pd[6]=(unsigned char)((t>> 8)|pal);
  105. t=pack&0x0000f000; if (t) pd[7]=(unsigned char)((t>>12)|pal);
  106. blank = 0;
  107. }
  108. return blank; // Tile blank?
  109. }
  110. // start: (tile_start<<16)|row_start, end: [same]
  111. static void DrawWindowFull(int start, int end, int prio)
  112. {
  113. struct PicoVideo *pvid=&Pico.video;
  114. int nametab, nametab_step, trow, tilex, blank=-1, code;
  115. unsigned char *scrpos = PicoDraw2FB;
  116. int tile_start, tile_end; // in cells
  117. // parse ranges
  118. tile_start = start>>16;
  119. tile_end = end>>16;
  120. start = start<<16>>16;
  121. end = end<<16>>16;
  122. // Find name table line:
  123. if (pvid->reg[12]&1)
  124. {
  125. nametab=(pvid->reg[3]&0x3c)<<9; // 40-cell mode
  126. nametab_step = 1<<6;
  127. }
  128. else
  129. {
  130. nametab=(pvid->reg[3]&0x3e)<<9; // 32-cell mode
  131. nametab_step = 1<<5;
  132. }
  133. nametab += nametab_step*start;
  134. // check priority
  135. code=Pico.vram[nametab+tile_start];
  136. if ((code>>15) != prio) return; // hack: just assume that whole window uses same priority
  137. scrpos+=8*LINE_WIDTH+8;
  138. scrpos+=8*LINE_WIDTH*(start-START_ROW);
  139. // do a window until we reach planestart row
  140. for(trow = start; trow < end; trow++, nametab+=nametab_step) { // current tile row
  141. for (tilex=tile_start; tilex<tile_end; tilex++)
  142. {
  143. int code,addr,zero=0;
  144. // unsigned short *pal=NULL;
  145. unsigned char pal;
  146. code=Pico.vram[nametab+tilex];
  147. if (code==blank) continue;
  148. // Get tile address/2:
  149. addr=(code&0x7ff)<<4;
  150. // pal=PicoCramHigh+((code>>9)&0x30);
  151. pal=(unsigned char)((code>>9)&0x30);
  152. switch((code>>11)&3) {
  153. case 0: zero=TileXnormYnorm(scrpos+(tilex<<3),addr,pal); break;
  154. case 1: zero=TileXflipYnorm(scrpos+(tilex<<3),addr,pal); break;
  155. case 2: zero=TileXnormYflip(scrpos+(tilex<<3),addr,pal); break;
  156. case 3: zero=TileXflipYflip(scrpos+(tilex<<3),addr,pal); break;
  157. }
  158. if(zero) blank=code; // We know this tile is blank now
  159. }
  160. scrpos += LINE_WIDTH*8;
  161. }
  162. }
  163. static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend)
  164. {
  165. struct PicoVideo *pvid=&Pico.video;
  166. static char shift[4]={5,6,6,7}; // 32,64 or 128 sized tilemaps
  167. int width, height, ymask, htab;
  168. int nametab, hscroll=0, vscroll, cells;
  169. unsigned char *scrpos;
  170. int blank=-1, xmask, nametab_row, trow;
  171. // parse ranges
  172. cells = (planeend>>16)-(planestart>>16);
  173. planestart = planestart<<16>>16;
  174. planeend = planeend<<16>>16;
  175. // Work out the Tiles to draw
  176. htab=pvid->reg[13]<<9; // Horizontal scroll table address
  177. // if ( pvid->reg[11]&2) htab+=Scanline<<1; // Offset by line
  178. // if ((pvid->reg[11]&1)==0) htab&=~0xf; // Offset by tile
  179. htab+=plane; // A or B
  180. if(!(pvid->reg[11]&3)) { // full screen scroll
  181. // Get horizontal scroll value
  182. hscroll=Pico.vram[htab&0x7fff];
  183. htab = 0; // this marks that we don't have to update scroll value
  184. }
  185. // Work out the name table size: 32 64 or 128 tiles (0-3)
  186. width=pvid->reg[16];
  187. height=(width>>4)&3; width&=3;
  188. xmask=(1<<shift[width ])-1; // X Mask in tiles
  189. ymask=(height<<5)|0x1f; // Y Mask in tiles
  190. if(width == 1) ymask&=0x3f;
  191. else if(width>1) ymask =0x1f;
  192. // Find name table:
  193. if (plane==0) nametab=(pvid->reg[2]&0x38)<< 9; // A
  194. else nametab=(pvid->reg[4]&0x07)<<12; // B
  195. scrpos = PicoDraw2FB;
  196. scrpos+=8*LINE_WIDTH*(planestart-START_ROW);
  197. // Get vertical scroll value:
  198. vscroll=Pico.vsram[plane]&0x1ff;
  199. scrpos+=(8-(vscroll&7))*LINE_WIDTH;
  200. if(vscroll&7) planeend++; // we have vertically clipped tiles due to vscroll, so we need 1 more row
  201. *hcache++ = 8-(vscroll&7); // push y-offset to tilecache
  202. for(trow = planestart; trow < planeend; trow++) { // current tile row
  203. int cellc=cells,tilex,dx;
  204. // Find the tile row in the name table
  205. //ts.line=(vscroll+Scanline)&ymask;
  206. //ts.nametab+=(ts.line>>3)<<shift[width];
  207. nametab_row = nametab + (((trow+(vscroll>>3))&ymask)<<shift[width]); // pointer to nametable entries for this row
  208. // update hscroll if needed
  209. if(htab) {
  210. int htaddr=htab+(trow<<4);
  211. if(trow) htaddr-=(vscroll&7)<<1;
  212. hscroll=Pico.vram[htaddr&0x7fff];
  213. }
  214. // Draw tiles across screen:
  215. tilex=(-hscroll)>>3;
  216. dx=((hscroll-1)&7)+1;
  217. if(dx != 8) cellc++; // have hscroll, do more cells
  218. for (; cellc; dx+=8,tilex++,cellc--)
  219. {
  220. int code=0,addr=0,zero=0;
  221. // unsigned short *pal=NULL;
  222. unsigned char pal;
  223. code=Pico.vram[nametab_row+(tilex&xmask)];
  224. if (code==blank) continue;
  225. if (code>>15) { // high priority tile
  226. *hcache++ = code|(dx<<16)|(trow<<27); // cache it
  227. continue;
  228. }
  229. // Get tile address/2:
  230. addr=(code&0x7ff)<<4;
  231. // pal=PicoCramHigh+((code>>9)&0x30);
  232. pal=(unsigned char)((code>>9)&0x30);
  233. switch((code>>11)&3) {
  234. case 0: zero=TileXnormYnorm(scrpos+dx,addr,pal); break;
  235. case 1: zero=TileXflipYnorm(scrpos+dx,addr,pal); break;
  236. case 2: zero=TileXnormYflip(scrpos+dx,addr,pal); break;
  237. case 3: zero=TileXflipYflip(scrpos+dx,addr,pal); break;
  238. }
  239. if(zero) blank=code; // We know this tile is blank now
  240. }
  241. scrpos += LINE_WIDTH*8;
  242. }
  243. *hcache = 0; // terminate cache
  244. }
  245. static void DrawTilesFromCacheF(int *hc)
  246. {
  247. int code, addr, zero = 0;
  248. unsigned int prevy=0xFFFFFFFF;
  249. // unsigned short *pal;
  250. unsigned char pal;
  251. short blank=-1; // The tile we know is blank
  252. unsigned char *scrpos = PicoDraw2FB, *pd = 0;
  253. // *hcache++ = code|(dx<<16)|(trow<<27); // cache it
  254. scrpos+=(*hc++)*LINE_WIDTH - START_ROW*LINE_WIDTH*8;
  255. while((code=*hc++)) {
  256. if((short)code == blank) continue;
  257. // y pos
  258. if(((unsigned)code>>27) != prevy) {
  259. prevy = (unsigned)code>>27;
  260. pd = scrpos + prevy*LINE_WIDTH*8;
  261. }
  262. // Get tile address/2:
  263. addr=(code&0x7ff)<<4;
  264. // pal=PicoCramHigh+((code>>9)&0x30);
  265. pal=(unsigned char)((code>>9)&0x30);
  266. switch((code>>11)&3) {
  267. case 0: zero=TileXnormYnorm(pd+((code>>16)&0x1ff),addr,pal); break;
  268. case 1: zero=TileXflipYnorm(pd+((code>>16)&0x1ff),addr,pal); break;
  269. case 2: zero=TileXnormYflip(pd+((code>>16)&0x1ff),addr,pal); break;
  270. case 3: zero=TileXflipYflip(pd+((code>>16)&0x1ff),addr,pal); break;
  271. }
  272. if(zero) blank=(short)code;
  273. }
  274. }
  275. // sx and sy are coords of virtual screen with 8pix borders on top and on left
  276. static void DrawSpriteFull(unsigned int *sprite)
  277. {
  278. int width=0,height=0;
  279. // unsigned short *pal=NULL;
  280. unsigned char pal;
  281. int tile,code,tdeltax,tdeltay;
  282. unsigned char *scrpos;
  283. int sx, sy;
  284. sy=sprite[0];
  285. height=sy>>24;
  286. sy=(sy&0x1ff)-0x78; // Y
  287. width=(height>>2)&3; height&=3;
  288. width++; height++; // Width and height in tiles
  289. code=sprite[1];
  290. sx=((code>>16)&0x1ff)-0x78; // X
  291. tile=code&0x7ff; // Tile number
  292. tdeltax=height; // Delta to increase tile by going right
  293. tdeltay=1; // Delta to increase tile by going down
  294. if (code&0x0800) { tdeltax=-tdeltax; tile+=height*(width-1); } // Flip X
  295. if (code&0x1000) { tdeltay=-tdeltay; tile+=height-1; } // Flip Y
  296. //delta<<=4; // Delta of address
  297. // pal=PicoCramHigh+((code>>9)&0x30); // Get palette pointer
  298. pal=(unsigned char)((code>>9)&0x30);
  299. // goto first vertically visible tile
  300. while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; }
  301. scrpos = PicoDraw2FB;
  302. scrpos+=(sy-START_ROW*8)*LINE_WIDTH;
  303. for (; height > 0; height--, sy+=8, tile+=tdeltay)
  304. {
  305. int w = width, x=sx, t=tile;
  306. if(sy >= END_ROW*8+8) return; // offscreen
  307. for (; w; w--,x+=8,t+=tdeltax)
  308. {
  309. if(x<=0) continue;
  310. if(x>=328) break; // Offscreen
  311. t&=0x7fff; // Clip tile address
  312. switch((code>>11)&3) {
  313. case 0: TileXnormYnorm(scrpos+x,t<<4,pal); break;
  314. case 1: TileXflipYnorm(scrpos+x,t<<4,pal); break;
  315. case 2: TileXnormYflip(scrpos+x,t<<4,pal); break;
  316. case 3: TileXflipYflip(scrpos+x,t<<4,pal); break;
  317. }
  318. }
  319. scrpos+=8*LINE_WIDTH;
  320. }
  321. }
  322. #endif
  323. static void DrawAllSpritesFull(int prio, int maxwidth)
  324. {
  325. struct PicoVideo *pvid=&Pico.video;
  326. int table=0,maskrange=0;
  327. int i,u,link=0;
  328. unsigned int *sprites[80]; // Sprites
  329. int y_min=START_ROW*8, y_max=END_ROW*8; // for a simple sprite masking
  330. table=pvid->reg[5]&0x7f;
  331. if (pvid->reg[12]&1) table&=0x7e; // Lowest bit 0 in 40-cell mode
  332. table<<=8; // Get sprite table address/2
  333. for (i=u=0; u < 80; u++)
  334. {
  335. unsigned int *sprite=NULL;
  336. int code, code2, sx, sy, height;
  337. sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
  338. // get sprite info
  339. code = sprite[0];
  340. // check if it is not hidden vertically
  341. sy = (code&0x1ff)-0x80;
  342. height = (((code>>24)&3)+1)<<3;
  343. if(sy+height <= y_min || sy > y_max) goto nextsprite;
  344. // masking sprite?
  345. code2=sprite[1];
  346. sx = (code2>>16)&0x1ff;
  347. if(!sx) {
  348. int to = sy+height; // sy ~ from
  349. if(maskrange) {
  350. // try to merge with previous range
  351. if((maskrange>>16)+1 >= sy && (maskrange>>16) <= to && (maskrange&0xffff) < sy) sy = (maskrange&0xffff);
  352. else if((maskrange&0xffff)-1 <= to && (maskrange&0xffff) >= sy && (maskrange>>16) > to) to = (maskrange>>16);
  353. }
  354. // support only very simple masking (top and bottom of screen)
  355. if(sy <= y_min && to+1 > y_min) y_min = to+1;
  356. else if(to >= y_max && sy-1 < y_max) y_max = sy-1;
  357. else maskrange=sy|(to<<16);
  358. goto nextsprite;
  359. }
  360. // priority
  361. if(((code2>>15)&1) != prio) goto nextsprite; // wrong priority
  362. // check if sprite is not hidden horizontally
  363. sx -= 0x78; // Get X coordinate + 8
  364. if(sx <= -8*3 || sx >= maxwidth) goto nextsprite;
  365. // sprite is good, save it's index
  366. sprites[i++]=sprite;
  367. nextsprite:
  368. // Find next sprite
  369. link=(code>>16)&0x7f;
  370. if(!link) break; // End of sprites
  371. }
  372. // Go through sprites backwards:
  373. for (i-- ;i>=0; i--)
  374. {
  375. DrawSpriteFull(sprites[i]);
  376. }
  377. }
  378. #ifndef _ASM_DRAW_C
  379. static void BackFillFull(int reg7)
  380. {
  381. unsigned int back;
  382. // Start with a background color:
  383. // back=PicoCramHigh[reg7&0x3f];
  384. back=reg7&0x3f;
  385. back|=back<<8;
  386. back|=back<<16;
  387. memset32((int *)PicoDraw2FB, back, LINE_WIDTH*(8+(END_ROW-START_ROW)*8)/4);
  388. }
  389. #endif
  390. static void DrawDisplayFull(void)
  391. {
  392. struct PicoVideo *pvid=&Pico.video;
  393. int win, edge=0, hvwin=0; // LSb->MSb: hwin&plane, vwin&plane, full
  394. int planestart=START_ROW, planeend=END_ROW; // plane A start/end when window shares display with plane A (in tile rows or columns)
  395. int winstart=START_ROW, winend=END_ROW; // same for window
  396. int maxw, maxcolc; // max width and col cells
  397. if(pvid->reg[12]&1) {
  398. maxw = 328; maxcolc = 40;
  399. } else {
  400. maxw = 264; maxcolc = 32;
  401. }
  402. // horizontal window?
  403. if ((win=pvid->reg[0x12]))
  404. {
  405. hvwin=1; // hwindow shares display with plane A
  406. edge=win&0x1f;
  407. if(win == 0x80) {
  408. // fullscreen window
  409. hvwin=4;
  410. } else if(win < 0x80) {
  411. // window on the top
  412. if(edge <= START_ROW) hvwin=0; // window not visible in our drawing region
  413. else if(edge >= END_ROW) hvwin=4;
  414. else planestart = winend = edge;
  415. } else if(win > 0x80) {
  416. // window at the bottom
  417. if(edge >= END_ROW) hvwin=0;
  418. else planeend = winstart = edge;
  419. }
  420. }
  421. // check for vertical window, but only if win is not fullscreen
  422. if (hvwin != 4)
  423. {
  424. win=pvid->reg[0x11];
  425. edge=win&0x1f;
  426. if (win&0x80) {
  427. if(!edge) hvwin=4;
  428. else if(edge < (maxcolc>>1)) {
  429. // window is on the right
  430. hvwin|=2;
  431. planeend|=edge<<17;
  432. winstart|=edge<<17;
  433. winend|=maxcolc<<16;
  434. }
  435. } else {
  436. if(edge >= (maxcolc>>1)) hvwin=4;
  437. else if(edge) {
  438. // window is on the left
  439. hvwin|=2;
  440. winend|=edge<<17;
  441. planestart|=edge<<17;
  442. planeend|=maxcolc<<16;
  443. }
  444. }
  445. }
  446. if (hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; }
  447. HighCache2A[1] = HighCache2B[1] = 0;
  448. if (PicoDrawMask & PDRAW_LAYERB_ON)
  449. DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW);
  450. if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin)
  451. {
  452. case 4:
  453. // fullscreen window
  454. DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0);
  455. break;
  456. case 3:
  457. // we have plane A and both v and h windows
  458. DrawLayerFull(0, HighCache2A, planestart, planeend);
  459. DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0); // h
  460. DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0); // v
  461. break;
  462. case 2:
  463. case 1:
  464. // both window and plane A visible, window is vertical XOR horizontal
  465. DrawLayerFull(0, HighCache2A, planestart, planeend);
  466. DrawWindowFull(winstart, winend, 0);
  467. break;
  468. default:
  469. // fullscreen plane A
  470. DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW);
  471. break;
  472. }
  473. if (PicoDrawMask & PDRAW_SPRITES_LOW_ON)
  474. DrawAllSpritesFull(0, maxw);
  475. if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B);
  476. if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A);
  477. if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin)
  478. {
  479. case 4:
  480. // fullscreen window
  481. DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1);
  482. break;
  483. case 3:
  484. // we have plane A and both v and h windows
  485. DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1); // h
  486. DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 1); // v
  487. break;
  488. case 2:
  489. case 1:
  490. // both window and plane A visible, window is vertical XOR horizontal
  491. DrawWindowFull(winstart, winend, 1);
  492. break;
  493. }
  494. if (PicoDrawMask & PDRAW_SPRITES_HI_ON)
  495. DrawAllSpritesFull(1, maxw);
  496. }
  497. PICO_INTERNAL void PicoFrameFull()
  498. {
  499. pprof_start(draw);
  500. // prepare cram?
  501. if (PicoPrepareCram) PicoPrepareCram();
  502. // Draw screen:
  503. BackFillFull(Pico.video.reg[7]);
  504. if (Pico.video.reg[1] & 0x40)
  505. DrawDisplayFull();
  506. pprof_end(draw);
  507. }