Skip to content

Commit

Permalink
Merge pull request #91 from fjtrujy/finish_handler
Browse files Browse the repository at this point in the history
Finish handler
  • Loading branch information
fjtrujy authored Jan 10, 2025
2 parents 87a823f + 2897eec commit b5afab2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ set(INSTALL_PKGCONFIG_DIR "${GSKIT}/lib/pkgconfig" CACHE PATH "Installation dire
set(GSKIT_EXTERNAL_LIBS "")
set(GSKIT_EXTERNAL_INCLUDES "")

# Enable interprocedural optimization LTO
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)

set(CUR_GIT_TAG v0.0.0)
find_package(Git)
if(GIT_FOUND)
Expand Down Expand Up @@ -125,6 +128,8 @@ add_object_library_macros(GS_CORE_OBJS ee/gs/src/gsCore.c
gsKit_remove_vsync_handler
gsKit_add_hsync_handler
gsKit_remove_hsync_handler
gsKit_add_finish_handler
gsKit_remove_finish_handler
gsKit_clear
gsKit_set_scissor
gsKit_set_test
Expand Down
6 changes: 6 additions & 0 deletions ee/gs/include/gsCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ int gsKit_add_hsync_handler(int (*hsync_callback)());
/// Removes a hsync interrupt handler
void gsKit_remove_hsync_handler(int callback_id);

/// Installs a finish interrupt handler
int gsKit_add_finish_handler(int (*finish_callback)());

/// Removes a finish interrupt handler
void gsKit_remove_finish_handler(int callback_id);

/// Sets gsGlobal->EvenOrOdd depending on current field drawing
void gsKit_get_field(GSGLOBAL *gsGlobal);

Expand Down
28 changes: 28 additions & 0 deletions ee/gs/src/gsCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,34 @@ void gsKit_remove_hsync_handler(int callback_id)
}
#endif

#if F_gsKit_add_finish_handler
int gsKit_add_finish_handler(int (*finish_callback)())
{
int callback_id;

DIntr();
callback_id = AddIntcHandler(INTC_GS, finish_callback, 0);
EnableIntc(INTC_GS);
// Unmask Finish interrupt
GsPutIMR(GsGetIMR() & ~0x0200);
EIntr();

return callback_id;
}
#endif

#if F_gsKit_remove_finish_handler
void gsKit_remove_finish_handler(int callback_id)
{
DIntr();
// Mask HSync interrupt
GsPutIMR(GsGetIMR() | 0x0200);
DisableIntc(INTC_GS);
RemoveIntcHandler(INTC_GS, callback_id);
EIntr();
}
#endif

#if F_gsKit_clear
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
void gsKit_clear(GSGLOBAL *gsGlobal, u64 color)
Expand Down

0 comments on commit b5afab2

Please sign in to comment.