system/cartridge.js
function() {
		if ( !( this.header[0] === 0x4e && // 'N'
		        this.header[1] === 0x45 && // 'E'
		        this.header[2] === 0x53 && // 'S'
		        this.header[3] === 0x1a // ending character
		)) {
			throw new Error("Invalid ROM!");
		}
		
		if ( this.header[7] & 0xe ) {
			throw new Error("Bit 1-3 of byte 7 in ROM header must all be zeroes!");
		}
		
		if ( this.header[9] & 0xfe ) {
			throw new Error("Bit 1-7 of byte 9 in header must all be zeroes!");
		}
		
		var i;
		for ( i=10; i <= 15; i++ ) {
			if ( this.header[i] ) {
				throw new Error("Byte " + i + " in ROM header must be zero.");
			}
		}
		
		if ( this.header[6] & 0x4 ) {
			// TODO support trainers
			throw new Error("Trained ROMs are not supported");
		}
	}
function() {
		if ( !( this.header[0] === 0x4e && // 'N'
		        this.header[1] === 0x45 && // 'E'
		        this.header[2] === 0x53 && // 'S'
		        this.header[3] === 0x1a // ending character
		)) {
			throw new Error("Invalid ROM!");
		}
		
		if ( this.header[7] & 0xe ) {
			throw new Error("Bit 1-3 of byte 7 in ROM header must all be zeroes!");
		}
		
		if ( this.header[9] & 0xfe ) {
			throw new Error("Bit 1-7 of byte 9 in header must all be zeroes!");
		}
		
		var i;
		for ( i=10; i <= 15; i++ ) {
			if ( this.header[i] ) {
				throw new Error("Byte " + i + " in ROM header must be zero.");
			}
		}
		
		if ( this.header[6] & 0x4 ) {
			// TODO support trainers
			throw new Error("Trained ROMs are not supported");
		}
	}
function ( ) { if ( ! ( this . header [ 0 ] === 0x4e && // 'N' this . header [ 1 ] === 0x45 && // 'E' this . header [ 2 ] === 0x53 && // 'S' this . header [ 3 ] === 0x1a // ending character ) ) { throw new Error ( "Invalid ROM!" ) ; } if ( this . header [ 7 ] & 0xe ) { throw new Error ( "Bit 1-3 of byte 7 in ROM header must all be zeroes!" ) ; } if ( this . header [ 9 ] & 0xfe ) { throw new Error ( "Bit 1-7 of byte 9 in header must all be zeroes!" ) ; } var i ; for ( i = 10 ; i <= 15 ; i ++ ) { if ( this . header [ i ] ) { throw new Error ( "Byte " + i + " in ROM header must be zero." ) ; } } if ( this . header [ 6 ] & 0x4 ) { // TODO support trainers throw new Error ( "Trained ROMs are not supported" ) ; } }
Validate INES header.
Throws an exception if invalid.
Validate INES header . Throws an exception if invalid .