Add Apple SW0/SW1/SW2 button support

This commit is contained in:
Fred Sauer committed 2026-03-23 18:30:19 -07:00
1 parent 361722f1ba
commit f159ebcafb
4 files changed
+28 -2

No files matched your search

+5
View File
@@ -881,6 +881,11 @@ export abstract class BaseMachinePlatform<T extends Machine> extends BaseDebugPl
if (hasPaddleInput(this.machine)) {
this.machine.setPaddleInput(0, this.video.paddle_x);
this.machine.setPaddleInput(1, this.video.paddle_y);
if (this.machine.setPaddleButton) {
this.machine.setPaddleButton(0, this.video.paddle_buttons[0]);
this.machine.setPaddleButton(1, this.video.paddle_buttons[1]);
this.machine.setPaddleButton(2, this.video.paddle_buttons[2]);
}
}
// TODO: put into interface
if (this.machine['pollControls']) {
+1
View File
@@ -112,6 +112,7 @@ export interface AcceptsKeyInput {
export interface AcceptsPaddleInput {
setPaddleInput(controller: number, value: number): void;
setPaddleButton?(index: number, pressed: boolean): void;
}
// TODO: interface not yet used (setKeyInput() handles joystick)
+9
View File
@@ -86,6 +86,8 @@ export class RasterVideo {
// Start paddles/joystick centered in [0,255] range.
paddle_x = 128;
paddle_y = 128;
// Platforms can support up to three buttons.
paddle_buttons: boolean[] = [false, false, false];
setRotate(rotate: number) {
var canvas = this.canvas;
@@ -148,6 +150,13 @@ export class RasterVideo {
var new_y = Math.round(pos.y * 255 / this.canvas.height);
this.paddle_x = clamp(0, 255, new_x);
this.paddle_y = clamp(0, 255, new_y);
}).mousedown((e) => {
// TODO Allows users to specify mapping in settings.
this.paddle_buttons[0] = !e.shiftKey && !e.altKey;
this.paddle_buttons[1] = e.shiftKey && !e.altKey;
this.paddle_buttons[2] = e.altKey && !e.shiftKey;
}).mouseup((e) => {
this.paddle_buttons.fill(false);
});
};
}
+13 -2
View File
@@ -62,6 +62,7 @@ export class AppleII extends BasicScanlineMachine implements AcceptsBIOS, Accept
bank2wroffset = 0;
// Paddle/joystick, PDL0-PDL3 values (0-255).
paddleValues = [0, 0, 0, 0];
paddleButtons = [false, false, false];
paddleLastTriggered = 0;
// disk II
slots: SlotDevice[] = new Array(8);
@@ -282,8 +283,12 @@ export class AppleII extends BasicScanlineMachine implements AcceptsBIOS, Accept
case 1: // $C061 / $C069 - GAME SW0
case 2: // $C062 / $C06A - GAME SW1
case 3: // $C063 / $C06B - GAME SW2
// buttons (off)
return this.floatbus() & 0x7f;
// buttons
var btn = (address & 7) - 1;
if (this.paddleButtons[btn])
return this.floatbus() | 0x80;
else
return this.floatbus() & 0x7f;
case 4: // $C064 / $C06C - GAME PDL0
case 5: // $C065 / $C06D - GAME PDL1
case 6: // $C066 / $C06E - GAME PDL2
@@ -441,6 +446,12 @@ export class AppleII extends BasicScanlineMachine implements AcceptsBIOS, Accept
}
}
setPaddleButton(index: number, pressed: boolean): void {
if (index >= 0 && index < this.paddleButtons.length) {
this.paddleButtons[index] = pressed;
}
}
doLanguageCardIO(address: number) {
// TODO: require two writes in a row for some things
switch (address & 0x0f) {