diff --git a/src/device/expansion2.cpp b/src/device/expansion2.cpp index 66be4c8..b38e4d3 100644 --- a/src/device/expansion2.cpp +++ b/src/device/expansion2.cpp @@ -1,4 +1,5 @@ #include "expansion2.h" +#include "config.h" #include Expansion2::Expansion2() { reset(); } @@ -6,16 +7,26 @@ Expansion2::Expansion2() { reset(); } void Expansion2::reset() { post = 0; } uint8_t Expansion2::read(uint32_t address) { - (void)address; + if (address == 0x21) { // DUART Status + return 1 << 2; // Tx Empty + } return 0; } void Expansion2::write(uint32_t address, uint8_t data) { - if (address == 0x41) { + if (address == 0x22) { // DUART Command + // Ignore (Enable Tx/Rx, reset/flush commands) + } else if (address == 0x23) { // DUART Tx + if (config.debug.log.system) { + putchar(data); + } + } else if (address == 0x24) { // DUART Aux Control + // Ignore (baud rate, int flags) + } else if (address == 0x41) { post = data; - } - // PCSX-Redux/Openbios stdout channel - if (address == 0x80) { - putchar(data); + } else if (address == 0x80) { // PCSX-Redux/Openbios stdout channel + if (config.debug.log.system) { + putchar(data); + } } } \ No newline at end of file diff --git a/src/system.cpp b/src/system.cpp index 93d777a..5c71842 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -498,6 +498,20 @@ bool System::loadBios(const std::string& path) { this->biosPath = path; state = State::run; biosLoaded = true; + + auto patch = [&](uint32_t address, uint32_t opcode) { + address &= bios.size() - 1; + for (int i = 0; i < 4; i++) { + bios[address + i] = (opcode >> (i * 8)) & 0xff; + } + }; + + if (config.debug.log.system) { + fmt::print("[INFO] Patching BIOS for system log\n"); + patch(0x6F0C, 0x24010001); + patch(0x6F14, 0xAF81A9C0); + } + return true; }