Subversion Repositories Kolibri OS

Rev

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

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