Subversion Repositories Kolibri OS

Rev

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

Rev 4587 Rev 4923
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2012. 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
;;  VESA20.INC                                                  ;;
6
;;  VESA20.INC                                                  ;;
7
;;                                                              ;;
7
;;                                                              ;;
8
;;  Vesa 2.0 functions for MenuetOS                             ;;
8
;;  Vesa 2.0 functions for MenuetOS                             ;;
9
;;                                                              ;;
9
;;                                                              ;;
10
;;  Copyright 2002 Ville Turjanmaa                              ;;
10
;;  Copyright 2002 Ville Turjanmaa                              ;;
11
;;  Alexey, kgaz@crosswindws.net                                ;;
11
;;  Alexey, kgaz@crosswindws.net                                ;;
12
;;  - Voodoo compatible graphics                                ;;
12
;;  - Voodoo compatible graphics                                ;;
13
;;  Juan M. Caravaca                                            ;;
13
;;  Juan M. Caravaca                                            ;;
14
;;  - Graphics optimimizations eg. drawline                     ;;
14
;;  - Graphics optimimizations eg. drawline                     ;;
15
;;                                                              ;;
15
;;                                                              ;;
16
;;  See file COPYING for details                                ;;
16
;;  See file COPYING for details                                ;;
17
;;                                                              ;;
17
;;                                                              ;;
18
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19
 
19
 
20
$Revision: 3606 $
20
$Revision: 3606 $
21
 
21
 
22
 
22
 
23
; If you're planning to write your own video driver I suggest
23
; If you're planning to write your own video driver I suggest
24
; you replace the VESA12.INC file and see those instructions.
24
; you replace the VESA12.INC file and see those instructions.
25
 
25
 
26
 
26
 
27
;-----------------------------------------------------------------------------
27
;-----------------------------------------------------------------------------
28
; getpixel
28
; getpixel
29
;
29
;
30
; in:
30
; in:
31
; eax = x coordinate
31
; eax = x coordinate
32
; ebx = y coordinate
32
; ebx = y coordinate
33
;
33
;
34
; ret:
34
; ret:
35
; ecx = 00 RR GG BB
35
; ecx = 00 RR GG BB
36
;-----------------------------------------------------------------------------
36
;-----------------------------------------------------------------------------
37
align 4
37
align 4
38
getpixel:
38
getpixel:
39
        push    eax ebx edx edi
39
        push    eax ebx edx edi
40
        call    dword [GETPIXEL]
40
        call    dword [GETPIXEL]
41
        pop     edi edx ebx eax
41
        pop     edi edx ebx eax
42
        ret
42
        ret
43
;-----------------------------------------------------------------------------
43
;-----------------------------------------------------------------------------
44
align 4
44
align 4
45
Vesa20_getpixel24:
45
Vesa20_getpixel24:
46
; eax = x
46
; eax = x
47
; ebx = y
47
; ebx = y
48
;--------------------------------------
48
;--------------------------------------
49
; check for hardware cursor
49
; check for hardware cursor
50
        cmp     [_display.select_cursor], select_cursor
50
        cmp     [_display.select_cursor], select_cursor
51
        je      @f
51
        je      @f
52
        cmp     [_display.select_cursor], 0
52
        cmp     [_display.select_cursor], 0
53
        jne     .no_mouseunder
53
        jne     .no_mouseunder
54
;--------------------------------------
54
;--------------------------------------
55
align 4
55
align 4
56
@@:
56
@@:
57
; check mouse area for putpixel
57
; check mouse area for putpixel
58
        test    ecx, 0x04000000  ; don't load to mouseunder area
58
        test    ecx, 0x04000000  ; don't load to mouseunder area
59
        jnz     .no_mouseunder
59
        jnz     .no_mouseunder
60
        call    [_display.check_m_pixel]
60
        call    [_display.check_m_pixel]
61
        test    ecx, ecx        ;0xff000000
61
        test    ecx, ecx        ;0xff000000
62
        jnz     @f
62
        jnz     @f
63
;--------------------------------------
63
;--------------------------------------
64
align 4
64
align 4
65
.no_mouseunder:
65
.no_mouseunder:
66
;--------------------------------------
66
;--------------------------------------
67
;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
67
;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
68
        mov     ebx, [BPSLine_calc_area+ebx*4]
68
        mov     ebx, [BPSLine_calc_area+ebx*4]
69
        lea     edi, [eax+eax*2]; edi = x*3
69
        lea     edi, [eax+eax*2]; edi = x*3
70
        add     edi, ebx      ; edi = x*3+(y*y multiplier)
70
        add     edi, ebx      ; edi = x*3+(y*y multiplier)
71
        mov     ecx, [LFB_BASE+edi]
71
        mov     ecx, [LFB_BASE+edi]
72
;--------------------------------------
72
;--------------------------------------
73
align 4
73
align 4
74
@@:
74
@@:
75
        and     ecx, 0xffffff
75
        and     ecx, 0xffffff
76
        ret
76
        ret
77
;-----------------------------------------------------------------------------
77
;-----------------------------------------------------------------------------
78
align 4
78
align 4
79
Vesa20_getpixel32:
79
Vesa20_getpixel32:
80
;--------------------------------------
80
;--------------------------------------
81
; check for hardware cursor
81
; check for hardware cursor
82
        cmp     [_display.select_cursor], select_cursor
82
        cmp     [_display.select_cursor], select_cursor
83
        je      @f
83
        je      @f
84
        cmp     [_display.select_cursor], 0
84
        cmp     [_display.select_cursor], 0
85
        jne     .no_mouseunder
85
        jne     .no_mouseunder
86
;--------------------------------------
86
;--------------------------------------
87
align 4
87
align 4
88
@@:
88
@@:
89
; check mouse area for putpixel
89
; check mouse area for putpixel
90
        test    ecx, 0x04000000  ; don't load to mouseunder area
90
        test    ecx, 0x04000000  ; don't load to mouseunder area
91
        jnz     .no_mouseunder
91
        jnz     .no_mouseunder
92
        call    [_display.check_m_pixel]
92
        call    [_display.check_m_pixel]
93
        test    ecx, ecx        ;0xff000000
93
        test    ecx, ecx        ;0xff000000
94
        jnz     @f
94
        jnz     @f
95
;--------------------------------------
95
;--------------------------------------
96
align 4
96
align 4
97
.no_mouseunder:
97
.no_mouseunder:
98
;--------------------------------------
98
;--------------------------------------
99
;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
99
;        imul    ebx, [BytesPerScanLine] ; ebx = y * y multiplier
100
        mov     ebx, [BPSLine_calc_area+ebx*4]
100
        mov     ebx, [BPSLine_calc_area+ebx*4]
101
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
101
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
102
        mov     ecx, [LFB_BASE+edi]
102
        mov     ecx, [LFB_BASE+edi]
103
;--------------------------------------
103
;--------------------------------------
104
align 4
104
align 4
105
@@:
105
@@:
106
        and     ecx, 0xffffff
106
        and     ecx, 0xffffff
107
        ret
107
        ret
108
;-----------------------------------------------------------------------------
108
;-----------------------------------------------------------------------------
109
virtual at esp
109
virtual at esp
110
 putimg:
110
 putimg:
111
   .real_sx        dd ?
111
   .real_sx        dd ?
112
   .real_sy        dd ?
112
   .real_sy        dd ?
113
   .image_sx       dd ?
113
   .image_sx       dd ?
114
   .image_sy       dd ?
114
   .image_sy       dd ?
115
   .image_cx       dd ?
115
   .image_cx       dd ?
116
   .image_cy       dd ?
116
   .image_cy       dd ?
117
   .pti            dd ?
117
   .pti            dd ?
118
   .abs_cx         dd ?
118
   .abs_cx         dd ?
119
   .abs_cy         dd ?
119
   .abs_cy         dd ?
120
   .line_increment dd ?
120
   .line_increment dd ?
121
   .winmap_newline dd ?
121
   .winmap_newline dd ?
122
   .screen_newline dd ?
122
   .screen_newline dd ?
123
   .real_sx_and_abs_cx dd ?
123
   .real_sx_and_abs_cx dd ?
124
   .real_sy_and_abs_cy dd ?
124
   .real_sy_and_abs_cy dd ?
125
   .stack_data = 4*14
125
   .stack_data = 4*14
126
   .edi         dd      ?
126
   .edi         dd      ?
127
   .esi         dd      ?
127
   .esi         dd      ?
128
   .ebp         dd      ?
128
   .ebp         dd      ?
129
   .esp         dd      ?
129
   .esp         dd      ?
130
   .ebx         dd      ?
130
   .ebx         dd      ?
131
   .edx         dd      ?
131
   .edx         dd      ?
132
   .ecx         dd      ?
132
   .ecx         dd      ?
133
   .eax         dd      ?
133
   .eax         dd      ?
134
   .ret_addr    dd      ?
134
   .ret_addr    dd      ?
135
   .arg_0       dd      ?
135
   .arg_0       dd      ?
136
end virtual
136
end virtual
137
;-----------------------------------------------------------------------------
137
;-----------------------------------------------------------------------------
138
align 16
138
align 16
139
; ebx = pointer
139
; ebx = pointer
140
; ecx = size [x|y]
140
; ecx = size [x|y]
141
; edx = coordinates [x|y]
141
; edx = coordinates [x|y]
142
; ebp = pointer to 'get' function
142
; ebp = pointer to 'get' function
143
; esi = pointer to 'init' function
143
; esi = pointer to 'init' function
144
; edi = parameter for 'get' function
144
; edi = parameter for 'get' function
145
vesa20_putimage:
145
vesa20_putimage:
146
        pushad
146
        pushad
147
        sub     esp, putimg.stack_data
147
        sub     esp, putimg.stack_data
148
; save pointer to image
148
; save pointer to image
149
        mov     [putimg.pti], ebx
149
        mov     [putimg.pti], ebx
150
; unpack the size
150
; unpack the size
151
        mov     eax, ecx
151
        mov     eax, ecx
152
        and     ecx, 0xFFFF
152
        and     ecx, 0xFFFF
153
        shr     eax, 16
153
        shr     eax, 16
154
        mov     [putimg.image_sx], eax
154
        mov     [putimg.image_sx], eax
155
        mov     [putimg.image_sy], ecx
155
        mov     [putimg.image_sy], ecx
156
; unpack the coordinates
156
; unpack the coordinates
157
        mov     eax, edx
157
        mov     eax, edx
158
        and     edx, 0xFFFF
158
        and     edx, 0xFFFF
159
        shr     eax, 16
159
        shr     eax, 16
160
        mov     [putimg.image_cx], eax
160
        mov     [putimg.image_cx], eax
161
        mov     [putimg.image_cy], edx
161
        mov     [putimg.image_cy], edx
162
; calculate absolute (i.e. screen) coordinates
162
; calculate absolute (i.e. screen) coordinates
163
        mov     eax, [TASK_BASE]
163
        mov     eax, [TASK_BASE]
164
        mov     ebx, [eax-twdw + WDATA.box.left]
164
        mov     ebx, [eax-twdw + WDATA.box.left]
165
        add     ebx, [putimg.image_cx]
165
        add     ebx, [putimg.image_cx]
166
        mov     [putimg.abs_cx], ebx
166
        mov     [putimg.abs_cx], ebx
167
        mov     ebx, [eax-twdw + WDATA.box.top]
167
        mov     ebx, [eax-twdw + WDATA.box.top]
168
        add     ebx, [putimg.image_cy]
168
        add     ebx, [putimg.image_cy]
169
        mov     [putimg.abs_cy], ebx
169
        mov     [putimg.abs_cy], ebx
170
; real_sx = MIN(wnd_sx-image_cx, image_sx);
170
; real_sx = MIN(wnd_sx-image_cx, image_sx);
171
        mov     ebx, [eax-twdw + WDATA.box.width]; ebx = wnd_sx
171
        mov     ebx, [eax-twdw + WDATA.box.width]; ebx = wnd_sx
172
; \begin{diamond}[20.08.2006]
172
; \begin{diamond}[20.08.2006]
173
; note that WDATA.box.width is one pixel less than real window x-size
173
; note that WDATA.box.width is one pixel less than real window x-size
174
        inc     ebx
174
        inc     ebx
175
; \end{diamond}[20.08.2006]
175
; \end{diamond}[20.08.2006]
176
        sub     ebx, [putimg.image_cx]
176
        sub     ebx, [putimg.image_cx]
177
        ja      @f
177
        ja      @f
178
        add     esp, putimg.stack_data
178
        add     esp, putimg.stack_data
179
        popad
179
        popad
180
        ret
180
        ret
181
;--------------------------------------
181
;--------------------------------------
182
align 4
182
align 4
183
@@:
183
@@:
184
        cmp     ebx, [putimg.image_sx]
184
        cmp     ebx, [putimg.image_sx]
185
        jbe     .end_x
185
        jbe     .end_x
186
        mov     ebx, [putimg.image_sx]
186
        mov     ebx, [putimg.image_sx]
187
;--------------------------------------
187
;--------------------------------------
188
align 4
188
align 4
189
.end_x:
189
.end_x:
190
        mov     [putimg.real_sx], ebx
190
        mov     [putimg.real_sx], ebx
191
; init real_sy
191
; init real_sy
192
        mov     ebx, [eax-twdw + WDATA.box.height]; ebx = wnd_sy
192
        mov     ebx, [eax-twdw + WDATA.box.height]; ebx = wnd_sy
193
; \begin{diamond}[20.08.2006]
193
; \begin{diamond}[20.08.2006]
194
        inc     ebx
194
        inc     ebx
195
; \end{diamond}[20.08.2006]
195
; \end{diamond}[20.08.2006]
196
        sub     ebx, [putimg.image_cy]
196
        sub     ebx, [putimg.image_cy]
197
        ja      @f
197
        ja      @f
198
        add     esp, putimg.stack_data
198
        add     esp, putimg.stack_data
199
        popad
199
        popad
200
        ret
200
        ret
201
;--------------------------------------
201
;--------------------------------------
202
align 4
202
align 4
203
@@:
203
@@:
204
        cmp     ebx, [putimg.image_sy]
204
        cmp     ebx, [putimg.image_sy]
205
        jbe     .end_y
205
        jbe     .end_y
206
        mov     ebx, [putimg.image_sy]
206
        mov     ebx, [putimg.image_sy]
207
;--------------------------------------
207
;--------------------------------------
208
align 4
208
align 4
209
.end_y:
209
.end_y:
210
        mov     [putimg.real_sy], ebx
210
        mov     [putimg.real_sy], ebx
211
; line increment
211
; line increment
212
        mov     eax, [putimg.image_sx]
212
        mov     eax, [putimg.image_sx]
213
        mov     ecx, [putimg.real_sx]
213
        mov     ecx, [putimg.real_sx]
214
        sub     eax, ecx
214
        sub     eax, ecx
215
;;     imul    eax, [putimg.source_bpp]
215
;;     imul    eax, [putimg.source_bpp]
216
;     lea     eax, [eax + eax * 2]
216
;     lea     eax, [eax + eax * 2]
217
        call    esi
217
        call    esi
218
        add     eax, [putimg.arg_0]
218
        add     eax, [putimg.arg_0]
219
        mov     [putimg.line_increment], eax
219
        mov     [putimg.line_increment], eax
220
; winmap new line increment
220
; winmap new line increment
221
        mov     eax, [Screen_Max_X]
221
        mov     eax, [_display.width]
222
        inc     eax
-
 
223
        sub     eax, [putimg.real_sx]
222
        sub     eax, [putimg.real_sx]
224
        mov     [putimg.winmap_newline], eax
223
        mov     [putimg.winmap_newline], eax
225
; screen new line increment
224
; screen new line increment
226
        mov     eax, [_display.pitch]
225
        mov     eax, [_display.pitch]
227
        mov     ebx, [_display.bpp]
226
        mov     ebx, [_display.bpp]
228
        shr     ebx, 3
227
        shr     ebx, 3
229
        imul    ecx, ebx
228
        imul    ecx, ebx
230
        sub     eax, ecx
229
        sub     eax, ecx
231
        mov     [putimg.screen_newline], eax
230
        mov     [putimg.screen_newline], eax
232
; pointer to image
231
; pointer to image
233
        mov     esi, [putimg.pti]
232
        mov     esi, [putimg.pti]
234
; pointer to screen
233
; pointer to screen
235
        mov     edx, [putimg.abs_cy]
234
        mov     edx, [putimg.abs_cy]
236
;        imul    edx, [BytesPerScanLine]
235
;        imul    edx, [BytesPerScanLine]
237
        mov     edx, [BPSLine_calc_area+edx*4]
236
        mov     edx, [BPSLine_calc_area+edx*4]
238
        mov     eax, [putimg.abs_cx]
237
        mov     eax, [putimg.abs_cx]
239
;        movzx   ebx, byte [ScreenBPP]
238
;        movzx   ebx, byte [ScreenBPP]
240
;        shr     ebx, 3
239
;        shr     ebx, 3
241
        imul    eax, ebx
240
        imul    eax, ebx
242
        add     edx, eax
241
        add     edx, eax
243
; pointer to pixel map
242
; pointer to pixel map
244
        mov     eax, [putimg.abs_cy]
243
        mov     eax, [putimg.abs_cy]
245
        mov     eax, [d_width_calc_area + eax*4]
244
        mov     eax, [d_width_calc_area + eax*4]
246
 
245
 
247
        add     eax, [putimg.abs_cx]
246
        add     eax, [putimg.abs_cx]
248
        add     eax, [_WinMapAddress]
247
        add     eax, [_WinMapAddress]
249
        xchg    eax, ebp
248
        xchg    eax, ebp
250
;--------------------------------------
249
;--------------------------------------
251
        mov     ecx, [putimg.real_sx]
250
        mov     ecx, [putimg.real_sx]
252
        add     ecx, [putimg.abs_cx]
251
        add     ecx, [putimg.abs_cx]
253
        mov     [putimg.real_sx_and_abs_cx], ecx
252
        mov     [putimg.real_sx_and_abs_cx], ecx
254
        mov     ecx, [putimg.real_sy]
253
        mov     ecx, [putimg.real_sy]
255
        add     ecx, [putimg.abs_cy]
254
        add     ecx, [putimg.abs_cy]
256
        mov     [putimg.real_sy_and_abs_cy], ecx
255
        mov     [putimg.real_sy_and_abs_cy], ecx
257
;--------------------------------------
256
;--------------------------------------
258
; get process number
257
; get process number
259
        mov     ebx, [CURRENT_TASK]
258
        mov     ebx, [CURRENT_TASK]
260
        cmp     byte [_display.bpp], 32
259
        cmp     byte [_display.bpp], 32
261
        je      put_image_end_32
260
        je      put_image_end_32
262
;--------------------------------------
261
;--------------------------------------
263
put_image_end_24:
262
put_image_end_24:
264
        mov     edi, [putimg.real_sy]
263
        mov     edi, [putimg.real_sy]
265
;--------------------------------------
264
;--------------------------------------
266
; check for hardware cursor
265
; check for hardware cursor
267
        mov     ecx, [_display.select_cursor]
266
        mov     ecx, [_display.select_cursor]
268
        cmp     ecx, select_cursor
267
        cmp     ecx, select_cursor
269
        je      put_image_end_24_new
268
        je      put_image_end_24_new
270
        cmp     ecx, 0
269
        cmp     ecx, 0
271
        je      put_image_end_24_old
270
        je      put_image_end_24_old
272
;--------------------------------------
271
;--------------------------------------
273
align 4
272
align 4
274
.new_line:
273
.new_line:
275
        mov     ecx, [putimg.real_sx]
274
        mov     ecx, [putimg.real_sx]
276
;--------------------------------------
275
;--------------------------------------
277
align 4
276
align 4
278
.new_x:
277
.new_x:
279
        push    [putimg.edi]
278
        push    [putimg.edi]
280
        mov     eax, [putimg.ebp+4]
279
        mov     eax, [putimg.ebp+4]
281
        call    eax
280
        call    eax
282
        cmp     [ebp], bl
281
        cmp     [ebp], bl
283
        jne     .skip
282
        jne     .skip
284
;--------------------------------------
283
;--------------------------------------
285
; store to real LFB
284
; store to real LFB
286
        mov     [LFB_BASE+edx], ax
285
        mov     [LFB_BASE+edx], ax
287
        shr     eax, 16
286
        shr     eax, 16
288
        mov     [LFB_BASE+edx+2], al
287
        mov     [LFB_BASE+edx+2], al
289
;--------------------------------------
288
;--------------------------------------
290
align 4
289
align 4
291
.skip:
290
.skip:
292
        add     edx, 3
291
        add     edx, 3
293
        inc     ebp
292
        inc     ebp
294
        dec     ecx
293
        dec     ecx
295
        jnz     .new_x
294
        jnz     .new_x
296
 
295
 
297
        add     esi, [putimg.line_increment]
296
        add     esi, [putimg.line_increment]
298
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
297
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
299
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
298
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
300
 
299
 
301
        cmp     [putimg.ebp], putimage_get1bpp
300
        cmp     [putimg.ebp], putimage_get1bpp
302
        jz      .correct
301
        jz      .correct
303
        cmp     [putimg.ebp], putimage_get2bpp
302
        cmp     [putimg.ebp], putimage_get2bpp
304
        jz      .correct
303
        jz      .correct
305
        cmp     [putimg.ebp], putimage_get4bpp
304
        cmp     [putimg.ebp], putimage_get4bpp
306
        jnz     @f
305
        jnz     @f
307
;--------------------------------------
306
;--------------------------------------
308
align 4
307
align 4
309
.correct:
308
.correct:
310
        mov     eax, [putimg.edi]
309
        mov     eax, [putimg.edi]
311
        mov     byte [eax], 80h
310
        mov     byte [eax], 80h
312
;--------------------------------------
311
;--------------------------------------
313
align 4
312
align 4
314
@@:
313
@@:
315
        dec     edi
314
        dec     edi
316
        jnz     .new_line
315
        jnz     .new_line
317
;--------------------------------------
316
;--------------------------------------
318
align 4
317
align 4
319
.finish:
318
.finish:
320
        add     esp, putimg.stack_data
319
        add     esp, putimg.stack_data
321
        popad
320
        popad
322
        ret
321
        ret
323
;------------------------------------------------------------------------------
322
;------------------------------------------------------------------------------
324
align 4
323
align 4
325
put_image_end_24_old:
324
put_image_end_24_old:
326
;--------------------------------------
325
;--------------------------------------
327
align 4
326
align 4
328
.new_line:
327
.new_line:
329
        mov     ecx, [putimg.real_sx]
328
        mov     ecx, [putimg.real_sx]
330
;--------------------------------------
329
;--------------------------------------
331
align 4
330
align 4
332
.new_x:
331
.new_x:
333
        push    [putimg.edi]
332
        push    [putimg.edi]
334
        mov     eax, [putimg.ebp+4]
333
        mov     eax, [putimg.ebp+4]
335
        call    eax
334
        call    eax
336
        cmp     [ebp], bl
335
        cmp     [ebp], bl
337
        jne     .skip
336
        jne     .skip
338
;--------------------------------------
337
;--------------------------------------
339
        push    ecx
338
        push    ecx
340
 
339
 
341
        neg     ecx
340
        neg     ecx
342
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
341
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
343
        shl     ecx, 16
342
        shl     ecx, 16
344
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
343
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
345
        sub     ecx, edi
344
        sub     ecx, edi
346
 
345
 
347
; check mouse area for putpixel
346
; check mouse area for putpixel
348
        call    check_mouse_area_for_putpixel
347
        call    check_mouse_area_for_putpixel
349
        pop     ecx
348
        pop     ecx
350
; store to real LFB
349
; store to real LFB
351
        mov     [LFB_BASE+edx], ax
350
        mov     [LFB_BASE+edx], ax
352
        shr     eax, 16
351
        shr     eax, 16
353
        mov     [LFB_BASE+edx+2], al
352
        mov     [LFB_BASE+edx+2], al
354
;--------------------------------------
353
;--------------------------------------
355
align 4
354
align 4
356
.skip:
355
.skip:
357
        add     edx, 3
356
        add     edx, 3
358
        inc     ebp
357
        inc     ebp
359
        dec     ecx
358
        dec     ecx
360
        jnz     .new_x
359
        jnz     .new_x
361
 
360
 
362
        add     esi, [putimg.line_increment]
361
        add     esi, [putimg.line_increment]
363
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
362
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
364
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
363
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
365
 
364
 
366
        cmp     [putimg.ebp], putimage_get1bpp
365
        cmp     [putimg.ebp], putimage_get1bpp
367
        jz      .correct
366
        jz      .correct
368
        cmp     [putimg.ebp], putimage_get2bpp
367
        cmp     [putimg.ebp], putimage_get2bpp
369
        jz      .correct
368
        jz      .correct
370
        cmp     [putimg.ebp], putimage_get4bpp
369
        cmp     [putimg.ebp], putimage_get4bpp
371
        jnz     @f
370
        jnz     @f
372
;--------------------------------------
371
;--------------------------------------
373
align 4
372
align 4
374
.correct:
373
.correct:
375
        mov     eax, [putimg.edi]
374
        mov     eax, [putimg.edi]
376
        mov     byte [eax], 80h
375
        mov     byte [eax], 80h
377
;--------------------------------------
376
;--------------------------------------
378
align 4
377
align 4
379
@@:
378
@@:
380
        dec     edi
379
        dec     edi
381
        jnz     .new_line
380
        jnz     .new_line
382
        jmp     put_image_end_24.finish
381
        jmp     put_image_end_24.finish
383
;------------------------------------------------------------------------------
382
;------------------------------------------------------------------------------
384
align 4
383
align 4
385
put_image_end_24_new:
384
put_image_end_24_new:
386
;--------------------------------------
385
;--------------------------------------
387
align 4
386
align 4
388
.new_line:
387
.new_line:
389
        mov     ecx, [putimg.real_sx]
388
        mov     ecx, [putimg.real_sx]
390
;--------------------------------------
389
;--------------------------------------
391
align 4
390
align 4
392
.new_x:
391
.new_x:
393
        push    [putimg.edi]
392
        push    [putimg.edi]
394
        mov     eax, [putimg.ebp+4]
393
        mov     eax, [putimg.ebp+4]
395
        call    eax
394
        call    eax
396
        cmp     [ebp], bl
395
        cmp     [ebp], bl
397
        jne     .skip
396
        jne     .skip
398
;--------------------------------------
397
;--------------------------------------
399
        push    ecx
398
        push    ecx
400
;--------------------------------------
399
;--------------------------------------
401
align 4
400
align 4
402
.sh:
401
.sh:
403
        neg     ecx
402
        neg     ecx
404
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
403
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
405
;--------------------------------------
404
;--------------------------------------
406
; check for X
405
; check for X
407
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
406
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
408
        jae     .no_mouse_area
407
        jae     .no_mouse_area
409
 
408
 
410
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
409
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
411
        jb      .no_mouse_area
410
        jb      .no_mouse_area
412
 
411
 
413
        shl     ecx, 16
412
        shl     ecx, 16
414
 
413
 
415
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
414
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
416
        sub     ecx, edi
415
        sub     ecx, edi
417
;--------------------------------------
416
;--------------------------------------
418
; check for Y
417
; check for Y
419
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
418
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
420
        jae     .no_mouse_area
419
        jae     .no_mouse_area
421
 
420
 
422
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
421
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
423
        jb      .no_mouse_area
422
        jb      .no_mouse_area
424
;--------------------------------------
423
;--------------------------------------
425
; check mouse area for putpixel
424
; check mouse area for putpixel
426
        call    check_mouse_area_for_putpixel_new.1
425
        call    check_mouse_area_for_putpixel_new.1
427
        cmp     ecx, -1   ;SHIT HAPPENS?
426
        cmp     ecx, -1   ;SHIT HAPPENS?
428
        jne     .no_mouse_area
427
        jne     .no_mouse_area
429
 
428
 
430
        mov     ecx, [esp]
429
        mov     ecx, [esp]
431
        jmp     .sh
430
        jmp     .sh
432
;--------------------------------------
431
;--------------------------------------
433
align 4
432
align 4
434
.no_mouse_area:
433
.no_mouse_area:
435
        pop     ecx
434
        pop     ecx
436
; store to real LFB
435
; store to real LFB
437
        mov     [LFB_BASE+edx], ax
436
        mov     [LFB_BASE+edx], ax
438
        shr     eax, 16
437
        shr     eax, 16
439
        mov     [LFB_BASE+edx+2], al
438
        mov     [LFB_BASE+edx+2], al
440
;--------------------------------------
439
;--------------------------------------
441
align 4
440
align 4
442
.skip:
441
.skip:
443
        add     edx, 3
442
        add     edx, 3
444
        inc     ebp
443
        inc     ebp
445
        dec     ecx
444
        dec     ecx
446
        jnz     .new_x
445
        jnz     .new_x
447
 
446
 
448
        add     esi, [putimg.line_increment]
447
        add     esi, [putimg.line_increment]
449
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
448
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
450
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
449
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
451
 
450
 
452
        cmp     [putimg.ebp], putimage_get1bpp
451
        cmp     [putimg.ebp], putimage_get1bpp
453
        jz      .correct
452
        jz      .correct
454
        cmp     [putimg.ebp], putimage_get2bpp
453
        cmp     [putimg.ebp], putimage_get2bpp
455
        jz      .correct
454
        jz      .correct
456
        cmp     [putimg.ebp], putimage_get4bpp
455
        cmp     [putimg.ebp], putimage_get4bpp
457
        jnz     @f
456
        jnz     @f
458
;--------------------------------------
457
;--------------------------------------
459
align 4
458
align 4
460
.correct:
459
.correct:
461
        mov     eax, [putimg.edi]
460
        mov     eax, [putimg.edi]
462
        mov     byte [eax], 80h
461
        mov     byte [eax], 80h
463
;--------------------------------------
462
;--------------------------------------
464
align 4
463
align 4
465
@@:
464
@@:
466
        dec     edi
465
        dec     edi
467
        jnz     .new_line
466
        jnz     .new_line
468
        jmp     put_image_end_24.finish
467
        jmp     put_image_end_24.finish
469
;------------------------------------------------------------------------------
468
;------------------------------------------------------------------------------
470
align 4
469
align 4
471
put_image_end_32:
470
put_image_end_32:
472
        mov     edi, [putimg.real_sy]
471
        mov     edi, [putimg.real_sy]
473
;--------------------------------------
472
;--------------------------------------
474
; check for hardware cursor
473
; check for hardware cursor
475
        mov     ecx, [_display.select_cursor]
474
        mov     ecx, [_display.select_cursor]
476
        cmp     ecx, select_cursor
475
        cmp     ecx, select_cursor
477
        je      put_image_end_32_new
476
        je      put_image_end_32_new
478
        cmp     ecx, 0
477
        cmp     ecx, 0
479
        je      put_image_end_32_old
478
        je      put_image_end_32_old
480
;--------------------------------------
479
;--------------------------------------
481
align 4
480
align 4
482
.new_line:
481
.new_line:
483
        mov     ecx, [putimg.real_sx]
482
        mov     ecx, [putimg.real_sx]
484
;--------------------------------------
483
;--------------------------------------
485
align 4
484
align 4
486
.new_x:
485
.new_x:
487
        push    [putimg.edi]
486
        push    [putimg.edi]
488
        mov     eax, [putimg.ebp+4]
487
        mov     eax, [putimg.ebp+4]
489
        call    eax
488
        call    eax
490
        cmp     [ebp], bl
489
        cmp     [ebp], bl
491
        jne     .skip
490
        jne     .skip
492
;--------------------------------------
491
;--------------------------------------
493
; store to real LFB
492
; store to real LFB
494
        mov     [LFB_BASE+edx], eax
493
        mov     [LFB_BASE+edx], eax
495
;--------------------------------------
494
;--------------------------------------
496
align 4
495
align 4
497
.skip:
496
.skip:
498
        add     edx, 4
497
        add     edx, 4
499
        inc     ebp
498
        inc     ebp
500
        dec     ecx
499
        dec     ecx
501
        jnz     .new_x
500
        jnz     .new_x
502
 
501
 
503
        add     esi, [putimg.line_increment]
502
        add     esi, [putimg.line_increment]
504
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
503
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
505
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
504
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
506
 
505
 
507
        cmp     [putimg.ebp], putimage_get1bpp
506
        cmp     [putimg.ebp], putimage_get1bpp
508
        jz      .correct
507
        jz      .correct
509
        cmp     [putimg.ebp], putimage_get2bpp
508
        cmp     [putimg.ebp], putimage_get2bpp
510
        jz      .correct
509
        jz      .correct
511
        cmp     [putimg.ebp], putimage_get4bpp
510
        cmp     [putimg.ebp], putimage_get4bpp
512
        jnz     @f
511
        jnz     @f
513
;--------------------------------------
512
;--------------------------------------
514
align 4
513
align 4
515
.correct:
514
.correct:
516
        mov     eax, [putimg.edi]
515
        mov     eax, [putimg.edi]
517
        mov     byte [eax], 80h
516
        mov     byte [eax], 80h
518
;--------------------------------------
517
;--------------------------------------
519
align 4
518
align 4
520
@@:
519
@@:
521
        dec     edi
520
        dec     edi
522
        jnz     .new_line
521
        jnz     .new_line
523
;--------------------------------------
522
;--------------------------------------
524
align 4
523
align 4
525
.finish:
524
.finish:
526
        add     esp, putimg.stack_data
525
        add     esp, putimg.stack_data
527
        popad
526
        popad
528
        cmp     [SCR_MODE], 0x12
527
        cmp     [SCR_MODE], 0x12
529
        jne     @f
528
        jne     @f
530
        call    VGA__putimage
529
        call    VGA__putimage
531
;--------------------------------------
530
;--------------------------------------
532
align 4
531
align 4
533
@@:
532
@@:
534
        mov     [EGA_counter], 1
533
        mov     [EGA_counter], 1
535
        ret
534
        ret
536
;------------------------------------------------------------------------------
535
;------------------------------------------------------------------------------
537
align 4
536
align 4
538
put_image_end_32_old:
537
put_image_end_32_old:
539
;--------------------------------------
538
;--------------------------------------
540
align 4
539
align 4
541
.new_line:
540
.new_line:
542
        mov     ecx, [putimg.real_sx]
541
        mov     ecx, [putimg.real_sx]
543
;--------------------------------------
542
;--------------------------------------
544
align 4
543
align 4
545
.new_x:
544
.new_x:
546
        push    [putimg.edi]
545
        push    [putimg.edi]
547
        mov     eax, [putimg.ebp+4]
546
        mov     eax, [putimg.ebp+4]
548
        call    eax
547
        call    eax
549
        cmp     [ebp], bl
548
        cmp     [ebp], bl
550
        jne     .skip
549
        jne     .skip
551
;--------------------------------------
550
;--------------------------------------
552
        push    ecx
551
        push    ecx
553
 
552
 
554
        neg     ecx
553
        neg     ecx
555
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
554
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
556
        shl     ecx, 16
555
        shl     ecx, 16
557
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
556
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
558
        sub     ecx, edi
557
        sub     ecx, edi
559
 
558
 
560
; check mouse area for putpixel
559
; check mouse area for putpixel
561
        call    check_mouse_area_for_putpixel
560
        call    check_mouse_area_for_putpixel
562
        pop     ecx
561
        pop     ecx
563
; store to real LFB
562
; store to real LFB
564
        mov     [LFB_BASE+edx], eax
563
        mov     [LFB_BASE+edx], eax
565
;--------------------------------------
564
;--------------------------------------
566
align 4
565
align 4
567
.skip:
566
.skip:
568
        add     edx, 4
567
        add     edx, 4
569
        inc     ebp
568
        inc     ebp
570
        dec     ecx
569
        dec     ecx
571
        jnz     .new_x
570
        jnz     .new_x
572
 
571
 
573
        add     esi, [putimg.line_increment]
572
        add     esi, [putimg.line_increment]
574
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
573
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
575
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
574
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
576
 
575
 
577
        cmp     [putimg.ebp], putimage_get1bpp
576
        cmp     [putimg.ebp], putimage_get1bpp
578
        jz      .correct
577
        jz      .correct
579
        cmp     [putimg.ebp], putimage_get2bpp
578
        cmp     [putimg.ebp], putimage_get2bpp
580
        jz      .correct
579
        jz      .correct
581
        cmp     [putimg.ebp], putimage_get4bpp
580
        cmp     [putimg.ebp], putimage_get4bpp
582
        jnz     @f
581
        jnz     @f
583
;--------------------------------------
582
;--------------------------------------
584
align 4
583
align 4
585
.correct:
584
.correct:
586
        mov     eax, [putimg.edi]
585
        mov     eax, [putimg.edi]
587
        mov     byte [eax], 80h
586
        mov     byte [eax], 80h
588
;--------------------------------------
587
;--------------------------------------
589
align 4
588
align 4
590
@@:
589
@@:
591
        dec     edi
590
        dec     edi
592
        jnz     .new_line
591
        jnz     .new_line
593
        jmp     put_image_end_32.finish
592
        jmp     put_image_end_32.finish
594
;------------------------------------------------------------------------------
593
;------------------------------------------------------------------------------
595
align 4
594
align 4
596
put_image_end_32_new:
595
put_image_end_32_new:
597
;--------------------------------------
596
;--------------------------------------
598
align 4
597
align 4
599
.new_line:
598
.new_line:
600
        mov     ecx, [putimg.real_sx]
599
        mov     ecx, [putimg.real_sx]
601
;--------------------------------------
600
;--------------------------------------
602
align 4
601
align 4
603
.new_x:
602
.new_x:
604
        push    [putimg.edi]
603
        push    [putimg.edi]
605
        mov     eax, [putimg.ebp+4]
604
        mov     eax, [putimg.ebp+4]
606
        call    eax
605
        call    eax
607
        cmp     [ebp], bl
606
        cmp     [ebp], bl
608
        jne     .skip
607
        jne     .skip
609
;--------------------------------------
608
;--------------------------------------
610
        push    ecx
609
        push    ecx
611
;--------------------------------------
610
;--------------------------------------
612
align 4
611
align 4
613
.sh:
612
.sh:
614
        neg     ecx
613
        neg     ecx
615
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
614
        add     ecx, [putimg.real_sx_and_abs_cx + 4]
616
;--------------------------------------
615
;--------------------------------------
617
; check for X
616
; check for X
618
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
617
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
619
        jae     .no_mouse_area
618
        jae     .no_mouse_area
620
 
619
 
621
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
620
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
622
        jb      .no_mouse_area
621
        jb      .no_mouse_area
623
 
622
 
624
        shl     ecx, 16
623
        shl     ecx, 16
625
 
624
 
626
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
625
        add     ecx, [putimg.real_sy_and_abs_cy + 4]
627
        sub     ecx, edi
626
        sub     ecx, edi
628
;--------------------------------------
627
;--------------------------------------
629
; check for Y
628
; check for Y
630
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
629
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
631
        jae     .no_mouse_area
630
        jae     .no_mouse_area
632
 
631
 
633
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
632
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
634
        jb      .no_mouse_area
633
        jb      .no_mouse_area
635
;--------------------------------------
634
;--------------------------------------
636
; check mouse area for putpixel
635
; check mouse area for putpixel
637
        call    check_mouse_area_for_putpixel_new.1
636
        call    check_mouse_area_for_putpixel_new.1
638
        cmp     ecx, -1   ;SHIT HAPPENS?
637
        cmp     ecx, -1   ;SHIT HAPPENS?
639
        jne     .no_mouse_area
638
        jne     .no_mouse_area
640
 
639
 
641
        mov     ecx, [esp]
640
        mov     ecx, [esp]
642
        jmp     .sh
641
        jmp     .sh
643
;--------------------------------------
642
;--------------------------------------
644
align 4
643
align 4
645
.no_mouse_area:
644
.no_mouse_area:
646
        pop     ecx
645
        pop     ecx
647
; store to real LFB
646
; store to real LFB
648
        mov     [LFB_BASE+edx], eax
647
        mov     [LFB_BASE+edx], eax
649
;--------------------------------------
648
;--------------------------------------
650
align 4
649
align 4
651
.skip:
650
.skip:
652
        add     edx, 4
651
        add     edx, 4
653
        inc     ebp
652
        inc     ebp
654
        dec     ecx
653
        dec     ecx
655
        jnz     .new_x
654
        jnz     .new_x
656
 
655
 
657
        add     esi, [putimg.line_increment]
656
        add     esi, [putimg.line_increment]
658
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
657
        add     edx, [putimg.screen_newline];[BytesPerScanLine]
659
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
658
        add     ebp, [putimg.winmap_newline];[Screen_Max_X]
660
 
659
 
661
        cmp     [putimg.ebp], putimage_get1bpp
660
        cmp     [putimg.ebp], putimage_get1bpp
662
        jz      .correct
661
        jz      .correct
663
        cmp     [putimg.ebp], putimage_get2bpp
662
        cmp     [putimg.ebp], putimage_get2bpp
664
        jz      .correct
663
        jz      .correct
665
        cmp     [putimg.ebp], putimage_get4bpp
664
        cmp     [putimg.ebp], putimage_get4bpp
666
        jnz     @f
665
        jnz     @f
667
;--------------------------------------
666
;--------------------------------------
668
align 4
667
align 4
669
.correct:
668
.correct:
670
        mov     eax, [putimg.edi]
669
        mov     eax, [putimg.edi]
671
        mov     byte [eax], 80h
670
        mov     byte [eax], 80h
672
;--------------------------------------
671
;--------------------------------------
673
align 4
672
align 4
674
@@:
673
@@:
675
        dec     edi
674
        dec     edi
676
        jnz     .new_line
675
        jnz     .new_line
677
        jmp     put_image_end_32.finish
676
        jmp     put_image_end_32.finish
678
;------------------------------------------------------------------------------
677
;------------------------------------------------------------------------------
679
align 4
678
align 4
680
__sys_putpixel:
679
__sys_putpixel:
681
 
680
 
682
; eax = x coordinate
681
; eax = x coordinate
683
; ebx = y coordinate
682
; ebx = y coordinate
684
; ecx = ?? RR GG BB    ; 0x01000000 negation
683
; ecx = ?? RR GG BB    ; 0x01000000 negation
685
                       ; 0x02000000 used for draw_rectangle without top line
684
                       ; 0x02000000 used for draw_rectangle without top line
686
                       ;            for example drawwindow_III and drawwindow_IV
685
                       ;            for example drawwindow_III and drawwindow_IV
687
; edi = 0x00000001 force
686
; edi = 0x00000001 force
688
 
687
 
689
        pushad
688
        pushad
690
        cmp     [Screen_Max_X], eax
689
        cmp     eax, [_display.width]
691
        jb      .exit
690
        jae     .exit
692
        cmp     [Screen_Max_Y], ebx
691
        cmp     ebx, [_display.height]
693
        jb      .exit
692
        jae     .exit
694
        test    edi, 1           ; force ?
693
        test    edi, 1           ; force ?
695
        jnz     .forced
694
        jnz     .forced
696
 
695
 
697
; not forced:
696
; not forced:
698
        mov     edx, [d_width_calc_area + ebx*4]
697
        mov     edx, [d_width_calc_area + ebx*4]
699
        add     edx, [_WinMapAddress]
698
        add     edx, [_WinMapAddress]
700
        movzx   edx, byte [eax+edx]
699
        movzx   edx, byte [eax+edx]
701
        cmp     edx, [CURRENT_TASK]
700
        cmp     edx, [CURRENT_TASK]
702
        jne     .exit
701
        jne     .exit
703
;--------------------------------------
702
;--------------------------------------
704
align 4
703
align 4
705
.forced:
704
.forced:
706
; check if negation
705
; check if negation
707
        test    ecx, 0x01000000
706
        test    ecx, 0x01000000
708
        jz      .noneg
707
        jz      .noneg
709
 
708
 
710
        call    getpixel
709
        call    getpixel
711
        not     ecx
710
        not     ecx
712
 
711
 
713
        rol     ecx, 8
712
        rol     ecx, 8
714
        mov     cl, [esp+32-8+3]
713
        mov     cl, [esp+32-8+3]
715
        ror     ecx, 8
714
        ror     ecx, 8
716
        mov     [esp+32-8], ecx
715
        mov     [esp+32-8], ecx
717
;--------------------------------------
716
;--------------------------------------
718
align 4
717
align 4
719
.noneg:
718
.noneg:
720
; OK to set pixel
719
; OK to set pixel
721
        call    dword [PUTPIXEL]; call the real put_pixel function
720
        call    dword [PUTPIXEL]; call the real put_pixel function
722
;--------------------------------------
721
;--------------------------------------
723
align 4
722
align 4
724
.exit:
723
.exit:
725
        popad
724
        popad
726
        ret
725
        ret
727
;-----------------------------------------------------------------------------
726
;-----------------------------------------------------------------------------
728
align 4
727
align 4
729
Vesa20_putpixel24:
728
Vesa20_putpixel24:
730
; eax = x
729
; eax = x
731
; ebx = y
730
; ebx = y
732
        mov     ecx, eax
731
        mov     ecx, eax
733
        shl     ecx, 16
732
        shl     ecx, 16
734
        mov     cx, bx
733
        mov     cx, bx
735
 
734
 
736
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
735
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
737
        mov     ebx, [BPSLine_calc_area+ebx*4]
736
        mov     ebx, [BPSLine_calc_area+ebx*4]
738
        lea     edi, [eax+eax*2]; edi = x*3
737
        lea     edi, [eax+eax*2]; edi = x*3
739
        mov     eax, [esp+32-8+4]
738
        mov     eax, [esp+32-8+4]
740
;--------------------------------------
739
;--------------------------------------
741
; check for hardware cursor
740
; check for hardware cursor
742
        cmp     [_display.select_cursor], 0
741
        cmp     [_display.select_cursor], 0
743
        jne     @f
742
        jne     @f
744
; check mouse area for putpixel
743
; check mouse area for putpixel
745
        test    eax, 0x04000000
744
        test    eax, 0x04000000
746
        jnz     @f
745
        jnz     @f
747
        call    check_mouse_area_for_putpixel
746
        call    check_mouse_area_for_putpixel
748
;--------------------------------------
747
;--------------------------------------
749
align 4
748
align 4
750
@@:
749
@@:
751
; store to real LFB
750
; store to real LFB
752
        mov     [LFB_BASE+ebx+edi], ax
751
        mov     [LFB_BASE+ebx+edi], ax
753
        shr     eax, 16
752
        shr     eax, 16
754
        mov     [LFB_BASE+ebx+edi+2], al
753
        mov     [LFB_BASE+ebx+edi+2], al
755
        ret
754
        ret
756
;-----------------------------------------------------------------------------
755
;-----------------------------------------------------------------------------
757
align 4
756
align 4
758
Vesa20_putpixel24_new:
757
Vesa20_putpixel24_new:
759
; eax = x
758
; eax = x
760
; ebx = y
759
; ebx = y
761
        mov     ecx, eax
760
        mov     ecx, eax
762
        shl     ecx, 16
761
        shl     ecx, 16
763
        mov     cx, bx
762
        mov     cx, bx
764
 
763
 
765
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
764
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
766
        mov     ebx, [BPSLine_calc_area+ebx*4]
765
        mov     ebx, [BPSLine_calc_area+ebx*4]
767
        lea     edi, [eax+eax*2]; edi = x*3
766
        lea     edi, [eax+eax*2]; edi = x*3
768
        mov     eax, [esp+32-8+4]
767
        mov     eax, [esp+32-8+4]
769
;--------------------------------------
768
;--------------------------------------
770
; check for hardware cursor
769
; check for hardware cursor
771
        cmp     [_display.select_cursor], select_cursor
770
        cmp     [_display.select_cursor], select_cursor
772
        jne     @f
771
        jne     @f
773
; check mouse area for putpixel
772
; check mouse area for putpixel
774
        test    eax, 0x04000000
773
        test    eax, 0x04000000
775
        jnz     @f
774
        jnz     @f
776
;--------------------------------------
775
;--------------------------------------
777
; check for Y
776
; check for Y
778
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
777
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
779
        jae     @f
778
        jae     @f
780
 
779
 
781
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
780
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
782
        jb      @f
781
        jb      @f
783
 
782
 
784
        rol     ecx, 16
783
        rol     ecx, 16
785
;--------------------------------------
784
;--------------------------------------
786
; check for X
785
; check for X
787
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
786
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
788
        jae     @f
787
        jae     @f
789
 
788
 
790
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
789
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
791
        jb      @f
790
        jb      @f
792
 
791
 
793
        ror     ecx, 16
792
        ror     ecx, 16
794
 
793
 
795
        call    check_mouse_area_for_putpixel_new.1
794
        call    check_mouse_area_for_putpixel_new.1
796
;--------------------------------------
795
;--------------------------------------
797
align 4
796
align 4
798
@@:
797
@@:
799
; store to real LFB
798
; store to real LFB
800
        mov     [LFB_BASE+ebx+edi], ax
799
        mov     [LFB_BASE+ebx+edi], ax
801
        shr     eax, 16
800
        shr     eax, 16
802
        mov     [LFB_BASE+ebx+edi+2], al
801
        mov     [LFB_BASE+ebx+edi+2], al
803
        ret
802
        ret
804
;-----------------------------------------------------------------------------
803
;-----------------------------------------------------------------------------
805
align 4
804
align 4
806
Vesa20_putpixel32:
805
Vesa20_putpixel32:
807
; eax = x
806
; eax = x
808
; ebx = y
807
; ebx = y
809
        mov     ecx, eax
808
        mov     ecx, eax
810
        shl     ecx, 16
809
        shl     ecx, 16
811
        mov     cx, bx
810
        mov     cx, bx
812
 
811
 
813
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
812
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
814
        mov     ebx, [BPSLine_calc_area+ebx*4]
813
        mov     ebx, [BPSLine_calc_area+ebx*4]
815
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
814
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
816
        mov     eax, [esp+32-8+4]; eax = color
815
        mov     eax, [esp+32-8+4]; eax = color
817
;--------------------------------------
816
;--------------------------------------
818
; check for hardware cursor
817
; check for hardware cursor
819
        cmp     [_display.select_cursor], 0
818
        cmp     [_display.select_cursor], 0
820
        jne     @f
819
        jne     @f
821
; check mouse area for putpixel
820
; check mouse area for putpixel
822
        test    eax, 0x04000000
821
        test    eax, 0x04000000
823
        jnz     @f
822
        jnz     @f
824
        call    check_mouse_area_for_putpixel
823
        call    check_mouse_area_for_putpixel
825
;--------------------------------------
824
;--------------------------------------
826
align 4
825
align 4
827
@@:
826
@@:
828
        and     eax, 0xffffff
827
        and     eax, 0xffffff
829
; store to real LFB
828
; store to real LFB
830
        mov     [LFB_BASE+edi], eax
829
        mov     [LFB_BASE+edi], eax
831
        ret
830
        ret
832
;-----------------------------------------------------------------------------
831
;-----------------------------------------------------------------------------
833
align 4
832
align 4
834
Vesa20_putpixel32_new:
833
Vesa20_putpixel32_new:
835
; eax = x
834
; eax = x
836
; ebx = y
835
; ebx = y
837
        mov     ecx, eax
836
        mov     ecx, eax
838
        shl     ecx, 16
837
        shl     ecx, 16
839
        mov     cx, bx
838
        mov     cx, bx
840
 
839
 
841
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
840
;        imul    ebx, [BytesPerScanLine]  ; ebx = y * y multiplier
842
        mov     ebx, [BPSLine_calc_area+ebx*4]
841
        mov     ebx, [BPSLine_calc_area+ebx*4]
843
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
842
        lea     edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
844
        mov     eax, [esp+32-8+4]; eax = color
843
        mov     eax, [esp+32-8+4]; eax = color
845
;--------------------------------------
844
;--------------------------------------
846
; check for hardware cursor
845
; check for hardware cursor
847
        cmp     [_display.select_cursor], select_cursor
846
        cmp     [_display.select_cursor], select_cursor
848
        jne     @f
847
        jne     @f
849
; check mouse area for putpixel
848
; check mouse area for putpixel
850
        test    eax, 0x04000000
849
        test    eax, 0x04000000
851
        jnz     @f
850
        jnz     @f
852
;--------------------------------------
851
;--------------------------------------
853
; check for Y
852
; check for Y
854
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
853
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
855
        jae     @f
854
        jae     @f
856
 
855
 
857
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
856
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
858
        jb      @f
857
        jb      @f
859
 
858
 
860
        rol     ecx, 16
859
        rol     ecx, 16
861
;--------------------------------------
860
;--------------------------------------
862
; check for X
861
; check for X
863
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
862
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
864
        jae     @f
863
        jae     @f
865
 
864
 
866
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
865
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
867
        jb      @f
866
        jb      @f
868
 
867
 
869
        ror     ecx, 16
868
        ror     ecx, 16
870
 
869
 
871
        call    check_mouse_area_for_putpixel_new.1
870
        call    check_mouse_area_for_putpixel_new.1
872
;--------------------------------------
871
;--------------------------------------
873
align 4
872
align 4
874
@@:
873
@@:
875
        and     eax, 0xffffff
874
        and     eax, 0xffffff
876
; store to real LFB
875
; store to real LFB
877
        mov     [LFB_BASE+edi], eax
876
        mov     [LFB_BASE+edi], eax
878
        ret
877
        ret
879
;-----------------------------------------------------------------------------
878
;-----------------------------------------------------------------------------
880
align 4
879
align 4
881
calculate_edi:
880
calculate_edi:
882
        mov     edi, [d_width_calc_area + ebx*4]
881
        mov     edi, [d_width_calc_area + ebx*4]
883
        add     edi, eax
882
        add     edi, eax
884
        ret
883
        ret
885
;-----------------------------------------------------------------------------
884
;-----------------------------------------------------------------------------
886
; DRAWLINE
885
; DRAWLINE
887
;-----------------------------------------------------------------------------
886
;-----------------------------------------------------------------------------
888
align 4
887
align 4
889
__sys_draw_line:
888
__sys_draw_line:
890
; draw a line
889
; draw a line
891
; eax = HIWORD = x1
890
; eax = HIWORD = x1
892
;       LOWORD = x2
891
;       LOWORD = x2
893
; ebx = HIWORD = y1
892
; ebx = HIWORD = y1
894
;       LOWORD = y2
893
;       LOWORD = y2
895
; ecx = color
894
; ecx = color
896
; edi = force ?
895
; edi = force ?
897
        pusha
896
        pusha
898
 
897
 
899
dl_x1 equ esp+20
898
dl_x1 equ esp+20
900
dl_y1 equ esp+16
899
dl_y1 equ esp+16
901
dl_x2 equ esp+12
900
dl_x2 equ esp+12
902
dl_y2 equ esp+8
901
dl_y2 equ esp+8
903
dl_dx equ esp+4
902
dl_dx equ esp+4
904
dl_dy equ esp+0
903
dl_dy equ esp+0
905
 
904
 
906
        xor     edx, edx   ; clear edx
905
        xor     edx, edx   ; clear edx
907
        xor     esi, esi   ; unpack arguments
906
        xor     esi, esi   ; unpack arguments
908
        xor     ebp, ebp
907
        xor     ebp, ebp
909
        mov     si, ax     ; esi = x2
908
        mov     si, ax     ; esi = x2
910
        mov     bp, bx     ; ebp = y2
909
        mov     bp, bx     ; ebp = y2
911
        shr     eax, 16    ; eax = x1
910
        shr     eax, 16    ; eax = x1
912
        shr     ebx, 16    ; ebx = y1
911
        shr     ebx, 16    ; ebx = y1
913
        push    eax        ; save x1
912
        push    eax        ; save x1
914
        push    ebx        ; save y1
913
        push    ebx        ; save y1
915
        push    esi        ; save x2
914
        push    esi        ; save x2
916
        push    ebp        ; save y2
915
        push    ebp        ; save y2
917
; checking x-axis...
916
; checking x-axis...
918
        sub     esi, eax   ; esi = x2-x1
917
        sub     esi, eax   ; esi = x2-x1
919
        push    esi        ; save y2-y1
918
        push    esi        ; save y2-y1
920
        jl      .x2lx1     ; is x2 less than x1 ?
919
        jl      .x2lx1     ; is x2 less than x1 ?
921
        jg      .no_vline  ; x1 > x2 ?
920
        jg      .no_vline  ; x1 > x2 ?
922
        mov     edx, ebp   ; else (if x1=x2)
921
        mov     edx, ebp   ; else (if x1=x2)
923
        call    vline
922
        call    vline
924
        push    edx ; necessary to rightly restore stack frame at .exit
923
        push    edx ; necessary to rightly restore stack frame at .exit
925
        jmp     .exit
924
        jmp     .exit
926
;--------------------------------------
925
;--------------------------------------
927
align 4
926
align 4
928
.x2lx1:
927
.x2lx1:
929
        neg     esi         ; get esi absolute value
928
        neg     esi         ; get esi absolute value
930
;--------------------------------------
929
;--------------------------------------
931
align 4
930
align 4
932
.no_vline:
931
.no_vline:
933
; checking y-axis...
932
; checking y-axis...
934
        sub     ebp, ebx    ; ebp = y2-y1
933
        sub     ebp, ebx    ; ebp = y2-y1
935
        push    ebp         ; save y2-y1
934
        push    ebp         ; save y2-y1
936
        jl      .y2ly1      ; is y2 less than y1 ?
935
        jl      .y2ly1      ; is y2 less than y1 ?
937
        jg      .no_hline   ; y1 > y2 ?
936
        jg      .no_hline   ; y1 > y2 ?
938
        mov     edx, [dl_x2]; else (if y1=y2)
937
        mov     edx, [dl_x2]; else (if y1=y2)
939
        call    hline
938
        call    hline
940
        jmp     .exit
939
        jmp     .exit
941
;--------------------------------------
940
;--------------------------------------
942
align 4
941
align 4
943
.y2ly1:
942
.y2ly1:
944
        neg     ebp         ; get ebp absolute value
943
        neg     ebp         ; get ebp absolute value
945
;--------------------------------------
944
;--------------------------------------
946
align 4
945
align 4
947
.no_hline:
946
.no_hline:
948
        cmp     ebp, esi
947
        cmp     ebp, esi
949
        jle     .x_rules    ; |y2-y1| < |x2-x1|  ?
948
        jle     .x_rules    ; |y2-y1| < |x2-x1|  ?
950
        cmp     [dl_y2], ebx; make sure y1 is at the begining
949
        cmp     [dl_y2], ebx; make sure y1 is at the begining
951
        jge     .no_reverse1
950
        jge     .no_reverse1
952
        neg     dword [dl_dx]
951
        neg     dword [dl_dx]
953
        mov     edx, [dl_x2]
952
        mov     edx, [dl_x2]
954
        mov     [dl_x2], eax
953
        mov     [dl_x2], eax
955
        mov     [dl_x1], edx
954
        mov     [dl_x1], edx
956
        mov     edx, [dl_y2]
955
        mov     edx, [dl_y2]
957
        mov     [dl_y2], ebx
956
        mov     [dl_y2], ebx
958
        mov     [dl_y1], edx
957
        mov     [dl_y1], edx
959
;--------------------------------------
958
;--------------------------------------
960
align 4
959
align 4
961
.no_reverse1:
960
.no_reverse1:
962
        mov     eax, [dl_dx]
961
        mov     eax, [dl_dx]
963
        cdq                 ; extend eax sing to edx
962
        cdq                 ; extend eax sing to edx
964
        shl     eax, 16     ; using 16bit fix-point maths
963
        shl     eax, 16     ; using 16bit fix-point maths
965
        idiv    ebp         ; eax = ((x2-x1)*65536)/(y2-y1)
964
        idiv    ebp         ; eax = ((x2-x1)*65536)/(y2-y1)
966
;--------------------------------------
965
;--------------------------------------
967
; correction for the remainder of the division
966
; correction for the remainder of the division
968
        shl     edx, 1
967
        shl     edx, 1
969
        cmp     ebp, edx
968
        cmp     ebp, edx
970
        jb      @f
969
        jb      @f
971
        inc     eax
970
        inc     eax
972
;--------------------------------------
971
;--------------------------------------
973
align 4
972
align 4
974
@@:
973
@@:
975
;--------------------------------------
974
;--------------------------------------
976
        mov     edx, ebp    ; edx = counter (number of pixels to draw)
975
        mov     edx, ebp    ; edx = counter (number of pixels to draw)
977
        mov     ebp, 1 *65536; <<16   ; ebp = dy = 1.0
976
        mov     ebp, 1 *65536; <<16   ; ebp = dy = 1.0
978
        mov     esi, eax    ; esi = dx
977
        mov     esi, eax    ; esi = dx
979
        jmp     .y_rules
978
        jmp     .y_rules
980
;--------------------------------------
979
;--------------------------------------
981
align 4
980
align 4
982
.x_rules:
981
.x_rules:
983
        cmp     [dl_x2], eax ; make sure x1 is at the begining
982
        cmp     [dl_x2], eax ; make sure x1 is at the begining
984
        jge     .no_reverse2
983
        jge     .no_reverse2
985
        neg     dword [dl_dy]
984
        neg     dword [dl_dy]
986
        mov     edx, [dl_x2]
985
        mov     edx, [dl_x2]
987
        mov     [dl_x2], eax
986
        mov     [dl_x2], eax
988
        mov     [dl_x1], edx
987
        mov     [dl_x1], edx
989
        mov     edx, [dl_y2]
988
        mov     edx, [dl_y2]
990
        mov     [dl_y2], ebx
989
        mov     [dl_y2], ebx
991
        mov     [dl_y1], edx
990
        mov     [dl_y1], edx
992
;--------------------------------------
991
;--------------------------------------
993
align 4
992
align 4
994
.no_reverse2:
993
.no_reverse2:
995
        xor     edx, edx
994
        xor     edx, edx
996
        mov     eax, [dl_dy]
995
        mov     eax, [dl_dy]
997
        cdq                 ; extend eax sing to edx
996
        cdq                 ; extend eax sing to edx
998
        shl     eax, 16     ; using 16bit fix-point maths
997
        shl     eax, 16     ; using 16bit fix-point maths
999
        idiv    esi         ; eax = ((y2-y1)*65536)/(x2-x1)
998
        idiv    esi         ; eax = ((y2-y1)*65536)/(x2-x1)
1000
;--------------------------------------
999
;--------------------------------------
1001
; correction for the remainder of the division
1000
; correction for the remainder of the division
1002
        shl     edx, 1
1001
        shl     edx, 1
1003
        cmp     esi, edx
1002
        cmp     esi, edx
1004
        jb      @f
1003
        jb      @f
1005
        inc     eax
1004
        inc     eax
1006
;--------------------------------------
1005
;--------------------------------------
1007
align 4
1006
align 4
1008
@@:
1007
@@:
1009
;--------------------------------------
1008
;--------------------------------------
1010
        mov     edx, esi    ; edx = counter (number of pixels to draw)
1009
        mov     edx, esi    ; edx = counter (number of pixels to draw)
1011
        mov     esi, 1 *65536;<< 16   ; esi = dx = 1.0
1010
        mov     esi, 1 *65536;<< 16   ; esi = dx = 1.0
1012
        mov     ebp, eax    ; ebp = dy
1011
        mov     ebp, eax    ; ebp = dy
1013
;--------------------------------------
1012
;--------------------------------------
1014
align 4
1013
align 4
1015
.y_rules:
1014
.y_rules:
1016
        mov     eax, [dl_x1]
1015
        mov     eax, [dl_x1]
1017
        mov     ebx, [dl_y1]
1016
        mov     ebx, [dl_y1]
1018
        shl     eax, 16
1017
        shl     eax, 16
1019
        shl     ebx, 16
1018
        shl     ebx, 16
1020
 
1019
 
1021
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
1020
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
1022
;-----------------------------------------------------------------------------
1021
;-----------------------------------------------------------------------------
1023
align 4
1022
align 4
1024
.draw:
1023
.draw:
1025
        push    eax ebx
1024
        push    eax ebx
1026
;--------------------------------------
1025
;--------------------------------------
1027
; correction for the remainder of the division
1026
; correction for the remainder of the division
1028
        test    ah, 0x80
1027
        test    ah, 0x80
1029
        jz      @f
1028
        jz      @f
1030
        add     eax, 1 shl 16
1029
        add     eax, 1 shl 16
1031
;--------------------------------------
1030
;--------------------------------------
1032
align 4
1031
align 4
1033
@@:
1032
@@:
1034
;--------------------------------------
1033
;--------------------------------------
1035
        shr     eax, 16
1034
        shr     eax, 16
1036
;--------------------------------------
1035
;--------------------------------------
1037
; correction for the remainder of the division
1036
; correction for the remainder of the division
1038
        test    bh, 0x80
1037
        test    bh, 0x80
1039
        jz      @f
1038
        jz      @f
1040
        add     ebx, 1 shl 16
1039
        add     ebx, 1 shl 16
1041
;--------------------------------------
1040
;--------------------------------------
1042
align 4
1041
align 4
1043
@@:
1042
@@:
1044
;--------------------------------------
1043
;--------------------------------------
1045
        shr     ebx, 16
1044
        shr     ebx, 16
1046
;        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
1045
;        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
1047
;        call    [putpixel]
1046
;        call    [putpixel]
1048
        call    __sys_putpixel
1047
        call    __sys_putpixel
1049
        pop     ebx eax
1048
        pop     ebx eax
1050
        add     ebx, ebp     ; y = y+dy
1049
        add     ebx, ebp     ; y = y+dy
1051
        add     eax, esi     ; x = x+dx
1050
        add     eax, esi     ; x = x+dx
1052
        dec     edx
1051
        dec     edx
1053
        jnz     .draw
1052
        jnz     .draw
1054
; force last drawn pixel to be at (x2,y2)
1053
; force last drawn pixel to be at (x2,y2)
1055
        mov     eax, [dl_x2]
1054
        mov     eax, [dl_x2]
1056
        mov     ebx, [dl_y2]
1055
        mov     ebx, [dl_y2]
1057
;        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
1056
;        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
1058
;        call    [putpixel]
1057
;        call    [putpixel]
1059
        call    __sys_putpixel
1058
        call    __sys_putpixel
1060
;--------------------------------------
1059
;--------------------------------------
1061
align 4
1060
align 4
1062
.exit:
1061
.exit:
1063
        add     esp, 6*4
1062
        add     esp, 6*4
1064
        popa
1063
        popa
1065
;        call    [draw_pointer]
1064
;        call    [draw_pointer]
1066
        ret
1065
        ret
1067
;------------------------------------------------------------------------------
1066
;------------------------------------------------------------------------------
1068
align 4
1067
align 4
1069
hline:
1068
hline:
1070
; draw an horizontal line
1069
; draw an horizontal line
1071
; eax = x1
1070
; eax = x1
1072
; edx = x2
1071
; edx = x2
1073
; ebx = y
1072
; ebx = y
1074
; ecx = color
1073
; ecx = color
1075
; edi = force ?
1074
; edi = force ?
1076
        push    eax edx
1075
        push    eax edx
1077
        cmp     edx, eax   ; make sure x2 is above x1
1076
        cmp     edx, eax   ; make sure x2 is above x1
1078
        jge     @f
1077
        jge     @f
1079
        xchg    eax, edx
1078
        xchg    eax, edx
1080
;--------------------------------------
1079
;--------------------------------------
1081
align 4
1080
align 4
1082
@@:
1081
@@:
1083
        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
1082
        and     ecx, 0xFBFFFFFF  ;negate 0x04000000 save to mouseunder area
1084
;--------------------------------------
1083
;--------------------------------------
1085
align 4
1084
align 4
1086
@@:
1085
@@:
1087
;        call    [putpixel]
1086
;        call    [putpixel]
1088
        call    __sys_putpixel
1087
        call    __sys_putpixel
1089
        inc     eax
1088
        inc     eax
1090
        cmp     eax, edx
1089
        cmp     eax, edx
1091
        jle     @b
1090
        jle     @b
1092
        pop     edx eax
1091
        pop     edx eax
1093
        ret
1092
        ret
1094
;------------------------------------------------------------------------------
1093
;------------------------------------------------------------------------------
1095
align 4
1094
align 4
1096
vline:
1095
vline:
1097
; draw a vertical line
1096
; draw a vertical line
1098
; eax = x
1097
; eax = x
1099
; ebx = y1
1098
; ebx = y1
1100
; edx = y2
1099
; edx = y2
1101
; ecx = color
1100
; ecx = color
1102
; edi = force ?
1101
; edi = force ?
1103
        push    ebx edx
1102
        push    ebx edx
1104
        cmp     edx, ebx   ; make sure y2 is above y1
1103
        cmp     edx, ebx   ; make sure y2 is above y1
1105
        jge     @f
1104
        jge     @f
1106
        xchg    ebx, edx
1105
        xchg    ebx, edx
1107
;--------------------------------------
1106
;--------------------------------------
1108
align 4
1107
align 4
1109
@@:
1108
@@:
1110
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
1109
        and     ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area
1111
;--------------------------------------
1110
;--------------------------------------
1112
align 4
1111
align 4
1113
@@:
1112
@@:
1114
;        call    [putpixel]
1113
;        call    [putpixel]
1115
        call    __sys_putpixel
1114
        call    __sys_putpixel
1116
        inc     ebx
1115
        inc     ebx
1117
        cmp     ebx, edx
1116
        cmp     ebx, edx
1118
        jle     @b
1117
        jle     @b
1119
        pop     edx ebx
1118
        pop     edx ebx
1120
        ret
1119
        ret
1121
;------------------------------------------------------------------------------
1120
;------------------------------------------------------------------------------
1122
align 4
1121
align 4
1123
virtual at esp
1122
virtual at esp
1124
drbar:
1123
drbar:
1125
     .bar_sx       dd ?
1124
     .bar_sx       dd ?
1126
     .bar_sy       dd ?
1125
     .bar_sy       dd ?
1127
     .bar_cx       dd ?
1126
     .bar_cx       dd ?
1128
     .bar_cy       dd ?
1127
     .bar_cy       dd ?
1129
     .abs_cx       dd ?
1128
     .abs_cx       dd ?
1130
     .abs_cy       dd ?
1129
     .abs_cy       dd ?
1131
     .real_sx      dd ?
1130
     .real_sx      dd ?
1132
     .real_sy      dd ?
1131
     .real_sy      dd ?
1133
     .color        dd ?
1132
     .color        dd ?
1134
     .line_inc_scr dd ?
1133
     .line_inc_scr dd ?
1135
     .line_inc_map dd ?
1134
     .line_inc_map dd ?
1136
     .real_sx_and_abs_cx dd ?
1135
     .real_sx_and_abs_cx dd ?
1137
     .real_sy_and_abs_cy dd ?
1136
     .real_sy_and_abs_cy dd ?
1138
     .stack_data = 4*13
1137
     .stack_data = 4*13
1139
end virtual
1138
end virtual
1140
;--------------------------------------
1139
;--------------------------------------
1141
align 4
1140
align 4
1142
; eax   cx
1141
; eax   cx
1143
; ebx   cy
1142
; ebx   cy
1144
; ecx   xe
1143
; ecx   xe
1145
; edx   ye
1144
; edx   ye
1146
; edi   color
1145
; edi   color
1147
vesa20_drawbar:
1146
vesa20_drawbar:
1148
        pushad
1147
        pushad
1149
        sub     esp, drbar.stack_data
1148
        sub     esp, drbar.stack_data
1150
        mov     [drbar.color], edi
1149
        mov     [drbar.color], edi
1151
        sub     edx, ebx
1150
        sub     edx, ebx
1152
        jle     .exit       ;// mike.dld, 2005-01-29
1151
        jle     .exit       ;// mike.dld, 2005-01-29
1153
        sub     ecx, eax
1152
        sub     ecx, eax
1154
        jle     .exit       ;// mike.dld, 2005-01-29
1153
        jle     .exit       ;// mike.dld, 2005-01-29
1155
        mov     [drbar.bar_sy], edx
1154
        mov     [drbar.bar_sy], edx
1156
        mov     [drbar.bar_sx], ecx
1155
        mov     [drbar.bar_sx], ecx
1157
        mov     [drbar.bar_cx], eax
1156
        mov     [drbar.bar_cx], eax
1158
        mov     [drbar.bar_cy], ebx
1157
        mov     [drbar.bar_cy], ebx
1159
        mov     edi, [TASK_BASE]
1158
        mov     edi, [TASK_BASE]
1160
        add     eax, [edi-twdw + WDATA.box.left]; win_cx
1159
        add     eax, [edi-twdw + WDATA.box.left]; win_cx
1161
        add     ebx, [edi-twdw + WDATA.box.top]; win_cy
1160
        add     ebx, [edi-twdw + WDATA.box.top]; win_cy
1162
        mov     [drbar.abs_cx], eax
1161
        mov     [drbar.abs_cx], eax
1163
        mov     [drbar.abs_cy], ebx
1162
        mov     [drbar.abs_cy], ebx
1164
; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
1163
; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
1165
        mov     ebx, [edi-twdw + WDATA.box.width]; ebx = wnd_sx
1164
        mov     ebx, [edi-twdw + WDATA.box.width]; ebx = wnd_sx
1166
; \begin{diamond}[20.08.2006]
1165
; \begin{diamond}[20.08.2006]
1167
; note that WDATA.box.width is one pixel less than real window x-size
1166
; note that WDATA.box.width is one pixel less than real window x-size
1168
        inc     ebx
1167
        inc     ebx
1169
; \end{diamond}[20.08.2006]
1168
; \end{diamond}[20.08.2006]
1170
        sub     ebx, [drbar.bar_cx]
1169
        sub     ebx, [drbar.bar_cx]
1171
        ja      @f
1170
        ja      @f
1172
;--------------------------------------
1171
;--------------------------------------
1173
align 4
1172
align 4
1174
.exit:                       ;// mike.dld, 2005-01-29
1173
.exit:                       ;// mike.dld, 2005-01-29
1175
        add     esp, drbar.stack_data
1174
        add     esp, drbar.stack_data
1176
        popad
1175
        popad
1177
        xor     eax, eax
1176
        xor     eax, eax
1178
        inc     eax
1177
        inc     eax
1179
        ret
1178
        ret
1180
;--------------------------------------
1179
;--------------------------------------
1181
align 4
1180
align 4
1182
@@:
1181
@@:
1183
        cmp     ebx, [drbar.bar_sx]
1182
        cmp     ebx, [drbar.bar_sx]
1184
        jbe     .end_x
1183
        jbe     .end_x
1185
        mov     ebx, [drbar.bar_sx]
1184
        mov     ebx, [drbar.bar_sx]
1186
;--------------------------------------
1185
;--------------------------------------
1187
align 4
1186
align 4
1188
.end_x:
1187
.end_x:
1189
        mov     [drbar.real_sx], ebx
1188
        mov     [drbar.real_sx], ebx
1190
; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
1189
; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
1191
        mov     ebx, [edi-twdw + WDATA.box.height]; ebx = wnd_sy
1190
        mov     ebx, [edi-twdw + WDATA.box.height]; ebx = wnd_sy
1192
; \begin{diamond}[20.08.2006]
1191
; \begin{diamond}[20.08.2006]
1193
        inc     ebx
1192
        inc     ebx
1194
; \end{diamond}
1193
; \end{diamond}
1195
        sub     ebx, [drbar.bar_cy]
1194
        sub     ebx, [drbar.bar_cy]
1196
        ja      @f
1195
        ja      @f
1197
        add     esp, drbar.stack_data
1196
        add     esp, drbar.stack_data
1198
        popad
1197
        popad
1199
        xor     eax, eax
1198
        xor     eax, eax
1200
        inc     eax
1199
        inc     eax
1201
        ret
1200
        ret
1202
;--------------------------------------
1201
;--------------------------------------
1203
align 4
1202
align 4
1204
@@:
1203
@@:
1205
        cmp     ebx, [drbar.bar_sy]
1204
        cmp     ebx, [drbar.bar_sy]
1206
        jbe     .end_y
1205
        jbe     .end_y
1207
        mov     ebx, [drbar.bar_sy]
1206
        mov     ebx, [drbar.bar_sy]
1208
;--------------------------------------
1207
;--------------------------------------
1209
align 4
1208
align 4
1210
.end_y:
1209
.end_y:
1211
        mov     [drbar.real_sy], ebx
1210
        mov     [drbar.real_sy], ebx
1212
; line_inc_map
1211
; line_inc_map
1213
        mov     eax, [Screen_Max_X]
1212
        mov     eax, [_display.width]
1214
        sub     eax, [drbar.real_sx]
1213
        sub     eax, [drbar.real_sx]
1215
        inc     eax
-
 
1216
        mov     [drbar.line_inc_map], eax
1214
        mov     [drbar.line_inc_map], eax
1217
; line_inc_scr
1215
; line_inc_scr
1218
        mov     eax, [drbar.real_sx]
1216
        mov     eax, [drbar.real_sx]
1219
        mov     ebx, [_display.bpp]
1217
        mov     ebx, [_display.bpp]
1220
        shr     ebx, 3
1218
        shr     ebx, 3
1221
        imul    eax, ebx
1219
        imul    eax, ebx
1222
        neg     eax
1220
        neg     eax
1223
        add     eax, [_display.pitch]
1221
        add     eax, [_display.pitch]
1224
        mov     [drbar.line_inc_scr], eax
1222
        mov     [drbar.line_inc_scr], eax
1225
; pointer to screen
1223
; pointer to screen
1226
        mov     edx, [drbar.abs_cy]
1224
        mov     edx, [drbar.abs_cy]
1227
;        imul    edx, [BytesPerScanLine]
1225
;        imul    edx, [BytesPerScanLine]
1228
        mov     edx, [BPSLine_calc_area+edx*4]
1226
        mov     edx, [BPSLine_calc_area+edx*4]
1229
        mov     eax, [drbar.abs_cx]
1227
        mov     eax, [drbar.abs_cx]
1230
        imul    eax, ebx
1228
        imul    eax, ebx
1231
        add     edx, eax
1229
        add     edx, eax
1232
; pointer to pixel map
1230
; pointer to pixel map
1233
        mov     eax, [drbar.abs_cy]
1231
        mov     eax, [drbar.abs_cy]
1234
;        imul    eax, [Screen_Max_X]
1232
;        imul    eax, [Screen_Max_X]
1235
;        add     eax, [drbar.abs_cy]
1233
;        add     eax, [drbar.abs_cy]
1236
        mov     eax, [d_width_calc_area + eax*4]
1234
        mov     eax, [d_width_calc_area + eax*4]
1237
 
1235
 
1238
        add     eax, [drbar.abs_cx]
1236
        add     eax, [drbar.abs_cx]
1239
        add     eax, [_WinMapAddress]
1237
        add     eax, [_WinMapAddress]
1240
        xchg    eax, ebp
1238
        xchg    eax, ebp
1241
;--------------------------------------
1239
;--------------------------------------
1242
        mov     ebx, [drbar.real_sx]
1240
        mov     ebx, [drbar.real_sx]
1243
        add     ebx, [drbar.abs_cx]
1241
        add     ebx, [drbar.abs_cx]
1244
        mov     [drbar.real_sx_and_abs_cx], ebx
1242
        mov     [drbar.real_sx_and_abs_cx], ebx
1245
        mov     ebx, [drbar.real_sy]
1243
        mov     ebx, [drbar.real_sy]
1246
        add     ebx, [drbar.abs_cy]
1244
        add     ebx, [drbar.abs_cy]
1247
        mov     [drbar.real_sy_and_abs_cy], ebx
1245
        mov     [drbar.real_sy_and_abs_cy], ebx
1248
 
1246
 
1249
        add     edx, LFB_BASE
1247
        add     edx, LFB_BASE
1250
;--------------------------------------
1248
;--------------------------------------
1251
; get process number
1249
; get process number
1252
        mov     ebx, [CURRENT_TASK]  ; bl - process num
1250
        mov     ebx, [CURRENT_TASK]  ; bl - process num
1253
        mov     esi, [drbar.real_sy]
1251
        mov     esi, [drbar.real_sy]
1254
        mov     eax, [drbar.color] ; BBGGRR00
1252
        mov     eax, [drbar.color] ; BBGGRR00
1255
        rol     eax, 8
1253
        rol     eax, 8
1256
        mov     bh, al  ; 0x80 drawing gradient bars
1254
        mov     bh, al  ; 0x80 drawing gradient bars
1257
        ror     eax, 8
1255
        ror     eax, 8
1258
        cmp     byte [_display.bpp], 24
1256
        cmp     byte [_display.bpp], 24
1259
        jne     draw_bar_end_32
1257
        jne     draw_bar_end_32
1260
;--------------------------------------
1258
;--------------------------------------
1261
align 4
1259
align 4
1262
draw_bar_end_24:
1260
draw_bar_end_24:
1263
; eax - color high   RRGGBB
1261
; eax - color high   RRGGBB
1264
; bl - process num
1262
; bl - process num
1265
; ecx - temp
1263
; ecx - temp
1266
; edx - pointer to screen
1264
; edx - pointer to screen
1267
; esi - counter
1265
; esi - counter
1268
; edi - counter
1266
; edi - counter
1269
;--------------------------------------
1267
;--------------------------------------
1270
; check for hardware cursor
1268
; check for hardware cursor
1271
        mov     ecx, [_display.select_cursor]
1269
        mov     ecx, [_display.select_cursor]
1272
        cmp     ecx, select_cursor
1270
        cmp     ecx, select_cursor
1273
        je      draw_bar_end_24_new
1271
        je      draw_bar_end_24_new
1274
        cmp     ecx, 0
1272
        cmp     ecx, 0
1275
        je      draw_bar_end_24_old
1273
        je      draw_bar_end_24_old
1276
;--------------------------------------
1274
;--------------------------------------
1277
align 4
1275
align 4
1278
.new_y:
1276
.new_y:
1279
        mov     edi, [drbar.real_sx]
1277
        mov     edi, [drbar.real_sx]
1280
;--------------------------------------
1278
;--------------------------------------
1281
align 4
1279
align 4
1282
.new_x:
1280
.new_x:
1283
        cmp     byte [ebp], bl
1281
        cmp     byte [ebp], bl
1284
        jne     .skip
1282
        jne     .skip
1285
;--------------------------------------
1283
;--------------------------------------
1286
; store to real LFB
1284
; store to real LFB
1287
        mov     [edx], ax
1285
        mov     [edx], ax
1288
        shr     eax, 16
1286
        shr     eax, 16
1289
        mov     [edx + 2], al
1287
        mov     [edx + 2], al
1290
;--------------------------------------
1288
;--------------------------------------
1291
align 4
1289
align 4
1292
.skip:
1290
.skip:
1293
; add pixel
1291
; add pixel
1294
        add     edx, 3
1292
        add     edx, 3
1295
        inc     ebp
1293
        inc     ebp
1296
        dec     edi
1294
        dec     edi
1297
        jnz     .new_x
1295
        jnz     .new_x
1298
; add line
1296
; add line
1299
        add     edx, [drbar.line_inc_scr]
1297
        add     edx, [drbar.line_inc_scr]
1300
        add     ebp, [drbar.line_inc_map]
1298
        add     ebp, [drbar.line_inc_map]
1301
; drawing gradient bars
1299
; drawing gradient bars
1302
        test    bh, 0x80
1300
        test    bh, 0x80
1303
        jz      @f
1301
        jz      @f
1304
        test    al, al
1302
        test    al, al
1305
        jz      @f
1303
        jz      @f
1306
        dec     al
1304
        dec     al
1307
;--------------------------------------
1305
;--------------------------------------
1308
align 4
1306
align 4
1309
@@:
1307
@@:
1310
        dec     esi
1308
        dec     esi
1311
        jnz     .new_y
1309
        jnz     .new_y
1312
;--------------------------------------
1310
;--------------------------------------
1313
align 4
1311
align 4
1314
.end:
1312
.end:
1315
        add     esp, drbar.stack_data
1313
        add     esp, drbar.stack_data
1316
        popad
1314
        popad
1317
        xor     eax, eax
1315
        xor     eax, eax
1318
        ret
1316
        ret
1319
;------------------------------------------------------------------------------
1317
;------------------------------------------------------------------------------
1320
align 4
1318
align 4
1321
draw_bar_end_24_old:
1319
draw_bar_end_24_old:
1322
;--------------------------------------
1320
;--------------------------------------
1323
align 4
1321
align 4
1324
.new_y:
1322
.new_y:
1325
        mov     edi, [drbar.real_sx]
1323
        mov     edi, [drbar.real_sx]
1326
;--------------------------------------
1324
;--------------------------------------
1327
align 4
1325
align 4
1328
.new_x:
1326
.new_x:
1329
        cmp     byte [ebp], bl
1327
        cmp     byte [ebp], bl
1330
        jne     .skip
1328
        jne     .skip
1331
;--------------------------------------
1329
;--------------------------------------
1332
        mov     ecx, [drbar.real_sx_and_abs_cx]
1330
        mov     ecx, [drbar.real_sx_and_abs_cx]
1333
        sub     ecx, edi
1331
        sub     ecx, edi
1334
        shl     ecx, 16
1332
        shl     ecx, 16
1335
        add     ecx, [drbar.real_sy_and_abs_cy]
1333
        add     ecx, [drbar.real_sy_and_abs_cy]
1336
        sub     ecx, esi
1334
        sub     ecx, esi
1337
; check mouse area for putpixel
1335
; check mouse area for putpixel
1338
        call    check_mouse_area_for_putpixel
1336
        call    check_mouse_area_for_putpixel
1339
; store to real LFB
1337
; store to real LFB
1340
        mov     [edx], ax
1338
        mov     [edx], ax
1341
        shr     eax, 16
1339
        shr     eax, 16
1342
        mov     [edx + 2], al
1340
        mov     [edx + 2], al
1343
        mov     eax, [drbar.color]
1341
        mov     eax, [drbar.color]
1344
;--------------------------------------
1342
;--------------------------------------
1345
align 4
1343
align 4
1346
.skip:
1344
.skip:
1347
; add pixel
1345
; add pixel
1348
        add     edx, 3
1346
        add     edx, 3
1349
        inc     ebp
1347
        inc     ebp
1350
        dec     edi
1348
        dec     edi
1351
        jnz     .new_x
1349
        jnz     .new_x
1352
; add line
1350
; add line
1353
        add     edx, [drbar.line_inc_scr]
1351
        add     edx, [drbar.line_inc_scr]
1354
        add     ebp, [drbar.line_inc_map]
1352
        add     ebp, [drbar.line_inc_map]
1355
; drawing gradient bars
1353
; drawing gradient bars
1356
        test    bh, 0x80
1354
        test    bh, 0x80
1357
        jz      @f
1355
        jz      @f
1358
        test    al, al
1356
        test    al, al
1359
        jz      @f
1357
        jz      @f
1360
        dec     al
1358
        dec     al
1361
;--------------------------------------
1359
;--------------------------------------
1362
align 4
1360
align 4
1363
@@:
1361
@@:
1364
        dec     esi
1362
        dec     esi
1365
        jnz     .new_y
1363
        jnz     .new_y
1366
        jmp     draw_bar_end_24.end
1364
        jmp     draw_bar_end_24.end
1367
;------------------------------------------------------------------------------
1365
;------------------------------------------------------------------------------
1368
align 4
1366
align 4
1369
draw_bar_end_24_new:
1367
draw_bar_end_24_new:
1370
;--------------------------------------
1368
;--------------------------------------
1371
align 4
1369
align 4
1372
.new_y:
1370
.new_y:
1373
        mov     edi, [drbar.real_sx]
1371
        mov     edi, [drbar.real_sx]
1374
;--------------------------------------
1372
;--------------------------------------
1375
align 4
1373
align 4
1376
.new_x:
1374
.new_x:
1377
        cmp     byte [ebp], bl
1375
        cmp     byte [ebp], bl
1378
        jne     .skip
1376
        jne     .skip
1379
;--------------------------------------
1377
;--------------------------------------
1380
        mov     ecx, [drbar.real_sy_and_abs_cy]
1378
        mov     ecx, [drbar.real_sy_and_abs_cy]
1381
        sub     ecx, esi
1379
        sub     ecx, esi
1382
;--------------------------------------
1380
;--------------------------------------
1383
; check for Y
1381
; check for Y
1384
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1382
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1385
        jae     .no_mouse_area
1383
        jae     .no_mouse_area
1386
 
1384
 
1387
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1385
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1388
        jb      .no_mouse_area
1386
        jb      .no_mouse_area
1389
 
1387
 
1390
        rol     ecx, 16
1388
        rol     ecx, 16
1391
        add     ecx, [drbar.real_sx_and_abs_cx]
1389
        add     ecx, [drbar.real_sx_and_abs_cx]
1392
        sub     ecx, edi
1390
        sub     ecx, edi
1393
;--------------------------------------
1391
;--------------------------------------
1394
; check for X
1392
; check for X
1395
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1393
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1396
        jae     .no_mouse_area
1394
        jae     .no_mouse_area
1397
 
1395
 
1398
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1396
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1399
        jb      .no_mouse_area
1397
        jb      .no_mouse_area
1400
 
1398
 
1401
        ror     ecx, 16
1399
        ror     ecx, 16
1402
;--------------------------------------
1400
;--------------------------------------
1403
; check mouse area for putpixel
1401
; check mouse area for putpixel
1404
        push    eax
1402
        push    eax
1405
        call    check_mouse_area_for_putpixel_new.1
1403
        call    check_mouse_area_for_putpixel_new.1
1406
        mov     [edx], ax
1404
        mov     [edx], ax
1407
        shr     eax, 16
1405
        shr     eax, 16
1408
        mov     [edx + 2], al
1406
        mov     [edx + 2], al
1409
        pop     eax
1407
        pop     eax
1410
        jmp     .skip
1408
        jmp     .skip
1411
; store to real LFB
1409
; store to real LFB
1412
;--------------------------------------
1410
;--------------------------------------
1413
align 4
1411
align 4
1414
.no_mouse_area:
1412
.no_mouse_area:
1415
        mov     [edx], ax
1413
        mov     [edx], ax
1416
        ror     eax, 16
1414
        ror     eax, 16
1417
        mov     [edx + 2], al
1415
        mov     [edx + 2], al
1418
        rol     eax, 16
1416
        rol     eax, 16
1419
;--------------------------------------
1417
;--------------------------------------
1420
align 4
1418
align 4
1421
.skip:
1419
.skip:
1422
; add pixel
1420
; add pixel
1423
        add     edx, 3
1421
        add     edx, 3
1424
        inc     ebp
1422
        inc     ebp
1425
        dec     edi
1423
        dec     edi
1426
        jnz     .new_x
1424
        jnz     .new_x
1427
; add line
1425
; add line
1428
        add     edx, [drbar.line_inc_scr]
1426
        add     edx, [drbar.line_inc_scr]
1429
        add     ebp, [drbar.line_inc_map]
1427
        add     ebp, [drbar.line_inc_map]
1430
; drawing gradient bars
1428
; drawing gradient bars
1431
        test    bh, 0x80
1429
        test    bh, 0x80
1432
        jz      @f
1430
        jz      @f
1433
        test    al, al
1431
        test    al, al
1434
        jz      @f
1432
        jz      @f
1435
        dec     al
1433
        dec     al
1436
;--------------------------------------
1434
;--------------------------------------
1437
align 4
1435
align 4
1438
@@:
1436
@@:
1439
        dec     esi
1437
        dec     esi
1440
        jnz     .new_y
1438
        jnz     .new_y
1441
        jmp     draw_bar_end_24.end
1439
        jmp     draw_bar_end_24.end
1442
;------------------------------------------------------------------------------
1440
;------------------------------------------------------------------------------
1443
align 4
1441
align 4
1444
draw_bar_end_32:
1442
draw_bar_end_32:
1445
; eax - color high   RRGGBB
1443
; eax - color high   RRGGBB
1446
; bl - process num
1444
; bl - process num
1447
; ecx - temp
1445
; ecx - temp
1448
; edx - pointer to screen
1446
; edx - pointer to screen
1449
; esi - counter
1447
; esi - counter
1450
; edi - counter
1448
; edi - counter
1451
;--------------------------------------
1449
;--------------------------------------
1452
; check for hardware cursor
1450
; check for hardware cursor
1453
        mov     ecx, [_display.select_cursor]
1451
        mov     ecx, [_display.select_cursor]
1454
        cmp     ecx, select_cursor
1452
        cmp     ecx, select_cursor
1455
        je      draw_bar_end_32_new
1453
        je      draw_bar_end_32_new
1456
        cmp     ecx, 0
1454
        cmp     ecx, 0
1457
        je      draw_bar_end_32_old
1455
        je      draw_bar_end_32_old
1458
;--------------------------------------
1456
;--------------------------------------
1459
align 4
1457
align 4
1460
.new_y:
1458
.new_y:
1461
        mov     edi, [drbar.real_sx]
1459
        mov     edi, [drbar.real_sx]
1462
;--------------------------------------
1460
;--------------------------------------
1463
align 4
1461
align 4
1464
.new_x:
1462
.new_x:
1465
        cmp     byte [ebp], bl
1463
        cmp     byte [ebp], bl
1466
        jne     .skip
1464
        jne     .skip
1467
;--------------------------------------
1465
;--------------------------------------
1468
; store to real LFB
1466
; store to real LFB
1469
        mov     [edx], eax
1467
        mov     [edx], eax
1470
        mov     eax, [drbar.color]
1468
        mov     eax, [drbar.color]
1471
;--------------------------------------
1469
;--------------------------------------
1472
align 4
1470
align 4
1473
.skip:
1471
.skip:
1474
; add pixel
1472
; add pixel
1475
        add     edx, 4
1473
        add     edx, 4
1476
        inc     ebp
1474
        inc     ebp
1477
        dec     edi
1475
        dec     edi
1478
        jnz     .new_x
1476
        jnz     .new_x
1479
; add line
1477
; add line
1480
        add     edx, [drbar.line_inc_scr]
1478
        add     edx, [drbar.line_inc_scr]
1481
        add     ebp, [drbar.line_inc_map]
1479
        add     ebp, [drbar.line_inc_map]
1482
; drawing gradient bars
1480
; drawing gradient bars
1483
        test    bh, 0x80
1481
        test    bh, 0x80
1484
        jz      @f
1482
        jz      @f
1485
        test    al, al
1483
        test    al, al
1486
        jz      @f
1484
        jz      @f
1487
        dec     al
1485
        dec     al
1488
;--------------------------------------
1486
;--------------------------------------
1489
align 4
1487
align 4
1490
@@:
1488
@@:
1491
        dec     esi
1489
        dec     esi
1492
        jnz     .new_y
1490
        jnz     .new_y
1493
;--------------------------------------
1491
;--------------------------------------
1494
align 4
1492
align 4
1495
.end:
1493
.end:
1496
        add     esp, drbar.stack_data
1494
        add     esp, drbar.stack_data
1497
        popad
1495
        popad
1498
        cmp     [SCR_MODE], 0x12
1496
        cmp     [SCR_MODE], 0x12
1499
        jne     @f
1497
        jne     @f
1500
        call    VGA_draw_bar
1498
        call    VGA_draw_bar
1501
;--------------------------------------
1499
;--------------------------------------
1502
align 4
1500
align 4
1503
@@:
1501
@@:
1504
        xor     eax, eax
1502
        xor     eax, eax
1505
        mov     [EGA_counter], 1
1503
        mov     [EGA_counter], 1
1506
        ret
1504
        ret
1507
;------------------------------------------------------------------------------
1505
;------------------------------------------------------------------------------
1508
align 4
1506
align 4
1509
draw_bar_end_32_old:
1507
draw_bar_end_32_old:
1510
;--------------------------------------
1508
;--------------------------------------
1511
align 4
1509
align 4
1512
.new_y:
1510
.new_y:
1513
        mov     edi, [drbar.real_sx]
1511
        mov     edi, [drbar.real_sx]
1514
;--------------------------------------
1512
;--------------------------------------
1515
align 4
1513
align 4
1516
.new_x:
1514
.new_x:
1517
        cmp     byte [ebp], bl
1515
        cmp     byte [ebp], bl
1518
        jne     .skip
1516
        jne     .skip
1519
;--------------------------------------
1517
;--------------------------------------
1520
        mov     ecx, [drbar.real_sx_and_abs_cx]
1518
        mov     ecx, [drbar.real_sx_and_abs_cx]
1521
        sub     ecx, edi
1519
        sub     ecx, edi
1522
        shl     ecx, 16
1520
        shl     ecx, 16
1523
        add     ecx, [drbar.real_sy_and_abs_cy]
1521
        add     ecx, [drbar.real_sy_and_abs_cy]
1524
        sub     ecx, esi
1522
        sub     ecx, esi
1525
 
1523
 
1526
; check mouse area for putpixel
1524
; check mouse area for putpixel
1527
        call    check_mouse_area_for_putpixel
1525
        call    check_mouse_area_for_putpixel
1528
; store to real LFB
1526
; store to real LFB
1529
        mov     [edx], eax
1527
        mov     [edx], eax
1530
        mov     eax, [drbar.color]
1528
        mov     eax, [drbar.color]
1531
;--------------------------------------
1529
;--------------------------------------
1532
align 4
1530
align 4
1533
.skip:
1531
.skip:
1534
; add pixel
1532
; add pixel
1535
        add     edx, 4
1533
        add     edx, 4
1536
        inc     ebp
1534
        inc     ebp
1537
        dec     edi
1535
        dec     edi
1538
        jnz     .new_x
1536
        jnz     .new_x
1539
; add line
1537
; add line
1540
        add     edx, [drbar.line_inc_scr]
1538
        add     edx, [drbar.line_inc_scr]
1541
        add     ebp, [drbar.line_inc_map]
1539
        add     ebp, [drbar.line_inc_map]
1542
; drawing gradient bars
1540
; drawing gradient bars
1543
        test    bh, 0x80
1541
        test    bh, 0x80
1544
        jz      @f
1542
        jz      @f
1545
        test    al, al
1543
        test    al, al
1546
        jz      @f
1544
        jz      @f
1547
        dec     al
1545
        dec     al
1548
;--------------------------------------
1546
;--------------------------------------
1549
align 4
1547
align 4
1550
@@:
1548
@@:
1551
        dec     esi
1549
        dec     esi
1552
        jnz     .new_y
1550
        jnz     .new_y
1553
        jmp     draw_bar_end_32.end
1551
        jmp     draw_bar_end_32.end
1554
;------------------------------------------------------------------------------
1552
;------------------------------------------------------------------------------
1555
align 4
1553
align 4
1556
draw_bar_end_32_new:
1554
draw_bar_end_32_new:
1557
;--------------------------------------
1555
;--------------------------------------
1558
align 4
1556
align 4
1559
.new_y:
1557
.new_y:
1560
        mov     edi, [drbar.real_sx]
1558
        mov     edi, [drbar.real_sx]
1561
;--------------------------------------
1559
;--------------------------------------
1562
align 4
1560
align 4
1563
.new_x:
1561
.new_x:
1564
        cmp     byte [ebp], bl
1562
        cmp     byte [ebp], bl
1565
        jne     .skip
1563
        jne     .skip
1566
;--------------------------------------
1564
;--------------------------------------
1567
        mov     ecx, [drbar.real_sy_and_abs_cy]
1565
        mov     ecx, [drbar.real_sy_and_abs_cy]
1568
        sub     ecx, esi
1566
        sub     ecx, esi
1569
;--------------------------------------
1567
;--------------------------------------
1570
; check for Y
1568
; check for Y
1571
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1569
        cmp     cx, [Y_UNDER_sub_CUR_hot_y_add_curh]
1572
        jae     .no_mouse_area
1570
        jae     .no_mouse_area
1573
 
1571
 
1574
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1572
        sub     cx, [Y_UNDER_subtraction_CUR_hot_y]
1575
        jb      .no_mouse_area
1573
        jb      .no_mouse_area
1576
 
1574
 
1577
        rol     ecx, 16
1575
        rol     ecx, 16
1578
        add     ecx, [drbar.real_sx_and_abs_cx]
1576
        add     ecx, [drbar.real_sx_and_abs_cx]
1579
        sub     ecx, edi
1577
        sub     ecx, edi
1580
;--------------------------------------
1578
;--------------------------------------
1581
; check for X
1579
; check for X
1582
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1580
        cmp     cx, [X_UNDER_sub_CUR_hot_x_add_curh]
1583
        jae     .no_mouse_area
1581
        jae     .no_mouse_area
1584
 
1582
 
1585
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1583
        sub     cx, [X_UNDER_subtraction_CUR_hot_x]
1586
        jb      .no_mouse_area
1584
        jb      .no_mouse_area
1587
 
1585
 
1588
        ror     ecx, 16
1586
        ror     ecx, 16
1589
;--------------------------------------
1587
;--------------------------------------
1590
; check mouse area for putpixel
1588
; check mouse area for putpixel
1591
        push    eax
1589
        push    eax
1592
        call    check_mouse_area_for_putpixel_new.1
1590
        call    check_mouse_area_for_putpixel_new.1
1593
        mov     [edx], eax
1591
        mov     [edx], eax
1594
        pop     eax
1592
        pop     eax
1595
        jmp     .skip
1593
        jmp     .skip
1596
; store to real LFB
1594
; store to real LFB
1597
;--------------------------------------
1595
;--------------------------------------
1598
align 4
1596
align 4
1599
.no_mouse_area:
1597
.no_mouse_area:
1600
        mov     [edx], eax
1598
        mov     [edx], eax
1601
;--------------------------------------
1599
;--------------------------------------
1602
align 4
1600
align 4
1603
.skip:
1601
.skip:
1604
; add pixel
1602
; add pixel
1605
        add     edx, 4
1603
        add     edx, 4
1606
        inc     ebp
1604
        inc     ebp
1607
        dec     edi
1605
        dec     edi
1608
        jnz     .new_x
1606
        jnz     .new_x
1609
; add line
1607
; add line
1610
        add     edx, [drbar.line_inc_scr]
1608
        add     edx, [drbar.line_inc_scr]
1611
        add     ebp, [drbar.line_inc_map]
1609
        add     ebp, [drbar.line_inc_map]
1612
; drawing gradient bars
1610
; drawing gradient bars
1613
        test    bh, 0x80
1611
        test    bh, 0x80
1614
        jz      @f
1612
        jz      @f
1615
        test    al, al
1613
        test    al, al
1616
        jz      @f
1614
        jz      @f
1617
        dec     al
1615
        dec     al
1618
;--------------------------------------
1616
;--------------------------------------
1619
align 4
1617
align 4
1620
@@:
1618
@@:
1621
        dec     esi
1619
        dec     esi
1622
        jnz     .new_y
1620
        jnz     .new_y
1623
        jmp     draw_bar_end_32.end
1621
        jmp     draw_bar_end_32.end
1624
;------------------------------------------------------------------------------
1622
;------------------------------------------------------------------------------
1625
align 4
1623
align 4
1626
vesa20_drawbackground_tiled:
1624
vesa20_drawbackground_tiled:
1627
        pushad
1625
        pushad
1628
; External loop for all y from start to end
1626
; External loop for all y from start to end
1629
        mov     ebx, [draw_data+32+RECT.top]    ; y start
1627
        mov     ebx, [draw_data+32+RECT.top]    ; y start
1630
;--------------------------------------
1628
;--------------------------------------
1631
align 4
1629
align 4
1632
dp2:
1630
dp2:
1633
        mov     ebp, [draw_data+32+RECT.left]   ; x start
1631
        mov     ebp, [draw_data+32+RECT.left]   ; x start
1634
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
1632
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
1635
;                       and LFB data (output for our function) [edi]
1633
;                       and LFB data (output for our function) [edi]
1636
;        mov     eax, [BytesPerScanLine]
1634
;        mov     eax, [BytesPerScanLine]
1637
;        mul     ebx
1635
;        mul     ebx
1638
        mov     eax, [BPSLine_calc_area+ebx*4]
1636
        mov     eax, [BPSLine_calc_area+ebx*4]
1639
        xchg    ebp, eax
1637
        xchg    ebp, eax
1640
        add     ebp, eax
1638
        add     ebp, eax
1641
        add     ebp, eax
1639
        add     ebp, eax
1642
        add     ebp, eax
1640
        add     ebp, eax
1643
        cmp     byte [_display.bpp], 24    ; 24 or 32 bpp ? - x size
1641
        cmp     byte [_display.bpp], 24    ; 24 or 32 bpp ? - x size
1644
        jz      @f
1642
        jz      @f
1645
        add     ebp, eax
1643
        add     ebp, eax
1646
;--------------------------------------
1644
;--------------------------------------
1647
align 4
1645
align 4
1648
@@:
1646
@@:
1649
        add     ebp, LFB_BASE
1647
        add     ebp, LFB_BASE
1650
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1648
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1651
        call    calculate_edi
1649
        call    calculate_edi
1652
        xchg    edi, ebp
1650
        xchg    edi, ebp
1653
        add     ebp, [_WinMapAddress]
1651
        add     ebp, [_WinMapAddress]
1654
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
1652
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
1655
; 2) Calculate offset in background memory block
1653
; 2) Calculate offset in background memory block
1656
        push    eax
1654
        push    eax
1657
        xor     edx, edx
1655
        xor     edx, edx
1658
        mov     eax, ebx
1656
        mov     eax, ebx
1659
        div     dword [BgrDataHeight]   ; edx := y mod BgrDataHeight
1657
        div     dword [BgrDataHeight]   ; edx := y mod BgrDataHeight
1660
        pop     eax
1658
        pop     eax
1661
        push    eax
1659
        push    eax
1662
        mov     ecx, [BgrDataWidth]
1660
        mov     ecx, [BgrDataWidth]
1663
        mov     esi, edx
1661
        mov     esi, edx
1664
        imul    esi, ecx                ; esi := (y mod BgrDataHeight) * BgrDataWidth
1662
        imul    esi, ecx                ; esi := (y mod BgrDataHeight) * BgrDataWidth
1665
        xor     edx, edx
1663
        xor     edx, edx
1666
        div     ecx             ; edx := x mod BgrDataWidth
1664
        div     ecx             ; edx := x mod BgrDataWidth
1667
        sub     ecx, edx
1665
        sub     ecx, edx
1668
        add     esi, edx        ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth)
1666
        add     esi, edx        ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth)
1669
        pop     eax
1667
        pop     eax
1670
        lea     esi, [esi*3]
1668
        lea     esi, [esi*3]
1671
        add     esi, [img_background]
1669
        add     esi, [img_background]
1672
        xor     edx, edx
1670
        xor     edx, edx
1673
        inc     edx
1671
        inc     edx
1674
; 3) Loop through redraw rectangle and copy background data
1672
; 3) Loop through redraw rectangle and copy background data
1675
; Registers meaning:
1673
; Registers meaning:
1676
; eax = x, ebx = y (screen coordinates)
1674
; eax = x, ebx = y (screen coordinates)
1677
; ecx = deltax - number of pixels left in current tile block
1675
; ecx = deltax - number of pixels left in current tile block
1678
; edx = 1
1676
; edx = 1
1679
; esi -> bgr memory, edi -> output
1677
; esi -> bgr memory, edi -> output
1680
; ebp = offset in WinMapAddress
1678
; ebp = offset in WinMapAddress
1681
;--------------------------------------
1679
;--------------------------------------
1682
align 4
1680
align 4
1683
dp3:
1681
dp3:
1684
        cmp     [ebp], dl
1682
        cmp     [ebp], dl
1685
        jnz     nbgp
1683
        jnz     nbgp
1686
;--------------------------------------
1684
;--------------------------------------
1687
        push    eax ecx
1685
        push    eax ecx
1688
 
1686
 
1689
        mov     ecx, eax
1687
        mov     ecx, eax
1690
        shl     ecx, 16
1688
        shl     ecx, 16
1691
        add     ecx, ebx
1689
        add     ecx, ebx
1692
 
1690
 
1693
        mov     eax, [esi]
1691
        mov     eax, [esi]
1694
 
1692
 
1695
; check for hardware cursor
1693
; check for hardware cursor
1696
        cmp     [_display.select_cursor], select_cursor
1694
        cmp     [_display.select_cursor], select_cursor
1697
        je      @f
1695
        je      @f
1698
        cmp     [_display.select_cursor], 0
1696
        cmp     [_display.select_cursor], 0
1699
        jne     .no_mouseunder
1697
        jne     .no_mouseunder
1700
;--------------------------------------
1698
;--------------------------------------
1701
align 4
1699
align 4
1702
@@:
1700
@@:
1703
        and     eax, 0xffffff
1701
        and     eax, 0xffffff
1704
; check mouse area for putpixel
1702
; check mouse area for putpixel
1705
        call    [_display.check_mouse]
1703
        call    [_display.check_mouse]
1706
;--------------------------------------
1704
;--------------------------------------
1707
align 4
1705
align 4
1708
.no_mouseunder:
1706
.no_mouseunder:
1709
; store to real LFB
1707
; store to real LFB
1710
        mov     [edi], ax
1708
        mov     [edi], ax
1711
        shr     eax, 16
1709
        shr     eax, 16
1712
        mov     [edi+2], al
1710
        mov     [edi+2], al
1713
 
1711
 
1714
        pop     ecx eax
1712
        pop     ecx eax
1715
;--------------------------------------
1713
;--------------------------------------
1716
align 4
1714
align 4
1717
nbgp:
1715
nbgp:
1718
        add     esi, 3
1716
        add     esi, 3
1719
        add     edi, 3
1717
        add     edi, 3
1720
;--------------------------------------
1718
;--------------------------------------
1721
align 4
1719
align 4
1722
@@:
1720
@@:
1723
        cmp     byte [_display.bpp], 25    ; 24 or 32 bpp?
1721
        cmp     byte [_display.bpp], 25    ; 24 or 32 bpp?
1724
        sbb     edi, -1         ; +1 for 32 bpp
1722
        sbb     edi, -1         ; +1 for 32 bpp
1725
; I do not use 'inc eax' because this is slightly slower then 'add eax,1'
1723
; I do not use 'inc eax' because this is slightly slower then 'add eax,1'
1726
        add     ebp, edx
1724
        add     ebp, edx
1727
        add     eax, edx
1725
        add     eax, edx
1728
        cmp     eax, [draw_data+32+RECT.right]
1726
        cmp     eax, [draw_data+32+RECT.right]
1729
        ja      dp4
1727
        ja      dp4
1730
        sub     ecx, edx
1728
        sub     ecx, edx
1731
        jnz     dp3
1729
        jnz     dp3
1732
; next tile block on x-axis
1730
; next tile block on x-axis
1733
        mov     ecx, [BgrDataWidth]
1731
        mov     ecx, [BgrDataWidth]
1734
        sub     esi, ecx
1732
        sub     esi, ecx
1735
        sub     esi, ecx
1733
        sub     esi, ecx
1736
        sub     esi, ecx
1734
        sub     esi, ecx
1737
        jmp     dp3
1735
        jmp     dp3
1738
;--------------------------------------
1736
;--------------------------------------
1739
align 4
1737
align 4
1740
dp4:
1738
dp4:
1741
; next scan line
1739
; next scan line
1742
        inc     ebx
1740
        inc     ebx
1743
        cmp     ebx, [draw_data+32+RECT.bottom]
1741
        cmp     ebx, [draw_data+32+RECT.bottom]
1744
        jbe     dp2
1742
        jbe     dp2
1745
        popad
1743
        popad
1746
        mov     [EGA_counter], 1
1744
        mov     [EGA_counter], 1
1747
        cmp     [SCR_MODE], 0x12
1745
        cmp     [SCR_MODE], 0x12
1748
        jne     @f
1746
        jne     @f
1749
        call    VGA_drawbackground
1747
        call    VGA_drawbackground
1750
;--------------------------------------
1748
;--------------------------------------
1751
align 4
1749
align 4
1752
@@:
1750
@@:
1753
        ret
1751
        ret
1754
;------------------------------------------------------------------------------
1752
;------------------------------------------------------------------------------
1755
align 4
1753
align 4
1756
vesa20_drawbackground_stretch:
1754
vesa20_drawbackground_stretch:
1757
        pushad
1755
        pushad
1758
; Helper variables
1756
; Helper variables
1759
; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1)
1757
; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1)
1760
        mov     eax, [BgrDataWidth]
1758
        mov     eax, [BgrDataWidth]
1761
        dec     eax
1759
        dec     eax
1762
        xor     edx, edx
1760
        xor     edx, edx
1763
        div     dword [Screen_Max_X]
1761
        div     dword [Screen_Max_X]
1764
        push    eax     ; high
1762
        push    eax     ; high
1765
        xor     eax, eax
1763
        xor     eax, eax
1766
        div     dword [Screen_Max_X]
1764
        div     dword [Screen_Max_X]
1767
        push    eax     ; low
1765
        push    eax     ; low
1768
; the same for height
1766
; the same for height
1769
        mov     eax, [BgrDataHeight]
1767
        mov     eax, [BgrDataHeight]
1770
        dec     eax
1768
        dec     eax
1771
        xor     edx, edx
1769
        xor     edx, edx
1772
        div     dword [Screen_Max_Y]
1770
        div     dword [Screen_Max_Y]
1773
        push    eax     ; high
1771
        push    eax     ; high
1774
        xor     eax, eax
1772
        xor     eax, eax
1775
        div     dword [Screen_Max_Y]
1773
        div     dword [Screen_Max_Y]
1776
        push    eax     ; low
1774
        push    eax     ; low
1777
; External loop for all y from start to end
1775
; External loop for all y from start to end
1778
        mov     ebx, [draw_data+32+RECT.top]    ; y start
1776
        mov     ebx, [draw_data+32+RECT.top]    ; y start
1779
        mov     ebp, [draw_data+32+RECT.left]   ; x start
1777
        mov     ebp, [draw_data+32+RECT.left]   ; x start
1780
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
1778
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
1781
;                       and LFB data (output for our function) [edi]
1779
;                       and LFB data (output for our function) [edi]
1782
;        mov     eax, [BytesPerScanLine]
1780
;        mov     eax, [BytesPerScanLine]
1783
;        mul     ebx
1781
;        mul     ebx
1784
        mov     eax, [BPSLine_calc_area+ebx*4]
1782
        mov     eax, [BPSLine_calc_area+ebx*4]
1785
        xchg    ebp, eax
1783
        xchg    ebp, eax
1786
        add     ebp, eax
1784
        add     ebp, eax
1787
        add     ebp, eax
1785
        add     ebp, eax
1788
        add     ebp, eax
1786
        add     ebp, eax
1789
        cmp     byte [_display.bpp], 24    ; 24 or 32 bpp ? - x size
1787
        cmp     byte [_display.bpp], 24    ; 24 or 32 bpp ? - x size
1790
        jz      @f
1788
        jz      @f
1791
        add     ebp, eax
1789
        add     ebp, eax
1792
;--------------------------------------
1790
;--------------------------------------
1793
align 4
1791
align 4
1794
@@:
1792
@@:
1795
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1793
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1796
        call    calculate_edi
1794
        call    calculate_edi
1797
        xchg    edi, ebp
1795
        xchg    edi, ebp
1798
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
1796
; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress
1799
        push    ebx
1797
        push    ebx
1800
        push    eax
1798
        push    eax
1801
; 2) Calculate offset in background memory block
1799
; 2) Calculate offset in background memory block
1802
        mov     eax, ebx
1800
        mov     eax, ebx
1803
        imul    ebx, dword [esp+12]
1801
        imul    ebx, dword [esp+12]
1804
        mul     dword [esp+8]
1802
        mul     dword [esp+8]
1805
        add     edx, ebx        ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
1803
        add     edx, ebx        ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
1806
        mov     esi, edx
1804
        mov     esi, edx
1807
        imul    esi, [BgrDataWidth]
1805
        imul    esi, [BgrDataWidth]
1808
        push    edx
1806
        push    edx
1809
        push    eax
1807
        push    eax
1810
        mov     eax, [esp+8]
1808
        mov     eax, [esp+8]
1811
        mul     dword [esp+28]
1809
        mul     dword [esp+28]
1812
        push    eax
1810
        push    eax
1813
        mov     eax, [esp+12]
1811
        mov     eax, [esp+12]
1814
        mul     dword [esp+28]
1812
        mul     dword [esp+28]
1815
        add     [esp], edx
1813
        add     [esp], edx
1816
        pop     edx             ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
1814
        pop     edx             ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
1817
        add     esi, edx
1815
        add     esi, edx
1818
        lea     esi, [esi*3]
1816
        lea     esi, [esi*3]
1819
        add     esi, [img_background]
1817
        add     esi, [img_background]
1820
        push    eax
1818
        push    eax
1821
        push    edx
1819
        push    edx
1822
        push    esi
1820
        push    esi
1823
; 3) Smooth horizontal
1821
; 3) Smooth horizontal
1824
;--------------------------------------
1822
;--------------------------------------
1825
align 4
1823
align 4
1826
bgr_resmooth0:
1824
bgr_resmooth0:
1827
        mov     ecx, [esp+8]
1825
        mov     ecx, [esp+8]
1828
        mov     edx, [esp+4]
1826
        mov     edx, [esp+4]
1829
        mov     esi, [esp]
1827
        mov     esi, [esp]
1830
        push    edi
1828
        push    edi
1831
        mov     edi, bgr_cur_line
1829
        mov     edi, bgr_cur_line
1832
        call    smooth_line
1830
        call    smooth_line
1833
;--------------------------------------
1831
;--------------------------------------
1834
align 4
1832
align 4
1835
bgr_resmooth1:
1833
bgr_resmooth1:
1836
        mov     eax, [esp+16+4]
1834
        mov     eax, [esp+16+4]
1837
        inc     eax
1835
        inc     eax
1838
        cmp     eax, [BgrDataHeight]
1836
        cmp     eax, [BgrDataHeight]
1839
        jae     bgr.no2nd
1837
        jae     bgr.no2nd
1840
        mov     ecx, [esp+8+4]
1838
        mov     ecx, [esp+8+4]
1841
        mov     edx, [esp+4+4]
1839
        mov     edx, [esp+4+4]
1842
        mov     esi, [esp+4]
1840
        mov     esi, [esp+4]
1843
        add     esi, [BgrDataWidth]
1841
        add     esi, [BgrDataWidth]
1844
        add     esi, [BgrDataWidth]
1842
        add     esi, [BgrDataWidth]
1845
        add     esi, [BgrDataWidth]
1843
        add     esi, [BgrDataWidth]
1846
        mov     edi, bgr_next_line
1844
        mov     edi, bgr_next_line
1847
        call    smooth_line
1845
        call    smooth_line
1848
;--------------------------------------
1846
;--------------------------------------
1849
align 4
1847
align 4
1850
bgr.no2nd:
1848
bgr.no2nd:
1851
        pop     edi
1849
        pop     edi
1852
;--------------------------------------
1850
;--------------------------------------
1853
align 4
1851
align 4
1854
sdp3:
1852
sdp3:
1855
        xor     esi, esi
1853
        xor     esi, esi
1856
        mov     ecx, [esp+12]
1854
        mov     ecx, [esp+12]
1857
; 4) Loop through redraw rectangle and copy background data
1855
; 4) Loop through redraw rectangle and copy background data
1858
; Registers meaning:
1856
; Registers meaning:
1859
; esi = offset in current line, edi -> output
1857
; esi = offset in current line, edi -> output
1860
; ebp = offset in WinMapAddress
1858
; ebp = offset in WinMapAddress
1861
; dword [esp] = offset in bgr data
1859
; dword [esp] = offset in bgr data
1862
; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1)
1860
; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1)
1863
; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1)
1861
; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1)
1864
; dword [esp+20] = x
1862
; dword [esp+20] = x
1865
; dword [esp+24] = y
1863
; dword [esp+24] = y
1866
; precalculated constants:
1864
; precalculated constants:
1867
; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
1865
; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1)
1868
; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
1866
; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1)
1869
;--------------------------------------
1867
;--------------------------------------
1870
align 4
1868
align 4
1871
sdp3a:
1869
sdp3a:
1872
        mov     eax, [_WinMapAddress]
1870
        mov     eax, [_WinMapAddress]
1873
        cmp     [ebp+eax], byte 1
1871
        cmp     [ebp+eax], byte 1
1874
        jnz     snbgp
1872
        jnz     snbgp
1875
        mov     eax, [bgr_cur_line+esi]
1873
        mov     eax, [bgr_cur_line+esi]
1876
        test    ecx, ecx
1874
        test    ecx, ecx
1877
        jz      .novert
1875
        jz      .novert
1878
        mov     ebx, [bgr_next_line+esi]
1876
        mov     ebx, [bgr_next_line+esi]
1879
        call    [overlapping_of_points_ptr]
1877
        call    [overlapping_of_points_ptr]
1880
;--------------------------------------
1878
;--------------------------------------
1881
align 4
1879
align 4
1882
.novert:
1880
.novert:
1883
        push    ecx
1881
        push    ecx
1884
; check for hardware cursor
1882
; check for hardware cursor
1885
        cmp     [_display.select_cursor], select_cursor
1883
        cmp     [_display.select_cursor], select_cursor
1886
        je      @f
1884
        je      @f
1887
        cmp     [_display.select_cursor], 0
1885
        cmp     [_display.select_cursor], 0
1888
        jne     .no_mouseunder
1886
        jne     .no_mouseunder
1889
;--------------------------------------
1887
;--------------------------------------
1890
align 4
1888
align 4
1891
@@:
1889
@@:
1892
        mov     ecx, [esp+20+4]        ;x
1890
        mov     ecx, [esp+20+4]        ;x
1893
        shl     ecx, 16
1891
        shl     ecx, 16
1894
        add     ecx, [esp+24+4]        ;y
1892
        add     ecx, [esp+24+4]        ;y
1895
; check mouse area for putpixel
1893
; check mouse area for putpixel
1896
        call    [_display.check_mouse]
1894
        call    [_display.check_mouse]
1897
;--------------------------------------
1895
;--------------------------------------
1898
align 4
1896
align 4
1899
.no_mouseunder:
1897
.no_mouseunder:
1900
; store to real LFB
1898
; store to real LFB
1901
        mov     [LFB_BASE+edi], ax
1899
        mov     [LFB_BASE+edi], ax
1902
        shr     eax, 16
1900
        shr     eax, 16
1903
        mov     [LFB_BASE+edi+2], al
1901
        mov     [LFB_BASE+edi+2], al
1904
        pop     ecx
1902
        pop     ecx
1905
;--------------------------------------
1903
;--------------------------------------
1906
align 4
1904
align 4
1907
snbgp:
1905
snbgp:
1908
        cmp     byte [_display.bpp], 25
1906
        cmp     byte [_display.bpp], 25
1909
        sbb     edi, -4
1907
        sbb     edi, -4
1910
        add     ebp, 1
1908
        add     ebp, 1
1911
        mov     eax, [esp+20]
1909
        mov     eax, [esp+20]
1912
        add     eax, 1
1910
        add     eax, 1
1913
        mov     [esp+20], eax
1911
        mov     [esp+20], eax
1914
        add     esi, 4
1912
        add     esi, 4
1915
        cmp     eax, [draw_data+32+RECT.right]
1913
        cmp     eax, [draw_data+32+RECT.right]
1916
        jbe     sdp3a
1914
        jbe     sdp3a
1917
;--------------------------------------
1915
;--------------------------------------
1918
align 4
1916
align 4
1919
sdp4:
1917
sdp4:
1920
; next y
1918
; next y
1921
        mov     ebx, [esp+24]
1919
        mov     ebx, [esp+24]
1922
        add     ebx, 1
1920
        add     ebx, 1
1923
        mov     [esp+24], ebx
1921
        mov     [esp+24], ebx
1924
        cmp     ebx, [draw_data+32+RECT.bottom]
1922
        cmp     ebx, [draw_data+32+RECT.bottom]
1925
        ja      sdpdone
1923
        ja      sdpdone
1926
; advance edi, ebp to next scan line
1924
; advance edi, ebp to next scan line
1927
        sub     eax, [draw_data+32+RECT.left]
1925
        sub     eax, [draw_data+32+RECT.left]
1928
        sub     ebp, eax
1926
        sub     ebp, eax
1929
        add     ebp, [Screen_Max_X]
1927
        add     ebp, [_display.width]
1930
        add     ebp, 1
-
 
1931
        sub     edi, eax
1928
        sub     edi, eax
1932
        sub     edi, eax
1929
        sub     edi, eax
1933
        sub     edi, eax
1930
        sub     edi, eax
1934
        cmp     byte [_display.bpp], 24
1931
        cmp     byte [_display.bpp], 24
1935
        jz      @f
1932
        jz      @f
1936
        sub     edi, eax
1933
        sub     edi, eax
1937
;--------------------------------------
1934
;--------------------------------------
1938
align 4
1935
align 4
1939
@@:
1936
@@:
1940
        add     edi, [_display.pitch]
1937
        add     edi, [_display.pitch]
1941
; restore ecx,edx; advance esi to next background line
1938
; restore ecx,edx; advance esi to next background line
1942
        mov     eax, [esp+28]
1939
        mov     eax, [esp+28]
1943
        mov     ebx, [esp+32]
1940
        mov     ebx, [esp+32]
1944
        add     [esp+12], eax
1941
        add     [esp+12], eax
1945
        mov     eax, [esp+16]
1942
        mov     eax, [esp+16]
1946
        adc     [esp+16], ebx
1943
        adc     [esp+16], ebx
1947
        sub     eax, [esp+16]
1944
        sub     eax, [esp+16]
1948
        mov     ebx, eax
1945
        mov     ebx, eax
1949
        lea     eax, [eax*3]
1946
        lea     eax, [eax*3]
1950
        imul    eax, [BgrDataWidth]
1947
        imul    eax, [BgrDataWidth]
1951
        sub     [esp], eax
1948
        sub     [esp], eax
1952
        mov     eax, [draw_data+32+RECT.left]
1949
        mov     eax, [draw_data+32+RECT.left]
1953
        mov     [esp+20], eax
1950
        mov     [esp+20], eax
1954
        test    ebx, ebx
1951
        test    ebx, ebx
1955
        jz      sdp3
1952
        jz      sdp3
1956
        cmp     ebx, -1
1953
        cmp     ebx, -1
1957
        jnz     bgr_resmooth0
1954
        jnz     bgr_resmooth0
1958
        push    edi
1955
        push    edi
1959
        mov     esi, bgr_next_line
1956
        mov     esi, bgr_next_line
1960
        mov     edi, bgr_cur_line
1957
        mov     edi, bgr_cur_line
1961
        mov     ecx, [Screen_Max_X]
1958
        mov     ecx, [_display.width]
1962
        inc     ecx
-
 
1963
        rep movsd
1959
        rep movsd
1964
        jmp     bgr_resmooth1
1960
        jmp     bgr_resmooth1
1965
;--------------------------------------
1961
;--------------------------------------
1966
align 4
1962
align 4
1967
sdpdone:
1963
sdpdone:
1968
        add     esp, 44
1964
        add     esp, 44
1969
        popad
1965
        popad
1970
        mov     [EGA_counter], 1
1966
        mov     [EGA_counter], 1
1971
        cmp     [SCR_MODE], 0x12
1967
        cmp     [SCR_MODE], 0x12
1972
        jne     @f
1968
        jne     @f
1973
        call    VGA_drawbackground
1969
        call    VGA_drawbackground
1974
;--------------------------------------
1970
;--------------------------------------
1975
align 4
1971
align 4
1976
@@:
1972
@@:
1977
        ret
1973
        ret
1978
 
1974
 
1979
uglobal
1975
uglobal
1980
;--------------------------------------
1976
;--------------------------------------
1981
align 4
1977
align 4
1982
bgr_cur_line    rd      1920    ; maximum width of screen
1978
bgr_cur_line    rd      1920    ; maximum width of screen
1983
bgr_next_line   rd      1920
1979
bgr_next_line   rd      1920
1984
;--------------------------------------
1980
;--------------------------------------
1985
endg
1981
endg
1986
;--------------------------------------
1982
;--------------------------------------
1987
align 4
1983
align 4
1988
smooth_line:
1984
smooth_line:
1989
        mov     al, [esi+2]
1985
        mov     al, [esi+2]
1990
        shl     eax, 16
1986
        shl     eax, 16
1991
        mov     ax, [esi]
1987
        mov     ax, [esi]
1992
        test    ecx, ecx
1988
        test    ecx, ecx
1993
        jz      @f
1989
        jz      @f
1994
        mov     ebx, [esi+2]
1990
        mov     ebx, [esi+2]
1995
        shr     ebx, 8
1991
        shr     ebx, 8
1996
        call    [overlapping_of_points_ptr]
1992
        call    [overlapping_of_points_ptr]
1997
;--------------------------------------
1993
;--------------------------------------
1998
align 4
1994
align 4
1999
@@:
1995
@@:
2000
        stosd
1996
        stosd
2001
        mov     eax, [esp+20+8]
1997
        mov     eax, [esp+20+8]
2002
        add     eax, 1
1998
        add     eax, 1
2003
        mov     [esp+20+8], eax
1999
        mov     [esp+20+8], eax
2004
        cmp     eax, [draw_data+32+RECT.right]
2000
        cmp     eax, [draw_data+32+RECT.right]
2005
        ja      @f
2001
        ja      @f
2006
        add     ecx, [esp+36+8]
2002
        add     ecx, [esp+36+8]
2007
        mov     eax, edx
2003
        mov     eax, edx
2008
        adc     edx, [esp+40+8]
2004
        adc     edx, [esp+40+8]
2009
        sub     eax, edx
2005
        sub     eax, edx
2010
        lea     eax, [eax*3]
2006
        lea     eax, [eax*3]
2011
        sub     esi, eax
2007
        sub     esi, eax
2012
        jmp     smooth_line
2008
        jmp     smooth_line
2013
;--------------------------------------
2009
;--------------------------------------
2014
align 4
2010
align 4
2015
@@:
2011
@@:
2016
        mov     eax, [draw_data+32+RECT.left]
2012
        mov     eax, [draw_data+32+RECT.left]
2017
        mov     [esp+20+8], eax
2013
        mov     [esp+20+8], eax
2018
        ret
2014
        ret
2019
;------------------------------------------------------------------------------
2015
;------------------------------------------------------------------------------
2020
align 16
2016
align 16
2021
overlapping_of_points:
2017
overlapping_of_points:
2022
if 0
2018
if 0
2023
; this version of procedure works, but is slower than next version
2019
; this version of procedure works, but is slower than next version
2024
        push    ecx edx
2020
        push    ecx edx
2025
        mov     edx, eax
2021
        mov     edx, eax
2026
        push    esi
2022
        push    esi
2027
        shr     ecx, 24
2023
        shr     ecx, 24
2028
        mov     esi, ecx
2024
        mov     esi, ecx
2029
        mov     ecx, ebx
2025
        mov     ecx, ebx
2030
        movzx   ebx, dl
2026
        movzx   ebx, dl
2031
        movzx   eax, cl
2027
        movzx   eax, cl
2032
        sub     eax, ebx
2028
        sub     eax, ebx
2033
        movzx   ebx, dh
2029
        movzx   ebx, dh
2034
        imul    eax, esi
2030
        imul    eax, esi
2035
        add     dl, ah
2031
        add     dl, ah
2036
        movzx   eax, ch
2032
        movzx   eax, ch
2037
        sub     eax, ebx
2033
        sub     eax, ebx
2038
        imul    eax, esi
2034
        imul    eax, esi
2039
        add     dh, ah
2035
        add     dh, ah
2040
        ror     ecx, 16
2036
        ror     ecx, 16
2041
        ror     edx, 16
2037
        ror     edx, 16
2042
        movzx   eax, cl
2038
        movzx   eax, cl
2043
        movzx   ebx, dl
2039
        movzx   ebx, dl
2044
        sub     eax, ebx
2040
        sub     eax, ebx
2045
        imul    eax, esi
2041
        imul    eax, esi
2046
        pop     esi
2042
        pop     esi
2047
        add     dl, ah
2043
        add     dl, ah
2048
        mov     eax, edx
2044
        mov     eax, edx
2049
        pop     edx
2045
        pop     edx
2050
        ror     eax, 16
2046
        ror     eax, 16
2051
        pop     ecx
2047
        pop     ecx
2052
        ret
2048
        ret
2053
else
2049
else
2054
        push    ecx edx
2050
        push    ecx edx
2055
        mov     edx, eax
2051
        mov     edx, eax
2056
        push    esi
2052
        push    esi
2057
        shr     ecx, 26
2053
        shr     ecx, 26
2058
        mov     esi, ecx
2054
        mov     esi, ecx
2059
        mov     ecx, ebx
2055
        mov     ecx, ebx
2060
        shl     esi, 9
2056
        shl     esi, 9
2061
        movzx   ebx, dl
2057
        movzx   ebx, dl
2062
        movzx   eax, cl
2058
        movzx   eax, cl
2063
        sub     eax, ebx
2059
        sub     eax, ebx
2064
        movzx   ebx, dh
2060
        movzx   ebx, dh
2065
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
2061
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
2066
        movzx   eax, ch
2062
        movzx   eax, ch
2067
        sub     eax, ebx
2063
        sub     eax, ebx
2068
        add     dh, [BgrAuxTable+(eax+0x100)+esi]
2064
        add     dh, [BgrAuxTable+(eax+0x100)+esi]
2069
        ror     ecx, 16
2065
        ror     ecx, 16
2070
        ror     edx, 16
2066
        ror     edx, 16
2071
        movzx   eax, cl
2067
        movzx   eax, cl
2072
        movzx   ebx, dl
2068
        movzx   ebx, dl
2073
        sub     eax, ebx
2069
        sub     eax, ebx
2074
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
2070
        add     dl, [BgrAuxTable+(eax+0x100)+esi]
2075
        pop     esi
2071
        pop     esi
2076
        mov     eax, edx
2072
        mov     eax, edx
2077
        pop     edx
2073
        pop     edx
2078
        ror     eax, 16
2074
        ror     eax, 16
2079
        pop     ecx
2075
        pop     ecx
2080
        ret
2076
        ret
2081
end if
2077
end if
2082
 
2078
 
2083
iglobal
2079
iglobal
2084
;--------------------------------------
2080
;--------------------------------------
2085
align 4
2081
align 4
2086
overlapping_of_points_ptr       dd      overlapping_of_points
2082
overlapping_of_points_ptr       dd      overlapping_of_points
2087
;--------------------------------------
2083
;--------------------------------------
2088
endg
2084
endg
2089
;------------------------------------------------------------------------------
2085
;------------------------------------------------------------------------------
2090
align 4
2086
align 4
2091
init_background:
2087
init_background:
2092
        mov     edi, BgrAuxTable
2088
        mov     edi, BgrAuxTable
2093
        xor     edx, edx
2089
        xor     edx, edx
2094
;--------------------------------------
2090
;--------------------------------------
2095
align 4
2091
align 4
2096
.loop2:
2092
.loop2:
2097
        mov     eax, edx
2093
        mov     eax, edx
2098
        shl     eax, 8
2094
        shl     eax, 8
2099
        neg     eax
2095
        neg     eax
2100
        mov     ecx, 0x200
2096
        mov     ecx, 0x200
2101
;--------------------------------------
2097
;--------------------------------------
2102
align 4
2098
align 4
2103
.loop1:
2099
.loop1:
2104
        mov     byte [edi], ah
2100
        mov     byte [edi], ah
2105
        inc     edi
2101
        inc     edi
2106
        add     eax, edx
2102
        add     eax, edx
2107
        loop    .loop1
2103
        loop    .loop1
2108
        add     dl, 4
2104
        add     dl, 4
2109
        jnz     .loop2
2105
        jnz     .loop2
2110
        test    byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8)
2106
        test    byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8)
2111
        jz      @f
2107
        jz      @f
2112
        mov     [overlapping_of_points_ptr], overlapping_of_points_mmx
2108
        mov     [overlapping_of_points_ptr], overlapping_of_points_mmx
2113
;--------------------------------------
2109
;--------------------------------------
2114
align 4
2110
align 4
2115
@@:
2111
@@:
2116
        ret
2112
        ret
2117
;------------------------------------------------------------------------------
2113
;------------------------------------------------------------------------------
2118
align 16
2114
align 16
2119
overlapping_of_points_mmx:
2115
overlapping_of_points_mmx:
2120
        movd    mm0, eax
2116
        movd    mm0, eax
2121
        movd    mm4, eax
2117
        movd    mm4, eax
2122
        movd    mm1, ebx
2118
        movd    mm1, ebx
2123
        pxor    mm2, mm2
2119
        pxor    mm2, mm2
2124
        punpcklbw mm0, mm2
2120
        punpcklbw mm0, mm2
2125
        punpcklbw mm1, mm2
2121
        punpcklbw mm1, mm2
2126
        psubw   mm1, mm0
2122
        psubw   mm1, mm0
2127
        movd    mm3, ecx
2123
        movd    mm3, ecx
2128
        psrld   mm3, 24
2124
        psrld   mm3, 24
2129
        packuswb mm3, mm3
2125
        packuswb mm3, mm3
2130
        packuswb mm3, mm3
2126
        packuswb mm3, mm3
2131
        pmullw  mm1, mm3
2127
        pmullw  mm1, mm3
2132
        psrlw   mm1, 8
2128
        psrlw   mm1, 8
2133
        packuswb mm1, mm2
2129
        packuswb mm1, mm2
2134
        paddb   mm4, mm1
2130
        paddb   mm4, mm1
2135
        movd    eax, mm4
2131
        movd    eax, mm4
2136
        ret
2132
        ret
2137
;------------------------------------------------------------------------------
2133
;------------------------------------------------------------------------------