Skip to content

Commit

Permalink
Merge pull request #5520 from sepalani/write-console
Browse files Browse the repository at this point in the history
HLE: Fix __write_console implementation
  • Loading branch information
leoetlino committed Jun 3, 2017
2 parents 227bc38 + 2afa546 commit 4b53093
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Source/Core/Core/HLE/HLE_OS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,24 @@ void HLE_GeneralDebugPrint()
NOTICE_LOG(OSREPORT, "%08x->%08x| %s", LR, PC, SHIFTJISToUTF8(report_message).c_str());
}

// __write_console is slightly abnormal
// __write_console(int fd, const void* buffer, const u32* size)
void HLE_write_console()
{
std::string report_message = GetStringVA(4);
if (PowerPC::HostIsRAMAddress(GPR(5)))
{
u32 size = PowerPC::Read_U32(GPR(5));
if (size > report_message.size())
WARN_LOG(OSREPORT, "__write_console uses an invalid size of 0x%08x", size);
else if (size == 0)
WARN_LOG(OSREPORT, "__write_console uses a size of zero");
else
report_message = report_message.substr(0, size);
}
else
{
ERROR_LOG(OSREPORT, "__write_console uses an unreachable size pointer");
}

NPC = LR;

Expand Down

0 comments on commit 4b53093

Please sign in to comment.