From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- .../CompressedTileStorage_getData.cpp | 156 +++++++++++++++++++++ .../CompressedTileStorage_getData.h | 1 + .../CompressedTileStorage_getData.spu.vcxproj | 151 ++++++++++++++++++++ ...ompressedTileStorage_getData.spu.vcxproj.vspscc | 10 ++ .../CompressedTileStorage_getData/stdafx.h | 0 5 files changed, 318 insertions(+) create mode 100644 Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.cpp create mode 100644 Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.h create mode 100644 Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.spu.vcxproj create mode 100644 Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/CompressedTileStorage_getData.spu.vcxproj.vspscc create mode 100644 Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData/stdafx.h (limited to 'Minecraft.Client/PS3/SPU_Tasks/CompressedTileStorage_getData') 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 +#include +#include +#include +#include +#include +#include +#include + +#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 @@ + + + + + ContentPackage + PS3 + + + Debug + PS3 + + + Release + PS3 + + + + + + + + + + + {ED672663-B86E-436B-9530-A6589DE02366} + CompressedTileStorage_getData + SAK + SAK + SAK + SAK + + + + Application + SPU + + + Application + SPU + + + Application + SPU + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + PS3_Debug\ + PS3_Debug\ + *.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean) + + false + PS3_Release\ + PS3_Release\ + PS3_Release\ + PS3_Release\ + *.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean) + *.obj;*.d;*.map;*.lst;*.pch;$(TargetPath);undefined;$(ExtensionsToDeleteOnClean) + + + false + false + $(ProjectName) + SpursInit + $(ProjectName) + $(ProjectName) + + + + -ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions) + $(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories) + true + SN_TARGET_PS3_SPU;_DEBUG;__GCC__;SPU;%(PreprocessorDefinitions) + + + true + + + -Wl,--gc-sections -g %(AdditionalOptions) + -ldma;-lspurs_jq;%(AdditionalDependencies) + false + + + + + JobBin2 + ..\ObjFiles\Debug\$(TargetName).ppu$(ObjectExt) + + + + + -ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions) + $(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories) + true + Level3 + SN_TARGET_PS3_SPU;NDEBUG;__GCC__;SPU;%(PreprocessorDefinitions) + + + true + + + -Wl,--gc-sections -g %(AdditionalOptions) + -ldma;-lspurs_jq;%(AdditionalDependencies) + false + + + + + JobBin2 + ..\ObjFiles\Release\$(TargetName).ppu$(ObjectExt) + + + + + -ffunction-sections -fdata-sections -fstack-check %(AdditionalOptions) + $(SN_PS3_PATH)\spu\include\sn;$(SCE_PS3_ROOT)\target\spu\include;$(SCE_PS3_ROOT)\target\common\include;%(AdditionalIncludeDirectories) + true + Level3 + SN_TARGET_PS3_SPU;NDEBUG;__GCC__;SPU;%(PreprocessorDefinitions) + + + true + + + -Wl,--gc-sections -g %(AdditionalOptions) + -ldma;-lspurs_jq;%(AdditionalDependencies) + false + + + + + JobBin2 + ..\ObjFiles\ContentPackage\$(TargetName).ppu$(ObjectExt) + + + + + + \ 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 -- cgit v1.2.3