sharkdp / hexyl

A command-line hex viewer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Comodore prg mode

schorsch3000 opened this issue · comments

I'm super unsure if this really should be a part of hexyl, but let me explain:
I heavily use hexyl in my C64 developement process.
a comodore .prg files is prefixed with 2 bytes that are not actually part of the files content.
When loading a prg file to memory, the first two bytes pointing to the address in memory that file is loaded.

It would be super helpful if hexyl could set it's display-offset automatically.

i currently have a the following wrapper-script around hexyl to achive that:

#!/usr/bin/env bash
set -e
# file is the last parameter
file="${*: -1}"
highByte="$(dd if="$file" bs=1 skip=1 count=1 status=none | hexdump -v -e '/1 "%02X"')"
lowByte="$(dd if="$file" bs=1 count=1 status=none | hexdump -v -e '/1 "%02X"')"
offset=$((0x$highByte * 256 + 0x$lowByte))
hexyl -o "$((offset - 2))" "$@"

Thank you. I think a wrapper script like you have is the best solution here. This seems a bit too specialized a use case in order for it to be integrated into hexyl. Thank you for sharing though!