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

Patching directives #30

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Patching directives #30

wants to merge 7 commits into from

Conversation

nstbayless
Copy link

@nstbayless nstbayless commented Feb 3, 2020

I've added a few new directives which should help when making hacks or patches:

  • Can now parse a header from an existing .nes file with INCINES, or import the .nes file (header and all) with INCNES

  • Can seek to any arbitrary location (e.g. within an already-included binary file) to edit with SEEKABS x, SEEKREL x, and SKIPREL x (the lattermost also updates addr aka $) This allows jumping to locations without filling the bytes in-between.

The use case for these is that one might have an already-compiled .nes file that one wants to create a patch for, i.e. edit a particular part of the file (then use another program to generate a binary diff to create the patch like a .ips file. Perhaps in a future PR, .ips exporting can be done by asm6f directly?).

Since this is a new feature different from previous ones, I've updated the version number.

Bugfixes

  • Fixed some .nl addresses when $ is unset.

  • Fixed a couple bugs related to the ines/nes2 header. This was the biggest, located in the output function:

Before:

(byte)(inesmap_num & 0xF0) | (use_nes2 << 3) | (nes2tv_num << 7)

After

(byte)(inesmap_num & 0xF0) | (use_nes2 << 3) | (nes2vs_num)

the << 7 after nes2tv_num seems to be erroneous, so I removed that. On consulting the specifications, it seems that nes2vs_num should be there instead. (Previously, nes2vs_num was not output anywhere.)

Misc

  • cleaned up the output function, breaking it down into a couple different functions (output, output_file (which generates the output file if needed on a new pass), and flush_output (writes the current output buffer to the file))
  • extracted common pattern to replace file extension into its own functions, replace_ext and find_ext.
  • added a couple comments to the code.

@freem freem self-assigned this Feb 4, 2020
@nstbayless
Copy link
Author

Here is a source file showcasing the new patching directives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants