Rev 746 | 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: 749 $ |
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 |
||
737 | diamond | 349 | push 0 |
350 | pop es |
||
713 | Lrz | 351 | |
352 | noloaderblock: |
||
1 | ha | 353 | ; DISPLAY VESA INFORMATION |
713 | Lrz | 354 | call print_vesa_info |
355 | call calc_vmodes_table |
||
356 | call check_first_parm ;check and enable cursor_pos |
||
1 | ha | 357 | |
358 | |||
29 | halyavin | 359 | ; \begin{diamond}[30.11.2005] |
360 | cfgmanager: |
||
361 | ; settings: |
||
362 | ; a) preboot_graph = graphical mode |
||
363 | ; preboot_gprobe = probe this mode? |
||
713 | Lrz | 364 | ; b) preboot_dma = use DMA access? |
29 | halyavin | 365 | ; c) preboot_vrrm = use VRR? |
366 | ; d) preboot_device = from what boot? |
||
713 | Lrz | 367 | |
29 | halyavin | 368 | ; determine default settings |
514 | diamond | 369 | mov [.bSettingsChanged], 0 |
713 | Lrz | 370 | |
371 | ;.preboot_gr_end: |
||
726 | diamond | 372 | mov di, preboot_device |
373 | ; if image in memory is present and [preboot_device] is uninitialized, |
||
374 | ; set it to use this preloaded image |
||
375 | cmp byte [di], 0 |
||
376 | jnz .preboot_device_inited |
||
377 | cmp [.loader_block], -1 |
||
378 | jz @f |
||
379 | les bx, [.loader_block] |
||
380 | test byte [es:bx+1], 1 |
||
381 | jz @f |
||
382 | mov byte [di], 3 |
||
383 | jmp .preboot_device_inited |
||
384 | @@: |
||
385 | ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) |
||
386 | mov byte [di], 1 |
||
387 | .preboot_device_inited: |
||
713 | Lrz | 388 | ; following 6 lines set variables to 1 if its current value is 0 |
726 | diamond | 389 | cmp byte [di+preboot_dma-preboot_device], 1 |
390 | adc byte [di+preboot_dma-preboot_device], 0 |
||
391 | cmp byte [di+preboot_biosdisk-preboot_device], 1 |
||
392 | adc byte [di+preboot_biosdisk-preboot_device], 0 |
||
393 | cmp byte [di+preboot_vrrm-preboot_device], 1 |
||
394 | adc byte [di+preboot_vrrm-preboot_device], 0 |
||
29 | halyavin | 395 | ; notify user |
713 | Lrz | 396 | _setcursor 5,2 |
397 | |||
514 | diamond | 398 | mov si, linef |
713 | Lrz | 399 | call printplain |
514 | diamond | 400 | mov si, start_msg |
401 | call print |
||
402 | mov si, time_msg |
||
403 | call print |
||
29 | halyavin | 404 | ; get start time |
514 | diamond | 405 | call .gettime |
406 | mov [.starttime], eax |
||
407 | mov word [.timer], .newtimer |
||
408 | mov word [.timer+2], cs |
||
29 | halyavin | 409 | .printcfg: |
514 | diamond | 410 | _setcursor 9,0 |
411 | mov si, current_cfg_msg |
||
412 | call print |
||
413 | mov si, curvideo_msg |
||
414 | call print |
||
713 | Lrz | 415 | |
416 | call draw_current_vmode |
||
417 | |||
709 | diamond | 418 | mov si, usebd_msg |
419 | cmp [preboot_biosdisk], 1 |
||
420 | call .say_on_off |
||
514 | diamond | 421 | mov si, vrrm_msg |
422 | cmp [preboot_vrrm], 1 |
||
423 | call .say_on_off |
||
424 | mov si, preboot_device_msg |
||
425 | call print |
||
426 | mov al, [preboot_device] |
||
545 | spraid | 427 | and eax, 7 |
514 | diamond | 428 | mov si, [preboot_device_msgs+eax*2] |
429 | call printplain |
||
726 | diamond | 430 | .show_remarks: |
431 | ; show remarks in gray color |
||
432 | mov di, ((21-num_remarks)*80 + 2)*2 |
||
433 | push 0xB800 |
||
434 | pop es |
||
435 | mov cx, num_remarks |
||
436 | mov si, remarks |
||
437 | .write_remarks: |
||
438 | lodsw |
||
439 | push si |
||
440 | xchg ax, si |
||
441 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
||
442 | push di |
||
443 | .write_remark: |
||
444 | lodsb |
||
445 | test al, al |
||
446 | jz @f |
||
447 | stosw |
||
448 | jmp .write_remark |
||
449 | @@: |
||
450 | pop di |
||
451 | pop si |
||
452 | add di, 80*2 |
||
453 | loop .write_remarks |
||
29 | halyavin | 454 | .wait: |
514 | diamond | 455 | _setcursor 25,0 ; out of screen |
34 | halyavin | 456 | ; set timer interrupt handler |
514 | diamond | 457 | cli |
458 | push 0 |
||
459 | pop es |
||
713 | Lrz | 460 | push dword [es:8*4] |
461 | pop dword [.oldtimer] |
||
462 | push dword [.timer] |
||
463 | pop dword [es:8*4] |
||
464 | ; mov eax, [es:8*4] |
||
465 | ; mov [.oldtimer], eax |
||
466 | ; mov eax, [.timer] |
||
467 | ; mov [es:8*4], eax |
||
514 | diamond | 468 | sti |
29 | halyavin | 469 | ; wait for keypressed |
713 | Lrz | 470 | xor ax,ax |
514 | diamond | 471 | int 16h |
472 | push ax |
||
29 | halyavin | 473 | ; restore timer interrupt |
713 | Lrz | 474 | ; push 0 |
475 | ; pop es |
||
514 | diamond | 476 | mov eax, [.oldtimer] |
477 | mov [es:8*4], eax |
||
478 | mov [.timer], eax |
||
479 | _setcursor 7,0 |
||
480 | mov si, space_msg |
||
481 | call printplain |
||
726 | diamond | 482 | ; clear remarks and restore normal attributes |
483 | push es |
||
484 | mov di, ((21-num_remarks)*80 + 2)*2 |
||
485 | push 0xB800 |
||
486 | pop es |
||
487 | mov cx, num_remarks |
||
488 | mov ax, ' ' + (1*16 + 15)*100h |
||
489 | @@: |
||
490 | push cx |
||
491 | mov cx, 76 |
||
492 | rep stosw |
||
493 | pop cx |
||
494 | add di, 4*2 |
||
495 | loop @b |
||
496 | pop es |
||
514 | diamond | 497 | pop ax |
29 | halyavin | 498 | ; switch on key |
514 | diamond | 499 | cmp al, 13 |
500 | jz .continue |
||
501 | or al, 20h |
||
502 | cmp al, 'a' |
||
503 | jz .change_a |
||
504 | cmp al, 'b' |
||
505 | jz .change_b |
||
506 | cmp al, 'c' |
||
507 | jz .change_c |
||
508 | cmp al, 'd' |
||
726 | diamond | 509 | jnz .show_remarks |
514 | diamond | 510 | _setcursor 15,0 |
511 | mov si, bdev |
||
512 | call print |
||
545 | spraid | 513 | mov bx, '14' |
514 | diamond | 514 | call getkey |
515 | mov [preboot_device], al |
||
516 | _setcursor 13,0 |
||
29 | halyavin | 517 | .d: |
514 | diamond | 518 | mov [.bSettingsChanged], 1 |
713 | Lrz | 519 | call clear_vmodes_table ;clear vmodes_table |
514 | diamond | 520 | jmp .printcfg |
29 | halyavin | 521 | .change_a: |
713 | Lrz | 522 | .loops: |
523 | call draw_vmodes_table |
||
524 | |||
525 | xor ax,ax |
||
526 | int 0x16 |
||
527 | ; call clear_table_cursor ;clear current position of cursor |
||
528 | |||
529 | mov si,word [cursor_pos] |
||
530 | |||
531 | cmp ah,0x48;x,0x48E0 ; up |
||
532 | jne .down |
||
533 | cmp si,modes_table |
||
534 | jbe .loops |
||
535 | sub word [cursor_pos],size_of_step |
||
536 | jmp .loops |
||
537 | |||
538 | .down: cmp ah,0x50;x,0x50E0 ; down |
||
730 | diamond | 539 | jne .pgup |
713 | Lrz | 540 | cmp word[es:si+10],-1 |
541 | je .loops |
||
542 | add word [cursor_pos],size_of_step |
||
543 | jmp .loops |
||
544 | |||
730 | diamond | 545 | .pgup: cmp ah,0x49 ; page up |
546 | jne .pgdn |
||
731 | diamond | 547 | sub si, size_of_step*long_v_table |
730 | diamond | 548 | cmp si, modes_table |
549 | jae @f |
||
550 | mov si, modes_table |
||
551 | @@: |
||
552 | mov word [cursor_pos], si |
||
553 | mov si, word [home_cursor] |
||
731 | diamond | 554 | sub si, size_of_step*long_v_table |
730 | diamond | 555 | cmp si, modes_table |
556 | jae @f |
||
557 | mov si, modes_table |
||
558 | @@: |
||
559 | mov word [home_cursor], si |
||
560 | jmp .loops |
||
561 | |||
562 | .pgdn: cmp ah,0x51 ; page down |
||
563 | jne .enter |
||
564 | mov ax, [end_cursor] |
||
731 | diamond | 565 | add si, size_of_step*long_v_table |
730 | diamond | 566 | cmp si, ax |
567 | jb @f |
||
568 | mov si, ax |
||
569 | sub si, size_of_step |
||
570 | @@: |
||
571 | mov word [cursor_pos], si |
||
572 | mov si, word [home_cursor] |
||
731 | diamond | 573 | sub ax, size_of_step*long_v_table |
574 | add si, size_of_step*long_v_table |
||
730 | diamond | 575 | cmp si, ax |
576 | jb @f |
||
577 | mov si, ax |
||
578 | @@: |
||
579 | mov word [home_cursor], si |
||
580 | jmp .loops |
||
581 | |||
713 | Lrz | 582 | .enter: cmp al,0x0D;x,0x1C0D ; enter |
583 | jne .loops |
||
584 | push word [cursor_pos] |
||
746 | Lrz | 585 | pop bp |
586 | push word [es:bp] |
||
587 | pop word [x_save] |
||
588 | push word [es:bp+2] |
||
589 | pop word [y_save] |
||
749 | Lrz | 590 | push word [es:bp+6] |
591 | pop word [number_vm] |
||
746 | Lrz | 592 | mov word [preboot_graph],bp ;save choose |
593 | |||
514 | diamond | 594 | jmp .d |
713 | Lrz | 595 | |
29 | halyavin | 596 | .change_b: |
514 | diamond | 597 | _setcursor 15,0 |
709 | diamond | 598 | ; mov si, ask_dma |
599 | ; call print |
||
600 | ; mov bx, '13' |
||
601 | ; call getkey |
||
602 | ; mov [preboot_dma], al |
||
603 | mov si, ask_bd |
||
514 | diamond | 604 | call print |
709 | diamond | 605 | mov bx, '12' |
514 | diamond | 606 | call getkey |
709 | diamond | 607 | mov [preboot_biosdisk], al |
514 | diamond | 608 | _setcursor 11,0 |
609 | jmp .d |
||
29 | halyavin | 610 | .change_c: |
514 | diamond | 611 | _setcursor 15,0 |
612 | mov si, vrrmprint |
||
613 | call print |
||
614 | mov bx, '12' |
||
615 | call getkey |
||
616 | mov [preboot_vrrm], al |
||
617 | _setcursor 12,0 |
||
618 | jmp .d |
||
713 | Lrz | 619 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
40 | halyavin | 620 | .say_on_off: |
514 | diamond | 621 | pushf |
622 | call print |
||
623 | mov si, on_msg |
||
624 | popf |
||
625 | jz @f |
||
626 | mov si, off_msg |
||
627 | @@: jmp printplain |
||
40 | halyavin | 628 | ; novesa and vervesa strings are not used at the moment of executing this code |
629 | virtual at novesa |
||
29 | halyavin | 630 | .oldtimer dd ? |
631 | .starttime dd ? |
||
632 | .bSettingsChanged db ? |
||
34 | halyavin | 633 | .timer dd ? |
40 | halyavin | 634 | end virtual |
143 | diamond | 635 | .loader_block dd -1 |
29 | halyavin | 636 | .gettime: |
514 | diamond | 637 | mov ah, 0 |
638 | int 1Ah |
||
639 | xchg ax, cx |
||
640 | shl eax, 10h |
||
641 | xchg ax, dx |
||
642 | ret |
||
29 | halyavin | 643 | .newtimer: |
514 | diamond | 644 | push ds |
645 | push cs |
||
646 | pop ds |
||
647 | pushf |
||
648 | call [.oldtimer] |
||
649 | pushad |
||
650 | call .gettime |
||
651 | sub eax, [.starttime] |
||
652 | sub ax, 18*5 |
||
653 | jae .timergo |
||
654 | neg ax |
||
655 | add ax, 18-1 |
||
656 | mov bx, 18 |
||
657 | xor dx, dx |
||
658 | div bx |
||
29 | halyavin | 659 | if lang eq ru |
660 | ; ¯®¤®¦¤¨â¥ 5 ᥪã¤, 4/3/2 ᥪã¤ë, 1 ᥪã¤ã |
||
514 | diamond | 661 | cmp al, 5 |
662 | mov cl, ' ' |
||
663 | jae @f |
||
664 | cmp al, 1 |
||
665 | mov cl, 'ã' |
||
666 | jz @f |
||
667 | mov cl, 'ë' |
||
668 | @@: mov [time_str+9], cl |
||
274 | kaitz | 669 | else if lang eq et |
514 | diamond | 670 | cmp al, 1 |
671 | ja @f |
||
672 | mov [time_str+9], ' ' |
||
673 | mov [time_str+10],' ' |
||
381 | serge | 674 | @@: |
29 | halyavin | 675 | else |
676 | ; wait 5/4/3/2 seconds, 1 second |
||
514 | diamond | 677 | cmp al, 1 |
678 | mov cl, 's' |
||
679 | ja @f |
||
680 | mov cl, ' ' |
||
681 | @@: mov [time_str+9], cl |
||
29 | halyavin | 682 | end if |
514 | diamond | 683 | add al, '0' |
684 | mov [time_str+1], al |
||
685 | mov si, time_msg |
||
686 | _setcursor 7,0 |
||
687 | call print |
||
688 | _setcursor 25,0 |
||
689 | popad |
||
690 | pop ds |
||
691 | iret |
||
29 | halyavin | 692 | .timergo: |
514 | diamond | 693 | push 0 |
694 | pop es |
||
695 | mov eax, [.oldtimer] |
||
696 | mov [es:8*4], eax |
||
697 | mov sp, 0EC00h |
||
29 | halyavin | 698 | .continue: |
514 | diamond | 699 | sti |
700 | _setcursor 6,0 |
||
701 | mov si, space_msg |
||
702 | call printplain |
||
703 | call printplain |
||
704 | _setcursor 6,0 |
||
705 | mov si, loading_msg |
||
706 | call print |
||
707 | _setcursor 15,0 |
||
708 | cmp [.bSettingsChanged], 0 |
||
709 | jz .load |
||
710 | cmp [.loader_block], -1 |
||
711 | jz .load |
||
712 | les bx, [.loader_block] |
||
713 | mov eax, [es:bx+3] |
||
714 | push ds |
||
715 | pop es |
||
716 | test eax, eax |
||
717 | jz .load |
||
718 | push eax |
||
719 | mov si, save_quest |
||
720 | call print |
||
29 | halyavin | 721 | .waityn: |
514 | diamond | 722 | mov ah, 0 |
723 | int 16h |
||
724 | or al, 20h |
||
725 | cmp al, 'n' |
||
726 | jz .loadc |
||
727 | cmp al, 'y' |
||
728 | jnz .waityn |
||
729 | call putchar |
||
730 | mov byte [space_msg+80], 186 |
||
731 | pop eax |
||
732 | push cs |
||
733 | push .cont |
||
734 | push eax |
||
735 | retf |
||
29 | halyavin | 736 | .loadc: |
514 | diamond | 737 | pop eax |
29 | halyavin | 738 | .cont: |
514 | diamond | 739 | push cs |
740 | pop ds |
||
741 | mov si, space_msg |
||
742 | mov byte [si+80], 0 |
||
743 | _setcursor 15,0 |
||
744 | call printplain |
||
745 | _setcursor 15,0 |
||
29 | halyavin | 746 | .load: |
747 | ; \end{diamond}[02.12.2005] |
||
1 | ha | 748 | |
749 | ; ASK GRAPHICS MODE |
||
750 | |||
713 | Lrz | 751 | call set_vmode |
1 | ha | 752 | |
753 | ; GRAPHICS ACCELERATION |
||
346 | diamond | 754 | ; force yes |
755 | mov [es:0x901C], byte 1 |
||
1 | ha | 756 | |
514 | diamond | 757 | ; DMA ACCESS TO HD |
1 | ha | 758 | |
514 | diamond | 759 | mov al, [preboot_dma] |
760 | mov [es:0x901F], al |
||
346 | diamond | 761 | |
1 | ha | 762 | ; VRR_M USE |
763 | |||
465 | serge | 764 | mov al,[preboot_vrrm] |
514 | diamond | 765 | mov [es:0x9030], al |
766 | mov [es:0x901E], byte 1 |
||
1 | ha | 767 | |
768 | ; BOOT DEVICE |
||
769 | |||
514 | diamond | 770 | mov al, [preboot_device] |
40 | halyavin | 771 | dec al |
514 | diamond | 772 | mov [boot_dev], al |
1 | ha | 773 | |
774 | ; READ DISKETTE TO MEMORY |
||
775 | |||
465 | serge | 776 | ; cmp [boot_dev],0 |
1 | ha | 777 | jne no_sys_on_floppy |
465 | serge | 778 | mov si,diskload |
1 | ha | 779 | call print |
514 | diamond | 780 | xor ax, ax ; reset drive |
781 | xor dx, dx |
||
1 | ha | 782 | int 0x13 |
709 | diamond | 783 | ; do we boot from CD-ROM? |
784 | mov ah, 41h |
||
785 | mov bx, 55AAh |
||
786 | xor dx, dx |
||
787 | int 0x13 |
||
788 | jc .nocd |
||
789 | cmp bx, 0AA55h |
||
790 | jnz .nocd |
||
791 | mov ah, 48h |
||
792 | push ds |
||
793 | push es |
||
794 | pop ds |
||
795 | mov si, 0xa000 |
||
796 | mov word [si], 30 |
||
797 | int 0x13 |
||
798 | pop ds |
||
799 | jc .nocd |
||
800 | push ds |
||
801 | lds si, [es:si+26] |
||
802 | test byte [ds:si+10], 40h |
||
803 | pop ds |
||
804 | jz .nocd |
||
805 | ; yes - read all floppy by 18 sectors |
||
806 | mov cx, 0x0001 ; startcyl,startsector |
||
807 | .a1: |
||
808 | push cx dx |
||
809 | mov al, 18 |
||
810 | mov bx, 0xa000 |
||
811 | call boot_read_floppy |
||
812 | mov si, movedesc |
||
813 | push es |
||
814 | push ds |
||
815 | pop es |
||
816 | mov cx, 256*18 |
||
817 | mov ah, 0x87 |
||
818 | int 0x15 |
||
819 | pop es |
||
820 | pop dx cx |
||
821 | test ah, ah |
||
822 | jnz sayerr_floppy |
||
823 | add dword [si+8*3+2], 512*18 |
||
824 | inc dh |
||
825 | cmp dh, 2 |
||
826 | jnz .a1 |
||
827 | mov dh, 0 |
||
828 | inc ch |
||
829 | cmp ch, 80 |
||
830 | jae ok_sys_on_floppy |
||
831 | pusha |
||
832 | mov al, ch |
||
833 | shr ch, 2 |
||
834 | add al, ch |
||
835 | aam |
||
836 | xchg al, ah |
||
837 | add ax, '00' |
||
838 | mov si, pros |
||
839 | mov [si], ax |
||
840 | call printplain |
||
841 | popa |
||
842 | jmp .a1 |
||
843 | .nocd: |
||
844 | ; no - read only used sectors from floppy |
||
134 | diamond | 845 | ; now load floppy image to memory |
846 | ; at first load boot sector and first FAT table |
||
847 | mov cx, 0x0001 ; startcyl,startsector |
||
848 | xor dx, dx ; starthead,drive |
||
849 | mov al, 1+9 ; no of sectors to read |
||
850 | mov bx, 0xB000 ; es:bx -> data area |
||
851 | call boot_read_floppy |
||
852 | ; and copy them to extended memory |
||
465 | serge | 853 | mov si, movedesc |
134 | diamond | 854 | mov [si+8*2+3], bh |
855 | push es |
||
856 | push ds |
||
857 | pop es |
||
858 | mov cx, 256*10 |
||
859 | mov ah, 0x87 |
||
860 | int 0x15 |
||
76 | mario79 | 861 | test ah, ah |
134 | diamond | 862 | jz @f |
863 | sayerr_floppy: |
||
864 | mov dx, 0x3f2 |
||
865 | mov al, 0 |
||
866 | out dx, al |
||
465 | serge | 867 | mov si, memmovefailed |
134 | diamond | 868 | jmp sayerr_plain |
869 | @@: |
||
870 | add dword [si+8*3+2], 512*10 |
||
871 | ; copy FAT to second copy |
||
872 | mov byte [si+8*2+3], 0xB2 |
||
873 | mov cx, 256*9 |
||
874 | mov ah, 0x87 |
||
875 | int 0x15 |
||
876 | pop es |
||
877 | test ah, ah |
||
878 | jnz sayerr_floppy |
||
879 | add dword [si+8*3+2], 512*9 |
||
880 | ; calculate total number of sectors to read |
||
881 | mov ax, 1+9+14 ; boot+FAT+root |
||
882 | mov di, 0xB203 |
||
883 | .calc_loop: |
||
884 | test word [es:di], 0xFFF |
||
885 | jz @f |
||
886 | inc ax |
||
887 | @@: |
||
888 | test word [es:di+1], 0xFFF0 |
||
889 | jz @f |
||
890 | inc ax |
||
891 | @@: |
||
892 | add di, 3 |
||
893 | cmp di, 0xB200+1440*3 |
||
894 | jb .calc_loop |
||
895 | push ax |
||
896 | mov bp, 1+9 ; already read sectors |
||
897 | ; now read rest |
||
898 | mov byte [si+8*2+3], 0xA0 |
||
899 | mov di, 2-14 ; absolute sector-31 |
||
900 | mov cx, 0x0002 ; cylinder=0, sector=2 |
||
901 | mov dx, 0x0100 ; head=1, disk=0 |
||
902 | .read_loop: |
||
903 | ; determine whether sector must be read |
||
904 | cmp di, 2 |
||
905 | jl .read |
||
906 | mov bx, di |
||
907 | shr bx, 1 |
||
908 | jnc .even |
||
909 | test word [es:bx+di+0xB200], 0xFFF0 |
||
910 | jmp @f |
||
911 | .even: |
||
912 | test word [es:bx+di+0xB200], 0xFFF |
||
913 | @@: |
||
914 | jz .skip |
||
915 | .read: |
||
916 | mov bx, 0xA000 |
||
917 | mov al, 1 ; 1 sector |
||
918 | call boot_read_floppy |
||
919 | inc bp |
||
76 | mario79 | 920 | push es |
921 | push ds |
||
1 | ha | 922 | pop es |
134 | diamond | 923 | pusha |
924 | mov cx, 256 |
||
925 | mov ah, 0x87 |
||
1 | ha | 926 | int 0x15 |
134 | diamond | 927 | test ah, ah |
1 | ha | 928 | popa |
134 | diamond | 929 | pop es |
930 | jnz sayerr_floppy |
||
931 | .skip: |
||
932 | add dword [si+8*3+2], 512 |
||
933 | inc cx |
||
934 | cmp cl, 19 |
||
935 | jnz @f |
||
936 | mov cl, 1 |
||
1 | ha | 937 | inc dh |
134 | diamond | 938 | cmp dh, 2 |
939 | jnz @f |
||
940 | mov dh, 0 |
||
1 | ha | 941 | inc ch |
29 | halyavin | 942 | @@: |
134 | diamond | 943 | pop ax |
944 | push ax |
||
945 | pusha |
||
946 | ; draw percentage |
||
947 | ; total sectors: ax |
||
948 | ; read sectors: bp |
||
949 | xchg ax, bp |
||
950 | mov cx, 100 |
||
951 | mul cx |
||
952 | div bp |
||
953 | aam |
||
954 | xchg al, ah |
||
955 | add ax, '00' |
||
465 | serge | 956 | mov si, pros |
134 | diamond | 957 | cmp [si], ax |
958 | jz @f |
||
959 | mov [si], ax |
||
1 | ha | 960 | call printplain |
134 | diamond | 961 | @@: |
1 | ha | 962 | popa |
134 | diamond | 963 | inc di |
964 | cmp di, 2880-31 |
||
965 | jnz .read_loop |
||
966 | |||
967 | ; mov cx, 0x0001 ; startcyl,startsector |
||
968 | ; xor dx, dx ; starthead,drive |
||
969 | ; push word 80*2 ; read no of sect |
||
970 | ; reads: |
||
971 | ; pusha |
||
972 | ; xor si,si |
||
973 | ; newread: |
||
974 | ; mov bx,0xa000 ; es:bx -> data area |
||
975 | ; mov ax,0x0200+18 ; read, no of sectors to read |
||
976 | ; int 0x13 |
||
977 | ; test ah, ah |
||
978 | ; jz goodread |
||
979 | ; inc si |
||
980 | ; cmp si,10 |
||
981 | ; jnz newread |
||
982 | ; mov si,badsect-0x10000 |
||
983 | ;sayerr_plain: |
||
984 | ; call printplain |
||
985 | ; jmp $ |
||
986 | ; goodread: |
||
987 | ; ; move -> 1mb |
||
988 | ; mov si,movedesc-0x10000 |
||
989 | ; push es |
||
990 | ; push ds |
||
991 | ; pop es |
||
992 | ; mov cx,256*18 |
||
993 | ; mov ah,0x87 |
||
994 | ; int 0x15 |
||
995 | ; pop es |
||
996 | ; |
||
997 | ; test ah,ah ; was the move successfull ? |
||
998 | ; je goodmove |
||
999 | ; mov dx,0x3f2 ; floppy motor off |
||
1000 | ; mov al,0 |
||
1001 | ; out dx,al |
||
1002 | ; mov si,memmovefailed-0x10000 |
||
1003 | ; jmp sayerr_plain |
||
1004 | ; goodmove: |
||
1005 | ; |
||
1006 | ; add dword [movedesc-0x10000+0x18+2], 512*18 |
||
1007 | ; popa |
||
1008 | ; inc dh |
||
1009 | ; cmp dh,2 |
||
1010 | ; jnz bb2 |
||
1011 | ; mov dh,0 |
||
1012 | ; inc ch |
||
1013 | ; pusha ; print prosentage |
||
1014 | ; mov si,pros-0x10000 |
||
1015 | ; shr ch, 2 |
||
1016 | ; mov al, '5' |
||
1017 | ; test ch, 1 |
||
1018 | ; jnz @f |
||
1019 | ; mov al, '0' |
||
1020 | ;@@: |
||
1021 | ; mov [si+1], al |
||
1022 | ; shr ch, 1 |
||
1023 | ; add ch, '0' |
||
1024 | ; mov [si], ch |
||
1025 | ; call printplain |
||
1026 | ; popa |
||
1027 | ; bb2: |
||
1028 | ; pop ax |
||
1029 | ; dec ax |
||
1030 | ; push ax |
||
1031 | ; jnz reads |
||
1032 | ; readdone: |
||
1033 | ; pop ax |
||
465 | serge | 1034 | |
709 | diamond | 1035 | ok_sys_on_floppy: |
514 | diamond | 1036 | mov si, backspace2 |
1 | ha | 1037 | call printplain |
514 | diamond | 1038 | mov si, okt |
1 | ha | 1039 | call printplain |
514 | diamond | 1040 | no_sys_on_floppy: |
1041 | xor ax, ax ; reset drive |
||
1042 | xor dx, dx |
||
1 | ha | 1043 | int 0x13 |
514 | diamond | 1044 | mov dx, 0x3f2 ; floppy motor off |
1045 | mov al, 0 |
||
1046 | out dx, al |
||
1 | ha | 1047 | |
1048 | |||
1049 | ; SET GRAPHICS |
||
1050 | |||
514 | diamond | 1051 | xor ax, ax |
1052 | mov es, ax |
||
164 | serge | 1053 | |
514 | diamond | 1054 | mov ax, [es:0x9008] ; vga & 320x200 |
1055 | mov bx, ax |
||
1056 | cmp ax, 0x13 |
||
1 | ha | 1057 | je setgr |
514 | diamond | 1058 | cmp ax, 0x12 |
1 | ha | 1059 | je setgr |
514 | diamond | 1060 | mov ax, 0x4f02 ; Vesa |
412 | serge | 1061 | setgr: |
1 | ha | 1062 | int 0x10 |
514 | diamond | 1063 | test ah, ah |
1064 | mov si, fatalsel |
||
713 | Lrz | 1065 | jnz v_mode_error |
1 | ha | 1066 | ; set mode 0x12 graphics registers: |
514 | diamond | 1067 | cmp bx, 0x12 |
1 | ha | 1068 | jne gmok2 |
1069 | |||
514 | diamond | 1070 | mov al, 0x05 |
1071 | mov dx, 0x03ce |
||
40 | halyavin | 1072 | push dx |
514 | diamond | 1073 | out dx, al ; select GDC mode register |
1074 | mov al, 0x02 |
||
1075 | inc dx |
||
1076 | out dx, al ; set write mode 2 |
||
1 | ha | 1077 | |
514 | diamond | 1078 | mov al, 0x02 |
1079 | mov dx, 0x03c4 |
||
1080 | out dx, al ; select VGA sequencer map mask register |
||
1081 | mov al, 0x0f |
||
1082 | inc dx |
||
1083 | out dx, al ; set mask for all planes 0-3 |
||
1 | ha | 1084 | |
514 | diamond | 1085 | mov al, 0x08 |
1086 | pop dx |
||
1087 | out dx, al ; select GDC bit mask register |
||
1 | ha | 1088 | ; for writes to 0x03cf |
412 | serge | 1089 | gmok2: |
76 | mario79 | 1090 | push ds |
514 | diamond | 1091 | pop es |