""" Extract sprites and background graphics from "Plan 9 From Outer Space" (PC) Copyright (C) 2010 Gil Megidish This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see """ from PIL import Image from struct import unpack ndx = open("plan9.ndx", "rb").read() offset = 2 index = 1 palette = None while offset < len(ndx): c = (ord(ndx[offset+0])) | (ord(ndx[offset+1]) << 8) | (ord(ndx[offset+2]) << 16) code = ord(ndx[offset+3]) print "%x code %d" % (c, code) offset += 4 if code == 2: f = open("plan9.gfx", "rb") f.seek(c, 0) size = unpack("