the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1/* SCE CONFIDENTIAL
2PlayStation(R)3 Programmer Tool Runtime Library 430.001
3* Copyright (C) 2007 Sony Computer Entertainment Inc.
4* All Rights Reserved.
5*/
6
7/* common headers */
8#include <stdint.h>
9#include <stdlib.h>
10#include <alloca.h>
11#include <spu_intrinsics.h>
12#include <cell/spurs.h>
13#include <cell/dma.h>
14#include <cell/spurs/job_queue.h>
15
16#include "Renderer_TextureUpdate.h"
17#include "..\Common\DmaData.h"
18#include <vectormath/c/vectormath_aos_v.h>
19
20
21
22static const bool sc_verbose = false;
23
24CellSpursJobContext2* g_pSpursJobContext;
25
26
27void CopyPPUMemory(void* pSrc, void* pDst, int size)
28{
29 static const int bufferSize = 16384;
30 char spuBuffer[bufferSize];
31 int dataLeft = size;
32 char* pSrcPos = (char*)pSrc;
33 char* pDstPos = (char*)pDst;
34 while(dataLeft > 0)
35 {
36 int sizeToDma = dataLeft;
37 if(sizeToDma > bufferSize)
38 sizeToDma = bufferSize;
39
40 DmaData_SPU::getAndWait(spuBuffer, (uintptr_t)pSrcPos, sizeToDma);
41 DmaData_SPU::putAndWait(spuBuffer, (uintptr_t)pDstPos, sizeToDma);
42 pSrcPos += sizeToDma;
43 pDstPos += sizeToDma;
44 dataLeft -= sizeToDma;
45 }
46}
47
48
49void TextureDataUpdate(int xoffset, int yoffset, int width, int height, int pitch, void *pSrcData, void* pDstData, int level)
50{
51 int colourDepth = 4;
52 char* pTexData = (char*)pDstData;
53 char* pSrc = (char*) pSrcData;
54 int srcOffset = 0;
55 int dstOffset = 0;
56 for(int i=0; i<height;i++)
57 {
58 CopyPPUMemory(&pSrc[srcOffset], &pTexData[dstOffset], pitch*colourDepth);
59 srcOffset += width*colourDepth;
60 dstOffset += pitch;
61 }
62}
63
64
65void cellSpursJobQueueMain(CellSpursJobContext2 *pContext, CellSpursJob256 *pJob)
66{
67 // CellSpursTaskId idTask = cellSpursGetTaskId();
68 unsigned int idSpu = cellSpursGetCurrentSpuId();
69
70 if(sc_verbose)
71 spu_print("LevelRenderer_cull [SPU#%u] start\n", idSpu);
72
73 g_pSpursJobContext = pContext;
74 uint32_t eaDataIn = pJob->workArea.userData[0];
75// uint32_t eaDataOut =pJob->workArea.userData[1];
76
77 Renderer_TextureUpdate_DataIn dataIn;
78 DmaData_SPU::getAndWait(&dataIn, eaDataIn, sizeof(Renderer_TextureUpdate_DataIn));
79
80 if(sc_verbose)
81 spu_print("Renderer_TextureDataUpdate [SPU#%u] \n", idSpu);
82
83 TextureDataUpdate(dataIn.xoffset, dataIn.yoffset, dataIn.width, dataIn.height, dataIn.pitch, dataIn.pSrcData, dataIn.pDstData, dataIn.level );
84
85
86 if(sc_verbose)
87 spu_print("Renderer_TextureDataUpdate [SPU#%u] exit\n", idSpu);
88}
89