2007-03-26 16:18:08 +04:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
|
|
|
|
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;; BOOTCODE.INC ;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;; KolibriOS 16-bit loader, ;;
|
|
|
|
|
;; based on bootcode for MenuetOS ;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2007-07-27 17:52:03 +04:00
|
|
|
|
$Revision$
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;==========================================================================
|
|
|
|
|
;
|
|
|
|
|
; 16 BIT FUNCTIONS
|
|
|
|
|
;
|
|
|
|
|
;==========================================================================
|
|
|
|
|
|
2006-10-16 16:17:49 +04:00
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
putchar:
|
|
|
|
|
; in: al=character
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov ah, 0Eh
|
|
|
|
|
mov bh, 0
|
|
|
|
|
int 10h
|
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
print:
|
|
|
|
|
; in: si->string
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov al, 186
|
|
|
|
|
call putchar
|
|
|
|
|
mov al, ' '
|
|
|
|
|
call putchar
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
printplain:
|
|
|
|
|
; in: si->string
|
2007-05-21 17:25:02 +04:00
|
|
|
|
pusha
|
|
|
|
|
lodsb
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
call putchar
|
|
|
|
|
lodsb
|
|
|
|
|
cmp al, 0
|
|
|
|
|
jnz @b
|
|
|
|
|
popa
|
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
getkey:
|
|
|
|
|
; get number in range [bl,bh] (bl,bh in ['0'..'9'])
|
|
|
|
|
; in: bx=range
|
|
|
|
|
; out: ax=digit (1..9, 10 for 0)
|
2007-05-21 17:25:02 +04:00
|
|
|
|
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
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
setcursor:
|
|
|
|
|
; in: dl=column, dh=row
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov ah, 2
|
|
|
|
|
mov bh, 0
|
|
|
|
|
int 10h
|
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
macro _setcursor row,column
|
|
|
|
|
{
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov dx, row*256 + column
|
|
|
|
|
call setcursor
|
2005-12-14 11:09:29 +03:00
|
|
|
|
}
|
|
|
|
|
|
2006-08-24 16:33:31 +04:00
|
|
|
|
boot_read_floppy:
|
|
|
|
|
push si
|
|
|
|
|
xor si, si
|
|
|
|
|
mov ah, 2 ; read
|
|
|
|
|
@@:
|
|
|
|
|
push ax
|
|
|
|
|
int 0x13
|
|
|
|
|
pop ax
|
|
|
|
|
jnc @f
|
|
|
|
|
inc si
|
|
|
|
|
cmp si, 10
|
|
|
|
|
jb @b
|
2007-04-18 10:37:14 +04:00
|
|
|
|
mov si, badsect
|
2006-08-24 16:33:31 +04:00
|
|
|
|
sayerr_plain:
|
|
|
|
|
call printplain
|
|
|
|
|
jmp $
|
|
|
|
|
@@:
|
|
|
|
|
pop si
|
|
|
|
|
ret
|
|
|
|
|
|
2008-04-28 23:12:24 +04:00
|
|
|
|
; convert abs. sector number (AX) to BIOS T:H:S
|
|
|
|
|
; sector number = (abs.sector%BPB_SecPerTrk)+1
|
|
|
|
|
; pre.track number = (abs.sector/BPB_SecPerTrk)
|
|
|
|
|
; head number = pre.track number%BPB_NumHeads
|
|
|
|
|
; track number = pre.track number/BPB_NumHeads
|
|
|
|
|
; Return: cl - sector number
|
|
|
|
|
; ch - track number
|
|
|
|
|
; dl - drive number (0 = a:)
|
|
|
|
|
; dh - head number
|
|
|
|
|
conv_abs_to_THS:
|
|
|
|
|
push bx
|
|
|
|
|
mov bx,word [BPB_SecPerTrk]
|
|
|
|
|
xor dx,dx
|
|
|
|
|
div bx
|
|
|
|
|
inc dx
|
|
|
|
|
mov cl, dl ; cl = sector number
|
|
|
|
|
mov bx,word [BPB_NumHeads]
|
|
|
|
|
xor dx,dx
|
|
|
|
|
div bx
|
|
|
|
|
; !!!!!!! ax = track number, dx = head number
|
|
|
|
|
mov ch,al ; ch=track number
|
|
|
|
|
xchg dh,dl ; dh=head number
|
|
|
|
|
mov dl,0 ; dl=0 (drive 0 (a:))
|
|
|
|
|
pop bx
|
|
|
|
|
retn
|
|
|
|
|
; needed variables
|
2008-07-04 10:15:05 +04:00
|
|
|
|
BPB_SecPerTrk dw 0 ; sectors per track
|
|
|
|
|
BPB_NumHeads dw 0 ; number of heads
|
|
|
|
|
BPB_FATSz16 dw 0 ; size of FAT
|
|
|
|
|
BPB_RootEntCnt dw 0 ; count of root dir. entries
|
|
|
|
|
BPB_BytsPerSec dw 0 ; bytes per sector
|
|
|
|
|
BPB_RsvdSecCnt dw 0 ; number of reserved sectors
|
|
|
|
|
BPB_TotSec16 dw 0 ; count of the sectors on the volume
|
|
|
|
|
BPB_SecPerClus db 0 ; number of sectors per cluster
|
|
|
|
|
BPB_NumFATs db 0 ; number of FAT tables
|
|
|
|
|
abs_sector_adj dw 0 ; adjustment to make abs. sector number
|
|
|
|
|
end_of_FAT dw 0 ; end of FAT table
|
|
|
|
|
FirstDataSector dw 0 ; begin of data
|
2008-04-28 23:12:24 +04:00
|
|
|
|
|
2005-10-06 21:56:22 +04:00
|
|
|
|
;=========================================================================
|
|
|
|
|
;
|
|
|
|
|
; 16 BIT CODE
|
|
|
|
|
;
|
|
|
|
|
;=========================================================================
|
|
|
|
|
|
2008-02-07 15:07:20 +03:00
|
|
|
|
include 'bootvesa.inc' ;Include source for boot vesa
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
start_of_code:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
cld
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; \begin{diamond}[02.12.2005]
|
2007-05-21 17:25:02 +04:00
|
|
|
|
; if bootloader sets ax = 'KL', then ds:si points to loader block
|
|
|
|
|
cmp ax, 'KL'
|
|
|
|
|
jnz @f
|
|
|
|
|
mov word [cs:cfgmanager.loader_block], si
|
|
|
|
|
mov word [cs:cfgmanager.loader_block+2], ds
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
|
|
|
|
; \end{diamond}[02.12.2005]
|
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk
|
|
|
|
|
; (see comment to bx_from_load)
|
|
|
|
|
cmp cx, 'HA'
|
|
|
|
|
jnz no_hd_load
|
|
|
|
|
cmp dx,'RD'
|
|
|
|
|
jnz no_hd_load
|
|
|
|
|
mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007]
|
2007-05-11 23:38:23 +04:00
|
|
|
|
no_hd_load:
|
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; set up stack
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov ax, 3000h
|
|
|
|
|
mov ss, ax
|
|
|
|
|
mov sp, 0EC00h
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; set up segment registers
|
2007-05-21 17:25:02 +04:00
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
|
|
|
|
push cs
|
|
|
|
|
pop es
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
|
|
|
|
; set videomode
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov ax, 3
|
|
|
|
|
int 0x10
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2006-08-24 16:33:31 +04:00
|
|
|
|
if lang eq ru
|
2005-10-06 21:56:22 +04:00
|
|
|
|
; Load & set russian VGA font (RU.INC)
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov bp, RU_FNT1 ; RU_FNT1 - First part
|
|
|
|
|
mov bx, 1000h ; 768 bytes
|
|
|
|
|
mov cx, 30h ; 48 symbols
|
|
|
|
|
mov dx, 80h ; 128 - position of first symbol
|
|
|
|
|
mov ax, 1100h
|
|
|
|
|
int 10h
|
|
|
|
|
|
|
|
|
|
mov bp, RU_FNT2 ; RU_FNT2 -Second part
|
|
|
|
|
mov bx, 1000h ; 512 bytes
|
|
|
|
|
mov cx, 20h ; 32 symbols
|
|
|
|
|
mov dx, 0E0h ; 224 - position of first symbol
|
|
|
|
|
mov ax, 1100h
|
|
|
|
|
int 10h
|
2005-10-06 21:56:22 +04:00
|
|
|
|
; End set VGA russian font
|
2007-01-13 23:34:33 +03:00
|
|
|
|
else if lang eq et
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov bp, ET_FNT ; ET_FNT1
|
|
|
|
|
mov bx, 1000h ;
|
|
|
|
|
mov cx, 255 ; 256 symbols
|
|
|
|
|
xor dx, dx ; 0 - position of first symbol
|
|
|
|
|
mov ax, 1100h
|
|
|
|
|
int 10h
|
2006-08-24 16:33:31 +04:00
|
|
|
|
end if
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; draw frames
|
2007-05-21 17:25:02 +04:00
|
|
|
|
push 0xb800
|
|
|
|
|
pop es
|
|
|
|
|
xor di, di
|
|
|
|
|
mov ah, 1*16+15
|
2007-04-18 10:37:14 +04:00
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; draw top
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov si, d80x25_top
|
|
|
|
|
mov cx, d80x25_top_num * 80
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
lodsb
|
|
|
|
|
stosw
|
|
|
|
|
loop @b
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; draw spaces
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov si, space_msg
|
|
|
|
|
mov dx, 25 - d80x25_top_num - d80x25_bottom_num
|
2005-12-14 11:09:29 +03:00
|
|
|
|
dfl1:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
push si
|
|
|
|
|
mov cx, 80
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
lodsb
|
|
|
|
|
stosw
|
|
|
|
|
loop @b
|
|
|
|
|
pop si
|
|
|
|
|
dec dx
|
|
|
|
|
jnz dfl1
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; draw bottom
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov si, d80x25_bottom
|
|
|
|
|
mov cx, d80x25_bottom_num * 80
|
2005-12-14 11:09:29 +03:00
|
|
|
|
@@:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
lodsb
|
|
|
|
|
stosw
|
|
|
|
|
loop @b
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov byte [space_msg+80], 0 ; now space_msg is null terminated
|
2005-12-14 11:09:29 +03:00
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
_setcursor d80x25_top_num,0
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; TEST FOR 386+
|
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov bx, 0x4000
|
2005-10-06 21:56:22 +04:00
|
|
|
|
pushf
|
|
|
|
|
pop ax
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov dx, ax
|
|
|
|
|
xor ax, bx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
push ax
|
|
|
|
|
popf
|
|
|
|
|
pushf
|
|
|
|
|
pop ax
|
2007-05-21 17:25:02 +04:00
|
|
|
|
and ax, bx
|
|
|
|
|
and dx, bx
|
|
|
|
|
cmp ax, dx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
jnz cpugood
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov si, not386
|
2006-01-25 16:19:21 +03:00
|
|
|
|
sayerr:
|
2005-10-06 21:56:22 +04:00
|
|
|
|
call print
|
|
|
|
|
jmp $
|
|
|
|
|
cpugood:
|
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
push 0
|
2007-04-18 10:37:14 +04:00
|
|
|
|
popf
|
|
|
|
|
sti
|
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; set up esp
|
2007-05-21 17:25:02 +04:00
|
|
|
|
movzx esp, sp
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2006-09-27 18:58:51 +04:00
|
|
|
|
push 0
|
|
|
|
|
pop es
|
|
|
|
|
and word [es:0x9031], 0
|
2006-10-06 10:09:41 +04:00
|
|
|
|
; \begin{Mario79}
|
|
|
|
|
; find HDD IDE DMA PCI device
|
2006-09-27 18:58:51 +04:00
|
|
|
|
; check for PCI BIOS
|
|
|
|
|
mov ax, 0xB101
|
|
|
|
|
int 0x1A
|
|
|
|
|
jc .nopci
|
|
|
|
|
cmp edx, 'PCI '
|
|
|
|
|
jnz .nopci
|
|
|
|
|
; find PCI class code
|
|
|
|
|
; class 1 = mass storage
|
|
|
|
|
; subclass 1 = IDE controller
|
|
|
|
|
; a) class 1, subclass 1, programming interface 0x80
|
|
|
|
|
mov ax, 0xB103
|
|
|
|
|
mov ecx, 1*10000h + 1*100h + 0x80
|
2007-05-21 17:25:02 +04:00
|
|
|
|
xor si, si ; device index = 0
|
2006-09-27 18:58:51 +04:00
|
|
|
|
int 0x1A
|
|
|
|
|
jnc .found
|
2006-10-20 12:35:15 +04:00
|
|
|
|
; b) class 1, subclass 1, programming interface 0x8A
|
2006-09-27 18:58:51 +04:00
|
|
|
|
mov ax, 0xB103
|
2006-10-20 12:35:15 +04:00
|
|
|
|
mov ecx, 1*10000h + 1*100h + 0x8A
|
2007-05-21 17:25:02 +04:00
|
|
|
|
xor si, si ; device index = 0
|
2006-09-27 18:58:51 +04:00
|
|
|
|
int 0x1A
|
|
|
|
|
jnc .found
|
2006-10-20 12:35:15 +04:00
|
|
|
|
; c) class 1, subclass 1, programming interface 0x85
|
2006-09-27 18:58:51 +04:00
|
|
|
|
mov ax, 0xB103
|
2006-10-20 12:35:15 +04:00
|
|
|
|
mov ecx, 1*10000h + 1*100h + 0x85
|
2007-05-21 17:25:02 +04:00
|
|
|
|
xor si, si
|
2006-09-27 18:58:51 +04:00
|
|
|
|
int 0x1A
|
|
|
|
|
jc .nopci
|
|
|
|
|
.found:
|
|
|
|
|
; get memory base
|
|
|
|
|
mov ax, 0xB10A
|
|
|
|
|
mov di, 0x20 ; memory base is config register at 0x20
|
|
|
|
|
int 0x1A
|
|
|
|
|
jc .nopci
|
|
|
|
|
and cx, 0xFFF0 ; clear address decode type
|
|
|
|
|
mov [es:0x9031], cx
|
|
|
|
|
.nopci:
|
2006-10-06 10:09:41 +04:00
|
|
|
|
; \end{Mario79}
|
2006-09-27 18:58:51 +04:00
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov al, 0xf6 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
out 0x60, al
|
|
|
|
|
xor cx, cx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
wait_loop: ; variant 2
|
|
|
|
|
; reading state of port of 8042 controller
|
2007-05-21 17:25:02 +04:00
|
|
|
|
in al, 64h
|
|
|
|
|
and al, 00000010b ; ready flag
|
2006-10-06 10:09:41 +04:00
|
|
|
|
; wait until 8042 controller is ready
|
2005-10-06 21:56:22 +04:00
|
|
|
|
loopnz wait_loop
|
|
|
|
|
|
2008-02-07 15:07:20 +03:00
|
|
|
|
;;;/diamond today 5.02.2008
|
|
|
|
|
; 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
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2006-05-06 18:34:30 +04:00
|
|
|
|
; --------------- APM ---------------------
|
2007-05-21 17:25:02 +04:00
|
|
|
|
and word [es:0x9044], 0 ; ver = 0.0 (APM not found)
|
|
|
|
|
mov ax, 0x5300
|
|
|
|
|
xor bx, bx
|
|
|
|
|
int 0x15
|
|
|
|
|
jc apm_end ; APM not found
|
|
|
|
|
test cx, 2
|
|
|
|
|
jz apm_end ; APM 32-bit protected-mode interface not supported
|
|
|
|
|
mov [es:0x9044], ax ; Save APM Version
|
|
|
|
|
mov [es:0x9046], cx ; Save APM flags
|
|
|
|
|
|
|
|
|
|
; Write APM ver ----
|
|
|
|
|
and ax, 0xf0f
|
|
|
|
|
add ax, '00'
|
|
|
|
|
mov si, msg_apm
|
|
|
|
|
mov [si + 5], ah
|
|
|
|
|
mov [si + 7], al
|
|
|
|
|
_setcursor 0, 3
|
|
|
|
|
call printplain
|
|
|
|
|
; ------------------
|
|
|
|
|
|
|
|
|
|
mov ax, 0x5304 ; Disconnect interface
|
|
|
|
|
xor bx, bx
|
|
|
|
|
int 0x15
|
|
|
|
|
mov ax, 0x5303 ; Connect 32 bit mode interface
|
|
|
|
|
xor bx, bx
|
|
|
|
|
int 0x15
|
|
|
|
|
|
|
|
|
|
mov [es:0x9040], ebx
|
|
|
|
|
mov [es:0x9050], ax
|
|
|
|
|
mov [es:0x9052], cx
|
|
|
|
|
mov [es:0x9054], dx
|
2007-04-18 10:37:14 +04:00
|
|
|
|
|
2006-05-06 18:34:30 +04:00
|
|
|
|
apm_end:
|
2007-03-29 14:24:08 +04:00
|
|
|
|
_setcursor d80x25_top_num, 0
|
2007-03-22 04:09:49 +03:00
|
|
|
|
|
2008-02-07 15:07:20 +03:00
|
|
|
|
;CHECK current of code
|
|
|
|
|
cmp [cfgmanager.loader_block], -1
|
|
|
|
|
jz noloaderblock
|
|
|
|
|
les bx, [cfgmanager.loader_block]
|
|
|
|
|
cmp byte [es:bx], 1
|
|
|
|
|
mov si, loader_block_error
|
|
|
|
|
jnz sayerr
|
2008-02-14 01:16:08 +03:00
|
|
|
|
push 0
|
|
|
|
|
pop es
|
2008-02-07 15:07:20 +03:00
|
|
|
|
|
|
|
|
|
noloaderblock:
|
2005-10-06 21:56:22 +04:00
|
|
|
|
; DISPLAY VESA INFORMATION
|
2008-02-07 15:07:20 +03:00
|
|
|
|
call print_vesa_info
|
|
|
|
|
call calc_vmodes_table
|
|
|
|
|
call check_first_parm ;check and enable cursor_pos
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; \begin{diamond}[30.11.2005]
|
|
|
|
|
cfgmanager:
|
|
|
|
|
; settings:
|
|
|
|
|
; a) preboot_graph = graphical mode
|
|
|
|
|
; preboot_gprobe = probe this mode?
|
2008-02-07 15:07:20 +03:00
|
|
|
|
; b) preboot_dma = use DMA access?
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; c) preboot_vrrm = use VRR?
|
|
|
|
|
; d) preboot_device = from what boot?
|
2008-02-07 15:07:20 +03:00
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; determine default settings
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov [.bSettingsChanged], 0
|
2008-02-07 15:07:20 +03:00
|
|
|
|
|
|
|
|
|
;.preboot_gr_end:
|
2008-02-10 14:48:23 +03:00
|
|
|
|
mov di, preboot_device
|
|
|
|
|
; if image in memory is present and [preboot_device] is uninitialized,
|
|
|
|
|
; set it to use this preloaded image
|
|
|
|
|
cmp byte [di], 0
|
|
|
|
|
jnz .preboot_device_inited
|
|
|
|
|
cmp [.loader_block], -1
|
|
|
|
|
jz @f
|
|
|
|
|
les bx, [.loader_block]
|
|
|
|
|
test byte [es:bx+1], 1
|
|
|
|
|
jz @f
|
|
|
|
|
mov byte [di], 3
|
|
|
|
|
jmp .preboot_device_inited
|
|
|
|
|
@@:
|
|
|
|
|
; otherwise, set [preboot_device] to 1 (default value - boot from floppy)
|
|
|
|
|
mov byte [di], 1
|
|
|
|
|
.preboot_device_inited:
|
2008-02-07 15:07:20 +03:00
|
|
|
|
; following 6 lines set variables to 1 if its current value is 0
|
2008-02-10 14:48:23 +03:00
|
|
|
|
cmp byte [di+preboot_dma-preboot_device], 1
|
|
|
|
|
adc byte [di+preboot_dma-preboot_device], 0
|
|
|
|
|
cmp byte [di+preboot_biosdisk-preboot_device], 1
|
|
|
|
|
adc byte [di+preboot_biosdisk-preboot_device], 0
|
|
|
|
|
cmp byte [di+preboot_vrrm-preboot_device], 1
|
|
|
|
|
adc byte [di+preboot_vrrm-preboot_device], 0
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; notify user
|
2008-02-07 15:07:20 +03:00
|
|
|
|
_setcursor 5,2
|
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov si, linef
|
2008-02-07 15:07:20 +03:00
|
|
|
|
call printplain
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov si, start_msg
|
|
|
|
|
call print
|
|
|
|
|
mov si, time_msg
|
|
|
|
|
call print
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; get start time
|
2007-05-21 17:25:02 +04:00
|
|
|
|
call .gettime
|
|
|
|
|
mov [.starttime], eax
|
|
|
|
|
mov word [.timer], .newtimer
|
|
|
|
|
mov word [.timer+2], cs
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.printcfg:
|
2008-12-07 02:03:47 +03:00
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
_setcursor 9,0
|
|
|
|
|
mov si, current_cfg_msg
|
|
|
|
|
call print
|
|
|
|
|
mov si, curvideo_msg
|
|
|
|
|
call print
|
2008-02-07 15:07:20 +03:00
|
|
|
|
|
|
|
|
|
call draw_current_vmode
|
|
|
|
|
|
2008-02-04 18:31:59 +03:00
|
|
|
|
mov si, usebd_msg
|
|
|
|
|
cmp [preboot_biosdisk], 1
|
|
|
|
|
call .say_on_off
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov si, vrrm_msg
|
|
|
|
|
cmp [preboot_vrrm], 1
|
|
|
|
|
call .say_on_off
|
|
|
|
|
mov si, preboot_device_msg
|
|
|
|
|
call print
|
|
|
|
|
mov al, [preboot_device]
|
2007-06-17 19:40:48 +04:00
|
|
|
|
and eax, 7
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov si, [preboot_device_msgs+eax*2]
|
|
|
|
|
call printplain
|
2008-02-10 14:48:23 +03:00
|
|
|
|
.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
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.wait:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
_setcursor 25,0 ; out of screen
|
2006-01-11 12:46:06 +03:00
|
|
|
|
; set timer interrupt handler
|
2007-05-21 17:25:02 +04:00
|
|
|
|
cli
|
|
|
|
|
push 0
|
|
|
|
|
pop es
|
2008-02-07 15:07:20 +03:00
|
|
|
|
push dword [es:8*4]
|
|
|
|
|
pop dword [.oldtimer]
|
|
|
|
|
push dword [.timer]
|
|
|
|
|
pop dword [es:8*4]
|
|
|
|
|
; mov eax, [es:8*4]
|
|
|
|
|
; mov [.oldtimer], eax
|
|
|
|
|
; mov eax, [.timer]
|
|
|
|
|
; mov [es:8*4], eax
|
2007-05-21 17:25:02 +04:00
|
|
|
|
sti
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; wait for keypressed
|
2008-02-07 15:07:20 +03:00
|
|
|
|
xor ax,ax
|
2007-05-21 17:25:02 +04:00
|
|
|
|
int 16h
|
|
|
|
|
push ax
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; restore timer interrupt
|
2008-02-07 15:07:20 +03:00
|
|
|
|
; push 0
|
|
|
|
|
; pop es
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov eax, [.oldtimer]
|
|
|
|
|
mov [es:8*4], eax
|
|
|
|
|
mov [.timer], eax
|
2008-12-07 02:03:47 +03:00
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
_setcursor 7,0
|
|
|
|
|
mov si, space_msg
|
|
|
|
|
call printplain
|
2008-02-10 14:48:23 +03:00
|
|
|
|
; clear remarks and restore normal attributes
|
|
|
|
|
push es
|
|
|
|
|
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
|
2007-05-21 17:25:02 +04:00
|
|
|
|
pop ax
|
2005-12-14 11:09:29 +03:00
|
|
|
|
; switch on key
|
2007-05-21 17:25:02 +04:00
|
|
|
|
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'
|
2008-02-10 14:48:23 +03:00
|
|
|
|
jnz .show_remarks
|
2007-05-21 17:25:02 +04:00
|
|
|
|
_setcursor 15,0
|
|
|
|
|
mov si, bdev
|
|
|
|
|
call print
|
2007-06-17 19:40:48 +04:00
|
|
|
|
mov bx, '14'
|
2007-05-21 17:25:02 +04:00
|
|
|
|
call getkey
|
|
|
|
|
mov [preboot_device], al
|
|
|
|
|
_setcursor 13,0
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.d:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov [.bSettingsChanged], 1
|
2008-02-07 15:07:20 +03:00
|
|
|
|
call clear_vmodes_table ;clear vmodes_table
|
2007-05-21 17:25:02 +04:00
|
|
|
|
jmp .printcfg
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.change_a:
|
2008-02-07 15:07:20 +03:00
|
|
|
|
.loops:
|
|
|
|
|
call draw_vmodes_table
|
2008-07-04 10:15:05 +04:00
|
|
|
|
_setcursor 25,0 ; out of screen
|
2008-02-07 15:07:20 +03:00
|
|
|
|
xor ax,ax
|
|
|
|
|
int 0x16
|
|
|
|
|
; call clear_table_cursor ;clear current position of cursor
|
|
|
|
|
|
|
|
|
|
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
|
2008-02-11 12:08:05 +03:00
|
|
|
|
jne .pgup
|
2008-02-07 15:07:20 +03:00
|
|
|
|
cmp word[es:si+10],-1
|
|
|
|
|
je .loops
|
|
|
|
|
add word [cursor_pos],size_of_step
|
|
|
|
|
jmp .loops
|
|
|
|
|
|
2008-02-11 12:08:05 +03:00
|
|
|
|
.pgup: cmp ah,0x49 ; page up
|
|
|
|
|
jne .pgdn
|
2008-02-11 14:46:18 +03:00
|
|
|
|
sub si, size_of_step*long_v_table
|
2008-02-11 12:08:05 +03:00
|
|
|
|
cmp si, modes_table
|
|
|
|
|
jae @f
|
|
|
|
|
mov si, modes_table
|
|
|
|
|
@@:
|
|
|
|
|
mov word [cursor_pos], si
|
|
|
|
|
mov si, word [home_cursor]
|
2008-02-11 14:46:18 +03:00
|
|
|
|
sub si, size_of_step*long_v_table
|
2008-02-11 12:08:05 +03:00
|
|
|
|
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]
|
2008-02-11 14:46:18 +03:00
|
|
|
|
add si, size_of_step*long_v_table
|
2008-02-11 12:08:05 +03:00
|
|
|
|
cmp si, ax
|
|
|
|
|
jb @f
|
|
|
|
|
mov si, ax
|
|
|
|
|
sub si, size_of_step
|
|
|
|
|
@@:
|
|
|
|
|
mov word [cursor_pos], si
|
|
|
|
|
mov si, word [home_cursor]
|
2008-02-11 14:46:18 +03:00
|
|
|
|
sub ax, size_of_step*long_v_table
|
|
|
|
|
add si, size_of_step*long_v_table
|
2008-02-11 12:08:05 +03:00
|
|
|
|
cmp si, ax
|
|
|
|
|
jb @f
|
|
|
|
|
mov si, ax
|
|
|
|
|
@@:
|
|
|
|
|
mov word [home_cursor], si
|
|
|
|
|
jmp .loops
|
|
|
|
|
|
2008-02-07 15:07:20 +03:00
|
|
|
|
.enter: cmp al,0x0D;x,0x1C0D ; enter
|
|
|
|
|
jne .loops
|
|
|
|
|
push word [cursor_pos]
|
2008-02-18 14:37:45 +03:00
|
|
|
|
pop bp
|
|
|
|
|
push word [es:bp]
|
|
|
|
|
pop word [x_save]
|
|
|
|
|
push word [es:bp+2]
|
|
|
|
|
pop word [y_save]
|
2008-07-04 10:15:05 +04:00
|
|
|
|
push word [es:bp+6]
|
2008-02-19 09:04:16 +03:00
|
|
|
|
pop word [number_vm]
|
2008-02-18 14:37:45 +03:00
|
|
|
|
mov word [preboot_graph],bp ;save choose
|
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
jmp .d
|
2008-02-07 15:07:20 +03:00
|
|
|
|
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.change_b:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
_setcursor 15,0
|
2008-02-04 18:31:59 +03:00
|
|
|
|
; mov si, ask_dma
|
|
|
|
|
; call print
|
|
|
|
|
; mov bx, '13'
|
|
|
|
|
; call getkey
|
|
|
|
|
; mov [preboot_dma], al
|
|
|
|
|
mov si, ask_bd
|
2007-05-21 17:25:02 +04:00
|
|
|
|
call print
|
2008-02-04 18:31:59 +03:00
|
|
|
|
mov bx, '12'
|
2007-05-21 17:25:02 +04:00
|
|
|
|
call getkey
|
2008-02-04 18:31:59 +03:00
|
|
|
|
mov [preboot_biosdisk], al
|
2007-05-21 17:25:02 +04:00
|
|
|
|
_setcursor 11,0
|
|
|
|
|
jmp .d
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.change_c:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
_setcursor 15,0
|
|
|
|
|
mov si, vrrmprint
|
|
|
|
|
call print
|
|
|
|
|
mov bx, '12'
|
|
|
|
|
call getkey
|
|
|
|
|
mov [preboot_vrrm], al
|
|
|
|
|
_setcursor 12,0
|
|
|
|
|
jmp .d
|
2008-02-07 15:07:20 +03:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2006-01-25 16:19:21 +03:00
|
|
|
|
.say_on_off:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
pushf
|
|
|
|
|
call print
|
|
|
|
|
mov si, on_msg
|
|
|
|
|
popf
|
|
|
|
|
jz @f
|
|
|
|
|
mov si, off_msg
|
|
|
|
|
@@: jmp printplain
|
2006-01-25 16:19:21 +03:00
|
|
|
|
; novesa and vervesa strings are not used at the moment of executing this code
|
|
|
|
|
virtual at novesa
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.oldtimer dd ?
|
|
|
|
|
.starttime dd ?
|
|
|
|
|
.bSettingsChanged db ?
|
2006-01-11 12:46:06 +03:00
|
|
|
|
.timer dd ?
|
2006-01-25 16:19:21 +03:00
|
|
|
|
end virtual
|
2006-08-31 16:56:29 +04:00
|
|
|
|
.loader_block dd -1
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.gettime:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov ah, 0
|
|
|
|
|
int 1Ah
|
|
|
|
|
xchg ax, cx
|
|
|
|
|
shl eax, 10h
|
|
|
|
|
xchg ax, dx
|
|
|
|
|
ret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.newtimer:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
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
|
2005-12-14 11:09:29 +03:00
|
|
|
|
if lang eq ru
|
|
|
|
|
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5 ᥪ㭤, 4/3/2 ᥪ㭤<EFBFBD>, 1 ᥪ㭤<EFBFBD>
|
2007-05-21 17:25:02 +04:00
|
|
|
|
cmp al, 5
|
|
|
|
|
mov cl, ' '
|
|
|
|
|
jae @f
|
|
|
|
|
cmp al, 1
|
|
|
|
|
mov cl, '<27>'
|
|
|
|
|
jz @f
|
|
|
|
|
mov cl, '<27>'
|
|
|
|
|
@@: mov [time_str+9], cl
|
2007-01-13 23:34:33 +03:00
|
|
|
|
else if lang eq et
|
2007-05-21 17:25:02 +04:00
|
|
|
|
cmp al, 1
|
|
|
|
|
ja @f
|
|
|
|
|
mov [time_str+9], ' '
|
|
|
|
|
mov [time_str+10],' '
|
2007-03-01 23:32:19 +03:00
|
|
|
|
@@:
|
2005-12-14 11:09:29 +03:00
|
|
|
|
else
|
|
|
|
|
; wait 5/4/3/2 seconds, 1 second
|
2007-05-21 17:25:02 +04:00
|
|
|
|
cmp al, 1
|
|
|
|
|
mov cl, 's'
|
|
|
|
|
ja @f
|
|
|
|
|
mov cl, ' '
|
|
|
|
|
@@: mov [time_str+9], cl
|
2005-12-14 11:09:29 +03:00
|
|
|
|
end if
|
2007-05-21 17:25:02 +04:00
|
|
|
|
add al, '0'
|
|
|
|
|
mov [time_str+1], al
|
|
|
|
|
mov si, time_msg
|
|
|
|
|
_setcursor 7,0
|
|
|
|
|
call print
|
|
|
|
|
_setcursor 25,0
|
|
|
|
|
popad
|
|
|
|
|
pop ds
|
|
|
|
|
iret
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.timergo:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
push 0
|
|
|
|
|
pop es
|
|
|
|
|
mov eax, [.oldtimer]
|
|
|
|
|
mov [es:8*4], eax
|
|
|
|
|
mov sp, 0EC00h
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.continue:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
sti
|
|
|
|
|
_setcursor 6,0
|
|
|
|
|
mov si, space_msg
|
|
|
|
|
call printplain
|
|
|
|
|
call printplain
|
|
|
|
|
_setcursor 6,0
|
|
|
|
|
mov si, loading_msg
|
|
|
|
|
call print
|
|
|
|
|
_setcursor 15,0
|
|
|
|
|
cmp [.bSettingsChanged], 0
|
|
|
|
|
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
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.waityn:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
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
|
2008-12-07 02:03:47 +03:00
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
pop eax
|
|
|
|
|
push cs
|
|
|
|
|
push .cont
|
|
|
|
|
push eax
|
2008-12-07 02:03:47 +03:00
|
|
|
|
retf ;call back
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.loadc:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
pop eax
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.cont:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
|
|
|
|
mov si, space_msg
|
|
|
|
|
mov byte [si+80], 0
|
|
|
|
|
_setcursor 15,0
|
|
|
|
|
call printplain
|
|
|
|
|
_setcursor 15,0
|
2005-12-14 11:09:29 +03:00
|
|
|
|
.load:
|
|
|
|
|
; \end{diamond}[02.12.2005]
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
; ASK GRAPHICS MODE
|
|
|
|
|
|
2008-02-07 15:07:20 +03:00
|
|
|
|
call set_vmode
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
; GRAPHICS ACCELERATION
|
2007-02-14 19:01:07 +03:00
|
|
|
|
; force yes
|
|
|
|
|
mov [es:0x901C], byte 1
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
; DMA ACCESS TO HD
|
2007-02-14 19:01:07 +03:00
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov al, [preboot_dma]
|
|
|
|
|
mov [es:0x901F], al
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
; VRR_M USE
|
|
|
|
|
|
2007-04-18 10:37:14 +04:00
|
|
|
|
mov al,[preboot_vrrm]
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov [es:0x9030], al
|
|
|
|
|
mov [es:0x901E], byte 1
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
; BOOT DEVICE
|
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov al, [preboot_device]
|
2006-01-25 16:19:21 +03:00
|
|
|
|
dec al
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov [boot_dev], al
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
; READ DISKETTE TO MEMORY
|
|
|
|
|
|
2007-04-18 10:37:14 +04:00
|
|
|
|
; cmp [boot_dev],0
|
2005-10-06 21:56:22 +04:00
|
|
|
|
jne no_sys_on_floppy
|
2007-04-18 10:37:14 +04:00
|
|
|
|
mov si,diskload
|
2005-10-06 21:56:22 +04:00
|
|
|
|
call print
|
2007-05-21 17:25:02 +04:00
|
|
|
|
xor ax, ax ; reset drive
|
|
|
|
|
xor dx, dx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
int 0x13
|
2008-02-04 18:31:59 +03:00
|
|
|
|
; do we boot from CD-ROM?
|
|
|
|
|
mov ah, 41h
|
|
|
|
|
mov bx, 55AAh
|
|
|
|
|
xor dx, dx
|
|
|
|
|
int 0x13
|
|
|
|
|
jc .nocd
|
|
|
|
|
cmp bx, 0AA55h
|
|
|
|
|
jnz .nocd
|
|
|
|
|
mov ah, 48h
|
|
|
|
|
push ds
|
|
|
|
|
push es
|
|
|
|
|
pop ds
|
|
|
|
|
mov si, 0xa000
|
|
|
|
|
mov word [si], 30
|
|
|
|
|
int 0x13
|
|
|
|
|
pop ds
|
|
|
|
|
jc .nocd
|
|
|
|
|
push ds
|
|
|
|
|
lds si, [es:si+26]
|
|
|
|
|
test byte [ds:si+10], 40h
|
|
|
|
|
pop ds
|
|
|
|
|
jz .nocd
|
|
|
|
|
; yes - read all floppy by 18 sectors
|
2008-04-28 23:12:24 +04:00
|
|
|
|
|
|
|
|
|
; TODO: !!!! read only first sector and set variables !!!!!
|
|
|
|
|
; ...
|
|
|
|
|
; TODO: !!! then read flippy image track by track
|
|
|
|
|
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov cx, 0x0001 ; startcyl,startsector
|
2008-02-04 18:31:59 +03:00
|
|
|
|
.a1:
|
|
|
|
|
push cx dx
|
|
|
|
|
mov al, 18
|
|
|
|
|
mov bx, 0xa000
|
|
|
|
|
call boot_read_floppy
|
|
|
|
|
mov si, movedesc
|
|
|
|
|
push es
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
|
|
|
|
mov cx, 256*18
|
|
|
|
|
mov ah, 0x87
|
|
|
|
|
int 0x15
|
|
|
|
|
pop es
|
|
|
|
|
pop dx cx
|
|
|
|
|
test ah, ah
|
|
|
|
|
jnz sayerr_floppy
|
|
|
|
|
add dword [si+8*3+2], 512*18
|
|
|
|
|
inc dh
|
|
|
|
|
cmp dh, 2
|
|
|
|
|
jnz .a1
|
|
|
|
|
mov dh, 0
|
|
|
|
|
inc ch
|
|
|
|
|
cmp ch, 80
|
|
|
|
|
jae ok_sys_on_floppy
|
|
|
|
|
pusha
|
|
|
|
|
mov al, ch
|
|
|
|
|
shr ch, 2
|
|
|
|
|
add al, ch
|
|
|
|
|
aam
|
|
|
|
|
xchg al, ah
|
|
|
|
|
add ax, '00'
|
|
|
|
|
mov si, pros
|
|
|
|
|
mov [si], ax
|
|
|
|
|
call printplain
|
|
|
|
|
popa
|
|
|
|
|
jmp .a1
|
|
|
|
|
.nocd:
|
|
|
|
|
; no - read only used sectors from floppy
|
2006-08-24 16:33:31 +04:00
|
|
|
|
; now load floppy image to memory
|
|
|
|
|
; at first load boot sector and first FAT table
|
2008-04-28 23:12:24 +04:00
|
|
|
|
|
|
|
|
|
; read only first sector and fill variables
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov cx, 0x0001 ; first logical sector
|
|
|
|
|
xor dx, dx ; head = 0, drive = 0 (a:)
|
|
|
|
|
mov al, 1 ; read one sector
|
|
|
|
|
mov bx, 0xB000 ; es:bx -> data area
|
|
|
|
|
call boot_read_floppy
|
2008-04-28 23:12:24 +04:00
|
|
|
|
; fill the necessary parameters to work with a floppy
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov ax, word [es:bx+24]
|
|
|
|
|
mov word [BPB_SecPerTrk], ax
|
|
|
|
|
mov ax, word [es:bx+26]
|
|
|
|
|
mov word [BPB_NumHeads], ax
|
|
|
|
|
mov ax, word [es:bx+17]
|
|
|
|
|
mov word [BPB_RootEntCnt], ax
|
|
|
|
|
mov ax, word [es:bx+14]
|
|
|
|
|
mov word [BPB_RsvdSecCnt], ax
|
|
|
|
|
mov ax, word [es:bx+19]
|
|
|
|
|
mov word [BPB_TotSec16], ax
|
|
|
|
|
mov al, byte [es:bx+13]
|
|
|
|
|
mov byte [BPB_SecPerClus], al
|
|
|
|
|
mov al, byte [es:bx+16]
|
|
|
|
|
mov byte [BPB_NumFATs], al
|
2008-11-18 10:29:09 +03:00
|
|
|
|
;<Lrz> 18.11.2008
|
|
|
|
|
mov ax, word [es:bx+22]
|
|
|
|
|
mov word [BPB_FATSz16], ax
|
|
|
|
|
mov cx, word [es:bx+11]
|
|
|
|
|
mov word [BPB_BytsPerSec], cx
|
|
|
|
|
|
2008-04-28 23:12:24 +04:00
|
|
|
|
; count of clusters in FAT12 ((size_of_FAT*2)/3)
|
2008-11-18 10:29:09 +03:00
|
|
|
|
; mov ax, word [BPB_FATSz16]
|
|
|
|
|
; mov cx, word [BPB_BytsPerSec]
|
|
|
|
|
;end <Lrz> 18.11.2008
|
2008-07-04 10:15:05 +04:00
|
|
|
|
xor dx, dx
|
|
|
|
|
mul cx
|
|
|
|
|
shl ax, 1
|
|
|
|
|
mov cx, 3
|
|
|
|
|
div cx ; now ax - number of clusters in FAT12
|
|
|
|
|
mov word [end_of_FAT], ax
|
2008-04-28 23:12:24 +04:00
|
|
|
|
|
|
|
|
|
; load first FAT table
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov cx, 0x0002 ; startcyl,startsector ; TODO!!!!!
|
2006-08-24 16:33:31 +04:00
|
|
|
|
xor dx, dx ; starthead,drive
|
2008-04-28 23:12:24 +04:00
|
|
|
|
mov al, byte [BPB_FATSz16] ; no of sectors to read
|
|
|
|
|
add bx, word [BPB_BytsPerSec] ; es:bx -> data area
|
2006-08-24 16:33:31 +04:00
|
|
|
|
call boot_read_floppy
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov bx, 0xB000
|
2008-04-28 23:12:24 +04:00
|
|
|
|
|
2006-08-24 16:33:31 +04:00
|
|
|
|
; and copy them to extended memory
|
2007-04-18 10:37:14 +04:00
|
|
|
|
mov si, movedesc
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov [si+8*2+3], bh ; from
|
|
|
|
|
|
|
|
|
|
mov ax, word [BPB_BytsPerSec]
|
|
|
|
|
shr ax, 1 ; words per sector
|
|
|
|
|
mov cx, word [BPB_RsvdSecCnt]
|
|
|
|
|
add cx, word [BPB_FATSz16]
|
|
|
|
|
mul cx
|
|
|
|
|
push ax ; save to stack count of words in boot+FAT
|
|
|
|
|
xchg ax, cx
|
|
|
|
|
|
2006-08-24 16:33:31 +04:00
|
|
|
|
push es
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
|
|
|
|
mov ah, 0x87
|
|
|
|
|
int 0x15
|
2008-07-04 10:15:05 +04:00
|
|
|
|
pop es
|
2006-05-06 18:34:30 +04:00
|
|
|
|
test ah, ah
|
2006-08-24 16:33:31 +04:00
|
|
|
|
jz @f
|
|
|
|
|
sayerr_floppy:
|
|
|
|
|
mov dx, 0x3f2
|
|
|
|
|
mov al, 0
|
|
|
|
|
out dx, al
|
2007-04-18 10:37:14 +04:00
|
|
|
|
mov si, memmovefailed
|
2006-08-24 16:33:31 +04:00
|
|
|
|
jmp sayerr_plain
|
|
|
|
|
@@:
|
2008-07-04 10:15:05 +04:00
|
|
|
|
pop ax ; restore from stack count of words in boot+FAT
|
|
|
|
|
shl ax, 1 ; make bytes count from count of words
|
|
|
|
|
and eax, 0ffffh
|
2008-04-28 23:12:24 +04:00
|
|
|
|
add dword [si+8*3+2], eax
|
|
|
|
|
|
|
|
|
|
; copy first FAT to second copy
|
|
|
|
|
; TODO: BPB_NumFATs !!!!!
|
2008-07-04 10:15:05 +04:00
|
|
|
|
add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!!
|
|
|
|
|
mov byte [si+8*2+3], bh ; bx - begin of FAT
|
|
|
|
|
|
|
|
|
|
mov ax, word [BPB_BytsPerSec]
|
|
|
|
|
shr ax, 1 ; words per sector
|
|
|
|
|
mov cx, word [BPB_FATSz16]
|
|
|
|
|
mul cx
|
|
|
|
|
mov cx, ax ; cx - count of words in FAT
|
2008-04-28 23:12:24 +04:00
|
|
|
|
|
|
|
|
|
push es
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2006-08-24 16:33:31 +04:00
|
|
|
|
mov ah, 0x87
|
|
|
|
|
int 0x15
|
|
|
|
|
pop es
|
|
|
|
|
test ah, ah
|
|
|
|
|
jnz sayerr_floppy
|
2008-07-04 10:15:05 +04:00
|
|
|
|
|
|
|
|
|
mov ax, cx
|
|
|
|
|
shl ax, 1
|
|
|
|
|
and eax, 0ffffh ; ax - count of bytes in FAT
|
2008-04-28 23:12:24 +04:00
|
|
|
|
add dword [si+8*3+2], eax
|
2008-07-04 10:15:05 +04:00
|
|
|
|
|
2008-04-28 23:12:24 +04:00
|
|
|
|
; reading RootDir
|
|
|
|
|
; TODO: BPB_NumFATs
|
2008-07-04 10:15:05 +04:00
|
|
|
|
add bx, ax
|
|
|
|
|
add bx, 100h
|
|
|
|
|
and bx, 0ff00h ; bx - place in buffer to write RootDir
|
|
|
|
|
push bx
|
|
|
|
|
|
|
|
|
|
mov bx, word [BPB_BytsPerSec]
|
|
|
|
|
shr bx, 5 ; divide bx by 32
|
|
|
|
|
mov ax, word [BPB_RootEntCnt]
|
|
|
|
|
xor dx, dx
|
|
|
|
|
div bx
|
|
|
|
|
push ax ; ax - count of RootDir sectors
|
|
|
|
|
|
|
|
|
|
mov ax, word [BPB_FATSz16]
|
|
|
|
|
xor cx, cx
|
|
|
|
|
mov cl, byte [BPB_NumFATs]
|
|
|
|
|
mul cx
|
|
|
|
|
add ax, word [BPB_RsvdSecCnt] ; ax - first sector of RootDir
|
|
|
|
|
|
|
|
|
|
mov word [FirstDataSector], ax
|
|
|
|
|
pop bx
|
|
|
|
|
push bx
|
|
|
|
|
add word [FirstDataSector], bx ; Begin of data region of floppy
|
|
|
|
|
|
2008-04-28 23:12:24 +04:00
|
|
|
|
; read RootDir
|
2008-07-04 10:15:05 +04:00
|
|
|
|
call conv_abs_to_THS
|
|
|
|
|
pop ax
|
|
|
|
|
pop bx ; place in buffer to write
|
|
|
|
|
push ax
|
|
|
|
|
call boot_read_floppy ; read RootDir into buffer
|
2008-04-28 23:12:24 +04:00
|
|
|
|
; copy RootDir
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov byte [si+8*2+3], bh ; from buffer
|
|
|
|
|
pop ax ; ax = count of RootDir sectors
|
|
|
|
|
mov cx, word [BPB_BytsPerSec]
|
|
|
|
|
mul cx
|
|
|
|
|
shr ax, 1
|
|
|
|
|
mov cx, ax ; count of words to copy
|
|
|
|
|
push es
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2008-04-28 23:12:24 +04:00
|
|
|
|
mov ah, 0x87
|
|
|
|
|
int 0x15
|
2008-07-04 10:15:05 +04:00
|
|
|
|
pop es
|
2008-04-28 23:12:24 +04:00
|
|
|
|
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov ax, cx
|
|
|
|
|
shl ax, 1
|
|
|
|
|
and eax, 0ffffh ; ax - count of bytes in RootDir
|
|
|
|
|
add dword [si+8*3+2], eax ; add count of bytes copied
|
2008-04-28 23:12:24 +04:00
|
|
|
|
|
|
|
|
|
; Reading data clusters from floppy
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov byte [si+8*2+3], bh
|
|
|
|
|
push bx
|
2008-04-28 23:12:24 +04:00
|
|
|
|
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov di, 2 ; First data cluster
|
2006-08-24 16:33:31 +04:00
|
|
|
|
.read_loop:
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov bx, di
|
|
|
|
|
shr bx, 1 ; bx+di = di*1.5
|
|
|
|
|
jnc .even
|
|
|
|
|
test word [es:bx+di+0xB200], 0xFFF0 ; TODO: may not be 0xB200 !!!
|
|
|
|
|
jmp @f
|
2006-08-24 16:33:31 +04:00
|
|
|
|
.even:
|
2008-07-04 10:15:05 +04:00
|
|
|
|
test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!!
|
2008-04-28 23:12:24 +04:00
|
|
|
|
|
2006-08-24 16:33:31 +04:00
|
|
|
|
@@:
|
2008-07-04 10:15:05 +04:00
|
|
|
|
jz .skip
|
2008-04-28 23:12:24 +04:00
|
|
|
|
; read cluster di
|
|
|
|
|
;.read:
|
2008-07-04 10:15:05 +04:00
|
|
|
|
;conv cluster di to abs. sector ax
|
|
|
|
|
; ax = (N-2) * BPB_SecPerClus + FirstDataSector
|
|
|
|
|
mov ax, di
|
|
|
|
|
sub ax, 2
|
|
|
|
|
xor bx, bx
|
|
|
|
|
mov bl, byte [BPB_SecPerClus]
|
|
|
|
|
mul bx
|
|
|
|
|
add ax, word [FirstDataSector]
|
|
|
|
|
call conv_abs_to_THS
|
|
|
|
|
pop bx
|
|
|
|
|
push bx
|
|
|
|
|
mov al, byte [BPB_SecPerClus] ; number of sectors in cluster
|
|
|
|
|
call boot_read_floppy
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push es
|
|
|
|
|
push ds
|
2005-10-06 21:56:22 +04:00
|
|
|
|
pop es
|
2006-08-24 16:33:31 +04:00
|
|
|
|
pusha
|
2008-04-28 23:12:24 +04:00
|
|
|
|
;
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov ax, word [BPB_BytsPerSec]
|
|
|
|
|
xor cx, cx
|
|
|
|
|
mov cl, byte [BPB_SecPerClus]
|
|
|
|
|
mul cx
|
|
|
|
|
shr ax, 1 ; ax = (BPB_BytsPerSec * BPB_SecPerClus)/2
|
|
|
|
|
mov cx, ax ; number of words to copy (count words in cluster)
|
2008-04-28 23:12:24 +04:00
|
|
|
|
;
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov ah, 0x87
|
|
|
|
|
int 0x15 ; copy data
|
2006-08-24 16:33:31 +04:00
|
|
|
|
test ah, ah
|
2005-10-06 21:56:22 +04:00
|
|
|
|
popa
|
2006-08-24 16:33:31 +04:00
|
|
|
|
pop es
|
|
|
|
|
jnz sayerr_floppy
|
2008-04-28 23:12:24 +04:00
|
|
|
|
; skip cluster di
|
2006-08-24 16:33:31 +04:00
|
|
|
|
.skip:
|
2008-07-04 10:15:05 +04:00
|
|
|
|
mov ax, word [BPB_BytsPerSec]
|
|
|
|
|
xor cx, cx
|
|
|
|
|
mov cl, byte [BPB_SecPerClus]
|
|
|
|
|
mul cx
|
|
|
|
|
and eax, 0ffffh ; ax - count of bytes in cluster
|
|
|
|
|
add dword [si+8*3+2], eax
|
|
|
|
|
|
|
|
|
|
mov ax, word [end_of_FAT] ; max cluster number
|
2006-08-24 16:33:31 +04:00
|
|
|
|
pusha
|
|
|
|
|
; draw percentage
|
2008-04-28 23:12:24 +04:00
|
|
|
|
; total clusters: ax
|
|
|
|
|
; read clusters: di
|
2008-07-04 10:15:05 +04:00
|
|
|
|
xchg ax, di
|
2006-08-24 16:33:31 +04:00
|
|
|
|
mov cx, 100
|
|
|
|
|
mul cx
|
2008-07-04 10:15:05 +04:00
|
|
|
|
div di
|
2006-08-24 16:33:31 +04:00
|
|
|
|
aam
|
|
|
|
|
xchg al, ah
|
|
|
|
|
add ax, '00'
|
2007-04-18 10:37:14 +04:00
|
|
|
|
mov si, pros
|
2006-08-24 16:33:31 +04:00
|
|
|
|
cmp [si], ax
|
|
|
|
|
jz @f
|
|
|
|
|
mov [si], ax
|
|
|
|
|
call printplain
|
|
|
|
|
@@:
|
|
|
|
|
popa
|
|
|
|
|
inc di
|
2008-07-04 10:15:05 +04:00
|
|
|
|
cmp di, word [end_of_FAT] ; max number of cluster
|
2006-08-24 16:33:31 +04:00
|
|
|
|
jnz .read_loop
|
2008-07-04 10:15:05 +04:00
|
|
|
|
pop bx ; clear stack
|
2007-04-18 10:37:14 +04:00
|
|
|
|
|
2008-02-04 18:31:59 +03:00
|
|
|
|
ok_sys_on_floppy:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov si, backspace2
|
2005-10-06 21:56:22 +04:00
|
|
|
|
call printplain
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov si, okt
|
2005-10-06 21:56:22 +04:00
|
|
|
|
call printplain
|
2007-05-21 17:25:02 +04:00
|
|
|
|
no_sys_on_floppy:
|
|
|
|
|
xor ax, ax ; reset drive
|
|
|
|
|
xor dx, dx
|
2005-10-06 21:56:22 +04:00
|
|
|
|
int 0x13
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov dx, 0x3f2 ; floppy motor off
|
|
|
|
|
mov al, 0
|
|
|
|
|
out dx, al
|
2005-10-06 21:56:22 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; SET GRAPHICS
|
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
xor ax, ax
|
|
|
|
|
mov es, ax
|
2006-10-06 10:09:41 +04:00
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov ax, [es:0x9008] ; vga & 320x200
|
|
|
|
|
mov bx, ax
|
|
|
|
|
cmp ax, 0x13
|
2005-10-06 21:56:22 +04:00
|
|
|
|
je setgr
|
2007-05-21 17:25:02 +04:00
|
|
|
|
cmp ax, 0x12
|
2005-10-06 21:56:22 +04:00
|
|
|
|
je setgr
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov ax, 0x4f02 ; Vesa
|
2007-03-10 19:04:35 +03:00
|
|
|
|
setgr:
|
2005-10-06 21:56:22 +04:00
|
|
|
|
int 0x10
|
2007-05-21 17:25:02 +04:00
|
|
|
|
test ah, ah
|
|
|
|
|
mov si, fatalsel
|
2008-02-07 15:07:20 +03:00
|
|
|
|
jnz v_mode_error
|
2005-10-06 21:56:22 +04:00
|
|
|
|
; set mode 0x12 graphics registers:
|
2007-05-21 17:25:02 +04:00
|
|
|
|
cmp bx, 0x12
|
2005-10-06 21:56:22 +04:00
|
|
|
|
jne gmok2
|
|
|
|
|
|
2007-05-21 17:25:02 +04:00
|
|
|
|
mov al, 0x05
|
|
|
|
|
mov dx, 0x03ce
|
2006-01-25 16:19:21 +03:00
|
|
|
|
push dx
|
2007-05-21 17:25:02 +04:00
|
|
|
|
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
|
2005-10-06 21:56:22 +04:00
|
|
|
|
; for writes to 0x03cf
|
2007-03-10 19:04:35 +03:00
|
|
|
|
gmok2:
|
2006-05-06 18:34:30 +04:00
|
|
|
|
push ds
|
2007-05-21 17:25:02 +04:00
|
|
|
|
pop es
|