Skip to content

Commit

Permalink
Remove hud compile option
Browse files Browse the repository at this point in the history
  • Loading branch information
clementgallet committed Jan 31, 2023
1 parent 5b41677 commit 3b05bd7
Show file tree
Hide file tree
Showing 37 changed files with 23 additions and 231 deletions.
50 changes: 20 additions & 30 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ AM_SILENT_RULES([yes])

dnl **** Configure options ****

AC_ARG_ENABLE([hud], AS_HELP_STRING([--disable-hud], [Disable the HUD]))
AC_ARG_WITH([i386], AS_HELP_STRING([--with-i386],[Build libTAS with support for 32-bit executables]))
AC_ARG_ENABLE([i386-lib], AS_HELP_STRING([--enable-i386-lib],[Build 32-bit version of libTAS library]))

Expand Down Expand Up @@ -118,12 +117,10 @@ AS_IF([test "x$have_libswresample" = "xyes"], [
AC_SUBST(LIBSWRESAMPLE_CFLAGS)
])

AS_IF([test "x$enable_hud" != "xno"], [
CPPFLAGS='-I/usr/include/freetype2'
AC_CHECK_HEADERS([fontconfig/fontconfig.h ft2build.h], [], [enable_hud=no])
AC_SEARCH_LIBS([FcInitLoadConfigAndFonts], [fontconfig], [], [enable_hud=no])
AC_SEARCH_LIBS([FT_Open_Face], [freetype], [], [enable_hud=no])
])
CPPFLAGS='-I/usr/include/freetype2'
AC_CHECK_HEADERS([fontconfig/fontconfig.h ft2build.h], [], [AC_MSG_ERROR(The fontconfig and freetype headers are required!)])
AC_SEARCH_LIBS([FcInitLoadConfigAndFonts], [fontconfig], [], [AC_MSG_ERROR(The fontconfig library is required!)])
AC_SEARCH_LIBS([FT_Open_Face], [freetype], [], [AC_MSG_ERROR(The freetype library is required!)])

LIBRARY_LIBS=$LIBS
LIBS=
Expand All @@ -133,40 +130,33 @@ dnl **** Check for 32-bit libraries for libTAS library ****
save_CXX="$CXX"

case $host in
x86_64*|amd64*)
x86_64*|amd64*)
if [test "x$with_i386" = "xyes"] || [test "x$enable_i386_lib" = "xyes"]
then

AC_LANG_PUSH([C++])
CXX="$CXX -m32"
AC_LANG_PUSH([C++])
CXX="$CXX -m32"

dnl Look at different functions to avoid caching
AC_SEARCH_LIBS([dlclose], [dl dld])
AC_SEARCH_LIBS([XCloseDisplay], [X11], [], [AC_MSG_ERROR(The x11 library is required!)])
unset ac_cv_search_XGetXCBConnection
AC_SEARCH_LIBS([XGetXCBConnection], [X11-xcb], [], [AC_MSG_ERROR(The x11-xcb library is required!)])
AC_SEARCH_LIBS([pthread_exit], [pthread], [], [AC_MSG_ERROR(The pthread library is required!)])
AC_SEARCH_LIBS([snd_pcm_close], [asound], [], [AC_MSG_ERROR(The asound library is required!)])
dnl Look at different functions to avoid caching
AC_SEARCH_LIBS([dlclose], [dl dld])
AC_SEARCH_LIBS([XCloseDisplay], [X11], [], [AC_MSG_ERROR(The 32-bit x11 library is required!)])
unset ac_cv_search_XGetXCBConnection
AC_SEARCH_LIBS([XGetXCBConnection], [X11-xcb], [], [AC_MSG_ERROR(The 32-bit x11-xcb library is required!)])
AC_SEARCH_LIBS([pthread_exit], [pthread], [], [AC_MSG_ERROR(The 32-bit pthread library is required!)])
AC_SEARCH_LIBS([snd_pcm_close], [asound], [], [AC_MSG_ERROR(The 32-bit asound library is required!)])

AS_IF([test "x$enable_hud" != "xno"], [
AC_SEARCH_LIBS([FcConfigAppFontAddFile], [fontconfig], [], [enable_hud=no])
AC_SEARCH_LIBS([FT_Bitmap_Convert], [freetype], [], [enable_hud=no])
])
AC_SEARCH_LIBS([FcConfigAppFontAddFile], [fontconfig], [], [AC_MSG_ERROR(The 32-bit fontconfig library is required!)])
AC_SEARCH_LIBS([FT_Bitmap_Convert], [freetype], [], [AC_MSG_ERROR(The 32-bit freetype library is required!)])

LIBRARY32_LIBS=$LIBS
LIBS=
LIBRARY32_LIBS=$LIBS
LIBS=

CXX="$save_CXX"
AC_LANG_POP([C++])
CXX="$save_CXX"
AC_LANG_POP([C++])
fi
;;
esac

AS_IF([test "x$enable_hud" != "xno"], [
AC_DEFINE([LIBTAS_ENABLE_HUD], [1], [HUD is enabled])
AC_MSG_NOTICE([HUD is enabled])
])

dnl **** Export date and commit ****

AS_IF([test "x$enable_release_build" != "xyes"], [
Expand Down
4 changes: 0 additions & 4 deletions src/library/BusyLoopDetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,8 @@ void BusyLoopDetection::increment(int type)
if (timecall_count > 20) {
debuglogstdio(LCF_TIMESET, "Still softlocking, advance one frame");
std::function<void()> dummy_draw;
#ifdef LIBTAS_ENABLE_HUD
static RenderHUD dummy;
frameBoundary(dummy_draw, dummy);
#else
frameBoundary(dummy_draw);
#endif
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/library/DeterministicTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,8 @@ void DeterministicTimer::addDelay(struct timespec delayTicks)
* This decrements addedDelay by (basically) how much it advances ticks
*/
std::function<void()> dummy_draw;
#ifdef LIBTAS_ENABLE_HUD
static RenderHUD dummy;
frameBoundary(dummy_draw, dummy);
#else
frameBoundary(dummy_draw);
#endif
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/library/checkpoint/SaveStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,7 @@ void SaveStateManager::printError(int err)

if (err < 0) {
debuglogstdio(LCF_CHECKPOINT | LCF_ERROR, errors[-err]);
#ifdef LIBTAS_ENABLE_HUD
RenderHUD::insertMessage(errors[-err]);
#endif
}
}

Expand Down
5 changes: 0 additions & 5 deletions src/library/eglwrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,9 @@ EGLBoolean eglSwapBuffers( EGLDisplay dpy, EGLSurface surface )
DEBUGLOGCALL(LCF_WINDOW | LCF_OGL);

/* Start the frame boundary and pass the function to draw */
#ifdef LIBTAS_ENABLE_HUD
// static RenderHUD_GL renderHUD;
static RenderHUD_GL renderHUD;
renderHUD.setGLES(bindAPI == EGL_OPENGL_ES_API);
frameBoundary([&] () {orig::eglSwapBuffers(dpy, surface);}, renderHUD);
#else
frameBoundary([&] () {orig::eglSwapBuffers(dpy, surface);});
#endif

return EGL_TRUE;
}
Expand Down
62 changes: 1 addition & 61 deletions src/library/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ static uint64_t nondraw_framecount = 0;
/* Did we do at least one savestate? */
static bool didASavestate = false;

#ifdef LIBTAS_ENABLE_HUD
static void receive_messages(std::function<void()> draw, RenderHUD& hud);
#else
static void receive_messages(std::function<void()> draw);
#endif

/* Compute real and logical fps */
static void computeFPS(float& fps, float& lfps)
Expand Down Expand Up @@ -216,11 +212,7 @@ static void sendFrameCountTime()
sendData(&ticks_val, sizeof(uint64_t));
}

#ifdef LIBTAS_ENABLE_HUD
void frameBoundary(std::function<void()> draw, RenderHUD& hud)
#else
void frameBoundary(std::function<void()> draw)
#endif
{
static float fps, lfps = 0;

Expand Down Expand Up @@ -329,10 +321,8 @@ void frameBoundary(std::function<void()> draw)
sendMessage(MSGB_START_FRAMEBOUNDARY);

/* Reset ramwatches and lua drawings */
#ifdef LIBTAS_ENABLE_HUD
RenderHUD::resetWatches();
RenderHUD::resetLua();
#endif

/* Receive messages from the program */
int message = receiveMessage();
Expand All @@ -343,9 +333,7 @@ void frameBoundary(std::function<void()> draw)
{
/* Get ramwatch from the program */
std::string ramwatch = receiveString();
#ifdef LIBTAS_ENABLE_HUD
RenderHUD::insertWatch(ramwatch);
#endif
break;
}
case MSGN_LUA_RESOLUTION:
Expand All @@ -366,9 +354,7 @@ void frameBoundary(std::function<void()> draw)
uint32_t fg, bg;
receiveData(&fg, sizeof(uint32_t));
receiveData(&bg, sizeof(uint32_t));
#ifdef LIBTAS_ENABLE_HUD
RenderHUD::insertLuaText(x, y, text, fg, bg);
#endif
break;
}
case MSGN_LUA_PIXEL:
Expand All @@ -378,9 +364,7 @@ void frameBoundary(std::function<void()> draw)
receiveData(&y, sizeof(int));
uint32_t color;
receiveData(&color, sizeof(uint32_t));
#ifdef LIBTAS_ENABLE_HUD
RenderHUD::insertLuaPixel(x, y, color);
#endif
break;
}
case MSGN_LUA_RECT:
Expand All @@ -394,9 +378,7 @@ void frameBoundary(std::function<void()> draw)
uint32_t outline, fill;
receiveData(&outline, sizeof(uint32_t));
receiveData(&fill, sizeof(uint32_t));
#ifdef LIBTAS_ENABLE_HUD
RenderHUD::insertLuaRect(x, y, w, h, thickness, outline, fill);
#endif
break;
}
case MSGN_LUA_LINE:
Expand All @@ -408,9 +390,7 @@ void frameBoundary(std::function<void()> draw)
receiveData(&y1, sizeof(int));
uint32_t color;
receiveData(&color, sizeof(uint32_t));
#ifdef LIBTAS_ENABLE_HUD
RenderHUD::insertLuaLine(x0, y0, x1, y1, color);
#endif
break;
}
case MSGN_LUA_ELLIPSE:
Expand All @@ -422,9 +402,7 @@ void frameBoundary(std::function<void()> draw)
receiveData(&radius_y, sizeof(int));
uint32_t color;
receiveData(&color, sizeof(uint32_t));
#ifdef LIBTAS_ENABLE_HUD
RenderHUD::insertLuaEllipse(center_x, center_y, radius_x, radius_y, color);
#endif
break;
}
}
Expand All @@ -442,13 +420,11 @@ void frameBoundary(std::function<void()> draw)
/* If we want HUD to appear in encodes, we need to draw it before saving
* the window surface/texture/etc. This has the small drawback that we
* won't be able to remove HUD messages during that frame. */
#ifdef LIBTAS_ENABLE_HUD
if (!Global::skipping_draw && draw && Global::shared_config.osd_encode) {
AllInputs preview_ai;
preview_ai.emptyInputs();
hud.drawAll(framecount, nondraw_framecount, ai, preview_ai);
}
#endif

if (!Global::skipping_draw) {
if (draw) {
Expand Down Expand Up @@ -479,13 +455,11 @@ void frameBoundary(std::function<void()> draw)
}
}

#ifdef LIBTAS_ENABLE_HUD
if (!Global::skipping_draw && draw && !Global::shared_config.osd_encode) {
AllInputs preview_ai;
preview_ai.emptyInputs();
hud.drawAll(framecount, nondraw_framecount, ai, preview_ai);
}
#endif

/* Actual draw command */
if (!Global::skipping_draw && draw) {
Expand All @@ -494,11 +468,7 @@ void frameBoundary(std::function<void()> draw)
}

/* Receive messages from the program */
#ifdef LIBTAS_ENABLE_HUD
receive_messages(draw, hud);
#else
receive_messages(draw);
#endif
receive_messages(draw, hud);

/* No more socket messages here, unlocking the socket. */
unlockSocket();
Expand Down Expand Up @@ -631,29 +601,19 @@ static void pushQuitEvent(void)
}


#ifdef LIBTAS_ENABLE_HUD
static void screen_redraw(std::function<void()> draw, RenderHUD& hud, AllInputs preview_ai)
#else
static void screen_redraw(std::function<void()> draw, AllInputs preview_ai)
#endif
{
if (!Global::skipping_draw && draw) {
ScreenCapture::copySurfaceToScreen();

#ifdef LIBTAS_ENABLE_HUD
hud.drawAll(framecount, nondraw_framecount, ai, preview_ai);
#endif

GlobalNoLog gnl;
NATIVECALL(draw());
}
}

#ifdef LIBTAS_ENABLE_HUD
static void receive_messages(std::function<void()> draw, RenderHUD& hud)
#else
static void receive_messages(std::function<void()> draw)
#endif
{
AllInputs preview_ai;
preview_ai.emptyInputs();
Expand All @@ -664,13 +624,11 @@ static void receive_messages(std::function<void()> draw)
while (1) {
int slot = SaveStateManager::waitChild();
if (slot < 0) break;
#ifdef LIBTAS_ENABLE_HUD
std::string msg = "State ";
msg += std::to_string(slot);
msg += " saved";
RenderHUD::insertMessage(msg.c_str());
screen_redraw(draw, hud, preview_ai);
#endif
}

while (1)
Expand Down Expand Up @@ -701,13 +659,11 @@ static void receive_messages(std::function<void()> draw)
while (1) {
int slot = SaveStateManager::waitChild();
if (slot < 0) break;
#ifdef LIBTAS_ENABLE_HUD
std::string msg = "State ";
msg += std::to_string(slot);
msg += " saved";
RenderHUD::insertMessage(msg.c_str());
screen_redraw(draw, hud, preview_ai);
#endif
}
}
int status;
Expand Down Expand Up @@ -746,20 +702,12 @@ static void receive_messages(std::function<void()> draw)
break;

case MSGN_EXPOSE:
#ifdef LIBTAS_ENABLE_HUD
screen_redraw(draw, hud, preview_ai);
#else
screen_redraw(draw, preview_ai);
#endif
break;

case MSGN_PREVIEW_INPUTS:
receiveData(&preview_ai, sizeof(AllInputs));
#ifdef LIBTAS_ENABLE_HUD
screen_redraw(draw, hud, preview_ai);
#else
screen_redraw(draw, preview_ai);
#endif
break;

case MSGN_SAVESTATE_PATH:
Expand Down Expand Up @@ -810,18 +758,13 @@ static void receive_messages(std::function<void()> draw)
sendFrameCountTime();

/* Screen should have changed after loading */
#ifdef LIBTAS_ENABLE_HUD
screen_redraw(draw, hud, preview_ai);
#else
screen_redraw(draw, preview_ai);
#endif
}
else if (status == 0) {
/* Tell the program that the saving succeeded */
sendMessage(MSGB_SAVING_SUCCEEDED);

/* Print the successful message, unless we are saving in a fork */
#ifdef LIBTAS_ENABLE_HUD
if (!(Global::shared_config.savestate_settings & SharedConfig::SS_FORK)) {
if (Global::shared_config.osd & SharedConfig::OSD_MESSAGES) {
std::string msg;
Expand All @@ -832,7 +775,6 @@ static void receive_messages(std::function<void()> draw)
screen_redraw(draw, hud, preview_ai);
}
}
#endif

}
else {
Expand Down Expand Up @@ -866,10 +808,8 @@ static void receive_messages(std::function<void()> draw)
break;

case MSGN_OSD_MSG:
#ifdef LIBTAS_ENABLE_HUD
RenderHUD::insertMessage(receiveString().c_str());
screen_redraw(draw, hud, preview_ai);
#endif
break;

case MSGN_END_FRAMEBOUNDARY:
Expand Down
4 changes: 0 additions & 4 deletions src/library/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ extern uint64_t framecount;
* but can be called also by the timer when we need to advance time to avoid a
* game softlock (game expect time to pass).
*/
#ifdef LIBTAS_ENABLE_HUD
void frameBoundary(std::function<void()> draw, RenderHUD& hud);
#else
void frameBoundary(std::function<void()> draw);
#endif

}

Expand Down
Loading

0 comments on commit 3b05bd7

Please sign in to comment.