Draw2.c 18 KB

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