Seasons.NET

ちょっとした技術ブログです

ROMの空きを指定コードで埋める

 1 $KCODE = "s"
 2 
 3 MaxRomSize = 0x800000
 4 EmptyFillCode = 0xff
 5 BinaryFormat = "*.bin"
 6 
 7 romlist = Dir.glob(BinaryFormat)
 8 data = []
 9 if romlist.length == 1
10   romname = romlist.shift
11   romSize = File.size( romname )
12   emptysize = 0
13   emptysize = MaxRomSize - romSize if MaxRomSize > romSize
14   return if emptysize == 0
15   open( romname , "r" ){ |f| f.binmode; data = f.read.unpack("C*") + Array.new(emptysize,EmptyFillCode) }
16   open( romname + ".bin" , "w" ){ |f| f.binmode; f << data.pack("C*") }
17 end