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)

This commit is contained in:
Brendan Robert 2015-03-30 08:18:24 -05:00
parent 55b3693466
commit 3d12714068
5 changed files with 27 additions and 11 deletions

View File

@ -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

View File

@ -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);
}
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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());
}
};