Skip to content

Commit

Permalink
Work on autofire
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Aug 31, 2024
1 parent c385d55 commit 0413a01
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 45 deletions.
19 changes: 0 additions & 19 deletions Emulator/Components/C64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,6 @@ C64::eventName(EventSlot slot, EventID id)
}
break;

case SLOT_AFI1:
case SLOT_AFI2:

switch (id) {

case EVENT_NONE: return "none";
case AFI_FIRE: return "AFI_FIRE";
default: return "*** INVALID ***";
}
break;

case SLOT_MOT:

switch (id) {
Expand Down Expand Up @@ -1150,14 +1139,6 @@ C64::processEvents(Cycle cycle)
if (isDue<SLOT_RXD>(cycle)) {
userPort.rs232.processRxdEvent();
}
/*
if (isDue<SLOT_AFI1>(cycle)) {
port1.joystick.processEvent();
}
if (isDue<SLOT_AFI2>(cycle)) {
port2.joystick.processEvent();
}
*/
if (isDue<SLOT_MOT>(cycle)) {
datasette.processMotEvent(eventid[SLOT_MOT]);
}
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Components/C64Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ enum_long(SLOT)
SLOT_EXP, // Expansion port
SLOT_TXD, // Serial data out (RS232)
SLOT_RXD, // Serial data in (RS232)
SLOT_AFI1, // Auto-fire (joystick port 1)
SLOT_AFI2, // Auto-fire (joystick port 2)
SLOT_MOT, // Datasette motor
SLOT_DC8, // Disk change (Drive 8)
SLOT_DC9, // Disk change (Drive 9)
Expand Down Expand Up @@ -205,10 +203,6 @@ enum_i8(EventID)
RXD_BIT = 1,
RXD_EVENT_COUT,

// Auto-fire
AFI_FIRE = 1,
AFI_EVENT_COUNT,

// Datasette motor
MOT_START = 1,
MOT_STOP,
Expand Down
25 changes: 9 additions & 16 deletions Emulator/Peripherals/Joystick/Joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Joystick::trigger(GamePadAction event)
if (config.autofireBursts) {

// In burst mode, reload the magazine.
reload(config.autofireBullets);
reload();

} else {

Expand Down Expand Up @@ -125,13 +125,19 @@ Joystick::isAutofiring()
return bulletCounter > 0;
}

isize
Joystick::magazineSize()
{
return config.autofireBursts ? config.autofireBullets : INT_MAX;
}

void
Joystick::startAutofire()
{
debug(JOY_DEBUG, "startAutofire()\n");

// Load magazine
reload(config.autofireBursts ? config.autofireBullets : INT_MAX);
reload();

// Fire the first shot
button = true;
Expand All @@ -156,20 +162,7 @@ Joystick::stopAutofire()
void
Joystick::reload()
{
if (config.autofire) {

reload(config.autofireBursts ? config.autofireBullets : INT_MAX);

} else {

reload(0);
}
}

void
Joystick::reload(isize bullets)
{
bulletCounter = bullets;
bulletCounter = magazineSize();
}

}
4 changes: 3 additions & 1 deletion Emulator/Peripherals/Joystick/Joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,15 @@ class Joystick final : public SubComponent, public Inspectable<JoystickInfo> {
// Checks whether autofiring is active
bool isAutofiring();

// Returns the maximum number of bullets to fire
isize magazineSize();

// Starts or stops autofire mode
void startAutofire();
void stopAutofire();

// Reloads the autofire magazine
void reload();
void reload(isize bullets);
};

}
2 changes: 2 additions & 0 deletions Emulator/Peripherals/Joystick/JoystickBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ Joystick::setOption(Option opt, i64 value)
case OPT_AUTOFIRE_BURSTS:

config.autofireBursts = bool(value);
if (isAutofiring()) reload();
return;

case OPT_AUTOFIRE_BULLETS:

config.autofireBullets = isize(value);
if (isAutofiring()) reload();
return;

case OPT_AUTOFIRE_DELAY:
Expand Down
2 changes: 1 addition & 1 deletion GUI/MyControllerStatusBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ extension MyController {
emu?.set(.C64_SPEED_ADJUST, value: value)
}

@IBAction func speedResetAction(_ sender:Any!) {
@IBAction func speedResetAction(_ sender: Any!) {

emu?.set(.C64_SPEED_ADJUST, value: 100)
}
Expand Down
2 changes: 0 additions & 2 deletions Proxy/TypeExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ extension vc64.EventSlot: CustomStringConvertible {
case ._EXP: return "Expansion Port"
case ._TXD: return "RS232 Out"
case ._RXD: return "RS232 In"
case ._AFI1: return "Auto-fire Port 1"
case ._AFI2: return "Auto-fire Port 2"
case ._MOT: return "Datasette Motor"
case ._DC8: return "Disk Change Drive 8"
case ._DC9: return "Disk Change Drive 9"
Expand Down

0 comments on commit 0413a01

Please sign in to comment.