draw.c 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754
  1. /*
  2. * line renderer
  3. * (c) Copyright Dave, 2004
  4. * (C) notaz, 2006-2010
  5. *
  6. * This work is licensed under the terms of MAME license.
  7. * See COPYING file in the top-level directory.
  8. */
  9. /*
  10. * The renderer has 4 modes now:
  11. * - normal
  12. * - shadow/hilight (s/h)
  13. * - "sonic mode" for midline palette changes (8bit mode only)
  14. * - accurate sprites (AS) [+ s/h]
  15. *
  16. * s/h uses upper bits for both priority and shadow/hilight flags.
  17. * "sonic mode" is autodetected, shadow/hilight is enabled by emulated game.
  18. * AS is enabled by user and takes priority over "sonic mode".
  19. *
  20. * since renderer always draws line in 8bit mode, there are 2 spare bits:
  21. * b \ mode: s/h sonic
  22. * 00 normal pal index
  23. * 01 shadow pal index
  24. * 10 hilight+op spr pal index
  25. * 11 shadow +op spr pal index
  26. *
  27. * not handled properly:
  28. * - hilight op on shadow tile
  29. */
  30. #include "pico_int.h"
  31. int (*PicoScanBegin)(unsigned int num) = NULL;
  32. int (*PicoScanEnd) (unsigned int num) = NULL;
  33. static unsigned char DefHighCol[8+320+8];
  34. static unsigned char *HighColBase = DefHighCol;
  35. static int HighColIncrement;
  36. static unsigned int DefOutBuff[320*2/2];
  37. void *DrawLineDestBase = DefOutBuff;
  38. int DrawLineDestIncrement;
  39. static int HighCacheA[41+1]; // caches for high layers
  40. static int HighCacheB[41+1];
  41. static int HighPreSpr[80*2+1]; // slightly preprocessed sprites
  42. #define LF_PLANE_1 (1 << 0)
  43. #define LF_SH (1 << 1) // must be = 2
  44. #define LF_FORCE (1 << 2)
  45. #define SPRL_HAVE_HI 0x80 // have hi priority sprites
  46. #define SPRL_HAVE_LO 0x40 // *lo*
  47. #define SPRL_MAY_HAVE_OP 0x20 // may have operator sprites on the line
  48. #define SPRL_LO_ABOVE_HI 0x10 // low priority sprites may be on top of hi
  49. unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, tile_count, [spritep]...
  50. int rendstatus_old;
  51. int rendlines;
  52. static int skip_next_line=0;
  53. struct TileStrip
  54. {
  55. int nametab; // Position in VRAM of name table (for this tile line)
  56. int line; // Line number in pixels 0x000-0x3ff within the virtual tilemap
  57. int hscroll; // Horizontal scroll value in pixels for the line
  58. int xmask; // X-Mask (0x1f - 0x7f) for horizontal wraparound in the tilemap
  59. int *hc; // cache for high tile codes and their positions
  60. int cells; // cells (tiles) to draw (32 col mode doesn't need to update whole 320)
  61. };
  62. // stuff available in asm:
  63. #ifdef _ASM_DRAW_C
  64. void DrawWindow(int tstart, int tend, int prio, int sh,
  65. struct PicoEState *est);
  66. void DrawAllSprites(unsigned char *sprited, int prio, int sh,
  67. struct PicoEState *est);
  68. void DrawTilesFromCache(int *hc, int sh, int rlim,
  69. struct PicoEState *est);
  70. void DrawSpritesSHi(unsigned char *sprited, struct PicoEState *est);
  71. void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,
  72. struct PicoEState *est);
  73. void *blockcpy(void *dst, const void *src, size_t n);
  74. void blockcpy_or(void *dst, void *src, size_t n, int pat);
  75. #else
  76. // utility
  77. void blockcpy_or(void *dst, void *src, size_t n, int pat)
  78. {
  79. unsigned char *pd = dst, *ps = src;
  80. for (; n; n--)
  81. *pd++ = (unsigned char) (*ps++ | pat);
  82. }
  83. #define blockcpy memcpy
  84. #endif
  85. #define TileNormMaker_(pix_func) \
  86. { \
  87. unsigned int t; \
  88. \
  89. t = (pack&0x0000f000)>>12; pix_func(0); \
  90. t = (pack&0x00000f00)>> 8; pix_func(1); \
  91. t = (pack&0x000000f0)>> 4; pix_func(2); \
  92. t = (pack&0x0000000f) ; pix_func(3); \
  93. t = (pack&0xf0000000)>>28; pix_func(4); \
  94. t = (pack&0x0f000000)>>24; pix_func(5); \
  95. t = (pack&0x00f00000)>>20; pix_func(6); \
  96. t = (pack&0x000f0000)>>16; pix_func(7); \
  97. }
  98. #define TileFlipMaker_(pix_func) \
  99. { \
  100. unsigned int t; \
  101. \
  102. t = (pack&0x000f0000)>>16; pix_func(0); \
  103. t = (pack&0x00f00000)>>20; pix_func(1); \
  104. t = (pack&0x0f000000)>>24; pix_func(2); \
  105. t = (pack&0xf0000000)>>28; pix_func(3); \
  106. t = (pack&0x0000000f) ; pix_func(4); \
  107. t = (pack&0x000000f0)>> 4; pix_func(5); \
  108. t = (pack&0x00000f00)>> 8; pix_func(6); \
  109. t = (pack&0x0000f000)>>12; pix_func(7); \
  110. }
  111. #define TileNormMaker(funcname, pix_func) \
  112. static void funcname(unsigned char *pd, unsigned int pack, int pal) \
  113. TileNormMaker_(pix_func)
  114. #define TileFlipMaker(funcname, pix_func) \
  115. static void funcname(unsigned char *pd, unsigned int pack, int pal) \
  116. TileFlipMaker_(pix_func)
  117. #define TileNormMakerAS(funcname, pix_func) \
  118. static void funcname(unsigned char *pd, unsigned char *mb, unsigned int pack, int pal) \
  119. TileNormMaker_(pix_func)
  120. #define TileFlipMakerAS(funcname, pix_func) \
  121. static void funcname(unsigned char *pd, unsigned char *mb, unsigned int pack, int pal) \
  122. TileFlipMaker_(pix_func)
  123. #define pix_just_write(x) \
  124. if (t) pd[x]=pal|t
  125. TileNormMaker(TileNorm,pix_just_write)
  126. TileFlipMaker(TileFlip,pix_just_write)
  127. #ifndef _ASM_DRAW_C
  128. // draw a sprite pixel, process operator colors
  129. #define pix_sh(x) \
  130. if (!t); \
  131. else if (t>=0xe) pd[x]=(pd[x]&0x3f)|(t<<6); /* c0 shadow, 80 hilight */ \
  132. else pd[x]=pal|t
  133. TileNormMaker(TileNormSH, pix_sh)
  134. TileFlipMaker(TileFlipSH, pix_sh)
  135. // draw a sprite pixel, mark operator colors
  136. #define pix_sh_markop(x) \
  137. if (!t); \
  138. else if (t>=0xe) pd[x]|=0x80; \
  139. else pd[x]=pal|t
  140. TileNormMaker(TileNormSH_markop, pix_sh_markop)
  141. TileFlipMaker(TileFlipSH_markop, pix_sh_markop)
  142. #endif
  143. // process operator pixels only, apply only on low pri tiles and other op pixels
  144. #define pix_sh_onlyop(x) \
  145. if (t>=0xe && (pd[x]&0xc0)) \
  146. pd[x]=(pd[x]&0x3f)|(t<<6); /* c0 shadow, 80 hilight */ \
  147. #ifndef _ASM_DRAW_C
  148. TileNormMaker(TileNormSH_onlyop_lp, pix_sh_onlyop)
  149. TileFlipMaker(TileFlipSH_onlyop_lp, pix_sh_onlyop)
  150. #endif
  151. // draw a sprite pixel (AS)
  152. #define pix_as(x) \
  153. if (t & mb[x]) mb[x] = 0, pd[x] = pal | t
  154. TileNormMakerAS(TileNormAS, pix_as)
  155. TileFlipMakerAS(TileFlipAS, pix_as)
  156. // draw a sprite pixel, process operator colors (AS)
  157. #define pix_sh_as(x) \
  158. if (t & mb[x]) { \
  159. mb[x] = 0; \
  160. if (t>=0xe) pd[x]=(pd[x]&0x3f)|(t<<6); /* c0 shadow, 80 hilight */ \
  161. else pd[x] = pal | t; \
  162. }
  163. TileNormMakerAS(TileNormSH_AS, pix_sh_as)
  164. TileFlipMakerAS(TileFlipSH_AS, pix_sh_as)
  165. #define pix_sh_as_onlyop(x) \
  166. if (t & mb[x]) { \
  167. mb[x] = 0; \
  168. pix_sh_onlyop(x); \
  169. }
  170. TileNormMakerAS(TileNormSH_AS_onlyop_lp, pix_sh_as_onlyop)
  171. TileFlipMakerAS(TileFlipSH_AS_onlyop_lp, pix_sh_as_onlyop)
  172. // mark pixel as sprite pixel (AS)
  173. #define pix_sh_as_onlymark(x) \
  174. if (t) mb[x] = 0
  175. TileNormMakerAS(TileNormAS_onlymark, pix_sh_as_onlymark)
  176. TileFlipMakerAS(TileFlipAS_onlymark, pix_sh_as_onlymark)
  177. // forced both layer draw (through debug reg)
  178. #define pix_and(x) \
  179. pd[x] = (pd[x] & 0xc0) | (pd[x] & (pal | t))
  180. TileNormMaker(TileNorm_and, pix_and)
  181. TileFlipMaker(TileFlip_and, pix_and)
  182. // --------------------------------------------
  183. #ifndef _ASM_DRAW_C
  184. static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)
  185. {
  186. unsigned char *pd = Pico.est.HighCol;
  187. int tilex,dx,ty,code=0,addr=0,cells;
  188. int oldcode=-1,blank=-1; // The tile we know is blank
  189. int pal=0,sh;
  190. // Draw tiles across screen:
  191. sh = (lflags & LF_SH) << 5; // 0x40
  192. tilex=((-ts->hscroll)>>3)+cellskip;
  193. ty=(ts->line&7)<<1; // Y-Offset into tile
  194. dx=((ts->hscroll-1)&7)+1;
  195. cells = ts->cells - cellskip;
  196. if(dx != 8) cells++; // have hscroll, need to draw 1 cell more
  197. dx+=cellskip<<3;
  198. for (; cells > 0; dx+=8, tilex++, cells--)
  199. {
  200. unsigned int pack;
  201. code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)];
  202. if (code == blank)
  203. continue;
  204. if ((code >> 15) | (lflags & LF_FORCE)) { // high priority tile
  205. int cval = code | (dx<<16) | (ty<<25);
  206. if(code&0x1000) cval^=7<<26;
  207. *ts->hc++ = cval; // cache it
  208. continue;
  209. }
  210. if (code!=oldcode) {
  211. oldcode = code;
  212. // Get tile address/2:
  213. addr=(code&0x7ff)<<4;
  214. addr+=ty;
  215. if (code&0x1000) addr^=0xe; // Y-flip
  216. pal=((code>>9)&0x30)|sh;
  217. }
  218. pack = *(unsigned int *)(PicoMem.vram + addr);
  219. if (!pack) {
  220. blank = code;
  221. continue;
  222. }
  223. if (code & 0x0800) TileFlip(pd + dx, pack, pal);
  224. else TileNorm(pd + dx, pack, pal);
  225. }
  226. // terminate the cache list
  227. *ts->hc = 0;
  228. // if oldcode wasn't changed, it means all layer is hi priority
  229. if (oldcode == -1) Pico.est.rendstatus |= PDRAW_PLANE_HI_PRIO;
  230. }
  231. // this is messy
  232. static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
  233. {
  234. unsigned char *pd = Pico.est.HighCol;
  235. int tilex,dx,code=0,addr=0,cell=0;
  236. int oldcode=-1,blank=-1; // The tile we know is blank
  237. int pal=0,scan=Pico.est.DrawScanline;
  238. // Draw tiles across screen:
  239. tilex=(-ts->hscroll)>>3;
  240. dx=((ts->hscroll-1)&7)+1;
  241. if (ts->hscroll & 0x0f) {
  242. int adj = ((ts->hscroll ^ dx) >> 3) & 1;
  243. cell -= adj + 1;
  244. ts->cells -= adj;
  245. }
  246. cell+=cellskip;
  247. tilex+=cellskip;
  248. dx+=cellskip<<3;
  249. for (; cell < ts->cells; dx+=8,tilex++,cell++)
  250. {
  251. int nametabadd, ty;
  252. unsigned int pack;
  253. //if((cell&1)==0)
  254. {
  255. int line,vscroll;
  256. vscroll=PicoMem.vsram[(plane_sh&1)+(cell&~1)];
  257. // Find the line in the name table
  258. line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..
  259. nametabadd=(line>>3)<<(ts->line>>24); // .. and shift[width]
  260. ty=(line&7)<<1; // Y-Offset into tile
  261. }
  262. code=PicoMem.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];
  263. if (code==blank) continue;
  264. if (code>>15) { // high priority tile
  265. int cval = code | (dx<<16) | (ty<<25);
  266. if(code&0x1000) cval^=7<<26;
  267. *ts->hc++ = cval; // cache it
  268. continue;
  269. }
  270. if (code!=oldcode) {
  271. oldcode = code;
  272. // Get tile address/2:
  273. addr=(code&0x7ff)<<4;
  274. if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
  275. pal=((code>>9)&0x30)|((plane_sh<<5)&0x40);
  276. }
  277. pack = *(unsigned int *)(PicoMem.vram + addr);
  278. if (!pack) {
  279. blank = code;
  280. continue;
  281. }
  282. if (code & 0x0800) TileFlip(pd + dx, pack, pal);
  283. else TileNorm(pd + dx, pack, pal);
  284. }
  285. // terminate the cache list
  286. *ts->hc = 0;
  287. if (oldcode == -1) Pico.est.rendstatus |= PDRAW_PLANE_HI_PRIO;
  288. }
  289. #endif
  290. #ifndef _ASM_DRAW_C
  291. static
  292. #endif
  293. void DrawStripInterlace(struct TileStrip *ts)
  294. {
  295. unsigned char *pd = Pico.est.HighCol;
  296. int tilex=0,dx=0,ty=0,code=0,addr=0,cells;
  297. int oldcode=-1,blank=-1; // The tile we know is blank
  298. int pal=0;
  299. // Draw tiles across screen:
  300. tilex=(-ts->hscroll)>>3;
  301. ty=(ts->line&15)<<1; // Y-Offset into tile
  302. dx=((ts->hscroll-1)&7)+1;
  303. cells = ts->cells;
  304. if(dx != 8) cells++; // have hscroll, need to draw 1 cell more
  305. for (; cells; dx+=8,tilex++,cells--)
  306. {
  307. unsigned int pack;
  308. code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)];
  309. if (code==blank) continue;
  310. if (code>>15) { // high priority tile
  311. int cval = (code&0xfc00) | (dx<<16) | (ty<<25);
  312. cval|=(code&0x3ff)<<1;
  313. if(code&0x1000) cval^=0xf<<26;
  314. *ts->hc++ = cval; // cache it
  315. continue;
  316. }
  317. if (code!=oldcode) {
  318. oldcode = code;
  319. // Get tile address/2:
  320. addr=(code&0x7ff)<<5;
  321. if (code&0x1000) addr+=30-ty; else addr+=ty; // Y-flip
  322. // pal=Pico.cram+((code>>9)&0x30);
  323. pal=((code>>9)&0x30);
  324. }
  325. pack = *(unsigned int *)(PicoMem.vram + addr);
  326. if (!pack) {
  327. blank = code;
  328. continue;
  329. }
  330. if (code & 0x0800) TileFlip(pd + dx, pack, pal);
  331. else TileNorm(pd + dx, pack, pal);
  332. }
  333. // terminate the cache list
  334. *ts->hc = 0;
  335. }
  336. // --------------------------------------------
  337. #ifndef _ASM_DRAW_C
  338. static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,
  339. struct PicoEState *est)
  340. {
  341. struct PicoVideo *pvid=&Pico.video;
  342. const char shift[4]={5,6,5,7}; // 32,64 or 128 sized tilemaps (2 is invalid)
  343. struct TileStrip ts;
  344. int width, height, ymask;
  345. int vscroll, htab;
  346. ts.hc=hcache;
  347. ts.cells=maxcells;
  348. // Work out the TileStrip to draw
  349. // Work out the name table size: 32 64 or 128 tiles (0-3)
  350. width=pvid->reg[16];
  351. height=(width>>4)&3; width&=3;
  352. ts.xmask=(1<<shift[width])-1; // X Mask in tiles (0x1f-0x7f)
  353. ymask=(height<<8)|0xff; // Y Mask in pixels
  354. switch (width) {
  355. case 1: ymask &= 0x1ff; break;
  356. case 2: ymask = 0x007; break;
  357. case 3: ymask = 0x0ff; break;
  358. }
  359. // Find name table:
  360. if (plane_sh&1) ts.nametab=(pvid->reg[4]&0x07)<<12; // B
  361. else ts.nametab=(pvid->reg[2]&0x38)<< 9; // A
  362. htab=pvid->reg[13]<<9; // Horizontal scroll table address
  363. if ( pvid->reg[11]&2) htab+=est->DrawScanline<<1; // Offset by line
  364. if ((pvid->reg[11]&1)==0) htab&=~0xf; // Offset by tile
  365. htab+=plane_sh&1; // A or B
  366. // Get horizontal scroll value, will be masked later
  367. ts.hscroll = PicoMem.vram[htab & 0x7fff];
  368. if((pvid->reg[12]&6) == 6) {
  369. // interlace mode 2
  370. vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value
  371. // Find the line in the name table
  372. ts.line=(vscroll+(est->DrawScanline<<1))&((ymask<<1)|1);
  373. ts.nametab+=(ts.line>>4)<<shift[width];
  374. DrawStripInterlace(&ts);
  375. } else if( pvid->reg[11]&4) {
  376. // shit, we have 2-cell column based vscroll
  377. // luckily this doesn't happen too often
  378. ts.line=ymask|(shift[width]<<24); // save some stuff instead of line
  379. DrawStripVSRam(&ts, plane_sh, cellskip);
  380. } else {
  381. vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value
  382. // Find the line in the name table
  383. ts.line=(vscroll+est->DrawScanline)&ymask;
  384. ts.nametab+=(ts.line>>3)<<shift[width];
  385. DrawStrip(&ts, plane_sh, cellskip);
  386. }
  387. }
  388. // --------------------------------------------
  389. // tstart & tend are tile pair numbers
  390. static void DrawWindow(int tstart, int tend, int prio, int sh,
  391. struct PicoEState *est)
  392. {
  393. unsigned char *pd = Pico.est.HighCol;
  394. struct PicoVideo *pvid = &Pico.video;
  395. int tilex,ty,nametab,code=0;
  396. int blank=-1; // The tile we know is blank
  397. // Find name table line:
  398. if (pvid->reg[12]&1)
  399. {
  400. nametab=(pvid->reg[3]&0x3c)<<9; // 40-cell mode
  401. nametab+=(est->DrawScanline>>3)<<6;
  402. }
  403. else
  404. {
  405. nametab=(pvid->reg[3]&0x3e)<<9; // 32-cell mode
  406. nametab+=(est->DrawScanline>>3)<<5;
  407. }
  408. tilex=tstart<<1;
  409. if (!(est->rendstatus & PDRAW_WND_DIFF_PRIO)) {
  410. // check the first tile code
  411. code = PicoMem.vram[nametab + tilex];
  412. // if the whole window uses same priority (what is often the case), we may be able to skip this field
  413. if ((code>>15) != prio) return;
  414. }
  415. tend<<=1;
  416. ty=(est->DrawScanline&7)<<1; // Y-Offset into tile
  417. // Draw tiles across screen:
  418. if (!sh)
  419. {
  420. for (; tilex < tend; tilex++)
  421. {
  422. unsigned int pack;
  423. int dx, addr;
  424. int pal;
  425. code = PicoMem.vram[nametab + tilex];
  426. if (code==blank) continue;
  427. if ((code>>15) != prio) {
  428. est->rendstatus |= PDRAW_WND_DIFF_PRIO;
  429. continue;
  430. }
  431. // Get tile address/2:
  432. addr=(code&0x7ff)<<4;
  433. if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
  434. pack = *(unsigned int *)(PicoMem.vram + addr);
  435. if (!pack) {
  436. blank = code;
  437. continue;
  438. }
  439. pal = ((code >> 9) & 0x30);
  440. dx = 8 + (tilex << 3);
  441. if (code & 0x0800) TileFlip(pd + dx, pack, pal);
  442. else TileNorm(pd + dx, pack, pal);
  443. }
  444. }
  445. else
  446. {
  447. for (; tilex < tend; tilex++)
  448. {
  449. unsigned int pack;
  450. int dx, addr;
  451. int pal;
  452. code = PicoMem.vram[nametab + tilex];
  453. if(code==blank) continue;
  454. if((code>>15) != prio) {
  455. est->rendstatus |= PDRAW_WND_DIFF_PRIO;
  456. continue;
  457. }
  458. pal=((code>>9)&0x30);
  459. if (prio) {
  460. int *zb = (int *)(est->HighCol+8+(tilex<<3));
  461. *zb++ &= 0xbfbfbfbf;
  462. *zb &= 0xbfbfbfbf;
  463. } else {
  464. pal |= 0x40;
  465. }
  466. // Get tile address/2:
  467. addr=(code&0x7ff)<<4;
  468. if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
  469. pack = *(unsigned int *)(PicoMem.vram + addr);
  470. if (!pack) {
  471. blank = code;
  472. continue;
  473. }
  474. dx = 8 + (tilex << 3);
  475. if (code & 0x0800) TileFlip(pd + dx, pack, pal);
  476. else TileNorm(pd + dx, pack, pal);
  477. }
  478. }
  479. }
  480. // --------------------------------------------
  481. static void DrawTilesFromCacheShPrep(void)
  482. {
  483. // as some layer has covered whole line with hi priority tiles,
  484. // we can process whole line and then act as if sh/hi mode was off,
  485. // but leave lo pri op sprite markers alone
  486. int c = 320/4, *zb = (int *)(Pico.est.HighCol+8);
  487. Pico.est.rendstatus |= PDRAW_SHHI_DONE;
  488. while (c--)
  489. {
  490. *zb++ &= 0xbfbfbfbf;
  491. }
  492. }
  493. static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est)
  494. {
  495. unsigned char *pd = Pico.est.HighCol;
  496. int code, addr, dx;
  497. unsigned int pack;
  498. int pal;
  499. // *ts->hc++ = code | (dx<<16) | (ty<<25); // cache it
  500. if (sh && (est->rendstatus & (PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO)))
  501. {
  502. if (!(est->rendstatus & PDRAW_SHHI_DONE))
  503. DrawTilesFromCacheShPrep();
  504. sh = 0;
  505. }
  506. if (!sh)
  507. {
  508. short blank=-1; // The tile we know is blank
  509. while ((code=*hc++)) {
  510. if (!(code & 0x8000) || (short)code == blank)
  511. continue;
  512. // Get tile address/2:
  513. addr = (code & 0x7ff) << 4;
  514. addr += code >> 25; // y offset into tile
  515. pack = *(unsigned int *)(PicoMem.vram + addr);
  516. if (!pack) {
  517. blank = (short)code;
  518. continue;
  519. }
  520. dx = (code >> 16) & 0x1ff;
  521. pal = ((code >> 9) & 0x30);
  522. if (rlim-dx < 0)
  523. goto last_cut_tile;
  524. if (code & 0x0800) TileFlip(pd + dx, pack, pal);
  525. else TileNorm(pd + dx, pack, pal);
  526. }
  527. }
  528. else
  529. {
  530. while ((code=*hc++)) {
  531. unsigned char *zb;
  532. // Get tile address/2:
  533. addr=(code&0x7ff)<<4;
  534. addr+=(unsigned int)code>>25; // y offset into tile
  535. dx=(code>>16)&0x1ff;
  536. zb = est->HighCol+dx;
  537. *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;
  538. *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;
  539. pack = *(unsigned int *)(PicoMem.vram + addr);
  540. if (!pack)
  541. continue;
  542. pal = ((code >> 9) & 0x30);
  543. if (rlim - dx < 0)
  544. goto last_cut_tile;
  545. if (code & 0x0800) TileFlip(pd + dx, pack, pal);
  546. else TileNorm(pd + dx, pack, pal);
  547. }
  548. }
  549. return;
  550. last_cut_tile:
  551. // for vertical window cutoff
  552. {
  553. unsigned int t;
  554. pd += dx;
  555. if (code&0x0800)
  556. {
  557. switch (rlim-dx+8)
  558. {
  559. case 7: t=pack&0x00000f00; if (t) pd[6]=(unsigned char)(pal|(t>> 8)); // "break" is left out intentionally
  560. case 6: t=pack&0x000000f0; if (t) pd[5]=(unsigned char)(pal|(t>> 4));
  561. case 5: t=pack&0x0000000f; if (t) pd[4]=(unsigned char)(pal|(t ));
  562. case 4: t=pack&0xf0000000; if (t) pd[3]=(unsigned char)(pal|(t>>28));
  563. case 3: t=pack&0x0f000000; if (t) pd[2]=(unsigned char)(pal|(t>>24));
  564. case 2: t=pack&0x00f00000; if (t) pd[1]=(unsigned char)(pal|(t>>20));
  565. case 1: t=pack&0x000f0000; if (t) pd[0]=(unsigned char)(pal|(t>>16));
  566. default: break;
  567. }
  568. }
  569. else
  570. {
  571. switch (rlim-dx+8)
  572. {
  573. case 7: t=pack&0x00f00000; if (t) pd[6]=(unsigned char)(pal|(t>>20));
  574. case 6: t=pack&0x0f000000; if (t) pd[5]=(unsigned char)(pal|(t>>24));
  575. case 5: t=pack&0xf0000000; if (t) pd[4]=(unsigned char)(pal|(t>>28));
  576. case 4: t=pack&0x0000000f; if (t) pd[3]=(unsigned char)(pal|(t ));
  577. case 3: t=pack&0x000000f0; if (t) pd[2]=(unsigned char)(pal|(t>> 4));
  578. case 2: t=pack&0x00000f00; if (t) pd[1]=(unsigned char)(pal|(t>> 8));
  579. case 1: t=pack&0x0000f000; if (t) pd[0]=(unsigned char)(pal|(t>>12));
  580. default: break;
  581. }
  582. }
  583. }
  584. }
  585. // --------------------------------------------
  586. // Index + 0 : hhhhvvvv ab--hhvv yyyyyyyy yyyyyyyy // a: offscreen h, b: offs. v, h: horiz. size
  587. // Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
  588. static void DrawSprite(int *sprite, int sh)
  589. {
  590. void (*fTileFunc)(unsigned char *pd, unsigned int pack, int pal);
  591. unsigned char *pd = Pico.est.HighCol;
  592. int width=0,height=0;
  593. int row=0,code=0;
  594. int pal;
  595. int tile=0,delta=0;
  596. int sx, sy;
  597. // parse the sprite data
  598. sy=sprite[0];
  599. code=sprite[1];
  600. sx=code>>16; // X
  601. width=sy>>28;
  602. height=(sy>>24)&7; // Width and height in tiles
  603. sy=(sy<<16)>>16; // Y
  604. row=Pico.est.DrawScanline-sy; // Row of the sprite we are on
  605. if (code&0x1000) row=(height<<3)-1-row; // Flip Y
  606. tile=code + (row>>3); // Tile number increases going down
  607. delta=height; // Delta to increase tile by going right
  608. if (code&0x0800) { tile+=delta*(width-1); delta=-delta; } // Flip X
  609. tile &= 0x7ff; tile<<=4; tile+=(row&7)<<1; // Tile address
  610. delta<<=4; // Delta of address
  611. pal=(code>>9)&0x30;
  612. pal|=sh<<6;
  613. if (sh && (code&0x6000) == 0x6000) {
  614. if(code&0x0800) fTileFunc=TileFlipSH_markop;
  615. else fTileFunc=TileNormSH_markop;
  616. } else {
  617. if(code&0x0800) fTileFunc=TileFlip;
  618. else fTileFunc=TileNorm;
  619. }
  620. for (; width; width--,sx+=8,tile+=delta)
  621. {
  622. unsigned int pack;
  623. if(sx<=0) continue;
  624. if(sx>=328) break; // Offscreen
  625. pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));
  626. fTileFunc(pd + sx, pack, pal);
  627. }
  628. }
  629. #endif
  630. static NOINLINE void DrawTilesFromCacheForced(const int *hc)
  631. {
  632. unsigned char *pd = Pico.est.HighCol;
  633. int code, addr, dx;
  634. unsigned int pack;
  635. int pal;
  636. // *ts->hc++ = code | (dx<<16) | (ty<<25);
  637. while ((code = *hc++)) {
  638. // Get tile address/2:
  639. addr = (code & 0x7ff) << 4;
  640. addr += (code >> 25) & 0x0e; // y offset into tile
  641. dx = (code >> 16) & 0x1ff;
  642. pal = ((code >> 9) & 0x30);
  643. pack = *(unsigned int *)(PicoMem.vram + addr);
  644. if (code & 0x0800) TileFlip_and(pd + dx, pack, pal);
  645. else TileNorm_and(pd + dx, pack, pal);
  646. }
  647. }
  648. static void DrawSpriteInterlace(unsigned int *sprite)
  649. {
  650. unsigned char *pd = Pico.est.HighCol;
  651. int width=0,height=0;
  652. int row=0,code=0;
  653. int pal;
  654. int tile=0,delta=0;
  655. int sx, sy;
  656. // parse the sprite data
  657. sy=sprite[0];
  658. height=sy>>24;
  659. sy=(sy&0x3ff)-0x100; // Y
  660. width=(height>>2)&3; height&=3;
  661. width++; height++; // Width and height in tiles
  662. row=(Pico.est.DrawScanline<<1)-sy; // Row of the sprite we are on
  663. code=sprite[1];
  664. sx=((code>>16)&0x1ff)-0x78; // X
  665. if (code&0x1000) row^=(16<<height)-1; // Flip Y
  666. tile=code&0x3ff; // Tile number
  667. tile+=row>>4; // Tile number increases going down
  668. delta=height; // Delta to increase tile by going right
  669. if (code&0x0800) { tile+=delta*(width-1); delta=-delta; } // Flip X
  670. tile<<=5; tile+=(row&15)<<1; // Tile address
  671. delta<<=5; // Delta of address
  672. pal=((code>>9)&0x30); // Get palette pointer
  673. for (; width; width--,sx+=8,tile+=delta)
  674. {
  675. unsigned int pack;
  676. if(sx<=0) continue;
  677. if(sx>=328) break; // Offscreen
  678. pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));
  679. if (code & 0x0800) TileFlip(pd + sx, pack, pal);
  680. else TileNorm(pd + sx, pack, pal);
  681. }
  682. }
  683. static NOINLINE void DrawAllSpritesInterlace(int pri, int sh)
  684. {
  685. struct PicoVideo *pvid=&Pico.video;
  686. int i,u,table,link=0,sline=Pico.est.DrawScanline<<1;
  687. unsigned int *sprites[80]; // Sprite index
  688. table=pvid->reg[5]&0x7f;
  689. if (pvid->reg[12]&1) table&=0x7e; // Lowest bit 0 in 40-cell mode
  690. table<<=8; // Get sprite table address/2
  691. for (i=u=0; u < 80 && i < 21; u++)
  692. {
  693. unsigned int *sprite;
  694. int code, sx, sy, height;
  695. sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
  696. // get sprite info
  697. code = sprite[0];
  698. sx = sprite[1];
  699. if(((sx>>15)&1) != pri) goto nextsprite; // wrong priority sprite
  700. // check if it is on this line
  701. sy = (code&0x3ff)-0x100;
  702. height = (((code>>24)&3)+1)<<4;
  703. if(sline < sy || sline >= sy+height) goto nextsprite; // no
  704. // check if sprite is not hidden offscreen
  705. sx = (sx>>16)&0x1ff;
  706. sx -= 0x78; // Get X coordinate + 8
  707. if(sx <= -8*3 || sx >= 328) goto nextsprite;
  708. // sprite is good, save it's pointer
  709. sprites[i++]=sprite;
  710. nextsprite:
  711. // Find next sprite
  712. link=(code>>16)&0x7f;
  713. if(!link) break; // End of sprites
  714. }
  715. // Go through sprites backwards:
  716. for (i-- ;i>=0; i--)
  717. DrawSpriteInterlace(sprites[i]);
  718. }
  719. #ifndef _ASM_DRAW_C
  720. /*
  721. * s/h drawing: lo_layers|40, lo_sprites|40 && mark_op,
  722. * hi_layers&=~40, hi_sprites
  723. *
  724. * Index + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: vert./horiz. size
  725. * Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
  726. */
  727. static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)
  728. {
  729. void (*fTileFunc)(unsigned char *pd, unsigned int pack, int pal);
  730. unsigned char *pd = Pico.est.HighCol;
  731. unsigned char *p;
  732. int cnt;
  733. cnt = sprited[0] & 0x7f;
  734. if (cnt == 0) return;
  735. p = &sprited[3];
  736. // Go through sprites backwards:
  737. for (cnt--; cnt >= 0; cnt--)
  738. {
  739. int *sprite, code, pal, tile, sx, sy;
  740. int offs, delta, width, height, row;
  741. offs = (p[cnt] & 0x7f) * 2;
  742. sprite = est->HighPreSpr + offs;
  743. code = sprite[1];
  744. pal = (code>>9)&0x30;
  745. if (pal == 0x30)
  746. {
  747. if (code & 0x8000) // hi priority
  748. {
  749. if (code&0x800) fTileFunc=TileFlipSH;
  750. else fTileFunc=TileNormSH;
  751. } else {
  752. if (code&0x800) fTileFunc=TileFlipSH_onlyop_lp;
  753. else fTileFunc=TileNormSH_onlyop_lp;
  754. }
  755. } else {
  756. if (!(code & 0x8000)) continue; // non-operator low sprite, already drawn
  757. if (code&0x800) fTileFunc=TileFlip;
  758. else fTileFunc=TileNorm;
  759. }
  760. // parse remaining sprite data
  761. sy=sprite[0];
  762. sx=code>>16; // X
  763. width=sy>>28;
  764. height=(sy>>24)&7; // Width and height in tiles
  765. sy=(sy<<16)>>16; // Y
  766. row=est->DrawScanline-sy; // Row of the sprite we are on
  767. if (code&0x1000) row=(height<<3)-1-row; // Flip Y
  768. tile=code + (row>>3); // Tile number increases going down
  769. delta=height; // Delta to increase tile by going right
  770. if (code&0x0800) { tile+=delta*(width-1); delta=-delta; } // Flip X
  771. tile &= 0x7ff; tile<<=4; tile+=(row&7)<<1; // Tile address
  772. delta<<=4; // Delta of address
  773. for (; width; width--,sx+=8,tile+=delta)
  774. {
  775. unsigned int pack;
  776. if(sx<=0) continue;
  777. if(sx>=328) break; // Offscreen
  778. pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));
  779. fTileFunc(pd + sx, pack, pal);
  780. }
  781. }
  782. }
  783. #endif // !_ASM_DRAW_C
  784. static void DrawSpritesHiAS(unsigned char *sprited, int sh)
  785. {
  786. void (*fTileFunc)(unsigned char *pd, unsigned char *mb,
  787. unsigned int pack, int pal);
  788. unsigned char *pd = Pico.est.HighCol;
  789. unsigned char mb[8+320+8];
  790. unsigned char *p;
  791. int entry, cnt;
  792. cnt = sprited[0] & 0x7f;
  793. if (cnt == 0) return;
  794. memset(mb, 0xff, sizeof(mb));
  795. p = &sprited[3];
  796. // Go through sprites:
  797. for (entry = 0; entry < cnt; entry++)
  798. {
  799. int *sprite, code, pal, tile, sx, sy;
  800. int offs, delta, width, height, row;
  801. offs = (p[entry] & 0x7f) * 2;
  802. sprite = HighPreSpr + offs;
  803. code = sprite[1];
  804. pal = (code>>9)&0x30;
  805. if (sh && pal == 0x30)
  806. {
  807. if (code & 0x8000) // hi priority
  808. {
  809. if (code&0x800) fTileFunc = TileFlipSH_AS;
  810. else fTileFunc = TileNormSH_AS;
  811. } else {
  812. if (code&0x800) fTileFunc = TileFlipSH_AS_onlyop_lp;
  813. else fTileFunc = TileNormSH_AS_onlyop_lp;
  814. }
  815. } else {
  816. if (code & 0x8000) // hi priority
  817. {
  818. if (code&0x800) fTileFunc = TileFlipAS;
  819. else fTileFunc = TileNormAS;
  820. } else {
  821. if (code&0x800) fTileFunc = TileFlipAS_onlymark;
  822. else fTileFunc = TileNormAS_onlymark;
  823. }
  824. }
  825. // parse remaining sprite data
  826. sy=sprite[0];
  827. sx=code>>16; // X
  828. width=sy>>28;
  829. height=(sy>>24)&7; // Width and height in tiles
  830. sy=(sy<<16)>>16; // Y
  831. row=Pico.est.DrawScanline-sy; // Row of the sprite we are on
  832. if (code&0x1000) row=(height<<3)-1-row; // Flip Y
  833. tile=code + (row>>3); // Tile number increases going down
  834. delta=height; // Delta to increase tile by going right
  835. if (code&0x0800) { tile+=delta*(width-1); delta=-delta; } // Flip X
  836. tile &= 0x7ff; tile<<=4; tile+=(row&7)<<1; // Tile address
  837. delta<<=4; // Delta of address
  838. for (; width; width--,sx+=8,tile+=delta)
  839. {
  840. unsigned int pack;
  841. if(sx<=0) continue;
  842. if(sx>=328) break; // Offscreen
  843. pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));
  844. fTileFunc(pd + sx, mb + sx, pack, pal);
  845. }
  846. }
  847. }
  848. // Index + 0 : ----hhvv -lllllll -------y yyyyyyyy
  849. // Index + 4 : -------x xxxxxxxx pccvhnnn nnnnnnnn
  850. // v
  851. // Index + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: vert./horiz. size
  852. // Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
  853. static NOINLINE void PrepareSprites(int full)
  854. {
  855. const struct PicoVideo *pvid=&Pico.video;
  856. const struct PicoEState *est=&Pico.est;
  857. int u,link=0,sh;
  858. int table=0;
  859. int *pd = HighPreSpr;
  860. int max_lines = 224, max_sprites = 80, max_width = 328;
  861. int max_line_sprites = 20; // 20 sprites, 40 tiles
  862. if (!(Pico.video.reg[12]&1))
  863. max_sprites = 64, max_line_sprites = 16, max_width = 264;
  864. if (PicoIn.opt & POPT_DIS_SPRITE_LIM)
  865. max_line_sprites = MAX_LINE_SPRITES;
  866. if (pvid->reg[1]&8) max_lines = 240;
  867. sh = Pico.video.reg[0xC]&8; // shadow/hilight?
  868. table=pvid->reg[5]&0x7f;
  869. if (pvid->reg[12]&1) table&=0x7e; // Lowest bit 0 in 40-cell mode
  870. table<<=8; // Get sprite table address/2
  871. if (!full)
  872. {
  873. int pack;
  874. // updates: tilecode, sx
  875. for (u=0; u < max_sprites && (pack = *pd); u++, pd+=2)
  876. {
  877. unsigned int *sprite;
  878. int code2, sx, sy, height;
  879. sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
  880. // parse sprite info
  881. code2 = sprite[1];
  882. sx = (code2>>16)&0x1ff;
  883. sx -= 0x78; // Get X coordinate + 8
  884. sy = (pack << 16) >> 16;
  885. height = (pack >> 24) & 0xf;
  886. if (sy < max_lines &&
  887. sy + (height<<3) > est->DrawScanline && // sprite onscreen (y)?
  888. (sx > -24 || sx < max_width)) // onscreen x
  889. {
  890. int y = (sy >= est->DrawScanline) ? sy : est->DrawScanline;
  891. int entry = ((pd - HighPreSpr) / 2) | ((code2>>8)&0x80);
  892. for (; y < sy + (height<<3) && y < max_lines; y++)
  893. {
  894. int i, cnt;
  895. cnt = HighLnSpr[y][0] & 0x7f;
  896. if (cnt >= max_line_sprites) continue; // sprite limit?
  897. for (i = 0; i < cnt; i++)
  898. if (((HighLnSpr[y][3+i] ^ entry) & 0x7f) == 0) goto found;
  899. // this sprite was previously missing
  900. HighLnSpr[y][3+cnt] = entry;
  901. HighLnSpr[y][0] = cnt + 1;
  902. found:;
  903. if (entry & 0x80)
  904. HighLnSpr[y][1] |= SPRL_HAVE_HI;
  905. else HighLnSpr[y][1] |= SPRL_HAVE_LO;
  906. }
  907. }
  908. code2 &= ~0xfe000000;
  909. code2 -= 0x00780000; // Get X coordinate + 8 in upper 16 bits
  910. pd[1] = code2;
  911. // Find next sprite
  912. link=(sprite[0]>>16)&0x7f;
  913. if (!link) break; // End of sprites
  914. }
  915. }
  916. else
  917. {
  918. for (u = 0; u < max_lines; u++)
  919. *((int *)&HighLnSpr[u][0]) = 0;
  920. for (u = 0; u < max_sprites; u++)
  921. {
  922. unsigned int *sprite;
  923. int code, code2, sx, sy, hv, height, width;
  924. sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
  925. // parse sprite info
  926. code = sprite[0];
  927. sy = (code&0x1ff)-0x80;
  928. hv = (code>>24)&0xf;
  929. height = (hv&3)+1;
  930. width = (hv>>2)+1;
  931. code2 = sprite[1];
  932. sx = (code2>>16)&0x1ff;
  933. sx -= 0x78; // Get X coordinate + 8
  934. if (sy < max_lines && sy + (height<<3) > est->DrawScanline) // sprite onscreen (y)?
  935. {
  936. int entry, y, sx_min, onscr_x, maybe_op = 0;
  937. sx_min = 8-(width<<3);
  938. onscr_x = sx_min < sx && sx < max_width;
  939. if (sh && (code2 & 0x6000) == 0x6000)
  940. maybe_op = SPRL_MAY_HAVE_OP;
  941. entry = ((pd - HighPreSpr) / 2) | ((code2>>8)&0x80);
  942. y = (sy >= est->DrawScanline) ? sy : est->DrawScanline;
  943. for (; y < sy + (height<<3) && y < max_lines; y++)
  944. {
  945. unsigned char *p = &HighLnSpr[y][0];
  946. int cnt = p[0];
  947. if (cnt >= max_line_sprites) continue; // sprite limit?
  948. if (p[2] >= max_line_sprites*2) { // tile limit?
  949. p[0] |= 0x80;
  950. continue;
  951. }
  952. p[2] += width;
  953. if (sx == -0x78) {
  954. if (cnt > 0)
  955. p[0] |= 0x80; // masked, no more sprites for this line
  956. continue;
  957. }
  958. // must keep the first sprite even if it's offscreen, for masking
  959. if (cnt > 0 && !onscr_x) continue; // offscreen x
  960. p[3+cnt] = entry;
  961. p[0] = cnt + 1;
  962. p[1] |= (entry & 0x80) ? SPRL_HAVE_HI : SPRL_HAVE_LO;
  963. p[1] |= maybe_op; // there might be op sprites on this line
  964. if (cnt > 0 && (code2 & 0x8000) && !(p[3+cnt-1]&0x80))
  965. p[1] |= SPRL_LO_ABOVE_HI;
  966. }
  967. }
  968. *pd++ = (width<<28)|(height<<24)|(hv<<16)|((unsigned short)sy);
  969. *pd++ = (sx<<16)|((unsigned short)code2);
  970. // Find next sprite
  971. link=(code>>16)&0x7f;
  972. if (!link) break; // End of sprites
  973. }
  974. *pd = 0;
  975. #if 0
  976. for (u = 0; u < max_lines; u++)
  977. {
  978. int y;
  979. printf("c%03i: %2i, %2i: ", u, HighLnSpr[u][0] & 0x7f, HighLnSpr[u][2]);
  980. for (y = 0; y < HighLnSpr[u][0] & 0x7f; y++)
  981. printf(" %i", HighLnSpr[u][y+3]);
  982. printf("\n");
  983. }
  984. #endif
  985. }
  986. }
  987. #ifndef _ASM_DRAW_C
  988. static void DrawAllSprites(unsigned char *sprited, int prio, int sh,
  989. struct PicoEState *est)
  990. {
  991. unsigned char *p;
  992. int cnt;
  993. cnt = sprited[0] & 0x7f;
  994. if (cnt == 0) return;
  995. p = &sprited[3];
  996. // Go through sprites backwards:
  997. for (cnt--; cnt >= 0; cnt--)
  998. {
  999. int offs;
  1000. if ((p[cnt] >> 7) != prio) continue;
  1001. offs = (p[cnt]&0x7f) * 2;
  1002. DrawSprite(HighPreSpr + offs, sh);
  1003. }
  1004. }
  1005. // --------------------------------------------
  1006. void BackFill(int reg7, int sh, struct PicoEState *est)
  1007. {
  1008. unsigned int back;
  1009. // Start with a blank scanline (background colour):
  1010. back=reg7&0x3f;
  1011. back|=sh<<6;
  1012. back|=back<<8;
  1013. back|=back<<16;
  1014. memset32((int *)(est->HighCol+8), back, 320/4);
  1015. }
  1016. #endif
  1017. // --------------------------------------------
  1018. void PicoDoHighPal555_8bit(int sh, int line, struct PicoEState *est)
  1019. {
  1020. unsigned int *spal, *dpal;
  1021. unsigned int cnt = (sh ? 1 : est->SonicPalCount+1);
  1022. unsigned int t, i;
  1023. // reset dirty only if there are no outstanding changes
  1024. if (Pico.m.dirtyPal == 2)
  1025. Pico.m.dirtyPal = 0;
  1026. // In Sonic render mode palettes were backuped in SonicPal
  1027. spal = (void *)est->SonicPal;
  1028. dpal = (void *)est->HighPal;
  1029. // additional palettes stored after in-frame changes
  1030. for (i = 0; i < cnt * 0x40 / 2; i++) {
  1031. t = spal[i];
  1032. #ifdef USE_BGR555
  1033. t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4);
  1034. #else
  1035. t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);
  1036. #endif
  1037. // treat it like it was 4-bit per channel, since in s/h mode it somewhat is that.
  1038. // otherwise intensity difference between this and s/h will be wrong
  1039. t |= (t >> 4) & 0x08610861; // 0x18e318e3
  1040. dpal[i] = t;
  1041. }
  1042. // norm: xxx0, sh: 0xxx, hi: 0xxx + 7
  1043. if (sh)
  1044. {
  1045. // shadowed pixels
  1046. for (i = 0; i < 0x40 / 2; i++)
  1047. dpal[0x40/2 | i] = dpal[0xc0/2 | i] = (dpal[i] >> 1) & 0x738e738e;
  1048. // hilighted pixels
  1049. for (i = 0; i < 0x40 / 2; i++) {
  1050. t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e; // 0x7bef7bef;
  1051. t |= (t >> 4) & 0x08610861;
  1052. dpal[0x80/2 | i] = t;
  1053. }
  1054. }
  1055. }
  1056. #ifndef _ASM_DRAW_C
  1057. void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
  1058. {
  1059. unsigned int *spal, *dpal;
  1060. unsigned int t, i;
  1061. Pico.m.dirtyPal = 0;
  1062. spal = (void *)PicoMem.cram;
  1063. dpal = (void *)est->HighPal;
  1064. for (i = 0; i < 0x40 / 2; i++) {
  1065. t = spal[i];
  1066. #ifdef USE_BGR555
  1067. t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4);
  1068. #else
  1069. t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);
  1070. #endif
  1071. // treat it like it was 4-bit per channel, since in s/h mode it somewhat is that.
  1072. // otherwise intensity difference between this and s/h will be wrong
  1073. t |= (t >> 4) & 0x08610861; // 0x18e318e3
  1074. dpal[i] = t;
  1075. }
  1076. // norm: xxx0, sh: 0xxx, hi: 0xxx + 7
  1077. if (sh)
  1078. {
  1079. // shadowed pixels
  1080. for (i = 0; i < 0x40 / 2; i++)
  1081. dpal[0x40/2 | i] = dpal[0xc0/2 | i] = (dpal[i] >> 1) & 0x738e738e;
  1082. // hilighted pixels
  1083. for (i = 0; i < 0x40 / 2; i++) {
  1084. t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e; // 0x7bef7bef;
  1085. t |= (t >> 4) & 0x08610861;
  1086. dpal[0x80/2 | i] = t;
  1087. }
  1088. }
  1089. }
  1090. void FinalizeLine555(int sh, int line, struct PicoEState *est)
  1091. {
  1092. unsigned short *pd=est->DrawLineDest;
  1093. unsigned char *ps=est->HighCol+8;
  1094. unsigned short *pal=est->HighPal;
  1095. int len;
  1096. PicoDrawUpdateHighPal();
  1097. if (Pico.video.reg[12]&1) {
  1098. len = 320;
  1099. } else {
  1100. if (!(PicoIn.opt&POPT_DIS_32C_BORDER)) pd+=32;
  1101. len = 256;
  1102. }
  1103. {
  1104. #if 1
  1105. int i;
  1106. for (i = len; i > 0; i-=4) {
  1107. *pd++ = pal[*ps++];
  1108. *pd++ = pal[*ps++];
  1109. *pd++ = pal[*ps++];
  1110. *pd++ = pal[*ps++];
  1111. }
  1112. #else
  1113. extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);
  1114. extern void amips_clut_6bit(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);
  1115. if (!sh)
  1116. amips_clut_6bit(pd, ps, pal, len);
  1117. else amips_clut(pd, ps, pal, len);
  1118. #endif
  1119. }
  1120. }
  1121. #endif
  1122. static void FinalizeLine8bit(int sh, int line, struct PicoEState *est)
  1123. {
  1124. unsigned char *pd = est->DrawLineDest;
  1125. int len;
  1126. static int dirty_line;
  1127. if (Pico.m.dirtyPal == 1)
  1128. {
  1129. // a hack for mid-frame palette changes
  1130. if (!(est->rendstatus & PDRAW_SONIC_MODE) || line - dirty_line > 4) {
  1131. // store a maximum of 2 additional palettes in SonicPal
  1132. if (est->SonicPalCount < 2)
  1133. est->SonicPalCount ++;
  1134. dirty_line = line;
  1135. est->rendstatus |= PDRAW_SONIC_MODE;
  1136. }
  1137. blockcpy(est->SonicPal+est->SonicPalCount*0x40, PicoMem.cram, 0x40*2);
  1138. Pico.m.dirtyPal = 2;
  1139. }
  1140. if (Pico.video.reg[12]&1) {
  1141. len = 320;
  1142. } else {
  1143. if (!(PicoIn.opt & POPT_DIS_32C_BORDER))
  1144. pd += 32;
  1145. len = 256;
  1146. }
  1147. if (!sh && (est->rendstatus & PDRAW_SONIC_MODE)) {
  1148. // select active backup palette
  1149. blockcpy_or(pd, est->HighCol+8, len, est->SonicPalCount*0x40);
  1150. } else {
  1151. blockcpy(pd, est->HighCol+8, len);
  1152. }
  1153. }
  1154. static void (*FinalizeLine)(int sh, int line, struct PicoEState *est);
  1155. // --------------------------------------------
  1156. static int DrawDisplay(int sh)
  1157. {
  1158. struct PicoEState *est=&Pico.est;
  1159. unsigned char *sprited = &HighLnSpr[est->DrawScanline][0];
  1160. struct PicoVideo *pvid=&Pico.video;
  1161. int win=0, edge=0, hvwind=0, lflags;
  1162. int maxw, maxcells;
  1163. if (est->rendstatus & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {
  1164. // elprintf(EL_STATUS, "PrepareSprites(%i)", (est->rendstatus>>4)&1);
  1165. PrepareSprites(est->rendstatus & PDRAW_DIRTY_SPRITES);
  1166. est->rendstatus &= ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);
  1167. }
  1168. est->rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO);
  1169. if (pvid->reg[12]&1) {
  1170. maxw = 328; maxcells = 40;
  1171. } else {
  1172. maxw = 264; maxcells = 32;
  1173. }
  1174. // Find out if the window is on this line:
  1175. win=pvid->reg[0x12];
  1176. edge=(win&0x1f)<<3;
  1177. if (win&0x80) { if (est->DrawScanline>=edge) hvwind=1; }
  1178. else { if (est->DrawScanline< edge) hvwind=1; }
  1179. if (!hvwind) // we might have a vertical window here
  1180. {
  1181. win=pvid->reg[0x11];
  1182. edge=win&0x1f;
  1183. if (win&0x80) {
  1184. if (!edge) hvwind=1;
  1185. else if(edge < (maxcells>>1)) hvwind=2;
  1186. } else {
  1187. if (!edge);
  1188. else if(edge < (maxcells>>1)) hvwind=2;
  1189. else hvwind=1;
  1190. }
  1191. }
  1192. /* - layer B low - */
  1193. if (!(pvid->debug_p & PVD_KILL_B)) {
  1194. lflags = LF_PLANE_1 | (sh << 1);
  1195. if (pvid->debug_p & PVD_FORCE_B)
  1196. lflags |= LF_FORCE;
  1197. DrawLayer(lflags, HighCacheB, 0, maxcells, est);
  1198. }
  1199. /* - layer A low - */
  1200. lflags = 0 | (sh << 1);
  1201. if (pvid->debug_p & PVD_FORCE_A)
  1202. lflags |= LF_FORCE;
  1203. if (pvid->debug_p & PVD_KILL_A)
  1204. ;
  1205. else if (hvwind == 1)
  1206. DrawWindow(0, maxcells>>1, 0, sh, est);
  1207. else if (hvwind == 2) {
  1208. DrawLayer(lflags, HighCacheA, (win&0x80) ? 0 : edge<<1, (win&0x80) ? edge<<1 : maxcells, est);
  1209. DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh, est);
  1210. }
  1211. else
  1212. DrawLayer(lflags, HighCacheA, 0, maxcells, est);
  1213. /* - sprites low - */
  1214. if (pvid->debug_p & PVD_KILL_S_LO)
  1215. ;
  1216. else if (est->rendstatus & PDRAW_INTERLACE)
  1217. DrawAllSpritesInterlace(0, sh);
  1218. else if (sprited[1] & SPRL_HAVE_LO)
  1219. DrawAllSprites(sprited, 0, sh, est);
  1220. /* - layer B hi - */
  1221. if (!(pvid->debug_p & PVD_KILL_B) && HighCacheB[0])
  1222. DrawTilesFromCache(HighCacheB, sh, maxw, est);
  1223. /* - layer A hi - */
  1224. if (pvid->debug_p & PVD_KILL_A)
  1225. ;
  1226. else if (hvwind == 1)
  1227. DrawWindow(0, maxcells>>1, 1, sh, est);
  1228. else if (hvwind == 2) {
  1229. if (HighCacheA[0])
  1230. DrawTilesFromCache(HighCacheA, sh, (win&0x80) ? edge<<4 : maxw, est);
  1231. DrawWindow((win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 1, sh, est);
  1232. } else
  1233. if (HighCacheA[0])
  1234. DrawTilesFromCache(HighCacheA, sh, maxw, est);
  1235. /* - sprites hi - */
  1236. if (pvid->debug_p & PVD_KILL_S_HI)
  1237. ;
  1238. else if (est->rendstatus & PDRAW_INTERLACE)
  1239. DrawAllSpritesInterlace(1, sh);
  1240. // have sprites without layer pri bit ontop of sprites with that bit
  1241. else if ((sprited[1] & 0xd0) == 0xd0 && (PicoIn.opt & POPT_ACC_SPRITES))
  1242. DrawSpritesHiAS(sprited, sh);
  1243. else if (sh && (sprited[1] & SPRL_MAY_HAVE_OP))
  1244. DrawSpritesSHi(sprited, est);
  1245. else if (sprited[1] & SPRL_HAVE_HI)
  1246. DrawAllSprites(sprited, 1, 0, est);
  1247. if (pvid->debug_p & PVD_FORCE_B)
  1248. DrawTilesFromCacheForced(HighCacheB);
  1249. else if (pvid->debug_p & PVD_FORCE_A)
  1250. DrawTilesFromCacheForced(HighCacheA);
  1251. #if 0
  1252. {
  1253. int *c, a, b;
  1254. for (a = 0, c = HighCacheA; *c; c++, a++);
  1255. for (b = 0, c = HighCacheB; *c; c++, b++);
  1256. printf("%i:%03i: a=%i, b=%i\n", Pico.m.frame_count,
  1257. Pico.est.DrawScanline, a, b);
  1258. }
  1259. #endif
  1260. return 0;
  1261. }
  1262. // MUST be called every frame
  1263. PICO_INTERNAL void PicoFrameStart(void)
  1264. {
  1265. int offs = 8, lines = 224;
  1266. int dirty = ((Pico.est.rendstatus & PDRAW_SONIC_MODE) || Pico.m.dirtyPal);
  1267. // prepare to do this frame
  1268. Pico.est.rendstatus = 0;
  1269. if ((Pico.video.reg[12] & 6) == 6)
  1270. Pico.est.rendstatus |= PDRAW_INTERLACE; // interlace mode
  1271. if (!(Pico.video.reg[12] & 1))
  1272. Pico.est.rendstatus |= PDRAW_32_COLS;
  1273. if (Pico.video.reg[1] & 8) {
  1274. offs = 0;
  1275. lines = 240;
  1276. }
  1277. if (Pico.est.rendstatus != rendstatus_old || lines != rendlines) {
  1278. rendlines = lines;
  1279. // mode_change() might reset rendstatus_old by calling SetColorFormat
  1280. emu_video_mode_change((lines == 240) ? 0 : 8,
  1281. lines, (Pico.video.reg[12] & 1) ? 0 : 1);
  1282. rendstatus_old = Pico.est.rendstatus;
  1283. }
  1284. Pico.est.HighCol = HighColBase + offs * HighColIncrement;
  1285. Pico.est.DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement;
  1286. Pico.est.DrawScanline = 0;
  1287. skip_next_line = 0;
  1288. if (FinalizeLine == FinalizeLine8bit) {
  1289. // make a backup of the current palette in case Sonic mode is detected later
  1290. Pico.est.SonicPalCount = 0;
  1291. Pico.m.dirtyPal = (dirty ? 2 : 0); // mark as dirty but already copied
  1292. blockcpy(Pico.est.SonicPal, PicoMem.cram, 0x40*2);
  1293. }
  1294. if (PicoIn.opt & POPT_ALT_RENDERER)
  1295. return;
  1296. PrepareSprites(1);
  1297. }
  1298. static void DrawBlankedLine(int line, int offs, int sh, int bgc)
  1299. {
  1300. if (PicoScanBegin != NULL)
  1301. PicoScanBegin(line + offs);
  1302. BackFill(bgc, sh, &Pico.est);
  1303. if (FinalizeLine != NULL)
  1304. FinalizeLine(sh, line, &Pico.est);
  1305. if (PicoScanEnd != NULL)
  1306. PicoScanEnd(line + offs);
  1307. Pico.est.HighCol += HighColIncrement;
  1308. Pico.est.DrawLineDest = (char *)Pico.est.DrawLineDest + DrawLineDestIncrement;
  1309. }
  1310. static void PicoLine(int line, int offs, int sh, int bgc)
  1311. {
  1312. int skip = 0;
  1313. if (skip_next_line > 0) {
  1314. skip_next_line--;
  1315. return;
  1316. }
  1317. Pico.est.DrawScanline = line;
  1318. if (PicoScanBegin != NULL)
  1319. skip = PicoScanBegin(line + offs);
  1320. if (skip) {
  1321. skip_next_line = skip - 1;
  1322. return;
  1323. }
  1324. if (Pico.video.debug_p & (PVD_FORCE_A | PVD_FORCE_B))
  1325. bgc = 0x3f;
  1326. // Draw screen:
  1327. BackFill(bgc, sh, &Pico.est);
  1328. if (Pico.video.reg[1]&0x40)
  1329. DrawDisplay(sh);
  1330. if (FinalizeLine != NULL)
  1331. FinalizeLine(sh, line, &Pico.est);
  1332. if (PicoScanEnd != NULL)
  1333. skip_next_line = PicoScanEnd(line + offs);
  1334. Pico.est.HighCol += HighColIncrement;
  1335. Pico.est.DrawLineDest = (char *)Pico.est.DrawLineDest + DrawLineDestIncrement;
  1336. }
  1337. void PicoDrawSync(int to, int blank_last_line)
  1338. {
  1339. int line, offs = 0;
  1340. int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight?
  1341. int bgc = Pico.video.reg[7];
  1342. pprof_start(draw);
  1343. if (rendlines != 240) {
  1344. offs = 8;
  1345. if (to > 223)
  1346. to = 223;
  1347. }
  1348. for (line = Pico.est.DrawScanline; line < to; line++)
  1349. PicoLine(line, offs, sh, bgc);
  1350. // last line
  1351. if (line <= to)
  1352. {
  1353. if (blank_last_line)
  1354. DrawBlankedLine(line, offs, sh, bgc);
  1355. else PicoLine(line, offs, sh, bgc);
  1356. line++;
  1357. }
  1358. Pico.est.DrawScanline = line;
  1359. pprof_end(draw);
  1360. }
  1361. // also works for fast renderer
  1362. void PicoDrawUpdateHighPal(void)
  1363. {
  1364. struct PicoEState *est = &Pico.est;
  1365. if (Pico.m.dirtyPal) {
  1366. int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight?
  1367. if ((PicoIn.opt & POPT_ALT_RENDERER) | (est->rendstatus & PDRAW_SONIC_MODE))
  1368. sh = 0; // no s/h support
  1369. if (FinalizeLine == FinalizeLine8bit)
  1370. PicoDoHighPal555_8bit(sh, 0, est);
  1371. else
  1372. PicoDoHighPal555(sh, 0, est);
  1373. // cover for sprite priority bits if not in s/h or sonic mode
  1374. if (!sh && !(est->rendstatus & PDRAW_SONIC_MODE)) {
  1375. blockcpy(est->HighPal+0x40, est->HighPal, 0x40*2);
  1376. blockcpy(est->HighPal+0x80, est->HighPal, 0x80*2);
  1377. }
  1378. }
  1379. }
  1380. void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode)
  1381. {
  1382. switch (which)
  1383. {
  1384. case PDF_8BIT:
  1385. FinalizeLine = FinalizeLine8bit;
  1386. break;
  1387. case PDF_RGB555:
  1388. if ((PicoIn.AHW & PAHW_32X) && use_32x_line_mode)
  1389. FinalizeLine = FinalizeLine32xRGB555;
  1390. else
  1391. FinalizeLine = FinalizeLine555;
  1392. break;
  1393. default:
  1394. FinalizeLine = NULL;
  1395. break;
  1396. }
  1397. if (PicoIn.AHW & PAHW_32X)
  1398. PicoDrawSetOutFormat32x(which, use_32x_line_mode);
  1399. PicoDrawSetOutputMode4(which);
  1400. rendstatus_old = -1;
  1401. }
  1402. void PicoDrawSetOutBufMD(void *dest, int increment)
  1403. {
  1404. if (dest != NULL) {
  1405. DrawLineDestBase = dest;
  1406. DrawLineDestIncrement = increment;
  1407. Pico.est.DrawLineDest = DrawLineDestBase + Pico.est.DrawScanline * increment;
  1408. }
  1409. else {
  1410. DrawLineDestBase = DefOutBuff;
  1411. DrawLineDestIncrement = 0;
  1412. Pico.est.DrawLineDest = DefOutBuff;
  1413. }
  1414. }
  1415. // note: may be called on the middle of frame
  1416. void PicoDrawSetOutBuf(void *dest, int increment)
  1417. {
  1418. if (PicoIn.AHW & PAHW_32X)
  1419. PicoDrawSetOutBuf32X(dest, increment);
  1420. else
  1421. PicoDrawSetOutBufMD(dest, increment);
  1422. }
  1423. void PicoDrawSetInternalBuf(void *dest, int increment)
  1424. {
  1425. if (dest != NULL) {
  1426. HighColBase = dest;
  1427. HighColIncrement = increment;
  1428. Pico.est.HighCol = HighColBase + Pico.est.DrawScanline * increment;
  1429. }
  1430. else {
  1431. HighColBase = DefHighCol;
  1432. HighColIncrement = 0;
  1433. Pico.est.HighCol = DefHighCol;
  1434. }
  1435. }
  1436. void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num))
  1437. {
  1438. PicoScanBegin = NULL;
  1439. PicoScanEnd = NULL;
  1440. PicoScan32xBegin = NULL;
  1441. PicoScan32xEnd = NULL;
  1442. if ((PicoIn.AHW & PAHW_32X) && FinalizeLine != FinalizeLine32xRGB555) {
  1443. PicoScan32xBegin = begin;
  1444. PicoScan32xEnd = end;
  1445. }
  1446. else {
  1447. PicoScanBegin = begin;
  1448. PicoScanEnd = end;
  1449. }
  1450. }
  1451. void PicoDrawInit(void)
  1452. {
  1453. Pico.est.DrawLineDest = DefOutBuff;
  1454. Pico.est.HighCol = HighColBase;
  1455. Pico.est.HighPreSpr = HighPreSpr;
  1456. rendstatus_old = -1;
  1457. }
  1458. // vim:ts=2:sw=2:expandtab