Skip to content

Added hex viewer#357

Open
chrisgleissner wants to merge 6 commits intoGideonZ:masterfrom
chrisgleissner:feature/320-hex
Open

Added hex viewer#357
chrisgleissner wants to merge 6 commits intoGideonZ:masterfrom
chrisgleissner:feature/320-hex

Conversation

@chrisgleissner
Copy link

@chrisgleissner chrisgleissner commented Jul 4, 2023

Features

Design Notes

  • The decision about which view to use for opening a file was deliberately left to the user. There may be legit use cases to open a text file in hex view, and vice versa.
  • The firmware resulting from this PR was successfully flashed to a 64 Ultimate Elite, revision 1.4. All testing was done on this machine.
  • The offset rolls over from FFFF to 0000 if browsing a file larger than 64KiB. This should be OK as it mostly concerns browsing D64 and similar large files.

Examples

New "Hex View" entry in context-sensitive menu:
image

New "Hex View":
image

Same file opened via existing "View" which was left unchanged. In this example, byte 0x00 at offset 0x3b terminates the string rendering:
image

New "Hex View" using sample file containg contiguous sequence of numbers from 1 through 255:
image

@chrisgleissner
Copy link
Author

The branch feature/320-hex of this PR has been merged into the new branch chrisgleissner-feature/320-hex and the merge conflicts have been resolved there. Pending on that new branch are adjustments to the build files for the non-U64 builds which @GideonZ will take care of as discussed - many thanks.

Copilot AI review requested due to automatic review settings March 20, 2026 10:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated hex viewer mode to the existing file viewer/editor flow in the firmware UI, along with new navigation shortcuts to jump to start/end of file. This supports browsing binary files more reliably (per issue #320) without relying on text rendering behavior.

Changes:

  • Introduces HexEditor (hex/ASCII-style row rendering) and wires it into the UI as a new “Hex View” context menu action.
  • Refactors UserInterface::run_editor to accept an Editor* and adds run_hex_editor(...) for hex-view launch.
  • Adds Home/F2 (start) and End/F8 (end) navigation to the editor, and updates build rules/Makefiles to compile the new source.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
Makefile Adds ESP-IDF invocation variables and routes ESP32 builds through them
target/common/rules.mk Makes gitinfo depend on $(OUTPUT) so the generated header has a destination
software/userinterface/userinterface.h Adds hex-view constants and run_hex_editor declaration; internal editor runner overload
software/userinterface/userinterface.cc Refactors editor runner to take an Editor* and adds run_hex_editor implementation
software/userinterface/user_file_interaction.h Adds EditorType and S_hex_view declaration
software/userinterface/user_file_interaction.cc Adds “Hex View” context action and shared view_file(...) implementation
software/userinterface/editor.h Makes rendering extensible via virtual draw(int, Line*); declares HexEditor
software/userinterface/editor.cc Routes drawing through virtual per-line draw; adds Home/End shortcuts
software/userinterface/hex_editor.cc New hex viewer rendering implementation
target/u64ii/riscv/ultimate/Makefile Adds hex_editor.cc to build
target/u64/riscv/ultimate/Makefile Adds hex_editor.cc to build
target/u64/nios2/ultimate/Makefile Adds hex_editor.cc to build
target/u2plus_L/riscv/ultimate/Makefile Adds hex_editor.cc to build
target/u2plus/nios/ultimate/Makefile Adds hex_editor.cc to build
target/u2plus/nios/recovery/Makefile Adds hex_editor.cc to build
target/u2/zpu/update_to_mb/Makefile Adds hex_editor.cc to build
target/u2/zpu/ultimate/Makefile Adds hex_editor.cc to build
target/u2/riscv/ultimate/Makefile Adds hex_editor.cc to build
target/u2/microblaze/mb_ultimate/Makefile Adds hex_editor.cc to build
target/u2/microblaze/mb_ui/Makefile Adds hex_editor.cc to build

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chrisgleissner
Copy link
Author

chrisgleissner commented Mar 20, 2026

@GideonZ I have updated this PR with the latest changes from your repository to ensure it can be merged cleanly. I also added a unit test. Thanks for kicking off a workflow run.

Build and Deploy

Verified to work on my Ultimate 64 Elite I using Quartus 18.1 Lite and the following commands executed from the root of this repo, with my Kubuntu 24.04 PC connected via USB and USB Blaster to the JTAG interface of the U64.

cd /home/chris/dev/c64/1541ultimate
export QUARTUS_ROOTDIR=/home/chris/intelFPGA_lite/18.1/quartus
export QSYS_ROOTDIR=/home/chris/intelFPGA_lite/18.1/quartus/sopc_builder/bin
export PATH="/home/chris/intelFPGA_lite/18.1/quartus/bin:/home/chris/intelFPGA_lite/18.1/nios2eds/bin:/home/chris/intelFPGA_lite/18.1/nios2eds/bin/gnu/H-x86_64-pc-linux-gnu/bin:/home/chris/intelFPGA_lite/18.1/nios2eds/sdk2/bin:/home/chris/intelFPGA_lite/18.1/quartus/sopc_builder/bin:$PATH"
source /home/chris/.espressif/v5.5.3/esp-idf/export.sh >/dev/null
make -C /home/chris/dev/c64/1541ultimate -j"$(nproc)" u64
mkdir -p /home/chris/dev/c64/1541ultimate/build/output
cp -f /home/chris/dev/c64/1541ultimate/external/u64.sof /home/chris/dev/c64/1541ultimate/build/output/ultimate64-elite.sof
cp -f /home/chris/dev/c64/1541ultimate/target/u64/nios2/updater/output/u64.pof /home/chris/dev/c64/1541ultimate/build/output/ultimate64-elite.pof
jtagconfig
nios2-download -g /home/chris/dev/c64/1541ultimate/target/u64/nios2/ultimate/result/ultimate.elf

Screenshots

These were captured using C64 Stream, showing main features, as mentioned earlier in this PR:

Screenshot 2026-03-20 16-50-47 Screenshot 2026-03-20 16-51-55 Screenshot 2026-03-20 16-53-14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants