draw2.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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. static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers
  20. static int HighCache2B[41*(TILE_ROWS+1)+1+1];
  21. unsigned short *PicoCramHigh=PicoMem.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
  22. void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use
  23. // stuff available in asm:
  24. #ifdef _ASM_DRAW_C
  25. void BackFillFull(void *dst, int reg7);
  26. void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
  27. struct PicoEState *est);
  28. void DrawTilesFromCacheF(int *hc, struct PicoEState *est);
  29. void DrawWindowFull(int start, int end, int prio, struct PicoEState *est);
  30. void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est);
  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 *)(PicoMem.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 *)(PicoMem.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 *)(PicoMem.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 *)(PicoMem.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, struct PicoEState *est)
  112. {
  113. struct PicoVideo *pvid=&Pico.video;
  114. int nametab, nametab_step, trow, tilex, blank=-1, code;
  115. unsigned char *scrpos = est->Draw2FB;
  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=PicoMem.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=PicoMem.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. struct PicoEState *est)
  165. {
  166. struct PicoVideo *pvid=&Pico.video;
  167. static char shift[4]={5,6,6,7}; // 32,64 or 128 sized tilemaps
  168. int width, height, ymask, htab;
  169. int nametab, hscroll=0, vscroll, cells;
  170. unsigned char *scrpos;
  171. int blank=-1, xmask, nametab_row, trow;
  172. // parse ranges
  173. cells = (planeend>>16)-(planestart>>16);
  174. planestart = planestart<<16>>16;
  175. planeend = planeend<<16>>16;
  176. // Work out the Tiles to draw
  177. htab=pvid->reg[13]<<9; // Horizontal scroll table address
  178. // if ( pvid->reg[11]&2) htab+=Scanline<<1; // Offset by line
  179. // if ((pvid->reg[11]&1)==0) htab&=~0xf; // Offset by tile
  180. htab+=plane; // A or B
  181. if(!(pvid->reg[11]&3)) { // full screen scroll
  182. // Get horizontal scroll value
  183. hscroll=PicoMem.vram[htab&0x7fff];
  184. htab = 0; // this marks that we don't have to update scroll value
  185. }
  186. // Work out the name table size: 32 64 or 128 tiles (0-3)
  187. width=pvid->reg[16];
  188. height=(width>>4)&3; width&=3;
  189. xmask=(1<<shift[width ])-1; // X Mask in tiles
  190. ymask=(height<<5)|0x1f; // Y Mask in tiles
  191. if(width == 1) ymask&=0x3f;
  192. else if(width>1) ymask =0x1f;
  193. // Find name table:
  194. if (plane==0) nametab=(pvid->reg[2]&0x38)<< 9; // A
  195. else nametab=(pvid->reg[4]&0x07)<<12; // B
  196. scrpos = est->Draw2FB;
  197. scrpos+=8*LINE_WIDTH*(planestart-START_ROW);
  198. // Get vertical scroll value:
  199. vscroll=PicoMem.vsram[plane]&0x1ff;
  200. scrpos+=(8-(vscroll&7))*LINE_WIDTH;
  201. if(vscroll&7) planeend++; // we have vertically clipped tiles due to vscroll, so we need 1 more row
  202. *hcache++ = 8-(vscroll&7); // push y-offset to tilecache
  203. for(trow = planestart; trow < planeend; trow++) { // current tile row
  204. int cellc=cells,tilex,dx;
  205. // Find the tile row in the name table
  206. //ts.line=(vscroll+Scanline)&ymask;
  207. //ts.nametab+=(ts.line>>3)<<shift[width];
  208. nametab_row = nametab + (((trow+(vscroll>>3))&ymask)<<shift[width]); // pointer to nametable entries for this row
  209. // update hscroll if needed
  210. if(htab) {
  211. int htaddr=htab+(trow<<4);
  212. if(trow) htaddr-=(vscroll&7)<<1;
  213. hscroll=PicoMem.vram[htaddr&0x7fff];
  214. }
  215. // Draw tiles across screen:
  216. tilex=(-hscroll)>>3;
  217. dx=((hscroll-1)&7)+1;
  218. if(dx != 8) cellc++; // have hscroll, do more cells
  219. for (; cellc; dx+=8,tilex++,cellc--)
  220. {
  221. int code=0,addr=0,zero=0;
  222. // unsigned short *pal=NULL;
  223. unsigned char pal;
  224. code=PicoMem.vram[nametab_row+(tilex&xmask)];
  225. if (code==blank) continue;
  226. if (code>>15) { // high priority tile
  227. *hcache++ = code|(dx<<16)|(trow<<27); // cache it
  228. continue;
  229. }
  230. // Get tile address/2:
  231. addr=(code&0x7ff)<<4;
  232. // pal=PicoCramHigh+((code>>9)&0x30);
  233. pal=(unsigned char)((code>>9)&0x30);
  234. switch((code>>11)&3) {
  235. case 0: zero=TileXnormYnorm(scrpos+dx,addr,pal); break;
  236. case 1: zero=TileXflipYnorm(scrpos+dx,addr,pal); break;
  237. case 2: zero=TileXnormYflip(scrpos+dx,addr,pal); break;
  238. case 3: zero=TileXflipYflip(scrpos+dx,addr,pal); break;
  239. }
  240. if(zero) blank=code; // We know this tile is blank now
  241. }
  242. scrpos += LINE_WIDTH*8;
  243. }
  244. *hcache = 0; // terminate cache
  245. }
  246. static void DrawTilesFromCacheF(int *hc, struct PicoEState *est)
  247. {
  248. int code, addr, zero = 0;
  249. unsigned int prevy=0xFFFFFFFF;
  250. // unsigned short *pal;
  251. unsigned char pal;
  252. short blank=-1; // The tile we know is blank
  253. unsigned char *scrpos = est->Draw2FB, *pd = 0;
  254. // *hcache++ = code|(dx<<16)|(trow<<27); // cache it
  255. scrpos+=(*hc++)*LINE_WIDTH - START_ROW*LINE_WIDTH*8;
  256. while((code=*hc++)) {
  257. if((short)code == blank) continue;
  258. // y pos
  259. if(((unsigned)code>>27) != prevy) {
  260. prevy = (unsigned)code>>27;
  261. pd = scrpos + prevy*LINE_WIDTH*8;
  262. }
  263. // Get tile address/2:
  264. addr=(code&0x7ff)<<4;
  265. // pal=PicoCramHigh+((code>>9)&0x30);
  266. pal=(unsigned char)((code>>9)&0x30);
  267. switch((code>>11)&3) {
  268. case 0: zero=TileXnormYnorm(pd+((code>>16)&0x1ff),addr,pal); break;
  269. case 1: zero=TileXflipYnorm(pd+((code>>16)&0x1ff),addr,pal); break;
  270. case 2: zero=TileXnormYflip(pd+((code>>16)&0x1ff),addr,pal); break;
  271. case 3: zero=TileXflipYflip(pd+((code>>16)&0x1ff),addr,pal); break;
  272. }
  273. if(zero) blank=(short)code;
  274. }
  275. }
  276. // sx and sy are coords of virtual screen with 8pix borders on top and on left
  277. static void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est)
  278. {
  279. int width=0,height=0;
  280. // unsigned short *pal=NULL;
  281. unsigned char pal;
  282. int tile,code,tdeltax,tdeltay;
  283. unsigned char *scrpos;
  284. int sx, sy;
  285. sy=sprite[0];
  286. height=sy>>24;
  287. sy=(sy&0x1ff)-0x78; // Y
  288. width=(height>>2)&3; height&=3;
  289. width++; height++; // Width and height in tiles
  290. code=sprite[1];
  291. sx=((code>>16)&0x1ff)-0x78; // X
  292. tile=code&0x7ff; // Tile number
  293. tdeltax=height; // Delta to increase tile by going right
  294. tdeltay=1; // Delta to increase tile by going down
  295. if (code&0x0800) { tdeltax=-tdeltax; tile+=height*(width-1); } // Flip X
  296. if (code&0x1000) { tdeltay=-tdeltay; tile+=height-1; } // Flip Y
  297. //delta<<=4; // Delta of address
  298. // pal=PicoCramHigh+((code>>9)&0x30); // Get palette pointer
  299. pal=(unsigned char)((code>>9)&0x30);
  300. // goto first vertically visible tile
  301. while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; }
  302. scrpos = est->Draw2FB;
  303. scrpos+=(sy-START_ROW*8)*LINE_WIDTH;
  304. for (; height > 0; height--, sy+=8, tile+=tdeltay)
  305. {
  306. int w = width, x=sx, t=tile;
  307. if(sy >= END_ROW*8+8) return; // offscreen
  308. for (; w; w--,x+=8,t+=tdeltax)
  309. {
  310. if(x<=0) continue;
  311. if(x>=328) break; // Offscreen
  312. t&=0x7fff; // Clip tile address
  313. switch((code>>11)&3) {
  314. case 0: TileXnormYnorm(scrpos+x,t<<4,pal); break;
  315. case 1: TileXflipYnorm(scrpos+x,t<<4,pal); break;
  316. case 2: TileXnormYflip(scrpos+x,t<<4,pal); break;
  317. case 3: TileXflipYflip(scrpos+x,t<<4,pal); break;
  318. }
  319. }
  320. scrpos+=8*LINE_WIDTH;
  321. }
  322. }
  323. #endif
  324. static void DrawAllSpritesFull(int prio, int maxwidth)
  325. {
  326. struct PicoVideo *pvid=&Pico.video;
  327. int table=0,maskrange=0;
  328. int i,u,link=0;
  329. unsigned int *sprites[80]; // Sprites
  330. int y_min=START_ROW*8, y_max=END_ROW*8; // for a simple sprite masking
  331. table=pvid->reg[5]&0x7f;
  332. if (pvid->reg[12]&1) table&=0x7e; // Lowest bit 0 in 40-cell mode
  333. table<<=8; // Get sprite table address/2
  334. for (i=u=0; u < 80; u++)
  335. {
  336. unsigned int *sprite=NULL;
  337. int code, code2, sx, sy, height;
  338. sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
  339. // get sprite info
  340. code = sprite[0];
  341. // check if it is not hidden vertically
  342. sy = (code&0x1ff)-0x80;
  343. height = (((code>>24)&3)+1)<<3;
  344. if(sy+height <= y_min || sy > y_max) goto nextsprite;
  345. // masking sprite?
  346. code2=sprite[1];
  347. sx = (code2>>16)&0x1ff;
  348. if(!sx) {
  349. int to = sy+height; // sy ~ from
  350. if(maskrange) {
  351. // try to merge with previous range
  352. if((maskrange>>16)+1 >= sy && (maskrange>>16) <= to && (maskrange&0xffff) < sy) sy = (maskrange&0xffff);
  353. else if((maskrange&0xffff)-1 <= to && (maskrange&0xffff) >= sy && (maskrange>>16) > to) to = (maskrange>>16);
  354. }
  355. // support only very simple masking (top and bottom of screen)
  356. if(sy <= y_min && to+1 > y_min) y_min = to+1;
  357. else if(to >= y_max && sy-1 < y_max) y_max = sy-1;
  358. else maskrange=sy|(to<<16);
  359. goto nextsprite;
  360. }
  361. // priority
  362. if(((code2>>15)&1) != prio) goto nextsprite; // wrong priority
  363. // check if sprite is not hidden horizontally
  364. sx -= 0x78; // Get X coordinate + 8
  365. if(sx <= -8*3 || sx >= maxwidth) goto nextsprite;
  366. // sprite is good, save it's index
  367. sprites[i++]=sprite;
  368. nextsprite:
  369. // Find next sprite
  370. link=(code>>16)&0x7f;
  371. if(!link) break; // End of sprites
  372. }
  373. // Go through sprites backwards:
  374. for (i--; i >= 0; i--)
  375. {
  376. DrawSpriteFull(sprites[i], &Pico.est);
  377. }
  378. }
  379. #ifndef _ASM_DRAW_C
  380. static void BackFillFull(void *dst, int reg7)
  381. {
  382. unsigned int back;
  383. // Start with a background color:
  384. back=reg7&0x3f;
  385. back|=back<<8;
  386. back|=back<<16;
  387. memset32(dst, back, LINE_WIDTH*(8+(END_ROW-START_ROW)*8)/4);
  388. }
  389. #endif
  390. static void DrawDisplayFull(void)
  391. {
  392. struct PicoEState *est = &Pico.est;
  393. struct PicoVideo *pvid=&Pico.video;
  394. int win, edge=0, hvwin=0; // LSb->MSb: hwin&plane, vwin&plane, full
  395. int planestart=START_ROW, planeend=END_ROW; // plane A start/end when window shares display with plane A (in tile rows or columns)
  396. int winstart=START_ROW, winend=END_ROW; // same for window
  397. int maxw, maxcolc; // max width and col cells
  398. if(pvid->reg[12]&1) {
  399. maxw = 328; maxcolc = 40;
  400. } else {
  401. maxw = 264; maxcolc = 32;
  402. }
  403. // horizontal window?
  404. if ((win=pvid->reg[0x12]))
  405. {
  406. hvwin=1; // hwindow shares display with plane A
  407. edge=win&0x1f;
  408. if(win == 0x80) {
  409. // fullscreen window
  410. hvwin=4;
  411. } else if(win < 0x80) {
  412. // window on the top
  413. if(edge <= START_ROW) hvwin=0; // window not visible in our drawing region
  414. else if(edge >= END_ROW) hvwin=4;
  415. else planestart = winend = edge;
  416. } else if(win > 0x80) {
  417. // window at the bottom
  418. if(edge >= END_ROW) hvwin=0;
  419. else planeend = winstart = edge;
  420. }
  421. }
  422. // check for vertical window, but only if win is not fullscreen
  423. if (hvwin != 4)
  424. {
  425. win=pvid->reg[0x11];
  426. edge=win&0x1f;
  427. if (win&0x80) {
  428. if(!edge) hvwin=4;
  429. else if(edge < (maxcolc>>1)) {
  430. // window is on the right
  431. hvwin|=2;
  432. planeend|=edge<<17;
  433. winstart|=edge<<17;
  434. winend|=maxcolc<<16;
  435. }
  436. } else {
  437. if(edge >= (maxcolc>>1)) hvwin=4;
  438. else if(edge) {
  439. // window is on the left
  440. hvwin|=2;
  441. winend|=edge<<17;
  442. planestart|=edge<<17;
  443. planeend|=maxcolc<<16;
  444. }
  445. }
  446. }
  447. if (hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; }
  448. HighCache2A[1] = HighCache2B[1] = 0;
  449. if (!(pvid->debug_p & PVD_KILL_B))
  450. DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW, est);
  451. if (!(pvid->debug_p & PVD_KILL_A)) switch (hvwin)
  452. {
  453. case 4:
  454. // fullscreen window
  455. DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0, est);
  456. break;
  457. case 3:
  458. // we have plane A and both v and h windows
  459. DrawLayerFull(0, HighCache2A, planestart, planeend, est);
  460. DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 0, est); // h
  461. DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 0, est); // v
  462. break;
  463. case 2:
  464. case 1:
  465. // both window and plane A visible, window is vertical XOR horizontal
  466. DrawLayerFull(0, HighCache2A, planestart, planeend, est);
  467. DrawWindowFull(winstart, winend, 0, est);
  468. break;
  469. default:
  470. // fullscreen plane A
  471. DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW, est);
  472. break;
  473. }
  474. if (!(pvid->debug_p & PVD_KILL_S_LO))
  475. DrawAllSpritesFull(0, maxw);
  476. if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B, est);
  477. if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A, est);
  478. if (!(pvid->debug_p & PVD_KILL_A)) switch (hvwin)
  479. {
  480. case 4:
  481. // fullscreen window
  482. DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1, est);
  483. break;
  484. case 3:
  485. // we have plane A and both v and h windows
  486. DrawWindowFull( winstart&~0xff0000, (winend&~0xff0000)|(maxcolc<<16), 1, est); // h
  487. DrawWindowFull((winstart&~0xff)|START_ROW, (winend&~0xff)|END_ROW, 1, est); // v
  488. break;
  489. case 2:
  490. case 1:
  491. // both window and plane A visible, window is vertical XOR horizontal
  492. DrawWindowFull(winstart, winend, 1, est);
  493. break;
  494. }
  495. if (!(pvid->debug_p & PVD_KILL_S_HI))
  496. DrawAllSpritesFull(1, maxw);
  497. }
  498. PICO_INTERNAL void PicoFrameFull()
  499. {
  500. pprof_start(draw);
  501. // prepare cram?
  502. if (PicoPrepareCram) PicoPrepareCram();
  503. // Draw screen:
  504. BackFillFull(Pico.est.Draw2FB, Pico.video.reg[7]);
  505. if (Pico.video.reg[1] & 0x40)
  506. DrawDisplayFull();
  507. pprof_end(draw);
  508. }
  509. void PicoDraw2Init(void)
  510. {
  511. Pico.est.Draw2FB = PicoDraw2FB_;
  512. }