(self)
return t
Sprite tile loader
Sprite tile loader
Sprite tile loader
def read_tile_from_rom(self):
        """Sprite tile loader"""
        surf_buf = bytearray(256)

        for tile8x8_off in (8, 136, 0, 128):
            surf_off = tile8x8_off

            for y in range(8):
                row_bitplane1 = ord(self.fd1.read(1))
                row_bitplane2 = ord(self.fd1.read(1))
                row_bitplane3 = ord(self.fd2.read(1))
                row_bitplane4 = ord(self.fd2.read(1))

                for x in range(8):
                    bp1 = (row_bitplane1 >> x) & 1
                    bp2 = (row_bitplane2 >> x) & 1
                    bp3 = (row_bitplane3 >> x) & 1
                    bp4 = (row_bitplane4 >> x) & 1
                    col = (bp4 << 3) + (bp3 << 2) + (bp2 << 1) + bp1
                    surf_buf[surf_off] = col

                    surf_off += 1
                surf_off += 8
        t = pygame.image.fromstring(bytes(surf_buf), (16, 16), "P")
        return t
def read_tile_from_rom ( self ) : surf_buf = bytearray ( 256 ) for tile8x8_off in ( 8 , 136 , 0 , 128 ) : surf_off = tile8x8_off for y in range ( 8 ) : row_bitplane1 = ord ( self . fd1 . read ( 1 ) ) row_bitplane2 = ord ( self . fd1 . read ( 1 ) ) row_bitplane3 = ord ( self . fd2 . read ( 1 ) ) row_bitplane4 = ord ( self . fd2 . read ( 1 ) ) for x in range ( 8 ) : bp1 = ( row_bitplane1 >> x ) & 1 bp2 = ( row_bitplane2 >> x ) & 1 bp3 = ( row_bitplane3 >> x ) & 1 bp4 = ( row_bitplane4 >> x ) & 1 col = ( bp4 << 3 ) + ( bp3 << 2 ) + ( bp2 << 1 ) + bp1 surf_buf [ surf_off ] = col surf_off += 1 surf_off += 8 t = pygame . image . fromstring ( bytes ( surf_buf ) , ( 16 , 16 ) , "P" ) return t