Skip to content

Commit

Permalink
Work on paddles
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jun 2, 2024
1 parent 67f76e3 commit 19ef011
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 27 deletions.
42 changes: 42 additions & 0 deletions Emulator/Misc/RetroShell/InterpreterCmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ Interpreter::initCommandShell(Command &root)
root.popGroup();
}


//
// Peripherals (Joystick)
//
Expand Down Expand Up @@ -876,6 +877,47 @@ Interpreter::initCommandShell(Command &root)
root.popGroup();
}


//
// Peripherals (Paddles)
//

for (isize i = PORT_1; i <= PORT_2; i++) {

auto &paddle = i == PORT_1 ? c64.port1.paddle : c64.port2.paddle;

cmd = paddle.shellName();
description = paddle.description();
root.add({cmd}, description);

root.pushGroup("");

root.add({cmd, ""},
"Displays the current configuration",
[this](Arguments& argv, long value) {

auto &port = (value == PORT_1) ? c64.port1 : c64.port2;
retroShell.dump(port.paddle, Category::Config);

}, i);

root.add({cmd, "set"}, "Configures the component");

for (auto &opt : c64.port1.paddle.getOptions()) {

root.add({cmd, "set", OptionEnum::plainkey(opt)},
{OptionParser::create(opt)->argList()},
OptionEnum::help(opt),
[this](Arguments& argv, long value) {

emulator.set(Option(HI_WORD(value)), argv[0], LO_WORD(value));

}, HI_W_LO_W(opt, i));
}

root.popGroup();
}

//
// Peripherals (Datasette)
//
Expand Down
2 changes: 2 additions & 0 deletions GUI/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ extension Configuration {
defaults.set(Keys.Per.gameDevice2, gameDevice2)

defaults.set(.MOUSE_MODEL, mouseModel)
defaults.set(.PADDLE_ORIENTATION, paddleOrientation)

defaults.save()

Expand Down Expand Up @@ -834,6 +835,7 @@ extension Configuration {
gameDevice2 = defaults.int(Keys.Per.gameDevice2)

mouseModel = defaults.get(.MOUSE_MODEL)
paddleOrientation = defaults.get(.PADDLE_ORIENTATION)

emu.resume()
}
Expand Down
5 changes: 5 additions & 0 deletions GUI/Panels/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ class Configuration {
set { emu.set(.MOUSE_MODEL, value: newValue) }
}

var paddleOrientation: Int {
get { return emu.get(.PADDLE_ORIENTATION, id: 1) }
set { emu.set(.PADDLE_ORIENTATION, value: newValue) }
}

var autofire: Bool {
get { return emu.get(.AUTOFIRE, id: 1) != 0 }
set { emu.set(.AUTOFIRE, enable: newValue) }
Expand Down
2 changes: 2 additions & 0 deletions GUI/Panels/Configuration/ConfigurationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class ConfigurationController: DialogController {

// Mouse
@IBOutlet weak var perMouseModel: NSPopUpButton!
@IBOutlet weak var perPaddleOrientation: NSPopUpButton!
@IBOutlet weak var perPaddleOrientationText: NSTextField!

// Joystick
@IBOutlet weak var perAutofire: NSButton!
Expand Down
16 changes: 10 additions & 6 deletions GUI/Panels/Configuration/PeripheralsConf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ extension ConfigurationController {
func update(_ component: NSControl, enable: Bool) {
component.isEnabled = enable
}
/*
func update(_ component: NSSlider, enable: Bool) {
component.isEnabled = enable
}
*/

let enable8 = config.drive8Connected && !config.drive8AutoConf
let enable9 = config.drive9Connected && !config.drive9AutoConf
Expand Down Expand Up @@ -64,7 +59,11 @@ extension ConfigurationController {
perControlPort2.selectItem(withTag: config.gameDevice2)

// Mouse
let paddle = config.mouseModel >= 3
perMouseModel.selectItem(withTag: config.mouseModel)
perPaddleOrientation.selectItem(withTag: config.paddleOrientation)
update(perPaddleOrientation, enable: paddle)
update(perPaddleOrientationText, enable: paddle)

// Joysticks
let enable = config.autofire
Expand Down Expand Up @@ -152,7 +151,12 @@ extension ConfigurationController {

config.mouseModel = sender.selectedTag()
}


@IBAction func perPaddleOrientationAction(_ sender: NSPopUpButton!) {

config.paddleOrientation = sender.selectedTag()
}

@IBAction func perAutofireAction(_ sender: NSButton!) {

config.autofire = (sender.state == .on)
Expand Down
Loading

0 comments on commit 19ef011

Please sign in to comment.