Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export all labels to debug symbols #25

Merged
merged 2 commits into from Sep 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -3,6 +3,7 @@
# If your default python is 3, you may want to change this to python27.
PYTHON := python
2BPP := $(PYTHON) tools/gfx.py 2bpp
ASM := rgbasm -E

.SUFFIXES: .asm .o .gbc .png .2bpp

Expand Down Expand Up @@ -39,7 +40,7 @@ gfx_files = $(shell find src/gfx -type f -name '*.png')
src/main.o: $(asm_files) $(gfx_files:.png=.2bpp) bin/banks/bank_00_0.bin

.asm.o:
rgbasm -i src/ -o $@ $<
$(ASM) -i src/ -o $@ $<

# Then we link them to create a playable image.
# This also spits out game.sym, which lets you use labels in bgb.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -7,7 +7,7 @@ MD5 - 07C211479386825042EFB4AD31BB525F

## Usage

1. Install [rbgds](https://github.com/rednex/rgbds#1-installing-rgbds).
1. Install [rbgds](https://github.com/rednex/rgbds#1-installing-rgbds) (version >= 0.2.5 required).
2. `make all`

## Overview
Expand Down Expand Up @@ -35,7 +35,7 @@ Here is how to use BGB for reverse-engineering the game:
1. Compile the game (`make all`).

It produces `game.gbc` (a compiled rom identical to the original) and more importantly `game.map`, the debug symbols.

2. Open `game.gbc` in the [BGB emulator](http://bgb.bircd.org/).
3. Open the debugger, and jump to the `0000:0150` address. You'll see a function named `Start`. Notice how BGB knows the name of this function from the debug symbols.
4. You can now trace the execution of the code, set breakpoints, watchers, edit the memory, etc.
Expand Down
8 changes: 4 additions & 4 deletions src/code/bank0.asm
Expand Up @@ -576,7 +576,7 @@ LoadMapData::
; 09 $2E73
; ...
call label_4657
jp [hl]
jp hl

;
; $D6FE == 0: common case
Expand Down Expand Up @@ -1797,7 +1797,7 @@ label_BE7::
ld h, a
ld a, [$DE03]
ld l, a
jp [hl]
jp hl
ld a, $02
ld [MBC3SelectBank], a
call label_1A50
Expand Down Expand Up @@ -6374,7 +6374,7 @@ TableJump::
ld d, [hl] ; Load the high byte of the target address
ld l, e
ld h, d
jp [hl] ; Jump to the target address
jp hl ; Jump to the target address

; Turn off LCD at next vertical blanking
LCDOff::
Expand Down Expand Up @@ -9025,7 +9025,7 @@ label_3A8D::
ld h, d
ld [wCurrentBank], a
ld [MBC3SelectBank], a
jp [hl]
jp hl

data_3AAA::
db 8, 5, 8, 5, 8, $A, 8, $A, 8, $A, 8, $A, 8, $10, 4, $A
Expand Down
10 changes: 5 additions & 5 deletions src/code/bank1.asm
Expand Up @@ -1133,7 +1133,7 @@ label_47CD::
ld a, [wGameplaySubtype]
JP_TABLE
; Code below is actually data for the jump table
jp [hl]
jp hl
ld b, a
push af
ld b, a
Expand Down Expand Up @@ -3096,7 +3096,7 @@ label_53E8::
rst $38
adc a, d
ldd [hl], a
jp [hl]
jp hl
rst $38
adc a, d
ld l, $E9
Expand Down Expand Up @@ -3286,15 +3286,15 @@ label_54A0::
nop
rst $38
db $E8 ; add sp, d
jp [hl]
jp hl
rst $38
nop
db $E8 ; add sp, d
db $EC ; Undefined instruction
db $E8 ; add sp, d
rst $38
db $E8 ; add sp, d
jp [hl]
jp hl
rst $38
nop
db $E8 ; add sp, d
Expand Down Expand Up @@ -3324,7 +3324,7 @@ label_54A0::
db $EC ; Undefined instruction
db $E8 ; add sp, d
db $EC ; Undefined instruction
jp [hl]
jp hl
rst $38
nop
nop
Expand Down
2 changes: 1 addition & 1 deletion src/code/bank3.asm
Expand Up @@ -283,7 +283,7 @@ label_C918::
ld [hl], $05
ld a, $03
call label_9D3
jp [hl]
jp hl

data_C924::
db 1, 4
Expand Down
4 changes: 2 additions & 2 deletions tools/Z80Dis.c
Expand Up @@ -277,7 +277,7 @@ global_variable instruction InstructionTable[] = {
{0xE6, 2, "and $N"},
{0xE7, 1, "rst $20"},
{0xE8, 1, "add sp, d"},
{0xE9, 1, "jp [hl]"},
{0xE9, 1, "jp hl"},
{0xEA, 3, "ld [$NN], a"},
{0xEB, 1, "db $EB"},
{0xEC, 1, "db $EC"},
Expand Down Expand Up @@ -1953,7 +1953,7 @@ DisassembleBank(u16 BankNum) {
break;
}
case 0xE9: {
fprintf(Output, "jp [hl]\n");
fprintf(Output, "jp hl\n");
break;
}
case 0xEA: {
Expand Down