Srayan Jana
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Melee decomp resources **Decompiling functions with the live compilation on decomp.me** You can find the functions that still have to be decompiled in the project's `asm/` folder. You can also use the dolphin debugger to find functions you're interested in (see below). Then navigate to decomp.me/new, select GameCube/Wii and in the compiler preset select 'Melee'. Now copy the assembly code of the function from the project's `asm/` folder here and fill in a function name. All occurences of `-_SDA2_BASE_` in the code must be replaced with `@sda21`. Click on create scratch and you are ready to go. Since we have the same compiler that was used for the original Melee project, the goal is to write C code that matches the assembly 100%. Global variables, functions and constants can not be matched on decomp.me, this has to be done when adding the function to https://github.com/doldecomp/melee. When doing so, variables must be declared in the order that they are defined in the assembly's data sections (someone correct me if I'm wrong, I haven't done that part yet). **Automated decompilers** They are not perfect, but can be a good start: https://simonsoftware.se/other/ppc2cpp.py (github repo at https://github.com/matt-kempster/mips_to_c/tree/ppc2cpp) ghidra (TODO: setup instructions) IDA https://hex-rays.com/ida-free/ (TODO: setup instructions) **Using the Dolphin debugger** In Dolphin go to Settings > Interface > select 'Show Debugging UI'. Now you can inspect registers, Memory, the call stack, set break points and set memory watches. Dolphin also allows you to assign names to functions and save them as so called MAP files. The dolphin debugger then shows you useful function names instead of cryptic function addresses. You can get such a map file here: https://github.com/UnclePunch/Training-Mode/blob/master/GTME01.map By compiling the project with `make GENERATE_MAP=1`, you can also generate a map file of all assembly and all decompiled functions. **Understanding the assembly** The most common registers are R0-R31 for integers or bit fields, and f0-f31 for floating point values. - R1 is used as the stack pointer. - R2 points to a read only data section called SDA2 (small data area), also referred to as the table of contents pointer or RTOC. - R13 points to another data section, but this data can change. - PC is the instruction pointer - CR is the condition register, used for conditional jumps (For example an integer subtraction sets CR as a side effect, then a conditional jump can be used when the result was less than, greater than, or equal to zero.) R2 and R13 stay constant and have values `R2=0x804df9e0`, `R13=0x804db6a0`. When a value relative to R2 or R13 is dereferenced, you can find those values with the Dolphin debugger. PPC instruction set documentation: http://math-atlas.sourceforge.net/devel/assembly/ppc_isa.pdf ABI documentation (haven't read this, don't know how good it is): https://www.nxp.com/docs/en/application-note/PPCEABI.pdf Compiler Writer's Guide (useful for recognizing assembly instruction patterns used for flow control, conversions, calling conventions, ...): https://cr.yp.to/2005-590/powerpc-cwg.pdf Calling conventions (short, probably incomplete): http://wiki.tockdom.com/wiki/Compiler The last site also contains a lot of other useful information for decompiling. **Other Melee reverse engineering resources** Community spreadsheet, documentation of data structures: https://docs.google.com/spreadsheets/d/1JX2w-r2fuvWuNgGb6D3Cs4wHQKLFegZe2jhbBuIhCG8/edit#gid=5 m-ex: Has C files with many struct definitions. But we don't copy-paste them blindly to this project until we can verify everything by decompilation. https://github.com/akaneia/m-ex/blob/master/MexTK/include/ **Compiling the repo locally** Clone the repo https://github.com/doldecomp/melee to your PC and follow the build instructions in the Readme.md. Due to a bug we need an older version of devkitPPC which you can get here: https://wii.leseratte10.de/devkitPro/devkitPPC/r39%20(2021-05-25)/ TODO: This info should really go into the Readme.md instead **Contributing code** Ideally you have decompiled a whole assembly file, because then the file can be replaced by a single C file. Replacing only individual functions with C versions is tricky. Talk to the devs how to procede when the assembly file is too large for you to decompile alone. TODO: How to contribute individual functions (put them in a temporary file that doesn't get compiled?)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully