mirror of
https://github.com/chocolate-doom/research.git
synced 2024-11-28 15:02:44 +00:00
8dfb24ef9b
Subversion-branch: /research Subversion-revision: 1851
44 lines
658 B
Ruby
Executable file
44 lines
658 B
Ruby
Executable file
#!/usr/bin/env ruby
|
|
|
|
require "scanf"
|
|
require "json"
|
|
|
|
filename = ARGV[0]
|
|
offset = ARGV[1].scanf("%x")[0]
|
|
|
|
NUM_MOBJS=137
|
|
|
|
def read_int(file)
|
|
c1 = file.getc
|
|
c2 = file.getc
|
|
c3 = file.getc
|
|
c4 = file.getc
|
|
|
|
c1 | (c2 << 8) | (c3 << 16) | (c4 << 24)
|
|
end
|
|
|
|
def read_mobj(file)
|
|
result = []
|
|
|
|
23.times do
|
|
i = read_int(file)
|
|
result.push(i)
|
|
end
|
|
|
|
result
|
|
end
|
|
|
|
states = []
|
|
|
|
File.open(filename) do |file|
|
|
file.seek(offset)
|
|
|
|
NUM_MOBJS.times do
|
|
states.push(read_mobj(file))
|
|
end
|
|
end
|
|
|
|
for state in states
|
|
puts state.to_json
|
|
end
|
|
|