// File: /workspace/github_cpp_makefile_star2_O1/magmastonealex[P]fbkeyboard/src/Display.cpp
// Function: Display::Display(int, int, int)
Display::Display(int width, int height, int dpi) : width{width}, height{height}, dpi{dpi} {
	keyboardImage = new ImageRGB();
	keyboardImage->w = width;
	keyboardImage->h = height;
	keyboardImage->data = new RGB[width*height];

	//Initialize background to grey.
	//Doing not-grey would be much slower.
	memset((unsigned char*) keyboardImage->data, 0x70, width*height*3);

	margin = width / 33;
	scale = dpi / 34;

	entryWidth = dpi/3;

	keyboardWidth = width - entryWidth;

	rowWidth = keyboardWidth/4;

	stepSizePx = (height-(2*margin) - (11*8*scale))/10;

	kbScale = scale-2;

	if(kbScale < 0) {
    	kbScale = 1;
    }

    maxlen = (height-(2*margin)) / ((scale*8) + 4);

    currentKeyboard = &LCkeyboard;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r14d
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
movl %esi, (%rdi)
movl %edx, 0x4(%rdi)
movl %ecx, 0x10(%rdi)
leaq 0x50(%rdi), %rax
movq %rax, 0x40(%rdi)
movq $0x0, 0x48(%rdi)
xorl %eax, %eax
movb %al, 0x50(%rdi)
leaq 0x68(%rdi), %rcx
movq %rcx, (%rsp)
movups 0x1b96(%rip), %xmm0     # 0x4004
movups %xmm0, 0x68(%rdi)
movups 0x1b9b(%rip), %xmm0     # 0x4014
movups %xmm0, 0x78(%rdi)
movb %al, 0x88(%rdi)
movups 0x1b9b(%rip), %xmm0     # 0x4025
movups %xmm0, 0x89(%rdi)
movups 0x1b9d(%rip), %xmm0     # 0x4035
movups %xmm0, 0x99(%rdi)
movb %al, 0xa9(%rdi)
movups 0x1b9a(%rip), %xmm0     # 0x4046
movups %xmm0, 0xaa(%rdi)
movups 0x1b9c(%rip), %xmm0     # 0x4056
movups %xmm0, 0xba(%rdi)
movb $0x7c, 0xca(%rdi)
movb %al, 0xeb(%rdi)
movups 0x1ba2(%rip), %xmm0     # 0x4077
movups %xmm0, 0xdb(%rdi)
movups 0x1b84(%rip), %xmm0     # 0x4067
movups %xmm0, 0xcb(%rdi)
movl $0x10, %edi
callq 0x2190
movq %rax, %r12
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq %rax, 0x30(%rbx)
movl %r15d, (%rax)
movl %ebp, 0x4(%rax)
movl %ebp, %eax
imull %r15d, %eax
movslq %eax, %r13
movl $0x3, %ecx
movq %r13, %rax
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x2030
movq %rax, 0x8(%r12)
leal (%r13,%r13,2), %ecx
movslq %ecx, %rdx
movq %rax, %rdi
movl $0x70, %esi
callq 0x20f0
movslq %r15d, %r8
imulq $0x3e0f83e1, %r8, %rdi  # imm = 0x3E0F83E1
movq %rdi, %rax
shrq $0x3f, %rax
shrq $0x20, %rdi
sarl $0x3, %edi
addl %eax, %edi
movl %edi, 0x8(%rbx)
movslq %r14d, %rax
imulq $0x78787879, %rax, %rcx # imm = 0x78787879
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
sarl $0x4, %ecx
leal (%rcx,%rdx), %esi
movl %esi, 0xc(%rbx)
imulq $0x55555556, %rax, %r9  # imm = 0x55555556
movq %r9, %r10
shrq $0x3f, %r10
shrq $0x20, %r9
addl %r10d, %r9d
movl %r9d, 0x14(%rbx)
subl %r9d, %r8d
movl %r8d, 0x18(%rbx)
leal 0x3(%r8), %r9d
testl %r8d, %r8d
cmovnsl %r8d, %r9d
sarl $0x2, %r9d
movl %r9d, 0x1c(%rbx)
addl %edi, %edi
subl %edi, %ebp
imull $-0x58, %esi, %edi
addl %ebp, %edi
movslq %edi, %rdi
imulq $0x66666667, %rdi, %rdi # imm = 0x66666667
movq %rdi, %r8
shrq $0x3f, %r8
sarq $0x22, %rdi
addl %r8d, %edi
movl %edi, 0x20(%rbx)
addl %edx, %ecx
addl $-0x2, %ecx
cmpl $0x44, %eax
movl $0x1, %eax
cmovgel %ecx, %eax
movl %eax, 0x24(%rbx)
leal 0x4(,%rsi,8), %ecx
movl %ebp, %eax
cltd
idivl %ecx
movl %eax, 0x28(%rbx)
movq (%rsp), %rax
movq %rax, 0x60(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq