Subversion Repositories Kolibri OS

Rev

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

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