// File: /workspace/github_c_makefile_star2_O3/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, 0x59ceb4(%rip)    # 0x5fa950
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jne 0x5ded6
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d58, %rsp           # imm = 0x1D58
movl %ecx, %r12d
leaq 0x15af66(%rip), %rcx    # 0x1b8a28
cmpl $0xc8, (%rcx)
jne 0x5dec5
movl %r9d, %r15d
movl %edx, %r13d
movl %edi, %ebp
movl %esi, 0x4(%rsp)
movq %r8, 0x10(%rsp)
callq 0x5ded7
callq 0x3da9c
leaq 0x59cc50(%rip), %r14    # 0x5fa740
xorl %ebx, %ebx
xorl %edi, %edi
callq *0xa0(%r14)
movl $0xbe2, %edi            # imm = 0xBE2
callq *0x40(%r14)
movl $0x0, 0x3c(%rsp)
movl 0x59cf32(%rip), %eax    # 0x5faa44
movl %eax, 0x18(%rsp)
movswq %r13w, %rcx
leaq 0x3d8e8f(%rip), %rax    # 0x4369b0
movd (%rax,%rcx,4), %xmm1
movb 0x2(%rax,%rcx,4), %dl
leaq 0x46c5b(%rip), %rcx     # 0xa478c
movl (%rcx), %ecx
testl %ecx, %ecx
jne 0x5db7b
movzbl %dl, %edx
leaq 0x15aec3(%rip), %rsi    # 0x1b8a04
movslq (%rsi), %rsi
movd %xmm1, %edi
movl $0xff, %r8d
movl %edi, %r9d
andl %r8d, %r9d
shlq $0x8, %rsi
addq 0x35479(%rip), %rsi     # 0x92fd8
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 0x1cc08(%rip), %xmm1    # 0x7a7a0
movlps %xmm1, 0x1c(%rsp)
testw %r12w, %r12w
cmovsl %r12d, %ebx
divss 0x1c9f3(%rip), %xmm2    # 0x7a5a0
movss %xmm2, 0x24(%rsp)
movl $0x3f800000, 0x28(%rsp) # imm = 0x3F800000
movswq %bx, %rdx
movd (%rax,%rdx,4), %xmm1
movb 0x2(%rax,%rdx,4), %al
testl %ecx, %ecx
movq 0x10(%rsp), %r9
jne 0x5dc0f
movzbl %al, %eax
leaq 0x15ae29(%rip), %rcx    # 0x1b8a04
movslq (%rcx), %rcx
movd %xmm1, %edx
movl $0xff, %esi
movl %edx, %edi
andl %esi, %edi
shlq $0x8, %rcx
addq 0x353e2(%rip), %rcx     # 0x92fd8
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 0x1cb7f(%rip), %xmm0    # 0x7a7a0
movlps %xmm0, 0x2c(%rsp)
movzbl %al, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x1c968(%rip), %xmm0    # 0x7a5a0
movss %xmm0, 0x34(%rsp)
testw %r12w, %r12w
jns 0x5dc49
xorps %xmm0, %xmm0
jmp 0x5dc51
movss 0x194c3(%rip), %xmm0    # 0x77114
movzbl %r15b, %ecx
xorl %eax, %eax
cmpb $0x2, %cl
movl $0x2, %edx
cmovbl %ecx, %edx
movss %xmm0, 0x38(%rsp)
setb %cl
movzbl %dl, %esi
shll $0x5, %esi
leaq 0x34dc8(%rip), %rdi     # 0x92a40
movsd 0x8(%rdi,%rsi), %xmm0
leaq 0x90(%rsp), %rsi
movq %rsi, 0x48(%rsp)
leaq 0x450(%rsp), %rsi
movq %rsi, 0x58(%rsp)
movb (%r9), %dil
testb %dil, %dil
je 0x5deb1
shlb $0x6, %dl
movzbl %dl, %edx
cvtsi2ss %edx, %xmm4
mulss 0x1c8fa(%rip), %xmm4    # 0x7a5b0
cvtdq2ps %xmm0, %xmm5
movaps 0x1caf0(%rip), %xmm6    # 0x7a7b0
mulps %xmm5, %xmm6
movb %cl, %al
cvtsi2ssl 0x4(%rsp), %xmm7
leaq 0x1cc86(%rip), %rcx     # 0x7a958
movss (%rcx,%rax,4), %xmm8
movaps %xmm5, %xmm9
shufps $0x55, %xmm5, %xmm9     # xmm9 = xmm9[1,1],xmm5[1,1]
addss %xmm7, %xmm9
movd %xmm0, %r15d
xorl %r13d, %r13d
movss 0x1c8d1(%rip), %xmm10   # 0x7a5c8
movabsq $0x100000000, %r12      # imm = 0x100000000
xorl %r14d, %r14d
movss %xmm4, 0xc(%rsp)
movaps %xmm5, 0x80(%rsp)
movaps %xmm6, 0x70(%rsp)
movss %xmm7, 0x4(%rsp)
movss %xmm8, 0x8(%rsp)
movaps %xmm9, 0x60(%rsp)
movq %r14, %rbx
shlq $0x20, %rbx
movslq %r14d, %r14
leaq 0x49c(%rsp), %rcx
xorl %eax, %eax
xorl %esi, %esi
xorl %edx, %edx
addq %r12, %rbx
movzbl %dil, %edi
movl %edi, %r8d
andl $0x1f, %r8d
xorps %xmm0, %xmm0
cvtsi2ss %r8d, %xmm0
mulss %xmm10, %xmm0
shrl $0x5, %edi
xorps %xmm1, %xmm1
cvtsi2ss %edi, %xmm1
mulss %xmm8, %xmm1
addss %xmm4, %xmm1
movw %ax, 0x90(%rsp,%rsi,2)
movl %edx, %edi
orl $0x1, %edi
movw %di, 0x92(%rsp,%rsi,2)
movl %edx, %edi
orl $0x2, %edi
movw %di, 0x94(%rsp,%rsi,2)
movw %dx, 0x96(%rsp,%rsi,2)
movw %di, 0x98(%rsp,%rsi,2)
movl %edx, %edi
orl $0x3, %edi
xorps %xmm2, %xmm2
cvtsi2ss %ebp, %xmm2
movw %di, 0x9a(%rsp,%rsi,2)
movss %xmm2, -0x4c(%rcx)
movss %xmm7, -0x48(%rcx)
movl %r13d, -0x44(%rcx)
movss %xmm0, -0x40(%rcx)
movss %xmm1, -0x3c(%rcx)
movaps %xmm5, %xmm3
addss %xmm2, %xmm3
movss %xmm3, -0x38(%rcx)
movss %xmm7, -0x34(%rcx)
movl %r13d, -0x30(%rcx)
movss %xmm1, -0x28(%rcx)
movss %xmm3, -0x24(%rcx)
movss %xmm9, -0x20(%rcx)
movl %r13d, -0x1c(%rcx)
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)
movl %r13d, -0x8(%rcx)
movss %xmm0, -0x4(%rcx)
shufps $0x55, %xmm3, %xmm3     # xmm3 = xmm3[1,1,1,1]
movss %xmm3, (%rcx)
leaq 0x6(%rsi), %r8
addl %r15d, %ebp
movb 0x1(%r9,%r14), %dil
incq %r14
addl $0x4, %eax
testb %dil, %dil
je 0x5de54
addq $0x4, %rdx
addq $0x50, %rcx
cmpq $0x1da, %rsi            # imm = 0x1DA
movq %r8, %rsi
jb 0x5dd42
movl %r8d, 0x40(%rsp)
movl %eax, 0x50(%rsp)
movl $0x4, %edi
leaq 0x18(%rsp), %rsi
callq 0x5d891
movss 0x1c753(%rip), %xmm10   # 0x7a5c8
movaps 0x60(%rsp), %xmm9
movss 0x8(%rsp), %xmm8
movss 0x4(%rsp), %xmm7
movaps 0x70(%rsp), %xmm6
movaps 0x80(%rsp), %xmm5
movss 0xc(%rsp), %xmm4
movq 0x10(%rsp), %r9
sarq $0x20, %rbx
movb (%r9,%rbx), %dil
testb %dil, %dil
jne 0x5dd2a
movl $0x1, %edi
leaq 0x59c883(%rip), %rax    # 0x5fa740
callq *0xa0(%rax)
xorl %eax, %eax
addq $0x1d58, %rsp           # imm = 0x1D58
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq