Subversion Repositories Kolibri OS

Rev

Rev 1941 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
750 victor 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
714 Lrz 7
 
750 victor 8
$Revision: 2014 $
9
 
714 Lrz 10
struc VBE_VGAInfo {
1703 art_zh 11
  .VESASignature	  dd ?	  ; char
12
  .VESAVersion		  dw ?	  ; short
13
  .OemStringPtr 	  dd ?	  ; char *
14
  .Capabilities 	  dd ?	  ; ulong
15
  .VideoModePtr 	  dd ?	  ; ulong
16
  .TotalMemory		  dw ?	  ; short
714 Lrz 17
  ; VBE 2.0+
1703 art_zh 18
  .OemSoftwareRev	  db ?	  ; short
19
  .OemVendorNamePtr	  dw ?	  ; char *
20
  .OemProductNamePtr	  dw ?	  ; char *
21
  .OemProductRevPtr	  dw ?	  ; char *
22
  .reserved		  rb 222  ; char
23
  .OemData		  rb 256  ; char
714 Lrz 24
}
25
 
26
struc VBE_ModeInfo {
1703 art_zh 27
  .ModeAttributes	  dw ?	  ; short
28
  .WinAAttributes	  db ?	  ; char
29
  .WinBAttributes	  db ?	  ; char
30
  .WinGranularity	  dw ?	  ; short
31
  .WinSize		  dw ?	  ; short
32
  .WinASegment		  dw ?	  ; ushort
33
  .WinBSegment		  dw ?	  ; ushort
34
  .WinFuncPtr		  dd ?	  ; void *
35
  .BytesPerScanLine	  dw ?	  ; short
36
  .XRes 		  dw ?	  ; short
37
  .YRes 		  dw ?	  ; short
38
  .XCharSize		  db ?	  ; char
39
  .YCharSize		  db ?	  ; char
40
  .NumberOfPlanes	  db ?	  ; char
41
  .BitsPerPixel 	  db ?	  ; char
42
  .NumberOfBanks	  db ?	  ; char
43
  .MemoryModel		  db ?	  ; char
44
  .BankSize		  db ?	  ; char
45
  .NumberOfImagePages	  db ?	  ; char
46
  .res1 		  db ?	  ; char
47
  .RedMaskSize		  db ?	  ; char
48
  .RedFieldPosition	  db ?	  ; char
49
  .GreenMaskSize	  db ?	  ; char
50
  .GreenFieldPosition	  db ?	  ; char
51
  .BlueMaskSize 	  db ?	  ; char
52
  .BlueFieldPosition	  db ?	  ; char
53
  .RsvedMaskSize	  db ?	  ; char
54
  .RsvedFieldPosition	  db ?	  ; char
55
  .DirectColorModeInfo	  db ?	  ; char ; MISSED IN THIS TUTORIAL!! SEE ABOVE
714 Lrz 56
  ; VBE 2.0+
1703 art_zh 57
  .PhysBasePtr		  dd ?	  ; ulong
58
  .OffScreenMemOffset	  dd ?	  ; ulong
59
  .OffScreenMemSize	  dw ?	  ; short
714 Lrz 60
  ; VBE 3.0+
1703 art_zh 61
  .LinbytesPerScanLine	  dw ?	  ; short
62
  .BankNumberOfImagePages db ?	  ; char
63
  .LinNumberOfImagePages  db ?	  ; char
64
  .LinRedMaskSize	  db ?	  ; char
65
  .LinRedFieldPosition	  db ?	  ; char
66
  .LingreenMaskSize	  db ?	  ; char
67
  .LinGreenFieldPosition  db ?	  ; char
68
  .LinBlueMaskSize	  db ?	  ; char
69
  .LinBlueFieldPosition   db ?	  ; char
70
  .LinRsvdMaskSize	  db ?	  ; char
71
  .LinRsvdFieldPosition   db ?	  ; char
72
  .MaxPixelClock	  dd ?	  ; ulong
73
  .res2 		  rb 190  ; char
714 Lrz 74
}
75
 
76
virtual at $A000
77
  vi VBE_VGAInfo
78
  mi VBE_ModeInfo
79
modes_table:
80
end virtual
2014 art_zh 81
cursor_pos  dw 0     ;temporary cursor storage.
714 Lrz 82
home_cursor dw 0    ;current shows rows a table
83
end_cursor  dw 0     ;end of position current shows rows a table
834 diamond 84
scroll_start dw 0    ;start position of scroll bar
85
scroll_end  dw 0     ;end position of scroll bar
714 Lrz 86
long_v_table equ 9   ;long of visible video table
731 diamond 87
size_of_step equ 10
88
scroll_area_size equ (long_v_table-2)
714 Lrz 89
int2str:
1703 art_zh 90
	dec	bl
91
	jz	@f
92
	xor	edx,edx
93
	div	ecx
94
	push	edx
95
	call	int2str
96
	pop	eax
97
    @@: or	al,0x30
98
	mov	[ds:di],al
99
	inc	di
100
	ret
714 Lrz 101
 
102
int2strnz:
1703 art_zh 103
	cmp	eax,ecx
104
	jb	@f
105
	xor	edx,edx
106
	div	ecx
107
	push	edx
108
	call	int2strnz
109
	pop	eax
110
    @@: or	al,0x30
111
	mov	[es:di],al
112
	inc	di
113
	ret
946 lrz 114
 
714 Lrz 115
 
116
;-------------------------------------------------------
117
print_vesa_info:
118
 
1703 art_zh 119
	mov	[es:vi.VESASignature],'VBE2'
120
	mov	ax,0x4F00
121
	mov	di,vi	   ;0xa000
122
	int	0x10
123
	or	ah,ah
124
	jz	@f
125
	mov	[es:vi.VESASignature],'VESA'
126
	mov	ax,$4F00
127
	mov	di,vi
128
	int	0x10
129
	or	ah,ah
130
	jnz	$
714 Lrz 131
  @@:
1703 art_zh 132
	cmp	[es:vi.VESASignature],'VESA'
133
	jne	$
134
	cmp	[es:vi.VESAVersion],0x0100
135
	jb	$
714 Lrz 136
 
137
  .vesaok2:
138
 
1703 art_zh 139
	ret
714 Lrz 140
;-----------------------------------------------------------------------------
141
 
142
calc_vmodes_table:
1703 art_zh 143
	pushad
714 Lrz 144
 
145
;        push    0
146
;        pop     es
147
 
1703 art_zh 148
	lfs	si, [es:vi.VideoModePtr]
714 Lrz 149
 
1703 art_zh 150
	mov	bx,modes_table
1700 art_zh 151
 
714 Lrz 152
  .next_mode:
1703 art_zh 153
	mov	cx,word [fs:si] ; mode number
154
	cmp	cx,-1
155
	je	.modes_ok.2
714 Lrz 156
 
1703 art_zh 157
	mov	ax,0x4F01
158
	mov	di,mi
159
	int	0x10
714 Lrz 160
 
1703 art_zh 161
	or	ah,ah
162
	jnz	.modes_ok.2		;vesa_info.exit
714 Lrz 163
 
1703 art_zh 164
	test	[es:mi.ModeAttributes],00000001b   ;videomode support ?
165
	jz	@f
166
	test	[es:mi.ModeAttributes],00010000b   ;picture ?
167
	jz	@f
168
	test	[es:mi.ModeAttributes],10000000b   ;LFB ?
169
	jz	@f
714 Lrz 170
 
1703 art_zh 171
	cmp	[es:mi.BitsPerPixel], 32	;to show only 32 bpp videomodes
172
	jb	@f
730 diamond 173
 
947 lrz 174
.l0:
1703 art_zh 175
	cmp	[es:mi.XRes],800	; only 800x600 and higher
176
	jb	@f
714 Lrz 177
 
1703 art_zh 178
	mov	ax,[es:mi.XRes]
179
	mov	[es:bx+0],ax		   ; +0[2] : resolution X
180
	mov	ax,[es:mi.YRes]
181
	mov	[es:bx+2],ax		   ; +2[2] : resolution Y
182
	mov	ax,[es:mi.ModeAttributes]
183
	mov	[es:bx+4],ax		   ; +4[2] : attributes
714 Lrz 184
 
1700 art_zh 185
;<<        cmp     [s_vesa.ver],'2'
186
;<<        jb      .lp1
714 Lrz 187
 
1703 art_zh 188
	or	cx,0x4000			; use LFB <<< ?
189
.lp1:	mov	[es:bx+6],cx		   ; +6 : mode number
190
	movzx	ax,byte [es:mi.BitsPerPixel]
191
	mov	word [es:bx+8],ax		; +8 : bits per pixel << ?
192
	add	bx,size_of_step 		; size of record
714 Lrz 193
 
194
    @@:
1703 art_zh 195
	add	si,2
196
	jmp	.next_mode
714 Lrz 197
 
198
  .modes_ok.2:
199
 
1703 art_zh 200
	mov	word[es:bx],-1	;end video table
201
	mov	word[end_cursor],bx	;save end cursor position
202
	popad
203
	ret
714 Lrz 204
 
205
check_first_parm:
1703 art_zh 206
	mov	si,word [preboot_graph]
207
	test	si,si
208
	jnz	 .no_zero	 ;if no zero
714 Lrz 209
.zerro:
1941 art_zh 210
	mov	word[preboot_graph], ax
714 Lrz 211
 
1703 art_zh 212
	mov	ax,1024
213
	mov	bx,768
214
	mov	si,modes_table
215
	call	.loops
216
	test	ax,ax
217
	jz     .ok_found_mode
714 Lrz 218
 
1703 art_zh 219
	mov	si,modes_table
220
	jmp	.ok_found_mode
714 Lrz 221
 
746 Lrz 222
.no_zero:
749 Lrz 223
	mov	bp,word [number_vm]
1703 art_zh 224
	cmp	bp,word [es:si+6]
225
	jz	.ok_found_mode
226
	mov	ax,word [x_save]
227
	mov	bx,word [y_save]
228
	mov	si,modes_table
229
	call	.loops
230
	test	ax,ax
231
	jz     .ok_found_mode
746 Lrz 232
 
749 Lrz 233
	mov    si,modes_table
746 Lrz 234
 
714 Lrz 235
.ok_found_mode:
1703 art_zh 236
	mov	word [home_cursor],si
237
	mov	word [preboot_graph],si
238
	mov	ax,si
714 Lrz 239
 
1703 art_zh 240
	mov	ecx,long_v_table
714 Lrz 241
 
1703 art_zh 242
.loop:	add	ax,size_of_step
243
	cmp	ax,word [end_cursor]
244
	jae	.next_step
245
	loop	.loop
714 Lrz 246
.next_step:
1703 art_zh 247
	sub	ax,size_of_step*long_v_table
248
	cmp	ax,modes_table
249
	jae	@f
250
	mov	ax,modes_table
738 diamond 251
@@:
714 Lrz 252
 
1703 art_zh 253
	mov	word [home_cursor],ax
254
	mov	si,[preboot_graph]
255
	mov	word [cursor_pos],si
946 lrz 256
 
1703 art_zh 257
	push	word [es:si]
258
	pop	word [x_save]
259
	push	word [es:si+2]
260
	pop	word [y_save]
261
	push	word [es:si+6]
262
	pop	word [number_vm]
946 lrz 263
 
1703 art_zh 264
	ret
714 Lrz 265
;;;;;;;;;;;;;;;;;;;;;;;;;;;
266
.loops:
1703 art_zh 267
	cmp	ax,word [es:si]
268
	jne	.next
269
	cmp	bx,word [es:si+2]
270
	jne	.next
271
	je	.ok
272
.next:	add	si,size_of_step
273
	cmp	word [es:si],-1
274
	je	.exit
275
	jmp	.loops
276
.ok:	xor	ax,ax
946 lrz 277
	ret
1703 art_zh 278
.exit:	or	ax,-1
946 lrz 279
	ret
714 Lrz 280
 
281
 
282
;-----------------------------------------------------------------------------
283
 
284
set_vmode:
1703 art_zh 285
	push	0 ;0;x1000
286
	pop	es
714 Lrz 287
 
1703 art_zh 288
	mov	si,word [preboot_graph] 	   ;[preboot_graph]
289
	mov	cx,word [es:si+6]	     ; number of mode
714 Lrz 290
 
291
 
1703 art_zh 292
	mov	ax,word [es:si+0]	     ; resolution X
293
	mov	bx,word [es:si+2]	     ; resolution Y
714 Lrz 294
 
295
 
1703 art_zh 296
	mov	word [es:0x900A],ax		 ; resolution X
297
	mov	word [es:0x900C],bx		 ; resolution Y
298
	mov	word [es:0x9008],cx		 ; number of mode
714 Lrz 299
 
1703 art_zh 300
 
1700 art_zh 301
;  VESA 2 and Vesa 3 only
714 Lrz 302
 
1703 art_zh 303
	mov	ax,0x4f01
304
	and	cx,0xfff
305
	mov	di,mi;0xa000
306
	int	0x10
307
	; LFB
308
	mov	eax,[es:mi.PhysBasePtr] 	;di+0x28]
309
	mov	[es:0x9018],eax
310
	; ---- vbe voodoo
311
	BytesPerLine equ 0x10
312
	mov	ax, [es:di+BytesPerLine]
313
	mov	[es:0x9001], ax
314
	; BPP
714 Lrz 315
.l0:
1703 art_zh 316
	mov	al, byte [es:di+0x19]
317
	mov	[es:0x9000], al
318
	jmp	.exit
714 Lrz 319
 
320
  .exit:
1703 art_zh 321
	ret
714 Lrz 322
 
323
 
324
;=============================================================================
325