// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rsi, %r15
movq %rdi, %rbx
pushq $0x7b
popq %rsi
movq %r15, %rdi
callq 0x2100
movq %rax, %r14
movb $0x0, (%rax)
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x2cf9
movq 0x4f326(%rip), %rcx     # 0x54fc0
pushq $0x3b
popq %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x2d23
cmpl $0x8, (%r12)
jne 0x5d05
movq 0x18(%rsp), %rdi
callq 0x2dd7
movl %eax, %ebp
movq 0x20(%rsp), %rdi
callq 0x2dd7
incq %r14
movb (%r14), %cl
movl %ecx, %edx
andb $-0x10, %dl
incq %r14
cmpb $0x20, %dl
je 0x5cc8
leal -0x7f(%rcx), %edx
addb $-0x40, %cl
xorl %esi, %esi
cmpb $-0x3f, %dl
movzbl %cl, %ecx
cmovbl %esi, %ecx
movzbl %cl, %r15d
cmpl $0x3, %eax
cmovael %esi, %eax
testl %eax, %eax
je 0x5d15
cmpl $0x2, %eax
jne 0x5d34
leaq 0x80488(%rbx), %rdi
jmp 0x5d28
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
imull $0x60, %r15d, %eax
imulq $0x28, %rax, %rax
leaq (%rbx,%rax), %rdi
addq $0x80488, %rdi          # imm = 0x80488
movl $0x3b100, %edx          # imm = 0x3B100
xorl %esi, %esi
callq 0x2120
imull $0x60, %r15d, %eax
imulq $0x28, %rax, %rax
leaq (%rbx,%rax), %rdx
addq $0x80488, %rdx          # imm = 0x80488
movq %r14, %rdi
movl %ebp, %esi
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5b5c