User Tools

Site Tools


general:guides:hxd_guide

This is an old revision of the document!


HxD Hex Guide

By FelixWright, A.K.A. Cosmic

Hello, and welcome to our current graphics guide for HxD and hex editing in general.

The main goal of this guide is to teach newbies how to edit ROMs with hexadecimal.

Let's get started.

What is HxD?

HxD is a hex editor, disk editor, and memory editor developed for Windows. HxD can open files larger than 4 GiB and open and edit the raw contents of disk drives, as well as display and edit the memory used by running processes. Among other features, it can calculate various checksums, compare files, or shred files. The most recent version was created in 2009 by Maël Hörz.

Downloading HxD

HxD 2.0 RC can be downloaded from mh-nexus.

What is Hexadecimal?

To understand hexadecimal, you need to understand decimal. Decimal (also called base-ten, and occasionally called denary) is the standard system for denoting integer and non-integer numbers. Decimal is called base10 because it uses ten values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Because it is the de-facto standard number system, it does not have any denotation.

Example: 100 in Decimal is 100.

Hexadecimal is a positional numeral system with a radix, or base, of 16. This means it uses sixteen symbols, in this case 0–9 to represent values zero to nine, and A–F to represent values ten to fifteen. In the romhacking scene, hex values are denoted with $ or 0x.

Example: 100 in Hexadecimal is $64 or 0x64.

More examples:

DECIMAL  =  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

    HEX  =  0 1 2 3 4 5 6 7 8 9 A  B  C  D  E  F  10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F

There are many online resources for converting hex to decimal, but in this tutorial I will explain how to convert hex to decimal and decimal to hex using windows calculator. Before we begin, run calc.exe and press Alt + 3. This will put the calculator in programming mode.

Converting Hex to decimal

Select the “Hex” Bubble.

Paste in your hex value (Ctrl + V) or type it in. Select the “Dec” Bubble.

Ctrl + C to copy converted value to clipboard.

Converting decimal to Hex

Select the “Dec” Bubble.

Paste in your dec value (Ctrl + V) or type it in. Select the “Hex” Bubble.

Ctrl + C to copy converted value to clipboard.

Using HxD

Keyboard Shortcuts

Before we get into hex editing you should learn keyboard shortcuts. For ROMHacking, here's what you will need to know:

Key Combination Description
F3 Find Again
F6 Next Difference (File Compare)
Delete Clear Selection (Note: This shortens filesize!)
CTRL + A Select All
CTRL + E Select Block…
CTRL + G Go To…
CTRL + K File Compare…
CTRL + N New file (Empty)
CTRL + C Copy Selection
CTRL + X Cut Selection
CTRL + V Paste Insert (Note: This increases filesize!)
CTRL + B Paste Write (Overwrite)
CTRL + Z Undo
CTRL + Y Redo
CTRL + O Open a file…
CTRL + R Find & Replace…
CTRL + S Save a file
Shift + F3 Find Again (Reverse)
Shift + F6 Previous Difference (File Compare)
Ctrl + F4/Ctrl + W Close file
Ctrl+Number (0-9) Goto bookmark
Ctrl+Shift+Number (0-9) Add bookmark
Left and Right Arrow keys Move to next/previous byte
Up and Down Arrow keys Move to next/previous row
Shift + Up/Shift + Down Select next/previous row
Shift + Left/Shift + Right Select next/previous byte

WARNING: Changes in filesize could destroy your ROM if you're not careful!

Going to an offset

Going forward, Let's say you want to disable the low energy alarm in Zero Mission. 0x52888 = 1D 2F to 14 E0

Open Zero Mission in HxD, and use Goto… (Ctrl + G)

As you can see, by default HxD assumes you want to put in a hex address, and the address above is hex so that is fine. If you run into a decimal or octal address though, you can select the dec or oct bubbles and then paste in the address.

Editing Hex Values

So we're at address 0x52888. The text cursor should be blinking to the left of 1D. Select 1D, and type 14. Your cursor should now be blinking to the left of 2F. Select 2F, and replace it with E0. Save your changes with Ctrl + S. You have just performed a hex tweak! Open your ROM in an emulator, and reduce samus' energy below 30. There should no longer be a low energy alarm.

PC and SNES addresses

Because HxD uses PC addresses, and the majority of documentation for SNES games is written with SNES addresses, it's important to know the distinction between the two. PC addresses start at $0:0000, while SNES addresses start at $80:8000. Every SNES bank starts at $8000, while PC banks start at $0000. To know at a glance whether or not an address is a SNES or PC address, know that Super Metroid, as well as just about every other SNES game, never comes close to reaching $80:8000 in PC, so any address starting there or beyond is very likely a SNES address. Even though converting between PC and SNES addresses is pretty simple math, I highly recommend using the tool “Lunar Address” to avoid errors.

Examples:

PC address SNES address
$0:4000 $80:C000
$0:9500 $81:0500
$7:FFFF $8F:FFFF
general/guides/hxd_guide.1528202234.txt.gz · Last modified: 2018/06/05 12:37 by mccad