diff --git a/Assets/dll/stella.wbx.zst b/Assets/dll/stella.wbx.zst index f765436017..a4a69c9f71 100644 Binary files a/Assets/dll/stella.wbx.zst and b/Assets/dll/stella.wbx.zst differ diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/Stella/LibStella.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/Stella/LibStella.cs index 8b7e0eb654..53d4bc155e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/Stella/LibStella.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/Stella/LibStella.cs @@ -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); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/Stella/Stella.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/Stella/Stella.IEmulator.cs index a356fe9687..4797668292 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/Stella/Stella.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/Stella/Stella.IEmulator.cs @@ -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++; diff --git a/waterbox/stella/BizhawkInterface.cxx b/waterbox/stella/BizhawkInterface.cxx index 5032547991..8db6ae7266 100644 --- a/waterbox/stella/BizhawkInterface.cxx +++ b/waterbox/stella/BizhawkInterface.cxx @@ -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); diff --git a/waterbox/stella/core b/waterbox/stella/core index 48734d5c38..3479e04061 160000 --- a/waterbox/stella/core +++ b/waterbox/stella/core @@ -1 +1 @@ -Subproject commit 48734d5c38c12e3988959ebcb6efee4a570268e3 +Subproject commit 3479e040610f2370266aa153eb23989b6b439c0d