Subversion Repositories Kolibri OS

Rev

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

Rev 941 Rev 946
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: 941 $
8
$Revision: 946 $
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
;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
116
v_mode_error:
117
v_mode_error:
117
        _setcursor 19,2
118
        _setcursor 19,2
118
        mov     si, fatalsel
119
        mov     si, fatalsel
119
        call    printplain
120
        call    printplain
120
        _setcursor 20,2
121
        _setcursor 20,2
121
        mov     si,pres_key
122
        mov     si,pres_key
122
        call    printplain
123
        call    printplain
123
        xor     eax,eax
124
        xor     eax,eax
124
        int     16h
125
        int     16h
125
        jmp     cfgmanager.d
126
        jmp     cfgmanager.d
126
;-------------------------------------------------------
127
;-------------------------------------------------------
127
;
128
;
128
 
129
 
129
 
130
 
130
 
131
 
131
;-------------------------------------------------------
132
;-------------------------------------------------------
132
print_vesa_info:
133
print_vesa_info:
133
        _setcursor 5,2
134
        _setcursor 5,2
134
 
135
 
135
        mov     [es:vi.VESASignature],'VBE2'
136
        mov     [es:vi.VESASignature],'VBE2'
136
        mov     ax,0x4F00
137
        mov     ax,0x4F00
137
        mov     di,vi      ;0xa000
138
        mov     di,vi      ;0xa000
138
        int     0x10
139
        int     0x10
139
        or      ah,ah
140
        or      ah,ah
140
        jz      @f
141
        jz      @f
141
        mov     [es:vi.VESASignature],'VESA'
142
        mov     [es:vi.VESASignature],'VESA'
142
        mov     ax,$4F00
143
        mov     ax,$4F00
143
        mov     di,vi
144
        mov     di,vi
144
        int     0x10
145
        int     0x10
145
        or      ah,ah
146
        or      ah,ah
146
        jnz     .exit
147
        jnz     .exit
147
  @@:
148
  @@:
148
        cmp     [es:vi.VESASignature],'VESA'
149
        cmp     [es:vi.VESASignature],'VESA'
149
        jne     .exit
150
        jne     .exit
150
        cmp     [es:vi.VESAVersion],0x0100
151
        cmp     [es:vi.VESAVersion],0x0100
151
        jb      .exit
152
        jb      .exit
152
        jmp     .vesaok2
153
        jmp     .vesaok2
153
 
154
 
154
  .exit:
155
  .exit:
155
        mov     si,novesa
156
        mov     si,novesa
156
        call    printplain
157
        call    printplain
157
        ret
158
        ret
158
 
159
 
159
  .vesaok2:
160
  .vesaok2:
160
        mov     ax,[es:vi.VESAVersion]
161
        mov     ax,[es:vi.VESAVersion]
161
        add     ax,'00'
162
        add     ax,'00'
162
 
163
 
163
        mov     [s_vesa.ver], ah
164
        mov     [s_vesa.ver], ah
164
        mov     [s_vesa.ver+2], al
165
        mov     [s_vesa.ver+2], al
165
        mov     si,s_vesa
166
        mov     si,s_vesa
166
        call    printplain
167
        call    printplain
167
 
168
 
168
        _setcursor 4,2
169
        _setcursor 4,2
169
        mov     si,word[es:vi.OemStringPtr]
170
        mov     si,word[es:vi.OemStringPtr]
170
        mov     di,si
171
        mov     di,si
171
 
172
 
172
        push    ds
173
        push    ds
173
        mov     ds,word[es:vi.OemStringPtr+2]
174
        mov     ds,word[es:vi.OemStringPtr+2]
174
        call    printplain
175
        call    printplain
175
        pop     ds
176
        pop     ds
176
 
177
 
177
        ret
178
        ret
178
;-----------------------------------------------------------------------------
179
;-----------------------------------------------------------------------------
179
 
180
 
180
calc_vmodes_table:
181
calc_vmodes_table:
181
        pushad
182
        pushad
182
 
183
 
183
;        push    0
184
;        push    0
184
;        pop     es
185
;        pop     es
185
 
186
 
186
        lfs     si, [es:vi.VideoModePtr]
187
        lfs     si, [es:vi.VideoModePtr]
187
 
188
 
188
        mov     bx,modes_table
189
        mov     bx,modes_table
189
;save no vesa mode of work 320x200, EGA/CGA 256 梥⮢ and 640x480, VGA 16 梥⮢
190
;save no vesa mode of work 320x200, EGA/CGA 256 梥⮢ and 640x480, VGA 16 梥⮢
190
        mov     word [es:bx],640
191
        mov     word [es:bx],640
191
        mov     word [es:bx+2],480
192
        mov     word [es:bx+2],480
192
        mov     word [es:bx+6],0x13
193
        mov     word [es:bx+6],0x13
193
        
194
        
194
        mov     word [es:bx+10],640
195
        mov     word [es:bx+10],640
195
        mov     word [es:bx+12],480
196
        mov     word [es:bx+12],480
196
        mov     word [es:bx+16],0x12
197
        mov     word [es:bx+16],0x12
197
        add     bx,20
198
        add     bx,20
198
  .next_mode:
199
  .next_mode:
199
        mov     cx,word [fs:si] ; mode number
200
        mov     cx,word [fs:si] ; mode number
200
        cmp     cx,-1
201
        cmp     cx,-1
201
        je      .modes_ok.2
202
        je      .modes_ok.2
202
 
203
 
203
        mov     ax,0x4F01
204
        mov     ax,0x4F01
204
        mov     di,mi
205
        mov     di,mi
205
        int     0x10
206
        int     0x10
206
 
207
 
207
        or      ah,ah
208
        or      ah,ah
208
        jnz     .modes_ok.2;vesa_info.exit
209
        jnz     .modes_ok.2;vesa_info.exit
209
 
210
 
210
        test    [es:mi.ModeAttributes],00000001b   ;videomode support ?
211
        test    [es:mi.ModeAttributes],00000001b   ;videomode support ?
211
        jz      @f
212
        jz      @f
212
        test    [es:mi.ModeAttributes],00010000b   ;picture ?
213
        test    [es:mi.ModeAttributes],00010000b   ;picture ?
213
        jz      @f
214
        jz      @f
214
        test    [es:mi.ModeAttributes],10000000b   ;LFB ?
215
        test    [es:mi.ModeAttributes],10000000b   ;LFB ?
215
        jz      @f
216
        jz      @f
216
 
217
 
217
;        cmp     [es:mi.BitsPerPixel], 24
218
;        cmp     [es:mi.BitsPerPixel], 24
218
;        jb      @f
219
;        jb      @f
219
 
220
 
220
        cmp     [es:mi.BitsPerPixel],16
221
        cmp     [es:mi.BitsPerPixel],16
221
        jne     .l0
222
        jne     .l0
222
        cmp     [es:mi.GreenMaskSize],5
223
        cmp     [es:mi.GreenMaskSize],5
223
        jne     .l0
224
        jne     .l0
224
        mov     [es:mi.BitsPerPixel],15
225
        mov     [es:mi.BitsPerPixel],15
225
 
226
 
226
 
227
 
227
  .l0:
228
  .l0:
228
        cmp     [es:mi.XRes],640
229
        cmp     [es:mi.XRes],640
229
        jb      @f
230
        jb      @f
230
        cmp     [es:mi.YRes],480
231
        cmp     [es:mi.YRes],480
231
        jb      @f
232
        jb      @f
232
;        cmp     [es:mi.BitsPerPixel],8
233
;        cmp     [es:mi.BitsPerPixel],8
233
;        jb      @f
234
;        jb      @f
234
 
235
 
235
        mov     ax,[es:mi.XRes]
236
        mov     ax,[es:mi.XRes]
236
        mov     [es:bx+0],ax               ; +0[2] : resolution X
237
        mov     [es:bx+0],ax               ; +0[2] : resolution X
237
        mov     ax,[es:mi.YRes]
238
        mov     ax,[es:mi.YRes]
238
        mov     [es:bx+2],ax               ; +2[2] : resolution Y
239
        mov     [es:bx+2],ax               ; +2[2] : resolution Y
239
        mov     ax,[es:mi.ModeAttributes]
240
        mov     ax,[es:mi.ModeAttributes]
240
        mov     [es:bx+4],ax               ; +4[2] : attributes
241
        mov     [es:bx+4],ax               ; +4[2] : attributes
241
 
242
 
242
        cmp     [s_vesa.ver],'2'
243
        cmp     [s_vesa.ver],'2'
243
        jb      .lp1
244
        jb      .lp1
244
 
245
 
245
        or      cx,0x4000  ; use LFB
246
        or      cx,0x4000  ; use LFB
246
  .lp1: mov     [es:bx+6],cx               ; +6 : mode number
247
  .lp1: mov     [es:bx+6],cx               ; +6 : mode number
247
        movzx   ax,byte [es:mi.BitsPerPixel]
248
        movzx   ax,byte [es:mi.BitsPerPixel]
248
        mov     word [es:bx+8],ax               ; +8 : bits per pixel
249
        mov     word [es:bx+8],ax               ; +8 : bits per pixel
249
        add     bx,size_of_step
250
        add     bx,size_of_step                 ; size of record 
250
 
251
 
251
    @@:
252
    @@:
252
        add     si,2
253
        add     si,2
253
        jmp     .next_mode
254
        jmp     .next_mode
254
 
255
 
255
  .modes_ok.2:
256
  .modes_ok.2:
256
 
257
 
257
        mov     word[es:bx],-1  ;end video table
258
        mov     word[es:bx],-1  ;end video table
258
        mov     word[end_cursor],bx     ;save end cursor position
259
        mov     word[end_cursor],bx     ;save end cursor position
259
;;;;;;;;;;;;;;;;;;
260
;;;;;;;;;;;;;;;;;;
260
;Sort array
261
;Sort array
261
;        mov     si,modes_table
262
;        mov     si,modes_table
262
;.new_mode:
263
;.new_mode:
263
;        mov     ax,word [es:si]
264
;        mov     ax,word [es:si]
264
;        cmp     ax,-1
265
;        cmp     ax,-1
265
;        je      .exxit
266
;        je      .exxit
266
;        add     ax,word [es:si+2]
267
;        add     ax,word [es:si+2]
267
;        add     ax,word [es:si+8]
268
;        add     ax,word [es:si+8]
268
;        mov     bp,si
269
;        mov     bp,si
269
;.again:
270
;.again:
270
;        add     bp,12
271
;        add     bp,12
271
;        mov     bx,word [es:bp]
272
;        mov     bx,word [es:bp]
272
;        cmp     bx,-1
273
;        cmp     bx,-1
273
;        je      .exit
274
;        je      .exit
274
;        add     bx,word [es:bp+2]
275
;        add     bx,word [es:bp+2]
275
;        add     bx,word [es:bp+8]
276
;        add     bx,word [es:bp+8]
276
;        
277
;        
277
;        cmp     ax,bx
278
;        cmp     ax,bx
278
;        ja      .loops
279
;        ja      .loops
279
;        jmp     .again
280
;        jmp     .again
280
;.loops: 
281
;.loops: 
281
;        push    dword [es:si]
282
;        push    dword [es:si]
282
;        push    dword [es:si+4]
283
;        push    dword [es:si+4]
283
;        push    dword [es:si+8]
284
;        push    dword [es:si+8]
284
;        push    dword [es:bp]
285
;        push    dword [es:bp]
285
;        push    dword [es:bp+4]
286
;        push    dword [es:bp+4]
286
;        push    dword [es:bp+8]
287
;        push    dword [es:bp+8]
287
;
288
;
288
;        pop     dword [es:si+8]
289
;        pop     dword [es:si+8]
289
;        pop     dword [es:si+4]
290
;        pop     dword [es:si+4]
290
;        pop     dword [es:si]
291
;        pop     dword [es:si]
291
;        pop     dword [es:bp+8]
292
;        pop     dword [es:bp+8]
292
;        pop     dword [es:bp+4]
293
;        pop     dword [es:bp+4]
293
;        pop     dword [es:bp]
294
;        pop     dword [es:bp]
294
;        jmp     .new_mode
295
;        jmp     .new_mode
295
;
296
;
296
;.exit:  add     si,12
297
;.exit:  add     si,12
297
;        jmp     .new_mode
298
;        jmp     .new_mode
298
;.exxit:
299
;.exxit:
299
        popad
300
        popad
300
        ret
301
        ret
301
 
302
 
302
;-----------------------------------------------------------------------------
303
;-----------------------------------------------------------------------------
303
 
304
 
304
draw_current_vmode:
305
draw_current_vmode:
305
        push    0
306
        push    0
306
        pop     es
307
        pop     es
307
 
308
 
308
        mov     si,word [cursor_pos]
309
        mov     si,word [cursor_pos]
309
 
310
 
310
        cmp     word [es:si+6],0x12
311
        cmp     word [es:si+6],0x12
311
        je      .no_vesa_0x12
312
        je      .no_vesa_0x12
312
 
313
 
313
        cmp     word [es:si+6],0x13
314
        cmp     word [es:si+6],0x13
314
        je      .no_vesa_0x13
315
        je      .no_vesa_0x13
315
 
316
 
316
        mov     di,loader_block_error
317
        mov     di,loader_block_error
317
        movzx   eax,word[es:si+0]
318
        movzx   eax,word[es:si+0]
318
        mov     ecx,10
319
        mov     ecx,10
319
        call    int2strnz
320
        call    int2strnz
320
        mov     byte[es:di],'x'
321
        mov     byte[es:di],'x'
321
        inc     di
322
        inc     di
322
        movzx   eax,word[es:si+2]
323
        movzx   eax,word[es:si+2]
323
        call    int2strnz
324
        call    int2strnz
324
        mov     byte[es:di],'x'
325
        mov     byte[es:di],'x'
325
        inc     di
326
        inc     di
326
        movzx   eax,word[es:si+8]
327
        movzx   eax,word[es:si+8]
327
        call    int2strnz
328
        call    int2strnz
328
        mov     dword[es:di],0x00000d0a
329
        mov     dword[es:di],0x00000d0a
329
        mov     si,loader_block_error
330
        mov     si,loader_block_error
330
        push    ds
331
        push    ds
331
        push    es
332
        push    es
332
        pop     ds
333
        pop     ds
333
        call    printplain
334
        call    printplain
334
        pop     ds
335
        pop     ds
335
        ret
336
        ret
336
.no_vesa_0x13:
337
.no_vesa_0x13:
337
        mov     si,mode0
338
        mov     si,mode0
338
        jmp     .print
339
        jmp     .print
339
.no_vesa_0x12:
340
.no_vesa_0x12:
340
        mov     si,mode9
341
        mov     si,mode9
341
.print:
342
.print:
342
        call    printplain
343
        call    printplain
343
        ret        
344
        ret        
344
;-----------------------------------------------------------------------------
345
;-----------------------------------------------------------------------------
345
check_first_parm:
346
check_first_parm:
346
        mov     si,word [preboot_graph]
347
        mov     si,word [preboot_graph]
347
        test    si,si
348
        test    si,si
348
        jnz      .no_zero        ;if no zero
349
        jnz      .no_zero        ;if no zero
349
.zerro:
350
.zerro:
350
;        mov     ax,modes_table
351
;        mov     ax,modes_table
351
;        mov     word [cursor_pos],ax
352
;        mov     word [cursor_pos],ax
352
;        mov     word [home_cursor],ax
353
;        mov     word [home_cursor],ax
353
;        mov     word [preboot_graph],ax
354
;        mov     word [preboot_graph],ax
354
;SET default video of mode first probe will fined a move of work 1024x768@32
355
;SET default video of mode first probe will fined a move of work 1024x768@32
355
 
356
 
356
        mov     ax,1024
357
        mov     ax,1024
357
        mov     bx,768
358
        mov     bx,768
358
        mov     si,modes_table
359
        mov     si,modes_table
359
        call    .loops
360
        call    .loops
360
        test    ax,ax
361
        test    ax,ax
361
        jz     .ok_found_mode
362
        jz     .ok_found_mode
362
        mov     ax,800
363
        mov     ax,800
363
        mov     bx,600
364
        mov     bx,600
364
        mov     si,modes_table
365
        mov     si,modes_table
365
        call    .loops
366
        call    .loops
366
        test    ax,ax
367
        test    ax,ax
367
        jz     .ok_found_mode
368
        jz     .ok_found_mode
368
        mov     ax,640
369
        mov     ax,640
369
        mov     bx,480
370
        mov     bx,480
370
        mov     si,modes_table
371
        mov     si,modes_table
371
        call    .loops
372
        call    .loops
372
        test    ax,ax
373
        test    ax,ax
373
        jz     .ok_found_mode
374
        jz     .ok_found_mode
374
 
375
 
375
        mov     si,modes_table
376
        mov     si,modes_table
376
        jmp     .ok_found_mode
377
        jmp     .ok_found_mode
377
 
378
 
378
 
379
 
379
 
380
 
380
.no_zero:
381
.no_zero:
381
	mov	bp,word [number_vm]
382
	mov	bp,word [number_vm]
382
        cmp     bp,word [es:si+6]
383
        cmp     bp,word [es:si+6]
383
        jz      .ok_found_mode
384
        jz      .ok_found_mode
384
        mov     ax,word [x_save]
385
        mov     ax,word [x_save]
385
        mov     bx,word [y_save]
386
        mov     bx,word [y_save]
386
        mov     si,modes_table
387
        mov     si,modes_table
387
        call    .loops
388
        call    .loops
388
        test    ax,ax
389
        test    ax,ax
389
        jz     .ok_found_mode
390
        jz     .ok_found_mode
390
 
391
 
391
	mov    si,modes_table
392
	mov    si,modes_table
392
;        cmp     ax,modes_table
393
;        cmp     ax,modes_table
393
;        jb      .zerro           ;check on correct if bellow
394
;        jb      .zerro           ;check on correct if bellow
394
;        cmp     ax,word [end_cursor]
395
;        cmp     ax,word [end_cursor]
395
;        ja      .zerro           ;check on correct if anymore
396
;        ja      .zerro           ;check on correct if anymore
396
 
397
 
397
.ok_found_mode:
398
.ok_found_mode:
398
        mov     word [home_cursor],si
399
        mov     word [home_cursor],si
399
;        mov     word [cursor_pos],si
400
;        mov     word [cursor_pos],si
400
        mov     word [preboot_graph],si
401
        mov     word [preboot_graph],si
401
        mov     ax,si
402
        mov     ax,si
402
 
403
 
403
        mov     ecx,long_v_table
404
        mov     ecx,long_v_table
404
 
405
 
405
.loop:  add     ax,size_of_step
406
.loop:  add     ax,size_of_step
406
        cmp     ax,word [end_cursor]
407
        cmp     ax,word [end_cursor]
407
        jae     .next_step
408
        jae     .next_step
408
        loop    .loop
409
        loop    .loop
409
.next_step:
410
.next_step:
410
        sub     ax,size_of_step*long_v_table
411
        sub     ax,size_of_step*long_v_table
411
        cmp     ax,modes_table
412
        cmp     ax,modes_table
412
        jae     @f
413
        jae     @f
413
        mov     ax,modes_table
414
        mov     ax,modes_table
414
@@:
415
@@:
415
 
416
 
416
        mov     word[home_cursor],ax
417
        mov     word [home_cursor],ax
417
        push    word [preboot_graph]
418
        mov	si,[preboot_graph]
418
        pop     word [cursor_pos]
419
        mov     word [cursor_pos],si
-
 
420
 
-
 
421
        push    word [es:si]
-
 
422
        pop     word [x_save]
-
 
423
        push    word [es:si+2]
-
 
424
        pop     word [y_save]
-
 
425
        push    word [es:si+6]
-
 
426
        pop     word [number_vm]
-
 
427
 
419
        ret
428
        ret
420
;;;;;;;;;;;;;;;;;;;;;;;;;;;
429
;;;;;;;;;;;;;;;;;;;;;;;;;;;
421
.loops:
430
.loops:
422
        cmp     ax,word [es:si]
431
        cmp     ax,word [es:si]
423
        jne     .next
432
        jne     .next
424
        cmp     bx,word [es:si+2]
433
        cmp     bx,word [es:si+2]
425
        jne     .next
434
        jne     .next
426
        cmp     word [es:si+8],32
435
        cmp     word [es:si+8],32
427
        je      .ok
436
        je      .ok
428
        cmp     word [es:si+8],24
437
        cmp     word [es:si+8],24
429
        je      .ok
438
        je      .ok
430
.next:  add     si,size_of_step
439
.next:  add     si,size_of_step
431
        cmp     word [es:si],-1
440
        cmp     word [es:si],-1
432
        je      .exit
441
        je      .exit
433
        jmp     .loops
442
        jmp     .loops
434
.ok:    xor     ax,ax        
443
.ok:    xor     ax,ax        
-
 
444
	ret
435
.exit:  ret
445
.exit:  or	ax,-1
-
 
446
	ret
436
 
447
 
437
 
448
 
438
;-----------------------------------------------------------------------------
449
;-----------------------------------------------------------------------------
439
 
450
 
440
;default_vmode:
451
;default_vmode:
441
        
452
        
442
;-----------------------------------------------------------------------------
453
;-----------------------------------------------------------------------------
443
draw_vmodes_table:
454
draw_vmodes_table:
444
        _setcursor 9, 2
455
        _setcursor 9, 2
445
        mov     si,gr_mode
456
        mov     si,gr_mode
446
        call    printplain
457
        call    printplain
447
 
458
 
448
        mov     si,_st
459
        mov     si,_st
449
        call    printplain
460
        call    printplain
450
 
461
 
451
        push    word [cursor_pos]
462
        push    word [cursor_pos]
452
        pop     ax
463
        pop     ax
453
        push    word [home_cursor]
464
        push    word [home_cursor]
454
        pop     si
465
        pop     si
455
        mov     cx,si
466
        mov     cx,si
456
 
467
 
457
        cmp     ax,si
468
        cmp     ax,si
458
        je      .ok
469
        je      .ok
459
        jb      .low
470
        jb      .low
460
 
471
 
461
 
472
 
462
        add     cx,size_of_step*long_v_table
473
        add     cx,size_of_step*long_v_table
463
        
474
        
464
        cmp     ax,cx
475
        cmp     ax,cx
465
        jb      .ok
476
        jb      .ok
466
        
477
        
467
        sub     cx,size_of_step*long_v_table
478
        sub     cx,size_of_step*long_v_table
468
        add     cx,size_of_step
479
        add     cx,size_of_step
469
        cmp     cx,word[end_cursor]
480
        cmp     cx,word[end_cursor]
470
        jae     .ok
481
        jae     .ok
471
        add     si,size_of_step
482
        add     si,size_of_step
472
        push    si
483
        push    si
473
        pop     word [home_cursor]
484
        pop     word [home_cursor]
474
        jmp     .ok
485
        jmp     .ok
475
 
486
 
476
 
487
 
477
.low:   sub     cx,size_of_step
488
.low:   sub     cx,size_of_step
478
        cmp     cx,modes_table
489
        cmp     cx,modes_table
479
        jb      .ok
490
        jb      .ok
480
        push    cx
491
        push    cx
481
        push    cx
492
        push    cx
482
        pop     word [home_cursor]
493
        pop     word [home_cursor]
483
        pop     si
494
        pop     si
484
 
495
 
485
 
496
 
486
.ok:
497
.ok:
487
; calculate scroll position
498
; calculate scroll position
488
        push    si
499
        push    si
489
        mov     ax, [end_cursor]
500
        mov     ax, [end_cursor]
490
        sub     ax, modes_table
501
        sub     ax, modes_table
491
        mov     bx, size_of_step
502
        mov     bx, size_of_step
492
        cwd
503
        cwd
493
        div     bx
504
        div     bx
494
        mov     si, ax          ; si = size of list
505
        mov     si, ax          ; si = size of list
495
        mov     ax, [home_cursor]
506
        mov     ax, [home_cursor]
496
        sub     ax, modes_table
507
        sub     ax, modes_table
497
        cwd
508
        cwd
498
        div     bx
509
        div     bx
499
        mov     di, ax
510
        mov     di, ax
500
        mov     ax, scroll_area_size*long_v_table
511
        mov     ax, scroll_area_size*long_v_table
501
        cwd
512
        cwd
502
        div     si
513
        div     si
503
        test    ax, ax
514
        test    ax, ax
504
        jnz     @f
515
        jnz     @f
505
        inc     ax
516
        inc     ax
506
@@:
517
@@:
507
        cmp     al, scroll_area_size
518
        cmp     al, scroll_area_size
508
        jb      @f
519
        jb      @f
509
        mov     al, scroll_area_size
520
        mov     al, scroll_area_size
510
@@:
521
@@:
511
        mov     cx, ax
522
        mov     cx, ax
512
; cx = scroll height
523
; cx = scroll height
513
; calculate scroll pos
524
; calculate scroll pos
514
        xor     bx, bx          ; initialize scroll pos
525
        xor     bx, bx          ; initialize scroll pos
515
        sub     al, scroll_area_size+1
526
        sub     al, scroll_area_size+1
516
        neg     al
527
        neg     al
517
        sub     si, long_v_table-1
528
        sub     si, long_v_table-1
518
        jbe     @f
529
        jbe     @f
519
        mul     di
530
        mul     di
520
        div     si
531
        div     si
521
        mov     bx, ax
532
        mov     bx, ax
522
@@:
533
@@:
523
        inc     bx
534
        inc     bx
524
        imul    ax, bx, size_of_step
535
        imul    ax, bx, size_of_step
525
        add     ax, [home_cursor]
536
        add     ax, [home_cursor]
526
        mov     [scroll_start], ax
537
        mov     [scroll_start], ax
527
        imul    cx, size_of_step
538
        imul    cx, size_of_step
528
        add     ax, cx
539
        add     ax, cx
529
        mov     [scroll_end], ax
540
        mov     [scroll_end], ax
530
        pop     si
541
        pop     si
531
        mov     bp,long_v_table               ;show rows
542
        mov     bp,long_v_table               ;show rows
532
.@@_next_bit:
543
.@@_next_bit:
533
;clear cursor
544
;clear cursor
-
 
545
	mov	ax,'  '
534
        mov     word[ds:_r1+21],'  '
546
        mov     word[ds:_r1+21],ax
535
        mov     word[ds:_r1+50],'  '
547
        mov     word[ds:_r1+50],ax
536
 
548
 
537
        mov     word[ds:_r2+21],'  '
549
        mov     word[ds:_r2+21],ax
538
        mov     word[ds:_r2+45],'  '
550
        mov     word[ds:_r2+45],ax
539
 
551
 
540
        mov     word[ds:_rs+21],'  '
552
        mov     word[ds:_rs+21],ax
541
        mov     word[ds:_rs+46],'  '
553
        mov     word[ds:_rs+46],ax
542
; draw string
554
; draw string
543
        cmp     word [es:si+6],0x12
555
        cmp     word [es:si+6],0x12
544
        je      .show_0x12
556
        je      .show_0x12
545
        cmp     word [es:si+6],0x13
557
        cmp     word [es:si+6],0x13
546
        je      .show_0x13
558
        je      .show_0x13
547
 
559
 
548
        movzx   eax,word[es:si]
560
        movzx   eax,word[es:si]
549
        cmp     ax,-1
561
        cmp     ax,-1
550
        je      .@@_end
562
        je      .@@_end
551
        mov     di,_rs+23          
563
        mov     di,_rs+23          
552
        mov     ecx,10
564
        mov     ecx,10
553
        mov     bl,4
565
        mov     bl,4
554
        call    int2str
566
        call    int2str
555
        movzx   eax,word[es:si+2]
567
        movzx   eax,word[es:si+2]
556
        inc     di
568
        inc     di
557
        mov     bl,4
569
        mov     bl,4
558
        call    int2str
570
        call    int2str
559
 
571
 
560
        movzx   eax,word[es:si+8]
572
        movzx   eax,word[es:si+8]
561
        inc     di
573
        inc     di
562
        mov     bl,2
574
        mov     bl,2
563
        call    int2str
575
        call    int2str
564
 
576
 
565
        cmp     si, word [cursor_pos]
577
        cmp     si, word [cursor_pos]
566
        jne     .next
578
        jne     .next
567
;draw   cursor
579
;draw   cursor
568
        mov     word[ds:_rs+21],'>>'
580
        mov     word[ds:_rs+21],'>>'
569
        mov     word[ds:_rs+46],'<<'
581
        mov     word[ds:_rs+46],'<<'
570
        
582
        
571
 
583
 
572
 
584
 
573
.next:
585
.next:
574
        push    si
586
        push    si
575
        mov     si,_rs
587
        mov     si,_rs
576
.@@_sh:
588
.@@_sh:
577
; add to the string pseudographics for scrollbar
589
; add to the string pseudographics for scrollbar
578
        pop     bx
590
        pop     bx
579
        push    bx
591
        push    bx
580
        mov     byte [si+53], ' '
592
        mov     byte [si+53], ' '
581
        cmp     bx, [scroll_start]
593
        cmp     bx, [scroll_start]
582
        jb      @f
594
        jb      @f
583
        cmp     bx, [scroll_end]
595
        cmp     bx, [scroll_end]
584
        jae     @f
596
        jae     @f
585
        mov     byte [si+53], 0xDB ; filled bar
597
        mov     byte [si+53], 0xDB ; filled bar
586
@@:
598
@@:
587
        push    bx
599
        push    bx
588
        add     bx, size_of_step
600
        add     bx, size_of_step
589
        cmp     bx, [end_cursor]
601
        cmp     bx, [end_cursor]
590
        jnz     @f
602
        jnz     @f
591
        mov     byte [si+53], 31 ; 'down arrow' symbol
603
        mov     byte [si+53], 31 ; 'down arrow' symbol
592
@@:
604
@@:
593
        sub     bx, [home_cursor]
605
        sub     bx, [home_cursor]
594
        cmp     bx, size_of_step*long_v_table
606
        cmp     bx, size_of_step*long_v_table
595
        jnz     @f
607
        jnz     @f
596
        mov     byte [si+53], 31 ; 'down arrow' symbol
608
        mov     byte [si+53], 31 ; 'down arrow' symbol
597
@@:
609
@@:
598
        pop     bx
610
        pop     bx
599
        cmp     bx, [home_cursor]
611
        cmp     bx, [home_cursor]
600
        jnz     @f
612
        jnz     @f
601
        mov     byte [si+53], 30 ; 'up arrow' symbol
613
        mov     byte [si+53], 30 ; 'up arrow' symbol
602
@@:
614
@@:
603
        call    printplain
615
        call    printplain
604
        pop     si
616
        pop     si
605
        add     si,size_of_step
617
        add     si,size_of_step
606
 
618
 
607
        dec     bp
619
        dec     bp
608
        jnz     .@@_next_bit
620
        jnz     .@@_next_bit
609
 
621
 
610
.@@_end:
622
.@@_end:
611
        mov     si,_bt
623
        mov     si,_bt
612
        call    printplain
624
        call    printplain
613
        ret
625
        ret
614
.show_0x13:
626
.show_0x13:
615
        push    si
627
        push    si
616
 
628
 
617
        cmp     si, word [cursor_pos]
629
        cmp     si, word [cursor_pos]
618
        jne     @f
630
        jne     @f
619
        mov     word[ds:_r1+21],'>>'
631
        mov     word[ds:_r1+21],'>>'
620
        mov     word[ds:_r1+50],'<<'        
632
        mov     word[ds:_r1+50],'<<'        
621
@@:
633
@@:
622
        mov     si,_r1
634
        mov     si,_r1
623
        jmp     .@@_sh
635
        jmp     .@@_sh
624
.show_0x12:
636
.show_0x12:
625
        push    si
637
        push    si
626
        cmp     si, word [cursor_pos]
638
        cmp     si, word [cursor_pos]
627
        jne     @f
639
        jne     @f
628
 
640
 
629
        mov     word[ds:_r2+21],'>>'
641
        mov     word[ds:_r2+21],'>>'
630
        mov     word[ds:_r2+45],'<<'
642
        mov     word[ds:_r2+45],'<<'
631
@@:
643
@@:
632
        mov     si,_r2
644
        mov     si,_r2
633
        jmp     .@@_sh
645
        jmp     .@@_sh
634
 
646
 
635
;-----------------------------------------------------------------------------
647
;-----------------------------------------------------------------------------
636
;Clear arrea of current video page (0xb800)
648
;Clear arrea of current video page (0xb800)
637
clear_vmodes_table:
649
clear_vmodes_table:
638
        pusha
650
        pusha
639
       ; draw frames
651
       ; draw frames
640
        push    es
652
        push    es
641
        push    0xb800
653
        push    0xb800
642
        pop     es
654
        pop     es
643
        mov     di,1444
655
        mov     di,1444
644
        xor     ax,ax
656
        xor     ax,ax
645
        mov     ah, 1*16+15
657
        mov     ah, 1*16+15
646
        mov     cx,70
658
        mov     cx,70
647
        mov     bp,12
659
        mov     bp,12
648
.loop_start:
660
.loop_start:
649
        rep     stosw            ;®ç¨á⪠ ®¡« á⨠íªà ­  
661
        rep     stosw
650
        mov     cx,70
662
        mov     cx,70
651
        add     di,20
663
        add     di,20
652
        dec     bp               ;㬥­ì襭¨¥ bp, ¢ bp áç¥â稪
664
        dec     bp
653
        jns        .loop_start       
665
        jns		.loop_start       
654
        pop     es
666
        pop     es
655
        popa
667
        popa
656
        ret
668
        ret
657
 
669
 
658
;-----------------------------------------------------------------------------
670
;-----------------------------------------------------------------------------
659
 
671
 
660
set_vmode:
672
set_vmode:
661
        push    0 ;0;x1000
673
        push    0 ;0;x1000
662
        pop     es
674
        pop     es
663
 
675
 
664
        mov     si,word [preboot_graph]            ;[preboot_graph]
676
        mov     si,word [preboot_graph]            ;[preboot_graph]
665
        mov     cx,word [es:si+6]            ; number of mode
677
        mov     cx,word [es:si+6]            ; number of mode
666
        
678
        
667
 
679
 
668
        mov     ax,word [es:si+0]            ; resolution X
680
        mov     ax,word [es:si+0]            ; resolution X
669
        mov     bx,word [es:si+2]            ; resolution Y
681
        mov     bx,word [es:si+2]            ; resolution Y
670
 
682
 
671
 
683
 
672
        mov     word [es:0x900A],ax              ; resolution X
684
        mov     word [es:0x900A],ax              ; resolution X
673
        mov     word [es:0x900C],bx              ; resolution Y
685
        mov     word [es:0x900C],bx              ; resolution Y
674
        mov     word [es:0x9008],cx              ; number of mode
686
        mov     word [es:0x9008],cx              ; number of mode
675
 
687
 
676
        cmp     cx,0x12
688
        cmp     cx,0x12
677
        je      .mode0x12_0x13
689
        je      .mode0x12_0x13
678
        cmp     cx,0x13
690
        cmp     cx,0x13
679
        je      .mode0x12_0x13
691
        je      .mode0x12_0x13
680
 
692
 
681
 
693
 
682
        cmp     byte [s_vesa.ver],'2'
694
        cmp     byte [s_vesa.ver],'2'
683
        jb      .vesa12
695
        jb      .vesa12
684
 
696
 
685
;  VESA 2 and Vesa 3
697
;  VESA 2 and Vesa 3
686
 
698
 
687
        mov     ax,0x4f01
699
        mov     ax,0x4f01
688
        and     cx,0xfff
700
        and     cx,0xfff
689
        mov     di,mi;0xa000
701
        mov     di,mi;0xa000
690
        int     0x10
702
        int     0x10
691
        ; LFB
703
        ; LFB
692
        mov     eax,[es:mi.PhysBasePtr];di+0x28]
704
        mov     eax,[es:mi.PhysBasePtr];di+0x28]
693
        mov     [es:0x9018],eax
705
        mov     [es:0x9018],eax
694
        ; ---- vbe voodoo
706
        ; ---- vbe voodoo
695
        BytesPerLine equ 0x10
707
        BytesPerLine equ 0x10
696
        mov     ax, [es:di+BytesPerLine]
708
        mov     ax, [es:di+BytesPerLine]
697
        mov     [es:0x9001], ax
709
        mov     [es:0x9001], ax
698
        ; BPP
710
        ; BPP
699
        cmp     [es:mi.BitsPerPixel],16
711
        cmp     [es:mi.BitsPerPixel],16
700
        jne     .l0
712
        jne     .l0
701
        cmp     [es:mi.GreenMaskSize],5
713
        cmp     [es:mi.GreenMaskSize],5
702
        jne     .l0
714
        jne     .l0
703
        mov     [es:mi.BitsPerPixel],15
715
        mov     [es:mi.BitsPerPixel],15
704
.l0:
716
.l0:
705
        mov     al, byte [es:di+0x19]
717
        mov     al, byte [es:di+0x19]
706
        mov     [es:0x9000], al
718
        mov     [es:0x9000], al
707
        jmp     .exit
719
        jmp     .exit
708
 
720
 
709
.mode0x12_0x13:
721
.mode0x12_0x13:
710
        mov     byte [es:0x9000], 32
722
        mov     byte [es:0x9000], 32
711
        or      dword [es:0x9018], 0xFFFFFFFF; 0x800000
723
        or      dword [es:0x9018], 0xFFFFFFFF; 0x800000
712
 
724
 
713
 
725
 
714
;  VESA 1.2 PM BANK SWITCH ADDRESS
726
;  VESA 1.2 PM BANK SWITCH ADDRESS
715
 
727
 
716
.vesa12:
728
.vesa12:
717
 
729
 
718
 
730
 
719
        mov     ax,0x4f0A
731
        mov     ax,0x4f0A
720
        xor     bx,bx
732
        xor     bx,bx
721
        int     0x10
733
        int     0x10
722
        xor     eax,eax
734
        xor     eax,eax
723
        xor     ebx,ebx
735
        xor     ebx,ebx
724
        mov     ax,es
736
        mov     ax,es
725
        shl     eax,4
737
        shl     eax,4
726
        mov     bx,di
738
        mov     bx,di
727
        add     eax,ebx
739
        add     eax,ebx
728
        movzx   ebx,word[es:di]
740
        movzx   ebx,word[es:di]
729
        add     eax,ebx
741
        add     eax,ebx
730
        push    0x0000
742
        push    0x0000
731
        pop     es
743
        pop     es
732
        mov     [es:0x9014],eax
744
        mov     [es:0x9014],eax
733
  .exit:
745
  .exit:
734
        ret
746
        ret
735
 
747
 
736
 
748
 
737
;        mov     dword[es:0x9018],0x000A0000
749
;        mov     dword[es:0x9018],0x000A0000
738
;        ret
750
;        ret
739
 
751
 
740
;=============================================================================
752
;=============================================================================
741
;=============================================================================
753
;=============================================================================
742
;=============================================================================
754
;=============================================================================
743
@@:
755
@@:
744
>
756
>
745
@@:
757
@@:
746
>
758
>
747
>
759
>
748
>
760
>