Rev 3711 | Rev 3760 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3711 | Rev 3712 | ||
---|---|---|---|
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: 3711 $ |
14 | $Revision: 3712 $ |
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 | mov ax, 0xB103 |
409 | mov ax, 0xB103 |
409 | mov ecx, 1*10000h + 1*100h + 0x80 |
410 | mov ecx, 1*10000h + 1*100h + 0x80 |
410 | mov [es:BOOT_IDE_PI_16], cx |
411 | mov [es:BOOT_IDE_PI_16], cx |
411 | xor si, si ; device index = 0 |
412 | xor si, si ; device index = 0 |
412 | int 0x1A |
413 | int 0x1A |
413 | jnc .found_1 |
414 | jnc .found_1 ; Parallel IDE Controller |
414 | ; b) class 1, subclass 1, programming interface 0x8f |
415 | ; b) class 1, subclass 1, programming interface 0x8f |
415 | mov ax, 0xB103 |
416 | mov ax, 0xB103 |
416 | mov ecx, 1*10000h + 1*100h + 0x8f |
417 | mov ecx, 1*10000h + 1*100h + 0x8f |
417 | mov [es:BOOT_IDE_PI_16], cx |
418 | mov [es:BOOT_IDE_PI_16], cx |
418 | xor si, si ; device index = 0 |
419 | xor si, si ; device index = 0 |
419 | int 0x1A |
420 | int 0x1A |
420 | jnc .found |
421 | jnc .found |
421 | ; c) class 1, subclass 1, programming interface 0x85 |
422 | ; c) class 1, subclass 1, programming interface 0x85 |
422 | mov ax, 0xB103 |
423 | mov ax, 0xB103 |
423 | mov ecx, 1*10000h + 1*100h + 0x85 |
424 | mov ecx, 1*10000h + 1*100h + 0x85 |
424 | mov [es:BOOT_IDE_PI_16], cx |
425 | mov [es:BOOT_IDE_PI_16], cx |
425 | xor si, si ; device index = 0 |
426 | xor si, si ; device index = 0 |
426 | int 0x1A |
427 | int 0x1A |
427 | jnc .found |
428 | jnc .found |
428 | ; 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. |
|
429 | mov ax, 0xB103 |
431 | mov ax, 0xB103 |
430 | mov ecx, 1*10000h + 1*100h + 0x8A |
432 | mov ecx, 1*10000h + 1*100h + 0x8A |
431 | mov [es:BOOT_IDE_PI_16], cx |
433 | mov [es:BOOT_IDE_PI_16], cx |
432 | xor si, si ; device index = 0 |
434 | xor si, si ; device index = 0 |
433 | int 0x1A |
435 | int 0x1A |
434 | jnc .found |
436 | jnc .found_1 ; Parallel IDE Controller |
435 | 437 | ||
436 | jmp .nopci |
438 | jmp .nopci |
437 | .found_1: |
439 | .found_1: |
438 | ; get memory base BAR4 |
440 | ; get memory base BAR4 |
439 | mov ax, 0xB10A |
441 | mov ax, 0xB10A |
440 | mov di, 0x20 ; memory base is config register at 0x20 |
442 | mov di, 0x20 ; memory base is config register at 0x20 |
441 | push cx |
443 | push cx |
442 | int 0x1A |
444 | int 0x1A |
443 | jc .no_BAR4 ;.nopci |
445 | jc .no_BAR4 ;.nopci |
444 | and cx, 0xFFF0 ; clear address decode type |
446 | and cx, 0xFFF0 ; clear address decode type |
445 | mov [es:BOOT_IDE_BASE_ADDR], cx |
447 | mov [es:BOOT_IDE_BASE_ADDR], cx |
446 | .no_BAR4: |
448 | .no_BAR4: |
447 | pop cx |
449 | pop cx |
448 | .found: |
450 | .found: |
449 | ; get memory base BAR0 |
451 | ; get memory base BAR0 |
450 | mov ax, 0xB10A |
452 | mov ax, 0xB10A |
451 | mov di, 0x10 ; memory base is config register at 0x20 |
453 | mov di, 0x10 ; memory base is config register at 0x10 |
452 | push cx |
454 | push cx |
453 | int 0x1A |
455 | int 0x1A |
454 | jc .no_BAR0 ;.nopci |
456 | jc .no_BAR0 ;.nopci |
455 | mov [es:BOOT_IDE_BAR0_16], cx |
457 | mov [es:BOOT_IDE_BAR0_16], cx |
456 | .no_BAR0: |
458 | .no_BAR0: |
457 | pop cx |
459 | pop cx |
458 | ; get memory base BAR1 |
460 | ; get memory base BAR1 |
459 | mov ax, 0xB10A |
461 | mov ax, 0xB10A |
460 | mov di, 0x14 ; memory base is config register at 0x20 |
462 | mov di, 0x14 ; memory base is config register at 0x14 |
461 | push cx |
463 | push cx |
462 | int 0x1A |
464 | int 0x1A |
463 | jc .no_BAR1 ;.nopci |
465 | jc .no_BAR1 ;.nopci |
464 | mov [es:BOOT_IDE_BAR1_16], cx |
466 | mov [es:BOOT_IDE_BAR1_16], cx |
465 | .no_BAR1: |
467 | .no_BAR1: |
466 | pop cx |
468 | pop cx |
467 | ; get memory base BAR2 |
469 | ; get memory base BAR2 |
468 | mov ax, 0xB10A |
470 | mov ax, 0xB10A |
469 | mov di, 0x18 ; memory base is config register at 0x20 |
471 | mov di, 0x18 ; memory base is config register at 0x18 |
470 | push cx |
472 | push cx |
471 | int 0x1A |
473 | int 0x1A |
472 | jc .no_BAR2 ;.nopci |
474 | jc .no_BAR2 ;.nopci |
473 | mov [es:BOOT_IDE_BAR2_16], cx |
475 | mov [es:BOOT_IDE_BAR2_16], cx |
474 | .no_BAR2: |
476 | .no_BAR2: |
475 | pop cx |
477 | pop cx |
476 | ; get memory base BAR3 |
478 | ; get memory base BAR3 |
477 | mov ax, 0xB10A |
479 | mov ax, 0xB10A |
478 | mov di, 0x1C ; memory base is config register at 0x20 |
480 | mov di, 0x1C ; memory base is config register at 0x1c |
479 | push cx |
481 | push cx |
480 | int 0x1A |
482 | int 0x1A |
481 | jc .no_BAR3 ;.nopci |
483 | jc .no_BAR3 ;.nopci |
482 | mov [es:BOOT_IDE_BAR3_16], cx |
484 | mov [es:BOOT_IDE_BAR3_16], cx |
483 | .no_BAR3: |
485 | .no_BAR3: |
484 | pop cx |
486 | pop cx |
485 | .nopci: |
487 | .nopci: |
486 | ; \end{Mario79} |
488 | ; \end{Mario79} |
487 | 489 | ||
488 | mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
490 | mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
489 | out 0x60, al |
491 | out 0x60, al |
490 | xor cx, cx |
492 | xor cx, cx |
491 | wait_loop: ; variant 2 |
493 | wait_loop: ; variant 2 |
492 | ; reading state of port of 8042 controller |
494 | ; reading state of port of 8042 controller |
493 | in al, 64h |
495 | in al, 64h |
494 | and al, 00000010b ; ready flag |
496 | and al, 00000010b ; ready flag |
495 | ; wait until 8042 controller is ready |
497 | ; wait until 8042 controller is ready |
496 | loopnz wait_loop |
498 | loopnz wait_loop |
497 | 499 | ||
498 | ;;;/diamond today 5.02.2008 |
500 | ;;;/diamond today 5.02.2008 |
499 | ; set keyboard typematic rate & delay |
501 | ; set keyboard typematic rate & delay |
500 | mov al, 0xf3 |
502 | mov al, 0xf3 |
501 | out 0x60, al |
503 | out 0x60, al |
502 | xor cx, cx |
504 | xor cx, cx |
503 | @@: |
505 | @@: |
504 | in al, 64h |
506 | in al, 64h |
505 | test al, 2 |
507 | test al, 2 |
506 | loopnz @b |
508 | loopnz @b |
507 | mov al, 0 |
509 | mov al, 0 |
508 | out 0x60, al |
510 | out 0x60, al |
509 | xor cx, cx |
511 | xor cx, cx |
510 | @@: |
512 | @@: |
511 | in al, 64h |
513 | in al, 64h |
512 | test al, 2 |
514 | test al, 2 |
513 | loopnz @b |
515 | loopnz @b |
514 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
516 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
515 | ; --------------- APM --------------------- |
517 | ; --------------- APM --------------------- |
516 | and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found) |
518 | and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found) |
517 | mov ax, 0x5300 |
519 | mov ax, 0x5300 |
518 | xor bx, bx |
520 | xor bx, bx |
519 | int 0x15 |
521 | int 0x15 |
520 | jc apm_end ; APM not found |
522 | jc apm_end ; APM not found |
521 | test cx, 2 |
523 | test cx, 2 |
522 | jz apm_end ; APM 32-bit protected-mode interface not supported |
524 | jz apm_end ; APM 32-bit protected-mode interface not supported |
523 | mov [es:BOOT_APM_VERSION], ax ; Save APM Version |
525 | mov [es:BOOT_APM_VERSION], ax ; Save APM Version |
524 | mov [es:BOOT_APM_FLAGS], cx ; Save APM flags |
526 | mov [es:BOOT_APM_FLAGS], cx ; Save APM flags |
525 | 527 | ||
526 | ; Write APM ver ---- |
528 | ; Write APM ver ---- |
527 | and ax, 0xf0f |
529 | and ax, 0xf0f |
528 | add ax, '00' |
530 | add ax, '00' |
529 | mov si, msg_apm |
531 | mov si, msg_apm |
530 | mov [si + 5], ah |
532 | mov [si + 5], ah |
531 | mov [si + 7], al |
533 | mov [si + 7], al |
532 | _setcursor 0, 3 |
534 | _setcursor 0, 3 |
533 | call printplain |
535 | call printplain |
534 | ; ------------------ |
536 | ; ------------------ |
535 | 537 | ||
536 | mov ax, 0x5304 ; Disconnect interface |
538 | mov ax, 0x5304 ; Disconnect interface |
537 | xor bx, bx |
539 | xor bx, bx |
538 | int 0x15 |
540 | int 0x15 |
539 | mov ax, 0x5303 ; Connect 32 bit mode interface |
541 | mov ax, 0x5303 ; Connect 32 bit mode interface |
540 | xor bx, bx |
542 | xor bx, bx |
541 | int 0x15 |
543 | int 0x15 |
542 | 544 | ||
543 | mov [es:BOOT_APM_ENTRY], ebx |
545 | mov [es:BOOT_APM_ENTRY], ebx |
544 | mov [es:BOOT_APM_CODE_32], ax |
546 | mov [es:BOOT_APM_CODE_32], ax |
545 | mov [es:BOOT_APM_CODE_16], cx |
547 | mov [es:BOOT_APM_CODE_16], cx |
546 | mov [es:BOOT_APM_DATA_16], dx |
548 | mov [es:BOOT_APM_DATA_16], dx |
547 | 549 | ||
548 | apm_end: |
550 | apm_end: |
549 | _setcursor d80x25_top_num, 0 |
551 | _setcursor d80x25_top_num, 0 |
550 | 552 | ||
551 | if ~ defined extended_primary_loader |
553 | if ~ defined extended_primary_loader |
552 | ;CHECK current of code |
554 | ;CHECK current of code |
553 | cmp [cfgmanager.loader_block], -1 |
555 | cmp [cfgmanager.loader_block], -1 |
554 | jz noloaderblock |
556 | jz noloaderblock |
555 | les bx, [cfgmanager.loader_block] |
557 | les bx, [cfgmanager.loader_block] |
556 | cmp byte [es:bx], 1 |
558 | cmp byte [es:bx], 1 |
557 | mov si, loader_block_error |
559 | mov si, loader_block_error |
558 | jnz sayerr |
560 | jnz sayerr |
559 | push 0 |
561 | push 0 |
560 | pop es |
562 | pop es |
561 | end if |
563 | end if |
562 | 564 | ||
563 | noloaderblock: |
565 | noloaderblock: |
564 | ; DISPLAY VESA INFORMATION |
566 | ; DISPLAY VESA INFORMATION |
565 | call print_vesa_info |
567 | call print_vesa_info |
566 | call calc_vmodes_table |
568 | call calc_vmodes_table |
567 | call check_first_parm ;check and enable cursor_pos |
569 | call check_first_parm ;check and enable cursor_pos |
568 | 570 | ||
569 | ; \begin{diamond}[30.11.2005] |
571 | ; \begin{diamond}[30.11.2005] |
570 | cfgmanager: |
572 | cfgmanager: |
571 | ; settings: |
573 | ; settings: |
572 | ; a) preboot_graph = graphical mode |
574 | ; a) preboot_graph = graphical mode |
573 | ; preboot_gprobe = probe this mode? |
575 | ; preboot_gprobe = probe this mode? |
574 | ; b) preboot_dma = use DMA access? |
576 | ; b) preboot_dma = use DMA access? |
575 | ; c) preboot_vrrm = use VRR? |
577 | ; c) preboot_vrrm = use VRR? |
576 | ; d) preboot_device = from what boot? |
578 | ; d) preboot_device = from what boot? |
577 | 579 | ||
578 | ; determine default settings |
580 | ; determine default settings |
579 | if ~ defined extended_primary_loader |
581 | if ~ defined extended_primary_loader |
580 | mov [.bSettingsChanged], 0 |
582 | mov [.bSettingsChanged], 0 |
581 | end if |
583 | end if |
582 | 584 | ||
583 | ;.preboot_gr_end: |
585 | ;.preboot_gr_end: |
584 | mov di, preboot_device |
586 | mov di, preboot_device |
585 | ; if image in memory is present and [preboot_device] is uninitialized, |
587 | ; if image in memory is present and [preboot_device] is uninitialized, |
586 | ; set it to use this preloaded image |
588 | ; set it to use this preloaded image |
587 | cmp byte [di], 0 |
589 | cmp byte [di], 0 |
588 | jnz .preboot_device_inited |
590 | jnz .preboot_device_inited |
589 | if defined extended_primary_loader |
591 | if defined extended_primary_loader |
590 | inc byte [di] |
592 | inc byte [di] |
591 | cmp byte [bootdevice], 'f' ; floppy? |
593 | cmp byte [bootdevice], 'f' ; floppy? |
592 | jz .preboot_device_inited |
594 | jz .preboot_device_inited |
593 | inc byte [di] |
595 | inc byte [di] |
594 | else |
596 | else |
595 | cmp [.loader_block], -1 |
597 | cmp [.loader_block], -1 |
596 | jz @f |
598 | jz @f |
597 | les bx, [.loader_block] |
599 | les bx, [.loader_block] |
598 | test byte [es:bx+1], 1 |
600 | test byte [es:bx+1], 1 |
599 | jz @f |
601 | jz @f |
600 | mov byte [di], 3 |
602 | mov byte [di], 3 |
601 | jmp .preboot_device_inited |
603 | jmp .preboot_device_inited |
602 | @@: |
604 | @@: |
603 | ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) |
605 | ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) |
604 | mov byte [di], 1 |
606 | mov byte [di], 1 |
605 | end if |
607 | end if |
606 | .preboot_device_inited: |
608 | .preboot_device_inited: |
607 | ; following 4 lines set variables to 1 if its current value is 0 |
609 | ; following 4 lines set variables to 1 if its current value is 0 |
608 | cmp byte [di+preboot_dma-preboot_device], 1 |
610 | cmp byte [di+preboot_dma-preboot_device], 1 |
609 | adc byte [di+preboot_dma-preboot_device], 0 |
611 | adc byte [di+preboot_dma-preboot_device], 0 |
610 | ; cmp byte [di+preboot_biosdisk-preboot_device], 1 |
612 | ; cmp byte [di+preboot_biosdisk-preboot_device], 1 |
611 | ; adc byte [di+preboot_biosdisk-preboot_device], 0 |
613 | ; adc byte [di+preboot_biosdisk-preboot_device], 0 |
612 | ;; default value for VRR is OFF |
614 | ;; default value for VRR is OFF |
613 | ; cmp byte [di+preboot_vrrm-preboot_device], 0 |
615 | ; cmp byte [di+preboot_vrrm-preboot_device], 0 |
614 | ; jnz @f |
616 | ; jnz @f |
615 | ; mov byte [di+preboot_vrrm-preboot_device], 2 |
617 | ; mov byte [di+preboot_vrrm-preboot_device], 2 |
616 | ;@@: |
618 | ;@@: |
617 | ; notify user |
619 | ; notify user |
618 | _setcursor 5,2 |
620 | _setcursor 5,2 |
619 | 621 | ||
620 | mov si, linef |
622 | mov si, linef |
621 | call printplain |
623 | call printplain |
622 | mov si, start_msg |
624 | mov si, start_msg |
623 | call print |
625 | call print |
624 | mov si, time_msg |
626 | mov si, time_msg |
625 | call print |
627 | call print |
626 | ; get start time |
628 | ; get start time |
627 | call .gettime |
629 | call .gettime |
628 | mov [.starttime], eax |
630 | mov [.starttime], eax |
629 | mov word [.timer], .newtimer |
631 | mov word [.timer], .newtimer |
630 | mov word [.timer+2], cs |
632 | mov word [.timer+2], cs |
631 | .printcfg: |
633 | .printcfg: |
632 | 634 | ||
633 | _setcursor 9,0 |
635 | _setcursor 9,0 |
634 | mov si, current_cfg_msg |
636 | mov si, current_cfg_msg |
635 | call print |
637 | call print |
636 | mov si, curvideo_msg |
638 | mov si, curvideo_msg |
637 | call print |
639 | call print |
638 | 640 | ||
639 | call draw_current_vmode |
641 | call draw_current_vmode |
640 | 642 | ||
641 | mov si, usebd_msg |
643 | mov si, usebd_msg |
642 | cmp [preboot_biosdisk], 1 |
644 | cmp [preboot_biosdisk], 1 |
643 | call .say_on_off |
645 | call .say_on_off |
644 | ; mov si, vrrm_msg |
646 | ; mov si, vrrm_msg |
645 | ; cmp [preboot_vrrm], 1 |
647 | ; cmp [preboot_vrrm], 1 |
646 | ; call .say_on_off |
648 | ; call .say_on_off |
647 | mov si, preboot_device_msg |
649 | mov si, preboot_device_msg |
648 | call print |
650 | call print |
649 | mov al, [preboot_device] |
651 | mov al, [preboot_device] |
650 | if defined extended_primary_loader |
652 | if defined extended_primary_loader |
651 | and eax, 3 |
653 | and eax, 3 |
652 | else |
654 | else |
653 | and eax, 7 |
655 | and eax, 7 |
654 | end if |
656 | end if |
655 | mov si, [preboot_device_msgs+eax*2] |
657 | mov si, [preboot_device_msgs+eax*2] |
656 | call printplain |
658 | call printplain |
657 | .show_remarks: |
659 | .show_remarks: |
658 | ; show remarks in gray color |
660 | ; show remarks in gray color |
659 | mov di, ((21-num_remarks)*80 + 2)*2 |
661 | mov di, ((21-num_remarks)*80 + 2)*2 |
660 | push 0xB800 |
662 | push 0xB800 |
661 | pop es |
663 | pop es |
662 | mov cx, num_remarks |
664 | mov cx, num_remarks |
663 | mov si, remarks |
665 | mov si, remarks |
664 | .write_remarks: |
666 | .write_remarks: |
665 | lodsw |
667 | lodsw |
666 | push si |
668 | push si |
667 | xchg ax, si |
669 | xchg ax, si |
668 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
670 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
669 | push di |
671 | push di |
670 | .write_remark: |
672 | .write_remark: |
671 | lodsb |
673 | lodsb |
672 | test al, al |
674 | test al, al |
673 | jz @f |
675 | jz @f |
674 | stosw |
676 | stosw |
675 | jmp .write_remark |
677 | jmp .write_remark |
676 | @@: |
678 | @@: |
677 | pop di |
679 | pop di |
678 | pop si |
680 | pop si |
679 | add di, 80*2 |
681 | add di, 80*2 |
680 | loop .write_remarks |
682 | loop .write_remarks |
681 | .wait: |
683 | .wait: |
682 | _setcursor 25,0 ; out of screen |
684 | _setcursor 25,0 ; out of screen |
683 | ; set timer interrupt handler |
685 | ; set timer interrupt handler |
684 | cli |
686 | cli |
685 | push 0 |
687 | push 0 |
686 | pop es |
688 | pop es |
687 | push dword [es:8*4] |
689 | push dword [es:8*4] |
688 | pop dword [.oldtimer] |
690 | pop dword [.oldtimer] |
689 | push dword [.timer] |
691 | push dword [.timer] |
690 | pop dword [es:8*4] |
692 | pop dword [es:8*4] |
691 | ; mov eax, [es:8*4] |
693 | ; mov eax, [es:8*4] |
692 | ; mov [.oldtimer], eax |
694 | ; mov [.oldtimer], eax |
693 | ; mov eax, [.timer] |
695 | ; mov eax, [.timer] |
694 | ; mov [es:8*4], eax |
696 | ; mov [es:8*4], eax |
695 | sti |
697 | sti |
696 | ; wait for keypressed |
698 | ; wait for keypressed |
697 | xor ax, ax |
699 | xor ax, ax |
698 | int 16h |
700 | int 16h |
699 | push ax |
701 | push ax |
700 | ; restore timer interrupt |
702 | ; restore timer interrupt |
701 | ; push 0 |
703 | ; push 0 |
702 | ; pop es |
704 | ; pop es |
703 | mov eax, [.oldtimer] |
705 | mov eax, [.oldtimer] |
704 | mov [es:8*4], eax |
706 | mov [es:8*4], eax |
705 | mov [.timer], eax |
707 | mov [.timer], eax |
706 | 708 | ||
707 | _setcursor 7,0 |
709 | _setcursor 7,0 |
708 | mov si, space_msg |
710 | mov si, space_msg |
709 | call printplain |
711 | call printplain |
710 | ; clear remarks and restore normal attributes |
712 | ; clear remarks and restore normal attributes |
711 | push es |
713 | push es |
712 | mov di, ((21-num_remarks)*80 + 2)*2 |
714 | mov di, ((21-num_remarks)*80 + 2)*2 |
713 | push 0xB800 |
715 | push 0xB800 |
714 | pop es |
716 | pop es |
715 | mov cx, num_remarks |
717 | mov cx, num_remarks |
716 | mov ax, ' ' + (1*16 + 15)*100h |
718 | mov ax, ' ' + (1*16 + 15)*100h |
717 | @@: |
719 | @@: |
718 | push cx |
720 | push cx |
719 | mov cx, 76 |
721 | mov cx, 76 |
720 | rep stosw |
722 | rep stosw |
721 | pop cx |
723 | pop cx |
722 | add di, 4*2 |
724 | add di, 4*2 |
723 | loop @b |
725 | loop @b |
724 | pop es |
726 | pop es |
725 | pop ax |
727 | pop ax |
726 | ; switch on key |
728 | ; switch on key |
727 | cmp al, 13 |
729 | cmp al, 13 |
728 | jz .continue |
730 | jz .continue |
729 | or al, 20h |
731 | or al, 20h |
730 | cmp al, 'a' |
732 | cmp al, 'a' |
731 | jz .change_a |
733 | jz .change_a |
732 | cmp al, 'b' |
734 | cmp al, 'b' |
733 | jz .change_b |
735 | jz .change_b |
734 | ; cmp al, 'c' |
736 | ; cmp al, 'c' |
735 | ; jz .change_c |
737 | ; jz .change_c |
736 | cmp al, 'c' ; 'd' |
738 | cmp al, 'c' ; 'd' |
737 | jnz .show_remarks |
739 | jnz .show_remarks |
738 | _setcursor 15,0 |
740 | _setcursor 15,0 |
739 | mov si, bdev |
741 | mov si, bdev |
740 | call print |
742 | call print |
741 | if defined extended_primary_loader |
743 | if defined extended_primary_loader |
742 | mov bx, '12' |
744 | mov bx, '12' |
743 | else |
745 | else |
744 | mov bx, '14' |
746 | mov bx, '14' |
745 | end if |
747 | end if |
746 | call getkey |
748 | call getkey |
747 | mov [preboot_device], al |
749 | mov [preboot_device], al |
748 | _setcursor 13,0 |
750 | _setcursor 13,0 |
749 | .d: |
751 | .d: |
750 | if ~ defined extended_primary_loader |
752 | if ~ defined extended_primary_loader |
751 | mov [.bSettingsChanged], 1 |
753 | mov [.bSettingsChanged], 1 |
752 | end if |
754 | end if |
753 | call clear_vmodes_table ;clear vmodes_table |
755 | call clear_vmodes_table ;clear vmodes_table |
754 | jmp .printcfg |
756 | jmp .printcfg |
755 | .change_a: |
757 | .change_a: |
756 | .loops: |
758 | .loops: |
757 | call draw_vmodes_table |
759 | call draw_vmodes_table |
758 | _setcursor 25,0 ; out of screen |
760 | _setcursor 25,0 ; out of screen |
759 | xor ax, ax |
761 | xor ax, ax |
760 | int 0x16 |
762 | int 0x16 |
761 | ; call clear_table_cursor ;clear current position of cursor |
763 | ; call clear_table_cursor ;clear current position of cursor |
762 | 764 | ||
763 | mov si, word [cursor_pos] |
765 | mov si, word [cursor_pos] |
764 | 766 | ||
765 | cmp ah, 0x48;x,0x48E0 ; up |
767 | cmp ah, 0x48;x,0x48E0 ; up |
766 | jne .down |
768 | jne .down |
767 | cmp si, modes_table |
769 | cmp si, modes_table |
768 | jbe .loops |
770 | jbe .loops |
769 | sub word [cursor_pos], size_of_step |
771 | sub word [cursor_pos], size_of_step |
770 | jmp .loops |
772 | jmp .loops |
771 | 773 | ||
772 | .down: |
774 | .down: |
773 | cmp ah, 0x50;x,0x50E0 ; down |
775 | cmp ah, 0x50;x,0x50E0 ; down |
774 | jne .pgup |
776 | jne .pgup |
775 | cmp word[es:si+10], -1 |
777 | cmp word[es:si+10], -1 |
776 | je .loops |
778 | je .loops |
777 | add word [cursor_pos], size_of_step |
779 | add word [cursor_pos], size_of_step |
778 | jmp .loops |
780 | jmp .loops |
779 | 781 | ||
780 | .pgup: |
782 | .pgup: |
781 | cmp ah, 0x49 ; page up |
783 | cmp ah, 0x49 ; page up |
782 | jne .pgdn |
784 | jne .pgdn |
783 | sub si, size_of_step*long_v_table |
785 | sub si, size_of_step*long_v_table |
784 | cmp si, modes_table |
786 | cmp si, modes_table |
785 | jae @f |
787 | jae @f |
786 | mov si, modes_table |
788 | mov si, modes_table |
787 | @@: |
789 | @@: |
788 | mov word [cursor_pos], si |
790 | mov word [cursor_pos], si |
789 | mov si, word [home_cursor] |
791 | mov si, word [home_cursor] |
790 | sub si, size_of_step*long_v_table |
792 | sub si, size_of_step*long_v_table |
791 | cmp si, modes_table |
793 | cmp si, modes_table |
792 | jae @f |
794 | jae @f |
793 | mov si, modes_table |
795 | mov si, modes_table |
794 | @@: |
796 | @@: |
795 | mov word [home_cursor], si |
797 | mov word [home_cursor], si |
796 | jmp .loops |
798 | jmp .loops |
797 | 799 | ||
798 | .pgdn: |
800 | .pgdn: |
799 | cmp ah, 0x51 ; page down |
801 | cmp ah, 0x51 ; page down |
800 | jne .enter |
802 | jne .enter |
801 | mov ax, [end_cursor] |
803 | mov ax, [end_cursor] |
802 | add si, size_of_step*long_v_table |
804 | add si, size_of_step*long_v_table |
803 | cmp si, ax |
805 | cmp si, ax |
804 | jb @f |
806 | jb @f |
805 | mov si, ax |
807 | mov si, ax |
806 | sub si, size_of_step |
808 | sub si, size_of_step |
807 | @@: |
809 | @@: |
808 | mov word [cursor_pos], si |
810 | mov word [cursor_pos], si |
809 | mov si, word [home_cursor] |
811 | mov si, word [home_cursor] |
810 | sub ax, size_of_step*long_v_table |
812 | sub ax, size_of_step*long_v_table |
811 | add si, size_of_step*long_v_table |
813 | add si, size_of_step*long_v_table |
812 | cmp si, ax |
814 | cmp si, ax |
813 | jb @f |
815 | jb @f |
814 | mov si, ax |
816 | mov si, ax |
815 | @@: |
817 | @@: |
816 | mov word [home_cursor], si |
818 | mov word [home_cursor], si |
817 | jmp .loops |
819 | jmp .loops |
818 | 820 | ||
819 | .enter: |
821 | .enter: |
820 | cmp al, 0x0D;x,0x1C0D ; enter |
822 | cmp al, 0x0D;x,0x1C0D ; enter |
821 | jne .loops |
823 | jne .loops |
822 | push word [cursor_pos] |
824 | push word [cursor_pos] |
823 | pop bp |
825 | pop bp |
824 | push word [es:bp] |
826 | push word [es:bp] |
825 | pop word [x_save] |
827 | pop word [x_save] |
826 | push word [es:bp+2] |
828 | push word [es:bp+2] |
827 | pop word [y_save] |
829 | pop word [y_save] |
828 | push word [es:bp+6] |
830 | push word [es:bp+6] |
829 | pop word [number_vm] |
831 | pop word [number_vm] |
830 | mov word [preboot_graph], bp ;save choose |
832 | mov word [preboot_graph], bp ;save choose |
831 | 833 | ||
832 | jmp .d |
834 | jmp .d |
833 | 835 | ||
834 | .change_b: |
836 | .change_b: |
835 | _setcursor 15,0 |
837 | _setcursor 15,0 |
836 | ; mov si, ask_dma |
838 | ; mov si, ask_dma |
837 | ; call print |
839 | ; call print |
838 | ; mov bx, '13' |
840 | ; mov bx, '13' |
839 | ; call getkey |
841 | ; call getkey |
840 | ; mov [preboot_dma], al |
842 | ; mov [preboot_dma], al |
841 | mov si, ask_bd |
843 | mov si, ask_bd |
842 | call print |
844 | call print |
843 | mov bx, '12' |
845 | mov bx, '12' |
844 | call getkey |
846 | call getkey |
845 | mov [preboot_biosdisk], al |
847 | mov [preboot_biosdisk], al |
846 | _setcursor 11,0 |
848 | _setcursor 11,0 |
847 | jmp .d |
849 | jmp .d |
848 | ;.change_c: |
850 | ;.change_c: |
849 | ; _setcursor 15,0 |
851 | ; _setcursor 15,0 |
850 | ; mov si, vrrmprint |
852 | ; mov si, vrrmprint |
851 | ; call print |
853 | ; call print |
852 | ; mov bx, '12' |
854 | ; mov bx, '12' |
853 | ; call getkey |
855 | ; call getkey |
854 | ; mov [preboot_vrrm], al |
856 | ; mov [preboot_vrrm], al |
855 | ; _setcursor 12,0 |
857 | ; _setcursor 12,0 |
856 | ; jmp .d |
858 | ; jmp .d |
857 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
859 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
858 | .say_on_off: |
860 | .say_on_off: |
859 | pushf |
861 | pushf |
860 | call print |
862 | call print |
861 | mov si, on_msg |
863 | mov si, on_msg |
862 | popf |
864 | popf |
863 | jz @f |
865 | jz @f |
864 | mov si, off_msg |
866 | mov si, off_msg |
865 | @@: |
867 | @@: |
866 | jmp printplain |
868 | jmp printplain |
867 | ; novesa and vervesa strings are not used at the moment of executing this code |
869 | ; novesa and vervesa strings are not used at the moment of executing this code |
868 | virtual at novesa |
870 | virtual at novesa |
869 | .oldtimer dd ? |
871 | .oldtimer dd ? |
870 | .starttime dd ? |
872 | .starttime dd ? |
871 | if ~ defined extended_primary_loader |
873 | if ~ defined extended_primary_loader |
872 | .bSettingsChanged db ? |
874 | .bSettingsChanged db ? |
873 | end if |
875 | end if |
874 | .timer dd ? |
876 | .timer dd ? |
875 | end virtual |
877 | end virtual |
876 | if ~ defined extended_primary_loader |
878 | if ~ defined extended_primary_loader |
877 | .loader_block dd -1 |
879 | .loader_block dd -1 |
878 | end if |
880 | end if |
879 | .gettime: |
881 | .gettime: |
880 | mov ah, 0 |
882 | mov ah, 0 |
881 | int 1Ah |
883 | int 1Ah |
882 | xchg ax, cx |
884 | xchg ax, cx |
883 | shl eax, 10h |
885 | shl eax, 10h |
884 | xchg ax, dx |
886 | xchg ax, dx |
885 | ret |
887 | ret |
886 | .newtimer: |
888 | .newtimer: |
887 | push ds |
889 | push ds |
888 | push cs |
890 | push cs |
889 | pop ds |
891 | pop ds |
890 | pushf |
892 | pushf |
891 | call [.oldtimer] |
893 | call [.oldtimer] |
892 | pushad |
894 | pushad |
893 | call .gettime |
895 | call .gettime |
894 | sub eax, [.starttime] |
896 | sub eax, [.starttime] |
895 | if defined extended_primary_loader |
897 | if defined extended_primary_loader |
896 | sub ax, [preboot_timeout] |
898 | sub ax, [preboot_timeout] |
897 | else |
899 | else |
898 | sub ax, 18*5 |
900 | sub ax, 18*5 |
899 | end if |
901 | end if |
900 | jae .timergo |
902 | jae .timergo |
901 | neg ax |
903 | neg ax |
902 | add ax, 18-1 |
904 | add ax, 18-1 |
903 | mov bx, 18 |
905 | mov bx, 18 |
904 | xor dx, dx |
906 | xor dx, dx |
905 | div bx |
907 | div bx |
906 | if lang eq ru |
908 | if lang eq ru |
907 | ; подождите 5 секунд, 4/3/2 секунды, 1 секунду |
909 | ; подождите 5 секунд, 4/3/2 секунды, 1 секунду |
908 | cmp al, 5 |
910 | cmp al, 5 |
909 | mov cl, ' ' |
911 | mov cl, ' ' |
910 | jae @f |
912 | jae @f |
911 | cmp al, 1 |
913 | cmp al, 1 |
912 | mov cl, 0xE3 ; 'у' in cp866 |
914 | mov cl, 0xE3 ; 'у' in cp866 |
913 | jz @f |
915 | jz @f |
914 | mov cl, 0xEB ; 'ы' in cp866 |
916 | mov cl, 0xEB ; 'ы' in cp866 |
915 | @@: |
917 | @@: |
916 | mov [time_str+9], cl |
918 | mov [time_str+9], cl |
917 | else if lang eq et |
919 | else if lang eq et |
918 | cmp al, 1 |
920 | cmp al, 1 |
919 | ja @f |
921 | ja @f |
920 | mov byte [time_str+9], ' ' |
922 | mov byte [time_str+9], ' ' |
921 | mov byte [time_str+10], ' ' |
923 | mov byte [time_str+10], ' ' |
922 | @@: |
924 | @@: |
923 | else if lang eq sp |
925 | else if lang eq sp |
924 | ; esperar 5/4/3/2 segundos, 1 segundo |
926 | ; esperar 5/4/3/2 segundos, 1 segundo |
925 | cmp al, 1 |
927 | cmp al, 1 |
926 | mov cl, 's' |
928 | mov cl, 's' |
927 | ja @f |
929 | ja @f |
928 | mov cl, ' ' |
930 | mov cl, ' ' |
929 | @@: |
931 | @@: |
930 | mov [time_str+10], cl |
932 | mov [time_str+10], cl |
931 | else |
933 | else |
932 | ; wait 5/4/3/2 seconds, 1 second |
934 | ; wait 5/4/3/2 seconds, 1 second |
933 | cmp al, 1 |
935 | cmp al, 1 |
934 | mov cl, 's' |
936 | mov cl, 's' |
935 | ja @f |
937 | ja @f |
936 | mov cl, ' ' |
938 | mov cl, ' ' |
937 | @@: |
939 | @@: |
938 | mov [time_str+9], cl |
940 | mov [time_str+9], cl |
939 | end if |
941 | end if |
940 | add al, '0' |
942 | add al, '0' |
941 | mov [time_str+1], al |
943 | mov [time_str+1], al |
942 | mov si, time_msg |
944 | mov si, time_msg |
943 | _setcursor 7,0 |
945 | _setcursor 7,0 |
944 | call print |
946 | call print |
945 | _setcursor 25,0 |
947 | _setcursor 25,0 |
946 | popad |
948 | popad |
947 | pop ds |
949 | pop ds |
948 | iret |
950 | iret |
949 | .timergo: |
951 | .timergo: |
950 | push 0 |
952 | push 0 |
951 | pop es |
953 | pop es |
952 | mov eax, [.oldtimer] |
954 | mov eax, [.oldtimer] |
953 | mov [es:8*4], eax |
955 | mov [es:8*4], eax |
954 | mov sp, 0EC00h |
956 | mov sp, 0EC00h |
955 | .continue: |
957 | .continue: |
956 | sti |
958 | sti |
957 | _setcursor 6,0 |
959 | _setcursor 6,0 |
958 | mov si, space_msg |
960 | mov si, space_msg |
959 | call printplain |
961 | call printplain |
960 | call printplain |
962 | call printplain |
961 | _setcursor 6,0 |
963 | _setcursor 6,0 |
962 | mov si, loading_msg |
964 | mov si, loading_msg |
963 | call print |
965 | call print |
964 | _setcursor 15,0 |
966 | _setcursor 15,0 |
965 | if ~ defined extended_primary_loader |
967 | if ~ defined extended_primary_loader |
966 | cmp [.bSettingsChanged], 0 |
968 | cmp [.bSettingsChanged], 0 |
967 | jz .load |
969 | jz .load |
968 | cmp [.loader_block], -1 |
970 | cmp [.loader_block], -1 |
969 | jz .load |
971 | jz .load |
970 | les bx, [.loader_block] |
972 | les bx, [.loader_block] |
971 | mov eax, [es:bx+3] |
973 | mov eax, [es:bx+3] |
972 | push ds |
974 | push ds |
973 | pop es |
975 | pop es |
974 | test eax, eax |
976 | test eax, eax |
975 | jz .load |
977 | jz .load |
976 | push eax |
978 | push eax |
977 | mov si, save_quest |
979 | mov si, save_quest |
978 | call print |
980 | call print |
979 | .waityn: |
981 | .waityn: |
980 | mov ah, 0 |
982 | mov ah, 0 |
981 | int 16h |
983 | int 16h |
982 | or al, 20h |
984 | or al, 20h |
983 | cmp al, 'n' |
985 | cmp al, 'n' |
984 | jz .loadc |
986 | jz .loadc |
985 | if lang eq sp |
987 | if lang eq sp |
986 | cmp al, 's' |
988 | cmp al, 's' |
987 | else |
989 | else |
988 | cmp al, 'y' |
990 | cmp al, 'y' |
989 | end if |
991 | end if |
990 | jnz .waityn |
992 | jnz .waityn |
991 | call putchar |
993 | call putchar |
992 | mov byte [space_msg+80], 186 |
994 | mov byte [space_msg+80], 186 |
993 | 995 | ||
994 | pop eax |
996 | pop eax |
995 | push cs |
997 | push cs |
996 | push .cont |
998 | push .cont |
997 | push eax |
999 | push eax |
998 | retf ;call back |
1000 | retf ;call back |
999 | .loadc: |
1001 | .loadc: |
1000 | pop eax |
1002 | pop eax |
1001 | .cont: |
1003 | .cont: |
1002 | push cs |
1004 | push cs |
1003 | pop ds |
1005 | pop ds |
1004 | mov si, space_msg |
1006 | mov si, space_msg |
1005 | mov byte [si+80], 0 |
1007 | mov byte [si+80], 0 |
1006 | _setcursor 15,0 |
1008 | _setcursor 15,0 |
1007 | call printplain |
1009 | call printplain |
1008 | _setcursor 15,0 |
1010 | _setcursor 15,0 |
1009 | .load: |
1011 | .load: |
1010 | end if |
1012 | end if |
1011 | ; \end{diamond}[02.12.2005] |
1013 | ; \end{diamond}[02.12.2005] |
1012 | 1014 | ||
1013 | ; ASK GRAPHICS MODE |
1015 | ; ASK GRAPHICS MODE |
1014 | 1016 | ||
1015 | call set_vmode |
1017 | call set_vmode |
1016 | 1018 | ||
1017 | ; GRAPHICS ACCELERATION |
1019 | ; GRAPHICS ACCELERATION |
1018 | ; force yes |
1020 | ; force yes |
1019 | mov [es:BOOT_MTRR], byte 1 |
1021 | mov [es:BOOT_MTRR], byte 1 |
1020 | 1022 | ||
1021 | ; DMA ACCESS TO HD |
1023 | ; DMA ACCESS TO HD |
1022 | 1024 | ||
1023 | mov al, [preboot_dma] |
1025 | mov al, [preboot_dma] |
1024 | mov [es:BOOT_DMA], al |
1026 | mov [es:BOOT_DMA], al |
1025 | 1027 | ||
1026 | ;; VRR_M USE |
1028 | ;; VRR_M USE |
1027 | ; |
1029 | ; |
1028 | ; mov al,[preboot_vrrm] |
1030 | ; mov al,[preboot_vrrm] |
1029 | ; mov [es:0x9030], al |
1031 | ; mov [es:0x9030], al |
1030 | 1032 | ||
1031 | ; BOOT DEVICE |
1033 | ; BOOT DEVICE |
1032 | 1034 | ||
1033 | mov al, [preboot_device] |
1035 | mov al, [preboot_device] |
1034 | dec al |
1036 | dec al |
1035 | mov [boot_dev], al |
1037 | mov [boot_dev], al |
1036 | 1038 | ||
1037 | ; GET MEMORY MAP |
1039 | ; GET MEMORY MAP |
1038 | include '../detect/biosmem.inc' |
1040 | include '../detect/biosmem.inc' |
1039 | 1041 | ||
1040 | ; READ DISKETTE TO MEMORY |
1042 | ; READ DISKETTE TO MEMORY |
1041 | 1043 | ||
1042 | cmp [boot_dev], 0 |
1044 | cmp [boot_dev], 0 |
1043 | jne no_sys_on_floppy |
1045 | jne no_sys_on_floppy |
1044 | mov si, diskload |
1046 | mov si, diskload |
1045 | call print |
1047 | call print |
1046 | xor ax, ax ; reset drive |
1048 | xor ax, ax ; reset drive |
1047 | xor dx, dx |
1049 | xor dx, dx |
1048 | int 0x13 |
1050 | int 0x13 |
1049 | ; do we boot from CD-ROM? |
1051 | ; do we boot from CD-ROM? |
1050 | mov ah, 41h |
1052 | mov ah, 41h |
1051 | mov bx, 55AAh |
1053 | mov bx, 55AAh |
1052 | xor dx, dx |
1054 | xor dx, dx |
1053 | int 0x13 |
1055 | int 0x13 |
1054 | jc .nocd |
1056 | jc .nocd |
1055 | cmp bx, 0AA55h |
1057 | cmp bx, 0AA55h |
1056 | jnz .nocd |
1058 | jnz .nocd |
1057 | mov ah, 48h |
1059 | mov ah, 48h |
1058 | push ds |
1060 | push ds |
1059 | push es |
1061 | push es |
1060 | pop ds |
1062 | pop ds |
1061 | mov si, 0xa000 |
1063 | mov si, 0xa000 |
1062 | mov word [si], 30 |
1064 | mov word [si], 30 |
1063 | int 0x13 |
1065 | int 0x13 |
1064 | pop ds |
1066 | pop ds |
1065 | jc .nocd |
1067 | jc .nocd |
1066 | push ds |
1068 | push ds |
1067 | lds si, [es:si+26] |
1069 | lds si, [es:si+26] |
1068 | test byte [ds:si+10], 40h |
1070 | test byte [ds:si+10], 40h |
1069 | pop ds |
1071 | pop ds |
1070 | jz .nocd |
1072 | jz .nocd |
1071 | ; yes - read all floppy by 18 sectors |
1073 | ; yes - read all floppy by 18 sectors |
1072 | 1074 | ||
1073 | ; TODO: !!!! read only first sector and set variables !!!!! |
1075 | ; TODO: !!!! read only first sector and set variables !!!!! |
1074 | ; ... |
1076 | ; ... |
1075 | ; TODO: !!! then read flippy image track by track |
1077 | ; TODO: !!! then read flippy image track by track |
1076 | 1078 | ||
1077 | mov cx, 0x0001 ; startcyl,startsector |
1079 | mov cx, 0x0001 ; startcyl,startsector |
1078 | .a1: |
1080 | .a1: |
1079 | push cx dx |
1081 | push cx dx |
1080 | mov al, 18 |
1082 | mov al, 18 |
1081 | mov bx, 0xa000 |
1083 | mov bx, 0xa000 |
1082 | call boot_read_floppy |
1084 | call boot_read_floppy |
1083 | mov si, movedesc |
1085 | mov si, movedesc |
1084 | push es |
1086 | push es |
1085 | push ds |
1087 | push ds |
1086 | pop es |
1088 | pop es |
1087 | mov cx, 256*18 |
1089 | mov cx, 256*18 |
1088 | mov ah, 0x87 |
1090 | mov ah, 0x87 |
1089 | int 0x15 |
1091 | int 0x15 |
1090 | pop es |
1092 | pop es |
1091 | pop dx cx |
1093 | pop dx cx |
1092 | test ah, ah |
1094 | test ah, ah |
1093 | jnz sayerr_floppy |
1095 | jnz sayerr_floppy |
1094 | add dword [si+8*3+2], 512*18 |
1096 | add dword [si+8*3+2], 512*18 |
1095 | inc dh |
1097 | inc dh |
1096 | cmp dh, 2 |
1098 | cmp dh, 2 |
1097 | jnz .a1 |
1099 | jnz .a1 |
1098 | mov dh, 0 |
1100 | mov dh, 0 |
1099 | inc ch |
1101 | inc ch |
1100 | cmp ch, 80 |
1102 | cmp ch, 80 |
1101 | jae ok_sys_on_floppy |
1103 | jae ok_sys_on_floppy |
1102 | pusha |
1104 | pusha |
1103 | mov al, ch |
1105 | mov al, ch |
1104 | shr ch, 2 |
1106 | shr ch, 2 |
1105 | add al, ch |
1107 | add al, ch |
1106 | aam |
1108 | aam |
1107 | xchg al, ah |
1109 | xchg al, ah |
1108 | add ax, '00' |
1110 | add ax, '00' |
1109 | mov si, pros |
1111 | mov si, pros |
1110 | mov [si], ax |
1112 | mov [si], ax |
1111 | call printplain |
1113 | call printplain |
1112 | popa |
1114 | popa |
1113 | jmp .a1 |
1115 | jmp .a1 |
1114 | .nocd: |
1116 | .nocd: |
1115 | ; no - read only used sectors from floppy |
1117 | ; no - read only used sectors from floppy |
1116 | ; now load floppy image to memory |
1118 | ; now load floppy image to memory |
1117 | ; at first load boot sector and first FAT table |
1119 | ; at first load boot sector and first FAT table |
1118 | 1120 | ||
1119 | ; read only first sector and fill variables |
1121 | ; read only first sector and fill variables |
1120 | mov cx, 0x0001 ; first logical sector |
1122 | mov cx, 0x0001 ; first logical sector |
1121 | xor dx, dx ; head = 0, drive = 0 (a:) |
1123 | xor dx, dx ; head = 0, drive = 0 (a:) |
1122 | mov al, 1 ; read one sector |
1124 | mov al, 1 ; read one sector |
1123 | mov bx, 0xB000 ; es:bx -> data area |
1125 | mov bx, 0xB000 ; es:bx -> data area |
1124 | call boot_read_floppy |
1126 | call boot_read_floppy |
1125 | ; fill the necessary parameters to work with a floppy |
1127 | ; fill the necessary parameters to work with a floppy |
1126 | mov ax, word [es:bx+24] |
1128 | mov ax, word [es:bx+24] |
1127 | mov word [BPB_SecPerTrk], ax |
1129 | mov word [BPB_SecPerTrk], ax |
1128 | mov ax, word [es:bx+26] |
1130 | mov ax, word [es:bx+26] |
1129 | mov word [BPB_NumHeads], ax |
1131 | mov word [BPB_NumHeads], ax |
1130 | mov ax, word [es:bx+17] |
1132 | mov ax, word [es:bx+17] |
1131 | mov word [BPB_RootEntCnt], ax |
1133 | mov word [BPB_RootEntCnt], ax |
1132 | mov ax, word [es:bx+14] |
1134 | mov ax, word [es:bx+14] |
1133 | mov word [BPB_RsvdSecCnt], ax |
1135 | mov word [BPB_RsvdSecCnt], ax |
1134 | mov ax, word [es:bx+19] |
1136 | mov ax, word [es:bx+19] |
1135 | mov word [BPB_TotSec16], ax |
1137 | mov word [BPB_TotSec16], ax |
1136 | mov al, byte [es:bx+13] |
1138 | mov al, byte [es:bx+13] |
1137 | mov byte [BPB_SecPerClus], al |
1139 | mov byte [BPB_SecPerClus], al |
1138 | mov al, byte [es:bx+16] |
1140 | mov al, byte [es:bx+16] |
1139 | mov byte [BPB_NumFATs], al |
1141 | mov byte [BPB_NumFATs], al |
1140 | ; |
1142 | ; |
1141 | mov ax, word [es:bx+22] |
1143 | mov ax, word [es:bx+22] |
1142 | mov word [BPB_FATSz16], ax |
1144 | mov word [BPB_FATSz16], ax |
1143 | mov cx, word [es:bx+11] |
1145 | mov cx, word [es:bx+11] |
1144 | mov word [BPB_BytsPerSec], cx |
1146 | mov word [BPB_BytsPerSec], cx |
1145 | 1147 | ||
1146 | ; count of clusters in FAT12 ((size_of_FAT*2)/3) |
1148 | ; count of clusters in FAT12 ((size_of_FAT*2)/3) |
1147 | ; mov ax, word [BPB_FATSz16] |
1149 | ; mov ax, word [BPB_FATSz16] |
1148 | ; mov cx, word [BPB_BytsPerSec] |
1150 | ; mov cx, word [BPB_BytsPerSec] |
1149 | ;end |
1151 | ;end |
1150 | xor dx, dx |
1152 | xor dx, dx |
1151 | mul cx |
1153 | mul cx |
1152 | shl ax, 1 |
1154 | shl ax, 1 |
1153 | mov cx, 3 |
1155 | mov cx, 3 |
1154 | div cx ; now ax - number of clusters in FAT12 |
1156 | div cx ; now ax - number of clusters in FAT12 |
1155 | mov word [end_of_FAT], ax |
1157 | mov word [end_of_FAT], ax |
1156 | 1158 | ||
1157 | ; load first FAT table |
1159 | ; load first FAT table |
1158 | mov cx, 0x0002 ; startcyl,startsector ; TODO!!!!! |
1160 | mov cx, 0x0002 ; startcyl,startsector ; TODO!!!!! |
1159 | xor dx, dx ; starthead,drive |
1161 | xor dx, dx ; starthead,drive |
1160 | mov al, byte [BPB_FATSz16] ; no of sectors to read |
1162 | mov al, byte [BPB_FATSz16] ; no of sectors to read |
1161 | add bx, word [BPB_BytsPerSec] ; es:bx -> data area |
1163 | add bx, word [BPB_BytsPerSec] ; es:bx -> data area |
1162 | call boot_read_floppy |
1164 | call boot_read_floppy |
1163 | mov bx, 0xB000 |
1165 | mov bx, 0xB000 |
1164 | 1166 | ||
1165 | ; and copy them to extended memory |
1167 | ; and copy them to extended memory |
1166 | mov si, movedesc |
1168 | mov si, movedesc |
1167 | mov [si+8*2+3], bh ; from |
1169 | mov [si+8*2+3], bh ; from |
1168 | 1170 | ||
1169 | mov ax, word [BPB_BytsPerSec] |
1171 | mov ax, word [BPB_BytsPerSec] |
1170 | shr ax, 1 ; words per sector |
1172 | shr ax, 1 ; words per sector |
1171 | mov cx, word [BPB_RsvdSecCnt] |
1173 | mov cx, word [BPB_RsvdSecCnt] |
1172 | add cx, word [BPB_FATSz16] |
1174 | add cx, word [BPB_FATSz16] |
1173 | mul cx |
1175 | mul cx |
1174 | push ax ; save to stack count of words in boot+FAT |
1176 | push ax ; save to stack count of words in boot+FAT |
1175 | xchg ax, cx |
1177 | xchg ax, cx |
1176 | 1178 | ||
1177 | push es |
1179 | push es |
1178 | push ds |
1180 | push ds |
1179 | pop es |
1181 | pop es |
1180 | mov ah, 0x87 |
1182 | mov ah, 0x87 |
1181 | int 0x15 |
1183 | int 0x15 |
1182 | pop es |
1184 | pop es |
1183 | test ah, ah |
1185 | test ah, ah |
1184 | jz @f |
1186 | jz @f |
1185 | sayerr_floppy: |
1187 | sayerr_floppy: |
1186 | mov dx, 0x3f2 |
1188 | mov dx, 0x3f2 |
1187 | mov al, 0 |
1189 | mov al, 0 |
1188 | out dx, al |
1190 | out dx, al |
1189 | sayerr_memmove: |
1191 | sayerr_memmove: |
1190 | mov si, memmovefailed |
1192 | mov si, memmovefailed |
1191 | jmp sayerr_plain |
1193 | jmp sayerr_plain |
1192 | @@: |
1194 | @@: |
1193 | pop ax ; restore from stack count of words in boot+FAT |
1195 | pop ax ; restore from stack count of words in boot+FAT |
1194 | shl ax, 1 ; make bytes count from count of words |
1196 | shl ax, 1 ; make bytes count from count of words |
1195 | and eax, 0ffffh |
1197 | and eax, 0ffffh |
1196 | add dword [si+8*3+2], eax |
1198 | add dword [si+8*3+2], eax |
1197 | 1199 | ||
1198 | ; copy first FAT to second copy |
1200 | ; copy first FAT to second copy |
1199 | ; TODO: BPB_NumFATs !!!!! |
1201 | ; TODO: BPB_NumFATs !!!!! |
1200 | add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!! |
1202 | add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!! |
1201 | mov byte [si+8*2+3], bh ; bx - begin of FAT |
1203 | mov byte [si+8*2+3], bh ; bx - begin of FAT |
1202 | 1204 | ||
1203 | mov ax, word [BPB_BytsPerSec] |
1205 | mov ax, word [BPB_BytsPerSec] |
1204 | shr ax, 1 ; words per sector |
1206 | shr ax, 1 ; words per sector |
1205 | mov cx, word [BPB_FATSz16] |
1207 | mov cx, word [BPB_FATSz16] |
1206 | mul cx |
1208 | mul cx |
1207 | mov cx, ax ; cx - count of words in FAT |
1209 | mov cx, ax ; cx - count of words in FAT |
1208 | 1210 | ||
1209 | push es |
1211 | push es |
1210 | push ds |
1212 | push ds |
1211 | pop es |
1213 | pop es |
1212 | mov ah, 0x87 |
1214 | mov ah, 0x87 |
1213 | int 0x15 |
1215 | int 0x15 |
1214 | pop es |
1216 | pop es |
1215 | test ah, ah |
1217 | test ah, ah |
1216 | jnz sayerr_floppy |
1218 | jnz sayerr_floppy |
1217 | 1219 | ||
1218 | mov ax, cx |
1220 | mov ax, cx |
1219 | shl ax, 1 |
1221 | shl ax, 1 |
1220 | and eax, 0ffffh ; ax - count of bytes in FAT |
1222 | and eax, 0ffffh ; ax - count of bytes in FAT |
1221 | add dword [si+8*3+2], eax |
1223 | add dword [si+8*3+2], eax |
1222 | 1224 | ||
1223 | ; reading RootDir |
1225 | ; reading RootDir |
1224 | ; TODO: BPB_NumFATs |
1226 | ; TODO: BPB_NumFATs |
1225 | add bx, ax |
1227 | add bx, ax |
1226 | add bx, 100h |
1228 | add bx, 100h |
1227 | and bx, 0ff00h ; bx - place in buffer to write RootDir |
1229 | and bx, 0ff00h ; bx - place in buffer to write RootDir |
1228 | push bx |
1230 | push bx |
1229 | 1231 | ||
1230 | mov bx, word [BPB_BytsPerSec] |
1232 | mov bx, word [BPB_BytsPerSec] |
1231 | shr bx, 5 ; divide bx by 32 |
1233 | shr bx, 5 ; divide bx by 32 |
1232 | mov ax, word [BPB_RootEntCnt] |
1234 | mov ax, word [BPB_RootEntCnt] |
1233 | xor dx, dx |
1235 | xor dx, dx |
1234 | div bx |
1236 | div bx |
1235 | push ax ; ax - count of RootDir sectors |
1237 | push ax ; ax - count of RootDir sectors |
1236 | 1238 | ||
1237 | mov ax, word [BPB_FATSz16] |
1239 | mov ax, word [BPB_FATSz16] |
1238 | xor cx, cx |
1240 | xor cx, cx |
1239 | mov cl, byte [BPB_NumFATs] |
1241 | mov cl, byte [BPB_NumFATs] |
1240 | mul cx |
1242 | mul cx |
1241 | add ax, word [BPB_RsvdSecCnt] ; ax - first sector of RootDir |
1243 | add ax, word [BPB_RsvdSecCnt] ; ax - first sector of RootDir |
1242 | 1244 | ||
1243 | mov word [FirstDataSector], ax |
1245 | mov word [FirstDataSector], ax |
1244 | pop bx |
1246 | pop bx |
1245 | push bx |
1247 | push bx |
1246 | add word [FirstDataSector], bx ; Begin of data region of floppy |
1248 | add word [FirstDataSector], bx ; Begin of data region of floppy |
1247 | 1249 | ||
1248 | ; read RootDir |
1250 | ; read RootDir |
1249 | call conv_abs_to_THS |
1251 | call conv_abs_to_THS |
1250 | pop ax |
1252 | pop ax |
1251 | pop bx ; place in buffer to write |
1253 | pop bx ; place in buffer to write |
1252 | push ax |
1254 | push ax |
1253 | call boot_read_floppy ; read RootDir into buffer |
1255 | call boot_read_floppy ; read RootDir into buffer |
1254 | ; copy RootDir |
1256 | ; copy RootDir |
1255 | mov byte [si+8*2+3], bh ; from buffer |
1257 | mov byte [si+8*2+3], bh ; from buffer |
1256 | pop ax ; ax = count of RootDir sectors |
1258 | pop ax ; ax = count of RootDir sectors |
1257 | mov cx, word [BPB_BytsPerSec] |
1259 | mov cx, word [BPB_BytsPerSec] |
1258 | mul cx |
1260 | mul cx |
1259 | shr ax, 1 |
1261 | shr ax, 1 |
1260 | mov cx, ax ; count of words to copy |
1262 | mov cx, ax ; count of words to copy |
1261 | push es |
1263 | push es |
1262 | push ds |
1264 | push ds |
1263 | pop es |
1265 | pop es |
1264 | mov ah, 0x87 |
1266 | mov ah, 0x87 |
1265 | int 0x15 |
1267 | int 0x15 |
1266 | pop es |
1268 | pop es |
1267 | 1269 | ||
1268 | mov ax, cx |
1270 | mov ax, cx |
1269 | shl ax, 1 |
1271 | shl ax, 1 |
1270 | and eax, 0ffffh ; ax - count of bytes in RootDir |
1272 | and eax, 0ffffh ; ax - count of bytes in RootDir |
1271 | add dword [si+8*3+2], eax ; add count of bytes copied |
1273 | add dword [si+8*3+2], eax ; add count of bytes copied |
1272 | 1274 | ||
1273 | ; Reading data clusters from floppy |
1275 | ; Reading data clusters from floppy |
1274 | mov byte [si+8*2+3], bh |
1276 | mov byte [si+8*2+3], bh |
1275 | push bx |
1277 | push bx |
1276 | 1278 | ||
1277 | mov di, 2 ; First data cluster |
1279 | mov di, 2 ; First data cluster |
1278 | .read_loop: |
1280 | .read_loop: |
1279 | mov bx, di |
1281 | mov bx, di |
1280 | shr bx, 1 ; bx+di = di*1.5 |
1282 | shr bx, 1 ; bx+di = di*1.5 |
1281 | jnc .even |
1283 | jnc .even |
1282 | test word [es:bx+di+0xB200], 0xFFF0 ; TODO: may not be 0xB200 !!! |
1284 | test word [es:bx+di+0xB200], 0xFFF0 ; TODO: may not be 0xB200 !!! |
1283 | jmp @f |
1285 | jmp @f |
1284 | .even: |
1286 | .even: |
1285 | test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!! |
1287 | test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!! |
1286 | 1288 | ||
1287 | @@: |
1289 | @@: |
1288 | jz .skip |
1290 | jz .skip |
1289 | ; read cluster di |
1291 | ; read cluster di |
1290 | ;.read: |
1292 | ;.read: |
1291 | ;conv cluster di to abs. sector ax |
1293 | ;conv cluster di to abs. sector ax |
1292 | ; ax = (N-2) * BPB_SecPerClus + FirstDataSector |
1294 | ; ax = (N-2) * BPB_SecPerClus + FirstDataSector |
1293 | mov ax, di |
1295 | mov ax, di |
1294 | sub ax, 2 |
1296 | sub ax, 2 |
1295 | xor bx, bx |
1297 | xor bx, bx |
1296 | mov bl, byte [BPB_SecPerClus] |
1298 | mov bl, byte [BPB_SecPerClus] |
1297 | mul bx |
1299 | mul bx |
1298 | add ax, word [FirstDataSector] |
1300 | add ax, word [FirstDataSector] |
1299 | call conv_abs_to_THS |
1301 | call conv_abs_to_THS |
1300 | pop bx |
1302 | pop bx |
1301 | push bx |
1303 | push bx |
1302 | mov al, byte [BPB_SecPerClus] ; number of sectors in cluster |
1304 | mov al, byte [BPB_SecPerClus] ; number of sectors in cluster |
1303 | call boot_read_floppy |
1305 | call boot_read_floppy |
1304 | push es |
1306 | push es |
1305 | push ds |
1307 | push ds |
1306 | pop es |
1308 | pop es |
1307 | pusha |
1309 | pusha |
1308 | ; |
1310 | ; |
1309 | mov ax, word [BPB_BytsPerSec] |
1311 | mov ax, word [BPB_BytsPerSec] |
1310 | xor cx, cx |
1312 | xor cx, cx |
1311 | mov cl, byte [BPB_SecPerClus] |
1313 | mov cl, byte [BPB_SecPerClus] |
1312 | mul cx |
1314 | mul cx |
1313 | shr ax, 1 ; ax = (BPB_BytsPerSec * BPB_SecPerClus)/2 |
1315 | shr ax, 1 ; ax = (BPB_BytsPerSec * BPB_SecPerClus)/2 |
1314 | mov cx, ax ; number of words to copy (count words in cluster) |
1316 | mov cx, ax ; number of words to copy (count words in cluster) |
1315 | ; |
1317 | ; |
1316 | mov ah, 0x87 |
1318 | mov ah, 0x87 |
1317 | int 0x15 ; copy data |
1319 | int 0x15 ; copy data |
1318 | test ah, ah |
1320 | test ah, ah |
1319 | popa |
1321 | popa |
1320 | pop es |
1322 | pop es |
1321 | jnz sayerr_floppy |
1323 | jnz sayerr_floppy |
1322 | ; skip cluster di |
1324 | ; skip cluster di |
1323 | .skip: |
1325 | .skip: |
1324 | mov ax, word [BPB_BytsPerSec] |
1326 | mov ax, word [BPB_BytsPerSec] |
1325 | xor cx, cx |
1327 | xor cx, cx |
1326 | mov cl, byte [BPB_SecPerClus] |
1328 | mov cl, byte [BPB_SecPerClus] |
1327 | mul cx |
1329 | mul cx |
1328 | and eax, 0ffffh ; ax - count of bytes in cluster |
1330 | and eax, 0ffffh ; ax - count of bytes in cluster |
1329 | add dword [si+8*3+2], eax |
1331 | add dword [si+8*3+2], eax |
1330 | 1332 | ||
1331 | mov ax, word [end_of_FAT] ; max cluster number |
1333 | mov ax, word [end_of_FAT] ; max cluster number |
1332 | pusha |
1334 | pusha |
1333 | ; draw percentage |
1335 | ; draw percentage |
1334 | ; total clusters: ax |
1336 | ; total clusters: ax |
1335 | ; read clusters: di |
1337 | ; read clusters: di |
1336 | xchg ax, di |
1338 | xchg ax, di |
1337 | mov cx, 100 |
1339 | mov cx, 100 |
1338 | mul cx |
1340 | mul cx |
1339 | div di |
1341 | div di |
1340 | aam |
1342 | aam |
1341 | xchg al, ah |
1343 | xchg al, ah |
1342 | add ax, '00' |
1344 | add ax, '00' |
1343 | mov si, pros |
1345 | mov si, pros |
1344 | cmp [si], ax |
1346 | cmp [si], ax |
1345 | jz @f |
1347 | jz @f |
1346 | mov [si], ax |
1348 | mov [si], ax |
1347 | call printplain |
1349 | call printplain |
1348 | @@: |
1350 | @@: |
1349 | popa |
1351 | popa |
1350 | inc di |
1352 | inc di |
1351 | cmp di, word [end_of_FAT] ; max number of cluster |
1353 | cmp di, word [end_of_FAT] ; max number of cluster |
1352 | jnz .read_loop |
1354 | jnz .read_loop |
1353 | pop bx ; clear stack |
1355 | pop bx ; clear stack |
1354 | 1356 | ||
1355 | ok_sys_on_floppy: |
1357 | ok_sys_on_floppy: |
1356 | mov si, backspace2 |
1358 | mov si, backspace2 |
1357 | call printplain |
1359 | call printplain |
1358 | mov si, okt |
1360 | mov si, okt |
1359 | call printplain |
1361 | call printplain |
1360 | no_sys_on_floppy: |
1362 | no_sys_on_floppy: |
1361 | xor ax, ax ; reset drive |
1363 | xor ax, ax ; reset drive |
1362 | xor dx, dx |
1364 | xor dx, dx |
1363 | int 0x13 |
1365 | int 0x13 |
1364 | mov dx, 0x3f2 ; floppy motor off |
1366 | mov dx, 0x3f2 ; floppy motor off |
1365 | mov al, 0 |
1367 | mov al, 0 |
1366 | out dx, al |
1368 | out dx, al |
1367 | 1369 | ||
1368 | if defined extended_primary_loader |
1370 | if defined extended_primary_loader |
1369 | cmp [boot_dev], 1 |
1371 | cmp [boot_dev], 1 |
1370 | jne no_sys_from_primary |
1372 | jne no_sys_from_primary |
1371 | ; load kolibri.img using callback from primary loader |
1373 | ; load kolibri.img using callback from primary loader |
1372 | and word [movedesc + 24 + 2], 0 |
1374 | and word [movedesc + 24 + 2], 0 |
1373 | mov byte [movedesc + 24 + 4], 10h |
1375 | mov byte [movedesc + 24 + 4], 10h |
1374 | ; read in blocks of 64K until file is fully loaded |
1376 | ; read in blocks of 64K until file is fully loaded |
1375 | mov ax, 1 |
1377 | mov ax, 1 |
1376 | .repeat: |
1378 | .repeat: |
1377 | mov di, image_file_struct |
1379 | mov di, image_file_struct |
1378 | call [bootcallback] |
1380 | call [bootcallback] |
1379 | push cs |
1381 | push cs |
1380 | pop ds |
1382 | pop ds |
1381 | push cs |
1383 | push cs |
1382 | pop es |
1384 | pop es |
1383 | cmp bx, 1 |
1385 | cmp bx, 1 |
1384 | ja sayerr_badsect |
1386 | ja sayerr_badsect |
1385 | push bx |
1387 | push bx |
1386 | mov si, movedesc |
1388 | mov si, movedesc |
1387 | and word [si + 16 + 2], 0 |
1389 | and word [si + 16 + 2], 0 |
1388 | mov byte [si + 16 + 4], 4 |
1390 | mov byte [si + 16 + 4], 4 |
1389 | mov ah, 87h |
1391 | mov ah, 87h |
1390 | mov cx, 8000h |
1392 | mov cx, 8000h |
1391 | int 15h |
1393 | int 15h |
1392 | pop bx |
1394 | pop bx |
1393 | test ah, ah |
1395 | test ah, ah |
1394 | jnz sayerr_memmove |
1396 | jnz sayerr_memmove |
1395 | inc byte [si + 24 + 4] |
1397 | inc byte [si + 24 + 4] |
1396 | test bx, bx |
1398 | test bx, bx |
1397 | jz no_sys_from_primary |
1399 | jz no_sys_from_primary |
1398 | mov ax, 2 |
1400 | mov ax, 2 |
1399 | jmp .repeat |
1401 | jmp .repeat |
1400 | no_sys_from_primary: |
1402 | no_sys_from_primary: |
1401 | end if |
1403 | end if |
1402 | 1404 | ||
1403 | ; SET GRAPHICS |
1405 | ; SET GRAPHICS |
1404 | 1406 | ||
1405 | xor ax, ax |
1407 | xor ax, ax |
1406 | mov es, ax |
1408 | mov es, ax |
1407 | 1409 | ||
1408 | mov ax, [es:BOOT_VESA_MODE] ; vga & 320x200 |
1410 | mov ax, [es:BOOT_VESA_MODE] ; vga & 320x200 |
1409 | mov bx, ax |
1411 | mov bx, ax |
1410 | cmp ax, 0x13 |
1412 | cmp ax, 0x13 |
1411 | je setgr |
1413 | je setgr |
1412 | cmp ax, 0x12 |
1414 | cmp ax, 0x12 |
1413 | je setgr |
1415 | je setgr |
1414 | mov ax, 0x4f02 ; Vesa |
1416 | mov ax, 0x4f02 ; Vesa |
1415 | setgr: |
1417 | setgr: |
1416 | int 0x10 |
1418 | int 0x10 |
1417 | test ah, ah |
1419 | test ah, ah |
1418 | mov si, fatalsel |
1420 | mov si, fatalsel |
1419 | jnz v_mode_error |
1421 | jnz v_mode_error |
1420 | ; set mode 0x12 graphics registers: |
1422 | ; set mode 0x12 graphics registers: |
1421 | cmp bx, 0x12 |
1423 | cmp bx, 0x12 |
1422 | jne gmok2 |
1424 | jne gmok2 |
1423 | 1425 | ||
1424 | mov al, 0x05 |
1426 | mov al, 0x05 |
1425 | mov dx, 0x03ce |
1427 | mov dx, 0x03ce |
1426 | push dx |
1428 | push dx |
1427 | out dx, al ; select GDC mode register |
1429 | out dx, al ; select GDC mode register |
1428 | mov al, 0x02 |
1430 | mov al, 0x02 |
1429 | inc dx |
1431 | inc dx |
1430 | out dx, al ; set write mode 2 |
1432 | out dx, al ; set write mode 2 |
1431 | 1433 | ||
1432 | mov al, 0x02 |
1434 | mov al, 0x02 |
1433 | mov dx, 0x03c4 |
1435 | mov dx, 0x03c4 |
1434 | out dx, al ; select VGA sequencer map mask register |
1436 | out dx, al ; select VGA sequencer map mask register |
1435 | mov al, 0x0f |
1437 | mov al, 0x0f |
1436 | inc dx |
1438 | inc dx |
1437 | out dx, al ; set mask for all planes 0-3 |
1439 | out dx, al ; set mask for all planes 0-3 |
1438 | 1440 | ||
1439 | mov al, 0x08 |
1441 | mov al, 0x08 |
1440 | pop dx |
1442 | pop dx |
1441 | out dx, al ; select GDC bit mask register |
1443 | out dx, al ; select GDC bit mask register |
1442 | ; for writes to 0x03cf |
1444 | ; for writes to 0x03cf |
1443 | gmok2: |
1445 | gmok2: |
1444 | push ds |
1446 | push ds |
1445 | pop es |
1447 | pop es |