| 1 | #ifndef _OP_LIGHT_ARM_H_ |
| 2 | #define _OP_LIGHT_ARM_H_ |
| 3 | |
| 4 | //////////////////////////////////////////////////////////////////////////////// |
| 5 | // Extract bgr555 color from Gouraud u32 fixed-pt 8.3:8.3:8.2 rgb triplet |
| 6 | // |
| 7 | // INPUT: |
| 8 | // 'gCol' input: rrrrrrrrXXXggggggggXXXbbbbbbbbXX |
| 9 | // ^ bit 31 |
| 10 | // RETURNS: |
| 11 | // u16 output: 0bbbbbgggggrrrrr |
| 12 | // ^ bit 16 |
| 13 | // Where 'r,g,b' are integer bits of colors, 'X' fixed-pt, and '0' zero |
| 14 | //////////////////////////////////////////////////////////////////////////////// |
| 15 | GPU_INLINE uint_fast16_t gpuLightingRGBARM(u32 gCol) |
| 16 | { |
| 17 | uint_fast16_t out = 0x03E0; // don't need the mask after starting to write output |
| 18 | u32 tmp; |
| 19 | |
| 20 | asm ("and %[tmp], %[gCol], %[out]\n\t" // tmp holds 0x000000bbbbb00000 |
| 21 | "and %[out], %[out], %[gCol], lsr #0x0B\n\t" // out holds 0x000000ggggg00000 |
| 22 | "orr %[tmp], %[out], %[tmp], lsl #0x05\n\t" // tmp holds 0x0bbbbbggggg00000 |
| 23 | "orr %[out], %[tmp], %[gCol], lsr #0x1B\n\t" // out holds 0x0bbbbbgggggrrrrr |
| 24 | : [out] "+&r" (out), [tmp] "=&r" (tmp) |
| 25 | : [gCol] "r" (gCol) |
| 26 | ); |
| 27 | |
| 28 | return out; |
| 29 | } |
| 30 | |
| 31 | |
| 32 | GPU_INLINE uint_fast16_t gpuLightingTXTARM(uint_fast16_t uSrc, u8 r5, u8 g5, u8 b5) |
| 33 | { |
| 34 | uint_fast16_t out = 0x03E0; |
| 35 | u32 db, dg; |
| 36 | asm ("and %[dg], %[out], %[src] \n\t" |
| 37 | "orr %[dg], %[dg], %[g5] \n\t" |
| 38 | "and %[db], %[out], %[src], lsr #0x05 \n\t" |
| 39 | "ldrb %[dg], [%[lut], %[dg]] \n\t" |
| 40 | "and %[out], %[out], %[src], lsl #0x05 \n\t" |
| 41 | "orr %[out], %[out], %[r5] \n\t" |
| 42 | "orr %[db], %[db], %[b5] \n\t" |
| 43 | "ldrb %[out], [%[lut], %[out]] \n\t" |
| 44 | "ldrb %[db], [%[lut], %[db]] \n\t" |
| 45 | "tst %[src], #0x8000\n\t" |
| 46 | "orr %[out], %[out], %[dg], lsl #0x05 \n\t" |
| 47 | "orrne %[out], %[out], #0x8000\n\t" |
| 48 | "orr %[out], %[out], %[db], lsl #0x0A \n\t" |
| 49 | : [out] "=&r" (out), [db] "=&r" (db), [dg] "=&r" (dg) |
| 50 | : [r5] "r" (r5), [g5] "r" (g5), [b5] "r" (b5), |
| 51 | [lut] "r" (gpu_unai.LightLUT), [src] "r" (uSrc), "0" (out) |
| 52 | : "cc"); |
| 53 | return out; |
| 54 | } |
| 55 | |
| 56 | GPU_INLINE uint_fast16_t gpuLightingTXTGouraudARM(uint_fast16_t uSrc, u32 gCol) |
| 57 | { |
| 58 | uint_fast16_t out = 0x03E0; // don't need the mask after starting to write output |
| 59 | u32 db,dg,gtmp; |
| 60 | asm ("and %[dg], %[out], %[src] \n\t" |
| 61 | "and %[gtmp],%[out], %[gCol], lsr #0x0B \n\t" |
| 62 | "and %[db], %[out], %[src], lsr #0x05 \n\t" |
| 63 | "orr %[dg], %[dg], %[gtmp], lsr #0x05 \n\t" |
| 64 | "and %[gtmp],%[out], %[gCol] \n\t" |
| 65 | "ldrb %[dg], [%[lut], %[dg]] \n\t" |
| 66 | "and %[out], %[out], %[src], lsl #0x05 \n\t" |
| 67 | "orr %[out], %[out], %[gCol], lsr #0x1B \n\t" |
| 68 | "orr %[db], %[db], %[gtmp], lsr #0x05 \n\t" |
| 69 | "ldrb %[out], [%[lut], %[out]] \n\t" |
| 70 | "ldrb %[db], [%[lut], %[db]] \n\t" |
| 71 | "tst %[src], #0x8000\n\t" |
| 72 | "orr %[out], %[out], %[dg], lsl #0x05 \n\t" |
| 73 | "orrne %[out], %[out], #0x8000\n\t" |
| 74 | "orr %[out], %[out], %[db], lsl #0x0A \n\t" |
| 75 | : [out] "=&r" (out), [db] "=&r" (db), [dg] "=&r" (dg), |
| 76 | [gtmp] "=&r" (gtmp) \ |
| 77 | : [gCol] "r" (gCol), [lut] "r" (gpu_unai.LightLUT), "0" (out), [src] "r" (uSrc) |
| 78 | : "cc"); |
| 79 | |
| 80 | return out; |
| 81 | } |
| 82 | |
| 83 | #endif //_OP_LIGHT_ARM_H_ |