Skip to content
Snippets Groups Projects
Verified Commit 8376919f authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

fix: major joypad issue with selection

The selection mode was being returned with an inverted value.
parent b67ec4d6
No related branches found
No related tags found
No related merge requests found
Pipeline #2404 passed
...@@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
* * Major JoyPad issue with Action/Select read in register
## [0.7.2] - 2023-03-04 ## [0.7.2] - 2023-03-04
......
...@@ -5,6 +5,7 @@ use crate::warnln; ...@@ -5,6 +5,7 @@ use crate::warnln;
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, PartialEq, Eq)]
pub enum PadSelection { pub enum PadSelection {
None,
Action, Action,
Direction, Direction,
} }
...@@ -45,7 +46,7 @@ impl Pad { ...@@ -45,7 +46,7 @@ impl Pad {
select: false, select: false,
b: false, b: false,
a: false, a: false,
selection: PadSelection::Action, selection: PadSelection::None,
int_pad: false, int_pad: false,
} }
} }
...@@ -70,15 +71,12 @@ impl Pad { ...@@ -70,15 +71,12 @@ impl Pad {
| if self.up { 0x00 } else { 0x04 } | if self.up { 0x00 } else { 0x04 }
| if self.down { 0x00 } else { 0x08 }) | if self.down { 0x00 } else { 0x08 })
} }
PadSelection::None => 0x0f,
}; };
value |= if self.selection == PadSelection::Direction { value |= match self.selection {
0x10 PadSelection::Action => 0x10,
} else { PadSelection::Direction => 0x20,
0x00 PadSelection::None => 0x30,
} | if self.selection == PadSelection::Action {
0x20
} else {
0x00
}; };
value value
} }
...@@ -92,11 +90,12 @@ impl Pad { ...@@ -92,11 +90,12 @@ impl Pad {
pub fn write(&mut self, addr: u16, value: u8) { pub fn write(&mut self, addr: u16, value: u8) {
match addr & 0x00ff { match addr & 0x00ff {
0x0000 => { 0x0000 => {
self.selection = if value & 0x10 == 0x00 { self.selection = match value & 0x30 {
PadSelection::Direction 0x10 => PadSelection::Action,
} else { 0x20 => PadSelection::Direction,
PadSelection::Action 0x30 => PadSelection::None,
} _ => PadSelection::None,
};
} }
_ => warnln!("Writing to unknown Pad location 0x{:04x}", addr), _ => warnln!("Writing to unknown Pad location 0x{:04x}", addr),
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment