removed code that was only there to be tested

This commit is contained in:
Trevor Merritt 2024-10-16 11:57:57 -04:00
parent b4b8bfb24b
commit 128100c54e
3 changed files with 44 additions and 138 deletions

90
.idea/workspace.xml generated
View File

@ -8,8 +8,7 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="9bcba7c5-ac1d-4216-959a-63faee7047bc" name="Changes" comment=""> <list default="true" id="9bcba7c5-ac1d-4216-959a-63faee7047bc" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/gemma/src/chip8/instructions.rs" beforeDir="false" afterPath="$PROJECT_DIR$/gemma/src/chip8/instructions.rs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gemma/tests/computer_tests.rs" beforeDir="false" afterPath="$PROJECT_DIR$/gemma/tests/computer_tests.rs" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -40,17 +39,25 @@
<component name="PropertiesComponent">{ <component name="PropertiesComponent">{
&quot;keyToString&quot;: { &quot;keyToString&quot;: {
&quot;Cargo.Build `Run emmagui`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Run emmagui`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Run gemmaegui`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Run gemmaimgui`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Run trevors_chip8_toy`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Run trevors_chip8_toy`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test chip8::computer::test::cls_test`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Test chip8::computer::test::cls_test`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test chip8::instructions::test::LdStVx_test`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Test chip8::instructions::test::LdStVx_test`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test chip8::instructions::test::random_produces_different_numbers`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test chip8::instructions::test::series8xy6_corex_tests`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test chip8::instructions::test::shl_vx_vy_test`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Test chip8::instructions::test::shl_vx_vy_test`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test chip8::util::test::byte_to_bool_changes`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Test chip8::util::test::byte_to_bool_changes`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test chip8::util::test::ubln`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Test chip8::util::test::ubln`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test chip8::video::test::poke_byte_test`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Test chip8::video::test::poke_byte_test`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test chip8::video::test::poke_byte`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Test chip8::video::test::poke_byte`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test computer::test`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Test computer::test`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test instructions::test (1)`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test instructions::test`.executor&quot;: &quot;Run&quot;, &quot;Cargo.Build `Test instructions::test`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build gemma.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Run emmagui.executor&quot;: &quot;Run&quot;, &quot;Cargo.Run emmagui.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Run gemmaegui.executor&quot;: &quot;Debug&quot;,
&quot;Cargo.Run gemmaimgui.executor&quot;: &quot;Debug&quot;,
&quot;Cargo.Run trevors_chip8_toy.executor&quot;: &quot;Debug&quot;, &quot;Cargo.Run trevors_chip8_toy.executor&quot;: &quot;Debug&quot;,
&quot;Cargo.Test chip8::computer::test::cls_test.executor&quot;: &quot;Run&quot;, &quot;Cargo.Test chip8::computer::test::cls_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::computer::test::decoder_test_valid_instructions.executor&quot;: &quot;Run&quot;, &quot;Cargo.Test chip8::computer::test::decoder_test_valid_instructions.executor&quot;: &quot;Run&quot;,
@ -62,7 +69,11 @@
&quot;Cargo.Test chip8::instructions::test::SneVxVy_test.executor&quot;: &quot;Run&quot;, &quot;Cargo.Test chip8::instructions::test::SneVxVy_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::decoder_test_invalid_instructions.executor&quot;: &quot;Run&quot;, &quot;Cargo.Test chip8::instructions::test::decoder_test_invalid_instructions.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::draw_nibble_vx_vy_n_test.executor&quot;: &quot;Debug&quot;, &quot;Cargo.Test chip8::instructions::test::draw_nibble_vx_vy_n_test.executor&quot;: &quot;Debug&quot;,
&quot;Cargo.Test chip8::instructions::test::encode_decode_test.executor&quot;: &quot;Debug&quot;, &quot;Cargo.Test chip8::instructions::test::encode_decode_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::random_produces_different_numbers.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::series4000_corex_tests.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::series8xy4_corex_tests.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::series8xy6_corex_tests.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::shl_vx_vy_test.executor&quot;: &quot;Run&quot;, &quot;Cargo.Test chip8::instructions::test::shl_vx_vy_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::subn_vx_vy_test.executor&quot;: &quot;Run&quot;, &quot;Cargo.Test chip8::instructions::test::subn_vx_vy_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::util::test::bool_to_byte_changes.executor&quot;: &quot;Run&quot;, &quot;Cargo.Test chip8::util::test::bool_to_byte_changes.executor&quot;: &quot;Run&quot;,
@ -72,6 +83,7 @@
&quot;Cargo.Test chip8::video::test::poke_byte_test.executor&quot;: &quot;Run&quot;, &quot;Cargo.Test chip8::video::test::poke_byte_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::video::test::poke_sprite_test.executor&quot;: &quot;Debug&quot;, &quot;Cargo.Test chip8::video::test::poke_sprite_test.executor&quot;: &quot;Debug&quot;,
&quot;Cargo.Test computer::test.executor&quot;: &quot;Debug&quot;, &quot;Cargo.Test computer::test.executor&quot;: &quot;Debug&quot;,
&quot;Cargo.Test instructions::test (1).executor&quot;: &quot;Debug&quot;,
&quot;Cargo.Test instructions::test.executor&quot;: &quot;Debug&quot;, &quot;Cargo.Test instructions::test.executor&quot;: &quot;Debug&quot;,
&quot;Cargo.Test sound_timer::test.executor&quot;: &quot;Run&quot;, &quot;Cargo.Test sound_timer::test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test util::test.executor&quot;: &quot;Run&quot;, &quot;Cargo.Test util::test.executor&quot;: &quot;Run&quot;,
@ -79,7 +91,7 @@
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.rust.reset.selective.auto.import&quot;: &quot;true&quot;, &quot;RunOnceActivity.rust.reset.selective.auto.import&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;, &quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/tmerritt/Projects/trevors_chip8_toy&quot;, &quot;last_opened_file_path&quot;: &quot;/home/tmerritt/Projects/chip8_toy/gemmaimgui&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;, &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;, &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
@ -89,9 +101,17 @@
&quot;settings.editor.selected.configurable&quot;: &quot;language.rust.build.tool.cargo&quot; &quot;settings.editor.selected.configurable&quot;: &quot;language.rust.build.tool.cargo&quot;
} }
}</component> }</component>
<component name="RunManager" selected="Cargo.Run emmagui"> <component name="RecentsManager">
<configuration name="Run emmagui" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true"> <key name="CopyFile.RECENT_KEYS">
<option name="command" value="run --package emmaemu --bin emmagui" /> <recent name="$PROJECT_DIR$/gemmaimgui" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/gemmaimgui/src/bin" />
</key>
</component>
<component name="RunManager" selected="Cargo.Run gemmaegui">
<configuration name="Run gemmaegui" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="run --package gemmaegui --bin gemmaegui" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" /> <option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs /> <envs />
<option name="emulateTerminal" value="true" /> <option name="emulateTerminal" value="true" />
@ -107,8 +127,8 @@
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" /> <option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method> </method>
</configuration> </configuration>
<configuration name="Test chip8::instructions::test::draw_nibble_vx_vy_n_test" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true"> <configuration name="Run gemmaimgui" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package emmaemu --lib chip8::instructions::test::draw_nibble_vx_vy_n_test -- --exact" /> <option name="command" value="run --package gemmaimgui --bin gemmaimgui" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" /> <option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs /> <envs />
<option name="emulateTerminal" value="true" /> <option name="emulateTerminal" value="true" />
@ -124,42 +144,8 @@
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" /> <option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method> </method>
</configuration> </configuration>
<configuration name="Test chip8::instructions::test::shl_vx_vy_test" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true"> <configuration name="Test chip8::instructions::test::random_produces_different_numbers" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package emmaemu --lib chip8::instructions::test::shl_vx_vy_test -- --exact" /> <option name="command" value="test --package gemma --lib chip8::instructions::test::random_produces_different_numbers -- --exact" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="true" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Test chip8::video::test::poke_byte_test" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package emmaemu --lib chip8::video::test::poke_byte_test -- --exact" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="true" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Test instructions::test" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package emmaemu --lib chip8::instructions::test" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" /> <option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs /> <envs />
<option name="emulateTerminal" value="true" /> <option name="emulateTerminal" value="true" />
@ -177,11 +163,10 @@
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Cargo.Run emmagui" /> <item itemvalue="Cargo.Run gemmaegui" />
<item itemvalue="Cargo.Test chip8::instructions::test::draw_nibble_vx_vy_n_test" /> <item itemvalue="Cargo.Run gemmaimgui" />
<item itemvalue="Cargo.Test chip8::video::test::poke_byte_test" /> <item itemvalue="Cargo.Test chip8::instructions::test::random_produces_different_numbers" />
<item itemvalue="Cargo.Test instructions::test" /> <item itemvalue="Cargo.Run gemmaimgui" />
<item itemvalue="Cargo.Test chip8::instructions::test::shl_vx_vy_test" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
@ -210,6 +195,11 @@
<workItem from="1728340928442" duration="435000" /> <workItem from="1728340928442" duration="435000" />
<workItem from="1728430338491" duration="1663000" /> <workItem from="1728430338491" duration="1663000" />
<workItem from="1728516979775" duration="902000" /> <workItem from="1728516979775" duration="902000" />
<workItem from="1728566900465" duration="5969000" />
<workItem from="1728661808985" duration="57000" />
<workItem from="1728664714687" duration="2580000" />
<workItem from="1728667676967" duration="637000" />
<workItem from="1728672277369" duration="3861000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -674,15 +674,10 @@ impl Chip8CpuInstructions {
// it wraps around to the opposite side of the screen. // it wraps around to the opposite side of the screen.
let source_memory_offset = input.registers.peek_i(); let source_memory_offset = input.registers.peek_i();
let x_offset = input.registers.peek(*x as u8); let x_offset = input.registers.peek(*x);
let y_offset = input.registers.peek(*y as u8); let y_offset = input.registers.peek(*y);
// let target_memory_offset = x_offset as u16 * 64 + y_offset as u16; for byte_index in 0..*n {
let num_bytes_to_read = *n;
let mut did_change = false;
for byte_index in 0..num_bytes_to_read {
let current_byte = input.memory.peek(byte_index as u16 + source_memory_offset); let current_byte = input.memory.peek(byte_index as u16 + source_memory_offset);
let x_offset: u16 = (x_offset + byte_index) as u16 * 64; let x_offset: u16 = (x_offset + byte_index) as u16 * 64;
for bit_index in 0..8 { for bit_index in 0..8 {

View File

@ -50,60 +50,13 @@ impl Chip8Video {
self.memory[effective_address as usize] = xored_value; self.memory[effective_address as usize] = xored_value;
} }
/*
CHATGPT
pub fn poke_byte(&mut self, first_address: u16, to_write: u8) {
let effective_address = first_address as usize % CHIP8_VIDEO_MEMORY;
// Loop through each bit of the byte
for i in 0..8 {
let is_set = (to_write & (0x80 >> i)) != 0;
let address = effective_address + i;
if address < CHIP8_VIDEO_MEMORY {
self.poke(address as u16, is_set);
}
}
}
*/
pub fn poke_byte(&mut self, first_address: u16, to_write: u8) { pub fn poke_byte(&mut self, first_address: u16, to_write: u8) {
for i in (0..8).rev() { for i in (0..8).rev() {
let shifted = ((1 << i) & to_write) >> i; self.poke(first_address + (7 - i), (to_write & (1 << i)) != 0);
//
let target_address = first_address + (7 - i);
let is_set = (to_write & (1 << i)) != 0;
self.poke(target_address, is_set);
} }
} }
/*
MINE
pub fn poke_byte(&mut self, first_address: u16, to_write: u8) {
for i in (0..8).rev() {
let shifted = ((1 << i) & to_write) >> i;
//
let target_address = first_address + (7 - i);
let is_set = shifted == 1;
self.poke(target_address, is_set);
}
}
*/
pub fn poke_sprite(&mut self, first_address: u16, to_write: Vec<u8>) -> Self {
let sprite_length = to_write.len();
for (index, byte) in to_write.iter().enumerate() {
let real_address = index * 64;
self.poke_byte(real_address as u16, *byte);
};
self.to_owned()
}
pub fn format_as_string(self) -> String { pub fn format_as_string(self) -> String {
let mut output = String::new(); let mut output = String::new();
for row in 0..32 { for row in 0..32 {
@ -355,38 +308,6 @@ mod test {
assert!(v.clone().peek(test_offset + 7)); assert!(v.clone().peek(test_offset + 7));
} }
#[test]
fn poke_sprite_test() {
let mut v = Chip8Video::default();
let to_poke = [
0b00000000,
0b11111111,
0b10101010,
0b01010101
];
v.poke_sprite(0x00, to_poke.into());
assert!(v.peek(0x40));
assert!(v.peek(0x41));
assert!(v.peek(0x42));
assert!(v.peek(0x43));
assert!(v.peek(0x44));
assert!(v.peek(0x45));
assert!(v.peek(0x46));
assert!(v.peek(0x47));
// row 3 column 1
assert!(!v.peek(0xC0));
assert!(v.peek(0xC1));
assert!(!v.peek(0xC2));
assert!(v.peek(0xC3));
assert!(!v.peek(0xC4));
assert!(v.peek(0xC5));
assert!(!v.peek(0xC6));
assert!(v.peek(0xC7));
}
#[test] #[test]
fn verify_change_registered() { fn verify_change_registered() {
let mut v = Chip8Video::default(); let mut v = Chip8Video::default();