Giter VIP home page Giter VIP logo

windfish's Introduction

Windfish

Windfish is a disassembler for Gameboy ROMs that can generate RBGDS-compatible assembly code.

Background

This project was initiated to support archaelogical efforts aimed at understanding the implementation details behind Link's Awakening for the original Gameboy. The project has since grown to be a general disassembler for Gameboy ROMs.

The name "Windfish" is a reference to the main focus of the Link's Awakening storyline.

Overview

The core design principle of the Windfish disassembler is to maximize legibility of generated assembly code with minimal configuration.

Windfish supports several powerful features for disassembling Gameboy ROMs, including:

  • Control-flow disassembly: Able to follow branches in control flow in order to distinguish code from binary data.
  • Memory bank awareness: Bank changes are monitored so that jumps to 0x4000-0x7999 memory regions can move to the correct bank.
  • Regions: Text, image (2bpp, 1bpp), and data regions can be registered enabling a rich representation of the disassembly in the Windfish IDE.
  • Data types: Custom datatypes can be registered and, when detected, automatically referenced in the generated assembly to improve code readability.
  • Globals: Global variables can be registered and referred to within the generated assembly.
  • Macros: Common assembly patterns can be registered and, when detected, generated as RGBDS macros.
  • Scope awareness: Contiguous blocks of scope are inferred during disassembly.

IDE

The frontend for Windfish

The Windfish disassembler is best invoked through the IDE which is integrated closely with the powerful Sameboy emulator and debugger.

Features of the IDE:

  • Full Sameboy debugger integration: See https://sameboy.github.io/debugger/ for complete documentation on the debugger.
  • Full Sameboy emulation: This enables a tight feedback loop where emulation can be used to increase your understanding of the disassembly.
  • Configuration editing: Edit regions, data types, globals, and macros from the IDE.
  • Labeled callstack: The labels are read directly from the full-context disassembly.
  • Tooltip documentation: Documentation for instructions can be seen by hovering over the instruction.
  • Function scope visualization: Function scopes are shown as a contiguous line alongside the source.
  • Selected bank visualization: The selected bank is shown alongside each instruction.

Learn more

Learn more about the Windfish architecture.

windfish's People

Contributors

jverkoey 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

windfish's Issues

Support showing disassembly for RAM

The blargg tests copy their tests into RAM from $4000 to $C000. KoholintIsland only supports showing disassembly results for the cartridge, meaning it's not possible to visualize and step through the instructions for these tests in a meaningful way..

Surface errors in configuration in the IDE

Some examples of errors:

  • out of bound cartridge locations
  • duplicate scripts, macros, globals, data types, labels
  • infinite loops in scripts (may need to introduce a timeout for scripts)

Add a "step out" debugging command

This command should continue execution until a layer is popped off of the callstack. If there are no layers to pop off then this command should be disabled.

Make it possible to extract functions to separate files

This will enable larger structural organization of the disassembly.

One way to do this would be to allow a filename to be associated with a function. Doing so would cause the function's entire scope to be moved to that file. This file would in turn be imported from the appropriate bank.

Build an emulator pane.

The emulator pane should enable the following features:

  • Initiate an emulation run at a specific address with an initial CPU state.
  • Emulating one instruction at a time and visualizing CPU state results.

Some open questions:

  • What happens when the CPU state is ambiguous and conditional logic is encountered?

Surface ambiguous inferred types in the UI

When an instruction can be inferred as having multiple types, this should be surfaced in the UI as a "fixit"-style suggestion to select one of the types as the preferred type.

Add support for building the ROM from the disassembly

This will help verify that the checksums of assembling the disassembly matches the checksum of the ROM and that no errors were introduced as a result of a bug in Windfish or the project configuration.

Doing so will require integrating the rgbds tool into the Windfish UI in some manner.

Implement serial interrupts

This should improve the likelihood of blargg/instr_timing/instr_timing passing, as it relies on the serial interrupt being fired.

Add breakpoint support to the emulator

  • Able to add breakpoints
  • Able to delete breakpoints
  • Emulator pauses when a breakpoint is encountered (when breakpoints are on macros, only the first instruction of the macro should pause the emulator)

Speed up end-to-end disassembly times by parallelizing tasks

There are two primary phases to disassembly:

  1. The disassembly itself.
  2. The generation of attributed text for each ROM bank.

Phase #2 can only begin once phase #1 has concluded. Phase #2 is likely the easiest part to parallelize because each ROM bank's attributed text can be generated in parallel without any overlap.

Phase #1 will be harder to parallelize. This will require exploring how to allow runs to happen in parallel to one another, merging the results in the same order that runs were initiated in order to preserve consistency across multiple disassembly invocations.

Tasks

  • Create an instrumentation baseline of end-to-end disassembly so that improvements can be measured.

Support mapping code to a memory region

This will enable the disassembler to treat any call/jp addresses within the region as mapped to the destination region. This will be particularly handy for working with the test ROMs as they frequently copy code into RAM before running it.

The reverse mapping can be useful as well: if the emulator detects it is running in a mapped region it can highlight the code at the source region instead.

Stop emulation when the project is closed

The project and its emulator currently continue running in the background even after the project is closed. Only full termination of the IDE causes emulation to stop.

Current viewport is reset when disassembling finishes

The viewport gets reset to bank 0 at the top rather than staying fixed to the current view.

A related bug is that if the bank being debugged is not open when a breakpoint is hit, then the bank's source will be opened but the correct location won't be jumped to until at least one more emulation step occurs. There is likely some race condition happening between loading the bank's source and the ability to jump to a given line in the source.

Backport symbols to macOS 10.15

They are currently drawn as white squares with the accessibility label drawn over top. Ideally we are using the same symbol icons on 10.15 that we're using on 10.11+.

Implement proper PPU pixel fifo queuing

The current implementation is a rough approximation but is not cycle accurate and has some visual quirks. Note the odd flashes in the opening sequence of Link's Awakening on the beach scene where sprites disappear around 2/3 of the way into the scanline:

2021-01-05-01-08

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.