// File: /workspace/github_c_makefile_star2_O1/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, 0x59e010(%rip)    # 0x5f9950
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jne 0x5bd7d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d38, %rsp           # imm = 0x1D38
movl %ecx, %r12d
leaq 0x15c0c2(%rip), %rcx    # 0x1b7a28
cmpl $0xc8, (%rcx)
jne 0x5bd6c
movq %r8, %rbx
movl %edx, %r13d
movl %edi, %ebp
movl %r9d, 0x10(%rsp)
movl %esi, 0xc(%rsp)
callq 0x5bd7e
callq 0x3c626
leaq 0x59ddac(%rip), %r15    # 0x5f9740
xorl %r14d, %r14d
xorl %edi, %edi
callq *0xa0(%r15)
movl $0xbe2, %edi            # imm = 0xBE2
callq *0x40(%r15)
movl $0x0, 0x4c(%rsp)
movl 0x59e08d(%rip), %eax    # 0x5f9a44
movl %eax, 0x28(%rsp)
movswq %r13w, %rcx
leaq 0x3d9fea(%rip), %rax    # 0x4359b0
movb (%rax,%rcx,4), %dil
movb 0x1(%rax,%rcx,4), %sil
movb 0x2(%rax,%rcx,4), %dl
leaq 0x47db2(%rip), %rcx     # 0xa378c
movl (%rcx), %ecx
testl %ecx, %ecx
jne 0x5ba0c
movzbl %dil, %edi
movzbl %sil, %esi
leaq 0x15c015(%rip), %r8     # 0x1b7a04
movslq (%r8), %r8
shlq $0x8, %r8
addq 0x365db(%rip), %r8      # 0x91fd8
movzbl %dl, %edx
movb (%rdi,%r8), %dil
movb (%rsi,%r8), %sil
movb (%rdx,%r8), %dl
movzbl %dil, %edi
cvtsi2ss %edi, %xmm1
testw %r12w, %r12w
movss 0x1d894(%rip), %xmm0    # 0x792b4
divss %xmm0, %xmm1
movss %xmm1, 0x2c(%rsp)
movzbl %sil, %esi
xorps %xmm1, %xmm1
cvtsi2ss %esi, %xmm1
cmovsl %r12d, %r14d
divss %xmm0, %xmm1
movss %xmm1, 0x30(%rsp)
movzbl %dl, %edx
xorps %xmm1, %xmm1
cvtsi2ss %edx, %xmm1
divss %xmm0, %xmm1
movss %xmm1, 0x34(%rsp)
movl $0x3f800000, 0x38(%rsp) # imm = 0x3F800000
movswq %r14w, %rdi
movb (%rax,%rdi,4), %sil
movb 0x1(%rax,%rdi,4), %dl
movb 0x2(%rax,%rdi,4), %al
testl %ecx, %ecx
movl 0x10(%rsp), %r8d
jne 0x5baa1
movzbl %sil, %ecx
movzbl %dl, %edx
leaq 0x15bf7e(%rip), %rsi    # 0x1b7a04
movslq (%rsi), %rdi
shlq $0x8, %rdi
addq 0x36544(%rip), %rdi     # 0x91fd8
movzbl %al, %eax
movb (%rcx,%rdi), %sil
movb (%rdx,%rdi), %dl
movb (%rax,%rdi), %al
movzbl %sil, %ecx
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
divss %xmm0, %xmm1
movss %xmm1, 0x3c(%rsp)
movzbl %dl, %ecx
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
divss %xmm0, %xmm1
movzbl %al, %eax
cvtsi2ss %eax, %xmm2
movss %xmm1, 0x40(%rsp)
divss %xmm0, %xmm2
movss %xmm2, 0x44(%rsp)
testw %r12w, %r12w
jns 0x5bae6
xorps %xmm0, %xmm0
jmp 0x5baee
movss 0x1a4a6(%rip), %xmm0    # 0x75f94
movzbl %r8b, %ecx
xorl %eax, %eax
cmpb $0x2, %cl
movl $0x2, %edx
cmovbl %ecx, %edx
setb %cl
movzbl %dl, %esi
shll $0x5, %esi
leaq 0x35ee1(%rip), %rdi     # 0x919f0
cvtsi2ssl 0xc(%rdi,%rsi), %xmm5
movss %xmm0, 0x48(%rsp)
movl 0x8(%rdi,%rsi), %r15d
leaq 0x70(%rsp), %rsi
movq %rsi, 0x58(%rsp)
leaq 0x430(%rsp), %rsi
movq %rsi, 0x68(%rsp)
cmpb $0x0, (%rbx)
je 0x5bd58
shlb $0x6, %dl
movzbl %dl, %edx
cvtsi2ss %edx, %xmm6
movss 0x1d77e(%rip), %xmm7    # 0x792d0
mulss %xmm7, %xmm6
cvtsi2ss %r15d, %xmm8
movaps %xmm8, %xmm9
mulss %xmm7, %xmm9
mulss %xmm5, %xmm7
movb %cl, %al
leaq 0x1d8e7(%rip), %rcx     # 0x79458
cvtsi2ssl 0xc(%rsp), %xmm10
movss (%rcx,%rax,4), %xmm11
addss %xmm10, %xmm5
leaq 0x1(%rbx), %r12
xorl %r13d, %r13d
movss 0x1d755(%rip), %xmm12   # 0x792e8
xorl %r14d, %r14d
movss %xmm5, 0x10(%rsp)
movss %xmm6, 0xc(%rsp)
movss %xmm7, 0x24(%rsp)
movss %xmm8, 0x20(%rsp)
movss %xmm9, 0x1c(%rsp)
movss %xmm10, 0x18(%rsp)
movss %xmm11, 0x14(%rsp)
movslq %r14d, %rcx
movb (%rbx,%rcx), %r8b
testb %r8b, %r8b
je 0x5bcf7
addq %r12, %rcx
xorl %eax, %eax
leaq 0x47c(%rsp), %rdx
xorl %edi, %edi
xorl %esi, %esi
movzbl %r8b, %r8d
movl %r8d, %r9d
andl $0x1f, %r9d
xorps %xmm0, %xmm0
cvtsi2ss %r9d, %xmm0
mulss %xmm12, %xmm0
shrl $0x5, %r8d
xorps %xmm1, %xmm1
cvtsi2ss %r8d, %xmm1
mulss %xmm11, %xmm1
addss %xmm6, %xmm1
movw %ax, 0x70(%rsp,%rdi,2)
movl %esi, %r8d
orl $0x1, %r8d
movw %r8w, 0x72(%rsp,%rdi,2)
movl %esi, %r8d
orl $0x2, %r8d
movw %r8w, 0x74(%rsp,%rdi,2)
movw %si, 0x76(%rsp,%rdi,2)
movw %r8w, 0x78(%rsp,%rdi,2)
movl %esi, %r8d
orl $0x3, %r8d
xorps %xmm2, %xmm2
cvtsi2ss %ebp, %xmm2
movw %r8w, 0x7a(%rsp,%rdi,2)
movss %xmm2, -0x4c(%rdx)
movss %xmm10, -0x48(%rdx)
movl %r13d, -0x44(%rdx)
movss %xmm0, -0x40(%rdx)
movss %xmm1, -0x3c(%rdx)
movaps %xmm8, %xmm3
addss %xmm2, %xmm3
movss %xmm3, -0x38(%rdx)
movss %xmm10, -0x34(%rdx)
movl %r13d, -0x30(%rdx)
movaps %xmm9, %xmm4
addss %xmm0, %xmm4
movss %xmm4, -0x2c(%rdx)
movss %xmm1, -0x28(%rdx)
movss %xmm3, -0x24(%rdx)
movss %xmm5, -0x20(%rdx)
movl %r13d, -0x1c(%rdx)
movss %xmm4, -0x18(%rdx)
addss %xmm7, %xmm1
movss %xmm1, -0x14(%rdx)
movss %xmm2, -0x10(%rdx)
movss %xmm5, -0xc(%rdx)
movl %r13d, -0x8(%rdx)
movss %xmm0, -0x4(%rdx)
movss %xmm1, (%rdx)
leaq 0x6(%rdi), %r9
addl %r15d, %ebp
movb (%rcx), %r8b
incl %r14d
addl $0x4, %eax
testb %r8b, %r8b
je 0x5bcfc
addq $0x4, %rsi
incq %rcx
addq $0x50, %rdx
cmpq $0x1da, %rdi            # imm = 0x1DA
movq %r9, %rdi
jb 0x5bbe5
jmp 0x5bcfc
xorl %r9d, %r9d
xorl %eax, %eax
movl %r9d, 0x50(%rsp)
movl %eax, 0x60(%rsp)
movl $0x4, %edi
leaq 0x28(%rsp), %rsi
callq 0x5b735
movslq %r14d, %rax
cmpb $0x0, (%rbx,%rax)
movss 0x10(%rsp), %xmm5
movss 0xc(%rsp), %xmm6
movss 0x24(%rsp), %xmm7
movss 0x20(%rsp), %xmm8
movss 0x1c(%rsp), %xmm9
movss 0x18(%rsp), %xmm10
movss 0x14(%rsp), %xmm11
movss 0x1d596(%rip), %xmm12   # 0x792e8
jne 0x5bbc4
movl $0x1, %edi
leaq 0x59d9dc(%rip), %rax    # 0x5f9740
callq *0xa0(%rax)
xorl %eax, %eax
addq $0x1d38, %rsp           # imm = 0x1D38
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq