Subversion Repositories Kolibri OS

Rev

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

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