mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-08-04 03:07:07 -04:00
Minorly optimise palette calculation functions
This commit is contained in:
parent
4405515c73
commit
148d2debcb
118
misc/ps1/iso.xml
118
misc/ps1/iso.xml
@ -61,65 +61,65 @@
|
|||||||
<file name="CCUBEPS1.EXE" type="data" source="../../ClassiCube-ps1.exe" />
|
<file name="CCUBEPS1.EXE" type="data" source="../../ClassiCube-ps1.exe" />
|
||||||
|
|
||||||
<dir name="audio">
|
<dir name="audio">
|
||||||
<file name="DCLOTH1.SND" type="data" source="audio/dig_cloth1.snd" />
|
<file name="DCLOTH1.SND" type="data" source="sounds/dig_cloth1.snd" />
|
||||||
<file name="DCLOTH2.SND" type="data" source="audio/dig_cloth2.snd" />
|
<file name="DCLOTH2.SND" type="data" source="sounds/dig_cloth2.snd" />
|
||||||
<file name="DCLOTH3.SND" type="data" source="audio/dig_cloth3.snd" />
|
<file name="DCLOTH3.SND" type="data" source="sounds/dig_cloth3.snd" />
|
||||||
<file name="DCLOTH4.SND" type="data" source="audio/dig_cloth4.snd" />
|
<file name="DCLOTH4.SND" type="data" source="sounds/dig_cloth4.snd" />
|
||||||
<file name="DGLASS1.SND" type="data" source="audio/dig_glass1.snd" />
|
<file name="DGLASS1.SND" type="data" source="sounds/dig_glass1.snd" />
|
||||||
<file name="DGLASS2.SND" type="data" source="audio/dig_glass2.snd" />
|
<file name="DGLASS2.SND" type="data" source="sounds/dig_glass2.snd" />
|
||||||
<file name="DGLASS3.SND" type="data" source="audio/dig_glass3.snd" />
|
<file name="DGLASS3.SND" type="data" source="sounds/dig_glass3.snd" />
|
||||||
<file name="DGRASS1.SND" type="data" source="audio/dig_grass1.snd" />
|
<file name="DGRASS1.SND" type="data" source="sounds/dig_grass1.snd" />
|
||||||
<file name="DGRASS2.SND" type="data" source="audio/dig_grass2.snd" />
|
<file name="DGRASS2.SND" type="data" source="sounds/dig_grass2.snd" />
|
||||||
<file name="DGRASS3.SND" type="data" source="audio/dig_grass3.snd" />
|
<file name="DGRASS3.SND" type="data" source="sounds/dig_grass3.snd" />
|
||||||
<file name="DGRASS4.SND" type="data" source="audio/dig_grass4.snd" />
|
<file name="DGRASS4.SND" type="data" source="sounds/dig_grass4.snd" />
|
||||||
<file name="DGRAVEL1.SND" type="data" source="audio/dig_gravel1.snd" />
|
<file name="DGRAVEL1.SND" type="data" source="sounds/dig_gravel1.snd" />
|
||||||
<file name="DGRAVEL2.SND" type="data" source="audio/dig_gravel2.snd" />
|
<file name="DGRAVEL2.SND" type="data" source="sounds/dig_gravel2.snd" />
|
||||||
<file name="DGRAVEL3.SND" type="data" source="audio/dig_gravel3.snd" />
|
<file name="DGRAVEL3.SND" type="data" source="sounds/dig_gravel3.snd" />
|
||||||
<file name="DGRAVEL4.SND" type="data" source="audio/dig_gravel4.snd" />
|
<file name="DGRAVEL4.SND" type="data" source="sounds/dig_gravel4.snd" />
|
||||||
<file name="DSAND1.SND" type="data" source="audio/dig_sand1.snd" />
|
<file name="DSAND1.SND" type="data" source="sounds/dig_sand1.snd" />
|
||||||
<file name="DSAND2.SND" type="data" source="audio/dig_sand2.snd" />
|
<file name="DSAND2.SND" type="data" source="sounds/dig_sand2.snd" />
|
||||||
<file name="DSAND3.SND" type="data" source="audio/dig_sand3.snd" />
|
<file name="DSAND3.SND" type="data" source="sounds/dig_sand3.snd" />
|
||||||
<file name="DSAND4.SND" type="data" source="audio/dig_sand4.snd" />
|
<file name="DSAND4.SND" type="data" source="sounds/dig_sand4.snd" />
|
||||||
<file name="DSNOW1.SND" type="data" source="audio/dig_snow1.snd" />
|
<file name="DSNOW1.SND" type="data" source="sounds/dig_snow1.snd" />
|
||||||
<file name="DSNOW2.SND" type="data" source="audio/dig_snow2.snd" />
|
<file name="DSNOW2.SND" type="data" source="sounds/dig_snow2.snd" />
|
||||||
<file name="DSNOW3.SND" type="data" source="audio/dig_snow3.snd" />
|
<file name="DSNOW3.SND" type="data" source="sounds/dig_snow3.snd" />
|
||||||
<file name="DSNOW4.SND" type="data" source="audio/dig_snow4.snd" />
|
<file name="DSNOW4.SND" type="data" source="sounds/dig_snow4.snd" />
|
||||||
<file name="DSTONE1.SND" type="data" source="audio/dig_stone1.snd" />
|
<file name="DSTONE1.SND" type="data" source="sounds/dig_stone1.snd" />
|
||||||
<file name="DSTONE2.SND" type="data" source="audio/dig_stone2.snd" />
|
<file name="DSTONE2.SND" type="data" source="sounds/dig_stone2.snd" />
|
||||||
<file name="DSTONE3.SND" type="data" source="audio/dig_stone3.snd" />
|
<file name="DSTONE3.SND" type="data" source="sounds/dig_stone3.snd" />
|
||||||
<file name="DSTONE4.SND" type="data" source="audio/dig_stone4.snd" />
|
<file name="DSTONE4.SND" type="data" source="sounds/dig_stone4.snd" />
|
||||||
<file name="DWOOD1.SND" type="data" source="audio/dig_wood1.snd" />
|
<file name="DWOOD1.SND" type="data" source="sounds/dig_wood1.snd" />
|
||||||
<file name="DWOOD2.SND" type="data" source="audio/dig_wood2.snd" />
|
<file name="DWOOD2.SND" type="data" source="sounds/dig_wood2.snd" />
|
||||||
<file name="DWOOD3.SND" type="data" source="audio/dig_wood3.snd" />
|
<file name="DWOOD3.SND" type="data" source="sounds/dig_wood3.snd" />
|
||||||
<file name="DWOOD4.SND" type="data" source="audio/dig_wood4.snd" />
|
<file name="DWOOD4.SND" type="data" source="sounds/dig_wood4.snd" />
|
||||||
<file name="SCLOTH1.SND" type="data" source="audio/step_cloth1.snd" />
|
<file name="SCLOTH1.SND" type="data" source="sounds/step_cloth1.snd" />
|
||||||
<file name="SCLOTH2.SND" type="data" source="audio/step_cloth2.snd" />
|
<file name="SCLOTH2.SND" type="data" source="sounds/step_cloth2.snd" />
|
||||||
<file name="SCLOTH3.SND" type="data" source="audio/step_cloth3.snd" />
|
<file name="SCLOTH3.SND" type="data" source="sounds/step_cloth3.snd" />
|
||||||
<file name="SCLOTH4.SND" type="data" source="audio/step_cloth4.snd" />
|
<file name="SCLOTH4.SND" type="data" source="sounds/step_cloth4.snd" />
|
||||||
<file name="SGRASS1.SND" type="data" source="audio/step_grass1.snd" />
|
<file name="SGRASS1.SND" type="data" source="sounds/step_grass1.snd" />
|
||||||
<file name="SGRASS2.SND" type="data" source="audio/step_grass2.snd" />
|
<file name="SGRASS2.SND" type="data" source="sounds/step_grass2.snd" />
|
||||||
<file name="SGRASS3.SND" type="data" source="audio/step_grass3.snd" />
|
<file name="SGRASS3.SND" type="data" source="sounds/step_grass3.snd" />
|
||||||
<file name="SGRASS4.SND" type="data" source="audio/step_grass4.snd" />
|
<file name="SGRASS4.SND" type="data" source="sounds/step_grass4.snd" />
|
||||||
<file name="SGRAVEL1.SND" type="data" source="audio/step_gravel1.snd" />
|
<file name="SGRAVEL1.SND" type="data" source="sounds/step_gravel1.snd" />
|
||||||
<file name="SGRAVEL2.SND" type="data" source="audio/step_gravel2.snd" />
|
<file name="SGRAVEL2.SND" type="data" source="sounds/step_gravel2.snd" />
|
||||||
<file name="SGRAVEL3.SND" type="data" source="audio/step_gravel3.snd" />
|
<file name="SGRAVEL3.SND" type="data" source="sounds/step_gravel3.snd" />
|
||||||
<file name="SGRAVEL4.SND" type="data" source="audio/step_gravel4.snd" />
|
<file name="SGRAVEL4.SND" type="data" source="sounds/step_gravel4.snd" />
|
||||||
<file name="SSAND1.SND" type="data" source="audio/step_sand1.snd" />
|
<file name="SSAND1.SND" type="data" source="sounds/step_sand1.snd" />
|
||||||
<file name="SSAND2.SND" type="data" source="audio/step_sand2.snd" />
|
<file name="SSAND2.SND" type="data" source="sounds/step_sand2.snd" />
|
||||||
<file name="SSAND3.SND" type="data" source="audio/step_sand3.snd" />
|
<file name="SSAND3.SND" type="data" source="sounds/step_sand3.snd" />
|
||||||
<file name="SSAND4.SND" type="data" source="audio/step_sand4.snd" />
|
<file name="SSAND4.SND" type="data" source="sounds/step_sand4.snd" />
|
||||||
<file name="SSNOW1.SND" type="data" source="audio/step_snow1.snd" />
|
<file name="SSNOW1.SND" type="data" source="sounds/step_snow1.snd" />
|
||||||
<file name="SSNOW2.SND" type="data" source="audio/step_snow2.snd" />
|
<file name="SSNOW2.SND" type="data" source="sounds/step_snow2.snd" />
|
||||||
<file name="SSNOW3.SND" type="data" source="audio/step_snow3.snd" />
|
<file name="SSNOW3.SND" type="data" source="sounds/step_snow3.snd" />
|
||||||
<file name="SSNOW4.SND" type="data" source="audio/step_snow4.snd" />
|
<file name="SSNOW4.SND" type="data" source="sounds/step_snow4.snd" />
|
||||||
<file name="SSTONE1.SND" type="data" source="audio/step_stone1.snd" />
|
<file name="SSTONE1.SND" type="data" source="sounds/step_stone1.snd" />
|
||||||
<file name="SSTONE2.SND" type="data" source="audio/step_stone2.snd" />
|
<file name="SSTONE2.SND" type="data" source="sounds/step_stone2.snd" />
|
||||||
<file name="SSTONE3.SND" type="data" source="audio/step_stone3.snd" />
|
<file name="SSTONE3.SND" type="data" source="sounds/step_stone3.snd" />
|
||||||
<file name="SSTONE4.SND" type="data" source="audio/step_stone4.snd" />
|
<file name="SSTONE4.SND" type="data" source="sounds/step_stone4.snd" />
|
||||||
<file name="SWOOD1.SND" type="data" source="audio/step_wood1.snd" />
|
<file name="SWOOD1.SND" type="data" source="sounds/step_wood1.snd" />
|
||||||
<file name="SWOOD2.SND" type="data" source="audio/step_wood2.snd" />
|
<file name="SWOOD2.SND" type="data" source="sounds/step_wood2.snd" />
|
||||||
<file name="SWOOD3.SND" type="data" source="audio/step_wood3.snd" />
|
<file name="SWOOD3.SND" type="data" source="sounds/step_wood3.snd" />
|
||||||
<file name="SWOOD4.SND" type="data" source="audio/step_wood4.snd" />
|
<file name="SWOOD4.SND" type="data" source="sounds/step_wood4.snd" />
|
||||||
</dir>
|
</dir>
|
||||||
<dir name="texpacks">
|
<dir name="texpacks">
|
||||||
<file name="default.zip" type="data" source="classicube.zip" />
|
<file name="default.zip" type="data" source="classicube.zip" />
|
||||||
|
BIN
misc/ps1/sounds/audio.zip
Normal file
BIN
misc/ps1/sounds/audio.zip
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_cloth1.snd
Normal file
BIN
misc/ps1/sounds/dig_cloth1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_cloth2.snd
Normal file
BIN
misc/ps1/sounds/dig_cloth2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_cloth3.snd
Normal file
BIN
misc/ps1/sounds/dig_cloth3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_cloth4.snd
Normal file
BIN
misc/ps1/sounds/dig_cloth4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_glass1.snd
Normal file
BIN
misc/ps1/sounds/dig_glass1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_glass2.snd
Normal file
BIN
misc/ps1/sounds/dig_glass2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_glass3.snd
Normal file
BIN
misc/ps1/sounds/dig_glass3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_grass1.snd
Normal file
BIN
misc/ps1/sounds/dig_grass1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_grass2.snd
Normal file
BIN
misc/ps1/sounds/dig_grass2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_grass3.snd
Normal file
BIN
misc/ps1/sounds/dig_grass3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_grass4.snd
Normal file
BIN
misc/ps1/sounds/dig_grass4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_gravel1.snd
Normal file
BIN
misc/ps1/sounds/dig_gravel1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_gravel2.snd
Normal file
BIN
misc/ps1/sounds/dig_gravel2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_gravel3.snd
Normal file
BIN
misc/ps1/sounds/dig_gravel3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_gravel4.snd
Normal file
BIN
misc/ps1/sounds/dig_gravel4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_sand1.snd
Normal file
BIN
misc/ps1/sounds/dig_sand1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_sand2.snd
Normal file
BIN
misc/ps1/sounds/dig_sand2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_sand3.snd
Normal file
BIN
misc/ps1/sounds/dig_sand3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_sand4.snd
Normal file
BIN
misc/ps1/sounds/dig_sand4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_snow1.snd
Normal file
BIN
misc/ps1/sounds/dig_snow1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_snow2.snd
Normal file
BIN
misc/ps1/sounds/dig_snow2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_snow3.snd
Normal file
BIN
misc/ps1/sounds/dig_snow3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_snow4.snd
Normal file
BIN
misc/ps1/sounds/dig_snow4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_stone1.snd
Normal file
BIN
misc/ps1/sounds/dig_stone1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_stone2.snd
Normal file
BIN
misc/ps1/sounds/dig_stone2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_stone3.snd
Normal file
BIN
misc/ps1/sounds/dig_stone3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_stone4.snd
Normal file
BIN
misc/ps1/sounds/dig_stone4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_wood1.snd
Normal file
BIN
misc/ps1/sounds/dig_wood1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_wood2.snd
Normal file
BIN
misc/ps1/sounds/dig_wood2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_wood3.snd
Normal file
BIN
misc/ps1/sounds/dig_wood3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/dig_wood4.snd
Normal file
BIN
misc/ps1/sounds/dig_wood4.snd
Normal file
Binary file not shown.
9
misc/ps1/sounds/gen.sh
Executable file
9
misc/ps1/sounds/gen.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
rm "audio.zip" *.wav
|
||||||
|
wget "classicube.net/static/audio.zip"
|
||||||
|
unzip "audio.zip"
|
||||||
|
|
||||||
|
for i in *.wav; do
|
||||||
|
~/repos/psxavenc/build/psxavenc -t spu -f 32000 $i "${i%.wav}.snd"
|
||||||
|
done
|
||||||
|
|
||||||
|
rm *.wav
|
BIN
misc/ps1/sounds/step_cloth1.snd
Normal file
BIN
misc/ps1/sounds/step_cloth1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_cloth2.snd
Normal file
BIN
misc/ps1/sounds/step_cloth2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_cloth3.snd
Normal file
BIN
misc/ps1/sounds/step_cloth3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_cloth4.snd
Normal file
BIN
misc/ps1/sounds/step_cloth4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_grass1.snd
Normal file
BIN
misc/ps1/sounds/step_grass1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_grass2.snd
Normal file
BIN
misc/ps1/sounds/step_grass2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_grass3.snd
Normal file
BIN
misc/ps1/sounds/step_grass3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_grass4.snd
Normal file
BIN
misc/ps1/sounds/step_grass4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_gravel1.snd
Normal file
BIN
misc/ps1/sounds/step_gravel1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_gravel2.snd
Normal file
BIN
misc/ps1/sounds/step_gravel2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_gravel3.snd
Normal file
BIN
misc/ps1/sounds/step_gravel3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_gravel4.snd
Normal file
BIN
misc/ps1/sounds/step_gravel4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_sand1.snd
Normal file
BIN
misc/ps1/sounds/step_sand1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_sand2.snd
Normal file
BIN
misc/ps1/sounds/step_sand2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_sand3.snd
Normal file
BIN
misc/ps1/sounds/step_sand3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_sand4.snd
Normal file
BIN
misc/ps1/sounds/step_sand4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_snow1.snd
Normal file
BIN
misc/ps1/sounds/step_snow1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_snow2.snd
Normal file
BIN
misc/ps1/sounds/step_snow2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_snow3.snd
Normal file
BIN
misc/ps1/sounds/step_snow3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_snow4.snd
Normal file
BIN
misc/ps1/sounds/step_snow4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_stone1.snd
Normal file
BIN
misc/ps1/sounds/step_stone1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_stone2.snd
Normal file
BIN
misc/ps1/sounds/step_stone2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_stone3.snd
Normal file
BIN
misc/ps1/sounds/step_stone3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_stone4.snd
Normal file
BIN
misc/ps1/sounds/step_stone4.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_wood1.snd
Normal file
BIN
misc/ps1/sounds/step_wood1.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_wood2.snd
Normal file
BIN
misc/ps1/sounds/step_wood2.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_wood3.snd
Normal file
BIN
misc/ps1/sounds/step_wood3.snd
Normal file
Binary file not shown.
BIN
misc/ps1/sounds/step_wood4.snd
Normal file
BIN
misc/ps1/sounds/step_wood4.snd
Normal file
Binary file not shown.
@ -465,13 +465,14 @@ static CC_INLINE int FindInPalette(BitmapCol* palette, int pal_count, BitmapCol
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int CalcPalette(BitmapCol* palette, struct Bitmap* bmp, int rowWidth) {
|
static int CalcPalette(BitmapCol* palette, struct Bitmap* bmp, int rowWidth) {
|
||||||
|
int width = bmp->width, height = bmp->height;
|
||||||
|
|
||||||
|
BitmapCol* row = bmp->scan0;
|
||||||
int pal_count = 0;
|
int pal_count = 0;
|
||||||
|
|
||||||
for (int y = 0; y < bmp->height; y++)
|
for (int y = 0; y < height; y++, row += rowWidth)
|
||||||
{
|
{
|
||||||
BitmapCol* row = bmp->scan0 + y * rowWidth;
|
for (int x = 0; x < width; x++)
|
||||||
|
|
||||||
for (int x = 0; x < bmp->width; x++)
|
|
||||||
{
|
{
|
||||||
BitmapCol color = row[x];
|
BitmapCol color = row[x];
|
||||||
int idx = FindInPalette(palette, pal_count, color);
|
int idx = FindInPalette(palette, pal_count, color);
|
||||||
|
@ -319,14 +319,15 @@ static CC_INLINE int FindInPalette(cc_uint16* pal, int pal_size, cc_uint16 color
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CC_INLINE int CalcPalette(cc_uint16* palette, struct Bitmap* bmp, int rowWidth) {
|
static CC_INLINE int CalcPalette(cc_uint16* palette, struct Bitmap* bmp, int rowWidth) {
|
||||||
|
int width = bmp->width, height = bmp->height;
|
||||||
|
cc_uint16* row = bmp->scan0;
|
||||||
|
|
||||||
int pal_count = 1;
|
int pal_count = 1;
|
||||||
palette[0] = 0; // entry 0 is transparent colour
|
palette[0] = 0; // entry 0 is transparent colour
|
||||||
|
|
||||||
for (int y = 0; y < bmp->height; y++)
|
for (int y = 0; y < height; y++, row += rowWidth)
|
||||||
{
|
{
|
||||||
cc_uint16* row = bmp->scan0 + y * rowWidth;
|
for (int x = 0; x < width; x++)
|
||||||
|
|
||||||
for (int x = 0; x < bmp->width; x++)
|
|
||||||
{
|
{
|
||||||
cc_uint16 color = row[x];
|
cc_uint16 color = row[x];
|
||||||
int idx = FindInPalette(palette, pal_count, color);
|
int idx = FindInPalette(palette, pal_count, color);
|
||||||
@ -378,40 +379,34 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
|
|||||||
char* tmp = (char*)tmp_u16;
|
char* tmp = (char*)tmp_u16;
|
||||||
|
|
||||||
u32 banks = vramSetPrimaryBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD);
|
u32 banks = vramSetPrimaryBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD);
|
||||||
|
|
||||||
int stride;
|
int stride;
|
||||||
|
|
||||||
|
int width = bmp->width, height = bmp->height;
|
||||||
|
cc_uint16* row = bmp->scan0;
|
||||||
|
|
||||||
if (tex_fmt == GL_RGB4) {
|
if (tex_fmt == GL_RGB4) {
|
||||||
char* buf = malloc(tex_size);
|
stride = width >> 3;
|
||||||
int i = 0;
|
|
||||||
if (!buf) return NULL;
|
|
||||||
|
|
||||||
for (int y = 0; y < bmp->height; y++)
|
for (int y = 0; y < height; y++, row += rowWidth)
|
||||||
{
|
{
|
||||||
cc_uint16* row = bmp->scan0 + y * rowWidth;
|
for (int x = 0; x < width; x++)
|
||||||
|
|
||||||
for (int x = 0; x < bmp->width; x++, i++)
|
|
||||||
{
|
{
|
||||||
int idx = FindInPalette(palette, pal_count, row[x]);
|
int idx = FindInPalette(palette, pal_count, row[x]);
|
||||||
|
|
||||||
if ((i & 3) == 0) {
|
if ((x & 3) == 0) {
|
||||||
buf[i >> 2] = idx;
|
tmp[x >> 2] = idx;
|
||||||
} else {
|
} else {
|
||||||
buf[i >> 2] |= idx << (2 * (i & 3));
|
tmp[x >> 2] |= idx << (2 * (x & 3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CopyHWords(tmp, addr + stride * y, stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyHWords(buf, addr, tex_size >> 1);
|
|
||||||
free(buf);
|
|
||||||
} else if (tex_fmt == GL_RGB16) {
|
} else if (tex_fmt == GL_RGB16) {
|
||||||
stride = bmp->width >> 2;
|
stride = width >> 2;
|
||||||
|
|
||||||
for (int y = 0; y < bmp->height; y++, addr += stride)
|
for (int y = 0; y < height; y++, addr += stride, row += rowWidth)
|
||||||
{
|
{
|
||||||
cc_uint16* row = bmp->scan0 + y * rowWidth;
|
for (int x = 0; x < width; x++)
|
||||||
|
|
||||||
for (int x = 0; x < bmp->width; x++)
|
|
||||||
{
|
{
|
||||||
int idx = FindInPalette(palette, pal_count, row[x]);
|
int idx = FindInPalette(palette, pal_count, row[x]);
|
||||||
|
|
||||||
@ -424,24 +419,22 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
|
|||||||
CopyHWords(tmp, addr, stride);
|
CopyHWords(tmp, addr, stride);
|
||||||
}
|
}
|
||||||
} else if (tex_fmt == GL_RGB256) {
|
} else if (tex_fmt == GL_RGB256) {
|
||||||
stride = bmp->width >> 1;
|
stride = width >> 1;
|
||||||
|
|
||||||
for (int y = 0; y < bmp->height; y++, addr += stride)
|
for (int y = 0; y < height; y++, addr += stride, row += rowWidth)
|
||||||
{
|
{
|
||||||
cc_uint16* row = bmp->scan0 + y * rowWidth;
|
for (int x = 0; x < width; x++)
|
||||||
|
|
||||||
for (int x = 0; x < bmp->width; x++)
|
|
||||||
{
|
{
|
||||||
tmp[x] = FindInPalette(palette, pal_count, row[x]);
|
tmp[x] = FindInPalette(palette, pal_count, row[x]);
|
||||||
}
|
}
|
||||||
CopyHWords(tmp, addr, stride);
|
CopyHWords(tmp, addr, stride);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stride = bmp->width;
|
stride = width;
|
||||||
|
|
||||||
for (int y = 0; y < bmp->height; y++, addr += stride) {
|
for (int y = 0; y < height; y++, addr += stride, row += rowWidth)
|
||||||
cc_uint16* src = bmp->scan0 + y * rowWidth;
|
{
|
||||||
CopyHWords(src, addr, stride);
|
CopyHWords(row, addr, stride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,8 @@ static CC_INLINE void DMAFlushBuffer(void) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
typedef struct CCTexture_ {
|
typedef struct CCTexture_ {
|
||||||
cc_uint32 width, height;
|
cc_uint32 width, height;
|
||||||
cc_uint32 log2_width, log2_height;
|
cc_uint16 log2_width, log2_height;
|
||||||
|
cc_uint16 format, pal_index;
|
||||||
cc_uint32 pad[(64 - 16)/4];
|
cc_uint32 pad[(64 - 16)/4];
|
||||||
BitmapCol pixels[]; // aligned to 64 bytes (only need 16?)
|
BitmapCol pixels[]; // aligned to 64 bytes (only need 16?)
|
||||||
} CCTexture;
|
} CCTexture;
|
||||||
@ -181,6 +182,8 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
|
|||||||
tex->height = bmp->height;
|
tex->height = bmp->height;
|
||||||
tex->log2_width = draw_log2(bmp->width);
|
tex->log2_width = draw_log2(bmp->width);
|
||||||
tex->log2_height = draw_log2(bmp->height);
|
tex->log2_height = draw_log2(bmp->height);
|
||||||
|
tex->format = GS_PSM_32;
|
||||||
|
tex->pal_index = 0;
|
||||||
|
|
||||||
CopyTextureData(tex->pixels, bmp->width * BITMAPCOLOR_SIZE,
|
CopyTextureData(tex->pixels, bmp->width * BITMAPCOLOR_SIZE,
|
||||||
bmp, rowWidth * BITMAPCOLOR_SIZE);
|
bmp, rowWidth * BITMAPCOLOR_SIZE);
|
||||||
@ -191,7 +194,7 @@ static void UpdateTextureBuffer(int context, CCTexture* tex, unsigned buf_addr,
|
|||||||
PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0, GIF_FLG_PACKED, 1), GIF_REG_AD);
|
PACK_GIFTAG(q, GIF_SET_TAG(1,0,0,0, GIF_FLG_PACKED, 1), GIF_REG_AD);
|
||||||
q++;
|
q++;
|
||||||
|
|
||||||
PACK_GIFTAG(q, GS_SET_TEX0(buf_addr >> 6, buf_stride >> 6, GS_PSM_32,
|
PACK_GIFTAG(q, GS_SET_TEX0(buf_addr >> 6, buf_stride >> 6, tex->format,
|
||||||
tex->log2_width, tex->log2_height, TEXTURE_COMPONENTS_RGBA, TEXTURE_FUNCTION_MODULATE,
|
tex->log2_width, tex->log2_height, TEXTURE_COMPONENTS_RGBA, TEXTURE_FUNCTION_MODULATE,
|
||||||
0, 0, CLUT_STORAGE_MODE1, 0, CLUT_NO_LOAD), GS_REG_TEX0 + context);
|
0, 0, CLUT_STORAGE_MODE1, 0, CLUT_NO_LOAD), GS_REG_TEX0 + context);
|
||||||
q++;
|
q++;
|
||||||
@ -214,7 +217,7 @@ void Gfx_BindTexture(GfxResourceID texId) {
|
|||||||
|
|
||||||
qword_t *Q = packet->data;
|
qword_t *Q = packet->data;
|
||||||
|
|
||||||
Q = draw_texture_transfer(Q, tex->pixels, tex->width, tex->height, GS_PSM_32, dst_addr, dst_stride);
|
Q = draw_texture_transfer(Q, tex->pixels, tex->width, tex->height, tex->buffer, dst_addr, dst_stride);
|
||||||
Q = draw_texture_flush(Q);
|
Q = draw_texture_flush(Q);
|
||||||
|
|
||||||
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, Q - packet->data, 0,0);
|
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, Q - packet->data, 0,0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user