0,0 → 1,683 |
; Copyright (c) 2009, <Lrz> |
; All rights reserved. |
; |
; Redistribution and use in source and binary forms, with or without |
; modification, are permitted provided that the following conditions are met: |
; * Redistributions of source code must retain the above copyright |
; notice, this list of conditions and the following disclaimer. |
; * Redistributions in binary form must reproduce the above copyright |
; notice, this list of conditions and the following disclaimer in the |
; documentation and/or other materials provided with the distribution. |
; * Neither the name of the <organization> nor the |
; names of its contributors may be used to endorse or promote products |
; derived from this software without specific prior written permission. |
; |
; THIS SOFTWARE IS PROVIDED BY Alexey Teplov aka <Lrz> ''AS IS'' AND ANY |
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY |
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
;***************************************************************************** |
|
;òóò ðàñïîëîãàåòñÿ ìîäóëü ñ ïîìîùüþ êîòîðîãî áóäóò ïàðñèòüñÿ âñå îñòàëüíûå ñåêöèè |
color_sym_black equ 0 |
color_sym_blue equ 1 |
color_sym_green equ 2 |
color_sym_turquoise equ 3 |
color_sym_red equ 4 |
|
color_sym_lightgray equ 7 |
|
color_sym_lightblue equ 9 |
color_sym_lettuce equ 10 |
color_sym_pink equ 12 |
color_sym_yellow equ 14 |
|
macro use_any_sec |
{ |
;óçíàåì ðàáîòó ïðåäûäóùåãî øàãà ò.å. ÷åìó = timeout, åñëè îí 0, òî âèçóàëüíàÿ ÷àñòü íå áóäåò îòîáðàæåíà íà äèñïëåå ñ âûáîðîì çàãðóçî÷íûõ ñåêöèé. |
;èíà÷å ìû åå äîëæíû îòîáðàçèòü è æäàòü çàÿâëåíîå âðåìÿ äëÿ âûáîðà è êîíèãóðèðîâàíèÿ ïóêíêòîâ ñåêöèè îò ïîëüçîâàòåëÿ. |
|
if DEBUG |
pusha |
mov ax,word [value_timeout] ;èäåò ïðîâåðêà íà íàëè÷åå çíà÷åíèÿ timeout, äëÿ áîëåå áûñòðîé ðàáîòû, ýòîò ïàðàìåòð äîëæåí áûòü óæå îáðàáîòàí,ò.å. â ýòîì ñëó÷àå ïðè åãî =0 áóäåò ñôîðìèðîâàí óêàçàòåëü òîëüêî íà äåôîëòíóþ ñåêöèþ, èíà÷å èíôîðìàöèÿ áóäåò ñîáðàíà ïî âñåì ñåêöèÿì è ñîñòàâëåíû óêàçàòåëè â áëîêå ïàìÿòè |
; mov ax,cx |
mov cx,0x0a |
mov di,show_db1 |
mov dword[ds:di],' ' |
mov word [ds:di+4],' ' |
call decode |
;Show size |
mov si,show_db1 |
call printplain |
; |
popa |
end if |
|
test ax,ax |
jz .parse_run_only |
|
;îòîáðàçèì ïîëíûé ñïèñîê âñåõ íàéäåíûõ ñåêöèé. |
if DEBUG |
pusha |
mov si,show_all_sect |
call printplain |
popa |
end if |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
mov al, 0xf6 ; Ñáðîñ êëàâèàòóðû, ðàçðåøèòü ñêàíèðîâàíèå |
out 0x60, al |
xor cx, cx |
.wait_loop: ; variant 2 |
; reading state of port of 8042 controller |
in al, 64h |
and al, 00000010b ; ready flag |
; wait until 8042 controller is ready |
loopnz .wait_loop |
|
|
; set keyboard typematic rate & delay |
mov al, 0xf3 |
out 0x60, al |
xor cx, cx |
@@: |
in al, 64h |
test al, 2 |
loopnz @b |
mov al, 0 |
out 0x60, al |
xor cx, cx |
@@: |
in al, 64h |
test al, 2 |
loopnz @b |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; get start time |
call gettime |
mov dword [start_timer],eax |
mov word [timer_],newtimer |
mov word [timer_+2],cs |
;óñòàíîâèòü ñâîå ïðåðûâàíèå íà òàéìåð ò.å. êîä áóäåò ïåððûâàòüñÿ ~18 ðàç â ñåê è ïåðåõîäèòü íà îáðàáîò÷èê |
cli |
push 0 |
pop es |
push dword [es:8*4] |
pop dword [old_timer] |
push dword [timer_] |
pop dword [es:8*4] |
sti |
|
;ïðîöåäóðà ôîðìèðîâàíèÿ áóôåðà äëÿ ñêðîëèíãà ñåêöèé |
;if DEBUG |
; pusha |
; mov ax,point_default |
; mov ax,cx |
; mov cx,0x0a |
; mov di,show_db1 |
; mov dword[ds:di],' ' |
; mov word [ds:di+4],' ' |
; call decode |
;Show size |
; mov si,show_db1 |
; call printplain |
; |
; xor ax,ax |
; int 0x16 |
; popa |
;end if |
;;;;;;;;;;;;;ðàçìåð ïðåäûäóùåé ñåöèè óñòàíîâèì =0 |
mov save_descript_size,18 |
;îòîáðàçèòü black screen |
show_bl_sc ;es=0xb800 |
.show_all_scr: |
get_frame_buffer ;es=0x2000 |
;îòîáðàæåíèå ñåêöèé |
call show_bl_sc_sect ;es=0xb800 |
;îòîáðàçèòü àêòèâíûé êóðñîð |
.show_active_cursor: |
show_act_cursor |
show_descript ;ìàêðîñ ïî îòîáðàæåíèþ îïèñàíèÿ ñåêöèè |
|
;îòîáðàçèòü Press any key .... |
mov eax,dword [old_timer] |
cmp eax,dword [timer_] |
jz .interrupt_16 |
|
show_timer_message |
mov word [start_stack],sp |
.interrupt_16: |
xor ax,ax ;ïîëó÷èì èíôîðìàöèþ î òîì ÷òî íàæàòî |
int 0x16 |
;check on change |
mov ebx,dword [old_timer] |
cmp ebx,dword [timer_] |
jz @f |
;restore timer interrupt |
cli |
push 0 |
pop es |
; mov eax,dword [old_timer] ; âîññòàíîâèì ïðåæäíåå ïðåðûâàíèå |
mov [es:8*4],ebx |
mov dword [timer_],ebx |
sti |
|
push ax |
clear_timer_msg |
pop ax |
@@: |
call clean_active_cursor ;clean old cursor ;es=0xb800 |
|
cmp ah,0x48 ;ðåàêöèÿ ñèñòåìû íà ñîáûòèÿ |
jz .up |
cmp ah,0x50 |
jz .down |
cmp ah,0x49 |
jz .pgup |
cmp ah,0x51 |
jz .pgdown |
cmp ah,0x47 |
jz .home |
cmp ah,0x4f |
jz .end |
|
cmp al,0xD |
jnz .show_active_cursor |
|
jmp .end_show_all ;ïàðñèíã ñåêöèè êîòîðàÿ óêàçàíà â point_default |
.up: |
mov si,point_to_point_def ;çíà÷åíèå óêàçàòåëÿ |
add si,2 |
lea ax,point_to_hframe |
|
cmp si,ax |
ja @f |
|
mov point_to_point_def,si |
mov ax,[si] |
mov point_default,ax |
jmp .show_active_cursor |
@@: |
call find_before_sect |
jmp .show_all_scr |
|
|
|
.down: |
mov si,point_to_point_def ;çíà÷åíèå óêàçàòåëÿ |
mov ax,point_to_eframe ;óêàçàòåëü íà ïîñëåäíèé ýëåìåíò |
sub si,2 |
cmp si,ax |
jb @f |
|
mov point_to_point_def,si |
mov ax,[si] |
mov point_default,ax |
jmp .show_active_cursor |
|
@@: call find_next_sect |
jmp .show_all_scr |
|
.pgup: |
mov cx,size_show_section |
@@: |
push cx |
call find_before_sect |
pop cx |
loop @b |
jmp .show_all_scr |
|
|
.pgdown: |
mov cx,size_show_section |
@@: |
push cx |
call find_next_sect |
pop cx |
loop @b |
jmp .show_all_scr |
|
.home: |
xor di,di |
call find_next_sect.h |
jmp .show_all_scr |
|
.end: |
mov di,save_cx |
call find_before_sect.e |
jmp .show_all_scr |
|
|
|
|
; òóò ìû áóäåì ïàðñèòü òîëüêî äåôîëòíóþ ñåêöèþ è âûïîëíÿòü åå íè÷åãî íå ïðåäëàãàÿ ïîëüçîâàòåëþ èç äèàëîãîâ. |
.parse_run_only: |
if DEBUG |
pusha |
mov si,no_show_only_w |
call printplain |
popa |
end if |
|
|
.end_show_all: |
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;show black screen SL |
macro show_bl_sc |
{ |
;;;;;;;;;;;;;;; |
;î÷èñòèì ýêðàí è âûâåäåì ìåíþ |
; draw frames |
xor ax,ax |
if DEBUG |
mov ax,0x0720 |
end if |
push 0xb800 |
pop es |
xor di, di |
; draw top |
mov cx, 25 * 80 |
rep stosw |
;;;;;;;;;;;;;;;;;;;;;;; show 'Secondary Loader v0.xxx' |
mov di,164 |
mov si,version |
mov cx,version_end-version |
mov ah,color_sym_yellow |
@@: |
lodsb |
stosw |
loop @b |
;;;;;;;;;;;;;;;;;;;;;;; show firm )) |
mov di,286 |
mov ah,color_sym_pink;color_sym_red |
mov al,'K' |
stosw |
mov al,' ' |
stosw |
mov ah,color_sym_lightgray;color_sym_lightblue;color_sym_pink |
mov si,soft_mes |
mov cx,soft_mes_end- soft_mes |
@@: |
lodsb |
stosw |
loop @b |
;;;;;;;;;;;;;;;;;;;;;;; show '__________________________' |
mov di,480 |
mov ah,color_sym_yellow |
mov al,'Ä' |
mov cx,61 |
rep stosw |
;;;;;;;;;;;;;;;;;;;;;;; show 'Select section' |
mov di,804 |
mov si,select_section |
mov cx,select_section_end - select_section |
mov ah,color_sym_lightgray |
@@: |
lodsb |
stosw |
loop @b |
;;;;;;;;;;;;;;;;;;;;;;; show 'Section description' |
mov di,880 |
mov si,section_description |
mov cx,section_description_end - section_description |
; mov ah,color_sym_lightgray |
@@: |
lodsb |
stosw |
loop @b |
|
} |
|
macro show_timer_message |
{ |
;;;;;;;;;;;;;;;;;;;;; show Press any key |
;;;;;;;;;;;;;;;;;;;;; show ramk |
|
xor ax,ax |
mov di,3360 |
mov cx,80*4 |
rep stosw |
|
mov di,3362 |
mov ah,color_sym_pink |
mov al,0xDA |
stosw |
mov al,0xc4 |
mov cx,76 |
rep stosw |
mov al,0xBF |
stosw |
add di,4 |
mov al,0xb3 |
stosw |
add di,152 |
stosw |
add di,4 |
stosw |
add di,152 |
stosw |
add di,4 |
mov al,0xc0 |
stosw |
mov al,0xc4 |
mov cx,76 |
rep stosw |
mov al,0xd9 |
stosw |
;;;;;;;;;;;;;;;;;;;;;;;;ramk is complete show |
;show first message |
mov si,start_msg |
mov cx,start_msg_e-start_msg |
mov di,3526 |
@@: |
lodsb |
stosw |
loop @b |
;;;;;;;;;;;;;;;;;;;; show press Enter to.... |
add di,44 |
mov si,time_msg |
mov cx,time_msg_e-time_msg |
@@: |
lodsb |
stosw |
loop @b |
} |
|
|
|
|
|
|
|
|
macro get_frame_buffer |
{ |
mov cx,save_cx ;it's placed size of ini file |
les di,dword [file_data] |
|
mov si,di ;point frame |
mov bx,cx |
mov dx,size_show_section |
; mov point_to_hframe,di ; âíåñåì çíà÷åíèå, òàê ïîäñòðàõîâêà íå áîëåå |
|
mov al,byte [es:di] |
push word .first_ret_bl_sc |
cmp al,' ' |
jz .first_bl_sc |
jmp get_firs_sym.not_space |
.first_bl_sc: |
jmp get_firs_sym.first_sp |
|
.start_hbl: |
call get_firs_sym ;get first symbol on new line |
test cx,cx |
jz error.correct_exit_bl ;critical error not found default point it's not possible because it's param chacking before |
cmp al,'[' |
jnz .start_hbl |
|
mov si,di ;point frame |
mov bx,cx |
mov dx,size_show_section |
jmp .analisist_al |
|
|
.start_bl: |
call get_firs_sym ;get first symbol on new line |
.first_ret_bl_sc: ;ïåðâûé âîçâðàò |
test cx,cx |
jz error.correct_exit_bl ;critical error not found default point it's not possible because it's param chacking before |
.analisist_al: |
cmp al,'[' |
jnz .start_bl |
;ïðîñìàòðèâàåì ini ôàéë ñ íà÷àëà â ïîèñêàõ ñåêöèè óêàçàíîé êàê default |
;ïîèñê ôðåéìà â êîòîðîì ñîäåðæèòüñÿ çíà÷åíèå default |
.found_sect_bl: |
cmp di,point_loader |
jz .start_bl |
cmp di,point_default |
jz .save_point_def |
|
dec dx |
jnz .start_bl |
|
jmp .start_hbl |
|
|
.save_point_def: |
;èòàê äàëåå ìû äîëæíû çàïîëíèòü frame áóôåð àäðåñîâ ñåêöèé, ÷òî áû ïîòîì ïî íåìó áûñòðî ïåðåìåùàòüñÿ íå âû÷èñëÿÿ ñíîâà àäðåñà |
mov di,si ;óêàçàòåëü íà íà÷àëî |
mov cx,bx |
lea si,point_to_hframe |
mov dx,size_show_section+1 ;ò.ê. ó íàñ ñòðóêòóðà ñîäåðæèò ðàçìåð ìåæäó ïåðâûì è âòîðûì óêàçàòåëåì, òî íàì íóæíî íà 1 àäðåñ áîëüøå îáñ÷èòàòü ñåêöèé. |
;ïåðåõîäèì íà îáðàáîòêó çíà÷åíèÿ óêàçàòåëÿ |
mov al,byte [es:di] |
push word .first_ret_mfb |
cmp al,' ' |
jz .first_bl_mbf |
jmp get_firs_sym.not_space |
.first_bl_mbf: |
jmp get_firs_sym.first_sp |
|
.start_mfb: |
call get_firs_sym ;get first symbol on new line |
.first_ret_mfb: ;ïåðâûé âîçâðàò |
jcxz .val_buff_comp ;.end_loader ;found or not found parametrs in section exit in section |
cmp al,'[' |
jnz .start_mfb |
|
.found_sect_mfb: |
cmp di,point_loader ;if we have section loader |
jz .start_mfb |
|
mov [si],di |
|
sub si,2 |
dec dx |
jnz .start_mfb |
;bufer is full |
jmp @f |
.val_buff_comp: |
push save_cx |
pop word [si] |
sub si,2 |
@@: |
|
add si,4 |
mov point_to_eframe,si |
|
} |
|
macro show_act_cursor |
{ |
;îòîáðàæåíèå êóðñîðà ïî óìîë÷àíèþ |
lea si,point_to_hframe |
mov di,962-160 |
mov ax,point_default |
mov cx,size_show_section |
.home_show_cur: |
mov bx,[si] |
add di,160 |
cmp bx,ax |
jz .show_cursor_activ |
sub si,2 |
loop .home_show_cur |
|
.show_cursor_activ: |
; push 0xb800 |
; pop es |
mov point_to_point_def,si |
mov ax,(color_sym_red*0x100+0x10) |
stosw |
add di,68 |
inc ax |
stosw |
} |
|
macro clear_timer_msg |
{ |
push 0xb800 |
pop es |
xor ax,ax |
if DEBUG |
mov ax,0x0720 |
end if |
;;;;;;;;;;;;;;;;;;;;; show Press any key |
mov di,3360 |
mov cx,80*4 |
rep stosw |
|
;show sect |
push ini_data_ |
pop es |
call show_bl_sc_sect ;es=0xb800 |
|
} |
|
macro show_descript |
;Ýòîò ìàêðîñ ïîêàçûâàåò êðàòêîå îïèñàíèå, åñëè îíî åñòü ó ñåêöèè â ïóíêòå |
;Section description |
{ |
local .start_p_sh_d |
local .exit |
local .rest_value_loop_sh_d |
local .end_sh_desc_sec |
local .loop_message |
local .show_mess_prev_eq |
mov di,point_default |
push ini_data_ |
mov si,point_to_point_def |
pop es |
sub si,2 |
mov cx,[si] ;çàãðóçèì óêàçàòåëü íàñëåäóþùèþ ñåêöèþ |
sub cx,di ;âîò òåïåðü èìååì èñòèíûé ðàçìåð |
;di - óêàçàòåëü íà äåôîëòíóþ ñåêöèþ ò.å. âûáðàííóþ cx - ðàçìåð îáëàñòè. äëÿ ïðîñìîòðà |
|
.start_p_sh_d: |
call get_firs_sym ;get first symbol on new line |
test cx,cx |
jz .exit ;íåòó? íó ëàäíî - ñëåäóþùåå çíà÷åíèå òîãäà ) |
cmp al,'d' |
jnz .start_p_sh_d |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
mov bx,cx |
mov ax,di |
|
mov si,parse_descript |
mov cx,parse_descript_e - parse_descript |
repe cmpsb |
jnz .rest_value_loop_sh_d ;is not compare |
|
sub bx,parse_descript_e - parse_descript ;correct cx |
add bx,cx |
mov cx,bx |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ðàçáîð àëÿ ' = ' |
mov ax,0x3d20 ;cut al=' ' ah='=' |
repe scasb |
jcxz .rest_value_loop_sh_d ;not found param timeout |
|
cmp ah,byte [es:di-1] ;find '=' |
jnz .rest_value_loop_sh_d |
|
repe scasb ;cut ' ' |
inc cx |
dec di |
;;;;;;;;;;;;;;;;;;;;di óêàçûâàåò íà ñòðî÷êó, êîòîðóþ íàì íóæíî âûâîäèòü. |
;ñòðî÷êà áóäåò âûâîäèòüñÿ áëîêàìè ïî 37 ñèìâîëîâ. |
;íàñòðîèì êóäà áóäåì âûâîäèòü ò.å. íà÷àëî |
;es:di - óêàçûâàþò íà ñòðî÷êó èç êîòîðîé ìû áåðåì ñèìâîë, ds:si êóäà áóäåì âûâîäèòü |
push di |
pop si |
|
push es |
pop ds |
|
push 0xb800 |
pop es |
|
mov di,1040 |
mov bx,18 |
mov find_sec_di,di |
mov save_cx_d,bx |
;;;;;;;;;;;;;;;;;;;;;;;;;; |
;clean string |
|
push di |
xor ax,ax |
|
@@: mov cx,38 |
push di |
rep stosw |
pop di |
|
cmp save_descript_size,bx |
jz @f |
|
|
add di,160 |
dec bx |
jnz @b |
|
@@: pop di |
;enter in mess |
.show_mess_prev_eq: |
lodsb |
mov ah,color_sym_lettuce;color_sym_turquoise |
; sub di,2 |
cmp al,'"' |
jz .loop_message |
cmp al,"'" |
jnz .end_sh_desc_sec |
|
.loop_message: |
mov cx,38 |
@@: |
lodsb |
cmp al,'"' |
jz .end_sh_desc_sec |
cmp al,"'" |
jz .end_sh_desc_sec |
stosw |
loop @b |
|
add find_sec_di,160 |
mov di,find_sec_di |
dec save_cx_d |
cmp save_cx_d,0 |
jnz .loop_message |
|
.end_sh_desc_sec: |
push save_cx_d |
pop save_descript_size |
|
push cs |
pop ds |
jmp .exit |
|
|
.rest_value_loop_sh_d: |
mov di,ax |
mov cx,bx |
jmp .start_p_sh_d |
|
.exit: |
} |