// File: /workspace/github_c_makefile_star2_O0/hamsternz[P]emulate-risc-v/display.c
// Function: display_start
int display_start(void) {
  int i, maxx, maxy;
  if(log_file == NULL) {
    log_file = fopen("events.log","wb");
  }
  for(i = 0; i < N_TRACE; i++) {
    trace_lines[i] = malloc(TRACE_WIDTH+1);
    if(trace_lines[i] == NULL) {
      fprintf(stderr, "Unable to allocate trace lines\n");
      return 0;
    }
    memset(trace_lines[i], ' ', TRACE_WIDTH);
    trace_lines[i][TRACE_WIDTH] = 0;
  }

  for(i = 0; i < N_UART; i++) {
    uart_lines[i] = malloc(UART_WIDTH+1);
    if(uart_lines[i] == NULL) {
      fprintf(stderr, "Unable to allocate uart lines\n");
      return 0;
    }
    memset(uart_lines[i], ' ', UART_WIDTH);
    uart_lines[i][UART_WIDTH] = 0;
  }

  /* This sets up the screen */
  if(initscr()==NULL) {
    return 0;
  }

  if(!has_colors()) {
    endwin();
    fprintf(stderr,"Terminal must support colour\n");
    return 0;
  }

  getmaxyx(stdscr, maxy, maxx);
  if(maxx < 80 || maxy < 30)
  {
    endwin();
    fprintf(stderr,"Terminal must be at least 80x30 - currently %i x %i\n", maxx, maxy);
    return 0;
  }

  start_color();
  init_pair(BORDER_PAIR,   COLOR_WHITE, COLOR_BLACK);
  init_pair(INACTIVE_PAIR, COLOR_CYAN,  COLOR_BLUE);
  init_pair(ACTIVE_PAIR,   COLOR_WHITE, COLOR_BLUE);
  /* This sets up the keyboard to send character by
   *    *      character, without echoing to the screen */ 
  cbreak();
  noecho();
  keypad(stdscr, TRUE);
  nonl();
  timeout(0);
  intrflush(stdscr, FALSE);
  return 1;
}

// Assembly:
subq $0x18, %rsp
cmpq $0x0, 0xc774(%rip)      # 0x12b00
jne 0x63a8
leaq 0x5127(%rip), %rdi      # 0xb4bc
leaq 0x512b(%rip), %rsi      # 0xb4c7
callq 0x21a0
movq %rax, 0xc758(%rip)      # 0x12b00
movl $0x0, 0x10(%rsp)
cmpl $0x11, 0x10(%rsp)
jge 0x6453
movl $0x35, %edi
callq 0x2180
movq %rax, %rdx
movslq 0x10(%rsp), %rcx
leaq 0xc73c(%rip), %rax      # 0x12b10
movq %rdx, (%rax,%rcx,8)
movslq 0x10(%rsp), %rcx
leaq 0xc72c(%rip), %rax      # 0x12b10
cmpq $0x0, (%rax,%rcx,8)
jne 0x6410
movq 0x7c06(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x50ce(%rip), %rsi      # 0xb4ca
movb $0x0, %al
callq 0x2130
movl $0x0, 0x14(%rsp)
jmp 0x6681
movslq 0x10(%rsp), %rcx
leaq 0xc6f4(%rip), %rax      # 0x12b10
movq (%rax,%rcx,8), %rdi
movl $0x20, %esi
movl $0x34, %edx
callq 0x20e0
movslq 0x10(%rsp), %rcx
leaq 0xc6d5(%rip), %rax      # 0x12b10
movq (%rax,%rcx,8), %rax
movb $0x0, 0x34(%rax)
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x63b0
movl $0x0, 0x10(%rsp)
cmpl $0x6, 0x10(%rsp)
jge 0x64fe
movl $0x51, %edi
callq 0x2180
movq %rax, %rdx
movslq 0x10(%rsp), %rcx
leaq 0xc721(%rip), %rax      # 0x12ba0
movq %rdx, (%rax,%rcx,8)
movslq 0x10(%rsp), %rcx
leaq 0xc711(%rip), %rax      # 0x12ba0
cmpq $0x0, (%rax,%rcx,8)
jne 0x64bb
movq 0x7b5b(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x5043(%rip), %rsi      # 0xb4ea
movb $0x0, %al
callq 0x2130
movl $0x0, 0x14(%rsp)
jmp 0x6681
movslq 0x10(%rsp), %rcx
leaq 0xc6d9(%rip), %rax      # 0x12ba0
movq (%rax,%rcx,8), %rdi
movl $0x20, %esi
movl $0x50, %edx
callq 0x20e0
movslq 0x10(%rsp), %rcx
leaq 0xc6ba(%rip), %rax      # 0x12ba0
movq (%rax,%rcx,8), %rax
movb $0x0, 0x50(%rax)
movl 0x10(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10(%rsp)
jmp 0x645b
callq 0x20c0
cmpq $0x0, %rax
jne 0x6516
movl $0x0, 0x14(%rsp)
jmp 0x6681
callq 0x2030
testb $0x1, %al
jne 0x6549
callq 0x21f0
movq 0x7acd(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4fd4(%rip), %rsi      # 0xb509
movb $0x0, %al
callq 0x2130
movl $0x0, 0x14(%rsp)
jmp 0x6681
xorl %eax, %eax
movq 0x7a86(%rip), %rcx      # 0xdfd8
cmpq (%rcx), %rax
je 0x656e
movq 0x7a7a(%rip), %rax      # 0xdfd8
movq (%rax), %rax
movswl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x6579
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x4(%rsp)
jmp 0x6579
movl 0x4(%rsp), %eax
movl %eax, 0x8(%rsp)
xorl %eax, %eax
movq 0x7a4e(%rip), %rcx      # 0xdfd8
cmpq (%rcx), %rax
je 0x65a5
movq 0x7a42(%rip), %rax      # 0xdfd8
movq (%rax), %rax
movswl 0x6(%rax), %eax
addl $0x1, %eax
movl %eax, (%rsp)
jmp 0x65af
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, (%rsp)
jmp 0x65af
movl (%rsp), %eax
movl %eax, 0xc(%rsp)
cmpl $0x50, 0xc(%rsp)
jl 0x65c4
cmpl $0x1e, 0x8(%rsp)
jge 0x65f6
callq 0x21f0
movq 0x7a28(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movl 0xc(%rsp), %edx
movl 0x8(%rsp), %ecx
leaq 0x4f45(%rip), %rsi      # 0xb527
movb $0x0, %al
callq 0x2130
movl $0x0, 0x14(%rsp)
jmp 0x6681
callq 0x20f0
movl $0x1, %edi
movl $0x7, %esi
xorl %edx, %edx
callq 0x2170
movl $0x2, %edi
movl $0x6, %esi
movl $0x4, %edx
callq 0x2170
movl $0x3, %edi
movl $0x7, %esi
movl $0x4, %edx
callq 0x2170
callq 0x2160
callq 0x20a0
movq 0x7993(%rip), %rax      # 0xdfd8
movq (%rax), %rdi
movl $0x1, %esi
callq 0x2110
callq 0x2050
movq 0x797a(%rip), %rax      # 0xdfd8
movq (%rax), %rdi
xorl %esi, %esi
callq 0x2140
movq 0x7969(%rip), %rax      # 0xdfd8
movq (%rax), %rdi
xorl %esi, %esi
callq 0x2150
movl $0x1, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x18, %rsp
retq
nopw (%rax,%rax)