From f70ae8040e83568b395a1f8cbcabeed8a3facafe Mon Sep 17 00:00:00 2001 From: Marco Maccaferri Date: Tue, 9 Jun 2020 11:07:56 +0200 Subject: [PATCH] Fixed SIO and CF devices detection --- src/com/maccasoft/tools/Application.java | 11 +++++++---- src/com/maccasoft/tools/Emulator.java | 11 ++++++++--- src/com/maccasoft/tools/Machine.java | 24 ++++++++++++++++++------ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/com/maccasoft/tools/Application.java b/src/com/maccasoft/tools/Application.java index 5aa18ad..4685186 100644 --- a/src/com/maccasoft/tools/Application.java +++ b/src/com/maccasoft/tools/Application.java @@ -2458,14 +2458,15 @@ public class Application { public int inPort(int port) { switch (port & 0xFF) { case SIOA_C: { + int result = 0b00101100; // TX Buffer Empty, DCD and CTS try { if (debugTerminal != null && debugTerminal.getInputStream().available() > 0) { - return 0x04 + 0x01; + result |= 0x01; // RX Char Available } } catch (Exception e) { e.printStackTrace(); } - return 0x04; // Always return TX buffer empty + return result; } case SIOA_D: { try { @@ -2475,10 +2476,12 @@ public class Application { } catch (Exception e) { e.printStackTrace(); } - break; + return 0x00; } case SIOB_C: - return 0x04; // Always return TX buffer empty + return 0b00101100; // TX Buffer Empty, DCD and CTS + case SIOB_D: + return 0x00; } if ((port & 0xFF) == preferences.getTms9918Ram()) { diff --git a/src/com/maccasoft/tools/Emulator.java b/src/com/maccasoft/tools/Emulator.java index 15f9ef9..b802dd8 100644 --- a/src/com/maccasoft/tools/Emulator.java +++ b/src/com/maccasoft/tools/Emulator.java @@ -132,14 +132,15 @@ public class Emulator { public int inPort(int port) { switch (port & 0xFF) { case SIOA_C: + int result = 0b00101100; // TX Buffer Empty, DCD and CTS try { if (is.available() > 0) { - return 0x04 + 0x01; + result |= 0x01; // RX Char Available } } catch (Exception e) { e.printStackTrace(); } - return 0x04; // Always return TX buffer empty + return result; case SIOA_D: try { if (is.available() > 0) { @@ -148,7 +149,11 @@ public class Emulator { } catch (Exception e) { e.printStackTrace(); } - break; + return 0x00; + case SIOB_C: + return 0b00101100; // TX Buffer Empty, DCD and CTS + case SIOB_D: + return 0x00; } return super.inPort(port); } diff --git a/src/com/maccasoft/tools/Machine.java b/src/com/maccasoft/tools/Machine.java index a2d6ee3..1bd5172 100644 --- a/src/com/maccasoft/tools/Machine.java +++ b/src/com/maccasoft/tools/Machine.java @@ -49,6 +49,7 @@ public class Machine extends MemIoOps { byte cfCommand; byte[] cfLBA = new byte[4]; + byte cfSecCount; File cfFile; RandomAccessFile cf; @@ -198,12 +199,15 @@ public class Machine extends MemIoOps { } } break; + case CF_SECCOUNT: + return cfSecCount & 0xFF; case CF_STATUS: - return 0x40; // CF ready - case SIOA_C: - return 0x04; // Always return TX buffer empty - case SIOB_C: - return 0x04; // Always return TX buffer empty + if (cfCommand == CF_WRITE_SEC || cfCommand == CF_READ_SEC) { + return 0x48; // CF Ready, DRQ + } + else { + return 0x40; // CF Ready + } } return port; @@ -259,8 +263,16 @@ public class Machine extends MemIoOps { cfLBA[3] = (byte) value; break; } + case CF_SECCOUNT: + cfSecCount = (byte) value; + break; case 0x38: // ROM page - page = !page; + if ((value & 0xFF) == 0x01) { + page = true; + } + else { + page = false; + } break; } }