Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ VU_OBJECTS_VSM := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(VU_SOURCES_VSM:.$(VSME
VCL_SOURCES := $(shell find $(SRCDIR) -type f -name *.$(VCLPPEXT))
VCL_OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(VCL_SOURCES:.$(VCLPPEXT)=.$(OBJEXT)))


ifeq ($(EESIO_USE_SIOCOOKIE), 1)
LIB += -lsiocookie
CFLAGS += -DEESIO_UART_USE_SIOCOOKIE
endif

#Default Make
all: resources $(TARGET)
#all: resources irxcopy $(TARGET)
Expand Down Expand Up @@ -114,4 +120,4 @@ run-pcsx2:
$(WSL_LINUX_PCSX2)/pcsx2x64.exe --elf=$(WSL_MAKE_WINDOWS)$(CURDIR)/$(TARGETDIR)/$(TARGET)

#Non-File Targets
.PHONY: all remake clean cleaner resources
.PHONY: all remake clean cleaner resources
3 changes: 2 additions & 1 deletion demo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
int main() {
Tyra::EngineOptions options;

options.loggingMode = LOGGING_EESIO;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to fix this duplicate

if (Demo::IS_REAL_PS2_VIA_USB) {
options.writeLogsToFile = true;
options.loggingMode = LOGGING_FILE;
options.loadUsbDriver = true;
}

Expand Down
24 changes: 20 additions & 4 deletions engine/inc/debug/debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
#include "file/file_utils.hpp"
#include "info/info.hpp"

#ifdef EESIO_UART_USE_SIOCOOKIE
#include <SIOCookie.h>
#else
#include <sio.h>
#endif

#define TYRA_LOG(...) TyraDebug::writeLines("LOG: ", ##__VA_ARGS__, "\n")
#define TYRA_WARN(...) TyraDebug::writeLines("==WARN: ", ##__VA_ARGS__, "\n")
#define TYRA_ERROR(...) TyraDebug::writeLines("====ERR: ", ##__VA_ARGS__, "\n")
Expand All @@ -48,8 +54,11 @@ class TyraDebug {
using expander = int[];
(void)expander{0, (void(ss << std::forward<Args>(args)), 0)...};

if (Tyra::Info::writeLogsToFile) {
if (Tyra::Info::loggingMode == LOGGING_FILE) {
writeInLogFile(&ss);
} else if (Tyra::Info::loggingMode == LOGGING_EESIO) {
initializeEESIO();
sio_putsn(ss.str().c_str());
} else {
printf("%s", ss.str().c_str());
}
Expand All @@ -63,7 +72,7 @@ class TyraDebug {
ss1 << "| Assertion failed!\n";
ss1 << "|\n";

if (Tyra::Info::writeLogsToFile) {
if (Tyra::Info::loggingMode == LOGGING_FILE) {
writeInLogFile(&ss1);
} else {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why LOGGING_EESIO is not here?

printf("%s", ss1.str().c_str());
Expand All @@ -76,8 +85,11 @@ class TyraDebug {
ss2 << "| File : " << file << ":" << line << "\n";
ss2 << "====================================\n\n";

if (Tyra::Info::writeLogsToFile) {
if (Tyra::Info::loggingMode == LOGGING_FILE) {
writeInLogFile(&ss2);
} else if (Tyra::Info::loggingMode == LOGGING_EESIO) {
initializeEESIO();
sio_putsn(ss2.str().c_str());
} else {
printf("%s", ss2.str().c_str());
}
Expand All @@ -93,6 +105,7 @@ class TyraDebug {

private:
static void writeInLogFile(std::stringstream* ss);
static void initializeEESIO();

template <typename Arg, typename... Args>
static void writeAssertLines(Arg&& arg, Args&&... args) {
Expand All @@ -103,8 +116,11 @@ class TyraDebug {
(void)expander{
0, (void(ss << "| " << std::forward<Args>(args) << "\n"), 0)...};

if (Tyra::Info::writeLogsToFile) {
if (Tyra::Info::loggingMode == LOGGING_FILE) {
writeInLogFile(&ss);
} else if (Tyra::Info::loggingMode == LOGGING_EESIO) {
initializeEESIO();
sio_putsn(ss.str().c_str());
} else {
printf("%s", ss.str().c_str());
}
Expand Down
2 changes: 1 addition & 1 deletion engine/inc/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct EngineOptions {
* True -> logs will be written to file.
* False -> logs will be displayed in console
*/
bool writeLogsToFile = false;
int loggingMode = LOGGING_STDOUT;

bool loadUsbDriver = false;
};
Expand Down
6 changes: 5 additions & 1 deletion engine/inc/info/info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "time/timer.hpp"
#include "./version.hpp"

#define LOGGING_STDOUT (0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace this C-Style code to C++ enums (like here).

_EESIO can be misleading for Tyra beginners, what do you think about LOGGING_UART?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace this C-Style code to C++ enums (like here).

_EESIO can be misleading for Tyra beginners, what do you think about LOGGING_UART?

Maybe. If we explicitly say this is for EE.
Because DECKARD slims also have an additional UART for their emulated IOP

Rn I don't have my PC at hand. Will fix later

#define LOGGING_FILE (1)
#define LOGGING_EESIO (3)

namespace Tyra {

class Info {
Expand All @@ -24,7 +28,7 @@ class Info {

Version version;

static bool writeLogsToFile;
static int loggingMode;

/** Called by engine */
void update();
Expand Down
14 changes: 14 additions & 0 deletions engine/src/debug/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "debug/debug.hpp"

bool EESIO_Initialized = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about making this variable as private static? It will be inside TyraDebug then

void TyraDebug::writeInLogFile(std::stringstream* ss) {
std::ofstream logFile;
logFile.open(Tyra::FileUtils::fromCwd("log.txt"),
Expand All @@ -18,3 +19,16 @@ void TyraDebug::writeInLogFile(std::stringstream* ss) {
logFile.flush();
// logFile.close();
}

void TyraDebug::initializeEESIO() {
if (EESIO_Initialized)
return;
#ifndef EESIO_UART_USE_SIOCOOKIE
sio_init(38400, 0, 0, 0, 0);
sio_putsn("TYRA: EE_SIO Enabled\n");
#else
ee_sio_start(38400, 0, 0, 0, 0, 1); // alternative wrapper. initializes UART, but also re-routes STDOUT and STDERR FILE* streams to EE_SIO
printf("TYRA: EE_SIO Enabled & STDOUT/STDERR hooked\n")
Comment on lines +26 to +31
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this a bit more?
Correct me if I'm wrong:

  • If somebody will use LOGGING_EESIO, all stdout logs (printf) will by default go to UART? (#else) But we use sio_putsn() anyway?
  • What will happen if somebody will declare EESIO_UART_USE_SIOCOOKIE? (which is not defined by default?)

BTW I see that you have EESIO_UART_USE_SIOCOOKIE and EESIO_USE_SIOCOOKIE (different name) is it a bug?

#endif
EESIO_Initialized = true;
}
4 changes: 2 additions & 2 deletions engine/src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Tyra {
Engine::Engine() { initAll(false); }

Engine::Engine(const EngineOptions& options) {
info.writeLogsToFile = options.writeLogsToFile;
info.loggingMode = options.loggingMode;
initAll(options.loadUsbDriver);
}

Expand All @@ -37,7 +37,7 @@ void Engine::realLoop() {

void Engine::initAll(const bool& loadUsbDriver) {
srand(time(nullptr));
irx.loadAll(loadUsbDriver, info.writeLogsToFile);
irx.loadAll(loadUsbDriver, info.loggingMode);
renderer.init();
banner.show(&renderer);
audio.init();
Expand Down
2 changes: 1 addition & 1 deletion engine/src/info/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Tyra {

bool Info::writeLogsToFile = false;
int Info::loggingMode = LOGGING_STDOUT;

Info::Info() {
fps = 0;
Expand Down