Subversion Repositories Kolibri OS

Rev

Rev 3887 | Rev 3890 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ; Calendar for KolibriOS
  2. ;
  3. ; v1.3 - code update, redesign by Leency
  4. ; v1.1 - add change time support by DedOK
  5. ; v1.0 - written in pure assembler by Ivushkin Andrey aka Willow
  6. ; also - diamond, spraid, fedesco
  7. ;
  8. ; Created: November 1, 2004
  9.  
  10.  
  11. use32                ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à 
  12.  
  13.   org    0x0         ;  ¤à¥á æ¨ï á ­ã«ï
  14.  
  15.   db     'MENUET01'  ; 8-¡ ©â­ë© ¨¤¥­â¨ä¨ª â®à MenuetOS
  16.   dd     0x01        ; ¢¥àá¨ï § £®«®¢ª  (¢á¥£¤  1)
  17.   dd     start       ;  ¤à¥á ¬¥âª¨, á ª®â®à®© ­ ç¨­ ¥âáï ¢ë¯®«­¥­¨¥ ¯à®£à ¬¬
  18.   dd     I_END       ; à §¬¥à ¯à®£à ¬¬ë
  19.   dd     0x1000      ; ª®«¨ç¥á⢮ ¯ ¬ïâ¨
  20.   dd     0x1000      ;  ¤à¥á ¢¥à設ë áâíª 
  21.   dd     0x0         ;  ¤à¥á ¡ãä¥à  ¤«ï áâப¨ ¯ à ¬¥â஢ (­¥ ¨á¯®«ì§ã¥âáï)
  22.   dd     0x0         ; § à¥§¥à¢¨à®¢ ­®
  23. include 'lang.inc'
  24. include '..\..\..\macros.inc' ; 㬥­ìè ¥â à §¬¥à ¯à®£à ¬¬ë
  25. include 'data.inc'
  26.  
  27.  
  28.  
  29. macro ShowFocus field,reg
  30. {
  31.    local  .nofocus, .exit
  32.      cmp  [focus],field
  33.      jne  .nofocus
  34.    if reg eq
  35.      mov  ecx,0x10e7c750;0x10ddeeff
  36.    else
  37.      mov  reg,0x10e7c750;0x10ddeeff
  38.    end if
  39.      jmp  .exit
  40.    .nofocus:
  41.    if reg eq
  42.      mov  ecx,COL_DROPDOWN_T
  43.    else
  44.      mov  reg,COL_DROPDOWN_T
  45.    end if
  46.    .exit:
  47. }
  48.  
  49. macro GetSkinHeight
  50. {
  51.         mov  eax,48
  52.         mov  ebx,4
  53.         int 0x40
  54. }
  55.  
  56.  
  57. str2int:
  58.     xor  eax,eax
  59.     lodsb
  60.     mov  ebx,eax
  61.     shr  ebx,4
  62.     and  eax,0xf
  63.     imul ebx,10
  64.     add  al,bl
  65.     ret
  66.  
  67. start:
  68.     mcall 29
  69.     mov  [datestr],eax
  70.     mov  esi,datestr
  71.     call str2int
  72.     add  eax,1900
  73.     mov  [Year],eax
  74.     call str2int
  75.     dec  eax
  76.     mov  [Month],eax
  77.     call str2int
  78.     mov  [day_sel],eax
  79.     test byte[esi],0
  80.     jnz  .no2000
  81.     add  [Year],100
  82.   .no2000:
  83.     jmp  upd            ; §¤¥áì ­ ç¨­ ¥âáï ¢ë¯®«­¥­¨¥ ¯à®£à ¬¬ë
  84. red:                    ; ¯¥à¥à¨á®¢ âì ®ª­®
  85.  
  86.     call draw_window
  87.  
  88. still:                  ; ƒ‹€‚›‰ –ˆŠ‹ Žƒ€ŒŒ›
  89.  
  90.     mcall 23,50     ; wait here for event
  91.   .evt:
  92.     mov  ebp,[focus]
  93.     cmp  eax,1          ; ¯¥à¥à¨á®¢ âì ®ª­® ?
  94.     je   red            ; ¥á«¨ ¤  - ­  ¬¥âªã red
  95.     cmp  eax,2          ; ­ ¦ â  ª« ¢¨è  ?
  96.     je   key            ; ¥á«¨ ¤  - ­  key
  97.     cmp  eax,3          ; ­ ¦ â  ª­®¯ª  ?
  98.     je   button         ; ¥á«¨ ¤  - ­  button
  99.  
  100.     call draw_clock
  101.  
  102.     jmp  still          ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
  103.  
  104.   key:
  105.     mcall 2             ; get pressed key
  106.     cmp  ah,9
  107.     jne  no_tab
  108.   .tab:
  109.     cmp  ebp,FOCUSABLE
  110.     je   foc_cycle
  111.     inc  [focus]
  112.   upd:
  113.     call calculate
  114.     jmp  red
  115.   foc_cycle:
  116.     mov  [focus],2
  117.     jmp  upd
  118.   no_tab:
  119.     push eax
  120.     shr  eax,8
  121.     mov  ecx,12
  122.     mov  edi,Fkeys
  123.     repne scasb
  124.     pop  eax
  125.     jnz  .noFkey
  126.     sub  edi,Fkeys+1
  127.     mov  [Month],edi
  128.     jmp  upd
  129.   .noFkey:
  130.     cmp  ebp,4
  131.     jne  no_spinner
  132.     cmp  ah,176
  133.     je   year_dec
  134.     cmp  ah,179
  135.     je   year_inc
  136.   no_spinner:
  137.     cmp  ebp,2
  138.     jne  .nomonth
  139.     cmp  ah,177
  140.     je   noclose.drop
  141.     jmp  still
  142.   .nomonth:
  143.     cmp  ebp,3
  144.     je   noy_up.year_evt
  145.     cmp  ebp,5
  146.     jne  still
  147.     mov  ebx,[day_sel]
  148.     cmp  ah,176         ; left arrow
  149.     jb   still
  150.     cmp  ah,179
  151.     ja   still
  152.     shr  eax,8
  153.     sub  eax,176
  154.     movsx ecx,byte[day_bounds+eax*2]
  155.     movzx eax,byte[day_bounds+eax*2+1]
  156.     add  ecx,ebx
  157.     test eax,eax
  158.     jz   .chk0
  159.     cmp  ecx,eax
  160.     ja   still
  161.   .ok:
  162.     mov  [day_sel],ecx
  163.     call draw_days
  164.     jmp  still          ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
  165.   .chk0:
  166.     cmp  ecx,eax
  167.     jle  still
  168.     jmp  .ok
  169.  
  170. day_bounds db -1,0,7,0,-7,0,1,0 ; left,down,up,right
  171.  
  172.   button:
  173.     mcall 17    ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
  174.     movzx ebx,ah
  175.     cmp  ah,200
  176.     jbe  nodayselect
  177.     sub  ah,200
  178.     mov  byte[day_sel],ah
  179.     cmp  ebp,5
  180.     jne  .redraw
  181.     call draw_days
  182.     jmp  still
  183.   .redraw:
  184.     mov  [focus],5
  185.     jmp  red
  186.   nodayselect:
  187.     cmp  ah,100
  188.     jb   no_list
  189.     sub  ah,100
  190.     mov  byte[Month],ah
  191.     mov  [focus],2
  192.     jmp  upd
  193.   no_list:
  194.     cmp  ah,1           ; ¨¤¥­â¨ä¨ª â®à == 1 ?
  195.     jne  noclose        ; ¥á«¨ ­¥â - ¨¤¨ ¢¯¥àñ¤ ­  noclose
  196.   close:
  197.     or   eax,-1         ; ¢ë室 ¨§ ¯à®£à ¬¬ë
  198.     mcall               ; ¢ë§®¢ á¨á⥬ë
  199.  
  200.   noclose:
  201.  
  202.     cmp  ah,72
  203.     je   plus_he
  204.  
  205.     cmp  ah,73
  206.     je   plus_hd
  207.  
  208.     cmp  ah,74
  209.     je   minus_he
  210.  
  211.     cmp  ah,75
  212.     je   minus_hd
  213.  
  214.     cmp  ah,76
  215.     je   plus_me
  216.  
  217.     cmp  ah,77
  218.     je   plus_md
  219.  
  220.     cmp  ah,78
  221.     je   minus_me
  222.  
  223.     cmp  ah,79
  224.     je   minus_md
  225.  
  226.     cmp  ah,80
  227.     je   reset
  228.  
  229.     cmp  ah,81
  230.     je   set_date
  231.  
  232.     cmp  ah,2           ; drop down list
  233.     jne  no_dropdn
  234.   .drop:
  235.     mov  [focus],2
  236.     cmp  [dropped],al   ; ==0
  237.     jne  red
  238.     call draw_window
  239.     mov  edx,1 shl 31+231
  240.     mov  ecx,31
  241.     mov  eax,8
  242.   .bremove:
  243.     mcall
  244.     dec  edx
  245.     loop .bremove
  246.     call draw_dropdown
  247.     jmp  still
  248.   no_dropdn:
  249.     cmp  ah,3           ; year -1
  250.     jne  noy_dn
  251.   year_dec:
  252.     dec  [Year]
  253.     mov  [focus],4
  254.     jmp  upd
  255.   noy_dn:
  256.     cmp  ah,4           ; year+1
  257.     jne  noy_up
  258.   year_inc:
  259.     inc  [Year]
  260.     mov  [focus],4
  261.     jmp  upd
  262.   noy_up:
  263.     cmp  ah,5
  264.     jne  noy_click
  265.     mov  [focus],3
  266.     call draw_window
  267.   .still:
  268.     mcall 10
  269.     cmp  eax,2
  270.     jne  still.evt
  271.     mcall 2
  272.   .year_evt:
  273.     mov  ebx,10
  274.     cmp  ah,9
  275.     je   key.tab
  276.     cmp  ah,8           ; backspace
  277.     jne  .nobsp
  278.     mov  eax,[Year]
  279.     xor  edx,edx
  280.     div  ebx
  281.   .ch_year:
  282.     mov  [Year],eax
  283.     call draw_year
  284.     jmp  .still
  285.   .nobsp:
  286.     cmp  ah,13          ; enter
  287.     je   upd
  288.     cmp  ah,182
  289.     jne  .noclear       ; del
  290.     xor  eax,eax
  291.     jmp  .ch_year
  292.   .noclear:
  293.     cmp  ah,48
  294.     jb   .still
  295.     cmp  ah,57
  296.     ja   .still
  297.     cmp  [Year],1000
  298.     jae  .still
  299.     shr  eax,8
  300.     lea  ecx,[eax-48]
  301.     mov  eax,[Year]
  302.     imul eax,ebx
  303.     add  eax,ecx
  304.     jmp  .ch_year
  305.   noy_click:
  306.     cmp  ah,10
  307.     jne  start
  308.     xor  [new_style],1
  309.     jmp  upd
  310.  
  311.  
  312. reset:
  313.  
  314.     mov  eax,3
  315.     mcall
  316.     mov  ecx,eax
  317.     shl  ecx,16
  318.     shr  ecx,16
  319.     mov  eax,22
  320.     mov  ebx,0x00000000
  321.     mcall
  322.  
  323.     jmp  still
  324.  
  325. plus_hd:
  326.     mcall 3
  327.     mov  ecx,eax
  328.     add  ecx,1
  329.     mov  eax,22
  330.     mcall 22,0x00000000
  331.     jmp  still
  332.  
  333. plus_he:
  334.     mcall 3
  335.     mov  ecx,eax
  336.     add  ecx,16
  337.     mcall 22,0x00000000
  338.     jmp  still
  339.  
  340. minus_hd:
  341.     mcall 3
  342.     mov  ecx,eax
  343.     sub  ecx,1
  344.     mov  eax,22
  345.     mov  ebx,0x00000000
  346.     mcall
  347.  
  348.     jmp  still
  349.  
  350. minus_he:
  351.  
  352.     mov  eax,3
  353.     mcall
  354.     mov  ecx,eax
  355.     sub  ecx,16
  356.     mov  eax,22
  357.     mov  ebx,0x00000000
  358.     mcall
  359.  
  360.     jmp  still
  361.  
  362. plus_md:
  363.  
  364.     mov  eax,3
  365.     mcall
  366.     mov  ecx,eax
  367.     add  ecx,256
  368.     mov  eax,22
  369.     mov  ebx,0x00000000
  370.     mcall
  371.  
  372.     jmp  still
  373.  
  374. plus_me:
  375.  
  376.     mcall 3
  377.     mov  ecx,eax
  378.     add  ecx,4096
  379.     mcall 22,0x00000000
  380.     jmp  still
  381.  
  382. minus_md:
  383.  
  384.     mcall 3
  385.     mov  ecx,eax
  386.     sub  ecx,256
  387.     mcall 22,0x00000000
  388.     jmp  still
  389.  
  390. minus_me:
  391.  
  392.     mcall 3
  393.     mov  ecx,eax
  394.     sub  ecx,4096
  395.     mcall 22,0x00000000
  396.     jmp  still
  397.  
  398. set_date:
  399.  
  400.     mov  eax,0x00000000
  401.     mov ebx,[day_sel]
  402.     call additem
  403.     shl  eax,8
  404.     mov  ebx,[Month]
  405.     add  ebx,1
  406.     call additem
  407.     shl  eax,8
  408.     mov  ebx,[Year]
  409.     call additem
  410.     mov  ecx,eax
  411.     mov  eax,22
  412.     mov  ebx,1
  413.     mcall
  414.  
  415.     jmp  still
  416.  
  417. additem:
  418.  
  419.     add  eax,1
  420.     daa
  421.     sub  ebx,1
  422.     cmp  ebx,0
  423.     jne  additem
  424.  
  425.     ret
  426.  
  427.  
  428. ;   *********************************************
  429. ;   *******  Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ *******
  430. ;   *********************************************
  431.  
  432. draw_clock:
  433.  
  434.     mcall 3
  435.     mov  ecx,eax
  436.     mcall 47,0x00020100, ,205*65536+280,0x50000000,COL_WINDOW_BG
  437.  
  438.     shr  ecx,8
  439.     add  edx,20*65536
  440.     mcall
  441.  
  442.     shr  ecx,8
  443.     add  edx,20*65536
  444.     mcall
  445.     ret
  446.  
  447. draw_window:
  448.  
  449.     mcall 12,1
  450.     mcall 0,WIN_X,WIN_Y-15,COL_WINDOW_BG, ,title ; define window
  451.         GetSkinHeight
  452.         mov ecx, eax
  453.         shl ecx, 16
  454.         add ecx, 43
  455.         mcall 13,B_WBAR_X, ,COL_TOOLBAR_BG ; draw toolbar background
  456.     call draw_week
  457.  
  458.     mcall 8,205*65536+7,290*65536+10,72,COL_TIME_BUTTONS
  459.  
  460.     mov  ebx,212*65536+7
  461.     inc  edx
  462.     mcall
  463.  
  464.     mov  ebx,205*65536+7
  465.     mov  ecx,300*65536+10
  466.     inc  edx
  467.     mcall
  468.  
  469.     mov  ebx,212*65536+7
  470.     inc  edx
  471.     mcall
  472.  
  473.     mov  ebx,225*65536+7
  474.     mov  ecx,290*65536+10
  475.     inc  edx
  476.     mcall
  477.  
  478.     mov  ebx,232*65536+7
  479.     inc  edx
  480.     mcall
  481.  
  482.     mov  ebx,225*65536+7
  483.     mov  ecx,300*65536+10
  484.     inc  edx
  485.     mcall
  486.  
  487.     mov  ebx,232*65536+7
  488.     inc  edx
  489.     mcall
  490.  
  491.     mov  ebx,244*65536+14
  492.     mov  ecx,290*65536+20
  493.     inc  edx
  494.     mcall
  495.  
  496.     mov  ebx,14*65536+110
  497.     mov  ecx,285*65536+22
  498.     mov  esi,COL_DATE_BUTTONS
  499.     inc  edx
  500.     mcall
  501.  
  502.     mov  esi,COL_MONTH_YEAR_B   ; new style
  503.     mov  edx,10
  504.     or   edx,1 shl 29+1 shl 30
  505.     mov  ebx,B_NS_X
  506.     mov  ecx,B_NS_Y
  507.     mcall
  508.     add  edx,1-1 shl 29
  509.     mov  ebx,B_TODAY_X+8*(today_end-today_msg)
  510.     mov  ecx,B_TODAY_Y
  511.     mcall
  512.     mov  ecx,B_Y
  513.     mov  ebx,B_MONTH_X
  514.     mov  edx,2
  515.     mcall
  516.     mov  ebx,B_SPIN_X ; <
  517.     inc  edx
  518.     mcall
  519.     add  ebx,61 shl 16 ; >
  520.     inc  edx
  521.     mcall
  522.     call draw_days
  523.  
  524.         ; äã­ªæ¨ï 4 : ­ ¯¨á âì ¢ ®ª­¥ ⥪áâ
  525.     mcall 4,162*65536+280,0x800000ff,sys_text
  526.     mcall  ,180*65536+302,0x800000ff,minus
  527.     mcall  ,180*65536+292,0x80ff0000,plus
  528.     mcall  , 24*65536+292,0x00000000,set_date_t,15 ;set date text
  529.  
  530.     mov  ecx,0x10ddeeff            ; èà¨äâ 1 ¨ 梥â ( 0xF0RRGGBB )
  531.  
  532.     mov  edx,n_style
  533.     mov  esi,ns_end-n_style
  534.     mov  ebx,B_NS
  535.     cmp  [new_style],1
  536.     je   .high
  537.     mov  ecx,0xa0a0a0
  538.     jmp  .int
  539.   .high:
  540.     mov  ecx,COL_NEW_STYLE_T
  541.   .int:
  542.     mcall
  543.  
  544.     mov  ecx,COL_GO_TODAY_T
  545.     mov  edx,today_msg
  546.     mov  ebx,B_TODAY
  547.     mov  esi,today_end-today_msg
  548.     mcall
  549.  
  550.     mov  ebx,B_SPIN
  551.     mov  edx,spinner
  552.     mov  esi,12
  553.     ShowFocus 4
  554.     mcall
  555.  
  556.     mov  edx,[Month]
  557.     movzx  esi,byte[month_name]
  558.     imul edx,esi
  559.     add  edx,month_name+1
  560.     mov  ebx,B_MONTH
  561.     ShowFocus 2
  562.     mcall
  563.  
  564.     call draw_year
  565.     mov  [dropped],0
  566.     mcall 12,2
  567.     ret
  568.  
  569. draw_year:
  570.     mcall 8,B_YEAR_X,B_Y,5,COL_MONTH_YEAR_B
  571.     ShowFocus 3,esi
  572.     mcall 47,0x40001,Year,B_YEAR
  573.     ret
  574.  
  575. draw_dropdown:
  576.     mov  [dropped],1
  577.     push [Month]
  578.     pop  [focus]
  579.     add  [focus],100
  580.     mov  ecx,12
  581.     mov  edx,100
  582.     push dword month_name+1
  583.     push dword B_DROP
  584.     push dword B_Y+16 shl 16
  585.   .ddd_loop:
  586.     mov  edi,edx
  587.     push ecx
  588.     mov  esi,COL_DROPDOWN_BG
  589.     mcall 8,B_MONTH_X,[esp+4]
  590.     shr  eax,1
  591.     mov  ebx,[esp+8]
  592.     xchg edx,[esp+12]
  593.     movzx esi,byte[month_name]
  594.     ShowFocus edi
  595.     mcall
  596.     add  edx,esi
  597.     xchg edx,[esp+12]
  598.     add  dword[esp+8],16
  599.     add  dword[esp+4],16 shl 16
  600.     inc  edx
  601.     pop  ecx
  602.     loop .ddd_loop
  603.     add  esp,12
  604.     ret
  605.  
  606. draw_week:
  607.     mov  eax,13
  608.     mov  ebx,B_WBAR_X
  609.     mov  ecx,B_WBAR_Y
  610.     mov  edx,COL_WEEKDAY_BG
  611.     mcall
  612.     movzx esi,byte[week_days]
  613.     movzx edi,byte[week_days+1]
  614.     mov  ebx,B_WEEK
  615.     mov  ecx,7
  616.     mov  edx,week_days+2
  617.     mov  eax,4
  618.   .week:
  619.     push ecx
  620.     cmp  ecx,edi
  621.     je   .holiday
  622.     mov  ecx,0x10000000
  623.     jmp  .noholiday
  624.   .holiday:
  625.     mov  ecx,0x10cc1010
  626.   .noholiday:
  627.     mcall
  628.     add  edx,esi
  629.     add  ebx,B_WX_SHIFT
  630.     pop  ecx
  631.     loop .week
  632.     ret
  633.  
  634. draw_days:
  635.     call count_days
  636.     cmp  ecx,[day_sel]
  637.     jae  .ok
  638.     mov  [day_sel],ecx
  639.   .ok:
  640.     mov  [number],0
  641.     mov  eax,47
  642.     mov  edx,B_DAYS_Y
  643.     mov  ebx,0x10001
  644.     mov  edi,[firstday]
  645.   .dayloop:
  646.     push ecx
  647.     movzx edx,dx
  648.     mov  esi,edi
  649.     shl  esi,21
  650.     lea  edx,[edx+esi+34 shl 16]
  651.     mov  ecx,edi
  652.     add  cl,[week_days+1]
  653.     cmp  ecx,7
  654.     je   .holiday
  655.     mov  esi,0x10000000 ; COL_DATE_TEXT
  656.     jmp  .noholiday
  657.   .holiday:
  658.     mov  esi,0x10cc1010
  659.   .noholiday:
  660.     mov  ecx,number
  661.     inc  dword[ecx]
  662.     pusha
  663.     mov  ebx,edx
  664.     mov  bx,31           ; width
  665.     sub  ebx,8 shl 16
  666.     shrd ecx,edx,16
  667.     mov  cx,29           ; height
  668.     sub  ecx,12 shl 16
  669.     mov  edx,[number]
  670.     cmp  edx,[day_sel]
  671.     je   .draw_sel
  672.     mov  esi,COL_DATE_BUTTONS
  673.     jmp  .draw_but
  674.   .draw_sel:
  675.     mov  esi,COL_DATE_CURRENT
  676.     cmp  [focus],5
  677.     jne  .draw_but
  678.     mov  esi,COL_DATE_CHANGED
  679.   .draw_but:
  680.     add  edx,200+1 shl 29
  681.     mcall 8
  682.         mov    eax, [number]
  683.     xor    edx, edx
  684.     mov    ecx, 10
  685.     div    ecx
  686.     mov    [remainder], edx
  687.     mov    [quotient],  eax
  688.         popa
  689.        
  690.         ;first number
  691.         mov ecx,quotient
  692.     mcall
  693.         add edx,1 shl 16
  694.         mcall
  695.         sub edx,1 shl 16
  696.        
  697.         ;second number
  698.         mov ecx,remainder
  699.         add edx,9 shl 16
  700.     mcall
  701.         add edx,1 shl 16
  702.         mcall
  703.         sub edx,10 shl 16
  704.        
  705.        
  706.     pop  ecx
  707.     inc  edi
  708.     cmp  edi,7
  709.     jne  .nowrap
  710.     xor  edi,edi
  711.     add  dx,B_DAYS_SHIFT
  712.   .nowrap:
  713.     loop .eloop
  714.     jmp  .ex
  715.   .eloop:
  716.     jmp  .dayloop
  717.   .ex:
  718.     ret
  719.  
  720. count_days:    ; ecx -days in month
  721.     call is_leap_year
  722.     mov  ecx,[Month]
  723.     mov  eax,1
  724.     movzx ecx,byte[day_count+ecx]
  725.     add  ecx,28
  726.     cmp  eax,[leap_year]
  727.     jne  .noleap
  728.     cmp  eax,[Month]
  729.     jne  .noleap
  730.     inc  ecx
  731.   .noleap:
  732.     mov  [day_bounds+3],cl
  733.     mov  [day_bounds+7],cl
  734.     ret
  735.  
  736. is_leap_year:
  737.     mov  [leap_year],0
  738.     mov  eax,[Year]
  739.     mov  bl,100
  740.     div  bl          ; ah=Year mod 100, al=Year%100
  741.     test ah,ah
  742.     jz  .century
  743.     shr  ax,8        ; ax - last 2 digits
  744.   .century:
  745.     test al,11b
  746.     jnz  .noleap
  747.     inc  [leap_year]
  748.   .noleap:
  749.     ret
  750.  
  751. calculate:
  752.     mov  ebx,[Year]
  753.     mov  eax,[Month]
  754.     sub  eax,2
  755.     jge  .nojf
  756.     dec  ebx
  757.     add  eax,12
  758.   .nojf:
  759.     add  eax,4
  760.     xor  edx,edx
  761.     mov  ecx,153
  762.     imul cx
  763.     mov  ecx,5
  764.     div  cx
  765.     inc  eax
  766.     mov  ecx,365
  767.     imul ecx,ebx
  768.     add  eax,ecx
  769.     mov  ecx,ebx
  770.     shr  ecx,2
  771.     add  eax,ecx
  772.     dec  eax
  773.     cmp  [new_style],0
  774.     je   .nonew
  775.     add  eax,2
  776.     xchg eax,ebx
  777.     mov  ecx,100
  778.     xor  edx,edx
  779.     div  cx
  780.     sub  ebx,eax
  781.     shr  eax,2
  782.     add  ebx,eax
  783.   .nonew:
  784.     add  ebx,5
  785.     mov  eax,ebx
  786.     xor  edx,edx
  787.     movzx ebx,byte[week_days+1]
  788.     sub  eax,ebx
  789.     inc  eax
  790.     mov  ebx,7
  791.     div  bx
  792.     mov  [firstday],edx
  793.     ret
  794.  
  795. I_END:
  796.  
  797. firstday  dd ?
  798. Year dd   ?
  799. Month dd  ?
  800. day_sel   dd ?
  801. all_days  dd ?
  802.  
  803. datestr   dd  ?
  804. leap_year dd ?
  805. number    dd ?
  806. year_input dd ?
  807.