// File: khedoros[P]khednes/ppu3.cpp
// Function: ppu::set_mirror(unsigned int)
void ppu::set_mirror(unsigned int mode) {
    if(mode == VERT) {
        nt[0] = &(name_table[NT0_OFFSET]);
        nt[2] = nt[0];

        at[0] = &(name_table[AT0_OFFSET]);
        at[2] = at[0];

        nt[1] = &(name_table[NT1_OFFSET]);
        nt[3] = nt[1];

        at[1] = &(name_table[AT1_OFFSET]);
        at[3] = at[1];
    }
    else if(mode == HORIZ) {
        nt[0] = &(name_table[NT0_OFFSET]);
        nt[1] = nt[0];

        at[0] = &(name_table[AT0_OFFSET]);
        at[1] = at[0];

        nt[2] = &(name_table[NT1_OFFSET]);
        nt[3] = nt[2];

        at[2] = &(name_table[AT1_OFFSET]);
        at[3] = at[2];
    }
    else if(mode == FOUR_SCR) {
        nt[0] = &(name_table[NT0_OFFSET]);
        at[0] = &(name_table[AT0_OFFSET]);

        nt[1] = &(name_table[NT1_OFFSET]);
        at[1] = &(name_table[AT1_OFFSET]);

        nt[2] = &(name_table[NT2_OFFSET]);
        at[2] = &(name_table[AT2_OFFSET]);

        nt[3] = &(name_table[NT3_OFFSET]);
        at[3] = &(name_table[AT3_OFFSET]);
    }
    else { cout<<"WTF? Unrecognized mirror mode."<<endl;}
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movl %esi, 0xc(%rsp)
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
cmpl $0x0, 0xc(%rsp)
jne 0x1c9cb
movq (%rsp), %rax
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
movq %rcx, 0x16f0(%rax)
movq 0x16f0(%rax), %rcx
movq %rcx, 0x1700(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0x3c0, %rcx            # imm = 0x3C0
movq %rcx, 0x1710(%rax)
movq 0x1710(%rax), %rcx
movq %rcx, 0x1720(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0x400, %rcx            # imm = 0x400
movq %rcx, 0x16f8(%rax)
movq 0x16f8(%rax), %rcx
movq %rcx, 0x1708(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0x7c0, %rcx            # imm = 0x7C0
movq %rcx, 0x1718(%rax)
movq 0x1718(%rax), %rcx
movq %rcx, 0x1728(%rax)
jmp 0x1cb60
cmpl $0x1, 0xc(%rsp)
jne 0x1ca70
movq (%rsp), %rax
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
movq %rcx, 0x16f0(%rax)
movq 0x16f0(%rax), %rcx
movq %rcx, 0x16f8(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0x3c0, %rcx            # imm = 0x3C0
movq %rcx, 0x1710(%rax)
movq 0x1710(%rax), %rcx
movq %rcx, 0x1718(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0x400, %rcx            # imm = 0x400
movq %rcx, 0x1700(%rax)
movq 0x1700(%rax), %rcx
movq %rcx, 0x1708(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0x7c0, %rcx            # imm = 0x7C0
movq %rcx, 0x1720(%rax)
movq 0x1720(%rax), %rcx
movq %rcx, 0x1728(%rax)
jmp 0x1cb5e
cmpl $0x2, 0xc(%rsp)
jne 0x1cb3a
movq (%rsp), %rax
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
movq %rcx, 0x16f0(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0x3c0, %rcx            # imm = 0x3C0
movq %rcx, 0x1710(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0x400, %rcx            # imm = 0x400
movq %rcx, 0x16f8(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0x7c0, %rcx            # imm = 0x7C0
movq %rcx, 0x1718(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0x800, %rcx            # imm = 0x800
movq %rcx, 0x1700(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0xbc0, %rcx            # imm = 0xBC0
movq %rcx, 0x1720(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0xc00, %rcx            # imm = 0xC00
movq %rcx, 0x1708(%rax)
movq %rax, %rcx
addq $0x6ec, %rcx            # imm = 0x6EC
addq $0xfc0, %rcx            # imm = 0xFC0
movq %rcx, 0x1728(%rax)
jmp 0x1cb5c
movq 0x1a46f(%rip), %rdi     # 0x36fb0
leaq 0xfa48(%rip), %rsi      # 0x2c590
callq 0x43c0
movq %rax, %rdi
movq 0x1a439(%rip), %rsi     # 0x36f90
callq 0x4400
jmp 0x1cb5e
jmp 0x1cb60
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)