asm6f icon indicating copy to clipboard operation
asm6f copied to clipboard

Patching directives

Open nstbayless opened this issue 6 years ago • 1 comments

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.

nstbayless avatar Feb 03 '20 03:02 nstbayless

Here is a source file showcasing the new patching directives.

nstbayless avatar Feb 05 '20 17:02 nstbayless