Class: Rnes::InesHeader
- Inherits:
-
Object
- Object
- Rnes::InesHeader
- Defined in:
- lib/rnes/ines_header.rb
Constant Summary collapse
- BYTESIZE =
16- PREFIX_BYTES =
[ 0x4E, # N 0x45, # E 0x53, # S 0x1A, # end-of-file in MS-DOS ].freeze
Instance Method Summary collapse
- #bytesize ⇒ Integer
- #character_ram_bytesize ⇒ Integer
- #character_rom_bytesize ⇒ Integer
- #has_battery_backed_program_rom_bit? ⇒ Boolean
- #has_mirror_ignoring_bit? ⇒ Boolean
- #has_trainer_bit? ⇒ Boolean
- #has_vertical_mirroring_bit? ⇒ Boolean
-
#initialize(bytes) ⇒ InesHeader
constructor
A new instance of InesHeader.
- #mapper_number ⇒ Integer
- #program_rom_bytesize ⇒ Integer
- #trainer_bytesize ⇒ Integer
- #valid? ⇒ Boolean
Constructor Details
#initialize(bytes) ⇒ InesHeader
Returns a new instance of InesHeader.
13 14 15 |
# File 'lib/rnes/ines_header.rb', line 13 def initialize(bytes) @bytes = bytes end |
Instance Method Details
#character_ram_bytesize ⇒ Integer
23 24 25 |
# File 'lib/rnes/ines_header.rb', line 23 def character_ram_bytesize @bytes[8] end |
#character_rom_bytesize ⇒ Integer
28 29 30 |
# File 'lib/rnes/ines_header.rb', line 28 def character_rom_bytesize @bytes[5] * 8 * 2**10 end |
#has_battery_backed_program_rom_bit? ⇒ Boolean
33 34 35 |
# File 'lib/rnes/ines_header.rb', line 33 def has_battery_backed_program_rom_bit? flags1[1] == 1 end |
#has_mirror_ignoring_bit? ⇒ Boolean
38 39 40 |
# File 'lib/rnes/ines_header.rb', line 38 def has_mirror_ignoring_bit? flags1[3] == 1 end |
#has_trainer_bit? ⇒ Boolean
Note:
Trainers are 512 bytes of code which is loaded into $7000 before the game starts for hacker use.
44 45 46 |
# File 'lib/rnes/ines_header.rb', line 44 def has_trainer_bit? flags1[2] == 1 end |
#has_vertical_mirroring_bit? ⇒ Boolean
49 50 51 |
# File 'lib/rnes/ines_header.rb', line 49 def has_vertical_mirroring_bit? flags1[0] == 1 end |
#mapper_number ⇒ Integer
54 55 56 |
# File 'lib/rnes/ines_header.rb', line 54 def mapper_number flags2 & 0b11110000 | flags1 >> 4 end |
#program_rom_bytesize ⇒ Integer
59 60 61 |
# File 'lib/rnes/ines_header.rb', line 59 def program_rom_bytesize @bytes[4] * 16 * 2**10 end |
#trainer_bytesize ⇒ Integer
64 65 66 67 68 69 70 |
# File 'lib/rnes/ines_header.rb', line 64 def trainer_bytesize if has_trainer_bit? 512 else 0 end end |
#valid? ⇒ Boolean
73 74 75 |
# File 'lib/rnes/ines_header.rb', line 73 def valid? @bytes[0..3] == PREFIX_BYTES end |