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