// File: mdpkh[P]retro6k/src/main.cpp
// Function: PaintCell(unsigned char, unsigned char)
inline void PaintCell(unsigned char col, unsigned char row)
{
	unsigned char glyph = sysram[0x0800 | row << 5 | col];
	unsigned char att[4];
	unsigned char tatt[5];
	tatt[0] = sysram[0x0A40 + ((row & 0x1e) << 4) + col] >> (4 * (row & 0x1));
	tatt[1] = sysram[0x0B60 + ((row & 0x1e) << 4) + col] >> (4 * (row & 0x1));
	tatt[2] = sysram[0x0C80 + ((row & 0x1e) << 4) + col] >> (4 * (row & 0x1));
	tatt[3] = sysram[0x0DA0 + ((row & 0x1e) << 4) + col] >> (4 * (row & 0x1));
	tatt[4] = sysram[0x0EC0 + ((row & 0x1e) << 4) + col] >> (4 * (row & 0x1));
	att[0] = (tatt[0] & 0x1) | (tatt[1] & 0x1) << 1 | (tatt[2] & 0x1) << 2 | (tatt[3] & 0x1) << 3 | (tatt[4] & 0x1) << 4;
	att[1] = (tatt[0] & 0x2) >> 1 | (tatt[1] & 0x2) | (tatt[2] & 0x2) << 1 | (tatt[3] & 0x2) << 2 | (tatt[4] & 0x2) << 3;
	att[2] = (tatt[0] & 0x4) >> 2 | (tatt[1] & 0x4) >> 1 | (tatt[2] & 0x4) | (tatt[3] & 0x4) << 1 | (tatt[4] & 0x4) << 2;
	att[3] = (tatt[0] & 0x8) >> 3 | (tatt[1] & 0x8) >> 2 | (tatt[2] & 0x8) >> 1 | (tatt[3] & 0x8) | (tatt[4] & 0x8) << 1;
	PaintCell(col, row, glyph, att);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %sil, %al
movb %dil, %cl
movb %cl, -0x1(%rbp)
movb %al, -0x2(%rbp)
movq 0x19505(%rip), %rax     # 0x2d560
movzbl -0x2(%rbp), %ecx
shll $0x5, %ecx
orl $0x800, %ecx            # imm = 0x800
movzbl -0x1(%rbp), %edx
orl %edx, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x3(%rbp)
movq 0x194e2(%rip), %rax     # 0x2d560
movzbl -0x2(%rbp), %ecx
andl $0x1e, %ecx
shll $0x4, %ecx
addl $0xa40, %ecx            # imm = 0xA40
movzbl -0x1(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movzbl -0x2(%rbp), %ecx
andl $0x1, %ecx
shll $0x2, %ecx
sarl %cl, %eax
movb %al, -0xc(%rbp)
movq 0x194af(%rip), %rax     # 0x2d560
movzbl -0x2(%rbp), %ecx
andl $0x1e, %ecx
shll $0x4, %ecx
addl $0xb60, %ecx            # imm = 0xB60
movzbl -0x1(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movzbl -0x2(%rbp), %ecx
andl $0x1, %ecx
shll $0x2, %ecx
sarl %cl, %eax
movb %al, -0xb(%rbp)
movq 0x1947c(%rip), %rax     # 0x2d560
movzbl -0x2(%rbp), %ecx
andl $0x1e, %ecx
shll $0x4, %ecx
addl $0xc80, %ecx            # imm = 0xC80
movzbl -0x1(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movzbl -0x2(%rbp), %ecx
andl $0x1, %ecx
shll $0x2, %ecx
sarl %cl, %eax
movb %al, -0xa(%rbp)
movq 0x19449(%rip), %rax     # 0x2d560
movzbl -0x2(%rbp), %ecx
andl $0x1e, %ecx
shll $0x4, %ecx
addl $0xda0, %ecx            # imm = 0xDA0
movzbl -0x1(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movzbl -0x2(%rbp), %ecx
andl $0x1, %ecx
shll $0x2, %ecx
sarl %cl, %eax
movb %al, -0x9(%rbp)
movq 0x19416(%rip), %rax     # 0x2d560
movzbl -0x2(%rbp), %ecx
andl $0x1e, %ecx
shll $0x4, %ecx
addl $0xec0, %ecx            # imm = 0xEC0
movzbl -0x1(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movzbl -0x2(%rbp), %ecx
andl $0x1, %ecx
shll $0x2, %ecx
sarl %cl, %eax
movb %al, -0x8(%rbp)
movzbl -0xc(%rbp), %eax
andl $0x1, %eax
movzbl -0xb(%rbp), %ecx
andl $0x1, %ecx
shll %ecx
orl %ecx, %eax
movzbl -0xa(%rbp), %ecx
andl $0x1, %ecx
shll $0x2, %ecx
orl %ecx, %eax
movzbl -0x9(%rbp), %ecx
andl $0x1, %ecx
shll $0x3, %ecx
orl %ecx, %eax
movzbl -0x8(%rbp), %ecx
andl $0x1, %ecx
shll $0x4, %ecx
orl %ecx, %eax
movb %al, -0x7(%rbp)
movzbl -0xc(%rbp), %eax
andl $0x2, %eax
sarl %eax
movzbl -0xb(%rbp), %ecx
andl $0x2, %ecx
orl %ecx, %eax
movzbl -0xa(%rbp), %ecx
andl $0x2, %ecx
shll %ecx
orl %ecx, %eax
movzbl -0x9(%rbp), %ecx
andl $0x2, %ecx
shll $0x2, %ecx
orl %ecx, %eax
movzbl -0x8(%rbp), %ecx
andl $0x2, %ecx
shll $0x3, %ecx
orl %ecx, %eax
movb %al, -0x6(%rbp)
movzbl -0xc(%rbp), %eax
andl $0x4, %eax
sarl $0x2, %eax
movzbl -0xb(%rbp), %ecx
andl $0x4, %ecx
sarl %ecx
orl %ecx, %eax
movzbl -0xa(%rbp), %ecx
andl $0x4, %ecx
orl %ecx, %eax
movzbl -0x9(%rbp), %ecx
andl $0x4, %ecx
shll %ecx
orl %ecx, %eax
movzbl -0x8(%rbp), %ecx
andl $0x4, %ecx
shll $0x2, %ecx
orl %ecx, %eax
movb %al, -0x5(%rbp)
movzbl -0xc(%rbp), %eax
andl $0x8, %eax
sarl $0x3, %eax
movzbl -0xb(%rbp), %ecx
andl $0x8, %ecx
sarl $0x2, %ecx
orl %ecx, %eax
movzbl -0xa(%rbp), %ecx
andl $0x8, %ecx
sarl %ecx
orl %ecx, %eax
movzbl -0x9(%rbp), %ecx
andl $0x8, %ecx
orl %ecx, %eax
movzbl -0x8(%rbp), %ecx
andl $0x8, %ecx
shll %ecx
orl %ecx, %eax
movb %al, -0x4(%rbp)
movb -0x1(%rbp), %sil
movb -0x2(%rbp), %dl
movb -0x3(%rbp), %al
leaq -0x7(%rbp), %rcx
movzbl %sil, %edi
movzbl %dl, %esi
movzbl %al, %edx
callq 0xfb80
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)