IOP: PSX bios console output

This commit is contained in:
Pseudonym 2016-11-05 12:08:20 +00:00
parent f1c4b7d5df
commit 8259b29896
8 changed files with 110 additions and 2 deletions

View File

@ -411,7 +411,8 @@ set(pcsx2ps2Sources
ps2/pgif.cpp
ps2/LegacyDmac.cpp
ps2/Iop/IopHwRead.cpp
ps2/Iop/IopHwWrite.cpp)
ps2/Iop/IopHwWrite.cpp
ps2/Iop/PsxBios.cpp)
# ps2 headers
set(pcsx2ps2Headers

View File

@ -65,6 +65,7 @@ void psxReset()
psxHwReset();
ioman::reset();
psxBiosReset();
}
void psxShutdown() {

View File

@ -211,4 +211,7 @@ extern void (*psxCP0[32])();
extern void (*psxCP2[64])();
extern void (*psxCP2BSC[32])();
extern void psxBiosReset();
extern bool __fastcall psxBiosCall();
#endif /* __R3000A_H__ */

View File

@ -147,7 +147,6 @@ static __fi void execI()
psxBSC[psxRegs.code >> 26]();
}
static void doBranch(s32 tar) {
branch2 = iopIsDelaySlot = true;
branchPC = tar;
@ -179,6 +178,9 @@ static s32 intExecuteBlock( s32 eeCycles )
iopCycleEE = eeCycles;
while (iopCycleEE > 0){
if ((psxHu32(HW_ICFG) & 8) && ((psxRegs.pc & 0x1fffffffU) == 0xa0 || (psxRegs.pc & 0x1fffffffU) == 0xb0 || (psxRegs.pc & 0x1fffffffU) == 0xc0))
psxBiosCall();
branch2 = 0;
while (!branch2) {
execI();

91
pcsx2/ps2/Iop/PsxBios.cpp Normal file
View File

@ -0,0 +1,91 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2016 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "IopCommon.h"
static std::string psxout_buf;
static void flush_stdout(bool closing = false)
{
size_t linelen;
while (!psxout_buf.empty()) {
linelen = psxout_buf.find_first_of("\n\0", 0, 2);
if (linelen == std::string::npos) {
if (!closing)
return;
} else
psxout_buf[linelen++] = '\n';
iopConLog(ShiftJIS_ConvertString(psxout_buf.c_str(), linelen));
psxout_buf.erase(0, linelen);
}
}
void psxBiosReset()
{
flush_stdout(true);
}
// Called for Playstation BIOS calls at 0xA0, 0xB0 and 0xC0 in kernel reserved memory (seemingly by actually calling those addresses)
// Returns true if we internally process the call, not that we're likely to do any such thing
bool __fastcall psxBiosCall()
{
// TODO: Tracing
// TODO (maybe, psx is hardly a priority): HLE framework
switch ((psxRegs.pc & 0x1FFFFFFFU) << 4 & 0xf00 | psxRegs.GPR.n.t1 & 0xff) {
case 0xa03:
case 0xb35:
// write(fd, data, size)
{
int fd = psxRegs.GPR.n.a0;
if (fd != 1)
return false;
u32 data = psxRegs.GPR.n.a1;
u32 size = psxRegs.GPR.n.a2;
while (size--)
psxout_buf.push_back(iopMemRead8(data++));
flush_stdout(false);
return false;
}
case 0xa09:
case 0xb3b:
// putc(c, fd)
if (psxRegs.GPR.n.a1 != 1)
return false;
// fd=1, fall through to putchar
case 0xa3c:
case 0xb3d:
// putchar(c)
psxout_buf.push_back((char)psxRegs.GPR.n.a0);
flush_stdout(false);
return false;
case 0xa3e:
case 0xb3f:
// puts(s)
{
u32 str = psxRegs.GPR.n.a0;
while (char c = iopMemRead8(str++))
psxout_buf.push_back(c);
psxout_buf.push_back('\n');
flush_stdout(false);
return false;
}
}
return false;
}

View File

@ -195,6 +195,7 @@
<ClCompile Include="..\..\PrecompiledHeader.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\ps2\Iop\PsxBios.cpp" />
<ClCompile Include="..\..\ps2\LegacyDmac.cpp" />
<ClCompile Include="..\..\ps2\pgif.cpp" />
<ClCompile Include="..\..\ShiftJisToUnicode.cpp" />

View File

@ -880,6 +880,9 @@
<ClCompile Include="..\..\Mdec.cpp">
<Filter>System\Ps2\Iop</Filter>
</ClCompile>
<ClCompile Include="..\..\ps2\Iop\PsxBios.cpp">
<Filter>System\Ps2\Iop</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Patch.h">

View File

@ -1109,6 +1109,12 @@ static void __fastcall iopRecRecompile( const u32 startpc )
_initX86regs();
if ((psxHu32(HW_ICFG) & 8) && (HWADDR(startpc) == 0xa0 || HWADDR(startpc) == 0xb0 || HWADDR(startpc) == 0xc0)) {
xFastCall(psxBiosCall);
xTEST(al, al);
xJNZ(iopDispatcherReg);
}
if( IsDebugBuild )
{
xFastCall((void*)PreBlockCheck, psxpc);