From fc62512edd4d8cebf53b8f4b437543efd5a81c67 Mon Sep 17 00:00:00 2001 From: Trevor Merritt Date: Thu, 26 Sep 2024 13:21:19 -0400 Subject: [PATCH] now blows up with the hard test. the easy one runs but the rendering is still not done --- coraxhard.ch8 | Bin 0 -> 761 bytes emma/src/bin/support/emmagui_support.rs | 3 +- emma/src/chip8/instructions.rs | 67 ++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 coraxhard.ch8 diff --git a/coraxhard.ch8 b/coraxhard.ch8 new file mode 100644 index 0000000000000000000000000000000000000000..9fc874c917a5a6957c4affe5ac285211abb749b2 GIT binary patch literal 761 zcmY+?KZw&%7y$6sn)b9Elu|?#G~D3OF1ZLnyd?@Yt4sHsnxucAV>u8sE(r%6T-=WO zB430%IN=}%-f$3y8ywuvo1TM%pmG)L;!wZuHIdwsy!^iJeeZi8Y1Hfz`(>9K@0jT6 z!|O0RNqYC-4?fHN>YzR>IW4yh2PX;q{E|Ryv>`f8hE+JsBzo9_7^MzJxpZwQSKv68 z@uDNMo>ky;Zm(q)%3daM;}zBJHTqWvH-;tHU%Jg!%MhE4Vwk;y`jt8{%MfWy+9$Lf zw8&|BEPQ0;XOZubyLGP>Zdh&V3u}rh4~ z-Xwf_Zr4%fo1tU1T4$p+IGsJU*@iaj!t~5}$>7ZyWoww7PmS{EW>a@-e&@G?lPfj#wF^yMUuo*7 z_cLXvRn&@9rJxwm71ZSfsot_%Wqwo6^gD|DL)^u { // Fx0A - LD Vx, K @@ -595,6 +603,7 @@ impl Chip8CpuInstructions { // Set delay timer = 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); } Chip8CpuInstructions::LdStVx(new_time) => { @@ -987,17 +996,65 @@ mod test { fn RndVxByte_test() {} fn DrawVxVyNibble_test() {} fn SkpVx_test() { + // skip if key pressed + } 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 LdStVx_test() {} + fn LdVxK_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 LdVxI_test() {} -} \ No newline at end of file +/* + #[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); + } + */ +}