Add System Out as a logging source. (#2563)

* Enable logging from new source, PS2 system output

* Enable printf formatting with (up to only 7 currently)

* Fix fallthrough bug in SYSCALL switch/case

* Remove unnecessary memread32 call in sysPrintOut case
This commit is contained in:
Souzooka 2018-08-27 01:56:48 -10:00 committed by Robert Neumann
parent 4eaee45d1a
commit 7963f418c1
5 changed files with 43 additions and 11 deletions

View File

@ -318,6 +318,7 @@ struct SysConsoleLogPack
{
ConsoleLogSource ELF;
ConsoleLogSource eeRecPerf;
ConsoleLogSource sysoutConsole;
ConsoleLogFromVM<Color_Cyan> eeConsole;
ConsoleLogFromVM<Color_Yellow> iopConsole;
@ -387,8 +388,9 @@ extern void __Log( const char* fmt, ... );
#define MDEC_LOG macTrace(IOP.MDEC)
#define ELF_LOG SysConsole.ELF.IsActive() && SysConsole.ELF.Write
#define eeRecPerfLog SysConsole.eeRecPerf.IsActive() && SysConsole.eeRecPerf
#define eeConLog SysConsole.eeConsole.IsActive() && SysConsole.eeConsole.Write
#define eeDeci2Log SysConsole.deci2.IsActive() && SysConsole.deci2.Write
#define iopConLog SysConsole.iopConsole.IsActive()&& SysConsole.iopConsole.Write
#define ELF_LOG SysConsole.ELF.IsActive() && SysConsole.ELF.Write
#define eeRecPerfLog SysConsole.eeRecPerf.IsActive() && SysConsole.eeRecPerf
#define eeConLog SysConsole.eeConsole.IsActive() && SysConsole.eeConsole.Write
#define eeDeci2Log SysConsole.deci2.IsActive() && SysConsole.deci2.Write
#define iopConLog SysConsole.iopConsole.IsActive() && SysConsole.iopConsole.Write
#define sysConLog SysConsole.sysoutConsole.IsActive() && SysConsole.sysoutConsole.Write

View File

@ -982,8 +982,29 @@ void SYSCALL()
}
else
__Deci2Call(cpuRegs.GPR.n.a0.UL[0], (u32*)PSM(cpuRegs.GPR.n.a1.UL[0]));
break;
}
break;
case Syscall::sysPrintOut:
{
if (cpuRegs.GPR.n.a0.UL[0] != 0)
{
// TODO: Only supports 7 format arguments. Need to read from the stack for more.
// Is there a function which collects PS2 arguments?
sysConLog(
ShiftJIS_ConvertString((char*)PSM(cpuRegs.GPR.n.a0.UL[0])),
cpuRegs.GPR.n.a1.UL[0],
cpuRegs.GPR.n.a2.UL[0],
cpuRegs.GPR.n.a3.UL[0],
cpuRegs.GPR.n.t0.UL[0],
cpuRegs.GPR.n.t1.UL[0],
cpuRegs.GPR.n.t2.UL[0],
cpuRegs.GPR.n.t3.UL[0]
);
}
break;
}
default:
break;

View File

@ -21,6 +21,7 @@ enum Syscall : u8
{
SetGsCrt = 2,
SetVTLBRefillHandler = 13,
sysPrintOut = 117,
sceSifSetDma = 119,
Deci2Call = 124
};

View File

@ -114,14 +114,20 @@ TLD_iopConsole = {
TLD_deci2 = {
L"DECI2", L"DECI&2 Console",
pxDt("Shows DECI2 debugging logs (EE processor)")
},
TLD_sysoutConsole = {
L"SYSout", L"System Out",
pxDt("Shows strings printed to the system output stream.")
};
SysConsoleLogPack::SysConsoleLogPack()
: ELF (&TLD_ELF, Color_Gray)
, eeRecPerf (&TLD_eeRecPerf, Color_Gray)
, eeConsole (&TLD_eeConsole)
, iopConsole(&TLD_iopConsole)
, deci2 (&TLD_deci2)
: ELF (&TLD_ELF, Color_Gray)
, eeRecPerf (&TLD_eeRecPerf, Color_Gray)
, sysoutConsole(&TLD_sysoutConsole, Color_Gray)
, eeConsole (&TLD_eeConsole)
, iopConsole (&TLD_iopConsole)
, deci2 (&TLD_deci2)
{
}

View File

@ -294,6 +294,7 @@ static ConsoleLogSource* const ConLogSources[] =
NULL,
(ConsoleLogSource*)&pxConLog_Event,
(ConsoleLogSource*)&pxConLog_Thread,
(ConsoleLogSource*)&SysConsole.sysoutConsole
};
// WARNING ConsoleLogSources & ConLogDefaults must have the same size
@ -306,6 +307,7 @@ static const bool ConLogDefaults[] =
false,
false,
false,
false,
false
};