| 1 | @ vim:filetype=armasm\r |
| 2 | @ some color conversion and blitting routines\r |
| 3 | \r |
| 4 | @ (c) Copyright 2006, 2007 notaz\r |
| 5 | @ All Rights Reserved\r |
| 6 | \r |
| 7 | @ vim:filetype=armasm\r |
| 8 | \r |
| 9 | .text\r |
| 10 | .align 4\r |
| 11 | \r |
| 12 | @ Convert 0000bbb0 ggg0rrr0 0000bbb0 ggg0rrr0\r |
| 13 | @ to 00000000 rrr00000 ggg00000 bbb00000 ...\r |
| 14 | \r |
| 15 | @ lr = 0x00e000e0, out: r3=lower_pix, r2=higher_pix; trashes rin\r |
| 16 | @ if sh==2, r8=0x00404040 (sh!=0 destroys flags!)\r |
| 17 | .macro convRGB32_2 rin sh=0\r |
| 18 | and r2, lr, \rin, lsr #4 @ blue\r |
| 19 | and r3, \rin, lr\r |
| 20 | orr r2, r2, r3, lsl #8 @ g0b0g0b0\r |
| 21 | \r |
| 22 | mov r3, r2, lsl #16 @ g0b00000\r |
| 23 | and \rin,lr, \rin, ror #12 @ 00r000r0 (reversed)\r |
| 24 | orr r3, r3, \rin, lsr #16 @ g0b000r0\r |
| 25 | .if \sh == 1\r |
| 26 | mov r3, r3, ror #17 @ shadow mode\r |
| 27 | .elseif \sh == 2\r |
| 28 | adds r3, r3, #0x40000000 @ green\r |
| 29 | orrcs r3, r3, #0xe0000000\r |
| 30 | mov r3, r3, ror #8\r |
| 31 | adds r3, r3, #0x40000000\r |
| 32 | orrcs r3, r3, #0xe0000000\r |
| 33 | mov r3, r3, ror #16\r |
| 34 | adds r3, r3, #0x40000000\r |
| 35 | orrcs r3, r3, #0xe0000000\r |
| 36 | mov r3, r3, ror #24\r |
| 37 | .else\r |
| 38 | mov r3, r3, ror #16 @ r3=low\r |
| 39 | .endif\r |
| 40 | \r |
| 41 | orr r3, r3, r3, lsr #3\r |
| 42 | str r3, [r0], #4\r |
| 43 | \r |
| 44 | mov r2, r2, lsr #16\r |
| 45 | orr r2, r2, \rin, lsl #16\r |
| 46 | .if \sh == 1\r |
| 47 | mov r2, r2, lsr #1\r |
| 48 | .elseif \sh == 2\r |
| 49 | mov r2, r2, ror #8\r |
| 50 | adds r2, r2, #0x40000000 @ blue\r |
| 51 | orrcs r2, r2, #0xe0000000\r |
| 52 | mov r2, r2, ror #8\r |
| 53 | adds r2, r2, #0x40000000\r |
| 54 | orrcs r2, r2, #0xe0000000\r |
| 55 | mov r2, r2, ror #8\r |
| 56 | adds r2, r2, #0x40000000\r |
| 57 | orrcs r2, r2, #0xe0000000\r |
| 58 | mov r2, r2, ror #8\r |
| 59 | .endif\r |
| 60 | \r |
| 61 | orr r2, r2, r2, lsr #3\r |
| 62 | str r2, [r0], #4\r |
| 63 | .endm\r |
| 64 | \r |
| 65 | \r |
| 66 | .global vidConvCpyRGB32 @ void *to, void *from, int pixels\r |
| 67 | \r |
| 68 | vidConvCpyRGB32:\r |
| 69 | stmfd sp!, {r4-r7,lr}\r |
| 70 | \r |
| 71 | mov r12, r2, lsr #3 @ repeats\r |
| 72 | mov lr, #0x00e00000\r |
| 73 | orr lr, lr, #0x00e0\r |
| 74 | \r |
| 75 | .loopRGB32:\r |
| 76 | subs r12, r12, #1\r |
| 77 | \r |
| 78 | ldmia r1!, {r4-r7}\r |
| 79 | convRGB32_2 r4\r |
| 80 | convRGB32_2 r5\r |
| 81 | convRGB32_2 r6\r |
| 82 | convRGB32_2 r7\r |
| 83 | \r |
| 84 | bgt .loopRGB32\r |
| 85 | \r |
| 86 | ldmfd sp!, {r4-r7,lr}\r |
| 87 | bx lr\r |
| 88 | \r |
| 89 | \r |
| 90 | .global vidConvCpyRGB32sh @ void *to, void *from, int pixels\r |
| 91 | \r |
| 92 | vidConvCpyRGB32sh:\r |
| 93 | stmfd sp!, {r4-r7,lr}\r |
| 94 | \r |
| 95 | mov r12, r2, lsr #3 @ repeats\r |
| 96 | mov lr, #0x00e00000\r |
| 97 | orr lr, lr, #0x00e0\r |
| 98 | \r |
| 99 | .loopRGB32sh:\r |
| 100 | subs r12, r12, #1\r |
| 101 | \r |
| 102 | ldmia r1!, {r4-r7}\r |
| 103 | convRGB32_2 r4, 1\r |
| 104 | convRGB32_2 r5, 1\r |
| 105 | convRGB32_2 r6, 1\r |
| 106 | convRGB32_2 r7, 1\r |
| 107 | \r |
| 108 | bgt .loopRGB32sh\r |
| 109 | \r |
| 110 | ldmfd sp!, {r4-r7,lr}\r |
| 111 | bx lr\r |
| 112 | \r |
| 113 | \r |
| 114 | .global vidConvCpyRGB32hi @ void *to, void *from, int pixels\r |
| 115 | \r |
| 116 | vidConvCpyRGB32hi:\r |
| 117 | stmfd sp!, {r4-r7,lr}\r |
| 118 | \r |
| 119 | mov r12, r2, lsr #3 @ repeats\r |
| 120 | mov lr, #0x00e00000\r |
| 121 | orr lr, lr, #0x00e0\r |
| 122 | \r |
| 123 | .loopRGB32hi:\r |
| 124 | ldmia r1!, {r4-r7}\r |
| 125 | convRGB32_2 r4, 2\r |
| 126 | convRGB32_2 r5, 2\r |
| 127 | convRGB32_2 r6, 2\r |
| 128 | convRGB32_2 r7, 2\r |
| 129 | \r |
| 130 | subs r12, r12, #1\r |
| 131 | bgt .loopRGB32hi\r |
| 132 | \r |
| 133 | ldmfd sp!, {r4-r7,lr}\r |
| 134 | bx lr\r |
| 135 | \r |
| 136 | \r |
| 137 | @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r |
| 138 | \r |
| 139 | \r |
| 140 | @ mode2 blitter for 40 cols\r |
| 141 | .global vidCpyM2_40col @ void *dest, void *src\r |
| 142 | \r |
| 143 | vidCpyM2_40col:\r |
| 144 | stmfd sp!, {r4-r6,lr}\r |
| 145 | \r |
| 146 | mov r12, #224 @ lines\r |
| 147 | add r1, r1, #8\r |
| 148 | \r |
| 149 | vidCpyM2_40_loop_out:\r |
| 150 | mov r6, #10\r |
| 151 | vidCpyM2_40_loop:\r |
| 152 | subs r6, r6, #1\r |
| 153 | ldmia r1!, {r2-r5}\r |
| 154 | stmia r0!, {r2-r5}\r |
| 155 | ldmia r1!, {r2-r5}\r |
| 156 | stmia r0!, {r2-r5}\r |
| 157 | bne vidCpyM2_40_loop\r |
| 158 | subs r12,r12,#1\r |
| 159 | add r1, r1, #8\r |
| 160 | bne vidCpyM2_40_loop_out\r |
| 161 | \r |
| 162 | ldmfd sp!, {r4-r6,lr}\r |
| 163 | bx lr\r |
| 164 | \r |
| 165 | \r |
| 166 | @ mode2 blitter for 32 cols\r |
| 167 | .global vidCpyM2_32col @ void *dest, void *src\r |
| 168 | \r |
| 169 | vidCpyM2_32col:\r |
| 170 | stmfd sp!, {r4-r6,lr}\r |
| 171 | \r |
| 172 | mov r12, #224 @ lines\r |
| 173 | add r1, r1, #8\r |
| 174 | add r0, r0, #32\r |
| 175 | \r |
| 176 | vidCpyM2_32_loop_out:\r |
| 177 | mov r6, #8\r |
| 178 | vidCpyM2_32_loop:\r |
| 179 | subs r6, r6, #1\r |
| 180 | ldmia r1!, {r2-r5}\r |
| 181 | stmia r0!, {r2-r5}\r |
| 182 | ldmia r1!, {r2-r5}\r |
| 183 | stmia r0!, {r2-r5}\r |
| 184 | bne vidCpyM2_32_loop\r |
| 185 | subs r12,r12,#1\r |
| 186 | add r0, r0, #64\r |
| 187 | add r1, r1, #8+64\r |
| 188 | bne vidCpyM2_32_loop_out\r |
| 189 | \r |
| 190 | ldmfd sp!, {r4-r6,lr}\r |
| 191 | bx lr\r |
| 192 | \r |
| 193 | \r |
| 194 | @ mode2 blitter for 32 cols with no borders\r |
| 195 | .global vidCpyM2_32col_nobord @ void *dest, void *src\r |
| 196 | \r |
| 197 | vidCpyM2_32col_nobord:\r |
| 198 | stmfd sp!, {r4-r6,lr}\r |
| 199 | \r |
| 200 | mov r12, #224 @ lines\r |
| 201 | add r1, r1, #8\r |
| 202 | b vidCpyM2_32_loop_out\r |
| 203 | \r |
| 204 | \r |
| 205 | .global spend_cycles @ c\r |
| 206 | \r |
| 207 | spend_cycles:\r |
| 208 | mov r0, r0, lsr #2 @ 4 cycles/iteration\r |
| 209 | sub r0, r0, #2 @ entry/exit/init\r |
| 210 | .sc_loop:\r |
| 211 | subs r0, r0, #1\r |
| 212 | bpl .sc_loop\r |
| 213 | \r |
| 214 | bx lr\r |
| 215 | \r |
| 216 | \r |
| 217 | .global flushcache\r |
| 218 | \r |
| 219 | flushcache:\r |
| 220 | swi #0x9f0002\r |
| 221 | mov pc, lr\r |
| 222 | \r |
| 223 | \r |