removed code that was only there to be tested
This commit is contained in:
parent
b4b8bfb24b
commit
128100c54e
90
.idea/workspace.xml
generated
90
.idea/workspace.xml
generated
@ -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">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"Cargo.Build `Run emmagui`.executor": "Run",
|
"Cargo.Build `Run emmagui`.executor": "Run",
|
||||||
|
"Cargo.Build `Run gemmaegui`.executor": "Run",
|
||||||
|
"Cargo.Build `Run gemmaimgui`.executor": "Run",
|
||||||
"Cargo.Build `Run trevors_chip8_toy`.executor": "Run",
|
"Cargo.Build `Run trevors_chip8_toy`.executor": "Run",
|
||||||
"Cargo.Build `Test chip8::computer::test::cls_test`.executor": "Run",
|
"Cargo.Build `Test chip8::computer::test::cls_test`.executor": "Run",
|
||||||
"Cargo.Build `Test chip8::instructions::test::LdStVx_test`.executor": "Run",
|
"Cargo.Build `Test chip8::instructions::test::LdStVx_test`.executor": "Run",
|
||||||
|
"Cargo.Build `Test chip8::instructions::test::random_produces_different_numbers`.executor": "Run",
|
||||||
|
"Cargo.Build `Test chip8::instructions::test::series8xy6_corex_tests`.executor": "Run",
|
||||||
"Cargo.Build `Test chip8::instructions::test::shl_vx_vy_test`.executor": "Run",
|
"Cargo.Build `Test chip8::instructions::test::shl_vx_vy_test`.executor": "Run",
|
||||||
"Cargo.Build `Test chip8::util::test::byte_to_bool_changes`.executor": "Run",
|
"Cargo.Build `Test chip8::util::test::byte_to_bool_changes`.executor": "Run",
|
||||||
"Cargo.Build `Test chip8::util::test::ubln`.executor": "Run",
|
"Cargo.Build `Test chip8::util::test::ubln`.executor": "Run",
|
||||||
"Cargo.Build `Test chip8::video::test::poke_byte_test`.executor": "Run",
|
"Cargo.Build `Test chip8::video::test::poke_byte_test`.executor": "Run",
|
||||||
"Cargo.Build `Test chip8::video::test::poke_byte`.executor": "Run",
|
"Cargo.Build `Test chip8::video::test::poke_byte`.executor": "Run",
|
||||||
"Cargo.Build `Test computer::test`.executor": "Run",
|
"Cargo.Build `Test computer::test`.executor": "Run",
|
||||||
|
"Cargo.Build `Test instructions::test (1)`.executor": "Run",
|
||||||
"Cargo.Build `Test instructions::test`.executor": "Run",
|
"Cargo.Build `Test instructions::test`.executor": "Run",
|
||||||
|
"Cargo.Build gemma.executor": "Run",
|
||||||
"Cargo.Run emmagui.executor": "Run",
|
"Cargo.Run emmagui.executor": "Run",
|
||||||
|
"Cargo.Run gemmaegui.executor": "Debug",
|
||||||
|
"Cargo.Run gemmaimgui.executor": "Debug",
|
||||||
"Cargo.Run trevors_chip8_toy.executor": "Debug",
|
"Cargo.Run trevors_chip8_toy.executor": "Debug",
|
||||||
"Cargo.Test chip8::computer::test::cls_test.executor": "Run",
|
"Cargo.Test chip8::computer::test::cls_test.executor": "Run",
|
||||||
"Cargo.Test chip8::computer::test::decoder_test_valid_instructions.executor": "Run",
|
"Cargo.Test chip8::computer::test::decoder_test_valid_instructions.executor": "Run",
|
||||||
@ -62,7 +69,11 @@
|
|||||||
"Cargo.Test chip8::instructions::test::SneVxVy_test.executor": "Run",
|
"Cargo.Test chip8::instructions::test::SneVxVy_test.executor": "Run",
|
||||||
"Cargo.Test chip8::instructions::test::decoder_test_invalid_instructions.executor": "Run",
|
"Cargo.Test chip8::instructions::test::decoder_test_invalid_instructions.executor": "Run",
|
||||||
"Cargo.Test chip8::instructions::test::draw_nibble_vx_vy_n_test.executor": "Debug",
|
"Cargo.Test chip8::instructions::test::draw_nibble_vx_vy_n_test.executor": "Debug",
|
||||||
"Cargo.Test chip8::instructions::test::encode_decode_test.executor": "Debug",
|
"Cargo.Test chip8::instructions::test::encode_decode_test.executor": "Run",
|
||||||
|
"Cargo.Test chip8::instructions::test::random_produces_different_numbers.executor": "Run",
|
||||||
|
"Cargo.Test chip8::instructions::test::series4000_corex_tests.executor": "Run",
|
||||||
|
"Cargo.Test chip8::instructions::test::series8xy4_corex_tests.executor": "Run",
|
||||||
|
"Cargo.Test chip8::instructions::test::series8xy6_corex_tests.executor": "Run",
|
||||||
"Cargo.Test chip8::instructions::test::shl_vx_vy_test.executor": "Run",
|
"Cargo.Test chip8::instructions::test::shl_vx_vy_test.executor": "Run",
|
||||||
"Cargo.Test chip8::instructions::test::subn_vx_vy_test.executor": "Run",
|
"Cargo.Test chip8::instructions::test::subn_vx_vy_test.executor": "Run",
|
||||||
"Cargo.Test chip8::util::test::bool_to_byte_changes.executor": "Run",
|
"Cargo.Test chip8::util::test::bool_to_byte_changes.executor": "Run",
|
||||||
@ -72,6 +83,7 @@
|
|||||||
"Cargo.Test chip8::video::test::poke_byte_test.executor": "Run",
|
"Cargo.Test chip8::video::test::poke_byte_test.executor": "Run",
|
||||||
"Cargo.Test chip8::video::test::poke_sprite_test.executor": "Debug",
|
"Cargo.Test chip8::video::test::poke_sprite_test.executor": "Debug",
|
||||||
"Cargo.Test computer::test.executor": "Debug",
|
"Cargo.Test computer::test.executor": "Debug",
|
||||||
|
"Cargo.Test instructions::test (1).executor": "Debug",
|
||||||
"Cargo.Test instructions::test.executor": "Debug",
|
"Cargo.Test instructions::test.executor": "Debug",
|
||||||
"Cargo.Test sound_timer::test.executor": "Run",
|
"Cargo.Test sound_timer::test.executor": "Run",
|
||||||
"Cargo.Test util::test.executor": "Run",
|
"Cargo.Test util::test.executor": "Run",
|
||||||
@ -79,7 +91,7 @@
|
|||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.rust.reset.selective.auto.import": "true",
|
"RunOnceActivity.rust.reset.selective.auto.import": "true",
|
||||||
"git-widget-placeholder": "master",
|
"git-widget-placeholder": "master",
|
||||||
"last_opened_file_path": "/home/tmerritt/Projects/trevors_chip8_toy",
|
"last_opened_file_path": "/home/tmerritt/Projects/chip8_toy/gemmaimgui",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
@ -89,9 +101,17 @@
|
|||||||
"settings.editor.selected.configurable": "language.rust.build.tool.cargo"
|
"settings.editor.selected.configurable": "language.rust.build.tool.cargo"
|
||||||
}
|
}
|
||||||
}</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>
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user