Subversion Repositories Kolibri OS

Rev

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

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