Skip to content

General Editing Commands

cxd4 edited this page Apr 11, 2016 · 6 revisions

Aside from the main documentation for the game's file data progress storage, there are a few generic commands not covered elsewhere.

They include: erase, copy, new, swap, and forcing the CPU endianness of the MIPS bytes.

Note that the option switches will be ugly things like -& and -|, because the English-alphabetical letter flag names tend to be reserved for the vast pool of game progress fields.

Minimalist File Update

Executing zs $FILE_PATH with no flags or switches will simply load the flash RAM file, analyze it for machine byte order and validity, and do any fixes (if necessary) to File 1's checksum and magic number to make sure the ROM doesn't dismiss File 1 as corrupted.

This command is useful when simply hex-editing the save file's machine code (instead of using this tool to do the save-editing automatically), as doing so without updating the 16-bit checksum every time will cause the ROM to dismiss all changes.

Selection of the Current File

zs $PATH "-@" (unsigned int) will redirect the program's cursor into the flash save file, to the game file specified by an octal digit, unsigned int. The default is page 0 of the flash RAM, which is File 1 on all versions. "-@" 1 will redirect to &flash_RAM[1 * FILE_SIZE], which is File 2 on all versions. Most other pages (e.g., "-@" 2) vary in purpose between the Japanese and non-Japanese ROM versions, so only 0 and 1 are really necessary to know. The maximum is 7.

Erase

  • zs $PATH "-&" will raise a run-time prompt asking whether to erase the file.
  • zs $PATH "-&" NOCONFIRM executes erasure of the current file without warning.
  • zs $PATH "-&" (any) (any) (as long as there are 4 arguments) will erase the entire file block but to all 1's: 0xFF, instead of the null byte (0x00).

New

  • zs $PATH "-|" will re-randomize the winning Lottery Shop numbers (in West Clock Town), the Bombers' hideout password, and the Oceanside Spider House's colored masks shoot order (hidden heart piece when hunting for skulltulas in great bay) as if a brand new file was allocated by the game.
  • zs $PATH "-|" (any) will try (in this author's humble opinion, pretty convincingly) to conduct the actual ROM's process of initializing the bytes of a brand new file.
  • zs $PATH "-|" "K[EEP]" will do like the previous but preserve Link's inventory (items and masks).

Note: None of those commands will wipe the entire file first. The Erase command (-&) must be executed first to wipe the whole game file. Simply New by itself will only fill in the non-zero things the game sets when creating a new file but will not memset the entire thing.

Swap

Quite usable, because if both File 1 and File 2 are in use by the USA ROM, then there is no way to switch their positions around without deleting one of them and then using the in-game "Copy" command.

zs $PATH "-^" (unsigned int) will interpret the octal number string as an unsigned int between 0o00 to 0o17 (15 in decimal), as there are 16 pages of game files in the flash RAM. (See Selection of the Current File, -@ for how to refer to File 1 and File 2 using this.) The resulting file's bytes will all be swapped with those of the currently selected file.

If the target game file is the same as the current, the operation is null and early-exited. Swapping File 1 with File 1 shall have no effect.

Copy

The syntax rules are the same as with Swap. The target game file will be copied into from the currently selected game file as pointed to by the -@ flag.

  • zs $PATH "-~" 0: copies the currently queued game file into File 1
  • zs $PATH "-~" 2: copies the currently queued game file into File 2

Again, such an operation where the destination and source match is a null one.

Force Output Endian

Finally, there is this command. The program has been written thoroughly to detect various byte orders within a 64-bit word boundary, but the two most important ones for most folks to know about are:

  • The "real" byte order, native to the big-endian MIPS CPU which the real Nintendo 64 hardware uses. Most people who are more deeply involved with the N64 home-brew or demo scenes will probably have some device that can flash the genuine cartridge's flash RAM save chip to a file which they can then use utilities like this save editor on.
  • The "emulator" byte order, native to the x86 32-bit little endian used by the flash RAM support in Nemu64, Project64, 1964, Mupen64 and others. The "tl;dr" for newbies will be that this is what they want, assuming they're using emulators.

There is not much reason to document this command since the automatic endian detection at start-up is already quite reliable. The only problem is if the entire save file is totally blank, in which case it is impossible to predict whether an inaccurate emulator or the real N64 generated it or which one the user intends to load the to-be-edited save file on to.

  • zs $PATH "-=" 0 will store finished save file as N64-native.
  • zs $PATH "-=" 1 will store finished file as 16-bit little endian.
  • zs $PATH "-=" 2 will store finished file as 32-bit halfword-swapped.
  • zs $PATH "-=" 3 will store finished file as 32-bit little endian.
  • zs $PATH "-=" 4 will store finished file as 64-bit word-swapped.
  • zs $PATH "-=" 7 will store finished file as 64-bit little endian.
Clone this wiki locally