Subversion Repositories Kolibri OS

Rev

Rev 34 | Rev 76 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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