a little bit of fixing
This commit is contained in:
parent
d7a60d1c97
commit
a3dfec659a
|
@ -208,13 +208,6 @@ impl Memory {
|
||||||
self.io[addr_l] = data;
|
self.io[addr_l] = data;
|
||||||
} else {
|
} else {
|
||||||
match address {
|
match address {
|
||||||
0xFF02 => {
|
|
||||||
if data == 0x81 {
|
|
||||||
print!("{}", self.get(0xFF01) as char);
|
|
||||||
stdout().flush().unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
0xFF04 => self.io[addr_l] = 0,
|
|
||||||
0xFF00 => {
|
0xFF00 => {
|
||||||
// joypad
|
// joypad
|
||||||
if !get_bit(data, 5) {
|
if !get_bit(data, 5) {
|
||||||
|
@ -224,13 +217,26 @@ impl Memory {
|
||||||
self.joypad.bank_sel = JoypadBank::Direction
|
self.joypad.bank_sel = JoypadBank::Direction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
0xFF02 => {
|
||||||
|
if data == 0x81 {
|
||||||
|
print!("{}", self.get(0xFF01) as char);
|
||||||
|
stdout().flush().unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0xFF04 => self.io[addr_l] = 0,
|
||||||
|
0xFF07 => {
|
||||||
|
self.masked_io(addr_l, data, 0b111);
|
||||||
|
}
|
||||||
|
0xFF0F => {
|
||||||
|
self.masked_io(addr_l, data, 0b11111);
|
||||||
|
}
|
||||||
0xFF11 | 0xFF14 | 0xFF16 | 0xFF19 | 0xFF1E | 0xFF23 | 0xFF26 => {
|
0xFF11 | 0xFF14 | 0xFF16 | 0xFF19 | 0xFF1E | 0xFF23 | 0xFF26 => {
|
||||||
// sound
|
// sound
|
||||||
self.io[addr_l] = data;
|
self.io[addr_l] = data;
|
||||||
}
|
}
|
||||||
0xFF41 => {
|
0xFF41 => {
|
||||||
// mixed read/write
|
// mixed read/write
|
||||||
self.io[addr_l] = (self.io[addr_l] & 0b00000111) | (data & 0b11111000)
|
self.masked_io(addr_l, data, 0b01111000);
|
||||||
}
|
}
|
||||||
0xFF4D | 0xFF56 => {
|
0xFF4D | 0xFF56 => {
|
||||||
// cgb only
|
// cgb only
|
||||||
|
@ -259,6 +265,10 @@ impl Memory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn masked_io(&mut self, addr_l: usize, data: u8, mask: u8) {
|
||||||
|
self.io[addr_l] = (self.io[addr_l] & (!mask)) | (data & mask);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update_pressed_keys(&mut self, keys: Vec<Key>) -> bool {
|
pub fn update_pressed_keys(&mut self, keys: Vec<Key>) -> bool {
|
||||||
let old = self.joypad;
|
let old = self.joypad;
|
||||||
self.joypad.down = keys.contains(&Key::Down) || keys.contains(&Key::S);
|
self.joypad.down = keys.contains(&Key::Down) || keys.contains(&Key::S);
|
||||||
|
|
Loading…
Reference in a new issue