# vim:filetype=mips
-# only CLUT for now..
+# several drawing related functions for Allegrex MIPS
+# (c) Copyright 2007, Grazvydas "notaz" Ignotas
+# All Rights Reserved
.set noreorder # don't reorder any instructions
.set noat # don't use $at
+.text
+.align 4
# void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count)
nop
+.global amips_clut_6bit
+
+amips_clut_6bit:
+ srl $a3, 2
+ li $t4, 0
+ li $t5, 0
+ li $t6, 0
+ li $t7, 0
+amips_clut_loop6:
+ lbu $t0, 0($a1) # tried lw here, no improvement noticed
+ lbu $t1, 1($a1)
+ lbu $t2, 2($a1)
+ lbu $t3, 3($a1)
+ ins $t4, $t0, 1, 6
+ ins $t5, $t1, 1, 6
+ ins $t6, $t2, 1, 6
+ ins $t7, $t3, 1, 6
+ addu $t0, $t4, $a2
+ addu $t1, $t5, $a2
+ addu $t2, $t6, $a2
+ addu $t3, $t7, $a2
+ lhu $t0, 0($t0)
+ lhu $t1, 0($t1)
+ lhu $t2, 0($t2)
+ lhu $t3, 0($t3)
+ ins $t0, $t1, 16, 16 # ins rt, rs, pos, size - Insert size bits starting
+ ins $t2, $t3, 16, 16 # from the LSB of rs into rt starting at position pos
+ sw $t0, 0($a0)
+ sw $t2, 4($a0)
+ addiu $a0, 8
+ addiu $a3, -1
+ bnez $a3, amips_clut_loop6
+ addiu $a1, 4
+ jr $ra
+ nop
+
+
# $a0 - pd, $a1 - tile word, $a2 - pal
# ext rt, rs, pos, size // Extract size bits from position pos in rs and store in rt
jr $ra
sb $t0, 0($a0)
+.data
+.align 4
+
TileTable:
.long 000000000000, tile00000001, tile00000010, tile00000011, tile00000100, tile00000101, tile00000110, tile00000111
.long tile00001000, tile00001001, tile00001010, tile00001011, tile00001100, tile00001101, tile00001110, tile00001111