예제 #1
0
class ScriptFloat(mrc.Block):
    length = mrc.Const(mrc.UInt32_BE(0x00), 0x0a)
    sign = mrc.Bits16(0x04, bits=0x8000)
    exponent = mrc.Bits16(0x04, bits=0x7fff)
    integer = mrc.Bits64(0x06, bits=0x8000000000000000)
    fraction = mrc.Bits64(0x06, bits=0x7fffffffffffffff)

    @property
    def value(self):
        if (self.exponent == 0):
            f64exp = 0
        elif (self.exponent == 0x7fff):
            f64exp = 0x7ff
        else:
            normexp = self.exponent - 0x3fff  # value range from -0x3ffe to 0x3fff
            if not (-0x3fe <= normexp < 0x3ff):
                raise ValueError('Exponent too big for a float64')

            f64exp = normexp + 0x3ff

        f64fract = self.fraction >> 11
        f64bin = utils.to_uint64_be(f64fract + (f64exp << 52) +
                                    0x80000000 * self.sign)
        f64 = utils.from_float64_be(f64bin)
        return f64

    @property
    def repr(self):
        return self.value
예제 #2
0
class BitmapCastV4(mrc.Block):
    _data = None

    bpp = mrc.Bits16(0x00, 0b1111000000000000)
    pitch = mrc.Bits16(0x00, 0b0000111111111111)
    initial_rect = mrc.BlockField(Rect, 0x02)
    bounding_rect = mrc.BlockField(Rect, 0x0a)
    reg_y = mrc.UInt16_BE(0x12)
    reg_x = mrc.UInt16_BE(0x14)
    #bpp =          mrc.UInt16_BE( 0x16 )
    #unk4 =         mrc.Bytes( 0x18, length=0x24 )
    #name =         mrc.Bytes( 0x3e )
    unk4 = mrc.Bytes(0x16)

    @property
    def repr(self):
        #return 'name={}, pitch={}, bpp={}, reg_x={}, reg_y={}, unk1={}, unk2={}'.format( self.name, self.pitch, self.bpp, self.reg_x, self.reg_y, self.unk1, self.unk2 )
        return 'bpp={}, pitch={}, reg_x={}, reg_y={}, initial_rect={}, bounding_rect={}'.format(
            self.bpp, self.pitch, self.reg_x, self.reg_y, self.initial_rect,
            self.bounding_rect)

    def __init__(self, *argc, **argv):
        self.image = img.IndexedImage(self,
                                      mrc.Ref('_data.data'),
                                      mrc.Ref('pitch'),
                                      mrc.Ref('initial_rect.height'),
                                      palette=DIRECTOR_PALETTE)
        super().__init__(*argc, **argv)
예제 #3
0
class RGB555Colour(Colour):
    r_raw = mrc.Bits16(0x00, 0b0111110000000000)
    g_raw = mrc.Bits16(0x00, 0b0000001111100000)
    b_raw = mrc.Bits16(0x00, 0b0000000000011111)

    @property
    def r(self):
        return self.r_raw / 31

    @r.setter
    def r(self, value):
        self.r_raw = round(value * 31)

    @property
    def g(self):
        return self.g_raw / 31

    @g.setter
    def g(self, value):
        self.g_raw = round(value * 31)

    @property
    def b(self):
        return self.b_raw / 31

    @b.setter
    def b(self, value):
        self.b_raw = round(value * 31)
예제 #4
0
class Colour15(img.Colour):
    r_raw = mrc.Bits16(
        0x00,
        bits=0b0111110000000000,
        endian='little',
    )
    g_raw = mrc.Bits16(
        0x00,
        bits=0b0000001111100000,
        endian='little',
    )
    b_raw = mrc.Bits16(
        0x00,
        bits=0b0000000000011111,
        endian='little',
    )

    @property
    def r_8(self):
        return (self.r_raw << 3) + 7

    @property
    def g_8(self):
        return (self.g_raw << 3) + 7

    @property
    def b_8(self):
        return (self.b_raw << 3) + 7
예제 #5
0
class TileQuad(mrc.Block):
    index = mrc.Bits16(0x00, 0xffc0, endian='little')
    flip_v = mrc.Bits16(0x00, 0x0020, endian='little')
    flip_h = mrc.Bits16(0x00, 0x0010, endian='little')
    unk1 = mrc.Bits16(0x00, 0x000f, endian='little')

    @property
    def repr(self):
        return 'index: {}, flip_h: {}, flip_v: {}'.format(
            self.index, self.flip_h, self.flip_v)
예제 #6
0
class ResourceInfo(mrc.Block):
    int_id = mrc.Bits16(0x00, 0b1000000000000000, endian='little')
    type_id = mrc.Bits16(0x00, 0b0111111111111111, endian='little')
    count = mrc.UInt16_LE(0x02)
    reserved = mrc.Bytes(0x04, length=0x04)
    resources = mrc.BlockField(Resource, 0x08, count=mrc.Ref('count'))

    @property
    def repr(self):
        return 'type_id={}, int_id={}, count={}'.format(
            self.type_id, self.int_id, self.count)
예제 #7
0
class ScriptContextEntry(mrc.Block):
    unk1 = mrc.UInt16_BE(0x00)
    unk2 = mrc.UInt16_BE(0x02)
    unk3 = mrc.UInt16_BE(0x04)
    index = mrc.UInt16_BE(0x06)  # for mmap.entries
    unk4 = mrc.Bits16(0x08, 0b1111111111111011)
    active = mrc.Bits16(0x08, 0b0000000000000100)
    link = mrc.Int16_BE(0x0a)

    @property
    def repr(self):
        return 'index: {}, active: {}'.format(self.index, self.active)
예제 #8
0
파일: lomax.py 프로젝트: rvanlaar/mrcrowbar
class Colour15(img.RGB555Colour):
    r_raw = mrc.Bits16(
        0x00,
        bits=0b0111110000000000,
        endian='little',
    )
    g_raw = mrc.Bits16(
        0x00,
        bits=0b0000001111100000,
        endian='little',
    )
    b_raw = mrc.Bits16(
        0x00,
        bits=0b0000000000011111,
        endian='little',
    )
예제 #9
0
class Resource(mrc.Block):
    offset = mrc.UInt16_LE(0x00)
    size = mrc.UInt16_LE(0x02)
    unk2 = mrc.Bits(0x04, 0b10000000)
    preload = mrc.Bits(0x04, 0b01000000)
    sharable = mrc.Bits(0x04, 0b00100000)
    movable = mrc.Bits(0x04, 0b00010000)
    in_memory = mrc.Bits(0x04, 0b00000100)
    unk2 = mrc.Bits(0x04, 0b00000011)
    unk3 = mrc.Bits(0x05, 0b11100000)
    discardable = mrc.Bits(0x05, 0b00010000)
    unk4 = mrc.Bits(0x05, 0b00001111)
    int_id = mrc.Bits16(0x06, 0b1000000000000000, endian='little')
    resource_id = mrc.Bits16(0x06, 0b0111111111111111, endian='little')
    reserved = mrc.Bytes(0x08, length=0x04)

    @property
    def repr(self):
        return 'offset=0x{:04x}, size=0x{:04x}, resource_id=0x{:04x}, int_id={}'.format(
            self.offset, self.size, self.resource_id, self.int_id)
예제 #10
0
class BGR555Colour(RGB555Colour):
    b_raw = mrc.Bits16(0x00, 0b0111110000000000)
    g_raw = mrc.Bits16(0x00, 0b0000001111100000)
    r_raw = mrc.Bits16(0x00, 0b0000000000011111)