(self, display, addr, num_bytes)
return [_item for _pair in zip(*hbytes) for _item in _pair] [:num_bytes]
Retrieve bytes from Tandy 640x200x4
Retrieve bytes from Tandy 640x200x4
Retrieve bytes from Tandy 640x200x4
def get_memory(self, display, addr, num_bytes):
        """Retrieve bytes from Tandy 640x200x4 """
        # 8 pixels per 2 bytes
        # low attribute bits stored in even bytes, high bits in odd bytes.
        half_len = (num_bytes+1) // 2
        hbytes = bytearray(half_len), bytearray(half_len)
        for parity, byte_array in enumerate(hbytes):
            plane = parity ^ (addr % 2)
            for page, x, y, ofs, length in self._walk_memory(addr, num_bytes, 2):
                pixarray = display.pages[page].pixels[y, x : x + length*self._ppb*2]
                #hbytes[parity][ofs:ofs+length] = interval_to_bytes(pixarray, self._ppb*2, plane)
                byte_array[ofs:ofs+length] = (pixarray >> plane).packed(self._ppb * 2)
        # resulting array may be too long by one byte, so cut to size
        return [_item for _pair in zip(*hbytes) for _item in _pair] [:num_bytes]
def get_memory ( self , display , addr , num_bytes ) : # 8 pixels per 2 bytes # low attribute bits stored in even bytes, high bits in odd bytes. half_len = ( num_bytes + 1 ) // 2 hbytes = bytearray ( half_len ) , bytearray ( half_len ) for parity , byte_array in enumerate ( hbytes ) : plane = parity ^ ( addr % 2 ) for page , x , y , ofs , length in self . _walk_memory ( addr , num_bytes , 2 ) : pixarray = display . pages [ page ] . pixels [ y , x : x + length * self . _ppb * 2 ] #hbytes[parity][ofs:ofs+length] = interval_to_bytes(pixarray, self._ppb*2, plane) byte_array [ ofs : ofs + length ] = ( pixarray >> plane ) . packed ( self . _ppb * 2 ) # resulting array may be too long by one byte, so cut to size return [ _item for _pair in zip ( * hbytes ) for _item in _pair ] [ : num_bytes ]