Skip to content

Commit 3f175d4

Browse files
committed
Create finish handler methods
1 parent 87a823f commit 3f175d4

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ add_object_library_macros(GS_CORE_OBJS ee/gs/src/gsCore.c
125125
gsKit_remove_vsync_handler
126126
gsKit_add_hsync_handler
127127
gsKit_remove_hsync_handler
128+
gsKit_add_finish_handler
129+
gsKit_remove_finish_handler
128130
gsKit_clear
129131
gsKit_set_scissor
130132
gsKit_set_test

ee/gs/include/gsCore.h

+6
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ int gsKit_add_hsync_handler(int (*hsync_callback)());
152152
/// Removes a hsync interrupt handler
153153
void gsKit_remove_hsync_handler(int callback_id);
154154

155+
/// Installs a finish interrupt handler
156+
int gsKit_add_finish_handler(int (*finish_callback)());
157+
158+
/// Removes a finish interrupt handler
159+
void gsKit_remove_finish_handler(int callback_id);
160+
155161
/// Sets gsGlobal->EvenOrOdd depending on current field drawing
156162
void gsKit_get_field(GSGLOBAL *gsGlobal);
157163

ee/gs/src/gsCore.c

+28
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,34 @@ void gsKit_remove_hsync_handler(int callback_id)
252252
}
253253
#endif
254254

255+
#if F_gsKit_add_finish_handler
256+
int gsKit_add_finish_handler(int (*finish_callback)())
257+
{
258+
int callback_id;
259+
260+
DIntr();
261+
callback_id = AddIntcHandler(INTC_GS, finish_callback, 0);
262+
EnableIntc(INTC_GS);
263+
// Unmask Finish interrupt
264+
GsPutIMR(GsGetIMR() & ~0x0200);
265+
EIntr();
266+
267+
return callback_id;
268+
}
269+
#endif
270+
271+
#if F_gsKit_remove_finish_handler
272+
void gsKit_remove_finish_handler(int callback_id)
273+
{
274+
DIntr();
275+
// Mask HSync interrupt
276+
GsPutIMR(GsGetIMR() | 0x0200);
277+
DisableIntc(INTC_GS);
278+
RemoveIntcHandler(INTC_GS, callback_id);
279+
EIntr();
280+
}
281+
#endif
282+
255283
#if F_gsKit_clear
256284
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
257285
void gsKit_clear(GSGLOBAL *gsGlobal, u64 color)

0 commit comments

Comments
 (0)