Patch a position

The most important patcher command is the “patch” command, with this you overwrite (never insert) bytes

patch <position> 0x<value>

# Patch position 12 (0x0C) with the four bytes 0x0025015E - changes the ROM version number to r37.350
CapCLI> patch 0x0C 0x0025015E

Create/set alias

Within Cap you can create variables (for some reason, I started using the word alias, now its stuck), but it’s just a variable, you can directly assign values to aliases, grab a chunk of the ROM and put it into an alias (to patch somewhere else or change), if the alias looks like it could be a number, you can add to or subtract from it, and you can treat it like a string and chop it up using the mid function.

I’ll probably add some extra functions here, like conversion between hex, int and strings, as it’s a little limited at the mo.

alias <aliasname> <value>

CapCLI> alias FRED 0x01020304
CapCLI> echo $FRED

alias <aliasname> romdata <start> <size>

CapCLI> loadrom "ROMs/TOSEC.Firmware/Kickstart v2.05 r37.350 (1992-04)(Commodore)(A600HD)[!].rom"
CapCLI> alias FRED romdata 0x0C 0x04
CapCLI> echo $FRED

alias <aliasname> add <value>

CapCLI> echo $FRED
CapCLI> alias FRED add 1
CapCLI> echo $FRED

Note, add and subtract only work properly on hex values, i.e. they must begin 0x (I might change this later)

alias <aliasname> subtract <value>

CapCLI> echo $FRED
CapCLI> alias FRED subtract 51
CapCLI> echo $FRED

alias <aliasname> mid <start> <size>

CapCLI> echo $FRED
CapCLI> alias FRED mid 3 2
CapCLI> echo $FRED

Note, the alias has 0x at the start of it, this is included in the length, so position 0 is "0", position 1 is "x" etc.

Inbuilt aliases

For your delectation, I have created some inbuilt aliases that help you access/modify ROM and library information, you (almost) only ever change data with the patch command.

ROM things

The ROMBASE calculated from the ROM


The Commodore checksum (not CRC32)


The location within the ROM of the kickstart version (usually 12, 0x0C)


Note the use of brackets, to say "location of" rather than the actual kickstart version.

# read the kickstart version into the KSV alias
CapCLI> alias KSV romdata $(KICKSTARTVERSION) 4
CapCLI> echo $KSV

Locations of library things

These will give you the location of things that relate to specific libraries, so you can read or manipulate them - remember, the brackets mean "give me the location" not the value stored at that location


If you want the start and end location of a library, then you can simply use the name;


CapCLI> echo $cia.resource
274624 275640

Hash aliases

You can find and refer to files by their hash value, but only if you have previously done an “auditfiles” command, the auditfiles command hashes every file under the named directory and creates an alias for every file based upon it’s hash value – as you can guess, scanning an entire directory tree is very CPU and disk intensive, so don’t do this on gigs or data, it’s only really worthwhile on ROMs or Components.
This is used extensively in the “Recipes and Tests” to load a specific ROM or component (without having to know the exact name).

Scan all files under a directory and evaluate the hash value
auditfiles <dirname>

CapCLI> auditfiles ROMs
CapCLI> echo "$0x43b0df7b"
ROMs/TOSEC.Firmware/Kickstart v2.05 r37.350 (1992-04)(Commodore)(A600HD)[!].rom

Patching the checksum

If you have altered the ROM, you will need to update the C= checksum, there’s a hard way and an easy way, but the hard way isn’t that hard.

Using the location of the start of the checksum, patch it with a newly calculated value
patch $Checksum.(START) $CALCCHECKSUM

The "checksum" command does this for you

Finding data

If you want to scan the ROM (or just a library) for the location of things, I have a command for that… the unusually named find command, if the find is successful then the alias $FIND is set to the position that it found it, if it’s not found then $FIND is not updated and you just get “Not found” (I might change this to reset $FIND).

You can search for binary text using hex representation (so searching for strings is a bit laborious) or you can search for 68000 opcodes

find <from> <to> <what>

CapCLI> find 0 262143 0x6C696272617279
CapCLI> echo $FIND

CapCLI> find 0 262143 0x112233445566778899aa
Not found
CapCLI> echo $FIND

findopcode <from> <to> <what>

CapCLI> findopcode $0x75094a7b.scsidisk_40.12_(21.12.93) "JSR FCD6(A6)"
CapCLI> echo $FIND
Scroll to Top