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