weekend work

This commit is contained in:
Trevor Merritt 2024-11-04 10:38:46 -05:00
parent 5663123f81
commit 434cf92414
29 changed files with 564 additions and 654 deletions

5
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,5 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

317
.idea/workspace.xml generated
View File

@ -1,317 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="ALL" />
</component>
<component name="CargoProjects">
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
</component>
<component name="ChangeListManager">
<<<<<<< Updated upstream
<list default="true" id="9bcba7c5-ac1d-4216-959a-63faee7047bc" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/gemma/src/chip8/video.rs" beforeDir="false" afterPath="$PROJECT_DIR$/gemma/src/chip8/video.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gemmaimgui/src/bin/support/emmagui_support.rs" beforeDir="false" afterPath="$PROJECT_DIR$/gemmaimgui/src/bin/support/emmagui_support.rs" afterDir="false" />
</list>
=======
<list default="true" id="9bcba7c5-ac1d-4216-959a-63faee7047bc" name="Changes" comment="" />
>>>>>>> Stashed changes
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Rust File" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MacroExpansionManager">
<option name="directoryName" value="0idvlgji" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 8
}</component>
<component name="ProjectId" id="2lWbraarISJOe7BUvwdyYSG4lax" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Cargo.Build `Run emmagui`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Run gemmaegui_viewer`.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 `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::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::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::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::scroll_down_1_row_test`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test computer::test`.executor&quot;: &quot;Run&quot;,
<<<<<<< Updated upstream
&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 video::test`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build gemma.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Run ch8asm.executor&quot;: &quot;Run&quot;,
=======
&quot;Cargo.Build `Test computer_dump_registers_to_string`.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_name_tests`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build `Test video::test`.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Build gemma.executor&quot;: &quot;Run&quot;,
>>>>>>> Stashed changes
&quot;Cargo.Run emmagui.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Run gemmaegui.executor&quot;: &quot;Debug&quot;,
&quot;Cargo.Run gemmaegui_viewer.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;,
<<<<<<< Updated upstream
&quot;Cargo.Test ch8asm::test.executor&quot;: &quot;Debug&quot;,
=======
>>>>>>> Stashed changes
&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::instructions::test::LdStVx_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::LdVxDt_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::LdiAddr_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::RndVxByte_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::instructions::test::ShrVxVy_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::draw_nibble_vx_vy_n_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::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::byte_to_bool_changes.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::util::test::ubln.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::video::test::poke_byte.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::reset_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::video::test::scroll_down_10_row_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::video::test::scroll_down_1_row_test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test chip8::video::test::write_checkboard.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test computer::test.executor&quot;: &quot;Debug&quot;,
<<<<<<< Updated upstream
&quot;Cargo.Test instruction_tests.executor&quot;: &quot;Run&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 computer_dump_registers_to_string.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test encode_decode_name_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_name_tests.executor&quot;: &quot;Run&quot;,
>>>>>>> Stashed changes
&quot;Cargo.Test sound_timer::test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test util::test.executor&quot;: &quot;Run&quot;,
&quot;Cargo.Test video::test.executor&quot;: &quot;Debug&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.rust.reset.selective.auto.import&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&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.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;org.rust.cargo.project.model.PROJECT_DISCOVERY&quot;: &quot;true&quot;,
&quot;org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon&quot;: &quot;&quot;,
&quot;org.rust.first.attach.projects&quot;: &quot;true&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;advanced.settings&quot;
},
&quot;keyToStringList&quot;: {
&quot;com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File&quot;: [
&quot;TEXT&quot;
]
}
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/gemmaimgui" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/resources/schip_font" />
<recent name="$PROJECT_DIR$/gemmautil/src" />
<recent name="$PROJECT_DIR$/gemmaimgui/src/bin" />
</key>
</component>
<component name="RunManager" selected="Cargo.Run gemmaimgui">
<configuration name="Run ch8asm" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="run --package gemmautil --bin ch8asm" />
<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="Run gemmaimgui" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="run --package gemmaimgui --bin gemmaimgui" />
<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 ch8asm::test" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package gemmautil --bin ch8asm test" />
<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 instruction_tests" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package gemma --test instruction_tests" />
<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 video::test" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package gemma --lib chip8::video::test" />
<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>
<recent_temporary>
<list>
<item itemvalue="Cargo.Run gemmaimgui" />
<item itemvalue="Cargo.Test instruction_tests" />
<item itemvalue="Cargo.Test ch8asm::test" />
<item itemvalue="Cargo.Run ch8asm" />
<item itemvalue="Cargo.Test video::test" />
</list>
</recent_temporary>
</component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="9bcba7c5-ac1d-4216-959a-63faee7047bc" name="Changes" comment="" />
<created>1725298979064</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1725298979064</updated>
<workItem from="1725298980124" duration="3266000" />
<workItem from="1725303630898" duration="12000" />
<workItem from="1727131542697" duration="7568000" />
<workItem from="1727378878624" duration="3739000" />
<workItem from="1727387040213" duration="747000" />
<workItem from="1727453497186" duration="42000" />
<workItem from="1727462825027" duration="12845000" />
<workItem from="1727553854364" duration="5720000" />
<workItem from="1728070957648" duration="8635000" />
<workItem from="1728140555847" duration="18000" />
<workItem from="1728218199415" duration="9235000" />
<workItem from="1728340928442" duration="435000" />
<workItem from="1728430338491" duration="1663000" />
<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" />
<workItem from="1729266677612" duration="4335000" />
<workItem from="1729274179500" duration="3149000" />
<workItem from="1729353568282" duration="4624000" />
<workItem from="1729375372050" duration="3579000" />
<workItem from="1729797802231" duration="9220000" />
<<<<<<< Updated upstream
<workItem from="1729992186995" duration="4475000" />
<workItem from="1730040713781" duration="2808000" />
<workItem from="1730065968935" duration="6000" />
=======
<workItem from="1729992186995" duration="4226000" />
<workItem from="1730115460078" duration="31140000" />
>>>>>>> Stashed changes
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnknownFeatures">
<option featureType="com.intellij.fileTypeFactory" implementationName="*.asc" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/emma/src/chip8/system_memory.rs</url>
<line>46</line>
<option name="timeStamp" value="2" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/trevors_chip8_toy$Test_video__test.info" NAME="Test video::test Coverage Results" MODIFIED="1728072993962" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="RsCoverageRunner" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" CONTEXT_FILE_PATH="$PROJECT_DIR$" />
</component>
</project>

83
.vscode/launch.json vendored
View File

@ -1,83 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'trevors_chip8_toy'",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=trevors_chip8_toy"
],
"filter": {
"name": "trevors_chip8_toy",
"kind": "lib"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'trevors_chip8_toy'",
"cargo": {
"args": [
"build",
"--bin=trevors_chip8_toy",
"--package=trevors_chip8_toy"
],
"filter": {
"name": "trevors_chip8_toy",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'trevors_chip8_toy'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=trevors_chip8_toy",
"--package=trevors_chip8_toy"
],
"filter": {
"name": "trevors_chip8_toy",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'trevors_chip8_core'",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=trevors_chip8_core"
],
"filter": {
"name": "trevors_chip8_core",
"kind": "lib"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}

245
Cargo.lock generated
View File

@ -50,9 +50,9 @@ dependencies = [
[[package]]
name = "accesskit_macos"
version = "0.17.3"
version = "0.17.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49509c722e8da39e6c569f7d13ec51620208988913e738abbc67e3c65f06e6d5"
checksum = "bfc6c1ecd82053d127961ad80a8beaa6004fb851a3a5b96506d7a6bd462403f6"
dependencies = [
"accesskit",
"accesskit_consumer",
@ -96,9 +96,9 @@ dependencies = [
[[package]]
name = "accesskit_winit"
version = "0.22.3"
version = "0.22.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9987e852fe7e4e5a493f8c8af0b729b47da2750f0dea10a4c8984fe1117ebaec"
checksum = "aea3522719f1c44564d03e9469a8e2f3a98b3a8a880bd66d0789c6b9c4a669dd"
dependencies = [
"accesskit",
"accesskit_macos",
@ -228,9 +228,9 @@ dependencies = [
[[package]]
name = "anstream"
version = "0.6.15"
version = "0.6.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338"
dependencies = [
"anstyle",
"anstyle-parse",
@ -243,43 +243,43 @@ dependencies = [
[[package]]
name = "anstyle"
version = "1.0.8"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "anstyle-parse"
version = "0.2.5"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.1"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.4"
version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
dependencies = [
"anstyle",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
name = "anyhow"
version = "1.0.89"
version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13"
[[package]]
name = "arboard"
@ -434,7 +434,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -469,7 +469,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -656,7 +656,7 @@ checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -673,9 +673,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "bytes"
version = "1.7.2"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3"
checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da"
[[package]]
name = "calloop"
@ -728,7 +728,7 @@ dependencies = [
"calloop 0.12.4",
"rustix",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-client 0.31.7",
]
[[package]]
@ -740,7 +740,7 @@ dependencies = [
"calloop 0.13.0",
"rustix",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-client 0.31.7",
]
[[package]]
@ -754,9 +754,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.1.30"
version = "1.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945"
checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9"
dependencies = [
"jobserver",
"libc",
@ -847,7 +847,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -948,9 +948,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "colorchoice"
version = "1.0.2"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "com"
@ -1503,7 +1503,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1618,9 +1618,9 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
[[package]]
name = "fdeflate"
version = "0.3.5"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8090f921a24b04994d9929e204f50b498a33ea6ba559ffaa05e04f7ee7fb5ab"
checksum = "07c6f4c64c1d33a3111c4466f7365ebdcc37c5bd1ea0d62aae2e3d722aacbedb"
dependencies = [
"simd-adler32",
]
@ -1668,7 +1668,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1728,9 +1728,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
[[package]]
name = "futures-lite"
version = "2.3.0"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5"
checksum = "3f1fa2f9765705486b33fd2acf1577f8ec449c2ba1f318ae5447697b7c08d210"
dependencies = [
"fastrand",
"futures-core",
@ -1747,7 +1747,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -1784,10 +1784,15 @@ name = "gemma"
version = "0.1.0"
dependencies = [
"chrono",
"clap",
"dimensioned",
"flate2",
"hex",
"log",
"pretty_env_logger",
"rand 0.9.0-alpha.2",
"serde",
"serde_json",
]
[[package]]
@ -2351,9 +2356,9 @@ dependencies = [
[[package]]
name = "immutable-chunkmap"
version = "2.0.5"
version = "2.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4419f022e55cc63d5bbd6b44b71e1d226b9c9480a47824c706e9d54e5c40c5eb"
checksum = "12f97096f508d54f8f8ab8957862eee2ccd628847b6217af1a335e1c44dee578"
dependencies = [
"arrayvec 0.7.6",
]
@ -2397,6 +2402,12 @@ version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itoa"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "jni"
version = "0.21.1"
@ -2477,9 +2488,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
version = "0.2.160"
version = "0.2.161"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0b21006cd1874ae9e650973c565615676dc4a274c965bb0a73796dac838ce4f"
checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
[[package]]
name = "libloading"
@ -2894,7 +2905,7 @@ dependencies = [
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -3260,7 +3271,7 @@ dependencies = [
"pest_meta",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -3276,29 +3287,29 @@ dependencies = [
[[package]]
name = "pin-project"
version = "1.1.6"
version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec"
checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.1.6"
version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8"
checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
name = "pin-project-lite"
version = "0.2.14"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff"
[[package]]
name = "pin-utils"
@ -3415,9 +3426,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.88"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9"
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
dependencies = [
"unicode-ident",
]
@ -3587,9 +3598,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.11.0"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
@ -3634,9 +3645,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustix"
version = "0.38.37"
version = "0.38.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a"
dependencies = [
"bitflags 2.6.0",
"errno",
@ -3645,6 +3656,12 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "ryu"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
[[package]]
name = "safe_arch"
version = "0.5.2"
@ -3745,22 +3762,34 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.210"
version = "1.0.214"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.210"
version = "1.0.214"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
name = "serde_json"
version = "1.0.132"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
]
[[package]]
@ -3771,7 +3800,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -3897,9 +3926,9 @@ dependencies = [
"rustix",
"thiserror",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-client 0.31.7",
"wayland-csd-frame",
"wayland-cursor 0.31.6",
"wayland-cursor 0.31.7",
"wayland-protocols 0.31.2",
"wayland-protocols-wlr 0.2.0",
"wayland-scanner 0.31.5",
@ -3922,11 +3951,11 @@ dependencies = [
"rustix",
"thiserror",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-client 0.31.7",
"wayland-csd-frame",
"wayland-cursor 0.31.6",
"wayland-protocols 0.32.4",
"wayland-protocols-wlr 0.3.4",
"wayland-cursor 0.31.7",
"wayland-protocols 0.32.5",
"wayland-protocols-wlr 0.3.5",
"wayland-scanner 0.31.5",
"xkeysym",
]
@ -4007,9 +4036,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.79"
version = "2.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
dependencies = [
"proc-macro2",
"quote",
@ -4046,22 +4075,22 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.64"
version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.64"
version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
checksum = "b08be0f17bd307950653ce45db00cd31200d82b624b36e181337d9c7d92765b5"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -4187,7 +4216,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -4349,7 +4378,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
"wasm-bindgen-shared",
]
@ -4383,7 +4412,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -4426,9 +4455,9 @@ dependencies = [
[[package]]
name = "wayland-client"
version = "0.31.6"
version = "0.31.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3f45d1222915ef1fd2057220c1d9d9624b7654443ea35c3877f7a52bd0a5a2d"
checksum = "b66249d3fc69f76fd74c82cc319300faa554e9d865dab1f7cd66cc20db10b280"
dependencies = [
"bitflags 2.6.0",
"rustix",
@ -4472,12 +4501,12 @@ dependencies = [
[[package]]
name = "wayland-cursor"
version = "0.31.6"
version = "0.31.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a94697e66e76c85923b0d28a0c251e8f0666f58fc47d316c0f4da6da75d37cb"
checksum = "32b08bc3aafdb0035e7fe0fdf17ba0c09c268732707dca4ae098f60cb28c9e4c"
dependencies = [
"rustix",
"wayland-client 0.31.6",
"wayland-client 0.31.7",
"xcursor",
]
@ -4501,19 +4530,19 @@ checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4"
dependencies = [
"bitflags 2.6.0",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-client 0.31.7",
"wayland-scanner 0.31.5",
]
[[package]]
name = "wayland-protocols"
version = "0.32.4"
version = "0.32.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b5755d77ae9040bb872a25026555ce4cb0ae75fd923e90d25fba07d81057de0"
checksum = "7cd0ade57c4e6e9a8952741325c30bf82f4246885dca8bf561898b86d0c1f58e"
dependencies = [
"bitflags 2.6.0",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-client 0.31.7",
"wayland-scanner 0.31.5",
]
@ -4525,21 +4554,21 @@ checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479"
dependencies = [
"bitflags 2.6.0",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-client 0.31.7",
"wayland-protocols 0.31.2",
"wayland-scanner 0.31.5",
]
[[package]]
name = "wayland-protocols-plasma"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a0a41a6875e585172495f7a96dfa42ca7e0213868f4f15c313f7c33221a7eff"
checksum = "9b31cab548ee68c7eb155517f2212049dc151f7cd7910c2b66abfd31c3ee12bd"
dependencies = [
"bitflags 2.6.0",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-protocols 0.32.4",
"wayland-client 0.31.7",
"wayland-protocols 0.32.5",
"wayland-scanner 0.31.5",
]
@ -4551,21 +4580,21 @@ checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6"
dependencies = [
"bitflags 2.6.0",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-client 0.31.7",
"wayland-protocols 0.31.2",
"wayland-scanner 0.31.5",
]
[[package]]
name = "wayland-protocols-wlr"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dad87b5fd1b1d3ca2f792df8f686a2a11e3fe1077b71096f7a175ab699f89109"
checksum = "782e12f6cd923c3c316130d56205ebab53f55d6666b7faddfad36cecaeeb4022"
dependencies = [
"bitflags 2.6.0",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-protocols 0.32.4",
"wayland-client 0.31.7",
"wayland-protocols 0.32.5",
"wayland-scanner 0.31.5",
]
@ -4865,7 +4894,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -4876,7 +4905,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -5227,7 +5256,7 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-client 0.31.7",
"wayland-protocols 0.31.2",
"wayland-protocols-plasma 0.2.0",
"web-sys",
@ -5279,9 +5308,9 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"wayland-backend",
"wayland-client 0.31.6",
"wayland-protocols 0.32.4",
"wayland-protocols-plasma 0.3.4",
"wayland-client 0.31.7",
"wayland-protocols 0.32.5",
"wayland-protocols-plasma 0.3.5",
"web-sys",
"web-time 1.1.0",
"windows-sys 0.52.0",
@ -5477,7 +5506,7 @@ checksum = "709ab20fc57cb22af85be7b360239563209258430bccf38d8b979c5a2ae3ecce"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
"zbus-lockstep",
"zbus_xml",
"zvariant",
@ -5492,7 +5521,7 @@ dependencies = [
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
"zvariant_utils",
]
@ -5538,7 +5567,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]
[[package]]
@ -5563,7 +5592,7 @@ dependencies = [
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
"zvariant_utils",
]
@ -5575,5 +5604,5 @@ checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn 2.0.87",
]

View File

@ -1,13 +1,23 @@
[workspace]
members = ["gemma", "gemmaegui", "gemmaimgui", "gemmatelnet", "gemmasdl2", "gemmautil" ]
members = [
"gemma",
"gemmaegui",
"gemmaimgui",
"gemmatelnet",
"gemmasdl2",
"gemmautil",
]
resolver = "2"
[workspace.dependencies]
pretty_env_logger = { version = "0.5.0" }
log = { version = "0.4.22" }
pretty_env_logger = { version = "0.5" }
log = { version = "0.4" }
rand = { version = "0.9.0-alpha.2" }
chrono = { version = "0.4.38" }
dimensioned = { version = "0.8.0" }
chrono = { version = "0.4" }
dimensioned = { version = "0.8" }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
clap = { version = "4.5", features = ["derive"] }
# EGUI
egui = { version = "0.29" }

File diff suppressed because one or more lines are too long

View File

@ -11,3 +11,8 @@ log.workspace = true
# beep = "0.3.0"
chrono.workspace = true
dimensioned.workspace = true
serde.workspace = true
serde_json.workspace = true
flate2 = "1.0"
clap = { version = "4.5.20", features = ["derive"] }
hex = "0.4.3"

View File

@ -0,0 +1,57 @@
use clap::{Parser, Subcommand};
use flate2::{write::{GzEncoder, GzDecoder}, Compression};
use std::io::prelude::*;
use std::io::{self, Write};
#[derive(Parser)]
#[command(author, version, about = "Compress or decompress a string", long_about = None)]
struct Cli {
/// Subcommand: either 'compress' or 'decompress'
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
/// Compress the input string
Compress {
/// The string to compress
input: String,
},
/// Decompress the input string (must be compressed format)
Decompress {
/// The compressed string to decompress, in hex format
input: String,
},
}
fn compress_string(input: &str) -> Vec<u8> {
let mut encoder = GzEncoder::new(Vec::new(), Compression::default());
encoder.write_all(input.as_bytes()).expect("Compression failed");
encoder.finish().expect("Failed to finish compression")
}
fn decompress_string(input: &[u8]) -> String {
let mut decoder = GzDecoder::new(Vec::new());
decoder.write_all(input).expect("Decompression failed");
let decompressed_data = decoder.finish().expect("Failed to finish decompression");
String::from_utf8(decompressed_data).expect("Invalid UTF-8")
}
fn main() {
let cli = Cli::parse();
match cli.command {
Commands::Compress { input } => {
let compressed = compress_string(&input);
// Convert to hex format for easier readability in the terminal
println!("Compressed (hex): {:?} / from {}b to {}b", hex::encode(compressed.clone()), input.len(), compressed.len());
}
Commands::Decompress { input } => {
// Decode hex string back to bytes
let compressed_bytes = hex::decode(input).expect("Invalid hex input");
let decompressed = decompress_string(&compressed_bytes);
println!("Decompressed: {}", decompressed);
}
}
}

View File

@ -1,16 +1,18 @@
use log::{debug};
use crate::chip8::delay_timer::DelayTimer;
use crate::chip8::keypad::Keypad;
use crate::chip8::quirk_modes::QuirkMode;
use crate::chip8::registers::Chip8Registers;
use crate::chip8::sound_timer::SoundTimer;
use crate::chip8::stack::Chip8Stack;
use log::debug;
use serde::{Deserialize, Serialize};
use super::{
cpu_states::Chip8CpuStates, instructions::Chip8CpuInstructions, system_memory::Chip8SystemMemory, video::Chip8Video,
cpu_states::Chip8CpuStates, instructions::Chip8CpuInstructions,
system_memory::Chip8SystemMemory, video::Chip8Video,
};
#[derive(Clone)]
#[derive(Clone, Serialize, Deserialize)]
pub struct Chip8Computer {
pub num_cycles: i32,
pub memory: Chip8SystemMemory,
@ -21,7 +23,7 @@ pub struct Chip8Computer {
pub state: Chip8CpuStates,
pub keypad: Keypad,
pub stack: Chip8Stack,
pub quirk_mode: QuirkMode
pub quirk_mode: QuirkMode,
}
impl Default for Chip8Computer {
fn default() -> Self {
@ -35,7 +37,7 @@ impl Default for Chip8Computer {
state: Chip8CpuStates::default(),
keypad: Keypad::default(),
stack: Chip8Stack::default(),
quirk_mode: QuirkMode::default()
quirk_mode: QuirkMode::default(),
}
}
}
@ -100,8 +102,7 @@ impl Chip8Computer {
let high_byte = (local_memory.peek(start_pc) as u16).rotate_left(8);
let low_byte = local_memory.peek(start_pc + 1) as u16;
let result = high_byte | low_byte;
let decoded_instruction =
Chip8CpuInstructions::decode(result, &self.quirk_mode);
let decoded_instruction = Chip8CpuInstructions::decode(result, &self.quirk_mode);
// todo: THIS IS BAD AND IS A SIDE EFFECT
decoded_instruction.execute(self);

View File

@ -1,4 +1,6 @@
#[derive(Clone, Copy, Default)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Default, Serialize, Deserialize)]
pub enum Chip8CpuStates {
#[default]
WaitingForInstruction,
@ -6,4 +8,3 @@ pub enum Chip8CpuStates {
ExecutingInstruction,
Error,
}

View File

@ -1,6 +1,8 @@
#[derive(Clone, Copy)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Serialize, Deserialize)]
pub struct DelayTimer {
counter: u8
counter: u8,
}
impl Default for DelayTimer {
@ -15,9 +17,7 @@ impl DelayTimer {
}
pub fn new() -> Self {
DelayTimer {
counter: 0xff
}
DelayTimer { counter: 0xff }
}
pub fn reset(&mut self) {

View File

@ -6,6 +6,7 @@ use crate::chip8::util::InstructionUtil;
use crate::constants::*;
use log::debug;
use rand::Rng;
use serde::{Deserialize, Serialize};
use std::fmt::{Debug, Display, Formatter};
use std::ops::BitAnd;
use std::time::Instant;
@ -18,7 +19,7 @@ y - A 4-bit value, the upper 4 bits of the low byte of the instruction
kk or byte - An 8-bit value, the lowest 8 bits of the instruction
*/
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Chip8CpuInstructions {
/// 0nnn
/// Exit to System Call at nnn

View File

@ -1,7 +1,8 @@
use serde::{Deserialize, Serialize};
use crate::constants::CHIP8_KEYBOARD;
#[derive(Clone, Copy)]
#[derive(Default)]
#[derive(Clone, Copy, Default, Serialize, Deserialize)]
pub struct Keypad {
keys: [bool; 0x10],
}
@ -20,7 +21,6 @@ impl Keypad {
if index == 3 {
return_value += format!("|{}|\n", is_lit).as_str();
} else {
return_value += format!("|{}", is_lit).as_str();
}
@ -31,7 +31,6 @@ impl Keypad {
}
}
impl Keypad {
pub fn push_key(&mut self, key_index: u8) {
self.keys[key_index as usize] = true;

View File

@ -1,7 +1,9 @@
#[derive(Default, Clone)]
use serde::{Deserialize, Serialize};
#[derive(Default, Clone, Serialize, Deserialize)]
pub enum QuirkMode {
#[default]
Chip8,
XOChip,
SChipModern
SChipModern,
}

View File

@ -1,6 +1,8 @@
use serde::{Deserialize, Serialize};
/// Registers. numbered 1-16 publicly.
/// Privately using zero base array so -1 to shift from pub to priv.
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Serialize, Deserialize)]
pub struct Chip8Registers {
pub registers: [u8; 16],
pub i_register: u16,

View File

@ -1,8 +1,9 @@
use log::trace;
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Serialize, Deserialize)]
pub struct SoundTimer {
counter: i32
counter: i32,
}
impl Default for SoundTimer {
@ -16,9 +17,7 @@ impl SoundTimer {
self.counter
}
pub fn new() -> Self {
SoundTimer {
counter: 0
}
SoundTimer { counter: 0 }
}
pub fn set_timer(&mut self, new_value: i32) {
trace!("SETTING SOUND TIMER TO {new_value}");
@ -26,7 +25,11 @@ impl SoundTimer {
}
pub fn tick(&mut self) {
trace!("TICKING SOUND FROM {} to {}", self.counter, self.counter - 1);
trace!(
"TICKING SOUND FROM {} to {}",
self.counter,
self.counter - 1
);
if self.counter > 0 {
self.counter -= 1;
/*

View File

@ -1,9 +1,9 @@
#[derive(Clone)]
#[derive(Default)]
pub struct Chip8Stack {
items: Vec<u16>
}
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Serialize, Deserialize)]
pub struct Chip8Stack {
items: Vec<u16>,
}
impl Chip8Stack {
pub fn push(&mut self, new_value: &u16) {
@ -11,7 +11,7 @@ impl Chip8Stack {
// println!("Deep deep stack?");
panic!("Stack Overflow");
}
self.items.push(*new_value );
self.items.push(*new_value);
}
pub fn pop(&mut self) -> u16 {
if self.items.is_empty() {
@ -24,9 +24,7 @@ impl Chip8Stack {
}
pub fn new() -> Self {
Chip8Stack {
items: vec![]
}
Chip8Stack { items: vec![] }
}
pub fn reset(&mut self) {

View File

@ -1,18 +1,17 @@
use log::{trace};
use log::trace;
use crate::constants::*;
use serde::Deserialize;
use serde::Serialize;
#[derive(Clone, Copy)]
#[derive(Clone, Serialize, Deserialize)]
pub struct Chip8SystemMemory {
memory: [u8; CHIP8_MEMORY_SIZE as usize],
memory: Vec<u8>,
}
impl Default for Chip8SystemMemory {
fn default() -> Self {
let mut x = Chip8SystemMemory {
memory: [0x00; CHIP8_MEMORY_SIZE as usize],
};
let mut x = Chip8SystemMemory::new();
x.load_fonts_to_memory();
x.load_schip_fonts_to_memory();
@ -20,27 +19,44 @@ impl Default for Chip8SystemMemory {
}
}
impl Chip8SystemMemory {
fn empty_memory() -> Vec<u8> {
let mut working_memory = vec![];
pub fn reset(&mut self){
self.memory = [0x00; CHIP8_MEMORY_SIZE as usize];
for _ in 0..CHIP8_MEMORY_SIZE {
working_memory.push(0x00);
}
working_memory
}
pub fn reset(&mut self) {
self.memory = Chip8SystemMemory::empty_memory();
self.load_fonts_to_memory();
self.load_schip_fonts_to_memory();
}
pub fn new() -> Self {
Chip8SystemMemory {
memory: [0x00; CHIP8_MEMORY_SIZE as usize],
memory: Chip8SystemMemory::empty_memory(),
}
}
pub fn peek(&self, address: u16) -> u8 {
trace!("PEEK: {} / {}", address, self.memory[address as usize].clone());
trace!(
"PEEK: {} / {}",
address,
self.memory[address as usize].clone()
);
let effective = address as i32 % CHIP8_MEMORY_SIZE;
self.memory[effective as usize]
}
pub fn poke(&mut self, address: u16, value: u8) {
trace!("POKE: {} / {} to {}", address, self.memory[address as usize], value);
trace!(
"POKE: {} / {} to {}",
address,
self.memory[address as usize],
value
);
self.memory[address as usize] = value;
}
@ -80,10 +96,22 @@ impl Chip8SystemMemory {
pub fn load_schip_fonts_to_memory(&mut self) {
let all_font_characters = [
SCHIPFONT_0, SCHIPFONT_1, SCHIPFONT_2, SCHIPFONT_3,
SCHIPFONT_4, SCHIPFONT_5, SCHIPFONT_6, SCHIPFONT_7,
SCHIPFONT_8, SCHIPFONT_9, SCHIPFONT_A, SCHIPFONT_B,
SCHIPFONT_C, SCHIPFONT_D, SCHIPFONT_E, SCHIPFONT_F
SCHIPFONT_0,
SCHIPFONT_1,
SCHIPFONT_2,
SCHIPFONT_3,
SCHIPFONT_4,
SCHIPFONT_5,
SCHIPFONT_6,
SCHIPFONT_7,
SCHIPFONT_8,
SCHIPFONT_9,
SCHIPFONT_A,
SCHIPFONT_B,
SCHIPFONT_C,
SCHIPFONT_D,
SCHIPFONT_E,
SCHIPFONT_F,
];
for (font_index, current_font) in all_font_characters.iter().enumerate() {
let base_offset = 0x100;

View File

@ -1,14 +1,18 @@
use log::{debug};
use crate::chip8::video::Chip8VideoModes::{HighRes, LowRes};
use crate::constants::{CHIP8_VIDEO_HEIGHT, CHIP8_VIDEO_MEMORY, CHIP8_VIDEO_WIDTH, SCHIP_VIDE_MEMORY, SCHIP_VIDEO_HEIGHT, SCHIP_VIDEO_WIDTH};
use crate::constants::{
CHIP8_VIDEO_HEIGHT, CHIP8_VIDEO_MEMORY, CHIP8_VIDEO_WIDTH, SCHIP_VIDEO_HEIGHT,
SCHIP_VIDEO_WIDTH, SCHIP_VIDE_MEMORY,
};
use log::debug;
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Serialize, Deserialize)]
pub enum Chip8VideoModes {
LowRes,
HighRes,
}
#[derive(Clone)]
#[derive(Clone, Serialize, Deserialize)]
pub struct Chip8Video {
memory: Vec<bool>,
pub has_frame_changed: bool,
@ -42,12 +46,8 @@ impl Chip8Video {
pub fn cls(&mut self) {
self.memory.clear();
let num_loops = match self.current_res {
LowRes => {
CHIP8_VIDEO_MEMORY
}
HighRes => {
SCHIP_VIDE_MEMORY
}
LowRes => CHIP8_VIDEO_MEMORY,
HighRes => SCHIP_VIDE_MEMORY,
};
for i in 0..num_loops {
self.memory.push(false);
@ -74,7 +74,9 @@ impl Chip8Video {
};
let effective_address = if address >= loop_value {
address % loop_value
} else { address };
} else {
address
};
self.memory[effective_address as usize]
}
@ -103,7 +105,10 @@ impl Chip8Video {
pub fn poke_2byte(&mut self, first_address: u16, to_write: [u8; 2]) {
for (idx, _) in to_write.iter().enumerate() {
for i in (0..8).rev() {
self.poke(first_address + (idx * 8) as u16 + (7 - i), (to_write[idx] & (1 << i)) != 0);
self.poke(
first_address + (idx * 8) as u16 + (7 - i),
(to_write[idx] & (1 << i)) != 0,
);
}
}
}
@ -115,7 +120,10 @@ impl Chip8Video {
for row in 0..height {
for column in 0..width {
let data_offset = row * width + column;
debug!("Rendering {data_offset} with value {}", self.memory[data_offset as usize]);
debug!(
"Rendering {data_offset} with value {}",
self.memory[data_offset as usize]
);
if self.memory[data_offset as usize] {
output += "*"
} else {
@ -200,7 +208,6 @@ impl Chip8Video {
self.memory[clear_start..].fill(false);
}
pub fn scroll_down(&mut self, how_far: i32) {
let (width, height) = self.get_resolution();
let row_shift = how_far * width;
@ -212,7 +219,7 @@ impl Chip8Video {
let base_offset: usize = (current_source_offset + current_source_column) as usize;
let extended_offset: usize = base_offset + row_shift as usize;
self.memory[extended_offset] = self.memory[base_offset];
};
}
}
// Clear the new top rows after shifting
@ -224,7 +231,13 @@ impl Chip8Video {
impl Default for Chip8Video {
fn default() -> Self {
let mut mem = vec![];
for _ in 0..CHIP8_VIDEO_MEMORY { mem.push(false); }
Chip8Video { memory: mem, has_frame_changed: false, current_res: Chip8VideoModes::LowRes }
for _ in 0..CHIP8_VIDEO_MEMORY {
mem.push(false);
}
Chip8Video {
memory: mem,
has_frame_changed: false,
current_res: Chip8VideoModes::LowRes,
}
}
}

View File

@ -0,0 +1,40 @@
use flate2::write::{GzEncoder, GzDecoder};
use flate2::Compression;
use std::io::prelude::*;
use gemma::chip8::computer::Chip8Computer;
fn load_result(to_load: &str) -> String {
std::fs::read_to_string(format!("resources/test/state/{}", to_load)).unwrap()
}
fn load_compressed_result(to_load: &str) -> String {
// load the file...
// ...then uncompress the string.
let mut decoder = GzDecoder::new(Vec::new());
decoder.write_all(load_result(to_load).as_ref()).expect("Decompression failed");
let decompressed_data = decoder.finish().expect("Failed to finish decompression");
String::from_utf8(decompressed_data).expect("Invalid UTF-8")
}
fn load_rom(to_load: &str) -> Vec<u8> {
std::fs::read(format!("resources/roms/{}", to_load)).unwrap()
}
#[test]
fn smoke_round_trip_serialize_deserialize() {
let x = Chip8Computer::new();
let expected_string = load_result("smoke_001_round_trip_serialize_deserialize.json");
let serialized = serde_json::to_string(&x).unwrap();
let deserialized: Chip8Computer = serde_json::from_str(&expected_string).unwrap();
println!("SERIALIZED [{}]", serialized);
// TODO: using trim here is a hack to handle editors adding a newline at the end of a file...even a 1 line file
assert_eq!(serialized.trim(), expected_string.trim());
assert_eq!(deserialized, x);
}
#[test]
fn computer_001_system_zero_state() {
let x = Chip8Computer::new();
let expected_string = load_compressed_result("smoke_002_round_trip_serialize_deserialize.tflt");
let serialized = serde_json::to_string(&x).unwrap();
}

View File

@ -10,11 +10,11 @@ rand.workspace = true
log.workspace = true
chrono.workspace = true
dimensioned.workspace = true
clap.workspace = true
imgui-glium-renderer = { version = "0.12.0" }
imgui-winit-support = { version = "0.12.0" }
glium = { version = "0.34.0" }
image = { version = "0.23" }
imgui = { version = "0.12.0" }
winit = { version = "0.27", features = ["x11", "mint"]}
winit = { version = "0.27", features = ["x11", "mint"] }
copypasta = { version = "0.8" }
clap = { version = "4.5.20", features = ["derive"] }

View File

@ -1,9 +1,10 @@
use std::default::Default;
use std::time::Instant;
use clap::{Parser, Subcommand};
use gemma::chip8::computer_manager::Chip8ComputerManager;
use std::path::Path;
use std::time::Instant;
use std::{default::Default, path::PathBuf};
use support::{emmagui_support::GemmaImguiSupport, ui_state::ImGuiUiState};
mod support;
/// Keypad Mappings for my Linux box
@ -12,16 +13,39 @@ mod support;
/// 7 8 9 E
/// A 0 B F
const LIN_KEYS: [(u16, u8); 0x10] = [(537, 0x01),(538, 0x02),(539, 0x03),(540, 0x0c),
(562, 0x04),(568, 0x05),(550, 0x06),(563, 0x0d),
(546, 7),(564, 8),(549, 9),(551, 0xe),
(571, 0xa),(569, 0),(548, 0xb),(567, 0xf)];
const LIN_KEYS: [(u16, u8); 0x10] = [
(537, 0x01),
(538, 0x02),
(539, 0x03),
(540, 0x0c),
(562, 0x04),
(568, 0x05),
(550, 0x06),
(563, 0x0d),
(546, 0x7),
(564, 0x8),
(549, 0x9),
(551, 0xe),
(571, 0xa),
(569, 0x0),
(548, 0xb),
(567, 0xf),
];
#[derive(Parser)]
#[command(version, about, long_about = None)]
struct GemmaImguiCLIOptions {
roms_directory: Option<PathBuf>,
}
fn main() {
pretty_env_logger::init();
let cli_options = GemmaImguiCLIOptions::parse();
let mut system = Chip8ComputerManager::default();
let mut ui_state = ImGuiUiState::default();
println!("GOT A ROMS_DIRECTORY => [{:?}]", cli_options.roms_directory);
let mut ui_state = ImGuiUiState::new(cli_options.roms_directory);
support::simple_init(file!(), move |_, ui| {
let current_time = Instant::now();
@ -53,14 +77,21 @@ fn main() {
let target_ms = ui_state.frame_time;
let loop_start_time = Instant::now();
while Instant::now().duration_since(current_time).as_millis() < target_ms as u128 && num_cycles < ui_state.target_ips {
while Instant::now().duration_since(current_time).as_millis() < target_ms as u128
&& num_cycles < ui_state.target_ips
{
if system.tick() {
num_cycles += 1;
}
}
let cycles_time = Instant::now().duration_since(loop_start_time);
if num_cycles > 0 {
println!("Ran for {}ms and executed {}/{} cycles.", cycles_time.as_millis(), num_cycles, ui_state.target_ips);
println!(
"Ran for {}ms and executed {}/{} cycles.",
cycles_time.as_millis(),
num_cycles,
ui_state.target_ips
);
}
// GUI Parts
if ui_state.show_video {
@ -75,7 +106,12 @@ fn main() {
if ui_state.show_memory {
let active_instruction = system.state().registers.peek_pc();
GemmaImguiSupport::hex_memory_display(system.state().memory, (0x100, 0x10), active_instruction as i16, ui);
GemmaImguiSupport::hex_memory_display(
system.state().memory.clone(),
(0x100, 0x10),
active_instruction as i16,
ui,
);
}
if ui_state.show_keypad {

View File

@ -1,15 +1,15 @@
use gemma::constants::CHIP8_KEYBOARD;
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
use imgui::{CollapsingHeader, Condition, ImColor32, Ui};
use log::debug;
use crate::support::gui_file_list::GuiFileList;
use crate::ImGuiUiState;
use gemma::chip8::computer::Chip8Computer;
use gemma::chip8::computer_manager::Chip8ComputerManager;
use gemma::chip8::computer_manager::ManagerDumpables::{Keyboard, Registers, Video};
use gemma::chip8::system_memory::Chip8SystemMemory;
use crate::ImGuiUiState;
use crate::support::gui_file_list::GuiFileList;
use gemma::constants::CHIP8_KEYBOARD;
use imgui::{CollapsingHeader, Condition, ImColor32, Ui};
use log::debug;
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
const ROM_ROOT: &str = "resources/roms";
@ -55,7 +55,10 @@ impl GemmaImguiSupport {
for current_column in 0..=width {
let x_offset = origin[0] as i32 + (current_column * cell_width);
let current_origin = [x_offset as f32, y_offset as f32];
let current_limit = [(x_offset + cell_width) as f32, (y_offset + cell_height) as f32];
let current_limit = [
(x_offset + cell_width) as f32,
(y_offset + cell_height) as f32,
];
let memory_offset = (current_row * width + current_column) as u16;
let to_render = system_to_control.video_memory.peek(memory_offset);
let color: ImColor32 = if to_render {
@ -63,7 +66,14 @@ impl GemmaImguiSupport {
} else {
gui_state.off_colour
};
fg.add_rect_filled_multicolor(current_origin, current_limit, color, color, color, color);
fg.add_rect_filled_multicolor(
current_origin,
current_limit,
color,
color,
color,
color,
);
}
}
} else {
@ -72,7 +82,10 @@ impl GemmaImguiSupport {
for current_column in 0..width {
let x_offset = origin[0] as i32 + (current_column * cell_width);
let current_origin = [x_offset as f32, y_offset as f32];
let current_limit = [(x_offset + cell_width) as f32, (y_offset + cell_height) as f32];
let current_limit = [
(x_offset + cell_width) as f32,
(y_offset + cell_height) as f32,
];
let memory_offset = (current_row * width + current_column) as u16;
let to_render = system_to_control.video_memory.peek(memory_offset);
let color: ImColor32 = if to_render {
@ -80,12 +93,23 @@ impl GemmaImguiSupport {
} else {
gui_state.off_colour
};
fg.add_rect_filled_multicolor(current_origin, current_limit, color, color, color, color);
fg.add_rect_filled_multicolor(
current_origin,
current_limit,
color,
color,
color,
color,
);
}
}
}
}
pub fn system_controls(system_to_control: &mut Chip8ComputerManager, gui_state: &mut ImGuiUiState, ui: &Ui) {
pub fn system_controls(
system_to_control: &mut Chip8ComputerManager,
gui_state: &mut ImGuiUiState,
ui: &Ui,
) {
// let mut state: Chip8Computer = system_to_control;
ui.window("!!!! CONTROLS !!!!")
.position([100.0, 640.0], Condition::FirstUseEver)
@ -95,19 +119,35 @@ impl GemmaImguiSupport {
/* ROM Lister */
if CollapsingHeader::new("Roms").build(ui) {
let new_filename = GuiFileList::display_path(PathBuf::from(ROM_ROOT), &gui_state.filename_to_load, ui);
let new_filename = GuiFileList::display_path(
gui_state.roms_root_path.clone(),
&gui_state.filename_to_load,
ui,
);
if !new_filename.is_empty() {
if new_filename != gui_state.filename_to_load {
debug!("NEW FILENAME SELECTED -> {new_filename}");
gui_state.filename_to_load = new_filename;
}
if ui.button("Load Program") {
let mut buffer = Vec::new();
debug!("PREPARING TO LOAD {}", gui_state.filename_to_load);
// 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(&(ROM_ROOT.to_string() + "/" + &gui_state.filename_to_load))).expect("put 1-chip8-logo.ch8 in this directory");
input_file.read_to_end(&mut buffer).expect("unable to read file");
system_to_control.load_new_program_to_system_memory((&*buffer).into());
let mut buffer: Vec<u8> = Vec::new();
let full_name = format!(
"{}/{}",
gui_state
.roms_root_path
.clone()
.as_os_str()
.to_string_lossy(),
gui_state.filename_to_load.to_string()
);
debug!("PREPARING TO LOAD {}", full_name);
let input_file = File::open(Path::new(&full_name));
input_file
.unwrap()
.read_to_end(&mut buffer)
.expect("Unable to read rom.");
system_to_control.load_new_program_to_system_memory(buffer);
}
}
}
@ -116,7 +156,7 @@ impl GemmaImguiSupport {
// if the system has no program loaded hide the buttons.
let bytes: [u8; 2] = [
system_to_control.state().memory.peek(0x200),
system_to_control.state().memory.peek(0x201)
system_to_control.state().memory.peek(0x201),
];
let mut show_buttons = bytes[0] != 0 || bytes[1] == 0xe0;
@ -158,7 +198,8 @@ impl GemmaImguiSupport {
ui.checkbox("Show Registers", &mut gui_state.show_registers);
ui.same_line();
ui.checkbox("Show Keypad", &mut gui_state.show_keypad);
ui.input_int("Target IPS", &mut gui_state.target_ips).build();
ui.input_int("Target IPS", &mut gui_state.target_ips)
.build();
};
});
}
@ -185,7 +226,12 @@ impl GemmaImguiSupport {
});
}
pub fn hex_memory_display(bytes: Chip8SystemMemory, position: (i32, i32), active: i16, ui: &Ui) {
pub fn hex_memory_display(
bytes: Chip8SystemMemory,
position: (i32, i32),
active: i16,
ui: &Ui,
) {
let rows = position.0;
let cols = position.1;
ui.window("System Memory")
@ -207,16 +253,22 @@ impl GemmaImguiSupport {
y: text_location[1] + text_size[1],
};
let hovering = ui.is_mouse_hovering_rect(text_location, [bounding_box.x, bounding_box.y]);
let hovering = ui.is_mouse_hovering_rect(
text_location,
[bounding_box.x, bounding_box.y],
);
let is_active = data_offset == active as i32;
ui.text_colored(if hovering {
ui.text_colored(
if hovering {
[0., 1., 1., 1.]
} else if is_active {
[1., 0., 1., 1.]
} else {
[1., 1., 0., 1.]
}, formatted_text.clone());
},
formatted_text.clone(),
);
// if we are hovering show that at the bottom...
if hovering {
@ -226,7 +278,12 @@ impl GemmaImguiSupport {
// Check if the left mouse button is clicked while hovering over the text
if ui.is_mouse_clicked(imgui::MouseButton::Left) {
debug!("Offset: [{}] [0x{:02x}] Value: [{}]", data_offset, data_offset, formatted_text.clone());
debug!(
"Offset: [{}] [0x{:02x}] Value: [{}]",
data_offset,
data_offset,
formatted_text.clone()
);
// Perform any action here, e.g., call a function, trigger an event, etc.
}
}
@ -237,7 +294,10 @@ impl GemmaImguiSupport {
}
}
}
ui.text(format!("Offset 0x{:03x}", current_x_hover * cols + current_y_hover));
ui.text(format!(
"Offset 0x{:03x}",
current_x_hover * cols + current_y_hover
));
});
}
}

View File

@ -1,5 +1,8 @@
use std::time::Instant;
use imgui::ImColor32;
use std::path::PathBuf;
use std::time::Instant;
pub const ROMPATH_DEFAULT: &str = "resources/roms";
pub struct ImGuiUiState {
pub show_registers: bool,
@ -12,7 +15,8 @@ pub struct ImGuiUiState {
pub is_running: bool,
pub frame_time: u32,
pub last_frame_instant: Instant,
pub target_ips: i32
pub target_ips: i32,
pub roms_root_path: PathBuf,
}
impl Clone for ImGuiUiState {
@ -28,7 +32,9 @@ impl Clone for ImGuiUiState {
is_running: self.is_running,
frame_time: self.frame_time,
last_frame_instant: self.last_frame_instant,
target_ips: self.target_ips
target_ips: self.target_ips,
roms_root_path: self.roms_root_path.to_owned(),
}
}
}
@ -46,7 +52,21 @@ impl Default for ImGuiUiState {
is_running: false,
frame_time: 16,
last_frame_instant: Instant::now(),
target_ips: 200000
target_ips: 200000,
roms_root_path: PathBuf::from(ROMPATH_DEFAULT),
}
}
}
impl ImGuiUiState {
pub fn new(rom_path: Option<PathBuf>) -> ImGuiUiState {
let unwrapped = rom_path.clone().unwrap_or(PathBuf::from(ROMPATH_DEFAULT));
println!("UNWRAPPED => [{:?}]", unwrapped);
ImGuiUiState {
roms_root_path: rom_path.unwrap_or(PathBuf::from(ROMPATH_DEFAULT)),
..Default::default()
}
}
}

View File

@ -5,6 +5,6 @@ edition = "2021"
[dependencies]
gemma = { path = "../gemma" }
clap = { version = "4.5.20", features = ["derive"] }
clap.workspace = true
pest = "2.7.14"
pest_derive = "2.7.14"

View File

@ -1,7 +1,7 @@
use clap::{Arg, Command};
use std::fs::File;
use std::io;
use std::io::{BufReader, Read};
use clap::{Arg, Command};
#[derive(Debug)]
struct CliArgs {
@ -19,7 +19,6 @@ fn main() {
.required(true)
.index(1),
)
.get_matches();
// Parse the command-line arguments
@ -76,8 +75,5 @@ fn read_file_to_bools(file_path: &str) -> io::Result<Vec<u8>> {
output.push(current_byte);
}
Ok(output)
}

View File

@ -0,0 +1,2 @@
a
¢Ð¢$ТѢ,Ñ,Fƒï,,<ò<>óö<,,ïƒF,(O<>Ïo8

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
1f8b08000000000000ffed9bcb8adb301440f7fd162dfc0c136d0b854257dd743104636c4d2212dba924b704e37fafecb13b4e42da4099a10c87631d45575792e56897b8abdb2a2b4ec5415919884a558d39c96eaa1fa324106192fc2e433b8ec47a35d85f61188db170f55c450f63bd0c4dd562021fbac89f9a67a12979eaf66bad92e15af69de5bc4c7e159ad78eaeeb79c9b98c63a3e47cd38bbcab5d2e624309e0d509c7271dff212316e1da1fcc5be387ef331d4a3a9670bdfee7ccf98c44893f0f69348eba9139cd3597f8e6dac1f9da7178e78cc3bddcbb9ff40d3397596f3fe7bdcffdde3c0000000000000000000000000078376c7a61d4565ba78c95ddcbc7c7bf8d133a9bb365208e854cc3a817b669eb3273baf2d1aef08db1bb17a53ae4a7cbb8ff59b2173f74a99aecf20f1b4ff9c12a8131c618638c31c618638c31c618638c31c618638c31c618638c31c618e3ffd81bb1cb6df664f24a65c52eafb7aa94cfdd456b8caa5d6694955f9a9f5f95ed8575b953f25bae9daeb79f1af3b9b6ceb485d34d2df6ea74cc4bd9f9dabefa6b059bf15e8abdecb453955fcf07beb7daecb3aa2995fcb8d3c787fec32fcefd4d09ab520000