mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-09-09 09:51:34 -07:00
Allow {patch offset length}
(necessary for pokegold)
This commit is contained in:
parent
f33a041930
commit
732acf1d4f
@ -88,11 +88,11 @@ Any other characters are output as-is.
|
||||
## Patch template commands
|
||||
|
||||
|
||||
### <code>{patch[ <i>offset</i>]}</code>
|
||||
### <code>{patch[ <i>offset</i>[ <i>length</i>]]}</code>
|
||||
|
||||
Outputs the bytes of the current patch as a value series, or as a hexadecimal number if there is only one byte. The bytes are found between the current patch label, and the label which is the current patch label plus "`_End`". An optional argument is an *offset* to add to the current patch label before gathering the contents between it and the end label.
|
||||
Outputs the bytes of the current patch as a value series, or as a hexadecimal number if there is only one byte. The bytes are found between the current patch label, and the label which is the current patch label plus "`_End`". An optional first argument is an *offset* to add to the current patch label before gathering the contents between it and the end label. An optional second argument is a *length* of bytes to output instead of the length between the start and end labels.
|
||||
|
||||
For example, if "`{patch}`" outputs "`a3:ab cd ef`", then "`{patch +1}`" outputs "`a2:cd ef`", and "`{patch +2}`" outputs "`0xef`".
|
||||
For example, if "`{patch}`" outputs "`a3:ab cd ef`", then "`{patch +1}`" outputs "`a2:cd ef`", and "`{patch +1 1}`" outputs "`0xcd`".
|
||||
|
||||
Converting the patch template will print a warning if any differences exist between the original and patched ROMs, which are not covered by "`patch`" commands.
|
||||
|
||||
|
@ -214,6 +214,9 @@ void interpret_command(char *command, const struct Symbol *current_hook, const s
|
||||
|
||||
// Use the arguments
|
||||
if (!strcmp(command, "patch") || !strcmp(command, "PATCH") || !strcmp(command, "patch_") || !strcmp(command, "PATCH_")) {
|
||||
if (argc > 2) {
|
||||
error_exit("Error: Invalid arguments for command: \"%s\"", command);
|
||||
}
|
||||
if (!current_hook) {
|
||||
error_exit("Error: No current patch for command: \"%s\"", command);
|
||||
}
|
||||
@ -224,8 +227,13 @@ void interpret_command(char *command, const struct Symbol *current_hook, const s
|
||||
if (fseek(new_rom, current_offset, SEEK_SET)) {
|
||||
error_exit("Error: Cannot seek to \"vc_patch %s\" in the new ROM\n", current_hook->name);
|
||||
}
|
||||
int length;
|
||||
if (argc == 2) {
|
||||
length = parse_number(argv[1], 0);
|
||||
} else {
|
||||
const struct Symbol *current_hook_end = symbol_find_cat(symbols, current_hook->name, "_End");
|
||||
int length = current_hook_end->offset - current_offset;
|
||||
length = current_hook_end->offset - current_offset;
|
||||
}
|
||||
buffer_append(patches, &(struct Patch){current_offset, length});
|
||||
bool modified = false;
|
||||
if (length == 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user