Subversion Repositories Kolibri OS

Rev

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

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