3 # several drawing related functions for Allegrex MIPS
4 # (c) Copyright 2007, Grazvydas "notaz" Ignotas
7 .set noreorder # don't reorder any instructions
8 .set noat # don't use $at
13 # void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count)
20 lbu $t0, 0($a1) # tried lw here, no improvement noticed
36 ins $t0, $t1, 16, 16 # ins rt, rs, pos, size - Insert size bits starting
37 ins $t2, $t3, 16, 16 # from the LSB of rs into rt starting at position pos
42 bnez $a3, amips_clut_loop
48 .global amips_clut_6bit
57 lbu $t0, 0($a1) # tried lw here, no improvement noticed
73 ins $t0, $t1, 16, 16 # ins rt, rs, pos, size - Insert size bits starting
74 ins $t2, $t3, 16, 16 # from the LSB of rs into rt starting at position pos
79 bnez $a3, amips_clut_loop6
85 # $a0 - pd, $a1 - tile word, $a2 - pal
86 # ext rt, rs, pos, size // Extract size bits from position pos in rs and store in rt
88 .macro TilePixelPrep shift dreg offs
90 ext \dreg, $a1, \shift, 4
96 ins $t9, $t8, \offs, 1
104 lui $t1, %hi(Pico+0x10000)
106 lw $a1, %lo(Pico+0x10000)($a1) # Pico.vram + addr
109 beq $t1, $a1, SingleColor
110 and $v0, $0 # not empty tile
115 beqz $t8, tile11111111 # common case
116 lui $v1, %hi(HighCol)
117 lui $t8, %hi(TileTable)
119 lw $t8, %lo(TileTable)($t8)
120 lw $v1, %lo(HighCol)($v1)
130 TilePixelPrep 12, $t0, 0
131 TilePixelPrep 8, $t1, 1
132 TilePixelPrep 4, $t2, 2
133 TilePixelPrep 0, $t3, 3
134 TilePixelPrep 28, $t4, 4
135 TilePixelPrep 24, $t5, 5
136 TilePixelPrep 20, $t6, 6
137 TilePixelPrep 16, $t7, 7
145 TilePixelPrep 16, $t0, 0
146 TilePixelPrep 20, $t1, 1
147 TilePixelPrep 24, $t2, 2
148 TilePixelPrep 28, $t3, 3
149 TilePixelPrep 0, $t4, 4
150 TilePixelPrep 4, $t5, 5
151 TilePixelPrep 8, $t6, 6
152 TilePixelPrep 12, $t7, 7
157 lui $t9, %hi(HighCol)
158 lw $t9, %lo(HighCol)($t9)
174 or $v0, $0, 1 # empty tile
177 lw $v1, %lo(HighCol)($v1)
1719 .long 000000000000, tile00000001, tile00000010, tile00000011, tile00000100, tile00000101, tile00000110, tile00000111
1720 .long tile00001000, tile00001001, tile00001010, tile00001011, tile00001100, tile00001101, tile00001110, tile00001111
1721 .long tile00010000, tile00010001, tile00010010, tile00010011, tile00010100, tile00010101, tile00010110, tile00010111
1722 .long tile00011000, tile00011001, tile00011010, tile00011011, tile00011100, tile00011101, tile00011110, tile00011111
1723 .long tile00100000, tile00100001, tile00100010, tile00100011, tile00100100, tile00100101, tile00100110, tile00100111
1724 .long tile00101000, tile00101001, tile00101010, tile00101011, tile00101100, tile00101101, tile00101110, tile00101111
1725 .long tile00110000, tile00110001, tile00110010, tile00110011, tile00110100, tile00110101, tile00110110, tile00110111
1726 .long tile00111000, tile00111001, tile00111010, tile00111011, tile00111100, tile00111101, tile00111110, tile00111111
1727 .long tile01000000, tile01000001, tile01000010, tile01000011, tile01000100, tile01000101, tile01000110, tile01000111
1728 .long tile01001000, tile01001001, tile01001010, tile01001011, tile01001100, tile01001101, tile01001110, tile01001111
1729 .long tile01010000, tile01010001, tile01010010, tile01010011, tile01010100, tile01010101, tile01010110, tile01010111
1730 .long tile01011000, tile01011001, tile01011010, tile01011011, tile01011100, tile01011101, tile01011110, tile01011111
1731 .long tile01100000, tile01100001, tile01100010, tile01100011, tile01100100, tile01100101, tile01100110, tile01100111
1732 .long tile01101000, tile01101001, tile01101010, tile01101011, tile01101100, tile01101101, tile01101110, tile01101111
1733 .long tile01110000, tile01110001, tile01110010, tile01110011, tile01110100, tile01110101, tile01110110, tile01110111
1734 .long tile01111000, tile01111001, tile01111010, tile01111011, tile01111100, tile01111101, tile01111110, tile01111111
1735 .long tile10000000, tile10000001, tile10000010, tile10000011, tile10000100, tile10000101, tile10000110, tile10000111
1736 .long tile10001000, tile10001001, tile10001010, tile10001011, tile10001100, tile10001101, tile10001110, tile10001111
1737 .long tile10010000, tile10010001, tile10010010, tile10010011, tile10010100, tile10010101, tile10010110, tile10010111
1738 .long tile10011000, tile10011001, tile10011010, tile10011011, tile10011100, tile10011101, tile10011110, tile10011111
1739 .long tile10100000, tile10100001, tile10100010, tile10100011, tile10100100, tile10100101, tile10100110, tile10100111
1740 .long tile10101000, tile10101001, tile10101010, tile10101011, tile10101100, tile10101101, tile10101110, tile10101111
1741 .long tile10110000, tile10110001, tile10110010, tile10110011, tile10110100, tile10110101, tile10110110, tile10110111
1742 .long tile10111000, tile10111001, tile10111010, tile10111011, tile10111100, tile10111101, tile10111110, tile10111111
1743 .long tile11000000, tile11000001, tile11000010, tile11000011, tile11000100, tile11000101, tile11000110, tile11000111
1744 .long tile11001000, tile11001001, tile11001010, tile11001011, tile11001100, tile11001101, tile11001110, tile11001111
1745 .long tile11010000, tile11010001, tile11010010, tile11010011, tile11010100, tile11010101, tile11010110, tile11010111
1746 .long tile11011000, tile11011001, tile11011010, tile11011011, tile11011100, tile11011101, tile11011110, tile11011111
1747 .long tile11100000, tile11100001, tile11100010, tile11100011, tile11100100, tile11100101, tile11100110, tile11100111
1748 .long tile11101000, tile11101001, tile11101010, tile11101011, tile11101100, tile11101101, tile11101110, tile11101111
1749 .long tile11110000, tile11110001, tile11110010, tile11110011, tile11110100, tile11110101, tile11110110, tile11110111
1750 .long tile11111000, tile11111001, tile11111010, tile11111011, tile11111100, tile11111101, tile11111110, tile11111111