Skip to content

Commit

Permalink
Merge pull request #285 from ogamespec/master
Browse files Browse the repository at this point in the history
Linux build fixes
  • Loading branch information
ogamespec authored Aug 12, 2023
2 parents 7e373ca + f7f7a38 commit 8026d5c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 65 deletions.
24 changes: 17 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 3.0)
project (pureikyubu)

# Choose an X86/X64 build
Expand All @@ -11,6 +11,11 @@ else ()
set(X64 OFF)
endif ()

find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main)
find_package (Threads)
find_package(OpenGL REQUIRED)

add_definitions (-D_LINUX)
add_definitions (-DCMAKE_BUILD_TYPE=Debug)

Expand All @@ -26,7 +31,7 @@ add_executable (pureikyubu
src/bootrtc.cpp
src/config.cpp
src/cp.cpp
src/cuinull.cpp
src/cui_imgui.cpp
src/debug.cpp
src/debugui.cpp
src/di.cpp
Expand Down Expand Up @@ -68,11 +73,16 @@ add_executable (pureikyubu
src/vi.cpp
src/xf.cpp
src/xfbnull.cpp

thirdparty/imgui/imgui.cpp
thirdparty/imgui/imgui_demo.cpp
thirdparty/imgui/imgui_draw.cpp
thirdparty/imgui/backends/imgui_impl_sdl2.cpp
thirdparty/imgui/backends/imgui_impl_sdlrenderer2.cpp
thirdparty/imgui/imgui_tables.cpp
thirdparty/imgui/imgui_widgets.cpp
)

target_link_libraries (pureikyubu LINK_PUBLIC fmt)
find_package (Threads)
find_package(OpenGL REQUIRED)
include_directories( ${CMAKE_THREAD_LIBS_INIT} ${OPENGL_INCLUDE_DIRS} )
include_directories( thirdparty/imgui ${CMAKE_THREAD_LIBS_INIT} ${OPENGL_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS} )

target_link_libraries (pureikyubu ${CMAKE_THREAD_LIBS_INIT} ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})
target_link_libraries (pureikyubu ${CMAKE_THREAD_LIBS_INIT} ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} fmt SDL2 )
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Build using Visual Studio 2022. To build, open `scripts/pureikyubu.sln` and clic

### Generic Linux (Ubuntu) version

The Linux build does not yet have support for graphics, sound and a full Debug UI. All emulation output can be seen only through debug messages.
The Linux build does not yet have support for graphics and sound. All emulation output can be seen only through debug messages.

```
# Choose a suitable folder to store a clone of the repository, cd there and then
Expand Down
4 changes: 2 additions & 2 deletions src/cui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ namespace Debug
va_list arg;

va_start(arg, fmt);
vsprintf_s(buf, sizeof(buf) - 1, fmt, arg);
vsprintf(buf, fmt, arg);
va_end(arg);

std::string text = buf;
Expand All @@ -296,7 +296,7 @@ namespace Debug
va_list arg;

va_start(arg, fmt);
vsprintf_s(buf, sizeof(buf) - 1, fmt, arg);
vsprintf(buf, fmt, arg);
va_end(arg);

std::string text = buf;
Expand Down
4 changes: 2 additions & 2 deletions src/cui_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ namespace Debug
va_list arg;

va_start(arg, fmt);
vsprintf_s(buf, sizeof(buf) - 1, fmt, arg);
vsprintf(buf, fmt, arg);
va_end(arg);

std::string text = buf;
Expand All @@ -443,7 +443,7 @@ namespace Debug
va_list arg;

va_start(arg, fmt);
vsprintf_s(buf, sizeof(buf) - 1, fmt, arg);
vsprintf(buf, fmt, arg);
va_end(arg);

std::string text = buf;
Expand Down
4 changes: 4 additions & 0 deletions src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ namespace Debug
any_debugger_present = true;
}

// TODO: Jdi it

#ifdef _WINDOWS
if (!any_debugger_present) {
UI::Report(
Util::StringToWstring(
std::string("The emulation is crashed. Details can be viewed in the debugger (Ctrl+D)\n\n" + std::string(buf))).c_str());
}
#endif
}

void Report(Channel chan, const char* text, ...)
Expand Down
55 changes: 2 additions & 53 deletions src/uisimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,57 +318,6 @@ void UIReflector()
JdiAddCmd("GetRenderTarget", CmdGetRenderTarget);
}

// A simple example of a debugger that just prints debug messages. Works in its own thread.

Thread* debugger;

void DebugThreadProc(void* param)
{
static size_t mipsIterCounter = 1;
std::list<std::pair<int, std::string>> queue;

UI::SimpleJdi.QueryDebugMessages(queue);

if (!queue.empty())
{
for (auto it = queue.begin(); it != queue.end(); ++it)
{
std::string channelName = UI::SimpleJdi.DebugChannelToString(it->first);

if (channelName.size() != 0)
{
printf("%s: ", channelName.c_str());
}

printf("%s", it->second.c_str());
}

queue.clear();
fflush(stdout);
}

Thread::Sleep(100);

// Output Gekko mips every second

mipsIterCounter++;
if (mipsIterCounter == 10)
{
mipsIterCounter = 1;
printf("Gekko mips: %f\n", (float)UI::SimpleJdi.GetResetGekkoMipsCounter() / 1000000.f);
}
}

void DebugStart()
{
debugger = EMUCreateThread(DebugThreadProc, false, nullptr, "DebugThread");
}

void DebugStop()
{
EMUJoinThread(debugger);
}

int main(int argc, char** argv)
{
// Check parameters
Expand All @@ -393,7 +342,7 @@ int main(int argc, char** argv)

UI::SimpleJdi.LoadFile(argv[1]);
UI::SimpleJdi.Run();
DebugStart();
Debug::debugger = new Debug::Debugger();

// Wait key press..

Expand All @@ -409,7 +358,7 @@ int main(int argc, char** argv)

UI::SimpleJdi.Unload();
JdiRemoveNode(UI_JDI_JSON);
DebugStop();
delete Debug::debugger;

printf("\nThank you for flying pureikyubu airlines!\n");
return 0;
Expand Down

0 comments on commit 8026d5c

Please sign in to comment.