Subversion Repositories Kolibri OS

Rev

Rev 496 | Rev 3586 | 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.  
  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.     cmp  ah,81
  418.     je   set_date
  419.  
  420.     cmp  ah,2           ; drop down list
  421.     jne  no_dropdn
  422.   .drop:
  423.     mov  [focus],2
  424.     cmp  [dropped],al   ; ==0
  425.     jne  red
  426.     call draw_window
  427.     mov  edx,1 shl 31+231
  428.     mov  ecx,31
  429.     mov  eax,8
  430.   .bremove:
  431.     mcall
  432.     dec  edx
  433.     loop .bremove
  434.     call draw_dropdown
  435.     jmp  still
  436.   no_dropdn:
  437.     cmp  ah,3           ; year -1
  438.     jne  noy_dn
  439.   year_dec:
  440.     dec  [Year]
  441.     mov  [focus],4
  442.     jmp  upd
  443.   noy_dn:
  444.     cmp  ah,4           ; year+1
  445.     jne  noy_up
  446.   year_inc:
  447.     inc  [Year]
  448.     mov  [focus],4
  449.     jmp  upd
  450.   noy_up:
  451.     cmp  ah,5
  452.     jne  noy_click
  453.     mov  [focus],3
  454.     call draw_window
  455.   .still:
  456.     mcall 10
  457.     cmp  eax,2
  458.     jne  still.evt
  459.     mcall 2
  460.   .year_evt:
  461.     mov  ebx,10
  462.     cmp  ah,9
  463.     je   key.tab
  464.     cmp  ah,8           ; backspace
  465.     jne  .nobsp
  466.     mov  eax,[Year]
  467.     xor  edx,edx
  468.     div  ebx
  469.   .ch_year:
  470.     mov  [Year],eax
  471.     call draw_year
  472.     jmp  .still
  473.   .nobsp:
  474.     cmp  ah,13          ; enter
  475.     je   upd
  476.     cmp  ah,182
  477.     jne  .noclear       ; del
  478.     xor  eax,eax
  479.     jmp  .ch_year
  480.   .noclear:
  481.     cmp  ah,48
  482.     jb   .still
  483.     cmp  ah,57
  484.     ja   .still
  485.     cmp  [Year],1000
  486.     jae  .still
  487.     shr  eax,8
  488.     lea  ecx,[eax-48]
  489.     mov  eax,[Year]
  490.     imul eax,ebx
  491.     add  eax,ecx
  492.     jmp  .ch_year
  493.   noy_click:
  494.     cmp  ah,10
  495.     jne  start
  496.     xor  [new_style],1
  497.     jmp  upd
  498.  
  499.  
  500. reset:
  501.  
  502.     mov  eax,3
  503.     mcall
  504.     mov  ecx,eax
  505.     shl  ecx,16
  506.     shr  ecx,16
  507.     mov  eax,22
  508.     mov  ebx,0x00000000
  509.     mcall
  510.  
  511.     jmp  still
  512.  
  513. plus_hd:
  514.  
  515.     mov  eax,3
  516.     mcall
  517.     mov  ecx,eax
  518.     add  ecx,1
  519.     mov  eax,22
  520.     mov  ebx,0x00000000
  521.     mcall
  522.  
  523.     jmp  still
  524.  
  525. plus_he:
  526.  
  527.     mov  eax,3
  528.     mcall
  529.     mov  ecx,eax
  530.     add  ecx,16
  531.     mov  eax,22
  532.     mov  ebx,0x00000000
  533.     mcall
  534.  
  535.     jmp  still
  536.  
  537. minus_hd:
  538.  
  539.     mov  eax,3
  540.     mcall
  541.     mov  ecx,eax
  542.     sub  ecx,1
  543.     mov  eax,22
  544.     mov  ebx,0x00000000
  545.     mcall
  546.  
  547.     jmp  still
  548.  
  549. minus_he:
  550.  
  551.     mov  eax,3
  552.     mcall
  553.     mov  ecx,eax
  554.     sub  ecx,16
  555.     mov  eax,22
  556.     mov  ebx,0x00000000
  557.     mcall
  558.  
  559.     jmp  still
  560.  
  561. plus_md:
  562.  
  563.     mov  eax,3
  564.     mcall
  565.     mov  ecx,eax
  566.     add  ecx,256
  567.     mov  eax,22
  568.     mov  ebx,0x00000000
  569.     mcall
  570.  
  571.     jmp  still
  572.  
  573. plus_me:
  574.  
  575.     mov  eax,3
  576.     mcall
  577.     mov  ecx,eax
  578.     add  ecx,4096
  579.     mov  eax,22
  580.     mov  ebx,0x00000000
  581.     mcall
  582.  
  583.     jmp  still
  584.  
  585. minus_md:
  586.  
  587.     mov  eax,3
  588.     mcall
  589.     mov  ecx,eax
  590.     sub  ecx,256
  591.     mov  eax,22
  592.     mov  ebx,0x00000000
  593.     mcall
  594.  
  595.     jmp  still
  596.  
  597. minus_me:
  598.  
  599.     mov  eax,3
  600.     mcall
  601.     mov  ecx,eax
  602.     sub  ecx,4096
  603.     mov  eax,22
  604.     mov  ebx,0x00000000
  605.     mcall
  606.  
  607.     jmp  still
  608.  
  609. set_date:
  610.  
  611.     mov  eax,0x00000000
  612.     mov ebx,[day_sel]
  613.     call additem
  614.     shl  eax,8
  615.     mov  ebx,[Month]
  616.     add  ebx,1
  617.     call additem
  618.     shl  eax,8
  619.     mov  ebx,[Year]
  620.     call additem
  621.     mov  ecx,eax
  622.     mov  eax,22
  623.     mov  ebx,1
  624.     mcall
  625.  
  626.     jmp  still
  627.  
  628. additem:
  629.  
  630.     add  eax,1
  631.     daa
  632.     sub  ebx,1
  633.     cmp  ebx,0
  634.     jne  additem
  635.  
  636.     ret
  637.  
  638.  
  639. ;   *********************************************
  640. ;   *******  Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ *******
  641. ;   *********************************************
  642.  
  643. draw_clock:
  644.  
  645.     mov  eax,3
  646.     mcall
  647.     mov  ecx,eax
  648.     mov  eax,47
  649.     mov esi,0x50000000
  650.     mov  edi,0xaabbcc
  651.     mov  ebx,0x00020100
  652.     mov  edx,205*65536+280
  653.     mcall
  654.  
  655.     shr  ecx,8
  656.     add  edx,20*65536
  657.     mcall
  658.  
  659.     shr  ecx,8
  660.     add  edx,20*65536
  661.     mcall
  662.     ret
  663.  
  664. draw_window:
  665.  
  666.  
  667.     mov  eax,12                    ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
  668.     mov  ebx,1                     ; 1 - ­ ç¨­ ¥¬ à¨á®¢ âì
  669.     mcall
  670.                                    ; ‘Ž‡„€ðŒ ŽŠŽ
  671.     xor  eax,eax                   ; äã­ªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­®
  672.     mov  ebx,WIN_X
  673.   if SKIP eq 0
  674.     mov  ecx,WIN_Y
  675.   else
  676.     mov  ecx,WIN_Y-15
  677.   end if
  678.     mov  edx,0x14aabbcc            ; 梥â à ¡®ç¥© ®¡« á⨠ RRGGBB,8->color gl
  679.     mov  edi,title                 ; § £®«®¢®ª
  680.     mcall
  681.     call draw_week
  682.  
  683.     mov  eax,8
  684.     mov  ebx,205*65536+7
  685.     mov  ecx,290*65536+10
  686.     mov  esi,0x005555dd
  687.     mov  edx,72
  688.     mcall
  689.  
  690.     mov  ebx,212*65536+7
  691.     inc  edx
  692.     mcall
  693.  
  694.     mov  ebx,205*65536+7
  695.     mov  ecx,300*65536+10
  696.     inc  edx
  697.     mcall
  698.  
  699.     mov  ebx,212*65536+7
  700.     inc  edx
  701.     mcall
  702.  
  703.     mov  ebx,224*65536+7
  704.     mov  ecx,290*65536+10
  705.     inc  edx
  706.     mcall
  707.  
  708.     mov  ebx,231*65536+7
  709.     inc  edx
  710.     mcall
  711.  
  712.     mov  ebx,224*65536+7
  713.     mov  ecx,300*65536+10
  714.     inc  edx
  715.     mcall
  716.  
  717.     mov  ebx,231*65536+7
  718.     inc  edx
  719.     mcall
  720.  
  721.     mov  ebx,243*65536+14
  722.     mov  ecx,290*65536+20
  723.     mov  esi,0x00dd7777
  724.     inc  edx
  725.     mcall
  726.  
  727.     mov  ebx,10*65536+100
  728.     mov  ecx,290*65536+20
  729.     mov  esi,0x00d5d5d5
  730.     inc  edx
  731.     mcall
  732.  
  733.     mov  esi,0x05080d0
  734.   if SKIP eq 0
  735.     mov  ebx,B_DATE_X
  736.     mov  ecx,B_DATE_Y
  737.     mov  edx,eax
  738.     mcall
  739.     inc  edx
  740.     add  ebx,B_DATE_BSHIFT
  741.     mcall
  742.     inc  edx
  743.   else
  744.     mov  edx,10
  745.   end if
  746.     or   edx,1 shl 29+1 shl 30
  747.     mov  ebx,B_NS_X
  748.     mov  ecx,B_NS_Y
  749.     mcall
  750.     add  edx,1-1 shl 29
  751.     mov  ebx,B_TODAY_X+8*(today_end-today_msg)
  752.     mov  ecx,B_TODAY_Y
  753.     mcall
  754.     mov  ecx,B_Y
  755.     mov  ebx,B_MONTH_X
  756.     mov  edx,2
  757.     mcall
  758.     mov  ebx,B_SPIN_X
  759.     inc  edx
  760.     mcall
  761.     add  ebx,B_SPIN_WIDTH shl 16
  762.     inc  edx
  763.     mcall
  764.     call draw_days
  765.  
  766.     mov  eax,4                     ; äã­ªæ¨ï 4 : ­ ¯¨á âì ¢ ®ª­¥ ⥪áâ
  767.     mov  ebx,110*65536+280
  768.     mov  ecx,0x800000ff
  769.     mov  edx,sys_text
  770.     mcall
  771.  
  772.     mov  ebx,149*65536+302
  773.     mov  edx,minus
  774.     mcall
  775.  
  776.     mov  ebx,137*65536+292
  777.     mov  ecx,0x80ff0000
  778.     mov  edx,plus
  779.     mcall
  780.  
  781.     mov  ebx,15*65536+298
  782.     mov  ecx,0x00000000
  783.     mov  esi,15
  784.     mov  edx,setd
  785.     mcall
  786.  
  787.     mov  ecx,0x10ddeeff            ; èà¨äâ 1 ¨ 梥â ( 0xF0RRGGBB )
  788.  
  789.  if SKIP eq 0
  790.     mov  ebx,B_DATE
  791.     mov  edx,datebut
  792.     mov  esi,9
  793.     btc  ecx,28
  794.     mcall
  795.     add  ebx,B_DATE_SHIFT
  796.     add  edx,esi
  797.     mcall
  798.  end if
  799.     mov  edx,n_style
  800.     mov  esi,ns_end-n_style
  801.     mov  ebx,B_NS
  802.     cmp  [new_style],1
  803.     je   .high
  804.     mov  ecx,0xa0a0a0
  805.     jmp  .int
  806.   .high:
  807.     mov  ecx,0xac0000;d048c8
  808.   .int:
  809.     mcall
  810.  
  811.     mov  ecx,0xd048c8
  812.     mov  edx,today_msg
  813.     mov  ebx,B_TODAY
  814.     mov  esi,today_end-today_msg
  815.     mcall
  816.  
  817.     mov  ebx,B_SPIN
  818.     mov  edx,spinner
  819.     mov  esi,3
  820.     ShowFocus 4
  821.     mcall
  822.  
  823.     mov  edx,[Month]
  824.     movzx  esi,byte[month_name]
  825.     imul edx,esi
  826.     add  edx,month_name+1
  827.     mov  ebx,B_MONTH
  828.     ShowFocus 2
  829.     mcall
  830.  
  831.     call draw_year
  832.     mov  [dropped],0
  833.     mov  eax,12                    ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
  834.     mov  ebx,2                     ; 2, § ª®­ç¨«¨ à¨á®¢ âì
  835.     mcall
  836.     ret                            ; ¢ë室¨¬ ¨§ ¯à®æ¥¤ãàë
  837.  
  838. draw_year:
  839.     mcall 8,B_YEAR_X,B_Y,5,0x05080d0
  840.     ShowFocus 3,esi
  841.     mcall 47,0x40001,Year,B_YEAR
  842.     ret
  843.  
  844. draw_dropdown:
  845.     mov  [dropped],1
  846.     push [Month]
  847.     pop  [focus]
  848.     add  [focus],100
  849.     mov  ecx,12
  850.     mov  edx,100
  851.     push dword month_name+1
  852.     push dword B_DROP
  853.     push dword B_Y+16 shl 16
  854.   .ddd_loop:
  855.     mov  edi,edx
  856.     push ecx
  857.     mov  ebx,B_MONTH_X
  858.     mov  ecx,[esp+4]
  859.     mov  esi,0x6f9fef
  860.     mov  eax,8
  861.     mcall
  862.     shr  eax,1
  863.     mov  ebx,[esp+8]
  864.     xchg edx,[esp+12]
  865.     movzx esi,byte[month_name]
  866.     ShowFocus edi
  867.     mcall
  868.     add  edx,esi
  869.     xchg edx,[esp+12]
  870.     add  dword[esp+8],16
  871.     add  dword[esp+4],16 shl 16
  872.     inc  edx
  873.     pop  ecx
  874.     loop .ddd_loop
  875.     add  esp,12
  876.     ret
  877.  
  878. draw_week:
  879.     mov  eax,13
  880.     mov  ebx,B_WBAR_X
  881.     mov  ecx,B_WBAR_Y
  882.     mov  edx,0x90a0b0
  883.     mcall
  884.     movzx esi,byte[week_days]
  885.     movzx edi,byte[week_days+1]
  886.     mov  ebx,B_WEEK
  887.     mov  ecx,7
  888.     mov  edx,week_days+2
  889.     mov  eax,4
  890.   .week:
  891.     push ecx
  892.     cmp  ecx,edi
  893.     je   .holiday
  894.     mov  ecx,0x10000000
  895.     jmp  .noholiday
  896.   .holiday:
  897.     mov  ecx,0x10cc1010
  898.   .noholiday:
  899.     mcall
  900.     add  edx,esi
  901.     add  ebx,B_WX_SHIFT
  902.     pop  ecx
  903.     loop .week
  904.     ret
  905.  
  906. draw_days:
  907.     mov  eax,13
  908.     mov  ebx,B_DBAR_X
  909.     mov  ecx,B_DBAR_Y
  910.     mov  edx,0xe0e0e0
  911.     mcall
  912.     call count_days
  913.     cmp  ecx,[day_sel]
  914.     jae  .ok
  915.     mov  [day_sel],ecx
  916.   .ok:
  917.     mov  [number],0
  918.     mov  eax,47
  919.     mov  edx,B_DAYS_Y
  920.     mov  ebx,0x20001
  921.     mov  edi,[firstday]
  922.   .dayloop:
  923.     push ecx
  924.     movzx edx,dx
  925.     mov  esi,edi
  926.     shl  esi,21
  927.     lea  edx,[edx+esi+30 shl 16]
  928.     mov  ecx,edi
  929.     add  cl,[week_days+1]
  930.     cmp  ecx,7
  931.     je   .holiday
  932.     mov  esi,0x10000000
  933.     jmp  .noholiday
  934.   .holiday:
  935.     mov  esi,0x10cc1010
  936.   .noholiday:
  937.     mov  ecx,number
  938.     inc  dword[ecx]
  939.     pusha
  940.     mov  ebx,edx
  941.     mov  bx,20
  942.     sub  ebx,3 shl 16
  943.     shrd ecx,edx,16
  944.     mov  cx,20
  945.     sub  ecx,7 shl 16
  946.     mov  edx,[number]
  947.     cmp  edx,[day_sel]
  948.     je   .draw_sel
  949.     mov  esi,0xe0e0e0
  950.     jmp  .draw_but
  951.   .draw_sel:
  952.     mov  esi,0x5080d0
  953.     cmp  [focus],5
  954.     jne  .draw_but
  955.     mov  esi,0xef7840;0xe26830
  956.   .draw_but:
  957.     add  edx,200+1 shl 29
  958.     mov  eax,8
  959.     mcall
  960.     popa
  961.     mcall
  962.     pop  ecx
  963.     inc  edi
  964.     cmp  edi,7
  965.     jne  .nowrap
  966.     xor  edi,edi
  967.     add  dx,B_DAYS_SHIFT
  968.   .nowrap:
  969.     loop .eloop
  970.     jmp  .ex
  971.   .eloop:
  972.     jmp  .dayloop
  973.   .ex:
  974.     ret
  975.  
  976. count_days:    ; ecx -days in month
  977.     call is_leap_year
  978.     mov  ecx,[Month]
  979.     mov  eax,1
  980.     movzx ecx,byte[day_count+ecx]
  981.     add  ecx,28
  982.     cmp  eax,[leap_year]
  983.     jne  .noleap
  984.     cmp  eax,[Month]
  985.     jne  .noleap
  986.     inc  ecx
  987.   .noleap:
  988.     mov  [day_bounds+3],cl
  989.     mov  [day_bounds+7],cl
  990.     ret
  991.  
  992. is_leap_year:
  993.     mov  [leap_year],0
  994.     mov  eax,[Year]
  995.     mov  bl,100
  996.     div  bl          ; ah=Year mod 100, al=Year%100
  997.     test ah,ah
  998.     jz  .century
  999.     shr  ax,8        ; ax - last 2 digits
  1000.   .century:
  1001.     test al,11b
  1002.     jnz  .noleap
  1003.     inc  [leap_year]
  1004.   .noleap:
  1005.     ret
  1006.  
  1007. calculate:
  1008.     mov  ebx,[Year]
  1009.     mov  eax,[Month]
  1010.     sub  eax,2
  1011.     jge  .nojf
  1012.     dec  ebx
  1013.     add  eax,12
  1014.   .nojf:
  1015.     add  eax,4
  1016.     xor  edx,edx
  1017.     mov  ecx,153
  1018.     imul cx
  1019.     mov  ecx,5
  1020.     div  cx
  1021.     inc  eax
  1022.     mov  ecx,365
  1023.     imul ecx,ebx
  1024.     add  eax,ecx
  1025.     mov  ecx,ebx
  1026.     shr  ecx,2
  1027.     add  eax,ecx
  1028.     dec  eax
  1029.     cmp  [new_style],0
  1030.     je   .nonew
  1031.     add  eax,2
  1032.     xchg eax,ebx
  1033.     mov  ecx,100
  1034.     xor  edx,edx
  1035.     div  cx
  1036.     sub  ebx,eax
  1037.     shr  eax,2
  1038.     add  ebx,eax
  1039.   .nonew:
  1040.     add  ebx,5
  1041.     mov  eax,ebx
  1042.     xor  edx,edx
  1043.     movzx ebx,byte[week_days+1]
  1044.     sub  eax,ebx
  1045.     inc  eax
  1046.     mov  ebx,7
  1047.     div  bx
  1048.     mov  [firstday],edx
  1049.     ret
  1050.  
  1051. ; ‡¤¥áì ­ å®¤ïâáï ¤ ­­ë¥ ¯à®£à ¬¬ë:
  1052.  
  1053. ; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¬­®£®ï§ëç­ë© - § ¤ ©â¥ ï§ëª ¢ lang.inc
  1054. day_count db 3,0,3,2,3,2,3,3,2,3,2,3
  1055. Fkeys     db 210,211,212,213,214,215,216,217,208,209,228,159
  1056.  
  1057. title:   ; áâப  § £®«®¢ª 
  1058. if lang eq ru
  1059.      db   'Š€‹…„€œ',0
  1060. else if lang eq ge
  1061.      db   'KALENDER',0
  1062. else if lang eq fr
  1063.      db   'CALENDRIER',0
  1064. else if lang eq et
  1065.      db   'KALENDER',0
  1066. else
  1067.      db   'CALENDAR',0
  1068. end if
  1069.  
  1070. if SKIP eq 0
  1071. datebut:
  1072. if lang eq ru
  1073.      db   '1-ï ¤ â  '
  1074.      db   '2-ï ¤ â  '
  1075. else if lang eq fr
  1076.      db   '1ere date'
  1077.      db   '2eme date'
  1078. else if lang eq ge
  1079.      db   ' Datum 1 '
  1080.      db   ' Datum 2 '
  1081. else if lang eq et
  1082.      db   'Kuupäev 1'
  1083.      db   'Kuupäev 2'
  1084. else
  1085.      db   '1st date '
  1086.      db   '2nd date '
  1087. end if
  1088. end if
  1089. n_style:
  1090. if lang eq ru
  1091.      db   '®¢ë© á⨫ì'
  1092. else if lang eq de
  1093.      db   'Neuer Stil'
  1094. else if lang eq fr
  1095.      db   'Nouveau'
  1096. else if lang eq et
  1097.      db   'Uus stiil'
  1098. else
  1099.      db   'New style'
  1100. end if
  1101. ns_end:
  1102. today_msg:
  1103. if lang eq ru
  1104.      db   '‘¥£®¤­ï'
  1105. else if lang eq ge
  1106.      db   'Heute'
  1107. else if lang eq fr
  1108.      db   "Aujourd'hui"
  1109. else if lang eq et
  1110.      db   'Täna'
  1111. else
  1112.      db   'Today'
  1113. end if
  1114. today_end:
  1115. focus dd  3
  1116. new_style dd 1
  1117. dropped db 0
  1118.  
  1119. sys_text:  db  'á¨á⥬­®¥ ¢à¥¬ï',0
  1120. plus:  db  '¤®¡ ¢¨âì(+)',0
  1121. minus:  db  'ã¡à âì(-)',0
  1122. setd:   db  '“áâ ­®¢¨âì ¤ âã',0
  1123.  
  1124. I_END:  ; ª®­¥æ ¯à®£à ¬¬ë
  1125. firstday  dd ?
  1126. Year dd   ?
  1127. Month dd  ?
  1128. day_sel   dd ?
  1129. all_days  dd ?
  1130.  
  1131. datestr   dd  ?
  1132. leap_year dd ?
  1133. number    dd ?
  1134. year_input dd ?