Subversion Repositories Kolibri OS

Rev

Rev 1231 | 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.     @@:
  52.         or      al, 0x30
  53.         mov     [ds:di], al
  54.         inc     di
  55.         ret
  56.  
  57. end if
  58.  
  59.  
  60. putchar:
  61. ; in: al=character
  62.         mov     ah, 0Eh
  63.         mov     bh, 0
  64.         int     10h
  65.         ret
  66.  
  67. printplain:
  68. ; in: si->string
  69.         pushad
  70.         lodsb
  71. @@:
  72.         call    putchar
  73.         lodsb
  74.         test    al, al
  75.         jnz     @b
  76.         mov     al, 13
  77.         call    putchar
  78.  
  79.         mov     al, 10
  80.         call    putchar
  81.         popad
  82.         ret
  83. getkey:
  84. ; get number in range [bl,bh] (bl,bh in ['0'..'9'])
  85. ; in: bx=range
  86. ; out: ax=digit (1..9, 10 for 0)
  87.         mov     ah, 0
  88.         int     16h
  89.         cmp     al, bl
  90.         jb      getkey
  91.         cmp     al, bh
  92.         ja      getkey
  93.         push    ax
  94.         call    putchar
  95.         pop     ax
  96.         and     ax, 0Fh
  97.         jnz     @f
  98.         mov     al, 10
  99. @@:
  100.         ret
  101.  
  102. ;setcursor:
  103. ; in: dl=column, dh=row
  104. ;        mov     ah, 2
  105. ;        mov     bh, 0
  106. ;        int     10h
  107. ;        ret
  108.  
  109. ;macro _setcursor row,column
  110. ;{
  111. ;        mov     dx, row*256 + column
  112. ;        call    setcursor
  113. ;}
  114.  
  115. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  116. ;
  117. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  118. get_firs_sym:
  119. .start:
  120.         mov     al, byte [es:di]
  121.         inc     di
  122.         dec     cx
  123.         jcxz    .exit
  124.  
  125.         cmp     al, 0xa         ;cmp al,0xa
  126.         jz      ._entry
  127.  
  128.         cmp     al, ';'
  129.         jnz     .start
  130.  
  131. .first_com:
  132.  
  133.         mov     al, 0xa
  134.         repnz scasb
  135.         jcxz    .exit
  136. ._entry:
  137.         mov     al, byte [es:di]
  138. .first_sp:
  139.         cmp     al, ' '
  140.         jnz     .not_space
  141.  
  142. ;       mov     al,' '          ;cut ' '
  143.         repe scasb
  144.         dec     di
  145.         inc     cx
  146.         mov     al, byte [es:di]
  147. .not_space:
  148.         cmp     al, ';'
  149.         jz      .first_com
  150. .exit:
  151.         ret
  152. ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  153. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  154. show_name_section:
  155.         push    si
  156.         push    ini_data_
  157.         pop     es
  158.  
  159.  
  160.         mov     al, ']'
  161.         repnz scasb
  162.         test    cx, cx
  163.         jz      error.incorect_section_def
  164. .find_val_name_fb1:
  165.         mov     al, 'n'
  166. .find_val_name_fb:
  167.         repnz scasb
  168.         jcxz    .not_name_sec_fb
  169.  
  170.         mov     si, parse_name
  171.  
  172.         push    cx
  173.         push    di
  174.  
  175.         mov     cx, parse_name_e -parse_name
  176.         repe cmpsb
  177.         pop     di
  178.         pop     cx
  179.         jz      .yaaa_find_value
  180.  
  181.  
  182.         jmp     .find_val_name_fb
  183.  
  184. .yaaa_find_value:
  185.         sub     cx, parse_name_e -parse_name
  186.         add     di, parse_name_e -parse_name
  187.  
  188.         mov     ax, 0x3d20         ; ah='='
  189.         repe scasb
  190.         test    cx, cx
  191.         jz      .not_name_sec_fb
  192.  
  193.         cmp     ah, byte [es:di-1]   ;find '='
  194.         jnz     .find_val_name_fb1
  195.        
  196.         repe scasb                 ;cut ' '
  197.         inc     cx
  198.         dec     di
  199.  
  200.  
  201. ;âñå âûðåçàëè è âñå ãîòîâî äëÿ âûâîäà èìåíè ñåêöèè ))
  202.         push    es
  203.         pop     ds
  204.  
  205. .def_sect_name:
  206.         push    0xb800
  207.         pop     es
  208. ;clear array for message
  209.         xor     ax, ax
  210. if DEBUG
  211.         mov     ax, 0x0720
  212. end if
  213.  
  214.         mov     cx, 39
  215.         mov     si, di
  216.         mov     di, dx
  217.         sub     di, 2
  218.         rep stosw
  219. ;//////////////////////
  220.  
  221.  
  222.         mov     di, dx
  223.         mov     ah, color_sym_white;color_sym_lightblue
  224.         mov     cx, 36
  225.         lodsb
  226.         sub     di, 2
  227.         cmp     al, '"'
  228.         jz      @f
  229.         cmp     al, "'"
  230.         jnz     .end_sh_name_sec
  231. @@:
  232.         lodsb
  233. @@:
  234.         stosw
  235.         lodsb
  236.         cmp     al, '"'
  237.         jz      .end_sh_name_sec
  238.         cmp     al, "'"
  239.         jz      .end_sh_name_sec
  240.         loop    @b
  241.        
  242.         mov     al, '}'
  243.         mov     ah, color_sym_yellow
  244.         stosw
  245. .end_sh_name_sec:
  246.         push    cs
  247.         pop     ds
  248.  
  249.         pop     si
  250.         ret
  251.  
  252. .not_name_sec_fb:    ;íåò èìåíè â íàçâàíèè ñåêöèè - çíà÷èò òàê è ñêàæåì îá ýòîì
  253.         push    cs
  254.         pop     ds
  255.         mov     di, default_section_name
  256.         jmp     .def_sect_name
  257.  
  258. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  259. ;ïðîöåäóðà ïîèñêà ââåðõ ñëåäóþùåé ñåêöèè
  260. ;â point_default ñîäåðæèòüñÿ óêàçàòåëü íà äåôàóëò ñåêöèþ, è â ïðåäåëàõ âðåéìà ìû áåãàåì ïî çàðàíåå ïðîïàðñåíûìè çíà÷åíèÿì óêàçàòåëåé
  261. ;äëÿ òîãî ÷òî áû îòîáðàçèòü è ïðîïàðñèòü ñëåäóþùèé ôðåéì, íàì íóæíî ïîëó÷èòü çà ïåðäûäóùèé èëè ñëåäóþùèé óêàçàòåëü
  262. find_before_sect:
  263.         mov     di, point_default
  264. .e:
  265.         push    ini_data_
  266.         pop     es
  267.         mov     cx, di  ;ïðåäïîëîæèì áóäåì ïðîñìàòðèâàòü ê íà÷àëó, òåêóùàÿ ïîçèöèÿ di = ñêîëüêî ñèìâîëîâ îò íà÷àëà äîêóìåíòà èìååòñÿ
  268.         mov     bx, cx  ;êîïèÿ
  269.  
  270. ;íàñòðîèëè óêàçàòåëü íà äåôàóëò ñåêöèþ
  271. ;áóäåì èñêàòü ââåðõ
  272. .find_start_section:
  273.         std     ;óñòàíîâêà ôëàãà íàïðàâëåíèÿ - áóäåì ïðîñìàòèðâàòü ê íà÷àëó íàøåãî èíè ôàéëà
  274. ;áóäåì èñêàòü íà÷àëî ñåêöèè ò.å. '[' ýòîò ñèìâîë
  275.         mov     al, 0xa
  276.         repnz scasb     ;ïðîñêàíèðóåì íà íàëè÷åå ñèìâîëà íà÷àëà ñåêöèè
  277.         jcxz    .go_    ;ìû ïðîñìîòðåëè äî íà÷àëà ôàéëà, íî òàê è íè÷åãî íå íàøëè ;(( ïî òèõîìó âûéäåì )
  278.  
  279.         mov     find_sec_di, di ;ñîõðàíèì äàííûå
  280.         mov     cx, di ;
  281.  
  282.         sub     bx, cx
  283.         mov     cx, bx  ;â ñx çíà÷åíèå - êîë-âî ñèìâîëîâ
  284.         cld
  285.         call    get_firs_sym
  286. .ret_go:
  287.         jcxz    ._not_section   ; â äàííîì ñëó÷àå èìååì êîíñòðóêöèþ 0xa ... ; hello [ñåêöèÿ] îáëîìñ èùåì äàëåå
  288.  
  289.         cmp     di, point_loader; ñåêöèþ loader ìû íå çàíîñèì èíà÷å êðàõ
  290.         jz      ._not_section
  291. ;âñå óäà÷íî ìû íàøëè âõîæäåíèå ñåêöèè ïðåäûäóùåé
  292.         cmp     al, '['
  293.         jnz     ._not_section
  294.         mov     point_default, di
  295. .exit_scan_sect:
  296.         ret
  297. ;;;;;;;; âîññòàíîâèì çíà÷åíèÿ è ïðîäîëæèì ïîèñêè íà÷àëà ñåêöèè êîòîðàÿ íàñ óñòðîèò ))
  298. ._not_section:
  299.         mov     di, find_sec_di
  300.         mov     cx, di
  301.         mov     bx, cx
  302.         jmp     .find_start_section
  303. .go_:
  304.         cld
  305.         mov     cx, bx  ;â ñx çíà÷åíèå - êîë-âî ñèìâîëîâ
  306.  
  307.         mov     al, byte [es:di]
  308.         push    word .f_go
  309.         cmp     al, ' '
  310.         jz      @f
  311.         jmp     get_firs_sym.not_space
  312. @@:
  313.         jmp     get_firs_sym.first_sp
  314.  
  315. .f_go:
  316.         jcxz    .exit_scan_sect ; â äàííîì ñëó÷àå èìååì êîíñòðóêöèþ 0xa ... ; hello [ñåêöèÿ] îáëîìñ èùåì äàëåå
  317.  
  318.         cmp     di, point_loader; ñåêöèþ loader ìû íå çàíîñèì èíà÷å êðàõ
  319.         jz      .exit_scan_sect
  320. ;âñå óäà÷íî ìû íàøëè âõîæäåíèå ñåêöèè ïðåäûäóùåé
  321.         cmp     al, '['
  322.         jnz     .exit_scan_sect
  323.         mov     point_default, di
  324.         ret
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  333. ;
  334. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  335. find_next_sect:
  336.         mov     di, point_default
  337.         push    ini_data_
  338.         pop     es
  339.         mov     cx, save_cx;di   ;ïðåäïîëîæèì áóäåì ïðîñìàòðèâàòü ê êîíöó, òåêóùàÿ ïîçèöèÿ di = ñêîëüêî ñèìâîëîâ îò íà÷àëà äîêóìåíòà èìååòñÿ
  340.         sub     cx, di  ;ñåé÷àñ â cx îñòàòîê ò.å.  ñêîëüêî ìîæíî êðóòèòü äî êîíöà è íå âûëàçèòü íà íà÷àëî
  341.         jmp     .let_s_go
  342. .h:
  343.         push    ini_data_
  344.         pop     es
  345.         mov     cx, save_cx;di   ;ïðåäïîëîæèì áóäåì ïðîñìàòðèâàòü ê êîíöó, òåêóùàÿ ïîçèöèÿ di = ñêîëüêî ñèìâîëîâ îò íà÷àëà äîêóìåíòà èìååòñÿ
  346. ;       sub     cx,di   ;ñåé÷àñ â cx îñòàòîê ò.å.  ñêîëüêî ìîæíî êðóòèòü äî êîíöà è íå âûëàçèòü íà íà÷àëî
  347.  
  348.         mov     al, byte [es:di]
  349.         push    word .let_s_go_ret
  350.         cmp     al, ' '
  351.         jz      @f
  352.         jmp     get_firs_sym.not_space
  353. @@:
  354.         jmp     get_firs_sym.first_sp
  355.  
  356.  
  357.  
  358.  
  359. ;íàñòðîèëè óêàçàòåëü íà äåôàóëò ñåêöèþ
  360. ;áóäåì èñêàòü âíèç
  361. .let_s_go:
  362.         call    get_firs_sym
  363. .let_s_go_ret:
  364.         jcxz    .exit_scan_sect ; â äàííîì ñëó÷àå èìååì êîíñòðóêöèþ 0xa ... ; hello [ñåêöèÿ] îáëîìñ èùåì äàëåå
  365.         cmp     al, '['
  366.         jnz     .let_s_go
  367.         cmp     di, point_loader
  368.         jz      .let_s_go
  369. ;âñå óäà÷íî ìû íàøëè âõîæäåíèå ñåêöèè ïðåäûäóùåé
  370.         mov     point_default, di
  371. .exit_scan_sect:
  372.         ret
  373.  
  374. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  375. ;clean old cursor
  376. clean_active_cursor:
  377. ;íå èçìåíÿåò çíà÷åíèå ax
  378. ;îòîáðàæåíèå êóðñîðà ïî óìîë÷àíèþ
  379.         lea     si, point_to_hframe
  380.         mov     di, 962-160
  381.         mov     dx, point_default
  382.         mov     cx, 18
  383. .clean_show_cur:
  384.         mov     bx, [si]
  385.         add     di, 160
  386.         cmp     bx, dx
  387.         jz      .clean_cursor_
  388.         sub     si, 2
  389.         loop    .clean_show_cur
  390.  
  391. ;       jmp $
  392.  
  393. .clean_cursor_:
  394.         push    0xb800
  395.         pop     es
  396.         push    ax
  397.         mov     point_to_point_def, si
  398.         xor     ax, ax
  399. if DEBUG
  400.         mov     ax, 0x0720
  401. end if
  402.         stosw
  403.         add     di, 68
  404.         stosw
  405.         pop     ax
  406.         ret
  407. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  408. ;óñòàíîâêà òàéìåðà è îòîáðàæåíèå ñ÷åò÷èêà âðåìåíè
  409. gettime:
  410.         mov     ah, 0
  411.         int     1Ah
  412.         xchg    ax, cx
  413.         shl     eax, 10h
  414.         xchg    ax, dx
  415.         ret
  416. newtimer:
  417.         push    ds
  418.  
  419.         push    cs
  420.         pop     ds
  421.  
  422.         pushf
  423.         call    far dword [old_timer]
  424.  
  425.         pushad
  426.         call    gettime
  427.  
  428.         sub     eax, dword[start_timer]
  429.         mov     bx, word [value_timeout]
  430.         imul    bx, 18
  431.         sub     bx, ax
  432.         jbe     .timergo
  433.  
  434.         push    es
  435.  
  436.         push    0xb800
  437.         pop     es
  438.         mov     ax, bx
  439.  
  440.         mov     bx, 18
  441.         xor     dx, dx
  442.         div     bx
  443.  
  444.         mov     bx, 10
  445.         mov     di, 3734
  446.         call    .decode
  447.  
  448.         xor     ax, ax
  449.         stosw
  450.  
  451. ; wait 5/4/3/2 seconds, 1 second
  452.         pop     es
  453.         popad
  454.         pop     ds
  455.  
  456.         iret
  457. .timergo:
  458.         push    0
  459.         pop     es
  460.         mov     eax, dword [old_timer]
  461.         mov     [es:8*4], eax
  462.         mov     dword [timer_], eax
  463.         mov     sp, word [start_stack]
  464.         mov     bp, word [save_bp_from_timer]
  465. ;;íå âîññòàíîâëåíûé ñòåê :(
  466.         sti
  467.         jmp     parse_start.parse_run_only
  468.  
  469.  
  470. .decode:
  471. ;input ax - ÷èñëî, es:di êóäà ïèñàòü, bx=10
  472.         cmp     ax, bx
  473.         jb      @f
  474.         xor     dx, dx
  475.         div     bx
  476.         push    dx
  477.         call    .decode
  478.         pop     ax
  479.     @@:
  480.         or      al, 0x30
  481.         push    ax
  482.         mov     ah, 9
  483.         stosw
  484.         pop     ax
  485.         ret
  486.  
  487. show_bl_sc_sect:
  488. ;1) îòîáðàæåíèå ñïèñêà ñåêöèé. Åñëè ñåêöèÿ íå èìåò èìÿ - îøèáêà - âûâîä Section unname
  489. ;ïðîâåðêà íà íàëè÷åå èìåíè.
  490. ;âõîäíûå äàííûå es:di -óêàçàòåëü íà ñåêöèþ - cx ðàçìåð ñåêöèè
  491. ;       push    bp
  492.         mov     bx, point_to_eframe
  493.         lea     si, point_to_hframe
  494.         mov     dx, 966
  495.  
  496. .home_show_fb:
  497.         cmp     si, bx
  498.         jb      ._show_space_fb
  499.         mov     di, [si]
  500.         sub     si, 2
  501.         mov     cx, [si]
  502.         sub     cx, di          ;home first section it's end before section
  503.         call    show_name_section
  504.         add     dx, 160
  505.         jmp     .home_show_fb
  506. ._show_space_fb:
  507.         sub     dx, 4
  508.         push    0xb800
  509.         pop     es
  510. @@:
  511.         cmp     dx, 0xE64
  512.         ja      .exit_show_fb
  513.         mov     di, dx
  514. ;clear array for message
  515.         xor     ax, ax
  516. if DEBUG
  517.         mov     ax, 0x0720
  518. end if
  519.         mov     cx, 39
  520.         rep stosw
  521. ;//////////////////////
  522.  
  523.         add     dx, 160
  524.         jmp     @b
  525. .exit_show_fb:
  526. ;        pop    bp
  527.         ret
  528.  
  529.