Subversion Repositories Kolibri OS

Rev

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

Rev 1508 Rev 1700
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
7
 
8
$Revision: 1508 $
8
$Revision: 1700 $
9
 
9
 
10
struc VBE_VGAInfo {
10
struc VBE_VGAInfo {
11
  .VESASignature          dd ?    ; char
11
  .VESASignature          dd ?    ; char
12
  .VESAVersion            dw ?    ; short
12
  .VESAVersion            dw ?    ; short
13
  .OemStringPtr           dd ?    ; char *
13
  .OemStringPtr           dd ?    ; char *
14
  .Capabilities           dd ?    ; ulong
14
  .Capabilities           dd ?    ; ulong
15
  .VideoModePtr           dd ?    ; ulong
15
  .VideoModePtr           dd ?    ; ulong
16
  .TotalMemory            dw ?    ; short
16
  .TotalMemory            dw ?    ; short
17
  ; VBE 2.0+
17
  ; VBE 2.0+
18
  .OemSoftwareRev         db ?    ; short
18
  .OemSoftwareRev         db ?    ; short
19
  .OemVendorNamePtr       dw ?    ; char *
19
  .OemVendorNamePtr       dw ?    ; char *
20
  .OemProductNamePtr      dw ?    ; char *
20
  .OemProductNamePtr      dw ?    ; char *
21
  .OemProductRevPtr       dw ?    ; char *
21
  .OemProductRevPtr       dw ?    ; char *
22
  .reserved               rb 222  ; char
22
  .reserved               rb 222  ; char
23
  .OemData                rb 256  ; char
23
  .OemData                rb 256  ; char
24
}
24
}
25
 
25
 
26
struc VBE_ModeInfo {
26
struc VBE_ModeInfo {
27
  .ModeAttributes         dw ?    ; short
27
  .ModeAttributes         dw ?    ; short
28
  .WinAAttributes         db ?    ; char
28
  .WinAAttributes         db ?    ; char
29
  .WinBAttributes         db ?    ; char
29
  .WinBAttributes         db ?    ; char
30
  .WinGranularity         dw ?    ; short
30
  .WinGranularity         dw ?    ; short
31
  .WinSize                dw ?    ; short
31
  .WinSize                dw ?    ; short
32
  .WinASegment            dw ?    ; ushort
32
  .WinASegment            dw ?    ; ushort
33
  .WinBSegment            dw ?    ; ushort
33
  .WinBSegment            dw ?    ; ushort
34
  .WinFuncPtr             dd ?    ; void *
34
  .WinFuncPtr             dd ?    ; void *
35
  .BytesPerScanLine       dw ?    ; short
35
  .BytesPerScanLine       dw ?    ; short
36
  .XRes                   dw ?    ; short
36
  .XRes                   dw ?    ; short
37
  .YRes                   dw ?    ; short
37
  .YRes                   dw ?    ; short
38
  .XCharSize              db ?    ; char
38
  .XCharSize              db ?    ; char
39
  .YCharSize              db ?    ; char
39
  .YCharSize              db ?    ; char
40
  .NumberOfPlanes         db ?    ; char
40
  .NumberOfPlanes         db ?    ; char
41
  .BitsPerPixel           db ?    ; char
41
  .BitsPerPixel           db ?    ; char
42
  .NumberOfBanks          db ?    ; char
42
  .NumberOfBanks          db ?    ; char
43
  .MemoryModel            db ?    ; char
43
  .MemoryModel            db ?    ; char
44
  .BankSize               db ?    ; char
44
  .BankSize               db ?    ; char
45
  .NumberOfImagePages     db ?    ; char
45
  .NumberOfImagePages     db ?    ; char
46
  .res1                   db ?    ; char
46
  .res1                   db ?    ; char
47
  .RedMaskSize            db ?    ; char
47
  .RedMaskSize            db ?    ; char
48
  .RedFieldPosition       db ?    ; char
48
  .RedFieldPosition       db ?    ; char
49
  .GreenMaskSize          db ?    ; char
49
  .GreenMaskSize          db ?    ; char
50
  .GreenFieldPosition     db ?    ; char
50
  .GreenFieldPosition     db ?    ; char
51
  .BlueMaskSize           db ?    ; char
51
  .BlueMaskSize           db ?    ; char
52
  .BlueFieldPosition      db ?    ; char
52
  .BlueFieldPosition      db ?    ; char
53
  .RsvedMaskSize          db ?    ; char
53
  .RsvedMaskSize          db ?    ; char
54
  .RsvedFieldPosition     db ?    ; char
54
  .RsvedFieldPosition     db ?    ; char
55
  .DirectColorModeInfo    db ?    ; char ; MISSED IN THIS TUTORIAL!! SEE ABOVE
55
  .DirectColorModeInfo    db ?    ; char ; MISSED IN THIS TUTORIAL!! SEE ABOVE
56
  ; VBE 2.0+
56
  ; VBE 2.0+
57
  .PhysBasePtr            dd ?    ; ulong
57
  .PhysBasePtr            dd ?    ; ulong
58
  .OffScreenMemOffset     dd ?    ; ulong
58
  .OffScreenMemOffset     dd ?    ; ulong
59
  .OffScreenMemSize       dw ?    ; short
59
  .OffScreenMemSize       dw ?    ; short
60
  ; VBE 3.0+
60
  ; VBE 3.0+
61
  .LinbytesPerScanLine    dw ?    ; short
61
  .LinbytesPerScanLine    dw ?    ; short
62
  .BankNumberOfImagePages db ?    ; char
62
  .BankNumberOfImagePages db ?    ; char
63
  .LinNumberOfImagePages  db ?    ; char
63
  .LinNumberOfImagePages  db ?    ; char
64
  .LinRedMaskSize         db ?    ; char
64
  .LinRedMaskSize         db ?    ; char
65
  .LinRedFieldPosition    db ?    ; char
65
  .LinRedFieldPosition    db ?    ; char
66
  .LingreenMaskSize       db ?    ; char
66
  .LingreenMaskSize       db ?    ; char
67
  .LinGreenFieldPosition  db ?    ; char
67
  .LinGreenFieldPosition  db ?    ; char
68
  .LinBlueMaskSize        db ?    ; char
68
  .LinBlueMaskSize        db ?    ; char
69
  .LinBlueFieldPosition   db ?    ; char
69
  .LinBlueFieldPosition   db ?    ; char
70
  .LinRsvdMaskSize        db ?    ; char
70
  .LinRsvdMaskSize        db ?    ; char
71
  .LinRsvdFieldPosition   db ?    ; char
71
  .LinRsvdFieldPosition   db ?    ; char
72
  .MaxPixelClock          dd ?    ; ulong
72
  .MaxPixelClock          dd ?    ; ulong
73
  .res2                   rb 190  ; char
73
  .res2                   rb 190  ; char
74
}
74
}
75
 
75
 
76
virtual at $A000
76
virtual at $A000
77
  vi VBE_VGAInfo
77
  vi VBE_VGAInfo
78
  mi VBE_ModeInfo
78
  mi VBE_ModeInfo
79
modes_table:
79
modes_table:
80
end virtual
80
end virtual
81
cursor_pos  dw 0         ;âðåìåííîå õðàíåíèå êóðñîðà.
81
cursor_pos  dw 0         ;âðåìåííîå õðàíåíèå êóðñîðà.
82
home_cursor dw 0    ;current shows rows a table
82
home_cursor dw 0    ;current shows rows a table
83
end_cursor  dw 0     ;end of position current shows rows a table
83
end_cursor  dw 0     ;end of position current shows rows a table
84
scroll_start dw 0    ;start position of scroll bar
84
scroll_start dw 0    ;start position of scroll bar
85
scroll_end  dw 0     ;end position of scroll bar
85
scroll_end  dw 0     ;end position of scroll bar
86
long_v_table equ 9   ;long of visible video table
86
long_v_table equ 9   ;long of visible video table
87
size_of_step equ 10
87
size_of_step equ 10
88
scroll_area_size equ (long_v_table-2)
88
scroll_area_size equ (long_v_table-2)
89
int2str:
89
int2str:
90
        dec     bl
90
        dec     bl
91
        jz      @f
91
        jz      @f
92
        xor     edx,edx
92
        xor     edx,edx
93
        div     ecx
93
        div     ecx
94
        push    edx
94
        push    edx
95
        call    int2str
95
        call    int2str
96
        pop     eax
96
        pop     eax
97
    @@: or      al,0x30
97
    @@: or      al,0x30
98
        mov     [ds:di],al
98
        mov     [ds:di],al
99
        inc     di
99
        inc     di
100
        ret
100
        ret
101
 
101
 
102
int2strnz:
102
int2strnz:
103
        cmp     eax,ecx
103
        cmp     eax,ecx
104
        jb      @f
104
        jb      @f
105
        xor     edx,edx
105
        xor     edx,edx
106
        div     ecx
106
        div     ecx
107
        push    edx
107
        push    edx
108
        call    int2strnz
108
        call    int2strnz
109
        pop     eax
109
        pop     eax
110
    @@: or      al,0x30
110
    @@: or      al,0x30
111
        mov     [es:di],al
111
        mov     [es:di],al
112
        inc     di
112
        inc     di
113
        ret
113
        ret
114
 
114
 
115
;-------------------------------------------------------
115
;-------------------------------------------------------
116
;Write message about incorrect v_mode and write message about jmp on swith v_mode
116
;Write message about incorrect v_mode and write message about jmp on swith v_mode
117
v_mode_error:
117
v_mode_error:
118
        _setcursor 19,2
118
        _setcursor 19,2
119
        mov     si, fatalsel
119
        mov     si, fatalsel
120
        call    printplain
120
        call    printplain
121
        _setcursor 20,2
121
        _setcursor 20,2
122
        mov     si,pres_key
122
        mov     si,pres_key
123
        call    printplain
123
        call    printplain
124
        xor     eax,eax
124
        xor     eax,eax
125
        int     16h
125
        int     16h
126
        jmp     cfgmanager.d
126
        jmp     cfgmanager.d
127
;-------------------------------------------------------
127
;-------------------------------------------------------
128
;
128
;
129
 
129
 
130
 
130
 
131
 
131
 
132
;-------------------------------------------------------
132
;-------------------------------------------------------
133
print_vesa_info:
133
print_vesa_info:
134
        _setcursor 5,2
134
        _setcursor 5,2
135
 
135
 
136
        mov     [es:vi.VESASignature],'VBE2'
136
        mov     [es:vi.VESASignature],'VBE2'
137
        mov     ax,0x4F00
137
        mov     ax,0x4F00
138
        mov     di,vi      ;0xa000
138
        mov     di,vi      ;0xa000
139
        int     0x10
139
        int     0x10
140
        or      ah,ah
140
        or      ah,ah
141
        jz      @f
141
        jz      @f
142
        mov     [es:vi.VESASignature],'VESA'
142
        mov     [es:vi.VESASignature],'VESA'
143
        mov     ax,$4F00
143
        mov     ax,$4F00
144
        mov     di,vi
144
        mov     di,vi
145
        int     0x10
145
        int     0x10
146
        or      ah,ah
146
        or      ah,ah
147
        jnz     .exit
147
        jnz     .exit
148
  @@:
148
  @@:
149
        cmp     [es:vi.VESASignature],'VESA'
149
        cmp     [es:vi.VESASignature],'VESA'
150
        jne     .exit
150
        jne     .exit
151
        cmp     [es:vi.VESAVersion],0x0100
151
        cmp     [es:vi.VESAVersion],0x0100
152
        jb      .exit
152
        jb      .exit
153
        jmp     .vesaok2
153
        jmp     .vesaok2
154
 
154
 
155
  .exit:
155
  .exit:
156
        mov     si,novesa
156
        mov     si,novesa
157
        call    printplain
157
        call    printplain
158
        ret
158
        ret
159
 
159
 
160
  .vesaok2:
160
  .vesaok2:
161
        mov     ax,[es:vi.VESAVersion]
161
        mov     ax,[es:vi.VESAVersion]
162
        add     ax,'00'
162
        add     ax,'00'
163
 
163
 
164
        mov     [s_vesa.ver], ah
164
        mov     [s_vesa.ver], ah
165
        mov     [s_vesa.ver+2], al
165
        mov     [s_vesa.ver+2], al
166
        mov     si,s_vesa
166
        mov     si,s_vesa
167
        call    printplain
167
        call    printplain
168
 
168
 
169
        _setcursor 4,2
169
        _setcursor 4,2
170
        mov     si,word[es:vi.OemStringPtr]
170
        mov     si,word[es:vi.OemStringPtr]
171
        mov     di,si
171
        mov     di,si
172
 
172
 
173
        push    ds
173
        push    ds
174
        mov     ds,word[es:vi.OemStringPtr+2]
174
        mov     ds,word[es:vi.OemStringPtr+2]
175
        call    printplain
175
        call    printplain
176
        pop     ds
176
        pop     ds
177
 
177
 
178
        ret
178
        ret
179
;-----------------------------------------------------------------------------
179
;-----------------------------------------------------------------------------
180
 
180
 
181
calc_vmodes_table:
181
calc_vmodes_table:
182
        pushad
182
        pushad
183
 
183
 
184
;        push    0
184
;        push    0
185
;        pop     es
185
;        pop     es
186
 
186
 
187
        lfs     si, [es:vi.VideoModePtr]
187
        lfs     si, [es:vi.VideoModePtr]
188
 
188
 
189
        mov     bx,modes_table
189
        mov     bx,modes_table
190
;save no vesa mode of work 320x200, EGA/CGA 256 colors and 640x480, VGA 16 cols
-
 
191
;        mov     word [es:bx],640
-
 
192
;        mov     word [es:bx+2],480
-
 
193
;        mov     word [es:bx+6],0x13
-
 
194
        
190
 
195
;        mov     word [es:bx+10],640
-
 
196
;        mov     word [es:bx+12],480
-
 
197
;        mov     word [es:bx+16],0x12
-
 
198
;        add     bx,20
-
 
199
  .next_mode:
191
  .next_mode:
200
        mov     cx,word [fs:si] ; mode number
192
        mov     cx,word [fs:si] ; mode number
201
        cmp     cx,-1
193
        cmp     cx,-1
202
        je      .modes_ok.2
194
        je      .modes_ok.2
203
 
195
 
204
        mov     ax,0x4F01
196
        mov     ax,0x4F01
205
        mov     di,mi
197
        mov     di,mi
206
        int     0x10
198
        int     0x10
207
 
199
 
208
        or      ah,ah
200
        or      ah,ah
209
        jnz     .modes_ok.2;vesa_info.exit
201
        jnz     .modes_ok.2		;vesa_info.exit
210
 
202
 
211
        test    [es:mi.ModeAttributes],00000001b   ;videomode support ?
203
        test    [es:mi.ModeAttributes],00000001b   ;videomode support ?
212
        jz      @f
204
        jz      @f
213
        test    [es:mi.ModeAttributes],00010000b   ;picture ?
205
        test    [es:mi.ModeAttributes],00010000b   ;picture ?
214
        jz      @f
206
        jz      @f
215
        test    [es:mi.ModeAttributes],10000000b   ;LFB ?
207
        test    [es:mi.ModeAttributes],10000000b   ;LFB ?
216
        jz      @f
208
        jz      @f
217
 
209
 
218
        cmp     [es:mi.BitsPerPixel], 32	;to show only 32 bpp videomodes 
210
        cmp     [es:mi.BitsPerPixel], 32	;to show only 32 bpp videomodes 
219
        jb      @f
211
        jb      @f
220
 
212
 
221
.l0:
213
.l0:
222
        cmp     [es:mi.XRes],800	; only 800x600 and higher
214
        cmp     [es:mi.XRes],800	; only 800x600 and higher
223
        jb      @f
215
        jb      @f
224
 
216
 
225
        mov     ax,[es:mi.XRes]
217
        mov     ax,[es:mi.XRes]
226
        mov     [es:bx+0],ax               ; +0[2] : resolution X
218
        mov     [es:bx+0],ax               ; +0[2] : resolution X
227
        mov     ax,[es:mi.YRes]
219
        mov     ax,[es:mi.YRes]
228
        mov     [es:bx+2],ax               ; +2[2] : resolution Y
220
        mov     [es:bx+2],ax               ; +2[2] : resolution Y
229
        mov     ax,[es:mi.ModeAttributes]
221
        mov     ax,[es:mi.ModeAttributes]
230
        mov     [es:bx+4],ax               ; +4[2] : attributes
222
        mov     [es:bx+4],ax               ; +4[2] : attributes
231
 
223
 
232
        cmp     [s_vesa.ver],'2'
224
;<<        cmp     [s_vesa.ver],'2'
233
        jb      .lp1
225
;<<        jb      .lp1
234
 
226
 
235
        or      cx,0x4000  ; use LFB
227
        or      cx,0x4000  			; use LFB <<< ?
236
.lp1:	mov     [es:bx+6],cx               ; +6 : mode number
228
.lp1:	mov     [es:bx+6],cx               ; +6 : mode number
237
        movzx   ax,byte [es:mi.BitsPerPixel]
229
        movzx   ax,byte [es:mi.BitsPerPixel]
238
        mov     word [es:bx+8],ax               ; +8 : bits per pixel
230
        mov     word [es:bx+8],ax               ; +8 : bits per pixel << ?
239
        add     bx,size_of_step                 ; size of record 
231
        add     bx,size_of_step                 ; size of record 
240
 
232
 
241
    @@:
233
    @@:
242
        add     si,2
234
        add     si,2
243
        jmp     .next_mode
235
        jmp     .next_mode
244
 
236
 
245
  .modes_ok.2:
237
  .modes_ok.2:
246
 
238
 
247
        mov     word[es:bx],-1  ;end video table
239
        mov     word[es:bx],-1  ;end video table
248
        mov     word[end_cursor],bx     ;save end cursor position
240
        mov     word[end_cursor],bx     ;save end cursor position
249
        popad
241
        popad
250
        ret
242
        ret
251
 
243
 
252
;-----------------------------------------------------------------------------
244
;-----------------------------------------------------------------------------
253
 
245
 
254
draw_current_vmode:
246
;draw_current_vmode:
255
        push    0
247
;        push    0
256
        pop     es
248
;        pop     es
257
 
249
 
258
        mov     si,word [cursor_pos]
250
;        mov     si,word [cursor_pos]
259
 
251
 
260
        cmp     word [es:si+6],0x12
252
;        cmp     word [es:si+6],0x12
261
        je      .no_vesa_0x12
253
;        je      .no_vesa_0x12
262
 
254
 
263
        cmp     word [es:si+6],0x13
255
;        cmp     word [es:si+6],0x13
264
        je      .no_vesa_0x13
256
;        je      .no_vesa_0x13
265
 
257
 
266
        mov     di,loader_block_error
258
;        mov     di,loader_block_error
267
        movzx   eax,word[es:si+0]
259
;        movzx   eax,word[es:si+0]
268
        mov     ecx,10
260
;        mov     ecx,10
269
        call    int2strnz
261
;        call    int2strnz
270
        mov     byte[es:di],'x'
262
;        mov     byte[es:di],'x'
271
        inc     di
263
;        inc     di
272
        movzx   eax,word[es:si+2]
264
;        movzx   eax,word[es:si+2]
273
        call    int2strnz
265
;        call    int2strnz
274
        mov     byte[es:di],'x'
266
;        mov     byte[es:di],'x'
275
        inc     di
267
;        inc     di
276
        movzx   eax,word[es:si+8]
268
;        movzx   eax,word[es:si+8]
277
        call    int2strnz
269
;        call    int2strnz
278
        mov     dword[es:di],0x00000d0a
270
;        mov     dword[es:di],0x00000d0a
279
        mov     si,loader_block_error
271
;        mov     si,loader_block_error
280
        push    ds
272
;        push    ds
281
        push    es
273
;        push    es
282
        pop     ds
274
;        pop     ds
283
        call    printplain
275
;        call    printplain
284
        pop     ds
276
;        pop     ds
285
        ret
277
;        ret
286
.no_vesa_0x13:
278
;.no_vesa_0x13:
287
        mov     si,mode0
279
;        mov     si,mode0
288
        jmp     .print
280
;        jmp     .print
289
.no_vesa_0x12:
281
;.no_vesa_0x12:
290
        mov     si,mode9
282
;        mov     si,mode9
291
.print:
283
;.print:
292
        call    printplain
284
;        call    printplain
293
        ret        
285
;        ret        
294
;-----------------------------------------------------------------------------
286
;-----------------------------------------------------------------------------
295
check_first_parm:
287
check_first_parm:
296
        mov     si,word [preboot_graph]
288
        mov     si,word [preboot_graph]
297
        test    si,si
289
        test    si,si
298
        jnz      .no_zero        ;if no zero
290
        jnz      .no_zero        ;if no zero
299
.zerro:
291
.zerro:
300
;        mov     ax,modes_table
292
;        mov     ax,modes_table
301
;        mov     word [cursor_pos],ax
293
;        mov     word [cursor_pos],ax
302
;        mov     word [home_cursor],ax
294
;        mov     word [home_cursor],ax
303
;        mov     word [preboot_graph],ax
295
;        mov     word [preboot_graph],ax
304
;SET default video of mode first probe will fined a move of work 1024x768@32
296
;SET default video of mode first probe will fined a move of work 1024x768@32
305
 
297
 
306
        mov     ax,1024
298
        mov     ax,1024
307
        mov     bx,768
299
        mov     bx,768
308
        mov     si,modes_table
300
        mov     si,modes_table
309
        call    .loops
301
        call    .loops
310
        test    ax,ax
302
        test    ax,ax
311
        jz     .ok_found_mode
303
        jz     .ok_found_mode
312
        mov     ax,800
-
 
313
        mov     bx,600
-
 
314
        mov     si,modes_table
-
 
315
        call    .loops
-
 
316
        test    ax,ax
-
 
317
        jz     .ok_found_mode
-
 
318
 
304
 
319
        mov     si,modes_table
305
        mov     si,modes_table
320
        jmp     .ok_found_mode
306
        jmp     .ok_found_mode
321
 
307
 
322
.no_zero:
308
.no_zero:
323
	mov	bp,word [number_vm]
309
	mov	bp,word [number_vm]
324
        cmp     bp,word [es:si+6]
310
        cmp     bp,word [es:si+6]
325
        jz      .ok_found_mode
311
        jz      .ok_found_mode
326
        mov     ax,word [x_save]
312
        mov     ax,word [x_save]
327
        mov     bx,word [y_save]
313
        mov     bx,word [y_save]
328
        mov     si,modes_table
314
        mov     si,modes_table
329
        call    .loops
315
        call    .loops
330
        test    ax,ax
316
        test    ax,ax
331
        jz     .ok_found_mode
317
        jz     .ok_found_mode
332
 
318
 
333
	mov    si,modes_table
319
	mov    si,modes_table
334
;        cmp     ax,modes_table
-
 
335
;        jb      .zerro           ;check on correct if bellow
-
 
336
;        cmp     ax,word [end_cursor]
-
 
337
;        ja      .zerro           ;check on correct if anymore
-
 
338
 
320
 
339
.ok_found_mode:
321
.ok_found_mode:
340
        mov     word [home_cursor],si
322
        mov     word [home_cursor],si
341
;        mov     word [cursor_pos],si
-
 
342
        mov     word [preboot_graph],si
323
        mov     word [preboot_graph],si
343
        mov     ax,si
324
        mov     ax,si
344
 
325
 
345
        mov     ecx,long_v_table
326
        mov     ecx,long_v_table
346
 
327
 
347
.loop:  add     ax,size_of_step
328
.loop:  add     ax,size_of_step
348
        cmp     ax,word [end_cursor]
329
        cmp     ax,word [end_cursor]
349
        jae     .next_step
330
        jae     .next_step
350
        loop    .loop
331
        loop    .loop
351
.next_step:
332
.next_step:
352
        sub     ax,size_of_step*long_v_table
333
        sub     ax,size_of_step*long_v_table
353
        cmp     ax,modes_table
334
        cmp     ax,modes_table
354
        jae     @f
335
        jae     @f
355
        mov     ax,modes_table
336
        mov     ax,modes_table
356
@@:
337
@@:
357
 
338
 
358
        mov     word [home_cursor],ax
339
        mov     word [home_cursor],ax
359
        mov	si,[preboot_graph]
340
        mov	si,[preboot_graph]
360
        mov     word [cursor_pos],si
341
        mov     word [cursor_pos],si
361
 
342
 
362
        push    word [es:si]
343
        push    word [es:si]
363
        pop     word [x_save]
344
        pop     word [x_save]
364
        push    word [es:si+2]
345
        push    word [es:si+2]
365
        pop     word [y_save]
346
        pop     word [y_save]
366
        push    word [es:si+6]
347
        push    word [es:si+6]
367
        pop     word [number_vm]
348
        pop     word [number_vm]
368
 
349
 
369
        ret
350
        ret
370
;;;;;;;;;;;;;;;;;;;;;;;;;;;
351
;;;;;;;;;;;;;;;;;;;;;;;;;;;
371
.loops:
352
.loops:
372
        cmp     ax,word [es:si]
353
        cmp     ax,word [es:si]
373
        jne     .next
354
        jne     .next
374
        cmp     bx,word [es:si+2]
355
        cmp     bx,word [es:si+2]
375
        jne     .next
356
        jne     .next
376
        cmp     word [es:si+8],32
-
 
377
        je      .ok
-
 
378
        cmp     word [es:si+8],24
-
 
379
        je      .ok
357
        je      .ok
380
.next:  add     si,size_of_step
358
.next:  add     si,size_of_step
381
        cmp     word [es:si],-1
359
        cmp     word [es:si],-1
382
        je      .exit
360
        je      .exit
383
        jmp     .loops
361
        jmp     .loops
384
.ok:    xor     ax,ax        
362
.ok:    xor     ax,ax        
385
	ret
363
	ret
386
.exit:  or	ax,-1
364
.exit:  or	ax,-1
387
	ret
365
	ret
388
 
366
 
389
 
367
 
390
;-----------------------------------------------------------------------------
368
;-----------------------------------------------------------------------------
391
 
369
 
392
;default_vmode:
370
;default_vmode:
393
        
371
        
394
;-----------------------------------------------------------------------------
372
;-----------------------------------------------------------------------------
395
draw_vmodes_table:
373
draw_vmodes_table:
396
        _setcursor 9, 2
374
;        _setcursor 9, 2
397
        mov     si,gr_mode
375
;        mov     si,gr_mode
398
        call    printplain
376
;        call    printplain
399
 
377
 
400
        mov     si,_st
378
;        mov     si,_st
401
        call    printplain
379
;        call    printplain
402
 
380
 
403
        push    word [cursor_pos]
381
;        push    word [cursor_pos]
404
        pop     ax
382
;        pop     ax
405
        push    word [home_cursor]
383
;        push    word [home_cursor]
406
        pop     si
384
;        pop     si
407
        mov     cx,si
385
;        mov     cx,si
408
 
386
 
409
        cmp     ax,si
387
 ;       cmp     ax,si
410
        je      .ok
388
;        je      .ok
411
        jb      .low
389
;        jb      .low
412
 
390
 
413
 
391
 
414
        add     cx,size_of_step*long_v_table
392
 ;       add     cx,size_of_step*long_v_table
415
        
393
        
416
        cmp     ax,cx
394
  ;      cmp     ax,cx
417
        jb      .ok
395
;        jb      .ok
418
        
396
        
419
        sub     cx,size_of_step*long_v_table
397
;        sub     cx,size_of_step*long_v_table
420
        add     cx,size_of_step
398
;        add     cx,size_of_step
421
        cmp     cx,word[end_cursor]
399
;        cmp     cx,word[end_cursor]
422
        jae     .ok
400
;        jae     .ok
423
        add     si,size_of_step
401
;        add     si,size_of_step
424
        push    si
402
;        push    si
425
        pop     word [home_cursor]
403
;        pop     word [home_cursor]
426
        jmp     .ok
404
;        jmp     .ok
427
 
405
 
428
 
406
 
429
.low:   sub     cx,size_of_step
407
;.low:   sub     cx,size_of_step
430
        cmp     cx,modes_table
408
;        cmp     cx,modes_table
431
        jb      .ok
409
;        jb      .ok
432
        push    cx
410
;        push    cx
433
        push    cx
411
;        push    cx
434
        pop     word [home_cursor]
412
;        pop     word [home_cursor]
435
        pop     si
413
;        pop     si
436
 
414
 
437
 
415
 
438
.ok:
416
;.ok:
439
; calculate scroll position
417
; calculate scroll position
440
        push    si
418
;        push    si
441
        mov     ax, [end_cursor]
419
;        mov     ax, [end_cursor]
442
        sub     ax, modes_table
420
;        sub     ax, modes_table
443
        mov     bx, size_of_step
421
;        mov     bx, size_of_step
444
        cwd
422
;        cwd
445
        div     bx
423
;        div     bx
446
        mov     si, ax          ; si = size of list
424
;        mov     si, ax          ; si = size of list
447
        mov     ax, [home_cursor]
425
;        mov     ax, [home_cursor]
448
        sub     ax, modes_table
426
;        sub     ax, modes_table
449
        cwd
427
;        cwd
450
        div     bx
428
;        div     bx
451
        mov     di, ax
429
;        mov     di, ax
452
        mov     ax, scroll_area_size*long_v_table
430
;        mov     ax, scroll_area_size*long_v_table
453
        cwd
431
;        cwd
454
        div     si
432
;        div     si
455
        test    ax, ax
433
;        test    ax, ax
456
        jnz     @f
434
;        jnz     @f
457
        inc     ax
435
;        inc     ax
458
@@:
436
;@@:
459
        cmp     al, scroll_area_size
437
;        cmp     al, scroll_area_size
460
        jb      @f
438
;        jb      @f
461
        mov     al, scroll_area_size
439
;        mov     al, scroll_area_size
462
@@:
440
;@@:
463
        mov     cx, ax
441
;        mov     cx, ax
464
; cx = scroll height
442
; cx = scroll height
465
; calculate scroll pos
443
; calculate scroll pos
466
        xor     bx, bx          ; initialize scroll pos
444
;        xor     bx, bx          ; initialize scroll pos
467
        sub     al, scroll_area_size+1
445
;        sub     al, scroll_area_size+1
468
        neg     al
446
;        neg     al
469
        sub     si, long_v_table-1
447
;        sub     si, long_v_table-1
470
        jbe     @f
448
;        jbe     @f
471
        mul     di
449
;        mul     di
472
        div     si
450
;        div     si
473
        mov     bx, ax
451
;        mov     bx, ax
474
@@:
452
;@@:
475
        inc     bx
453
;        inc     bx
476
        imul    ax, bx, size_of_step
454
;        imul    ax, bx, size_of_step
477
        add     ax, [home_cursor]
455
;        add     ax, [home_cursor]
478
        mov     [scroll_start], ax
456
;        mov     [scroll_start], ax
479
        imul    cx, size_of_step
457
;        imul    cx, size_of_step
480
        add     ax, cx
458
;        add     ax, cx
481
        mov     [scroll_end], ax
459
;        mov     [scroll_end], ax
482
        pop     si
460
;        pop     si
483
        mov     bp,long_v_table               ;show rows
461
;        mov     bp,long_v_table               ;show rows
484
.@@_next_bit:
462
;.@@_next_bit:
485
;clear cursor
463
;clear cursor
486
	mov	ax,'  '
464
;	mov	ax,'  '
487
        mov     word[ds:_r1+21],ax
465
;        mov     word[ds:_r1+21],ax
488
        mov     word[ds:_r1+50],ax
466
;        mov     word[ds:_r1+50],ax
489
 
467
 
490
        mov     word[ds:_r2+21],ax
468
;        mov     word[ds:_r2+21],ax
491
        mov     word[ds:_r2+45],ax
469
;        mov     word[ds:_r2+45],ax
492
 
470
 
493
        mov     word[ds:_rs+21],ax
471
;        mov     word[ds:_rs+21],ax
494
        mov     word[ds:_rs+46],ax
472
;        mov     word[ds:_rs+46],ax
495
; draw string
473
; draw string
496
        cmp     word [es:si+6],0x12
474
;        cmp     word [es:si+6],0x12
497
        je      .show_0x12
475
;        je      .show_0x12
498
        cmp     word [es:si+6],0x13
476
;        cmp     word [es:si+6],0x13
499
        je      .show_0x13
477
;        je      .show_0x13
500
 
478
 
501
        movzx   eax,word[es:si]
479
;        movzx   eax,word[es:si]
502
        cmp     ax,-1
480
;        cmp     ax,-1
503
        je      .@@_end
481
;        je      .@@_end
504
        mov     di,_rs+23          
482
;        mov     di,_rs+23          
505
        mov     ecx,10
483
;        mov     ecx,10
506
        mov     bl,4
484
;        mov     bl,4
507
        call    int2str
485
;        call    int2str
508
        movzx   eax,word[es:si+2]
486
;        movzx   eax,word[es:si+2]
509
        inc     di
487
;        inc     di
510
        mov     bl,4
488
;        mov     bl,4
511
        call    int2str
489
;        call    int2str
512
 
490
 
513
        movzx   eax,word[es:si+8]
491
;        movzx   eax,word[es:si+8]
514
        inc     di
492
;        inc     di
515
        mov     bl,2
493
;        mov     bl,2
516
        call    int2str
494
;        call    int2str
517
 
495
 
518
        cmp     si, word [cursor_pos]
496
;        cmp     si, word [cursor_pos]
519
        jne     .next
497
;        jne     .next
520
;draw   cursor
498
;draw   cursor
521
        mov     word[ds:_rs+21],'>>'
499
;        mov     word[ds:_rs+21],'>>'
522
        mov     word[ds:_rs+46],'<<'
500
;        mov     word[ds:_rs+46],'<<'
523
        
501
        
524
 
502
 
525
 
503
 
526
.next:
504
;.next:
527
        push    si
505
;        push    si
528
        mov     si,_rs
506
;        mov     si,_rs
529
.@@_sh:
507
;.@@_sh:
530
; add to the string pseudographics for scrollbar
508
; add to the string pseudographics for scrollbar
531
        pop     bx
509
;        pop     bx
532
        push    bx
510
;        push    bx
533
        mov     byte [si+53], ' '
511
;        mov     byte [si+53], ' '
534
        cmp     bx, [scroll_start]
512
;        cmp     bx, [scroll_start]
535
        jb      @f
513
;        jb      @f
536
        cmp     bx, [scroll_end]
514
;        cmp     bx, [scroll_end]
537
        jae     @f
515
;        jae     @f
538
        mov     byte [si+53], 0xDB ; filled bar
516
;        mov     byte [si+53], 0xDB ; filled bar
539
@@:
517
;@@:
540
        push    bx
518
;        push    bx
541
        add     bx, size_of_step
519
;        add     bx, size_of_step
542
        cmp     bx, [end_cursor]
520
;        cmp     bx, [end_cursor]
543
        jnz     @f
521
;        jnz     @f
544
        mov     byte [si+53], 31 ; 'down arrow' symbol
522
;        mov     byte [si+53], 31 ; 'down arrow' symbol
545
@@:
523
;@@:
546
        sub     bx, [home_cursor]
524
;        sub     bx, [home_cursor]
547
        cmp     bx, size_of_step*long_v_table
525
;        cmp     bx, size_of_step*long_v_table
548
        jnz     @f
526
;        jnz     @f
549
        mov     byte [si+53], 31 ; 'down arrow' symbol
527
;        mov     byte [si+53], 31 ; 'down arrow' symbol
550
@@:
528
;@@:
551
        pop     bx
529
;        pop     bx
552
        cmp     bx, [home_cursor]
530
;        cmp     bx, [home_cursor]
553
        jnz     @f
531
;        jnz     @f
554
        mov     byte [si+53], 30 ; 'up arrow' symbol
532
;        mov     byte [si+53], 30 ; 'up arrow' symbol
555
@@:
533
;@@:
556
        call    printplain
534
;        call    printplain
557
        pop     si
535
;        pop     si
558
        add     si,size_of_step
536
;        add     si,size_of_step
559
 
537
 
560
        dec     bp
538
;        dec     bp
561
        jnz     .@@_next_bit
539
;        jnz     .@@_next_bit
562
 
540
 
563
.@@_end:
541
;.@@_end:
564
        mov     si,_bt
542
;        mov     si,_bt
565
        call    printplain
543
;        call    printplain
566
        ret
544
        ret
567
.show_0x13:
545
;.show_0x13:
568
        push    si
546
;        push    si
569
 
547
 
570
        cmp     si, word [cursor_pos]
548
;        cmp     si, word [cursor_pos]
571
        jne     @f
549
;        jne     @f
572
        mov     word[ds:_r1+21],'>>'
550
;        mov     word[ds:_r1+21],'>>'
573
        mov     word[ds:_r1+50],'<<'        
551
;        mov     word[ds:_r1+50],'<<'        
574
@@:
552
;@@:
575
        mov     si,_r1
553
;        mov     si,_r1
576
        jmp     .@@_sh
554
;        jmp     .@@_sh
577
.show_0x12:
555
;.show_0x12:
578
        push    si
556
;        push    si
579
        cmp     si, word [cursor_pos]
557
;        cmp     si, word [cursor_pos]
580
        jne     @f
558
;        jne     @f
581
 
559
 
582
        mov     word[ds:_r2+21],'>>'
560
;        mov     word[ds:_r2+21],'>>'
583
        mov     word[ds:_r2+45],'<<'
561
;        mov     word[ds:_r2+45],'<<'
584
@@:
562
;@@:
585
        mov     si,_r2
563
;        mov     si,_r2
586
        jmp     .@@_sh
564
;        jmp     .@@_sh
587
 
565
 
588
;-----------------------------------------------------------------------------
566
;-----------------------------------------------------------------------------
589
;Clear arrea of current video page (0xb800)
567
;Clear area of current video page (0xb800)
590
clear_vmodes_table:
568
clear_vmodes_table:
591
        pusha
569
        pusha
592
       ; draw frames
570
       ; draw frames
593
        push    es
571
        push    es
594
        push    0xb800
572
        push    0xb800
595
        pop     es
573
        pop     es
596
        mov     di,1444
574
        mov     di,1444
597
        xor     ax,ax
575
        xor     ax,ax
598
        mov     ah, 1*16+15
576
        mov     ah, 1*16+15
599
        mov     cx,70
577
        mov     cx,70
600
        mov     bp,12
578
        mov     bp,12
601
.loop_start:
579
.loop_start:
602
        rep     stosw
580
        rep     stosw
603
        mov     cx,70
581
        mov     cx,70
604
        add     di,20
582
        add     di,20
605
        dec     bp
583
        dec     bp
606
        jns		.loop_start       
584
        jns		.loop_start       
607
        pop     es
585
        pop     es
608
        popa
586
        popa
609
        ret
587
        ret
610
 
588
 
611
;-----------------------------------------------------------------------------
589
;-----------------------------------------------------------------------------
612
 
590
 
613
set_vmode:
591
set_vmode:
614
        push    0 ;0;x1000
592
        push    0 ;0;x1000
615
        pop     es
593
        pop     es
616
 
594
 
617
        mov     si,word [preboot_graph]            ;[preboot_graph]
595
        mov     si,word [preboot_graph]            ;[preboot_graph]
618
        mov     cx,word [es:si+6]            ; number of mode
596
        mov     cx,word [es:si+6]            ; number of mode
619
        
597
        
620
 
598
 
621
        mov     ax,word [es:si+0]            ; resolution X
599
        mov     ax,word [es:si+0]            ; resolution X
622
        mov     bx,word [es:si+2]            ; resolution Y
600
        mov     bx,word [es:si+2]            ; resolution Y
623
 
601
 
624
 
602
 
625
        mov     word [es:0x900A],ax              ; resolution X
603
        mov     word [es:0x900A],ax              ; resolution X
626
        mov     word [es:0x900C],bx              ; resolution Y
604
        mov     word [es:0x900C],bx              ; resolution Y
627
        mov     word [es:0x9008],cx              ; number of mode
605
        mov     word [es:0x9008],cx              ; number of mode
628
 
-
 
629
;        cmp     cx,0x12
-
 
630
;        je      .mode0x12_0x13
-
 
631
;        cmp     cx,0x13
-
 
632
;        je      .mode0x12_0x13
-
 
633
 
-
 
634
 
-
 
635
;        cmp     byte [s_vesa.ver],'2'
-
 
636
;        jb      .vesa12
606
 
637
 
607
 
638
;  VESA 2 and Vesa 3
608
;  VESA 2 and Vesa 3 only
639
 
609
 
640
        mov     ax,0x4f01
610
        mov     ax,0x4f01
641
        and     cx,0xfff
611
        and     cx,0xfff
642
        mov     di,mi;0xa000
612
        mov     di,mi;0xa000
643
        int     0x10
613
        int     0x10
644
        ; LFB
614
        ; LFB
645
        mov     eax,[es:mi.PhysBasePtr];di+0x28]
615
        mov     eax,[es:mi.PhysBasePtr]		;di+0x28]
646
        mov     [es:0x9018],eax
616
        mov     [es:0x9018],eax
647
        ; ---- vbe voodoo
617
        ; ---- vbe voodoo
648
        BytesPerLine equ 0x10
618
        BytesPerLine equ 0x10
649
        mov     ax, [es:di+BytesPerLine]
619
        mov     ax, [es:di+BytesPerLine]
650
        mov     [es:0x9001], ax
620
        mov     [es:0x9001], ax
651
        ; BPP
621
        ; BPP
652
;        cmp     [es:mi.BitsPerPixel],16
-
 
653
;        jne     .l0
-
 
654
;        cmp     [es:mi.GreenMaskSize],5
-
 
655
;        jne     .l0
-
 
656
;        mov     [es:mi.BitsPerPixel],15
-
 
657
.l0:
622
.l0:
658
        mov     al, byte [es:di+0x19]
623
        mov     al, byte [es:di+0x19]
659
        mov     [es:0x9000], al
624
        mov     [es:0x9000], al
660
        jmp     .exit
625
        jmp     .exit
661
 
-
 
662
;.mode0x12_0x13:
-
 
663
;        mov     byte [es:0x9000], 32
-
 
664
;        or      dword [es:0x9018], 0xFFFFFFFF; 0x800000
-
 
665
 
-
 
666
 
-
 
667
;  VESA 1.2 PM BANK SWITCH ADDRESS
-
 
668
 
-
 
669
;.vesa12:
-
 
670
 
-
 
671
 
-
 
672
;        mov     ax,0x4f0A
-
 
673
;        xor     bx,bx
-
 
674
;        int     0x10
-
 
675
;        xor     eax,eax
-
 
676
;        xor     ebx,ebx
-
 
677
;        mov     ax,es
-
 
678
;        shl     eax,4
-
 
679
;        mov     bx,di
-
 
680
;        add     eax,ebx
-
 
681
;        movzx   ebx,word[es:di]
-
 
682
;        add     eax,ebx
-
 
683
;        push    0x0000
-
 
684
;        pop     es
-
 
685
;        mov     [es:0x9014],eax
626
 
686
  .exit:
627
  .exit:
687
        ret
628
        ret
688
 
629
 
689
 
630
 
690
;=============================================================================
631
;=============================================================================
691
@@:
632
;@@:
692
>
633
;>
693
@@:
634
;@@:
694
>
635
;>
695
>
636
>
696
>
637
>