aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData')
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.cpp156
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.h1
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.spu.vcxproj151
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.spu.vcxproj.vspscc10
-rw-r--r--Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/stdafx.h0
5 files changed, 318 insertions, 0 deletions
diff --git a/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.cpp b/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.cpp
new file mode 100644
index 00000000..fa52c3e1
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.cpp
@@ -0,0 +1,156 @@
+/* SCE CONFIDENTIAL
+PlayStation(R)3 Programmer Tool Runtime Library 430.001
+* Copyright (C) 2007 Sony Computer Entertainment Inc.
+* All Rights Reserved.
+*/
+
+/* common headers */
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <spu_intrinsics.h>
+#include <cell/spurs.h>
+#include <spu_printf.h>
+#include <cell/dma.h>
+#include <cell/spurs/job_queue.h>
+
+#include "..\Common\DmaData.h"
+
+#include "CompressedTileStorage_getData.h"
+
+static const bool sc_verbose = false;
+
+CellSpursJobContext2* g_pSpursJobContext;
+
+
+
+
+class CCompressedTileStorage_getData
+{
+public:
+ unsigned char indicesAndData[32768+4096];
+ int allocatedSize;
+ int newAllocatedSize;
+ uint32_t newIndicesPPU;
+private:
+
+ static const int INDEX_OFFSET_MASK = 0x7ffe;
+ static const int INDEX_OFFSET_SHIFT = 1;
+ static const int INDEX_TILE_MASK = 0x00ff;
+ static const int INDEX_TILE_SHIFT = 8;
+ static const int INDEX_TYPE_MASK = 0x0003;
+ static const int INDEX_TYPE_1_BIT = 0x0000;
+ static const int INDEX_TYPE_2_BIT = 0x0001;
+ static const int INDEX_TYPE_4_BIT = 0x0002;
+ static const int INDEX_TYPE_0_OR_8_BIT = 0x0003;
+ static const int INDEX_TYPE_0_BIT_FLAG = 0x0004;
+
+public:
+ CCompressedTileStorage_getData(unsigned char* idxAndData, int dataSize)
+ {
+ allocatedSize = dataSize;
+ spu_assert(allocatedSize < (int)sizeof(indicesAndData));
+ DmaData_SPU::getAndWait(indicesAndData, (uintptr_t)idxAndData, DmaData_SPU::roundUpDMASize(allocatedSize));
+ }
+ void getData(uint8_t* retArray, unsigned int retOffset);
+
+ // Get an index into the normal ordering of tiles for the java game, given a block index (0 to 511) and a tile index (0 to 63)
+ int getIndex(int block, int tile)
+ {
+ // bits for index into data is: xxxxzzzzyyyyyyy
+ // we want block(b) & tile(t) spread out as:
+ // from: ______bbbbbbbbb
+ // to: bb__bb__bbbbb__
+ //
+ // from: _________tttttt
+ // to: __tt__tt_____tt
+
+ int index = ( ( block & 0x180) << 6 ) | ( ( block & 0x060 ) << 4 ) | ( ( block & 0x01f ) << 2 );
+ index |= ( ( tile & 0x30 ) << 7) | ( ( tile & 0x0c ) << 5 ) | ( tile & 0x03 );
+
+ return index;
+ }
+
+};
+
+void CCompressedTileStorage_getData::getData(uint8_t* retArray, unsigned int retOffset)
+{
+ unsigned short *blockIndices = (unsigned short *)indicesAndData;
+ unsigned char *data = indicesAndData + 1024;
+
+ for( int i = 0; i < 512; i++ )
+ {
+ int indexType = blockIndices[i] & INDEX_TYPE_MASK;
+ if( indexType == INDEX_TYPE_0_OR_8_BIT )
+ {
+ if( blockIndices[i] & INDEX_TYPE_0_BIT_FLAG )
+ {
+ for( int j = 0; j < 64; j++ )
+ {
+ retArray[getIndex(i,j) + retOffset] = ( blockIndices[i] >> INDEX_TILE_SHIFT ) & INDEX_TILE_MASK;
+ }
+ }
+ else
+ {
+ // 8-bit reads are just directly read from the 64 long array of values stored for the block
+ unsigned char *packed = data + ( ( blockIndices[i] >> INDEX_OFFSET_SHIFT ) & INDEX_OFFSET_MASK );
+
+ for( int j = 0; j < 64; j++ )
+ {
+ retArray[getIndex(i,j) + retOffset] = packed[j];
+ }
+ }
+ }
+ else
+ {
+ // 1, 2, or 4 bits per block packed format
+
+ int bitspertile = 1 << indexType; // will be 1, 2 or 4 (from index values of 0, 1, 2)
+ int tiletypecount = 1 << bitspertile; // will be 2, 4 or 16 (from index values of 0, 1, 2)
+ int tiletypemask = tiletypecount - 1; // will be 1, 3 or 15 (from index values of 0, 1, 2)
+ int indexshift = 3 - indexType; // will be 3, 2 or 1 (from index values of 0, 1, 2)
+ int indexmask_bits = 7 >> indexType; // will be 7, 3 or 1 (from index values of 0, 1, 2)
+ int indexmask_bytes = 62 >> indexshift; // will be 7, 15 or 31 (from index values of 0, 1, 2)
+
+ unsigned char *tile_types = data + ( ( blockIndices[i] >> INDEX_OFFSET_SHIFT ) & INDEX_OFFSET_MASK );
+ unsigned char *packed = tile_types + tiletypecount;
+
+ for( int j = 0; j < 64; j++ )
+ {
+ int idx = ( j >> indexshift ) & indexmask_bytes;
+ int bit = ( j & indexmask_bits ) * bitspertile;
+ retArray[getIndex(i,j) + retOffset] = tile_types[( packed[idx] >> bit ) & tiletypemask];
+ }
+ }
+ }
+}
+
+
+
+void cellSpursJobQueueMain(CellSpursJobContext2 *pContext, CellSpursJob256 *pJob)
+{
+// CellSpursTaskId idTask = cellSpursGetTaskId();
+ unsigned int idSpu = cellSpursGetCurrentSpuId();
+
+ if(sc_verbose)
+ spu_printf("CompressedTileStorage_getData [SPU#%u] start\n", idSpu);
+
+ g_pSpursJobContext = pContext;
+
+ unsigned char* pIdxAndData = (unsigned char*)pJob->workArea.userData[0];
+ int dataSize = (int)pJob->workArea.userData[1];
+ unsigned char* pDst = (unsigned char*)pJob->workArea.userData[2];
+ unsigned int retOffset = (unsigned int)pJob->workArea.userData[3];
+
+ CCompressedTileStorage_getData c(pIdxAndData, dataSize);
+
+ unsigned char retArray[32768];
+
+ c.getData(retArray, retOffset);
+
+ DmaData_SPU::putAndWait(retArray, (uintptr_t)pDst, 32768);
+
+ if(sc_verbose)
+ spu_printf("CompressedTileStorage_getData [SPU#%u] exit\n", idSpu);
+}
+
diff --git a/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.h b/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.h
new file mode 100644
index 00000000..6f70f09b
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.h
@@ -0,0 +1 @@
+#pragma once
diff --git a/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.spu.vcxproj b/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.spu.vcxproj
new file mode 100644
index 00000000..5deca3c5
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.spu.vcxproj
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="us-ascii"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="ContentPackage|PS3">
+ <Configuration>ContentPackage</Configuration>
+ <Platform>PS3</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|PS3">
+ <Configuration>Debug</Configuration>
+ <Platform>PS3</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|PS3">
+ <Configuration>Release</Configuration>
+ <Platform>PS3</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="CompressedTileStorage_getData.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="CompressedTileStorage_getData.h" />
+ <ClInclude Include="stdafx.h" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{ED672663-B86E-436B-9530-A6589DE02366}</ProjectGuid>
+ <ProjectName>CompressedTileStorage_getData</ProjectName>
+ <SccProjectName>SAK</SccProjectName>
+ <SccAuxPath>SAK</SccAuxPath>
+ <SccLocalPath>SAK</SccLocalPath>
+ <SccProvider>SAK</SccProvider>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>SPU</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>SPU</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>SPU</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">PS3_Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">PS3_Debug\</IntDir>
+ <ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'" />
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">false</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">PS3_Release\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">PS3_Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">PS3_Release\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">PS3_Release\</IntDir>
+ <ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean>
+ <ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">*.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|PS3'" />
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'" />
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">false</GenerateManifest>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">false</GenerateManifest>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">$(ProjectName)</TargetName>
+ <SpursUsage>SpursInit</SpursUsage>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">$(ProjectName)</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">$(ProjectName)</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|PS3'">
+ <ClCompile>
+ <AdditionalOptions>-ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>$(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <PreprocessorDefinitions>SN_TARGET_PS3_SPU;_DEBUG;__GCC__;SPU;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ProjectReference>
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
+ </ProjectReference>
+ <Link>
+ <AdditionalOptions>-Wl,--gc-sections -g %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>-ldma;-lspurs_jq;%(AdditionalDependencies)</AdditionalDependencies>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ <SpuElfConversion>
+ <EmbedFormat>JobBin2</EmbedFormat>
+ <OutputFile>..\ObjFiles\Debug\$(TargetName).ppu$(ObjectExt)</OutputFile>
+ </SpuElfConversion>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|PS3'">
+ <ClCompile>
+ <AdditionalOptions>-ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>$(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OptimizationLevel>Level3</OptimizationLevel>
+ <PreprocessorDefinitions>SN_TARGET_PS3_SPU;NDEBUG;__GCC__;SPU;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ProjectReference>
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
+ </ProjectReference>
+ <Link>
+ <AdditionalOptions>-Wl,--gc-sections -g %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>-ldma;-lspurs_jq;%(AdditionalDependencies)</AdditionalDependencies>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ <SpuElfConversion>
+ <EmbedFormat>JobBin2</EmbedFormat>
+ <OutputFile>..\ObjFiles\Release\$(TargetName).ppu$(ObjectExt)</OutputFile>
+ </SpuElfConversion>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ContentPackage|PS3'">
+ <ClCompile>
+ <AdditionalOptions>-ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>$(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OptimizationLevel>Level3</OptimizationLevel>
+ <PreprocessorDefinitions>SN_TARGET_PS3_SPU;NDEBUG;__GCC__;SPU;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <ProjectReference>
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
+ </ProjectReference>
+ <Link>
+ <AdditionalOptions>-Wl,--gc-sections -g %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalDependencies>-ldma;-lspurs_jq;%(AdditionalDependencies)</AdditionalDependencies>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention>
+ </DataExecutionPrevention>
+ </Link>
+ <SpuElfConversion>
+ <EmbedFormat>JobBin2</EmbedFormat>
+ <OutputFile>..\ObjFiles\ContentPackage\$(TargetName).ppu$(ObjectExt)</OutputFile>
+ </SpuElfConversion>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.spu.vcxproj.vspscc b/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.spu.vcxproj.vspscc
new file mode 100644
index 00000000..b6d32892
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.spu.vcxproj.vspscc
@@ -0,0 +1,10 @@
+""
+{
+"FILE_VERSION" = "9237"
+"ENLISTMENT_CHOICE" = "NEVER"
+"PROJECT_FILE_RELATIVE_PATH" = ""
+"NUMBER_OF_EXCLUDED_FILES" = "0"
+"ORIGINAL_PROJECT_FILE_PATH" = ""
+"NUMBER_OF_NESTED_PROJECTS" = "0"
+"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
+}
diff --git a/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/stdafx.h b/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/stdafx.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/stdafx.h