// File: /workspace/github_c_makefile_star2_O2/mist64[P]cbmbasic/plugin.c
// Function: plugin_gone
unsigned short
plugin_gone() {
	set_chrptr(get_chrptr()+1);
	for (;;) {
		unsigned short chrptr;
		set_chrptr(get_chrptr()-1);
		chrptr = get_chrptr();
		/*
		 * this example shows:
		 * - how to get a 16 bit integer
		 * - how to get an 8 bit integer
		 * - how to check for a comma delimiter
		 * - how to do error handling
		 */
		if (compare("LOCATE")) {
			unsigned char x,y;
			y = get_byte(); /* 'line' first */
			check_comma();
			x = get_byte(); /* then 'column' */
			/* XXX ignores terminal size */
			if (x>80 || y>25 || x==0 || y==0)
				return error(ERROR_ILLEGAL_QUANTITY);
			move_cursor(x, y);

			continue;
		}

                /* Implements the ANSI Set Graphics Mode
		   as appears on http://ascii-table.com/ansi-escape-sequences.php
	           Note that some attributes will be implemented differently depending on what
                   terminal program you are using.
                */
		if (compare("ANSISGM")) {
			char attr, fg, bg;
			attr = get_byte(); /* Attribute */
			check_comma();
			fg = get_byte(); /* Foreground color */
			check_comma();
			bg = get_byte(); /* Background color */

			if (attr < 0 || attr > 8) return error(ERROR_ILLEGAL_QUANTITY);
			if (fg < 30 || fg > 37) return error(ERROR_ILLEGAL_QUANTITY);
			if (bg < 40 || bg > 47) return error(ERROR_ILLEGAL_QUANTITY);

			printf("\033[%d;%d;%dm",attr,bg,fg);
	        	continue;
		}

                /* ANSI erase line */
		if (compare("ANSIEL")) {
			printf("\033[K");
                }

                /* ANSI save cursor pos */
		if (compare("ANSISC")) {
			printf("\033[s");
                }

                /* ANSI restore cursor pos */
		if (compare("ANSIRC")) {
			printf("\033[u");
                }

		/*
		 * this example shows:
		 * - how to override existing keywords
		 * - how to hand the instruction to the
		 *   original interpreter if we don't want
		 *   to handle it
		 */
		if (compare("\222")) { /* 0x92 - WAIT */
			unsigned short a;
			unsigned char b;
			a = get_word();
			check_comma();
			b = get_byte();
			if (a==6502) {
				printf("MICROSOFT!");
				continue;
			} else {
				set_chrptr(chrptr);
				return 0;
			}
		}

		/*
		 * this example shows:
		 * - how to deal with new keywords that contain
		 *   existing keywords
		 * - how to parse a string
		 */
		if (compare("\236TEM")) {
			char s[256];

			get_string(s);
			system(s);

			continue;
		}

		if (compare("QUIT")) {
			exit(0);
		}
		break;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
leaq 0xc67b(%rip), %rbp      # 0x20140
incw 0x7a(%rbp)
leaq 0x9da7(%rip), %rbx      # 0x1d877
leaq 0x9da7(%rip), %r14      # 0x1d87e
leaq 0x9da8(%rip), %r15      # 0x1d886
movzwl 0x7a(%rbp), %r12d
decl %r12d
movw %r12w, 0x7a(%rbp)
movq %rbx, %rdi
callq 0x13a48
testl %eax, %eax
je 0x13b31
callq 0x13cfe
movl %eax, %r12d
callq 0x13d53
callq 0x13cfe
leal -0x51(%rax), %ecx
cmpb $-0x50, %cl
jb 0x13cb9
leal -0x1a(%r12), %ecx
cmpb $-0x1a, %cl
jbe 0x13cb9
movzbl %r12b, %esi
movzbl %al, %edi
callq 0x13dca
jmp 0x13ade
movq %r14, %rdi
callq 0x13a48
testl %eax, %eax
je 0x13b99
callq 0x13cfe
movl %eax, %r12d
callq 0x13d53
callq 0x13cfe
movl %eax, %r13d
callq 0x13d53
callq 0x13cfe
cmpb $0x9, %r12b
jae 0x13cb9
leal -0x26(%r13), %ecx
cmpb $-0x9, %cl
jbe 0x13cb9
leal -0x30(%rax), %ecx
cmpb $-0x9, %cl
jbe 0x13cb9
movsbl %r12b, %esi
movsbl %r13b, %ecx
movzbl %al, %edx
movq %r15, %rdi
xorl %eax, %eax
callq 0x10c0
jmp 0x13ade
leaq 0x9cf2(%rip), %rdi      # 0x1d892
callq 0x13a48
testl %eax, %eax
je 0x13bb7
leaq 0x9ce9(%rip), %rdi      # 0x1d899
xorl %eax, %eax
callq 0x10c0
leaq 0x9cdf(%rip), %rdi      # 0x1d89d
callq 0x13a48
testl %eax, %eax
je 0x13bd5
leaq 0x9cd6(%rip), %rdi      # 0x1d8a4
xorl %eax, %eax
callq 0x10c0
leaq 0x9ccc(%rip), %rdi      # 0x1d8a8
callq 0x13a48
testl %eax, %eax
je 0x13bf3
leaq 0x9cc3(%rip), %rdi      # 0x1d8af
xorl %eax, %eax
callq 0x10c0
leaq 0x9cb9(%rip), %rdi      # 0x1d8b3
callq 0x13a48
testl %eax, %eax
je 0x13c45
movl $0xad8a, %edi           # imm = 0xAD8A
callq 0x13d14
movl $0xb7f7, %edi           # imm = 0xB7F7
callq 0x13d14
movzwl 0x14(%rbp), %r13d
callq 0x13d53
callq 0x13cfe
cmpw $0x1966, %r13w          # imm = 0x1966
jne 0x13cd9
leaq 0x9c7c(%rip), %rdi      # 0x1d8b5
xorl %eax, %eax
callq 0x10c0
jmp 0x13ade
leaq 0x9c74(%rip), %rdi      # 0x1d8c0
callq 0x13a48
testl %eax, %eax
je 0x13ce0
movl $0xad9e, %edi           # imm = 0xAD9E
callq 0x13d14
movl $0xb6a3, %edi           # imm = 0xB6A3
callq 0x13d14
leaq 0x1c4d1(%rip), %rax     # 0x30145
movzbl (%rax), %eax
leaq 0x1c4c4(%rip), %rcx     # 0x30142
movzbl (%rcx), %edx
leaq 0x1c4c0(%rip), %rcx     # 0x30148
movzbl (%rcx), %ecx
shll $0x8, %ecx
orq %rdx, %rcx
addq %rbp, %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x13ca8
movb (%rcx,%rdx), %sil
movb %sil, (%rsp,%rdx)
incq %rdx
jmp 0x13c96
movb $0x0, (%rsp,%rax)
movq %rsp, %rdi
callq 0x10b0
jmp 0x13ade
leaq 0x1c482(%rip), %rax     # 0x30142
movb $0xe, (%rax)
movw $0xa437, %ax            # imm = 0xA437
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movw %r12w, 0x7a(%rbp)
jmp 0x13cf0
leaq 0x9bde(%rip), %rdi      # 0x1d8c5
callq 0x13a48
testl %eax, %eax
jne 0x13cf4
xorl %eax, %eax
jmp 0x13cc7
xorl %edi, %edi
callq 0x1200