-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathview-death-sequences.py
56 lines (42 loc) · 1.13 KB
/
view-death-sequences.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
import Image
import string
import ega_palette
MAGIC = 0x33b0
def put_tile(image, tiledata, x, y):
bitmap = [chr(0)] * (48*48)
for ty in range(48):
for tx in range(48):
# get the four bits for this pixel
c0 = ord(tiledata[(tx >> 3) + (ty * 6) + MAGIC*0])
c1 = ord(tiledata[(tx >> 3) + (ty * 6) + MAGIC*1])
c2 = ord(tiledata[(tx >> 3) + (ty * 6) + MAGIC*2])
c3 = ord(tiledata[(tx >> 3) + (ty * 6) + MAGIC*3])
# build up a nibble
bit = 7 - (tx & 7)
color = ((c3 >> bit) & 1) << 3
color = color | (((c2 >> bit) & 1) << 2)
color = color | (((c1 >> bit) & 1) << 1)
color = color | (((c0 >> bit) & 1) << 0)
bitmap[ty*48 + tx] = chr(color)
s = string.joinfields(bitmap, '')
smallimage = Image.fromstring("P", (48, 48), s)
image.paste(smallimage, (x, y))
f = open("dave.exe", "rb")
f.seek(0x18a60)
data = f.read()
f.close()
im = Image.new("P", (48*5, 48*8))
im.im.putpalette("RGB", ega_palette.palette)
x = 0
y = 0
offset = 0
while y < 8:
tile = data[offset:]
offset = offset + (6*48)
put_tile(im, tile, x*48, y*48)
x = x + 1
if x == 5:
x = 0
y = y + 1
im.save("death-sequences.png")