Skip to content

Commit b071534

Browse files
committed
Repo cc
1 parent 7b529a0 commit b071534

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+26486
-0
lines changed

.clang-format

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
BasedOnStyle: Microsoft
3+
SortIncludes: Never
4+
SortUsingDeclarations: false
5+
ColumnLimit: 0

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
frontend/configure.h
3+
.vs/

CMakeLists.txt

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
cmake_minimum_required(VERSION 3.6)
2+
3+
include(FetchContent)
4+
include(CheckCCompilerFlag)
5+
include("tools/glsl-shaders.cmake")
6+
7+
enable_language(CXX)
8+
set(CMAKE_CXX_STANDARD 20)
9+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
10+
11+
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
12+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
13+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
14+
15+
project(vkhandybug VERSION "0.1.0")
16+
17+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/frontend/configure.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/frontend/configure.h")
18+
19+
find_package(Vulkan REQUIRED)
20+
find_package(Threads REQUIRED)
21+
22+
include("tools/cmake.dependencies")
23+
24+
FetchContent_MakeAvailable(glfw)
25+
FetchContent_MakeAvailable(vkmemalloc)
26+
FetchContent_MakeAvailable(vkbootstrap)
27+
FetchContent_MakeAvailable(zlib)
28+
FetchContent_MakeAvailable(fmt)
29+
FetchContent_Populate(miniaudio)
30+
FetchContent_Populate(cereal)
31+
FetchContent_Populate(imgui)
32+
FetchContent_Populate(imgui_filedialog)
33+
FetchContent_Populate(hashlib)
34+
35+
file(GLOB_RECURSE vkhandybug_SOURCES CONFIGURE_DEPENDS
36+
"frontend/*.c"
37+
"frontend/*.cpp"
38+
"frontend/renderer/*.cpp"
39+
"frontend/renderer/*.c"
40+
"frontend/resources/shaders/*.spv"
41+
"lynx_core/*.cpp"
42+
${imgui_SOURCE_DIR}/imgui.cpp
43+
${imgui_SOURCE_DIR}/imgui_tables.cpp
44+
${imgui_SOURCE_DIR}/imgui_widgets.cpp
45+
${imgui_SOURCE_DIR}/imgui_draw.cpp
46+
${imgui_SOURCE_DIR}/backends/imgui_impl_vulkan.cpp
47+
${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp
48+
${imgui_filedialog_SOURCE_DIR}/ImGuiFileDialog.cpp
49+
${hashlib_SOURCE_DIR}/md5.cpp
50+
)
51+
52+
add_executable(${PROJECT_NAME} ${vkhandybug_SOURCES})
53+
54+
check_c_compiler_flag(-Wcpp HAVE_WARNING)
55+
check_c_compiler_flag(-Wreturn-type HAVE_RETURN_TYPE)
56+
57+
if (HAVE_WARNING)
58+
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-cpp)
59+
endif (HAVE_WARNING)
60+
61+
if (HAVE_RETURN_TYPE)
62+
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-return-type)
63+
endif (HAVE_RETURN_TYPE)
64+
65+
target_glsl_shaders( ${PROJECT_NAME} PRIVATE
66+
"${CMAKE_CURRENT_SOURCE_DIR}/frontend/resources/shaders/lynx_render.comp"
67+
)
68+
target_include_directories(${PROJECT_NAME} PRIVATE
69+
${Vulkan_INCLUDE_DIRS}
70+
${vkbootstrap_SOURCE_DIR}/src
71+
${imgui_SOURCE_DIR}
72+
${imgui_SOURCE_DIR}/backends
73+
${vkmemalloc_SOURCE_DIR}/include
74+
${zlib_SOURCE_DIR}
75+
${zlib_BINARY_DIR}
76+
${fmt_SOURCE_DIR}/include
77+
${imgui_filedialog_SOURCE_DIR}
78+
${miniaudio_SOURCE_DIR}
79+
${cereal_SOURCE_DIR}/include
80+
${hashlib_SOURCE_DIR}
81+
"lynx_core/"
82+
"frontend/include/"
83+
)
84+
85+
target_link_libraries(${PROJECT_NAME} PRIVATE
86+
Vulkan::Vulkan
87+
Threads::Threads
88+
vk-bootstrap::vk-bootstrap
89+
VulkanMemoryAllocator
90+
glfw
91+
zlib
92+
fmt
93+
)
94+
95+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/frontend/resources/shaders/lynx_render.comp.spv" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/shaders/lynx_render.comp.spv" COPYONLY)
96+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/frontend/resources/fonts/Crisp.ttf" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/fonts/Crisp.ttf" COPYONLY)

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# VkHandybug
2+
3+
Debugger for the Atari Lynx emulator [Handy](https://handy.sourceforge.net/).
4+
5+
Based on ImGui, GLFW/Vulkan, reasonably cross platform (Linux - GCC 12.1, Windows - Visual Studio 2022).
6+
7+
To load symbols create file with the same name as the cart but with the .lbl extension.
8+
The *lbl* file can be a Vice label file (generated by [cl65](https://cc65.github.io/doc/cl65.html) -Ln option) or simply be a list of "addr label":
9+
10+
```
11+
0034 here
12+
4ADE andhere
13+
```
14+
15+
![](/assets/screen1.jpg)

assets/screen1.jpg

283 KB
Loading

frontend/comlynx_hub.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#include "comlynx_hub.h"
2+
#include "session.h"
3+
#include "system.h"
4+
#include "comlynx_visualizer.h"
5+
6+
ComLynxHub::ComLynxHub()
7+
{
8+
}
9+
10+
ComLynxHub::~ComLynxHub()
11+
{
12+
}
13+
14+
void ComLynxHub::register_session(std::shared_ptr<Session> session)
15+
{
16+
auto objref = std::make_shared<ComLynxCallBackArg>();
17+
objref->hub = this;
18+
objref->session_identifier = session->identifier();
19+
_callback_objrefs.push_back(objref);
20+
21+
session->system()->ComLynxTxCallback([](int data, void *objref) {
22+
ComLynxCallBackArg *arg = (ComLynxCallBackArg *)objref;
23+
arg->hub->enqueue(data, arg->session_identifier);
24+
},
25+
objref.get());
26+
27+
session->system()->ComLynxCable(1);
28+
29+
_sessions.push_back(session);
30+
}
31+
32+
void ComLynxHub::register_comlynx_visualizer(std::shared_ptr<ComLynxVisualizer> visualizer)
33+
{
34+
_comlynx_visualizer = visualizer;
35+
}
36+
37+
void ComLynxHub::unregister_session(std::shared_ptr<Session> session)
38+
{
39+
auto found = std::find_if(_sessions.begin(), _sessions.end(), [&](const std::shared_ptr<Session> s) { return s->identifier() == session->identifier(); });
40+
41+
if (found == _sessions.end())
42+
{
43+
return;
44+
}
45+
46+
(*found)->system()->ComLynxCable(0);
47+
(*found)->system()->ComLynxTxCallback(nullptr, nullptr);
48+
49+
std::erase_if(_sessions, [&](const std::shared_ptr<Session> s) { return s->identifier() == session->identifier(); });
50+
std::erase_if(_callback_objrefs, [&](const std::shared_ptr<ComLynxCallBackArg> s) { return s->session_identifier == session->identifier(); });
51+
}
52+
53+
void ComLynxHub::process_queue()
54+
{
55+
if (_queue.empty())
56+
{
57+
return;
58+
}
59+
60+
std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now();
61+
62+
for (auto &f : _queue)
63+
{
64+
_comlynx_visualizer->add_frame(f.sender_id, now, (uint8_t)f.data);
65+
}
66+
67+
if (_queue.size() == 1)
68+
{
69+
auto &item = _queue.back();
70+
71+
for (auto session : _sessions)
72+
{
73+
if (session->identifier() == item.sender_id)
74+
{
75+
continue;
76+
}
77+
session->system()->ComLynxRxData(item.data);
78+
}
79+
}
80+
81+
_queue.clear();
82+
}
83+
84+
void ComLynxHub::enqueue(int data, std::string sender_id)
85+
{
86+
_queue.push_back({sender_id, data});
87+
}

0 commit comments

Comments
 (0)