Subversion Repositories Kolibri OS

Rev

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

Rev 52 Rev 75
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                        ;;
2
;;                                                        ;;
3
;;  VESA20.INC                                            ;;
3
;;  VESA20.INC                                            ;;
4
;;                                                        ;;
4
;;                                                        ;;
5
;;  Vesa 2.0 functions for MenuetOS                       ;;
5
;;  Vesa 2.0 functions for MenuetOS                       ;;
6
;;                                                        ;;
6
;;                                                        ;;
7
;;  Copyright 2002 Ville Turjanmaa                        ;;
7
;;  Copyright 2002 Ville Turjanmaa                        ;;
8
;;  Alexey, kgaz@crosswindws.net                          ;;
8
;;  Alexey, kgaz@crosswindws.net                          ;;
9
;;  - Voodoo compatible graphics                          ;;
9
;;  - Voodoo compatible graphics                          ;;
10
;;  Juan M. Caravaca                                      ;;
10
;;  Juan M. Caravaca                                      ;;
11
;;  - Graphics optimimizations eg. drawline               ;;
11
;;  - Graphics optimimizations eg. drawline               ;;
12
;;                                                        ;;
12
;;                                                        ;;
13
;;  See file COPYING for details                          ;;
13
;;  See file COPYING for details                          ;;
14
;;                                                        ;;
14
;;                                                        ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16
 
16
 
17
; If you're planning to write your own video driver I suggest
17
; If you're planning to write your own video driver I suggest
18
; you replace the VESA12.INC file and see those instructions.
18
; you replace the VESA12.INC file and see those instructions.
19
 
19
 
20
ScreenWidth             equ     0xfe00
20
ScreenWidth             equ     0xfe00
21
ScreenHeight            equ     0xfe04
21
ScreenHeight            equ     0xfe04
22
BytesPerScanLine        equ     0xfe08
22
BytesPerScanLine        equ     0xfe08
23
LFBAddress              equ     0xfe80
23
LFBAddress              equ     0xfe80
24
ScreenBPP               equ     0xfbf1
24
ScreenBPP               equ     0xfbf1
25
WinMapAddress           equ     0x460000
25
WinMapAddress           equ     0x460000
26
 
26
 
27
 
27
 
28
 
28
 
29
;*************************************************
29
;*************************************************
30
; getpixel
30
; getpixel
31
;
31
;
32
; in:
32
; in:
33
; eax = x coordinate
33
; eax = x coordinate
34
; ebx = y coordinate
34
; ebx = y coordinate
35
;
35
;
36
; ret:
36
; ret:
37
; ecx = 00 RR GG BB
37
; ecx = 00 RR GG BB
38
 
38
 
39
getpixel:
39
getpixel:
40
        push    eax ebx edx edi
40
        push    eax ebx edx edi
41
        call    dword [0xe024]
41
        call    dword [0xe024]
42
        pop     edi edx ebx eax
42
        pop     edi edx ebx eax
43
        ret
43
        ret
44
 
44
 
45
Vesa20_getpixel24:
45
Vesa20_getpixel24:
46
        ; eax = x
46
        ; eax = x
47
        ; ebx = y
47
        ; ebx = y
48
        imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
48
        imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
49
        lea     edi, [eax+eax*2] ; edi = x*3
49
        lea     edi, [eax+eax*2] ; edi = x*3
50
        add     edi, ebx         ; edi = x*3+(y*y multiplier)
50
        add     edi, ebx         ; edi = x*3+(y*y multiplier)
51
        add     edi, [LFBAddress]    ; ebx = where pixel is in memory
51
        add     edi, [LFBAddress]    ; ebx = where pixel is in memory
52
        mov     ecx, [edi]
52
        mov     ecx, [edi]
53
        and     ecx, 0xffffff
53
        and     ecx, 0xffffff
54
        ret
54
        ret
55
 
55
 
56
 
56
 
57
Vesa20_getpixel32:
57
Vesa20_getpixel32:
58
        imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
58
        imul    ebx, [BytesPerScanLine]    ; ebx = y * y multiplier
59
        lea     edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
59
        lea     edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
60
        add     edi, [LFBAddress]    ; ebx = where pixel is in memory
60
        add     edi, [LFBAddress]    ; ebx = where pixel is in memory
61
        mov     ecx, [edi]
61
        mov     ecx, [edi]
62
        and     ecx, 0xffffff
62
        and     ecx, 0xffffff
63
        ret
63
        ret
64
 
64
 
65
;*************************************************
65
;*************************************************
66
 
66
 
67
virtual at esp
67
virtual at esp
68
 putimg:
68
 putimg:
69
   .real_sx        dd ?
69
   .real_sx        dd ?
70
   .real_sy        dd ?
70
   .real_sy        dd ?
71
   .image_sx       dd ?
71
   .image_sx       dd ?
72
   .image_sy       dd ?
72
   .image_sy       dd ?
73
   .image_cx       dd ?
73
   .image_cx       dd ?
74
   .image_cy       dd ?
74
   .image_cy       dd ?
75
   .pti            dd ?
75
   .pti            dd ?
76
   .abs_cx         dd ?
76
   .abs_cx         dd ?
77
   .abs_cy         dd ?
77
   .abs_cy         dd ?
78
   .line_increment dd ?
78
   .line_increment dd ?
79
   .source_bpp     dd ?
79
   .source_bpp     dd ?
80
   .winmap_newline dd ?
80
   .winmap_newline dd ?
81
   .screen_newline dd ?
81
   .screen_newline dd ?
82
   .stack_data = 4*13
82
   .stack_data = 4*13
83
end virtual
83
end virtual
84
 
84
 
85
align 4
85
align 4
86
; ebx = pointer
86
; ebx = pointer
87
; ecx = size [x|y]
87
; ecx = size [x|y]
88
; edx = coordinates [x|y]
88
; edx = coordinates [x|y]
89
vesa20_putimage:
89
vesa20_putimage:
90
        pushad
90
        pushad
91
        call    [disable_mouse]
91
        call    [disable_mouse]
92
 
92
 
93
        sub     esp, putimg.stack_data
93
        sub     esp, putimg.stack_data
94
 
94
 
95
        mov     [putimg.source_bpp], 3
95
        mov     [putimg.source_bpp], 3
96
;        test    ebx, 0x80000000
96
;        test    ebx, 0x80000000
97
;        jz      @f
97
;        jz      @f
98
;        inc     [putimg.source_bpp]
98
;        inc     [putimg.source_bpp]
99
;      @@:
99
;      @@:
100
;        and     ebx, 0x7FFFFFFF
100
;        and     ebx, 0x7FFFFFFF
101
 
101
 
102
        ; save pointer to image
102
        ; save pointer to image
103
        mov     [putimg.pti], ebx
103
        mov     [putimg.pti], ebx
104
 
104
 
105
        ; unpack the size
105
        ; unpack the size
106
        mov     eax, ecx
106
        mov     eax, ecx
107
        and     ecx, 0xFFFF
107
        and     ecx, 0xFFFF
108
        shr     eax, 16
108
        shr     eax, 16
109
        mov     [putimg.image_sx], eax
109
        mov     [putimg.image_sx], eax
110
        mov     [putimg.image_sy], ecx
110
        mov     [putimg.image_sy], ecx
111
 
111
 
112
        ; unpack the coordinates
112
        ; unpack the coordinates
113
        mov     eax, edx
113
        mov     eax, edx
114
        and     edx, 0xFFFF
114
        and     edx, 0xFFFF
115
        shr     eax, 16
115
        shr     eax, 16
116
        mov     [putimg.image_cx], eax
116
        mov     [putimg.image_cx], eax
117
        mov     [putimg.image_cy], edx
117
        mov     [putimg.image_cy], edx
118
 
118
 
119
        ; calculate absolute (i.e. screen) coordinates
119
        ; calculate absolute (i.e. screen) coordinates
120
        mov     eax, [0x3010]
120
        mov     eax, [0x3010]
121
        mov     ebx, [eax-twdw + 0]
121
        mov     ebx, [eax-twdw + 0]
122
        add     ebx, [putimg.image_cx]
122
        add     ebx, [putimg.image_cx]
123
        mov     [putimg.abs_cx], ebx
123
        mov     [putimg.abs_cx], ebx
124
        mov     ebx, [eax-twdw + 4]
124
        mov     ebx, [eax-twdw + 4]
125
        add     ebx, [putimg.image_cy]
125
        add     ebx, [putimg.image_cy]
126
        mov     [putimg.abs_cy], ebx
126
        mov     [putimg.abs_cy], ebx
127
 
127
 
128
        ; real_sx = MIN(wnd_sx-image_cx, image_sx);
128
        ; real_sx = MIN(wnd_sx-image_cx, image_sx);
129
        mov     ebx, [eax-twdw + 8] ; ebx = wnd_sx
129
        mov     ebx, [eax-twdw + 8] ; ebx = wnd_sx
130
        sub     ebx, [putimg.image_cx]
130
        sub     ebx, [putimg.image_cx]
131
        ja      @f
131
        ja      @f
132
        add     esp, putimg.stack_data
132
        add     esp, putimg.stack_data
133
        popad
133
        popad
134
        xor     eax, eax
-
 
135
        inc     eax
-
 
136
        ret
134
        ret
137
      @@:
135
      @@:
138
        cmp     ebx, [putimg.image_sx]
136
        cmp     ebx, [putimg.image_sx]
139
        jbe     .end_x
137
        jbe     .end_x
140
        mov     ebx, [putimg.image_sx]
138
        mov     ebx, [putimg.image_sx]
141
        dec     ebx
139
        dec     ebx
142
      .end_x:
140
      .end_x:
143
        inc     ebx
141
        inc     ebx
144
        mov     [putimg.real_sx], ebx
142
        mov     [putimg.real_sx], ebx
145
 
143
 
146
        ; init real_sy
144
        ; init real_sy
147
        mov     ebx, [eax-twdw + 12] ; ebx = wnd_sy
145
        mov     ebx, [eax-twdw + 12] ; ebx = wnd_sy
148
        sub     ebx, [putimg.image_cy]
146
        sub     ebx, [putimg.image_cy]
149
        ja      @f
147
        ja      @f
150
        add     esp, putimg.stack_data
148
        add     esp, putimg.stack_data
151
        popad
149
        popad
152
        xor     eax, eax
-
 
153
        inc     eax
-
 
154
        ret
150
        ret
155
      @@:
151
      @@:
156
        cmp     ebx, [putimg.image_sy]
152
        cmp     ebx, [putimg.image_sy]
157
        jbe     .end_y
153
        jbe     .end_y
158
        mov     ebx, [putimg.image_sy]
154
        mov     ebx, [putimg.image_sy]
159
        dec     ebx
155
        dec     ebx
160
      .end_y:
156
      .end_y:
161
        inc     ebx
157
        inc     ebx
162
        mov     [putimg.real_sy], ebx
158
        mov     [putimg.real_sy], ebx
163
 
159
 
164
        ; line increment
160
        ; line increment
165
        mov     eax, [putimg.image_sx]
161
        mov     eax, [putimg.image_sx]
166
        sub     eax, [putimg.real_sx]
162
        sub     eax, [putimg.real_sx]
167
;;        imul    eax, [putimg.source_bpp]
163
;;        imul    eax, [putimg.source_bpp]
168
        lea     eax, [eax + eax * 2]
164
        lea     eax, [eax + eax * 2]
169
        mov     [putimg.line_increment], eax
165
        mov     [putimg.line_increment], eax
170
 
166
 
171
        ; winmap new line increment
167
        ; winmap new line increment
172
        mov     eax, [ScreenWidth]
168
        mov     eax, [ScreenWidth]
173
        inc     eax
169
        inc     eax
174
        sub     eax, [putimg.real_sx]
170
        sub     eax, [putimg.real_sx]
175
        mov     [putimg.winmap_newline], eax
171
        mov     [putimg.winmap_newline], eax
176
 
172
 
177
        ; screen new line increment
173
        ; screen new line increment
178
        mov     eax, [BytesPerScanLine]
174
        mov     eax, [BytesPerScanLine]
179
        mov     ecx, [putimg.real_sx]
175
        mov     ecx, [putimg.real_sx]
180
        movzx   ebx, byte [ScreenBPP]
176
        movzx   ebx, byte [ScreenBPP]
181
        shr     ebx, 3
177
        shr     ebx, 3
182
        imul    ecx, ebx
178
        imul    ecx, ebx
183
        sub     eax, ecx
179
        sub     eax, ecx
184
        mov     [putimg.screen_newline], eax
180
        mov     [putimg.screen_newline], eax
185
 
181
 
186
        ; pointer to image
182
        ; pointer to image
187
        mov     ecx, [putimg.pti]
183
        mov     ecx, [putimg.pti]
188
 
184
 
189
        ; pointer to screen
185
        ; pointer to screen
190
        mov     edx, [putimg.abs_cy]
186
        mov     edx, [putimg.abs_cy]
191
        imul    edx, [BytesPerScanLine]
187
        imul    edx, [BytesPerScanLine]
192
        mov     eax, [putimg.abs_cx]
188
        mov     eax, [putimg.abs_cx]
193
        movzx   ebx, byte [ScreenBPP]
189
        movzx   ebx, byte [ScreenBPP]
194
        shr     ebx, 3
190
        shr     ebx, 3
195
        imul    eax, ebx
191
        imul    eax, ebx
196
        add     edx, eax
192
        add     edx, eax
197
        add     edx, [LFBAddress]
193
        add     edx, [LFBAddress]
198
 
194
 
199
        ; pointer to pixel map
195
        ; pointer to pixel map
200
        mov     eax, [putimg.abs_cy]
196
        mov     eax, [putimg.abs_cy]
201
        imul    eax, [ScreenWidth]
197
        imul    eax, [ScreenWidth]
202
        add     eax, [putimg.abs_cy]
198
        add     eax, [putimg.abs_cy]
203
        add     eax, [putimg.abs_cx]
199
        add     eax, [putimg.abs_cx]
204
        add     eax, WinMapAddress
200
        add     eax, WinMapAddress
205
        xchg    eax, ebp
201
        xchg    eax, ebp
206
 
202
 
207
        ; get process number
203
        ; get process number
208
        mov     eax, [0x3010]
204
        mov     eax, [0x3010]
209
        mov     bl, [eax+0xE]
205
        mov     bl, [eax+0xE]
210
 
206
 
211
        cmp     byte [ScreenBPP], 32
207
        cmp     byte [ScreenBPP], 32
212
        je      put_image_end_32
208
        je      put_image_end_32
213
 
209
 
214
;put_image_end_24:
210
;put_image_end_24:
215
        ;cli ; !!!!!!!!!!!!!!!!!!!!!!
211
        ;cli ; !!!!!!!!!!!!!!!!!!!!!!
216
        mov     edi, [putimg.real_sy]
212
        mov     edi, [putimg.real_sy]
217
        align   4
213
        align   4
218
      .new_line:
214
      .new_line:
219
        mov     esi, [putimg.real_sx]
215
        mov     esi, [putimg.real_sx]
220
 
216
 
221
;        push    ebp edx
217
;        push    ebp edx
222
        align   4
218
        align   4
223
          .new_x:
219
          .new_x:
224
 
220
 
225
                cmp     [ebp], bl
221
                cmp     [ebp], bl
226
                jne     .skip
222
                jne     .skip
227
                mov     eax, [ecx]        ; ecx = RRBBGGRR
223
                mov     eax, [ecx]        ; ecx = RRBBGGRR
228
                mov     [edx], ax
224
                mov     [edx], ax
229
                shr     eax, 16
225
                shr     eax, 16
230
                mov     [edx+2], al
226
                mov     [edx+2], al
231
              .skip:
227
              .skip:
232
 
228
 
233
            add     ecx, 3 ;[putimg.source_bpp]
229
            add     ecx, 3 ;[putimg.source_bpp]
234
            add     edx, 3
230
            add     edx, 3
235
            inc     ebp
231
            inc     ebp
236
 
232
 
237
            dec     esi
233
            dec     esi
238
            jnz     .new_x
234
            jnz     .new_x
239
;        pop     edx ebp
235
;        pop     edx ebp
240
 
236
 
241
        add     ecx, [putimg.line_increment]
237
        add     ecx, [putimg.line_increment]
242
        add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
238
        add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
243
        add     ebp, [putimg.winmap_newline] ;[ScreenWidth]
239
        add     ebp, [putimg.winmap_newline] ;[ScreenWidth]
244
        ;inc     ebp
240
        ;inc     ebp
245
 
241
 
246
        dec     edi
242
        dec     edi
247
        jnz     .new_line
243
        jnz     .new_line
248
   .finish:
244
   .finish:
249
        add     esp, putimg.stack_data
245
        add     esp, putimg.stack_data
250
        popad
246
        popad
251
        xor     eax, eax
-
 
252
        ;sti ; !!!!!!!!!!!!!!!!!!!!!
247
        ;sti ; !!!!!!!!!!!!!!!!!!!!!
253
ret
248
ret
254
 
249
 
255
put_image_end_32:
250
put_image_end_32:
256
        mov     edi, [putimg.real_sy]
251
        mov     edi, [putimg.real_sy]
257
        align   4
252
        align   4
258
      .new_line:
253
      .new_line:
259
        mov     esi, [putimg.real_sx]
254
        mov     esi, [putimg.real_sx]
260
 
255
 
261
;        push    ebp edx
256
;        push    ebp edx
262
        align   4
257
        align   4
263
          .new_x:
258
          .new_x:
264
 
259
 
265
                cmp     [ebp], bl
260
                cmp     [ebp], bl
266
                jne     .skip
261
                jne     .skip
267
                mov     eax, [ecx]        ; ecx = RRBBGGRR
262
                mov     eax, [ecx]        ; ecx = RRBBGGRR
268
                mov     [edx], eax
263
                mov     [edx], eax
269
              .skip:
264
              .skip:
270
 
265
 
271
            add     ecx, [putimg.source_bpp]
266
            add     ecx, [putimg.source_bpp]
272
            add     edx, 4
267
            add     edx, 4
273
            inc     ebp
268
            inc     ebp
274
 
269
 
275
            dec     esi
270
            dec     esi
276
            jnz     .new_x
271
            jnz     .new_x
277
;        pop     edx ebp
272
;        pop     edx ebp
278
 
273
 
279
        add     ecx, [putimg.line_increment]
274
        add     ecx, [putimg.line_increment]
280
        add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
275
        add     edx, [putimg.screen_newline] ;[BytesPerScanLine]
281
        add     ebp, [putimg.winmap_newline] ;[ScreenWidth]
276
        add     ebp, [putimg.winmap_newline] ;[ScreenWidth]
282
        ;inc     ebp
277
        ;inc     ebp
283
 
278
 
284
        dec     edi
279
        dec     edi
285
        jnz     .new_line
280
        jnz     .new_line
286
   .finish:
281
   .finish:
287
        add     esp, putimg.stack_data
282
        add     esp, putimg.stack_data
288
        popad
283
        popad
289
        xor     eax, eax
-
 
290
ret
284
ret
291
 
285
 
292
 
286
 
293
;*************************************************
287
;*************************************************
294
align 4
288
align 4
295
__sys_putpixel:
289
__sys_putpixel:
296
 
290
 
297
; eax = x coordinate
291
; eax = x coordinate
298
; ebx = y coordinate
292
; ebx = y coordinate
299
; ecx = ?? RR GG BB    ; 0x01000000 negation
293
; ecx = ?? RR GG BB    ; 0x01000000 negation
300
; edi = 0x00000001 force
294
; edi = 0x00000001 force
301
 
295
 
302
;;;        mov  [novesachecksum], dword 0
296
;;;        mov  [novesachecksum], dword 0
303
 
297
 
304
        pushad
298
        pushad
305
        test  edi,1                 ; force ?
299
        test  edi,1                 ; force ?
306
        jnz   .forced
300
        jnz   .forced
307
      ; not forced:
301
      ; not forced:
308
        push  ecx               ; save 24th bit in case negative pixel wanted
302
        push  ecx               ; save 24th bit in case negative pixel wanted
309
        call  checkpixel
303
        call  checkpixel
310
        test  ecx,ecx
304
        test  ecx,ecx
311
        pop   ecx
305
        pop   ecx
312
        jnz   .exit
306
        jnz   .exit
313
      .forced:
307
      .forced:
314
        cmp   [ScreenWidth], eax
308
        cmp   [ScreenWidth], eax
315
        jb    .exit
309
        jb    .exit
316
        cmp   [ScreenHeight], ebx
310
        cmp   [ScreenHeight], ebx
317
        jb    .exit
311
        jb    .exit
318
      .ok:
312
      .ok:
319
        ; check if negation
313
        ; check if negation
320
        test  ecx,0x01000000
314
        test  ecx,0x01000000
321
        jz    .noneg
315
        jz    .noneg
322
        call  getpixel
316
        call  getpixel
323
        not   ecx
317
        not   ecx
324
        mov   [esp+32-8],ecx
318
        mov   [esp+32-8],ecx
325
      .noneg:
319
      .noneg:
326
        ; OK to set pixel
320
        ; OK to set pixel
327
        call  dword [0xe020]        ; call the real put_pixel function
321
        call  dword [0xe020]        ; call the real put_pixel function
328
      .exit:
322
      .exit:
329
        popad
323
        popad
330
 
324
 
331
        ret
325
        ret
332
 
326
 
333
align 4
327
align 4
334
Vesa20_putpixel24:
328
Vesa20_putpixel24:
335
 
329
 
336
        ; eax = x
330
        ; eax = x
337
        ; ebx = y
331
        ; ebx = y
338
 
332
 
339
        imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
333
        imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
340
        lea     edi, [eax+eax*2]  ; edi = x*3
334
        lea     edi, [eax+eax*2]  ; edi = x*3
341
        mov     eax, [esp+32-8+4]
335
        mov     eax, [esp+32-8+4]
342
        add     edi, [LFBAddress]
336
        add     edi, [LFBAddress]
343
        add     edi, ebx          ; ebx = where to put pixel in memory
337
        add     edi, ebx          ; ebx = where to put pixel in memory
344
        mov     [edi], ax
338
        mov     [edi], ax
345
        shr     eax, 16
339
        shr     eax, 16
346
        mov     [edi+2], al
340
        mov     [edi+2], al
347
 
341
 
348
        ret
342
        ret
349
 
343
 
350
 
344
 
351
align 4
345
align 4
352
Vesa20_putpixel32:
346
Vesa20_putpixel32:
353
 
347
 
354
        ; eax = x
348
        ; eax = x
355
        ; ebx = y
349
        ; ebx = y
356
 
350
 
357
        imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
351
        imul    ebx, [BytesPerScanLine]     ; ebx = y * y multiplier
358
        lea     edi, [ebx+eax*4]  ; edi = x*4+(y*y multiplier)
352
        lea     edi, [ebx+eax*4]  ; edi = x*4+(y*y multiplier)
359
        mov     eax, [esp+32-8+4] ; eax = color
353
        mov     eax, [esp+32-8+4] ; eax = color
360
        add     edi, [LFBAddress]     ; ebx = where to put pixel in memory
354
        add     edi, [LFBAddress]     ; ebx = where to put pixel in memory
361
        mov     [edi], eax
355
        mov     [edi], eax
362
 
356
 
363
        ret
357
        ret
364
 
358
 
365
 
359
 
366
;*************************************************
360
;*************************************************
367
 
361
 
368
;align 4
362
;align 4
369
calculate_edi:
363
calculate_edi:
370
        mov     edi, ebx
364
        mov     edi, ebx
371
        imul    edi, [ScreenWidth]
365
        imul    edi, [ScreenWidth]
372
        add     edi, ebx
366
        add     edi, ebx
373
        add     edi, eax
367
        add     edi, eax
374
ret
368
ret
375
 
369
 
376
;*************************************************
370
;*************************************************
377
 
371
 
378
; DRAWLINE
372
; DRAWLINE
379
 
373
 
380
align 4
374
align 4
381
__sys_draw_line:
375
__sys_draw_line:
382
;     inc   [mouse_pause]
376
;     inc   [mouse_pause]
383
        call    [disable_mouse]
377
        call    [disable_mouse]
384
 
378
 
385
; draw a line
379
; draw a line
386
; eax = HIWORD = x1
380
; eax = HIWORD = x1
387
;       LOWORD = x2
381
;       LOWORD = x2
388
; ebx = HIWORD = y1
382
; ebx = HIWORD = y1
389
;       LOWORD = y2
383
;       LOWORD = y2
390
; ecx = color
384
; ecx = color
391
; edi = force ?
385
; edi = force ?
392
        pusha
386
        pusha
393
 
387
 
394
dl_x1 equ esp+20
388
dl_x1 equ esp+20
395
dl_y1 equ esp+16
389
dl_y1 equ esp+16
396
dl_x2 equ esp+12
390
dl_x2 equ esp+12
397
dl_y2 equ esp+8
391
dl_y2 equ esp+8
398
dl_dx equ esp+4
392
dl_dx equ esp+4
399
dl_dy equ esp+0
393
dl_dy equ esp+0
400
 
394
 
401
        xor     edx, edx      ; clear edx
395
        xor     edx, edx      ; clear edx
402
        xor     esi, esi      ; unpack arguments
396
        xor     esi, esi      ; unpack arguments
403
        xor     ebp, ebp
397
        xor     ebp, ebp
404
        mov     si, ax        ; esi = x2
398
        mov     si, ax        ; esi = x2
405
        mov     bp, bx        ; ebp = y2
399
        mov     bp, bx        ; ebp = y2
406
        shr     eax, 16       ; eax = x1
400
        shr     eax, 16       ; eax = x1
407
        shr     ebx, 16       ; ebx = y1
401
        shr     ebx, 16       ; ebx = y1
408
 
402
 
409
        push    eax           ; save x1
403
        push    eax           ; save x1
410
        push    ebx           ; save y1
404
        push    ebx           ; save y1
411
        push    esi           ; save x2
405
        push    esi           ; save x2
412
        push    ebp           ; save y2
406
        push    ebp           ; save y2
413
 
407
 
414
        ; checking x-axis...
408
        ; checking x-axis...
415
        sub     esi, eax      ; esi = x2-x1
409
        sub     esi, eax      ; esi = x2-x1
416
        push    esi           ; save y2-y1
410
        push    esi           ; save y2-y1
417
        jl      .x2lx1        ; is x2 less than x1 ?
411
        jl      .x2lx1        ; is x2 less than x1 ?
418
        jg      .no_vline     ; x1 > x2 ?
412
        jg      .no_vline     ; x1 > x2 ?
419
        mov     edx, ebp      ; else (if x1=x2)
413
        mov     edx, ebp      ; else (if x1=x2)
420
        call    vline
414
        call    vline
421
        push    edx    ; necessary to rightly restore stack frame at .exit
415
        push    edx    ; necessary to rightly restore stack frame at .exit
422
        jmp     .exit
416
        jmp     .exit
423
.x2lx1:
417
.x2lx1:
424
        neg     esi            ; get esi absolute value
418
        neg     esi            ; get esi absolute value
425
.no_vline:
419
.no_vline:
426
 
420
 
427
        ; checking y-axis...
421
        ; checking y-axis...
428
        sub     ebp, ebx       ; ebp = y2-y1
422
        sub     ebp, ebx       ; ebp = y2-y1
429
        push    ebp            ; save y2-y1
423
        push    ebp            ; save y2-y1
430
        jl      .y2ly1         ; is y2 less than y1 ?
424
        jl      .y2ly1         ; is y2 less than y1 ?
431
        jg      .no_hline      ; y1 > y2 ?
425
        jg      .no_hline      ; y1 > y2 ?
432
        mov     edx, [dl_x2]   ; else (if y1=y2)
426
        mov     edx, [dl_x2]   ; else (if y1=y2)
433
        call    hline
427
        call    hline
434
        jmp     .exit
428
        jmp     .exit
435
.y2ly1:
429
.y2ly1:
436
        neg     ebp            ; get ebp absolute value
430
        neg     ebp            ; get ebp absolute value
437
.no_hline:
431
.no_hline:
438
 
432
 
439
 
433
 
440
        cmp     ebp, esi
434
        cmp     ebp, esi
441
        jle     .x_rules       ; |y2-y1| < |x2-x1|  ?
435
        jle     .x_rules       ; |y2-y1| < |x2-x1|  ?
442
 
436
 
443
        cmp     [dl_y2], ebx   ; make sure y1 is at the begining
437
        cmp     [dl_y2], ebx   ; make sure y1 is at the begining
444
        jge     .no_reverse1
438
        jge     .no_reverse1
445
 
439
 
446
        neg     dword [dl_dx]
440
        neg     dword [dl_dx]
447
        mov     edx, [dl_x2]
441
        mov     edx, [dl_x2]
448
        mov     [dl_x2], eax
442
        mov     [dl_x2], eax
449
        mov     [dl_x1], edx
443
        mov     [dl_x1], edx
450
        mov     edx, [dl_y2]
444
        mov     edx, [dl_y2]
451
        mov     [dl_y2], ebx
445
        mov     [dl_y2], ebx
452
        mov     [dl_y1], edx
446
        mov     [dl_y1], edx
453
 
447
 
454
.no_reverse1:
448
.no_reverse1:
455
 
449
 
456
        mov     eax, [dl_dx]
450
        mov     eax, [dl_dx]
457
        cdq                    ; extend eax sing to edx
451
        cdq                    ; extend eax sing to edx
458
        shl     eax, 16        ; using 16bit fix-point maths
452
        shl     eax, 16        ; using 16bit fix-point maths
459
        idiv    ebp            ; eax = ((x2-x1)*65536)/(y2-y1)
453
        idiv    ebp            ; eax = ((x2-x1)*65536)/(y2-y1)
460
        mov     edx, ebp       ; edx = counter (number of pixels to draw)
454
        mov     edx, ebp       ; edx = counter (number of pixels to draw)
461
        mov     ebp, 1 *65536  ; <<16   ; ebp = dy = 1.0
455
        mov     ebp, 1 *65536  ; <<16   ; ebp = dy = 1.0
462
        mov     esi, eax       ; esi = dx
456
        mov     esi, eax       ; esi = dx
463
 
457
 
464
        jmp     .y_rules
458
        jmp     .y_rules
465
.x_rules:
459
.x_rules:
466
 
460
 
467
        cmp     [dl_x2], eax    ; make sure x1 is at the begining
461
        cmp     [dl_x2], eax    ; make sure x1 is at the begining
468
        jge     .no_reverse2
462
        jge     .no_reverse2
469
 
463
 
470
        neg     dword [dl_dy]
464
        neg     dword [dl_dy]
471
        mov     edx, [dl_x2]
465
        mov     edx, [dl_x2]
472
        mov     [dl_x2], eax
466
        mov     [dl_x2], eax
473
        mov     [dl_x1], edx
467
        mov     [dl_x1], edx
474
        mov     edx, [dl_y2]
468
        mov     edx, [dl_y2]
475
        mov     [dl_y2], ebx
469
        mov     [dl_y2], ebx
476
        mov     [dl_y1], edx
470
        mov     [dl_y1], edx
477
 
471
 
478
.no_reverse2:
472
.no_reverse2:
479
 
473
 
480
        xor     edx, edx
474
        xor     edx, edx
481
        mov     eax, [dl_dy]
475
        mov     eax, [dl_dy]
482
        cdq                    ; extend eax sing to edx
476
        cdq                    ; extend eax sing to edx
483
        shl     eax, 16        ; using 16bit fix-point maths
477
        shl     eax, 16        ; using 16bit fix-point maths
484
        idiv    esi            ; eax = ((y2-y1)*65536)/(x2-x1)
478
        idiv    esi            ; eax = ((y2-y1)*65536)/(x2-x1)
485
        mov     edx, esi       ; edx = counter (number of pixels to draw)
479
        mov     edx, esi       ; edx = counter (number of pixels to draw)
486
        mov     esi, 1 *65536  ;<< 16   ; esi = dx = 1.0
480
        mov     esi, 1 *65536  ;<< 16   ; esi = dx = 1.0
487
        mov     ebp, eax       ; ebp = dy
481
        mov     ebp, eax       ; ebp = dy
488
 
482
 
489
.y_rules:
483
.y_rules:
490
 
484
 
491
        mov     eax, [dl_x1]
485
        mov     eax, [dl_x1]
492
        mov     ebx, [dl_y1]
486
        mov     ebx, [dl_y1]
493
        shl     eax, 16
487
        shl     eax, 16
494
        shl     ebx, 16
488
        shl     ebx, 16
495
 
489
 
496
align 4
490
align 4
497
 
491
 
498
.draw:
492
.draw:
499
        push    eax ebx
493
        push    eax ebx
500
        shr     eax, 16
494
        shr     eax, 16
501
        shr     ebx, 16
495
        shr     ebx, 16
502
        call    [putpixel]
496
        call    [putpixel]
503
        pop     ebx eax
497
        pop     ebx eax
504
 
498
 
505
        add     ebx, ebp        ; y = y+dy
499
        add     ebx, ebp        ; y = y+dy
506
        add     eax, esi        ; x = x+dx
500
        add     eax, esi        ; x = x+dx
507
 
501
 
508
        dec     edx
502
        dec     edx
509
        jnz     .draw
503
        jnz     .draw
510
 
504
 
511
        ; force last drawn pixel to be at (x2,y2)
505
        ; force last drawn pixel to be at (x2,y2)
512
        mov     eax, [dl_x2]
506
        mov     eax, [dl_x2]
513
        mov     ebx, [dl_y2]
507
        mov     ebx, [dl_y2]
514
        call    [putpixel]
508
        call    [putpixel]
515
.exit:
509
.exit:
516
        add     esp, 6*4
510
        add     esp, 6*4
517
        popa
511
        popa
518
;     dec   [mouse_pause]
512
;     dec   [mouse_pause]
519
     call   [draw_pointer]
513
     call   [draw_pointer]
520
ret
514
ret
521
 
515
 
522
 
516
 
523
hline:
517
hline:
524
; draw an horizontal line
518
; draw an horizontal line
525
; eax = x1
519
; eax = x1
526
; edx = x2
520
; edx = x2
527
; ebx = y
521
; ebx = y
528
; ecx = color
522
; ecx = color
529
; edi = force ?
523
; edi = force ?
530
        push    eax edx
524
        push    eax edx
531
 
525
 
532
        cmp     edx, eax      ; make sure x2 is above x1
526
        cmp     edx, eax      ; make sure x2 is above x1
533
        jge     @f
527
        jge     @f
534
        xchg    eax, edx
528
        xchg    eax, edx
535
        align   4
529
        align   4
536
   @@:
530
   @@:
537
        call    [putpixel]
531
        call    [putpixel]
538
        inc     eax
532
        inc     eax
539
        cmp     eax, edx
533
        cmp     eax, edx
540
        jle     @b
534
        jle     @b
541
 
535
 
542
        pop     edx eax
536
        pop     edx eax
543
ret
537
ret
544
 
538
 
545
 
539
 
546
vline:
540
vline:
547
; draw a vertical line
541
; draw a vertical line
548
; eax = x
542
; eax = x
549
; ebx = y1
543
; ebx = y1
550
; edx = y2
544
; edx = y2
551
; ecx = color
545
; ecx = color
552
; edi = force ?
546
; edi = force ?
553
        push    ebx edx
547
        push    ebx edx
554
 
548
 
555
        cmp     edx, ebx      ; make sure y2 is above y1
549
        cmp     edx, ebx      ; make sure y2 is above y1
556
        jge     @f
550
        jge     @f
557
        xchg    ebx, edx
551
        xchg    ebx, edx
558
        align   4
552
        align   4
559
   @@:
553
   @@:
560
        call    [putpixel]
554
        call    [putpixel]
561
        inc     ebx
555
        inc     ebx
562
        cmp     ebx, edx
556
        cmp     ebx, edx
563
        jle     @b
557
        jle     @b
564
 
558
 
565
        pop     edx ebx
559
        pop     edx ebx
566
ret
560
ret
567
 
561
 
568
 
562
 
569
;*************************************************
563
;*************************************************
570
 
564
 
571
 
565
 
572
virtual at esp
566
virtual at esp
573
      drbar:
567
      drbar:
574
        .bar_sx       dd ?
568
        .bar_sx       dd ?
575
        .bar_sy       dd ?
569
        .bar_sy       dd ?
576
        .bar_cx       dd ?
570
        .bar_cx       dd ?
577
        .bar_cy       dd ?
571
        .bar_cy       dd ?
578
        .abs_cx       dd ?
572
        .abs_cx       dd ?
579
        .abs_cy       dd ?
573
        .abs_cy       dd ?
580
        .real_sx      dd ?
574
        .real_sx      dd ?
581
        .real_sy      dd ?
575
        .real_sy      dd ?
582
        .color        dd ?
576
        .color        dd ?
583
        .line_inc_scr dd ?
577
        .line_inc_scr dd ?
584
        .line_inc_map dd ?
578
        .line_inc_map dd ?
585
        .stack_data = 4*11
579
        .stack_data = 4*11
586
end virtual
580
end virtual
587
 
581
 
588
align 4
582
align 4
589
; eax   cx
583
; eax   cx
590
; ebx   cy
584
; ebx   cy
591
; ecx   xe
585
; ecx   xe
592
; edx   ye
586
; edx   ye
593
; edi   color
587
; edi   color
594
vesa20_drawbar:
588
vesa20_drawbar:
595
        
589
        
596
        pushad
590
        pushad
597
        call    [disable_mouse]
591
        call    [disable_mouse]
598
 
592
 
599
        sub     esp, drbar.stack_data
593
        sub     esp, drbar.stack_data
600
 
594
 
601
        mov     [drbar.color], edi
595
        mov     [drbar.color], edi
602
 
596
 
603
        sub     edx, ebx
597
        sub     edx, ebx
604
        jle     .exit          ;// mike.dld, 2005-01-29
598
        jle     .exit          ;// mike.dld, 2005-01-29
605
        sub     ecx, eax
599
        sub     ecx, eax
606
        jle     .exit          ;// mike.dld, 2005-01-29
600
        jle     .exit          ;// mike.dld, 2005-01-29
607
        mov     [drbar.bar_sy], edx
601
        mov     [drbar.bar_sy], edx
608
        mov     [drbar.bar_sx], ecx
602
        mov     [drbar.bar_sx], ecx
609
 
603
 
610
        mov     [drbar.bar_cx], eax
604
        mov     [drbar.bar_cx], eax
611
        mov     [drbar.bar_cy], ebx
605
        mov     [drbar.bar_cy], ebx
612
 
606
 
613
        mov     edi, [0x3010]
607
        mov     edi, [0x3010]
614
        add     eax, [edi-twdw + 0] ; win_cx
608
        add     eax, [edi-twdw + 0] ; win_cx
615
        add     ebx, [edi-twdw + 4] ; win_cy
609
        add     ebx, [edi-twdw + 4] ; win_cy
616
        mov     [drbar.abs_cx], eax
610
        mov     [drbar.abs_cx], eax
617
        mov     [drbar.abs_cy], ebx
611
        mov     [drbar.abs_cy], ebx
618
 
612
 
619
        ; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
613
        ; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
620
        mov     ebx, [edi-twdw + 8] ; ebx = wnd_sx
614
        mov     ebx, [edi-twdw + 8] ; ebx = wnd_sx
621
        sub     ebx, [drbar.bar_cx]
615
        sub     ebx, [drbar.bar_cx]
622
        ja      @f
616
        ja      @f
623
  .exit:                       ;// mike.dld, 2005-01-29
617
  .exit:                       ;// mike.dld, 2005-01-29
624
        add     esp, drbar.stack_data
618
        add     esp, drbar.stack_data
625
        popad
619
        popad
626
        xor     eax, eax
620
        xor     eax, eax
627
        inc     eax
621
        inc     eax
628
        
622
        
629
        ret
623
        ret
630
      @@:
624
      @@:
631
        cmp     ebx, [drbar.bar_sx]
625
        cmp     ebx, [drbar.bar_sx]
632
        jbe     .end_x
626
        jbe     .end_x
633
        mov     ebx, [drbar.bar_sx]
627
        mov     ebx, [drbar.bar_sx]
634
      .end_x:
628
      .end_x:
635
        mov     [drbar.real_sx], ebx
629
        mov     [drbar.real_sx], ebx
636
 
630
 
637
        ; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
631
        ; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
638
        mov     ebx, [edi-twdw + 12] ; ebx = wnd_sy
632
        mov     ebx, [edi-twdw + 12] ; ebx = wnd_sy
639
        sub     ebx, [drbar.bar_cy]
633
        sub     ebx, [drbar.bar_cy]
640
        ja      @f
634
        ja      @f
641
        add     esp, drbar.stack_data
635
        add     esp, drbar.stack_data
642
        popad
636
        popad
643
        xor     eax, eax
637
        xor     eax, eax
644
        inc     eax
638
        inc     eax
645
        
639
        
646
        ret
640
        ret
647
      @@:
641
      @@:
648
        cmp     ebx, [drbar.bar_sy]
642
        cmp     ebx, [drbar.bar_sy]
649
        jbe     .end_y
643
        jbe     .end_y
650
        mov     ebx, [drbar.bar_sy]
644
        mov     ebx, [drbar.bar_sy]
651
      .end_y:
645
      .end_y:
652
        mov     [drbar.real_sy], ebx
646
        mov     [drbar.real_sy], ebx
653
 
647
 
654
        ; line_inc_map
648
        ; line_inc_map
655
        mov     eax, [ScreenWidth]
649
        mov     eax, [ScreenWidth]
656
        sub     eax, [drbar.real_sx]
650
        sub     eax, [drbar.real_sx]
657
        inc     eax
651
        inc     eax
658
        mov     [drbar.line_inc_map], eax
652
        mov     [drbar.line_inc_map], eax
659
 
653
 
660
        ; line_inc_scr
654
        ; line_inc_scr
661
        mov     eax, [drbar.real_sx]
655
        mov     eax, [drbar.real_sx]
662
        movzx   ebx, byte [ScreenBPP]
656
        movzx   ebx, byte [ScreenBPP]
663
        shr     ebx, 3
657
        shr     ebx, 3
664
        imul    eax, ebx
658
        imul    eax, ebx
665
        neg     eax
659
        neg     eax
666
        add     eax, [BytesPerScanLine]
660
        add     eax, [BytesPerScanLine]
667
        mov     [drbar.line_inc_scr], eax
661
        mov     [drbar.line_inc_scr], eax
668
 
662
 
669
        ; pointer to screen
663
        ; pointer to screen
670
        mov     edx, [drbar.abs_cy]
664
        mov     edx, [drbar.abs_cy]
671
        imul    edx, [BytesPerScanLine]
665
        imul    edx, [BytesPerScanLine]
672
        mov     eax, [drbar.abs_cx]
666
        mov     eax, [drbar.abs_cx]
673
;        movzx   ebx, byte [ScreenBPP]
667
;        movzx   ebx, byte [ScreenBPP]
674
;        shr     ebx, 3
668
;        shr     ebx, 3
675
        imul    eax, ebx
669
        imul    eax, ebx
676
        add     edx, eax
670
        add     edx, eax
677
        add     edx, [LFBAddress]
671
        add     edx, [LFBAddress]
678
 
672
 
679
        ; pointer to pixel map
673
        ; pointer to pixel map
680
        mov     eax, [drbar.abs_cy]
674
        mov     eax, [drbar.abs_cy]
681
        imul    eax, [ScreenWidth]
675
        imul    eax, [ScreenWidth]
682
        add     eax, [drbar.abs_cy]
676
        add     eax, [drbar.abs_cy]
683
        add     eax, [drbar.abs_cx]
677
        add     eax, [drbar.abs_cx]
684
        add     eax, WinMapAddress
678
        add     eax, WinMapAddress
685
        xchg    eax, ebp
679
        xchg    eax, ebp
686
 
680
 
687
        ; get process number
681
        ; get process number
688
        mov     eax, [0x3010]
682
        mov     eax, [0x3010]
689
        mov     bl, [eax+0xE]
683
        mov     bl, [eax+0xE]
690
 
684
 
691
        cmp     byte [ScreenBPP], 24
685
        cmp     byte [ScreenBPP], 24
692
        jne     draw_bar_end_32
686
        jne     draw_bar_end_32
693
draw_bar_end_24:
687
draw_bar_end_24:
694
        ;cli ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
688
        ;cli ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
695
        mov     eax, [drbar.color]    ;; BBGGRR00
689
        mov     eax, [drbar.color]    ;; BBGGRR00
696
        mov     bh, al                ;; bh  = BB
690
        mov     bh, al                ;; bh  = BB
697
        shr     eax, 8                ;; eax = RRGG
691
        shr     eax, 8                ;; eax = RRGG
698
; eax - color high   RRGG
692
; eax - color high   RRGG
699
; bl - process num
693
; bl - process num
700
; bh - color low    BB
694
; bh - color low    BB
701
; ecx - temp
695
; ecx - temp
702
; edx - pointer to screen
696
; edx - pointer to screen
703
; esi - counter
697
; esi - counter
704
; edi - counter
698
; edi - counter
705
 
699
 
706
        mov     esi, [drbar.real_sy]
700
        mov     esi, [drbar.real_sy]
707
        align   4
701
        align   4
708
     .new_y:
702
     .new_y:
709
        mov     edi, [drbar.real_sx]
703
        mov     edi, [drbar.real_sx]
710
        align   4
704
        align   4
711
     .new_x:
705
     .new_x:
712
 
706
 
713
        cmp     byte [ebp], bl
707
        cmp     byte [ebp], bl
714
        jne     .skip
708
        jne     .skip
715
        mov     [edx], bh
709
        mov     [edx], bh
716
        mov     [edx + 1], ax
710
        mov     [edx + 1], ax
717
      .skip:
711
      .skip:
718
 
712
 
719
        ; add pixel
713
        ; add pixel
720
        add     edx, 3
714
        add     edx, 3
721
        inc     ebp
715
        inc     ebp
722
 
716
 
723
        dec     edi
717
        dec     edi
724
        jnz     .new_x
718
        jnz     .new_x
725
 
719
 
726
        ; add line
720
        ; add line
727
        add     edx, [drbar.line_inc_scr]
721
        add     edx, [drbar.line_inc_scr]
728
        add     ebp, [drbar.line_inc_map]
722
        add     ebp, [drbar.line_inc_map]
729
 
723
 
730
    ;  drawing gradient bars
724
    ;  drawing gradient bars
731
        test    eax, 0x00800000
725
        test    eax, 0x00800000
732
        jz      @f
726
        jz      @f
733
        test    bh, bh
727
        test    bh, bh
734
        jz      @f
728
        jz      @f
735
        dec     bh
729
        dec     bh
736
      @@:
730
      @@:
737
    ; 
731
    ; 
738
 
732
 
739
        dec     esi
733
        dec     esi
740
        jnz     .new_y
734
        jnz     .new_y
741
 
735
 
742
        add     esp, drbar.stack_data
736
        add     esp, drbar.stack_data
743
        popad
737
        popad
744
        xor     eax, eax
738
        xor     eax, eax
745
        ;sti ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
739
        ;sti ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
746
ret
740
ret
747
 
741
 
748
draw_bar_end_32:
742
draw_bar_end_32:
749
        mov     eax, [drbar.color]    ;; BBGGRR00
743
        mov     eax, [drbar.color]    ;; BBGGRR00
750
 
744
 
751
        mov     esi, [drbar.real_sy]
745
        mov     esi, [drbar.real_sy]
752
        align   4
746
        align   4
753
     .new_y:
747
     .new_y:
754
        mov     edi, [drbar.real_sx]
748
        mov     edi, [drbar.real_sx]
755
        align   4
749
        align   4
756
     .new_x:
750
     .new_x:
757
 
751
 
758
        cmp     byte [ebp], bl
752
        cmp     byte [ebp], bl
759
        jne     .skip
753
        jne     .skip
760
        mov     [edx], eax
754
        mov     [edx], eax
761
      .skip:
755
      .skip:
762
 
756
 
763
        ; add pixel
757
        ; add pixel
764
        add     edx, 4
758
        add     edx, 4
765
        inc     ebp
759
        inc     ebp
766
 
760
 
767
        dec     edi
761
        dec     edi
768
        jnz     .new_x
762
        jnz     .new_x
769
 
763
 
770
        ; add line
764
        ; add line
771
        add     edx, [drbar.line_inc_scr]
765
        add     edx, [drbar.line_inc_scr]
772
        add     ebp, [drbar.line_inc_map]
766
        add     ebp, [drbar.line_inc_map]
773
 
767
 
774
    ;  drawing gradient bars
768
    ;  drawing gradient bars
775
        test    eax, 0x80000000
769
        test    eax, 0x80000000
776
        jz      @f
770
        jz      @f
777
        test    al, al
771
        test    al, al
778
        jz      @f
772
        jz      @f
779
        dec     al
773
        dec     al
780
      @@:
774
      @@:
781
    ; 
775
    ; 
782
 
776
 
783
        dec     esi
777
        dec     esi
784
        jnz     .new_y
778
        jnz     .new_y
785
 
779
 
786
        add     esp, drbar.stack_data
780
        add     esp, drbar.stack_data
787
        popad
781
        popad
788
        xor     eax, eax
782
        xor     eax, eax
789
 
783
 
790
ret
784
ret
791
 
785
 
792
 
786
 
793
;voodoodbcplimit:
787
;voodoodbcplimit:
794
 
788
 
795
; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
789
; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
796
 
790
 
797
 
791
 
798
;     pusha
792
;     pusha
799
 
793
 
800
;     xor edx,edx
794
;     xor edx,edx
801
;     mov eax,ebp
795
;     mov eax,ebp
802
;     mov ebx,[ScreenWidth] ; Screen_X_size
796
;     mov ebx,[ScreenWidth] ; Screen_X_size
803
;     inc ebx   ; +1
797
;     inc ebx   ; +1
804
;     sub eax,WinMapAddress ; -AddrBuffer
798
;     sub eax,WinMapAddress ; -AddrBuffer
805
;     div ebx ;
799
;     div ebx ;
806
;     mov ebx,eax ; ebx:=Y
800
;     mov ebx,eax ; ebx:=Y
807
;     mov eax,edx ; eax:=X
801
;     mov eax,edx ; eax:=X
808
;     call cplimit
802
;     call cplimit
809
 
803
 
810
;     test ecx,ecx
804
;     test ecx,ecx
811
;     jne  dbcpl12
805
;     jne  dbcpl12
812
;     popa
806
;     popa
813
;     clc
807
;     clc
814
;     ret
808
;     ret
815
;   dbcpl12:
809
;   dbcpl12:
816
;     popa
810
;     popa
817
;     stc
811
;     stc
818
;     ret
812
;     ret
819
 
813
 
820
 
814
 
821
 
815
 
822
 
816
 
823
;dbcplimit:
817
;dbcplimit:
824
 
818
 
825
;        pusha
819
;        pusha
826
 
820
 
827
;        xor  edx,edx
821
;        xor  edx,edx
828
;        mov  ebx,[ScreenWidth]
822
;        mov  ebx,[ScreenWidth]
829
;        inc  ebx
823
;        inc  ebx
830
;        sub  eax,WinMapAddress
824
;        sub  eax,WinMapAddress
831
;        div  ebx
825
;        div  ebx
832
;        mov  ebx,eax
826
;        mov  ebx,eax
833
;        mov  eax,edx
827
;        mov  eax,edx
834
;        call cplimit
828
;        call cplimit
835
 
829
 
836
;        test ecx,ecx
830
;        test ecx,ecx
837
;        jne  dbcpl1
831
;        jne  dbcpl1
838
;        popa
832
;        popa
839
;        clc
833
;        clc
840
;        ret
834
;        ret
841
;     dbcpl1:
835
;     dbcpl1:
842
;        popa
836
;        popa
843
;        stc
837
;        stc
844
;        ret
838
;        ret
845
 
839
 
846
 
840
 
847
 
841
 
848
 
842
 
849
 
843
 
850
 
844
 
851
;--------------vbe voodoo ------------------------------------------------
845
;--------------vbe voodoo ------------------------------------------------
852
vesa20_drawbackground_tiled:
846
vesa20_drawbackground_tiled:
853
 
847
 
854
     call [disable_mouse]
848
     call [disable_mouse]
855
 
849
 
856
     push ebp
850
     push ebp
857
     push eax
851
     push eax
858
     push ebx
852
     push ebx
859
     push ecx
853
     push ecx
860
     push edx
854
     push edx
861
 
855
 
862
     mov edx,dword [WinMapAddress-8] ; B
856
     mov edx,dword [WinMapAddress-8] ; B
863
     add edx,dword [WinMapAddress-8] ; +B
857
     add edx,dword [WinMapAddress-8] ; +B
864
     add edx,dword [WinMapAddress-8] ; +B
858
     add edx,dword [WinMapAddress-8] ; +B
865
     push edx
859
     push edx
866
 
860
 
867
     mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
861
     mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
868
     mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
862
     mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
869
 
863
 
870
     mov eax,[BytesPerScanLine]
864
     mov eax,[BytesPerScanLine]
871
     mul ebx
865
     mul ebx
872
     xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
866
     xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
873
     add ebp, eax   ; +X
867
     add ebp, eax   ; +X
874
     add ebp, eax   ; +X
868
     add ebp, eax   ; +X
875
     add ebp, eax   ; +X
869
     add ebp, eax   ; +X
876
 
870
 
877
     cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
871
     cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
878
     jz @f
872
     jz @f
879
     add ebp,eax ; +X
873
     add ebp,eax ; +X
880
   @@:
874
   @@:
881
     add ebp,[LFBAddress]  ; +LFB
875
     add ebp,[LFBAddress]  ; +LFB
882
 
876
 
883
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
877
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
884
 
878
 
885
     call calculate_edi
879
     call calculate_edi
886
 
880
 
887
 
881
 
888
   dp3:                             ; MAIN LOOP
882
   dp3:                             ; MAIN LOOP
889
 
883
 
890
     cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
884
     cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1)
891
;     je  ybgp
885
;     je  ybgp
892
;
886
;
893
;     jmp nbgp
887
;     jmp nbgp
894
;
888
;
895
;   ybgp:
889
;   ybgp:
896
     jne nbgp
890
     jne nbgp
897
 
891
 
898
     push eax
892
     push eax
899
     push ebx
893
     push ebx
900
 
894
 
901
     mov ecx,dword [WinMapAddress-8]    ; B
895
     mov ecx,dword [WinMapAddress-8]    ; B
902
     xor edx,edx                   ; edx:=0
896
     xor edx,edx                   ; edx:=0
903
     div ecx                       ; Xstart/B
897
     div ecx                       ; Xstart/B
904
 
898
 
905
     ; eax=Int(qn) edx:=Rem
899
     ; eax=Int(qn) edx:=Rem
906
 
900
 
907
     lea esi,[edx+edx*2]           ; esi:=edx*3
901
     lea esi,[edx+edx*2]           ; esi:=edx*3
908
 
902
 
909
     mov ecx,dword [WinMapAddress-4]    ; ecx:=H
903
     mov ecx,dword [WinMapAddress-4]    ; ecx:=H
910
     mov eax,[esp+0]               ; eax:=Ystart
904
     mov eax,[esp+0]               ; eax:=Ystart
911
     xor edx,edx                   ;
905
     xor edx,edx                   ;
912
     div ecx                       ; Ystart/H
906
     div ecx                       ; Ystart/H
913
 
907
 
914
     mov eax,edx                   ; eax:=Rem
908
     mov eax,edx                   ; eax:=Rem
915
     xor edx,edx                   ;
909
     xor edx,edx                   ;
916
     mov ebx,[esp+8]               ; ebx:=B*3
910
     mov ebx,[esp+8]               ; ebx:=B*3
917
     mul ebx                       ;
911
     mul ebx                       ;
918
     add esi,eax                   ;
912
     add esi,eax                   ;
919
     mov eax,[esi+0x300000]
913
     mov eax,[esi+0x300000]
920
     and eax,0xffffff
914
     and eax,0xffffff
921
 
915
 
922
     xchg edi, ebp
916
     xchg edi, ebp
923
     stosw
917
     stosw
924
     shr eax,16
918
     shr eax,16
925
     stosb
919
     stosb
926
     xchg ebp, edi                 ; ebp+=3
920
     xchg ebp, edi                 ; ebp+=3
927
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
921
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
928
     jz @f
922
     jz @f
929
     inc ebp ; +1
923
     inc ebp ; +1
930
   @@:
924
   @@:
931
 
925
 
932
     pop ebx
926
     pop ebx
933
     pop eax
927
     pop eax
934
 
928
 
935
     jmp hook1
929
     jmp hook1
936
 
930
 
937
   nbgp:
931
   nbgp:
938
     add ebp,3                     ; +3
932
     add ebp,3                     ; +3
939
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
933
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
940
     jz  @f
934
     jz  @f
941
     inc ebp ; +1
935
     inc ebp ; +1
942
   @@:
936
   @@:
943
 
937
 
944
   hook1:
938
   hook1:
945
 
939
 
946
     inc edi                       ; ptrBuffer++
940
     inc edi                       ; ptrBuffer++
947
     add esi,3                     ; ptrImage+=3
941
     add esi,3                     ; ptrImage+=3
948
     inc eax
942
     inc eax
949
     cmp eax,[draw_data+32+8]         ; X > xend?
943
     cmp eax,[draw_data+32+8]         ; X > xend?
950
;     jg nodp3
944
;     jg nodp3
951
;     jmp dp3
945
;     jmp dp3
952
;
946
;
953
;   nodp3:
947
;   nodp3:
954
     jle dp3
948
     jle dp3
955
 
949
 
956
     mov ebp,[draw_data+32+0]
950
     mov ebp,[draw_data+32+0]
957
 
951
 
958
     inc ebx
952
     inc ebx
959
 
953
 
960
     mov  eax,[BytesPerScanLine]
954
     mov  eax,[BytesPerScanLine]
961
     mul  ebx
955
     mul  ebx
962
     xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
956
     xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
963
     add  ebp, eax                 ; +X
957
     add  ebp, eax                 ; +X
964
     add  ebp, eax                 ; +X=X*2
958
     add  ebp, eax                 ; +X=X*2
965
     add  ebp, eax                 ; +X=X*3
959
     add  ebp, eax                 ; +X=X*3
966
     cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
960
     cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
967
     jz   @f
961
     jz   @f
968
     add  ebp,eax                  ; +X=X*4
962
     add  ebp,eax                  ; +X=X*4
969
   @@:
963
   @@:
970
     add ebp,[LFBAddress]          ; +LFB
964
     add ebp,[LFBAddress]          ; +LFB
971
 
965
 
972
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
966
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
973
 
967
 
974
     call calculate_edi
968
     call calculate_edi
975
 
969
 
976
     cmp ebx,[draw_data+32+12]
970
     cmp ebx,[draw_data+32+12]
977
;     jg  dp4
971
;     jg  dp4
978
;
972
;
979
;     jmp dp3
973
;     jmp dp3
980
;
974
;
981
;   dp4:
975
;   dp4:
982
     jle dp3
976
     jle dp3
983
 
977
 
984
     add esp,4
978
     add esp,4
985
 
979
 
986
     pop edx
980
     pop edx
987
     pop ecx
981
     pop ecx
988
     pop ebx
982
     pop ebx
989
     pop eax
983
     pop eax
990
     pop ebp
984
     pop ebp
991
 
985
 
992
     ret
986
     ret
993
 
987
 
994
; ----------
988
; ----------
995
 
989
 
996
 
990
 
997
vesa20_drawbackground_stretch:
991
vesa20_drawbackground_stretch:
998
 
992
 
999
     call  [disable_mouse]
993
     call  [disable_mouse]
1000
 
994
 
1001
     push ebp
995
     push ebp
1002
     push eax
996
     push eax
1003
     push ebx
997
     push ebx
1004
     push ecx
998
     push ecx
1005
     push edx
999
     push edx
1006
 
1000
 
1007
     mov edx,dword [WinMapAddress-8] ; B
1001
     mov edx,dword [WinMapAddress-8] ; B
1008
     add edx,dword [WinMapAddress-8] ; +B
1002
     add edx,dword [WinMapAddress-8] ; +B
1009
     add edx,dword [WinMapAddress-8] ; +B
1003
     add edx,dword [WinMapAddress-8] ; +B
1010
     push edx
1004
     push edx
1011
 
1005
 
1012
     mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
1006
     mov ebp,[draw_data+32+0] ; x start:=(x+Xwin)
1013
     mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
1007
     mov ebx,[draw_data+32+4] ; y start:=(y+Ywin)
1014
 
1008
 
1015
     mov eax,[BytesPerScanLine]
1009
     mov eax,[BytesPerScanLine]
1016
     mul ebx
1010
     mul ebx
1017
     xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
1011
     xchg ebp, eax  ; BytesPerScanLine*(Ywin+y)
1018
     add ebp, eax   ; +X
1012
     add ebp, eax   ; +X
1019
     add ebp, eax   ; +X
1013
     add ebp, eax   ; +X
1020
     add ebp, eax   ; +X
1014
     add ebp, eax   ; +X
1021
 
1015
 
1022
     cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
1016
     cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
1023
     jz  @f
1017
     jz  @f
1024
     add ebp,eax ; +X
1018
     add ebp,eax ; +X
1025
   @@:
1019
   @@:
1026
     add ebp,[LFBAddress] ; +LFB
1020
     add ebp,[LFBAddress] ; +LFB
1027
 
1021
 
1028
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1022
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1029
 
1023
 
1030
     call calculate_edi
1024
     call calculate_edi
1031
 
1025
 
1032
 
1026
 
1033
   sdp3:                            ; MAIN LOOP
1027
   sdp3:                            ; MAIN LOOP
1034
 
1028
 
1035
     cmp [edi+WinMapAddress],byte 1     ; ptrBuffer^<>byte(1)
1029
     cmp [edi+WinMapAddress],byte 1     ; ptrBuffer^<>byte(1)
1036
     jne snbgp
1030
     jne snbgp
1037
 
1031
 
1038
     push eax
1032
     push eax
1039
     push ebx
1033
     push ebx
1040
 
1034
 
1041
     mov   eax,dword [WinMapAddress-8]
1035
     mov   eax,dword [WinMapAddress-8]
1042
     imul  eax, [esp+4]      ;4
1036
     imul  eax, [esp+4]      ;4
1043
     xor   edx,edx
1037
     xor   edx,edx
1044
     mov   ebx,[ScreenWidth]
1038
     mov   ebx,[ScreenWidth]
1045
     div   ebx
1039
     div   ebx
1046
     lea   esi,[eax+eax*2]
1040
     lea   esi,[eax+eax*2]
1047
     mov   eax,dword [WinMapAddress-4]
1041
     mov   eax,dword [WinMapAddress-4]
1048
     imul  eax, [esp+0]      ;0
1042
     imul  eax, [esp+0]      ;0
1049
     xor   edx,edx
1043
     xor   edx,edx
1050
     mov   ebx,[ScreenHeight]
1044
     mov   ebx,[ScreenHeight]
1051
     div   ebx
1045
     div   ebx
1052
     imul  eax, [esp+8]      ;8
1046
     imul  eax, [esp+8]      ;8
1053
     add   esi,eax
1047
     add   esi,eax
1054
 
1048
 
1055
     mov   eax,[esi+0x300000]
1049
     mov   eax,[esi+0x300000]
1056
     and   eax,0xffffff
1050
     and   eax,0xffffff
1057
 
1051
 
1058
     xchg edi, ebp
1052
     xchg edi, ebp
1059
     stosw
1053
     stosw
1060
     shr eax,16
1054
     shr eax,16
1061
     stosb
1055
     stosb
1062
     xchg ebp, edi                 ; ebp+=3
1056
     xchg ebp, edi                 ; ebp+=3
1063
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
1057
     cmp [ScreenBPP],byte 24       ; 24 or 32 bpp ? - x size
1064
     jz  @f
1058
     jz  @f
1065
     inc ebp ; +1
1059
     inc ebp ; +1
1066
   @@:
1060
   @@:
1067
 
1061
 
1068
     pop ebx
1062
     pop ebx
1069
     pop eax
1063
     pop eax
1070
 
1064
 
1071
     jmp shook1
1065
     jmp shook1
1072
 
1066
 
1073
   snbgp:
1067
   snbgp:
1074
     add  ebp,3                     ; +3
1068
     add  ebp,3                     ; +3
1075
     cmp [ScreenBPP],byte 24        ; 24 or 32 bpp ? - x size
1069
     cmp [ScreenBPP],byte 24        ; 24 or 32 bpp ? - x size
1076
     jz  @f
1070
     jz  @f
1077
     inc ebp ; +1
1071
     inc ebp ; +1
1078
   @@:
1072
   @@:
1079
 
1073
 
1080
   shook1:
1074
   shook1:
1081
 
1075
 
1082
     inc edi                       ; ptrBuffer++
1076
     inc edi                       ; ptrBuffer++
1083
     add esi,3                     ; ptrImage+=3
1077
     add esi,3                     ; ptrImage+=3
1084
     inc eax
1078
     inc eax
1085
     cmp eax,[draw_data+32+8]         ; X > xend?
1079
     cmp eax,[draw_data+32+8]         ; X > xend?
1086
     jle sdp3
1080
     jle sdp3
1087
 
1081
 
1088
     mov ebp,[draw_data+32+0]
1082
     mov ebp,[draw_data+32+0]
1089
 
1083
 
1090
     inc ebx
1084
     inc ebx
1091
 
1085
 
1092
     mov  eax,[BytesPerScanLine]
1086
     mov  eax,[BytesPerScanLine]
1093
     mul  ebx
1087
     mul  ebx
1094
     xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
1088
     xchg ebp, eax                 ; BytesPerScanLine*(Ywin+y)
1095
     add  ebp, eax                 ; +X
1089
     add  ebp, eax                 ; +X
1096
     add  ebp, eax                 ; +X=X*2
1090
     add  ebp, eax                 ; +X=X*2
1097
     add  ebp, eax                 ; +X=X*3
1091
     add  ebp, eax                 ; +X=X*3
1098
     cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
1092
     cmp  [ScreenBPP],byte 24      ; 24 or 32 bpp ? - x size
1099
     jz   @f
1093
     jz   @f
1100
     add  ebp,eax                  ; +X=X*4
1094
     add  ebp,eax                  ; +X=X*4
1101
   @@:
1095
   @@:
1102
     add ebp,[LFBAddress]          ; +LFB
1096
     add ebp,[LFBAddress]          ; +LFB
1103
 
1097
 
1104
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1098
     ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
1105
 
1099
 
1106
     call calculate_edi
1100
     call calculate_edi
1107
 
1101
 
1108
     cmp ebx,[draw_data+32+12]
1102
     cmp ebx,[draw_data+32+12]
1109
     jle sdp3
1103
     jle sdp3
1110
 
1104
 
1111
     add esp,4
1105
     add esp,4
1112
 
1106
 
1113
     pop edx
1107
     pop edx
1114
     pop ecx
1108
     pop ecx
1115
     pop ebx
1109
     pop ebx
1116
     pop eax
1110
     pop eax
1117
     pop ebp
1111
     pop ebp
1118
 
1112
 
1119
     ret
1113
     ret