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