import struct
import array
import itertools
from mrcrowbar import models as mrc
from mrcrowbar.lib.hardware import ibm_pc
from mrcrowbar.lib.images import base as img
from mrcrowbar import utils
# source: http://ttf.mine.nu/techdocs.htm
[docs]
class SplashEGA( mrc.Block ):
image_data = mrc.Bytes( 0x0000, transform=img.Planarizer( bpp=4, width=320, height=200 ) )
def __init__( self, *args, **kwargs ):
mrc.Block.__init__( self, *args, **kwargs )
self.image = img.IndexedImage( self, width=320, height=200, palette=ibm_pc.EGA_DEFAULT_PALETTE, source=mrc.Ref( 'image_data' ) )
[docs]
class SplashVGA( mrc.Block ):
palette = mrc.BlockField( ibm_pc.VGAColour, 0x0000, count=256 )
image_data = mrc.Bytes( 0x0300 )
def __init__( self, *args, **kwargs ):
mrc.Block.__init__( self, *args, **kwargs )
self.image = img.IndexedImage( self, width=320, height=200, palette=mrc.Ref( 'palette' ), source=mrc.Ref( 'image_data' ) )
# TODO: add method to scrape this table from the EXE file
SPREXP_SQZ_SIZE_TABLE = (
(32, 31), (32, 32), (24, 32), (24, 32), (32, 31), (32, 26), (32, 15), (32, 16),
(32, 32), (32, 32), (24, 31), (24, 32), (24, 32), (32, 29), (32, 28), (32, 32),
(24, 31), (24, 32), (24, 32), (32, 32), (24, 31), (24, 32), (24, 29), (32, 32),
(32, 32), (32, 32), (32, 32), (32, 32), (32, 32), (32, 31), (24, 30), (24, 23),
(16, 16), (16, 16), (24, 20), (16, 16), (16, 14), (8, 16), (16, 16), (16, 15),
(16, 21), (24, 10), (16, 9), (24, 4), (8, 6), (24, 17), (16, 5), (16, 7),
(16, 5), (32, 9), (48, 8), (40, 5), (40, 5), (32, 17), (16, 11), (16, 16),
(40, 32), (32, 32), (24, 12), (8, 8), (16, 9), (32, 21), (24, 11), (24, 17),
(32, 16), (24, 20), (32, 25), (32, 22), (16, 23), (24, 17), (16, 9), (32, 13),
(32, 24), (16, 11), (16, 21), (32, 19), (32, 16), (32, 15), (32, 15), (24, 30),
(16, 25), (24, 21), (32, 17), (32, 22), (40, 8), (16, 29), (16, 8), (16, 7),
(16, 7), (24, 29), (16, 9), (16, 15), (32, 9), (32, 23), (32, 8), (16, 23),
(32, 21), (48, 33), (16, 12), (16, 12), (16, 13), (40, 32), (32, 33), (24, 32),
(32, 33), (40, 30), (48, 33), (48, 33), (48, 40), (48, 33), (32, 33), (32, 32),
(24, 33), (24, 32), (40, 33), (40, 33), (40, 33), (40, 31), (40, 35), (40, 32),
(40, 40), (24, 25), (24, 27), (56, 35), (32, 61), (56, 29), (24, 19), (24, 16),
(24, 20), (32, 20), (24, 20), (32, 27), (32, 28), (32, 32), (40, 32), (40, 19),
(40, 21), (40, 19), (32, 25), (32, 25), (40, 28), (40, 36), (32, 35), (40, 36),
(32, 35), (32, 32), (32, 32), (32, 40), (40, 32), (40, 16), (40, 37), (32, 30),
(24, 29), (24, 30), (24, 18), (24, 17), (24, 19), (40, 21), (32, 21), (32, 41),
(32, 42), (32, 41), (32, 41), (32, 41), (56, 41), (32, 50), (40, 40), (32, 36),
(16, 15), (16, 9), (16, 14), (16, 11), (32, 7), (32, 9), (32, 10), (32, 18),
(32, 27), (32, 27), (32, 27), (32, 27), (40, 14), (32, 22), (40, 27), (40, 33),
(40, 24), (32, 18), (32, 35), (32, 38), (32, 37), (32, 38), (32, 37), (32, 38),
(32, 31), (56, 23), (32, 31), (40, 31), (48, 28), (32, 49), (32, 49), (24, 49),
(32, 34), (32, 35), (32, 35), (32, 29), (40, 31), (40, 33), (40, 31), (24, 33),
(24, 31), (32, 33), (32, 39), (40, 26), (32, 41), (32, 34), (24, 11), (24, 16),
(24, 30), (32, 32), (40, 35), (48, 28), (48, 19), (32, 11), (32, 26), (40, 26),
(40, 35), (48, 26), (40, 27), (32, 17), (32, 17), (40, 26), (40, 25), (40, 20),
(32, 26), (32, 26), (40, 26), (32, 26), (24, 39), (40, 38), (32, 38), (40, 37),
(40, 37), (32, 37), (16, 24), (16, 40), (24, 30), (40, 38), (40, 30), (32, 24),
(40, 50), (40, 54), (64, 59), (64, 49), (64, 55), (48, 50), (48, 61), (48, 48),
(48, 42), (56, 52), (48, 46), (72, 47), (48, 52), (56, 52), (24, 33), (56, 61),
(56, 59), (56, 60), (56, 60), (48, 58), (32, 35), (32, 35), (32, 35), (32, 39),
(48, 45), (48, 43), (40, 23), (40, 40), (40, 41), (48, 40), (56, 52), (48, 31),
(16, 16), (16, 16), (40, 51), (48, 53), (40, 55), (40, 55), (40, 56), (40, 55),
(40, 56), (32, 39), (32, 36), (32, 38), (32, 38), (32, 37), (32, 38), (32, 38),
(32, 39), (32, 36), (32, 54), (24, 54), (32, 53), (24, 54), (24, 53), (40, 32),
(24, 32), (32, 31), (24, 32), (24, 31), (32, 27), (40, 37), (40, 38), (40, 38),
(32, 15), (40, 49), (24, 38), (24, 41), (32, 37), (24, 41), (16, 15), (16, 16),
(16, 16), (24, 21), (24, 24), (24, 21), (16, 21), (24, 30), (16, 25), (8, 9),
(32, 21), (56, 101), (64, 99), (88, 78), (64, 69), (64, 45), (80, 41), (72, 55),
(80, 41), (32, 33), (40, 30), (40, 33), (40, 35), (40, 34), (40, 33), (32, 34),
(24, 34), (32, 34), (40, 34), (16, 10), (24, 14), (24, 19), (24, 24), (32, 26),
(32, 28), (40, 32), (32, 33), (16, 9)
)
[docs]
class ZIVCompressor( mrc.Transform ):
[docs]
def import_data( self, buffer, parent=None ):
assert utils.is_bytes( buffer )
decompressed_size = ((buffer[0] & 0x0f) << 16) + (buffer[2] << 8) + buffer[3]
[docs]
class Loader( mrc.Loader ):
_SEP = mrc.Loader._SEP
TITUS_FILE_CLASS_MAP = {
#_SEP+'(TITRE).SQZ$': SplashVGA,
#_SEP+'(TITREEGA).SQZ$': SplashEGA,
}
def __init__( self ):
super().__init__( self.TITUS_FILE_CLASS_MAP )