// File: /workspace/github_c_makefile_star2_O0/serge-404[P]CPM32/cpm.c
// Function: io_output
void io_output( int add, int data) {
	int p,i;
	DEBUGOUT( stderr, "ERROR: i/o write port:%04x <- %02x\n", add, data);
 	switch (add) {
 		case 0xf9:  mem=&mem1024[(data & 0x0f) * 0x10000];
			 		goto ori128;
 		case 0xfb:  if (data & 0x80) {
 			            dispatcher=TRUE;
 						mem16=&mem1024[((int)data & 0x0f)<<6];
 					}
		 			else mem16=mem;
 					fullram=data & 0x20;
 					int50hz=data & 0x40;
 		case 0xf8:
 		case 0xfa:  
ori128:				if (orion128==FALSE) {		/* Switch to Orion128 mode and init F800 ROM area */
 	 					orion128=TRUE;
						p = ROM_ORG;
						for ( i = 0; i < ROM_CNT; i++) {
							mem1024[ p++] = 0xC3;
							setword( mem1024[ p++], 3*ROM_CNT+ROM_ORG);	    /*   JP MMMM */
						}
						mem1024[ p++] = 0xED; mem1024[ p++] = 0xED;         /* SPECIAL OPCODE */
						mem1024[ p++] = 0xC9;				          		/*   RET */
 					}
 					break;
 		default: exit( -1);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
cmpl $0x0, 0x10e23f(%rip)    # 0x11b4b4
je 0xd295
movq 0xdd7a(%rip), %rax      # 0x1aff8
movq (%rax), %rdi
movl -0x4(%rbp), %edx
movl -0x8(%rbp), %ecx
leaq 0xb172(%rip), %rsi      # 0x18400
movb $0x0, %al
callq 0x2220
movl -0x4(%rbp), %eax
addl $0xffffff08, %eax       # imm = 0xFFFFFF08
movl %eax, %ecx
movq %rcx, -0x18(%rbp)
subl $0x3, %eax
ja 0xd40b
movq -0x18(%rbp), %rax
leaq 0x7f05(%rip), %rcx      # 0x151bc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x8(%rbp), %eax
andl $0xf, %eax
shll $0x10, %eax
movslq %eax, %rcx
leaq 0xe16d(%rip), %rax      # 0x1b440
addq %rcx, %rax
movq %rax, 0xdf33(%rip)      # 0x1b210
jmp 0xd33d
movl -0x8(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xd315
movl $0x1, 0x10e14a(%rip)    # 0x11b440
movl -0x8(%rbp), %eax
andl $0xf, %eax
shll $0x6, %eax
movslq %eax, %rcx
leaq 0xe137(%rip), %rax      # 0x1b440
addq %rcx, %rax
movq %rax, 0xdf05(%rip)      # 0x1b218
jmp 0xd323
movq 0xdef4(%rip), %rax      # 0x1b210
movq %rax, 0xdef5(%rip)      # 0x1b218
movl -0x8(%rbp), %eax
andl $0x20, %eax
movl %eax, 0x10e115(%rip)    # 0x11b444
movl -0x8(%rbp), %eax
andl $0x40, %eax
movl %eax, 0x10e10d(%rip)    # 0x11b448
jmp 0xd33d
cmpl $0x0, 0x10e108(%rip)    # 0x11b44c
jne 0xd409
movl $0x1, 0x10e0f8(%rip)    # 0x11b44c
movl $0xf800, -0xc(%rbp)     # imm = 0xF800
movl $0x0, -0x10(%rbp)
cmpl $0x16, -0x10(%rbp)
jge 0xd3be
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0xe0c3(%rip), %rax      # 0x1b440
movb $-0x3d, (%rax,%rcx)
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0xe0aa(%rip), %rax      # 0x1b440
movb $0x42, (%rax,%rcx)
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0xe091(%rip), %rax      # 0x1b440
movb $-0x8, (%rax,%rcx)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xd362
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0xe06d(%rip), %rax      # 0x1b440
movb $-0x13, (%rax,%rcx)
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0xe054(%rip), %rax      # 0x1b440
movb $-0x13, (%rax,%rcx)
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0xe03b(%rip), %rax      # 0x1b440
movb $-0x37, (%rax,%rcx)
jmp 0xd415
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x23c0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)