Rev 795 | Rev 925 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 795 | Rev 816 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;; BOOTCODE.INC ;; |
7 | ;; BOOTCODE.INC ;; |
8 | ;; ;; |
8 | ;; ;; |
9 | ;; KolibriOS 16-bit loader, ;; |
9 | ;; KolibriOS 16-bit loader, ;; |
10 | ;; based on bootcode for MenuetOS ;; |
10 | ;; based on bootcode for MenuetOS ;; |
11 | ;; ;; |
11 | ;; ;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
13 | 13 | ||
14 | $Revision: 795 $ |
14 | $Revision: 816 $ |
15 | 15 | ||
16 | 16 | ||
17 | ;========================================================================== |
17 | ;========================================================================== |
18 | ; |
18 | ; |
19 | ; 16 BIT FUNCTIONS |
19 | ; 16 BIT FUNCTIONS |
20 | ; |
20 | ; |
21 | ;========================================================================== |
21 | ;========================================================================== |
22 | 22 | ||
23 | 23 | ||
24 | putchar: |
24 | putchar: |
25 | ; in: al=character |
25 | ; in: al=character |
26 | mov ah, 0Eh |
26 | mov ah, 0Eh |
27 | mov bh, 0 |
27 | mov bh, 0 |
28 | int 10h |
28 | int 10h |
29 | ret |
29 | ret |
30 | 30 | ||
31 | print: |
31 | print: |
32 | ; in: si->string |
32 | ; in: si->string |
33 | mov al, 186 |
33 | mov al, 186 |
34 | call putchar |
34 | call putchar |
35 | mov al, ' ' |
35 | mov al, ' ' |
36 | call putchar |
36 | call putchar |
37 | 37 | ||
38 | printplain: |
38 | printplain: |
39 | ; in: si->string |
39 | ; in: si->string |
40 | pusha |
40 | pusha |
41 | lodsb |
41 | lodsb |
42 | @@: |
42 | @@: |
43 | call putchar |
43 | call putchar |
44 | lodsb |
44 | lodsb |
45 | cmp al, 0 |
45 | cmp al, 0 |
46 | jnz @b |
46 | jnz @b |
47 | popa |
47 | popa |
48 | ret |
48 | ret |
49 | 49 | ||
50 | getkey: |
50 | getkey: |
51 | ; get number in range [bl,bh] (bl,bh in ['0'..'9']) |
51 | ; get number in range [bl,bh] (bl,bh in ['0'..'9']) |
52 | ; in: bx=range |
52 | ; in: bx=range |
53 | ; out: ax=digit (1..9, 10 for 0) |
53 | ; out: ax=digit (1..9, 10 for 0) |
54 | mov ah, 0 |
54 | mov ah, 0 |
55 | int 16h |
55 | int 16h |
56 | cmp al, bl |
56 | cmp al, bl |
57 | jb getkey |
57 | jb getkey |
58 | cmp al, bh |
58 | cmp al, bh |
59 | ja getkey |
59 | ja getkey |
60 | push ax |
60 | push ax |
61 | call putchar |
61 | call putchar |
62 | pop ax |
62 | pop ax |
63 | and ax, 0Fh |
63 | and ax, 0Fh |
64 | jnz @f |
64 | jnz @f |
65 | mov al, 10 |
65 | mov al, 10 |
66 | @@: |
66 | @@: |
67 | ret |
67 | ret |
68 | 68 | ||
69 | setcursor: |
69 | setcursor: |
70 | ; in: dl=column, dh=row |
70 | ; in: dl=column, dh=row |
71 | mov ah, 2 |
71 | mov ah, 2 |
72 | mov bh, 0 |
72 | mov bh, 0 |
73 | int 10h |
73 | int 10h |
74 | ret |
74 | ret |
75 | 75 | ||
76 | macro _setcursor row,column |
76 | macro _setcursor row,column |
77 | { |
77 | { |
78 | mov dx, row*256 + column |
78 | mov dx, row*256 + column |
79 | call setcursor |
79 | call setcursor |
80 | } |
80 | } |
81 | 81 | ||
82 | boot_read_floppy: |
82 | boot_read_floppy: |
83 | push si |
83 | push si |
84 | xor si, si |
84 | xor si, si |
85 | mov ah, 2 ; read |
85 | mov ah, 2 ; read |
86 | @@: |
86 | @@: |
87 | push ax |
87 | push ax |
88 | int 0x13 |
88 | int 0x13 |
89 | pop ax |
89 | pop ax |
90 | jnc @f |
90 | jnc @f |
91 | inc si |
91 | inc si |
92 | cmp si, 10 |
92 | cmp si, 10 |
93 | jb @b |
93 | jb @b |
94 | mov si, badsect |
94 | mov si, badsect |
95 | sayerr_plain: |
95 | sayerr_plain: |
96 | call printplain |
96 | call printplain |
97 | jmp $ |
97 | jmp $ |
98 | @@: |
98 | @@: |
99 | pop si |
99 | pop si |
100 | ret |
100 | ret |
101 | 101 | ||
102 | ; convert abs. sector number (AX) to BIOS T:H:S |
102 | ; convert abs. sector number (AX) to BIOS T:H:S |
103 | ; sector number = (abs.sector%BPB_SecPerTrk)+1 |
103 | ; sector number = (abs.sector%BPB_SecPerTrk)+1 |
104 | ; pre.track number = (abs.sector/BPB_SecPerTrk) |
104 | ; pre.track number = (abs.sector/BPB_SecPerTrk) |
105 | ; head number = pre.track number%BPB_NumHeads |
105 | ; head number = pre.track number%BPB_NumHeads |
106 | ; track number = pre.track number/BPB_NumHeads |
106 | ; track number = pre.track number/BPB_NumHeads |
107 | ; Return: cl - sector number |
107 | ; Return: cl - sector number |
108 | ; ch - track number |
108 | ; ch - track number |
109 | ; dl - drive number (0 = a:) |
109 | ; dl - drive number (0 = a:) |
110 | ; dh - head number |
110 | ; dh - head number |
111 | conv_abs_to_THS: |
111 | conv_abs_to_THS: |
112 | push bx |
112 | push bx |
113 | mov bx,word [BPB_SecPerTrk] |
113 | mov bx,word [BPB_SecPerTrk] |
114 | xor dx,dx |
114 | xor dx,dx |
115 | div bx |
115 | div bx |
116 | inc dx |
116 | inc dx |
117 | mov cl, dl ; cl = sector number |
117 | mov cl, dl ; cl = sector number |
118 | mov bx,word [BPB_NumHeads] |
118 | mov bx,word [BPB_NumHeads] |
119 | xor dx,dx |
119 | xor dx,dx |
120 | div bx |
120 | div bx |
121 | ; !!!!!!! ax = track number, dx = head number |
121 | ; !!!!!!! ax = track number, dx = head number |
122 | mov ch,al ; ch=track number |
122 | mov ch,al ; ch=track number |
123 | xchg dh,dl ; dh=head number |
123 | xchg dh,dl ; dh=head number |
124 | mov dl,0 ; dl=0 (drive 0 (a:)) |
124 | mov dl,0 ; dl=0 (drive 0 (a:)) |
125 | pop bx |
125 | pop bx |
126 | retn |
126 | retn |
127 | ; needed variables |
127 | ; needed variables |
128 | BPB_SecPerTrk dw 0 ; sectors per track |
128 | BPB_SecPerTrk dw 0 ; sectors per track |
129 | BPB_NumHeads dw 0 ; number of heads |
129 | BPB_NumHeads dw 0 ; number of heads |
130 | BPB_FATSz16 dw 0 ; size of FAT |
130 | BPB_FATSz16 dw 0 ; size of FAT |
131 | BPB_RootEntCnt dw 0 ; count of root dir. entries |
131 | BPB_RootEntCnt dw 0 ; count of root dir. entries |
132 | BPB_BytsPerSec dw 0 ; bytes per sector |
132 | BPB_BytsPerSec dw 0 ; bytes per sector |
133 | BPB_RsvdSecCnt dw 0 ; number of reserved sectors |
133 | BPB_RsvdSecCnt dw 0 ; number of reserved sectors |
134 | BPB_TotSec16 dw 0 ; count of the sectors on the volume |
134 | BPB_TotSec16 dw 0 ; count of the sectors on the volume |
135 | BPB_SecPerClus db 0 ; number of sectors per cluster |
135 | BPB_SecPerClus db 0 ; number of sectors per cluster |
136 | BPB_NumFATs db 0 ; number of FAT tables |
136 | BPB_NumFATs db 0 ; number of FAT tables |
137 | abs_sector_adj dw 0 ; adjustment to make abs. sector number |
137 | abs_sector_adj dw 0 ; adjustment to make abs. sector number |
138 | end_of_FAT dw 0 ; end of FAT table |
138 | end_of_FAT dw 0 ; end of FAT table |
139 | FirstDataSector dw 0 ; begin of data |
139 | FirstDataSector dw 0 ; begin of data |
140 | 140 | ||
141 | ;========================================================================= |
141 | ;========================================================================= |
142 | ; |
142 | ; |
143 | ; 16 BIT CODE |
143 | ; 16 BIT CODE |
144 | ; |
144 | ; |
145 | ;========================================================================= |
145 | ;========================================================================= |
146 | 146 | ||
147 | include 'bootvesa.inc' ;Include source for boot vesa |
147 | include 'bootvesa.inc' ;Include source for boot vesa |
148 | 148 | ||
149 | start_of_code: |
149 | start_of_code: |
150 | cld |
150 | cld |
151 | ; \begin{diamond}[02.12.2005] |
151 | ; \begin{diamond}[02.12.2005] |
152 | ; if bootloader sets ax = 'KL', then ds:si points to loader block |
152 | ; if bootloader sets ax = 'KL', then ds:si points to loader block |
153 | cmp ax, 'KL' |
153 | cmp ax, 'KL' |
154 | jnz @f |
154 | jnz @f |
155 | mov word [cs:cfgmanager.loader_block], si |
155 | mov word [cs:cfgmanager.loader_block], si |
156 | mov word [cs:cfgmanager.loader_block+2], ds |
156 | mov word [cs:cfgmanager.loader_block+2], ds |
157 | @@: |
157 | @@: |
158 | ; \end{diamond}[02.12.2005] |
158 | ; \end{diamond}[02.12.2005] |
159 | 159 | ||
160 | ; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk |
160 | ; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk |
161 | ; (see comment to bx_from_load) |
161 | ; (see comment to bx_from_load) |
162 | cmp cx, 'HA' |
162 | cmp cx, 'HA' |
163 | jnz no_hd_load |
163 | jnz no_hd_load |
164 | cmp dx,'RD' |
164 | cmp dx,'RD' |
165 | jnz no_hd_load |
165 | jnz no_hd_load |
166 | mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] |
166 | mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] |
167 | no_hd_load: |
167 | no_hd_load: |
168 | 168 | ||
169 | ; set up stack |
169 | ; set up stack |
170 | mov ax, 3000h |
170 | mov ax, 3000h |
171 | mov ss, ax |
171 | mov ss, ax |
172 | mov sp, 0EC00h |
172 | mov sp, 0EC00h |
173 | ; set up segment registers |
173 | ; set up segment registers |
174 | push cs |
174 | push cs |
175 | pop ds |
175 | pop ds |
176 | push cs |
176 | push cs |
177 | pop es |
177 | pop es |
178 | 178 | ||
179 | ; set videomode |
179 | ; set videomode |
180 | mov ax, 3 |
180 | mov ax, 3 |
181 | int 0x10 |
181 | int 0x10 |
182 | 182 | ||
183 | if lang eq ru |
183 | if lang eq ru |
184 | ; Load & set russian VGA font (RU.INC) |
184 | ; Load & set russian VGA font (RU.INC) |
185 | mov bp, RU_FNT1 ; RU_FNT1 - First part |
185 | mov bp, RU_FNT1 ; RU_FNT1 - First part |
186 | mov bx, 1000h ; 768 bytes |
186 | mov bx, 1000h ; 768 bytes |
187 | mov cx, 30h ; 48 symbols |
187 | mov cx, 30h ; 48 symbols |
188 | mov dx, 80h ; 128 - position of first symbol |
188 | mov dx, 80h ; 128 - position of first symbol |
189 | mov ax, 1100h |
189 | mov ax, 1100h |
190 | int 10h |
190 | int 10h |
191 | 191 | ||
192 | mov bp, RU_FNT2 ; RU_FNT2 -Second part |
192 | mov bp, RU_FNT2 ; RU_FNT2 -Second part |
193 | mov bx, 1000h ; 512 bytes |
193 | mov bx, 1000h ; 512 bytes |
194 | mov cx, 20h ; 32 symbols |
194 | mov cx, 20h ; 32 symbols |
195 | mov dx, 0E0h ; 224 - position of first symbol |
195 | mov dx, 0E0h ; 224 - position of first symbol |
196 | mov ax, 1100h |
196 | mov ax, 1100h |
197 | int 10h |
197 | int 10h |
198 | ; End set VGA russian font |
198 | ; End set VGA russian font |
199 | else if lang eq et |
199 | else if lang eq et |
200 | mov bp, ET_FNT ; ET_FNT1 |
200 | mov bp, ET_FNT ; ET_FNT1 |
201 | mov bx, 1000h ; |
201 | mov bx, 1000h ; |
202 | mov cx, 255 ; 256 symbols |
202 | mov cx, 255 ; 256 symbols |
203 | xor dx, dx ; 0 - position of first symbol |
203 | xor dx, dx ; 0 - position of first symbol |
204 | mov ax, 1100h |
204 | mov ax, 1100h |
205 | int 10h |
205 | int 10h |
206 | end if |
206 | end if |
207 | 207 | ||
208 | ; draw frames |
208 | ; draw frames |
209 | push 0xb800 |
209 | push 0xb800 |
210 | pop es |
210 | pop es |
211 | xor di, di |
211 | xor di, di |
212 | mov ah, 1*16+15 |
212 | mov ah, 1*16+15 |
213 | 213 | ||
214 | ; draw top |
214 | ; draw top |
215 | mov si, d80x25_top |
215 | mov si, d80x25_top |
216 | mov cx, d80x25_top_num * 80 |
216 | mov cx, d80x25_top_num * 80 |
217 | @@: |
217 | @@: |
218 | lodsb |
218 | lodsb |
219 | stosw |
219 | stosw |
220 | loop @b |
220 | loop @b |
221 | ; draw spaces |
221 | ; draw spaces |
222 | mov si, space_msg |
222 | mov si, space_msg |
223 | mov dx, 25 - d80x25_top_num - d80x25_bottom_num |
223 | mov dx, 25 - d80x25_top_num - d80x25_bottom_num |
224 | dfl1: |
224 | dfl1: |
225 | push si |
225 | push si |
226 | mov cx, 80 |
226 | mov cx, 80 |
227 | @@: |
227 | @@: |
228 | lodsb |
228 | lodsb |
229 | stosw |
229 | stosw |
230 | loop @b |
230 | loop @b |
231 | pop si |
231 | pop si |
232 | dec dx |
232 | dec dx |
233 | jnz dfl1 |
233 | jnz dfl1 |
234 | ; draw bottom |
234 | ; draw bottom |
235 | mov si, d80x25_bottom |
235 | mov si, d80x25_bottom |
236 | mov cx, d80x25_bottom_num * 80 |
236 | mov cx, d80x25_bottom_num * 80 |
237 | @@: |
237 | @@: |
238 | lodsb |
238 | lodsb |
239 | stosw |
239 | stosw |
240 | loop @b |
240 | loop @b |
241 | 241 | ||
242 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
242 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
243 | 243 | ||
244 | _setcursor d80x25_top_num,0 |
244 | _setcursor d80x25_top_num,0 |
245 | 245 | ||
246 | 246 | ||
247 | ; TEST FOR 386+ |
247 | ; TEST FOR 386+ |
248 | 248 | ||
249 | mov bx, 0x4000 |
249 | mov bx, 0x4000 |
250 | pushf |
250 | pushf |
251 | pop ax |
251 | pop ax |
252 | mov dx, ax |
252 | mov dx, ax |
253 | xor ax, bx |
253 | xor ax, bx |
254 | push ax |
254 | push ax |
255 | popf |
255 | popf |
256 | pushf |
256 | pushf |
257 | pop ax |
257 | pop ax |
258 | and ax, bx |
258 | and ax, bx |
259 | and dx, bx |
259 | and dx, bx |
260 | cmp ax, dx |
260 | cmp ax, dx |
261 | jnz cpugood |
261 | jnz cpugood |
262 | mov si, not386 |
262 | mov si, not386 |
263 | sayerr: |
263 | sayerr: |
264 | call print |
264 | call print |
265 | jmp $ |
265 | jmp $ |
266 | cpugood: |
266 | cpugood: |
267 | 267 | ||
268 | push 0 |
268 | push 0 |
269 | popf |
269 | popf |
270 | sti |
270 | sti |
271 | 271 | ||
272 | ; set up esp |
272 | ; set up esp |
273 | movzx esp, sp |
273 | movzx esp, sp |
274 | 274 | ||
275 | push 0 |
275 | push 0 |
276 | pop es |
276 | pop es |
277 | and word [es:0x9031], 0 |
277 | and word [es:0x9031], 0 |
278 | ; \begin{Mario79} |
278 | ; \begin{Mario79} |
279 | ; find HDD IDE DMA PCI device |
279 | ; find HDD IDE DMA PCI device |
280 | ; check for PCI BIOS |
280 | ; check for PCI BIOS |
281 | mov ax, 0xB101 |
281 | mov ax, 0xB101 |
282 | int 0x1A |
282 | int 0x1A |
283 | jc .nopci |
283 | jc .nopci |
284 | cmp edx, 'PCI ' |
284 | cmp edx, 'PCI ' |
285 | jnz .nopci |
285 | jnz .nopci |
286 | ; find PCI class code |
286 | ; find PCI class code |
287 | ; class 1 = mass storage |
287 | ; class 1 = mass storage |
288 | ; subclass 1 = IDE controller |
288 | ; subclass 1 = IDE controller |
289 | ; a) class 1, subclass 1, programming interface 0x80 |
289 | ; a) class 1, subclass 1, programming interface 0x80 |
290 | mov ax, 0xB103 |
290 | mov ax, 0xB103 |
291 | mov ecx, 1*10000h + 1*100h + 0x80 |
291 | mov ecx, 1*10000h + 1*100h + 0x80 |
292 | xor si, si ; device index = 0 |
292 | xor si, si ; device index = 0 |
293 | int 0x1A |
293 | int 0x1A |
294 | jnc .found |
294 | jnc .found |
295 | ; b) class 1, subclass 1, programming interface 0x8A |
295 | ; b) class 1, subclass 1, programming interface 0x8A |
296 | mov ax, 0xB103 |
296 | mov ax, 0xB103 |
297 | mov ecx, 1*10000h + 1*100h + 0x8A |
297 | mov ecx, 1*10000h + 1*100h + 0x8A |
298 | xor si, si ; device index = 0 |
298 | xor si, si ; device index = 0 |
299 | int 0x1A |
299 | int 0x1A |
300 | jnc .found |
300 | jnc .found |
301 | ; c) class 1, subclass 1, programming interface 0x85 |
301 | ; c) class 1, subclass 1, programming interface 0x85 |
302 | mov ax, 0xB103 |
302 | mov ax, 0xB103 |
303 | mov ecx, 1*10000h + 1*100h + 0x85 |
303 | mov ecx, 1*10000h + 1*100h + 0x85 |
304 | xor si, si |
304 | xor si, si |
305 | int 0x1A |
305 | int 0x1A |
306 | jc .nopci |
306 | jc .nopci |
307 | .found: |
307 | .found: |
308 | ; get memory base |
308 | ; get memory base |
309 | mov ax, 0xB10A |
309 | mov ax, 0xB10A |
310 | mov di, 0x20 ; memory base is config register at 0x20 |
310 | mov di, 0x20 ; memory base is config register at 0x20 |
311 | int 0x1A |
311 | int 0x1A |
312 | jc .nopci |
312 | jc .nopci |
313 | and cx, 0xFFF0 ; clear address decode type |
313 | and cx, 0xFFF0 ; clear address decode type |
314 | mov [es:0x9031], cx |
314 | mov [es:0x9031], cx |
315 | .nopci: |
315 | .nopci: |
316 | ; \end{Mario79} |
316 | ; \end{Mario79} |
317 | 317 | ||
318 | mov al, 0xf6 ; Ñáðîñ êëà âèà òóðû, ðà çðåøèòü ñêà Ãèðîâà Ãèå |
318 | mov al, 0xf6 ; Ñáðîñ êëà âèà òóðû, ðà çðåøèòü ñêà Ãèðîâà Ãèå |
319 | out 0x60, al |
319 | out 0x60, al |
320 | xor cx, cx |
320 | xor cx, cx |
321 | wait_loop: ; variant 2 |
321 | wait_loop: ; variant 2 |
322 | ; reading state of port of 8042 controller |
322 | ; reading state of port of 8042 controller |
323 | in al, 64h |
323 | in al, 64h |
324 | and al, 00000010b ; ready flag |
324 | and al, 00000010b ; ready flag |
325 | ; wait until 8042 controller is ready |
325 | ; wait until 8042 controller is ready |
326 | loopnz wait_loop |
326 | loopnz wait_loop |
327 | 327 | ||
328 | ;;;/diamond today 5.02.2008 |
328 | ;;;/diamond today 5.02.2008 |
329 | ; set keyboard typematic rate & delay |
329 | ; set keyboard typematic rate & delay |
330 | mov al, 0xf3 |
330 | mov al, 0xf3 |
331 | out 0x60, al |
331 | out 0x60, al |
332 | xor cx, cx |
332 | xor cx, cx |
333 | @@: |
333 | @@: |
334 | in al, 64h |
334 | in al, 64h |
335 | test al, 2 |
335 | test al, 2 |
336 | loopnz @b |
336 | loopnz @b |
337 | mov al, 0 |
337 | mov al, 0 |
338 | out 0x60, al |
338 | out 0x60, al |
339 | xor cx, cx |
339 | xor cx, cx |
340 | @@: |
340 | @@: |
341 | in al, 64h |
341 | in al, 64h |
342 | test al, 2 |
342 | test al, 2 |
343 | loopnz @b |
343 | loopnz @b |
344 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
344 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
345 | ; --------------- APM --------------------- |
345 | ; --------------- APM --------------------- |
346 | and word [es:0x9044], 0 ; ver = 0.0 (APM not found) |
346 | and word [es:0x9044], 0 ; ver = 0.0 (APM not found) |
347 | mov ax, 0x5300 |
347 | mov ax, 0x5300 |
348 | xor bx, bx |
348 | xor bx, bx |
349 | int 0x15 |
349 | int 0x15 |
350 | jc apm_end ; APM not found |
350 | jc apm_end ; APM not found |
351 | test cx, 2 |
351 | test cx, 2 |
352 | jz apm_end ; APM 32-bit protected-mode interface not supported |
352 | jz apm_end ; APM 32-bit protected-mode interface not supported |
353 | mov [es:0x9044], ax ; Save APM Version |
353 | mov [es:0x9044], ax ; Save APM Version |
354 | mov [es:0x9046], cx ; Save APM flags |
354 | mov [es:0x9046], cx ; Save APM flags |
355 | 355 | ||
356 | ; Write APM ver ---- |
356 | ; Write APM ver ---- |
357 | and ax, 0xf0f |
357 | and ax, 0xf0f |
358 | add ax, '00' |
358 | add ax, '00' |
359 | mov si, msg_apm |
359 | mov si, msg_apm |
360 | mov [si + 5], ah |
360 | mov [si + 5], ah |
361 | mov [si + 7], al |
361 | mov [si + 7], al |
362 | _setcursor 0, 3 |
362 | _setcursor 0, 3 |
363 | call printplain |
363 | call printplain |
364 | ; ------------------ |
364 | ; ------------------ |
365 | 365 | ||
366 | mov ax, 0x5304 ; Disconnect interface |
366 | mov ax, 0x5304 ; Disconnect interface |
367 | xor bx, bx |
367 | xor bx, bx |
368 | int 0x15 |
368 | int 0x15 |
369 | mov ax, 0x5303 ; Connect 32 bit mode interface |
369 | mov ax, 0x5303 ; Connect 32 bit mode interface |
370 | xor bx, bx |
370 | xor bx, bx |
371 | int 0x15 |
371 | int 0x15 |
372 | 372 | ||
373 | mov [es:0x9040], ebx |
373 | mov [es:0x9040], ebx |
374 | mov [es:0x9050], ax |
374 | mov [es:0x9050], ax |
375 | mov [es:0x9052], cx |
375 | mov [es:0x9052], cx |
376 | mov [es:0x9054], dx |
376 | mov [es:0x9054], dx |
377 | 377 | ||
378 | apm_end: |
378 | apm_end: |
379 | _setcursor d80x25_top_num, 0 |
379 | _setcursor d80x25_top_num, 0 |
380 | 380 | ||
381 | ;CHECK current of code |
381 | ;CHECK current of code |
382 | cmp [cfgmanager.loader_block], -1 |
382 | cmp [cfgmanager.loader_block], -1 |
383 | jz noloaderblock |
383 | jz noloaderblock |
384 | les bx, [cfgmanager.loader_block] |
384 | les bx, [cfgmanager.loader_block] |
385 | cmp byte [es:bx], 1 |
385 | cmp byte [es:bx], 1 |
386 | mov si, loader_block_error |
386 | mov si, loader_block_error |
387 | jnz sayerr |
387 | jnz sayerr |
388 | push 0 |
388 | push 0 |
389 | pop es |
389 | pop es |
390 | 390 | ||
391 | noloaderblock: |
391 | noloaderblock: |
392 | ; DISPLAY VESA INFORMATION |
392 | ; DISPLAY VESA INFORMATION |
393 | call print_vesa_info |
393 | call print_vesa_info |
394 | call calc_vmodes_table |
394 | call calc_vmodes_table |
395 | call check_first_parm ;check and enable cursor_pos |
395 | call check_first_parm ;check and enable cursor_pos |
396 | 396 | ||
397 | 397 | ||
398 | ; \begin{diamond}[30.11.2005] |
398 | ; \begin{diamond}[30.11.2005] |
399 | cfgmanager: |
399 | cfgmanager: |
400 | ; settings: |
400 | ; settings: |
401 | ; a) preboot_graph = graphical mode |
401 | ; a) preboot_graph = graphical mode |
402 | ; preboot_gprobe = probe this mode? |
402 | ; preboot_gprobe = probe this mode? |
403 | ; b) preboot_dma = use DMA access? |
403 | ; b) preboot_dma = use DMA access? |
404 | ; c) preboot_vrrm = use VRR? |
404 | ; c) preboot_vrrm = use VRR? |
405 | ; d) preboot_device = from what boot? |
405 | ; d) preboot_device = from what boot? |
406 | 406 | ||
407 | ; determine default settings |
407 | ; determine default settings |
408 | mov [.bSettingsChanged], 0 |
408 | mov [.bSettingsChanged], 0 |
409 | 409 | ||
410 | ;.preboot_gr_end: |
410 | ;.preboot_gr_end: |
411 | mov di, preboot_device |
411 | mov di, preboot_device |
412 | ; if image in memory is present and [preboot_device] is uninitialized, |
412 | ; if image in memory is present and [preboot_device] is uninitialized, |
413 | ; set it to use this preloaded image |
413 | ; set it to use this preloaded image |
414 | cmp byte [di], 0 |
414 | cmp byte [di], 0 |
415 | jnz .preboot_device_inited |
415 | jnz .preboot_device_inited |
416 | cmp [.loader_block], -1 |
416 | cmp [.loader_block], -1 |
417 | jz @f |
417 | jz @f |
418 | les bx, [.loader_block] |
418 | les bx, [.loader_block] |
419 | test byte [es:bx+1], 1 |
419 | test byte [es:bx+1], 1 |
420 | jz @f |
420 | jz @f |
421 | mov byte [di], 3 |
421 | mov byte [di], 3 |
422 | jmp .preboot_device_inited |
422 | jmp .preboot_device_inited |
423 | @@: |
423 | @@: |
424 | ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) |
424 | ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) |
425 | mov byte [di], 1 |
425 | mov byte [di], 1 |
426 | .preboot_device_inited: |
426 | .preboot_device_inited: |
427 | ; following 6 lines set variables to 1 if its current value is 0 |
427 | ; following 6 lines set variables to 1 if its current value is 0 |
428 | cmp byte [di+preboot_dma-preboot_device], 1 |
428 | cmp byte [di+preboot_dma-preboot_device], 1 |
429 | adc byte [di+preboot_dma-preboot_device], 0 |
429 | adc byte [di+preboot_dma-preboot_device], 0 |
430 | cmp byte [di+preboot_biosdisk-preboot_device], 1 |
430 | cmp byte [di+preboot_biosdisk-preboot_device], 1 |
431 | adc byte [di+preboot_biosdisk-preboot_device], 0 |
431 | adc byte [di+preboot_biosdisk-preboot_device], 0 |
432 | cmp byte [di+preboot_vrrm-preboot_device], 1 |
432 | cmp byte [di+preboot_vrrm-preboot_device], 1 |
433 | adc byte [di+preboot_vrrm-preboot_device], 0 |
433 | adc byte [di+preboot_vrrm-preboot_device], 0 |
434 | ; notify user |
434 | ; notify user |
435 | _setcursor 5,2 |
435 | _setcursor 5,2 |
436 | 436 | ||
437 | mov si, linef |
437 | mov si, linef |
438 | call printplain |
438 | call printplain |
439 | mov si, start_msg |
439 | mov si, start_msg |
440 | call print |
440 | call print |
441 | mov si, time_msg |
441 | mov si, time_msg |
442 | call print |
442 | call print |
443 | ; get start time |
443 | ; get start time |
444 | call .gettime |
444 | call .gettime |
445 | mov [.starttime], eax |
445 | mov [.starttime], eax |
446 | mov word [.timer], .newtimer |
446 | mov word [.timer], .newtimer |
447 | mov word [.timer+2], cs |
447 | mov word [.timer+2], cs |
448 | .printcfg: |
448 | .printcfg: |
449 | _setcursor 9,0 |
449 | _setcursor 9,0 |
450 | mov si, current_cfg_msg |
450 | mov si, current_cfg_msg |
451 | call print |
451 | call print |
452 | mov si, curvideo_msg |
452 | mov si, curvideo_msg |
453 | call print |
453 | call print |
454 | 454 | ||
455 | call draw_current_vmode |
455 | call draw_current_vmode |
456 | 456 | ||
457 | mov si, usebd_msg |
457 | mov si, usebd_msg |
458 | cmp [preboot_biosdisk], 1 |
458 | cmp [preboot_biosdisk], 1 |
459 | call .say_on_off |
459 | call .say_on_off |
460 | mov si, vrrm_msg |
460 | mov si, vrrm_msg |
461 | cmp [preboot_vrrm], 1 |
461 | cmp [preboot_vrrm], 1 |
462 | call .say_on_off |
462 | call .say_on_off |
463 | mov si, preboot_device_msg |
463 | mov si, preboot_device_msg |
464 | call print |
464 | call print |
465 | mov al, [preboot_device] |
465 | mov al, [preboot_device] |
466 | and eax, 7 |
466 | and eax, 7 |
467 | mov si, [preboot_device_msgs+eax*2] |
467 | mov si, [preboot_device_msgs+eax*2] |
468 | call printplain |
468 | call printplain |
469 | .show_remarks: |
469 | .show_remarks: |
470 | ; show remarks in gray color |
470 | ; show remarks in gray color |
471 | mov di, ((21-num_remarks)*80 + 2)*2 |
471 | mov di, ((21-num_remarks)*80 + 2)*2 |
472 | push 0xB800 |
472 | push 0xB800 |
473 | pop es |
473 | pop es |
474 | mov cx, num_remarks |
474 | mov cx, num_remarks |
475 | mov si, remarks |
475 | mov si, remarks |
476 | .write_remarks: |
476 | .write_remarks: |
477 | lodsw |
477 | lodsw |
478 | push si |
478 | push si |
479 | xchg ax, si |
479 | xchg ax, si |
480 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
480 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
481 | push di |
481 | push di |
482 | .write_remark: |
482 | .write_remark: |
483 | lodsb |
483 | lodsb |
484 | test al, al |
484 | test al, al |
485 | jz @f |
485 | jz @f |
486 | stosw |
486 | stosw |
487 | jmp .write_remark |
487 | jmp .write_remark |
488 | @@: |
488 | @@: |
489 | pop di |
489 | pop di |
490 | pop si |
490 | pop si |
491 | add di, 80*2 |
491 | add di, 80*2 |
492 | loop .write_remarks |
492 | loop .write_remarks |
493 | .wait: |
493 | .wait: |
494 | _setcursor 25,0 ; out of screen |
494 | _setcursor 25,0 ; out of screen |
495 | ; set timer interrupt handler |
495 | ; set timer interrupt handler |
496 | cli |
496 | cli |
497 | push 0 |
497 | push 0 |
498 | pop es |
498 | pop es |
499 | push dword [es:8*4] |
499 | push dword [es:8*4] |
500 | pop dword [.oldtimer] |
500 | pop dword [.oldtimer] |
501 | push dword [.timer] |
501 | push dword [.timer] |
502 | pop dword [es:8*4] |
502 | pop dword [es:8*4] |
503 | ; mov eax, [es:8*4] |
503 | ; mov eax, [es:8*4] |
504 | ; mov [.oldtimer], eax |
504 | ; mov [.oldtimer], eax |
505 | ; mov eax, [.timer] |
505 | ; mov eax, [.timer] |
506 | ; mov [es:8*4], eax |
506 | ; mov [es:8*4], eax |
507 | sti |
507 | sti |
508 | ; wait for keypressed |
508 | ; wait for keypressed |
509 | xor ax,ax |
509 | xor ax,ax |
510 | int 16h |
510 | int 16h |
511 | push ax |
511 | push ax |
512 | ; restore timer interrupt |
512 | ; restore timer interrupt |
513 | ; push 0 |
513 | ; push 0 |
514 | ; pop es |
514 | ; pop es |
515 | mov eax, [.oldtimer] |
515 | mov eax, [.oldtimer] |
516 | mov [es:8*4], eax |
516 | mov [es:8*4], eax |
517 | mov [.timer], eax |
517 | mov [.timer], eax |
518 | _setcursor 7,0 |
518 | _setcursor 7,0 |
519 | mov si, space_msg |
519 | mov si, space_msg |
520 | call printplain |
520 | call printplain |
521 | ; clear remarks and restore normal attributes |
521 | ; clear remarks and restore normal attributes |
522 | push es |
522 | push es |
523 | mov di, ((21-num_remarks)*80 + 2)*2 |
523 | mov di, ((21-num_remarks)*80 + 2)*2 |
524 | push 0xB800 |
524 | push 0xB800 |
525 | pop es |
525 | pop es |
526 | mov cx, num_remarks |
526 | mov cx, num_remarks |
527 | mov ax, ' ' + (1*16 + 15)*100h |
527 | mov ax, ' ' + (1*16 + 15)*100h |
528 | @@: |
528 | @@: |
529 | push cx |
529 | push cx |
530 | mov cx, 76 |
530 | mov cx, 76 |
531 | rep stosw |
531 | rep stosw |
532 | pop cx |
532 | pop cx |
533 | add di, 4*2 |
533 | add di, 4*2 |
534 | loop @b |
534 | loop @b |
535 | pop es |
535 | pop es |
536 | pop ax |
536 | pop ax |
537 | ; switch on key |
537 | ; switch on key |
538 | cmp al, 13 |
538 | cmp al, 13 |
539 | jz .continue |
539 | jz .continue |
540 | or al, 20h |
540 | or al, 20h |
541 | cmp al, 'a' |
541 | cmp al, 'a' |
542 | jz .change_a |
542 | jz .change_a |
543 | cmp al, 'b' |
543 | cmp al, 'b' |
544 | jz .change_b |
544 | jz .change_b |
545 | cmp al, 'c' |
545 | cmp al, 'c' |
546 | jz .change_c |
546 | jz .change_c |
547 | cmp al, 'd' |
547 | cmp al, 'd' |
548 | jnz .show_remarks |
548 | jnz .show_remarks |
549 | _setcursor 15,0 |
549 | _setcursor 15,0 |
550 | mov si, bdev |
550 | mov si, bdev |
551 | call print |
551 | call print |
552 | mov bx, '14' |
552 | mov bx, '14' |
553 | call getkey |
553 | call getkey |
554 | mov [preboot_device], al |
554 | mov [preboot_device], al |
555 | _setcursor 13,0 |
555 | _setcursor 13,0 |
556 | .d: |
556 | .d: |
557 | mov [.bSettingsChanged], 1 |
557 | mov [.bSettingsChanged], 1 |
558 | call clear_vmodes_table ;clear vmodes_table |
558 | call clear_vmodes_table ;clear vmodes_table |
559 | jmp .printcfg |
559 | jmp .printcfg |
560 | .change_a: |
560 | .change_a: |
561 | .loops: |
561 | .loops: |
562 | call draw_vmodes_table |
562 | call draw_vmodes_table |
563 | - | ||
- | 563 | _setcursor 25,0 ; out of screen |
|
564 | xor ax,ax |
564 | xor ax,ax |
565 | int 0x16 |
565 | int 0x16 |
566 | ; call clear_table_cursor ;clear current position of cursor |
566 | ; call clear_table_cursor ;clear current position of cursor |
567 | 567 | ||
568 | mov si,word [cursor_pos] |
568 | mov si,word [cursor_pos] |
569 | 569 | ||
570 | cmp ah,0x48;x,0x48E0 ; up |
570 | cmp ah,0x48;x,0x48E0 ; up |
571 | jne .down |
571 | jne .down |
572 | cmp si,modes_table |
572 | cmp si,modes_table |
573 | jbe .loops |
573 | jbe .loops |
574 | sub word [cursor_pos],size_of_step |
574 | sub word [cursor_pos],size_of_step |
575 | jmp .loops |
575 | jmp .loops |
576 | 576 | ||
577 | .down: cmp ah,0x50;x,0x50E0 ; down |
577 | .down: cmp ah,0x50;x,0x50E0 ; down |
578 | jne .pgup |
578 | jne .pgup |
579 | cmp word[es:si+10],-1 |
579 | cmp word[es:si+10],-1 |
580 | je .loops |
580 | je .loops |
581 | add word [cursor_pos],size_of_step |
581 | add word [cursor_pos],size_of_step |
582 | jmp .loops |
582 | jmp .loops |
583 | 583 | ||
584 | .pgup: cmp ah,0x49 ; page up |
584 | .pgup: cmp ah,0x49 ; page up |
585 | jne .pgdn |
585 | jne .pgdn |
586 | sub si, size_of_step*long_v_table |
586 | sub si, size_of_step*long_v_table |
587 | cmp si, modes_table |
587 | cmp si, modes_table |
588 | jae @f |
588 | jae @f |
589 | mov si, modes_table |
589 | mov si, modes_table |
590 | @@: |
590 | @@: |
591 | mov word [cursor_pos], si |
591 | mov word [cursor_pos], si |
592 | mov si, word [home_cursor] |
592 | mov si, word [home_cursor] |
593 | sub si, size_of_step*long_v_table |
593 | sub si, size_of_step*long_v_table |
594 | cmp si, modes_table |
594 | cmp si, modes_table |
595 | jae @f |
595 | jae @f |
596 | mov si, modes_table |
596 | mov si, modes_table |
597 | @@: |
597 | @@: |
598 | mov word [home_cursor], si |
598 | mov word [home_cursor], si |
599 | jmp .loops |
599 | jmp .loops |
600 | 600 | ||
601 | .pgdn: cmp ah,0x51 ; page down |
601 | .pgdn: cmp ah,0x51 ; page down |
602 | jne .enter |
602 | jne .enter |
603 | mov ax, [end_cursor] |
603 | mov ax, [end_cursor] |
604 | add si, size_of_step*long_v_table |
604 | add si, size_of_step*long_v_table |
605 | cmp si, ax |
605 | cmp si, ax |
606 | jb @f |
606 | jb @f |
607 | mov si, ax |
607 | mov si, ax |
608 | sub si, size_of_step |
608 | sub si, size_of_step |
609 | @@: |
609 | @@: |
610 | mov word [cursor_pos], si |
610 | mov word [cursor_pos], si |
611 | mov si, word [home_cursor] |
611 | mov si, word [home_cursor] |
612 | sub ax, size_of_step*long_v_table |
612 | sub ax, size_of_step*long_v_table |
613 | add si, size_of_step*long_v_table |
613 | add si, size_of_step*long_v_table |
614 | cmp si, ax |
614 | cmp si, ax |
615 | jb @f |
615 | jb @f |
616 | mov si, ax |
616 | mov si, ax |
617 | @@: |
617 | @@: |
618 | mov word [home_cursor], si |
618 | mov word [home_cursor], si |
619 | jmp .loops |
619 | jmp .loops |
620 | 620 | ||
621 | .enter: cmp al,0x0D;x,0x1C0D ; enter |
621 | .enter: cmp al,0x0D;x,0x1C0D ; enter |
622 | jne .loops |
622 | jne .loops |
623 | push word [cursor_pos] |
623 | push word [cursor_pos] |
624 | pop bp |
624 | pop bp |
625 | push word [es:bp] |
625 | push word [es:bp] |
626 | pop word [x_save] |
626 | pop word [x_save] |
627 | push word [es:bp+2] |
627 | push word [es:bp+2] |
628 | pop word [y_save] |
628 | pop word [y_save] |
629 | push word [es:bp+6] |
629 | push word [es:bp+6] |
630 | pop word [number_vm] |
630 | pop word [number_vm] |
631 | mov word [preboot_graph],bp ;save choose |
631 | mov word [preboot_graph],bp ;save choose |
632 | 632 | ||
633 | jmp .d |
633 | jmp .d |
634 | 634 | ||
635 | .change_b: |
635 | .change_b: |
636 | _setcursor 15,0 |
636 | _setcursor 15,0 |
637 | ; mov si, ask_dma |
637 | ; mov si, ask_dma |
638 | ; call print |
638 | ; call print |
639 | ; mov bx, '13' |
639 | ; mov bx, '13' |
640 | ; call getkey |
640 | ; call getkey |
641 | ; mov [preboot_dma], al |
641 | ; mov [preboot_dma], al |
642 | mov si, ask_bd |
642 | mov si, ask_bd |
643 | call print |
643 | call print |
644 | mov bx, '12' |
644 | mov bx, '12' |
645 | call getkey |
645 | call getkey |
646 | mov [preboot_biosdisk], al |
646 | mov [preboot_biosdisk], al |
647 | _setcursor 11,0 |
647 | _setcursor 11,0 |
648 | jmp .d |
648 | jmp .d |
649 | .change_c: |
649 | .change_c: |
650 | _setcursor 15,0 |
650 | _setcursor 15,0 |
651 | mov si, vrrmprint |
651 | mov si, vrrmprint |
652 | call print |
652 | call print |
653 | mov bx, '12' |
653 | mov bx, '12' |
654 | call getkey |
654 | call getkey |
655 | mov [preboot_vrrm], al |
655 | mov [preboot_vrrm], al |
656 | _setcursor 12,0 |
656 | _setcursor 12,0 |
657 | jmp .d |
657 | jmp .d |
658 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
658 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
659 | .say_on_off: |
659 | .say_on_off: |
660 | pushf |
660 | pushf |
661 | call print |
661 | call print |
662 | mov si, on_msg |
662 | mov si, on_msg |
663 | popf |
663 | popf |
664 | jz @f |
664 | jz @f |
665 | mov si, off_msg |
665 | mov si, off_msg |
666 | @@: jmp printplain |
666 | @@: jmp printplain |
667 | ; novesa and vervesa strings are not used at the moment of executing this code |
667 | ; novesa and vervesa strings are not used at the moment of executing this code |
668 | virtual at novesa |
668 | virtual at novesa |
669 | .oldtimer dd ? |
669 | .oldtimer dd ? |
670 | .starttime dd ? |
670 | .starttime dd ? |
671 | .bSettingsChanged db ? |
671 | .bSettingsChanged db ? |
672 | .timer dd ? |
672 | .timer dd ? |
673 | end virtual |
673 | end virtual |
674 | .loader_block dd -1 |
674 | .loader_block dd -1 |
675 | .gettime: |
675 | .gettime: |
676 | mov ah, 0 |
676 | mov ah, 0 |
677 | int 1Ah |
677 | int 1Ah |
678 | xchg ax, cx |
678 | xchg ax, cx |
679 | shl eax, 10h |
679 | shl eax, 10h |
680 | xchg ax, dx |
680 | xchg ax, dx |
681 | ret |
681 | ret |
682 | .newtimer: |
682 | .newtimer: |
683 | push ds |
683 | push ds |
684 | push cs |
684 | push cs |
685 | pop ds |
685 | pop ds |
686 | pushf |
686 | pushf |
687 | call [.oldtimer] |
687 | call [.oldtimer] |
688 | pushad |
688 | pushad |
689 | call .gettime |
689 | call .gettime |
690 | sub eax, [.starttime] |
690 | sub eax, [.starttime] |
691 | sub ax, 18*5 |
691 | sub ax, 18*5 |
692 | jae .timergo |
692 | jae .timergo |
693 | neg ax |
693 | neg ax |
694 | add ax, 18-1 |
694 | add ax, 18-1 |
695 | mov bx, 18 |
695 | mov bx, 18 |
696 | xor dx, dx |
696 | xor dx, dx |
697 | div bx |
697 | div bx |
698 | if lang eq ru |
698 | if lang eq ru |
699 | ; ¯®¤®¦¤¨â¥ 5 ᥪã¤, 4/3/2 ᥪã¤ë, 1 ᥪã¤ã |
699 | ; ¯®¤®¦¤¨â¥ 5 ᥪã¤, 4/3/2 ᥪã¤ë, 1 ᥪã¤ã |
700 | cmp al, 5 |
700 | cmp al, 5 |
701 | mov cl, ' ' |
701 | mov cl, ' ' |
702 | jae @f |
702 | jae @f |
703 | cmp al, 1 |
703 | cmp al, 1 |
704 | mov cl, 'ã' |
704 | mov cl, 'ã' |
705 | jz @f |
705 | jz @f |
706 | mov cl, 'ë' |
706 | mov cl, 'ë' |
707 | @@: mov [time_str+9], cl |
707 | @@: mov [time_str+9], cl |
708 | else if lang eq et |
708 | else if lang eq et |
709 | cmp al, 1 |
709 | cmp al, 1 |
710 | ja @f |
710 | ja @f |
711 | mov [time_str+9], ' ' |
711 | mov [time_str+9], ' ' |
712 | mov [time_str+10],' ' |
712 | mov [time_str+10],' ' |
713 | @@: |
713 | @@: |
714 | else |
714 | else |
715 | ; wait 5/4/3/2 seconds, 1 second |
715 | ; wait 5/4/3/2 seconds, 1 second |
716 | cmp al, 1 |
716 | cmp al, 1 |
717 | mov cl, 's' |
717 | mov cl, 's' |
718 | ja @f |
718 | ja @f |
719 | mov cl, ' ' |
719 | mov cl, ' ' |
720 | @@: mov [time_str+9], cl |
720 | @@: mov [time_str+9], cl |
721 | end if |
721 | end if |
722 | add al, '0' |
722 | add al, '0' |
723 | mov [time_str+1], al |
723 | mov [time_str+1], al |
724 | mov si, time_msg |
724 | mov si, time_msg |
725 | _setcursor 7,0 |
725 | _setcursor 7,0 |
726 | call print |
726 | call print |
727 | _setcursor 25,0 |
727 | _setcursor 25,0 |
728 | popad |
728 | popad |
729 | pop ds |
729 | pop ds |
730 | iret |
730 | iret |
731 | .timergo: |
731 | .timergo: |
732 | push 0 |
732 | push 0 |
733 | pop es |
733 | pop es |
734 | mov eax, [.oldtimer] |
734 | mov eax, [.oldtimer] |
735 | mov [es:8*4], eax |
735 | mov [es:8*4], eax |
736 | mov sp, 0EC00h |
736 | mov sp, 0EC00h |
737 | .continue: |
737 | .continue: |
738 | sti |
738 | sti |
739 | _setcursor 6,0 |
739 | _setcursor 6,0 |
740 | mov si, space_msg |
740 | mov si, space_msg |
741 | call printplain |
741 | call printplain |
742 | call printplain |
742 | call printplain |
743 | _setcursor 6,0 |
743 | _setcursor 6,0 |
744 | mov si, loading_msg |
744 | mov si, loading_msg |
745 | call print |
745 | call print |
746 | _setcursor 15,0 |
746 | _setcursor 15,0 |
747 | cmp [.bSettingsChanged], 0 |
747 | cmp [.bSettingsChanged], 0 |
748 | jz .load |
748 | jz .load |
749 | cmp [.loader_block], -1 |
749 | cmp [.loader_block], -1 |
750 | jz .load |
750 | jz .load |
751 | les bx, [.loader_block] |
751 | les bx, [.loader_block] |
752 | mov eax, [es:bx+3] |
752 | mov eax, [es:bx+3] |
753 | push ds |
753 | push ds |
754 | pop es |
754 | pop es |
755 | test eax, eax |
755 | test eax, eax |
756 | jz .load |
756 | jz .load |
757 | push eax |
757 | push eax |
758 | mov si, save_quest |
758 | mov si, save_quest |
759 | call print |
759 | call print |
760 | .waityn: |
760 | .waityn: |
761 | mov ah, 0 |
761 | mov ah, 0 |
762 | int 16h |
762 | int 16h |
763 | or al, 20h |
763 | or al, 20h |
764 | cmp al, 'n' |
764 | cmp al, 'n' |
765 | jz .loadc |
765 | jz .loadc |
766 | cmp al, 'y' |
766 | cmp al, 'y' |
767 | jnz .waityn |
767 | jnz .waityn |
768 | call putchar |
768 | call putchar |
769 | mov byte [space_msg+80], 186 |
769 | mov byte [space_msg+80], 186 |
770 | pop eax |
770 | pop eax |
771 | push cs |
771 | push cs |
772 | push .cont |
772 | push .cont |
773 | push eax |
773 | push eax |
774 | retf |
774 | retf |
775 | .loadc: |
775 | .loadc: |
776 | pop eax |
776 | pop eax |
777 | .cont: |
777 | .cont: |
778 | push cs |
778 | push cs |
779 | pop ds |
779 | pop ds |
780 | mov si, space_msg |
780 | mov si, space_msg |
781 | mov byte [si+80], 0 |
781 | mov byte [si+80], 0 |
782 | _setcursor 15,0 |
782 | _setcursor 15,0 |
783 | call printplain |
783 | call printplain |
784 | _setcursor 15,0 |
784 | _setcursor 15,0 |
785 | .load: |
785 | .load: |
786 | ; \end{diamond}[02.12.2005] |
786 | ; \end{diamond}[02.12.2005] |
787 | 787 | ||
788 | ; ASK GRAPHICS MODE |
788 | ; ASK GRAPHICS MODE |
789 | 789 | ||
790 | call set_vmode |
790 | call set_vmode |
791 | 791 | ||
792 | ; GRAPHICS ACCELERATION |
792 | ; GRAPHICS ACCELERATION |
793 | ; force yes |
793 | ; force yes |
794 | mov [es:0x901C], byte 1 |
794 | mov [es:0x901C], byte 1 |
795 | 795 | ||
796 | ; DMA ACCESS TO HD |
796 | ; DMA ACCESS TO HD |
797 | 797 | ||
798 | mov al, [preboot_dma] |
798 | mov al, [preboot_dma] |
799 | mov [es:0x901F], al |
799 | mov [es:0x901F], al |
800 | 800 | ||
801 | ; VRR_M USE |
801 | ; VRR_M USE |
802 | 802 | ||
803 | mov al,[preboot_vrrm] |
803 | mov al,[preboot_vrrm] |
804 | mov [es:0x9030], al |
804 | mov [es:0x9030], al |
805 | mov [es:0x901E], byte 1 |
805 | mov [es:0x901E], byte 1 |
806 | 806 | ||
807 | ; BOOT DEVICE |
807 | ; BOOT DEVICE |
808 | 808 | ||
809 | mov al, [preboot_device] |
809 | mov al, [preboot_device] |
810 | dec al |
810 | dec al |
811 | mov [boot_dev], al |
811 | mov [boot_dev], al |
812 | 812 | ||
813 | ; READ DISKETTE TO MEMORY |
813 | ; READ DISKETTE TO MEMORY |
814 | 814 | ||
815 | ; cmp [boot_dev],0 |
815 | ; cmp [boot_dev],0 |
816 | jne no_sys_on_floppy |
816 | jne no_sys_on_floppy |
817 | mov si,diskload |
817 | mov si,diskload |
818 | call print |
818 | call print |
819 | xor ax, ax ; reset drive |
819 | xor ax, ax ; reset drive |
820 | xor dx, dx |
820 | xor dx, dx |
821 | int 0x13 |
821 | int 0x13 |
822 | ; do we boot from CD-ROM? |
822 | ; do we boot from CD-ROM? |
823 | mov ah, 41h |
823 | mov ah, 41h |
824 | mov bx, 55AAh |
824 | mov bx, 55AAh |
825 | xor dx, dx |
825 | xor dx, dx |
826 | int 0x13 |
826 | int 0x13 |
827 | jc .nocd |
827 | jc .nocd |
828 | cmp bx, 0AA55h |
828 | cmp bx, 0AA55h |
829 | jnz .nocd |
829 | jnz .nocd |
830 | mov ah, 48h |
830 | mov ah, 48h |
831 | push ds |
831 | push ds |
832 | push es |
832 | push es |
833 | pop ds |
833 | pop ds |
834 | mov si, 0xa000 |
834 | mov si, 0xa000 |
835 | mov word [si], 30 |
835 | mov word [si], 30 |
836 | int 0x13 |
836 | int 0x13 |
837 | pop ds |
837 | pop ds |
838 | jc .nocd |
838 | jc .nocd |
839 | push ds |
839 | push ds |
840 | lds si, [es:si+26] |
840 | lds si, [es:si+26] |
841 | test byte [ds:si+10], 40h |
841 | test byte [ds:si+10], 40h |
842 | pop ds |
842 | pop ds |
843 | jz .nocd |
843 | jz .nocd |
844 | ; yes - read all floppy by 18 sectors |
844 | ; yes - read all floppy by 18 sectors |
845 | 845 | ||
846 | ; TODO: !!!! read only first sector and set variables !!!!! |
846 | ; TODO: !!!! read only first sector and set variables !!!!! |
847 | ; ... |
847 | ; ... |
848 | ; TODO: !!! then read flippy image track by track |
848 | ; TODO: !!! then read flippy image track by track |
849 | 849 | ||
850 | mov cx, 0x0001 ; startcyl,startsector |
850 | mov cx, 0x0001 ; startcyl,startsector |
851 | .a1: |
851 | .a1: |
852 | push cx dx |
852 | push cx dx |
853 | mov al, 18 |
853 | mov al, 18 |
854 | mov bx, 0xa000 |
854 | mov bx, 0xa000 |
855 | call boot_read_floppy |
855 | call boot_read_floppy |
856 | mov si, movedesc |
856 | mov si, movedesc |
857 | push es |
857 | push es |
858 | push ds |
858 | push ds |
859 | pop es |
859 | pop es |
860 | mov cx, 256*18 |
860 | mov cx, 256*18 |
861 | mov ah, 0x87 |
861 | mov ah, 0x87 |
862 | int 0x15 |
862 | int 0x15 |
863 | pop es |
863 | pop es |
864 | pop dx cx |
864 | pop dx cx |
865 | test ah, ah |
865 | test ah, ah |
866 | jnz sayerr_floppy |
866 | jnz sayerr_floppy |
867 | add dword [si+8*3+2], 512*18 |
867 | add dword [si+8*3+2], 512*18 |
868 | inc dh |
868 | inc dh |
869 | cmp dh, 2 |
869 | cmp dh, 2 |
870 | jnz .a1 |
870 | jnz .a1 |
871 | mov dh, 0 |
871 | mov dh, 0 |
872 | inc ch |
872 | inc ch |
873 | cmp ch, 80 |
873 | cmp ch, 80 |
874 | jae ok_sys_on_floppy |
874 | jae ok_sys_on_floppy |
875 | pusha |
875 | pusha |
876 | mov al, ch |
876 | mov al, ch |
877 | shr ch, 2 |
877 | shr ch, 2 |
878 | add al, ch |
878 | add al, ch |
879 | aam |
879 | aam |
880 | xchg al, ah |
880 | xchg al, ah |
881 | add ax, '00' |
881 | add ax, '00' |
882 | mov si, pros |
882 | mov si, pros |
883 | mov [si], ax |
883 | mov [si], ax |
884 | call printplain |
884 | call printplain |
885 | popa |
885 | popa |
886 | jmp .a1 |
886 | jmp .a1 |
887 | .nocd: |
887 | .nocd: |
888 | ; no - read only used sectors from floppy |
888 | ; no - read only used sectors from floppy |
889 | ; now load floppy image to memory |
889 | ; now load floppy image to memory |
890 | ; at first load boot sector and first FAT table |
890 | ; at first load boot sector and first FAT table |
891 | 891 | ||
892 | ; read only first sector and fill variables |
892 | ; read only first sector and fill variables |
893 | mov cx, 0x0001 ; first logical sector |
893 | mov cx, 0x0001 ; first logical sector |
894 | xor dx, dx ; head = 0, drive = 0 (a:) |
894 | xor dx, dx ; head = 0, drive = 0 (a:) |
895 | mov al, 1 ; read one sector |
895 | mov al, 1 ; read one sector |
896 | mov bx, 0xB000 ; es:bx -> data area |
896 | mov bx, 0xB000 ; es:bx -> data area |
897 | call boot_read_floppy |
897 | call boot_read_floppy |
898 | ; fill the necessary parameters to work with a floppy |
898 | ; fill the necessary parameters to work with a floppy |
899 | mov ax, word [es:bx+24] |
899 | mov ax, word [es:bx+24] |
900 | mov word [BPB_SecPerTrk], ax |
900 | mov word [BPB_SecPerTrk], ax |
901 | mov ax, word [es:bx+26] |
901 | mov ax, word [es:bx+26] |
902 | mov word [BPB_NumHeads], ax |
902 | mov word [BPB_NumHeads], ax |
903 | mov ax, word [es:bx+22] |
903 | mov ax, word [es:bx+22] |
904 | mov word [BPB_FATSz16], ax |
904 | mov word [BPB_FATSz16], ax |
905 | mov ax, word [es:bx+17] |
905 | mov ax, word [es:bx+17] |
906 | mov word [BPB_RootEntCnt], ax |
906 | mov word [BPB_RootEntCnt], ax |
907 | mov ax, word [es:bx+11] |
907 | mov ax, word [es:bx+11] |
908 | mov word [BPB_BytsPerSec], ax |
908 | mov word [BPB_BytsPerSec], ax |
909 | mov ax, word [es:bx+14] |
909 | mov ax, word [es:bx+14] |
910 | mov word [BPB_RsvdSecCnt], ax |
910 | mov word [BPB_RsvdSecCnt], ax |
911 | mov ax, word [es:bx+19] |
911 | mov ax, word [es:bx+19] |
912 | mov word [BPB_TotSec16], ax |
912 | mov word [BPB_TotSec16], ax |
913 | mov al, byte [es:bx+13] |
913 | mov al, byte [es:bx+13] |
914 | mov byte [BPB_SecPerClus], al |
914 | mov byte [BPB_SecPerClus], al |
915 | mov al, byte [es:bx+16] |
915 | mov al, byte [es:bx+16] |
916 | mov byte [BPB_NumFATs], al |
916 | mov byte [BPB_NumFATs], al |
917 | ; count of clusters in FAT12 ((size_of_FAT*2)/3) |
917 | ; count of clusters in FAT12 ((size_of_FAT*2)/3) |
918 | mov ax, word [BPB_FATSz16] |
918 | mov ax, word [BPB_FATSz16] |
919 | mov cx, word [BPB_BytsPerSec] |
919 | mov cx, word [BPB_BytsPerSec] |
920 | xor dx, dx |
920 | xor dx, dx |
921 | mul cx |
921 | mul cx |
922 | shl ax, 1 |
922 | shl ax, 1 |
923 | mov cx, 3 |
923 | mov cx, 3 |
924 | div cx ; now ax - number of clusters in FAT12 |
924 | div cx ; now ax - number of clusters in FAT12 |
925 | mov word [end_of_FAT], ax |
925 | mov word [end_of_FAT], ax |
926 | 926 | ||
927 | ; load first FAT table |
927 | ; load first FAT table |
928 | mov cx, 0x0002 ; startcyl,startsector ; TODO!!!!! |
928 | mov cx, 0x0002 ; startcyl,startsector ; TODO!!!!! |
929 | xor dx, dx ; starthead,drive |
929 | xor dx, dx ; starthead,drive |
930 | mov al, byte [BPB_FATSz16] ; no of sectors to read |
930 | mov al, byte [BPB_FATSz16] ; no of sectors to read |
931 | add bx, word [BPB_BytsPerSec] ; es:bx -> data area |
931 | add bx, word [BPB_BytsPerSec] ; es:bx -> data area |
932 | call boot_read_floppy |
932 | call boot_read_floppy |
933 | mov bx, 0xB000 |
933 | mov bx, 0xB000 |
934 | 934 | ||
935 | ; and copy them to extended memory |
935 | ; and copy them to extended memory |
936 | mov si, movedesc |
936 | mov si, movedesc |
937 | mov [si+8*2+3], bh ; from |
937 | mov [si+8*2+3], bh ; from |
938 | 938 | ||
939 | mov ax, word [BPB_BytsPerSec] |
939 | mov ax, word [BPB_BytsPerSec] |
940 | shr ax, 1 ; words per sector |
940 | shr ax, 1 ; words per sector |
941 | mov cx, word [BPB_RsvdSecCnt] |
941 | mov cx, word [BPB_RsvdSecCnt] |
942 | add cx, word [BPB_FATSz16] |
942 | add cx, word [BPB_FATSz16] |
943 | mul cx |
943 | mul cx |
944 | push ax ; save to stack count of words in boot+FAT |
944 | push ax ; save to stack count of words in boot+FAT |
945 | xchg ax, cx |
945 | xchg ax, cx |
946 | 946 | ||
947 | push es |
947 | push es |
948 | push ds |
948 | push ds |
949 | pop es |
949 | pop es |
950 | mov ah, 0x87 |
950 | mov ah, 0x87 |
951 | int 0x15 |
951 | int 0x15 |
952 | pop es |
952 | pop es |
953 | test ah, ah |
953 | test ah, ah |
954 | jz @f |
954 | jz @f |
955 | sayerr_floppy: |
955 | sayerr_floppy: |
956 | mov dx, 0x3f2 |
956 | mov dx, 0x3f2 |
957 | mov al, 0 |
957 | mov al, 0 |
958 | out dx, al |
958 | out dx, al |
959 | mov si, memmovefailed |
959 | mov si, memmovefailed |
960 | jmp sayerr_plain |
960 | jmp sayerr_plain |
961 | @@: |
961 | @@: |
962 | pop ax ; restore from stack count of words in boot+FAT |
962 | pop ax ; restore from stack count of words in boot+FAT |
963 | shl ax, 1 ; make bytes count from count of words |
963 | shl ax, 1 ; make bytes count from count of words |
964 | and eax, 0ffffh |
964 | and eax, 0ffffh |
965 | add dword [si+8*3+2], eax |
965 | add dword [si+8*3+2], eax |
966 | 966 | ||
967 | ; copy first FAT to second copy |
967 | ; copy first FAT to second copy |
968 | ; TODO: BPB_NumFATs !!!!! |
968 | ; TODO: BPB_NumFATs !!!!! |
969 | add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!! |
969 | add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!! |
970 | mov byte [si+8*2+3], bh ; bx - begin of FAT |
970 | mov byte [si+8*2+3], bh ; bx - begin of FAT |
971 | 971 | ||
972 | mov ax, word [BPB_BytsPerSec] |
972 | mov ax, word [BPB_BytsPerSec] |
973 | shr ax, 1 ; words per sector |
973 | shr ax, 1 ; words per sector |
974 | mov cx, word [BPB_FATSz16] |
974 | mov cx, word [BPB_FATSz16] |
975 | mul cx |
975 | mul cx |
976 | mov cx, ax ; cx - count of words in FAT |
976 | mov cx, ax ; cx - count of words in FAT |
977 | 977 | ||
978 | push es |
978 | push es |
979 | push ds |
979 | push ds |
980 | pop es |
980 | pop es |
981 | mov ah, 0x87 |
981 | mov ah, 0x87 |
982 | int 0x15 |
982 | int 0x15 |
983 | pop es |
983 | pop es |
984 | test ah, ah |
984 | test ah, ah |
985 | jnz sayerr_floppy |
985 | jnz sayerr_floppy |
986 | 986 | ||
987 | mov ax, cx |
987 | mov ax, cx |
988 | shl ax, 1 |
988 | shl ax, 1 |
989 | and eax, 0ffffh ; ax - count of bytes in FAT |
989 | and eax, 0ffffh ; ax - count of bytes in FAT |
990 | add dword [si+8*3+2], eax |
990 | add dword [si+8*3+2], eax |
991 | 991 | ||
992 | ; reading RootDir |
992 | ; reading RootDir |
993 | ; TODO: BPB_NumFATs |
993 | ; TODO: BPB_NumFATs |
994 | add bx, ax |
994 | add bx, ax |
995 | add bx, 100h |
995 | add bx, 100h |
996 | and bx, 0ff00h ; bx - place in buffer to write RootDir |
996 | and bx, 0ff00h ; bx - place in buffer to write RootDir |
997 | push bx |
997 | push bx |
998 | 998 | ||
999 | mov bx, word [BPB_BytsPerSec] |
999 | mov bx, word [BPB_BytsPerSec] |
1000 | shr bx, 5 ; divide bx by 32 |
1000 | shr bx, 5 ; divide bx by 32 |
1001 | mov ax, word [BPB_RootEntCnt] |
1001 | mov ax, word [BPB_RootEntCnt] |
1002 | xor dx, dx |
1002 | xor dx, dx |
1003 | div bx |
1003 | div bx |
1004 | push ax ; ax - count of RootDir sectors |
1004 | push ax ; ax - count of RootDir sectors |
1005 | 1005 | ||
1006 | mov ax, word [BPB_FATSz16] |
1006 | mov ax, word [BPB_FATSz16] |
1007 | xor cx, cx |
1007 | xor cx, cx |
1008 | mov cl, byte [BPB_NumFATs] |
1008 | mov cl, byte [BPB_NumFATs] |
1009 | mul cx |
1009 | mul cx |
1010 | add ax, word [BPB_RsvdSecCnt] ; ax - first sector of RootDir |
1010 | add ax, word [BPB_RsvdSecCnt] ; ax - first sector of RootDir |
1011 | 1011 | ||
1012 | mov word [FirstDataSector], ax |
1012 | mov word [FirstDataSector], ax |
1013 | pop bx |
1013 | pop bx |
1014 | push bx |
1014 | push bx |
1015 | add word [FirstDataSector], bx ; Begin of data region of floppy |
1015 | add word [FirstDataSector], bx ; Begin of data region of floppy |
1016 | 1016 | ||
1017 | ; read RootDir |
1017 | ; read RootDir |
1018 | call conv_abs_to_THS |
1018 | call conv_abs_to_THS |
1019 | pop ax |
1019 | pop ax |
1020 | pop bx ; place in buffer to write |
1020 | pop bx ; place in buffer to write |
1021 | push ax |
1021 | push ax |
1022 | call boot_read_floppy ; read RootDir into buffer |
1022 | call boot_read_floppy ; read RootDir into buffer |
1023 | ; copy RootDir |
1023 | ; copy RootDir |
1024 | mov byte [si+8*2+3], bh ; from buffer |
1024 | mov byte [si+8*2+3], bh ; from buffer |
1025 | pop ax ; ax = count of RootDir sectors |
1025 | pop ax ; ax = count of RootDir sectors |
1026 | mov cx, word [BPB_BytsPerSec] |
1026 | mov cx, word [BPB_BytsPerSec] |
1027 | mul cx |
1027 | mul cx |
1028 | shr ax, 1 |
1028 | shr ax, 1 |
1029 | mov cx, ax ; count of words to copy |
1029 | mov cx, ax ; count of words to copy |
1030 | push es |
1030 | push es |
1031 | push ds |
1031 | push ds |
1032 | pop es |
1032 | pop es |
1033 | mov ah, 0x87 |
1033 | mov ah, 0x87 |
1034 | int 0x15 |
1034 | int 0x15 |
1035 | pop es |
1035 | pop es |
1036 | 1036 | ||
1037 | mov ax, cx |
1037 | mov ax, cx |
1038 | shl ax, 1 |
1038 | shl ax, 1 |
1039 | and eax, 0ffffh ; ax - count of bytes in RootDir |
1039 | and eax, 0ffffh ; ax - count of bytes in RootDir |
1040 | add dword [si+8*3+2], eax ; add count of bytes copied |
1040 | add dword [si+8*3+2], eax ; add count of bytes copied |
1041 | 1041 | ||
1042 | ; Reading data clusters from floppy |
1042 | ; Reading data clusters from floppy |
1043 | mov byte [si+8*2+3], bh |
1043 | mov byte [si+8*2+3], bh |
1044 | push bx |
1044 | push bx |
1045 | 1045 | ||
1046 | mov di, 2 ; First data cluster |
1046 | mov di, 2 ; First data cluster |
1047 | .read_loop: |
1047 | .read_loop: |
1048 | mov bx, di |
1048 | mov bx, di |
1049 | shr bx, 1 ; bx+di = di*1.5 |
1049 | shr bx, 1 ; bx+di = di*1.5 |
1050 | jnc .even |
1050 | jnc .even |
1051 | test word [es:bx+di+0xB200], 0xFFF0 ; TODO: may not be 0xB200 !!! |
1051 | test word [es:bx+di+0xB200], 0xFFF0 ; TODO: may not be 0xB200 !!! |
1052 | jmp @f |
1052 | jmp @f |
1053 | .even: |
1053 | .even: |
1054 | test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!! |
1054 | test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!! |
1055 | 1055 | ||
1056 | @@: |
1056 | @@: |
1057 | jz .skip |
1057 | jz .skip |
1058 | ; read cluster di |
1058 | ; read cluster di |
1059 | ;.read: |
1059 | ;.read: |
1060 | ;conv cluster di to abs. sector ax |
1060 | ;conv cluster di to abs. sector ax |
1061 | ; ax = (N-2) * BPB_SecPerClus + FirstDataSector |
1061 | ; ax = (N-2) * BPB_SecPerClus + FirstDataSector |
1062 | mov ax, di |
1062 | mov ax, di |
1063 | sub ax, 2 |
1063 | sub ax, 2 |
1064 | xor bx, bx |
1064 | xor bx, bx |
1065 | mov bl, byte [BPB_SecPerClus] |
1065 | mov bl, byte [BPB_SecPerClus] |
1066 | mul bx |
1066 | mul bx |
1067 | add ax, word [FirstDataSector] |
1067 | add ax, word [FirstDataSector] |
1068 | call conv_abs_to_THS |
1068 | call conv_abs_to_THS |
1069 | pop bx |
1069 | pop bx |
1070 | push bx |
1070 | push bx |
1071 | mov al, byte [BPB_SecPerClus] ; number of sectors in cluster |
1071 | mov al, byte [BPB_SecPerClus] ; number of sectors in cluster |
1072 | call boot_read_floppy |
1072 | call boot_read_floppy |
1073 | push es |
1073 | push es |
1074 | push ds |
1074 | push ds |
1075 | pop es |
1075 | pop es |
1076 | pusha |
1076 | pusha |
1077 | ; |
1077 | ; |
1078 | mov ax, word [BPB_BytsPerSec] |
1078 | mov ax, word [BPB_BytsPerSec] |
1079 | xor cx, cx |
1079 | xor cx, cx |
1080 | mov cl, byte [BPB_SecPerClus] |
1080 | mov cl, byte [BPB_SecPerClus] |
1081 | mul cx |
1081 | mul cx |
1082 | shr ax, 1 ; ax = (BPB_BytsPerSec * BPB_SecPerClus)/2 |
1082 | shr ax, 1 ; ax = (BPB_BytsPerSec * BPB_SecPerClus)/2 |
1083 | mov cx, ax ; number of words to copy (count words in cluster) |
1083 | mov cx, ax ; number of words to copy (count words in cluster) |
1084 | ; |
1084 | ; |
1085 | mov ah, 0x87 |
1085 | mov ah, 0x87 |
1086 | int 0x15 ; copy data |
1086 | int 0x15 ; copy data |
1087 | test ah, ah |
1087 | test ah, ah |
1088 | popa |
1088 | popa |
1089 | pop es |
1089 | pop es |
1090 | jnz sayerr_floppy |
1090 | jnz sayerr_floppy |
1091 | ; skip cluster di |
1091 | ; skip cluster di |
1092 | .skip: |
1092 | .skip: |
1093 | mov ax, word [BPB_BytsPerSec] |
1093 | mov ax, word [BPB_BytsPerSec] |
1094 | xor cx, cx |
1094 | xor cx, cx |
1095 | mov cl, byte [BPB_SecPerClus] |
1095 | mov cl, byte [BPB_SecPerClus] |
1096 | mul cx |
1096 | mul cx |
1097 | and eax, 0ffffh ; ax - count of bytes in cluster |
1097 | and eax, 0ffffh ; ax - count of bytes in cluster |
1098 | add dword [si+8*3+2], eax |
1098 | add dword [si+8*3+2], eax |
1099 | 1099 | ||
1100 | mov ax, word [end_of_FAT] ; max cluster number |
1100 | mov ax, word [end_of_FAT] ; max cluster number |
1101 | pusha |
1101 | pusha |
1102 | ; draw percentage |
1102 | ; draw percentage |
1103 | ; total clusters: ax |
1103 | ; total clusters: ax |
1104 | ; read clusters: di |
1104 | ; read clusters: di |
1105 | xchg ax, di |
1105 | xchg ax, di |
1106 | mov cx, 100 |
1106 | mov cx, 100 |
1107 | mul cx |
1107 | mul cx |
1108 | div di |
1108 | div di |
1109 | aam |
1109 | aam |
1110 | xchg al, ah |
1110 | xchg al, ah |
1111 | add ax, '00' |
1111 | add ax, '00' |
1112 | mov si, pros |
1112 | mov si, pros |
1113 | cmp [si], ax |
1113 | cmp [si], ax |
1114 | jz @f |
1114 | jz @f |
1115 | mov [si], ax |
1115 | mov [si], ax |
1116 | call printplain |
1116 | call printplain |
1117 | @@: |
1117 | @@: |
1118 | popa |
1118 | popa |
1119 | inc di |
1119 | inc di |
1120 | cmp di, word [end_of_FAT] ; max number of cluster |
1120 | cmp di, word [end_of_FAT] ; max number of cluster |
1121 | jnz .read_loop |
1121 | jnz .read_loop |
1122 | pop bx ; clear stack |
1122 | pop bx ; clear stack |
1123 | 1123 | ||
1124 | ok_sys_on_floppy: |
1124 | ok_sys_on_floppy: |
1125 | mov si, backspace2 |
1125 | mov si, backspace2 |
1126 | call printplain |
1126 | call printplain |
1127 | mov si, okt |
1127 | mov si, okt |
1128 | call printplain |
1128 | call printplain |
1129 | no_sys_on_floppy: |
1129 | no_sys_on_floppy: |
1130 | xor ax, ax ; reset drive |
1130 | xor ax, ax ; reset drive |
1131 | xor dx, dx |
1131 | xor dx, dx |
1132 | int 0x13 |
1132 | int 0x13 |
1133 | mov dx, 0x3f2 ; floppy motor off |
1133 | mov dx, 0x3f2 ; floppy motor off |
1134 | mov al, 0 |
1134 | mov al, 0 |
1135 | out dx, al |
1135 | out dx, al |
1136 | 1136 | ||
1137 | 1137 | ||
1138 | ; SET GRAPHICS |
1138 | ; SET GRAPHICS |
1139 | 1139 | ||
1140 | xor ax, ax |
1140 | xor ax, ax |
1141 | mov es, ax |
1141 | mov es, ax |
1142 | 1142 | ||
1143 | mov ax, [es:0x9008] ; vga & 320x200 |
1143 | mov ax, [es:0x9008] ; vga & 320x200 |
1144 | mov bx, ax |
1144 | mov bx, ax |
1145 | cmp ax, 0x13 |
1145 | cmp ax, 0x13 |
1146 | je setgr |
1146 | je setgr |
1147 | cmp ax, 0x12 |
1147 | cmp ax, 0x12 |
1148 | je setgr |
1148 | je setgr |
1149 | mov ax, 0x4f02 ; Vesa |
1149 | mov ax, 0x4f02 ; Vesa |
1150 | setgr: |
1150 | setgr: |
1151 | int 0x10 |
1151 | int 0x10 |
1152 | test ah, ah |
1152 | test ah, ah |
1153 | mov si, fatalsel |
1153 | mov si, fatalsel |
1154 | jnz v_mode_error |
1154 | jnz v_mode_error |
1155 | ; set mode 0x12 graphics registers: |
1155 | ; set mode 0x12 graphics registers: |
1156 | cmp bx, 0x12 |
1156 | cmp bx, 0x12 |
1157 | jne gmok2 |
1157 | jne gmok2 |
1158 | 1158 | ||
1159 | mov al, 0x05 |
1159 | mov al, 0x05 |
1160 | mov dx, 0x03ce |
1160 | mov dx, 0x03ce |
1161 | push dx |
1161 | push dx |
1162 | out dx, al ; select GDC mode register |
1162 | out dx, al ; select GDC mode register |
1163 | mov al, 0x02 |
1163 | mov al, 0x02 |
1164 | inc dx |
1164 | inc dx |
1165 | out dx, al ; set write mode 2 |
1165 | out dx, al ; set write mode 2 |
1166 | 1166 | ||
1167 | mov al, 0x02 |
1167 | mov al, 0x02 |
1168 | mov dx, 0x03c4 |
1168 | mov dx, 0x03c4 |
1169 | out dx, al ; select VGA sequencer map mask register |
1169 | out dx, al ; select VGA sequencer map mask register |
1170 | mov al, 0x0f |
1170 | mov al, 0x0f |
1171 | inc dx |
1171 | inc dx |
1172 | out dx, al ; set mask for all planes 0-3 |
1172 | out dx, al ; set mask for all planes 0-3 |
1173 | 1173 | ||
1174 | mov al, 0x08 |
1174 | mov al, 0x08 |
1175 | pop dx |
1175 | pop dx |
1176 | out dx, al ; select GDC bit mask register |
1176 | out dx, al ; select GDC bit mask register |
1177 | ; for writes to 0x03cf |
1177 | ; for writes to 0x03cf |
1178 | gmok2: |
1178 | gmok2: |
1179 | push ds |
1179 | push ds |
1180 | pop es |
1180 | pop es |