derives + set stat properly + joypad improvements
This commit is contained in:
parent
ac6c2afd10
commit
d5efdd6084
|
@ -10,11 +10,13 @@ pub(crate) mod rom;
|
||||||
|
|
||||||
pub(crate) type Address = u16;
|
pub(crate) type Address = u16;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
enum JoypadBank {
|
enum JoypadBank {
|
||||||
Action,
|
Action,
|
||||||
Direction,
|
Direction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct Joypad {
|
struct Joypad {
|
||||||
bank_sel: JoypadBank,
|
bank_sel: JoypadBank,
|
||||||
down: bool,
|
down: bool,
|
||||||
|
@ -32,6 +34,7 @@ impl Joypad {
|
||||||
let mut reg = 0xFF;
|
let mut reg = 0xFF;
|
||||||
match self.bank_sel {
|
match self.bank_sel {
|
||||||
JoypadBank::Action => {
|
JoypadBank::Action => {
|
||||||
|
reg = clear_bit(reg, 5);
|
||||||
if self.start {
|
if self.start {
|
||||||
reg = clear_bit(reg, 3);
|
reg = clear_bit(reg, 3);
|
||||||
}
|
}
|
||||||
|
@ -46,6 +49,7 @@ impl Joypad {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JoypadBank::Direction => {
|
JoypadBank::Direction => {
|
||||||
|
reg = clear_bit(reg, 4);
|
||||||
if self.down {
|
if self.down {
|
||||||
reg = clear_bit(reg, 3);
|
reg = clear_bit(reg, 3);
|
||||||
}
|
}
|
||||||
|
@ -242,14 +246,15 @@ impl Memory {
|
||||||
}
|
}
|
||||||
0xFF11 | 0xFF14 | 0xFF16 | 0xFF19 | 0xFF1E | 0xFF23 | 0xFF26 => {
|
0xFF11 | 0xFF14 | 0xFF16 | 0xFF19 | 0xFF1E | 0xFF23 | 0xFF26 => {
|
||||||
// sound
|
// sound
|
||||||
|
self.io[addr_l] = data;
|
||||||
}
|
}
|
||||||
0xFF41 => {
|
0xFF41 => {
|
||||||
// mixed read/write addresses...
|
// mixed read/write
|
||||||
// need to fill these out more...
|
self.io[addr_l] = self.io[addr_l] | (data & 0b1111000)
|
||||||
// just seeing what breaks...
|
|
||||||
}
|
}
|
||||||
0xFF4D | 0xFF56 => {
|
0xFF4D | 0xFF56 => {
|
||||||
// cgb only
|
// cgb only
|
||||||
|
self.io[addr_l] = data;
|
||||||
}
|
}
|
||||||
0xFF44 | 0xFF76 | 0xFF77 => {
|
0xFF44 | 0xFF76 | 0xFF77 => {
|
||||||
// read-only addresses
|
// read-only addresses
|
||||||
|
|
Loading…
Reference in a new issue