-
-
Save asm256/a81d7697e7315c24d93e to your computer and use it in GitHub Desktop.
もっと!?不思議の幻想郷体験版のbinファイルをzipに変換
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ruby -Ku | |
#もっと!?不思議の幻想郷体験版のbinファイルをzipに変換 | |
#↓のname=のところを書換えて使う | |
require 'rubygems' | |
require 'kconv' | |
require 'zipruby' | |
name = 'd300' | |
class NFA0File | |
def read(size) | |
readN(size).pack('C*') | |
end | |
def readf(size,format) | |
read(size).unpack(format)[0] | |
end | |
def readN(size) | |
buf = @f.read size | |
buf.unpack('C*').map{|x| x ^ 8} | |
end | |
def readZ(size) | |
buf = @f.read size | |
buf.unpack('v*').map{|x| x ^ 0x808}.pack('C*').unpack('Z*')[0] | |
end | |
def initialize(freader) | |
@f = freader | |
@unk = read 8 | |
@size = readf(4,'L') | |
@offset = readf(4,'L') | |
@unk2 = read 4 | |
@name = readZ 0x80 | |
end | |
def dump | |
@f.seek @offset | |
read @size | |
end | |
def fname | |
@name | |
end | |
end | |
Zip::Archive.open("#{name}.zip", Zip::CREATE){|ar| | |
open("#{name}.bin" , "rb"){|fin| | |
fin.read 4 | |
fin.read 4 | |
num = fin.read(4).unpack('L')[0] | |
fin.read 4 | |
files = [] | |
num.times{ | |
files << NFA0File.new(fin) | |
p files[-1].fname | |
} | |
i = 0 | |
files.each{|nff| | |
i += 1 | |
print "\r#{i}/#{num} :#{nff.fname}" | |
ar.add_buffer(nff.fname , nff.dump) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment