the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1
2
3#pragma once
4#include <cell/spurs.h>
5
6
7#define JOBHEADER_SYMBOL(JobName) _binary_jqjob_##JobName##_jobbin2_jobheader
8
9// class C4JSpursJobEventQueue
10// {
11// C4JThread* m_pollingThread;
12// sys_event_port_t m_basicEventPort;
13// sys_event_queue_t m_basicEventQueue;
14//
15// typedef int (C4JSpursJobEventQueueFunc)(uint64_t data1, uint64_t data2);
16//
17// int eventPoll(void* lpParam)
18// {
19// sys_event_t event;
20// do
21// {
22// sys_event_queue_receive(m_basicEventQueue, &event, 0);
23// C4JSpursJobEventQueueFunc* func = (C4JSpursJobEventQueueFunc*)event.data1;
24// func(event.data2, event.data3);
25// } while(1);
26// return 0;
27// }
28//
29// void CompressedTileStorage::compress_SPUSendEvent(int upgradeBlock/*=-1*/)
30// {
31// if(g_pCompressSPUThread == NULL)
32// {
33// sys_event_port_create(&g_basicEventPort, SYS_EVENT_PORT_LOCAL, SYS_EVENT_PORT_NO_NAME);
34// sys_event_queue_attribute_t queue_attr = {SYS_SYNC_PRIORITY, SYS_PPU_QUEUE};
35// sys_event_queue_create(&g_basicEventQueue, &queue_attr, SYS_EVENT_QUEUE_LOCAL, 127);
36// sys_event_port_connect_local(g_basicEventPort, g_basicEventQueue);
37//
38// g_pCompressSPUThread = new C4JThread(compress_SPUEventPoll, this, "compress_SPU");
39// g_pCompressSPUThread->Run();
40// }
41//
42// sys_event_port_send(g_basicEventPort, (std::uint64_t)this, upgradeBlock, 0);
43// }
44//
45// };
46
47class C4JSpursJob
48{
49public:
50 CellSpursJob256 m_job256;
51
52 C4JSpursJob();
53};
54
55class TileCompressData_SPU;
56class C4JSpursJob_CompressedTile : public C4JSpursJob
57{
58public:
59 C4JSpursJob_CompressedTile();
60 C4JSpursJob_CompressedTile(TileCompressData_SPU* pDataIn, unsigned char* pDataOut);
61};
62
63class ChunkRebuildData;
64class C4JSpursJob_ChunkUpdate : public C4JSpursJob
65{
66public:
67 C4JSpursJob_ChunkUpdate();
68 C4JSpursJob_ChunkUpdate(ChunkRebuildData* pDataIn, ChunkRebuildData* pDataOut);
69};
70
71class LevelRenderer_cull_DataIn;
72class C4JSpursJob_LevelRenderer_cull : public C4JSpursJob
73{
74public:
75 C4JSpursJob_LevelRenderer_cull();
76 C4JSpursJob_LevelRenderer_cull(LevelRenderer_cull_DataIn* pDataIn);
77};
78
79class C4JSpursJob_LevelRenderer_zSort : public C4JSpursJob
80{
81public:
82 C4JSpursJob_LevelRenderer_zSort();
83 C4JSpursJob_LevelRenderer_zSort(LevelRenderer_cull_DataIn* pDataIn);
84};
85
86class LevelRenderer_FindNearestChunk_DataIn;
87class C4JSpursJob_LevelRenderer_FindNearestChunk : public C4JSpursJob
88{
89public:
90 C4JSpursJob_LevelRenderer_FindNearestChunk();
91 C4JSpursJob_LevelRenderer_FindNearestChunk(LevelRenderer_FindNearestChunk_DataIn* pDataIn);
92};
93
94
95// class Renderer_TextureUpdate_DataIn;
96// class C4JSpursJob_Renderer_TextureUpdate : public C4JSpursJob
97// {
98// public:
99// C4JSpursJob_Renderer_TextureUpdate();
100// C4JSpursJob_Renderer_TextureUpdate(Renderer_TextureUpdate_DataIn* pDataIn);
101// };
102
103class Texture_blit_DataIn;
104class C4JSpursJob_Texture_blit : public C4JSpursJob
105{
106public:
107 C4JSpursJob_Texture_blit();
108 C4JSpursJob_Texture_blit(Texture_blit_DataIn* pDataIn);
109};
110
111class CompressedTileStorage_compress_dataIn;
112class C4JSpursJob_CompressedTileStorage_compress : public C4JSpursJob
113{
114public:
115 C4JSpursJob_CompressedTileStorage_compress();
116 C4JSpursJob_CompressedTileStorage_compress(CompressedTileStorage_compress_dataIn* pDataIn);
117};
118
119class C4JSpursJob_CompressedTileStorage_getData : public C4JSpursJob
120{
121public:
122 C4JSpursJob_CompressedTileStorage_getData();
123 C4JSpursJob_CompressedTileStorage_getData(unsigned char* pIdxAndData, int dataSize, unsigned char* pDst, unsigned int retOffset);
124};
125
126
127
128
129// class GameRenderer_updateLightTexture_dataIn;
130// class C4JSpursJob_GameRenderer_updateLightTexture : public C4JSpursJob
131// {
132// public:
133// C4JSpursJob_GameRenderer_updateLightTexture();
134// C4JSpursJob_GameRenderer_updateLightTexture(GameRenderer_updateLightTexture_dataIn* pDataIn);
135// };
136
137
138class PerlinNoise_DataIn;
139class C4JSpursJob_PerlinNoise : public C4JSpursJob
140{
141public:
142 C4JSpursJob_PerlinNoise();
143 C4JSpursJob_PerlinNoise(PerlinNoise_DataIn* pDataIn);
144};
145
146
147// class C4JSpursJob_MemSet : public C4JSpursJob
148// {
149// public:
150// C4JSpursJob_MemSet();
151// C4JSpursJob_MemSet(void* pMem, int numBytes, uint8_t val);
152// };
153
154// class C4JSpursJob_RLECompress : public C4JSpursJob
155// {
156// public:
157// C4JSpursJob_RLECompress();
158// C4JSpursJob_RLECompress(void* pSrc, int srcSize, void* pDst, int* pDstSize);
159// };
160
161
162
163class C4JSpursJobQueue
164{
165public:
166 class Port
167 {
168 static bool s_initialised;
169 static CRITICAL_SECTION s_lock;
170 static uint16_t s_jobTagBitmask;
171 static Port* s_allocatedPorts[16];
172
173 cell::Spurs::JobQueue::Port2* m_pPort2;
174 int m_jobTag;
175 bool m_bDestroyed;
176 const char* m_portName;
177 int getFreeJobTag();
178 void releaseJobTag(int tag);
179 public:
180 Port(const char* portName);
181 ~Port();
182
183 static void destroyAll();
184 void submitJob(C4JSpursJob* pJob);
185 void waitForCompletion();
186 bool hasCompleted();
187 void submitSync();
188 };
189
190private:
191 static const unsigned int JOB_QUEUE_DEPTH = 256;
192 static C4JSpursJobQueue* m_pMainJobQueue;
193 uint8_t *pPool;
194 cell::Spurs::JobQueue::JobQueue<JOB_QUEUE_DEPTH> *pJobQueue;
195
196public:
197 static C4JSpursJobQueue& getMainJobQueue() {if(m_pMainJobQueue == NULL) m_pMainJobQueue = new C4JSpursJobQueue; return *m_pMainJobQueue;}
198
199 C4JSpursJobQueue();
200 void shutdown();
201 void submitJob(C4JSpursJob* pJob);
202 void waitForCompletion();
203 void submitSync();
204};
205