Code: Select all
MajorBytes: .incbin "first-5.rom5"
MinorBytes: .incbin "first-6.rom6"
4bppPlanarTo8bppLinear:
li r1,MinorBytes
li r2,MajorBytes
mulli r3,r0,8 ; R0 is an ID of tile to load, R3=tile data offset (in bytes)
andi r7,r0,3
cmpi r7,1
ble ($a,PC)
addi r3,r3,-$10
b (6,PC)
addi r3,r3,$10 ; in the each 4 tile group the order of following is {2,3,0,1}
add r1,r1,r3
add r2,r2,r3
addi r4,r1,$20000
addi r5,r2,$20000
li r6,$f1000000
<...>
<...>
slwi r[i]X1[/i],r[i]X1[/i],3 ; loading a highest bit for current pixel
slwi r[i]X2[/i],r[i]X2[/i],2 ; third
slwi r[i]X3[/i],r[i]X3[/i],1 ; second
add r[i]X[/i],r[i]X3[/i],r[i]X4[/i] ; and combining all the result with lowest
add r[i]X[/i],r[i]X[/i],r[i]X2[/i]
add r[i]X[/i],r[i]X[/i],r[i]X1[/i]
stbu r[i]X8[/i],1(r6)
bdnz (,PC)