// File: /workspace/github_c_makefile_star2_O1/uobikiemukot[P]yaft/./ctrlseq/dcs.h
// Function: decdld_parse_header
void decdld_parse_header(struct terminal_t *term, char *start_buf)
{
	/*
	DECDLD format
		DCS Pfn; Pcn; Pe; Pcmw; Pss; Pt; Pcmh; Pcss; f Dscs Sxbp1 ; Sxbp2 ; .. .; Sxbpn ST
	parameters
		DCS : ESC (0x1B) 'P' (0x50) (DCS(8bit C1 code) is not supported)
		Pfn : fontset (ignored)
		Pcn : start char (0 means SPACE 0x20)
		Pe  : erase mode
				0: clear selectet charset
				1: clear only redefined glyph
				2: clear all drcs charset
		Pcmw: max cellwidth (force CELL_WEDTH defined in glyph.h)
		Pss : screen size (ignored)
		Pt  : defines the glyph as text or full cell or sixel (force full cell mode)
		      (TODO: implement sixel/text mode)
		Pcmh: max cellheight (force CELL_HEIGHT defined in glyph.h)
		Pcss: character set size (force: 96)
				0: 94 glyphs charset
				1: 96 glyphs charset
		f   : '{' (0x7B)
		Dscs: define character set
				Intermediate char: SPACE (0x20) to '/' (0x2F)
				final char       : '0' (0x30) to '~' (0x7E)
									but allow chars between '@' (0x40) and '~' (0x7E) for DRCSMMv1
									(ref: https://github.com/saitoha/drcsterm/blob/master/README.rst)
		Sxbp: see parse_decdld_sixel()
		ST  : ESC (0x1B) '\' (0x5C) or BEL (0x07)
	*/
	char *cp;
	int start_char, erase_mode, charset;
	struct parm_t parm;

	/* replace final char of DECDLD header by NUL '\0' */
	cp = strchr(start_buf, '{');
	*cp = '\0';

	logging(DEBUG, "decdld_parse_header()\nbuf:%s\n", start_buf);

	/* split header by semicolon ';' */
	reset_parm(&parm);
	parse_arg(start_buf, &parm, ';', isdigit);

	if (parm.argc != 8) /* DECDLD header must have 8 params */
		return;

	/* set params */
	start_char = dec2num(parm.argv[1]);
	erase_mode = dec2num(parm.argv[2]);

	/* parse Dscs */
	cp++; /* skip final char (NUL) of DECDLD header */
	while (SPACE <= *cp && *cp <= '/') /* skip intermediate char */
		cp++;

	if (0x40 <= *cp && *cp <= 0x7E) /* final char of Dscs must be between 0x40 to 0x7E (DRCSMMv1) */
		charset = *cp - 0x40;
	else
		charset = 0;

	logging(DEBUG, "charset(ku):0x%.2X start_char:%d erase_mode:%d\n",
		charset, start_char, erase_mode);

	/* reset previous glyph data */
	if (erase_mode < 0 || erase_mode > 2)
		erase_mode = 0;

	if (erase_mode == 2)      /* reset all drcs charset */
		memset(term->drcs, 0, sizeof(struct glyph_t) * DRCS_CHARS);
	else if (erase_mode == 0) /* reset selected drcs charset */
		memset(term->drcs + GLYPHS_PER_CHARSET * charset, 0, sizeof(struct glyph_t) * DRCS_CHARS);

	//if (term->drcs[charset] == NULL) /* always allocate 96 chars buffer */
		//term->drcs[charset] = ecalloc(GLYPH_PER_CHARSET, sizeof(struct glyph_t));

	decdld_parse_data(cp + 1, start_char, term->drcs + GLYPHS_PER_CHARSET * charset); /* skip final char */
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
movl $0x7b, %esi
callq 0x2100
movq %rax, %r14
movb $0x0, (%rax)
movl $0x0, 0x8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x80(%rsp)
movups %xmm0, 0x70(%rsp)
movups %xmm0, 0x60(%rsp)
movups %xmm0, 0x50(%rsp)
movups %xmm0, 0x40(%rsp)
movups %xmm0, 0x30(%rsp)
movups %xmm0, 0x20(%rsp)
movups %xmm0, 0x10(%rsp)
testq %r15, %r15
je 0x6cc3
movq %r15, %rdi
callq 0x20d0
testq %rax, %rax
je 0x6cc3
movl 0x8(%rsp), %ecx
xorl %edx, %edx
testq %rdx, %rdx
jne 0x6c6a
movsbl (%r15), %edx
addl $-0x3a, %edx
cmpl $-0xa, %edx
movl $0x0, %edx
cmovaeq %r15, %rdx
cmpb $0x3b, (%r15)
jne 0x6c85
movb $0x0, (%r15)
cmpl $0xf, %ecx
jg 0x6c83
movslq %ecx, %rsi
movq %rdx, 0x10(%rsp,%rsi,8)
incl %ecx
xorl %edx, %edx
cmpq $0x1, %rax
jne 0x6c9f
testq %rdx, %rdx
je 0x6ca9
cmpl $0xf, %ecx
jg 0x6c9f
movslq %ecx, %rsi
movq %rdx, 0x10(%rsp,%rsi,8)
incl %ecx
incq %r15
decq %rax
jne 0x6c52
jmp 0x6cbf
cmpb $0x0, (%r15)
setne %sil
cmpl $0x10, %ecx
setge %dil
orb %sil, %dil
je 0x6c95
jmp 0x6c9f
movl %ecx, 0x8(%rsp)
cmpl $0x8, 0x8(%rsp)
jne 0x6d48
movq 0x18(%rsp), %rdi
xorl %r12d, %r12d
movl $0x0, %r15d
testq %rdi, %rdi
je 0x6cec
xorl %esi, %esi
movl $0xa, %edx
callq 0x2d03
movq %rax, %r15
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x6d05
xorl %esi, %esi
movl $0xa, %edx
callq 0x2d03
movq %rax, %r12
incq %r14
movb (%r14), %al
movl %eax, %ecx
andb $-0x10, %cl
incq %r14
cmpb $0x20, %cl
je 0x6d08
leal -0x7f(%rax), %ecx
addb $-0x40, %al
xorl %edx, %edx
cmpb $-0x3f, %cl
movzbl %al, %eax
cmovbl %edx, %eax
movzbl %al, %r13d
cmpl $0x3, %r12d
cmovael %edx, %r12d
testl %r12d, %r12d
je 0x6d59
cmpl $0x2, %r12d
jne 0x6d7d
leaq 0x80488(%rbx), %rdi
jmp 0x6d71
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl %r13d, %eax
shll $0x5, %eax
leal (%rax,%rax,2), %eax
leaq (%rax,%rax,4), %rax
leaq (%rbx,%rax,8), %rdi
addq $0x80488, %rdi          # imm = 0x80488
movl $0x3b100, %edx          # imm = 0x3B100
xorl %esi, %esi
callq 0x2130
shll $0x5, %r13d
leal (%r13,%r13,2), %eax
leaq (%rax,%rax,4), %rax
leaq (%rbx,%rax,8), %rdx
addq $0x80488, %rdx          # imm = 0x80488
movq %r14, %rdi
movl %r15d, %esi
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x6abc