diff --git a/Makefile.base b/Makefile.base index e31c0b7..653ac9a 100644 --- a/Makefile.base +++ b/Makefile.base @@ -16,7 +16,7 @@ IRXEMBEDDEDEXT := irx-em CFLAGS += -D_EE -Wall -O3 LINKFLAGS += -O3 -Wl,-zmax-page-size=128 ASFLAGS += -O3 -LIB += -lstdc++ -ldma -lpacket2 -lgraph -ldraw -lmath3d -lpng -lz -lpad -laudsrv -lpatches -lcdvd +LIB += -lstdc++ -ldma -lpacket2 -lgraph -ldraw -lmath3d -lpng -ldebug -lz -lpad -laudsrv -lpatches -lcdvd INC += -I$(PS2DEV)/ps2sdk/ee/include -I$(PS2DEV)/ps2sdk/common/include -I$(PS2DEV)/ps2sdk/ports/include #--------------------------------------------------------------------------------- diff --git a/README.MD b/README.MD index 5a0f73d..bff8391 100644 --- a/README.MD +++ b/README.MD @@ -121,6 +121,7 @@ List of games developed with Tyra. If you created one, please contact me - I will add it to the list :) * [Tyracraft](https://github.com/Wellinator/tyracraft) by [Wellinator](https://github.com/Wellinator) +* [Game with car](https://github.com/freebytego/gwc-ps2) by [freebytego](https://github.com/freebytego) * [Rock, paper, scissors](https://github.com/GuidoDQR/my-ps2-game) by [GuidoDQR](https://github.com/GuidoDQR) * [TyraTale](https://github.com/Br4k2n/TyraTale) by [Br4k2n](https://github.com/Br4k2n) diff --git a/engine/inc/debug/debug.hpp b/engine/inc/debug/debug.hpp index d919b0e..a8d3e97 100644 --- a/engine/inc/debug/debug.hpp +++ b/engine/inc/debug/debug.hpp @@ -20,6 +20,7 @@ #else // IF Debug #include +#include #include #include #include @@ -48,9 +49,7 @@ class TyraDebug { (void)expander{0, (void(ss << std::forward(args)), 0)...}; if (Tyra::Info::writeLogsToFile) { - auto* logFile = getLogFile(); - *logFile << ss.str(); - logFile->flush(); + writeInLogFile(&ss); } else { printf("%s", ss.str().c_str()); } @@ -65,9 +64,7 @@ class TyraDebug { ss1 << "|\n"; if (Tyra::Info::writeLogsToFile) { - auto* logFile = getLogFile(); - *logFile << ss1.str(); - logFile->flush(); + writeInLogFile(&ss1); } else { printf("%s", ss1.str().c_str()); } @@ -80,20 +77,22 @@ class TyraDebug { ss2 << "====================================\n\n"; if (Tyra::Info::writeLogsToFile) { - auto* logFile = getLogFile(); - *logFile << ss2.str(); - logFile->flush(); + writeInLogFile(&ss2); } else { printf("%s", ss2.str().c_str()); } + init_scr(); for (;;) { + scr_setXY(20, 10); + scr_printf(ss1.str().c_str()); + writeAssertLinesInScreen(args...); + scr_printf(ss2.str().c_str()); } } private: - static std::unique_ptr logFile; - static std::ofstream* getLogFile(); + static void writeInLogFile(std::stringstream* ss); template static void writeAssertLines(Arg&& arg, Args&&... args) { @@ -105,13 +104,23 @@ class TyraDebug { 0, (void(ss << "| " << std::forward(args) << "\n"), 0)...}; if (Tyra::Info::writeLogsToFile) { - auto* logfile = getLogFile(); - *logfile << ss.str(); - logFile->flush(); + writeInLogFile(&ss); } else { printf("%s", ss.str().c_str()); } } + + template + static void writeAssertLinesInScreen(Arg&& arg, Args&&... args) { + std::stringstream ss; + + ss << "| " << std::forward(arg) << "\n"; + using expander = int[]; + (void)expander{ + 0, (void(ss << "| " << std::forward(args) << "\n"), 0)...}; + + scr_printf(ss.str().c_str()); + } }; #endif // NDEBUG \ No newline at end of file diff --git a/engine/inc/irx/irx_loader.hpp b/engine/inc/irx/irx_loader.hpp index a9aa19f..168797e 100644 --- a/engine/inc/irx/irx_loader.hpp +++ b/engine/inc/irx/irx_loader.hpp @@ -27,6 +27,7 @@ class IrxLoader { void loadSio2man(const bool& verbose); void loadPadman(const bool& verbose); void loadLibsd(const bool& verbose); + void loadIO(const bool& verbose); void loadUsbModules(const bool& verbose); void loadAudsrv(const bool& verbose); diff --git a/engine/src/debug/debug.cpp b/engine/src/debug/debug.cpp index 292a10a..aff2466 100644 --- a/engine/src/debug/debug.cpp +++ b/engine/src/debug/debug.cpp @@ -10,16 +10,11 @@ #include "debug/debug.hpp" -std::unique_ptr TyraDebug::logFile; - -std::ofstream* TyraDebug::getLogFile() { - if (logFile) { - return logFile.get(); - } else { - logFile = std::make_unique(); - logFile->open(Tyra::FileUtils::fromCwd("log.txt"), - std::ofstream::out | std::ofstream::app); - return logFile.get(); - } - -} // namespace Tyra +void TyraDebug::writeInLogFile(std::stringstream* ss) { + std::ofstream logFile; + logFile.open(Tyra::FileUtils::fromCwd("log.txt"), + std::ofstream::out | std::ofstream::app); + logFile << ss->str(); + logFile.flush(); + // logFile.close(); +} diff --git a/engine/src/irx/fileXio.irx-em b/engine/src/irx/fileXio.irx-em new file mode 100644 index 0000000..fbdfe29 --- /dev/null +++ b/engine/src/irx/fileXio.irx-em @@ -0,0 +1,2 @@ +$PS2SDK/iop/irx/fileXio.irx +fileXio_irx diff --git a/engine/src/irx/iomanX.irx-em b/engine/src/irx/iomanX.irx-em new file mode 100644 index 0000000..d83e4fc --- /dev/null +++ b/engine/src/irx/iomanX.irx-em @@ -0,0 +1,2 @@ +$PS2SDK/iop/irx/iomanX.irx +iomanX_irx diff --git a/engine/src/irx/irx_loader.cpp b/engine/src/irx/irx_loader.cpp index c36f9b8..ec7f77d 100644 --- a/engine/src/irx/irx_loader.cpp +++ b/engine/src/irx/irx_loader.cpp @@ -20,30 +20,20 @@ #include "file/file_utils.hpp" // external IRX modules +#define EXTERN_IRX(_irx) \ + extern u8 _irx[]; \ + extern int size_##_irx -extern u8 sio2man_irx[]; -extern int size_sio2man_irx; - -extern u8 padman_irx[]; -extern int size_padman_irx; - -extern u8 audsrv_irx[]; -extern int size_audsrv_irx; - -extern u8 libsd_irx[]; -extern int size_libsd_irx; - -extern u8 bdm_irx[]; -extern int size_bdm_irx; - -extern u8 bdmfs_fatfs_irx[]; -extern int size_bdmfs_fatfs_irx; - -extern u8 usbd_irx[]; -extern int size_usbd_irx; - -extern u8 usbmass_bd_irx[]; -extern int size_usbmass_bd_irx; +EXTERN_IRX(sio2man_irx); +EXTERN_IRX(padman_irx); +EXTERN_IRX(audsrv_irx); +EXTERN_IRX(libsd_irx); +EXTERN_IRX(fileXio_irx); +EXTERN_IRX(iomanX_irx); +EXTERN_IRX(bdm_irx); +EXTERN_IRX(bdmfs_fatfs_irx); +EXTERN_IRX(usbd_irx); +EXTERN_IRX(usbmass_bd_irx); namespace Tyra { @@ -70,6 +60,7 @@ void IrxLoader::loadAll(const bool& withUsb, const bool& isLoggingToFile) { return; } + loadIO(!isLoggingToFile); loadSio2man(!isLoggingToFile); loadPadman(!isLoggingToFile); loadLibsd(!isLoggingToFile); @@ -116,6 +107,24 @@ void IrxLoader::loadLibsd(const bool& verbose) { if (verbose) TYRA_LOG("IRX: Libsd loaded!"); } +void IrxLoader::loadIO(const bool& verbose) { + int ret; + if (verbose) TYRA_LOG("IRX: Loading iomanX..."); + + SifExecModuleBuffer(&iomanX_irx, size_iomanX_irx, 0, nullptr, &ret); + TYRA_ASSERT(ret >= 0, "Failed to load module: iomanX_irx"); + + if (verbose) TYRA_LOG("IRX: iomanX loaded!"); + + if (verbose) TYRA_LOG("IRX: Loading fileXio..."); + + SifExecModuleBuffer(&fileXio_irx, size_fileXio_irx, 0, nullptr, &ret); + TYRA_ASSERT(ret >= 0, "Failed to load module: fileXio_irx"); + + if (verbose) TYRA_LOG("IRX: fileXio_irx loaded!"); + +} + void IrxLoader::loadUsbModules(const bool& verbose) { if (verbose) TYRA_LOG("IRX: Loading usb modules...");