// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/polymost.c
// Function: polymost_preparetext
static int polymost_preparetext(void)
{
	unsigned int *tbuf;

	if (texttexture) {
		return 0;
	}

	// construct a 256x256 rgba texture for the font glyph matrix.
	glfunc.glGenTextures(1,&texttexture);
	if (!texttexture) return -1;

	tbuf = (unsigned int *)Bcalloc(256*256, sizeof(unsigned int));
	if (!tbuf) {
		glfunc.glDeleteTextures(1,&texttexture);
		texttexture = 0;
		return -1;
	}

	// 8x8 - lines 0 to 63, 8 lines per row
	// 4x6 - lines 64 to 127, 8 lines per row
	// 8x14 - lines 128-255, 16 lines per row

	for (int fn = 0; fn < 3; fn++) {
		const struct textfontspec *f = &textfonts[fn];
		unsigned int *tptr = tbuf + 256*64*fn;
		int cellh = fn < 2 ? 8 : 16;

		for (int c = 0; c < 256; c++) {
			const unsigned char *letptr = &f->font[c * f->cellh + f->cellyoff];
			unsigned int *cptr = tptr + ((c/32) * 256 * cellh) + ((c%32)*8);

			for(int y = 0; y < f->charysiz; y++)
			{
				for(int x = 0; x < f->charxsiz; x++)
				{
					if (letptr[y] & pow2char[7 - x - f->cellxoff])
						cptr[x] = 0xffffffff;
				}
				cptr += 256;
			}
		}
	}

	glfunc.glActiveTexture(GL_TEXTURE0);
	glfunc.glBindTexture(GL_TEXTURE_2D, texttexture);
	glfunc.glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)tbuf);
	glfunc.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
	glfunc.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
	free(tbuf);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
cmpl $0x0, 0x562a65(%rip)    # 0x5eda14
je 0x8afbd
movl $0x0, -0x4(%rbp)
jmp 0x8b272
movl $0x1, %edi
leaq 0x562a4b(%rip), %rsi    # 0x5eda14
leaq 0x562740(%rip), %rax    # 0x5ed710
callq *0xb8(%rax)
cmpl $0x0, 0x562a37(%rip)    # 0x5eda14
jne 0x8afeb
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8b272
movl $0x10000, %edi          # imm = 0x10000
movl $0x4, %esi
callq 0x6880
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x8b034
movl $0x1, %edi
leaq 0x562a03(%rip), %rsi    # 0x5eda14
leaq 0x5626f8(%rip), %rax    # 0x5ed710
callq *0xc0(%rax)
movl $0x0, 0x5629ec(%rip)    # 0x5eda14
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8b272
movl $0x0, -0x14(%rbp)
cmpl $0x3, -0x14(%rbp)
jge 0x8b1bc
movslq -0x14(%rbp), %rcx
leaq 0x43ae0(%rip), %rax     # 0xceb30
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
shll $0xe, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %edx
movl $0x10, %eax
movl $0x8, %ecx
cmpl $0x2, %edx
cmovll %ecx, %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x100, -0x30(%rbp)     # imm = 0x100
jge 0x8b1ac
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x30(%rbp), %ecx
movq -0x20(%rbp), %rdx
imull 0x10(%rdx), %ecx
movq -0x20(%rbp), %rdx
addl 0x18(%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x30(%rbp), %eax
movl $0x20, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x58(%rbp), %rax
shll $0x8, %ecx
imull -0x2c(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movl -0x30(%rbp), %eax
movl $0x20, %ecx
cltd
idivl %ecx
movq -0x50(%rbp), %rax
shll $0x3, %edx
movslq %edx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x8b19c
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x8b180
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl $0x7, %ecx
subl -0x48(%rbp), %ecx
movq -0x20(%rbp), %rdx
subl 0x14(%rdx), %ecx
movslq %ecx, %rdx
leaq 0x55b37(%rip), %rcx     # 0xe0c90
movzbl (%rcx,%rdx), %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x8b173
movq -0x40(%rbp), %rax
movslq -0x48(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x8b175
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x8b128
movq -0x40(%rbp), %rax
addq $0x400, %rax            # imm = 0x400
movq %rax, -0x40(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x8b115
jmp 0x8b19e
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x8b090
jmp 0x8b1ae
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x8b03b
movl $0x84c0, %edi           # imm = 0x84C0
leaq 0x562548(%rip), %rax    # 0x5ed710
callq *0x140(%rax)
leaq 0x56253b(%rip), %rax    # 0x5ed710
movq 0xc8(%rax), %rax
movl 0x562832(%rip), %esi    # 0x5eda14
movl $0xde1, %edi            # imm = 0xDE1
callq *%rax
leaq 0x562520(%rip), %rax    # 0x5ed710
movq 0xd0(%rax), %rax
movq -0x10(%rbp), %r10
movl $0xde1, %edi            # imm = 0xDE1
xorl %r9d, %r9d
movl $0x1908, %edx           # imm = 0x1908
movl $0x100, %r8d            # imm = 0x100
movl %r9d, %esi
movl %r8d, %ecx
movl $0x1908, (%rsp)         # imm = 0x1908
movl $0x1401, 0x8(%rsp)      # imm = 0x1401
movq %r10, 0x10(%rsp)
callq *%rax
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
movl $0x2600, %edx           # imm = 0x2600
leaq 0x5624d0(%rip), %rax    # 0x5ed710
callq *0xe8(%rax)
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
movl $0x2600, %edx           # imm = 0x2600
leaq 0x5624b4(%rip), %rax    # 0x5ed710
callq *0xe8(%rax)
movq -0x10(%rbp), %rdi
callq 0x61c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)