Subversion Repositories Kolibri OS

Rev

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

  1. ; Copyright (c) 2009, <Lrz>
  2. ; All rights reserved.
  3. ;
  4. ; Redistribution and use in source and binary forms, with or without
  5. ; modification, are permitted provided that the following conditions are met:
  6. ;       * Redistributions of source code must retain the above copyright
  7. ;       notice, this list of conditions and the following disclaimer.
  8. ;       * Redistributions in binary form must reproduce the above copyright
  9. ;       notice, this list of conditions and the following disclaimer in the
  10. ;       documentation and/or other materials provided with the distribution.
  11. ;       * Neither the name of the <organization> nor the
  12. ;       names of its contributors may be used to endorse or promote products
  13. ;       derived from this software without specific prior written permission.
  14. ;
  15. ; THIS SOFTWARE IS PROVIDED BY Alexey Teplov aka <Lrz> ''AS IS'' AND ANY
  16. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  19. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. ;*****************************************************************************
  26.  
  27. ; òóò îïèñûâàþòñÿ ïðîöåäóðû êîòîðûå èñïîëüçóþòñÿ â secondary loader
  28. color_sym_black equ     0
  29. color_sym_blue  equ     1
  30. color_sym_green equ     2
  31. color_sym_turquoise equ 3
  32. color_sym_red   equ     4
  33.  
  34. color_sym_lightgray equ 7
  35.  
  36. color_sym_lightblue equ 9
  37. color_sym_lettuce   equ 10
  38. color_sym_pink  equ     12
  39. color_sym_yellow equ    14
  40. color_sym_white equ     15
  41. if DEBUG
  42. decode:
  43. ;input eax - ÷èñëî, es:di êóäà ïèñàòü, cx=10
  44.         cmp     eax,ecx
  45.         jb      @f
  46.         xor     edx,edx
  47.         div     ecx
  48.         push    edx
  49.         call    decode
  50.         pop     eax
  51.     @@: or      al,0x30
  52.         mov     [ds:di],al
  53.         inc     di
  54.         ret
  55.  
  56. end if
  57.  
  58.  
  59. putchar:
  60. ; in: al=character
  61.         mov     ah, 0Eh
  62.         mov     bh, 0
  63.         int     10h
  64.         ret
  65.  
  66. printplain:
  67. ; in: si->string
  68.         pusha
  69.         lodsb
  70. @@:
  71.         call    putchar
  72.         lodsb
  73.         cmp     al, 0
  74.         jnz     @b
  75.         mov     al,13
  76.         call    putchar
  77.  
  78.         mov     al,10
  79.         call    putchar
  80.         popa
  81.         ret
  82. getkey:
  83. ; get number in range [bl,bh] (bl,bh in ['0'..'9'])
  84. ; in: bx=range
  85. ; out: ax=digit (1..9, 10 for 0)
  86.         mov     ah, 0
  87.         int     16h
  88.         cmp     al, bl
  89.         jb      getkey
  90.         cmp     al, bh
  91.         ja      getkey
  92.         push    ax
  93.         call    putchar
  94.         pop     ax
  95.         and     ax, 0Fh
  96.         jnz     @f
  97.         mov     al, 10
  98. @@:
  99.         ret
  100.  
  101. ;setcursor:
  102. ; in: dl=column, dh=row
  103. ;        mov     ah, 2
  104. ;        mov     bh, 0
  105. ;        int     10h
  106. ;        ret
  107.  
  108. ;macro _setcursor row,column
  109. ;{
  110. ;        mov     dx, row*256 + column
  111. ;        call    setcursor
  112. ;}
  113.  
  114. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  115. ;
  116. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  117. get_firs_sym:
  118. .start:
  119.         mov     al,byte [es:di]
  120.         inc     di
  121.         dec     cx
  122.         jcxz    .exit
  123.  
  124.         cmp     al,0xa          ;cmp al,0xa
  125.         jz      ._entry
  126.  
  127.         cmp     al,';'
  128.         jnz     .start
  129.  
  130. .first_com:
  131.  
  132.         mov     al,0xa
  133.         repnz   scasb
  134.         jcxz    .exit
  135. ._entry:
  136.         mov     al,byte [es:di]
  137. .first_sp:
  138.         cmp     al,' '
  139.         jnz     .not_space
  140.  
  141. ;       mov     al,' '          ;cut ' '
  142.         repe    scasb
  143.         dec     di
  144.         inc     cx
  145.         mov     al,byte [es:di]
  146. .not_space:
  147.         cmp     al,';'
  148.         jz      .first_com
  149. .exit:  ret    
  150. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  151. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  152. show_name_section:
  153.         push    si
  154.         push    ini_data_
  155.         pop     es
  156.  
  157.  
  158.         mov     al,']'
  159.         repnz   scasb
  160.         test    cx,cx
  161.         jz      error.incorect_section_def
  162. .find_val_name_fb1:
  163.         mov     al,'n'
  164. .find_val_name_fb:
  165.         repnz   scasb
  166.         jcxz    .not_name_sec_fb
  167.  
  168.         mov     si,parse_name
  169.  
  170.         push    cx
  171.         push    di
  172.  
  173.         mov     cx,parse_name_e -parse_name
  174.         repe    cmpsb
  175.         pop     di
  176.         pop     cx
  177.         jz      .yaaa_find_value       
  178.  
  179.  
  180.         jmp     .find_val_name_fb
  181.  
  182. .yaaa_find_value:
  183.         sub     cx,parse_name_e -parse_name
  184.         add     di,parse_name_e -parse_name
  185.  
  186.         mov     ax,0x3d20          ; ah='='
  187.         repe    scasb
  188.         test    cx,cx
  189.         jz      .not_name_sec_fb
  190.  
  191.         cmp     ah,byte [es:di-1]    ;find '='
  192.         jnz     .find_val_name_fb1
  193.        
  194.         repe    scasb              ;cut ' '
  195.         inc     cx
  196.         dec     di
  197.  
  198.  
  199. ;âñå âûðåçàëè è âñå ãîòîâî äëÿ âûâîäà èìåíè ñåêöèè ))
  200.         push    es
  201.         pop     ds
  202.  
  203. .def_sect_name:
  204.         push    0xb800
  205.         pop     es
  206. ;clear array for message
  207.         xor     ax,ax
  208. if DEBUG
  209.         mov     ax,0x0720
  210. end if
  211.  
  212.         mov     cx,39
  213.         mov     si,di
  214.         mov     di,dx
  215.         sub     di,2
  216.         rep     stosw
  217. ;//////////////////////
  218.  
  219.  
  220.         mov     di,dx
  221.         mov     ah,color_sym_white;color_sym_lightblue
  222.         mov     cx,36
  223.         lodsb
  224.         sub     di,2
  225.         cmp     al,'"'
  226.         jz      @f
  227.         cmp     al,"'"
  228.         jnz     .end_sh_name_sec
  229. @@:     lodsb
  230. @@:
  231.         stosw
  232.         lodsb
  233.         cmp     al,'"'
  234.         jz      .end_sh_name_sec
  235.         cmp     al,"'"
  236.         jz      .end_sh_name_sec
  237.         loop    @b
  238.        
  239.         mov     al,'}'
  240.         mov     ah,color_sym_yellow
  241.         stosw
  242. .end_sh_name_sec:
  243.         push    cs
  244.         pop     ds
  245.  
  246.         pop     si
  247.         ret
  248.  
  249. .not_name_sec_fb:    ;íåò èìåíè â íàçâàíèè ñåêöèè - çíà÷èò òàê è ñêàæåì îá ýòîì
  250.         push    cs
  251.         pop     ds
  252.         mov     di,default_section_name
  253.         jmp     .def_sect_name
  254.  
  255. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  256. ;ïðîöåäóðà ïîèñêà ââåðõ ñëåäóþùåé ñåêöèè
  257. ;â point_default ñîäåðæèòüñÿ óêàçàòåëü íà äåôàóëò ñåêöèþ, è â ïðåäåëàõ âðåéìà ìû áåãàåì ïî çàðàíåå ïðîïàðñåíûìè çíà÷åíèÿì óêàçàòåëåé
  258. ;äëÿ òîãî ÷òî áû îòîáðàçèòü è ïðîïàðñèòü ñëåäóþùèé ôðåéì, íàì íóæíî ïîëó÷èòü çà ïåðäûäóùèé èëè ñëåäóþùèé óêàçàòåëü
  259. find_before_sect:
  260.         mov     di,point_default
  261. .e:
  262.         push    ini_data_
  263.         pop     es
  264.         mov     cx,di   ;ïðåäïîëîæèì áóäåì ïðîñìàòðèâàòü ê íà÷àëó, òåêóùàÿ ïîçèöèÿ di = ñêîëüêî ñèìâîëîâ îò íà÷àëà äîêóìåíòà èìååòñÿ
  265.         mov     bx,cx   ;êîïèÿ
  266.  
  267. ;íàñòðîèëè óêàçàòåëü íà äåôàóëò ñåêöèþ
  268. ;áóäåì èñêàòü ââåðõ
  269. .find_start_section:
  270.         std     ;óñòàíîâêà ôëàãà íàïðàâëåíèÿ - áóäåì ïðîñìàòèðâàòü ê íà÷àëó íàøåãî èíè ôàéëà
  271. ;áóäåì èñêàòü íà÷àëî ñåêöèè ò.å. '[' ýòîò ñèìâîë
  272.         mov     al,0xa
  273.         repnz   scasb   ;ïðîñêàíèðóåì íà íàëè÷åå ñèìâîëà íà÷àëà ñåêöèè
  274.         jcxz    .go_    ;ìû ïðîñìîòðåëè äî íà÷àëà ôàéëà, íî òàê è íè÷åãî íå íàøëè ;(( ïî òèõîìó âûéäåì )
  275.  
  276.         mov     find_sec_di,di  ;ñîõðàíèì äàííûå
  277.         mov     cx,di  ;
  278.  
  279.         sub     bx,cx
  280.         mov     cx,bx   ;â ñx çíà÷åíèå - êîë-âî ñèìâîëîâ
  281.         cld
  282.         call    get_firs_sym
  283. .ret_go:
  284.         jcxz    ._not_section   ; â äàííîì ñëó÷àå èìååì êîíñòðóêöèþ 0xa ... ; hello [ñåêöèÿ] îáëîìñ èùåì äàëåå
  285.  
  286.         cmp     di,point_loader ; ñåêöèþ loader ìû íå çàíîñèì èíà÷å êðàõ
  287.         jz      ._not_section
  288. ;âñå óäà÷íî ìû íàøëè âõîæäåíèå ñåêöèè ïðåäûäóùåé
  289.         cmp     al,'['
  290.         jnz     ._not_section
  291.         mov     point_default,di
  292. .exit_scan_sect:
  293.         ret
  294. ;;;;;;;; âîññòàíîâèì çíà÷åíèÿ è ïðîäîëæèì ïîèñêè íà÷àëà ñåêöèè êîòîðàÿ íàñ óñòðîèò ))
  295. ._not_section:
  296.         mov     di,find_sec_di
  297.         mov     cx,di
  298.         mov     bx,cx
  299.         jmp     .find_start_section
  300. .go_:
  301.         cld
  302.         mov     cx,bx   ;â ñx çíà÷åíèå - êîë-âî ñèìâîëîâ
  303.  
  304.         mov     al,byte [es:di]
  305.         push    word .f_go
  306.         cmp     al,' '
  307.         jz      @f
  308.         jmp     get_firs_sym.not_space
  309. @@:
  310.         jmp     get_firs_sym.first_sp
  311.  
  312. .f_go:
  313.         jcxz    .exit_scan_sect ; â äàííîì ñëó÷àå èìååì êîíñòðóêöèþ 0xa ... ; hello [ñåêöèÿ] îáëîìñ èùåì äàëåå
  314.  
  315.         cmp     di,point_loader ; ñåêöèþ loader ìû íå çàíîñèì èíà÷å êðàõ
  316.         jz      .exit_scan_sect
  317. ;âñå óäà÷íî ìû íàøëè âõîæäåíèå ñåêöèè ïðåäûäóùåé
  318.         cmp     al,'['
  319.         jnz     .exit_scan_sect
  320.         mov     point_default,di
  321.         ret
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  330. ;
  331. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  332. find_next_sect:
  333.         mov     di,point_default
  334.         push    ini_data_
  335.         pop     es
  336.         mov     cx,save_cx;di   ;ïðåäïîëîæèì áóäåì ïðîñìàòðèâàòü ê êîíöó, òåêóùàÿ ïîçèöèÿ di = ñêîëüêî ñèìâîëîâ îò íà÷àëà äîêóìåíòà èìååòñÿ
  337.         sub     cx,di   ;ñåé÷àñ â cx îñòàòîê ò.å.  ñêîëüêî ìîæíî êðóòèòü äî êîíöà è íå âûëàçèòü íà íà÷àëî
  338.         jmp     .let_s_go
  339. .h:
  340.         push    ini_data_
  341.         pop     es
  342.         mov     cx,save_cx;di   ;ïðåäïîëîæèì áóäåì ïðîñìàòðèâàòü ê êîíöó, òåêóùàÿ ïîçèöèÿ di = ñêîëüêî ñèìâîëîâ îò íà÷àëà äîêóìåíòà èìååòñÿ
  343. ;       sub     cx,di   ;ñåé÷àñ â cx îñòàòîê ò.å.  ñêîëüêî ìîæíî êðóòèòü äî êîíöà è íå âûëàçèòü íà íà÷àëî
  344.  
  345.         mov     al,byte [es:di]
  346.         push    word .let_s_go_ret
  347.         cmp     al,' '
  348.         jz      @f
  349.         jmp     get_firs_sym.not_space
  350. @@:
  351.         jmp     get_firs_sym.first_sp
  352.  
  353.  
  354.  
  355.  
  356. ;íàñòðîèëè óêàçàòåëü íà äåôàóëò ñåêöèþ
  357. ;áóäåì èñêàòü âíèç
  358. .let_s_go:
  359.         call    get_firs_sym
  360. .let_s_go_ret:
  361.         jcxz    .exit_scan_sect ; â äàííîì ñëó÷àå èìååì êîíñòðóêöèþ 0xa ... ; hello [ñåêöèÿ] îáëîìñ èùåì äàëåå
  362.         cmp     al,'['
  363.         jnz     .let_s_go
  364.         cmp     di,point_loader
  365.         jz      .let_s_go
  366. ;âñå óäà÷íî ìû íàøëè âõîæäåíèå ñåêöèè ïðåäûäóùåé
  367.         mov     point_default,di
  368. .exit_scan_sect:
  369.         ret
  370.  
  371. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  372. ;clean old cursor
  373. clean_active_cursor:
  374. ;íå èçìåíÿåò çíà÷åíèå ax
  375. ;îòîáðàæåíèå êóðñîðà ïî óìîë÷àíèþ
  376.         lea     si,point_to_hframe
  377.         mov     di,962-160
  378.         mov     dx,point_default
  379.         mov     cx,18
  380. .clean_show_cur:
  381.         mov     bx,[si]
  382.         add     di,160
  383.         cmp     bx,dx
  384.         jz      .clean_cursor_
  385.         sub     si,2
  386.         loop    .clean_show_cur
  387.  
  388. ;       jmp $
  389.  
  390. .clean_cursor_:
  391.         push    0xb800
  392.         pop     es
  393.         push    ax
  394.         mov     point_to_point_def,si
  395.         xor     ax,ax
  396. if DEBUG
  397.         mov     ax,0x0720
  398. end if
  399.         stosw
  400.         add     di,68
  401.         stosw
  402.         pop     ax
  403.         ret    
  404. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  405. ;óñòàíîâêà òàéìåðà è îòîáðàæåíèå ñ÷åò÷èêà âðåìåíè
  406. gettime:
  407.         mov     ah,0
  408.         int     1Ah
  409.         xchg    ax, cx
  410.         shl     eax, 10h
  411.         xchg    ax, dx
  412.         ret
  413. newtimer:
  414.         push    ds
  415.  
  416.         push    cs
  417.         pop     ds
  418.  
  419.         pushf
  420.         call    far dword [old_timer]
  421.  
  422.         pushad
  423.         call    gettime
  424.  
  425.         sub     eax, dword[start_timer]
  426.         mov     bx, word [value_timeout]
  427.         imul    bx,18
  428.         sub     bx, ax
  429.         jbe     .timergo
  430.  
  431.         push    es
  432.  
  433.         push    0xb800
  434.         pop     es
  435.         mov     ax,bx
  436.  
  437.         mov     bx, 18
  438.         xor     dx, dx
  439.         div     bx
  440.  
  441.         mov     bx,10
  442.         mov     di,3734
  443.         call    .decode
  444.  
  445.         xor     ax,ax
  446.         stosw
  447.  
  448. ; wait 5/4/3/2 seconds, 1 second
  449.         pop     es
  450.         popad
  451.         pop     ds
  452.  
  453.         iret
  454. .timergo:
  455.         push    0
  456.         pop     es
  457.         mov     eax,dword [old_timer]
  458.         mov     [es:8*4], eax
  459.         mov     dword [timer_],eax
  460.         mov     sp, word [start_stack]  
  461.         mov     bp,word [save_bp_from_timer]
  462. ;;íå âîññòàíîâëåíûé ñòåê :(
  463.         sti
  464.         jmp     parse_start.parse_run_only
  465.  
  466.  
  467. .decode:
  468. ;input ax - ÷èñëî, es:di êóäà ïèñàòü, bx=10
  469.         cmp     ax,bx
  470.         jb      @f
  471.         xor     dx,dx
  472.         div     bx
  473.         push    dx
  474.         call    .decode
  475.         pop     ax
  476.     @@: or      al,0x30
  477.         push    ax
  478.         mov     ah,9
  479.         stosw
  480.         pop     ax
  481.         ret
  482.  
  483. show_bl_sc_sect:
  484. ;1) îòîáðàæåíèå ñïèñêà ñåêöèé. Åñëè ñåêöèÿ íå èìåò èìÿ - îøèáêà - âûâîä Section unname
  485. ;ïðîâåðêà íà íàëè÷åå èìåíè.
  486. ;âõîäíûå äàííûå es:di -óêàçàòåëü íà ñåêöèþ - cx ðàçìåð ñåêöèè
  487. ;       push    bp
  488.         mov     bx,point_to_eframe
  489.         lea     si,point_to_hframe
  490.         mov     dx,966
  491.  
  492. .home_show_fb:
  493.         cmp     si,bx
  494.         jb      ._show_space_fb
  495.         mov     di,[si]
  496.         sub     si,2
  497.         mov     cx,[si]
  498.         sub     cx,di           ;home first section it's end before section
  499.         call    show_name_section
  500.         add     dx,160
  501.         jmp     .home_show_fb
  502. ._show_space_fb:
  503.         sub     dx,4
  504.         push    0xb800
  505.         pop     es
  506. @@:
  507.         cmp     dx,0xE64
  508.         ja      .exit_show_fb
  509.         mov     di,dx
  510. ;clear array for message
  511.         xor     ax,ax
  512. if DEBUG
  513.         mov     ax,0x0720
  514. end if
  515.         mov     cx,39
  516.         rep     stosw
  517. ;//////////////////////
  518.  
  519.         add     dx,160 
  520.         jmp     @b
  521. .exit_show_fb:
  522. ;        pop    bp
  523.         ret
  524.  
  525.