Fixed 8bpp and 4bpp index packing
This commit is contained in:
@@ -73,12 +73,13 @@ namespace PSXSplash.RuntimeCode
|
||||
/// <param name="packedValue">The packed ushort value.</param>
|
||||
public void Unpack(ushort packedValue)
|
||||
{
|
||||
r = (ushort)((packedValue >> 11) & 0b11111);
|
||||
g = (ushort)((packedValue >> 6) & 0b11111);
|
||||
b = (ushort)((packedValue >> 1) & 0b11111);
|
||||
SemiTransparent = (packedValue & 0b1) != 0;
|
||||
SemiTransparent = (packedValue & (1 << 15)) != 0;
|
||||
b = (ushort)((packedValue >> 10) & 0b11111);
|
||||
g = (ushort)((packedValue >> 5) & 0b11111);
|
||||
r = (ushort)(packedValue & 0b11111);
|
||||
}
|
||||
|
||||
|
||||
public Color GetUnityColor()
|
||||
{
|
||||
return new Color(R / 31.0f, G / 31.0f, B / 31.0f);
|
||||
@@ -186,7 +187,7 @@ namespace PSXSplash.RuntimeCode
|
||||
// Combine two 8-bit indices into one ushort.
|
||||
int index1 = psxTex.PixelIndices[baseIndex, y] & 0xFF;
|
||||
int index2 = psxTex.PixelIndices[baseIndex + 1, y] & 0xFF;
|
||||
ushort packed = (ushort)((index1 << 8) | index2);
|
||||
ushort packed = (ushort)((index2 << 8) | index1);
|
||||
VRAMPixel pixel = new VRAMPixel();
|
||||
pixel.Unpack(packed);
|
||||
psxTex.ImageData[group, psxTex.Height - y - 1] = pixel;
|
||||
@@ -202,7 +203,7 @@ namespace PSXSplash.RuntimeCode
|
||||
int idx2 = psxTex.PixelIndices[baseIndex + 1, y] & 0xF;
|
||||
int idx3 = psxTex.PixelIndices[baseIndex + 2, y] & 0xF;
|
||||
int idx4 = psxTex.PixelIndices[baseIndex + 3, y] & 0xF;
|
||||
ushort packed = (ushort)((idx1 << 12) | (idx2 << 8) | (idx3 << 4) | idx4);
|
||||
ushort packed = (ushort)((idx4 << 12) | (idx3 << 8) | (idx2 << 4) | idx1);
|
||||
VRAMPixel pixel = new VRAMPixel();
|
||||
pixel.Unpack(packed);
|
||||
psxTex.ImageData[group, psxTex.Height - y - 1] = pixel;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using PSXSplash.RuntimeCode;
|
||||
|
||||
|
||||
|
||||
@@ -154,7 +153,7 @@ namespace PSXSplash.RuntimeCode
|
||||
int clutHeight = 1;
|
||||
bool placed = false;
|
||||
|
||||
for (int x = 0; x < VRAM_WIDTH; x++)
|
||||
for (int x = 0; x < VRAM_WIDTH; x+=16)
|
||||
{
|
||||
for (int y = 0; y <= VRAM_HEIGHT; y++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user