// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heather.cpp
// Function: show_key(int, int, int)
void show_key(int row, int col, int invert)
{
int num_keys;
int i;
int shift;
int x,y;
int fg, bg;
unsigned char *old_font;
unsigned char old_height;
unsigned char old_width;
struct KEY_CAP *table;
char *lab;

   // Draw a touch screen keyboard key.  Invert allows flashing the key when
   // it is touched.

   if(invert) {            // set keycap colors
      bg = KBD_FG_COLOR;
      fg = KBD_BG_COLOR;
   }
   else {
      fg = KBD_FG_COLOR;
      bg = KBD_BG_COLOR;
   }

   x = (col * key_width) + TOUCH_MARGIN;  // where to draw the key cap
   y = (row * key_height) + TOUCH_MARGIN;

   if(rotate_screen) i = 1;  // rotate_screen
   else i = 0;
   draw_rectangle(x,y, key_width,key_height+i, KBD_GRID_COLOR);   // key outline
   fill_rectangle(x+1,y+1, key_width-2,key_height-2, bg);         // key interior

   old_font = dot_font;       // switch to large font for key labels
   old_height = TEXT_HEIGHT;
   old_width = TEXT_WIDTH;

   dot_font = (unsigned char *) &h_large_font[0];
   TEXT_HEIGHT = dot_font[8];         // char height
   TEXT_WIDTH = character_width('M'); // character_width('M');

   shift = (shifted ^ caps_lock);

   if(shift) {
      table = &uc_table[0];
      num_keys = sizeof(uc_table) / sizeof(struct KEY_CAP);
   }
   else if(rpn_mode || last_zoom_calc) {
      table = &calc_lc_table[0];
      num_keys = sizeof(calc_lc_table) / sizeof(struct KEY_CAP);
   }
   else {
      table = &normal_lc_table[0];
      num_keys = sizeof(normal_lc_table) / sizeof(struct KEY_CAP);
   }

   for(i=0; i<num_keys; i++) {  // find the key in the table and display it
      lab = table[i].label;
      if(lab == 0) ;
      else if((table[i].row == row) && (table[i].col == col)) {
         ++graphics_coords;
         x += ((key_width - (strlen(lab)*TEXT_WIDTH*vc_font_scale/100)) / 2);
         y += ((key_height - TEXT_HEIGHT*vc_font_scale/100) / 2);
         vidstr(y,x, fg, lab);
         --graphics_coords;
         break;
      }
   }

   dot_font = old_font;       // restore font size
   TEXT_HEIGHT = old_height;
   TEXT_WIDTH = old_width;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r15d
xorl %eax, %eax
testl %edx, %edx
movl $0xf, %ecx
cmovel %ecx, %eax
movl %eax, -0x40(%rbp)
movl %edi, %r12d
cmovel %edx, %ecx
movl %ecx, -0x30(%rbp)
movl 0x33062a(%rip), %edx    # 0x340168
movl %edx, %ebx
imull %esi, %ebx
movl 0x208cca(%rip), %r14d   # 0x218814
leal (%rbx,%r14,2), %edi
movl 0x330618(%rip), %ecx    # 0x34016c
movl %ecx, %r13d
imull %r12d, %r13d
leal (%r13,%r14,2), %esi
cmpl $0x1, 0x208cc1(%rip)    # 0x218828
sbbl $-0x1, %ecx
movl %edi, -0x3c(%rbp)
movl %esi, -0x38(%rbp)
movl $0xe, %r8d
callq 0xf222
leal (%rbx,%r14,2), %edi
incl %edi
leal 0x1(%r13,%r14,2), %esi
movl 0x3305dc(%rip), %edx    # 0x340168
addl $-0x2, %edx
movl 0x3305d7(%rip), %ecx    # 0x34016c
addl $-0x2, %ecx
movl -0x30(%rbp), %r8d
callq 0xf298
movq 0x330340(%rip), %rdx    # 0x33fee8
movzbl 0x208c65(%rip), %esi    # 0x218814
movzbl 0x208c5a(%rip), %edi    # 0x218810
leaq 0x149c43(%rip), %rax    # 0x159800
movq %rax, 0x330324(%rip)    # 0x33fee8
movzbl 0x149c3d(%rip), %ebx    # 0x159808
movl %ebx, 0x208c43(%rip)    # 0x218814
movzwl 0x149d6c(%rip), %ecx    # 0x159944
movzbl (%rcx,%rax), %r14d
movl %r14d, 0x208c2c(%rip)   # 0x218810
movl 0x3305a6(%rip), %eax    # 0x340190
cmpl 0x330580(%rip), %eax    # 0x340170
jne 0xfc12
movl 0x2fcbbc(%rip), %eax    # 0x30c7b4
orl 0x32bc2a(%rip), %eax    # 0x33b828
leaq 0x15124b(%rip), %rcx    # 0x160e50
leaq 0x150944(%rip), %rax    # 0x160550
cmovneq %rcx, %rax
jmp 0xfc19
leaq 0x151b37(%rip), %rax    # 0x161750
movl $0x8, %ecx
movq (%rax,%rcx), %r13
testq %r13, %r13
je 0xfc35
cmpl %r12d, -0x8(%rax,%rcx)
jne 0xfc35
cmpl %r15d, -0x4(%rax,%rcx)
je 0xfc47
addq $0x18, %rcx
cmpq $0x908, %rcx            # imm = 0x908
jne 0xfc1e
jmp 0xfcde
incb 0x208c1b(%rip)          # 0x218868
movslq 0x330514(%rip), %r15    # 0x340168
movl %edi, -0x34(%rbp)
movq %r13, %rdi
movq %rdx, -0x30(%rbp)
movl %esi, %r12d
callq 0x9120
movslq 0x2138d7(%rip), %rcx    # 0x223544
imulq %rcx, %r14
imulq %r14, %rax
shrq $0x2, %rax
movabsq $0x28f5c28f5c28f5c3, %rdx # imm = 0x28F5C28F5C28F5C3
mulq %rdx
shrq $0x2, %rdx
subq %rdx, %r15
shrq %r15
movl -0x3c(%rbp), %esi
addl %r15d, %esi
imull %ecx, %ebx
movslq %ebx, %rax
imulq $-0x51eb851f, %rax, %rax # imm = 0xAE147AE1
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x25, %rax
addl %ecx, %eax
addl 0x3304b6(%rip), %eax    # 0x34016c
movl %eax, %edi
shrl $0x1f, %edi
addl %eax, %edi
sarl %edi
addl -0x38(%rbp), %edi
movzbl -0x40(%rbp), %edx
movq %r13, %rcx
callq 0xe787
movl -0x34(%rbp), %edi
movl %r12d, %esi
movq -0x30(%rbp), %rdx
decb 0x208b8a(%rip)          # 0x218868
movq %rdx, 0x330203(%rip)    # 0x33fee8
movl %esi, 0x208b29(%rip)    # 0x218814
movl %edi, 0x208b1f(%rip)    # 0x218810
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq