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