// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/deark-char.c
// Function: do_create_standard_font
static void do_create_standard_font(deark *c, struct charextractx *ectx)
{
	i64 i;
	struct de_bitmap_font *font;
	const u8 *vga_cp437_font_data;
	struct de_bitmap_font_char *ch;
	struct de_encconv_state es;

	font = de_create_bitmap_font(c);
	ectx->standard_font = font;

	vga_cp437_font_data = de_get_vga_cp437_font_ptr();

	font->num_chars = 256 + NUM_EXTRA_FONT_CHARS;
	font->nominal_width = 8;
	font->nominal_height = 16;
	font->has_nonunicode_codepoints = 1;
	font->has_unicode_codepoints = 1;

	font->char_array = de_mallocarray(c, font->num_chars, sizeof(struct de_bitmap_font_char));

	// Set defaults for each character
	for(i=0; i<font->num_chars; i++) {
		ch = &font->char_array[i];
		ch->width = font->nominal_width;
		ch->height = font->nominal_height;
		ch->rowspan = 1;
	}

	de_encconv_init(&es, DE_ENCODING_CP437_G);
	for(i=0; i<font->num_chars; i++) {
		ch = &font->char_array[i];
		ch->codepoint_nonunicode = (i32)i;
		ch->codepoint_unicode = de_char_to_unicode_ex((i32)i, &es);
		ch->bitmap = (u8*)&vga_cp437_font_data[i*16];
	}

	// Add vt100 characters that aren't in CP437
	for(i=0; i<NUM_EXTRA_FONT_CHARS; i++) {
		ch = &font->char_array[256+i];
		ch->codepoint_nonunicode = DE_CODEPOINT_INVALID;
		ch->codepoint_unicode = extra_font_codepoints[i];
		ch->bitmap = (u8*)&extra_font_data[i*16];
	}
	font->index_of_replacement_char = 256;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x16f6f0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
callq 0x161460
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq $0x10d, 0x18(%rax)      # imm = 0x10D
movq -0x20(%rbp), %rax
movl $0x8, (%rax)
movq -0x20(%rbp), %rax
movl $0x10, 0x4(%rax)
movq -0x20(%rbp), %rax
movb $0x1, 0x10(%rax)
movq -0x20(%rbp), %rax
movb $0x1, 0x11(%rax)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
movl $0x28, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jge 0x16e163
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rax
movq $0x1, 0x18(%rax)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x16e10c
leaq -0x50(%rbp), %rdi
movl $0xd, %esi
callq 0x160150
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jge 0x16e1e4
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl %eax, %edi
leaq -0x50(%rbp), %rsi
callq 0x160a30
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x16e179
movq $0x0, -0x18(%rbp)
cmpq $0xd, -0x18(%rbp)
jge 0x16e258
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x18(%rbp), %rcx
addq $0x100, %rcx            # imm = 0x100
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl $0xfffffff, (%rax)      # imm = 0xFFFFFFF
movq -0x18(%rbp), %rcx
leaq 0x675da(%rip), %rax     # 0x1d5800
movl (%rax,%rcx,4), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
shlq $0x4, %rax
leaq 0x67601(%rip), %rcx     # 0x1d5840
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x16e1ec
movq -0x20(%rbp), %rax
movq $0x100, 0x8(%rax)       # imm = 0x100
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)