(self, display, addr, byte_array)
Set bytes in Tandy 640x200x4 memory.
Set bytes in Tandy 640x200x4 memory.
Set bytes in Tandy 640x200x4 memory .
def set_memory(self, display, addr, byte_array):
        """Set bytes in Tandy 640x200x4 memory."""
        hbytes = byte_array[0::2], byte_array[1::2]
        # Tandy-6 encodes 8 pixels per byte, alternating colour planes.
        # I.e. even addresses are 'colour plane 0', odd ones are 'plane 1'
        for parity, half in enumerate(hbytes):
            plane = parity ^ (addr % 2)
            mask = 2 ** plane
            for page, x, y, ofs, length in self._walk_memory(addr, len(byte_array), 2):
                #pixarray = bytes_to_interval(hbytes[parity][ofs:ofs+length], 2*self._ppb, mask)
                pixarray = (
                    bytematrix.ByteMatrix.frompacked(
                        # what's the deal with the empty bytearrays here in some of the tests?
                        half[ofs:ofs+length], height=1, items_per_byte=2*self._ppb
                    ) << plane
                )
                width = pixarray.width
                substrate = display.pages[page].pixels[y, x:x+width] & ~mask
                display.pages[page].pixels[y, x:x+width] = (pixarray & mask) | substrate
def set_memory ( self , display , addr , byte_array ) : hbytes = byte_array [ 0 : : 2 ] , byte_array [ 1 : : 2 ] # Tandy-6 encodes 8 pixels per byte, alternating colour planes. # I.e. even addresses are 'colour plane 0', odd ones are 'plane 1' for parity , half in enumerate ( hbytes ) : plane = parity ^ ( addr % 2 ) mask = 2 ** plane for page , x , y , ofs , length in self . _walk_memory ( addr , len ( byte_array ) , 2 ) : #pixarray = bytes_to_interval(hbytes[parity][ofs:ofs+length], 2*self._ppb, mask) pixarray = ( bytematrix . ByteMatrix . frompacked ( # what's the deal with the empty bytearrays here in some of the tests? half [ ofs : ofs + length ] , height = 1 , items_per_byte = 2 * self . _ppb ) << plane ) width = pixarray . width substrate = display . pages [ page ] . pixels [ y , x : x + width ] & ~ mask display . pages [ page ] . pixels [ y , x : x + width ] = ( pixarray & mask ) | substrate