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 # $a0 - pd, $a1 - tile word, $a2 - pal
49 # ext rt, rs, pos, size // Extract size bits from position pos in rs and store in rt
51 .macro TilePixelPrep shift dreg offs
53 ext \dreg, $a1, \shift, 4
59 ins $t9, $t8, \offs, 1
67 lui $t1, %hi(Pico+0x10000)
69 lw $a1, %lo(Pico+0x10000)($a1) # Pico.vram + addr
72 beq $t1, $a1, SingleColor
73 and $v0, $0 # not empty tile
78 beqz $t8, tile11111111 # common case
80 lui $t8, %hi(TileTable)
82 lw $t8, %lo(TileTable)($t8)
83 lw $v1, %lo(HighCol)($v1)
93 TilePixelPrep 12, $t0, 0
94 TilePixelPrep 8, $t1, 1
95 TilePixelPrep 4, $t2, 2
96 TilePixelPrep 0, $t3, 3
97 TilePixelPrep 28, $t4, 4
98 TilePixelPrep 24, $t5, 5
99 TilePixelPrep 20, $t6, 6
100 TilePixelPrep 16, $t7, 7
108 TilePixelPrep 16, $t0, 0
109 TilePixelPrep 20, $t1, 1
110 TilePixelPrep 24, $t2, 2
111 TilePixelPrep 28, $t3, 3
112 TilePixelPrep 0, $t4, 4
113 TilePixelPrep 4, $t5, 5
114 TilePixelPrep 8, $t6, 6
115 TilePixelPrep 12, $t7, 7
120 lui $t9, %hi(HighCol)
121 lw $t9, %lo(HighCol)($t9)
137 or $v0, $0, 1 # empty tile
140 lw $v1, %lo(HighCol)($v1)
1682 .long 000000000000, tile00000001, tile00000010, tile00000011, tile00000100, tile00000101, tile00000110, tile00000111
1683 .long tile00001000, tile00001001, tile00001010, tile00001011, tile00001100, tile00001101, tile00001110, tile00001111
1684 .long tile00010000, tile00010001, tile00010010, tile00010011, tile00010100, tile00010101, tile00010110, tile00010111
1685 .long tile00011000, tile00011001, tile00011010, tile00011011, tile00011100, tile00011101, tile00011110, tile00011111
1686 .long tile00100000, tile00100001, tile00100010, tile00100011, tile00100100, tile00100101, tile00100110, tile00100111
1687 .long tile00101000, tile00101001, tile00101010, tile00101011, tile00101100, tile00101101, tile00101110, tile00101111
1688 .long tile00110000, tile00110001, tile00110010, tile00110011, tile00110100, tile00110101, tile00110110, tile00110111
1689 .long tile00111000, tile00111001, tile00111010, tile00111011, tile00111100, tile00111101, tile00111110, tile00111111
1690 .long tile01000000, tile01000001, tile01000010, tile01000011, tile01000100, tile01000101, tile01000110, tile01000111
1691 .long tile01001000, tile01001001, tile01001010, tile01001011, tile01001100, tile01001101, tile01001110, tile01001111
1692 .long tile01010000, tile01010001, tile01010010, tile01010011, tile01010100, tile01010101, tile01010110, tile01010111
1693 .long tile01011000, tile01011001, tile01011010, tile01011011, tile01011100, tile01011101, tile01011110, tile01011111
1694 .long tile01100000, tile01100001, tile01100010, tile01100011, tile01100100, tile01100101, tile01100110, tile01100111
1695 .long tile01101000, tile01101001, tile01101010, tile01101011, tile01101100, tile01101101, tile01101110, tile01101111
1696 .long tile01110000, tile01110001, tile01110010, tile01110011, tile01110100, tile01110101, tile01110110, tile01110111
1697 .long tile01111000, tile01111001, tile01111010, tile01111011, tile01111100, tile01111101, tile01111110, tile01111111
1698 .long tile10000000, tile10000001, tile10000010, tile10000011, tile10000100, tile10000101, tile10000110, tile10000111
1699 .long tile10001000, tile10001001, tile10001010, tile10001011, tile10001100, tile10001101, tile10001110, tile10001111
1700 .long tile10010000, tile10010001, tile10010010, tile10010011, tile10010100, tile10010101, tile10010110, tile10010111
1701 .long tile10011000, tile10011001, tile10011010, tile10011011, tile10011100, tile10011101, tile10011110, tile10011111
1702 .long tile10100000, tile10100001, tile10100010, tile10100011, tile10100100, tile10100101, tile10100110, tile10100111
1703 .long tile10101000, tile10101001, tile10101010, tile10101011, tile10101100, tile10101101, tile10101110, tile10101111
1704 .long tile10110000, tile10110001, tile10110010, tile10110011, tile10110100, tile10110101, tile10110110, tile10110111
1705 .long tile10111000, tile10111001, tile10111010, tile10111011, tile10111100, tile10111101, tile10111110, tile10111111
1706 .long tile11000000, tile11000001, tile11000010, tile11000011, tile11000100, tile11000101, tile11000110, tile11000111
1707 .long tile11001000, tile11001001, tile11001010, tile11001011, tile11001100, tile11001101, tile11001110, tile11001111
1708 .long tile11010000, tile11010001, tile11010010, tile11010011, tile11010100, tile11010101, tile11010110, tile11010111
1709 .long tile11011000, tile11011001, tile11011010, tile11011011, tile11011100, tile11011101, tile11011110, tile11011111
1710 .long tile11100000, tile11100001, tile11100010, tile11100011, tile11100100, tile11100101, tile11100110, tile11100111
1711 .long tile11101000, tile11101001, tile11101010, tile11101011, tile11101100, tile11101101, tile11101110, tile11101111
1712 .long tile11110000, tile11110001, tile11110010, tile11110011, tile11110100, tile11110101, tile11110110, tile11110111
1713 .long tile11111000, tile11111001, tile11111010, tile11111011, tile11111100, tile11111101, tile11111110, tile11111111