now blows up with the hard test. the easy one runs but the rendering is still not done
This commit is contained in:
parent
7436200a6f
commit
fc62512edd
BIN
coraxhard.ch8
Normal file
BIN
coraxhard.ch8
Normal file
Binary file not shown.
@ -53,7 +53,8 @@ impl EmmaGui {
|
|||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
|
|
||||||
println!("PREPARING TO LOAD 1-chip8-logo.ch8");
|
println!("PREPARING TO LOAD 1-chip8-logo.ch8");
|
||||||
let mut input_file = File::open(Path::new("./1-chip8-logo.ch8")).expect("put 1-chip8-logo.ch8 in this directory");
|
// let mut input_file = File::open(Path::new("./1-chip8-logo.ch8")).expect("put 1-chip8-logo.ch8 in this directory");
|
||||||
|
let mut input_file = File::open(Path::new("./coraxhard.ch8")).expect("put 1-chip8-logo.ch8 in this directory");
|
||||||
input_file.read_to_end(&mut buffer).expect("unable to read file");
|
input_file.read_to_end(&mut buffer).expect("unable to read file");
|
||||||
system_to_control.load_bytes_to_memory(0x200, buffer.into());
|
system_to_control.load_bytes_to_memory(0x200, buffer.into());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -545,6 +545,13 @@ impl Chip8CpuInstructions {
|
|||||||
//
|
//
|
||||||
// read nibble bytes from memory starting at I
|
// read nibble bytes from memory starting at I
|
||||||
|
|
||||||
|
let start_position = input.registers.peek_i();
|
||||||
|
let num_bytes_to_read = *n;
|
||||||
|
for i in start_position..start_position + num_bytes_to_read {
|
||||||
|
// let current_byte = input.memory[i as usize];
|
||||||
|
// println!("READ BYTE [{current_byte:8b}");
|
||||||
|
}
|
||||||
|
|
||||||
let mut did_change: bool = false;
|
let mut did_change: bool = false;
|
||||||
|
|
||||||
for draw_x in 0..*n {
|
for draw_x in 0..*n {
|
||||||
@ -582,7 +589,8 @@ impl Chip8CpuInstructions {
|
|||||||
// Set Vx = delay timer value.
|
// Set Vx = delay timer value.
|
||||||
//
|
//
|
||||||
// The value of DT is placed into Vx.
|
// The value of DT is placed into Vx.
|
||||||
input.registers.poke(*x as u8, input.delay_timer.current() as u8);
|
let value_to_set = input.registers.peek(*x as u8);
|
||||||
|
input.delay_timer.set_timer(value_to_set as i32);
|
||||||
}
|
}
|
||||||
Chip8CpuInstructions::LdVxK(x) => {
|
Chip8CpuInstructions::LdVxK(x) => {
|
||||||
// Fx0A - LD Vx, K
|
// Fx0A - LD Vx, K
|
||||||
@ -595,6 +603,7 @@ impl Chip8CpuInstructions {
|
|||||||
// Set delay timer = Vx.
|
// Set delay timer = Vx.
|
||||||
//
|
//
|
||||||
// DT is set equal to the value of Vx.
|
// DT is set equal to the value of Vx.
|
||||||
|
println!("SETTING DELAY TIMER TO [{}]", *new_time);
|
||||||
input.delay_timer.set_timer(*new_time as i32);
|
input.delay_timer.set_timer(*new_time as i32);
|
||||||
}
|
}
|
||||||
Chip8CpuInstructions::LdStVx(new_time) => {
|
Chip8CpuInstructions::LdStVx(new_time) => {
|
||||||
@ -987,17 +996,65 @@ mod test {
|
|||||||
fn RndVxByte_test() {}
|
fn RndVxByte_test() {}
|
||||||
fn DrawVxVyNibble_test() {}
|
fn DrawVxVyNibble_test() {}
|
||||||
fn SkpVx_test() {
|
fn SkpVx_test() {
|
||||||
|
// skip if key pressed
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
fn SnKpVx_test() {
|
fn SnKpVx_test() {
|
||||||
|
// skip key not pressed
|
||||||
|
|
||||||
}
|
}
|
||||||
fn LdVxDt() {
|
#[test]
|
||||||
|
fn LdVxDt_test() {
|
||||||
|
// delay timer reading
|
||||||
|
let mut x = Chip8Computer::new();
|
||||||
|
|
||||||
|
// set the value we want in the timer to V0...
|
||||||
|
Chip8CpuInstructions::LdVxByte(0x0, 0x10).execute(&mut x);
|
||||||
|
// ...then tell the CPU to use that value for the timer.
|
||||||
|
Chip8CpuInstructions::LdVxDt(0x0).execute(&mut x);
|
||||||
|
x.delay_timer.tick();
|
||||||
|
x.delay_timer.tick();
|
||||||
|
x.delay_timer.tick();
|
||||||
|
assert_eq!(x.delay_timer.current(), 0xd);
|
||||||
|
for i in 0..0x10 {
|
||||||
|
x.delay_timer.tick();
|
||||||
|
}
|
||||||
|
assert_eq!(x.delay_timer.current(), 0x00);
|
||||||
|
x.delay_timer.tick();
|
||||||
|
assert_eq!(x.delay_timer.current(), 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn LdVxK_test() {}
|
fn LdVxK_test() {
|
||||||
fn LdStVx_test() {}
|
// Wait for a key press, store the value of the key in Vx.
|
||||||
|
// All execution stops until a key is pressed, then the value of that key is stored in Vx.
|
||||||
|
|
||||||
|
}
|
||||||
|
fn LdStVx_test() {
|
||||||
|
// sound timer setting
|
||||||
|
}
|
||||||
fn LdIVx_test() {}
|
fn LdIVx_test() {}
|
||||||
fn LdVxI_test() {}
|
fn LdVxI_test() {}
|
||||||
}
|
/*
|
||||||
|
#[test]
|
||||||
|
fn LdDtVx_test() {
|
||||||
|
|
||||||
|
// delay timer setting
|
||||||
|
let mut x = Chip8Computer::new();
|
||||||
|
|
||||||
|
// lets set our delay timer...
|
||||||
|
Chip8CpuInstructions::LdVxByte(0x0, 0x80).execute(&mut x);
|
||||||
|
Chip8CpuInstructions::LdDtVx(0x0).execute(&mut x);
|
||||||
|
|
||||||
|
// now that we have our timer set to 0x80 we should tick it 0x10 times
|
||||||
|
// so we are then down to 0x70
|
||||||
|
for i in 0..0x10 {
|
||||||
|
x.delay_timer.tick();
|
||||||
|
}
|
||||||
|
// Then tell the CPU to copy that timer over into our V0
|
||||||
|
Chip8CpuInstructions::LdVxK(0x0).execute(&mut x);
|
||||||
|
let register_value = x.registers.peek(0);
|
||||||
|
// assert_eq!(register_value, 0x70);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user