Rev 3762 | Rev 3777 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3762 | Rev 3774 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;; BOOTCODE.INC ;; |
7 | ;; BOOTCODE.INC ;; |
8 | ;; ;; |
8 | ;; ;; |
9 | ;; KolibriOS 16-bit loader, ;; |
9 | ;; KolibriOS 16-bit loader, ;; |
10 | ;; based on bootcode for MenuetOS ;; |
10 | ;; based on bootcode for MenuetOS ;; |
11 | ;; ;; |
11 | ;; ;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
13 | 13 | ||
14 | $Revision: 3762 $ |
14 | $Revision: 3774 $ |
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 | test al, al |
45 | test al, al |
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 | sayerr_badsect: |
94 | sayerr_badsect: |
95 | mov si, badsect |
95 | mov si, badsect |
96 | sayerr_plain: |
96 | sayerr_plain: |
97 | call printplain |
97 | call printplain |
98 | jmp $ |
98 | jmp $ |
99 | @@: |
99 | @@: |
100 | pop si |
100 | pop si |
101 | ret |
101 | ret |
102 | 102 | ||
103 | ; convert abs. sector number (AX) to BIOS T:H:S |
103 | ; convert abs. sector number (AX) to BIOS T:H:S |
104 | ; sector number = (abs.sector%BPB_SecPerTrk)+1 |
104 | ; sector number = (abs.sector%BPB_SecPerTrk)+1 |
105 | ; pre.track number = (abs.sector/BPB_SecPerTrk) |
105 | ; pre.track number = (abs.sector/BPB_SecPerTrk) |
106 | ; head number = pre.track number%BPB_NumHeads |
106 | ; head number = pre.track number%BPB_NumHeads |
107 | ; track number = pre.track number/BPB_NumHeads |
107 | ; track number = pre.track number/BPB_NumHeads |
108 | ; Return: cl - sector number |
108 | ; Return: cl - sector number |
109 | ; ch - track number |
109 | ; ch - track number |
110 | ; dl - drive number (0 = a:) |
110 | ; dl - drive number (0 = a:) |
111 | ; dh - head number |
111 | ; dh - head number |
112 | conv_abs_to_THS: |
112 | conv_abs_to_THS: |
113 | push bx |
113 | push bx |
114 | mov bx, word [BPB_SecPerTrk] |
114 | mov bx, word [BPB_SecPerTrk] |
115 | xor dx, dx |
115 | xor dx, dx |
116 | div bx |
116 | div bx |
117 | inc dx |
117 | inc dx |
118 | mov cl, dl ; cl = sector number |
118 | mov cl, dl ; cl = sector number |
119 | mov bx, word [BPB_NumHeads] |
119 | mov bx, word [BPB_NumHeads] |
120 | xor dx, dx |
120 | xor dx, dx |
121 | div bx |
121 | div bx |
122 | ; !!!!!!! ax = track number, dx = head number |
122 | ; !!!!!!! ax = track number, dx = head number |
123 | mov ch, al ; ch=track number |
123 | mov ch, al ; ch=track number |
124 | xchg dh, dl ; dh=head number |
124 | xchg dh, dl ; dh=head number |
125 | mov dl, 0 ; dl=0 (drive 0 (a:)) |
125 | mov dl, 0 ; dl=0 (drive 0 (a:)) |
126 | pop bx |
126 | pop bx |
127 | retn |
127 | retn |
128 | ; needed variables |
128 | ; needed variables |
129 | BPB_SecPerTrk dw 0 ; sectors per track |
129 | BPB_SecPerTrk dw 0 ; sectors per track |
130 | BPB_NumHeads dw 0 ; number of heads |
130 | BPB_NumHeads dw 0 ; number of heads |
131 | BPB_FATSz16 dw 0 ; size of FAT |
131 | BPB_FATSz16 dw 0 ; size of FAT |
132 | BPB_RootEntCnt dw 0 ; count of root dir. entries |
132 | BPB_RootEntCnt dw 0 ; count of root dir. entries |
133 | BPB_BytsPerSec dw 0 ; bytes per sector |
133 | BPB_BytsPerSec dw 0 ; bytes per sector |
134 | BPB_RsvdSecCnt dw 0 ; number of reserved sectors |
134 | BPB_RsvdSecCnt dw 0 ; number of reserved sectors |
135 | BPB_TotSec16 dw 0 ; count of the sectors on the volume |
135 | BPB_TotSec16 dw 0 ; count of the sectors on the volume |
136 | BPB_SecPerClus db 0 ; number of sectors per cluster |
136 | BPB_SecPerClus db 0 ; number of sectors per cluster |
137 | BPB_NumFATs db 0 ; number of FAT tables |
137 | BPB_NumFATs db 0 ; number of FAT tables |
138 | abs_sector_adj dw 0 ; adjustment to make abs. sector number |
138 | abs_sector_adj dw 0 ; adjustment to make abs. sector number |
139 | end_of_FAT dw 0 ; end of FAT table |
139 | end_of_FAT dw 0 ; end of FAT table |
140 | FirstDataSector dw 0 ; begin of data |
140 | FirstDataSector dw 0 ; begin of data |
141 | 141 | ||
142 | ;========================================================================= |
142 | ;========================================================================= |
143 | ; |
143 | ; |
144 | ; 16 BIT CODE |
144 | ; 16 BIT CODE |
145 | ; |
145 | ; |
146 | ;========================================================================= |
146 | ;========================================================================= |
147 | 147 | ||
148 | include 'bootvesa.inc' ;Include source for boot vesa |
148 | include 'bootvesa.inc' ;Include source for boot vesa |
149 | if defined extended_primary_loader |
149 | if defined extended_primary_loader |
150 | include 'parsers.inc' |
150 | include 'parsers.inc' |
151 | end if |
151 | end if |
152 | 152 | ||
153 | start_of_code: |
153 | start_of_code: |
154 | 154 | ||
155 | if defined extended_primary_loader |
155 | if defined extended_primary_loader |
156 | ; save data from primary loader |
156 | ; save data from primary loader |
157 | mov word [cs:bootcallback], si |
157 | mov word [cs:bootcallback], si |
158 | mov word [cs:bootcallback+2], ds |
158 | mov word [cs:bootcallback+2], ds |
159 | push cs |
159 | push cs |
160 | pop ds |
160 | pop ds |
161 | mov [bootdevice], ax |
161 | mov [bootdevice], ax |
162 | mov [bootfs], bx |
162 | mov [bootfs], bx |
163 | 163 | ||
164 | ; set up stack |
164 | ; set up stack |
165 | mov ax, 3000h |
165 | mov ax, 3000h |
166 | mov ss, ax |
166 | mov ss, ax |
167 | mov sp, 0EC00h |
167 | mov sp, 0EC00h |
168 | 168 | ||
169 | ; try to load configuration file |
169 | ; try to load configuration file |
170 | mov ax, 1 |
170 | mov ax, 1 |
171 | mov di, config_file_struct |
171 | mov di, config_file_struct |
172 | call [bootcallback] |
172 | call [bootcallback] |
173 | cld |
173 | cld |
174 | push cs |
174 | push cs |
175 | pop es |
175 | pop es |
176 | ; bx=0 - ok, bx=1 - part of file loaded, assume this is ok |
176 | ; bx=0 - ok, bx=1 - part of file loaded, assume this is ok |
177 | cmp bx, 1 |
177 | cmp bx, 1 |
178 | ja .config_bad |
178 | ja .config_bad |
179 | ; configuration file was loaded, parse |
179 | ; configuration file was loaded, parse |
180 | ; if length is too big, use first 0FFFFh bytes |
180 | ; if length is too big, use first 0FFFFh bytes |
181 | test dx, dx |
181 | test dx, dx |
182 | jz @f |
182 | jz @f |
183 | mov ax, 0FFFFh |
183 | mov ax, 0FFFFh |
184 | @@: |
184 | @@: |
185 | ; ds:si will be pointer to current data, dx = limit |
185 | ; ds:si will be pointer to current data, dx = limit |
186 | xchg ax, dx |
186 | xchg ax, dx |
187 | push 4000h |
187 | push 4000h |
188 | pop ds |
188 | pop ds |
189 | xor si, si |
189 | xor si, si |
190 | .parse_loop: |
190 | .parse_loop: |
191 | ; skip spaces |
191 | ; skip spaces |
192 | cmp si, dx |
192 | cmp si, dx |
193 | jae .parse_done |
193 | jae .parse_done |
194 | lodsb |
194 | lodsb |
195 | cmp al, ' ' |
195 | cmp al, ' ' |
196 | jbe .parse_loop |
196 | jbe .parse_loop |
197 | dec si |
197 | dec si |
198 | ; loop over all possible configuration values |
198 | ; loop over all possible configuration values |
199 | mov bx, config_file_variables |
199 | mov bx, config_file_variables |
200 | .find_variant: |
200 | .find_variant: |
201 | ; get length |
201 | ; get length |
202 | mov cx, [es:bx] |
202 | mov cx, [es:bx] |
203 | ; zero length = end of list |
203 | ; zero length = end of list |
204 | jecxz .find_newline |
204 | jecxz .find_newline |
205 | ; skip over length |
205 | ; skip over length |
206 | inc bx |
206 | inc bx |
207 | inc bx |
207 | inc bx |
208 | mov di, bx |
208 | mov di, bx |
209 | ; skip over string |
209 | ; skip over string |
210 | add bx, cx |
210 | add bx, cx |
211 | ; test whether we have at least cx symbols left |
211 | ; test whether we have at least cx symbols left |
212 | mov ax, cx |
212 | mov ax, cx |
213 | add ax, si |
213 | add ax, si |
214 | jc .next_variant1 |
214 | jc .next_variant1 |
215 | cmp ax, dx |
215 | cmp ax, dx |
216 | jae .next_variant1 |
216 | jae .next_variant1 |
217 | ; save current position |
217 | ; save current position |
218 | push si |
218 | push si |
219 | ; compare strings |
219 | ; compare strings |
220 | repz cmpsb |
220 | repz cmpsb |
221 | jnz .next_variant2 |
221 | jnz .next_variant2 |
222 | ; strings are equal; look for "=" with possible spaces before and after |
222 | ; strings are equal; look for "=" with possible spaces before and after |
223 | @@: |
223 | @@: |
224 | cmp si, dx |
224 | cmp si, dx |
225 | jae .next_variant2 |
225 | jae .next_variant2 |
226 | lodsb |
226 | lodsb |
227 | cmp al, ' ' |
227 | cmp al, ' ' |
228 | jbe @b |
228 | jbe @b |
229 | cmp al, '=' |
229 | cmp al, '=' |
230 | jnz .next_variant2 |
230 | jnz .next_variant2 |
231 | ; ok, we found the true variant |
231 | ; ok, we found the true variant |
232 | ; ignore saved position on the stack |
232 | ; ignore saved position on the stack |
233 | pop ax |
233 | pop ax |
234 | ; call the parser |
234 | ; call the parser |
235 | call word [es:bx] |
235 | call word [es:bx] |
236 | ; line parsed, find next |
236 | ; line parsed, find next |
237 | .find_newline: |
237 | .find_newline: |
238 | cmp si, dx |
238 | cmp si, dx |
239 | jae .parse_done |
239 | jae .parse_done |
240 | lodsb |
240 | lodsb |
241 | cmp al, 13 |
241 | cmp al, 13 |
242 | jz .parse_loop |
242 | jz .parse_loop |
243 | cmp al, 10 |
243 | cmp al, 10 |
244 | jz .parse_loop |
244 | jz .parse_loop |
245 | jmp .find_newline |
245 | jmp .find_newline |
246 | .next_variant2: |
246 | .next_variant2: |
247 | ; continue to the next variant, restoring current position |
247 | ; continue to the next variant, restoring current position |
248 | pop si |
248 | pop si |
249 | .next_variant1: |
249 | .next_variant1: |
250 | ; continue to the next variant |
250 | ; continue to the next variant |
251 | ; skip over the parser |
251 | ; skip over the parser |
252 | inc bx |
252 | inc bx |
253 | inc bx |
253 | inc bx |
254 | jmp .find_variant |
254 | jmp .find_variant |
255 | .parse_done: |
255 | .parse_done: |
256 | .config_bad: |
256 | .config_bad: |
257 | 257 | ||
258 | ; set up segment registers |
258 | ; set up segment registers |
259 | push cs |
259 | push cs |
260 | pop ds |
260 | pop ds |
261 | else |
261 | else |
262 | cld |
262 | cld |
263 | ; \begin{diamond}[02.12.2005] |
263 | ; \begin{diamond}[02.12.2005] |
264 | ; if bootloader sets ax = 'KL', then ds:si points to loader block |
264 | ; if bootloader sets ax = 'KL', then ds:si points to loader block |
265 | cmp ax, 'KL' |
265 | cmp ax, 'KL' |
266 | jnz @f |
266 | jnz @f |
267 | mov word [cs:cfgmanager.loader_block], si |
267 | mov word [cs:cfgmanager.loader_block], si |
268 | mov word [cs:cfgmanager.loader_block+2], ds |
268 | mov word [cs:cfgmanager.loader_block+2], ds |
269 | @@: |
269 | @@: |
270 | ; \end{diamond}[02.12.2005] |
270 | ; \end{diamond}[02.12.2005] |
271 | 271 | ||
272 | ; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk |
272 | ; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk |
273 | ; (see comment to bx_from_load) |
273 | ; (see comment to bx_from_load) |
274 | cmp cx, 'HA' |
274 | cmp cx, 'HA' |
275 | jnz no_hd_load |
275 | jnz no_hd_load |
276 | cmp dx, 'RD' |
276 | cmp dx, 'RD' |
277 | jnz no_hd_load |
277 | jnz no_hd_load |
278 | mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] |
278 | mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] |
279 | no_hd_load: |
279 | no_hd_load: |
280 | 280 | ||
281 | ; set up stack |
281 | ; set up stack |
282 | mov ax, 3000h |
282 | mov ax, 3000h |
283 | mov ss, ax |
283 | mov ss, ax |
284 | mov sp, 0EC00h |
284 | mov sp, 0EC00h |
285 | ; set up segment registers |
285 | ; set up segment registers |
286 | push cs |
286 | push cs |
287 | pop ds |
287 | pop ds |
288 | push cs |
288 | push cs |
289 | pop es |
289 | pop es |
290 | end if |
290 | end if |
291 | 291 | ||
292 | ; set videomode |
292 | ; set videomode |
293 | mov ax, 3 |
293 | mov ax, 3 |
294 | int 0x10 |
294 | int 0x10 |
295 | 295 | ||
296 | if lang eq ru |
296 | if lang eq ru |
297 | ; Load & set russian VGA font (RU.INC) |
297 | ; Load & set russian VGA font (RU.INC) |
298 | mov bp, RU_FNT1 ; RU_FNT1 - First part |
298 | mov bp, RU_FNT1 ; RU_FNT1 - First part |
299 | mov bx, 1000h ; 768 bytes |
299 | mov bx, 1000h ; 768 bytes |
300 | mov cx, 30h ; 48 symbols |
300 | mov cx, 30h ; 48 symbols |
301 | mov dx, 80h ; 128 - position of first symbol |
301 | mov dx, 80h ; 128 - position of first symbol |
302 | mov ax, 1100h |
302 | mov ax, 1100h |
303 | int 10h |
303 | int 10h |
304 | 304 | ||
305 | mov bp, RU_FNT2 ; RU_FNT2 -Second part |
305 | mov bp, RU_FNT2 ; RU_FNT2 -Second part |
306 | mov bx, 1000h ; 512 bytes |
306 | mov bx, 1000h ; 512 bytes |
307 | mov cx, 20h ; 32 symbols |
307 | mov cx, 20h ; 32 symbols |
308 | mov dx, 0E0h ; 224 - position of first symbol |
308 | mov dx, 0E0h ; 224 - position of first symbol |
309 | mov ax, 1100h |
309 | mov ax, 1100h |
310 | int 10h |
310 | int 10h |
311 | ; End set VGA russian font |
311 | ; End set VGA russian font |
312 | else if lang eq et |
312 | else if lang eq et |
313 | mov bp, ET_FNT ; ET_FNT1 |
313 | mov bp, ET_FNT ; ET_FNT1 |
314 | mov bx, 1000h ; |
314 | mov bx, 1000h ; |
315 | mov cx, 255 ; 256 symbols |
315 | mov cx, 255 ; 256 symbols |
316 | xor dx, dx ; 0 - position of first symbol |
316 | xor dx, dx ; 0 - position of first symbol |
317 | mov ax, 1100h |
317 | mov ax, 1100h |
318 | int 10h |
318 | int 10h |
319 | end if |
319 | end if |
320 | 320 | ||
321 | ; draw frames |
321 | ; draw frames |
322 | push 0xb800 |
322 | push 0xb800 |
323 | pop es |
323 | pop es |
324 | xor di, di |
324 | xor di, di |
325 | mov ah, 1*16+15 |
325 | mov ah, 1*16+15 |
326 | 326 | ||
327 | ; draw top |
327 | ; draw top |
328 | mov si, d80x25_top |
328 | mov si, d80x25_top |
329 | mov cx, d80x25_top_num * 80 |
329 | mov cx, d80x25_top_num * 80 |
330 | @@: |
330 | @@: |
331 | lodsb |
331 | lodsb |
332 | stosw |
332 | stosw |
333 | loop @b |
333 | loop @b |
334 | ; draw spaces |
334 | ; draw spaces |
335 | mov si, space_msg |
335 | mov si, space_msg |
336 | mov dx, 25 - d80x25_top_num - d80x25_bottom_num |
336 | mov dx, 25 - d80x25_top_num - d80x25_bottom_num |
337 | dfl1: |
337 | dfl1: |
338 | push si |
338 | push si |
339 | mov cx, 80 |
339 | mov cx, 80 |
340 | @@: |
340 | @@: |
341 | lodsb |
341 | lodsb |
342 | stosw |
342 | stosw |
343 | loop @b |
343 | loop @b |
344 | pop si |
344 | pop si |
345 | dec dx |
345 | dec dx |
346 | jnz dfl1 |
346 | jnz dfl1 |
347 | ; draw bottom |
347 | ; draw bottom |
348 | mov si, d80x25_bottom |
348 | mov si, d80x25_bottom |
349 | mov cx, d80x25_bottom_num * 80 |
349 | mov cx, d80x25_bottom_num * 80 |
350 | @@: |
350 | @@: |
351 | lodsb |
351 | lodsb |
352 | stosw |
352 | stosw |
353 | loop @b |
353 | loop @b |
354 | 354 | ||
355 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
355 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
356 | 356 | ||
357 | _setcursor d80x25_top_num,0 |
357 | _setcursor d80x25_top_num,0 |
358 | 358 | ||
359 | 359 | ||
360 | ; TEST FOR 386+ |
360 | ; TEST FOR 386+ |
361 | 361 | ||
362 | mov bx, 0x4000 |
362 | mov bx, 0x4000 |
363 | pushf |
363 | pushf |
364 | pop ax |
364 | pop ax |
365 | mov dx, ax |
365 | mov dx, ax |
366 | xor ax, bx |
366 | xor ax, bx |
367 | push ax |
367 | push ax |
368 | popf |
368 | popf |
369 | pushf |
369 | pushf |
370 | pop ax |
370 | pop ax |
371 | and ax, bx |
371 | and ax, bx |
372 | and dx, bx |
372 | and dx, bx |
373 | cmp ax, dx |
373 | cmp ax, dx |
374 | jnz cpugood |
374 | jnz cpugood |
375 | mov si, not386 |
375 | mov si, not386 |
376 | sayerr: |
376 | sayerr: |
377 | call print |
377 | call print |
378 | jmp $ |
378 | jmp $ |
379 | cpugood: |
379 | cpugood: |
380 | 380 | ||
381 | push 0 |
381 | push 0 |
382 | popf |
382 | popf |
383 | sti |
383 | sti |
384 | 384 | ||
385 | ; set up esp |
385 | ; set up esp |
386 | movzx esp, sp |
386 | movzx esp, sp |
387 | 387 | ||
388 | push 0 |
388 | push 0 |
389 | pop es |
389 | pop es |
390 | xor ax, ax |
390 | xor ax, ax |
391 | and word [es:BOOT_IDE_BASE_ADDR], ax ;0 |
391 | and word [es:BOOT_IDE_BASE_ADDR], ax ;0 |
392 | and word [es:BOOT_IDE_BAR0_16], ax ;0 |
392 | and word [es:BOOT_IDE_BAR0_16], ax ;0 |
393 | and word [es:BOOT_IDE_BAR1_16], ax ;0 |
393 | and word [es:BOOT_IDE_BAR1_16], ax ;0 |
394 | and word [es:BOOT_IDE_BAR2_16], ax ;0 |
394 | and word [es:BOOT_IDE_BAR2_16], ax ;0 |
395 | and word [es:BOOT_IDE_BAR3_16], ax ;0 |
395 | and word [es:BOOT_IDE_BAR3_16], ax ;0 |
396 | ; \begin{Mario79} |
396 | ; \begin{Mario79} |
397 | ; find HDD IDE DMA PCI device |
397 | ; find HDD IDE DMA PCI device |
398 | ; check for PCI BIOS |
398 | ; check for PCI BIOS |
399 | mov ax, 0xB101 |
399 | mov ax, 0xB101 |
400 | int 0x1A |
400 | int 0x1A |
401 | jc .nopci |
401 | jc .nopci |
402 | cmp edx, 'PCI ' |
402 | cmp edx, 'PCI ' |
403 | jnz .nopci |
403 | jnz .nopci |
404 | ; find PCI class code |
404 | ; find PCI class code |
405 | ; class 1 = mass storage |
405 | ; class 1 = mass storage |
406 | ; subclass 1 = IDE controller |
406 | ; subclass 1 = IDE controller |
407 | ; a) class 1, subclass 1, programming interface 0x80 |
407 | ; a) class 1, subclass 1, programming interface 0x80 |
408 | ; This is a Parallel IDE Controller which uses IRQs 14 and 15. |
408 | ; This is a Parallel IDE Controller which uses IRQs 14 and 15. |
409 | mov ax, 0xB103 |
409 | mov ax, 0xB103 |
410 | mov ecx, 1*10000h + 1*100h + 0x80 |
410 | mov ecx, 1*10000h + 1*100h + 0x80 |
411 | mov [es:BOOT_IDE_PI_16], cx |
411 | mov [es:BOOT_IDE_PI_16], cx |
412 | xor si, si ; device index = 0 |
412 | xor si, si ; device index = 0 |
413 | int 0x1A |
413 | int 0x1A |
414 | jnc .found_1 ; Parallel IDE Controller |
414 | jnc .found_1 ; Parallel IDE Controller |
415 | ; b) class 1, subclass 1, programming interface 0x8f |
415 | ; b) class 1, subclass 1, programming interface 0x8f |
416 | mov ax, 0xB103 |
416 | mov ax, 0xB103 |
417 | mov ecx, 1*10000h + 1*100h + 0x8f |
417 | mov ecx, 1*10000h + 1*100h + 0x8f |
418 | mov [es:BOOT_IDE_PI_16], cx |
418 | mov [es:BOOT_IDE_PI_16], cx |
419 | xor si, si ; device index = 0 |
419 | xor si, si ; device index = 0 |
420 | int 0x1A |
420 | int 0x1A |
421 | jnc .found |
421 | jnc .found |
422 | ; c) class 1, subclass 1, programming interface 0x85 |
422 | ; c) class 1, subclass 1, programming interface 0x85 |
423 | mov ax, 0xB103 |
423 | mov ax, 0xB103 |
424 | mov ecx, 1*10000h + 1*100h + 0x85 |
424 | mov ecx, 1*10000h + 1*100h + 0x85 |
425 | mov [es:BOOT_IDE_PI_16], cx |
425 | mov [es:BOOT_IDE_PI_16], cx |
426 | xor si, si ; device index = 0 |
426 | xor si, si ; device index = 0 |
427 | int 0x1A |
427 | int 0x1A |
428 | jnc .found |
428 | jnc .found |
429 | ; d) class 1, subclass 1, programming interface 0x8A |
429 | ; d) class 1, subclass 1, programming interface 0x8A |
430 | ; This is a Parallel IDE Controller which uses IRQs 14 and 15. |
430 | ; This is a Parallel IDE Controller which uses IRQs 14 and 15. |
431 | mov ax, 0xB103 |
431 | mov ax, 0xB103 |
432 | mov ecx, 1*10000h + 1*100h + 0x8A |
432 | mov ecx, 1*10000h + 1*100h + 0x8A |
433 | mov [es:BOOT_IDE_PI_16], cx |
433 | mov [es:BOOT_IDE_PI_16], cx |
434 | xor si, si ; device index = 0 |
434 | xor si, si ; device index = 0 |
435 | int 0x1A |
435 | int 0x1A |
436 | jnc .found_1 ; Parallel IDE Controller |
436 | jnc .found_1 ; Parallel IDE Controller |
437 | - | ||
- | 437 | ; Controller not found! |
|
- | 438 | xor ax, ax |
|
- | 439 | mov [es:BOOT_IDE_PI_16], ax |
|
438 | jmp .nopci |
440 | jmp .nopci |
- | 441 | ;-------------------------------------- |
|
439 | .found_1: |
442 | .found_1: |
440 | ; get memory base BAR4 |
443 | ; get memory base BAR4 |
441 | mov ax, 0xB10A |
444 | mov ax, 0xB10A |
442 | mov di, 0x20 ; memory base is config register at 0x20 |
445 | mov di, 0x20 ; memory base is config register at 0x20 |
443 | push cx |
446 | push cx |
444 | int 0x1A |
447 | int 0x1A |
445 | jc .no_BAR4 ;.nopci |
448 | jc .no_BAR4 ;.nopci |
446 | and cx, 0xFFF0 ; clear address decode type |
449 | and cx, 0xFFFC ; clear address decode type |
447 | mov [es:BOOT_IDE_BASE_ADDR], cx |
450 | mov [es:BOOT_IDE_BASE_ADDR], cx |
448 | .no_BAR4: |
451 | .no_BAR4: |
449 | pop cx |
452 | pop cx |
- | 453 | ;-------------------------------------- |
|
450 | .found: |
454 | .found: |
451 | ; get Interrupt Line |
455 | ; get Interrupt Line |
452 | mov ax, 0xB10A |
456 | mov ax, 0xB10A |
453 | mov di, 0x3c ; memory base is config register at 0x3c |
457 | mov di, 0x3c ; memory base is config register at 0x3c |
454 | push cx |
458 | push cx |
455 | int 0x1A |
459 | int 0x1A |
456 | jc .no_Interrupt ;.nopci |
460 | jc .no_Interrupt ;.nopci |
457 | ; and cx, 0xFFF0 ; clear address decode type |
- | |
- | 461 | ||
458 | mov [es:BOOT_IDE_INTERR_16], cx |
462 | mov [es:BOOT_IDE_INTERR_16], cx |
459 | .no_Interrupt: |
463 | .no_Interrupt: |
460 | pop cx |
464 | pop cx |
- | 465 | ;-------------------------------------- |
|
461 | ; get memory base BAR0 |
466 | ; get memory base BAR0 |
462 | mov ax, 0xB10A |
467 | mov ax, 0xB10A |
463 | mov di, 0x10 ; memory base is config register at 0x10 |
468 | mov di, 0x10 ; memory base is config register at 0x10 |
464 | push cx |
469 | push cx |
465 | int 0x1A |
470 | int 0x1A |
466 | jc .no_BAR0 ;.nopci |
471 | jc .no_BAR0 ;.nopci |
- | 472 | ||
467 | mov [es:BOOT_IDE_BAR0_16], cx |
473 | mov [es:BOOT_IDE_BAR0_16], cx |
468 | .no_BAR0: |
474 | .no_BAR0: |
469 | pop cx |
475 | pop cx |
- | 476 | ;-------------------------------------- |
|
470 | ; get memory base BAR1 |
477 | ; get memory base BAR1 |
471 | mov ax, 0xB10A |
478 | mov ax, 0xB10A |
472 | mov di, 0x14 ; memory base is config register at 0x14 |
479 | mov di, 0x14 ; memory base is config register at 0x14 |
473 | push cx |
480 | push cx |
474 | int 0x1A |
481 | int 0x1A |
475 | jc .no_BAR1 ;.nopci |
482 | jc .no_BAR1 ;.nopci |
- | 483 | ||
476 | mov [es:BOOT_IDE_BAR1_16], cx |
484 | mov [es:BOOT_IDE_BAR1_16], cx |
477 | .no_BAR1: |
485 | .no_BAR1: |
478 | pop cx |
486 | pop cx |
- | 487 | ;-------------------------------------- |
|
479 | ; get memory base BAR2 |
488 | ; get memory base BAR2 |
480 | mov ax, 0xB10A |
489 | mov ax, 0xB10A |
481 | mov di, 0x18 ; memory base is config register at 0x18 |
490 | mov di, 0x18 ; memory base is config register at 0x18 |
482 | push cx |
491 | push cx |
483 | int 0x1A |
492 | int 0x1A |
484 | jc .no_BAR2 ;.nopci |
493 | jc .no_BAR2 ;.nopci |
- | 494 | ||
485 | mov [es:BOOT_IDE_BAR2_16], cx |
495 | mov [es:BOOT_IDE_BAR2_16], cx |
486 | .no_BAR2: |
496 | .no_BAR2: |
487 | pop cx |
497 | pop cx |
- | 498 | ;-------------------------------------- |
|
488 | ; get memory base BAR3 |
499 | ; get memory base BAR3 |
489 | mov ax, 0xB10A |
500 | mov ax, 0xB10A |
490 | mov di, 0x1C ; memory base is config register at 0x1c |
501 | mov di, 0x1C ; memory base is config register at 0x1c |
491 | push cx |
502 | push cx |
492 | int 0x1A |
503 | int 0x1A |
493 | jc .no_BAR3 ;.nopci |
504 | jc .no_BAR3 ;.nopci |
- | 505 | ||
494 | mov [es:BOOT_IDE_BAR3_16], cx |
506 | mov [es:BOOT_IDE_BAR3_16], cx |
495 | .no_BAR3: |
507 | .no_BAR3: |
496 | pop cx |
508 | pop cx |
- | 509 | ;-------------------------------------- |
|
497 | .nopci: |
510 | .nopci: |
498 | ; \end{Mario79} |
511 | ; \end{Mario79} |
499 | 512 | ||
500 | mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
513 | mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
501 | out 0x60, al |
514 | out 0x60, al |
502 | xor cx, cx |
515 | xor cx, cx |
503 | wait_loop: ; variant 2 |
516 | wait_loop: ; variant 2 |
504 | ; reading state of port of 8042 controller |
517 | ; reading state of port of 8042 controller |
505 | in al, 64h |
518 | in al, 64h |
506 | and al, 00000010b ; ready flag |
519 | and al, 00000010b ; ready flag |
507 | ; wait until 8042 controller is ready |
520 | ; wait until 8042 controller is ready |
508 | loopnz wait_loop |
521 | loopnz wait_loop |
509 | 522 | ||
510 | ;;;/diamond today 5.02.2008 |
523 | ;;;/diamond today 5.02.2008 |
511 | ; set keyboard typematic rate & delay |
524 | ; set keyboard typematic rate & delay |
512 | mov al, 0xf3 |
525 | mov al, 0xf3 |
513 | out 0x60, al |
526 | out 0x60, al |
514 | xor cx, cx |
527 | xor cx, cx |
515 | @@: |
528 | @@: |
516 | in al, 64h |
529 | in al, 64h |
517 | test al, 2 |
530 | test al, 2 |
518 | loopnz @b |
531 | loopnz @b |
519 | mov al, 0 |
532 | mov al, 0 |
520 | out 0x60, al |
533 | out 0x60, al |
521 | xor cx, cx |
534 | xor cx, cx |
522 | @@: |
535 | @@: |
523 | in al, 64h |
536 | in al, 64h |
524 | test al, 2 |
537 | test al, 2 |
525 | loopnz @b |
538 | loopnz @b |
526 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
539 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
527 | ; --------------- APM --------------------- |
540 | ; --------------- APM --------------------- |
528 | and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found) |
541 | and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found) |
529 | mov ax, 0x5300 |
542 | mov ax, 0x5300 |
530 | xor bx, bx |
543 | xor bx, bx |
531 | int 0x15 |
544 | int 0x15 |
532 | jc apm_end ; APM not found |
545 | jc apm_end ; APM not found |
533 | test cx, 2 |
546 | test cx, 2 |
534 | jz apm_end ; APM 32-bit protected-mode interface not supported |
547 | jz apm_end ; APM 32-bit protected-mode interface not supported |
535 | mov [es:BOOT_APM_VERSION], ax ; Save APM Version |
548 | mov [es:BOOT_APM_VERSION], ax ; Save APM Version |
536 | mov [es:BOOT_APM_FLAGS], cx ; Save APM flags |
549 | mov [es:BOOT_APM_FLAGS], cx ; Save APM flags |
537 | 550 | ||
538 | ; Write APM ver ---- |
551 | ; Write APM ver ---- |
539 | and ax, 0xf0f |
552 | and ax, 0xf0f |
540 | add ax, '00' |
553 | add ax, '00' |
541 | mov si, msg_apm |
554 | mov si, msg_apm |
542 | mov [si + 5], ah |
555 | mov [si + 5], ah |
543 | mov [si + 7], al |
556 | mov [si + 7], al |
544 | _setcursor 0, 3 |
557 | _setcursor 0, 3 |
545 | call printplain |
558 | call printplain |
546 | ; ------------------ |
559 | ; ------------------ |
547 | 560 | ||
548 | mov ax, 0x5304 ; Disconnect interface |
561 | mov ax, 0x5304 ; Disconnect interface |
549 | xor bx, bx |
562 | xor bx, bx |
550 | int 0x15 |
563 | int 0x15 |
551 | mov ax, 0x5303 ; Connect 32 bit mode interface |
564 | mov ax, 0x5303 ; Connect 32 bit mode interface |
552 | xor bx, bx |
565 | xor bx, bx |
553 | int 0x15 |
566 | int 0x15 |
554 | 567 | ||
555 | mov [es:BOOT_APM_ENTRY], ebx |
568 | mov [es:BOOT_APM_ENTRY], ebx |
556 | mov [es:BOOT_APM_CODE_32], ax |
569 | mov [es:BOOT_APM_CODE_32], ax |
557 | mov [es:BOOT_APM_CODE_16], cx |
570 | mov [es:BOOT_APM_CODE_16], cx |
558 | mov [es:BOOT_APM_DATA_16], dx |
571 | mov [es:BOOT_APM_DATA_16], dx |
559 | 572 | ||
560 | apm_end: |
573 | apm_end: |
561 | _setcursor d80x25_top_num, 0 |
574 | _setcursor d80x25_top_num, 0 |
562 | 575 | ||
563 | if ~ defined extended_primary_loader |
576 | if ~ defined extended_primary_loader |
564 | ;CHECK current of code |
577 | ;CHECK current of code |
565 | cmp [cfgmanager.loader_block], -1 |
578 | cmp [cfgmanager.loader_block], -1 |
566 | jz noloaderblock |
579 | jz noloaderblock |
567 | les bx, [cfgmanager.loader_block] |
580 | les bx, [cfgmanager.loader_block] |
568 | cmp byte [es:bx], 1 |
581 | cmp byte [es:bx], 1 |
569 | mov si, loader_block_error |
582 | mov si, loader_block_error |
570 | jnz sayerr |
583 | jnz sayerr |
571 | push 0 |
584 | push 0 |
572 | pop es |
585 | pop es |
573 | end if |
586 | end if |
574 | 587 | ||
575 | noloaderblock: |
588 | noloaderblock: |
576 | ; DISPLAY VESA INFORMATION |
589 | ; DISPLAY VESA INFORMATION |
577 | call print_vesa_info |
590 | call print_vesa_info |
578 | call calc_vmodes_table |
591 | call calc_vmodes_table |
579 | call check_first_parm ;check and enable cursor_pos |
592 | call check_first_parm ;check and enable cursor_pos |
580 | 593 | ||
581 | ; \begin{diamond}[30.11.2005] |
594 | ; \begin{diamond}[30.11.2005] |
582 | cfgmanager: |
595 | cfgmanager: |
583 | ; settings: |
596 | ; settings: |
584 | ; a) preboot_graph = graphical mode |
597 | ; a) preboot_graph = graphical mode |
585 | ; preboot_gprobe = probe this mode? |
598 | ; preboot_gprobe = probe this mode? |
586 | ; b) preboot_dma = use DMA access? |
599 | ; b) preboot_dma = use DMA access? |
587 | ; c) preboot_vrrm = use VRR? |
600 | ; c) preboot_vrrm = use VRR? |
588 | ; d) preboot_device = from what boot? |
601 | ; d) preboot_device = from what boot? |
589 | 602 | ||
590 | ; determine default settings |
603 | ; determine default settings |
591 | if ~ defined extended_primary_loader |
604 | if ~ defined extended_primary_loader |
592 | mov [.bSettingsChanged], 0 |
605 | mov [.bSettingsChanged], 0 |
593 | end if |
606 | end if |
594 | 607 | ||
595 | ;.preboot_gr_end: |
608 | ;.preboot_gr_end: |
596 | mov di, preboot_device |
609 | mov di, preboot_device |
597 | ; if image in memory is present and [preboot_device] is uninitialized, |
610 | ; if image in memory is present and [preboot_device] is uninitialized, |
598 | ; set it to use this preloaded image |
611 | ; set it to use this preloaded image |
599 | cmp byte [di], 0 |
612 | cmp byte [di], 0 |
600 | jnz .preboot_device_inited |
613 | jnz .preboot_device_inited |
601 | if defined extended_primary_loader |
614 | if defined extended_primary_loader |
602 | inc byte [di] |
615 | inc byte [di] |
603 | cmp byte [bootdevice], 'f' ; floppy? |
616 | cmp byte [bootdevice], 'f' ; floppy? |
604 | jz .preboot_device_inited |
617 | jz .preboot_device_inited |
605 | inc byte [di] |
618 | inc byte [di] |
606 | else |
619 | else |
607 | cmp [.loader_block], -1 |
620 | cmp [.loader_block], -1 |
608 | jz @f |
621 | jz @f |
609 | les bx, [.loader_block] |
622 | les bx, [.loader_block] |
610 | test byte [es:bx+1], 1 |
623 | test byte [es:bx+1], 1 |
611 | jz @f |
624 | jz @f |
612 | mov byte [di], 3 |
625 | mov byte [di], 3 |
613 | jmp .preboot_device_inited |
626 | jmp .preboot_device_inited |
614 | @@: |
627 | @@: |
615 | ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) |
628 | ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) |
616 | mov byte [di], 1 |
629 | mov byte [di], 1 |
617 | end if |
630 | end if |
618 | .preboot_device_inited: |
631 | .preboot_device_inited: |
619 | ; following 4 lines set variables to 1 if its current value is 0 |
632 | ; following 4 lines set variables to 1 if its current value is 0 |
620 | cmp byte [di+preboot_dma-preboot_device], 1 |
633 | cmp byte [di+preboot_dma-preboot_device], 1 |
621 | adc byte [di+preboot_dma-preboot_device], 0 |
634 | adc byte [di+preboot_dma-preboot_device], 0 |
622 | ; cmp byte [di+preboot_biosdisk-preboot_device], 1 |
635 | ; cmp byte [di+preboot_biosdisk-preboot_device], 1 |
623 | ; adc byte [di+preboot_biosdisk-preboot_device], 0 |
636 | ; adc byte [di+preboot_biosdisk-preboot_device], 0 |
624 | ;; default value for VRR is OFF |
637 | ;; default value for VRR is OFF |
625 | ; cmp byte [di+preboot_vrrm-preboot_device], 0 |
638 | ; cmp byte [di+preboot_vrrm-preboot_device], 0 |
626 | ; jnz @f |
639 | ; jnz @f |
627 | ; mov byte [di+preboot_vrrm-preboot_device], 2 |
640 | ; mov byte [di+preboot_vrrm-preboot_device], 2 |
628 | ;@@: |
641 | ;@@: |
629 | ; notify user |
642 | ; notify user |
630 | _setcursor 5,2 |
643 | _setcursor 5,2 |
631 | 644 | ||
632 | mov si, linef |
645 | mov si, linef |
633 | call printplain |
646 | call printplain |
634 | mov si, start_msg |
647 | mov si, start_msg |
635 | call print |
648 | call print |
636 | mov si, time_msg |
649 | mov si, time_msg |
637 | call print |
650 | call print |
638 | ; get start time |
651 | ; get start time |
639 | call .gettime |
652 | call .gettime |
640 | mov [.starttime], eax |
653 | mov [.starttime], eax |
641 | mov word [.timer], .newtimer |
654 | mov word [.timer], .newtimer |
642 | mov word [.timer+2], cs |
655 | mov word [.timer+2], cs |
643 | .printcfg: |
656 | .printcfg: |
644 | 657 | ||
645 | _setcursor 9,0 |
658 | _setcursor 9,0 |
646 | mov si, current_cfg_msg |
659 | mov si, current_cfg_msg |
647 | call print |
660 | call print |
648 | mov si, curvideo_msg |
661 | mov si, curvideo_msg |
649 | call print |
662 | call print |
650 | 663 | ||
651 | call draw_current_vmode |
664 | call draw_current_vmode |
652 | 665 | ||
653 | mov si, usebd_msg |
666 | mov si, usebd_msg |
654 | cmp [preboot_biosdisk], 1 |
667 | cmp [preboot_biosdisk], 1 |
655 | call .say_on_off |
668 | call .say_on_off |
656 | ; mov si, vrrm_msg |
669 | ; mov si, vrrm_msg |
657 | ; cmp [preboot_vrrm], 1 |
670 | ; cmp [preboot_vrrm], 1 |
658 | ; call .say_on_off |
671 | ; call .say_on_off |
659 | mov si, preboot_device_msg |
672 | mov si, preboot_device_msg |
660 | call print |
673 | call print |
661 | mov al, [preboot_device] |
674 | mov al, [preboot_device] |
662 | if defined extended_primary_loader |
675 | if defined extended_primary_loader |
663 | and eax, 3 |
676 | and eax, 3 |
664 | else |
677 | else |
665 | and eax, 7 |
678 | and eax, 7 |
666 | end if |
679 | end if |
667 | mov si, [preboot_device_msgs+eax*2] |
680 | mov si, [preboot_device_msgs+eax*2] |
668 | call printplain |
681 | call printplain |
669 | .show_remarks: |
682 | .show_remarks: |
670 | ; show remarks in gray color |
683 | ; show remarks in gray color |
671 | mov di, ((21-num_remarks)*80 + 2)*2 |
684 | mov di, ((21-num_remarks)*80 + 2)*2 |
672 | push 0xB800 |
685 | push 0xB800 |
673 | pop es |
686 | pop es |
674 | mov cx, num_remarks |
687 | mov cx, num_remarks |
675 | mov si, remarks |
688 | mov si, remarks |
676 | .write_remarks: |
689 | .write_remarks: |
677 | lodsw |
690 | lodsw |
678 | push si |
691 | push si |
679 | xchg ax, si |
692 | xchg ax, si |
680 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
693 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
681 | push di |
694 | push di |
682 | .write_remark: |
695 | .write_remark: |
683 | lodsb |
696 | lodsb |
684 | test al, al |
697 | test al, al |
685 | jz @f |
698 | jz @f |
686 | stosw |
699 | stosw |
687 | jmp .write_remark |
700 | jmp .write_remark |
688 | @@: |
701 | @@: |
689 | pop di |
702 | pop di |
690 | pop si |
703 | pop si |
691 | add di, 80*2 |
704 | add di, 80*2 |
692 | loop .write_remarks |
705 | loop .write_remarks |
693 | .wait: |
706 | .wait: |
694 | _setcursor 25,0 ; out of screen |
707 | _setcursor 25,0 ; out of screen |
695 | ; set timer interrupt handler |
708 | ; set timer interrupt handler |
696 | cli |
709 | cli |
697 | push 0 |
710 | push 0 |
698 | pop es |
711 | pop es |
699 | push dword [es:8*4] |
712 | push dword [es:8*4] |
700 | pop dword [.oldtimer] |
713 | pop dword [.oldtimer] |
701 | push dword [.timer] |
714 | push dword [.timer] |
702 | pop dword [es:8*4] |
715 | pop dword [es:8*4] |
703 | ; mov eax, [es:8*4] |
716 | ; mov eax, [es:8*4] |
704 | ; mov [.oldtimer], eax |
717 | ; mov [.oldtimer], eax |
705 | ; mov eax, [.timer] |
718 | ; mov eax, [.timer] |
706 | ; mov [es:8*4], eax |
719 | ; mov [es:8*4], eax |
707 | sti |
720 | sti |
708 | ; wait for keypressed |
721 | ; wait for keypressed |
709 | xor ax, ax |
722 | xor ax, ax |
710 | int 16h |
723 | int 16h |
711 | push ax |
724 | push ax |
712 | ; restore timer interrupt |
725 | ; restore timer interrupt |
713 | ; push 0 |
726 | ; push 0 |
714 | ; pop es |
727 | ; pop es |
715 | mov eax, [.oldtimer] |
728 | mov eax, [.oldtimer] |
716 | mov [es:8*4], eax |
729 | mov [es:8*4], eax |
717 | mov [.timer], eax |
730 | mov [.timer], eax |
718 | 731 | ||
719 | _setcursor 7,0 |
732 | _setcursor 7,0 |
720 | mov si, space_msg |
733 | mov si, space_msg |
721 | call printplain |
734 | call printplain |
722 | ; clear remarks and restore normal attributes |
735 | ; clear remarks and restore normal attributes |
723 | push es |
736 | push es |
724 | mov di, ((21-num_remarks)*80 + 2)*2 |
737 | mov di, ((21-num_remarks)*80 + 2)*2 |
725 | push 0xB800 |
738 | push 0xB800 |
726 | pop es |
739 | pop es |
727 | mov cx, num_remarks |
740 | mov cx, num_remarks |
728 | mov ax, ' ' + (1*16 + 15)*100h |
741 | mov ax, ' ' + (1*16 + 15)*100h |
729 | @@: |
742 | @@: |
730 | push cx |
743 | push cx |
731 | mov cx, 76 |
744 | mov cx, 76 |
732 | rep stosw |
745 | rep stosw |
733 | pop cx |
746 | pop cx |
734 | add di, 4*2 |
747 | add di, 4*2 |
735 | loop @b |
748 | loop @b |
736 | pop es |
749 | pop es |
737 | pop ax |
750 | pop ax |
738 | ; switch on key |
751 | ; switch on key |
739 | cmp al, 13 |
752 | cmp al, 13 |
740 | jz .continue |
753 | jz .continue |
741 | or al, 20h |
754 | or al, 20h |
742 | cmp al, 'a' |
755 | cmp al, 'a' |
743 | jz .change_a |
756 | jz .change_a |
744 | cmp al, 'q' ; Trick to make 'A' key on azerty keyboard work |
757 | cmp al, 'q' ; Trick to make 'A' key on azerty keyboard work |
745 | je .change_a |
758 | je .change_a |
746 | cmp al, 'b' |
759 | cmp al, 'b' |
747 | jz .change_b |
760 | jz .change_b |
748 | ; cmp al, 'c' |
761 | ; cmp al, 'c' |
749 | ; jz .change_c |
762 | ; jz .change_c |
750 | cmp al, 'c' ; 'd' |
763 | cmp al, 'c' ; 'd' |
751 | jnz .show_remarks |
764 | jnz .show_remarks |
752 | _setcursor 15,0 |
765 | _setcursor 15,0 |
753 | mov si, bdev |
766 | mov si, bdev |
754 | call print |
767 | call print |
755 | if defined extended_primary_loader |
768 | if defined extended_primary_loader |
756 | mov bx, '12' |
769 | mov bx, '12' |
757 | else |
770 | else |
758 | mov bx, '14' |
771 | mov bx, '14' |
759 | end if |
772 | end if |
760 | call getkey |
773 | call getkey |
761 | mov [preboot_device], al |
774 | mov [preboot_device], al |
762 | _setcursor 13,0 |
775 | _setcursor 13,0 |
763 | .d: |
776 | .d: |
764 | if ~ defined extended_primary_loader |
777 | if ~ defined extended_primary_loader |
765 | mov [.bSettingsChanged], 1 |
778 | mov [.bSettingsChanged], 1 |
766 | end if |
779 | end if |
767 | call clear_vmodes_table ;clear vmodes_table |
780 | call clear_vmodes_table ;clear vmodes_table |
768 | jmp .printcfg |
781 | jmp .printcfg |
769 | .change_a: |
782 | .change_a: |
770 | .loops: |
783 | .loops: |
771 | call draw_vmodes_table |
784 | call draw_vmodes_table |
772 | _setcursor 25,0 ; out of screen |
785 | _setcursor 25,0 ; out of screen |
773 | xor ax, ax |
786 | xor ax, ax |
774 | int 0x16 |
787 | int 0x16 |
775 | ; call clear_table_cursor ;clear current position of cursor |
788 | ; call clear_table_cursor ;clear current position of cursor |
776 | 789 | ||
777 | mov si, word [cursor_pos] |
790 | mov si, word [cursor_pos] |
778 | 791 | ||
779 | cmp ah, 0x48;x,0x48E0 ; up |
792 | cmp ah, 0x48;x,0x48E0 ; up |
780 | jne .down |
793 | jne .down |
781 | cmp si, modes_table |
794 | cmp si, modes_table |
782 | jbe .loops |
795 | jbe .loops |
783 | sub word [cursor_pos], size_of_step |
796 | sub word [cursor_pos], size_of_step |
784 | jmp .loops |
797 | jmp .loops |
785 | 798 | ||
786 | .down: |
799 | .down: |
787 | cmp ah, 0x50;x,0x50E0 ; down |
800 | cmp ah, 0x50;x,0x50E0 ; down |
788 | jne .pgup |
801 | jne .pgup |
789 | cmp word[es:si+10], -1 |
802 | cmp word[es:si+10], -1 |
790 | je .loops |
803 | je .loops |
791 | add word [cursor_pos], size_of_step |
804 | add word [cursor_pos], size_of_step |
792 | jmp .loops |
805 | jmp .loops |
793 | 806 | ||
794 | .pgup: |
807 | .pgup: |
795 | cmp ah, 0x49 ; page up |
808 | cmp ah, 0x49 ; page up |
796 | jne .pgdn |
809 | jne .pgdn |
797 | sub si, size_of_step*long_v_table |
810 | sub si, size_of_step*long_v_table |
798 | cmp si, modes_table |
811 | cmp si, modes_table |
799 | jae @f |
812 | jae @f |
800 | mov si, modes_table |
813 | mov si, modes_table |
801 | @@: |
814 | @@: |
802 | mov word [cursor_pos], si |
815 | mov word [cursor_pos], si |
803 | mov si, word [home_cursor] |
816 | mov si, word [home_cursor] |
804 | sub si, size_of_step*long_v_table |
817 | sub si, size_of_step*long_v_table |
805 | cmp si, modes_table |
818 | cmp si, modes_table |
806 | jae @f |
819 | jae @f |
807 | mov si, modes_table |
820 | mov si, modes_table |
808 | @@: |
821 | @@: |
809 | mov word [home_cursor], si |
822 | mov word [home_cursor], si |
810 | jmp .loops |
823 | jmp .loops |
811 | 824 | ||
812 | .pgdn: |
825 | .pgdn: |
813 | cmp ah, 0x51 ; page down |
826 | cmp ah, 0x51 ; page down |
814 | jne .enter |
827 | jne .enter |
815 | mov ax, [end_cursor] |
828 | mov ax, [end_cursor] |
816 | add si, size_of_step*long_v_table |
829 | add si, size_of_step*long_v_table |
817 | cmp si, ax |
830 | cmp si, ax |
818 | jb @f |
831 | jb @f |
819 | mov si, ax |
832 | mov si, ax |
820 | sub si, size_of_step |
833 | sub si, size_of_step |
821 | @@: |
834 | @@: |
822 | mov word [cursor_pos], si |
835 | mov word [cursor_pos], si |
823 | mov si, word [home_cursor] |
836 | mov si, word [home_cursor] |
824 | sub ax, size_of_step*long_v_table |
837 | sub ax, size_of_step*long_v_table |
825 | add si, size_of_step*long_v_table |
838 | add si, size_of_step*long_v_table |
826 | cmp si, ax |
839 | cmp si, ax |
827 | jb @f |
840 | jb @f |
828 | mov si, ax |
841 | mov si, ax |
829 | @@: |
842 | @@: |
830 | mov word [home_cursor], si |
843 | mov word [home_cursor], si |
831 | jmp .loops |
844 | jmp .loops |
832 | 845 | ||
833 | .enter: |
846 | .enter: |
834 | cmp al, 0x0D;x,0x1C0D ; enter |
847 | cmp al, 0x0D;x,0x1C0D ; enter |
835 | jne .loops |
848 | jne .loops |
836 | push word [cursor_pos] |
849 | push word [cursor_pos] |
837 | pop bp |
850 | pop bp |
838 | push word [es:bp] |
851 | push word [es:bp] |
839 | pop word [x_save] |
852 | pop word [x_save] |
840 | push word [es:bp+2] |
853 | push word [es:bp+2] |
841 | pop word [y_save] |
854 | pop word [y_save] |
842 | push word [es:bp+6] |
855 | push word [es:bp+6] |
843 | pop word [number_vm] |
856 | pop word [number_vm] |
844 | mov word [preboot_graph], bp ;save choose |
857 | mov word [preboot_graph], bp ;save choose |
845 | 858 | ||
846 | jmp .d |
859 | jmp .d |
847 | 860 | ||
848 | .change_b: |
861 | .change_b: |
849 | _setcursor 15,0 |
862 | _setcursor 15,0 |
850 | ; mov si, ask_dma |
863 | ; mov si, ask_dma |
851 | ; call print |
864 | ; call print |
852 | ; mov bx, '13' |
865 | ; mov bx, '13' |
853 | ; call getkey |
866 | ; call getkey |
854 | ; mov [preboot_dma], al |
867 | ; mov [preboot_dma], al |
855 | mov si, ask_bd |
868 | mov si, ask_bd |
856 | call print |
869 | call print |
857 | mov bx, '12' |
870 | mov bx, '12' |
858 | call getkey |
871 | call getkey |
859 | mov [preboot_biosdisk], al |
872 | mov [preboot_biosdisk], al |
860 | _setcursor 11,0 |
873 | _setcursor 11,0 |
861 | jmp .d |
874 | jmp .d |
862 | ;.change_c: |
875 | ;.change_c: |
863 | ; _setcursor 15,0 |
876 | ; _setcursor 15,0 |
864 | ; mov si, vrrmprint |
877 | ; mov si, vrrmprint |
865 | ; call print |
878 | ; call print |
866 | ; mov bx, '12' |
879 | ; mov bx, '12' |
867 | ; call getkey |
880 | ; call getkey |
868 | ; mov [preboot_vrrm], al |
881 | ; mov [preboot_vrrm], al |
869 | ; _setcursor 12,0 |
882 | ; _setcursor 12,0 |
870 | ; jmp .d |
883 | ; jmp .d |
871 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
884 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
872 | .say_on_off: |
885 | .say_on_off: |
873 | pushf |
886 | pushf |
874 | call print |
887 | call print |
875 | mov si, on_msg |
888 | mov si, on_msg |
876 | popf |
889 | popf |
877 | jz @f |
890 | jz @f |
878 | mov si, off_msg |
891 | mov si, off_msg |
879 | @@: |
892 | @@: |
880 | jmp printplain |
893 | jmp printplain |
881 | ; novesa and vervesa strings are not used at the moment of executing this code |
894 | ; novesa and vervesa strings are not used at the moment of executing this code |
882 | virtual at novesa |
895 | virtual at novesa |
883 | .oldtimer dd ? |
896 | .oldtimer dd ? |
884 | .starttime dd ? |
897 | .starttime dd ? |
885 | if ~ defined extended_primary_loader |
898 | if ~ defined extended_primary_loader |
886 | .bSettingsChanged db ? |
899 | .bSettingsChanged db ? |
887 | end if |
900 | end if |
888 | .timer dd ? |
901 | .timer dd ? |
889 | end virtual |
902 | end virtual |
890 | if ~ defined extended_primary_loader |
903 | if ~ defined extended_primary_loader |
891 | .loader_block dd -1 |
904 | .loader_block dd -1 |
892 | end if |
905 | end if |
893 | .gettime: |
906 | .gettime: |
894 | mov ah, 0 |
907 | mov ah, 0 |
895 | int 1Ah |
908 | int 1Ah |
896 | xchg ax, cx |
909 | xchg ax, cx |
897 | shl eax, 10h |
910 | shl eax, 10h |
898 | xchg ax, dx |
911 | xchg ax, dx |
899 | ret |
912 | ret |
900 | .newtimer: |
913 | .newtimer: |
901 | push ds |
914 | push ds |
902 | push cs |
915 | push cs |
903 | pop ds |
916 | pop ds |
904 | pushf |
917 | pushf |
905 | call [.oldtimer] |
918 | call [.oldtimer] |
906 | pushad |
919 | pushad |
907 | call .gettime |
920 | call .gettime |
908 | sub eax, [.starttime] |
921 | sub eax, [.starttime] |
909 | if defined extended_primary_loader |
922 | if defined extended_primary_loader |
910 | sub ax, [preboot_timeout] |
923 | sub ax, [preboot_timeout] |
911 | else |
924 | else |
912 | sub ax, 18*5 |
925 | sub ax, 18*5 |
913 | end if |
926 | end if |
914 | jae .timergo |
927 | jae .timergo |
915 | neg ax |
928 | neg ax |
916 | add ax, 18-1 |
929 | add ax, 18-1 |
917 | mov bx, 18 |
930 | mov bx, 18 |
918 | xor dx, dx |
931 | xor dx, dx |
919 | div bx |
932 | div bx |
920 | if lang eq ru |
933 | if lang eq ru |
921 | ; подождите 5 секунд, 4/3/2 секунды, 1 секунду |
934 | ; подождите 5 секунд, 4/3/2 секунды, 1 секунду |
922 | cmp al, 5 |
935 | cmp al, 5 |
923 | mov cl, ' ' |
936 | mov cl, ' ' |
924 | jae @f |
937 | jae @f |
925 | cmp al, 1 |
938 | cmp al, 1 |
926 | mov cl, 0xE3 ; 'у' in cp866 |
939 | mov cl, 0xE3 ; 'у' in cp866 |
927 | jz @f |
940 | jz @f |
928 | mov cl, 0xEB ; 'ы' in cp866 |
941 | mov cl, 0xEB ; 'ы' in cp866 |
929 | @@: |
942 | @@: |
930 | mov [time_str+9], cl |
943 | mov [time_str+9], cl |
931 | else if lang eq et |
944 | else if lang eq et |
932 | cmp al, 1 |
945 | cmp al, 1 |
933 | ja @f |
946 | ja @f |
934 | mov byte [time_str+9], ' ' |
947 | mov byte [time_str+9], ' ' |
935 | mov byte [time_str+10], ' ' |
948 | mov byte [time_str+10], ' ' |
936 | @@: |
949 | @@: |
937 | else if lang eq sp |
950 | else if lang eq sp |
938 | ; esperar 5/4/3/2 segundos, 1 segundo |
951 | ; esperar 5/4/3/2 segundos, 1 segundo |
939 | cmp al, 1 |
952 | cmp al, 1 |
940 | mov cl, 's' |
953 | mov cl, 's' |
941 | ja @f |
954 | ja @f |
942 | mov cl, ' ' |
955 | mov cl, ' ' |
943 | @@: |
956 | @@: |
944 | mov [time_str+10], cl |
957 | mov [time_str+10], cl |
945 | else |
958 | else |
946 | ; wait 5/4/3/2 seconds, 1 second |
959 | ; wait 5/4/3/2 seconds, 1 second |
947 | cmp al, 1 |
960 | cmp al, 1 |
948 | mov cl, 's' |
961 | mov cl, 's' |
949 | ja @f |
962 | ja @f |
950 | mov cl, ' ' |
963 | mov cl, ' ' |
951 | @@: |
964 | @@: |
952 | mov [time_str+9], cl |
965 | mov [time_str+9], cl |
953 | end if |
966 | end if |
954 | add al, '0' |
967 | add al, '0' |
955 | mov [time_str+1], al |
968 | mov [time_str+1], al |
956 | mov si, time_msg |
969 | mov si, time_msg |
957 | _setcursor 7,0 |
970 | _setcursor 7,0 |
958 | call print |
971 | call print |
959 | _setcursor 25,0 |
972 | _setcursor 25,0 |
960 | popad |
973 | popad |
961 | pop ds |
974 | pop ds |
962 | iret |
975 | iret |
963 | .timergo: |
976 | .timergo: |
964 | push 0 |
977 | push 0 |
965 | pop es |
978 | pop es |
966 | mov eax, [.oldtimer] |
979 | mov eax, [.oldtimer] |
967 | mov [es:8*4], eax |
980 | mov [es:8*4], eax |
968 | mov sp, 0EC00h |
981 | mov sp, 0EC00h |
969 | .continue: |
982 | .continue: |
970 | sti |
983 | sti |
971 | _setcursor 6,0 |
984 | _setcursor 6,0 |
972 | mov si, space_msg |
985 | mov si, space_msg |
973 | call printplain |
986 | call printplain |
974 | call printplain |
987 | call printplain |
975 | _setcursor 6,0 |
988 | _setcursor 6,0 |
976 | mov si, loading_msg |
989 | mov si, loading_msg |
977 | call print |
990 | call print |
978 | _setcursor 15,0 |
991 | _setcursor 15,0 |
979 | if ~ defined extended_primary_loader |
992 | if ~ defined extended_primary_loader |
980 | cmp [.bSettingsChanged], 0 |
993 | cmp [.bSettingsChanged], 0 |
981 | jz .load |
994 | jz .load |
982 | cmp [.loader_block], -1 |
995 | cmp [.loader_block], -1 |
983 | jz .load |
996 | jz .load |
984 | les bx, [.loader_block] |
997 | les bx, [.loader_block] |
985 | mov eax, [es:bx+3] |
998 | mov eax, [es:bx+3] |
986 | push ds |
999 | push ds |
987 | pop es |
1000 | pop es |
988 | test eax, eax |
1001 | test eax, eax |
989 | jz .load |
1002 | jz .load |
990 | push eax |
1003 | push eax |
991 | mov si, save_quest |
1004 | mov si, save_quest |
992 | call print |
1005 | call print |
993 | .waityn: |
1006 | .waityn: |
994 | mov ah, 0 |
1007 | mov ah, 0 |
995 | int 16h |
1008 | int 16h |
996 | or al, 20h |
1009 | or al, 20h |
997 | cmp al, 'n' |
1010 | cmp al, 'n' |
998 | jz .loadc |
1011 | jz .loadc |
999 | if lang eq sp |
1012 | if lang eq sp |
1000 | cmp al, 's' |
1013 | cmp al, 's' |
1001 | else |
1014 | else |
1002 | cmp al, 'y' |
1015 | cmp al, 'y' |
1003 | end if |
1016 | end if |
1004 | jnz .waityn |
1017 | jnz .waityn |
1005 | call putchar |
1018 | call putchar |
1006 | mov byte [space_msg+80], 186 |
1019 | mov byte [space_msg+80], 186 |
1007 | 1020 | ||
1008 | pop eax |
1021 | pop eax |
1009 | push cs |
1022 | push cs |
1010 | push .cont |
1023 | push .cont |
1011 | push eax |
1024 | push eax |
1012 | retf ;call back |
1025 | retf ;call back |
1013 | .loadc: |
1026 | .loadc: |
1014 | pop eax |
1027 | pop eax |
1015 | .cont: |
1028 | .cont: |
1016 | push cs |
1029 | push cs |
1017 | pop ds |
1030 | pop ds |
1018 | mov si, space_msg |
1031 | mov si, space_msg |
1019 | mov byte [si+80], 0 |
1032 | mov byte [si+80], 0 |
1020 | _setcursor 15,0 |
1033 | _setcursor 15,0 |
1021 | call printplain |
1034 | call printplain |
1022 | _setcursor 15,0 |
1035 | _setcursor 15,0 |
1023 | .load: |
1036 | .load: |
1024 | end if |
1037 | end if |
1025 | ; \end{diamond}[02.12.2005] |
1038 | ; \end{diamond}[02.12.2005] |
1026 | 1039 | ||
1027 | ; ASK GRAPHICS MODE |
1040 | ; ASK GRAPHICS MODE |
1028 | 1041 | ||
1029 | call set_vmode |
1042 | call set_vmode |
1030 | 1043 | ||
1031 | ; GRAPHICS ACCELERATION |
1044 | ; GRAPHICS ACCELERATION |
1032 | ; force yes |
1045 | ; force yes |
1033 | mov [es:BOOT_MTRR], byte 1 |
1046 | mov [es:BOOT_MTRR], byte 1 |
1034 | 1047 | ||
1035 | ; DMA ACCESS TO HD |
1048 | ; DMA ACCESS TO HD |
1036 | 1049 | ||
1037 | mov al, [preboot_dma] |
1050 | mov al, [preboot_dma] |
1038 | mov [es:BOOT_DMA], al |
1051 | mov [es:BOOT_DMA], al |
1039 | 1052 | ||
1040 | ;; VRR_M USE |
1053 | ;; VRR_M USE |
1041 | ; |
1054 | ; |
1042 | ; mov al,[preboot_vrrm] |
1055 | ; mov al,[preboot_vrrm] |
1043 | ; mov [es:0x9030], al |
1056 | ; mov [es:0x9030], al |
1044 | 1057 | ||
1045 | ; BOOT DEVICE |
1058 | ; BOOT DEVICE |
1046 | 1059 | ||
1047 | mov al, [preboot_device] |
1060 | mov al, [preboot_device] |
1048 | dec al |
1061 | dec al |
1049 | mov [boot_dev], al |
1062 | mov [boot_dev], al |
1050 | 1063 | ||
1051 | ; GET MEMORY MAP |
1064 | ; GET MEMORY MAP |
1052 | include '../detect/biosmem.inc' |
1065 | include '../detect/biosmem.inc' |
1053 | 1066 | ||
1054 | ; READ DISKETTE TO MEMORY |
1067 | ; READ DISKETTE TO MEMORY |
1055 | 1068 | ||
1056 | cmp [boot_dev], 0 |
1069 | cmp [boot_dev], 0 |
1057 | jne no_sys_on_floppy |
1070 | jne no_sys_on_floppy |
1058 | mov si, diskload |
1071 | mov si, diskload |
1059 | call print |
1072 | call print |
1060 | xor ax, ax ; reset drive |
1073 | xor ax, ax ; reset drive |
1061 | xor dx, dx |
1074 | xor dx, dx |
1062 | int 0x13 |
1075 | int 0x13 |
1063 | ; do we boot from CD-ROM? |
1076 | ; do we boot from CD-ROM? |
1064 | mov ah, 41h |
1077 | mov ah, 41h |
1065 | mov bx, 55AAh |
1078 | mov bx, 55AAh |
1066 | xor dx, dx |
1079 | xor dx, dx |
1067 | int 0x13 |
1080 | int 0x13 |
1068 | jc .nocd |
1081 | jc .nocd |
1069 | cmp bx, 0AA55h |
1082 | cmp bx, 0AA55h |
1070 | jnz .nocd |
1083 | jnz .nocd |
1071 | mov ah, 48h |
1084 | mov ah, 48h |
1072 | push ds |
1085 | push ds |
1073 | push es |
1086 | push es |
1074 | pop ds |
1087 | pop ds |
1075 | mov si, 0xa000 |
1088 | mov si, 0xa000 |
1076 | mov word [si], 30 |
1089 | mov word [si], 30 |
1077 | int 0x13 |
1090 | int 0x13 |
1078 | pop ds |
1091 | pop ds |
1079 | jc .nocd |
1092 | jc .nocd |
1080 | push ds |
1093 | push ds |
1081 | lds si, [es:si+26] |
1094 | lds si, [es:si+26] |
1082 | test byte [ds:si+10], 40h |
1095 | test byte [ds:si+10], 40h |
1083 | pop ds |
1096 | pop ds |
1084 | jz .nocd |
1097 | jz .nocd |
1085 | ; yes - read all floppy by 18 sectors |
1098 | ; yes - read all floppy by 18 sectors |
1086 | 1099 | ||
1087 | ; TODO: !!!! read only first sector and set variables !!!!! |
1100 | ; TODO: !!!! read only first sector and set variables !!!!! |
1088 | ; ... |
1101 | ; ... |
1089 | ; TODO: !!! then read flippy image track by track |
1102 | ; TODO: !!! then read flippy image track by track |
1090 | 1103 | ||
1091 | mov cx, 0x0001 ; startcyl,startsector |
1104 | mov cx, 0x0001 ; startcyl,startsector |
1092 | .a1: |
1105 | .a1: |
1093 | push cx dx |
1106 | push cx dx |
1094 | mov al, 18 |
1107 | mov al, 18 |
1095 | mov bx, 0xa000 |
1108 | mov bx, 0xa000 |
1096 | call boot_read_floppy |
1109 | call boot_read_floppy |
1097 | mov si, movedesc |
1110 | mov si, movedesc |
1098 | push es |
1111 | push es |
1099 | push ds |
1112 | push ds |
1100 | pop es |
1113 | pop es |
1101 | mov cx, 256*18 |
1114 | mov cx, 256*18 |
1102 | mov ah, 0x87 |
1115 | mov ah, 0x87 |
1103 | int 0x15 |
1116 | int 0x15 |
1104 | pop es |
1117 | pop es |
1105 | pop dx cx |
1118 | pop dx cx |
1106 | test ah, ah |
1119 | test ah, ah |
1107 | jnz sayerr_floppy |
1120 | jnz sayerr_floppy |
1108 | add dword [si+8*3+2], 512*18 |
1121 | add dword [si+8*3+2], 512*18 |
1109 | inc dh |
1122 | inc dh |
1110 | cmp dh, 2 |
1123 | cmp dh, 2 |
1111 | jnz .a1 |
1124 | jnz .a1 |
1112 | mov dh, 0 |
1125 | mov dh, 0 |
1113 | inc ch |
1126 | inc ch |
1114 | cmp ch, 80 |
1127 | cmp ch, 80 |
1115 | jae ok_sys_on_floppy |
1128 | jae ok_sys_on_floppy |
1116 | pusha |
1129 | pusha |
1117 | mov al, ch |
1130 | mov al, ch |
1118 | shr ch, 2 |
1131 | shr ch, 2 |
1119 | add al, ch |
1132 | add al, ch |
1120 | aam |
1133 | aam |
1121 | xchg al, ah |
1134 | xchg al, ah |
1122 | add ax, '00' |
1135 | add ax, '00' |
1123 | mov si, pros |
1136 | mov si, pros |
1124 | mov [si], ax |
1137 | mov [si], ax |
1125 | call printplain |
1138 | call printplain |
1126 | popa |
1139 | popa |
1127 | jmp .a1 |
1140 | jmp .a1 |
1128 | .nocd: |
1141 | .nocd: |
1129 | ; no - read only used sectors from floppy |
1142 | ; no - read only used sectors from floppy |
1130 | ; now load floppy image to memory |
1143 | ; now load floppy image to memory |
1131 | ; at first load boot sector and first FAT table |
1144 | ; at first load boot sector and first FAT table |
1132 | 1145 | ||
1133 | ; read only first sector and fill variables |
1146 | ; read only first sector and fill variables |
1134 | mov cx, 0x0001 ; first logical sector |
1147 | mov cx, 0x0001 ; first logical sector |
1135 | xor dx, dx ; head = 0, drive = 0 (a:) |
1148 | xor dx, dx ; head = 0, drive = 0 (a:) |
1136 | mov al, 1 ; read one sector |
1149 | mov al, 1 ; read one sector |
1137 | mov bx, 0xB000 ; es:bx -> data area |
1150 | mov bx, 0xB000 ; es:bx -> data area |
1138 | call boot_read_floppy |
1151 | call boot_read_floppy |
1139 | ; fill the necessary parameters to work with a floppy |
1152 | ; fill the necessary parameters to work with a floppy |
1140 | mov ax, word [es:bx+24] |
1153 | mov ax, word [es:bx+24] |
1141 | mov word [BPB_SecPerTrk], ax |
1154 | mov word [BPB_SecPerTrk], ax |
1142 | mov ax, word [es:bx+26] |
1155 | mov ax, word [es:bx+26] |
1143 | mov word [BPB_NumHeads], ax |
1156 | mov word [BPB_NumHeads], ax |
1144 | mov ax, word [es:bx+17] |
1157 | mov ax, word [es:bx+17] |
1145 | mov word [BPB_RootEntCnt], ax |
1158 | mov word [BPB_RootEntCnt], ax |
1146 | mov ax, word [es:bx+14] |
1159 | mov ax, word [es:bx+14] |
1147 | mov word [BPB_RsvdSecCnt], ax |
1160 | mov word [BPB_RsvdSecCnt], ax |
1148 | mov ax, word [es:bx+19] |
1161 | mov ax, word [es:bx+19] |
1149 | mov word [BPB_TotSec16], ax |
1162 | mov word [BPB_TotSec16], ax |
1150 | mov al, byte [es:bx+13] |
1163 | mov al, byte [es:bx+13] |
1151 | mov byte [BPB_SecPerClus], al |
1164 | mov byte [BPB_SecPerClus], al |
1152 | mov al, byte [es:bx+16] |
1165 | mov al, byte [es:bx+16] |
1153 | mov byte [BPB_NumFATs], al |
1166 | mov byte [BPB_NumFATs], al |
1154 | ; |
1167 | ; |
1155 | mov ax, word [es:bx+22] |
1168 | mov ax, word [es:bx+22] |
1156 | mov word [BPB_FATSz16], ax |
1169 | mov word [BPB_FATSz16], ax |
1157 | mov cx, word [es:bx+11] |
1170 | mov cx, word [es:bx+11] |
1158 | mov word [BPB_BytsPerSec], cx |
1171 | mov word [BPB_BytsPerSec], cx |
1159 | 1172 | ||
1160 | ; count of clusters in FAT12 ((size_of_FAT*2)/3) |
1173 | ; count of clusters in FAT12 ((size_of_FAT*2)/3) |
1161 | ; mov ax, word [BPB_FATSz16] |
1174 | ; mov ax, word [BPB_FATSz16] |
1162 | ; mov cx, word [BPB_BytsPerSec] |
1175 | ; mov cx, word [BPB_BytsPerSec] |
1163 | ;end |
1176 | ;end |
1164 | xor dx, dx |
1177 | xor dx, dx |
1165 | mul cx |
1178 | mul cx |
1166 | shl ax, 1 |
1179 | shl ax, 1 |
1167 | mov cx, 3 |
1180 | mov cx, 3 |
1168 | div cx ; now ax - number of clusters in FAT12 |
1181 | div cx ; now ax - number of clusters in FAT12 |
1169 | mov word [end_of_FAT], ax |
1182 | mov word [end_of_FAT], ax |
1170 | 1183 | ||
1171 | ; load first FAT table |
1184 | ; load first FAT table |
1172 | mov cx, 0x0002 ; startcyl,startsector ; TODO!!!!! |
1185 | mov cx, 0x0002 ; startcyl,startsector ; TODO!!!!! |
1173 | xor dx, dx ; starthead,drive |
1186 | xor dx, dx ; starthead,drive |
1174 | mov al, byte [BPB_FATSz16] ; no of sectors to read |
1187 | mov al, byte [BPB_FATSz16] ; no of sectors to read |
1175 | add bx, word [BPB_BytsPerSec] ; es:bx -> data area |
1188 | add bx, word [BPB_BytsPerSec] ; es:bx -> data area |
1176 | call boot_read_floppy |
1189 | call boot_read_floppy |
1177 | mov bx, 0xB000 |
1190 | mov bx, 0xB000 |
1178 | 1191 | ||
1179 | ; and copy them to extended memory |
1192 | ; and copy them to extended memory |
1180 | mov si, movedesc |
1193 | mov si, movedesc |
1181 | mov [si+8*2+3], bh ; from |
1194 | mov [si+8*2+3], bh ; from |
1182 | 1195 | ||
1183 | mov ax, word [BPB_BytsPerSec] |
1196 | mov ax, word [BPB_BytsPerSec] |
1184 | shr ax, 1 ; words per sector |
1197 | shr ax, 1 ; words per sector |
1185 | mov cx, word [BPB_RsvdSecCnt] |
1198 | mov cx, word [BPB_RsvdSecCnt] |
1186 | add cx, word [BPB_FATSz16] |
1199 | add cx, word [BPB_FATSz16] |
1187 | mul cx |
1200 | mul cx |
1188 | push ax ; save to stack count of words in boot+FAT |
1201 | push ax ; save to stack count of words in boot+FAT |
1189 | xchg ax, cx |
1202 | xchg ax, cx |
1190 | 1203 | ||
1191 | push es |
1204 | push es |
1192 | push ds |
1205 | push ds |
1193 | pop es |
1206 | pop es |
1194 | mov ah, 0x87 |
1207 | mov ah, 0x87 |
1195 | int 0x15 |
1208 | int 0x15 |
1196 | pop es |
1209 | pop es |
1197 | test ah, ah |
1210 | test ah, ah |
1198 | jz @f |
1211 | jz @f |
1199 | sayerr_floppy: |
1212 | sayerr_floppy: |
1200 | mov dx, 0x3f2 |
1213 | mov dx, 0x3f2 |
1201 | mov al, 0 |
1214 | mov al, 0 |
1202 | out dx, al |
1215 | out dx, al |
1203 | sayerr_memmove: |
1216 | sayerr_memmove: |
1204 | mov si, memmovefailed |
1217 | mov si, memmovefailed |
1205 | jmp sayerr_plain |
1218 | jmp sayerr_plain |
1206 | @@: |
1219 | @@: |
1207 | pop ax ; restore from stack count of words in boot+FAT |
1220 | pop ax ; restore from stack count of words in boot+FAT |
1208 | shl ax, 1 ; make bytes count from count of words |
1221 | shl ax, 1 ; make bytes count from count of words |
1209 | and eax, 0ffffh |
1222 | and eax, 0ffffh |
1210 | add dword [si+8*3+2], eax |
1223 | add dword [si+8*3+2], eax |
1211 | 1224 | ||
1212 | ; copy first FAT to second copy |
1225 | ; copy first FAT to second copy |
1213 | ; TODO: BPB_NumFATs !!!!! |
1226 | ; TODO: BPB_NumFATs !!!!! |
1214 | add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!! |
1227 | add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!! |
1215 | mov byte [si+8*2+3], bh ; bx - begin of FAT |
1228 | mov byte [si+8*2+3], bh ; bx - begin of FAT |
1216 | 1229 | ||
1217 | mov ax, word [BPB_BytsPerSec] |
1230 | mov ax, word [BPB_BytsPerSec] |
1218 | shr ax, 1 ; words per sector |
1231 | shr ax, 1 ; words per sector |
1219 | mov cx, word [BPB_FATSz16] |
1232 | mov cx, word [BPB_FATSz16] |
1220 | mul cx |
1233 | mul cx |
1221 | mov cx, ax ; cx - count of words in FAT |
1234 | mov cx, ax ; cx - count of words in FAT |
1222 | 1235 | ||
1223 | push es |
1236 | push es |
1224 | push ds |
1237 | push ds |
1225 | pop es |
1238 | pop es |
1226 | mov ah, 0x87 |
1239 | mov ah, 0x87 |
1227 | int 0x15 |
1240 | int 0x15 |
1228 | pop es |
1241 | pop es |
1229 | test ah, ah |
1242 | test ah, ah |
1230 | jnz sayerr_floppy |
1243 | jnz sayerr_floppy |
1231 | 1244 | ||
1232 | mov ax, cx |
1245 | mov ax, cx |
1233 | shl ax, 1 |
1246 | shl ax, 1 |
1234 | and eax, 0ffffh ; ax - count of bytes in FAT |
1247 | and eax, 0ffffh ; ax - count of bytes in FAT |
1235 | add dword [si+8*3+2], eax |
1248 | add dword [si+8*3+2], eax |
1236 | 1249 | ||
1237 | ; reading RootDir |
1250 | ; reading RootDir |
1238 | ; TODO: BPB_NumFATs |
1251 | ; TODO: BPB_NumFATs |
1239 | add bx, ax |
1252 | add bx, ax |
1240 | add bx, 100h |
1253 | add bx, 100h |
1241 | and bx, 0ff00h ; bx - place in buffer to write RootDir |
1254 | and bx, 0ff00h ; bx - place in buffer to write RootDir |
1242 | push bx |
1255 | push bx |
1243 | 1256 | ||
1244 | mov bx, word [BPB_BytsPerSec] |
1257 | mov bx, word [BPB_BytsPerSec] |
1245 | shr bx, 5 ; divide bx by 32 |
1258 | shr bx, 5 ; divide bx by 32 |
1246 | mov ax, word [BPB_RootEntCnt] |
1259 | mov ax, word [BPB_RootEntCnt] |
1247 | xor dx, dx |
1260 | xor dx, dx |
1248 | div bx |
1261 | div bx |
1249 | push ax ; ax - count of RootDir sectors |
1262 | push ax ; ax - count of RootDir sectors |
1250 | 1263 | ||
1251 | mov ax, word [BPB_FATSz16] |
1264 | mov ax, word [BPB_FATSz16] |
1252 | xor cx, cx |
1265 | xor cx, cx |
1253 | mov cl, byte [BPB_NumFATs] |
1266 | mov cl, byte [BPB_NumFATs] |
1254 | mul cx |
1267 | mul cx |
1255 | add ax, word [BPB_RsvdSecCnt] ; ax - first sector of RootDir |
1268 | add ax, word [BPB_RsvdSecCnt] ; ax - first sector of RootDir |
1256 | 1269 | ||
1257 | mov word [FirstDataSector], ax |
1270 | mov word [FirstDataSector], ax |
1258 | pop bx |
1271 | pop bx |
1259 | push bx |
1272 | push bx |
1260 | add word [FirstDataSector], bx ; Begin of data region of floppy |
1273 | add word [FirstDataSector], bx ; Begin of data region of floppy |
1261 | 1274 | ||
1262 | ; read RootDir |
1275 | ; read RootDir |
1263 | call conv_abs_to_THS |
1276 | call conv_abs_to_THS |
1264 | pop ax |
1277 | pop ax |
1265 | pop bx ; place in buffer to write |
1278 | pop bx ; place in buffer to write |
1266 | push ax |
1279 | push ax |
1267 | call boot_read_floppy ; read RootDir into buffer |
1280 | call boot_read_floppy ; read RootDir into buffer |
1268 | ; copy RootDir |
1281 | ; copy RootDir |
1269 | mov byte [si+8*2+3], bh ; from buffer |
1282 | mov byte [si+8*2+3], bh ; from buffer |
1270 | pop ax ; ax = count of RootDir sectors |
1283 | pop ax ; ax = count of RootDir sectors |
1271 | mov cx, word [BPB_BytsPerSec] |
1284 | mov cx, word [BPB_BytsPerSec] |
1272 | mul cx |
1285 | mul cx |
1273 | shr ax, 1 |
1286 | shr ax, 1 |
1274 | mov cx, ax ; count of words to copy |
1287 | mov cx, ax ; count of words to copy |
1275 | push es |
1288 | push es |
1276 | push ds |
1289 | push ds |
1277 | pop es |
1290 | pop es |
1278 | mov ah, 0x87 |
1291 | mov ah, 0x87 |
1279 | int 0x15 |
1292 | int 0x15 |
1280 | pop es |
1293 | pop es |
1281 | 1294 | ||
1282 | mov ax, cx |
1295 | mov ax, cx |
1283 | shl ax, 1 |
1296 | shl ax, 1 |
1284 | and eax, 0ffffh ; ax - count of bytes in RootDir |
1297 | and eax, 0ffffh ; ax - count of bytes in RootDir |
1285 | add dword [si+8*3+2], eax ; add count of bytes copied |
1298 | add dword [si+8*3+2], eax ; add count of bytes copied |
1286 | 1299 | ||
1287 | ; Reading data clusters from floppy |
1300 | ; Reading data clusters from floppy |
1288 | mov byte [si+8*2+3], bh |
1301 | mov byte [si+8*2+3], bh |
1289 | push bx |
1302 | push bx |
1290 | 1303 | ||
1291 | mov di, 2 ; First data cluster |
1304 | mov di, 2 ; First data cluster |
1292 | .read_loop: |
1305 | .read_loop: |
1293 | mov bx, di |
1306 | mov bx, di |
1294 | shr bx, 1 ; bx+di = di*1.5 |
1307 | shr bx, 1 ; bx+di = di*1.5 |
1295 | jnc .even |
1308 | jnc .even |
1296 | test word [es:bx+di+0xB200], 0xFFF0 ; TODO: may not be 0xB200 !!! |
1309 | test word [es:bx+di+0xB200], 0xFFF0 ; TODO: may not be 0xB200 !!! |
1297 | jmp @f |
1310 | jmp @f |
1298 | .even: |
1311 | .even: |
1299 | test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!! |
1312 | test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!! |
1300 | 1313 | ||
1301 | @@: |
1314 | @@: |
1302 | jz .skip |
1315 | jz .skip |
1303 | ; read cluster di |
1316 | ; read cluster di |
1304 | ;.read: |
1317 | ;.read: |
1305 | ;conv cluster di to abs. sector ax |
1318 | ;conv cluster di to abs. sector ax |
1306 | ; ax = (N-2) * BPB_SecPerClus + FirstDataSector |
1319 | ; ax = (N-2) * BPB_SecPerClus + FirstDataSector |
1307 | mov ax, di |
1320 | mov ax, di |
1308 | sub ax, 2 |
1321 | sub ax, 2 |
1309 | xor bx, bx |
1322 | xor bx, bx |
1310 | mov bl, byte [BPB_SecPerClus] |
1323 | mov bl, byte [BPB_SecPerClus] |
1311 | mul bx |
1324 | mul bx |
1312 | add ax, word [FirstDataSector] |
1325 | add ax, word [FirstDataSector] |
1313 | call conv_abs_to_THS |
1326 | call conv_abs_to_THS |
1314 | pop bx |
1327 | pop bx |
1315 | push bx |
1328 | push bx |
1316 | mov al, byte [BPB_SecPerClus] ; number of sectors in cluster |
1329 | mov al, byte [BPB_SecPerClus] ; number of sectors in cluster |
1317 | call boot_read_floppy |
1330 | call boot_read_floppy |
1318 | push es |
1331 | push es |
1319 | push ds |
1332 | push ds |
1320 | pop es |
1333 | pop es |
1321 | pusha |
1334 | pusha |
1322 | ; |
1335 | ; |
1323 | mov ax, word [BPB_BytsPerSec] |
1336 | mov ax, word [BPB_BytsPerSec] |
1324 | xor cx, cx |
1337 | xor cx, cx |
1325 | mov cl, byte [BPB_SecPerClus] |
1338 | mov cl, byte [BPB_SecPerClus] |
1326 | mul cx |
1339 | mul cx |
1327 | shr ax, 1 ; ax = (BPB_BytsPerSec * BPB_SecPerClus)/2 |
1340 | shr ax, 1 ; ax = (BPB_BytsPerSec * BPB_SecPerClus)/2 |
1328 | mov cx, ax ; number of words to copy (count words in cluster) |
1341 | mov cx, ax ; number of words to copy (count words in cluster) |
1329 | ; |
1342 | ; |
1330 | mov ah, 0x87 |
1343 | mov ah, 0x87 |
1331 | int 0x15 ; copy data |
1344 | int 0x15 ; copy data |
1332 | test ah, ah |
1345 | test ah, ah |
1333 | popa |
1346 | popa |
1334 | pop es |
1347 | pop es |
1335 | jnz sayerr_floppy |
1348 | jnz sayerr_floppy |
1336 | ; skip cluster di |
1349 | ; skip cluster di |
1337 | .skip: |
1350 | .skip: |
1338 | mov ax, word [BPB_BytsPerSec] |
1351 | mov ax, word [BPB_BytsPerSec] |
1339 | xor cx, cx |
1352 | xor cx, cx |
1340 | mov cl, byte [BPB_SecPerClus] |
1353 | mov cl, byte [BPB_SecPerClus] |
1341 | mul cx |
1354 | mul cx |
1342 | and eax, 0ffffh ; ax - count of bytes in cluster |
1355 | and eax, 0ffffh ; ax - count of bytes in cluster |
1343 | add dword [si+8*3+2], eax |
1356 | add dword [si+8*3+2], eax |
1344 | 1357 | ||
1345 | mov ax, word [end_of_FAT] ; max cluster number |
1358 | mov ax, word [end_of_FAT] ; max cluster number |
1346 | pusha |
1359 | pusha |
1347 | ; draw percentage |
1360 | ; draw percentage |
1348 | ; total clusters: ax |
1361 | ; total clusters: ax |
1349 | ; read clusters: di |
1362 | ; read clusters: di |
1350 | xchg ax, di |
1363 | xchg ax, di |
1351 | mov cx, 100 |
1364 | mov cx, 100 |
1352 | mul cx |
1365 | mul cx |
1353 | div di |
1366 | div di |
1354 | aam |
1367 | aam |
1355 | xchg al, ah |
1368 | xchg al, ah |
1356 | add ax, '00' |
1369 | add ax, '00' |
1357 | mov si, pros |
1370 | mov si, pros |
1358 | cmp [si], ax |
1371 | cmp [si], ax |
1359 | jz @f |
1372 | jz @f |
1360 | mov [si], ax |
1373 | mov [si], ax |
1361 | call printplain |
1374 | call printplain |
1362 | @@: |
1375 | @@: |
1363 | popa |
1376 | popa |
1364 | inc di |
1377 | inc di |
1365 | cmp di, word [end_of_FAT] ; max number of cluster |
1378 | cmp di, word [end_of_FAT] ; max number of cluster |
1366 | jnz .read_loop |
1379 | jnz .read_loop |
1367 | pop bx ; clear stack |
1380 | pop bx ; clear stack |
1368 | 1381 | ||
1369 | ok_sys_on_floppy: |
1382 | ok_sys_on_floppy: |
1370 | mov si, backspace2 |
1383 | mov si, backspace2 |
1371 | call printplain |
1384 | call printplain |
1372 | mov si, okt |
1385 | mov si, okt |
1373 | call printplain |
1386 | call printplain |
1374 | no_sys_on_floppy: |
1387 | no_sys_on_floppy: |
1375 | xor ax, ax ; reset drive |
1388 | xor ax, ax ; reset drive |
1376 | xor dx, dx |
1389 | xor dx, dx |
1377 | int 0x13 |
1390 | int 0x13 |
1378 | mov dx, 0x3f2 ; floppy motor off |
1391 | mov dx, 0x3f2 ; floppy motor off |
1379 | mov al, 0 |
1392 | mov al, 0 |
1380 | out dx, al |
1393 | out dx, al |
1381 | 1394 | ||
1382 | if defined extended_primary_loader |
1395 | if defined extended_primary_loader |
1383 | cmp [boot_dev], 1 |
1396 | cmp [boot_dev], 1 |
1384 | jne no_sys_from_primary |
1397 | jne no_sys_from_primary |
1385 | ; load kolibri.img using callback from primary loader |
1398 | ; load kolibri.img using callback from primary loader |
1386 | and word [movedesc + 24 + 2], 0 |
1399 | and word [movedesc + 24 + 2], 0 |
1387 | mov byte [movedesc + 24 + 4], 10h |
1400 | mov byte [movedesc + 24 + 4], 10h |
1388 | ; read in blocks of 64K until file is fully loaded |
1401 | ; read in blocks of 64K until file is fully loaded |
1389 | mov ax, 1 |
1402 | mov ax, 1 |
1390 | .repeat: |
1403 | .repeat: |
1391 | mov di, image_file_struct |
1404 | mov di, image_file_struct |
1392 | call [bootcallback] |
1405 | call [bootcallback] |
1393 | push cs |
1406 | push cs |
1394 | pop ds |
1407 | pop ds |
1395 | push cs |
1408 | push cs |
1396 | pop es |
1409 | pop es |
1397 | cmp bx, 1 |
1410 | cmp bx, 1 |
1398 | ja sayerr_badsect |
1411 | ja sayerr_badsect |
1399 | push bx |
1412 | push bx |
1400 | mov si, movedesc |
1413 | mov si, movedesc |
1401 | and word [si + 16 + 2], 0 |
1414 | and word [si + 16 + 2], 0 |
1402 | mov byte [si + 16 + 4], 4 |
1415 | mov byte [si + 16 + 4], 4 |
1403 | mov ah, 87h |
1416 | mov ah, 87h |
1404 | mov cx, 8000h |
1417 | mov cx, 8000h |
1405 | int 15h |
1418 | int 15h |
1406 | pop bx |
1419 | pop bx |
1407 | test ah, ah |
1420 | test ah, ah |
1408 | jnz sayerr_memmove |
1421 | jnz sayerr_memmove |
1409 | inc byte [si + 24 + 4] |
1422 | inc byte [si + 24 + 4] |
1410 | test bx, bx |
1423 | test bx, bx |
1411 | jz no_sys_from_primary |
1424 | jz no_sys_from_primary |
1412 | mov ax, 2 |
1425 | mov ax, 2 |
1413 | jmp .repeat |
1426 | jmp .repeat |
1414 | no_sys_from_primary: |
1427 | no_sys_from_primary: |
1415 | end if |
1428 | end if |
1416 | 1429 | ||
1417 | ; SET GRAPHICS |
1430 | ; SET GRAPHICS |
1418 | 1431 | ||
1419 | xor ax, ax |
1432 | xor ax, ax |
1420 | mov es, ax |
1433 | mov es, ax |
1421 | 1434 | ||
1422 | mov ax, [es:BOOT_VESA_MODE] ; vga & 320x200 |
1435 | mov ax, [es:BOOT_VESA_MODE] ; vga & 320x200 |
1423 | mov bx, ax |
1436 | mov bx, ax |
1424 | cmp ax, 0x13 |
1437 | cmp ax, 0x13 |
1425 | je setgr |
1438 | je setgr |
1426 | cmp ax, 0x12 |
1439 | cmp ax, 0x12 |
1427 | je setgr |
1440 | je setgr |
1428 | mov ax, 0x4f02 ; Vesa |
1441 | mov ax, 0x4f02 ; Vesa |
1429 | setgr: |
1442 | setgr: |
1430 | int 0x10 |
1443 | int 0x10 |
1431 | test ah, ah |
1444 | test ah, ah |
1432 | mov si, fatalsel |
1445 | mov si, fatalsel |
1433 | jnz v_mode_error |
1446 | jnz v_mode_error |
1434 | ; set mode 0x12 graphics registers: |
1447 | ; set mode 0x12 graphics registers: |
1435 | cmp bx, 0x12 |
1448 | cmp bx, 0x12 |
1436 | jne gmok2 |
1449 | jne gmok2 |
1437 | 1450 | ||
1438 | mov al, 0x05 |
1451 | mov al, 0x05 |
1439 | mov dx, 0x03ce |
1452 | mov dx, 0x03ce |
1440 | push dx |
1453 | push dx |
1441 | out dx, al ; select GDC mode register |
1454 | out dx, al ; select GDC mode register |
1442 | mov al, 0x02 |
1455 | mov al, 0x02 |
1443 | inc dx |
1456 | inc dx |
1444 | out dx, al ; set write mode 2 |
1457 | out dx, al ; set write mode 2 |
1445 | 1458 | ||
1446 | mov al, 0x02 |
1459 | mov al, 0x02 |
1447 | mov dx, 0x03c4 |
1460 | mov dx, 0x03c4 |
1448 | out dx, al ; select VGA sequencer map mask register |
1461 | out dx, al ; select VGA sequencer map mask register |
1449 | mov al, 0x0f |
1462 | mov al, 0x0f |
1450 | inc dx |
1463 | inc dx |
1451 | out dx, al ; set mask for all planes 0-3 |
1464 | out dx, al ; set mask for all planes 0-3 |
1452 | 1465 | ||
1453 | mov al, 0x08 |
1466 | mov al, 0x08 |
1454 | pop dx |
1467 | pop dx |
1455 | out dx, al ; select GDC bit mask register |
1468 | out dx, al ; select GDC bit mask register |
1456 | ; for writes to 0x03cf |
1469 | ; for writes to 0x03cf |
1457 | gmok2: |
1470 | gmok2: |
1458 | push ds |
1471 | push ds |
1459 | pop es |
1472 | pop es |