Internal Name

From TLoZ: ALTTP Hacking Resources
Jump to: navigation, search

See also: Standard Notation

The internal name of a LoROM SNES game like ALTTP is a simple 21-character ASCII string located at $7FC0[$15], intended for use only by people working with the development and certification of the game. All internal names shorter than 21 characters in length must be padded to full length by adding extra ASCII space characters at the end.

ALTTP itself does not read or use its internal name for any purpose, so you may safely change it to any valid printable ASCII string you desire. To create such a string with modern programming languages, create a standard Unicode string that includes only the characters U+20 through U+7E, pad the length of the string to 21 code points by adding additional U+20, then encode it as UTF-8 (with NO byte-order mark).

Sample C# Code

public static class SnesInternalName
{
	public const int RomOffsetToInternalName = 0x7FC0 , InternalNameLength = 21 ;

	public static void WriteInternalName ( byte [ ] Data , string Name )
	{
		if ( Name . Length < InternalNameLength )
		{
			Name = new System . Text . StringBuilder ( Name , InternalNameLength ) . Append ( ' ' , InternalNameLength - Name . Length ) . ToString ( ) ;
		}

		byte [ ] NameBytes = new System . Text . UTF8Encoding ( false ) . GetBytes ( Name ) ;

		System . Array . Copy ( NameBytes , 0 , Data , RomOffsetToInternalName , InternalNameLength ) ;
	}

	public static string ReadInternalName ( byte [ ] Data )
	{
		int NameLength = InternalNameLength ;

		while ( Data [ RomOffsetToInternalName + NameLength - 1 ] == 0x20 )
		{
			NameLength -- ;
		}

		return ( System . Text . Encoding . UTF8 . GetString ( Data , RomOffsetToInternalName , NameLength ) ) ;
	}
}