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