// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathmsc.cpp
// Function: zoom_cal(int, int)
void zoom_cal(int year, int month)
{
int day;
int dow;
int row, col;
int top;
int color;
int i, j;
int CAL_WIDTH;
int CAL_LEFT;
int pre_month;
double jd;
char *days;

   // Show a zoomed full screen calendar
   
   CAL_WIDTH = 30;
   CAL_LEFT = 2;
   i = 4;
   days = "SUN MON TUE WED THU FRI SAT";
   if(SMALL_SCREEN) {
      CAL_WIDTH = 24;
      CAL_LEFT = 2;
      i = 3;
      days = "SU MO TU WE TH FR SA";
   }

   CAL_LEFT = (TEXT_COLS - ((CAL_WIDTH*3) + (i*2))) / 2;

   if(month < 1) month = 1;
   if(month > 12) month = 12;

   erase_screen();

   col = CAL_LEFT;
   top = 0;
   if(SCREEN_HEIGHT < SHORT_SCREEN) pre_month = 1; // start with 1 previous months
   else pre_month = 4;  // 4 previous months
   month = month - pre_month;
   if(month <= 0) { 
      --year;
      month += 12;
   }

   for(j=1; j<=48; j++) {  // display up to 48 months
      init_dsm(year);
      calc_dst_times(year, dst_list[dst_area]);  // find daylight savings change times

      row = 0;

      dow = day_of_week(1, month, year);
      if(year < 0) sprintf(out, "%s %d BC", full_months[month], 0-year);
      else         sprintf(out, "%s %04d",  full_months[month], year);
      i = ((CAL_WIDTH-3) - strlen(out)) / 2;
      color = WHITE;
      if((month == pri_month) && (year == pri_year)) color = GREEN;
      else if(j <= pre_month) color = DIM_WHITE;
      vidstr(top+row, col+i, color, out);  // center year/month string
      ++row;

      vidstr(top+row, col, color, days);
      ++row;

      jd = jdate(year,month,1);
      calc_moons(jd, 3); 

      for(day=1; day<=dim[month]; day++) {  // show the day values
         dow = day_of_week(day, month, year);

         if(SMALL_SCREEN) sprintf(out, "%-3d", day);
         else             sprintf(out, "%-4d", day);
         i = col + (dow * strlen(out));

         if((month == dst_start_month) && (day == dst_start_day)) color = BLUE;
         else if((month == dst_end_month) && (day == dst_end_day)) color = BLUE;
         else if(moons[day][0] && (moons[day][0] != 'Q')) {
            if(strstr(moons[day], "Full")) color = YELLOW;     // full moon
            else if(strstr(moons[day], "Blue")) color = YELLOW; // blue moon
            else color = BROWN;  // new moon / black moon
         }
         else if(is_holiday(year,month,day)) color = CYAN;
         else if((month == pri_month) && (year == pri_year)) color = GREEN;
         else if(j <= pre_month) color = DIM_WHITE;
         else color = WHITE;
         if((pri_year == year) && (pri_month == month) && (pri_day == day) && (pri_seconds & 1)) {
            color = BLACK;  // blink today's date
         }
         vidstr(top+row, i, color, out);

         if(dow >= 6) {  // end of week, go to next row
            ++row;
         }
      }


      col += CAL_WIDTH;  // setup for next month
      if(col > ((CAL_WIDTH*2)+CAL_LEFT)) {
         col = CAL_LEFT;
         top += 8;
      }
      if(top >= (TEXT_ROWS-8)) break;

      ++month;
      if(month > 12) {
         month = 1;
         year += 1;
      }
   }

   init_dsm(this_year);
   calc_dst_times(this_year, dst_list[dst_area]);  // find daylight savings change times
   calc_moons(jd_local, 5); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
leaq 0x123c70(%rip), %rcx    # 0x202800
leaq 0x12e9ad(%rip), %rax    # 0x20d544
imull $0x31a, (%rax), %eax    # imm = 0x31A
movl (%rcx), %ecx
pushq $0x64
popq %r8
cltd
idivl %r8d
cmpl %eax, %ecx
setl %al
leaq 0x123c51(%rip), %r15    # 0x202804
movl $0x258, %ecx            # imm = 0x258
cmpl %ecx, (%r15)
movl %edi, %r12d
setl %cl
orb %al, %cl
movzbl %cl, %eax
leal (%rax,%rax), %ecx
testb %al, %al
pushq $0x18
popq %rax
pushq $0x1e
popq %r13
cmovnel %eax, %r13d
leaq 0x40300(%rip), %rax     # 0x11eedd
leaq 0x402dd(%rip), %rdx     # 0x11eec1
cmovneq %rax, %rdx
movq %rdx, -0x68(%rbp)
leaq 0x123c15(%rip), %rax    # 0x202808
imull $-0x3, %r13d, %edx
addl (%rax), %ecx
leal (%rdx,%rcx), %eax
addl $-0x8, %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
movl %eax, %ebx
cmpl $0x2, %esi
pushq $0x1
popq %rax
cmovll %eax, %esi
cmpl $0xc, %esi
pushq $0xc
popq %r14
cmovll %esi, %r14d
callq 0xe7d9
xorl %eax, %eax
movl $0x258, %ecx            # imm = 0x258
cmpl %ecx, (%r15)
movl %r12d, %r15d
setge %al
leal (%rax,%rax,2), %eax
incl %eax
movl %eax, -0x48(%rbp)
subl %eax, %r14d
leal 0xc(%r14), %ecx
xorl %eax, %eax
testl %r14d, %r14d
setle %al
cmovgl %r14d, %ecx
movq %rcx, -0x30(%rbp)
subl %eax, %r15d
leal -0x3(%r13), %eax
movq %rax, -0x60(%rbp)
movq %r13, -0x70(%rbp)
leal (%rbx,%r13,2), %edi
leaq 0x2475b7(%rip), %r12    # 0x326220
movq %rbx, %rax
movq %rbx, -0x58(%rbp)
movl %eax, -0x34(%rbp)
movq $0x0, -0x40(%rbp)
pushq $0x1
popq %rbx
movl %edi, -0x44(%rbp)
cmpl $0x31, %ebx
je 0xdefa3
movl %r15d, %edi
callq 0xcd74f
leaq 0x218c03(%rip), %rax    # 0x2f789c
movslq (%rax), %rax
leaq 0x75b8d(%rip), %rcx     # 0x154830
movq (%rcx,%rax,8), %rsi
movl %r15d, %edi
callq 0xce1f2
movslq -0x30(%rbp), %rcx
leaq 0x75af6(%rip), %rax     # 0x1547b0
movq %rcx, -0x78(%rbp)
movq (%rax,%rcx,8), %rdx
testl %r15d, %r15d
js 0xdecd6
movq %r12, %rdi
leaq 0x38fb3(%rip), %rsi     # 0x117c84
movl %r15d, %ecx
jmp 0xdece5
movl %r15d, %ecx
negl %ecx
movq %r12, %rdi
leaq 0x4020d(%rip), %rsi     # 0x11eef2
xorl %eax, %eax
callq 0x9060
movq %r12, %rdi
callq 0x9120
movq -0x60(%rbp), %rsi
subq %rax, %rsi
shrq %rsi
leaq 0x21880b(%rip), %rax    # 0x2f7510
movl (%rax), %eax
xorl -0x30(%rbp), %eax
leaq 0x218803(%rip), %rcx    # 0x2f7514
movl (%rcx), %ecx
xorl %r15d, %ecx
movl %ebx, -0x50(%rbp)
cmpl -0x48(%rbp), %ebx
seta %dl
shlb $0x3, %dl
orb $0x7, %dl
orl %eax, %ecx
movzbl %dl, %eax
movl %eax, -0x4c(%rbp)
pushq $0xa
popq %rcx
cmovel %ecx, %eax
movl -0x34(%rbp), %r13d
addl %r13d, %esi
movzbl %al, %ebx
movq -0x40(%rbp), %r14
movl %r14d, %edi
movl %ebx, %edx
movq %r12, %rcx
callq 0xe2d2
leal 0x1(%r14), %edi
movl %r13d, %esi
movl %ebx, %edx
movq -0x68(%rbp), %rcx
callq 0xe2d2
movl %r15d, %edi
movq -0x30(%rbp), %rsi
pushq $0x1
popq %rdx
callq 0xc2f07
callq 0xd57b4
pushq $0x1
popq %r14
pushq $0x2
popq %rax
movl %eax, %r13d
movl %r15d, -0x38(%rbp)
leaq 0x75977(%rip), %rax     # 0x154700
movq -0x78(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
cmpq %rax, %r14
jg 0xdef47
movl %r14d, %edi
movq -0x30(%rbp), %rsi
movl %r15d, %edx
callq 0xcd7b8
leaq 0x12e794(%rip), %rcx    # 0x20d544
imull $0x31a, (%rcx), %ecx    # imm = 0x31A
movl %eax, %r15d
movl %ecx, %eax
cltd
pushq $0x64
popq %rcx
idivl %ecx
leaq 0x123a3c(%rip), %rcx    # 0x202804
cmpl $0x258, (%rcx)          # imm = 0x258
leaq 0x32971(%rip), %rcx     # 0x111746
jl 0xdedde
leaq 0x338ab(%rip), %rcx     # 0x112689
leaq 0x32961(%rip), %rsi     # 0x111746
leaq 0x123a14(%rip), %rdx    # 0x202800
cmpl %eax, (%rdx)
jl 0xdedf3
movq %rcx, %rsi
movq %r12, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x9060
movq %r12, %rdi
callq 0x9120
movq %rax, %r12
movb $0x9, %cl
movq -0x30(%rbp), %rax
cmpl 0x285bed(%rip), %eax    # 0x364a04
jne 0xdee28
movl 0x285be1(%rip), %eax    # 0x364a00
cmpq %rax, %r14
je 0xdeec4
movq -0x30(%rbp), %rax
cmpl 0x285bda(%rip), %eax    # 0x364a0c
jne 0xdee43
movl 0x285bce(%rip), %eax    # 0x364a08
cmpq %rax, %r14
je 0xdeec4
leaq 0x7c176(%rip), %rax     # 0x15afc0
movq (%rax,%r14,8), %rbx
movzbl (%rbx), %eax
testl %eax, %eax
je 0xdee5a
cmpl $0x51, %eax
jne 0xdee93
movl -0x38(%rbp), %edi
movq -0x30(%rbp), %rsi
movl %r14d, %edx
callq 0xdaa9d
movb $0xb, %cl
testl %eax, %eax
jne 0xdeec4
leaq 0x21869a(%rip), %rax    # 0x2f7510
movl (%rax), %eax
xorl -0x30(%rbp), %eax
leaq 0x218692(%rip), %rcx    # 0x2f7514
movl (%rcx), %ecx
xorl -0x38(%rbp), %ecx
orl %eax, %ecx
pushq $0xa
popq %rcx
je 0xdeec4
movl -0x4c(%rbp), %ecx
jmp 0xdeec4
movq %rbx, %rdi
leaq 0x4005e(%rip), %rsi     # 0x11eefb
callq 0x9090
movb $0xe, %cl
testq %rax, %rax
jne 0xdeec4
movq %rbx, %rdi
leaq 0x4004d(%rip), %rsi     # 0x11ef00
callq 0x9090
testq %rax, %rax
setne %cl
shlb $0x3, %cl
orb $0x6, %cl
movzbl %r15b, %ebx
imull %ebx, %r12d
addl -0x34(%rbp), %r12d
leaq 0x21863d(%rip), %rax    # 0x2f7514
movl (%rax), %eax
movl -0x38(%rbp), %r15d
xorl %r15d, %eax
leaq 0x218629(%rip), %rdx    # 0x2f7510
movl (%rdx), %edx
xorl -0x30(%rbp), %edx
leaq 0x218619(%rip), %rsi    # 0x2f750c
movl (%rsi), %esi
leaq 0x218604(%rip), %rdi    # 0x2f7500
testb $0x1, (%rdi)
movzbl %cl, %ecx
movl $0x0, %r8d
cmovel %ecx, %r8d
cmpq %rsi, %r14
cmovnel %ecx, %r8d
orl %eax, %edx
cmovnel %ecx, %r8d
movq -0x40(%rbp), %rax
leal (%r13,%rax), %edi
movzbl %r8b, %edx
movl %r12d, %esi
leaq 0x2472f0(%rip), %r12    # 0x326220
movq %r12, %rcx
callq 0xe2d2
cmpb $0x6, %bl
sbbl $-0x1, %r13d
incq %r14
jmp 0xded82
movl -0x34(%rbp), %ecx
addl -0x70(%rbp), %ecx
movq -0x40(%rbp), %rsi
leal 0x8(%rsi), %eax
movl -0x44(%rbp), %edi
movl %ecx, %edx
cmpl %edi, %ecx
cmovlel %esi, %eax
leaq 0x1238a7(%rip), %rcx    # 0x20280c
movl (%rcx), %ecx
addl $-0x8, %ecx
cmpl %ecx, %eax
movl -0x50(%rbp), %ebx
jge 0xdefa3
cmpl %edi, %edx
cmovgl -0x58(%rbp), %edx
movl %edx, -0x34(%rbp)
xorl %ecx, %ecx
movq -0x30(%rbp), %rdx
cmpl $0xc, %edx
leal 0x1(%rdx), %edx
setge %cl
pushq $0x1
popq %rsi
cmovgel %esi, %edx
addl %ecx, %r15d
incl %ebx
movl %edx, %ecx
movq %rcx, -0x30(%rbp)
movq %rax, -0x40(%rbp)
jmp 0xdec81
leaq 0x218576(%rip), %rbx    # 0x2f7520
movl (%rbx), %edi
callq 0xcd74f
movl (%rbx), %edi
leaq 0x2188e2(%rip), %rax    # 0x2f789c
movslq (%rax), %rax
leaq 0x7586c(%rip), %rcx     # 0x154830
movq (%rcx,%rax,8), %rsi
callq 0xce1f2
leaq 0x218574(%rip), %rax    # 0x2f7548
movsd (%rax), %xmm0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd57b4