Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 1.53 KB | None | 0 0
  1. abstract Rom
  2.  
  3. type InesHeader
  4.     PrgRomSize::UInt8
  5.     ChrRomSize::UInt8
  6.     IgnoreMirror::Bool
  7.     Trainer::Bool
  8.     HasBatteryRam::Bool
  9.     Mirror::Bool
  10.     IsNES2Format::Bool
  11.     Arcade2::Bool
  12.     Arcade1::Bool
  13.     PrgRamSize::UInt8
  14.     TVSystem::Bool
  15.     BusConflict::Bool
  16.     PrgRam::Bool
  17.     TVSystem2::UInt8
  18.     Mapper::UInt8
  19. end
  20. type Ines <: Rom
  21.     Header::InesHeader
  22.     Rom::Array{UInt8,1}
  23.     Ines(file::String) = begin
  24.         rom = Mmap.mmap(file)
  25.         PrgRomSize = rom[5]*16,
  26.         ChrRomSize = rom[6]*8,
  27.         IgnoreMirror = Bool(rom[7] & 0b00001000),
  28.         Trainer = Bool(rom[7] & 0b00000100),
  29.         HasBatteryRam = Bool(rom[7] & 0b00000010),
  30.         Mirror = Bool(rom[7] & 0b00000001),
  31.         IsNES2Format = if ((rom[8] & 0b00001100) >> 2) == 2
  32.             true
  33.         else
  34.             false
  35.         end,
  36.         Arcade2 = Bool(rom[8] * 0b00000010),
  37.         Arcade1 = Bool(rom[8] * 0b00000001),
  38.         PrgRamSize = rom[9] * 8,
  39.         TVSystem = Bool(rom[10] & 0x1),
  40.         BusConflict = Bool(rom[11] & 0b00100000),
  41.         PrgRam = Bool(rom[11] & 0b00010000),
  42.         TVSystem2 = rom[11] & 0x3,
  43.         Mapper = (rom[7] & 0b11110000) | (rom[8] & 0b00001111)
  44.         contents = rom[17:end]
  45.         new(InesHeader(PrgRomSize, ChrRomSize, IgnoreMirror, Trainer, HasBatteryRam, Mirror, IsNES2Format, Arcade2, Arcade1, PrgRamSize, TVSystem, BusConflict, PrgRam, TVSystem2, Mapper), contents)
  46.     end
  47. end
  48. test_rom = Ines("/home/john/Code/ksy/specimens/ines/2600\ Bros\ (SMB1\ Hack).nes")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement