sharkdp / hexyl

A command-line hex viewer
Apache License 2.0
8.92k stars 227 forks source link

Feature request: Comodore prg mode #209

Closed schorsch3000 closed 7 months ago

schorsch3000 commented 7 months ago

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))" "$@"
sharkdp commented 7 months ago

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!