// File: 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
subq $0x70, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl $0x1e, -0x2c(%rbp)
movl $0x2, -0x30(%rbp)
movl $0x4, -0x24(%rbp)
leaq 0x48059(%rip), %rax     # 0x197b33
movq %rax, -0x48(%rbp)
leaq 0x127efb(%rip), %rax    # 0x2779e0
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
leaq 0x132c33(%rip), %rax    # 0x282724
imull $0x31a, (%rax), %eax    # imm = 0x31A
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jl 0x14fb17
leaq 0x127ed5(%rip), %rax    # 0x2779e4
cmpl $0x258, (%rax)          # imm = 0x258
jge 0x14fb37
movl $0x18, -0x2c(%rbp)
movl $0x2, -0x30(%rbp)
movl $0x3, -0x24(%rbp)
leaq 0x4801c(%rip), %rax     # 0x197b4f
movq %rax, -0x48(%rbp)
leaq 0x127eaa(%rip), %rax    # 0x2779e8
movl (%rax), %eax
imull $0x3, -0x2c(%rbp), %ecx
movl -0x24(%rbp), %edx
shll %edx
addl %edx, %ecx
subl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x30(%rbp)
cmpl $0x1, -0x8(%rbp)
jge 0x14fb65
movl $0x1, -0x8(%rbp)
cmpl $0xc, -0x8(%rbp)
jle 0x14fb72
movl $0xc, -0x8(%rbp)
callq 0x117e0
movl -0x30(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
leaq 0x127e59(%rip), %rax    # 0x2779e4
cmpl $0x258, (%rax)          # imm = 0x258
jge 0x14fb9c
movl $0x1, -0x34(%rbp)
jmp 0x14fba3
movl $0x4, -0x34(%rbp)
movl -0x8(%rbp), %eax
subl -0x34(%rbp), %eax
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jg 0x14fbc4
movl -0x4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4(%rbp)
movl -0x8(%rbp), %eax
addl $0xc, %eax
movl %eax, -0x8(%rbp)
movl $0x1, -0x28(%rbp)
cmpl $0x30, -0x28(%rbp)
jg 0x150026
movl -0x4(%rbp), %edi
callq 0x132930
movl -0x4(%rbp), %edi
leaq 0x21ce95(%rip), %rax    # 0x36ca7c
movslq (%rax), %rcx
leaq 0x79c3f(%rip), %rax     # 0x1c9830
movq (%rax,%rcx,8), %rsi
callq 0x1339f0
movl $0x0, -0x14(%rbp)
movl -0x8(%rbp), %esi
movl -0x4(%rbp), %edx
movl $0x1, %edi
callq 0x132a50
movzbl %al, %eax
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x4(%rbp)
jge 0x14fc48
movslq -0x8(%rbp), %rcx
leaq 0x79b88(%rip), %rax     # 0x1c97b0
movq (%rax,%rcx,8), %rdx
xorl %ecx, %ecx
subl -0x4(%rbp), %ecx
leaq 0x24b7c8(%rip), %rdi    # 0x39b400
leaq 0x47f25(%rip), %rsi     # 0x197b64
movb $0x0, %al
callq 0x9060
jmp 0x14fc6f
movslq -0x8(%rbp), %rcx
leaq 0x79b5d(%rip), %rax     # 0x1c97b0
movq (%rax,%rcx,8), %rdx
movl -0x4(%rbp), %ecx
leaq 0x24b79f(%rip), %rdi    # 0x39b400
leaq 0x40bf8(%rip), %rsi     # 0x190860
movb $0x0, %al
callq 0x9060
movl -0x2c(%rbp), %eax
subl $0x3, %eax
cltq
movq %rax, -0x58(%rbp)
leaq 0x24b77e(%rip), %rdi    # 0x39b400
callq 0x9120
movq %rax, %rcx
movq -0x58(%rbp), %rax
subq %rcx, %rax
shrq %rax
movl %eax, -0x24(%rbp)
movl $0xf, -0x20(%rbp)
movl -0x8(%rbp), %eax
leaq 0x21ca48(%rip), %rcx    # 0x36c6f0
cmpl (%rcx), %eax
jne 0x14fcc3
movl -0x4(%rbp), %eax
leaq 0x21ca3e(%rip), %rcx    # 0x36c6f4
cmpl (%rcx), %eax
jne 0x14fcc3
movl $0xa, -0x20(%rbp)
jmp 0x14fcd4
movl -0x28(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x14fcd2
movl $0x7, -0x20(%rbp)
jmp 0x14fcd4
movl -0x1c(%rbp), %edi
addl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
addl -0x24(%rbp), %esi
movl -0x20(%rbp), %eax
leaq 0x24b716(%rip), %rcx    # 0x39b400
movzbl %al, %edx
callq 0x10ee0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x1c(%rbp), %edi
addl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x20(%rbp), %eax
movq -0x48(%rbp), %rcx
movzbl %al, %edx
callq 0x10ee0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x122140
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movl $0x3, %edi
callq 0x13f470
movl $0x1, -0xc(%rbp)
movl -0xc(%rbp), %eax
movslq -0x8(%rbp), %rdx
leaq 0x799ab(%rip), %rcx     # 0x1c9700
cmpl (%rcx,%rdx,4), %eax
jg 0x14ffbb
movl -0xc(%rbp), %edi
movl -0x8(%rbp), %esi
movl -0x4(%rbp), %edx
callq 0x132a50
movzbl %al, %eax
movl %eax, -0x10(%rbp)
leaq 0x127c67(%rip), %rax    # 0x2779e0
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
leaq 0x13299f(%rip), %rax    # 0x282724
imull $0x31a, (%rax), %eax    # imm = 0x31A
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x5c(%rbp), %eax
cmpl %ecx, %eax
jl 0x14fdab
leaq 0x127c41(%rip), %rax    # 0x2779e4
cmpl $0x258, (%rax)          # imm = 0x258
jge 0x14fdc5
movl -0xc(%rbp), %edx
leaq 0x24b64b(%rip), %rdi    # 0x39b400
leaq 0x3adff(%rip), %rsi     # 0x18abbb
movb $0x0, %al
callq 0x9060
jmp 0x14fddd
movl -0xc(%rbp), %edx
leaq 0x24b631(%rip), %rdi    # 0x39b400
leaq 0x3bd5a(%rip), %rsi     # 0x18bb30
movb $0x0, %al
callq 0x9060
movslq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movslq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq 0x24b60c(%rip), %rdi    # 0x39b400
callq 0x9120
movq -0x70(%rbp), %rcx
movq %rax, %rdx
movq -0x68(%rbp), %rax
imulq %rdx, %rcx
addq %rcx, %rax
movl %eax, -0x24(%rbp)
movl -0x8(%rbp), %eax
cmpl 0x289e55(%rip), %eax    # 0x3d9c6c
jne 0x14fe30
movl -0xc(%rbp), %eax
cmpl 0x289e46(%rip), %eax    # 0x3d9c68
jne 0x14fe30
movl $0x9, -0x20(%rbp)
jmp 0x14ff3f
movl -0x8(%rbp), %eax
cmpl 0x289e3b(%rip), %eax    # 0x3d9c74
jne 0x14fe52
movl -0xc(%rbp), %eax
cmpl 0x289e2c(%rip), %eax    # 0x3d9c70
jne 0x14fe52
movl $0x9, -0x20(%rbp)
jmp 0x14ff3d
movslq -0xc(%rbp), %rcx
leaq 0x80343(%rip), %rax     # 0x1d01a0
movq (%rax,%rcx,8), %rax
cmpb $0x0, (%rax)
je 0x14fedc
movslq -0xc(%rbp), %rcx
leaq 0x8032f(%rip), %rax     # 0x1d01a0
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x51, %eax
je 0x14fedc
movslq -0xc(%rbp), %rcx
leaq 0x80318(%rip), %rax     # 0x1d01a0
movq (%rax,%rcx,8), %rdi
leaq 0x47cda(%rip), %rsi     # 0x197b6d
callq 0x9090
cmpq $0x0, %rax
je 0x14fea7
movl $0xe, -0x20(%rbp)
jmp 0x14feda
movslq -0xc(%rbp), %rcx
leaq 0x802ee(%rip), %rax     # 0x1d01a0
movq (%rax,%rcx,8), %rdi
leaq 0x47cb5(%rip), %rsi     # 0x197b72
callq 0x9090
cmpq $0x0, %rax
je 0x14fed1
movl $0xe, -0x20(%rbp)
jmp 0x14fed8
movl $0x6, -0x20(%rbp)
jmp 0x14feda
jmp 0x14ff3b
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl -0xc(%rbp), %edx
callq 0x148890
cmpl $0x0, %eax
je 0x14fef8
movl $0xb, -0x20(%rbp)
jmp 0x14ff39
movl -0x8(%rbp), %eax
leaq 0x21c7ee(%rip), %rcx    # 0x36c6f0
cmpl (%rcx), %eax
jne 0x14ff1d
movl -0x4(%rbp), %eax
leaq 0x21c7e4(%rip), %rcx    # 0x36c6f4
cmpl (%rcx), %eax
jne 0x14ff1d
movl $0xa, -0x20(%rbp)
jmp 0x14ff37
movl -0x28(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x14ff2e
movl $0x7, -0x20(%rbp)
jmp 0x14ff35
movl $0xf, -0x20(%rbp)
jmp 0x14ff37
jmp 0x14ff39
jmp 0x14ff3b
jmp 0x14ff3d
jmp 0x14ff3f
leaq 0x21c7ae(%rip), %rax    # 0x36c6f4
movl (%rax), %eax
cmpl -0x4(%rbp), %eax
jne 0x14ff81
leaq 0x21c79c(%rip), %rax    # 0x36c6f0
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jne 0x14ff81
leaq 0x21c78a(%rip), %rax    # 0x36c6ec
movl (%rax), %eax
cmpl -0xc(%rbp), %eax
jne 0x14ff81
leaq 0x21c770(%rip), %rax    # 0x36c6e0
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x14ff81
movl $0x0, -0x20(%rbp)
movl -0x1c(%rbp), %edi
addl -0x14(%rbp), %edi
movl -0x24(%rbp), %esi
movl -0x20(%rbp), %eax
leaq 0x24b46c(%rip), %rcx    # 0x39b400
movzbl %al, %edx
callq 0x10ee0
cmpl $0x6, -0x10(%rbp)
jl 0x14ffab
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x14ffad
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x14fd47
movl -0x2c(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl -0x2c(%rbp), %ecx
shll %ecx
addl -0x30(%rbp), %ecx
cmpl %ecx, %eax
jle 0x14ffe2
movl -0x30(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
leaq 0x127a00(%rip), %rcx    # 0x2779ec
movl (%rcx), %ecx
subl $0x8, %ecx
cmpl %ecx, %eax
jl 0x14fff7
jmp 0x150026
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
cmpl $0xc, -0x8(%rbp)
jle 0x150016
movl $0x1, -0x8(%rbp)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x150018
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x14fbcb
leaq 0x21c6d3(%rip), %rax    # 0x36c700
movl (%rax), %edi
callq 0x132930
leaq 0x21c6c5(%rip), %rax    # 0x36c700
movl (%rax), %edi
leaq 0x21ca38(%rip), %rax    # 0x36ca7c
movslq (%rax), %rcx
leaq 0x797e2(%rip), %rax     # 0x1c9830
movq (%rax,%rcx,8), %rsi
callq 0x1339f0
leaq 0x21c6ca(%rip), %rax    # 0x36c728
movsd (%rax), %xmm0
movl $0x5, %edi
callq 0x13f470
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)