From 3d127140680a5e1ab619cdec9067f256e84fd57d Mon Sep 17 00:00:00 2001 From: Brendan Robert Date: Mon, 30 Mar 2015 08:18:24 -0500 Subject: [PATCH] Cleanup of how the paddle trigger is handled in order to support floating bus (also better floating bus support on the other memory softswitches as well) --- src/main/java/jace/apple2e/SoftSwitches.java | 17 +++++++++++++---- .../apple2e/softswitch/MemorySoftSwitch.java | 10 ++++++++-- .../apple2e/softswitch/VideoSoftSwitch.java | 3 ++- src/main/java/jace/core/SoftSwitch.java | 3 +++ src/main/java/jace/hardware/Joystick.java | 5 +---- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/main/java/jace/apple2e/SoftSwitches.java b/src/main/java/jace/apple2e/SoftSwitches.java index 4da0de1..6103d39 100644 --- a/src/main/java/jace/apple2e/SoftSwitches.java +++ b/src/main/java/jace/apple2e/SoftSwitches.java @@ -88,12 +88,21 @@ public enum SoftSwitches { PB0(new MemorySoftSwitch("Pushbutton0", -1, -1, 0x0c061, RAMEvent.TYPE.ANY, null)), PB1(new MemorySoftSwitch("Pushbutton1", -1, -1, 0x0c062, RAMEvent.TYPE.ANY, null)), PB2(new MemorySoftSwitch("Pushbutton2", -1, -1, 0x0c063, RAMEvent.TYPE.ANY, null)), - PDLTRIG(new MemorySoftSwitch( - "PaddleTrigger", + PDLTRIG(new SoftSwitch("PaddleTrigger", null, new int[]{0x0c070, 0x0c071, 0x0c072, 0x0c073, 0x0c074, 0x0c075, 0x0c076, 0x0c077, 0x0c078, 0x0c079, 0x0c07a, 0x0c07b, 0x0c07c, 0x0c07d, 0x0c07e, 0x0c07f}, - null, RAMEvent.TYPE.ANY, false)), + null, RAMEvent.TYPE.ANY, false) { + @Override + protected byte readSwitch() { + setState(true); + return computer.getVideo().getFloatingBus(); + } + + @Override + public void stateChanged() { + } + }), PDL0(new MemorySoftSwitch("Paddle0", -1, -1, 0x0c064, RAMEvent.TYPE.ANY, false)), PDL1(new MemorySoftSwitch("Paddle1", -1, -1, 0x0c065, RAMEvent.TYPE.ANY, false)), PDL2(new MemorySoftSwitch("Paddle2", -1, -1, 0x0c066, RAMEvent.TYPE.ANY, false)), @@ -114,7 +123,7 @@ public enum SoftSwitches { KEYBOARD_STROBE_READ(new SoftSwitch("KeyStrobe_Read", 0x0c010, -1, -1, RAMEvent.TYPE.READ, false) { @Override protected byte readSwitch() { - throw new UnsupportedOperationException("Not supported yet."); + return computer.getVideo().getFloatingBus(); } @Override diff --git a/src/main/java/jace/apple2e/softswitch/MemorySoftSwitch.java b/src/main/java/jace/apple2e/softswitch/MemorySoftSwitch.java index 81bad9e..22166af 100644 --- a/src/main/java/jace/apple2e/softswitch/MemorySoftSwitch.java +++ b/src/main/java/jace/apple2e/softswitch/MemorySoftSwitch.java @@ -18,7 +18,6 @@ */ package jace.apple2e.softswitch; -import jace.core.Computer; import jace.core.RAMEvent; import jace.core.SoftSwitch; @@ -38,6 +37,7 @@ public class MemorySoftSwitch extends SoftSwitch { super(name, offAddrs, onAddrs, queryAddrs, changeType, initalState); } + @Override public void stateChanged() { // System.out.println(getName()+ " was switched to "+getState()); if (computer.getMemory() != null) { @@ -46,7 +46,13 @@ public class MemorySoftSwitch extends SoftSwitch { } // Todo: Implement floating bus, maybe? + @Override protected byte readSwitch() { - return (byte) (getState() ? 0x0A0 : 0x020); + byte value = computer.getVideo().getFloatingBus(); + if (getState()) { + return (byte) (value | 0x080); + } else { + return (byte) (value & 0x07f); + } } } \ No newline at end of file diff --git a/src/main/java/jace/apple2e/softswitch/VideoSoftSwitch.java b/src/main/java/jace/apple2e/softswitch/VideoSoftSwitch.java index 924be07..3c627d1 100644 --- a/src/main/java/jace/apple2e/softswitch/VideoSoftSwitch.java +++ b/src/main/java/jace/apple2e/softswitch/VideoSoftSwitch.java @@ -18,7 +18,6 @@ */ package jace.apple2e.softswitch; -import jace.core.Computer; import jace.core.RAMEvent; import jace.core.SoftSwitch; @@ -38,6 +37,7 @@ public class VideoSoftSwitch extends SoftSwitch { super(name, offAddrs, onAddrs, queryAddrs, changeType, initalState); } + @Override public void stateChanged() { // System.out.println("Set "+getName()+" -> "+getState()); if (computer.getVideo() != null) { @@ -45,6 +45,7 @@ public class VideoSoftSwitch extends SoftSwitch { } } + @Override protected byte readSwitch() { // System.out.println("Read "+getName()+" = "+getState()); return (byte) (getState() ? 0x080 : 0x000); diff --git a/src/main/java/jace/core/SoftSwitch.java b/src/main/java/jace/core/SoftSwitch.java index 7fafe88..a021463 100644 --- a/src/main/java/jace/core/SoftSwitch.java +++ b/src/main/java/jace/core/SoftSwitch.java @@ -144,6 +144,9 @@ public abstract class SoftSwitch { @Override protected void doEvent(RAMEvent e) { + if (e.getType().isRead()) { + e.setNewValue(computer.getVideo().getFloatingBus()); + } if (!exclusionActivate.contains(e.getAddress())) { // System.out.println("Access to "+Integer.toHexString(e.getAddress())+" ENABLES switch "+getName()); setState(true); diff --git a/src/main/java/jace/hardware/Joystick.java b/src/main/java/jace/hardware/Joystick.java index 8add599..113f59a 100644 --- a/src/main/java/jace/hardware/Joystick.java +++ b/src/main/java/jace/hardware/Joystick.java @@ -199,14 +199,11 @@ public class Joystick extends Device { protected void doEvent(RAMEvent e) { setRun(true); readJoystick(); -// if (x <= 0) { xSwitch.setState(true); x = 10 + joyX * 11; -// } -// if (y <= 0) { ySwitch.setState(true); y = 10 + joyY * 11; -// } + e.setNewValue(computer.getVideo().getFloatingBus()); } };