Misc changes
authorDan Olson <theoddone33@icculus.org>
Wed, 6 Aug 2008 10:16:46 +0000 (03:16 -0700)
committerDan Olson <theoddone33@icculus.org>
Wed, 6 Aug 2008 10:16:46 +0000 (03:16 -0700)
.gitignore
base/i_linux.c
dumpwad.py
pyhexen/wad.py
scripts/dumpendtext.py [new file with mode: 0644]

index 78f08dd..7e097a0 100644 (file)
@@ -6,3 +6,4 @@ heretic.cfg
 hheretic-gl
 include/config.h
 *.pyc
+*.wad
index 0110a4c..8463c51 100644 (file)
@@ -1032,11 +1032,11 @@ void put_dos2ansi (byte attrib)
 {
        byte fore,back,blink=0,intens=0;
        int table[] = {30,34,32,36,31,35,33,37};
-       
+
        fore = attrib&15;       // bits 0-3
        back = attrib&112; // bits 4-6
-               blink = attrib&128; // bit 7
-       
+       blink = attrib&128; // bit 7
+
        // Fix background, blink is either on or off.
        back = back>>4;
 
index e3c829f..bebaa8e 100644 (file)
@@ -1,8 +1,8 @@
 
 import sys
-import pyhexen.wad as wad
+from pyhexen.wad import *
 
-myWad = wad.wad()
+myWad = WadReader()
 
 print ("Loading wads...")
 myWad.InitMultipleFiles (sys.argv[1:])
index bee8980..5eb1cba 100644 (file)
@@ -6,12 +6,13 @@ from struct import *
 class WadException(Exception):
        pass
 
-class wad:
+class WadBase:
        wadinfo_t = '<4sii'
        wadinfo_size = calcsize (wadinfo_t)
        filelump_t = '<ii8s'
        filelump_size = calcsize (filelump_t)
 
+class WadReader:
        def __init__(self):
                self.lumps = []
 
@@ -27,7 +28,7 @@ class wad:
                lumpinfo = []
                if ext.lower() == '.wad':
                        # yay, a wad file.
-                       (id, numLumps, infoTable) = unpack (wad.wadinfo_t, fileHandle.read(wad.wadinfo_size))
+                       (id, numLumps, infoTable) = unpack (WadBase.wadinfo_t, fileHandle.read(WadBase.wadinfo_size))
 
                        if id != 'IWAD' and id != 'PWAD':
                                raise WadException("Wad file %s doesn't have IWAD or PWAD id" % filename)
@@ -35,7 +36,7 @@ class wad:
                        fileHandle.seek (infoTable)
 
                        for i in range (0, numLumps):
-                               lumpinfo.append (unpack (wad.filelump_t, fileHandle.read(wad.filelump_size)))
+                               lumpinfo.append (unpack (WadBase.filelump_t, fileHandle.read(WadBase.filelump_size)))
                else:
                        # single file, boring.
                        size = os.stat (filename).st_size
@@ -56,8 +57,6 @@ class wad:
                return len (self.lumps)
 
        def CheckNumForName (self, name):
-               # meh sucky in-place crappy way to do
-               # stuff :(
                searchName = name.upper()[:8]
                for (x, y) in enumerate (reversed(self.lumps)):
                        (handle, pos, length, name) = y
@@ -86,4 +85,3 @@ class wad:
        def CacheLumpName (self, name, tag):
                return self.CacheLumpNum (self.GetNumForName (name), tag)
 
-
diff --git a/scripts/dumpendtext.py b/scripts/dumpendtext.py
new file mode 100644 (file)
index 0000000..0e32100
--- /dev/null
@@ -0,0 +1,35 @@
+
+from pyhexen.wad import *
+import sys
+
+def print_dos_string (str):
+       table = [ 30, 34, 32, 36, 31, 35, 33, 37 ]
+
+       i = 0
+       while i < len(str):
+               c = str[i + 0] # character
+               a = ord(str[i + 1]) # attribute
+
+               fore = a & 15;
+               back = (a & 112) >> 4;
+               blink = a & 128;
+
+               intens = (fore > 7) and 1 or 0
+
+               fore = table[fore & 7]
+               back = table[back] + 10
+
+               if blink:
+                       print ('\033[%d;5;%dm\033[%dm%c' % (intens, fore, back, c)),
+               else:
+                       print ('\033[%d;25;%dm\033[%dm%c' % (intens, fore, back, c)),
+               i += 2
+
+       print ("\033[m");
+
+w = WadReader()
+
+w.InitMultipleFiles (sys.argv[1:])
+
+print_dos_string (w.ReadLump (w.GetNumForName ('ENDTEXT')))
+