123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031 |
- /*
- * assembly optimized versions of most funtions from draw.c
- * (C) notaz, 2006-2010
- *
- * This work is licensed under the terms of MAME license.
- * See COPYING file in the top-level directory.
- *
- * this is highly specialized, be careful if changing related C code!
- */
- .include "port_config.s"
- .extern Pico
- .extern PicoOpt
- .extern HighCol
- .extern DrawScanline
- .extern HighSprZ
- .extern rendstatus
- .extern HighPreSpr
- .extern DrawLineDest
- .extern DrawStripInterlace
- .extern HighCacheS_ptr
- .equiv OVERRIDE_HIGHCOL, 1
- .equ PDRAW_SPRITES_MOVED, (1<<0)
- .equ PDRAW_WND_DIFF_PRIO, (1<<1)
- .equ PDRAW_ACC_SPRITES, (1<<2)
- .equ PDRAW_DIRTY_SPRITES, (1<<4)
- .equ PDRAW_PLANE_HI_PRIO, (1<<6)
- .equ PDRAW_SHHI_DONE, (1<<7)
- @ helper
- .macro TilePixel pat lsrr offs
- .if !\lsrr
- ands r4, \pat, r2
- .else
- ands r4, \pat, r2, lsr #\lsrr
- .endif
- orrne r4, r3, r4
- strneb r4, [r1,#\offs]
- .endm
- @ TileNorm (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
- .macro TileNorm pat
- TilePixel \pat, 12, 0 @ #0x0000f000
- TilePixel \pat, 8, 1 @ #0x00000f00
- TilePixel \pat, 4, 2 @ #0x000000f0
- TilePixel \pat, 0, 3 @ #0x0000000f
- TilePixel \pat, 28, 4 @ #0xf0000000
- TilePixel \pat, 24, 5 @ #0x0f000000
- TilePixel \pat, 20, 6 @ #0x00f00000
- TilePixel \pat, 16, 7 @ #0x000f0000
- .endm
- @ TileFlip (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
- .macro TileFlip pat
- TilePixel \pat, 16, 0 @ #0x000f0000
- TilePixel \pat, 20, 1 @ #0x00f00000
- TilePixel \pat, 24, 2 @ #0x0f000000
- TilePixel \pat, 28, 3 @ #0xf0000000
- TilePixel \pat, 0, 4 @ #0x0000000f
- TilePixel \pat, 4, 5 @ #0x000000f0
- TilePixel \pat, 8, 6 @ #0x00000f00
- TilePixel \pat, 12, 7 @ #0x0000f000
- .endm
- @ shadow/hilight mode
- @ this one is for hi priority layer
- .macro TilePixelShHP lsrr offs
- .if !\lsrr
- ands r4, r12, r2
- .else
- ands r4, r12, r2, lsr #\lsrr
- .endif
- ldreqb r4, [r1,#\offs]
- orrne r4, r3, r4
- andeq r4, r4, #0xbf
- strb r4, [r1,#\offs]
- .endm
- @ TileNormShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: register with helper pattern 0xf, touches r3 high bits
- .macro TileNormShHP
- TilePixelShHP 12, 0 @ #0x0000f000
- TilePixelShHP 8, 1 @ #0x00000f00
- TilePixelShHP 4, 2 @ #0x000000f0
- TilePixelShHP 0, 3 @ #0x0000000f
- TilePixelShHP 28, 4 @ #0xf0000000
- TilePixelShHP 24, 5 @ #0x0f000000
- TilePixelShHP 20, 6 @ #0x00f00000
- TilePixelShHP 16, 7 @ #0x000f0000
- .endm
- @ TileFlipShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
- .macro TileFlipShHP
- TilePixelShHP 16, 0 @ #0x000f0000
- TilePixelShHP 20, 1 @ #0x00f00000
- TilePixelShHP 24, 2 @ #0x0f000000
- TilePixelShHP 28, 3 @ #0xf0000000
- TilePixelShHP 0, 4 @ #0x0000000f
- TilePixelShHP 4, 5 @ #0x000000f0
- TilePixelShHP 8, 6 @ #0x00000f00
- TilePixelShHP 12, 7 @ #0x0000f000
- .endm
- @ TileSingleSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx; r12: helper pattern 0xf
- .macro TileSingleSh
- tst r0, #1 @ not aligned?
- mov r7, #0x00c000
- orr r7, r7, #0xc0
- ldrneb r4, [r1]
- ldreqh r4, [r1]
- orr r4, r4, r7
- strneb r4, [r1], #1
- streqh r4, [r1], #2
- ldrh r4, [r1]
- orr r4, r4, r7
- strh r4, [r1], #2
- ldrh r4, [r1]
- orr r4, r4, r7
- strh r4, [r1], #2
- ldrh r4, [r1]
- orr r4, r4, r7
- strh r4, [r1], #2
- ldrneb r4, [r1]
- orr r4, r4, r7
- strneb r4, [r1], #1
- .endm
- @ TileSingleHi (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
- .macro TileSingleHi
- tst r1, #1 @ not aligned?
- mov r7, #0x008000
- orr r7, r7, #0x80
- ldrneb r4, [r1], #1
- ldreqh r4, [r1], #2 @ 1ci
- ldrh r12, [r1], #2
- bic r4, r4, r7, lsr #1
- orr r4, r4, r7
- strneb r4, [r1, #-3]
- streqh r4, [r1, #-4]
- ldrh r4, [r1], #2
- bic r12, r12, r7, lsr #1
- orr r12, r12, r7
- strh r12, [r1, #-4]
- ldrh r12, [r1], #2
- bic r4, r4, r7, lsr #1
- orr r4, r4, r7
- strh r4, [r1, #-4]
- ldrneb r4, [r1]
- bic r12, r12, r7, lsr #1
- orr r12, r12, r7
- strh r12, [r1, #-2]
- bicne r4, r4, r7, lsr #1
- orrne r4, r4, r7
- strneb r4, [r1], #1
- mov r12, #0xf
- .endm
- .macro TileDoShGenPixel shift ofs
- .if \shift
- ands r4, r12, r2, lsr #\shift
- .else
- ands r4, r12, r2
- .endif
- beq 0f
- cmp r4, #0xe
- ldrgeb r7, [r1,#\ofs]
- orrlt r7, r3, r4 @ normal
- bicge r7, r7, #0xc0
- orrge r7, r7, r4, lsl #6
- strb r7, [r1,#\ofs]
- 0:
- .endm
- @ TileFlipSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
- .macro TileFlipSh
- TileDoShGenPixel 16, 0 @ #0x000f0000
- TileDoShGenPixel 20, 1 @ #0x00f00000
- TileDoShGenPixel 24, 2 @ #0x0f000000
- TileDoShGenPixel 28, 3 @ #0xf0000000
- TileDoShGenPixel 0, 4 @ #0x0000000f
- TileDoShGenPixel 4, 5 @ #0x000000f0
- TileDoShGenPixel 8, 6 @ #0x00000f00
- TileDoShGenPixel 12, 7 @ #0x0000f000
- .endm
- @ TileNormSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
- .macro TileNormSh
- TileDoShGenPixel 12, 0 @ #0x0000f000
- TileDoShGenPixel 8, 1 @ #0x00000f00
- TileDoShGenPixel 4, 2 @ #0x000000f0
- TileDoShGenPixel 0, 3 @ #0x0000000f
- TileDoShGenPixel 28, 4 @ #0xf0000000
- TileDoShGenPixel 24, 5 @ #0x0f000000
- TileDoShGenPixel 20, 6 @ #0x00f00000
- TileDoShGenPixel 16, 7 @ #0x000f0000
- .endm
- .macro TileDoShGenPixel_markop shift ofs
- .if \shift
- ands r4, r12, r2, lsr #\shift
- .else
- ands r4, r12, r2
- .endif
- beq 0f
- cmp r4, #0xe
- ldrgeb r4, [r1,#\ofs]
- orrlt r4, r3, r4
- orrge r4, r4, #0x80
- strb r4, [r1,#\ofs]
- 0:
- .endm
- .macro TileFlipSh_markop
- TileDoShGenPixel_markop 16, 0 @ #0x000f0000
- TileDoShGenPixel_markop 20, 1 @ #0x00f00000
- TileDoShGenPixel_markop 24, 2 @ #0x0f000000
- TileDoShGenPixel_markop 28, 3 @ #0xf0000000
- TileDoShGenPixel_markop 0, 4 @ #0x0000000f
- TileDoShGenPixel_markop 4, 5 @ #0x000000f0
- TileDoShGenPixel_markop 8, 6 @ #0x00000f00
- TileDoShGenPixel_markop 12, 7 @ #0x0000f000
- .endm
- .macro TileNormSh_markop
- TileDoShGenPixel_markop 12, 0 @ #0x0000f000
- TileDoShGenPixel_markop 8, 1 @ #0x00000f00
- TileDoShGenPixel_markop 4, 2 @ #0x000000f0
- TileDoShGenPixel_markop 0, 3 @ #0x0000000f
- TileDoShGenPixel_markop 28, 4 @ #0xf0000000
- TileDoShGenPixel_markop 24, 5 @ #0x0f000000
- TileDoShGenPixel_markop 20, 6 @ #0x00f00000
- TileDoShGenPixel_markop 16, 7 @ #0x000f0000
- .endm
- .macro TileDoShGenPixel_onlyop_lp shift ofs
- .if \shift
- ands r7, r12, r2, lsr #\shift
- .else
- ands r7, r12, r2
- .endif
- ldrneb r4, [r1,#\ofs]
- cmp r7, #0xe
- blt 0f
- tst r4, #0xc0
- bicne r4, r4, #0xc0
- orrne r4, r4, r7, lsl #6
- strneb r4, [r1,#\ofs]
- 0:
- .endm
- .macro TileFlipSh_onlyop_lp
- TileDoShGenPixel_onlyop_lp 16, 0 @ #0x000f0000
- TileDoShGenPixel_onlyop_lp 20, 1 @ #0x00f00000
- TileDoShGenPixel_onlyop_lp 24, 2 @ #0x0f000000
- TileDoShGenPixel_onlyop_lp 28, 3 @ #0xf0000000
- TileDoShGenPixel_onlyop_lp 0, 4 @ #0x0000000f
- TileDoShGenPixel_onlyop_lp 4, 5 @ #0x000000f0
- TileDoShGenPixel_onlyop_lp 8, 6 @ #0x00000f00
- TileDoShGenPixel_onlyop_lp 12, 7 @ #0x0000f000
- .endm
- .macro TileNormSh_onlyop_lp
- TileDoShGenPixel_onlyop_lp 12, 0 @ #0x0000f000
- TileDoShGenPixel_onlyop_lp 8, 1 @ #0x00000f00
- TileDoShGenPixel_onlyop_lp 4, 2 @ #0x000000f0
- TileDoShGenPixel_onlyop_lp 0, 3 @ #0x0000000f
- TileDoShGenPixel_onlyop_lp 28, 4 @ #0xf0000000
- TileDoShGenPixel_onlyop_lp 24, 5 @ #0x0f000000
- TileDoShGenPixel_onlyop_lp 20, 6 @ #0x00f00000
- TileDoShGenPixel_onlyop_lp 16, 7 @ #0x000f0000
- .endm
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- @ struct TileStrip
- @ {
- @ int nametab; // 0x00
- @ int line; // 0x04
- @ int hscroll; // 0x08
- @ int xmask; // 0x0C
- @ int *hc; // 0x10 (pointer to cache buffer)
- @ int cells; // 0x14
- @ };
- @ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);
- .global DrawLayer
- DrawLayer:
- stmfd sp!, {r4-r11,lr}
- ldr r11, =(Pico+0x22228) @ Pico.video
- mov r8, #1
- ldrb r7, [r11, #16] @ ??vv??hh
- mov r6, r1 @ hcache
- orr r9, r3, r0, lsl #30
- orr r9, r9, r2, lsl #8 @ r9=sh[31]|cellskip[15:8]|maxcells[7:0] (tmp)
- mov r1, r7, lsl #4
- orr r1, r1, #0x00ff
- and r10, r7, #3
- cmp r10, #1
- biclt r1, r1, #0xfc00
- biceq r1, r1, #0xfe00
- bicgt r1, r1, #0xff00 @ r1=ymask=(height<<8)|0xff; ...; // Y Mask in pixels
- add r10, r10, #5
- cmp r10, #7
- subge r10, r10, #1 @ r10=shift[width] (5,6,6,7)
- @ calculate xmask:
- mov r5, r8, lsl r10
- sub r5, r5, #1 @ r5=xmask
- @ Find name table:
- ands r0, r0, #1
- ldreqb r12, [r11, #2]
- ldrneb r12, [r11, #4]
- ldr r2, =DrawScanline @ trying to make good use of pipeline here
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram
- moveq r12, r12, lsl #10
- movne r12, r12, lsl #13
- and r12, r12, #(7<<13) @ r12=(ts->nametab<<1) (halfword compliant)
- ldrh r8, [r11, #12]
- ldrb r7, [r11, #11]
- ldr r2, [r2]
- mov r4, r8, lsr #8 @ pvid->reg[13]
- mov r4, r4, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords)
- tst r7, #2
- addne r4, r4, r2, lsl #2 @ htab+=DrawScanline<<1; // Offset by line
- tst r7, #1
- biceq r4, r4, #0x1f @ htab&=~0xf; // Offset by tile
- add r4, r4, r0, lsl #1 @ htab+=plane
- bic r4, r4, #0x00ff0000 @ just in case
- ldrh r3, [lr, r4] @ r3=hscroll
- tst r7, #4
- bne .DrawStrip_vsscroll
- @ Get vertical scroll value:
- add r7, lr, #0x012000
- add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)
- ldr r7, [r7]
- tst r8, #2
- tstne r8, #4
- bne .DrawStrip_interlace
- tst r0, r0
- movne r7, r7, lsr #16
- @ Find the line in the name table
- add r2, r2, r7
- and r2, r2, r1
- mov r4, r2, lsr #3
- add r10, r10, #1 @ shift[width]++
- add r12, r12, r4, lsl r10 @ nametab+=(ts.line>>3)<<shift[width];
- @ ldmia r0, {r1,r2,r3,r5,r6,r9} @ r2=line, r3=ts->hscroll, r5=ts->xmask, r6=ts->hc, r9=ts->cells
- and r10,r2, #7
- mov r10,r10, lsl #1 @ r10=ty=(ts->line&7)<<1;
- orr r10,r10, r9, lsl #24
- rsb r8, r3, #0
- mov r8, r8, lsr #3 @ r8=tilex=(-ts->hscroll)>>3
- sub r1, r3, #1
- and r1, r1, #7
- add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1
- tst r9, #1<<31
- mov r3, #0
- orrne r10,r10, #1<<23 @ r10=(cells<<24|sh<<23|hi_not_empty<<22|had_output<<21|ty)
- movne r3, #0x40 @ default to shadowed pal on sh mode
- cmp r7, #8
- addne r10,r10, #0x01000000 @ we will loop cells+1 times if there is scroll
- and r9, r9, #0xff00
- add r8, r8, r9, lsr #8 @ tilex+=cellskip
- add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
- sub r10,r10,r9, lsl #16 @ cells-=cellskip
- @ cache some stuff to avoid mem access
- .if OVERRIDE_HIGHCOL
- ldr r11,=HighCol
- mov r0, #0xf
- ldr r11,[r11]
- .else
- ldr r11,=HighCol
- mov r0, #0xf
- .endif
- mvn r9, #0 @ r9=prevcode=-1
- add r1, r11, r7 @ r1=pdest
- @ r4 & r7 are scratch in this loop
- .dsloop_subr1:
- sub r1, r1, #8
- .dsloop: @ 40-41 times
- subs r10,r10, #0x01000000
- bmi .dsloop_exit
- .dsloop_enter:
- and r7, r5, r8
- add r7, lr, r7, lsl #1 @ Pico.vram+((tilex&ts->xmask) as halfwords)
- ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)
- add r1, r1, #8
- add r8, r8, #1
- tst r7, #0x8000
- bne .DrawStrip_hiprio
- cmp r7, r9
- beq .DrawStrip_samecode @ we know stuff about this tile already
- mov r9, r7 @ remember code
- orr r10, r10, #1<<21 @ seen non hi-prio tile
- movs r2, r9, lsl #20 @ if (code&0x1000)
- mov r2, r2, lsl #1
- add r2, r2, r10, lsl #17
- mov r2, r2, lsr #17
- eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
- ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- bic r7, r3, #0x3f
- and r3, r9, #0x6000
- add r3, r7, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
- .DrawStrip_samecode:
- tst r2, r2
- beq .dsloop @ tileline blank
- cmp r2, r2, ror #4
- beq .DrawStrip_SingleColor @ tileline singlecolor
- tst r9, #0x0800
- bne .DrawStrip_TileFlip
- @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
- .DrawStrip_TileNorm:
- TileNorm r0
- b .dsloop
- .DrawStrip_TileFlip:
- TileFlip r0
- b .dsloop
- .DrawStrip_SingleColor:
- and r4, r2, #0xf
- orr r4, r3, r4
- orr r4, r4, r4, lsl #8
- tst r1, #1 @ not aligned?
- strneb r4, [r1], #1
- streqh r4, [r1], #2
- strh r4, [r1], #2
- strh r4, [r1], #2
- strh r4, [r1], #2
- strneb r4, [r1], #1 @ have a remaining unaligned pixel?
- b .dsloop_subr1
- .DrawStrip_hiprio_maybempt:
- cmp r7, r9
- beq .dsloop @ must've been empty, otherwise we wouldn't get here
- movs r2, r7, lsl #20 @ if (code&0x1000)
- mov r2, r2, lsl #1
- add r2, r2, r10, lsl #17
- mov r2, r2, lsr #17
- eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
- ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- mov r9, r7 @ remember code
- tst r2, r2
- beq .dsloop
- orr r10, r10, #1<<22
- .DrawStrip_hiprio:
- tst r10, #0x00c00000
- beq .DrawStrip_hiprio_maybempt
- sub r0, r1, r11
- orr r7, r7, r0, lsl #16
- orr r7, r7, r10, lsl #25 @ (ty<<25)
- tst r7, #0x1000
- eorne r7, r7, #7<<26 @ if(code&0x1000) cval^=7<<26;
- str r7, [r6], #4 @ cache hi priority tile
- mov r0, #0xf
- b .dsloop
- .dsloop_exit:
- tst r10, #1<<21 @ seen non hi-prio tile
- ldreq r1, =rendstatus
- mov r0, #0
- ldreq r2, [r1]
- str r0, [r6] @ terminate the cache list
- orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles
- streq r2, [r1]
- ldmfd sp!, {r4-r11,lr}
- bx lr
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .DrawStrip_vsscroll:
- rsb r8, r3, #0
- mov r8, r8, lsr #3 @ r8=tilex=(-ts->hscroll)>>3
- bic r8, r8, #0x3fc00000
- orr r8, r8, r5, lsl #25 @ r8=(xmask[31:25]|had_output[24]|tilex[21:0])
- ldr r4, =DrawScanline
- orr r5, r1, r10, lsl #24
- ldr r4, [r4]
- sub r1, r3, #1
- orr r5, r5, r4, lsl #16 @ r5=(shift_width[31:24]|scanline[23:16]|ymask[15:0])
- and r1, r1, #7
- add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1
- mov r10,r9, lsl #16
- tst r0, #1
- orrne r10,r10, #0x8000
- tst r9, #1<<31
- mov r3, #0
- orr r10,r10, #0xff000000 @ will be adjusted on entering loop
- orrne r10,r10, #1<<23 @ r10=(cell[31:24]|sh[23]|hi_not_empty[22]|cells_max[21:16]|plane[15]|ty[14:0])
- movne r3, #0x40 @ default to shadowed pal on sh mode
- cmp r7, #8
- subne r10,r10, #0x01000000 @ have hscroll, start with negative cell
- and r9, r9, #0xff00
- add r8, r8, r9, lsr #8 @ tilex+=cellskip
- add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
- add r10,r10,r9, lsl #16 @ cell+=cellskip
- @ cache some stuff to avoid mem access
- .if OVERRIDE_HIGHCOL
- ldr r11,=HighCol
- mov r0, #0xf
- ldr r11,[r11]
- .else
- ldr r11,=HighCol
- mov r0, #0xf
- .endif
- mvn r9, #0 @ r9=prevcode=-1
- add r1, r11, r7 @ r1=pdest
- @ r4 & r7 are scratch in this loop
- .dsloop_vs_subr1:
- sub r1, r1, #8
- .dsloop_vs: @ 40-41 times
- add r10,r10, #0x01000000
- and r4, r10, #0x003f0000
- cmp r4, r10, asr #8
- ble .dsloop_vs_exit
- @ calc offset and read tileline code to r7, also calc ty
- add r7, lr, #0x012000
- add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)
- add r7, r7, r10,asr #23 @ vsram + ((cell&~1)<<1)
- bic r7, r7, #3
- tst r10,#0x8000 @ plane1?
- addne r7, r7, #2
- ldrh r7, [r7] @ r7=vscroll
- bic r10,r10,#0xff @ clear old ty
- and r4, r5, #0xff0000 @ scanline
- add r4, r4, r7, lsl #16 @ ... += vscroll
- and r4, r4, r5, lsl #16 @ ... &= ymask
- and r7, r4, #0x70000
- orr r10,r10,r7, lsr #15 @ new ty
- mov r4, r4, lsr #19
- mov r7, r5, lsr #24
- mov r4, r4, lsl r7 @ nametabadd
- and r7, r8, r8, lsr #25
- add r7, lr, r7, lsl #1 @ Pico.vram+((tilex&ts->xmask) as halfwords)
- add r7, r7, r4, lsl #1
- ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)
- add r1, r1, #8
- add r8, r8, #1
- tst r7, #0x8000
- bne .DrawStrip_vs_hiprio
- cmp r7, r9
- beq .DrawStrip_vs_samecode @ we know stuff about this tile already
- mov r9, r7 @ remember code
- orr r8, r8, #(1<<24)@ seen non hi-prio tile
- movs r2, r9, lsl #20 @ if (code&0x1000)
- mov r2, r2, lsl #1
- add r2, r2, r10, lsl #17
- mov r2, r2, lsr #17
- eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
- ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- bic r7, r3, #0x3f
- and r3, r9, #0x6000
- add r3, r7, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
- .DrawStrip_vs_samecode:
- tst r2, r2
- beq .dsloop_vs @ tileline blank
- cmp r2, r2, ror #4
- beq .DrawStrip_vs_SingleColor @ tileline singlecolor
- tst r9, #0x0800
- bne .DrawStrip_vs_TileFlip
- @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
- .DrawStrip_vs_TileNorm:
- TileNorm r0
- b .dsloop_vs
- .DrawStrip_vs_TileFlip:
- TileFlip r0
- b .dsloop_vs
- .DrawStrip_vs_SingleColor:
- and r4, r2, #0xf
- orr r4, r3, r4
- orr r4, r4, r4, lsl #8
- tst r1, #1 @ not aligned?
- strneb r4, [r1], #1
- streqh r4, [r1], #2
- strh r4, [r1], #2
- strh r4, [r1], #2
- strh r4, [r1], #2
- strneb r4, [r1], #1 @ have a remaining unaligned pixel?
- b .dsloop_vs_subr1
- .DrawStrip_vs_hiprio:
- tst r10, #0x00c00000
- beq .DrawStrip_vs_hiprio_maybempt
- sub r0, r1, r11
- orr r7, r7, r0, lsl #16
- orr r7, r7, r10, lsl #25 @ (ty<<25)
- tst r7, #0x1000
- eorne r7, r7, #7<<26 @ if(code&0x1000) cval^=7<<26;
- str r7, [r6], #4 @ cache hi priority tile
- mov r0, #0xf
- b .dsloop_vs
- .DrawStrip_vs_hiprio_maybempt:
- cmp r7, r9
- beq .dsloop_vs @ must've been empty, otherwise we wouldn't get here
- movs r2, r7, lsl #20 @ if (code&0x1000)
- mov r2, r2, lsl #1
- add r2, r2, r10, lsl #17
- mov r2, r2, lsr #17
- eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
- ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- mov r9, r7 @ remember code
- tst r2, r2
- orrne r10, r10, #1<<22
- bne .DrawStrip_vs_hiprio
- b .dsloop_vs
- .dsloop_vs_exit:
- tst r8, #(1<<24) @ seen non hi-prio tile
- ldreq r1, =rendstatus
- mov r0, #0
- ldreq r2, [r1]
- str r0, [r6] @ terminate the cache list
- orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles
- streq r2, [r1]
- ldmfd sp!, {r4-r11,lr}
- bx lr
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- @ interlace mode 2? Sonic 2?
- .DrawStrip_interlace:
- tst r0, r0
- moveq r7, r7, lsl #21
- movne r7, r7, lsl #5
- @ Find the line in the name table
- add r2, r7, r2, lsl #22 @ r2=(vscroll+(DrawScanline<<1))<<21 (11 bits);
- orr r1, r1, #0x80000000
- and r2, r2, r1, ror #10 @ &((ymask<<1)|1)<<21;
- mov r2, r2, lsr #21
- mov r4, r2, lsr #4
- mov r12, r12, lsr #1 @ halfwords
- add r0, r12, r4, lsl r10 @ nametab+=(ts.line>>4)<<shift[width];
- and r9, r9, #0xff
- sub sp, sp, #6*4
- stmia sp, {r0,r2,r3,r5,r6,r9}
- mov r0, sp
- bl DrawStripInterlace @ struct TileStrip *ts
- add sp, sp, #6*4
- ldmfd sp!, {r4-r11,lr}
- bx lr
- .pool
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .global BackFill @ int reg7, int sh
- BackFill:
- stmfd sp!, {r4-r9,lr}
- .if OVERRIDE_HIGHCOL
- ldr lr, =HighCol
- mov r0, r0, lsl #26
- ldr lr, [lr]
- mov r0, r0, lsr #26
- add lr, lr, #8
- .else
- ldr lr, =(HighCol+8)
- mov r0, r0, lsl #26
- mov r0, r0, lsr #26
- .endif
- orr r0, r0, r1, lsl #6
- orr r0, r0, r0, lsl #8
- orr r0, r0, r0, lsl #16
- mov r1, r0
- mov r2, r0
- mov r3, r0
- mov r4, r0
- mov r5, r0
- mov r6, r0
- mov r7, r0
- @ go go go!
- stmia lr!, {r0-r7} @ 10*8*4
- stmia lr!, {r0-r7}
- stmia lr!, {r0-r7}
- stmia lr!, {r0-r7}
- stmia lr!, {r0-r7}
- stmia lr!, {r0-r7}
- stmia lr!, {r0-r7}
- stmia lr!, {r0-r7}
- stmia lr!, {r0-r7}
- stmia lr!, {r0-r7}
- ldmfd sp!, {r4-r9,r12}
- bx r12
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .global DrawTilesFromCache @ int *hc, int sh, int rlim
- DrawTilesFromCache:
- stmfd sp!, {r4-r8,r11,lr}
- @ cache some stuff to avoid mem access
- .if OVERRIDE_HIGHCOL
- ldr r11,=HighCol
- mov r12,#0xf
- ldr r11,[r11]
- .else
- ldr r11,=HighCol
- mov r12,#0xf
- .endif
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram
- mvn r5, #0 @ r5=prevcode=-1
- ands r8, r1, #1
- orr r8, r8, r2, lsl #1
- bne .dtfc_check_rendflags
- @ scratch: r4, r7
- .dtfc_loop:
- ldr r6, [r0], #4 @ read code
- movs r1, r6, lsr #16 @ r1=dx;
- ldmeqfd sp!, {r4-r8,r11,pc} @ dx is never zero, this must be a terminator, return
- bic r4, r1, #0xfe00
- add r1, r11, r4 @ r1=pdest
- mov r7, r6, lsl #16
- cmp r5, r7, lsr #16
- beq .dtfc_samecode @ if (code==prevcode)
- mov r5, r7, lsr #16
- mov r2, r5, lsl #21
- mov r2, r2, lsr #17 @ r2=addr=(code&0x7ff)<<4;
- add r2, r2, r6, lsr #25 @ addr+=ty
- and r3, r5, #0x6000
- mov r3, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
- ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- .dtfc_samecode:
- rsbs r4, r4, r8, lsr #1
- bmi .dtfc_cut_tile
- tst r8, #1
- bne .dtfc_shadow
- tst r2, r2
- beq .dtfc_loop
- cmp r2, r2, ror #4
- beq .dtfc_SingleColor @ tileline singlecolor
- tst r5, #0x0800
- bne .dtfc_TileFlip
- @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
- .dtfc_TileNorm:
- TileNorm r12
- b .dtfc_loop
- .dtfc_TileFlip:
- TileFlip r12
- b .dtfc_loop
- .dtfc_SingleColor:
- and r4, r2, #0xf
- orr r4, r3, r4
- orr r4, r4, r4, lsl #8
- tst r1, #1 @ not aligned?
- strneb r4, [r1], #1
- streqh r4, [r1], #2
- strh r4, [r1], #2
- strh r4, [r1], #2
- strh r4, [r1], #2
- strneb r4, [r1], #1 @ have a remaining unaligned pixel?
- b .dtfc_loop
- .dtfc_shadow:
- tst r2, r2
- beq .dtfc_shadow_blank
- cmp r2, r2, ror #4
- beq .dtfc_SingleColor @ tileline singlecolor
- tst r5, #0x0800
- bne .dtfc_TileFlipShHP
- @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
- .dtfc_TileNormShHP:
- TileNormShHP
- b .dtfc_loop
- .dtfc_TileFlipShHP:
- TileFlipShHP
- b .dtfc_loop
- .dtfc_shadow_blank:
- tst r1, #1
- ldrneb r4, [r1]
- mov r6, #0xbf
- and r4, r4, #0xbf
- strneb r4, [r1], #1
- ldrh r4, [r1]
- orr r6, r6, r6, lsl #8
- and r4, r4, r6
- strh r4, [r1], #2
- ldrh r4, [r1]
- and r4, r4, r6
- strh r4, [r1], #2
- ldrh r4, [r1]
- and r4, r4, r6
- strh r4, [r1], #2
- ldrh r4, [r1]
- and r4, r4, r6
- streqh r4, [r1]
- strneb r4, [r1]
- b .dtfc_loop
- .dtfc_cut_tile:
- add r4, r4, #7 @ 0-6
- mov r4, r4, lsl #2
- mov r12,#0xf<<28
- mov r12,r12,asr r4
- mov r2, r2, ror #16
- tst r5, #0x0800 @ flipped?
- mvnne r12,r12
- and r2, r2, r12
- mov r2, r2, ror #16
- mov r12,#0xf
- tst r8, #1
- bne .dtfc_shadow
- tst r2, r2
- beq .dtfc_loop
- tst r5, #0x0800
- beq .dtfc_TileNorm
- b .dtfc_TileFlip
- @ check if we have detected layer covered with hi-prio tiles:
- .dtfc_check_rendflags:
- ldr r1, =rendstatus
- ldr r2, [r1]
- tst r2, #(PDRAW_PLANE_HI_PRIO|PDRAW_SHHI_DONE)
- beq .dtfc_loop
- bic r8, r8, #1 @ sh/hi mode off
- tst r2, #PDRAW_SHHI_DONE
- bne .dtfc_loop @ already processed
- orr r2, r2, #PDRAW_SHHI_DONE
- str r2, [r1]
- add r1, r11,#8
- mov r3, #320/4/4
- mov r6, #0xbf
- orr r6, r6, r6, lsl #8
- orr r6, r6, r6, lsl #16
- .dtfc_loop_shprep:
- ldmia r1, {r2,r4,r5,r7}
- subs r3, r3, #1
- and r2, r2, r6
- and r4, r4, r6
- and r5, r5, r6
- and r7, r7, r6
- stmia r1!,{r2,r4,r5,r7}
- bne .dtfc_loop_shprep
- mvn r5, #0 @ r5=prevcode=-1
- b .dtfc_loop
- .pool
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .global DrawSpritesSHi @ unsigned char *sprited
- DrawSpritesSHi:
- ldr r3, [r0]
- mov r12,#0xff
- ands r3, r3, #0x7f
- bxeq lr
- stmfd sp!, {r4-r11,lr}
- strb r12,[r0,#2] @ set end marker
- add r10,r0, #3 @ r10=HighLnSpr end
- add r10,r10,r3 @ r10=HighLnSpr end
- .if OVERRIDE_HIGHCOL
- ldr r11,=HighCol
- mov r12,#0xf
- ldr r11,[r11]
- .else
- ldr r11,=HighCol
- mov r12,#0xf
- .endif
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram
- DrawSpriteSHi:
- @ draw next sprite
- ldrb r0, [r10,#-1]!
- ldr r1, =HighPreSpr
- @ ldr r8, [sp, #-4]
- cmp r0, #0xff
- ldmeqfd sp!, {r4-r11,pc} @ end of list
- and r0, r0, #0x7f
- add r0, r1, r0, lsl #3
- ldr r9, [r0, #4] @ sprite[1]
- mov r2, r9, asr #16 @ r2=sx
- mov r9, r9, lsl #16
- mov r3, r9, lsr #31 @ priority
- mov r9, r9, lsr #16
- @ orr r9, r9, r8, lsl #31 @ r9=code|sh[31] @@ sh is always on here now
- and r4, r9, #0x6000
- orr r9, r9, r4, lsl #16
- orr r9, r9, #0x90000000 @ r9=scc1 ???? ... <code> (s=shadow/hilight, cc=pal)
- cmp r12,r9, lsr #28 @ sh/hi with pal3?
- cmpne r3, #1 @ if not, is it hi prio?
- bne DrawSpriteSHi @ non-operator low sprite, already drawn
- ldr r3, [r0] @ sprite[0]
- ldr r7, =DrawScanline
- mov r6, r3, lsr #28
- sub r6, r6, #1 @ r6=width-1 (inc later)
- mov r5, r3, lsr #24
- and r5, r5, #7 @ r5=height
- mov r0, r3, lsl #16 @ r4=sy<<16 (tmp)
- ldr r7, [r7]
- sub r7, r7, r0, asr #16 @ r7=row=DrawScanline-sy
- tst r9, #0x1000
- movne r0, r5, lsl #3
- subne r0, r0, #1
- subne r7, r0, r7 @ if (code&0x1000) row=(height<<3)-1-row; // Flip Y
- add r8, r9, r7, lsr #3 @ tile+=row>>3; // Tile number increases going down
- tst r9, #0x0800
- mlane r8, r5, r6, r8 @ if (code&0x0800) { tile+=delta*(width-1);
- rsbne r5, r5, #0 @ delta=-delta; } // r5=delta now
- mov r8, r8, lsl #21
- mov r8, r8, lsr #17
- and r7, r7, #7
- add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address
- mov r5, r5, lsl #4 @ delta<<=4; // Delta of address
- mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30);
- add r6, r6, #1 @ inc now
- adds r0, r2, #0 @ mov sx to r0 and set ZV flags
- b .dsprShi_loop_enter
- .dsprShi_loop:
- subs r6, r6, #1 @ width--
- beq DrawSpriteSHi
- adds r0, r0, #8 @ sx+=8
- add r8, r8, r5 @ tile+=delta
- .dsprShi_loop_enter:
- ble .dsprShi_loop @ sx <= 0
- cmp r0, #328
- bge DrawSpriteSHi
- mov r8, r8, lsl #17
- mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
- ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- add r1, r11, r0 @ r1=pdest
- tst r2, r2
- beq .dsprShi_loop
- cmp r12, r9, lsr #28
- beq .dsprShi_shadow
- cmp r2, r2, ror #4
- beq .dsprShi_SingleColor @ tileline singlecolor
- tst r9, #0x0800
- bne .dsprShi_TileFlip
- @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
- @ scratch: r4, r7
- .dsprShi_TileNorm:
- TileNorm r12
- b .dsprShi_loop
- .dsprShi_TileFlip:
- TileFlip r12
- b .dsprShi_loop
- .dsprShi_SingleColor:
- and r4, r2, #0xf
- orr r4, r3, r4
- orr r4, r4, r4, lsl #8
- tst r0, #1 @ not aligned?
- strneb r4, [r1], #1
- streqh r4, [r1], #2
- strh r4, [r1], #2
- strh r4, [r1], #2
- strh r4, [r1], #2
- strneb r4, [r1], #1
- b .dsprShi_loop
- .dsprShi_shadow:
- tst r9, #0x8000
- beq .dsprShi_shadow_lowpri
- cmp r2, r2, ror #4
- beq .dsprShi_singlec_sh
- tst r9, #0x0800
- bne .dsprShi_TileFlip_sh
- @ (r1=pdest, r2=pixels8, r3=pal) r4, r7: scratch, r12: helper pattern
- .dsprShi_TileNorm_sh:
- TileNormSh
- b .dsprShi_loop
- .dsprShi_TileFlip_sh:
- TileFlipSh
- b .dsprShi_loop
- .dsprShi_singlec_sh:
- cmp r2, #0xe0000000
- bcc .dsprShi_SingleColor @ normal singlecolor tileline (carry inverted in ARM)
- tst r2, #0x10000000
- bne .dsprShi_sh_sh
- TileSingleHi
- b .dsprShi_loop
- .dsprShi_sh_sh:
- TileSingleSh
- b .dsprShi_loop
- .dsprShi_shadow_lowpri:
- tst r9, #0x800
- bne .dsprShi_TileFlip_sh_lp
- .dsprShi_TileNorm_sh_lp:
- TileNormSh_onlyop_lp
- b .dsprShi_loop
- .dsprShi_TileFlip_sh_lp:
- TileFlipSh_onlyop_lp
- b .dsprShi_loop
- .pool
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .global DrawAllSprites @ unsigned char *sprited, int prio, int sh
- DrawAllSprites:
- ldr r3, =rendstatus
- orr r1, r2, r1, lsl #1
- ldr r12,[r3]
- tst r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)
- beq das_no_prep
- stmfd sp!, {r0,r1,lr}
- and r0, r12,#PDRAW_DIRTY_SPRITES
- bic r12,r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)
- str r12,[r3]
- bl PrepareSprites
- ldmfd sp!, {r0,r1,lr}
- das_no_prep:
- ldr r3, [r0]
- ands r3, r3, #0x7f
- bxeq lr
- @ time to do some real work
- stmfd sp!, {r4-r11,lr}
- mov r12,#0xff
- strb r12,[r0,#2] @ set end marker
- add r10,r0, #3
- add r10,r10,r3 @ r10=HighLnSpr end
- str r1, [sp, #-4] @ no calls after this point
- .if OVERRIDE_HIGHCOL
- ldr r11,=HighCol
- mov r12,#0xf
- ldr r11,[r11]
- .else
- ldr r11,=HighCol
- mov r12,#0xf
- .endif
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram
- @ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size
- @ + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
- DrawSprite: @ was: unsigned int *sprite, int sh, int acc_sprites
- @ draw next sprite
- ldrb r0, [r10,#-1]!
- ldr r1, =HighPreSpr
- ldr r8, [sp, #-4]
- mov r2, r0, lsr #7
- cmp r0, #0xff
- ldmeqfd sp!, {r4-r11,pc} @ end of list
- cmp r2, r8, lsr #1
- bne DrawSprite @ wrong priority
- and r0, r0, #0x7f
- add r0, r1, r0, lsl #3
- @ stmfd sp!, {r4-r9,r11,lr}
- @ orr r8, r2, r1, lsl #4
- ldr r3, [r0] @ sprite[0]
- ldr r7, =DrawScanline
- mov r6, r3, lsr #28
- sub r6, r6, #1 @ r6=width-1 (inc later)
- mov r5, r3, lsr #24
- and r5, r5, #7 @ r5=height
- mov r4, r3, lsl #16 @ r4=sy<<16 (tmp)
- ldr r7, [r7]
- ldr r9, [r0, #4]
- sub r7, r7, r4, asr #16 @ r7=row=DrawScanline-sy
- mov r2, r9, asr #16 @ r2=sx
- mov r9, r9, lsl #16
- mov r9, r9, lsr #16
- orr r9, r9, r8, lsl #31 @ r9=code|sh[31]
- tst r9, #0x1000
- movne r4, r5, lsl #3
- subne r4, r4, #1
- subne r7, r4, r7 @ if (code&0x1000) row=(height<<3)-1-row; // Flip Y
- add r8, r9, r7, lsr #3 @ tile+=row>>3; // Tile number increases going down
- tst r9, #0x0800
- mlane r8, r5, r6, r8 @ if (code&0x0800) { tile+=delta*(width-1);
- rsbne r5, r5, #0 @ delta=-delta; } // r5=delta now
- mov r8, r8, lsl #21
- mov r8, r8, lsr #17
- and r7, r7, #7
- add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address
- .dspr_continue:
- @ cache some stuff to avoid mem access
- mov r5, r5, lsl #4 @ delta<<=4; // Delta of address
- and r4, r9, #0x6000
- orr r9, r9, r4, lsl #16
- orrs r9, r9, #0x10000000 @ r9=scc1 ???? ... <code> (s=shadow/hilight, cc=pal)
- mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30);
- orrmi r3, r3, #0x40 @ for sh/hi
- add r6, r6, #1 @ inc now
- adds r0, r2, #0 @ mov sx to r0 and set ZV flags
- b .dspr_loop_enter
- .dspr_loop:
- subs r6, r6, #1 @ width--
- beq DrawSprite
- adds r0, r0, #8 @ sx+=8
- add r8, r8, r5 @ tile+=delta
- .dspr_loop_enter:
- ble .dspr_loop @ sx <= 0
- cmp r0, #328
- bge DrawSprite
- mov r8, r8, lsl #17
- mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
- ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- add r1, r11, r0 @ r1=pdest
- tst r2, r2
- beq .dspr_loop
- cmp r12, r9, lsr #28
- beq .dspr_shadow
- cmp r2, r2, ror #4
- beq .dspr_SingleColor @ tileline singlecolor
- tst r9, #0x0800
- bne .dspr_TileFlip
- @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
- @ scratch: r4, r7
- .dspr_TileNorm:
- TileNorm r12
- b .dspr_loop
- .dspr_TileFlip:
- TileFlip r12
- b .dspr_loop
- .dspr_singlec_sh:
- cmp r2, #0xe0000000
- bcs .dspr_TileNorm_sh @ op. tileline, markop. XXX: maybe add a spec. handler?
- .dspr_SingleColor:
- and r4, r2, #0xf
- orr r4, r3, r4
- orr r4, r4, r4, lsl #8
- tst r0, #1 @ not aligned?
- strneb r4, [r1], #1
- streqh r4, [r1], #2
- strh r4, [r1], #2
- strh r4, [r1], #2
- strh r4, [r1], #2
- strneb r4, [r1], #1
- b .dspr_loop
- .dspr_shadow:
- cmp r2, r2, ror #4
- beq .dspr_singlec_sh
- tst r9, #0x0800
- bne .dspr_TileFlip_sh
- @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
- .dspr_TileNorm_sh:
- TileNormSh_markop
- b .dspr_loop
- .dspr_TileFlip_sh:
- TileFlipSh_markop
- b .dspr_loop
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- .global DrawWindow @ int tstart, int tend, int prio, int sh // int *hcache
- DrawWindow:
- stmfd sp!, {r4-r11,lr}
- ldr r11, =(Pico+0x22228) @ Pico.video
- ldr r10, =DrawScanline
- ldrb r12, [r11, #3] @ pvid->reg[3]
- ldr r10, [r10]
- ldr r4, [r11, #12]
- mov r5, r10, lsr #3
- and r10, r10, #7
- mov r10, r10, lsl #1 @ r10=ty
- mov r12, r12, lsl #10
- tst r4, #1 @ 40 cell mode?
- andne r12, r12, #0xf000 @ 0x3c<<10
- andeq r12, r12, #0xf800
- addne r12, r12, r5, lsl #7
- addeq r12, r12, r5, lsl #6 @ nametab
- add r12, r12, r0, lsl #2 @ +starttile
- ldr r6, =rendstatus
- ldr lr, =(Pico+0x10000) @ lr=Pico.vram
- ldr r6, [r6]
- @ fetch the first code now
- ldrh r7, [lr, r12]
- ands r6, r6, #PDRAW_WND_DIFF_PRIO
- orr r6, r6, r2
- eoreq r8, r2, r7, lsr #15 @ do prio bits differ?
- cmpeq r8, #1
- ldmeqfd sp!, {r4-r11,pc} @ yes, assume that whole window uses same priority
- orr r6, r6, r3, lsl #8 @ shadow mode
- sub r8, r1, r0
- @ cache some stuff to avoid mem access
- .if OVERRIDE_HIGHCOL
- ldr r11,=HighCol
- mov r8, r8, lsl #1 @ cells
- ldr r11,[r11]
- mvn r9, #0 @ r9=prevcode=-1
- add r11,r11,#8
- .else
- ldr r11,=(HighCol+8)
- mov r8, r8, lsl #1 @ cells
- mvn r9, #0 @ r9=prevcode=-1
- .endif
- add r1, r11, r0, lsl #4 @ r1=pdest
- mov r0, #0xf
- b .dwloop_enter
- @ r4,r5 are scratch in this loop
- .dwloop:
- add r1, r1, #8
- .dwloop_nor1:
- add r12, r12, #2 @ halfwords
- ldrh r7, [lr, r12] @ r7=code (int, but from unsigned, no sign extend)
- subs r8, r8, #1
- beq .dwloop_end @ done
- eor r5, r6, r7, lsr #15
- tst r5, #1
- orrne r6, r6, #2 @ wrong pri
- bne .dwloop
- cmp r7, r9
- beq .dw_samecode @ we know stuff about this tile already
- .dwloop_enter:
- mov r9, r7 @ remember code
- movs r2, r9, lsl #20 @ if (code&0x1000)
- mov r2, r2, lsl #1
- add r2, r10, r2, lsr #17 @ r2=addr=(code&0x7ff)<<4; addr+=ty
- eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
- and r3, r9, #0x6000
- mov r3, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
- ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
- .dw_samecode:
- tst r6, #0x100
- bne .dw_shadow
- .dw_shadow_done:
- tst r2, r2
- beq .dwloop @ tileline blank
- cmp r2, r2, ror #4
- beq .dw_SingleColor @ tileline singlecolor
- tst r9, #0x0800
- bne .dw_TileFlip
- @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
- .dw_TileNorm:
- TileNorm r0
- b .dwloop
- .dw_TileFlip:
- TileFlip r0
- b .dwloop
- .dw_SingleColor:
- and r4, r0, r2 @ #0x0000000f
- orr r4, r3, r4
- orr r4, r4, r4, lsl #8
- orr r4, r4, r4, lsl #16
- mov r5, r4
- stmia r1!, {r4,r5}
- b .dwloop_nor1 @ we incremeted r1 ourselves
- .dw_shadow:
- tst r6, #1 @ hi pri?
- orreq r3, r3, #0x40
- beq .dw_shadow_done
- ldr r4, [r1]
- mov r5, #0x3f
- orr r5, r5, r5, lsl #8
- orr r5, r5, r5, lsl #16
- and r4, r4, r5
- str r4, [r1]
- ldr r4, [r1,#4]
- and r4, r4, r5
- str r4, [r1,#4]
- b .dw_shadow_done
- .dwloop_end:
- ldr r0, =rendstatus
- ldr r1, [r0]
- and r6, r6, #PDRAW_WND_DIFF_PRIO
- orr r1, r1, r6
- str r1, [r0]
- ldmfd sp!, {r4-r11,r12}
- bx r12
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- @ hilights 2 pixels in RGB444/BGR444 format
- .macro TileDoShHi2Pixels444 reg
- mov \reg, \reg, ror #12
- adds \reg, \reg, #0x40000000
- orrcs \reg, \reg, #0xf0000000
- mov \reg, \reg, ror #28
- adds \reg, \reg, #0x40000000
- orrcs \reg, \reg, #0xf0000000
- mov \reg, \reg, ror #28
- adds \reg, \reg, #0x40000000
- orrcs \reg, \reg, #0xf0000000
- mov \reg, \reg, ror #24
- adds \reg, \reg, #0x40000000
- orrcs \reg, \reg, #0xf0000000
- mov \reg, \reg, ror #28
- adds \reg, \reg, #0x40000000
- orrcs \reg, \reg, #0xf0000000
- mov \reg, \reg, ror #28
- adds \reg, \reg, #0x40000000
- orrcs \reg, \reg, #0xf0000000
- mov \reg, \reg, ror #12
- .endm
- .global FinalizeLineBGR444 @ int sh
- FinalizeLineBGR444:
- stmfd sp!, {r4-r6,lr}
- mov r6, r0
- ldr lr, =(Pico+0x22228) @ Pico.video
- ldr r0, =DrawLineDest
- ldrb r12, [lr, #12]
- ldr r0, [r0]
- sub r3, lr, #0x128 @ r3=Pico.cram
- tst r12, #1
- movne r2, #320/4 @ len
- bne .fl_no32colBGR444
- ldr r4, =PicoOpt
- mov r2, #256/4
- ldr r4, [r4]
- tst r4, #0x100
- addeq r0, r0, #32*2
- .fl_no32colBGR444:
- tst r6, r6
- beq .fl_noshBGR444
- ldr r4, =HighPal
- ldrb r12, [lr, #-0x1a] @ 0x2220e ~ dirtyPal
- tst r12, r12
- moveq r3, r4
- beq .fl_noshBGR444
- mov r12, #0
- strb r12, [lr, #-0x1a]
- mov lr, #0x40/8
- @ copy pal:
- .fl_loopcpBGR444:
- ldmia r3!, {r1,r5,r6,r12}
- subs lr, lr, #1
- stmia r4!, {r1,r5,r6,r12}
- bne .fl_loopcpBGR444
- @ shadowed pixels:
- mov r12, #0x0077
- orr r12,r12,#0x0700
- orr r12,r12,r12,lsl #16
- sub r3, r3, #0x40*2
- add r5, r4, #0x80*2
- mov lr, #0x40/4
- .fl_loopcpBGR444_sh:
- ldmia r3!, {r1,r6}
- subs lr, lr, #1
- and r1, r12, r1, lsr #1
- and r6, r12, r6, lsr #1
- stmia r4!, {r1,r6}
- stmia r5!, {r1,r6}
- bne .fl_loopcpBGR444_sh
- @ hilighted pixels:
- sub r3, r3, #0x40*2
- mov lr, #0x40/2
- .fl_loopcpBGR444_hi:
- ldr r1, [r3], #4
- TileDoShHi2Pixels444 r1
- str r1, [r4], #4
- subs lr, lr, #1
- bne .fl_loopcpBGR444_hi
- sub r3, r4, #0x40*3*2
- mov r6, #1
- .fl_noshBGR444:
- ldr r12,=rendstatus
- eors r6, r6, #1 @ sh is 0
- ldr r12,[r12]
- mov lr, #0xff
- tstne r12,#PDRAW_ACC_SPRITES
- .if OVERRIDE_HIGHCOL
- ldr r1, =HighCol
- movne lr, #0x3f
- ldr r1, [r1]
- mov lr, lr, lsl #1
- add r1, r1, #8
- .else
- ldr r1, =(HighCol+8)
- movne lr, #0x3f
- mov lr, lr, lsl #1
- .endif
- .fl_loopBGR444:
- ldr r12, [r1], #4
- subs r2, r2, #1
- and r4, lr, r12, lsl #1
- ldrh r4, [r3, r4]
- and r5, lr, r12, lsr #7
- ldrh r5, [r3, r5]
- and r6, lr, r12, lsr #15
- ldrh r6, [r3, r6]
- and r12,lr, r12, lsr #23
- ldrh r12,[r3, r12] @ 1c.i.
- orr r4, r4, r5, lsl #16
- orr r5, r6, r12,lsl #16
- stmia r0!, {r4,r5}
- bne .fl_loopBGR444
- ldmfd sp!, {r4-r6,lr}
- bx lr
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- @ Convert 0000bbb0 ggg0rrr0
- @ to rrrrrggg gggbbbbb
- @ r2,r3 - scratch, lr = 0x001c001c, r8 = 0x08610861
- .macro convRGB565 reg
- and r2, lr, \reg,lsr #7 @ b
- and r3, lr, \reg,lsr #3 @ g
- and \reg, lr, \reg,lsl #1 @ r
- orr r2, r2, r3, lsl #6
- orr \reg, r2, \reg,lsl #11
- and r2, r8, \reg,lsr #4
- orr \reg, \reg, r2
- .endm
- @ trashes: r2-r8,r12,lr; r8 = 0x08610861; r0,r1 are advanced
- .macro vidConvCpyRGB565_local
- mov r12, r2, lsr #3 @ repeats
- mov lr, #0x001c0000
- orr lr, lr, #0x01c @ lr == pattern 0x001c001c
- 0:
- ldmia r1!, {r4-r7}
- subs r12, r12, #1
- convRGB565 r4
- str r4, [r0], #4
- convRGB565 r5
- str r5, [r0], #4
- convRGB565 r6
- str r6, [r0], #4
- convRGB565 r7
- str r7, [r0], #4
- bgt 0b
- .endm
- .global vidConvCpyRGB565
- vidConvCpyRGB565: @ void *to, void *from, int pixels
- stmfd sp!, {r4-r9,lr}
- mov r8, #0x0061
- orr r8, r8, #0x0800
- orr r8, r8, r8, lsl #16
- vidConvCpyRGB565_local
- ldmfd sp!, {r4-r9,lr}
- bx lr
- .global PicoDoHighPal555 @ int sh
- PicoDoHighPal555:
- stmfd sp!, {r4-r9,lr}
- mov r1, #0
- ldr r8, =(Pico+0x22228) @ Pico.video
- PicoDoHighPal555_nopush:
- orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h
- ldr r0, =HighPal
- mov r1, #0
- strb r1, [r8, #-0x1a] @ 0x2220e ~ dirtyPal
- sub r1, r8, #0x128 @ r1=Pico.cram
- mov r2, #0x40
- mov r8, #0x0061
- orr r8, r8, #0x0800
- orr r8, r8, r8, lsl #16
- vidConvCpyRGB565_local
- tst r9, #(1<<31)
- beq PicoDoHighPal555_end
- ldr r3, =HighPal
- @ shadowed pixels:
- mov r12, #0x008e
- add r4, r3, #0x40*2
- orr r12,r12,#0x7300
- add r5, r3, #0xc0*2
- orr r12,r12,r12,lsl #16
- mov lr, #0x40/4
- .fl_loopcpRGB555_sh:
- ldmia r3!, {r1,r6}
- subs lr, lr, #1
- and r1, r12, r1, lsr #1
- and r6, r12, r6, lsr #1
- stmia r4!, {r1,r6}
- stmia r5!, {r1,r6}
- bne .fl_loopcpRGB555_sh
- @ hilighted pixels:
- @ t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e;
- @ t |= (t >> 4) & 0x08610861;
- @ r8=0x08610861
- sub r3, r3, #0x40*2
- mov lr, #0x40/4
- .fl_loopcpRGB555_hi:
- ldmia r3!, {r1,r6}
- and r1, r12, r1, lsr #1
- and r6, r12, r6, lsr #1
- add r1, r12, r1
- add r6, r12, r6
- and r5, r8, r1, lsr #4
- and r7, r8, r6, lsr #4
- orr r1, r1, r5
- orr r6, r6, r7
- stmia r4!, {r1,r6}
- subs lr, lr, #1
- bne .fl_loopcpRGB555_hi
- mov r0, #1
- PicoDoHighPal555_end:
- tst r9, #1
- ldmeqfd sp!, {r4-r9,pc}
- ldr r8, =(Pico+0x22228) @ Pico.video
- b FinalizeLineRGB555_pal_done
- .global FinalizeLine555 @ int sh
- FinalizeLine555:
- stmfd sp!, {r4-r9,lr}
- ldr r8, =(Pico+0x22228) @ Pico.video
- ldrb r2, [r8, #-0x1a] @ 0x2220e ~ dirtyPal
- mov r1, #1
- tst r2, r2
- bne PicoDoHighPal555_nopush
- FinalizeLineRGB555_pal_done:
- ldr r3, =HighPal
- ldr r12,=rendstatus
- eors r0, r0, #1 @ sh is 0
- ldr r12,[r12]
- mov lr, #0xff
- tstne r12,#PDRAW_ACC_SPRITES
- movne lr, #0x3f
- .if OVERRIDE_HIGHCOL
- ldr r1, =HighCol
- ldr r0, =DrawLineDest
- ldr r1, [r1]
- ldr r0, [r0]
- add r1, r1, #8
- .else
- ldr r0, =DrawLineDest
- ldr r1, =(HighCol+8)
- ldr r0, [r0]
- .endif
- ldrb r12, [r8, #12]
- mov lr, lr, lsl #1
- tst r12, #1
- movne r2, #320/8 @ len
- bne .fl_no32colRGB555
- ldr r4, =PicoOpt
- mov r2, #256/8
- ldr r4, [r4]
- tst r4, #0x4000
- bne .fl_32scale_RGB555
- tst r4, #0x0100
- addeq r0, r0, #32*2
- .fl_no32colRGB555:
- .if UNALIGNED_DRAWLINEDEST
- @ this is basically for Gizmondo, which has unaligned odd lines in the framebuffer
- tst r0, #2
- bne .fl_RGB555u
- .endif
- .fl_loopRGB555:
- ldr r12, [r1], #4
- ldr r7, [r1], #4
- and r4, lr, r12, lsl #1
- ldrh r4, [r3, r4]
- and r5, lr, r12, lsr #7
- ldrh r5, [r3, r5]
- and r6, lr, r12, lsr #15
- ldrh r6, [r3, r6]
- orr r4, r4, r5, lsl #16
- and r5, lr, r12, lsr #23
- ldrh r5, [r3, r5]
- and r8, lr, r7, lsl #1
- ldrh r8, [r3, r8]
- orr r5, r6, r5, lsl #16
- and r6, lr, r7, lsr #7
- ldrh r6, [r3, r6]
- and r12,lr, r7, lsr #15
- ldrh r12,[r3, r12]
- and r7, lr, r7, lsr #23
- ldrh r7, [r3, r7]
- orr r8, r8, r6, lsl #16
- subs r2, r2, #1
- orr r12,r12, r7, lsl #16
- stmia r0!, {r4,r5,r8,r12}
- bne .fl_loopRGB555
- ldmfd sp!, {r4-r9,lr}
- bx lr
- .fl_32scale_RGB555:
- stmfd sp!, {r10}
- mov r9, #0x3900 @ f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
- orr r9, r9, #0x00e7
- .if UNALIGNED_DRAWLINEDEST
- tst r0, #2
- bne .fl_32scale_RGB555u
- .endif
- .fl_loop32scale_RGB555:
- ldr r12, [r1], #4
- ldr r7, [r1], #4
- and r4, lr, r12,lsl #1
- ldrh r4, [r3, r4]
- and r5, lr, r12,lsr #7
- ldrh r5, [r3, r5]
- and r4, r4, r9, lsl #2
- orr r4, r4, r4, lsl #14 @ r4[31:16] = 1/4 pix_s 0
- and r5, r5, r9, lsl #2
- sub r6, r5, r5, lsr #2 @ r6 = 3/4 pix_s 1
- add r4, r4, r6, lsl #16 @ pix_d 0, 1
- and r6, lr, r12,lsr #15
- ldrh r6, [r3, r6]
- and r12,lr, r12,lsr #23
- ldrh r12,[r3, r12]
- and r6, r6, r9, lsl #2
- add r5, r5, r6
- mov r5, r5, lsr #1
- sub r6, r6, r6, lsr #2 @ r6 = 3/4 pix_s 2
- orr r5, r5, r6, lsl #16
- and r6, lr, r7, lsl #1
- ldrh r6, [r3, r6]
- and r12,r12,r9, lsl #2
- add r5, r5, r12,lsl #14 @ pix_d 2, 3
- and r6, r6, r9, lsl #2
- orr r6, r12,r6, lsl #16 @ pix_d 4, 5
- and r12,lr, r7, lsr #7
- ldrh r12,[r3, r12]
- and r10,lr, r7, lsr #15
- ldrh r10,[r3, r10]
- and r12,r12,r9, lsl #2
- sub r8, r12,r12,lsr #2 @ r8 = 3/4 pix_s 1
- add r8, r8, r6, lsr #18
- and r7, lr, r7, lsr #23
- ldrh r7, [r3, r7]
- and r10,r10,r9, lsl #2
- orr r8, r8, r10,lsl #15
- add r8, r8, r12,lsl #15 @ pix_d 6, 7
- sub r10,r10,r10,lsr #2 @ r10= 3/4 pix_s 2
- and r7, r7, r9, lsl #2
- add r10,r10,r7, lsr #2 @ += 1/4 pix_s 3
- orr r10,r10,r7, lsl #16 @ pix_d 8, 9
- subs r2, r2, #1
- stmia r0!, {r4,r5,r6,r8,r10}
- bne .fl_loop32scale_RGB555
- ldmfd sp!, {r10}
- ldmfd sp!, {r4-r9,lr}
- bx lr
- .if UNALIGNED_DRAWLINEDEST
- @ unaligned versions of loops
- @ warning: starts drawing 2bytes before dst
- .fl_RGB555u:
- sub r0, r0, #2 @ initial adjustment
- mov r8, #0
- .fl_loopRGB555u:
- ldr r12, [r1], #4
- ldr r7, [r1], #4
- and r6, lr, r12,lsl #1
- ldrh r6, [r3, r6]
- and r5, lr, r12,lsr #7
- ldrh r5, [r3, r5]
- orr r4, r8, r6, lsl #16
- and r6, lr, r12,lsr #15
- ldrh r6, [r3, r6]
- and r8, lr, r12,lsr #23
- ldrh r8, [r3, r8]
- orr r5, r5, r6, lsl #16
- and r6, lr, r7, lsl #1
- ldrh r6, [r3, r6]
- and r12,lr, r7, lsr #7
- ldrh r12,[r3, r12]
- orr r6, r8, r6, lsl #16
- and r8, lr, r7, lsr #15
- ldrh r8, [r3, r8]
- and r7, lr, r7, lsr #23
- subs r2, r2, #1
- orr r12,r12,r8, lsl #16
- ldrh r8, [r3, r7]
- stmia r0!, {r4,r5,r6,r12}
- bne .fl_loopRGB555u
- strh r8, [r0], #2
- ldmfd sp!, {r4-r9,lr}
- bx lr
- .fl_32scale_RGB555u:
- sub r0, r0, #2 @ initial adjustment
- mov r4, #0
- @ r9 f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
- .fl_loop32scale_RGB555u:
- ldr r12, [r1], #4
- ldr r7, [r1], #4
- and r6, lr, r12,lsl #1
- ldrh r6, [r3, r6]
- and r5, lr, r12,lsr #7
- ldrh r5, [r3, r5]
- and r6, r6, r9, lsl #2
- orr r4, r4, r6, lsl #16 @ r4 = pix_d -1, 0
- and r5, r5, r9, lsl #2
- sub r8, r5, r5, lsr #2 @ r8 = 3/4 pix_s 1
- add r6, r8, r6, lsr #2 @ r6 = (1/4 pix_s 0) + (3/4 pix_s 1)
- orr r5, r6, r5, lsl #15
- and r6, lr, r12,lsr #15
- ldrh r6, [r3, r6]
- and r12,lr, r12,lsr #23
- ldrh r12,[r3, r12]
- and r6, r6, r9, lsl #2
- add r5, r5, r6, lsl #15 @ r5 = pix_d 1, 2
- and r8, lr, r7, lsl #1
- ldrh r8, [r3, r8]
- and r10,lr, r7, lsr #7
- ldrh r10,[r3, r10]
- and r12,r12,r9, lsl #2
- sub r6, r6, r6, lsr #2 @ r6 = 3/4 pix_s 2
- add r6, r6, r12,lsr #2
- orr r6, r6, r12,lsl #16 @ r6 = pix_d 3, 4
- and r8, r8, r9, lsl #2
- and r10,r10,r9, lsl #2
- sub r12,r10,r10,lsr #2 @ r12 = 3/4 pix_s 5
- orr r8, r8, r8, lsl #14
- add r8, r8, r12,lsl #16 @ r8 = pix_d 5, 6
- and r12,lr, r7, lsr #15
- ldrh r12,[r3, r12]
- and r7, lr, r7, lsr #23
- ldrh r7, [r3, r7]
- and r12,r12,r9, lsl #2
- add r10,r10,r12
- mov r10,r10, lsr #1
- sub r12,r12,r12,lsr #2 @ r12 = 3/4 pix_s 6
- orr r10,r10,r12,lsl #16
- and r7, r7, r9, lsl #2
- add r10,r10,r7, lsl #14 @ r10 = pix_d 7, 8
- subs r2, r2, #1
- stmia r0!, {r4,r5,r6,r8,r10}
- mov r4, r7
- bne .fl_loop32scale_RGB555u
- strh r4, [r0], #2
- ldmfd sp!, {r10}
- ldmfd sp!, {r4-r9,lr}
- bx lr
- .endif @ UNALIGNED_DRAWLINEDEST
- @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- @ utility
- .global blockcpy @ void *dst, void *src, size_t n
- blockcpy:
- stmfd sp!, {r4,r5}
- mov r2, r2, lsr #4
- blockcpy_loop:
- ldmia r1!, {r3-r5,r12}
- subs r2, r2, #1
- stmia r0!, {r3-r5,r12}
- bne blockcpy_loop
- ldmfd sp!, {r4,r5}
- bx lr
- .global blockcpy_or @ void *dst, void *src, size_t n, int pat
- blockcpy_or:
- stmfd sp!, {r4-r6}
- orr r3, r3, r3, lsl #8
- orr r3, r3, r3, lsl #16
- mov r2, r2, lsr #4
- blockcpy_loop_or:
- ldmia r1!, {r4-r6,r12}
- subs r2, r2, #1
- orr r4, r4, r3
- orr r5, r5, r3
- orr r6, r6, r3
- orr r12,r12,r3
- stmia r0!, {r4-r6,r12}
- bne blockcpy_loop_or
- ldmfd sp!, {r4-r6}
- bx lr
- @ vim:filetype=armasm
|