Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 1.42 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.         return((InesHeader(
  26.                     rom[5]*16,
  27.                     rom[6]*8,
  28.                     Bool(rom[7] & 0b00001000),
  29.                     Bool(rom[7] & 0b00000100),
  30.                     Bool(rom[7] & 0b00000010),
  31.                     Bool(rom[7] & 0b00000001),
  32.                     if ((rom[8] & 0b00001100) >> 2) == 2
  33.                         true
  34.                     else
  35.                         false
  36.                     end,
  37.                     Bool(rom[8] * 0b00000010),
  38.                     Bool(rom[8] * 0b00000001),
  39.                     rom[9] * 8,
  40.                     Bool(rom[10] & 0x1),
  41.                     Bool(rom[11] & 0b00100000),
  42.                     Bool(rom[11] & 0b00010000),
  43.                     rom[11] & 0x3,
  44.                     (rom[7] & 0b11110000) | (rom[8] & 0b00001111)
  45.                     ), rom[16:end]))
  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