[A26][Stella] Adds support for the console Select switch (#4178)

* [Stella] Added the Select switch input

* [Stella] Reduced console switches into a single int corresponding to the SWCHB register
This commit is contained in:
Luke Stadem 2025-03-22 11:49:27 -05:00 committed by GitHub
parent eb79f2e735
commit 3af38050f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 49 additions and 33 deletions

Binary file not shown.

View File

@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
[In] InitSettings settings);
[BizImport(CallingConvention.Cdecl)]
public abstract void stella_frame_advance(byte port1, byte port2, bool reset, bool power, bool leftDiffToggled, bool rightDiffToggled);
public abstract void stella_frame_advance(byte port1, byte port2, byte switchPort, bool power);
[BizImport(CallingConvention.Cdecl)]
public abstract void stella_get_video(out int w, out int h, out int pitch, ref IntPtr buffer);

View File

@ -16,17 +16,24 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
byte port1 = _controllerDeck.ReadPort1(controller);
byte port2 = _controllerDeck.ReadPort2(controller);
// Handle all the console controls here
bool powerPressed = false;
bool resetPressed = false;
if (controller.IsPressed("Power")) powerPressed = true;
if (controller.IsPressed("Reset")) resetPressed = true;
if (controller.IsPressed("Toggle Left Difficulty")) _leftDifficultyToggled = !_leftDifficultyToggled;
// Handle all the console switches here
if (controller.IsPressed("Toggle Right Difficulty")) _rightDifficultyToggled = !_rightDifficultyToggled;
if (controller.IsPressed("Toggle Left Difficulty")) _leftDifficultyToggled = !_leftDifficultyToggled;
// select and reset switches default to an unpressed state
// unknown whether TV color switch matters for TASing, so default to Color for now
byte switchPort = 0b00001011;
if (_rightDifficultyToggled) switchPort |= 0b10000000;
if (_leftDifficultyToggled) switchPort |= 0b01000000;
if (controller.IsPressed("Select")) switchPort &= 0b11111101; // 0 = Pressed
if (controller.IsPressed("Reset")) switchPort &= 0b11111110; // 0 = Pressed
bool powerPressed = false;
if (controller.IsPressed("Power")) powerPressed = true;
IsLagFrame = true;
Core.stella_frame_advance(port1, port2, resetPressed, powerPressed, _leftDifficultyToggled, _rightDifficultyToggled);
Core.stella_frame_advance(port1, port2, switchPort, powerPressed);
if (IsLagFrame)
LagCount++;

View File

@ -150,36 +150,45 @@ ECL_EXPORT void stella_get_audio(int *n, void **buffer)
ECL_EXPORT void stella_get_video(int& w, int& h, int& pitch, uint8_t*& buffer)
{
w = _a2600->console().tia().width();
h = _a2600->console().tia().height();
buffer = _a2600->console().tia().frameBuffer();
pitch = _a2600->console().tia().width();
w = _a2600->console().tia().width();
h = _a2600->console().tia().height();
buffer = _a2600->console().tia().frameBuffer();
pitch = _a2600->console().tia().width();
}
ECL_EXPORT void stella_frame_advance(uint8_t port1, uint8_t port2, bool reset, bool power, bool leftDiffToggled, bool rightDiffToggled)
// Console Switches (switchPort)
// SWCHB.7 P1 Difficulty Switch (0=Beginner (B), 1=Advanced (A))
// SWCHB.6 P0 Difficulty Switch (0=Beginner (B), 1=Advanced (A))
// SWCHB.4-5 Not used
// SWCHB.3 Color Switch (0=B/W, 1=Color) (Always 0 for SECAM)
// SWCHB.2 Not used
// SWCHB.1 Select Switch (0=Pressed)
// SWCHB.0 Reset Switch (0=Pressed)
ECL_EXPORT void stella_frame_advance(uint8_t port1, uint8_t port2, uint8_t switchPort, bool power)
{
_a2600->console().switches().setLeftDifficultyA(leftDiffToggled);
_a2600->console().switches().setRightDifficultyA(rightDiffToggled);
_a2600->console().switches().setReset(!reset);
if (power) _a2600->console().system().reset(true);
_a2600->console().switches().setRightDifficultyA(switchPort & 0b10000000);
_a2600->console().switches().setLeftDifficultyA( switchPort & 0b01000000);
_a2600->console().switches().setTvColor( switchPort & 0b00001000);
_a2600->console().switches().setSelect( switchPort & 0b00000010);
_a2600->console().switches().setReset( switchPort & 0b00000001);
if (power) _a2600->console().system().reset(true);
_a2600->console().leftController().write(::Controller::DigitalPin::One, port1 & 0b00010000); // Up
_a2600->console().leftController().write(::Controller::DigitalPin::Two, port1 & 0b00100000); // Down
_a2600->console().leftController().write(::Controller::DigitalPin::Three, port1 & 0b01000000); // Left
_a2600->console().leftController().write(::Controller::DigitalPin::Four, port1 & 0b10000000); // Right
_a2600->console().leftController().write(::Controller::DigitalPin::Six, port1 & 0b00001000); // Button
_a2600->console().leftController().write(::Controller::DigitalPin::One, port1 & 0b00010000); // Up
_a2600->console().leftController().write(::Controller::DigitalPin::Two, port1 & 0b00100000); // Down
_a2600->console().leftController().write(::Controller::DigitalPin::Three, port1 & 0b01000000); // Left
_a2600->console().leftController().write(::Controller::DigitalPin::Four, port1 & 0b10000000); // Right
_a2600->console().leftController().write(::Controller::DigitalPin::Six, port1 & 0b00001000); // Button
_a2600->console().rightController().write(::Controller::DigitalPin::One, port2 & 0b00010000); // Up
_a2600->console().rightController().write(::Controller::DigitalPin::Two, port2 & 0b00100000); // Down
_a2600->console().rightController().write(::Controller::DigitalPin::Three, port2 & 0b01000000); // Left
_a2600->console().rightController().write(::Controller::DigitalPin::Four, port2 & 0b10000000); // Right
_a2600->console().rightController().write(::Controller::DigitalPin::Six, port2 & 0b00001000); // Button
_a2600->console().rightController().write(::Controller::DigitalPin::One, port2 & 0b00010000); // Up
_a2600->console().rightController().write(::Controller::DigitalPin::Two, port2 & 0b00100000); // Down
_a2600->console().rightController().write(::Controller::DigitalPin::Three, port2 & 0b01000000); // Left
_a2600->console().rightController().write(::Controller::DigitalPin::Four, port2 & 0b10000000); // Right
_a2600->console().rightController().write(::Controller::DigitalPin::Six, port2 & 0b00001000); // Button
nsamples = 0;
_a2600->dispatchEmulation();
// printRAM();
// printFrameBuffer();
nsamples = 0;
_a2600->dispatchEmulation();
// printRAM();
// printFrameBuffer();
}
ECL_ENTRY void (*input_callback_cb)(void);

@ -1 +1 @@
Subproject commit 48734d5c38c12e3988959ebcb6efee4a570268e3
Subproject commit 3479e040610f2370266aa153eb23989b6b439c0d