// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/polymost.c
// Function: polymost_printext256
int polymost_printext256(int xpos, int ypos, short col, short backcol, const  char *name, char fontsize)
{
	GLfloat tx, ty, txc, tyc, txg, tyg, tyoff, cx, cy;
	int c, indexcnt, vbocnt;
	palette_t colour;
	struct polymostdrawauxcall draw;
	struct polymostvboitem vboitem[80*4];
	GLushort vboindexes[80*6];

	if ((rendmode != 3) || (qsetmode != 200)) return(-1);

	polymost_preparetext();
	setpolymost2dview();	// disables blending, texturing, and depth testing
	glfunc.glDepthMask(GL_FALSE);	// disable writing to the z-buffer
	glfunc.glEnable(GL_BLEND);

	draw.mode = 0;	// Text.

	draw.texture0 = texttexture;

	colour = curpalette[col];
	if (!usegammabrightness) {
		colour.r = britable[curbrightness][ colour.r ];
		colour.g = britable[curbrightness][ colour.g ];
		colour.b = britable[curbrightness][ colour.b ];
	}
	draw.colour.r = colour.r / 255.f;
	draw.colour.g = colour.g / 255.f;
	draw.colour.b = colour.b / 255.f;
	draw.colour.a = 1.f;

	colour = curpalette[min(0, backcol)];
	if (!usegammabrightness) {
		colour.r = britable[curbrightness][ colour.r ];
		colour.g = britable[curbrightness][ colour.g ];
		colour.b = britable[curbrightness][ colour.b ];
	}
	draw.bgcolour.r = colour.r / 255.f;
	draw.bgcolour.g = colour.g / 255.f;
	draw.bgcolour.b = colour.b / 255.f;
	if (backcol >= 0) {
		draw.bgcolour.a = 1.f;
	} else {
		draw.bgcolour.a = 0.f;
	}

	fontsize = min((unsigned)fontsize, 2);
	tyoff = 64.f * (float)fontsize / 256.f;
	cx = (float)textfonts[(unsigned)fontsize].charxsiz;
	cy = (float)textfonts[(unsigned)fontsize].charysiz;
	txc = cx/256.f;		// texture-space width/height of character
	tyc = cy/256.f;
	txg = 8.f/256.f;	// texture-space width/height of cell
	tyg = (fontsize < 2 ? 8.f : 16.f) / 256.f;

	draw.indexes = vboindexes;
	draw.elementvbo = vboitem;

	c = 0;
	indexcnt = vbocnt = 0;
	while (name[c]) {
		for (; name[c] && indexcnt < 80*6; c++) {
			tx = (GLfloat)((unsigned char)name[c]%32)*txg;
			ty = (GLfloat)((unsigned char)name[c]/32)*tyg + tyoff;

			vboindexes[indexcnt + 0] = vbocnt+0;
			vboindexes[indexcnt + 1] = vbocnt+1;
			vboindexes[indexcnt + 2] = vbocnt+2;
			vboindexes[indexcnt + 3] = vbocnt+0;
			vboindexes[indexcnt + 4] = vbocnt+2;
			vboindexes[indexcnt + 5] = vbocnt+3;

			vboitem[vbocnt + 0].v.x = (GLfloat)xpos;
			vboitem[vbocnt + 0].v.y = (GLfloat)ypos;
			vboitem[vbocnt + 0].v.z = 0.f;
			vboitem[vbocnt + 0].t.s = tx;
			vboitem[vbocnt + 0].t.t = ty;

			vboitem[vbocnt + 1].v.x = (GLfloat)xpos+cx;
			vboitem[vbocnt + 1].v.y = (GLfloat)ypos;
			vboitem[vbocnt + 1].v.z = 0.f;
			vboitem[vbocnt + 1].t.s = tx+txc;
			vboitem[vbocnt + 1].t.t = ty;

			vboitem[vbocnt + 2].v.x = (GLfloat)xpos+cx;
			vboitem[vbocnt + 2].v.y = (GLfloat)ypos+cy;
			vboitem[vbocnt + 2].v.z = 0.f;
			vboitem[vbocnt + 2].t.s = tx+txc;
			vboitem[vbocnt + 2].t.t = ty+tyc;

			vboitem[vbocnt + 3].v.x = (GLfloat)xpos;
			vboitem[vbocnt + 3].v.y = (GLfloat)ypos+cy;
			vboitem[vbocnt + 3].v.z = 0.f;
			vboitem[vbocnt + 3].t.s = tx;
			vboitem[vbocnt + 3].t.t = ty+tyc;

			indexcnt += 6;
			vbocnt += 4;
			xpos += textfonts[(unsigned)fontsize].charxsiz;
		}

		draw.indexcount = indexcnt;
		draw.elementcount = vbocnt;

		polymost_drawaux_glcall(GL_TRIANGLES, &draw);

		indexcnt = vbocnt = 0;
	}

	glfunc.glDepthMask(GL_TRUE);	// re-enable writing to the z-buffer

	return 0;
}

// Assembly:
cmpl $0x3, 0x5a028b(%rip)    # 0x5f3950
pushq $-0x1
popq %rax
jne 0x53acd
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d58, %rsp           # imm = 0x1D58
movl %ecx, %r12d
leaq 0x15e33f(%rip), %rcx    # 0x1b1a28
cmpl $0xc8, (%rcx)
jne 0x53abc
movq %r8, %rbx
movl %edx, %r13d
movl %edi, %ebp
movl %r9d, 0x10(%rsp)
movl %esi, 0xc(%rsp)
callq 0x53ace
callq 0x39c49
leaq 0x5a0029(%rip), %r15    # 0x5f3740
xorl %r14d, %r14d
xorl %edi, %edi
callq *0xa0(%r15)
movl $0xbe2, %edi            # imm = 0xBE2
callq *0x40(%r15)
andl $0x0, 0x3c(%rsp)
movl 0x5a030d(%rip), %eax    # 0x5f3a44
movl %eax, 0x18(%rsp)
movswq %r13w, %rcx
leaq 0x3dc26a(%rip), %rax    # 0x42f9b0
movd (%rax,%rcx,4), %xmm1
movb 0x2(%rax,%rcx,4), %dl
leaq 0x4a036(%rip), %rcx     # 0x9d78c
movl (%rcx), %ecx
testl %ecx, %ecx
jne 0x537a0
movzbl %dl, %edx
leaq 0x15e29e(%rip), %rsi    # 0x1b1a04
movslq (%rsi), %rsi
movd %xmm1, %edi
movl $0xff, %r8d
movl %edi, %r9d
andl %r8d, %r9d
shlq $0x8, %rsi
addq 0x3884c(%rip), %rsi     # 0x8bfd0
movzbl (%r9,%rsi), %r9d
shrl $0x8, %edi
andl %r8d, %edi
movb (%rdx,%rsi), %dl
movzbl (%rdi,%rsi), %esi
shll $0x8, %esi
orl %r9d, %esi
movd %esi, %xmm1
movzbl %dl, %edx
cvtsi2ss %edx, %xmm2
pxor %xmm0, %xmm0
punpcklbw %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3],xmm1[4],xmm0[4],xmm1[5],xmm0[5],xmm1[6],xmm0[6],xmm1[7],xmm0[7]
punpcklwd %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3]
cvtdq2ps %xmm1, %xmm1
divps 0x1bd23(%rip), %xmm1    # 0x6f4e0
movlps %xmm1, 0x1c(%rsp)
testw %r12w, %r12w
cmovsl %r12d, %r14d
divss 0x1bb4e(%rip), %xmm2    # 0x6f320
movss %xmm2, 0x24(%rsp)
movl $0x3f800000, 0x28(%rsp) # imm = 0x3F800000
movswq %r14w, %rdx
movd (%rax,%rdx,4), %xmm1
movb 0x2(%rax,%rdx,4), %al
testl %ecx, %ecx
movl 0x10(%rsp), %r8d
jne 0x53834
movzbl %al, %eax
leaq 0x15e204(%rip), %rcx    # 0x1b1a04
movslq (%rcx), %rcx
movd %xmm1, %edx
movl $0xff, %esi
movl %edx, %edi
andl %esi, %edi
shlq $0x8, %rcx
addq 0x387b5(%rip), %rcx     # 0x8bfd0
movzbl (%rdi,%rcx), %edi
shrl $0x8, %edx
andl %esi, %edx
movb (%rax,%rcx), %al
movzbl (%rdx,%rcx), %ecx
shll $0x8, %ecx
orl %edi, %ecx
movd %ecx, %xmm1
punpcklbw %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3],xmm1[4],xmm0[4],xmm1[5],xmm0[5],xmm1[6],xmm0[6],xmm1[7],xmm0[7]
punpcklwd %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3]
cvtdq2ps %xmm1, %xmm0
divps 0x1bc9a(%rip), %xmm0    # 0x6f4e0
movlps %xmm0, 0x2c(%rsp)
movzbl %al, %eax
cvtsi2ss %eax, %xmm0
divss 0x1bac6(%rip), %xmm0    # 0x6f320
movss %xmm0, 0x34(%rsp)
testw %r12w, %r12w
jns 0x5386b
xorps %xmm0, %xmm0
jmp 0x53873
movss 0x18761(%rip), %xmm0    # 0x6bfd4
movzbl %r8b, %eax
xorl %ecx, %ecx
cmpb $0x2, %al
pushq $0x2
popq %rdx
cmovbl %eax, %edx
setb %cl
movzbl %dl, %eax
shlb $0x6, %dl
movzbl %dl, %edx
cvtsi2ss %edx, %xmm4
leaq 0x18(%rsp), %rsi
mulss 0x1ba92(%rip), %xmm4    # 0x6f330
movss %xmm0, 0x20(%rsi)
shll $0x5, %eax
leaq 0x38173(%rip), %rdx     # 0x8ba20
movq 0x8(%rdx,%rax), %r12
movq %r12, %xmm0
cvtdq2ps %xmm0, %xmm5
movaps 0x1bc2f(%rip), %xmm6    # 0x6f4f0
mulps %xmm5, %xmm6
leaq 0x1bdcd(%rip), %rax     # 0x6f698
movss (%rax,%rcx,4), %xmm7
leaq 0x90(%rsp), %rax
movq %rax, 0x30(%rsi)
leaq 0x450(%rsp), %rax
cvtsi2ssl 0xc(%rsp), %xmm8
movq %rax, 0x40(%rsi)
movaps %xmm5, %xmm9
shufps $0x55, %xmm5, %xmm9     # xmm9 = xmm9[1,1],xmm5[1,1]
addss %xmm8, %xmm9
leaq 0x49c(%rsp), %r13
xorl %r15d, %r15d
movss 0x1ba37(%rip), %xmm10   # 0x6f348
pushq $0x4
popq %r14
movss %xmm4, 0x10(%rsp)
movaps %xmm5, 0x80(%rsp)
movaps %xmm6, 0x70(%rsp)
movss %xmm7, 0x14(%rsp)
movss %xmm8, 0xc(%rsp)
movaps %xmm9, 0x60(%rsp)
movslq %r15d, %r15
movb (%rbx,%r15), %dil
testb %dil, %dil
je 0x53aaa
xorl %eax, %eax
movq %r13, %rcx
xorl %esi, %esi
xorl %edx, %edx
testb %dil, %dil
je 0x53a61
cmpq $0x1df, %rdx            # imm = 0x1DF
ja 0x53a61
movzbl %dil, %edi
movl %edi, %r8d
andl $0x1f, %r8d
cvtsi2ss %r8d, %xmm0
mulss %xmm10, %xmm0
shrl $0x5, %edi
cvtsi2ss %edi, %xmm1
mulss %xmm7, %xmm1
addss %xmm4, %xmm1
movw %ax, 0x90(%rsp,%rdx,2)
movl %esi, %edi
orl $0x1, %edi
movw %di, 0x92(%rsp,%rdx,2)
cvtsi2ss %ebp, %xmm2
movl %esi, %edi
orl $0x2, %edi
movss %xmm2, -0x4c(%rcx)
movss %xmm8, -0x48(%rcx)
andl $0x0, -0x44(%rcx)
movss %xmm0, -0x40(%rcx)
movss %xmm1, -0x3c(%rcx)
movaps %xmm5, %xmm3
addss %xmm2, %xmm3
movss %xmm3, -0x38(%rcx)
movss %xmm8, -0x34(%rcx)
andl $0x0, -0x30(%rcx)
movw %di, 0x94(%rsp,%rdx,2)
movw %si, 0x96(%rsp,%rdx,2)
movss %xmm1, -0x28(%rcx)
movss %xmm3, -0x24(%rcx)
movss %xmm9, -0x20(%rcx)
andl $0x0, -0x1c(%rcx)
movw %di, 0x98(%rsp,%rdx,2)
movl %esi, %edi
movaps %xmm0, %xmm3
unpcklps %xmm1, %xmm3            # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
addps %xmm6, %xmm3
movss %xmm3, -0x2c(%rcx)
movlps %xmm3, -0x18(%rcx)
movss %xmm2, -0x10(%rcx)
movss %xmm9, -0xc(%rcx)
andl $0x0, -0x8(%rcx)
orl $0x3, %edi
movw %di, 0x9a(%rsp,%rdx,2)
movss %xmm0, -0x4(%rcx)
shufps $0x55, %xmm3, %xmm3     # xmm3 = xmm3[1,1,1,1]
movss %xmm3, (%rcx)
addq $0x6, %rdx
addq $0x4, %rsi
addl %r12d, %ebp
movb 0x1(%rbx,%r15), %dil
incq %r15
addl $0x4, %eax
addq $0x50, %rcx
jmp 0x53954
movl %edx, 0x40(%rsp)
movl %eax, 0x50(%rsp)
movl %r14d, %edi
leaq 0x18(%rsp), %rsi
callq 0x534cc
movss 0x1b8c9(%rip), %xmm10   # 0x6f348
movaps 0x60(%rsp), %xmm9
movss 0xc(%rsp), %xmm8
movss 0x14(%rsp), %xmm7
movaps 0x70(%rsp), %xmm6
movaps 0x80(%rsp), %xmm5
movss 0x10(%rsp), %xmm4
jmp 0x5393b
pushq $0x1
popq %rdi
leaq 0x59fc8c(%rip), %rax    # 0x5f3740
callq *0xa0(%rax)
xorl %eax, %eax
addq $0x1d58, %rsp           # imm = 0x1D58
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq