// File: /workspace/github_cpp_makefile_star2_O3/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, 0x2fd9a3(%rip)   # 0x30c7a8
jne 0xef34
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl 0x2099f8(%rip), %ebx    # 0x218814
movl 0x209a5a(%rip), %eax    # 0x21887c
movl 0x2099d8(%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, 0x33131f(%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, 0x3312f9(%rip)    # 0x340168
testl %edi, %edi
je 0xee78
callq 0xeceb
addl %ebx, %ebx
xorl %r15d, %r15d
movl %ebx, %r14d
xorl %r12d, %r12d
movl %r15d, %edi
movl %r12d, %esi
xorl %edx, %edx
callq 0xfb0c
incl %r12d
cmpl $0xf, %r12d
jne 0xee83
addl 0x3312cc(%rip), %r14d   # 0x34016c
incl %r15d
cmpl $0x6, %r15d
jne 0xee80
incb 0x2099b9(%rip)          # 0x218868
addl 0x20995e(%rip), %r14d   # 0x218814
leaq 0xfb11a(%rip), %rcx     # 0x109fd7
movl %r14d, %edi
movl %ebx, %esi
movl $0xb, %edx
callq 0xe787
decb 0x209996(%rip)          # 0x218868
leaq 0x151687(%rip), %rax    # 0x160560
xorl %ecx, %ecx
leaq 0x140c0e(%rip), %rdx    # 0x14faf0
movslq (%rax), %rsi
cmpq $-0x3, %rsi
jb 0xeef2
movq 0x18(%rdx,%rsi,8), %rsi
movl %ecx, (%rsi)
incq %rcx
addq $0x18, %rax
cmpq $0x60, %rcx
jne 0xeee2
leaq 0x15285a(%rip), %rax    # 0x161760
xorl %ecx, %ecx
leaq 0x140bf9(%rip), %rdx    # 0x14fb08
movslq (%rax), %rsi
cmpq $-0x3, %rsi
jb 0xef1f
movq 0x18(%rdx,%rsi,8), %rsi
movl %ecx, (%rsi)
incq %rcx
addq $0x18, %rax
cmpq $0x60, %rcx
jne 0xef0f
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq