blue screen removal: some bugs fixed

git-svn-id: svn://kolibrios.org@1703 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Artem Jerdev (art_zh) 2010-11-15 23:04:33 +00:00
parent c5737c5fed
commit 57b74ef78d
3 changed files with 310 additions and 966 deletions

View File

@ -47,24 +47,6 @@ printplain:
popa popa
ret ret
getkey:
;get number in range [bl,bh] (bl,bh in ['0'..'9'])
; in: bx=range
; out: ax=digit (1..9, 10 for 0)
mov ah, 0
int 16h
cmp al, bl
jb getkey
cmp al, bh
ja getkey
push ax
call putchar
pop ax
and ax, 0Fh
jnz @f
mov al, 10
@@:
ret
setcursor: setcursor:
; in: dl=column, dh=row ; in: dl=column, dh=row
@ -90,15 +72,20 @@ boot_read_floppy:
jnc @f jnc @f
inc si inc si
cmp si, 10 cmp si, 10
jb @b jnb $
mov si, badsect
sayerr_plain:
call printplain
jmp $
@@: @@:
pop si pop si
ret ret
sayerr_plain:
call printplain
jmp $
sayerr:
call print
jmp $
; convert abs. sector number (AX) to BIOS T:H:S ; convert abs. sector number (AX) to BIOS T:H:S
; sector number = (abs.sector%BPB_SecPerTrk)+1 ; sector number = (abs.sector%BPB_SecPerTrk)+1
; pre.track number = (abs.sector/BPB_SecPerTrk) ; pre.track number = (abs.sector/BPB_SecPerTrk)
@ -209,20 +196,16 @@ dfl1:
; draw bottom ; draw bottom
mov si, d80x25_bottom mov si, d80x25_bottom
mov cx, d80x25_bottom_num * 80 mov cx, d80x25_bottom_num * 80
;@@: @@:
; lodsb lodsb
; stoswvmode stosw
; loop @b loop @b
mov byte [space_msg+80], 0 ; now space_msg is null terminated mov byte [space_msg+80], 0 ; now space_msg is null terminated
_setcursor d80x25_top_num,0 _setcursor d80x25_top_num,0
cpugood:
sayerr:
call print
jmp $
cpugood:
push 0 push 0
popf popf
@ -336,7 +319,7 @@ cfgmanager:
; d) preboot_device = from what boot? ; d) preboot_device = from what boot?
; determine default settings ; determine default settings
mov [.bSettingsChanged], 0 ; mov [.bSettingsChanged], 0
;.preboot_gr_end: ;.preboot_gr_end:
mov di, preboot_device mov di, preboot_device
@ -360,287 +343,13 @@ cfgmanager:
adc byte [di+preboot_dma-preboot_device], 0 adc byte [di+preboot_dma-preboot_device], 0
cmp byte [di+preboot_biosdisk-preboot_device], 1 cmp byte [di+preboot_biosdisk-preboot_device], 1
adc byte [di+preboot_biosdisk-preboot_device], 0 adc byte [di+preboot_biosdisk-preboot_device], 0
; default value for VRR is OFF
cmp byte [di+preboot_vrrm-preboot_device], 0
jnz @f
mov byte [di+preboot_vrrm-preboot_device], 2
@@:
; notify user
_setcursor 5,2
mov si, linef
call printplain
mov si, start_msg
call print
mov si, time_msg
call print
; get start time
call .gettime
mov [.starttime], eax
mov word [.timer], .newtimer
mov word [.timer+2], cs
.printcfg:
_setcursor 9,0
mov si, current_cfg_msg
call print
mov si, curvideo_msg
call print
;<< call draw_current_vmode
mov si, usebd_msg
cmp [preboot_biosdisk], 1
call .say_on_off
mov si, vrrm_msg
cmp [preboot_vrrm], 1
call .say_on_off
mov si, preboot_device_msg
call print
mov al, [preboot_device]
and eax, 7
mov si, [preboot_device_msgs+eax*2]
call printplain
.show_remarks:
; show remarks in gray color
mov di, ((21-num_remarks)*80 + 2)*2
push 0xB800
pop es
mov cx, num_remarks
mov si, remarks
.write_remarks:
lodsw
push si
xchg ax, si
mov ah, 1*16+7 ; background: blue (1), foreground: gray (7)
push di
.write_remark:
lodsb
test al, al
jz @f
stosw
jmp .write_remark
@@:
pop di
pop si
add di, 80*2
loop .write_remarks
.wait:
_setcursor 25,0 ; out of screen
; set timer interrupt handler
cli
push 0
pop es
push dword [es:8*4]
pop dword [.oldtimer]
push dword [.timer]
pop dword [es:8*4]
sti
; wait for keypressed
xor ax,ax
int 16h
push ax
; restore timer interrupt
mov eax, [.oldtimer]
mov [es:8*4], eax
mov [.timer], eax
_setcursor 7,0 _setcursor 7,0
mov si, space_msg mov si, space_msg
call printplain call printplain
; clear remarks and restore normal attributes ; pop ax ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ??
push es jmp .continue
mov di, ((21-num_remarks)*80 + 2)*2
push 0xB800
pop es
mov cx, num_remarks
mov ax, ' ' + (1*16 + 15)*100h
@@:
push cx
mov cx, 76
rep stosw
pop cx
add di, 4*2
loop @b
pop es
pop ax
; switch on key
cmp al, 13
jz .continue
or al, 20h
cmp al, 'a'
jz .change_a
cmp al, 'b'
jz .change_b
cmp al, 'c'
jz .change_c
cmp al, 'd'
jnz .show_remarks
_setcursor 15,0
mov si, bdev
call print
mov bx, '14'
call getkey
mov [preboot_device], al
_setcursor 13,0
.d:
mov [.bSettingsChanged], 1
call clear_vmodes_table ;clear vmodes_table
jmp .printcfg
.change_a:
.loops:
call draw_vmodes_table
_setcursor 25,0 ; out of screen
xor ax,ax
int 0x16
mov si,word [cursor_pos]
cmp ah,0x48;x,0x48E0 ; up
jne .down
cmp si,modes_table
jbe .loops
sub word [cursor_pos],size_of_step
jmp .loops
.down: cmp ah,0x50;x,0x50E0 ; down
jne .pgup
cmp word[es:si+10],-1
je .loops
add word [cursor_pos],size_of_step
jmp .loops
.pgup: cmp ah,0x49 ; page up
jne .pgdn
sub si, size_of_step*long_v_table
cmp si, modes_table
jae @f
mov si, modes_table
@@:
mov word [cursor_pos], si
mov si, word [home_cursor]
sub si, size_of_step*long_v_table
cmp si, modes_table
jae @f
mov si, modes_table
@@:
mov word [home_cursor], si
jmp .loops
.pgdn: cmp ah,0x51 ; page down
jne .enter
mov ax, [end_cursor]
add si, size_of_step*long_v_table
cmp si, ax
jb @f
mov si, ax
sub si, size_of_step
@@:
mov word [cursor_pos], si
mov si, word [home_cursor]
sub ax, size_of_step*long_v_table
add si, size_of_step*long_v_table
cmp si, ax
jb @f
mov si, ax
@@:
mov word [home_cursor], si
jmp .loops
.enter: cmp al,0x0D;x,0x1C0D ; enter
jne .loops
push word [cursor_pos]
pop bp
push word [es:bp]
pop word [x_save]
push word [es:bp+2]
pop word [y_save]
push word [es:bp+6]
pop word [number_vm]
mov word [preboot_graph],bp ;save choose
jmp .d
.change_b:
_setcursor 15,0
mov si, ask_bd
call print
mov bx, '12'
call getkey
mov [preboot_biosdisk], al
_setcursor 11,0
jmp .d
.change_c:
_setcursor 15,0
mov si, vrrmprint
call print
mov bx, '12'
call getkey
mov [preboot_vrrm], al
_setcursor 12,0
jmp .d
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.say_on_off:
pushf
call print
mov si, on_msg
popf
jz @f
mov si, off_msg
@@: jmp printplain
; novesa and vervesa strings are not used at the moment of executing this code
virtual at novesa
.oldtimer dd ?
.starttime dd ?
.bSettingsChanged db ?
.timer dd ?
end virtual
.loader_block dd -1 .loader_block dd -1
.gettime:
mov ah, 0
int 1Ah
xchg ax, cx
shl eax, 10h
xchg ax, dx
ret
.newtimer:
push ds
push cs
pop ds
pushf
call [.oldtimer]
pushad
call .gettime
sub eax, [.starttime]
sub ax, 18*5
jae .timergo
neg ax
add ax, 18-1
mov bx, 18
xor dx, dx
div bx
; wait 5/4/3/2 seconds, 1 second
cmp al, 1
mov cl, 's'
ja @f
mov cl, ' '
@@: mov [time_str+9], cl
add al, '0'
mov [time_str+1], al
mov si, time_msg
_setcursor 7,0
call print
_setcursor 25,0
popad
pop ds
iret
.timergo:
push 0
pop es
mov eax, [.oldtimer]
mov [es:8*4], eax
mov sp, 0EC00h
.continue: .continue:
sti sti
_setcursor 6,0 _setcursor 6,0
@ -651,35 +360,8 @@ end virtual
mov si, loading_msg mov si, loading_msg
call print call print
_setcursor 15,0 _setcursor 15,0
cmp [.bSettingsChanged], 0 jmp .load
jz .load
cmp [.loader_block], -1
jz .load
les bx, [.loader_block]
mov eax, [es:bx+3]
push ds
pop es
test eax, eax
jz .load
push eax
mov si, save_quest
call print
.waityn:
mov ah, 0
int 16h
or al, 20h
cmp al, 'n'
jz .loadc
cmp al, 'y'
jnz .waityn
call putchar
mov byte [space_msg+80], 186
pop eax
push cs
push .cont
push eax
retf ;call back
.loadc: .loadc:
pop eax pop eax
.cont: .cont:
@ -691,7 +373,6 @@ end virtual
call printplain call printplain
_setcursor 15,0 _setcursor 15,0
.load: .load:
; \end{diamond}[02.12.2005]
; ASK GRAPHICS MODE ; ASK GRAPHICS MODE
@ -870,8 +551,8 @@ sayerr_floppy:
mov dx, 0x3f2 mov dx, 0x3f2
mov al, 0 mov al, 0
out dx, al out dx, al
mov si, memmovefailed ; mov si, memmovefailed
jmp sayerr_plain jmp $
@@: @@:
pop ax ; restore from stack count of words in boot+FAT pop ax ; restore from stack count of words in boot+FAT
shl ax, 1 ; make bytes count from count of words shl ax, 1 ; make bytes count from count of words
@ -1055,37 +736,11 @@ no_sys_on_floppy:
mov es, ax mov es, ax
mov bx, [es:0x9008] ; vga & 320x200 mov bx, [es:0x9008] ; vga & 320x200
; mov bx, ax
; cmp ax, 0x13
; je setgr
; cmp ax, 0x12
; je setgr
mov ax, 0x4f02 ; Vesa mov ax, 0x4f02 ; Vesa
setgr: setgr:
int 0x10 int 0x10
test ah, ah test ah, ah
mov si, fatalsel jnz $
jnz v_mode_error
; set mode 0x12 graphics registers:
; cmp bx, 0x12
; jne gmok2
; mov al, 0x05
; mov dx, 0x03ce
; push dx
; out dx, al ; select GDC mode register
; mov al, 0x02
; inc dx
; out dx, al ; set write mode 2
; mov al, 0x02
; mov dx, 0x03c4
; out dx, al ; select VGA sequencer map mask register
; mov al, 0x0f
; inc dx
; out dx, al ; set mask for all planes 0-3
; mov al, 0x08
; pop dx
; out dx, al ; select GDC bit mask register
; for writes to 0x03cf
gmok2: gmok2:
push ds push ds
pop es pop es

View File

@ -15,96 +15,52 @@ $Revision$
d80x25_bottom: d80x25_bottom:
db 186,' KolibriOS is based on MenuetOS and comes with ABSOLUTELY ' db 186,' KolibriOS is based on MenuetOS and comes with ABSOLUTELY '
db 'NO WARRANTY ',186 db 'NO WARRANTY ',186
db 186,' See file COPYING for details ' db 186,' See file COPYING for details '
db ' ',186 db ' ',186
line_full_bottom line_full_bottom
d80x25_bottom_num = 3 d80x25_bottom_num = 3
msg_apm db " APM x.x ", 0 msg_apm db " APM x.x ", 0
vervesa db "Version of Vesa: Vesa x.x",13,10,0 vervesa db "Version of Vesa: Vesa x.x",13,10,0
novesa db "Display: EGA/CGA",13,10,0 ;novesa db "Display: EGA/CGA",13,10,0
s_vesa db "Version of VESA: " s_vesa db "Version of VESA: "
.ver db "?.?",13,10,0 .ver db "?.?",13,10,0
gr_mode db "Select a videomode: ",13,10,0 ;gr_mode db "Select a videomode: ",13,10,0
;s_bpp db 13,10,186," ƒ«ã¡¨­  梥â : "
; .bpp dw "??"
; db 13,10,0
vrrmprint db "Apply VRR? (picture frequency greater than 60Hz" ;vrrmprint db "Apply VRR? (picture frequency greater than 60Hz"
db " only for transfers:",13,10 ; db " only for transfers:",13,10
db 186," 1024*768->800*600 and 800*600->640*480) [1-yes,2-no]:",0 ; db 186," 1024*768->800*600 and 800*600->640*480) [1-yes,2-no]:",0
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0 ;ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
bdev db "Load ramdisk from [1-floppy; 2-C:\kolibri.img (FAT32);" ;bdev db "Load ramdisk from [1-floppy; 2-C:\kolibri.img (FAT32);"
db 13,10,186," " ; db 13,10,186," "
db "3-use preloaded ram-image from kernel restart;" ; db "3-use preloaded ram-image from kernel restart;"
db 13,10,186," " ; db 13,10,186," "
db "4-create blank image]: ",0 ; db "4-create blank image]: ",0
probetext db 13,10,13,10,186," Use standart graphics mode? [1-yes, " ;probetext db 13,10,13,10,186," Use standart graphics mode? [1-yes, "
db "2-probe bios (Vesa 3.0)]: ",0 ; db "2-probe bios (Vesa 3.0)]: ",0
;memokz256 db 13,10,186," RAM 256 Mb",0 ;prnotfnd db "Fatal - Videomode not found.",0
;memokz128 db 13,10,186," RAM 128 Mb",0 ;btns db "Fatal - Can't determine color depth.",0
;memokz64 db 13,10,186," RAM 64 Mb",0 ;badsect db 13,10,186," Fatal - Bad sector. Replace floppy.",0
;memokz32 db 13,10,186," RAM 32 Mb",0 ;memmovefailed db 13,10,186," Fatal - Int 0x15 move failed.",0
;memokz16 db 13,10,186," RAM 16 Mb",0 okt db " ... OK"
prnotfnd db "Fatal - Videomode not found.",0 linef db 13,10,0
;modena db "Fatal - VBE 0x112+ required.",0 diskload db "Loading diskette: 00 %",8,8,8,8,0
not386 db "Fatal - CPU 386+ required.",0 pros db "00"
btns db "Fatal - Can't determine color depth.",0 backspace2 db 8,8,0
fatalsel db "Fatal - Graphics mode not supported by hardware.",0 boot_dev db 0 ; 0=floppy, 1=hd
pres_key db "Press any key to choose a new videomode.",0 ;start_msg db "Press [abcd] to change settings, press [Enter] to continue booting",13,10,0
badsect db 13,10,186," Fatal - Bad sector. Replace floppy.",0 ;time_msg db " or wait "
memmovefailed db 13,10,186," Fatal - Int 0x15 move failed.",0 ;time_str db " 5 seconds"
okt db " ... OK" ; db " before automatical continuation",13,10,0
linef db 13,10,0 ;current_cfg_msg db "cfgmanager.printcfg reached",13,10,0
diskload db "Loading diskette: 00 %",8,8,8,8,0 ;curvideo_msg db " [a] Videomode: ",0
pros db "00"
backspace2 db 8,8,0
boot_dev db 0 ; 0=floppy, 1=hd
start_msg db "Press [abcd] to change settings, press [Enter] to continue booting",13,10,0
time_msg db " or wait "
time_str db " 5 seconds"
db " before automatical continuation",13,10,0
current_cfg_msg db "Current settings:",13,10,0
curvideo_msg db " [a] Videomode: ",0
;modes_msg dw mode4,mode1,mode2,mode3 loading_msg db "Loading KolibriOS...",0
;modevesa20 db " with LFB",0 ;save_quest db "Remember current settings? [y/n]: ",0
;modevesa12 db ", VESA 1.2 Bnk",0 loader_block_error db "Invalid boot data",0
mode0 db "320x200, EGA/CGA 256 colors",13,10,0
mode9 db "640x480, VGA 16 colors",13,10,0
;probeno_msg db " (standard mode)",0
;probeok_msg db " (check nonstandard modes)",0
;dma_msg db " [b] Use DMA for HDD access:",0
usebd_msg db " [b] Add disks visible by BIOS:",0
on_msg db " on",13,10,0
off_msg db " off",13,10,0
;readonly_msg db " only for reading",13,10,0
vrrm_msg db " [c] Use VRR:",0
preboot_device_msg db " [d] Floppy image: ",0
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "real floppy",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "use already loaded image",13,10,0
pdm4 db "create blank image",13,10,0
loading_msg db "Loading KolibriOS...",0
save_quest db "Remember current settings? [y/n]: ",0
loader_block_error db "Bootloader data invalid, I cannot continue. Stopped.",0
_st db 186,' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿',13,10,0
_r1 db 186,' ³ 320x200 EGA/CGA 256 colors ³ ³',13,10,0
_r2 db 186,' ³ 640x480 VGA 16 colors ³ ³',13,10,0
_rs db 186,' ³ ????x????@?? SVGA VESA ³ ³',13,10,0
_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ',13,10,0
remark1 db "Default values were selected to match most of configurations, but not all.",0
remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0
remark3 db "If the system does not boot, try to disable the item [b].",0
remarks dw remark1, remark2, remark3
num_remarks = 3

View File

@ -8,69 +8,69 @@
$Revision$ $Revision$
struc VBE_VGAInfo { struc VBE_VGAInfo {
.VESASignature dd ? ; char .VESASignature dd ? ; char
.VESAVersion dw ? ; short .VESAVersion dw ? ; short
.OemStringPtr dd ? ; char * .OemStringPtr dd ? ; char *
.Capabilities dd ? ; ulong .Capabilities dd ? ; ulong
.VideoModePtr dd ? ; ulong .VideoModePtr dd ? ; ulong
.TotalMemory dw ? ; short .TotalMemory dw ? ; short
; VBE 2.0+ ; VBE 2.0+
.OemSoftwareRev db ? ; short .OemSoftwareRev db ? ; short
.OemVendorNamePtr dw ? ; char * .OemVendorNamePtr dw ? ; char *
.OemProductNamePtr dw ? ; char * .OemProductNamePtr dw ? ; char *
.OemProductRevPtr dw ? ; char * .OemProductRevPtr dw ? ; char *
.reserved rb 222 ; char .reserved rb 222 ; char
.OemData rb 256 ; char .OemData rb 256 ; char
} }
struc VBE_ModeInfo { struc VBE_ModeInfo {
.ModeAttributes dw ? ; short .ModeAttributes dw ? ; short
.WinAAttributes db ? ; char .WinAAttributes db ? ; char
.WinBAttributes db ? ; char .WinBAttributes db ? ; char
.WinGranularity dw ? ; short .WinGranularity dw ? ; short
.WinSize dw ? ; short .WinSize dw ? ; short
.WinASegment dw ? ; ushort .WinASegment dw ? ; ushort
.WinBSegment dw ? ; ushort .WinBSegment dw ? ; ushort
.WinFuncPtr dd ? ; void * .WinFuncPtr dd ? ; void *
.BytesPerScanLine dw ? ; short .BytesPerScanLine dw ? ; short
.XRes dw ? ; short .XRes dw ? ; short
.YRes dw ? ; short .YRes dw ? ; short
.XCharSize db ? ; char .XCharSize db ? ; char
.YCharSize db ? ; char .YCharSize db ? ; char
.NumberOfPlanes db ? ; char .NumberOfPlanes db ? ; char
.BitsPerPixel db ? ; char .BitsPerPixel db ? ; char
.NumberOfBanks db ? ; char .NumberOfBanks db ? ; char
.MemoryModel db ? ; char .MemoryModel db ? ; char
.BankSize db ? ; char .BankSize db ? ; char
.NumberOfImagePages db ? ; char .NumberOfImagePages db ? ; char
.res1 db ? ; char .res1 db ? ; char
.RedMaskSize db ? ; char .RedMaskSize db ? ; char
.RedFieldPosition db ? ; char .RedFieldPosition db ? ; char
.GreenMaskSize db ? ; char .GreenMaskSize db ? ; char
.GreenFieldPosition db ? ; char .GreenFieldPosition db ? ; char
.BlueMaskSize db ? ; char .BlueMaskSize db ? ; char
.BlueFieldPosition db ? ; char .BlueFieldPosition db ? ; char
.RsvedMaskSize db ? ; char .RsvedMaskSize db ? ; char
.RsvedFieldPosition db ? ; char .RsvedFieldPosition db ? ; char
.DirectColorModeInfo db ? ; char ; MISSED IN THIS TUTORIAL!! SEE ABOVE .DirectColorModeInfo db ? ; char ; MISSED IN THIS TUTORIAL!! SEE ABOVE
; VBE 2.0+ ; VBE 2.0+
.PhysBasePtr dd ? ; ulong .PhysBasePtr dd ? ; ulong
.OffScreenMemOffset dd ? ; ulong .OffScreenMemOffset dd ? ; ulong
.OffScreenMemSize dw ? ; short .OffScreenMemSize dw ? ; short
; VBE 3.0+ ; VBE 3.0+
.LinbytesPerScanLine dw ? ; short .LinbytesPerScanLine dw ? ; short
.BankNumberOfImagePages db ? ; char .BankNumberOfImagePages db ? ; char
.LinNumberOfImagePages db ? ; char .LinNumberOfImagePages db ? ; char
.LinRedMaskSize db ? ; char .LinRedMaskSize db ? ; char
.LinRedFieldPosition db ? ; char .LinRedFieldPosition db ? ; char
.LingreenMaskSize db ? ; char .LingreenMaskSize db ? ; char
.LinGreenFieldPosition db ? ; char .LinGreenFieldPosition db ? ; char
.LinBlueMaskSize db ? ; char .LinBlueMaskSize db ? ; char
.LinBlueFieldPosition db ? ; char .LinBlueFieldPosition db ? ; char
.LinRsvdMaskSize db ? ; char .LinRsvdMaskSize db ? ; char
.LinRsvdFieldPosition db ? ; char .LinRsvdFieldPosition db ? ; char
.MaxPixelClock dd ? ; ulong .MaxPixelClock dd ? ; ulong
.res2 rb 190 ; char .res2 rb 190 ; char
} }
virtual at $A000 virtual at $A000
@ -78,7 +78,7 @@ virtual at $A000
mi VBE_ModeInfo mi VBE_ModeInfo
modes_table: modes_table:
end virtual end virtual
cursor_pos dw 0 ;âðåìåííîå õðàíåíèå êóðñîðà. cursor_pos dw 0 ;âðåìåííîå õðàíåíèå êóðñîðà.
home_cursor dw 0 ;current shows rows a table home_cursor dw 0 ;current shows rows a table
end_cursor dw 0 ;end of position current shows rows a table end_cursor dw 0 ;end of position current shows rows a table
scroll_start dw 0 ;start position of scroll bar scroll_start dw 0 ;start position of scroll bar
@ -87,545 +87,278 @@ long_v_table equ 9 ;long of visible video table
size_of_step equ 10 size_of_step equ 10
scroll_area_size equ (long_v_table-2) scroll_area_size equ (long_v_table-2)
int2str: int2str:
dec bl dec bl
jz @f jz @f
xor edx,edx xor edx,edx
div ecx div ecx
push edx push edx
call int2str call int2str
pop eax pop eax
@@: or al,0x30 @@: or al,0x30
mov [ds:di],al mov [ds:di],al
inc di inc di
ret ret
int2strnz: int2strnz:
cmp eax,ecx cmp eax,ecx
jb @f jb @f
xor edx,edx xor edx,edx
div ecx div ecx
push edx push edx
call int2strnz call int2strnz
pop eax pop eax
@@: or al,0x30 @@: or al,0x30
mov [es:di],al mov [es:di],al
inc di inc di
ret ret
;-------------------------------------------------------
;Write message about incorrect v_mode and write message about jmp on swith v_mode
v_mode_error:
_setcursor 19,2
mov si, fatalsel
call printplain
_setcursor 20,2
mov si,pres_key
call printplain
xor eax,eax
int 16h
jmp cfgmanager.d
;-------------------------------------------------------
;
;------------------------------------------------------- ;-------------------------------------------------------
print_vesa_info: print_vesa_info:
_setcursor 5,2 _setcursor 5,2
mov [es:vi.VESASignature],'VBE2' mov [es:vi.VESASignature],'VBE2'
mov ax,0x4F00 mov ax,0x4F00
mov di,vi ;0xa000 mov di,vi ;0xa000
int 0x10 int 0x10
or ah,ah or ah,ah
jz @f jz @f
mov [es:vi.VESASignature],'VESA' mov [es:vi.VESASignature],'VESA'
mov ax,$4F00 mov ax,$4F00
mov di,vi mov di,vi
int 0x10 int 0x10
or ah,ah or ah,ah
jnz .exit jnz $
@@: @@:
cmp [es:vi.VESASignature],'VESA' cmp [es:vi.VESASignature],'VESA'
jne .exit jne $
cmp [es:vi.VESAVersion],0x0100 cmp [es:vi.VESAVersion],0x0100
jb .exit jb $
jmp .vesaok2
.exit:
mov si,novesa
call printplain
ret
.vesaok2: .vesaok2:
mov ax,[es:vi.VESAVersion] mov ax,[es:vi.VESAVersion]
add ax,'00' add ax,'00'
mov [s_vesa.ver], ah mov [s_vesa.ver], ah
mov [s_vesa.ver+2], al mov [s_vesa.ver+2], al
mov si,s_vesa mov si,s_vesa
call printplain call printplain
_setcursor 4,2 _setcursor 4,2
mov si,word[es:vi.OemStringPtr] mov si,word[es:vi.OemStringPtr]
mov di,si mov di,si
push ds push ds
mov ds,word[es:vi.OemStringPtr+2] mov ds,word[es:vi.OemStringPtr+2]
call printplain call printplain
pop ds pop ds
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
calc_vmodes_table: calc_vmodes_table:
pushad pushad
; push 0 ; push 0
; pop es ; pop es
lfs si, [es:vi.VideoModePtr] lfs si, [es:vi.VideoModePtr]
mov bx,modes_table mov bx,modes_table
.next_mode: .next_mode:
mov cx,word [fs:si] ; mode number mov cx,word [fs:si] ; mode number
cmp cx,-1 cmp cx,-1
je .modes_ok.2 je .modes_ok.2
mov ax,0x4F01 mov ax,0x4F01
mov di,mi mov di,mi
int 0x10 int 0x10
or ah,ah or ah,ah
jnz .modes_ok.2 ;vesa_info.exit jnz .modes_ok.2 ;vesa_info.exit
test [es:mi.ModeAttributes],00000001b ;videomode support ? test [es:mi.ModeAttributes],00000001b ;videomode support ?
jz @f jz @f
test [es:mi.ModeAttributes],00010000b ;picture ? test [es:mi.ModeAttributes],00010000b ;picture ?
jz @f jz @f
test [es:mi.ModeAttributes],10000000b ;LFB ? test [es:mi.ModeAttributes],10000000b ;LFB ?
jz @f jz @f
cmp [es:mi.BitsPerPixel], 32 ;to show only 32 bpp videomodes cmp [es:mi.BitsPerPixel], 32 ;to show only 32 bpp videomodes
jb @f jb @f
.l0: .l0:
cmp [es:mi.XRes],800 ; only 800x600 and higher cmp [es:mi.XRes],800 ; only 800x600 and higher
jb @f jb @f
mov ax,[es:mi.XRes] mov ax,[es:mi.XRes]
mov [es:bx+0],ax ; +0[2] : resolution X mov [es:bx+0],ax ; +0[2] : resolution X
mov ax,[es:mi.YRes] mov ax,[es:mi.YRes]
mov [es:bx+2],ax ; +2[2] : resolution Y mov [es:bx+2],ax ; +2[2] : resolution Y
mov ax,[es:mi.ModeAttributes] mov ax,[es:mi.ModeAttributes]
mov [es:bx+4],ax ; +4[2] : attributes mov [es:bx+4],ax ; +4[2] : attributes
;<< cmp [s_vesa.ver],'2' ;<< cmp [s_vesa.ver],'2'
;<< jb .lp1 ;<< jb .lp1
or cx,0x4000 ; use LFB <<< ? or cx,0x4000 ; use LFB <<< ?
.lp1: mov [es:bx+6],cx ; +6 : mode number .lp1: mov [es:bx+6],cx ; +6 : mode number
movzx ax,byte [es:mi.BitsPerPixel] movzx ax,byte [es:mi.BitsPerPixel]
mov word [es:bx+8],ax ; +8 : bits per pixel << ? mov word [es:bx+8],ax ; +8 : bits per pixel << ?
add bx,size_of_step ; size of record add bx,size_of_step ; size of record
@@: @@:
add si,2 add si,2
jmp .next_mode jmp .next_mode
.modes_ok.2: .modes_ok.2:
mov word[es:bx],-1 ;end video table mov word[es:bx],-1 ;end video table
mov word[end_cursor],bx ;save end cursor position mov word[end_cursor],bx ;save end cursor position
popad popad
ret ret
;-----------------------------------------------------------------------------
;draw_current_vmode:
; push 0
; pop es
; mov si,word [cursor_pos]
; cmp word [es:si+6],0x12
; je .no_vesa_0x12
; cmp word [es:si+6],0x13
; je .no_vesa_0x13
; mov di,loader_block_error
; movzx eax,word[es:si+0]
; mov ecx,10
; call int2strnz
; mov byte[es:di],'x'
; inc di
; movzx eax,word[es:si+2]
; call int2strnz
; mov byte[es:di],'x'
; inc di
; movzx eax,word[es:si+8]
; call int2strnz
; mov dword[es:di],0x00000d0a
; mov si,loader_block_error
; push ds
; push es
; pop ds
; call printplain
; pop ds
; ret
;.no_vesa_0x13:
; mov si,mode0
; jmp .print
;.no_vesa_0x12:
; mov si,mode9
;.print:
; call printplain
; ret
;-----------------------------------------------------------------------------
check_first_parm: check_first_parm:
mov si,word [preboot_graph] mov si,word [preboot_graph]
test si,si test si,si
jnz .no_zero ;if no zero jnz .no_zero ;if no zero
.zerro: .zerro:
; mov ax,modes_table
; mov word [cursor_pos],ax
; mov word [home_cursor],ax
; mov word [preboot_graph],ax
;SET default video of mode first probe will fined a move of work 1024x768@32
mov ax,1024 mov ax,1024
mov bx,768 mov bx,768
mov si,modes_table mov si,modes_table
call .loops call .loops
test ax,ax test ax,ax
jz .ok_found_mode jz .ok_found_mode
mov si,modes_table mov si,modes_table
jmp .ok_found_mode jmp .ok_found_mode
.no_zero: .no_zero:
mov bp,word [number_vm] mov bp,word [number_vm]
cmp bp,word [es:si+6] cmp bp,word [es:si+6]
jz .ok_found_mode jz .ok_found_mode
mov ax,word [x_save] mov ax,word [x_save]
mov bx,word [y_save] mov bx,word [y_save]
mov si,modes_table mov si,modes_table
call .loops call .loops
test ax,ax test ax,ax
jz .ok_found_mode jz .ok_found_mode
mov si,modes_table mov si,modes_table
.ok_found_mode: .ok_found_mode:
mov word [home_cursor],si mov word [home_cursor],si
mov word [preboot_graph],si mov word [preboot_graph],si
mov ax,si mov ax,si
mov ecx,long_v_table mov ecx,long_v_table
.loop: add ax,size_of_step .loop: add ax,size_of_step
cmp ax,word [end_cursor] cmp ax,word [end_cursor]
jae .next_step jae .next_step
loop .loop loop .loop
.next_step: .next_step:
sub ax,size_of_step*long_v_table sub ax,size_of_step*long_v_table
cmp ax,modes_table cmp ax,modes_table
jae @f jae @f
mov ax,modes_table mov ax,modes_table
@@: @@:
mov word [home_cursor],ax mov word [home_cursor],ax
mov si,[preboot_graph] mov si,[preboot_graph]
mov word [cursor_pos],si mov word [cursor_pos],si
push word [es:si] push word [es:si]
pop word [x_save] pop word [x_save]
push word [es:si+2] push word [es:si+2]
pop word [y_save] pop word [y_save]
push word [es:si+6] push word [es:si+6]
pop word [number_vm] pop word [number_vm]
ret ret
;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
.loops: .loops:
cmp ax,word [es:si] cmp ax,word [es:si]
jne .next jne .next
cmp bx,word [es:si+2] cmp bx,word [es:si+2]
jne .next jne .next
je .ok je .ok
.next: add si,size_of_step .next: add si,size_of_step
cmp word [es:si],-1 cmp word [es:si],-1
je .exit je .exit
jmp .loops jmp .loops
.ok: xor ax,ax .ok: xor ax,ax
ret ret
.exit: or ax,-1 .exit: or ax,-1
ret ret
;-----------------------------------------------------------------------------
;default_vmode:
;-----------------------------------------------------------------------------
draw_vmodes_table:
; _setcursor 9, 2
; mov si,gr_mode
; call printplain
; mov si,_st
; call printplain
; push word [cursor_pos]
; pop ax
; push word [home_cursor]
; pop si
; mov cx,si
; cmp ax,si
; je .ok
; jb .low
; add cx,size_of_step*long_v_table
; cmp ax,cx
; jb .ok
; sub cx,size_of_step*long_v_table
; add cx,size_of_step
; cmp cx,word[end_cursor]
; jae .ok
; add si,size_of_step
; push si
; pop word [home_cursor]
; jmp .ok
;.low: sub cx,size_of_step
; cmp cx,modes_table
; jb .ok
; push cx
; push cx
; pop word [home_cursor]
; pop si
;.ok:
; calculate scroll position
; push si
; mov ax, [end_cursor]
; sub ax, modes_table
; mov bx, size_of_step
; cwd
; div bx
; mov si, ax ; si = size of list
; mov ax, [home_cursor]
; sub ax, modes_table
; cwd
; div bx
; mov di, ax
; mov ax, scroll_area_size*long_v_table
; cwd
; div si
; test ax, ax
; jnz @f
; inc ax
;@@:
; cmp al, scroll_area_size
; jb @f
; mov al, scroll_area_size
;@@:
; mov cx, ax
; cx = scroll height
; calculate scroll pos
; xor bx, bx ; initialize scroll pos
; sub al, scroll_area_size+1
; neg al
; sub si, long_v_table-1
; jbe @f
; mul di
; div si
; mov bx, ax
;@@:
; inc bx
; imul ax, bx, size_of_step
; add ax, [home_cursor]
; mov [scroll_start], ax
; imul cx, size_of_step
; add ax, cx
; mov [scroll_end], ax
; pop si
; mov bp,long_v_table ;show rows
;.@@_next_bit:
;clear cursor
; mov ax,' '
; mov word[ds:_r1+21],ax
; mov word[ds:_r1+50],ax
; mov word[ds:_r2+21],ax
; mov word[ds:_r2+45],ax
; mov word[ds:_rs+21],ax
; mov word[ds:_rs+46],ax
; draw string
; cmp word [es:si+6],0x12
; je .show_0x12
; cmp word [es:si+6],0x13
; je .show_0x13
; movzx eax,word[es:si]
; cmp ax,-1
; je .@@_end
; mov di,_rs+23
; mov ecx,10
; mov bl,4
; call int2str
; movzx eax,word[es:si+2]
; inc di
; mov bl,4
; call int2str
; movzx eax,word[es:si+8]
; inc di
; mov bl,2
; call int2str
; cmp si, word [cursor_pos]
; jne .next
;draw cursor
; mov word[ds:_rs+21],'>>'
; mov word[ds:_rs+46],'<<'
;.next:
; push si
; mov si,_rs
;.@@_sh:
; add to the string pseudographics for scrollbar
; pop bx
; push bx
; mov byte [si+53], ' '
; cmp bx, [scroll_start]
; jb @f
; cmp bx, [scroll_end]
; jae @f
; mov byte [si+53], 0xDB ; filled bar
;@@:
; push bx
; add bx, size_of_step
; cmp bx, [end_cursor]
; jnz @f
; mov byte [si+53], 31 ; 'down arrow' symbol
;@@:
; sub bx, [home_cursor]
; cmp bx, size_of_step*long_v_table
; jnz @f
; mov byte [si+53], 31 ; 'down arrow' symbol
;@@:
; pop bx
; cmp bx, [home_cursor]
; jnz @f
; mov byte [si+53], 30 ; 'up arrow' symbol
;@@:
; call printplain
; pop si
; add si,size_of_step
; dec bp
; jnz .@@_next_bit
;.@@_end:
; mov si,_bt
; call printplain
ret
;.show_0x13:
; push si
; cmp si, word [cursor_pos]
; jne @f
; mov word[ds:_r1+21],'>>'
; mov word[ds:_r1+50],'<<'
;@@:
; mov si,_r1
; jmp .@@_sh
;.show_0x12:
; push si
; cmp si, word [cursor_pos]
; jne @f
; mov word[ds:_r2+21],'>>'
; mov word[ds:_r2+45],'<<'
;@@:
; mov si,_r2
; jmp .@@_sh
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
;Clear area of current video page (0xb800) ;Clear area of current video page (0xb800)
clear_vmodes_table: ;clear_vmodes_table:
pusha ; pusha
; draw frames ; draw frames
push es ; push es
push 0xb800 ; push 0xb800
pop es ; pop es
mov di,1444 ; mov di,1444
xor ax,ax ; xor ax,ax
mov ah, 1*16+15 ; mov ah, 1*16+15
mov cx,70 ; mov cx,70
mov bp,12 ; mov bp,12
.loop_start: ;.loop_start:
rep stosw ; rep stosw
mov cx,70 ; mov cx,70
add di,20 ; add di,20
dec bp ; dec bp
jns .loop_start ; jns .loop_start
pop es ; pop es
popa ; popa
ret ; ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
set_vmode: set_vmode:
push 0 ;0;x1000 push 0 ;0;x1000
pop es pop es
mov si,word [preboot_graph] ;[preboot_graph] mov si,word [preboot_graph] ;[preboot_graph]
mov cx,word [es:si+6] ; number of mode mov cx,word [es:si+6] ; number of mode
mov ax,word [es:si+0] ; resolution X mov ax,word [es:si+0] ; resolution X
mov bx,word [es:si+2] ; resolution Y mov bx,word [es:si+2] ; resolution Y
mov word [es:0x900A],ax ; resolution X mov word [es:0x900A],ax ; resolution X
mov word [es:0x900C],bx ; resolution Y mov word [es:0x900C],bx ; resolution Y
mov word [es:0x9008],cx ; number of mode mov word [es:0x9008],cx ; number of mode
; VESA 2 and Vesa 3 only ; VESA 2 and Vesa 3 only
mov ax,0x4f01 mov ax,0x4f01
and cx,0xfff and cx,0xfff
mov di,mi;0xa000 mov di,mi;0xa000
int 0x10 int 0x10
; LFB ; LFB
mov eax,[es:mi.PhysBasePtr] ;di+0x28] mov eax,[es:mi.PhysBasePtr] ;di+0x28]
mov [es:0x9018],eax mov [es:0x9018],eax
; ---- vbe voodoo ; ---- vbe voodoo
BytesPerLine equ 0x10 BytesPerLine equ 0x10
mov ax, [es:di+BytesPerLine] mov ax, [es:di+BytesPerLine]
mov [es:0x9001], ax mov [es:0x9001], ax
; BPP ; BPP
.l0: .l0:
mov al, byte [es:di+0x19] mov al, byte [es:di+0x19]
mov [es:0x9000], al mov [es:0x9000], al
jmp .exit jmp .exit
.exit: .exit:
ret ret
;============================================================================= ;=============================================================================