Skip to content

Commit

Permalink
Added support for Robocom dongles
Browse files Browse the repository at this point in the history
  • Loading branch information
univta0001 committed Aug 19, 2024
1 parent 7111485 commit 619db67
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 21 deletions.
43 changes: 38 additions & 5 deletions emulator/src/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub enum Dongle {
SpeedStar,
Hayden,
CodeWriter(u8),
Robocom(u16),
}

#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))]
Expand Down Expand Up @@ -1104,11 +1105,43 @@ impl Bus {
let delta = self.get_cycles() - self.get_paddle_trigger();
let mut value = self.get_joystick_value(self.paddle_latch[3]);

if self.dongle == Dongle::Hayden {
// Implementation of Hayden dongle
let index = (self.annunciator[2] as u8) << 1 | self.annunciator[0] as u8;
let dongle_value = [0xff, 0x96, (0x96 + 0x50) / 2, 0x50];
value = dongle_value[index as usize];
match self.dongle {
Dongle::Hayden => {
// Implementation of Hayden dongle
let index =
(self.annunciator[2] as u8) << 1 | self.annunciator[0] as u8;
let dongle_value = [0xff, 0x96, (0x96 + 0x50) / 2, 0x50];
value = dongle_value[index as usize];
}

Dongle::Robocom(model) if !self.annunciator[3] => {
// Implementation of Robocom dongle
let index = ((self.annunciator[2] as u8) << 2)
| ((self.annunciator[1] as u8) << 1)
| self.annunciator[0] as u8;

match model {
500 => {
let lo = [0x3f, 0x2e, 0x54, 0x54, 0x2e, 0x22, 0x72, 0x17];
let hi = [0x6f, 0x54, 0x94, 0x94, 0x54, 0x40, 0xc4, 0x2e];
value = (lo[index as usize] + hi[index as usize] - 1) / 2;
}

1000 => {
let dongle_value = [34, 151, 48, 64, 113, 113, 64, 85];
value = dongle_value[index as usize];
}

1500 => {
let dongle_value = [153, 34, 64, 34, 48, 86, 114, 48];
value = dongle_value[index as usize];
}

_ => {}
}
}

_ => {}
}

if delta < (value as usize * 11) {
Expand Down
35 changes: 19 additions & 16 deletions sdl_frontend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,14 +850,15 @@ FLAGS:
--scale ratio Scale the graphics by ratio (Default is 2.0)
--z80_cirtech Enable Z80 Cirtech address translation
--saturn Enable Saturn memory (Only available in Apple 2+)
--speedstar Enable SpeedStar datakey dongle
--hayden Enable Hayden dongle
--codewriter Enable CodeWriter dongle
--interface name Set the interface name for Uthernet2 (Default is None. For e.g. eth0)
--dongle model Enable dongle
Value: speedstar, hayden, codewriter, robocom500,
robocom1000, robocom1500
--interface name Set the interface name for Uthernet2
Default is None. For e.g. eth0
ARGS:
[disk 1] Disk 1 file (woz, dsk, do, po file). File can be in gz format
[disk 2] Disk 2 file (woz, dsk, do, po file). File can be in gz format
[disk 1] Disk 1 file (woz, dsk, do, po file). Can be in gz format
[disk 2] Disk 2 file (woz, dsk, do, po file). Can be in gz format
Function Keys:
Ctrl-Shift-F1 Display emulation speed
Expand Down Expand Up @@ -1583,16 +1584,18 @@ fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
cpu.bus.set_z80_cirtech(true);
}

if pargs.contains("--speedstar") {
cpu.bus.set_dongle(Dongle::SpeedStar);
}

if pargs.contains("--hayden") {
cpu.bus.set_dongle(Dongle::Hayden);
}

if pargs.contains("--codewriter") {
cpu.bus.set_dongle(Dongle::CodeWriter(0x6b));
if let Some(dongle) = pargs.opt_value_from_str::<_, String>("--dongle")? {
match &dongle[..] {
"speedstar" => cpu.bus.set_dongle(Dongle::SpeedStar),
"hayden" => cpu.bus.set_dongle(Dongle::Hayden),
"codewriter" => cpu.bus.set_dongle(Dongle::CodeWriter(0x6b)),
"robocom500" => cpu.bus.set_dongle(Dongle::Robocom(500)),
"robocom1000" => cpu.bus.set_dongle(Dongle::Robocom(1000)),
"robocom1500" => cpu.bus.set_dongle(Dongle::Robocom(1500)),
_ => {
panic!("Dongle supported: speedstar, hayden, codewriter, robocom500, robocom1000, robocom1500");
}
}
}

let mut apple2p = false;
Expand Down

0 comments on commit 619db67

Please sign in to comment.