]> icculus.org git repositories - theoddone33/hheretic.git/blob - scripts/dumpendtext.py
Misc changes
[theoddone33/hheretic.git] / scripts / dumpendtext.py
1
2 from pyhexen.wad import *
3 import sys
4
5 def print_dos_string (str):
6         table = [ 30, 34, 32, 36, 31, 35, 33, 37 ]
7
8         i = 0
9         while i < len(str):
10                 c = str[i + 0] # character
11                 a = ord(str[i + 1]) # attribute
12
13                 fore = a & 15;
14                 back = (a & 112) >> 4;
15                 blink = a & 128;
16
17                 intens = (fore > 7) and 1 or 0
18
19                 fore = table[fore & 7]
20                 back = table[back] + 10
21
22                 if blink:
23                         print ('\033[%d;5;%dm\033[%dm%c' % (intens, fore, back, c)),
24                 else:
25                         print ('\033[%d;25;%dm\033[%dm%c' % (intens, fore, back, c)),
26                 i += 2
27
28         print ("\033[m");
29
30 w = WadReader()
31
32 w.InitMultipleFiles (sys.argv[1:])
33
34 print_dos_string (w.ReadLump (w.GetNumForName ('ENDTEXT')))
35