CinnamonPirate.com

NINJA File Format Specifications 2.0

N

INJA 2.0 follows a much simpler file format than its predecessor. Each patch consists of 3 regions: HEADER, INFO and DATA. HEADER and INFO make up the first sector of the patch (1024 bytes).

@HEADER@
{
  NINJA_MAGIC - string "NINJA" (5 bytes)
  NINJA_VER   - char "2"       (1 byte )
}

@INFO@
{
  // Info text encoding
  PATCH_ENC   - int ENC      (   1 byte )
    // 0: System codepage / 1: UTF-8
  // Author
  PATCH_AUTH  - string AUTH  (  84 bytes)
  // Version
  PATCH_VER   - string VER   (  11 bytes)
  // Title
  PATCH_TITLE - string TITLE ( 256 bytes)
  // Genre
  PATCH_GENRE - string GENRE (  48 bytes)
  // Language
  PATCH_LANG  - string LANG  (  48 bytes)
  // Date as YYYYMMDD
  PATCH_DATE  - string DATE  (   8 bytes)
  // Web site
  PATCH_WEB   - string WEB   ( 512 bytes)
  // Info (New line marked by "\n")
  PATCH_DESC  - string DESC  (1074 bytes)
}

@DATA@
{
  COMMAND     - int COMMAND  (  1 byte )

  if COMMAND == 0x1     // Open File|Close Current
  {
    // 0 Signals single-file
    FILE_N_MUL    - int N_MUL     (        1 byte )
    // Length of file name
    FILE_N_LEN    - int N_LEN     (    N_MUL bytes)
    // File name
    FILE_NAME     - string NAME   (    N_LEN bytes)
    // File format
    FILE_TYPE     - int TYPE      (        1 byte )
    FILE_SSIZE_MUL- int SSIZE_MUL (        1 byte )
    // Source file size
    FILE_SSIZE    - int SIZE      (SSIZE_MUL bytes)
    FILE_MSIZE_MUL- int MSIZE_MUL (        1 byte )
    // Modified file size
    FILE_MSIZE    - int MIZE      (MSIZE_MUL bytes)
    // Source MD5sum
    FILE_SMD5     - string SMD5   (       16 bytes)
    // Modified MD5sum
    FILE_MMD5     - string MMD5   (       16 bytes)

    if SSIZE > MSIZE
    {
      // Source overflow
      FILE_MAGIC   - char "M"        (       1 byte )
      FILE_OVER_MUL- int OVER_MUL    (       1 byte )
      // Overflow length
      FILE_OVER    - int OVER        (OVER_MUL bytes)
      // Lost from modified
      FILE_OVERFLOW- string OVERFLOW (    OVER bytes)
    }

    else if MSIZE > SSIZE
    {
      // Modified overflow
      FILE_MAGIC   - char "A"        (       1 byte )
      FILE_OVER_MUL- int OVER_MUL    (       1 byte )
      // Overflow length
      FILE_OVER    - int OVER        (OVER_MUL bytes)
      // Gained in modified
      FILE_OVERFLOW- string OVERFLOW (    OVER bytes)
    }
  }

  else if COMMAND == 02 // XOR Patch
  {
    PATCH_OFF_MUL- int OFF_MUL (      1 byte )
    // Patch offset
    PATCH_OFF    - int OFF     (OFF_MUL bytes)
    PATCH_LEN_MUL- int LEN_MUL (      1 byte )
    // Patch length
    PATCH_LEN    - int LEN     (LEN_MUL bytes)
    // XOR string
    PATCH_XOR    - string XOR  (    LEN bytes)
  }

  else if COMMAND == 0x0
    // Terminate patch
}