// File: 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
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x12b87
movl $0xf, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
jmp 0x12b95
movl $0xf, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x8(%rbp), %eax
imull 0x38c7a9(%rip), %eax    # 0x39f348
movl 0x264e4f(%rip), %ecx    # 0x2779f4
shll %ecx
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x4(%rbp), %eax
imull 0x38c796(%rip), %eax    # 0x39f34c
movl 0x264e38(%rip), %ecx    # 0x2779f4
shll %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, 0x264e3e(%rip)    # 0x277a08
je 0x12bd5
movl $0x1, -0x14(%rbp)
jmp 0x12bdc
movl $0x0, -0x14(%rbp)
movl -0x1c(%rbp), %edi
movl -0x20(%rbp), %esi
movl 0x38c760(%rip), %edx    # 0x39f348
movl 0x38c75e(%rip), %ecx    # 0x39f34c
addl -0x14(%rbp), %ecx
movl $0xe, %r8d
callq 0x12030
movl -0x1c(%rbp), %edi
addl $0x1, %edi
movl -0x20(%rbp), %esi
addl $0x1, %esi
movl 0x38c73a(%rip), %edx    # 0x39f348
subl $0x2, %edx
movl 0x38c735(%rip), %ecx    # 0x39f34c
subl $0x2, %ecx
movl -0x28(%rbp), %r8d
callq 0x120d0
movq 0x38c49e(%rip), %rax    # 0x39f0c8
movq %rax, -0x30(%rbp)
movl 0x264dc0(%rip), %eax    # 0x2779f4
movb %al, -0x31(%rbp)
movl 0x264db3(%rip), %eax    # 0x2779f0
movb %al, -0x32(%rbp)
leaq 0x1a5ba9(%rip), %rax    # 0x1b87f0
movq %rax, 0x38c47a(%rip)    # 0x39f0c8
movq 0x38c473(%rip), %rax    # 0x39f0c8
movzbl 0x8(%rax), %eax
movl %eax, 0x264d95(%rip)    # 0x2779f4
movl $0x4d, %edi
callq 0x103b0
movl %eax, 0x264d81(%rip)    # 0x2779f0
movl 0x38c6fb(%rip), %eax    # 0x39f370
xorl 0x38c6d5(%rip), %eax    # 0x39f350
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x12c98
leaq 0x1adab5(%rip), %rax    # 0x1c0740
movq %rax, -0x40(%rbp)
movl $0x60, -0x10(%rbp)
jmp 0x12cd2
cmpl $0x0, 0x387d69(%rip)    # 0x39aa08
jne 0x12caa
cmpl $0x0, 0x358cec(%rip)    # 0x36b994
je 0x12cbe
leaq 0x1ad18f(%rip), %rax    # 0x1bfe40
movq %rax, -0x40(%rbp)
movl $0x60, -0x10(%rbp)
jmp 0x12cd0
leaq 0x1ac87b(%rip), %rax    # 0x1bf540
movq %rax, -0x40(%rbp)
movl $0x60, -0x10(%rbp)
jmp 0x12cd2
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x12dfd
movq -0x40(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x12d08
jmp 0x12ded
movq -0x40(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x4(%rbp), %eax
jne 0x12deb
movq -0x40(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
cmpl -0x8(%rbp), %eax
jne 0x12deb
movb 0x264d05(%rip), %al     # 0x277a48
addb $0x1, %al
movb %al, 0x264cfd(%rip)     # 0x277a48
movslq 0x38c5f6(%rip), %rax    # 0x39f348
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rdi
callq 0x9120
movq -0x58(%rbp), %rcx
movslq 0x264c86(%rip), %rdx    # 0x2779f0
imulq %rdx, %rax
movslq 0x26f9af(%rip), %rdx    # 0x282724
imulq %rdx, %rax
movl $0x64, %esi
xorl %edx, %edx
divq %rsi
subq %rax, %rcx
shrq %rcx
movslq -0x1c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x1c(%rbp)
movl 0x38c5b3(%rip), %eax    # 0x39f34c
movl %eax, -0x4c(%rbp)
movl 0x264c52(%rip), %eax    # 0x2779f4
imull 0x26f97b(%rip), %eax    # 0x282724
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x4c(%rbp), %eax
subl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %edi
movl -0x1c(%rbp), %esi
movl -0x24(%rbp), %eax
movq -0x48(%rbp), %rcx
movzbl %al, %edx
callq 0x10ee0
movb 0x264c67(%rip), %al     # 0x277a48
addb $-0x1, %al
movb %al, 0x264c5f(%rip)     # 0x277a48
jmp 0x12dfd
jmp 0x12ded
jmp 0x12def
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x12cd9
movq -0x30(%rbp), %rax
movq %rax, 0x38c2c0(%rip)    # 0x39f0c8
movzbl -0x31(%rbp), %eax
movl %eax, 0x264be2(%rip)    # 0x2779f4
movzbl -0x32(%rbp), %eax
movl %eax, 0x264bd4(%rip)    # 0x2779f0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)