Giter Site home page Giter Site logo

mgbdis's People

Contributors

bnzis avatar iamg-r00t avatar issotm avatar kemenaran avatar mattcurrie avatar rbong avatar tobiasvl avatar tommylau-exe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mgbdis's Issues

Support scoped local labels

The following currently isn't disassembled correctly:

; @00:0000
    nop
    jr $0004
    nop
00:0000 Glob1
00:0001 .local
00:0003 Glob2
00:0004 .local

This will produce the following:

Glob1::
    nop

.local:
    jr .local

Glob2::
    nop

.local:

where the jr .local line should instead be Glob2.local. This is because mgbdis does not treat local labels specially: in RGBDS, they are always scoped. meaning the SYM file above is actually invalid. See below for what is actually produced.

00:0000 Glob1
00:0001 Glob1.local
00:0003 Glob2
00:0004 Glob2.local

mgbdis actually treats labels as local only if they begin with a dot, whereas the RGBDS rule is if they contain one at all.

This is actually linked to gbdev/rgbds#483 (and #12, by extension), though the currently drafted spec agrees on what has been outlined above.

Correct behavior

mgbdis should instead apply special meaning to local labels, trimming off their leading part if it's currently in scope. (Implementing that properly is a different problem.) Note that while Glob1.local: is actually valid syntax, it's a lot noisier, and nobody writes code like that.

Is there support for Charmaps or other Text formatting?

I can mark a block as .text in the sym file but the ROM I'm looking at isn't using standard ASCII so I'd need a Character Map or some other option to offset and make the text readable.

Is there a way to do that? Am I going about this the wrong way?

Note on HRAM/IO R/W

From README.md:

RGBDS optimises instructions like LD [$FF40],a to LDH [$FF00+40],a, so these are encoded as data bytes using a macro to ensure exact reproduction of the original ROM (thanks to ISSOtm). RGBDS >= v0.3.7 has an option to disable this optimisation. Use --disable-auto-ldh with mgbdis to disable the macro.

This only applies to constant expressions. If you instead export the symbol from an HRAM section, it'll use the 3-byte ld instruction.

Tetris fails to match

Original ROM is Tetris with a MD5 hash of 084f1e457749cdec86183189bd88ce69

Output ROM game.gb has a MD5 hash of 389d39cb232bebe3ff7d4ccbc6269a82

See here for a difference comparison. 101 differences: 104 bytes

Error on BIOS disassembly

I tried to disassemble the BIOS using this (nice) tool.

I create the cartridge using this python3 script

#!/usr/bin/env python3

code = bytearray([
    0x31, 0xFE, 0xFF, 0xAF, 0x21, 0xFF, 0x9F, 0x32, 0xCB, 0x7C, 0x20, 0xFB, 0x21, 0x26, 0xFF, 0x0E,
    0x11, 0x3E, 0x80, 0x32, 0xE2, 0x0C, 0x3E, 0xF3,  -- snip --
])

rom = code + bytearray([0x00] * (32768 - len(code)))

with open("bios.gb", "wb") as out_file:
  out_file.write(rom)

The mgbdis creates some files but when I looked in bank_000.asm, I found is an error

; Disassembly of "bios.gb"
; This file was created with:
; mgbdis v1.4 - Game Boy ROM disassembler by Matt Currie and contributors.
; https://github.com/mattcurrie/mgbdis

SECTION "ROM Bank $000", ROM0[$0]

RST_00::
    ld sp, $fffe
    xor a
    ld hl, $9fff

jr_000_0007:
    ld [hl-], a

RST_08::
    bit 7, h
    jr nz, jr_000_0007

    ld hl, $ff26
    db $0e  ;  <<<<<<<<<<<<<< ERROR

RST_10::
    ld de, $803e
    ld [hl-], a
    ld [c], a
    inc c
    ld a, $f3

The tool seems to skip the disassembly of the 0x09 opcode (LD c, n) that has to consume an other byte.

Too much use of RAM

I have 960 MB of RAM... When I try to decompile Pokemon (Fire Red or Fuego Rojo in spanish) it fills me all the RAM.

¿It would be possible for the program to save the content of the variables on the hard disk instead of the RAM in this case?

That way you could use less RAM and the system would not freeze. I'm talking about variables that use too much RAM.

Regression in spitting out wrong `jr` targets

commit 298ccf7 has caused a regression regardling how jr targets are calculated in non-tiny mode.
Building a disassembled pokemon crystal, for example, causes these errors:

$ make
rgbasm  -o game.o game.asm
rgblink -n game.sym -m game.map -o game.gbc game.o
error: game.asm(97) -> bank_04c.asm(14288): jr target out of reach (expected -129 < -16328 < 128)
error: game.asm(96) -> bank_04b.asm(14181): jr target out of reach (expected -129 < -16260 < 128)
error: game.asm(148) -> bank_07f.asm(16332): jr target out of reach (expected -129 < -16317 < 128)
error: game.asm(109) -> bank_058.asm(14228): jr target out of reach (expected -129 < -16257 < 128)
error: game.asm(103) -> bank_052.asm(14406): jr target out of reach (expected -129 < -16272 < 128)
Linking failed with 5 errors
make: *** [Makefile:13: game.gbc] Error 1

bdm source/win32 build

i would like to use bdm to create a sym file for this disassembler, but to my surprise the windows build (couldnt find source) is win64 only. would it be possible to provide a win32 build so i can use it in wine ? if the source is available somewhere, that would be even better of course.

Stop outputting instructions as data bytes

  • RGBDS optimises instructions like LD [$FF40],a to LDH [$FF00+40],a, so these are encoded as data bytes using a macro to ensure exact reproduction of the original ROM (thanks to ISSOtm).
  • RGBDS automatically adds NOP instructions after STOP and HALT, so the disassembler will output these as data bytes if the instruction is not followed by a NOP in the original ROM.

RGBDS has flags to prevent this (-L for the former since 0.3.7, -h for the latter before 0.3.5); it should be possible to pass flags to mgbdis (possibly the same ones?) to leverage this behavior, and avoid data bytes in the middle of code, which might throw people off.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.