Subversion Repositories Kolibri OS

Rev

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

  1. ; CALENDAR FOR MENUET v1.0
  2. ; Written in pure assembler by Ivushkin Andrey aka Willow
  3. ;
  4. ;
  5. ; Created:      November 1, 2004
  6. ; Last changed: January 13, 2005
  7. ;
  8. ; COMPILE WITH FASM
  9.  
  10. WIN_X equ (150 shl 16+270)
  11. WIN_Y equ (100 shl 16+335)
  12.  
  13. LINE1     equ 27 shl 16+16
  14. B_MONTH_X equ 10 shl 16+158
  15. B_Y       equ LINE1
  16. B_MONTH   equ 63 shl 16+32
  17.  
  18. B_WBAR_X  equ 10 shl 16+250
  19. B_WBAR_Y  equ 64 shl 16+20
  20. B_WEEK    equ 30 shl 16+70
  21. B_WX_SHIFT equ 32 shl 16
  22.  
  23. B_DBAR_X  equ B_WBAR_X
  24. B_DBAR_Y  equ 85 shl 16+190
  25.  
  26. B_DROP    equ B_MONTH+16
  27. B_DAYS_Y  equ 100
  28. B_DAYS_SHIFT equ 30
  29.  
  30. B_YEAR_X  equ 173 shl 16+58
  31. B_YEAR    equ 188 shl 16+32
  32.  
  33. B_TODAY_X equ 25 shl 16
  34. B_TODAY_Y equ 48 shl 16+10
  35. B_TODAY   equ 30 shl 16+50
  36.  
  37. B_SPIN_WIDTH equ 13
  38. B_SPIN_X  equ 234 shl 16+B_SPIN_WIDTH
  39. B_SPIN    equ 238 shl 16+32
  40.  
  41. B_DATE_X  equ 26 shl 16+60
  42. B_DATE_Y  equ 275 shl 16+16
  43. B_DATE_BSHIFT equ 80 shl 16
  44. B_DATE    equ 32 shl 16+280
  45. B_DATE_SHIFT equ 80 shl 16
  46.  
  47. B_NS_X    equ 185 shl 16+75
  48. B_NS_Y    equ 48 shl 16+10
  49. B_NS      equ 190 shl 16+50
  50.  
  51. FOCUSABLE equ 5
  52. SKIP      equ 1
  53.  
  54. use32                ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à 
  55.  
  56.   org    0x0         ;  ¤à¥á æ¨ï á ­ã«ï
  57.  
  58.   db     'MENUET01'  ; 8-¡ ©â­ë© ¨¤¥­â¨ä¨ª â®à MenuetOS
  59.   dd     0x01        ; ¢¥àá¨ï § £®«®¢ª  (¢á¥£¤  1)
  60.   dd     start       ;  ¤à¥á ¬¥âª¨, á ª®â®à®© ­ ç¨­ ¥âáï ¢ë¯®«­¥­¨¥ ¯à®£à ¬¬
  61.   dd     I_END       ; à §¬¥à ¯à®£à ¬¬ë
  62.   dd     0x1000      ; ª®«¨ç¥á⢮ ¯ ¬ïâ¨
  63.   dd     0x1000      ;  ¤à¥á ¢¥à設ë áâíª 
  64.   dd     0x0         ;  ¤à¥á ¡ãä¥à  ¤«ï áâப¨ ¯ à ¬¥â஢ (­¥ ¨á¯®«ì§ã¥âáï)
  65.   dd     0x0         ; § à¥§¥à¢¨à®¢ ­®
  66. include 'lang.inc'
  67. include 'macros.inc' ; 㬥­ìè ¥â à §¬¥à ¯à®£à ¬¬ë
  68. ;include 'debug.inc'
  69.  
  70.  
  71. macro  ShowFocus field,reg
  72. {
  73.    local  .nofocus, .exit
  74.      cmp  [focus],field
  75.      jne  .nofocus
  76.    if reg eq
  77.      mov  ecx,0x10e7c750;0x10ddeeff
  78.    else
  79.      mov  reg,0x10e7c750;0x10ddeeff
  80.    end if
  81.      jmp  .exit
  82.    .nofocus:
  83.    if reg eq
  84.      mov  ecx,0x10000000
  85.    else
  86.      mov  reg,0x10000000
  87.    end if
  88.    .exit:
  89. }
  90.  
  91. month_name:
  92. if lang eq ru
  93.      db   8
  94.      db   'Ÿ­¢ àì  '
  95.      db   '”¥¢à «ì '
  96.      db   'Œ àâ    '
  97.      db   '€¯à¥«ì  '
  98.      db   'Œ ©     '
  99.      db   'ˆî­ì    '
  100.      db   'ˆî«ì    '
  101.      db   '€¢£ãáâ  '
  102.      db   '‘¥­âï¡àì'
  103.      db   'Žªâï¡àì '
  104.      db   '®ï¡àì  '
  105.      db   '„¥ª ¡àì '
  106. else if lang eq de
  107.      db   9
  108.      db   'Januar   '
  109.      db   'Februar  '
  110.      db   'MÁrz     '
  111.      db   'April    '
  112.      db   'Mai      '
  113.      db   'Juni     '
  114.      db   'Juli     '
  115.      db   'August   '
  116.      db   'September'
  117.      db   'Oktober  '
  118.      db   'November '
  119.      db   'Dezember '
  120. else if lang eq fr
  121.      db   9
  122.      db   'Janvier  '
  123.      db   'Fevrier  '
  124.      db   'Mars     '
  125.      db   'Avril    '
  126.      db   'Mai      '
  127.      db   'Juin     '
  128.      db   'Juliet   '
  129.      db   'Aout     '
  130.      db   'Septembre'
  131.      db   'Octobre  '
  132.      db   'Novembre '
  133.      db   'Decembre '
  134. else if lang eq fi
  135.      db   9
  136.      db   'Tammikuu '
  137.      db   'Helmikuu '
  138.      db   'Maaliskuu'
  139.      db   'Huhtikuu '
  140.      db   'Toukokuu '
  141.      db   'KesÁkuu  '
  142.      db   'HeinÁkuu '
  143.      db   'Elokuu   '
  144.      db   'Syyskuu  '
  145.      db   'Lokakuu  '
  146.      db   'Marraskuu'
  147.      db   'Joulukuu '
  148. else if lang eq et
  149.      db   9
  150.      db   'Jaanuar  '
  151.      db   'Veebruar '
  152.      db   'Märts    '
  153.      db   'Aprill   '
  154.      db   'Mai      '
  155.      db   'Juuni    '
  156.      db   'Juuli    '
  157.      db   'August   '
  158.      db   'September'
  159.      db   'Oktoober '
  160.      db   'November '
  161.      db   'Detsember'
  162. else
  163.      db   9
  164.      db   'January  '
  165.      db   'February '
  166.      db   'March    '
  167.      db   'April    '
  168.      db   'May      '
  169.      db   'June     '
  170.      db   'July     '
  171.      db   'August   '
  172.      db   'September'
  173.      db   'October  '
  174.      db   'November '
  175.      db   'December '
  176. end if
  177. spinner db '< >'
  178. week_days:
  179. if lang eq ru
  180.      db   2
  181.      db   1
  182.      db   '­'
  183.      db   '‚â'
  184.      db   '‘à'
  185.      db   '—â'
  186.      db   'â'
  187.      db   '‘¡'
  188.      db   '‚á'
  189. else if lang eq de
  190.      db   2
  191.      db   7
  192.      db   'So'
  193.      db   'Mo'
  194.      db   'Di'
  195.      db   'Mi'
  196.      db   'Do'
  197.      db   'Fr'
  198.      db   'Sa'
  199. else if lang eq fr
  200.      db   3
  201.      db   7
  202.      db   'Dim'
  203.      db   'Lun'
  204.      db   'Mar'
  205.      db   'Mer'
  206.      db   'Jeu'
  207.      db   'Ven'
  208.      db   'Sam'
  209. else if lang eq fi
  210.      db   2
  211.      db   7
  212.      db   'Su'
  213.      db   'Ma'
  214.      db   'Ti'
  215.      db   'Ke'
  216.      db   'To'
  217.      db   'Pe'
  218.      db   'La'
  219. else if lang eq et
  220.      db   3
  221.      db   7
  222.      db   'Esm'
  223.      db   'Tei'
  224.      db   'Kol'
  225.      db   'Nel'
  226.      db   'Ree'
  227.      db   'Lau'
  228.      db   'Püh'
  229. else
  230.      db   3
  231.      db   7
  232.      db   'Sun'
  233.      db   'Mon'
  234.      db   'Tue'
  235.      db   'Wen'
  236.      db   'Thi'
  237.      db   'Fri'
  238.      db   'Sat'
  239. end if
  240.  
  241. str2int:
  242.     xor  eax,eax
  243.     lodsb
  244.     mov  ebx,eax
  245.     shr  ebx,4
  246.     and  eax,0xf
  247.     imul ebx,10
  248.     add  al,bl
  249.     ret
  250.  
  251. start:
  252.     mcall 29
  253.     mov  [datestr],eax
  254.     mov  esi,datestr
  255.     call str2int
  256.     add  eax,1900
  257.     mov  [Year],eax
  258.     call str2int
  259.     dec  eax
  260.     mov  [Month],eax
  261.     call str2int
  262.     mov  [day_sel],eax
  263.     test byte[esi],0
  264.     jnz  .no2000
  265.     add  [Year],100
  266.   .no2000:
  267.     jmp  upd            ; §¤¥áì ­ ç¨­ ¥âáï ¢ë¯®«­¥­¨¥ ¯à®£à ¬¬ë
  268. red:                    ; ¯¥à¥à¨á®¢ âì ®ª­®
  269.  
  270.     call draw_window    ; ¢ë§ë¢ ¥¬ ¯à®æ¥¤ãàã ®âà¨á®¢ª¨ ®ª­ 
  271.  
  272. still:                  ; ƒ‹€‚›‰ –ˆŠ‹ Žƒ€ŒŒ›
  273.  
  274.     mov  eax,23                 ; wait here for event
  275.     mov  ebx,50
  276.     mcall
  277.   .evt:
  278.     mov  ebp,[focus]
  279.     cmp  eax,1          ; ¯¥à¥à¨á®¢ âì ®ª­® ?
  280.     je   red            ; ¥á«¨ ¤  - ­  ¬¥âªã red
  281.     cmp  eax,2          ; ­ ¦ â  ª« ¢¨è  ?
  282.     je   key            ; ¥á«¨ ¤  - ­  key
  283.     cmp  eax,3          ; ­ ¦ â  ª­®¯ª  ?
  284.     je   button         ; ¥á«¨ ¤  - ­  button
  285.  
  286.     call draw_clock
  287.  
  288.     jmp  still          ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
  289.  
  290.   key:                  ; ­ ¦ â  ª« ¢¨è  ­  ª« ¢¨ âãà¥
  291.     mov  eax,2          ; äã­ªæ¨ï 2 - áç¨â âì ª®¤ ᨬ¢®« 
  292.     mcall               ; ¢ë§®¢ á¨á⥬ë
  293.     cmp  ah,9
  294.     jne  no_tab
  295.   .tab:
  296.     cmp  ebp,FOCUSABLE
  297.     je   foc_cycle
  298.     inc  [focus]
  299.   upd:
  300.     call calculate
  301.     jmp  red
  302.   foc_cycle:
  303.     mov  [focus],2
  304.     jmp  upd
  305.   no_tab:
  306.     push eax
  307.     shr  eax,8
  308.     mov  ecx,12
  309.     mov  edi,Fkeys
  310.     repne scasb
  311.     pop  eax
  312.     jnz  .noFkey
  313.     sub  edi,Fkeys+1
  314.     mov  [Month],edi
  315.     jmp  upd
  316.   .noFkey:
  317.     cmp  ebp,4
  318.     jne  no_spinner
  319.     cmp  ah,176
  320.     je   year_dec
  321.     cmp  ah,179
  322.     je   year_inc
  323.   no_spinner:
  324.     cmp  ebp,2
  325.     jne  .nomonth
  326.     cmp  ah,177
  327.     je   noclose.drop
  328.     jmp  still
  329.   .nomonth:
  330.     cmp  ebp,3
  331.     je   noy_up.year_evt
  332.     cmp  ebp,5
  333.     jne  still
  334.     mov  ebx,[day_sel]
  335.     cmp  ah,176         ; left arrow
  336.     jb   still
  337.     cmp  ah,179
  338.     ja   still
  339.     shr  eax,8
  340.     sub  eax,176
  341.     movsx ecx,byte[day_bounds+eax*2]
  342.     movzx eax,byte[day_bounds+eax*2+1]
  343.     add  ecx,ebx
  344.     test eax,eax
  345.     jz   .chk0
  346.     cmp  ecx,eax
  347.     ja   still
  348.   .ok:
  349.     mov  [day_sel],ecx
  350.     call draw_days
  351.     jmp  still          ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
  352.   .chk0:
  353.     cmp  ecx,eax
  354.     jle  still
  355.     jmp  .ok
  356.  
  357. day_bounds db -1,0,7,0,-7,0,1,0 ; left,down,up,right
  358.  
  359.   button:               ; ­ ¦ â  ª­®¯ª  ¢ ®ª­¥ ¯à®£à ¬¬ë
  360.     mov  eax,17         ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
  361.     mcall               ; ¢ë§®¢ á¨á⥬ë
  362.     movzx ebx,ah
  363.     cmp  ah,200
  364.     jbe  nodayselect
  365.     sub  ah,200
  366.     mov  byte[day_sel],ah
  367.     cmp  ebp,5
  368.     jne  .redraw
  369.     call draw_days
  370.     jmp  still
  371.   .redraw:
  372.     mov  [focus],5
  373.     jmp  red
  374.   nodayselect:
  375.     cmp  ah,100
  376.     jb   no_list
  377.     sub  ah,100
  378.     mov  byte[Month],ah
  379.     mov  [focus],2
  380.     jmp  upd
  381.   no_list:
  382.     cmp  ah,1           ; ¨¤¥­â¨ä¨ª â®à == 1 ?
  383.     jne  noclose        ; ¥á«¨ ­¥â - ¨¤¨ ¢¯¥àñ¤ ­  noclose
  384.   close:
  385.     or   eax,-1         ; ¢ë室 ¨§ ¯à®£à ¬¬ë
  386.     mcall               ; ¢ë§®¢ á¨á⥬ë
  387.  
  388.   noclose:
  389.  
  390.     cmp  ah,72
  391.     je   plus_he
  392.  
  393.     cmp  ah,73
  394.     je   plus_hd
  395.  
  396.     cmp  ah,74
  397.     je   minus_he
  398.  
  399.     cmp  ah,75
  400.     je   minus_hd
  401.  
  402.     cmp  ah,76
  403.     je   plus_me
  404.  
  405.     cmp  ah,77
  406.     je   plus_md
  407.  
  408.     cmp  ah,78
  409.     je   minus_me
  410.  
  411.     cmp  ah,79
  412.     je   minus_md
  413.  
  414.     cmp  ah,80
  415.     je   reset
  416.  
  417.     ;jmp  still
  418.  
  419.  
  420.  
  421.     cmp  ah,2           ; drop down list
  422.     jne  no_dropdn
  423.   .drop:
  424.     mov  [focus],2
  425.     cmp  [dropped],al   ; ==0
  426.     jne  red
  427.     call draw_window
  428.     mov  edx,1 shl 31+231
  429.     mov  ecx,31
  430.     mov  eax,8
  431.   .bremove:
  432.     mcall
  433.     dec  edx
  434.     loop .bremove
  435.     call draw_dropdown
  436.     jmp  still
  437.   no_dropdn:
  438.     cmp  ah,3           ; year -1
  439.     jne  noy_dn
  440.   year_dec:
  441.     dec  [Year]
  442.     mov  [focus],4
  443.     jmp  upd
  444.   noy_dn:
  445.     cmp  ah,4           ; year+1
  446.     jne  noy_up
  447.   year_inc:
  448.     inc  [Year]
  449.     mov  [focus],4
  450.     jmp  upd
  451.   noy_up:
  452.     cmp  ah,5
  453.     jne  noy_click
  454.     mov  [focus],3
  455.     call draw_window
  456.   .still:
  457.     mcall 10
  458.     cmp  eax,2
  459.     jne  still.evt
  460.     mcall 2
  461.   .year_evt:
  462.     mov  ebx,10
  463.     cmp  ah,9
  464.     je   key.tab
  465.     cmp  ah,8           ; backspace
  466.     jne  .nobsp
  467.     mov  eax,[Year]
  468.     xor  edx,edx
  469.     div  ebx
  470.   .ch_year:
  471.     mov  [Year],eax
  472.     call draw_year
  473.     jmp  .still
  474.   .nobsp:
  475.     cmp  ah,13          ; enter
  476.     je   upd
  477.     cmp  ah,182
  478.     jne  .noclear       ; del
  479.     xor  eax,eax
  480.     jmp  .ch_year
  481.   .noclear:
  482.     cmp  ah,48
  483.     jb   .still
  484.     cmp  ah,57
  485.     ja   .still
  486.     cmp  [Year],1000
  487.     jae  .still
  488.     shr  eax,8
  489.     lea  ecx,[eax-48]
  490.     mov  eax,[Year]
  491.     imul eax,ebx
  492.     add  eax,ecx
  493.     jmp  .ch_year
  494.   noy_click:
  495.     cmp  ah,10
  496.     jne  start
  497.     xor  [new_style],1
  498.     jmp  upd
  499.  
  500.  
  501. reset:
  502.  
  503.     mov  eax,3
  504.     mcall
  505.     mov  ecx,eax
  506.     shl  ecx,16
  507.     shr  ecx,16
  508.     mov  eax,22
  509.     mov  ebx,0x00000000
  510.     mcall
  511.  
  512.     jmp  still
  513.  
  514. plus_hd:
  515.  
  516.     mov  eax,3
  517.     mcall
  518.     mov  ecx,eax
  519.     add  ecx,1
  520.     mov  eax,22
  521.     mov  ebx,0x00000000
  522.     mcall
  523.  
  524.     jmp  still
  525.  
  526. plus_he:
  527.  
  528.     mov  eax,3
  529.     mcall
  530.     mov  ecx,eax
  531.     add  ecx,16
  532.     mov  eax,22
  533.     mov  ebx,0x00000000
  534.     mcall
  535.  
  536.     jmp  still
  537.  
  538. minus_hd:
  539.  
  540.     mov  eax,3
  541.     mcall
  542.     mov  ecx,eax
  543.     sub  ecx,1
  544.     mov  eax,22
  545.     mov  ebx,0x00000000
  546.     mcall
  547.  
  548.     jmp  still
  549.  
  550. minus_he:
  551.  
  552.     mov  eax,3
  553.     mcall
  554.     mov  ecx,eax
  555.     sub  ecx,16
  556.     mov  eax,22
  557.     mov  ebx,0x00000000
  558.     mcall
  559.  
  560.     jmp  still
  561.  
  562. plus_md:
  563.  
  564.     mov  eax,3
  565.     mcall
  566.     mov  ecx,eax
  567.     add  ecx,256
  568.     mov  eax,22
  569.     mov  ebx,0x00000000
  570.     mcall
  571.  
  572.     jmp  still
  573.  
  574. plus_me:
  575.  
  576.     mov  eax,3
  577.     mcall
  578.     mov  ecx,eax
  579.     add  ecx,4096
  580.     mov  eax,22
  581.     mov  ebx,0x00000000
  582.     mcall
  583.  
  584.     jmp  still
  585.  
  586. minus_md:
  587.  
  588.     mov  eax,3
  589.     mcall
  590.     mov  ecx,eax
  591.     sub  ecx,256
  592.     mov  eax,22
  593.     mov  ebx,0x00000000
  594.     mcall
  595.  
  596.     jmp  still
  597.  
  598. minus_me:
  599.  
  600.     mov  eax,3
  601.     mcall
  602.     mov  ecx,eax
  603.     sub  ecx,4096
  604.     mov  eax,22
  605.     mov  ebx,0x00000000
  606.     mcall
  607.  
  608.     jmp  still
  609.  
  610. ;   *********************************************
  611. ;   *******  Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ *******
  612. ;   *********************************************
  613.  
  614. draw_clock:
  615.  
  616.     mov  eax,3
  617.     mcall
  618.     mov  ecx,eax
  619.     mov  eax,47
  620.     mov esi,0x50000000
  621.     mov  edi,0xaabbcc
  622.     mov  ebx,0x00020100
  623.     mov  edx,205*65536+280
  624.     mcall
  625.  
  626.     shr  ecx,8
  627.     add  edx,20*65536
  628.     ;mov  eax,47
  629.     mcall
  630.  
  631.     shr  ecx,8
  632.     add  edx,20*65536
  633.     ;mov  eax,47
  634.     mcall
  635.     ret
  636.  
  637. draw_window:
  638.  
  639.  
  640.     mov  eax,12                    ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
  641.     mov  ebx,1                     ; 1 - ­ ç¨­ ¥¬ à¨á®¢ âì
  642.     mcall
  643.                                    ; ‘Ž‡„€ðŒ ŽŠŽ
  644.     xor  eax,eax                   ; äã­ªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­®
  645.     mov  ebx,WIN_X
  646.   if SKIP eq 0
  647.     mov  ecx,WIN_Y
  648.   else
  649.     mov  ecx,WIN_Y-15
  650.   end if
  651.     mov  edx,0x13aabbcc            ; 梥â à ¡®ç¥© ®¡« á⨠ RRGGBB,8->color gl
  652.     mov  edi,header                ; § £®«®¢®ª
  653.     mcall
  654.     call draw_week
  655.  
  656.     mov  eax,8
  657.     mov  ebx,205*65536+7
  658.     mov  ecx,290*65536+10
  659.     mov  esi,0x005555dd
  660.     mov  edx,72
  661.     mcall
  662.  
  663.     ;mov  eax,8
  664.     mov  ebx,212*65536+7
  665.     ;mov  ecx,290*65536+10
  666.     ;mov  esi,0x005555dd
  667.     inc  edx
  668.     mcall
  669.  
  670.     ;mov  eax,8
  671.     mov  ebx,205*65536+7
  672.     mov  ecx,300*65536+10
  673.     ;mov  esi,0x005555dd
  674.     inc  edx
  675.     mcall
  676.  
  677.     ;mov  eax,8
  678.     mov  ebx,212*65536+7
  679.     ;mov  ecx,300*65536+10
  680.     ;mov  esi,0x005555dd
  681.     inc  edx
  682.     mcall
  683.  
  684.     ;mov  eax,8
  685.     mov  ebx,224*65536+7
  686.     mov  ecx,290*65536+10
  687.     ;mov  esi,0x005555dd
  688.     inc  edx
  689.     mcall
  690.  
  691.     ;mov  eax,8
  692.     mov  ebx,231*65536+7
  693.     ;mov  ecx,290*65536+10
  694.     ;mov  esi,0x005555dd
  695.     inc  edx
  696.     mcall
  697.  
  698.     ;mov  eax,8
  699.     mov  ebx,224*65536+7
  700.     mov  ecx,300*65536+10
  701.     ;mov  esi,0x005555dd
  702.     inc  edx
  703.     mcall
  704.  
  705.     ;mov  eax,8
  706.     mov  ebx,231*65536+7
  707.     ;mov  ecx,300*65536+10
  708.     ;mov  esi,0x005555dd
  709.     inc  edx
  710.     mcall
  711.  
  712.     ;mov  eax,8
  713.     mov  ebx,243*65536+14
  714.     mov  ecx,290*65536+20
  715.     mov  esi,0x00dd7777
  716.     inc  edx
  717.     mcall
  718.  
  719.     mov  eax,8
  720.     mov  esi,0x05080d0
  721.   if SKIP eq 0
  722.     mov  ebx,B_DATE_X
  723.     mov  ecx,B_DATE_Y
  724.     mov  edx,eax
  725.     mcall
  726.     inc  edx
  727.     add  ebx,B_DATE_BSHIFT
  728.     mcall
  729.     inc  edx
  730.   else
  731.     mov  edx,10
  732.   end if
  733.     or   edx,1 shl 29+1 shl 30
  734.     mov  ebx,B_NS_X
  735.     mov  ecx,B_NS_Y
  736.     mcall
  737.     add  edx,1-1 shl 29
  738.     mov  ebx,B_TODAY_X+8*(today_end-today_msg)
  739.     mov  ecx,B_TODAY_Y
  740.     mcall
  741.     mov  ecx,B_Y
  742.     mov  ebx,B_MONTH_X
  743.     mov  edx,2
  744.     mcall
  745.     mov  ebx,B_SPIN_X
  746.     inc  edx
  747.     mcall
  748.     add  ebx,B_SPIN_WIDTH shl 16
  749.     inc  edx
  750.     mcall
  751.     call draw_days
  752.  
  753.     mov  eax,4                     ; äã­ªæ¨ï 4 : ­ ¯¨á âì ¢ ®ª­¥ ⥪áâ
  754.     mov  ebx,110*65536+280
  755.     mov  ecx,0x800000ff
  756.     mov  edx,sys_text
  757.     mcall
  758.  
  759.     ;mov  eax,4
  760.     mov  ebx,149*65536+302
  761.     ;mov  ecx,0x800000ff
  762.     mov  edx,minus
  763.     mcall
  764.  
  765.     ;mov  eax,4
  766.     mov  ebx,137*65536+292
  767.     mov  ecx,0x80ff0000
  768.     mov  edx,plus
  769.     mcall
  770.  
  771.  
  772.     ;mov  eax,4
  773.     mov  ecx,0x10ddeeff            ; èà¨äâ 1 ¨ 梥â ( 0xF0RRGGBB )
  774.  
  775.  if SKIP eq 0
  776.     mov  ebx,B_DATE
  777.     mov  edx,datebut
  778.     mov  esi,9
  779.     btc  ecx,28
  780.     mcall
  781.     add  ebx,B_DATE_SHIFT
  782.     add  edx,esi
  783.     mcall
  784.  end if
  785.     mov  edx,n_style
  786.     mov  esi,ns_end-n_style
  787.     mov  ebx,B_NS
  788.     cmp  [new_style],1
  789.     je   .high
  790.     mov  ecx,0xa0a0a0
  791.     jmp  .int
  792.   .high:
  793.     mov  ecx,0xac0000;d048c8
  794.   .int:
  795.     mcall
  796.  
  797.     mov  ecx,0xd048c8
  798.     mov  edx,today_msg
  799.     mov  ebx,B_TODAY
  800.     mov  esi,today_end-today_msg
  801.     mcall
  802.  
  803.     mov  ebx,B_SPIN
  804.     mov  edx,spinner
  805.     mov  esi,3
  806.     ShowFocus 4
  807.     mcall
  808.  
  809.     mov  edx,[Month]
  810.     movzx  esi,byte[month_name]
  811.     imul edx,esi
  812.     add  edx,month_name+1
  813.     mov  ebx,B_MONTH
  814.     ShowFocus 2
  815.     mcall
  816.  
  817.     call draw_year
  818.     mov  [dropped],0
  819.     mov  eax,12                    ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
  820.     mov  ebx,2                     ; 2, § ª®­ç¨«¨ à¨á®¢ âì
  821.     mcall
  822.     ret                            ; ¢ë室¨¬ ¨§ ¯à®æ¥¤ãàë
  823.  
  824. draw_year:
  825.     mcall 8,B_YEAR_X,B_Y,5,0x05080d0
  826.     ShowFocus 3,esi
  827.     mcall 47,0x40001,Year,B_YEAR
  828.     ret
  829.  
  830. draw_dropdown:
  831.     mov  [dropped],1
  832.     push [Month]
  833.     pop  [focus]
  834.     add  [focus],100
  835.     mov  ecx,12
  836.     mov  edx,100
  837.     push dword month_name+1
  838.     push dword B_DROP
  839.     push dword B_Y+16 shl 16
  840.   .ddd_loop:
  841.     mov  edi,edx
  842.     push ecx
  843.     mov  ebx,B_MONTH_X
  844.     mov  ecx,[esp+4]
  845.     mov  esi,0x6f9fef
  846.     mov  eax,8
  847.     mcall
  848.     shr  eax,1
  849.     mov  ebx,[esp+8]
  850.     xchg edx,[esp+12]
  851.     movzx esi,byte[month_name]
  852.     ShowFocus edi
  853.     mcall
  854.     add  edx,esi
  855.     xchg edx,[esp+12]
  856.     add  dword[esp+8],16
  857.     add  dword[esp+4],16 shl 16
  858.     inc  edx
  859.     pop  ecx
  860.     loop .ddd_loop
  861.     add  esp,12
  862.     ret
  863.  
  864. draw_week:
  865.     mov  eax,13
  866.     mov  ebx,B_WBAR_X
  867.     mov  ecx,B_WBAR_Y
  868.     mov  edx,0x90a0b0
  869.     mcall
  870.     movzx esi,byte[week_days]
  871.     movzx edi,byte[week_days+1]
  872.     mov  ebx,B_WEEK
  873.     mov  ecx,7
  874.     mov  edx,week_days+2
  875.     mov  eax,4
  876.   .week:
  877.     push ecx
  878.     cmp  ecx,edi
  879.     je   .holiday
  880.     mov  ecx,0x10000000
  881.     jmp  .noholiday
  882.   .holiday:
  883.     mov  ecx,0x10cc1010
  884.   .noholiday:
  885.     mcall
  886.     add  edx,esi
  887.     add  ebx,B_WX_SHIFT
  888.     pop  ecx
  889.     loop .week
  890.     ret
  891.  
  892. draw_days:
  893.     mov  eax,13
  894.     mov  ebx,B_DBAR_X
  895.     mov  ecx,B_DBAR_Y
  896.     mov  edx,0xe0e0e0
  897.     mcall
  898.     call count_days
  899.     cmp  ecx,[day_sel]
  900.     jae  .ok
  901.     mov  [day_sel],ecx
  902.   .ok:
  903.     mov  [number],0
  904.     mov  eax,47
  905.     mov  edx,B_DAYS_Y
  906.     mov  ebx,0x20001
  907.     mov  edi,[firstday]
  908.   .dayloop:
  909.     push ecx
  910.     movzx edx,dx
  911.     mov  esi,edi
  912.     shl  esi,21
  913.     lea  edx,[edx+esi+30 shl 16]
  914.     mov  ecx,edi
  915.     add  cl,[week_days+1]
  916.     cmp  ecx,7
  917.     je   .holiday
  918.     mov  esi,0x10000000
  919.     jmp  .noholiday
  920.   .holiday:
  921.     mov  esi,0x10cc1010
  922.   .noholiday:
  923.     mov  ecx,number
  924.     inc  dword[ecx]
  925.     pusha
  926.     mov  ebx,edx
  927.     mov  bx,20
  928.     sub  ebx,3 shl 16
  929.     shrd ecx,edx,16
  930.     mov  cx,20
  931.     sub  ecx,7 shl 16
  932.     mov  edx,[number]
  933.     cmp  edx,[day_sel]
  934.     je   .draw_sel
  935.     mov  esi,0xe0e0e0
  936.     jmp  .draw_but
  937.   .draw_sel:
  938.     mov  esi,0x5080d0
  939.     cmp  [focus],5
  940.     jne  .draw_but
  941.     mov  esi,0xef7840;0xe26830
  942.   .draw_but:
  943.     add  edx,200+1 shl 29
  944.     mov  eax,8
  945.     mcall
  946.     popa
  947.     mcall
  948.     pop  ecx
  949.     inc  edi
  950.     cmp  edi,7
  951.     jne  .nowrap
  952.     xor  edi,edi
  953.     add  dx,B_DAYS_SHIFT
  954.   .nowrap:
  955.     loop .eloop
  956.     jmp  .ex
  957.   .eloop:
  958.     jmp  .dayloop
  959.   .ex:
  960.     ret
  961.  
  962. count_days:    ; ecx -days in month
  963.     call is_leap_year
  964.     mov  ecx,[Month]
  965.     mov  eax,1
  966.     movzx ecx,byte[day_count+ecx]
  967.     add  ecx,28
  968.     cmp  eax,[leap_year]
  969.     jne  .noleap
  970.     cmp  eax,[Month]
  971.     jne  .noleap
  972.     inc  ecx
  973.   .noleap:
  974.     mov  [day_bounds+3],cl
  975.     mov  [day_bounds+7],cl
  976.     ret
  977.  
  978. is_leap_year:
  979.     mov  [leap_year],0
  980.     mov  eax,[Year]
  981.     mov  bl,100
  982.     div  bl          ; ah=Year mod 100, al=Year%100
  983.     test ah,ah
  984.     jz  .century
  985.     shr  ax,8        ; ax - last 2 digits
  986.   .century:
  987.     test al,11b
  988.     jnz  .noleap
  989.     inc  [leap_year]
  990.   .noleap:
  991.     ret
  992.  
  993. calculate:
  994.     mov  ebx,[Year]
  995.     mov  eax,[Month]
  996.     sub  eax,2
  997.     jge  .nojf
  998.     dec  ebx
  999.     add  eax,12
  1000.   .nojf:
  1001.     add  eax,4
  1002.     xor  edx,edx
  1003.     mov  ecx,153
  1004.     imul cx
  1005.     mov  ecx,5
  1006.     div  cx
  1007.     inc  eax
  1008.     mov  ecx,365
  1009.     imul ecx,ebx
  1010.     add  eax,ecx
  1011.     mov  ecx,ebx
  1012.     shr  ecx,2
  1013.     add  eax,ecx
  1014.     dec  eax
  1015.     cmp  [new_style],0
  1016.     je   .nonew
  1017.     add  eax,2
  1018.     xchg eax,ebx
  1019.     mov  ecx,100
  1020.     xor  edx,edx
  1021.     div  cx
  1022.     sub  ebx,eax
  1023.     shr  eax,2
  1024.     add  ebx,eax
  1025.   .nonew:
  1026.     add  ebx,5
  1027.     mov  eax,ebx
  1028.     xor  edx,edx
  1029.     movzx ebx,byte[week_days+1]
  1030.     sub  eax,ebx
  1031.     inc  eax
  1032.     mov  ebx,7
  1033.     div  bx
  1034.     mov  [firstday],edx
  1035.     ret
  1036.  
  1037. ; ‡¤¥áì ­ å®¤ïâáï ¤ ­­ë¥ ¯à®£à ¬¬ë:
  1038.  
  1039. ; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¬­®£®ï§ëç­ë© - § ¤ ©â¥ ï§ëª ¢ lang.inc
  1040. day_count db 3,0,3,2,3,2,3,3,2,3,2,3
  1041. Fkeys     db 210,211,212,213,214,215,216,217,208,209,228,159
  1042.  
  1043. header:          ; áâப  § £®«®¢ª 
  1044. if lang eq ru
  1045.      db   'Š€‹…„€œ',0
  1046. else if lang eq ge
  1047.      db   'KALENDER',0
  1048. else if lang eq fr
  1049.      db   'CALENDRIER',0
  1050. else if lang eq et
  1051.      db   'KALENDER',0
  1052. else
  1053.      db   'CALENDAR',0
  1054. end if
  1055.  
  1056. if SKIP eq 0
  1057. datebut:
  1058. if lang eq ru
  1059.      db   '1-ï ¤ â  '
  1060.      db   '2-ï ¤ â  '
  1061. else if lang eq fr
  1062.      db   '1ere date'
  1063.      db   '2eme date'
  1064. else if lang eq ge
  1065.      db   ' Datum 1 '
  1066.      db   ' Datum 2 '
  1067. else if lang eq et
  1068.      db   'Kuupäev 1'
  1069.      db   'Kuupäev 2'
  1070. else
  1071.      db   '1st date '
  1072.      db   '2nd date '
  1073. end if
  1074. end if
  1075. n_style:
  1076. if lang eq ru
  1077.      db   '®¢ë© á⨫ì'
  1078. else if lang eq de
  1079.      db   'Neuer Stil'
  1080. else if lang eq fr
  1081.      db   'Nouveau'
  1082. else if lang eq et
  1083.      db   'Uus stiil'
  1084. else
  1085.      db   'New style'
  1086. end if
  1087. ns_end:
  1088. today_msg:
  1089. if lang eq ru
  1090.      db   '‘¥£®¤­ï'
  1091. else if lang eq ge
  1092.      db   'Heute'
  1093. else if lang eq fr
  1094.      db   "Aujourd'hui"
  1095. else if lang eq et
  1096.      db   'Täna'
  1097. else
  1098.      db   'Today'
  1099. end if
  1100. today_end:
  1101. focus dd  3
  1102. new_style dd 1
  1103. dropped db 0
  1104.  
  1105. co_text:  db  '¢à¥¬ï á¥áᨨ',0
  1106. sys_text:  db  'á¨á⥬­®¥ ¢à¥¬ï',0
  1107. plus:  db  '¤®¡ ¢¨âì(+)',0
  1108. minus:  db  'ã¡à âì(-)',0
  1109.  
  1110. I_END:  ; ª®­¥æ ¯à®£à ¬¬ë
  1111. firstday  dd ?
  1112. Year dd   ?
  1113. Month dd  ?
  1114. day_sel   dd ?
  1115. all_days  dd ?
  1116.  
  1117. datestr   dd  ?
  1118. leap_year dd ?
  1119. number    dd ?
  1120. year_input dd ?
  1121.