Rev 12 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ha | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; BOOTCODE.INC ;; |
||
4 | ;; ;; |
||
29 | halyavin | 5 | ;; KolibriOS 16-bit loader, ;; |
6 | ;; based on bootcode for MenuetOS ;; |
||
1 | ha | 7 | ;; ;; |
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
9 | |||
10 | |||
11 | |||
12 | ;========================================================================== |
||
13 | ; |
||
14 | ; 16 BIT FUNCTIONS |
||
15 | ; |
||
16 | ;========================================================================== |
||
17 | |||
29 | halyavin | 18 | putchar: |
19 | ; in: al=character |
||
20 | mov ah, 0Eh |
||
21 | mov bh, 0 |
||
22 | int 10h |
||
23 | ret |
||
1 | ha | 24 | |
29 | halyavin | 25 | print: |
26 | ; in: si->string |
||
27 | mov al, 186 |
||
28 | call putchar |
||
29 | mov al, ' ' |
||
30 | call putchar |
||
1 | ha | 31 | |
29 | halyavin | 32 | printplain: |
33 | ; in: si->string |
||
34 | pusha |
||
35 | lodsb |
||
36 | @@: |
||
37 | call putchar |
||
38 | lodsb |
||
39 | cmp al, 0 |
||
40 | jnz @b |
||
41 | popa |
||
42 | ret |
||
1 | ha | 43 | |
29 | halyavin | 44 | ; Now int 16 is used for keyboard support. |
45 | ; This is shorter, simpler and more reliable. |
||
46 | if 0 |
||
1 | ha | 47 | getkey: push ecx |
48 | push edx |
||
49 | add ebx,0x0101 |
||
50 | xor eax,eax |
||
51 | |||
52 | gk1: |
||
53 | in al,0x60 |
||
54 | mov cl,al |
||
55 | gk0: |
||
56 | in al,0x60 |
||
57 | cmp al,cl |
||
58 | je gk0 |
||
59 | cmp ax,11 |
||
60 | jg gk0 |
||
61 | gk0_1: |
||
62 | mov cl,al |
||
63 | |||
64 | ; add al,47 |
||
65 | ; mov [ds:keyinbs-0x10000],al |
||
66 | ; mov si,keyinbs-0x10000 |
||
67 | ; call printplain |
||
68 | |||
69 | gk12: |
||
70 | in al,0x60 |
||
71 | cmp al,cl |
||
72 | je gk12 |
||
73 | cmp ax,240 |
||
74 | jne gk13 |
||
75 | mov al,cl |
||
76 | jmp gk14 |
||
77 | gk13: |
||
78 | add cl,128 |
||
79 | cmp al,cl |
||
80 | jne gk1 |
||
81 | sub al,128 |
||
82 | gk14: |
||
83 | |||
84 | movzx edx,bl |
||
85 | cmp eax,edx |
||
86 | jb gk1 |
||
87 | movzx edx,bh |
||
88 | cmp eax,edx |
||
89 | jg gk1 |
||
90 | test ebx,0x010000 |
||
91 | jnz gk3 |
||
92 | mov cx,0x1000 |
||
93 | mov dx,cx |
||
94 | add eax,47 |
||
95 | mov cx,ax |
||
96 | cmp cx,58 |
||
97 | jb gk_nozero |
||
98 | sub cx,10 |
||
99 | gk_nozero: |
||
100 | mov [ds:keyin-0x10000],cl |
||
101 | mov si,keyin-0x10000 |
||
102 | call printplain |
||
103 | gk3: |
||
104 | sub eax,48 |
||
105 | pop edx |
||
106 | pop ecx |
||
107 | ret |
||
29 | halyavin | 108 | end if |
1 | ha | 109 | |
29 | halyavin | 110 | getkey: |
111 | ; get number in range [bl,bh] (bl,bh in ['0'..'9']) |
||
112 | ; in: bx=range |
||
113 | ; out: ax=digit (1..9, 10 for 0) |
||
114 | mov ah, 0 |
||
115 | int 16h |
||
116 | cmp al, bl |
||
117 | jb getkey |
||
118 | cmp al, bh |
||
119 | ja getkey |
||
120 | push ax |
||
121 | call putchar |
||
122 | pop ax |
||
123 | and ax, 0Fh |
||
124 | jnz @f |
||
125 | mov al, 10 |
||
126 | @@: |
||
127 | ret |
||
1 | ha | 128 | |
29 | halyavin | 129 | setcursor: |
130 | ; in: dl=column, dh=row |
||
131 | mov ah, 2 |
||
132 | mov bh, 0 |
||
133 | int 10h |
||
134 | ret |
||
135 | |||
136 | macro _setcursor row,column |
||
137 | { |
||
138 | mov dx, row*256 + column |
||
139 | call setcursor |
||
140 | } |
||
141 | |||
142 | ; 16-bit data |
||
143 | ; videomodes table |
||
144 | gr_table: |
||
145 | dw 0x112+0100000000000000b , 640 , 480 ; 1 |
||
146 | dw 0x115+0100000000000000b , 800 , 600 ; 2 |
||
147 | dw 0x118+0100000000000000b , 1024 , 768 ; 3 |
||
148 | dw 0x11B+0100000000000000b , 1280 , 1024 ; 4 |
||
149 | dw 0x112 , 640 , 480 ; 5 |
||
150 | dw 0x115 , 800 , 600 ; 6 |
||
151 | dw 0x118 , 1024 , 768 ; 7 |
||
152 | dw 0x11B , 1280 ,1024 ; 8 |
||
153 | dw 0x13, 320, 200 ; 9 |
||
154 | dw 0x12, 640, 480 ; 0 |
||
155 | |||
156 | ; table for move to extended memory (int 15h, ah=87h) |
||
157 | movedesc: |
||
158 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
159 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
160 | |||
161 | db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0 |
||
162 | db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0 |
||
163 | |||
164 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
165 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
166 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
167 | db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 |
||
168 | |||
1 | ha | 169 | ;========================================================================= |
170 | ; |
||
171 | ; 16 BIT CODE |
||
172 | ; |
||
173 | ;========================================================================= |
||
174 | |||
175 | |||
176 | start_of_code: |
||
29 | halyavin | 177 | cld |
178 | ; \begin{diamond}[02.12.2005] |
||
179 | cmp ax, 'KL' |
||
180 | jnz @f |
||
181 | mov word [cs:cfgmanager.loader_block-0x10000], si |
||
182 | mov word [cs:cfgmanager.loader_block+2-0x10000], ds |
||
183 | @@: |
||
184 | ; \end{diamond}[02.12.2005] |
||
1 | ha | 185 | |
29 | halyavin | 186 | ; set up stack |
187 | mov ax, 3000h |
||
188 | mov ss, ax |
||
189 | mov sp, 0EC00h |
||
190 | ; set up segment registers |
||
191 | push cs |
||
192 | pop ds |
||
193 | push cs |
||
194 | pop es |
||
1 | ha | 195 | |
29 | halyavin | 196 | ; set videomode |
197 | mov ax, 3 |
||
1 | ha | 198 | int 0x10 |
199 | |||
200 | ; Load & set russian VGA font (RU.INC) |
||
201 | mov bp,RU_FNT1-10000h ; RU_FNT1 - First part |
||
202 | mov bx,1000h ; 768 bytes |
||
203 | mov cx,30h ; 48 symbols |
||
204 | mov dx,80h ; 128 - position of first symbol |
||
205 | mov ax,1100h |
||
206 | int 10h |
||
207 | |||
208 | mov bp,RU_FNT2-10000h ; RU_FNT2 -Second part |
||
209 | mov bx,1000h ; 512 bytes |
||
210 | mov cx,20h ; 32 symbols |
||
211 | mov dx,0E0h ; 224 - position of first symbol |
||
212 | mov ax,1100h |
||
213 | int 10h |
||
214 | ; End set VGA russian font |
||
215 | |||
29 | halyavin | 216 | ; draw frames |
217 | push 0xb800 |
||
218 | pop es |
||
219 | xor di, di |
||
220 | ; mov si,d80x25-0x10000 |
||
221 | ; mov cx,80*25 |
||
222 | ; mov ah,1*16+15 |
||
223 | ; dfl1: |
||
224 | ; lodsb |
||
225 | ; stosw |
||
226 | ; loop dfl1 |
||
227 | mov ah, 1*16+15 |
||
228 | ; draw top |
||
229 | mov si, d80x25_top - 0x10000 |
||
230 | mov cx, d80x25_top_num * 80 |
||
231 | @@: |
||
232 | lodsb |
||
233 | stosw |
||
234 | loop @b |
||
235 | ; draw spaces |
||
236 | mov si, space_msg - 0x10000 |
||
237 | mov cx, 25 - d80x25_top_num - d80x25_bottom_num |
||
238 | dfl1: |
||
239 | push cx |
||
240 | push si |
||
241 | mov cx, 80 |
||
242 | @@: |
||
243 | lodsb |
||
244 | stosw |
||
245 | loop @b |
||
246 | pop si |
||
247 | pop cx |
||
248 | loop dfl1 |
||
249 | ; draw bottom |
||
250 | mov si, d80x25_bottom - 0x10000 |
||
251 | mov cx, d80x25_bottom_num * 80 |
||
252 | @@: |
||
253 | lodsb |
||
254 | stosw |
||
255 | loop @b |
||
1 | ha | 256 | |
29 | halyavin | 257 | mov byte [space_msg-0x10000+80], 0 ; now space_msg is null terminated |
1 | ha | 258 | |
29 | halyavin | 259 | _setcursor d80x25_top_num,0 |
1 | ha | 260 | |
261 | |||
262 | ; TEST FOR 386+ |
||
263 | |||
29 | halyavin | 264 | mov bx, 0x4000 |
1 | ha | 265 | pushf |
266 | pop ax |
||
267 | mov dx,ax |
||
29 | halyavin | 268 | xor ax,bx |
1 | ha | 269 | push ax |
270 | popf |
||
271 | pushf |
||
272 | pop ax |
||
29 | halyavin | 273 | and ax,bx |
274 | and dx,bx |
||
1 | ha | 275 | cmp ax,dx |
276 | jnz cpugood |
||
277 | mov si,not386-0x10000 |
||
278 | call print |
||
279 | jmp $ |
||
280 | cpugood: |
||
281 | |||
29 | halyavin | 282 | ; set up esp |
283 | movzx esp, sp |
||
1 | ha | 284 | |
285 | ; FLUSH 8042 KEYBOARD CONTROLLER |
||
286 | |||
287 | ;// mike.dld [ |
||
288 | ; mov al,0xED |
||
289 | ; out 0x60,al |
||
290 | ; or cx,-1 |
||
291 | ; @@: |
||
292 | ; in al,0x64 |
||
293 | ; test al,2 |
||
294 | ; jz @f |
||
295 | ; loop @b |
||
296 | ; @@: |
||
297 | ; mov al,0 |
||
298 | ; out 0x60,al |
||
299 | ; or cx,-1 |
||
300 | ; @@: |
||
301 | ; in al,0x64 |
||
302 | ; test al,2 |
||
303 | ; jz @f |
||
304 | ; loop @b |
||
305 | ; @@: |
||
306 | ;// mike.dld ] |
||
307 | |||
308 | ; mov ecx,10000 |
||
309 | ; fl1: |
||
310 | ; in al,0x64 |
||
311 | ; loop fl1 |
||
312 | ; test al,1 |
||
313 | ; jz fl2 |
||
314 | ; in al,0x60 |
||
315 | ; jmp fl1 |
||
316 | ; fl2: |
||
317 | |||
318 | ;**************************************************************** |
||
319 | ; The function is modified Mario79 |
||
320 | ;***************************************************************** |
||
321 | ; wait_kbd: ; variant 1 |
||
322 | ; mov cx,2500h ;çàäåðæêà ïîðÿäêà 10 ìñåê |
||
323 | ; test_kbd: |
||
324 | ; in al,64h ;÷èòàåì ñîñòîÿíèå êëàâèàòóðû |
||
325 | ; test al,2 ;ïðîâåðêà áèòà ãîòîâíîñòè |
||
326 | ; loopnz test_kbd |
||
327 | |||
328 | mov al,0xf6 ; Ñáðîñ êëàâèàòóðû, ðàçðåøèòü ñêàíèðîâàíèå |
||
329 | out 0x60,al |
||
29 | halyavin | 330 | xor cx,cx |
1 | ha | 331 | wait_loop: ; variant 2 |
332 | ; reading state of port of 8042 controller |
||
333 | in al,64h |
||
334 | and al,00000010b ; ready flag |
||
335 | ; wait until 8042 controller is ready |
||
336 | loopnz wait_loop |
||
337 | |||
338 | ; DISPLAY VESA INFORMATION |
||
339 | |||
29 | halyavin | 340 | push 0 |
341 | pop es |
||
1 | ha | 342 | mov ax,0x4f00 |
343 | mov di,0xa000 |
||
344 | int 0x10 |
||
345 | cmp ax,0x004f |
||
29 | halyavin | 346 | mov si, novesa-0x10000 |
347 | jnz @f |
||
1 | ha | 348 | mov ax,[es:di+4] |
349 | add ax,'0'*256+'0' |
||
29 | halyavin | 350 | mov [vervesa+vervesa_off-0x10000], ah |
351 | mov [vervesa+vervesa_off+2-0x10000], al |
||
1 | ha | 352 | mov si,vervesa-0x10000 |
29 | halyavin | 353 | @@: call print |
1 | ha | 354 | |
29 | halyavin | 355 | ; \begin{diamond}[30.11.2005] |
356 | cfgmanager: |
||
357 | ; settings: |
||
358 | ; a) preboot_graph = graphical mode |
||
359 | ; preboot_gprobe = probe this mode? |
||
360 | ; b) preboot_mtrr = use hardware acceleration? |
||
361 | ; c) preboot_vrrm = use VRR? |
||
362 | ; d) preboot_device = from what boot? |
||
363 | mov si, preboot_graph-0x10000 |
||
364 | ; check bootloader block |
||
365 | cmp [.loader_block-0x10000], 0 |
||
366 | jz .noloaderblock |
||
367 | les bx, [.loader_block-0x10000] |
||
368 | cmp byte [es:bx], 1 |
||
369 | jz @f |
||
370 | mov si, loader_block_error-0x10000 |
||
371 | call print |
||
372 | jmp $ |
||
373 | @@: |
||
374 | test byte [es:bx+1], 1 |
||
375 | jz @f |
||
376 | ; image in memory present |
||
377 | cmp [si+preboot_device-preboot_graph], 0 |
||
378 | jnz @f |
||
379 | mov [si+preboot_device-preboot_graph], 3 |
||
380 | @@: |
||
381 | .noloaderblock: |
||
382 | ; determine default settings |
||
383 | mov [.bSettingsChanged-0x10000], 0 |
||
384 | cmp byte [si], 0 |
||
385 | jnz .preboot_gr_end |
||
386 | mov [si+preboot_gprobe-preboot_graph], 0 |
||
387 | mov al, [vervesa+vervesa_off-0x10000] |
||
388 | cmp al, 'x' |
||
389 | jz .novesa |
||
390 | cmp al, '1' |
||
391 | jz .vesa12 |
||
392 | mov [si+preboot_gprobe-preboot_graph], 2 |
||
393 | mov al, 3 |
||
394 | jmp @f |
||
395 | .vesa12: |
||
396 | mov al, 7 |
||
397 | jmp @f |
||
398 | .novesa: |
||
399 | mov al, 10 |
||
400 | @@: |
||
401 | mov [si], al |
||
402 | .preboot_gr_end: |
||
403 | cmp [si+preboot_mtrr-preboot_graph], 1 |
||
404 | adc [si+preboot_mtrr-preboot_graph], 0 |
||
405 | cmp [si+preboot_vrrm-preboot_graph], 1 |
||
406 | adc [si+preboot_vrrm-preboot_graph], 0 |
||
407 | cmp [si+preboot_device-preboot_graph], 1 |
||
408 | adc [si+preboot_device-preboot_graph], 0 |
||
409 | ; notify user |
||
410 | mov si, linef-0x10000 |
||
411 | call print |
||
412 | mov si, start_msg-0x10000 |
||
413 | call print |
||
414 | mov si, time_msg-0x10000 |
||
415 | call print |
||
416 | ; get start time |
||
417 | call .gettime |
||
418 | mov [.starttime-0x10000], eax |
||
419 | ; set timer interrupt handler |
||
420 | cli |
||
421 | push 0 |
||
422 | pop es |
||
423 | mov eax, [es:8*4] |
||
424 | mov [.oldtimer-0x10000], eax |
||
425 | mov word [es:8*4], .newtimer-0x10000 |
||
426 | mov [es:8*4+2], cs |
||
427 | .printcfg: |
||
428 | _setcursor 9,0 |
||
429 | mov si, current_cfg_msg-0x10000 |
||
430 | call print |
||
431 | mov si, curvideo_msg-0x10000 |
||
432 | call print |
||
433 | mov al, [preboot_graph-0x10000] |
||
434 | cmp al, 8 |
||
435 | ja .pnovesa |
||
436 | mov dl, al |
||
437 | and eax, 3 |
||
438 | mov si, [modes_msg-0x10000+eax*2] |
||
439 | call printplain |
||
440 | mov si, modevesa20-0x10000 |
||
441 | cmp dl, 4 |
||
442 | jbe @f |
||
443 | mov si, modevesa12-0x10000 |
||
444 | @@: |
||
445 | call printplain |
||
446 | cmp dl, 4 |
||
447 | ja .x |
||
448 | mov si, probeno_msg-0x10000 |
||
449 | cmp [preboot_gprobe-0x10000], 2 |
||
450 | jnz @f |
||
451 | mov si, probeok_msg-0x10000 |
||
452 | @@: |
||
453 | call printplain |
||
454 | .x: |
||
455 | jmp .c |
||
456 | .pnovesa: |
||
457 | cmp al, 9 |
||
458 | mov si, mode9-0x10000 |
||
459 | jz @b |
||
460 | mov si, mode10-0x10000 |
||
461 | jmp @b |
||
462 | .c: |
||
463 | mov si, linef-0x10000 |
||
464 | call printplain |
||
465 | mov si, mtrr_msg-0x10000 |
||
466 | call print |
||
467 | mov si, on_msg-0x10000 |
||
468 | cmp [preboot_mtrr-0x10000], 1 |
||
469 | jz @f |
||
470 | mov si, off_msg-0x10000 |
||
471 | @@: |
||
472 | call printplain |
||
473 | mov si, vrrm_msg-0x10000 |
||
474 | call print |
||
475 | mov si, on_msg-0x10000 |
||
476 | cmp [preboot_vrrm-0x10000], 1 |
||
477 | jz @f |
||
478 | mov si, off_msg-0x10000 |
||
479 | @@: |
||
480 | call printplain |
||
481 | mov si, preboot_device_msg-0x10000 |
||
482 | call print |
||
483 | mov al, [preboot_device-0x10000] |
||
484 | and eax, 3 |
||
485 | mov si, [preboot_device_msgs-0x10000+eax*2] |
||
486 | call printplain |
||
487 | .wait: |
||
488 | ; empty BIOS keyboard buffer |
||
489 | _setcursor 25,0 ; out of screen |
||
490 | ; wait for keypressed |
||
491 | mov ah, 0 |
||
492 | int 16h |
||
493 | push ax |
||
494 | ; restore timer interrupt |
||
495 | push 0 |
||
496 | pop es |
||
497 | mov ecx, [.oldtimer-0x10000] |
||
498 | mov [es:8*4], ecx |
||
499 | _setcursor 7,0 |
||
500 | mov si, space_msg-0x10000 |
||
501 | call printplain |
||
502 | pop ax |
||
503 | ; switch on key |
||
504 | cmp al, 13 |
||
505 | jz .continue |
||
506 | or al, 20h |
||
507 | cmp al, 'a' |
||
508 | jz .change_a |
||
509 | cmp al, 'b' |
||
510 | jz .change_b |
||
511 | cmp al, 'c' |
||
512 | jz .change_c |
||
513 | cmp al, 'd' |
||
514 | jnz .wait |
||
515 | _setcursor 15,0 |
||
516 | mov si,bdev-0x10000 |
||
517 | call printplain |
||
518 | mov bx,'13' |
||
519 | call getkey |
||
520 | mov [preboot_device-0x10000], al |
||
521 | _setcursor 13,0 |
||
522 | .d: |
||
523 | mov [.bSettingsChanged-0x10000], al |
||
524 | mov si, space_msg-0x10000 |
||
525 | call printplain |
||
526 | _setcursor 15,0 |
||
527 | mov cx, 6 |
||
528 | @@: |
||
529 | call printplain |
||
530 | loop @b |
||
531 | jmp .printcfg |
||
532 | .change_a: |
||
533 | _setcursor 15,0 |
||
534 | mov si, gr_mode-0x10000 |
||
535 | call printplain |
||
536 | mov bx, '09' |
||
537 | call getkey |
||
538 | mov [preboot_graph-0x10000], al |
||
539 | cmp al, 4 |
||
540 | ja @f |
||
541 | mov si, probetext-0x10000 |
||
542 | call printplain |
||
543 | mov bx, '12' |
||
544 | call getkey |
||
545 | mov [preboot_gprobe-0x10000], al |
||
546 | @@: |
||
547 | _setcursor 10,0 |
||
548 | jmp .d |
||
549 | .change_b: |
||
550 | _setcursor 15,0 |
||
551 | mov si, gr_acc-0x10000 |
||
552 | call printplain |
||
553 | mov bx, '12' |
||
554 | call getkey |
||
555 | mov [preboot_mtrr-0x10000], al |
||
556 | _setcursor 11,0 |
||
557 | jmp .d |
||
558 | .change_c: |
||
559 | _setcursor 15,0 |
||
560 | mov si, vrrmprint-0x10000 |
||
561 | call printplain |
||
562 | mov bx, '12' |
||
563 | call getkey |
||
564 | mov [preboot_vrrm-0x10000], al |
||
565 | _setcursor 12,0 |
||
566 | jmp .d |
||
567 | .oldtimer dd ? |
||
568 | .starttime dd ? |
||
569 | .bSettingsChanged db ? |
||
570 | .loader_block dd 0 |
||
571 | .gettime: |
||
572 | mov ah, 0 |
||
573 | int 1Ah |
||
574 | xchg ax, cx |
||
575 | shl eax, 10h |
||
576 | xchg ax, dx |
||
577 | ret |
||
578 | .newtimer: |
||
579 | push ds |
||
580 | push cs |
||
581 | pop ds |
||
582 | pushf |
||
583 | call [.oldtimer-0x10000] |
||
584 | pushad |
||
585 | call .gettime |
||
586 | sub eax, [.starttime-0x10000] |
||
587 | sub ax, 18*5 |
||
588 | jae .timergo |
||
589 | neg ax |
||
590 | add ax, 18-1 |
||
591 | mov bx, 18 |
||
592 | xor dx, dx |
||
593 | div bx |
||
594 | if lang eq ru |
||
595 | ; ¯®¤®¦¤¨â¥ 5 ᥪã¤, 4/3/2 ᥪã¤ë, 1 ᥪã¤ã |
||
596 | cmp al, 5 |
||
597 | mov cl, ' ' |
||
598 | jae @f |
||
599 | cmp al, 1 |
||
600 | mov cl, 'ã' |
||
601 | jz @f |
||
602 | mov cl, 'ë' |
||
603 | @@: mov [time_str+9-0x10000], cl |
||
604 | else |
||
605 | ; wait 5/4/3/2 seconds, 1 second |
||
606 | cmp al, 1 |
||
607 | mov cl, 's' |
||
608 | ja @f |
||
609 | mov cl, ' ' |
||
610 | @@: mov [time_str+9-0x10000], cl |
||
611 | end if |
||
612 | add al, '0' |
||
613 | mov [time_str+1-0x10000], al |
||
614 | mov si, time_msg-0x10000 |
||
615 | _setcursor 7,0 |
||
616 | call print |
||
617 | _setcursor 25,0 |
||
618 | popad |
||
619 | pop ds |
||
620 | iret |
||
621 | .timergo: |
||
622 | push 0 |
||
623 | pop es |
||
624 | mov eax, [.oldtimer-0x10000] |
||
625 | mov [es:8*4], eax |
||
626 | mov sp, 0EC00h |
||
627 | .continue: |
||
628 | sti |
||
629 | _setcursor 6,0 |
||
630 | mov si, space_msg-0x10000 |
||
631 | call printplain |
||
632 | call printplain |
||
633 | _setcursor 6,0 |
||
634 | mov si, loading_msg-0x10000 |
||
635 | call print |
||
636 | _setcursor 15,0 |
||
637 | cmp [.bSettingsChanged-0x10000], 0 |
||
638 | jz .load |
||
639 | cmp [.loader_block-0x10000], 0 |
||
640 | jz .load |
||
641 | les bx, [.loader_block-0x10000] |
||
642 | mov eax, [es:bx+3] |
||
643 | push ds |
||
644 | pop es |
||
645 | test eax, eax |
||
646 | jz .load |
||
647 | push eax |
||
648 | mov si, save_quest-0x10000 |
||
649 | call print |
||
650 | .waityn: |
||
651 | mov ah, 0 |
||
652 | int 16h |
||
653 | or al, 20h |
||
654 | cmp al, 'n' |
||
655 | jz .loadc |
||
656 | cmp al, 'y' |
||
657 | jnz .waityn |
||
658 | call putchar |
||
659 | pop eax |
||
660 | push cs |
||
661 | push .cont-0x10000 |
||
662 | push eax |
||
663 | retf |
||
664 | .loadc: |
||
665 | pop eax |
||
666 | .cont: |
||
667 | push cs |
||
668 | pop ds |
||
669 | _setcursor 15,0 |
||
670 | mov si, space_msg-0x10000 |
||
671 | call printplain |
||
672 | _setcursor 15,0 |
||
673 | .load: |
||
674 | ; \end{diamond}[02.12.2005] |
||
1 | ha | 675 | |
676 | ; ASK GRAPHICS MODE |
||
677 | |||
29 | halyavin | 678 | movzx ax, [preboot_graph-0x10000] |
679 | test ax, ax |
||
1 | ha | 680 | jne pre_graph |
681 | mov si,gr_mode-0x10000 |
||
682 | call printplain |
||
29 | halyavin | 683 | mov bx,'09' |
1 | ha | 684 | call getkey |
685 | pre_graph: |
||
29 | halyavin | 686 | push 0 |
687 | pop es |
||
688 | ; address is gr_table+6*(ax-1)-0x10000 |
||
689 | add ax, ax |
||
690 | lea si, [gr_table-0x10000 + eax + eax*2 - 6] |
||
691 | mov bx,[si+0] |
||
692 | mov cx,[si+2] |
||
693 | mov dx,[si+4] |
||
694 | cmp al, 9*2 |
||
695 | jb @f |
||
696 | mov byte [es:0x9000], 32 |
||
697 | mov dword [es:0x9018], 0x800000 |
||
698 | @@: |
||
1 | ha | 699 | mov [es:0x9008],bx |
700 | mov [es:0x900A],cx |
||
701 | mov [es:0x900C],dx |
||
702 | mov ax,32 |
||
29 | halyavin | 703 | test bh, bh |
704 | jz nov |
||
1 | ha | 705 | |
706 | ; USE DEFAULTS OR PROBE |
||
707 | |||
708 | ; bx - mode : cx - x size : dx - y size |
||
709 | |||
710 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
29 | halyavin | 711 | movzx ax,[preboot_gprobe-0x10000] |
1 | ha | 712 | test ax,ax |
713 | jne pre_probe |
||
714 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
715 | |||
716 | test bx,0100000000000000b |
||
717 | jz noprobe |
||
718 | |||
719 | mov si,probetext-0x10000 |
||
720 | call printplain |
||
721 | push bx |
||
29 | halyavin | 722 | mov bx, '12' |
1 | ha | 723 | call getkey |
724 | pop bx |
||
725 | |||
726 | pre_probe: |
||
29 | halyavin | 727 | dec ax |
1 | ha | 728 | je noprobe |
729 | |||
730 | push cx dx |
||
731 | |||
732 | mov bx,0x100 |
||
733 | |||
734 | newprobe: |
||
735 | |||
736 | inc bx |
||
737 | cmp bx,0x17f |
||
738 | jne probemore |
||
739 | |||
740 | mov si,prnotfnd-0x10000 |
||
741 | call printplain |
||
742 | |||
743 | jmp $ |
||
744 | |||
745 | probemore: |
||
746 | |||
747 | mov ax,0x4f01 |
||
748 | mov cx,bx |
||
749 | and cx,0xfff |
||
750 | mov di,0xa000 |
||
751 | int 0x10 |
||
752 | |||
29 | halyavin | 753 | test byte [es:di], 80h ; lfb? |
754 | jz newprobe |
||
755 | mov ax, [es:di+0x12] ; x size? |
||
756 | cmp ax, [esp+2] |
||
757 | jnz newprobe |
||
758 | cmp [es:di+0x14], dx ; y size? |
||
759 | jnz newprobe |
||
760 | cmp byte [es:di+0x19], 32 ;24 |
||
761 | jb newprobe |
||
1 | ha | 762 | |
763 | add bx,0100000000000000b |
||
764 | mov [es:0x9008],bx |
||
29 | halyavin | 765 | pop dx cx |
1 | ha | 766 | |
767 | noprobe: |
||
768 | |||
769 | |||
770 | ; FIND VESA 2.0 LFB & BPP |
||
771 | |||
772 | mov ax,0x4f01 |
||
773 | mov cx,bx |
||
774 | and cx,0xfff |
||
775 | mov di,0xa000 |
||
776 | int 0x10 |
||
777 | ; LFB |
||
778 | mov ecx,[es:di+0x28] |
||
779 | mov [es:0x9018],ecx |
||
780 | ; ---- vbe voodoo |
||
781 | BytesPerScanLine equ 0x10 |
||
782 | mov ax, [es:di+BytesPerScanLine] |
||
783 | mov [es:0x9001],ax |
||
29 | halyavin | 784 | ; BPP |
785 | movzx ax,byte [es:di+0x19] |
||
786 | mov [es:0x9000],al |
||
1 | ha | 787 | nov: |
788 | cmp ax,24 |
||
29 | halyavin | 789 | mov si,bt24-0x10000 |
790 | jz bppl |
||
1 | ha | 791 | cmp ax,32 |
792 | mov si,bt32-0x10000 |
||
29 | halyavin | 793 | jz bppl |
1 | ha | 794 | mov si,btns-0x10000 |
795 | call print |
||
796 | jmp $ |
||
797 | bppl: |
||
798 | call printplain |
||
799 | |||
800 | |||
801 | ; FIND VESA 1.2 PM BANK SWITCH ADDRESS |
||
802 | |||
29 | halyavin | 803 | push es |
1 | ha | 804 | mov ax,0x4f0A |
29 | halyavin | 805 | xor bx, bx |
1 | ha | 806 | int 0x10 |
807 | xor eax,eax |
||
808 | mov ax,es |
||
809 | shl eax,4 |
||
29 | halyavin | 810 | movzx ebx,di |
1 | ha | 811 | add eax,ebx |
812 | mov bx,[es:di] |
||
813 | add eax,ebx |
||
814 | pop es |
||
815 | mov [es:0x9014],eax |
||
816 | |||
817 | |||
818 | ; GRAPHICS ACCELERATION |
||
819 | |||
29 | halyavin | 820 | mov al, [preboot_mtrr-0x10000] |
1 | ha | 821 | test al,al |
822 | jne pre_mtrr |
||
823 | mov si,gr_acc-0x10000 |
||
824 | call printplain |
||
29 | halyavin | 825 | mov bx,'12' |
1 | ha | 826 | call getkey |
827 | pre_mtrr: |
||
828 | mov [es:0x901C],al |
||
29 | halyavin | 829 | ; commented by diamond - newlines are not used now |
830 | ; mov si,linef-0x10000 |
||
831 | ; call printplain |
||
1 | ha | 832 | |
833 | |||
834 | ; VRR_M USE |
||
835 | |||
29 | halyavin | 836 | mov al,[preboot_vrrm-0x10000] |
1 | ha | 837 | test al,al |
838 | jne pre_vrrm |
||
839 | mov si,vrrmprint-0x10000 |
||
840 | call print |
||
29 | halyavin | 841 | mov bx,'13' |
1 | ha | 842 | call getkey |
843 | pre_vrrm: |
||
844 | mov [es:0x9030],al |
||
29 | halyavin | 845 | ; commented by diamond - newlines are not used now |
846 | ; mov si,linef2-0x10000 |
||
847 | ; call printplain |
||
1 | ha | 848 | |
849 | |||
850 | ; MEMORY MODEL |
||
851 | |||
852 | ; movzx eax,byte [es:preboot_memory-0x10000] |
||
853 | ; cmp eax,0 |
||
854 | ; jne pre_mem |
||
855 | ;;;;;;;;;;;;;;;;;;;;;;;;; |
||
856 | ; mario79 - memory size ; |
||
857 | ;;;;;;;;;;;;;;;;;;;;;;;;; |
||
858 | ; mov ax,0E801h |
||
859 | ;;; xor bx,bx ; thanks to Alexei for bugfix [18.07.2004] |
||
860 | ; xor cx, cx |
||
861 | ; xor dx, dx |
||
862 | ; int 0x15 |
||
863 | ; movzx ebx, dx ;bx |
||
864 | ; movzx eax, cx ;ax |
||
865 | ; shl ebx,6 ; ïåðåâîä â êèëîáàéòû (x64) |
||
866 | ; add eax,ebx |
||
867 | ; add eax, 1000h ;440h |
||
868 | ; cmp eax,40000h ; 256? |
||
869 | ; jge mem_256_z |
||
870 | ; cmp eax,20000h ; 128? |
||
871 | ; jge mem_128_z |
||
872 | ; cmp eax,10000h ; 64? |
||
873 | ; jge mem_64_z |
||
874 | ; cmp eax,8000h ; 32? |
||
875 | ; jge mem_32_z |
||
876 | ; jmp mem_16_z |
||
877 | ; |
||
878 | ;mem_256_z: mov si,memokz256-0x10000 |
||
879 | ; call printplain |
||
880 | ; mov eax,5 |
||
881 | ; jmp pre_mem |
||
882 | ;mem_128_z: mov si,memokz128-0x10000 |
||
883 | ; call printplain |
||
884 | ; mov eax,4 |
||
885 | ; jmp pre_mem |
||
886 | ;mem_64_z: mov si,memokz64-0x10000 |
||
887 | ; call printplain |
||
888 | ; mov eax,3 |
||
889 | ; jmp pre_mem |
||
890 | ;mem_32_z: mov si,memokz32-0x10000 |
||
891 | ; call printplain |
||
892 | ; mov eax,2 |
||
893 | ; jmp pre_mem |
||
894 | ;mem_16_z: mov si,memokz16-0x10000 |
||
895 | ; call printplain |
||
896 | ; mov eax,1 |
||
897 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
898 | ; pre_mem: |
||
899 | ; push word 0x0000 |
||
900 | ; pop es |
||
901 | ; mov [es:0x9030],al |
||
902 | ; push word 0x1000 |
||
903 | ; pop es |
||
904 | ; mov si,linef-0x10000 |
||
905 | ; call printplain |
||
906 | |||
907 | |||
908 | |||
909 | |||
910 | ; DIRECT WRITE TO LFB, PAGING DISABLED |
||
911 | |||
912 | ; movzx eax,byte [es:preboot_lfb-0x10000] |
||
913 | ; mov eax,1 ; paging disabled |
||
914 | ; cmp eax,0 |
||
915 | ; jne pre_lfb |
||
916 | ; mov si,gr_direct-0x10000 |
||
917 | ; call printplain |
||
29 | halyavin | 918 | ; mov ebx,'12' |
1 | ha | 919 | ; call getkey |
920 | ; pre_lfb: |
||
921 | ; push word 0x0000 |
||
922 | ; pop es |
||
923 | ; mov [es:0x901E],al |
||
924 | ; mov ax,0x1000 |
||
925 | ; mov es,ax |
||
926 | ; mov si,linef-0x10000 |
||
927 | ; call printplain |
||
928 | mov [es:0x901E],byte 1 |
||
929 | |||
930 | |||
931 | |||
932 | ; BOOT DEVICE |
||
933 | |||
29 | halyavin | 934 | mov al, [preboot_device-0x10000] |
935 | test al, al |
||
936 | jnz pre_device |
||
1 | ha | 937 | mov si,bdev-0x10000 |
938 | call printplain |
||
29 | halyavin | 939 | mov bx,'13' |
1 | ha | 940 | call getkey |
941 | pre_device: |
||
29 | halyavin | 942 | dec ax |
943 | mov [boot_dev-0x10000],al |
||
944 | ; commented by diamond - newlines are not used now |
||
945 | ; mov si,linef-0x10000 |
||
946 | ; call printplain |
||
1 | ha | 947 | |
948 | |||
949 | |||
950 | ; READ DISKETTE TO MEMORY |
||
951 | |||
952 | cmp [boot_dev-0x10000],0 |
||
953 | jne no_sys_on_floppy |
||
954 | mov si,diskload-0x10000 |
||
955 | call print |
||
29 | halyavin | 956 | xor ax, ax ; reset drive |
957 | xor dx, dx |
||
1 | ha | 958 | int 0x13 |
959 | mov cx,0x0001 ; startcyl,startsector |
||
29 | halyavin | 960 | xor dx, dx ; starthead,drive |
1 | ha | 961 | push word 80*2 ; read no of sect |
962 | reads: |
||
963 | pusha |
||
964 | xor si,si |
||
965 | newread: |
||
966 | mov bx,0xa000 ; es:bx -> data area |
||
967 | mov ax,0x0200+18 ; read, no of sectors to read |
||
968 | int 0x13 |
||
29 | halyavin | 969 | test ah, ah |
1 | ha | 970 | jz goodread |
29 | halyavin | 971 | inc si |
1 | ha | 972 | cmp si,10 |
973 | jnz newread |
||
974 | mov si,badsect-0x10000 |
||
975 | call printplain |
||
976 | jmp $ |
||
977 | goodread: |
||
978 | ; move -> 1mb |
||
979 | mov si,movedesc-0x10000 |
||
29 | halyavin | 980 | push es |
981 | push ds |
||
1 | ha | 982 | pop es |
983 | mov cx,256*18 |
||
984 | mov ah,0x87 |
||
985 | int 0x15 |
||
29 | halyavin | 986 | pop es |
1 | ha | 987 | |
29 | halyavin | 988 | test ah,ah ; was the move successfull ? |
1 | ha | 989 | je goodmove |
990 | mov dx,0x3f2 ; floppy motor off |
||
991 | mov al,0 |
||
992 | out dx,al |
||
993 | mov si,memmovefailed-0x10000 |
||
994 | call print |
||
995 | jmp $ |
||
996 | goodmove: |
||
997 | |||
29 | halyavin | 998 | add dword [movedesc-0x10000+0x18+2], 512*18 |
1 | ha | 999 | popa |
1000 | inc dh |
||
1001 | cmp dh,2 |
||
1002 | jnz bb2 |
||
1003 | mov dh,0 |
||
1004 | inc ch |
||
1005 | pusha ; print prosentage |
||
1006 | mov si,pros-0x10000 |
||
29 | halyavin | 1007 | shr ch, 2 |
1008 | mov al, '5' |
||
1009 | test ch, 1 |
||
1010 | jnz @f |
||
1011 | mov al, '0' |
||
1012 | @@: |
||
1013 | mov [si+1], al |
||
1014 | shr ch, 1 |
||
1015 | add ch, '0' |
||
1016 | mov [si], ch |
||
1 | ha | 1017 | call printplain |
1018 | popa |
||
1019 | bb2: |
||
1020 | pop ax |
||
1021 | dec ax |
||
1022 | push ax |
||
29 | halyavin | 1023 | jnz reads |
1 | ha | 1024 | readdone: |
1025 | pop ax |
||
1026 | mov si,backspace-0x10000 |
||
1027 | call printplain |
||
1028 | call printplain |
||
1029 | mov si,okt-0x10000 |
||
1030 | call printplain |
||
1031 | no_sys_on_floppy: |
||
29 | halyavin | 1032 | xor ax, ax ; reset drive |
1033 | xor dx, dx |
||
1 | ha | 1034 | int 0x13 |
1035 | mov dx,0x3f2 ; floppy motor off |
||
1036 | mov al,0 |
||
29 | halyavin | 1037 | out dx,al |
1 | ha | 1038 | |
29 | halyavin | 1039 | push es |
1 | ha | 1040 | ; PAGE TABLE |
1041 | |||
29 | halyavin | 1042 | push dword [es:0x9018] |
1 | ha | 1043 | |
1044 | map_mem equ 64 ; amount of memory to map |
||
1045 | |||
29 | halyavin | 1046 | push 0x6000 |
1047 | pop es ; es:di = 6000:0 |
||
1048 | xor di,di |
||
1049 | mov cx,256*map_mem ; Map (mapmem) M |
||
1 | ha | 1050 | mov eax,7 |
1051 | pt2: |
||
29 | halyavin | 1052 | cmp cx,256*(map_mem-8) ; 8 M map to LFB |
1 | ha | 1053 | jnz pt3 |
1054 | pop eax |
||
1055 | add eax,7 |
||
1056 | pt3: |
||
29 | halyavin | 1057 | cmp cx,256*(map_mem-12) ; 12 M back to linear = physical |
1 | ha | 1058 | jnz pt4 |
1059 | mov eax,12*0x100000 + 7 |
||
1060 | pt4: |
||
1061 | stosd |
||
1062 | add eax,4096 |
||
1063 | loop pt2 |
||
1064 | |||
29 | halyavin | 1065 | push 0x7100 |
1066 | pop es |
||
1067 | xor di,di |
||
1 | ha | 1068 | mov eax,8*0x100000+7 |
29 | halyavin | 1069 | mov cx,256*4 |
1 | ha | 1070 | pt5: |
1071 | stosd |
||
1072 | add eax,0x1000 |
||
1073 | loop pt5 |
||
1074 | |||
1075 | ; 4 KB PAGE DIRECTORY |
||
1076 | |||
29 | halyavin | 1077 | push 0x7F00 |
1078 | pop es ; es:di = 7F00:0 |
||
1079 | xor di, di |
||
1080 | mov cx, 64 / 4 |
||
1 | ha | 1081 | mov eax, 0x60007 ; for 0 M |
1082 | pd4k: |
||
1083 | stosd |
||
1084 | add eax, 0x1000 |
||
1085 | loop pd4k |
||
1086 | mov dword [es:0x800],0x71007 ;map region 0x80000000-0x803FFFFF to 0x800000-0xCFFFFF |
||
29 | halyavin | 1087 | xor si,si |
1088 | mov di,second_base_address shr 20 |
||
1089 | mov cx,64/4 |
||
1090 | rep movs dword [es:di], [es:si] |
||
1 | ha | 1091 | |
1092 | mov eax, 0x7F000 +8+16 ; Page directory and enable caches |
||
1093 | mov cr3, eax |
||
1094 | |||
1095 | ; SET GRAPHICS |
||
1096 | |||
29 | halyavin | 1097 | pop es |
1098 | mov bx,[es:0x9008] ; vga & 320x200 |
||
1099 | mov ax, bx |
||
1100 | push ax |
||
1 | ha | 1101 | cmp ax,0x13 |
1102 | je setgr |
||
1103 | cmp ax,0x12 |
||
1104 | je setgr |
||
1105 | mov ax,0x4f02 ; Vesa |
||
1106 | setgr: |
||
1107 | int 0x10 |
||
29 | halyavin | 1108 | test ah,ah |
1 | ha | 1109 | jz gmok |
1110 | mov si,fatalsel-0x10000 |
||
1111 | call print |
||
1112 | jmp $ |
||
1113 | |||
1114 | gmok: |
||
1115 | ; set mode 0x12 graphics registers: |
||
1116 | cmp bx,0x12 |
||
1117 | jne gmok2 |
||
1118 | |||
1119 | mov al,0x05 |
||
1120 | mov dx,0x03ce |
||
1121 | out dx,al ; select GDC mode register |
||
1122 | mov al,0x02 |
||
29 | halyavin | 1123 | inc dx |
1 | ha | 1124 | out dx,al ; set write mode 2 |
1125 | |||
1126 | mov al,0x02 |
||
1127 | mov dx,0x03c4 |
||
1128 | out dx,al ; select VGA sequencer map mask register |
||
1129 | mov al,0x0f |
||
29 | halyavin | 1130 | inc dx |
1 | ha | 1131 | out dx,al ; set mask for all planes 0-3 |
1132 | |||
1133 | mov al,0x08 |
||
1134 | mov dx,0x03ce |
||
1135 | out dx,al ; select GDC bit mask register |
||
1136 | ; for writes to 0x03cf |
||
1137 | |||
1138 | gmok2: |
||
29 | halyavin | 1139 | push ds |
1140 | pop es |