// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heather.cpp
// Function: show_touch_kbd(int)
void show_touch_kbd(int erase)
{
int t,l, b,r;  // top,left, bottom,right
int row,col;
int key_size;
unsigned i;

   // draw the touch screen keyboard (upper or lower case)

   if(zoom_screen != 'K') return;

   t = 0+TOUCH_MARGIN;   // allowable keyboard outline
   l = 0+TOUCH_MARGIN;

   b = PLOT_ROW-TOUCH_MARGIN;
   r = SCREEN_WIDTH-TOUCH_MARGIN;

   if(0) {  // always square keys
     key_size = (b-t)/KBD_ROWS;
     if(((r-l)/KBD_COLS) < key_size) key_size = ((r-l)/KBD_COLS);
     r = TOUCH_MARGIN + (KBD_COLS*key_size);
     key_width = key_height = key_size;
   }
   else {   // possible rectangular keys to fill the keyboard space
      key_height = (b-t)/KBD_ROWS;
      key_width = (r-l)/KBD_COLS;
   }

   if(erase) {  // screen erase needed
      erase_screen();
   }

   for(row=0; row<KBD_ROWS; row++) {     // draw the keyboard grid
      for(col=0; col<KBD_COLS; col++) {
         show_key(row,col, 0);
      }

      t += key_height;
   }

   ++graphics_coords;
   vidstr(t+TEXT_HEIGHT,l, KBD_TITLE_COLOR, "Touch screen keyboard.  Enter a command or touch any blank key to exit.");
   --graphics_coords;

   // get the keyboard table indexes of the SHIFT and CAPS LOCK keys
   // so we can change the labels depending upon their state
   for(i=0; i<((sizeof(normal_lc_table) / sizeof(struct KEY_CAP))); i++) {
      if(normal_lc_table[i].val == TOUCH_SH) lc_shift_index = i;
      if(normal_lc_table[i].val == TOUCH_CAP) uc_cap_lock_index = i;
      if(normal_lc_table[i].val == TOUCH_BUT) lc_but_lock_index = i;
   }
   for(i=0; i<((sizeof(uc_table) / sizeof(struct KEY_CAP))); i++) {
      if(uc_table[i].val == TOUCH_SH) uc_shift_index = i;
      if(uc_table[i].val == TOUCH_CAP) uc_cap_lock_index = i;
      if(uc_table[i].val == TOUCH_BUT) uc_but_lock_index = i;
   }
}

// Assembly:
cmpb $0x4b, 0x2fd924(%rip)   # 0x30c7a8
jne 0xefb3
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl 0x209979(%rip), %ebx    # 0x218814
movl 0x2099db(%rip), %eax    # 0x21887c
movl 0x209959(%rip), %ecx    # 0x218800
leal (,%rbx,4), %edx
subl %edx, %eax
cltq
imulq $0x2aaaaaab, %rax, %rax # imm = 0x2AAAAAAB
movq %rax, %rsi
shrq $0x3f, %rsi
shrq $0x20, %rax
addl %esi, %eax
movl %eax, 0x3312a0(%rip)    # 0x34016c
subl %edx, %ecx
movslq %ecx, %rax
imulq $-0x77777777, %rax, %rcx # imm = 0x88888889
shrq $0x20, %rcx
addl %ecx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
sarl $0x3, %eax
addl %ecx, %eax
movl %eax, 0x33127a(%rip)    # 0x340168
testl %edi, %edi
je 0xeef7
callq 0xed5e
addl %ebx, %ebx
xorl %r15d, %r15d
movl %ebx, %r14d
xorl %r12d, %r12d
movl %r15d, %edi
movl %r12d, %esi
xorl %edx, %edx
callq 0xfb8f
incl %r12d
cmpl $0xf, %r12d
jne 0xef02
addl 0x33124d(%rip), %r14d   # 0x34016c
incl %r15d
cmpl $0x6, %r15d
jne 0xeeff
incb 0x20993a(%rip)          # 0x218868
addl 0x2098df(%rip), %r14d   # 0x218814
leaq 0xfb08b(%rip), %rcx     # 0x109fc7
movl %r14d, %edi
movl %ebx, %esi
movl $0xb, %edx
callq 0xe7d0
decb 0x209917(%rip)          # 0x218868
leaq 0x151608(%rip), %rax    # 0x160560
xorl %ecx, %ecx
leaq 0x140b8f(%rip), %rdx    # 0x14faf0
movslq (%rax), %rsi
cmpq $-0x3, %rsi
jb 0xef71
movq 0x18(%rdx,%rsi,8), %rsi
movl %ecx, (%rsi)
incq %rcx
addq $0x18, %rax
cmpq $0x60, %rcx
jne 0xef61
leaq 0x1527db(%rip), %rax    # 0x161760
xorl %ecx, %ecx
leaq 0x140b7a(%rip), %rdx    # 0x14fb08
movslq (%rax), %rsi
cmpq $-0x3, %rsi
jb 0xef9e
movq 0x18(%rdx,%rsi,8), %rsi
movl %ecx, (%rsi)
incq %rcx
addq $0x18, %rax
cmpq $0x60, %rcx
jne 0xef8e
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq