Загрузка данных


matrix = [
    "0000000000000000000000",
    "0000010000000000100000",
    "0000011000000001100000",
    "0000011100000011100000",
    "0000011111111111100000",
    "0000013330113330100000",
    "0000013103113103100000",
    "0000013113113113100000",
    "0000113333113333110000",
    "0001111111111111111000",
    "0011111111111111111100",
    "0111111111111111111110",
    "0111111111111111111110",
    "0111110111111110111110",
    "0111102111111112011110",
    "0111002111111112001110",
    "0010002011111102000100",
    "0000002001111002000000",
    "0000022200110022200000",
    "0000000000000000000000"
]

all_pixels = []
for row in matrix:
    for pixel in row:
        all_pixels.append(int(pixel))

tetrads = []
i = 0
while i < len(all_pixels):
    current_color = all_pixels[i]
    count = 0
    while i < len(all_pixels) and all_pixels[i] == current_color and count < 4:
        count += 1
        i += 1
    tetrada_val = (current_color << 2) | (count - 1)
    tetrads.append(tetrada_val)

if len(tetrads) % 2 != 0:
    tetrads.append(0)

compressed_bytes = []
for j in range(0, len(tetrads), 2):
    high_tetrad = tetrads[j]
    low_tetrad = tetrads[j+1]
    byte_val = (high_tetrad << 4) | low_tetrad
    compressed_bytes.append(byte_val)

for index, byte_data in enumerate(compressed_bytes):
    hex_offset = f"{index:04x}h"
    hex_byte = f"0{byte_data:02xh}"
    print(f"mov byte ptr ds:[bx+{hex_offset}], {hex_byte}")

print("hlt")