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

From NESdev Wiki
Jump to navigationJump to search
(Created page with "This file describes the format of <tt>ines.map</tt> and <tt>unif.map</tt> files used with DotFami. The file is a plain ASCII file which is preprocessed...")
 
No edit summary
Line 7: Line 7:
==Keywords==
==Keywords==
  crc
  crc
default
  function
  function
  if
  if
Line 46: Line 47:
==Cases==
==Cases==
A case in a switch is formatted as either a string literal or a constant expression, followed by <tt>{</tt> statements <tt>}</tt>
A case in a switch is formatted as either a string literal or a constant expression, followed by <tt>{</tt> statements <tt>}</tt>
The last case must be <tt>default</tt> instead of an expression and contains statements if none of the other cases match.


==Variables==
==Variables==
Line 55: Line 58:
* Parameters to procedures and functions are also acting like local variables which are already assigned.
* 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.
* 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, <tt>use</tt> statements, and <tt>parameter</tt> 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 <tt>use</tt> and <tt>parameter</tt> statements are not allowed in a function.
* The last statement (even inside a <tt>if</tt> or <tt>switch</tt>) should be an expression by itself which is the return value of this function.
==Expressions==
* <tt>mapper</tt>: For iNES, the mapper number. For UNIF, the mapper name (as a string).
* <tt>submapper</tt>: NES 2.0 submapper number (0 for old iNES files). For UNIF, includes flags such as battery RAM and so on.
* <tt>romsize</tt> expression: The expression a number 0 to 15 for PRG ROM, or 16 to 31 for CHR ROM. This indicates the size in bytes.
* <tt>rom</tt> expression: The expression is address (starting at PRG ROM 0, ..., CHR ROM 15) and returns the data byte at that address.
* <tt>crc</tt> expression: Expression is same as for <tt>romsize</tt> but result in CRC32 of ROM.
* Strings can be compared using <tt>==</tt> and <tt>!=</tt> only, and arithmetic may not be performed on strings.
* name <tt>(</tt> parameters <tt>)</tt>: Make a function call.
==Miscellaneous==
The <tt>parameter</tt> 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 <tt>use</tt> 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 <tt>.cart</tt> file.

Revision as of 22:43, 19 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
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). For UNIF, includes flags such as battery RAM 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.
  • 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.

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.