User:Zzo38/ines.map and unif.map: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 85: Line 85:


==iNES Flags==
==iNES Flags==
* bit3-bit0: Low four bits if iNES Flags 6.
* bit3-bit0: Low four bits of iNES Flags 6.
* bit7-bit4: Low four bits if iNES Flags 7. If the two unused bits of iNES are 10 then use NES 2.0 format; if 01 or 11 then treat this entire byte and all following as zero (so, also the remaining iNES flags in ines.map); if 00 then use old iNES format, using Flags 7 but ignoring the rest of the header.
* bit7-bit4: Low four bits of iNES Flags 7. If the two unused bits of iNES are 10 then use NES 2.0 format; if 01 or 11 then treat this entire byte and all following as zero (so, also the remaining iNES flags in ines.map); if 00 then use old iNES format, using Flags 7 but ignoring the rest of the header.
* bit11-bit8: Non-battery PRG RAM size (NES 2.0 RAM size lookup table).
* bit11-bit8: Non-battery PRG RAM size (NES 2.0 RAM size lookup table).
* bit15-bit12: Battery PRG RAM size (NES 2.0 RAM size lookup table).
* bit15-bit12: Battery PRG RAM size (NES 2.0 RAM size lookup table).

Revision as of 20:00, 24 August 2012

This file describes the format of ines.map and unif.map files used with DotFami.

The file is a plain ASCII file which is preprocessed with the C preprocessor and uses a C-like syntax. All constant operators (other than sizeof) are the same as in C, including the same precedence.

All data is signed 64-bit integers. ASCII character constants can be used, and you can use decimal, hexadecimal, and octal constants, same as in C.

Keywords

crc
default
flags
function
if
local
mapper
parameter
procedure
rom
romsize
submapper
switch
use

Outer Codes

At the top (outer) level of the file, the following statements are allowed:

  • variable = expression ;
  • parameter expression = expression ;
  • use string ;
  • if( condition ) statement
  • if( condition ) statement else statement
  • { statements }
  • switch( expression ) { cases }
  • function name ( parameters ) { statements }
  • procedure name ( parameters ) { statements }
  • procedurename ( parameters );

Inner Codes

Where statement(s) are expected at inner level, the following is acceptable:

  • variable = expression ;
  • parameter expression = expression ;
  • use string ;
  • if( condition ) statement
  • if( condition ) statement else statement
  • { statements }
  • switch( expression ) { cases }
  • local variables (only inside a {} block)
  • procedurename ( parameters );

Cases

A case in a switch is formatted as either a string literal or a constant expression, followed by { statements }

The last case must be default instead of an expression and contains statements if none of the other cases match.

Variables

  • Each variable may only be assigned once and must be assigned before used.
  • Some variables can be local to a block, which case they are accessible only within that block.
  • If a condition or switch statement contains blocks which assign variables not local to those blocks, then all cases must assign the same set of variables (not counting variables local to those blocks).
  • A procedure may also assign global variables.
  • Variables store 64-bit values.
  • Parameters to procedures and functions are also acting like local variables which are already assigned.
  • Strings can also be assigned to variables although they cannot be used as a number if they do.

Procedures

  • Procedures must be declared before used.
  • Recursive calls are not allowed.
  • Same rules for variables, use statements, and parameter statements apply to procedures, just as if its contents are placed where the procedure is called from.

Functions

  • Functions must be declared before used.
  • Recursive calls are not allowed.
  • A function call is made inside of an expression.
  • Only local variables may be assigned in a function.
  • Procedure calls are not allowed in a function.
  • The use and parameter statements are not allowed in a function.
  • The last statement (even inside a if or switch) should be an expression by itself which is the return value of this function.

Expressions

  • mapper: For iNES, the mapper number. For UNIF, the mapper name (as a string).
  • submapper: NES 2.0 submapper number (0 for old iNES files).
  • flags: Used in both iNES and UNIF; includes flags such as battery RAM, mirroring, and so on.
  • romsize expression: The expression a number 0 to 15 for PRG ROM, or 16 to 31 for CHR ROM. This indicates the size in bytes. (iNES uses only 0 and 16 and all other ROM sizes will be zero.)
  • rom expression: The expression is address (starting at PRG ROM 0, ..., CHR ROM 15) and returns the data byte at that address.
  • crc expression: Expression is same as for romsize but result in CRC32 of ROM.
  • Strings can be compared using == and != only, and arithmetic may not be performed on strings.
  • name ( parameters ): Make a function call.

iNES Flags

  • bit3-bit0: Low four bits of iNES Flags 6.
  • bit7-bit4: Low four bits of iNES Flags 7. If the two unused bits of iNES are 10 then use NES 2.0 format; if 01 or 11 then treat this entire byte and all following as zero (so, also the remaining iNES flags in ines.map); if 00 then use old iNES format, using Flags 7 but ignoring the rest of the header.
  • bit11-bit8: Non-battery PRG RAM size (NES 2.0 RAM size lookup table).
  • bit15-bit12: Battery PRG RAM size (NES 2.0 RAM size lookup table).
  • bit19-bit16: Non-battery CHR RAM size (NES 2.0 RAM size lookup table).
  • bit23-bit20: Battery CHR RAM size (NES 2.0 RAM size lookup table).

UNIF Flags

  • bit7-bit0: Mirroring setting.
  • bit8: Presence of UNIF "BATR" chunk.
  • bit9: Presence of UNIF "VROR" chunk.
  • bit10: Presence of UNIF "MIRR" chunk.

Miscellaneous

The parameter statement is optional and the first expression is the parameter number (0 to 255 only); each parameter can be assigned a maximum of one time, but it is not necessary that if it is assigned in one case that it must be assigned in the other cases as well.

The use statement must occur exactly once, using the same restrictions as assignment to variables. The string parameter can be a variable storing a string, or a string literal, which specifies the filename for a .cart file.

Errors

In case of division by zero or anything that violates the specifications here, there is no guarantee of what it will do, including it might crash. However, it might just display an error message instead.