Skip to content

Commit 86a30fb

Browse files
authored
Merge pull request #302 from fjtrujy/sceguEndObject
Improve `sceGuEndObject`
2 parents 5168b3f + e59e71e commit 86a30fb

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/gu/pspgu.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,10 @@ void sceGuBeginObject(int vtype, int count, const void* indices, const void* ver
779779

780780
/**
781781
* End conditional rendering of object
782+
*
783+
* @return 0 for success, < 0 for failure
782784
**/
783-
void sceGuEndObject(void);
785+
int sceGuEndObject(void);
784786

785787
/**
786788
* Enable or disable GE state

src/gu/sceGuEndObject.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,30 @@
88

99
#include "guInternal.h"
1010

11-
void sceGuEndObject(void)
11+
#define ERROR_NOT_FOUND 0x80000025
12+
13+
int sceGuEndObject(void)
1214
{
13-
// rewrite commands from sceGuBeginObject()
15+
int res;
16+
17+
gu_object_stack_depth--;
18+
if (gu_object_stack_depth < 0) {
19+
return -ERROR_NOT_FOUND;
20+
}
1421

1522
unsigned int *current = gu_list->current;
16-
gu_list->current = gu_object_stack[gu_object_stack_depth - 1];
23+
gu_list->current = gu_object_stack[gu_object_stack_depth];
1724

1825
sendCommandi(BASE, (((unsigned int)current) >> 8) & 0xf0000);
1926
sendCommandi(BJUMP, (unsigned int)current);
2027
gu_list->current = current;
2128

22-
gu_object_stack_depth--;
29+
if (gu_curr_context == GU_DIRECT) {
30+
res = _sceGuUpdateStallAddr();
31+
if (res < 0) {
32+
return res;
33+
}
34+
}
35+
36+
return gu_object_stack_depth;
2337
}

0 commit comments

Comments
 (0)