Improve the sceGuEndObject implementation

This commit is contained in:
Francisco Javier Trujillo Mata
2025-06-04 23:46:30 +02:00
parent 5168b3f705
commit e59e71e45b
2 changed files with 21 additions and 5 deletions

View File

@@ -779,8 +779,10 @@ void sceGuBeginObject(int vtype, int count, const void* indices, const void* ver
/** /**
* End conditional rendering of object * End conditional rendering of object
*
* @return 0 for success, < 0 for failure
**/ **/
void sceGuEndObject(void); int sceGuEndObject(void);
/** /**
* Enable or disable GE state * Enable or disable GE state

View File

@@ -8,16 +8,30 @@
#include "guInternal.h" #include "guInternal.h"
void sceGuEndObject(void) #define ERROR_NOT_FOUND 0x80000025
int sceGuEndObject(void)
{ {
// rewrite commands from sceGuBeginObject() int res;
gu_object_stack_depth--;
if (gu_object_stack_depth < 0) {
return -ERROR_NOT_FOUND;
}
unsigned int *current = gu_list->current; unsigned int *current = gu_list->current;
gu_list->current = gu_object_stack[gu_object_stack_depth - 1]; gu_list->current = gu_object_stack[gu_object_stack_depth];
sendCommandi(BASE, (((unsigned int)current) >> 8) & 0xf0000); sendCommandi(BASE, (((unsigned int)current) >> 8) & 0xf0000);
sendCommandi(BJUMP, (unsigned int)current); sendCommandi(BJUMP, (unsigned int)current);
gu_list->current = current; gu_list->current = current;
gu_object_stack_depth--; if (gu_curr_context == GU_DIRECT) {
res = _sceGuUpdateStallAddr();
if (res < 0) {
return res;
}
}
return gu_object_stack_depth;
} }