Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging Boxmon branch into main #108

Merged
merged 22 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5ec9d1b
Boxmon wip: commands, console, parser, working on expressions
indigodarkwolf Jan 11, 2023
2add530
Reduce severity of hypercalls error, improve messaging.
indigodarkwolf Mar 11, 2023
42157ab
Merge branch 'master' of https://github.com/indigodarkwolf/box16 into…
indigodarkwolf May 26, 2023
f5f4649
Expression parser seems to work
indigodarkwolf Jun 8, 2023
67bc39e
Find symbols by name, evaluate symbols in expressions
indigodarkwolf Jun 8, 2023
fff3a13
Split boxmon_expression to separate file, fix build
indigodarkwolf Jun 8, 2023
809142c
Conditional breakpoints
indigodarkwolf Jun 13, 2023
bc194aa
add_label command
indigodarkwolf Jun 14, 2023
d5407bf
Merge branch 'master' of https://github.com/indigodarkwolf/box16 into…
indigodarkwolf Jun 14, 2023
98e1bb0
Fix ZP disasm
indigodarkwolf Jun 15, 2023
14a60b2
Merge branch 'master' of https://github.com/indigodarkwolf/box16 into…
indigodarkwolf Jun 18, 2023
4b4f344
imgui style tweak, add right-click context menu to label list
indigodarkwolf Jun 20, 2023
94d77cc
Merge branch 'master' of https://github.com/indigodarkwolf/box16 into…
indigodarkwolf Jun 28, 2023
e967f72
Adding backtrace command
indigodarkwolf Jun 28, 2023
6daef53
cpuhistory, dump improvements
indigodarkwolf Jun 29, 2023
6150801
goto command
indigodarkwolf Jun 29, 2023
55c0e6d
Merge branch 'master' of https://github.com/indigodarkwolf/box16 into…
indigodarkwolf Dec 30, 2023
17a2bd3
Fix to win32 build
indigodarkwolf Dec 31, 2023
7b54912
io command, next command
indigodarkwolf Jan 1, 2024
dfe0030
new commands: reset, return, stopwatch, warp
indigodarkwolf Jan 1, 2024
9ba94f0
help improvements
indigodarkwolf Jan 8, 2024
aa56caa
Parse fix, improved help
indigodarkwolf Jan 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ YMFM_OBJS := $(patsubst $(YMFM_SRCDIR)/%.cpp,$(YMFM_OBJDIR)/%.o,$(YMFM_SRCS))
BOX16_SRCDIR := $(REPODIR)/src
BOX16_OBJDIR := $(OBJDIR)/box16/obj

BOX16_OBJDIRS := $(BOX16_OBJDIR) $(BOX16_OBJDIR)/compat $(BOX16_OBJDIR)/cpu $(BOX16_OBJDIR)/gif $(BOX16_OBJDIR)/glad $(BOX16_OBJDIR)/imgui $(BOX16_OBJDIR)/overlay $(BOX16_OBJDIR)/vera $(BOX16_OBJDIR)/ym2151
BOX16_OBJDIRS := $(BOX16_OBJDIR) $(BOX16_OBJDIR)/boxmon $(BOX16_OBJDIR)/compat $(BOX16_OBJDIR)/cpu $(BOX16_OBJDIR)/gif $(BOX16_OBJDIR)/glad $(BOX16_OBJDIR)/imgui $(BOX16_OBJDIR)/overlay $(BOX16_OBJDIR)/vera $(BOX16_OBJDIR)/ym2151
BOX16_INCDIRS := -I$(BOX16_SRCDIR) -I$(NFD_SRCDIR)/include -I$(VENDORSRC)/mINI/src/mini -I$(LPNG_SRCDIR) -I$(VENDORSRC)/rtmidi -I$(VENDORSRC)/ymfm/src

BOX16_SRCS := $(wildcard $(BOX16_SRCDIR)/*.cpp) $(BOX16_SRCDIR)/compat/compat.cpp $(wildcard $(BOX16_SRCDIR)/cpu/*.cpp) $(wildcard $(BOX16_SRCDIR)/gif/*.cpp) $(wildcard $(BOX16_SRCDIR)/glad/*.cpp) $(wildcard $(BOX16_SRCDIR)/imgui/*.cpp) $(wildcard $(BOX16_SRCDIR)/overlay/*.cpp) $(wildcard $(BOX16_SRCDIR)/vera/*.cpp) $(wildcard $(BOX16_SRCDIR)/ym2151/*.cpp)
BOX16_SRCS := $(wildcard $(BOX16_SRCDIR)/*.cpp) $(wildcard $(BOX16_SRCDIR)/boxmon/*.cpp) $(BOX16_SRCDIR)/compat/compat.cpp $(wildcard $(BOX16_SRCDIR)/cpu/*.cpp) $(wildcard $(BOX16_SRCDIR)/gif/*.cpp) $(wildcard $(BOX16_SRCDIR)/glad/*.cpp) $(wildcard $(BOX16_SRCDIR)/imgui/*.cpp) $(wildcard $(BOX16_SRCDIR)/overlay/*.cpp) $(wildcard $(BOX16_SRCDIR)/vera/*.cpp) $(wildcard $(BOX16_SRCDIR)/ym2151/*.cpp)
BOX16_OBJS := $(patsubst $(BOX16_SRCDIR)/%.cpp,$(BOX16_OBJDIR)/%.o,$(BOX16_SRCS))
BOX16_CFLAGS := $(shell $(PKGCONFIG) --cflags alsa sdl2 gl zlib) $(CFLAGS) $(CWARNS) $(BOX16_INCDIRS) -include $(BOX16_SRCDIR)/compat/compat.h $(MYFLAGS)
BOX16_LDFLAGS := $(DFLAGS) $(MYFLAGS) $(shell $(PKGCONFIG) --libs alsa sdl2 gl zlib) -lstdc++fs -ldl
Expand Down
9 changes: 9 additions & 0 deletions build/vs2022/box16.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ xcopy $(VendorDir)\zlib-1.2.13\lib\x64\*.dll "$(OutDir)" /E /I /F /Y
<ItemGroup>
<ClCompile Include="..\..\src\audio.cpp" />
<ClCompile Include="..\..\src\bitutils.cpp" />
<ClCompile Include="..\..\src\boxmon\boxmon.cpp" />
<ClCompile Include="..\..\src\boxmon\command.cpp" />
<ClCompile Include="..\..\src\boxmon\expression.cpp" />
<ClCompile Include="..\..\src\boxmon\parser.cpp" />
<ClCompile Include="..\..\src\compat\compat.cpp" />
<ClCompile Include="..\..\src\compat\getopt.cpp" />
<ClCompile Include="..\..\src\cpu\fake6502.cpp" />
Expand Down Expand Up @@ -424,6 +428,10 @@ xcopy $(VendorDir)\zlib-1.2.13\lib\x64\*.dll "$(OutDir)" /E /I /F /Y
<ItemGroup>
<ClInclude Include="..\..\src\audio.h" />
<ClInclude Include="..\..\src\bitutils.h" />
<ClInclude Include="..\..\src\boxmon\boxmon.h" />
<ClInclude Include="..\..\src\boxmon\command.h" />
<ClInclude Include="..\..\src\boxmon\expression.h" />
<ClInclude Include="..\..\src\boxmon\parser.h" />
<ClInclude Include="..\..\src\compat\compat.h" />
<ClInclude Include="..\..\src\compat\getopt.h" />
<ClInclude Include="..\..\src\compat\unistd.h" />
Expand Down Expand Up @@ -498,6 +506,7 @@ xcopy $(VendorDir)\zlib-1.2.13\lib\x64\*.dll "$(OutDir)" /E /I /F /Y
<ClInclude Include="..\..\vendor\ymfm\src\ymfm_opm.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\boxmon\parser.inl" />
<None Include="..\..\src\cpu\6502.opcodes" />
<None Include="..\..\src\cpu\65c02.opcodes" />
<None Include="..\..\src\cpu\buildtables.py" />
Expand Down
30 changes: 30 additions & 0 deletions build/vs2022/box16.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<Filter Include="Header Files">
<UniqueIdentifier>{fe82bbb0-2a22-4543-a74d-8e837e76276e}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\boxmon">
<UniqueIdentifier>{a21c457e-1f07-4a40-aee4-d5458508b4b5}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\glad">
<UniqueIdentifier>{b275878e-1323-473f-a92d-49303b9917bc}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -208,6 +211,15 @@
<ClCompile Include="..\..\src\hypercalls.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\boxmon\command.cpp">
<Filter>Source Files\boxmon</Filter>
</ClCompile>
<ClCompile Include="..\..\src\boxmon\parser.cpp">
<Filter>Source Files\boxmon</Filter>
</ClCompile>
<ClCompile Include="..\..\src\boxmon\boxmon.cpp">
<Filter>Source Files\boxmon</Filter>
</ClCompile>
<ClCompile Include="..\..\src\glad\gl.cpp">
<Filter>Source Files\glad</Filter>
</ClCompile>
Expand All @@ -217,6 +229,9 @@
<ClCompile Include="..\..\src\files.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\boxmon\expression.cpp">
<Filter>Source Files\boxmon</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\compat\compat.h">
Expand Down Expand Up @@ -432,6 +447,15 @@
<ClInclude Include="..\..\src\hypercalls.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\boxmon\command.h">
<Filter>Source Files\boxmon</Filter>
</ClInclude>
<ClInclude Include="..\..\src\boxmon\parser.h">
<Filter>Source Files\boxmon</Filter>
</ClInclude>
<ClInclude Include="..\..\src\boxmon\boxmon.h">
<Filter>Source Files\boxmon</Filter>
</ClInclude>
<ClInclude Include="..\..\src\glad\KHR\khrplatform.h">
<Filter>Source Files\glad\KHR</Filter>
</ClInclude>
Expand All @@ -444,6 +468,9 @@
<ClInclude Include="..\..\src\files.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\boxmon\expression.h">
<Filter>Source Files\boxmon</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\cpu\65c02.opcodes">
Expand All @@ -461,6 +488,9 @@
<None Include="..\..\src\cpu\README">
<Filter>Source Files\cpu</Filter>
</None>
<None Include="..\..\src\boxmon\parser.inl">
<Filter>Source Files\boxmon</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\src\imgui\LICENSE.txt">
Expand Down
Binary file modified resources/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
171 changes: 171 additions & 0 deletions src/boxmon/boxmon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#include "boxmon.h"

#include <cstdarg>
#include <fstream>

#include "command.h"
#include "parser.h"

boxmon::parser Console_parser;

std::vector<boxmon::console_line_type> Console_history;
std::vector<std::string> Command_history;

static bool Console_suppress_output = false;
static bool Console_suppress_warnings = false;
static bool Console_suppress_errors = false;

enum class parse_command_result {
ok,
parse_error,
not_found
};

void boxmon_system_init()
{
}

void boxmon_system_shutdown()
{
}

bool boxmon_load_file(const std::filesystem::path &path)
{
std::ifstream infile(path, std::ios_base::in);

if (!infile.is_open()) {
return false;
}

boxmon::parser file_parser;

int line_number = 0;
std::string line;
while (std::getline(infile, line)) {
++line_number;
char const *input = line.c_str();
file_parser.skip_whitespace(input);
if (*input == '\0') {
continue;
}

std::string command_name;
if (!file_parser.parse_word(command_name, input)) {
std::stringstream ss;
ss << "Parse error on line " << line_number << ": " << line << std::endl;
Console_history.push_back({ boxmon::message_severity::error, ss.str() });
continue;
}

const boxmon::boxmon_command *cmd = boxmon::boxmon_command::find(command_name.c_str());
if (cmd == nullptr) {
std::stringstream ss;
ss << "Unknown command on line " << line_number << ": \"" << command_name << "\"." << std::endl;
Console_history.push_back({ boxmon::message_severity::error, ss.str() });
continue;
}

if (!cmd->run(input, file_parser, false)) {
std::stringstream ss;
ss << "Parse error on line " << line_number << " while running \"" << command_name << "\" with args: " << input << std::endl;
Console_history.push_back({ boxmon::message_severity::error, ss.str() });
}
}
return true;
}

bool boxmon_do_console_command(const std::string &line)
{
char const *input = line.c_str();
Console_parser.skip_whitespace(input);
if (*input == '\0') {
return true;
}

std::string command_name;
if (!Console_parser.parse_word(command_name, input)) {
std::stringstream ss;
ss << "Parse error: " << line << std::endl;
Console_history.push_back({ boxmon::message_severity::error, ss.str() });
return false;
}

const boxmon::boxmon_command *cmd = boxmon::boxmon_command::find(command_name.c_str());
if (cmd == nullptr) {
std::stringstream ss;
ss << "Unknown command \"" << command_name << "\"" << std::endl;
Console_history.push_back({ boxmon::message_severity::error, ss.str() });
return false;
}

if (!cmd->run(input, Console_parser, false)) {
std::stringstream ss;
ss << "Parse error while running \"" << command_name << "\" with args: " << input << std::endl;
Console_history.push_back({ boxmon::message_severity::error, ss.str() });
return false;
}
return true;
}

void boxmon_console_printf(char const *format, ...)
{
if (Console_suppress_output) {
return;
}

va_list arglist;
va_start(arglist, format);

char buffer[1024];
vsnprintf(buffer, sizeof(buffer), format, arglist);
Console_history.push_back({ boxmon::message_severity::output, buffer });

va_end(arglist);
}

void boxmon_warning_printf(char const *format, ...)
{
if (Console_suppress_warnings) {
return;
}

va_list arglist;
va_start(arglist, format);

char buffer[1024];
vsnprintf(buffer, sizeof(buffer), format, arglist);
Console_history.push_back({ boxmon::message_severity::warning, buffer });

va_end(arglist);
}

void boxmon_error_printf(char const *format, ...)
{
if (Console_suppress_errors) {
return;
}

va_list arglist;
va_start(arglist, format);

char buffer[1024];
vsnprintf(buffer, sizeof(buffer), format, arglist);
Console_history.push_back({ boxmon::message_severity::error, buffer });

va_end(arglist);
}

const std::vector<boxmon::console_line_type> &boxmon_get_console_history()
{
return Console_history;
}

const std::vector<std::string> &boxmon_get_command_history()
{
return Command_history;
}

void boxmon_clear_console_history()
{
Console_history.clear();
}
31 changes: 31 additions & 0 deletions src/boxmon/boxmon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <filesystem>
#include <string>
#include <vector>

void boxmon_system_init();
void boxmon_system_shutdown();

bool boxmon_load_file(const std::filesystem::path &path);
bool boxmon_do_console_command(const std::string &command);

void boxmon_console_printf(char const *format, ...);
void boxmon_warning_printf(char const *format, ...);
void boxmon_error_printf(char const *format, ...);

namespace boxmon
{
enum message_severity {
output,
warning,
error
};

using console_line_type = std::tuple<message_severity, const std::string>;
} // namespace boxmon

const std::vector<boxmon::console_line_type> &boxmon_get_console_history();
const std::vector<std::string> &boxmon_get_command_history();

void boxmon_clear_console_history();
Loading