draw_arm.S 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237
  1. /*
  2. * assembly optimized versions of most funtions from draw.c
  3. * (C) notaz, 2006-2010,2017
  4. * (C) kub, 2020
  5. *
  6. * This work is licensed under the terms of MAME license.
  7. * See COPYING file in the top-level directory.
  8. *
  9. * this is highly specialized, be careful if changing related C code!
  10. *
  11. * NB only does RGB565 output, BGR isn't supported
  12. */
  13. #include "pico_int_offs.h"
  14. .extern DrawStripInterlace
  15. .equ PDRAW_SPRITES_MOVED, (1<<0)
  16. .equ PDRAW_WND_DIFF_PRIO, (1<<1)
  17. .equ PDRAW_PARSE_SPRITES, (1<<2)
  18. .equ PDRAW_DIRTY_SPRITES, (1<<4)
  19. .equ PDRAW_PLANE_HI_PRIO, (1<<6)
  20. .equ PDRAW_SHHI_DONE, (1<<7)
  21. @ helpers
  22. .macro add_c24 d s c
  23. add \d, \s, #(\c & 0x00ff00)
  24. .if \c & 0x0000ff
  25. add \d, \d, #(\c & 0x0000ff)
  26. .endif
  27. .if \c & 0xff0000
  28. add \d, \d, #(\c & 0xff0000)
  29. .endif
  30. .endm
  31. .macro TilePixel pat lsrr offs
  32. .if !\lsrr
  33. ands r4, \pat, r2
  34. .else
  35. ands r4, \pat, r2, lsr #\lsrr
  36. .endif
  37. orrne r4, r3, r4
  38. strneb r4, [r1,#\offs]
  39. .endm
  40. @ TileNorm (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
  41. .macro TileNorm pat
  42. TilePixel \pat, 12, 0 @ #0x0000f000
  43. TilePixel \pat, 8, 1 @ #0x00000f00
  44. TilePixel \pat, 4, 2 @ #0x000000f0
  45. TilePixel \pat, 0, 3 @ #0x0000000f
  46. TilePixel \pat, 28, 4 @ #0xf0000000
  47. TilePixel \pat, 24, 5 @ #0x0f000000
  48. TilePixel \pat, 20, 6 @ #0x00f00000
  49. TilePixel \pat, 16, 7 @ #0x000f0000
  50. .endm
  51. @ TileFlip (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
  52. .macro TileFlip pat
  53. TilePixel \pat, 16, 0 @ #0x000f0000
  54. TilePixel \pat, 20, 1 @ #0x00f00000
  55. TilePixel \pat, 24, 2 @ #0x0f000000
  56. TilePixel \pat, 28, 3 @ #0xf0000000
  57. TilePixel \pat, 0, 4 @ #0x0000000f
  58. TilePixel \pat, 4, 5 @ #0x000000f0
  59. TilePixel \pat, 8, 6 @ #0x00000f00
  60. TilePixel \pat, 12, 7 @ #0x0000f000
  61. .endm
  62. @ shadow/hilight mode
  63. @
  64. .macro TilePixelNonSH pat lsrr offs
  65. .if !\lsrr
  66. ands r4, \pat, r2
  67. .else
  68. ands r4, \pat, r2, lsr #\lsrr
  69. .endif
  70. beq 0f
  71. cmp r4, #0xe
  72. orr r4, r3, r4
  73. biceq r4, #0x80
  74. strb r4, [r1,#\offs]
  75. 0:
  76. .endm
  77. @ TileNormNonSH (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
  78. .macro TileNormNonSH pat
  79. TilePixelNonSH \pat, 12, 0 @ #0x0000f000
  80. TilePixelNonSH \pat, 8, 1 @ #0x00000f00
  81. TilePixelNonSH \pat, 4, 2 @ #0x000000f0
  82. TilePixelNonSH \pat, 0, 3 @ #0x0000000f
  83. TilePixelNonSH \pat, 28, 4 @ #0xf0000000
  84. TilePixelNonSH \pat, 24, 5 @ #0x0f000000
  85. TilePixelNonSH \pat, 20, 6 @ #0x00f00000
  86. TilePixelNonSH \pat, 16, 7 @ #0x000f0000
  87. .endm
  88. @ TileFlipNonSH (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
  89. .macro TileFlipNonSH pat
  90. TilePixelNonSH \pat, 16, 0 @ #0x000f0000
  91. TilePixelNonSH \pat, 20, 1 @ #0x00f00000
  92. TilePixelNonSH \pat, 24, 2 @ #0x0f000000
  93. TilePixelNonSH \pat, 28, 3 @ #0xf0000000
  94. TilePixelNonSH \pat, 0, 4 @ #0x0000000f
  95. TilePixelNonSH \pat, 4, 5 @ #0x000000f0
  96. TilePixelNonSH \pat, 8, 6 @ #0x00000f00
  97. TilePixelNonSH \pat, 12, 7 @ #0x0000f000
  98. .endm
  99. @ this one is for hi priority layer
  100. .macro TilePixelShHP lsrr offs
  101. .if !\lsrr
  102. ands r4, r12, r2
  103. .else
  104. ands r4, r12, r2, lsr #\lsrr
  105. .endif
  106. ldreqb r4, [r1,#\offs]
  107. orrne r4, r3, r4
  108. andeq r4, r4, #0x7f
  109. strb r4, [r1,#\offs]
  110. .endm
  111. @ TileNormShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: register with helper pattern 0xf, touches r3 high bits
  112. .macro TileNormShHP
  113. TilePixelShHP 12, 0 @ #0x0000f000
  114. TilePixelShHP 8, 1 @ #0x00000f00
  115. TilePixelShHP 4, 2 @ #0x000000f0
  116. TilePixelShHP 0, 3 @ #0x0000000f
  117. TilePixelShHP 28, 4 @ #0xf0000000
  118. TilePixelShHP 24, 5 @ #0x0f000000
  119. TilePixelShHP 20, 6 @ #0x00f00000
  120. TilePixelShHP 16, 7 @ #0x000f0000
  121. .endm
  122. @ TileFlipShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
  123. .macro TileFlipShHP
  124. TilePixelShHP 16, 0 @ #0x000f0000
  125. TilePixelShHP 20, 1 @ #0x00f00000
  126. TilePixelShHP 24, 2 @ #0x0f000000
  127. TilePixelShHP 28, 3 @ #0xf0000000
  128. TilePixelShHP 0, 4 @ #0x0000000f
  129. TilePixelShHP 4, 5 @ #0x000000f0
  130. TilePixelShHP 8, 6 @ #0x00000f00
  131. TilePixelShHP 12, 7 @ #0x0000f000
  132. .endm
  133. @ TileSingleSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx; r12: helper pattern 0xf
  134. .macro TileSingleSh
  135. tst r0, #1 @ not aligned?
  136. mov r7, #0x008000
  137. orr r7, r7, #0x80
  138. ldrneb r4, [r1], #1
  139. ldreqh r4, [r1], #2 @ 1ci
  140. ldrh r12, [r1], #2
  141. orr r4, r4, r7
  142. strneb r4, [r1, #-3]
  143. streqh r4, [r1, #-4]
  144. ldrh r4, [r1], #2
  145. orr r12, r12, r7
  146. strh r12, [r1, #-4]
  147. ldrh r12, [r1], #2
  148. orr r4, r4, r7
  149. strh r4, [r1, #-4]
  150. ldrneb r4, [r1]
  151. orr r12, r12, r7
  152. strh r12, [r1, #-2]
  153. orrne r4, r4, r7
  154. strneb r4, [r1], #1
  155. mov r12, #0xf
  156. .endm
  157. @ TileSingleHi (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
  158. .macro TileSingleHi
  159. tst r1, #1 @ not aligned?
  160. mov r7, #0x004000
  161. orr r7, r7, #0x40
  162. ldrneb r4, [r1], #1
  163. ldreqh r4, [r1], #2 @ 1ci
  164. ldrh r12, [r1], #2
  165. orr r4, r4, r7
  166. strneb r4, [r1, #-3]
  167. streqh r4, [r1, #-4]
  168. ldrh r4, [r1], #2
  169. orr r12, r12, r7
  170. strh r12, [r1, #-4]
  171. ldrh r12, [r1], #2
  172. orr r4, r4, r7
  173. strh r4, [r1, #-4]
  174. ldrneb r4, [r1]
  175. orr r12, r12, r7
  176. strh r12, [r1, #-2]
  177. orrne r4, r4, r7
  178. strneb r4, [r1], #1
  179. mov r12, #0xf
  180. .endm
  181. .macro TileDoShGenPixel shift ofs
  182. .if \shift
  183. ands r4, r12, r2, lsr #\shift
  184. .else
  185. ands r4, r12, r2
  186. .endif
  187. beq 0f
  188. cmp r4, #0xe
  189. ldrgeb r7, [r1,#\ofs]
  190. orrlt r7, r3, r4 @ normal
  191. subge r4, r4, #1
  192. orrge r7, r7, r4, lsl #6
  193. strb r7, [r1,#\ofs]
  194. 0:
  195. .endm
  196. @ TileFlipSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
  197. .macro TileFlipSh
  198. TileDoShGenPixel 16, 0 @ #0x000f0000
  199. TileDoShGenPixel 20, 1 @ #0x00f00000
  200. TileDoShGenPixel 24, 2 @ #0x0f000000
  201. TileDoShGenPixel 28, 3 @ #0xf0000000
  202. TileDoShGenPixel 0, 4 @ #0x0000000f
  203. TileDoShGenPixel 4, 5 @ #0x000000f0
  204. TileDoShGenPixel 8, 6 @ #0x00000f00
  205. TileDoShGenPixel 12, 7 @ #0x0000f000
  206. .endm
  207. @ TileNormSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
  208. .macro TileNormSh
  209. TileDoShGenPixel 12, 0 @ #0x0000f000
  210. TileDoShGenPixel 8, 1 @ #0x00000f00
  211. TileDoShGenPixel 4, 2 @ #0x000000f0
  212. TileDoShGenPixel 0, 3 @ #0x0000000f
  213. TileDoShGenPixel 28, 4 @ #0xf0000000
  214. TileDoShGenPixel 24, 5 @ #0x0f000000
  215. TileDoShGenPixel 20, 6 @ #0x00f00000
  216. TileDoShGenPixel 16, 7 @ #0x000f0000
  217. .endm
  218. .macro TileDoShGenPixel_markop shift ofs
  219. .if \shift
  220. ands r4, r12, r2, lsr #\shift
  221. .else
  222. ands r4, r12, r2
  223. .endif
  224. beq 0f
  225. cmp r4, #0xe
  226. ldrgeb r4, [r1,#\ofs]
  227. orrlt r4, r3, r4
  228. orrge r4, r4, #0x40
  229. strb r4, [r1,#\ofs]
  230. 0:
  231. .endm
  232. .macro TileFlipSh_markop
  233. TileDoShGenPixel_markop 16, 0 @ #0x000f0000
  234. TileDoShGenPixel_markop 20, 1 @ #0x00f00000
  235. TileDoShGenPixel_markop 24, 2 @ #0x0f000000
  236. TileDoShGenPixel_markop 28, 3 @ #0xf0000000
  237. TileDoShGenPixel_markop 0, 4 @ #0x0000000f
  238. TileDoShGenPixel_markop 4, 5 @ #0x000000f0
  239. TileDoShGenPixel_markop 8, 6 @ #0x00000f00
  240. TileDoShGenPixel_markop 12, 7 @ #0x0000f000
  241. .endm
  242. .macro TileNormSh_markop
  243. TileDoShGenPixel_markop 12, 0 @ #0x0000f000
  244. TileDoShGenPixel_markop 8, 1 @ #0x00000f00
  245. TileDoShGenPixel_markop 4, 2 @ #0x000000f0
  246. TileDoShGenPixel_markop 0, 3 @ #0x0000000f
  247. TileDoShGenPixel_markop 28, 4 @ #0xf0000000
  248. TileDoShGenPixel_markop 24, 5 @ #0x0f000000
  249. TileDoShGenPixel_markop 20, 6 @ #0x00f00000
  250. TileDoShGenPixel_markop 16, 7 @ #0x000f0000
  251. .endm
  252. .macro TileDoShGenPixel_onlyop_lp shift ofs
  253. .if \shift
  254. ands r7, r12, r2, lsr #\shift
  255. .else
  256. ands r7, r12, r2
  257. .endif
  258. ldrneb r4, [r1,#\ofs]
  259. cmp r7, #0xe
  260. blt 0f
  261. tst r4, #0x40
  262. bicne r4, r4, #0x40
  263. subne r7, r7, #1
  264. orrne r4, r4, r7, lsl #6
  265. strneb r4, [r1,#\ofs]
  266. 0:
  267. .endm
  268. .macro TileFlipSh_onlyop_lp
  269. TileDoShGenPixel_onlyop_lp 16, 0 @ #0x000f0000
  270. TileDoShGenPixel_onlyop_lp 20, 1 @ #0x00f00000
  271. TileDoShGenPixel_onlyop_lp 24, 2 @ #0x0f000000
  272. TileDoShGenPixel_onlyop_lp 28, 3 @ #0xf0000000
  273. TileDoShGenPixel_onlyop_lp 0, 4 @ #0x0000000f
  274. TileDoShGenPixel_onlyop_lp 4, 5 @ #0x000000f0
  275. TileDoShGenPixel_onlyop_lp 8, 6 @ #0x00000f00
  276. TileDoShGenPixel_onlyop_lp 12, 7 @ #0x0000f000
  277. .endm
  278. .macro TileNormSh_onlyop_lp
  279. TileDoShGenPixel_onlyop_lp 12, 0 @ #0x0000f000
  280. TileDoShGenPixel_onlyop_lp 8, 1 @ #0x00000f00
  281. TileDoShGenPixel_onlyop_lp 4, 2 @ #0x000000f0
  282. TileDoShGenPixel_onlyop_lp 0, 3 @ #0x0000000f
  283. TileDoShGenPixel_onlyop_lp 28, 4 @ #0xf0000000
  284. TileDoShGenPixel_onlyop_lp 24, 5 @ #0x0f000000
  285. TileDoShGenPixel_onlyop_lp 20, 6 @ #0x00f00000
  286. TileDoShGenPixel_onlyop_lp 16, 7 @ #0x000f0000
  287. .endm
  288. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  289. @ struct TileStrip
  290. @ {
  291. @ int nametab; // 0x00
  292. @ int line; // 0x04
  293. @ int hscroll; // 0x08
  294. @ int xmask; // 0x0C
  295. @ int *hc; // 0x10 (pointer to cache buffer)
  296. @ int cells; // 0x14
  297. @ };
  298. @ void DrawLayer(int lflags, int *hcache, int cellskip, int maxcells,
  299. @ struct PicoEState *est)
  300. .global DrawLayer
  301. DrawLayer:
  302. ldr r12, [sp] @ est
  303. stmfd sp!, {r4-r11,lr}
  304. ldr r11, [r12, #OFS_EST_Pico]
  305. mov r8, #1
  306. ldrb r7, [r11, #OFS_Pico_video_reg+16] @ ??vv??hh
  307. mov r6, r1 @ hcache
  308. orr r9, r3, r0, lsl #29 @ r9=force[31]|sh[30]|plane[29]
  309. orr r9, r9, r2, lsl #8 @ |cellskip[15:8]|maxcells[7:0] (tmp)
  310. mov r1, r7, lsl #4
  311. orr r1, r1, #0x00ff
  312. and r10, r7, #3
  313. cmp r10, #1
  314. biclt r1, r1, #0xfc00
  315. biceq r1, r1, #0xfe00
  316. cmp r10, #2
  317. moveq r1, #0x0007
  318. movgt r1, #0x00ff @ r1=ymask=(height<<8)|0xff; ...; // Y Mask in pixels
  319. cmp r10, #2
  320. addlt r10, r10, #5
  321. moveq r10, #5
  322. movgt r10, #7 @ r10=shift[width] (5,6,5,7)
  323. ldr r2, [r12, #OFS_EST_DrawScanline]
  324. ldr lr, [r12, #OFS_EST_PicoMem_vram]
  325. @ Find name table:
  326. ands r0, r0, #1
  327. ldreqb r12, [r11, #OFS_Pico_video_reg+2]
  328. ldrneb r12, [r11, #OFS_Pico_video_reg+4]
  329. @ calculate xmask:
  330. mov r5, r8, lsl r10
  331. sub r5, r5, #1 @ r5=xmask
  332. moveq r12, r12, lsl #10
  333. movne r12, r12, lsl #13
  334. and r12, r12, #(7<<13) @ r12=(ts->nametab<<1) (halfword compliant)
  335. ldrh r8, [r11, #OFS_Pico_video_reg+12]
  336. ldrb r7, [r11, #OFS_Pico_video_reg+11]
  337. mov r4, r8, lsr #8 @ pvid->reg[13]
  338. mov r4, r4, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords)
  339. ands r3, r7, #0x03
  340. beq 0f
  341. cmp r3, #2
  342. mov r3, r2, lsl #2 @ htab+=DrawScanline<<1; // Offset by line
  343. biceq r3, #0x1f @ htab&=~0xf; // Offset by tile
  344. andlt r3, #0x1f
  345. add r4, r4, r3
  346. 0: add r4, r4, r0, lsl #1 @ htab+=plane
  347. bic r4, r4, #0x00ff0000 @ just in case
  348. ldrh r3, [lr, r4] @ r3=hscroll
  349. tst r7, #4
  350. bne .DrawStrip_vsscroll
  351. @ Get vertical scroll value:
  352. add_c24 r7, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)
  353. ldr r7, [r7]
  354. tst r8, #2
  355. tstne r8, #4
  356. bne .DrawStrip_interlace
  357. tst r0, r0
  358. moveq r7, r7, lsl #16
  359. mov r7, r7, lsr #16
  360. @ Find the line in the name table
  361. add r2, r2, r7
  362. and r2, r2, r1
  363. mov r4, r2, lsr #3
  364. add r10, r10, #1 @ shift[width]++
  365. add r12, r12, r4, lsl r10 @ nametab+=(ts.line>>3)<<shift[width];
  366. @ ldmia r0, {r1,r2,r3,r5,r6,r9} @ r2=line, r3=ts->hscroll, r5=ts->xmask, r6=ts->hc, r9=ts->cells
  367. and r10,r2, #7
  368. mov r10,r10, lsl #1 @ r10=ty=(ts->line&7)<<1;
  369. orr r10,r10, r9, lsl #24
  370. rsb r8, r3, #0
  371. mov r8, r8, lsr #3 @ r8=tilex=(-ts->hscroll)>>3
  372. sub r1, r3, #1
  373. and r1, r1, #7
  374. add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1
  375. movs r3, r9, lsl #1 @ (force[31]|sh[30]) << 1
  376. mov r3, #0
  377. orrmi r10,r10, #1<<23 @ r10=cells[31:24]|sh[23]|hi_not_empty[22]
  378. @ orrcc r10,r10, #1<<20 @ |had_output[21]|!force[20]|ty[15:0]
  379. movmi r3, #0x80 @ default to shadowed pal on sh mode
  380. cmp r7, #8
  381. addne r10,r10, #0x01000000 @ we will loop cells+1 times if there is scroll
  382. and r9, r9, #0xff00
  383. add r8, r8, r9, lsr #8 @ tilex+=cellskip
  384. add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
  385. sub r10,r10,r9, lsl #16 @ cells-=cellskip
  386. @ cache some stuff to avoid mem access
  387. ldr r11,[sp, #9*4] @ est
  388. mov r0, #0xf
  389. ldr r11,[r11, #OFS_EST_HighCol]
  390. mvn r9, #0 @ r9=prevcode=-1
  391. add r1, r11, r7 @ r1=pdest
  392. @ r10=cells[31:24]|sh[23]|hi_not_empty[22]|had_output[21]|!force[20]|ty[15:0]
  393. @ r1=pd+dx r2=pack r3=pal r5=xmask r6=hc r8=tilex r9=prevcode r11=HighCol r12=nametab lr=vram
  394. @ r4 & r7 are scratch in this loop
  395. .dsloop_subr1:
  396. sub r1, r1, #8
  397. .dsloop: @ 40-41 times
  398. subs r10,r10, #0x01000000
  399. bmi .dsloop_exit
  400. .dsloop_enter:
  401. and r7, r5, r8
  402. add r7, lr, r7, lsl #1 @ Pico.vram+((tilex&ts->xmask) as halfwords)
  403. ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)
  404. add r1, r1, #8
  405. add r8, r8, #1
  406. cmp r7, r9
  407. beq .DrawStrip_samecode @ we know stuff about this tile already
  408. mov r9, r7 @ remember code
  409. movs r2, r9, lsl #20 @ if (code&0x1000)
  410. mov r2, r2, lsl #1
  411. add r2, r2, r10, lsl #17
  412. mov r2, r2, lsr #17
  413. eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
  414. ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
  415. .DrawStrip_samecode:
  416. tst r9, #0x8000
  417. @ tstne r10, #1<<20 @ !force[20]
  418. bne .DrawStrip_hiprio
  419. orr r10, r10, #1<<21 @ seen non hi-prio tile
  420. tst r2, r2
  421. beq .dsloop @ tileline blank
  422. bic r7, r3, #0x7f
  423. and r3, r9, #0x6000
  424. add r3, r7, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
  425. cmp r2, r2, ror #4
  426. beq .DrawStrip_SingleColor @ tileline singlecolor
  427. tst r9, #0x0800
  428. bne .DrawStrip_TileFlip
  429. @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
  430. .DrawStrip_TileNorm:
  431. TileNorm r0
  432. b .dsloop
  433. .DrawStrip_TileFlip:
  434. TileFlip r0
  435. b .dsloop
  436. .DrawStrip_SingleColor:
  437. and r4, r2, #0xf
  438. orr r4, r3, r4
  439. orr r4, r4, r4, lsl #8
  440. tst r1, #1 @ not aligned?
  441. strneb r4, [r1], #1
  442. streqh r4, [r1], #2
  443. strh r4, [r1], #2
  444. strh r4, [r1], #2
  445. strh r4, [r1], #2
  446. strneb r4, [r1], #1 @ have a remaining unaligned pixel?
  447. b .dsloop_subr1
  448. .DrawStrip_hiprio:
  449. tst r10, #(1<<23) @ sh[23]
  450. tsteq r2, r2 @ if (!sh[23] && code==blank) continue
  451. beq .dsloop
  452. @ orr r10, r10, #1<<22 @ hi_not_empty[22]
  453. sub r7, r1, r11
  454. orr r7, r9, r7, lsl #16
  455. orr r7, r7, r10, lsl #25 @ (ty<<25)
  456. tst r9, #0x1000
  457. eorne r7, r7, #0xe<<25 @ if(code&0x1000) cval^=0xe<<25;
  458. str r7, [r6], #4 @ cache hi priority tile code
  459. str r2, [r6], #4 @ cache hi priority tile data
  460. b .dsloop
  461. .dsloop_exit:
  462. tst r10, #1<<21 @ seen non hi-prio tile
  463. ldr r1, [sp, #9*4] @ est
  464. mov r0, #0
  465. ldreq r2, [r1, #OFS_EST_rendstatus]
  466. str r0, [r6] @ terminate the cache list
  467. orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles
  468. streq r2, [r1, #OFS_EST_rendstatus]
  469. ldmfd sp!, {r4-r11,pc}
  470. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  471. .DrawStrip_vsscroll:
  472. tst r8, #1 @ if h40: lflags |= 0x10000
  473. orrne r0, r0, #0x10000
  474. rsb r8, r3, #0
  475. mov r8, r8, lsr #3 @ r8=tilex=(-ts->hscroll)>>3
  476. bic r8, r8, #0x3fc00000
  477. orr r8, r8, r5, lsl #25 @ r8=(xmask[31:25]|had_output[24]|!force[23]|tilex[21:0])
  478. ldr r11, [sp, #9*4] @ est
  479. orr r5, r1, r10, lsl #24
  480. ldr r4, [r11, #OFS_EST_DrawScanline]
  481. sub r1, r3, #1
  482. orr r5, r5, r4, lsl #16 @ r5=(shift_width[31:24]|scanline[23:16]|ymask[15:0])
  483. and r1, r1, #7
  484. add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1
  485. mov r10,r9, lsl #16
  486. orr r10,r10, #0xff000000 @ will be adjusted on entering loop
  487. tst r0, #1
  488. orrne r10,r10, #0x8000
  489. tst r3, #0x0f @ hscroll & 0x0f?
  490. beq 0f
  491. eor r3, r3, r7
  492. sub r10,r10, #1<<24 @ cell-- // start from negative for hscroll
  493. tst r3, #0x08
  494. subne r10,r10, #1<<16 @ cells--
  495. subne r10,r10, #1<<24 @ cell-- // even more negative
  496. add_c24 r1, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)
  497. tst r0, #0x10000 @ h40?
  498. ldrne r3, [r1, #0x00] @ r3=vsram[0x00..0x01]
  499. ldreq r3, [r1, #0x40] @ r3=vsram[0x20..0x21]
  500. str r3, [r1, #0x7c] @ vsram[0x3e..0x3f]=r3
  501. 0:
  502. tst r9, #1<<30
  503. mov r3, #0
  504. orrne r10,r10, #1<<23 @ r10=(cell[31:24]|sh[23]|hi_not_empty[22]|cells_max[21:16]|plane[15]|ty[14:0])
  505. movne r3, #0x80 @ default to shadowed pal on sh mode
  506. @ tst r9, #1<<31
  507. @ orreq r8, r8, #1<<23
  508. and r9, r9, #0xff00
  509. add r8, r8, r9, lsr #8 @ tilex+=cellskip
  510. add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
  511. add r10,r10,r9, lsl #16 @ cell+=cellskip
  512. @ cache some stuff to avoid mem access
  513. ldr r11,[sp, #9*4] @ est
  514. mov r0, #0xf
  515. ldr r11,[r11, #OFS_EST_HighCol]
  516. mvn r9, #0 @ r9=prevcode=-1
  517. add r1, r11, r7 @ r1=pdest
  518. @ r10=cells[31:24]|sh[23]|hi_not_empty[22]|cells_max[21:16]|plane[15]|ty[14:0]
  519. @ r8=xmask[31:25]|had_output[24]|!force[23]|tilex[21:0]
  520. @ r5=shift_width[31:24]|scanline[23:16]|ymask[15:0]
  521. @ r3=nametabadd[31:16]|must_be_0[15:8]|pal[7:0]
  522. @ r1=pd+dx r2=pack r6=hc r9=prevcode r11=HighCol r12=nametab lr=vram
  523. @ r4 & r7 are scratch in this loop
  524. @ need to calc new ty?
  525. lsls r7, r10, #7 @ (cell&1)?
  526. bmi .dsloop_vs_subr1
  527. @ calc offset and read tileline code to r7, also calc ty
  528. add_c24 r7, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)
  529. and r4, r10, #0x3e000000
  530. add r7, r7, r4, asr #23 @ vsram + ((cell&0x3e)<<1)
  531. tst r10,#0x8000 @ plane1?
  532. addne r7, r7, #2
  533. ldrh r7, [r7] @ r7=vscroll
  534. bic r10,r10,#0xff @ clear old ty
  535. and r4, r5, #0xff0000 @ scanline
  536. add r4, r4, r7, lsl #16 @ ... += vscroll
  537. and r4, r4, r5, lsl #16 @ ... &= ymask
  538. and r7, r4, #0x70000
  539. orr r10,r10,r7, lsr #15 @ new ty
  540. mov r4, r4, lsr #19
  541. mov r7, r5, lsr #24
  542. mov r4, r4, lsl r7 @ nametabadd
  543. and r3, r3, #0xff
  544. orr r3, r3, r4, lsl #16 @ r3=(nametabadd[31:16],pal[15:0])
  545. .dsloop_vs_subr1:
  546. sub r1, r1, #8
  547. .dsloop_vs: @ 40-41 times
  548. add r10,r10, #0x01000000
  549. and r4, r10, #0x003f0000
  550. cmp r4, r10, asr #8
  551. ble .dsloop_vs_exit
  552. @ need to calc new ty?
  553. lsls r7, r10, #7 @ (cell&1)?
  554. bmi 0f
  555. @ calc offset and read tileline code to r7, also calc ty
  556. add_c24 r7, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)
  557. and r4, r10, #0x3e000000
  558. add r7, r7, r4, asr #23 @ vsram + ((cell&0x3e)<<1)
  559. tst r10,#0x8000 @ plane1?
  560. addne r7, r7, #2
  561. ldrh r7, [r7] @ r7=vscroll
  562. bic r10,r10,#0xff @ clear old ty
  563. and r4, r5, #0xff0000 @ scanline
  564. add r4, r4, r7, lsl #16 @ ... += vscroll
  565. and r4, r4, r5, lsl #16 @ ... &= ymask
  566. and r7, r4, #0x70000
  567. orr r10,r10,r7, lsr #15 @ new ty
  568. mov r4, r4, lsr #19
  569. mov r7, r5, lsr #24
  570. mov r4, r4, lsl r7 @ nametabadd
  571. and r3, r3, #0xff
  572. orr r3, r3, r4, lsl #16 @ r3=(nametabadd[31:16],pal[15:0])
  573. 0:
  574. and r7, r8, r8, lsr #25
  575. add r7, lr, r7, lsl #1 @ PicoMem.vram+((tilex&ts->xmask) as halfwords)
  576. add r7, r7, r3, lsr #15
  577. ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)
  578. add r1, r1, #8
  579. add r8, r8, #1
  580. orr r7, r7, r10, lsl #24 @ code | (ty << 24)
  581. cmp r7, r9
  582. beq .DrawStrip_vs_samecode @ we know stuff about this tile already
  583. mov r9, r7 @ remember code
  584. movs r2, r9, lsl #20 @ if (code&0x1000)
  585. mov r2, r2, lsl #1
  586. add r2, r2, r10, lsl #17
  587. mov r2, r2, lsr #17
  588. eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
  589. ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
  590. .DrawStrip_vs_samecode:
  591. tst r9, #0x8000
  592. @ tstne r8, #1<<23 @ !force[23]
  593. bne .DrawStrip_vs_hiprio
  594. orr r8, r8, #(1<<24)@ seen non hi-prio tile
  595. tst r2, r2
  596. beq .dsloop_vs @ tileline blank
  597. bic r7, r3, #0x7f
  598. and r3, r9, #0x6000
  599. add r3, r7, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
  600. cmp r2, r2, ror #4
  601. beq .DrawStrip_vs_SingleColor @ tileline singlecolor
  602. tst r9, #0x0800
  603. bne .DrawStrip_vs_TileFlip
  604. @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
  605. .DrawStrip_vs_TileNorm:
  606. TileNorm r0
  607. b .dsloop_vs
  608. .DrawStrip_vs_TileFlip:
  609. TileFlip r0
  610. b .dsloop_vs
  611. .DrawStrip_vs_SingleColor:
  612. and r4, r2, #0xf
  613. orr r4, r3, r4
  614. orr r4, r4, r4, lsl #8
  615. tst r1, #1 @ not aligned?
  616. strneb r4, [r1], #1
  617. streqh r4, [r1], #2
  618. strh r4, [r1], #2
  619. strh r4, [r1], #2
  620. strh r4, [r1], #2
  621. strneb r4, [r1], #1 @ have a remaining unaligned pixel?
  622. b .dsloop_vs_subr1
  623. .DrawStrip_vs_hiprio:
  624. tst r10, #(1<<23) @ sh[23]
  625. tsteq r2, r2 @ if (!sh[23] && code==blank) continue
  626. beq .dsloop_vs
  627. @ orr r10, r10, #1<<22 @ hi_not_empty[22]
  628. sub r7, r1, r11
  629. orr r7, r9, r7, lsl #16
  630. orr r7, r7, r10, lsl #25 @ (ty<<25)
  631. tst r9, #0x1000
  632. eorne r7, r7, #7<<26 @ if(code&0x1000) cval^=7<<26;
  633. str r7, [r6], #4 @ cache hi priority tile code
  634. str r2, [r6], #4 @ cache hi priority tile data
  635. b .dsloop_vs
  636. .dsloop_vs_exit:
  637. tst r8, #(1<<24) @ seen non hi-prio tile
  638. ldr r1, [sp, #9*4] @ est
  639. mov r0, #0
  640. ldreq r2, [r1, #OFS_EST_rendstatus]
  641. str r0, [r6] @ terminate the cache list
  642. orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles
  643. streq r2, [r1, #OFS_EST_rendstatus]
  644. ldmfd sp!, {r4-r11,pc}
  645. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  646. @ interlace mode 2? Sonic 2?
  647. .DrawStrip_interlace:
  648. tst r0, r0
  649. movne r7, r7, lsr #16
  650. mov r7, r7, lsl #21
  651. @ Find the line in the name table
  652. add r2, r7, r2, lsl #22 @ r2=(vscroll+(DrawScanline<<1))<<21 (11 bits);
  653. orr r1, r1, #0x80000000
  654. and r2, r2, r1, ror #10 @ &((ymask<<1)|1)<<21;
  655. mov r2, r2, lsr #21
  656. mov r4, r2, lsr #4
  657. mov r12, r12, lsr #1 @ halfwords
  658. add r0, r12, r4, lsl r10 @ nametab+=(ts.line>>4)<<shift[width];
  659. and r9, r9, #0xff
  660. sub sp, sp, #6*4
  661. stmia sp, {r0,r2,r3,r5,r6,r9}
  662. mov r0, sp
  663. mov r1, r9, lsr #29
  664. bl DrawStripInterlace @ struct TileStrip *ts, int plane_sh
  665. add sp, sp, #6*4
  666. ldmfd sp!, {r4-r11,pc}
  667. .pool
  668. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  669. @ void BackFill(int reg7, int sh, struct PicoEState *est)
  670. .global BackFill
  671. BackFill:
  672. stmfd sp!, {r4-r9,lr}
  673. mov r0, r0, lsl #26
  674. ldr lr, [r2, #OFS_EST_HighCol]
  675. mov r0, r0, lsr #26
  676. add lr, lr, #8
  677. orr r0, r0, r1, lsl #7
  678. orr r0, r0, r0, lsl #8
  679. orr r0, r0, r0, lsl #16
  680. mov r1, r0
  681. mov r2, r0
  682. mov r3, r0
  683. mov r4, r0
  684. mov r5, r0
  685. mov r6, r0
  686. mov r7, r0
  687. @ go go go!
  688. stmia lr!, {r0-r7} @ 10*8*4
  689. stmia lr!, {r0-r7}
  690. stmia lr!, {r0-r7}
  691. stmia lr!, {r0-r7}
  692. stmia lr!, {r0-r7}
  693. stmia lr!, {r0-r7}
  694. stmia lr!, {r0-r7}
  695. stmia lr!, {r0-r7}
  696. stmia lr!, {r0-r7}
  697. stmia lr!, {r0-r7}
  698. ldmfd sp!, {r4-r9,pc}
  699. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  700. @ void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est)
  701. .global DrawTilesFromCache
  702. DrawTilesFromCache:
  703. stmfd sp!, {r4-r9,r11,lr}
  704. @ cache some stuff to avoid mem access
  705. ldr r11,[r3, #OFS_EST_HighCol]
  706. mov r12,#0xf
  707. ldr lr, [r3, #OFS_EST_PicoMem_vram]
  708. mov r9, r3 @ est
  709. ands r8, r1, #1
  710. orr r8, r8, r2, lsl #1
  711. bne .dtfc_check_rendflags
  712. @ scratch: r4, r7
  713. .dtfc_loop:
  714. ldr r6, [r0], #4 @ read code
  715. movs r1, r6, lsr #16 @ r1=dx;
  716. ldmeqfd sp!, {r4-r9,r11,pc} @ dx is never zero, this must be a terminator, return
  717. bic r4, r1, #0xfe00
  718. add r1, r11, r4 @ r1=pdest
  719. ldr r2, [r0], #4 @ read pixel data
  720. and r3, r6, #0x6000
  721. mov r3, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
  722. rsbs r4, r4, r8, lsr #1
  723. bmi .dtfc_cut_tile
  724. tst r8, #1
  725. bne .dtfc_shadow
  726. tst r2, r2
  727. beq .dtfc_loop
  728. cmp r2, r2, ror #4
  729. beq .dtfc_SingleColor @ tileline singlecolor
  730. tst r6, #0x0800
  731. bne .dtfc_TileFlip
  732. @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
  733. .dtfc_TileNorm:
  734. TileNorm r12
  735. b .dtfc_loop
  736. .dtfc_TileFlip:
  737. TileFlip r12
  738. b .dtfc_loop
  739. .dtfc_SingleColor:
  740. and r4, r2, #0xf
  741. orr r4, r3, r4
  742. orr r4, r4, r4, lsl #8
  743. tst r1, #1 @ not aligned?
  744. strneb r4, [r1], #1
  745. streqh r4, [r1], #2
  746. strh r4, [r1], #2
  747. strh r4, [r1], #2
  748. strh r4, [r1], #2
  749. strneb r4, [r1], #1 @ have a remaining unaligned pixel?
  750. b .dtfc_loop
  751. .dtfc_shadow:
  752. tst r2, r2
  753. beq .dtfc_shadow_blank
  754. cmp r2, r2, ror #4
  755. beq .dtfc_SingleColor @ tileline singlecolor
  756. tst r6, #0x0800
  757. bne .dtfc_TileFlipShHP
  758. @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
  759. .dtfc_TileNormShHP:
  760. TileNormShHP
  761. b .dtfc_loop
  762. .dtfc_TileFlipShHP:
  763. TileFlipShHP
  764. b .dtfc_loop
  765. .dtfc_shadow_blank:
  766. tst r1, #1
  767. ldrneb r4, [r1]
  768. mov r6, #0x7f
  769. and r4, r4, r6
  770. strneb r4, [r1], #1
  771. ldrh r4, [r1]
  772. orr r6, r6, r6, lsl #8
  773. and r4, r4, r6
  774. strh r4, [r1], #2
  775. ldrh r4, [r1]
  776. and r4, r4, r6
  777. strh r4, [r1], #2
  778. ldrh r4, [r1]
  779. and r4, r4, r6
  780. strh r4, [r1], #2
  781. ldrh r4, [r1]
  782. and r4, r4, r6
  783. streqh r4, [r1]
  784. strneb r4, [r1]
  785. b .dtfc_loop
  786. .dtfc_cut_tile:
  787. add r4, r4, #7 @ 0-6
  788. mov r4, r4, lsl #2
  789. mov r12,#0xf<<28
  790. mov r12,r12,asr r4
  791. mov r2, r2, ror #16
  792. tst r6, #0x0800 @ flipped?
  793. mvnne r12,r12
  794. and r2, r2, r12
  795. mov r2, r2, ror #16
  796. mov r12,#0xf
  797. tst r8, #1
  798. bne .dtfc_shadow
  799. tst r2, r2
  800. beq .dtfc_loop
  801. tst r6, #0x0800
  802. beq .dtfc_TileNorm
  803. b .dtfc_TileFlip
  804. @ check if we have detected layer covered with hi-prio tiles:
  805. .dtfc_check_rendflags:
  806. ldr r2, [r9, #OFS_EST_rendstatus]
  807. tst r2, #(PDRAW_PLANE_HI_PRIO|PDRAW_SHHI_DONE)
  808. beq .dtfc_loop
  809. bic r8, r8, #1 @ sh/hi mode off
  810. tst r2, #PDRAW_SHHI_DONE
  811. bne .dtfc_loop @ already processed
  812. orr r2, r2, #PDRAW_SHHI_DONE
  813. str r2, [r9, #OFS_EST_rendstatus]
  814. add r1, r11,#8
  815. mov r3, #320/4/4
  816. mov r6, #0x7f
  817. orr r6, r6, r6, lsl #8
  818. orr r6, r6, r6, lsl #16
  819. .dtfc_loop_shprep:
  820. ldmia r1, {r2,r4,r5,r7}
  821. subs r3, r3, #1
  822. and r2, r2, r6
  823. and r4, r4, r6
  824. and r5, r5, r6
  825. and r7, r7, r6
  826. stmia r1!,{r2,r4,r5,r7}
  827. bne .dtfc_loop_shprep
  828. b .dtfc_loop
  829. .pool
  830. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  831. @ void DrawSpritesSHi(unsigned char *sprited, struct PicoEState *est)
  832. .global DrawSpritesSHi
  833. DrawSpritesSHi:
  834. ldrb r3, [r0]
  835. mov r12,#0xff
  836. ands r3, r3, #0x7f
  837. bxeq lr
  838. stmfd sp!, {r1,r3-r11,lr} @ +est
  839. strb r12,[r0,#3] @ set end marker
  840. ldrb r12,[r0,#1]
  841. add r10,r0, #4 @ r10=HighLnSpr end
  842. mvn r12,r12
  843. tst r12,#0x6 @ masking in slot 1 and tile ovfl?
  844. ldmeqfd sp!, {r1,r3-r11,pc}
  845. add r10,r10,r3 @ r10=HighLnSpr end
  846. ldrb r12,[r10,#0] @ width of last sprite
  847. ldr r11,[r1, #OFS_EST_HighCol]
  848. str r12,[sp, #4]
  849. mov r12,#0xf
  850. ldr lr, [r1, #OFS_EST_PicoMem_vram]
  851. DrawSpriteSHi:
  852. @ draw next sprite
  853. ldr r7, [sp] @ est
  854. ldrb r0, [r10,#-1]!
  855. ldr r1, [r7, #OFS_EST_HighPreSpr]
  856. cmp r0, #0xff
  857. ldmeqfd sp!, {r1,r3-r11,pc} @ end of list
  858. and r0, r0, #0x7f
  859. add r0, r1, r0, lsl #3
  860. ldr r9, [r0, #4] @ sprite[1]
  861. mov r2, r9, asr #16 @ r2=sx
  862. mov r9, r9, lsl #16
  863. mov r3, r9, lsr #31 @ priority
  864. mov r9, r9, lsr #16
  865. @ orr r9, r9, r8, lsl #31 @ r9=code|sh[31] @@ sh is always on here now
  866. and r4, r9, #0x6000
  867. orr r9, r9, r4, lsl #16
  868. orr r9, r9, #0x90000000 @ r9=scc1 ???? ... <code> (s=shadow/hilight, cc=pal)
  869. cmp r12,r9, lsr #28 @ sh/hi with pal3?
  870. cmpne r3, #1 @ if not, is it hi prio?
  871. strne r3, [sp, #4] @ reset last sprite width
  872. bne DrawSpriteSHi @ non-operator low sprite, already drawn
  873. ldr r3, [r0] @ sprite[0]
  874. mov r6, r3, lsr #28
  875. sub r6, r6, #1 @ r6=width-1 (inc later)
  876. mov r5, r3, lsr #24
  877. and r5, r5, #7 @ r5=height
  878. ldr r7, [r7, #OFS_EST_DrawScanline]
  879. mov r0, r3, lsl #16 @ r4=sy<<16 (tmp)
  880. sub r7, r7, r0, asr #16 @ r7=row=DrawScanline-sy
  881. tst r9, #0x1000
  882. movne r0, r5, lsl #3
  883. subne r0, r0, #1
  884. subne r7, r0, r7 @ if (code&0x1000) row=(height<<3)-1-row; // Flip Y
  885. add r8, r9, r7, lsr #3 @ tile+=row>>3; // Tile number increases going down
  886. tst r9, #0x0800
  887. mlane r8, r5, r6, r8 @ if (code&0x0800) { tile+=delta*(width-1);
  888. rsbne r5, r5, #0 @ delta=-delta; } // r5=delta now
  889. mov r8, r8, lsl #21
  890. mov r8, r8, lsr #17
  891. and r7, r7, #7
  892. add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address
  893. ldr r0, [sp, #4]
  894. add r6, r6, #1 @ inc now
  895. cmp r0, #0 @ check width of last sprite
  896. movne r6, r0
  897. movne r0, #0
  898. strne r0, [sp, #4]
  899. mov r5, r5, lsl #4 @ delta<<=4; // Delta of address
  900. mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30);
  901. adds r0, r2, #0 @ mov sx to r0 and set ZV flags
  902. b .dsprShi_loop_enter
  903. .dsprShi_loop:
  904. subs r6, r6, #1 @ width--
  905. beq DrawSpriteSHi
  906. adds r0, r0, #8 @ sx+=8
  907. add r8, r8, r5 @ tile+=delta
  908. .dsprShi_loop_enter:
  909. ble .dsprShi_loop @ sx <= 0
  910. cmp r0, #328
  911. bge DrawSpriteSHi
  912. mov r8, r8, lsl #17
  913. mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
  914. ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
  915. add r1, r11, r0 @ r1=pdest
  916. tst r2, r2
  917. beq .dsprShi_loop
  918. cmp r12, r9, lsr #28
  919. beq .dsprShi_shadow
  920. cmp r2, r2, ror #4
  921. beq .dsprShi_SingleColor @ tileline singlecolor
  922. tst r9, #0x0800
  923. bne .dsprShi_TileFlip
  924. @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
  925. @ scratch: r4, r7
  926. .dsprShi_TileNorm:
  927. TileNorm r12
  928. b .dsprShi_loop
  929. .dsprShi_TileFlip:
  930. TileFlip r12
  931. b .dsprShi_loop
  932. .dsprShi_SingleColor:
  933. and r4, r2, #0xf
  934. orr r4, r3, r4
  935. orr r4, r4, r4, lsl #8
  936. tst r0, #1 @ not aligned?
  937. strneb r4, [r1], #1
  938. streqh r4, [r1], #2
  939. strh r4, [r1], #2
  940. strh r4, [r1], #2
  941. strh r4, [r1], #2
  942. strneb r4, [r1], #1
  943. b .dsprShi_loop
  944. .dsprShi_shadow:
  945. tst r9, #0x8000
  946. beq .dsprShi_shadow_lowpri
  947. cmp r2, r2, ror #4
  948. beq .dsprShi_singlec_sh
  949. tst r9, #0x0800
  950. bne .dsprShi_TileFlip_sh
  951. @ (r1=pdest, r2=pixels8, r3=pal) r4, r7: scratch, r12: helper pattern
  952. .dsprShi_TileNorm_sh:
  953. TileNormSh
  954. b .dsprShi_loop
  955. .dsprShi_TileFlip_sh:
  956. TileFlipSh
  957. b .dsprShi_loop
  958. .dsprShi_singlec_sh:
  959. cmp r2, #0xe0000000
  960. bcc .dsprShi_SingleColor @ normal singlecolor tileline (carry inverted in ARM)
  961. tst r2, #0x10000000
  962. bne .dsprShi_sh_sh
  963. TileSingleHi
  964. b .dsprShi_loop
  965. .dsprShi_sh_sh:
  966. TileSingleSh
  967. b .dsprShi_loop
  968. .dsprShi_shadow_lowpri:
  969. tst r9, #0x800
  970. bne .dsprShi_TileFlip_sh_lp
  971. .dsprShi_TileNorm_sh_lp:
  972. TileNormSh_onlyop_lp
  973. b .dsprShi_loop
  974. .dsprShi_TileFlip_sh_lp:
  975. TileFlipSh_onlyop_lp
  976. b .dsprShi_loop
  977. .pool
  978. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  979. @ void DrawAllSprites(unsigned char *sprited, int prio, int sh,
  980. @ struct PicoEState *est)
  981. .global DrawAllSprites
  982. DrawAllSprites:
  983. orr r1, r2, r1, lsl #1
  984. ldr r2, [r0]
  985. ands r2, r2, #0x7f
  986. bxeq lr
  987. @ time to do some real work
  988. stmfd sp!, {r1,r3-r11,lr} @ +sh|prio<<1 +est
  989. mov r12,#0xff
  990. strb r12,[r0,#3] @ set end marker
  991. ldrb r12,[r0,#1]
  992. add r10,r0 ,#4
  993. mvn r12,r12
  994. tst r12,#0x6 @ masking in slot 1 and tile ovfl?
  995. ldmeqfd sp!, {r1,r3-r11,pc}
  996. add r10,r10,r2 @ r10=HighLnSpr end
  997. ldrb r12,[r10,#0] @ width of last sprite
  998. ldr r11,[r3, #OFS_EST_HighCol]
  999. orr r1 ,r1 ,r12,lsl #24
  1000. str r1, [sp]
  1001. mov r12,#0xf
  1002. ldr lr, [r3, #OFS_EST_PicoMem_vram]
  1003. @ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size
  1004. @ + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
  1005. DrawSprite:
  1006. @ draw next sprite
  1007. ldrb r0, [r10,#-1]!
  1008. ldr r4, [sp] @ sh|prio<<1|lastw<<24
  1009. ldr r7, [sp, #4] @ est
  1010. mov r2, r0, lsl #24
  1011. cmp r0, #0xff
  1012. ldmeqfd sp!, {r1,r3-r11,pc} @ end of list
  1013. eors r2, r2, r4, lsl #30
  1014. bic r2, r4, #0xff000000
  1015. str r2, [sp]
  1016. bmi DrawSprite @ wrong priority
  1017. ldr r1, [r7, #OFS_EST_HighPreSpr]
  1018. and r0, r0, #0x7f
  1019. add r0, r1, r0, lsl #3
  1020. ldr r3, [r0] @ sprite[0]
  1021. ldr r7, [r7, #OFS_EST_DrawScanline]
  1022. mov r6, r3, lsr #28
  1023. sub r6, r6, #1 @ r6=width-1 (inc later)
  1024. mov r5, r3, lsr #24
  1025. and r5, r5, #7 @ r5=height
  1026. mov r8, r3, lsl #16 @ r8=sy<<16 (tmp)
  1027. ldr r9, [r0, #4]
  1028. sub r7, r7, r8, asr #16 @ r7=row=DrawScanline-sy
  1029. mov r2, r9, asr #16 @ r2=sx
  1030. mov r9, r9, lsl #16
  1031. mov r9, r9, lsr #16
  1032. orr r9, r9, r4, lsl #31 @ r9=code|sh[31]
  1033. tst r9, #0x1000
  1034. movne r8, r5, lsl #3
  1035. subne r8, r8, #1
  1036. subne r7, r8, r7 @ if (code&0x1000) row=(height<<3)-1-row; // Flip Y
  1037. add r8, r9, r7, lsr #3 @ tile+=row>>3; // Tile number increases going down
  1038. tst r9, #0x0800
  1039. mlane r8, r5, r6, r8 @ if (code&0x0800) { tile+=delta*(width-1);
  1040. rsbne r5, r5, #0 @ delta=-delta; } // r5=delta now
  1041. mov r8, r8, lsl #21
  1042. mov r8, r8, lsr #17
  1043. and r7, r7, #7
  1044. add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address
  1045. add r6, r6, #1 @ inc now
  1046. cmp r4, #0x1000000 @ check width of last sprite
  1047. movhs r6, r4, lsr #24
  1048. @ cache some stuff to avoid mem access
  1049. mov r5, r5, lsl #4 @ delta<<=4; // Delta of address
  1050. and r4, r9, #0x6000
  1051. orr r9, r9, r4, lsl #16
  1052. orrs r9, r9, #0x10000000 @ r9=scc1 ???? ... <code> (s=shadow/hilight, cc=pal)
  1053. mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30);
  1054. orrmi r3, r3, #0x80 @ for sh/hi
  1055. adds r0, r2, #0 @ mov sx to r0 and set ZV flags
  1056. b .dspr_loop_enter
  1057. .dspr_loop:
  1058. subs r6, r6, #1 @ width--
  1059. beq DrawSprite
  1060. adds r0, r0, #8 @ sx+=8
  1061. add r8, r8, r5 @ tile+=delta
  1062. .dspr_loop_enter:
  1063. ble .dspr_loop @ sx <= 0
  1064. cmp r0, #328
  1065. bge DrawSprite
  1066. mov r8, r8, lsl #17
  1067. mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
  1068. ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
  1069. add r1, r11, r0 @ r1=pdest
  1070. tst r2, r2
  1071. beq .dspr_loop
  1072. cmp r12, r9, lsr #28
  1073. beq .dspr_shadow
  1074. tst r9, #0x80000000
  1075. bne .dspr_shnonsh
  1076. cmp r2, r2, ror #4
  1077. beq .dspr_SingleColor @ tileline singlecolor
  1078. tst r9, #0x0800
  1079. bne .dspr_TileFlip
  1080. @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
  1081. @ scratch: r4, r7
  1082. .dspr_TileNorm:
  1083. TileNorm r12
  1084. b .dspr_loop
  1085. .dspr_TileFlip:
  1086. TileFlip r12
  1087. b .dspr_loop
  1088. .dspr_singlec_sh:
  1089. cmp r2, #0xe0000000
  1090. bcs .dspr_TileNorm_sh @ op. tileline, markop. XXX: maybe add a spec. handler?
  1091. .dspr_SingleColor:
  1092. and r4, r2, #0xf
  1093. orr r4, r3, r4
  1094. orr r4, r4, r4, lsl #8
  1095. tst r0, #1 @ not aligned?
  1096. strneb r4, [r1], #1
  1097. streqh r4, [r1], #2
  1098. strh r4, [r1], #2
  1099. strh r4, [r1], #2
  1100. strh r4, [r1], #2
  1101. strneb r4, [r1], #1
  1102. b .dspr_loop
  1103. .dspr_shnonsh:
  1104. tst r9, #0x0800
  1105. bne .dspr_TileFlipNonSH
  1106. @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
  1107. @ scratch: r4, r7
  1108. .dspr_TileNormNonSH:
  1109. TileNormNonSH r12
  1110. b .dspr_loop
  1111. .dspr_TileFlipNonSH:
  1112. TileFlipNonSH r12
  1113. b .dspr_loop
  1114. .dspr_shadow:
  1115. cmp r2, r2, ror #4
  1116. beq .dspr_singlec_sh
  1117. tst r9, #0x0800
  1118. bne .dspr_TileFlip_sh
  1119. @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
  1120. .dspr_TileNorm_sh:
  1121. TileNormSh_markop
  1122. b .dspr_loop
  1123. .dspr_TileFlip_sh:
  1124. TileFlipSh_markop
  1125. b .dspr_loop
  1126. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  1127. @ void DrawWindow(int tstart, int tend, int prio, int sh
  1128. @ struct PicoEState *est)
  1129. .global DrawWindow
  1130. DrawWindow:
  1131. ldr r12, [sp] @ est
  1132. stmfd sp!, {r4-r11,lr}
  1133. ldr r6, [r12, #OFS_EST_Pico]
  1134. ldr r10, [r12, #OFS_EST_DrawScanline]
  1135. mov r11, r12 @ est
  1136. ldrb r12, [r6, #OFS_Pico_video_reg+3] @ pvid->reg[3]
  1137. ldr r4, [r6, #OFS_Pico_video_reg+12]
  1138. mov r5, r10, lsr #3
  1139. and r10, r10, #7
  1140. mov r10, r10, lsl #1 @ r10=ty
  1141. mov r12, r12, lsl #10
  1142. tst r4, #1 @ 40 cell mode?
  1143. andne r12, r12, #0xf000 @ 0x3c<<10
  1144. andeq r12, r12, #0xf800
  1145. addne r12, r12, r5, lsl #7
  1146. addeq r12, r12, r5, lsl #6 @ nametab
  1147. add r12, r12, r0, lsl #2 @ +starttile
  1148. ldr lr, [r11, #OFS_EST_PicoMem_vram]
  1149. ldr r6, [r11, #OFS_EST_rendstatus]
  1150. @ fetch the first code now
  1151. ldrh r7, [lr, r12]
  1152. ands r6, r6, #PDRAW_WND_DIFF_PRIO
  1153. cmpeq r2, #1 @ prio && !(rendstatus & WND_DIFF_PRIO)?
  1154. ldmeqfd sp!, {r4-r11,pc} @ yes, assume that whole window uses same priority
  1155. orr r6, r6, r2
  1156. orr r6, r6, r3, lsl #8 @ shadow mode
  1157. sub r8, r1, r0
  1158. @ cache some stuff to avoid mem access
  1159. ldr r11, [r11, #OFS_EST_HighCol]
  1160. mov r8, r8, lsl #1 @ cells
  1161. add r11,r11,#8
  1162. mvn r9, #0 @ r9=prevcode=-1
  1163. add r1, r11, r0, lsl #4 @ r1=pdest
  1164. mov r0, #0xf
  1165. b .dwloop_enter
  1166. @ r4,r5 are scratch in this loop
  1167. .dwloop:
  1168. add r1, r1, #8
  1169. .dwloop_nor1:
  1170. add r12, r12, #2 @ halfwords
  1171. ldrh r7, [lr, r12] @ r7=code (int, but from unsigned, no sign extend)
  1172. subs r8, r8, #1
  1173. beq .dwloop_end @ done
  1174. eor r5, r6, r7, lsr #15
  1175. tst r5, #1
  1176. orrne r6, r6, #PDRAW_WND_DIFF_PRIO @ wrong pri
  1177. bne .dwloop
  1178. cmp r7, r9
  1179. beq .dw_samecode @ we know stuff about this tile already
  1180. .dwloop_enter:
  1181. mov r9, r7 @ remember code
  1182. movs r2, r9, lsl #20 @ if (code&0x1000)
  1183. mov r2, r2, lsl #1
  1184. add r2, r10, r2, lsr #17 @ r2=addr=(code&0x7ff)<<4; addr+=ty
  1185. eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
  1186. and r3, r9, #0x6000
  1187. mov r3, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
  1188. ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
  1189. .dw_samecode:
  1190. tst r6, #0x100
  1191. bne .dw_shadow
  1192. .dw_shadow_done:
  1193. tst r2, r2
  1194. beq .dwloop @ tileline blank
  1195. cmp r2, r2, ror #4
  1196. beq .dw_SingleColor @ tileline singlecolor
  1197. tst r9, #0x0800
  1198. bne .dw_TileFlip
  1199. @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
  1200. .dw_TileNorm:
  1201. TileNorm r0
  1202. b .dwloop
  1203. .dw_TileFlip:
  1204. TileFlip r0
  1205. b .dwloop
  1206. .dw_SingleColor:
  1207. and r4, r0, r2 @ #0x0000000f
  1208. orr r4, r3, r4
  1209. orr r4, r4, r4, lsl #8
  1210. orr r4, r4, r4, lsl #16
  1211. mov r5, r4
  1212. stmia r1!, {r4,r5}
  1213. b .dwloop_nor1 @ we incremeted r1 ourselves
  1214. .dw_shadow:
  1215. tst r6, #1 @ hi pri?
  1216. orreq r3, r3, #0x80
  1217. beq .dw_shadow_done
  1218. ldr r4, [r1]
  1219. mov r5, #0x7f
  1220. orr r5, r5, r5, lsl #8
  1221. orr r5, r5, r5, lsl #16
  1222. and r4, r4, r5
  1223. str r4, [r1]
  1224. ldr r4, [r1,#4]
  1225. and r4, r4, r5
  1226. str r4, [r1,#4]
  1227. b .dw_shadow_done
  1228. .dwloop_end:
  1229. and r2, r6, #PDRAW_WND_DIFF_PRIO
  1230. ldmfd sp!, {r4-r11,lr}
  1231. ldr r0, [sp]
  1232. ldr r1, [r0, #OFS_EST_rendstatus]
  1233. orr r1, r1, r2
  1234. str r1, [r0, #OFS_EST_rendstatus]
  1235. bx lr
  1236. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  1237. @ Convert 0000bbb0 ggg0rrr0
  1238. @ to rrrrrggg gggbbbbb
  1239. @ r2,r3 - scratch, lr = 0x001c001c, r8 = 0x08610861
  1240. .macro convRGB565 reg
  1241. and r2, lr, \reg,lsr #7 @ b
  1242. and r3, lr, \reg,lsr #3 @ g
  1243. and \reg, lr, \reg,lsl #1 @ r
  1244. orr r2, r2, r3, lsl #6
  1245. orr \reg, r2, \reg,lsl #11
  1246. and r2, r8, \reg,lsr #4
  1247. orr \reg, \reg, r2
  1248. .endm
  1249. @ trashes: r2-r8,r12,lr; r8 = 0x08610861; r0,r1 are advanced
  1250. .macro vidConvCpyRGB565_local
  1251. mov r12, r2, lsr #3 @ repeats
  1252. mov lr, #0x001c0000
  1253. orr lr, lr, #0x01c @ lr == pattern 0x001c001c
  1254. 0:
  1255. ldmia r1!, {r4-r7}
  1256. subs r12, r12, #1
  1257. convRGB565 r4
  1258. str r4, [r0], #4
  1259. convRGB565 r5
  1260. str r5, [r0], #4
  1261. convRGB565 r6
  1262. str r6, [r0], #4
  1263. convRGB565 r7
  1264. str r7, [r0], #4
  1265. bgt 0b
  1266. .endm
  1267. .global vidConvCpyRGB565
  1268. vidConvCpyRGB565: @ void *to, void *from, int pixels
  1269. stmfd sp!, {r4-r9,lr}
  1270. mov r8, #0x0061
  1271. orr r8, r8, #0x0800
  1272. orr r8, r8, r8, lsl #16
  1273. vidConvCpyRGB565_local
  1274. ldmfd sp!, {r4-r9,pc}
  1275. @ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
  1276. .global PicoDoHighPal555
  1277. PicoDoHighPal555:
  1278. stmfd sp!, {r4-r10,lr}
  1279. mov r10,r2 @ est
  1280. ldr r8, [r10, #OFS_EST_Pico]
  1281. mov r9, r0
  1282. add r0, r10, #OFS_EST_HighPal
  1283. mov r1, #0
  1284. strb r1, [r8, #OFS_Pico_m_dirtyPal]
  1285. ldr r1, [r10, #OFS_EST_PicoMem_cram]
  1286. mov r2, #0x40
  1287. mov r8, #0x0061
  1288. orr r8, r8, #0x0800
  1289. orr r8, r8, r8, lsl #16
  1290. vidConvCpyRGB565_local
  1291. cmp r9, #0
  1292. beq PicoDoHighPal555_end
  1293. add r3, r10, #OFS_EST_HighPal
  1294. add r4, r3, #0x40*2
  1295. @ hilighted pixels (0x40-0x7f):
  1296. @ t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e;
  1297. @ t |= (t >> 4) & 0x08610861;
  1298. @ r8=0x08610861
  1299. mov r12, #0x008e
  1300. orr r12,r12,#0x7300
  1301. orr r12,r12,r12,lsl #16
  1302. mov lr, #0x40/4
  1303. .fl_loopcpRGB555_hi:
  1304. ldmia r3!, {r1,r6}
  1305. and r1, r12, r1, lsr #1
  1306. and r6, r12, r6, lsr #1
  1307. add r1, r12, r1
  1308. add r6, r12, r6
  1309. and r5, r8, r1, lsr #4
  1310. and r7, r8, r6, lsr #4
  1311. orr r1, r1, r5
  1312. orr r6, r6, r7
  1313. stmia r4!, {r1,r6}
  1314. subs lr, lr, #1
  1315. bne .fl_loopcpRGB555_hi
  1316. sub r3, r3, #0x40*2
  1317. @ shadowed (0x80-0xbf), shadow|hilight (aka normal, 0xc0-0xff) pixels:
  1318. add r5, r3, #0xc0*2
  1319. mov lr, #0x40/4
  1320. .fl_loopcpRGB555_sh:
  1321. ldmia r3!, {r1,r6}
  1322. subs lr, lr, #1
  1323. stmia r5!, {r1,r6} @ 0xc0, normal
  1324. and r1, r12, r1, lsr #1
  1325. and r6, r12, r6, lsr #1
  1326. stmia r4!, {r1,r6}
  1327. bne .fl_loopcpRGB555_sh
  1328. mov r0, #1
  1329. PicoDoHighPal555_end:
  1330. ldmfd sp!, {r4-r10,pc}
  1331. @ void FinalizeLine555(int sh, int line, struct PicoEState *est)
  1332. .global FinalizeLine555
  1333. FinalizeLine555:
  1334. stmfd sp!, {r4-r10,lr}
  1335. mov r10,r2 @ est
  1336. ldr r8, [r10, #OFS_EST_Pico]
  1337. bl PicoDrawUpdateHighPal
  1338. add r3, r10, #OFS_EST_HighPal
  1339. mov lr, #0xff
  1340. mov lr, lr, lsl #1
  1341. ldr r5, [r10, #OFS_EST_PicoOpt]
  1342. ldr r1, [r10, #OFS_EST_HighCol]
  1343. ldr r0, [r10, #OFS_EST_DrawLineDest]
  1344. ldr r4, [r5]
  1345. ldr r7, [r5, #OFS_PicoIn_AHW-OFS_PicoIn_opt]
  1346. ldrb r12,[r8, #OFS_Pico_video_reg+12]
  1347. ldr r2, [r8, #OFS_Pico_m_hardware]
  1348. add r1, r1, #8
  1349. tst r7, #0x10
  1350. beq .fl_no20colRGB555
  1351. and r7, r2, #0x3
  1352. cmp r7, #0x3 @ Game Gear, LCD?
  1353. bne .fl_no20colRGB555
  1354. mov r2, #160/8 @ len = 160
  1355. tst r4, #0x4000 @ EN_SOFTSCALE?
  1356. bne .fl_20scale_RGB555 @ scale 160->320
  1357. beq .fl_checkborder
  1358. .fl_no20colRGB555:
  1359. tst r12, #1 @ h32?
  1360. movne r2, #320/8 @ len = 320
  1361. bne .fl_no32colRGB555
  1362. moveq r2, #256/8 @ len = 256
  1363. tst r4, #0x4000 @ EN_SOFTSCALE?
  1364. bne .fl_32scale_RGB555 @ scale 256->320
  1365. .fl_checkborder:
  1366. tst r4, #0x0100 @ DIS_32C_BORDER?
  1367. rsbeq r4, r2, #320/8 @ pd += (320-len)/2
  1368. addeq r0, r0, r4, lsl #3
  1369. .fl_no32colRGB555:
  1370. #ifdef UNALIGNED_DRAWLINEDEST
  1371. @ this is basically for Gizmondo, which has unaligned odd lines in the framebuffer
  1372. tst r0, #2
  1373. bne .fl_RGB555u
  1374. #endif
  1375. .fl_loopRGB555:
  1376. ldr r12, [r1], #4
  1377. ldr r7, [r1], #4
  1378. and r4, lr, r12, lsl #1
  1379. ldrh r4, [r3, r4]
  1380. and r5, lr, r12, lsr #7
  1381. ldrh r5, [r3, r5]
  1382. and r6, lr, r12, lsr #15
  1383. ldrh r6, [r3, r6]
  1384. orr r4, r4, r5, lsl #16
  1385. and r5, lr, r12, lsr #23
  1386. ldrh r5, [r3, r5]
  1387. and r8, lr, r7, lsl #1
  1388. ldrh r8, [r3, r8]
  1389. orr r5, r6, r5, lsl #16
  1390. and r6, lr, r7, lsr #7
  1391. ldrh r6, [r3, r6]
  1392. and r12,lr, r7, lsr #15
  1393. ldrh r12,[r3, r12]
  1394. and r7, lr, r7, lsr #23
  1395. ldrh r7, [r3, r7]
  1396. orr r8, r8, r6, lsl #16
  1397. subs r2, r2, #1
  1398. orr r12,r12, r7, lsl #16
  1399. stmia r0!, {r4,r5,r8,r12}
  1400. bne .fl_loopRGB555
  1401. ldmfd sp!, {r4-r10,pc}
  1402. .fl_32scale_RGB555:
  1403. ldr r5, [r5, #OFS_PicoIn_filter-OFS_PicoIn_opt]
  1404. mov r9, #0xf700 @ f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
  1405. orr r9, r9, #0x00de
  1406. #ifdef UNALIGNED_DRAWLINEDEST
  1407. tst r0, #2
  1408. bne .fl_32scale_RGB555u
  1409. #endif
  1410. and r5, r5, #0x3
  1411. add pc, pc, r5, lsl #2
  1412. nop
  1413. b .fl_32scale_nn
  1414. b .fl_32scale_snn
  1415. b .fl_32scale_bl2
  1416. b .fl_32scale_bl4
  1417. .fl_32scale_nn:
  1418. ldr r12, [r1], #4
  1419. ldr r7, [r1], #4
  1420. and r4, lr, r12, lsl #1
  1421. ldrh r4, [r3, r4]
  1422. and r5, lr, r12, lsr #7
  1423. ldrh r5, [r3, r5]
  1424. and r6, lr, r12, lsr #15
  1425. ldrh r6, [r3, r6]
  1426. and r10,lr, r12, lsr #23
  1427. ldrh r10,[r3, r10]
  1428. orr r4, r4, r5, lsl #16
  1429. orr r5, r6, r6, lsl #16
  1430. and r6, lr, r7, lsl #1
  1431. ldrh r6, [r3, r6]
  1432. and r8, lr, r7, lsr #7
  1433. ldrh r8, [r3, r8]
  1434. and r12,lr, r7, lsr #15
  1435. ldrh r12,[r3, r12]
  1436. and r7, lr, r7, lsr #23
  1437. ldrh r7, [r3, r7]
  1438. orr r6, r10,r6, lsl #16
  1439. orr r8, r8,r12, lsl #16
  1440. subs r2, r2, #1
  1441. orr r10,r12,r7, lsl #16
  1442. stmia r0!, {r4,r5,r6,r8,r10}
  1443. bne .fl_32scale_nn
  1444. ldmfd sp!, {r4-r10,pc}
  1445. .fl_32scale_snn:
  1446. ldr r12, [r1], #4
  1447. ldr r7, [r1], #4
  1448. and r4, lr, r12, lsl #1
  1449. ldrh r4, [r3, r4]
  1450. and r5, lr, r12, lsr #7
  1451. ldrh r5, [r3, r5]
  1452. and r6, lr, r12, lsr #15
  1453. ldrh r6, [r3, r6]
  1454. and r10,lr, r12, lsr #23
  1455. ldrh r10,[r3, r10]
  1456. and r4, r4, r9
  1457. and r5, r5, r9
  1458. orr r4, r4, r5, lsl #16
  1459. and r6, r6, r9
  1460. add r5, r5, r6
  1461. mov r5, r5, lsr #1
  1462. orr r5, r5, r6, lsl #16
  1463. and r6, lr, r7, lsl #1
  1464. ldrh r6, [r3, r6]
  1465. and r8, lr, r7, lsr #7
  1466. ldrh r8, [r3, r8]
  1467. and r12,lr, r7, lsr #15
  1468. ldrh r12,[r3, r12]
  1469. and r7, lr, r7, lsr #23
  1470. ldrh r7, [r3, r7]
  1471. and r6, r6, r9
  1472. and r10,r10,r9
  1473. orr r6, r10,r6, lsl #16
  1474. and r12,r12,r9
  1475. and r7, r7, r9
  1476. orr r10,r12,r7, lsl #16
  1477. and r8, r8, r9
  1478. add r12,r12,r8
  1479. mov r12,r12,lsr #1
  1480. orr r8, r8,r12, lsl #16
  1481. subs r2, r2, #1
  1482. stmia r0!, {r4,r5,r6,r8,r10}
  1483. bne .fl_32scale_snn
  1484. ldmfd sp!, {r4-r10,pc}
  1485. .fl_32scale_bl2:
  1486. ldr r12, [r1], #4
  1487. ldr r7, [r1], #4
  1488. and r4, lr, r12, lsl #1
  1489. ldrh r4, [r3, r4]
  1490. and r5, lr, r12, lsr #7
  1491. ldrh r5, [r3, r5]
  1492. and r6, lr, r12, lsr #15
  1493. ldrh r6, [r3, r6]
  1494. and r4, r4, r9
  1495. and r5, r5, r9
  1496. add r10,r4, r5
  1497. mov r10,r10,lsr #1
  1498. orr r4, r4, r10,lsl #16 @ px0 | (px0+px1)/2
  1499. and r6, r6, r9
  1500. add r5, r5, r6
  1501. mov r5, r5, lsr #1
  1502. orr r5, r5, r6, lsl #16 @ (px1+px2)/2 | px2
  1503. and r10,lr, r12, lsr #23
  1504. ldrh r10,[r3, r10]
  1505. and r8, lr, r7, lsl #1
  1506. ldrh r8, [r3, r8]
  1507. and r10,r10,r9
  1508. and r8, r8, r9
  1509. orr r6, r10,r8, lsl #16 @ px3 | px4
  1510. and r12,lr, r7, lsr #15
  1511. ldrh r12,[r3, r12]
  1512. and r10, lr, r7, lsr #23
  1513. ldrh r10, [r3, r10]
  1514. and r7, lr, r7, lsr #7
  1515. ldrh r7, [r3, r7]
  1516. and r12,r12,r9
  1517. and r10,r10,r9
  1518. orr r10,r12,r10, lsl #16 @ px6 | px7
  1519. and r7, r7, r9
  1520. add r12,r12,r7
  1521. add r8, r8, r7
  1522. mov r8, r8, lsr #1
  1523. mov r12,r12,lsr #1
  1524. orr r8, r8,r12, lsl #16 @ (px4+px5)/2 | (px5+px6)/2
  1525. subs r2, r2, #1
  1526. stmia r0!, {r4,r5,r6,r8,r10}
  1527. bne .fl_32scale_bl2
  1528. ldmfd sp!, {r4-r10,pc}
  1529. .fl_32scale_bl4:
  1530. // TODO this should reflect the bl4 C algorithm, but it doesn't, it's bln.
  1531. and r9, r9, r9, lsl #1 @ nuke 2 LSBs to avoid spilling for n/4
  1532. .fl_32loop_bl4:
  1533. ldr r12, [r1], #4
  1534. ldr r7, [r1], #4
  1535. and r4, lr, r12,lsl #1
  1536. ldrh r4, [r3, r4]
  1537. and r5, lr, r12,lsr #7
  1538. ldrh r5, [r3, r5]
  1539. @ r4 = 1/4px0+3/4px1 : px0
  1540. and r4, r4, r9
  1541. orr r4, r4, r4, lsl #14 @ r4[31:16] = 1/4 pix_s 0
  1542. and r5, r5, r9
  1543. sub r6, r5, r5, lsr #2 @ r6 = 3/4 pix_s 1
  1544. add r4, r4, r6, lsl #16 @ pix_d 0, 1
  1545. and r6, lr, r12,lsr #15
  1546. ldrh r6, [r3, r6]
  1547. and r12,lr, r12,lsr #23
  1548. ldrh r12,[r3, r12]
  1549. @ r5 = 3/4px2+1/4px3 : (px1+px2)/2
  1550. and r6, r6, r9
  1551. add r5, r5, r6
  1552. mov r5, r5, lsr #1
  1553. sub r6, r6, r6, lsr #2 @ r6 = 3/4 pix_s 2
  1554. orr r5, r5, r6, lsl #16
  1555. and r6, lr, r7, lsl #1
  1556. ldrh r6, [r3, r6]
  1557. and r12,r12,r9
  1558. add r5, r5, r12,lsl #14 @ pix_d 2, 3
  1559. @ r6 = px4 : px3
  1560. and r6, r6, r9
  1561. orr r6, r12,r6, lsl #16 @ pix_d 4, 5
  1562. @ r8 = (px5+px6)/2 : 1/4px4+3/4px5
  1563. and r12,lr, r7, lsr #7
  1564. ldrh r12,[r3, r12]
  1565. and r10,lr, r7, lsr #15
  1566. ldrh r10,[r3, r10]
  1567. and r12,r12,r9
  1568. sub r8, r12,r12,lsr #2 @ r8 = 3/4 pix_s 1
  1569. add r8, r8, r6, lsr #18
  1570. and r7, lr, r7, lsr #23
  1571. ldrh r7, [r3, r7]
  1572. and r10,r10,r9
  1573. orr r8, r8, r10,lsl #15
  1574. add r8, r8, r12,lsl #15 @ pix_d 6, 7
  1575. @ r10 = px7 : 3/4px6+1/4px7
  1576. sub r10,r10,r10,lsr #2 @ r10= 3/4 pix_s 2
  1577. and r7, r7, r9
  1578. add r10,r10,r7, lsr #2 @ += 1/4 pix_s 3
  1579. orr r10,r10,r7, lsl #16 @ pix_d 8, 9
  1580. subs r2, r2, #1
  1581. stmia r0!, {r4,r5,r6,r8,r10}
  1582. bne .fl_32loop_bl4
  1583. ldmfd sp!, {r4-r10,pc}
  1584. .fl_20scale_RGB555:
  1585. ldr r5, [r5, #OFS_PicoIn_filter-OFS_PicoIn_opt]
  1586. mov r9, #0xf700 @ f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
  1587. orr r9, r9, #0x00de
  1588. #ifdef UNALIGNED_DRAWLINEDEST
  1589. tst r0, #2
  1590. bne .fl_20scale_RGB555u
  1591. #endif
  1592. and r5, r5, #0x2
  1593. add pc, pc, r5, lsl #1
  1594. nop
  1595. b .fl_20scale_nn
  1596. b .fl_20scale_bl2
  1597. .fl_20scale_nn:
  1598. ldr r12, [r1], #4
  1599. ldr r7, [r1], #4
  1600. and r4, lr, r12, lsl #1
  1601. ldrh r4, [r3, r4]
  1602. and r5, lr, r12, lsr #7
  1603. ldrh r5, [r3, r5]
  1604. and r6, lr, r12, lsr #15
  1605. ldrh r6, [r3, r6]
  1606. and r8 ,lr, r12, lsr #23
  1607. ldrh r8 ,[r3, r8 ]
  1608. orr r4, r4, r4, lsl #16
  1609. orr r5, r5, r5, lsl #16
  1610. orr r6, r6, r6, lsl #16
  1611. orr r8, r8, r8, lsl #16
  1612. stmia r0!, {r4,r5,r6,r8}
  1613. and r4, lr, r7, lsl #1
  1614. ldrh r4, [r3, r4]
  1615. and r5, lr, r7, lsr #7
  1616. ldrh r5, [r3, r5]
  1617. and r6 ,lr, r7, lsr #15
  1618. ldrh r6 ,[r3, r6]
  1619. and r8, lr, r7, lsr #23
  1620. ldrh r8, [r3, r8]
  1621. orr r4, r4, r4, lsl #16
  1622. orr r5, r5, r5, lsl #16
  1623. orr r6, r6, r6, lsl #16
  1624. orr r8, r8, r8, lsl #16
  1625. stmia r0!, {r4,r5,r6,r8}
  1626. subs r2, r2, #1
  1627. bne .fl_20scale_nn
  1628. ldmfd sp!, {r4-r10,pc}
  1629. .fl_20scale_bl2:
  1630. ldr r8, [r1]
  1631. and r8, lr, r8, lsl #1
  1632. ldrh r8, [r3, r8]
  1633. and r8, r8, r9
  1634. lsl r8, r8, #16
  1635. .fl_20loop_bl2:
  1636. ldr r12, [r1], #4
  1637. ldr r7, [r1], #4
  1638. and r4, lr, r12, lsl #1
  1639. ldrh r4, [r3, r4]
  1640. and r5, lr, r12, lsr #7
  1641. ldrh r5, [r3, r5]
  1642. and r6, lr, r12, lsr #15
  1643. ldrh r6, [r3, r6]
  1644. and r4, r4, r9
  1645. add r10,r4, r8, lsr #16
  1646. mov r10,r10,lsr #1
  1647. orr r4, r10,r4, lsl #16 @ (px-1+px0)/2 | px0
  1648. and r8 ,lr, r12, lsr #23
  1649. ldrh r8 ,[r3, r8]
  1650. and r5, r5, r9
  1651. add r10,r5, r4, lsr #16
  1652. mov r10,r10,lsr #1
  1653. orr r5, r10,r5, lsl #16 @ (px0 +px1)/2 | px1
  1654. and r6, r6, r9
  1655. add r10,r6, r5, lsr #16
  1656. mov r10,r10,lsr #1
  1657. orr r6, r10,r6, lsl #16 @ (px1 +px2)/2 | px2
  1658. and r8, r8, r9
  1659. add r10,r8, r6, lsr #16
  1660. mov r10,r10,lsr #1
  1661. orr r8, r10,r8, lsl #16 @ (px2 +px3)/2 | px3
  1662. stmia r0!, {r4,r5,r6,r8}
  1663. and r4, lr, r7, lsl #1
  1664. ldrh r4, [r3, r4]
  1665. and r5, lr, r7, lsr #7
  1666. ldrh r5, [r3, r5]
  1667. and r6, lr, r7, lsr #15
  1668. ldrh r6, [r3, r6]
  1669. and r4, r4, r9
  1670. add r10,r4, r8, lsr #16
  1671. mov r10,r10,lsr #1
  1672. orr r4, r10,r4, lsl #16 @ (px-1+px0)/2 | px0
  1673. and r8 ,lr, r7, lsr #23
  1674. ldrh r8 ,[r3, r8]
  1675. and r5, r5, r9
  1676. add r10,r5, r4, lsr #16
  1677. mov r10,r10,lsr #1
  1678. orr r5, r10,r5, lsl #16 @ (px0 +px1)/2 | px1
  1679. and r6, r6, r9
  1680. add r10,r6, r5, lsr #16
  1681. mov r10,r10,lsr #1
  1682. orr r6, r10,r6, lsl #16 @ (px1 +px2)/2 | px2
  1683. and r8, r8, r9
  1684. add r10,r8, r6, lsr #16
  1685. mov r10,r10,lsr #1
  1686. orr r8, r10,r8, lsl #16 @ (px2 +px3)/2 | px3
  1687. subs r2, r2, #1
  1688. stmia r0!, {r4,r5,r6,r8}
  1689. bne .fl_20loop_bl2
  1690. ldmfd sp!, {r4-r10,pc}
  1691. #ifdef UNALIGNED_DRAWLINEDEST
  1692. @ unaligned versions of loops
  1693. @ warning: starts drawing 2bytes before dst
  1694. .fl_RGB555u:
  1695. sub r0, r0, #2 @ initial adjustment
  1696. mov r8, #0
  1697. .fl_loopRGB555u:
  1698. ldr r12, [r1], #4
  1699. ldr r7, [r1], #4
  1700. and r6, lr, r12,lsl #1
  1701. ldrh r6, [r3, r6]
  1702. and r5, lr, r12,lsr #7
  1703. ldrh r5, [r3, r5]
  1704. orr r4, r8, r6, lsl #16
  1705. and r6, lr, r12,lsr #15
  1706. ldrh r6, [r3, r6]
  1707. and r8, lr, r12,lsr #23
  1708. ldrh r8, [r3, r8]
  1709. orr r5, r5, r6, lsl #16
  1710. and r6, lr, r7, lsl #1
  1711. ldrh r6, [r3, r6]
  1712. and r12,lr, r7, lsr #7
  1713. ldrh r12,[r3, r12]
  1714. orr r6, r8, r6, lsl #16
  1715. and r8, lr, r7, lsr #15
  1716. ldrh r8, [r3, r8]
  1717. and r7, lr, r7, lsr #23
  1718. subs r2, r2, #1
  1719. orr r12,r12,r8, lsl #16
  1720. ldrh r8, [r3, r7]
  1721. stmia r0!, {r4,r5,r6,r12}
  1722. bne .fl_loopRGB555u
  1723. strh r8, [r0], #2
  1724. ldmfd sp!, {r4-r10,pc}
  1725. .fl_32scale_RGB555u:
  1726. sub r0, r0, #2 @ initial adjustment
  1727. mov r4, #0
  1728. @ r9 f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
  1729. .fl_loop32scale_RGB555u:
  1730. ldr r12, [r1], #4
  1731. ldr r7, [r1], #4
  1732. and r6, lr, r12,lsl #1
  1733. ldrh r6, [r3, r6]
  1734. and r5, lr, r12,lsr #7
  1735. ldrh r5, [r3, r5]
  1736. and r6, r6, r9
  1737. orr r4, r4, r6, lsl #16 @ r4 = pix_d -1, 0
  1738. and r5, r5, r9
  1739. sub r8, r5, r5, lsr #2 @ r8 = 3/4 pix_s 1
  1740. add r6, r8, r6, lsr #2 @ r6 = (1/4 pix_s 0) + (3/4 pix_s 1)
  1741. orr r5, r6, r5, lsl #15
  1742. and r6, lr, r12,lsr #15
  1743. ldrh r6, [r3, r6]
  1744. and r12,lr, r12,lsr #23
  1745. ldrh r12,[r3, r12]
  1746. and r6, r6, r9
  1747. add r5, r5, r6, lsl #15 @ r5 = pix_d 1, 2
  1748. and r8, lr, r7, lsl #1
  1749. ldrh r8, [r3, r8]
  1750. and r10,lr, r7, lsr #7
  1751. ldrh r10,[r3, r10]
  1752. and r12,r12,r9
  1753. sub r6, r6, r6, lsr #2 @ r6 = 3/4 pix_s 2
  1754. add r6, r6, r12,lsr #2
  1755. orr r6, r6, r12,lsl #16 @ r6 = pix_d 3, 4
  1756. and r8, r8, r9
  1757. and r10,r10,r9
  1758. sub r12,r10,r10,lsr #2 @ r12 = 3/4 pix_s 5
  1759. orr r8, r8, r8, lsl #14
  1760. add r8, r8, r12,lsl #16 @ r8 = pix_d 5, 6
  1761. and r12,lr, r7, lsr #15
  1762. ldrh r12,[r3, r12]
  1763. and r7, lr, r7, lsr #23
  1764. ldrh r7, [r3, r7]
  1765. and r12,r12,r9
  1766. add r10,r10,r12
  1767. mov r10,r10, lsr #1
  1768. sub r12,r12,r12,lsr #2 @ r12 = 3/4 pix_s 6
  1769. orr r10,r10,r12,lsl #16
  1770. and r7, r7, r9
  1771. add r10,r10,r7, lsl #14 @ r10 = pix_d 7, 8
  1772. subs r2, r2, #1
  1773. stmia r0!, {r4,r5,r6,r8,r10}
  1774. mov r4, r7
  1775. bne .fl_loop32scale_RGB555u
  1776. strh r4, [r0], #2
  1777. ldmfd sp!, {r4-r10,pc}
  1778. #endif /* UNALIGNED_DRAWLINEDEST */
  1779. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  1780. @ utility
  1781. .global blockcpy @ void *dst, void *src, size_t n
  1782. blockcpy:
  1783. stmfd sp!, {r4,r5}
  1784. mov r2, r2, lsr #4
  1785. blockcpy_loop:
  1786. ldmia r1!, {r3-r5,r12}
  1787. subs r2, r2, #1
  1788. stmia r0!, {r3-r5,r12}
  1789. bne blockcpy_loop
  1790. ldmfd sp!, {r4,r5}
  1791. bx lr
  1792. .global blockcpy_or @ void *dst, void *src, size_t n, int pat
  1793. blockcpy_or:
  1794. stmfd sp!, {r4-r6}
  1795. orr r3, r3, r3, lsl #8
  1796. orr r3, r3, r3, lsl #16
  1797. mov r2, r2, lsr #4
  1798. blockcpy_loop_or:
  1799. ldmia r1!, {r4-r6,r12}
  1800. subs r2, r2, #1
  1801. orr r4, r4, r3
  1802. orr r5, r5, r3
  1803. orr r6, r6, r3
  1804. orr r12,r12,r3
  1805. stmia r0!, {r4-r6,r12}
  1806. bne blockcpy_loop_or
  1807. ldmfd sp!, {r4-r6}
  1808. bx lr
  1809. @ vim:filetype=armasm