Rev 848 | 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: 851 $ |
1 | ha | 15 | |
16 | |||
17 | ;========================================================================== |
||
18 | ; |
||
19 | ; 16 BIT FUNCTIONS |
||
20 | ; |
||
21 | ;========================================================================== |
||
22 | |||
848 | serge | 23 | use16 |
183 | diamond | 24 | |
29 | halyavin | 25 | putchar: |
26 | ; in: al=character |
||
514 | diamond | 27 | mov ah, 0Eh |
28 | mov bh, 0 |
||
29 | int 10h |
||
30 | ret |
||
1 | ha | 31 | |
29 | halyavin | 32 | print: |
33 | ; in: si->string |
||
514 | diamond | 34 | mov al, 186 |
851 | serge | 35 | call word putchar |
514 | diamond | 36 | mov al, ' ' |
851 | serge | 37 | call word putchar |
1 | ha | 38 | |
29 | halyavin | 39 | printplain: |
40 | ; in: si->string |
||
514 | diamond | 41 | pusha |
42 | lodsb |
||
29 | halyavin | 43 | @@: |
514 | diamond | 44 | call putchar |
45 | lodsb |
||
46 | cmp al, 0 |
||
47 | jnz @b |
||
48 | popa |
||
49 | ret |
||
1 | ha | 50 | |
29 | halyavin | 51 | getkey: |
52 | ; get number in range [bl,bh] (bl,bh in ['0'..'9']) |
||
53 | ; in: bx=range |
||
54 | ; out: ax=digit (1..9, 10 for 0) |
||
514 | diamond | 55 | mov ah, 0 |
56 | int 16h |
||
57 | cmp al, bl |
||
58 | jb getkey |
||
59 | cmp al, bh |
||
60 | ja getkey |
||
61 | push ax |
||
62 | call putchar |
||
63 | pop ax |
||
64 | and ax, 0Fh |
||
65 | jnz @f |
||
66 | mov al, 10 |
||
29 | halyavin | 67 | @@: |
514 | diamond | 68 | ret |
1 | ha | 69 | |
29 | halyavin | 70 | setcursor: |
71 | ; in: dl=column, dh=row |
||
514 | diamond | 72 | mov ah, 2 |
73 | mov bh, 0 |
||
74 | int 10h |
||
75 | ret |
||
29 | halyavin | 76 | |
77 | macro _setcursor row,column |
||
78 | { |
||
514 | diamond | 79 | mov dx, row*256 + column |
80 | call setcursor |
||
29 | halyavin | 81 | } |
82 | |||
134 | diamond | 83 | boot_read_floppy: |
84 | push si |
||
85 | xor si, si |
||
86 | mov ah, 2 ; read |
||
87 | @@: |
||
88 | push ax |
||
89 | int 0x13 |
||
90 | pop ax |
||
91 | jnc @f |
||
92 | inc si |
||
93 | cmp si, 10 |
||
94 | jb @b |
||
465 | serge | 95 | mov si, badsect |
134 | diamond | 96 | sayerr_plain: |
97 | call printplain |
||
98 | jmp $ |
||
99 | @@: |
||
100 | pop si |
||
101 | ret |
||
102 | |||
795 | shurf | 103 | ; convert abs. sector number (AX) to BIOS T:H:S |
104 | ; sector number = (abs.sector%BPB_SecPerTrk)+1 |
||
105 | ; pre.track number = (abs.sector/BPB_SecPerTrk) |
||
106 | ; head number = pre.track number%BPB_NumHeads |
||
107 | ; track number = pre.track number/BPB_NumHeads |
||
108 | ; Return: cl - sector number |
||
109 | ; ch - track number |
||
110 | ; dl - drive number (0 = a:) |
||
111 | ; dh - head number |
||
112 | conv_abs_to_THS: |
||
113 | push bx |
||
114 | mov bx,word [BPB_SecPerTrk] |
||
115 | xor dx,dx |
||
116 | div bx |
||
117 | inc dx |
||
118 | mov cl, dl ; cl = sector number |
||
119 | mov bx,word [BPB_NumHeads] |
||
120 | xor dx,dx |
||
121 | div bx |
||
122 | ; !!!!!!! ax = track number, dx = head number |
||
123 | mov ch,al ; ch=track number |
||
124 | xchg dh,dl ; dh=head number |
||
125 | mov dl,0 ; dl=0 (drive 0 (a:)) |
||
126 | pop bx |
||
127 | retn |
||
848 | serge | 128 | |
129 | sayerr: |
||
130 | call print |
||
131 | jmp $ |
||
132 | |||
795 | shurf | 133 | ; needed variables |
816 | Lrz | 134 | BPB_SecPerTrk dw 0 ; sectors per track |
135 | BPB_NumHeads dw 0 ; number of heads |
||
136 | BPB_FATSz16 dw 0 ; size of FAT |
||
137 | BPB_RootEntCnt dw 0 ; count of root dir. entries |
||
138 | BPB_BytsPerSec dw 0 ; bytes per sector |
||
139 | BPB_RsvdSecCnt dw 0 ; number of reserved sectors |
||
140 | BPB_TotSec16 dw 0 ; count of the sectors on the volume |
||
141 | BPB_SecPerClus db 0 ; number of sectors per cluster |
||
142 | BPB_NumFATs db 0 ; number of FAT tables |
||
143 | abs_sector_adj dw 0 ; adjustment to make abs. sector number |
||
144 | end_of_FAT dw 0 ; end of FAT table |
||
145 | FirstDataSector dw 0 ; begin of data |
||
795 | shurf | 146 | |
1 | ha | 147 | ;========================================================================= |
148 | ; |
||
149 | ; 16 BIT CODE |
||
150 | ; |
||
151 | ;========================================================================= |
||
152 | |||
837 | serge | 153 | include 'bootvesa.inc' ;Include source for boot vesa |
1 | ha | 154 | |
155 | start_of_code: |
||
848 | serge | 156 | |
514 | diamond | 157 | cld |
1 | ha | 158 | |
848 | serge | 159 | xor ecx, ecx |
160 | xor edx, edx |
||
161 | xor esi, esi |
||
162 | xor edi, edi |
||
163 | xor ebp, ebp |
||
488 | spraid | 164 | |
848 | serge | 165 | mov eax, 0x3000 |
166 | mov ss, ax |
||
167 | mov esp, 0EC00h |
||
1 | ha | 168 | |
848 | serge | 169 | mov ebx, 0x1000 |
170 | mov ds, bx |
||
171 | mov es, bx |
||
172 | |||
29 | halyavin | 173 | ; set videomode |
514 | diamond | 174 | mov ax, 3 |
175 | int 0x10 |
||
1 | ha | 176 | |
134 | diamond | 177 | if lang eq ru |
1 | ha | 178 | ; Load & set russian VGA font (RU.INC) |
514 | diamond | 179 | mov bp, RU_FNT1 ; RU_FNT1 - First part |
180 | mov bx, 1000h ; 768 bytes |
||
181 | mov cx, 30h ; 48 symbols |
||
182 | mov dx, 80h ; 128 - position of first symbol |
||
183 | mov ax, 1100h |
||
184 | int 10h |
||
1 | ha | 185 | |
514 | diamond | 186 | mov bp, RU_FNT2 ; RU_FNT2 -Second part |
187 | mov bx, 1000h ; 512 bytes |
||
188 | mov cx, 20h ; 32 symbols |
||
189 | mov dx, 0E0h ; 224 - position of first symbol |
||
190 | mov ax, 1100h |
||
191 | int 10h |
||
1 | ha | 192 | ; End set VGA russian font |
274 | kaitz | 193 | else if lang eq et |
514 | diamond | 194 | mov bp, ET_FNT ; ET_FNT1 |
195 | mov bx, 1000h ; |
||
196 | mov cx, 255 ; 256 symbols |
||
197 | xor dx, dx ; 0 - position of first symbol |
||
198 | mov ax, 1100h |
||
199 | int 10h |
||
134 | diamond | 200 | end if |
1 | ha | 201 | |
29 | halyavin | 202 | ; draw frames |
514 | diamond | 203 | push 0xb800 |
204 | pop es |
||
205 | xor di, di |
||
206 | mov ah, 1*16+15 |
||
465 | serge | 207 | |
29 | halyavin | 208 | ; draw top |
514 | diamond | 209 | mov si, d80x25_top |
210 | mov cx, d80x25_top_num * 80 |
||
29 | halyavin | 211 | @@: |
514 | diamond | 212 | lodsb |
213 | stosw |
||
214 | loop @b |
||
848 | serge | 215 | |
29 | halyavin | 216 | ; draw spaces |
514 | diamond | 217 | mov si, space_msg |
218 | mov dx, 25 - d80x25_top_num - d80x25_bottom_num |
||
29 | halyavin | 219 | dfl1: |
514 | diamond | 220 | push si |
221 | mov cx, 80 |
||
29 | halyavin | 222 | @@: |
514 | diamond | 223 | lodsb |
224 | stosw |
||
225 | loop @b |
||
226 | pop si |
||
227 | dec dx |
||
228 | jnz dfl1 |
||
29 | halyavin | 229 | ; draw bottom |
514 | diamond | 230 | mov si, d80x25_bottom |
231 | mov cx, d80x25_bottom_num * 80 |
||
29 | halyavin | 232 | @@: |
514 | diamond | 233 | lodsb |
234 | stosw |
||
235 | loop @b |
||
1 | ha | 236 | |
514 | diamond | 237 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
1 | ha | 238 | |
514 | diamond | 239 | _setcursor d80x25_top_num,0 |
1 | ha | 240 | |
514 | diamond | 241 | push 0 |
465 | serge | 242 | popf |
243 | sti |
||
244 | |||
160 | diamond | 245 | push 0 |
246 | pop es |
||
247 | and word [es:0x9031], 0 |
||
164 | serge | 248 | ; \begin{Mario79} |
249 | ; find HDD IDE DMA PCI device |
||
160 | diamond | 250 | ; check for PCI BIOS |
251 | mov ax, 0xB101 |
||
252 | int 0x1A |
||
253 | jc .nopci |
||
254 | cmp edx, 'PCI ' |
||
255 | jnz .nopci |
||
256 | ; find PCI class code |
||
257 | ; class 1 = mass storage |
||
258 | ; subclass 1 = IDE controller |
||
259 | ; a) class 1, subclass 1, programming interface 0x80 |
||
260 | mov ax, 0xB103 |
||
261 | mov ecx, 1*10000h + 1*100h + 0x80 |
||
514 | diamond | 262 | xor si, si ; device index = 0 |
160 | diamond | 263 | int 0x1A |
264 | jnc .found |
||
187 | diamond | 265 | ; b) class 1, subclass 1, programming interface 0x8A |
160 | diamond | 266 | mov ax, 0xB103 |
187 | diamond | 267 | mov ecx, 1*10000h + 1*100h + 0x8A |
514 | diamond | 268 | xor si, si ; device index = 0 |
160 | diamond | 269 | int 0x1A |
270 | jnc .found |
||
187 | diamond | 271 | ; c) class 1, subclass 1, programming interface 0x85 |
160 | diamond | 272 | mov ax, 0xB103 |
187 | diamond | 273 | mov ecx, 1*10000h + 1*100h + 0x85 |
514 | diamond | 274 | xor si, si |
160 | diamond | 275 | int 0x1A |
276 | jc .nopci |
||
277 | .found: |
||
278 | ; get memory base |
||
279 | mov ax, 0xB10A |
||
280 | mov di, 0x20 ; memory base is config register at 0x20 |
||
281 | int 0x1A |
||
282 | jc .nopci |
||
283 | and cx, 0xFFF0 ; clear address decode type |
||
284 | mov [es:0x9031], cx |
||
285 | .nopci: |
||
164 | serge | 286 | ; \end{Mario79} |
160 | diamond | 287 | |
514 | diamond | 288 | mov al, 0xf6 ; ╤сЁюё ъыртшрЄєЁ√, ЁрчЁх°шЄ№ ёърэшЁютрэшх |
289 | out 0x60, al |
||
290 | xor cx, cx |
||
1 | ha | 291 | wait_loop: ; variant 2 |
292 | ; reading state of port of 8042 controller |
||
514 | diamond | 293 | in al, 64h |
294 | and al, 00000010b ; ready flag |
||
164 | serge | 295 | ; wait until 8042 controller is ready |
1 | ha | 296 | loopnz wait_loop |
297 | |||
713 | Lrz | 298 | ;;;/diamond today 5.02.2008 |
299 | ; set keyboard typematic rate & delay |
||
300 | mov al, 0xf3 |
||
301 | out 0x60, al |
||
302 | xor cx, cx |
||
303 | @@: |
||
304 | in al, 64h |
||
305 | test al, 2 |
||
306 | loopnz @b |
||
307 | mov al, 0 |
||
308 | out 0x60, al |
||
309 | xor cx, cx |
||
310 | @@: |
||
311 | in al, 64h |
||
312 | test al, 2 |
||
313 | loopnz @b |
||
314 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
76 | mario79 | 315 | ; --------------- APM --------------------- |
514 | diamond | 316 | and word [es:0x9044], 0 ; ver = 0.0 (APM not found) |
317 | mov ax, 0x5300 |
||
318 | xor bx, bx |
||
319 | int 0x15 |
||
320 | jc apm_end ; APM not found |
||
321 | test cx, 2 |
||
322 | jz apm_end ; APM 32-bit protected-mode interface not supported |
||
323 | mov [es:0x9044], ax ; Save APM Version |
||
324 | mov [es:0x9046], cx ; Save APM flags |
||
164 | serge | 325 | |
514 | diamond | 326 | ; Write APM ver ---- |
327 | and ax, 0xf0f |
||
328 | add ax, '00' |
||
329 | mov si, msg_apm |
||
330 | mov [si + 5], ah |
||
331 | mov [si + 7], al |
||
332 | _setcursor 0, 3 |
||
333 | call printplain |
||
334 | ; ------------------ |
||
164 | serge | 335 | |
514 | diamond | 336 | mov ax, 0x5304 ; Disconnect interface |
337 | xor bx, bx |
||
338 | int 0x15 |
||
339 | mov ax, 0x5303 ; Connect 32 bit mode interface |
||
340 | xor bx, bx |
||
341 | int 0x15 |
||
465 | serge | 342 | |
514 | diamond | 343 | mov [es:0x9040], ebx |
344 | mov [es:0x9050], ax |
||
345 | mov [es:0x9052], cx |
||
346 | mov [es:0x9054], dx |
||
465 | serge | 347 | |
76 | mario79 | 348 | apm_end: |
437 | diamond | 349 | _setcursor d80x25_top_num, 0 |
76 | mario79 | 350 | |
737 | diamond | 351 | push 0 |
352 | pop es |
||
713 | Lrz | 353 | |
354 | noloaderblock: |
||
1 | ha | 355 | ; DISPLAY VESA INFORMATION |
713 | Lrz | 356 | call print_vesa_info |
357 | call calc_vmodes_table |
||
358 | call check_first_parm ;check and enable cursor_pos |
||
1 | ha | 359 | |
29 | halyavin | 360 | ; \begin{diamond}[30.11.2005] |
361 | cfgmanager: |
||
362 | ; settings: |
||
363 | ; a) preboot_graph = graphical mode |
||
364 | ; preboot_gprobe = probe this mode? |
||
713 | Lrz | 365 | ; b) preboot_dma = use DMA access? |
29 | halyavin | 366 | ; c) preboot_vrrm = use VRR? |
367 | ; d) preboot_device = from what boot? |
||
713 | Lrz | 368 | |
29 | halyavin | 369 | ; determine default settings |
514 | diamond | 370 | mov [.bSettingsChanged], 0 |
713 | Lrz | 371 | |
372 | ;.preboot_gr_end: |
||
726 | diamond | 373 | mov di, preboot_device |
374 | ; if image in memory is present and [preboot_device] is uninitialized, |
||
375 | ; set it to use this preloaded image |
||
376 | cmp byte [di], 0 |
||
377 | jnz .preboot_device_inited |
||
378 | cmp [.loader_block], -1 |
||
379 | jz @f |
||
380 | les bx, [.loader_block] |
||
381 | test byte [es:bx+1], 1 |
||
382 | jz @f |
||
383 | mov byte [di], 3 |
||
384 | jmp .preboot_device_inited |
||
385 | @@: |
||
386 | ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) |
||
387 | mov byte [di], 1 |
||
388 | .preboot_device_inited: |
||
713 | Lrz | 389 | ; following 6 lines set variables to 1 if its current value is 0 |
726 | diamond | 390 | cmp byte [di+preboot_dma-preboot_device], 1 |
391 | adc byte [di+preboot_dma-preboot_device], 0 |
||
392 | cmp byte [di+preboot_biosdisk-preboot_device], 1 |
||
393 | adc byte [di+preboot_biosdisk-preboot_device], 0 |
||
394 | cmp byte [di+preboot_vrrm-preboot_device], 1 |
||
395 | adc byte [di+preboot_vrrm-preboot_device], 0 |
||
29 | halyavin | 396 | ; notify user |
713 | Lrz | 397 | _setcursor 5,2 |
398 | |||
514 | diamond | 399 | mov si, linef |
713 | Lrz | 400 | call printplain |
514 | diamond | 401 | mov si, start_msg |
402 | call print |
||
403 | mov si, time_msg |
||
404 | call print |
||
29 | halyavin | 405 | ; get start time |
514 | diamond | 406 | call .gettime |
407 | mov [.starttime], eax |
||
408 | mov word [.timer], .newtimer |
||
409 | mov word [.timer+2], cs |
||
29 | halyavin | 410 | .printcfg: |
514 | diamond | 411 | _setcursor 9,0 |
412 | mov si, current_cfg_msg |
||
413 | call print |
||
414 | mov si, curvideo_msg |
||
415 | call print |
||
713 | Lrz | 416 | |
417 | call draw_current_vmode |
||
418 | |||
709 | diamond | 419 | mov si, usebd_msg |
420 | cmp [preboot_biosdisk], 1 |
||
421 | call .say_on_off |
||
514 | diamond | 422 | mov si, vrrm_msg |
423 | cmp [preboot_vrrm], 1 |
||
424 | call .say_on_off |
||
425 | mov si, preboot_device_msg |
||
426 | call print |
||
427 | mov al, [preboot_device] |
||
545 | spraid | 428 | and eax, 7 |
514 | diamond | 429 | mov si, [preboot_device_msgs+eax*2] |
430 | call printplain |
||
726 | diamond | 431 | .show_remarks: |
432 | ; show remarks in gray color |
||
433 | mov di, ((21-num_remarks)*80 + 2)*2 |
||
434 | push 0xB800 |
||
435 | pop es |
||
436 | mov cx, num_remarks |
||
437 | mov si, remarks |
||
438 | .write_remarks: |
||
439 | lodsw |
||
440 | push si |
||
441 | xchg ax, si |
||
442 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
||
443 | push di |
||
444 | .write_remark: |
||
445 | lodsb |
||
446 | test al, al |
||
447 | jz @f |
||
448 | stosw |
||
449 | jmp .write_remark |
||
450 | @@: |
||
451 | pop di |
||
452 | pop si |
||
453 | add di, 80*2 |
||
454 | loop .write_remarks |
||
29 | halyavin | 455 | .wait: |
514 | diamond | 456 | _setcursor 25,0 ; out of screen |
34 | halyavin | 457 | ; set timer interrupt handler |
514 | diamond | 458 | cli |
459 | push 0 |
||
460 | pop es |
||
713 | Lrz | 461 | push dword [es:8*4] |
462 | pop dword [.oldtimer] |
||
463 | push dword [.timer] |
||
837 | serge | 464 | pop dword [es:8*4] |
713 | Lrz | 465 | ; mov eax, [es:8*4] |
466 | ; mov [.oldtimer], eax |
||
467 | ; mov eax, [.timer] |
||
468 | ; mov [es:8*4], eax |
||
514 | diamond | 469 | sti |
29 | halyavin | 470 | ; wait for keypressed |
713 | Lrz | 471 | xor ax,ax |
514 | diamond | 472 | int 16h |
473 | push ax |
||
29 | halyavin | 474 | ; restore timer interrupt |
713 | Lrz | 475 | ; push 0 |
476 | ; pop es |
||
514 | diamond | 477 | mov eax, [.oldtimer] |
478 | mov [es:8*4], eax |
||
479 | mov [.timer], eax |
||
480 | _setcursor 7,0 |
||
481 | mov si, space_msg |
||
482 | call printplain |
||
726 | diamond | 483 | ; clear remarks and restore normal attributes |
484 | push es |
||
485 | mov di, ((21-num_remarks)*80 + 2)*2 |
||
486 | push 0xB800 |
||
487 | pop es |
||
488 | mov cx, num_remarks |
||
489 | mov ax, ' ' + (1*16 + 15)*100h |
||
490 | @@: |
||
491 | push cx |
||
492 | mov cx, 76 |
||
493 | rep stosw |
||
494 | pop cx |
||
495 | add di, 4*2 |
||
496 | loop @b |
||
497 | pop es |
||
514 | diamond | 498 | pop ax |
29 | halyavin | 499 | ; switch on key |
514 | diamond | 500 | cmp al, 13 |
501 | jz .continue |
||
502 | or al, 20h |
||
503 | cmp al, 'a' |
||
504 | jz .change_a |
||
505 | cmp al, 'b' |
||
506 | jz .change_b |
||
507 | cmp al, 'c' |
||
508 | jz .change_c |
||
509 | cmp al, 'd' |
||
726 | diamond | 510 | jnz .show_remarks |
514 | diamond | 511 | _setcursor 15,0 |
512 | mov si, bdev |
||
513 | call print |
||
545 | spraid | 514 | mov bx, '14' |
514 | diamond | 515 | call getkey |
516 | mov [preboot_device], al |
||
517 | _setcursor 13,0 |
||
29 | halyavin | 518 | .d: |
514 | diamond | 519 | mov [.bSettingsChanged], 1 |
713 | Lrz | 520 | call clear_vmodes_table ;clear vmodes_table |
514 | diamond | 521 | jmp .printcfg |
29 | halyavin | 522 | .change_a: |
713 | Lrz | 523 | .loops: |
524 | call draw_vmodes_table |
||
816 | Lrz | 525 | _setcursor 25,0 ; out of screen |
713 | Lrz | 526 | xor ax,ax |
527 | int 0x16 |
||
528 | ; call clear_table_cursor ;clear current position of cursor |
||
529 | |||
530 | mov si,word [cursor_pos] |
||
531 | |||
532 | cmp ah,0x48;x,0x48E0 ; up |
||
533 | jne .down |
||
534 | cmp si,modes_table |
||
535 | jbe .loops |
||
536 | sub word [cursor_pos],size_of_step |
||
537 | jmp .loops |
||
538 | |||
539 | .down: cmp ah,0x50;x,0x50E0 ; down |
||
730 | diamond | 540 | jne .pgup |
713 | Lrz | 541 | cmp word[es:si+10],-1 |
837 | serge | 542 | je .loops |
713 | Lrz | 543 | add word [cursor_pos],size_of_step |
544 | jmp .loops |
||
545 | |||
730 | diamond | 546 | .pgup: cmp ah,0x49 ; page up |
547 | jne .pgdn |
||
731 | diamond | 548 | sub si, size_of_step*long_v_table |
730 | diamond | 549 | cmp si, modes_table |
550 | jae @f |
||
551 | mov si, modes_table |
||
552 | @@: |
||
553 | mov word [cursor_pos], si |
||
554 | mov si, word [home_cursor] |
||
731 | diamond | 555 | sub si, size_of_step*long_v_table |
730 | diamond | 556 | cmp si, modes_table |
557 | jae @f |
||
558 | mov si, modes_table |
||
559 | @@: |
||
560 | mov word [home_cursor], si |
||
561 | jmp .loops |
||
562 | |||
563 | .pgdn: cmp ah,0x51 ; page down |
||
564 | jne .enter |
||
565 | mov ax, [end_cursor] |
||
731 | diamond | 566 | add si, size_of_step*long_v_table |
730 | diamond | 567 | cmp si, ax |
568 | jb @f |
||
569 | mov si, ax |
||
570 | sub si, size_of_step |
||
571 | @@: |
||
572 | mov word [cursor_pos], si |
||
573 | mov si, word [home_cursor] |
||
731 | diamond | 574 | sub ax, size_of_step*long_v_table |
575 | add si, size_of_step*long_v_table |
||
730 | diamond | 576 | cmp si, ax |
577 | jb @f |
||
578 | mov si, ax |
||
579 | @@: |
||
580 | mov word [home_cursor], si |
||
581 | jmp .loops |
||
582 | |||
713 | Lrz | 583 | .enter: cmp al,0x0D;x,0x1C0D ; enter |
584 | jne .loops |
||
585 | push word [cursor_pos] |
||
746 | Lrz | 586 | pop bp |
587 | push word [es:bp] |
||
588 | pop word [x_save] |
||
589 | push word [es:bp+2] |
||
590 | pop word [y_save] |
||
816 | Lrz | 591 | push word [es:bp+6] |
749 | Lrz | 592 | pop word [number_vm] |
746 | Lrz | 593 | mov word [preboot_graph],bp ;save choose |
837 | serge | 594 | |
514 | diamond | 595 | jmp .d |
713 | Lrz | 596 | |
29 | halyavin | 597 | .change_b: |
514 | diamond | 598 | _setcursor 15,0 |
709 | diamond | 599 | ; mov si, ask_dma |
600 | ; call print |
||
601 | ; mov bx, '13' |
||
602 | ; call getkey |
||
603 | ; mov [preboot_dma], al |
||
604 | mov si, ask_bd |
||
514 | diamond | 605 | call print |
709 | diamond | 606 | mov bx, '12' |
514 | diamond | 607 | call getkey |
709 | diamond | 608 | mov [preboot_biosdisk], al |
514 | diamond | 609 | _setcursor 11,0 |
610 | jmp .d |
||
29 | halyavin | 611 | .change_c: |
514 | diamond | 612 | _setcursor 15,0 |
613 | mov si, vrrmprint |
||
614 | call print |
||
615 | mov bx, '12' |
||
616 | call getkey |
||
617 | mov [preboot_vrrm], al |
||
618 | _setcursor 12,0 |
||
619 | jmp .d |
||
713 | Lrz | 620 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
40 | halyavin | 621 | .say_on_off: |
514 | diamond | 622 | pushf |
623 | call print |
||
624 | mov si, on_msg |
||
625 | popf |
||
626 | jz @f |
||
627 | mov si, off_msg |
||
628 | @@: jmp printplain |
||
40 | halyavin | 629 | ; novesa and vervesa strings are not used at the moment of executing this code |
630 | virtual at novesa |
||
29 | halyavin | 631 | .oldtimer dd ? |
632 | .starttime dd ? |
||
633 | .bSettingsChanged db ? |
||
34 | halyavin | 634 | .timer dd ? |
40 | halyavin | 635 | end virtual |
143 | diamond | 636 | .loader_block dd -1 |
29 | halyavin | 637 | .gettime: |
514 | diamond | 638 | mov ah, 0 |
639 | int 1Ah |
||
640 | xchg ax, cx |
||
641 | shl eax, 10h |
||
642 | xchg ax, dx |
||
643 | ret |
||
29 | halyavin | 644 | .newtimer: |
514 | diamond | 645 | push ds |
646 | push cs |
||
647 | pop ds |
||
648 | pushf |
||
649 | call [.oldtimer] |
||
650 | pushad |
||
651 | call .gettime |
||
652 | sub eax, [.starttime] |
||
653 | sub ax, 18*5 |
||
654 | jae .timergo |
||
655 | neg ax |
||
656 | add ax, 18-1 |
||
657 | mov bx, 18 |
||
658 | xor dx, dx |
||
659 | div bx |
||
29 | halyavin | 660 | if lang eq ru |
661 | ; подождите 5 секунд, 4/3/2 секунды, 1 секунду |
||
514 | diamond | 662 | cmp al, 5 |
663 | mov cl, ' ' |
||
664 | jae @f |
||
665 | cmp al, 1 |
||
666 | mov cl, 'у' |
||
667 | jz @f |
||
668 | mov cl, 'ы' |
||
669 | @@: mov [time_str+9], cl |
||
274 | kaitz | 670 | else if lang eq et |
514 | diamond | 671 | cmp al, 1 |
672 | ja @f |
||
673 | mov [time_str+9], ' ' |
||
674 | mov [time_str+10],' ' |
||
381 | serge | 675 | @@: |
29 | halyavin | 676 | else |
677 | ; wait 5/4/3/2 seconds, 1 second |
||
514 | diamond | 678 | cmp al, 1 |
679 | mov cl, 's' |
||
680 | ja @f |
||
681 | mov cl, ' ' |
||
682 | @@: mov [time_str+9], cl |
||
29 | halyavin | 683 | end if |
514 | diamond | 684 | add al, '0' |
685 | mov [time_str+1], al |
||
686 | mov si, time_msg |
||
687 | _setcursor 7,0 |
||
688 | call print |
||
689 | _setcursor 25,0 |
||
690 | popad |
||
691 | pop ds |
||
692 | iret |
||
29 | halyavin | 693 | .timergo: |
514 | diamond | 694 | push 0 |
695 | pop es |
||
696 | mov eax, [.oldtimer] |
||
697 | mov [es:8*4], eax |
||
698 | mov sp, 0EC00h |
||
29 | halyavin | 699 | .continue: |
514 | diamond | 700 | sti |
701 | _setcursor 6,0 |
||
702 | mov si, space_msg |
||
703 | call printplain |
||
704 | call printplain |
||
705 | _setcursor 6,0 |
||
706 | mov si, loading_msg |
||
707 | call print |
||
708 | _setcursor 15,0 |
||
709 | cmp [.bSettingsChanged], 0 |
||
710 | jz .load |
||
711 | cmp [.loader_block], -1 |
||
712 | jz .load |
||
713 | les bx, [.loader_block] |
||
714 | mov eax, [es:bx+3] |
||
715 | push ds |
||
716 | pop es |
||
717 | test eax, eax |
||
718 | jz .load |
||
719 | push eax |
||
720 | mov si, save_quest |
||
721 | call print |
||
29 | halyavin | 722 | .waityn: |
514 | diamond | 723 | mov ah, 0 |
724 | int 16h |
||
725 | or al, 20h |
||
726 | cmp al, 'n' |
||
727 | jz .loadc |
||
728 | cmp al, 'y' |
||
729 | jnz .waityn |
||
730 | call putchar |
||
731 | mov byte [space_msg+80], 186 |
||
732 | pop eax |
||
733 | push cs |
||
734 | push .cont |
||
735 | push eax |
||
736 | retf |
||
29 | halyavin | 737 | .loadc: |
514 | diamond | 738 | pop eax |
29 | halyavin | 739 | .cont: |
514 | diamond | 740 | push cs |
741 | pop ds |
||
742 | mov si, space_msg |
||
743 | mov byte [si+80], 0 |
||
744 | _setcursor 15,0 |
||
745 | call printplain |
||
746 | _setcursor 15,0 |
||
29 | halyavin | 747 | .load: |
748 | ; \end{diamond}[02.12.2005] |
||
1 | ha | 749 | |
750 | ; ASK GRAPHICS MODE |
||
751 | |||
713 | Lrz | 752 | call set_vmode |
1 | ha | 753 | |
754 | ; GRAPHICS ACCELERATION |
||
346 | diamond | 755 | ; force yes |
756 | mov [es:0x901C], byte 1 |
||
1 | ha | 757 | |
514 | diamond | 758 | ; DMA ACCESS TO HD |
1 | ha | 759 | |
514 | diamond | 760 | mov al, [preboot_dma] |
761 | mov [es:0x901F], al |
||
346 | diamond | 762 | |
1 | ha | 763 | ; SET GRAPHICS |
764 | |||
514 | diamond | 765 | xor ax, ax |
766 | mov es, ax |
||
164 | serge | 767 | |
514 | diamond | 768 | mov ax, [es:0x9008] ; vga & 320x200 |
769 | mov bx, ax |
||
770 | cmp ax, 0x13 |
||
1 | ha | 771 | je setgr |
514 | diamond | 772 | cmp ax, 0x12 |
1 | ha | 773 | je setgr |
514 | diamond | 774 | mov ax, 0x4f02 ; Vesa |
412 | serge | 775 | setgr: |
1 | ha | 776 | int 0x10 |
514 | diamond | 777 | test ah, ah |
778 | mov si, fatalsel |
||
713 | Lrz | 779 | jnz v_mode_error |
1 | ha | 780 | ; set mode 0x12 graphics registers: |
514 | diamond | 781 | cmp bx, 0x12 |
1 | ha | 782 | jne gmok2 |
783 | |||
514 | diamond | 784 | mov al, 0x05 |
785 | mov dx, 0x03ce |
||
40 | halyavin | 786 | push dx |
514 | diamond | 787 | out dx, al ; select GDC mode register |
788 | mov al, 0x02 |
||
789 | inc dx |
||
790 | out dx, al ; set write mode 2 |
||
1 | ha | 791 | |
514 | diamond | 792 | mov al, 0x02 |
793 | mov dx, 0x03c4 |
||
794 | out dx, al ; select VGA sequencer map mask register |
||
795 | mov al, 0x0f |
||
796 | inc dx |
||
797 | out dx, al ; set mask for all planes 0-3 |
||
1 | ha | 798 | |
514 | diamond | 799 | mov al, 0x08 |
800 | pop dx |
||
801 | out dx, al ; select GDC bit mask register |
||
1 | ha | 802 | ; for writes to 0x03cf |
412 | serge | 803 | gmok2: |
76 | mario79 | 804 | push ds |
514 | diamond | 805 | pop es |
848 | serge | 806 |