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 "Texture_blit.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
49
50
51
52
53
54void blit(Texture_blit_DataIn& dataIn)
55{
56 int yy = dataIn.yy;
57 int xx = dataIn.xx;
58// int hh = dataIn.hh;
59 int ww = dataIn.ww;
60 int shh = dataIn.shh;
61 int sww = dataIn.sww;
62 bool rotated = dataIn.rotated;
63
64 for (int srcY = 0; srcY < shh; srcY++)
65 {
66 int dstY = yy + srcY;
67 int srcLine = srcY * sww * 4;
68 int dstLine = dstY * ww * 4;
69
70 if (rotated)
71 {
72 dstY = yy + (shh - srcY);
73 }
74
75 for (int srcX = 0; srcX < sww; srcX++)
76 {
77 int dstPos = dstLine + (srcX + xx) * 4;
78 int srcPos = srcLine + srcX * 4;
79
80 if (rotated)
81 {
82 dstPos = (xx + srcX * ww * 4) + dstY * 4;
83 }
84
85 uint32_t val = DmaData_SPU::getValue32((uintptr_t)&dataIn.pSrcData[srcPos]);
86 DmaData_SPU::putValue32(val, (uintptr_t)&dataIn.pDstData[dstPos]);
87
88// data[level]->put(dstPos + 0, srcBuffer->get(srcPos + 0));
89// data[level]->put(dstPos + 1, srcBuffer->get(srcPos + 1));
90// data[level]->put(dstPos + 2, srcBuffer->get(srcPos + 2));
91// data[level]->put(dstPos + 3, srcBuffer->get(srcPos + 3));
92 }
93 }
94}
95
96
97
98void cellSpursJobQueueMain(CellSpursJobContext2 *pContext, CellSpursJob256 *pJob)
99{
100 // CellSpursTaskId idTask = cellSpursGetTaskId();
101 unsigned int idSpu = cellSpursGetCurrentSpuId();
102
103 if(sc_verbose)
104 spu_print("LevelRenderer_cull [SPU#%u] start\n", idSpu);
105
106 g_pSpursJobContext = pContext;
107 uint32_t eaDataIn = pJob->workArea.userData[0];
108// uint32_t eaDataOut =pJob->workArea.userData[1];
109
110 Texture_blit_DataIn dataIn;
111 DmaData_SPU::getAndWait(&dataIn, eaDataIn, sizeof(Texture_blit_DataIn));
112
113 if(sc_verbose)
114 spu_print("Texture_blit [SPU#%u] \n", idSpu);
115
116 blit(dataIn);
117
118
119 if(sc_verbose)
120 spu_print("Texture_blit [SPU#%u] exit\n", idSpu);
121}
122