Merge branch 'h4570:master' into Cleanup

This commit is contained in:
André Guilherme
2023-11-12 09:57:00 -03:00
committed by GitHub
8 changed files with 70 additions and 51 deletions
+1 -1
View File
@@ -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
#---------------------------------------------------------------------------------
+1
View File
@@ -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)
+23 -14
View File
@@ -20,6 +20,7 @@
#else // IF Debug
#include <stdio.h>
#include <debug.h>
#include <string>
#include <sstream>
#include <fstream>
@@ -48,9 +49,7 @@ class TyraDebug {
(void)expander{0, (void(ss << std::forward<Args>(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<std::ofstream> logFile;
static std::ofstream* getLogFile();
static void writeInLogFile(std::stringstream* ss);
template <typename Arg, typename... Args>
static void writeAssertLines(Arg&& arg, Args&&... args) {
@@ -105,13 +104,23 @@ class TyraDebug {
0, (void(ss << "| " << std::forward<Args>(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 <typename Arg, typename... Args>
static void writeAssertLinesInScreen(Arg&& arg, Args&&... args) {
std::stringstream ss;
ss << "| " << std::forward<Arg>(arg) << "\n";
using expander = int[];
(void)expander{
0, (void(ss << "| " << std::forward<Args>(args) << "\n"), 0)...};
scr_printf(ss.str().c_str());
}
};
#endif // NDEBUG
+1
View File
@@ -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);
+8 -13
View File
@@ -10,16 +10,11 @@
#include "debug/debug.hpp"
std::unique_ptr<std::ofstream> TyraDebug::logFile;
std::ofstream* TyraDebug::getLogFile() {
if (logFile) {
return logFile.get();
} else {
logFile = std::make_unique<std::ofstream>();
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();
}
+2
View File
@@ -0,0 +1,2 @@
$PS2SDK/iop/irx/fileXio.irx
fileXio_irx
+2
View File
@@ -0,0 +1,2 @@
$PS2SDK/iop/irx/iomanX.irx
iomanX_irx
+32 -23
View File
@@ -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...");