Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
425 victor 1
$Revision: 546 $
431 serge 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3
;;                                                              ;;
4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
7
;;  VESA20.INC                                                  ;;
8
;;                                                              ;;
9
;;  Vesa 2.0 functions for MenuetOS                             ;;
10
;;                                                              ;;
11
;;  Copyright 2002 Ville Turjanmaa                              ;;
12
;;  Alexey, kgaz@crosswindws.net                                ;;
13
;;  - Voodoo compatible graphics                                ;;
14
;;  Juan M. Caravaca                                            ;;
15
;;  - Graphics optimimizations eg. drawline                     ;;
16
;;                                                              ;;
17
;;  See file COPYING for details                                ;;
18
;;                                                              ;;
19
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1 ha 20
 
21
; If you're planning to write your own video driver I suggest
22
; you replace the VESA12.INC file and see those instructions.
23
 
381 serge 24
;ScreenWidth             equ     0xfe00
25
;ScreenHeight            equ     0xfe04
26
;BytesPerScanLine        equ     0xfe08
27
;LFBAddress              equ     0xfe80
28
;ScreenBPP               equ     0xfbf1
29
;WinMapAddress           equ     0x460000
1 ha 30
 
31
 
32
 
33
;*************************************************
34
; getpixel
35
;
36
; in:
37
; eax = x coordinate
38
; ebx = y coordinate
39
;
40
; ret:
41
; ecx = 00 RR GG BB
42
 
43
getpixel:
469 serge 44
     push    eax ebx edx edi
45
     call    dword [GETPIXEL]
46
     pop     edi edx ebx eax
47
     ret
1 ha 48
 
49
Vesa20_getpixel24:
469 serge 50
; eax = x
51
; ebx = y
52
     imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
53
     lea     edi, [eax+eax*2] ; edi = x*3
54
     add     edi, ebx         ; edi = x*3+(y*y multiplier)
55
     add     edi, [LFBAddress]    ; ebx = where pixel is in memory
56
     mov     ecx, [edi]
57
     and     ecx, 0xffffff
58
     ret
1 ha 59
 
60
Vesa20_getpixel32:
469 serge 61
     imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
62
     lea     edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
63
     add     edi, [LFBAddress]    ; ebx = where pixel is in memory
64
     mov     ecx, [edi]
65
     and     ecx, 0xffffff
66
     ret
1 ha 67
 
68
;*************************************************
69
 
70
virtual at esp
71
 putimg:
72
   .real_sx        dd ?
73
   .real_sy        dd ?
74
   .image_sx       dd ?
75
   .image_sy       dd ?
76
   .image_cx       dd ?
77
   .image_cy       dd ?
78
   .pti            dd ?
79
   .abs_cx         dd ?
80
   .abs_cy         dd ?
81
   .line_increment dd ?
82
   .winmap_newline dd ?
83
   .screen_newline dd ?
283 diamond 84
   .stack_data = 4*12
85
   .edi         dd      ?
86
   .esi         dd      ?
87
   .ebp         dd      ?
314 diamond 88
   .esp         dd      ?
89
   .ebx         dd      ?
90
   .edx         dd      ?
91
   .ecx         dd      ?
92
   .eax         dd      ?
93
   .ret_addr    dd      ?
94
   .arg_0       dd      ?
1 ha 95
end virtual
96
 
283 diamond 97
align 16
1 ha 98
; ebx = pointer
99
; ecx = size [x|y]
100
; edx = coordinates [x|y]
283 diamond 101
; ebp = pointer to 'get' function
102
; esi = pointer to 'init' function
103
; edi = parameter for 'get' function
469 serge 104
 
1 ha 105
vesa20_putimage:
469 serge 106
     pushad
107
     call    [disable_mouse]
108
     sub     esp, putimg.stack_data
109
; save pointer to image
110
     mov     [putimg.pti], ebx
111
; unpack the size
112
     mov     eax, ecx
113
     and     ecx, 0xFFFF
114
     shr     eax, 16
115
     mov     [putimg.image_sx], eax
116
     mov     [putimg.image_sy], ecx
117
; unpack the coordinates
118
     mov     eax, edx
119
     and     edx, 0xFFFF
120
     shr     eax, 16
121
     mov     [putimg.image_cx], eax
122
     mov     [putimg.image_cy], edx
123
; calculate absolute (i.e. screen) coordinates
124
     mov     eax, [TASK_BASE]
125
     mov     ebx, [eax-twdw + WDATA.box.left]
126
     add     ebx, [putimg.image_cx]
127
     mov     [putimg.abs_cx], ebx
128
     mov     ebx, [eax-twdw + WDATA.box.top]
129
     add     ebx, [putimg.image_cy]
130
     mov     [putimg.abs_cy], ebx
131
; real_sx = MIN(wnd_sx-image_cx, image_sx);
132
     mov     ebx, [eax-twdw + WDATA.box.width] ; ebx = wnd_sx
133 diamond 133
; \begin{diamond}[20.08.2006]
134
; note that WDATA.box.width is one pixel less than real window x-size
469 serge 135
     inc     ebx
133 diamond 136
; \end{diamond}[20.08.2006]
469 serge 137
     sub     ebx, [putimg.image_cx]
138
     ja      @f
139
     add     esp, putimg.stack_data
140
     popad
141
     ret
142
@@:
143
     cmp     ebx, [putimg.image_sx]
144
     jbe     .end_x
145
     mov     ebx, [putimg.image_sx]
146
.end_x:
147
     mov     [putimg.real_sx], ebx
148
; init real_sy
149
     mov     ebx, [eax-twdw + WDATA.box.height] ; ebx = wnd_sy
133 diamond 150
; \begin{diamond}[20.08.2006]
469 serge 151
     inc     ebx
133 diamond 152
; \end{diamond}[20.08.2006]
469 serge 153
     sub     ebx, [putimg.image_cy]
154
     ja      @f
155
     add     esp, putimg.stack_data
156
     popad
157
     ret
158
@@:
159
     cmp     ebx, [putimg.image_sy]
160
     jbe     .end_y
161
     mov     ebx, [putimg.image_sy]
162
.end_y:
163
     mov     [putimg.real_sy], ebx
164
; line increment
165
     mov     eax, [putimg.image_sx]
166
     sub     eax, [putimg.real_sx]
167
;;     imul    eax, [putimg.source_bpp]
168
;     lea     eax, [eax + eax * 2]
169
     call    esi
170
     add     eax, [putimg.arg_0]
171
     mov     [putimg.line_increment], eax
172
; winmap new line increment
173
     mov     eax, [ScreenWidth]
174
     inc     eax
175
     sub     eax, [putimg.real_sx]
176
     mov     [putimg.winmap_newline], eax
177
; screen new line increment
178
     mov     eax, [BytesPerScanLine]
179
     mov     ecx, [putimg.real_sx]
180
     movzx   ebx, byte [ScreenBPP]
181
     shr     ebx, 3
182
     imul    ecx, ebx
183
     sub     eax, ecx
184
     mov     [putimg.screen_newline], eax
185
; pointer to image
186
     mov     esi, [putimg.pti]
187
; pointer to screen
188
     mov     edx, [putimg.abs_cy]
189
     imul    edx, [BytesPerScanLine]
190
     mov     eax, [putimg.abs_cx]
191
     movzx   ebx, byte [ScreenBPP]
192
     shr     ebx, 3
193
     imul    eax, ebx
194
     add     edx, eax
195
     add     edx, [LFBAddress]
196
; pointer to pixel map
197
     mov     eax, [putimg.abs_cy]
198
     imul    eax, [ScreenWidth]
199
     add     eax, [putimg.abs_cy]
200
     add     eax, [putimg.abs_cx]
201
     add     eax, WinMapAddress
202
     xchg    eax, ebp
203
; get process number
204
     mov     ebx, [CURRENT_TASK]
205
     cmp     byte [ScreenBPP], 32
206
     je      put_image_end_32
1 ha 207
;put_image_end_24:
469 serge 208
     mov     edi, [putimg.real_sy]
209
align   4
210
.new_line:
211
     mov     ecx, [putimg.real_sx]
212
;     push    ebp edx
213
align   4
214
.new_x:
215
     push    [putimg.edi]
216
     mov     eax, [putimg.ebp+4]
217
     call    eax
218
     cmp     [ebp], bl
219
     jne     .skip
220
;     mov     eax, [esi]        ; eax = RRBBGGRR
221
     mov     [edx], ax
222
     shr     eax, 16
223
     mov     [edx+2], al
224
.skip:
225
;     add     esi, 3 ;[putimg.source_bpp]
226
     add     edx, 3
227
     inc     ebp
228
     dec     ecx
229
     jnz     .new_x
230
;     pop     edx ebp
231
     add     esi, [putimg.line_increment]
232
     add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
233
     add     ebp, [putimg.winmap_newline] ;[ScreenWidth]
234
;     inc     ebp
235
     dec     edi
236
     jnz     .new_line
237
.finish:
238
     add     esp, putimg.stack_data
239
     popad
240
     ret