Subversion Repositories Kolibri OS

Rev

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

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