Subversion Repositories Kolibri OS

Rev

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

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