@@ -235,46 +235,70 @@ static unsigned int __attribute__((aligned(16))) ge_init_list[] =
235
235
ZV (END ),
236
236
};
237
237
238
- void callbackFin (int id , void * arg )
238
+ void callbackFin (int id , void * arg )
239
239
{
240
- GuSettings * settings = (GuSettings * )arg ;
240
+ GuSettings * settings = (GuSettings * )arg ;
241
241
if (settings -> fin )
242
242
settings -> fin (id & 0xffff );
243
243
}
244
244
245
- void callbackSig (int id , void * arg )
245
+ void callbackSig (int id , void * arg )
246
246
{
247
- GuSettings * settings = (GuSettings * )arg ;
247
+ GuSettings * settings = (GuSettings * )arg ;
248
248
249
249
settings -> signal_history [(settings -> signal_offset ++ ) & 15 ] = id & 0xffff ;
250
250
251
251
if (settings -> sig )
252
252
settings -> sig (id & 0xffff );
253
253
254
- sceKernelSetEventFlag (settings -> kernel_event_flag ,1 );
254
+ sceKernelSetEventFlag (settings -> kernel_event_flag , 1 );
255
255
}
256
256
257
- void sceGuInit (void )
257
+ int sceGuInit (void )
258
258
{
259
+ int res ;
259
260
PspGeCallbackData callback ;
261
+
262
+ ge_edram_address = sceGeEdramGetAddr ();
263
+ _sceGuResetGlobalVariables ();
264
+
265
+ res = sceKernelCreateEventFlag ("SceGuSignal" , PSP_EVENT_WAITMULTIPLE , 3 , 0 );
266
+ if (res < 0 )
267
+ {
268
+ return res ;
269
+ }
270
+ gu_settings .kernel_event_flag = res ;
271
+
260
272
callback .signal_func = callbackSig ;
261
273
callback .signal_arg = & gu_settings ;
262
274
callback .finish_func = callbackFin ;
263
275
callback .finish_arg = & gu_settings ;
264
- gu_settings .ge_callback_id = sceGeSetCallback (& callback );
265
-
266
- gu_settings .swapBuffersCallback = 0 ;
267
- gu_settings .swapBuffersBehaviour = PSP_DISPLAY_SETBUF_IMMEDIATE ;
268
-
269
- ge_edram_address = sceGeEdramGetAddr ();
276
+ res = sceGeSetCallback (& callback );
277
+ if (res < 0 )
278
+ {
279
+ sceKernelDeleteEventFlag (gu_settings .kernel_event_flag );
280
+ gu_settings .kernel_event_flag = -1 ;
281
+ return res ;
282
+ }
283
+ gu_settings .ge_callback_id = res ;
270
284
271
285
// initialize graphics hardware
272
- ge_list_executed [0 ] = sceGeListEnQueue ((void * )((unsigned int )ge_init_list & 0x1fffffff ), 0 , gu_settings .ge_callback_id , 0 );
273
-
274
- resetValues ();
275
-
276
- gu_settings .kernel_event_flag = sceKernelCreateEventFlag ("SceGuSignal" , 512 , 3 , 0 );
277
-
286
+ res = sceGeListEnQueue ((void * )((unsigned int )ge_init_list & 0x1fffffff ), 0 , gu_settings .ge_callback_id , 0 );
287
+ if (res < 0 )
288
+ {
289
+ sceKernelDeleteEventFlag (gu_settings .kernel_event_flag );
290
+ sceGeUnsetCallback (gu_settings .ge_callback_id );
291
+ gu_settings .ge_callback_id = -1 ;
292
+ gu_settings .kernel_event_flag = -1 ;
293
+ return res ;
294
+ }
295
+ ge_list_executed [0 ] = res ;
278
296
// wait for init to complete
279
297
sceGeListSync (ge_list_executed [0 ], 0 );
298
+ sceGeDrawSync (0 );
299
+
300
+ gu_settings .swapBuffersCallback = NULL ;
301
+ gu_settings .swapBuffersBehaviour = PSP_DISPLAY_SETBUF_NEXTHSYNC ;
302
+
303
+ return 0 ;
280
304
}
0 commit comments