Subversion Repositories Kolibri OS

Rev

Rev 881 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 881 Rev 9587
1
REQ_DLL_VER      =  1
1
REQ_DLL_VER      =  1
2
DLL_ENTRY        =  1
2
DLL_ENTRY        =  1
3
 
3
 
4
HS_HORIZONTAL    =  0
4
HS_HORIZONTAL    =  0
5
HS_VERTICAL      =  1
5
HS_VERTICAL      =  1
6
HS_FDIAGONAL     =  2
6
HS_FDIAGONAL     =  2
7
HS_BDIAGONAL     =  3
7
HS_BDIAGONAL     =  3
8
HS_CROSS         =  4
8
HS_CROSS         =  4
9
HS_DIAGCROSS     =  5
9
HS_DIAGCROSS     =  5
10
 
10
 
11
SCR_PIXMAP       = -1
11
SCR_PIXMAP       = -1
12
 
12
 
13
PX_MEM_SYSTEM    =  0
13
PX_MEM_SYSTEM    =  0
14
PX_MEM_LOCAL     =  1
14
PX_MEM_LOCAL     =  1
15
PX_MEM_GART      =  2
15
PX_MEM_GART      =  2
16
 
16
 
17
PX_MEM_MASK      =  3
17
PX_MEM_MASK      =  3
18
 
18
 
19
ARGB32           = ((32 shl 24) or (2 shl 16) or 0x8888)
19
ARGB32           = ((32 shl 24) or (2 shl 16) or 0x8888)
20
 
20
 
21
macro CreateHatch hatch, bkcolor, fcolor
21
macro CreateHatch hatch, bkcolor, fcolor
22
{
22
{
23
           pushd fcolor
23
           pushd fcolor
24
           pushd bkcolor
24
           pushd bkcolor
25
           pushd hatch
25
           pushd hatch
26
           call [imp_CreateHatch]
26
           call [imp_CreateHatch]
27
           add esp, 3*4
27
           add esp, 3*4
28
}
28
}
29
 
29
 
30
macro DestroyBrush brush
30
macro DestroyBrush brush
31
{
31
{
32
           pushd brush
32
           pushd brush
33
           call [imp_DestroyBrush]
33
           call [imp_DestroyBrush]
34
           add esp, 4
34
           add esp, 4
35
}
35
}
36
 
36
 
37
macro CreatePixmap width, height, format, flags
37
macro CreatePixmap width, height, format, flags
38
{
38
{
39
           pushd flags
39
           pushd flags
40
           pushd format
40
           pushd format
41
           pushd height
41
           pushd height
42
           pushd width
42
           pushd width
43
           call [imp_CreatePixmap]
43
           call [imp_CreatePixmap]
44
           add esp, 4*4
44
           add esp, 4*4
45
}
45
}
46
 
46
 
47
macro DestroyPixmap pixmap
47
macro DestroyPixmap pixmap
48
{
48
{
49
          pushd pixmap
49
          pushd pixmap
50
          call [imp_DestroyPixmap]
50
          call [imp_DestroyPixmap]
51
          add esp, 4
51
          add esp, 4
52
};
52
};
53
 
53
 
54
macro LockPixmap pixmap
54
macro LockPixmap pixmap
55
{
55
{
56
           pushd pixmap
56
           pushd pixmap
57
           call [imp_LockPixmap]
57
           call [imp_LockPixmap]
58
           add esp, 4
58
           add esp, 4
59
}
59
}
60
 
60
 
61
macro UnlockPixmap pixmap
61
macro UnlockPixmap pixmap
62
{
62
{
63
           pushd pixmap
63
           pushd pixmap
64
           call [imp_UnlockPixmap]
64
           call [imp_UnlockPixmap]
65
           add esp, 4
65
           add esp, 4
66
}
66
}
67
 
67
 
68
macro ClearPixmap pixmap, color
68
macro ClearPixmap pixmap, color
69
{
69
{
70
           pushd color
70
           pushd color
71
           pushd pixmap
71
           pushd pixmap
72
           call [imp_ClearPixmap]
72
           call [imp_ClearPixmap]
73
           add esp, 2*4
73
           add esp, 2*4
74
}
74
}
75
 
75
 
76
macro Line pixmap, x0,y0,x1,y1,color
76
macro Line pixmap, x0,y0,x1,y1,color
77
{
77
{
78
           pushd color
78
           pushd color
79
           pushd y1
79
           pushd y1
80
           pushd x1
80
           pushd x1
81
           pushd y0
81
           pushd y0
82
           pushd x0
82
           pushd x0
83
           pushd pixmap
83
           pushd pixmap
84
           call [imp_Line]
84
           call [imp_Line]
85
           add esp, 6*4
85
           add esp, 6*4
86
};
86
};
87
 
87
 
88
macro DrawRect pixmap,x,y,w,h,color,border
88
macro DrawRect pixmap,x,y,w,h,color,border
89
{
89
{
90
           pushd border
90
           pushd border
91
           pushd color
91
           pushd color
92
           pushd h
92
           pushd h
93
           pushd w
93
           pushd w
94
           pushd y
94
           pushd y
95
           pushd x
95
           pushd x
96
           pushd pixmap
96
           pushd pixmap
97
           call [imp_DrawRect]
97
           call [imp_DrawRect]
98
           add esp, 7*4
98
           add esp, 7*4
99
}
99
}
100
 
100
 
101
macro FillRect pixmap,x,y,w,h,brush,border
101
macro FillRect pixmap,x,y,w,h,brush,border
102
{
102
{
103
           pushd border
103
           pushd border
104
           pushd brush
104
           pushd brush
105
           pushd h
105
           pushd h
106
           pushd w
106
           pushd w
107
           pushd y
107
           pushd y
108
           pushd x
108
           pushd x
109
           pushd pixmap
109
           pushd pixmap
110
           call [imp_FillRect]
110
           call [imp_FillRect]
111
           add esp, 7*4
111
           add esp, 7*4
112
}
112
}
113
 
113
 
114
macro Blit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h
114
macro Blit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h
115
{
115
{
116
           pushd h
116
           pushd h
117
           pushd w
117
           pushd w
118
           pushd srcy
118
           pushd srcy
119
           pushd srcx
119
           pushd srcx
120
           pushd srcpix
120
           pushd srcpix
121
           pushd dsty
121
           pushd dsty
122
           pushd dstx
122
           pushd dstx
123
           pushd dstpix
123
           pushd dstpix
124
           call [imp_Blit]
124
           call [imp_Blit]
125
           add esp, 8*4
125
           add esp, 8*4
126
}
126
}
127
 
127
 
128
macro TransparentBlit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h, key
128
macro TransparentBlit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h, key
129
{
129
{
130
           pushd key
130
           pushd key
131
           pushd h
131
           pushd h
132
           pushd w
132
           pushd w
133
           pushd srcy
133
           pushd srcy
134
           pushd srcx
134
           pushd srcx
135
           pushd srcpix
135
           pushd srcpix
136
           pushd dsty
136
           pushd dsty
137
           pushd dstx
137
           pushd dstx
138
           pushd dstpix
138
           pushd dstpix
139
           call [imp_TransparentBlit]
139
           call [imp_TransparentBlit]
140
           add esp, 9*4
140
           add esp, 9*4
141
}
141
}
142
 
142
 
143
macro fix_cwd  path
143
macro fix_cwd  path
144
{
144
{
145
          pushd path
145
          pushd path
146
 
146
 
147
          push '/'
147
          push '/'
148
          push path
148
          push path
149
          call _strrchr
149
          call _strrchr
150
 
150
 
151
          mov byte [eax], 0
151
          mov byte [eax], 0
152
 
152
 
153
          mov eax, 30
153
          mov eax, 30
154
          mov ebx, 1
154
          mov ebx, 1
155
          mov ecx, [esp+8]
155
          mov ecx, [esp+8]
156
          int 0x40
156
          int 0x40
157
 
157
 
158
          add esp, 12
158
          add esp, 12
159
}
159
}
160
 
160
 
161
szPxlib              db  '/rd/1/lib/pixlib.obj',0
161
szPxlib              db  '/sys/lib/pixlib.obj',0
162
 
162
 
163
szStart              db  'START',0
163
szStart              db  'START',0
164
szVersion            db  'version',0
164
szVersion            db  'version',0
165
 
165
 
166
szCreatePixmap       db  'CreatePixmap',0
166
szCreatePixmap       db  'CreatePixmap',0
167
szDestroyPixmap      db  'DestroyPixmap',0
167
szDestroyPixmap      db  'DestroyPixmap',0
168
szLockPixmap         db  'LockPixmap',0
168
szLockPixmap         db  'LockPixmap',0
169
szUnlockPixmap       db  'UnlockPixmap',0
169
szUnlockPixmap       db  'UnlockPixmap',0
170
szGetPixmapPitch     db  'GetPixmapPitch',0
170
szGetPixmapPitch     db  'GetPixmapPitch',0
171
 
171
 
172
szCreateHatch        db  'CreateHatch',0
172
szCreateHatch        db  'CreateHatch',0
173
szCreateMonoBrush    db  'CreateMonoBrush',0
173
szCreateMonoBrush    db  'CreateMonoBrush',0
174
szDestroyBrush       db  'DestroyBrush',0
174
szDestroyBrush       db  'DestroyBrush',0
175
 
175
 
176
szClearPixmap        db  'ClearPixmap',0
176
szClearPixmap        db  'ClearPixmap',0
177
szLine               db  'Line',0
177
szLine               db  'Line',0
178
szDrawRect           db  'DrawRect',0
178
szDrawRect           db  'DrawRect',0
179
szFillRect           db  'FillRect',0
179
szFillRect           db  'FillRect',0
180
szBlit               db  'Blit',0
180
szBlit               db  'Blit',0
181
szTransparentBlit    db  'TransparentBlit',0
181
szTransparentBlit    db  'TransparentBlit',0
182
 
182
 
183
align 4
183
align 4
184
 
184
 
185
px_import:
185
px_import:
186
 
186
 
187
imp_start            dd  szStart
187
imp_start            dd  szStart
188
imp_ver              dd  szVersion
188
imp_ver              dd  szVersion
189
 
189
 
190
imp_CreatePixmap     dd  szCreatePixmap
190
imp_CreatePixmap     dd  szCreatePixmap
191
imp_DestroyPixmap    dd  szDestroyPixmap
191
imp_DestroyPixmap    dd  szDestroyPixmap
192
imp_LockPixmap       dd  szLockPixmap
192
imp_LockPixmap       dd  szLockPixmap
193
imp_UnlockPixmap     dd  szUnlockPixmap
193
imp_UnlockPixmap     dd  szUnlockPixmap
194
imp_GetPixmapPitch   dd  szGetPixmapPitch
194
imp_GetPixmapPitch   dd  szGetPixmapPitch
195
 
195
 
196
imp_CreateHatch      dd  szCreateHatch
196
imp_CreateHatch      dd  szCreateHatch
197
imp_CreateMonoBrush  dd  szCreateMonoBrush
197
imp_CreateMonoBrush  dd  szCreateMonoBrush
198
imp_DestroyBrush     dd  szDestroyBrush
198
imp_DestroyBrush     dd  szDestroyBrush
199
 
199
 
200
imp_ClearPixmap      dd  szClearPixmap
200
imp_ClearPixmap      dd  szClearPixmap
201
imp_Line             dd  szLine
201
imp_Line             dd  szLine
202
imp_DrawRect         dd  szDrawRect
202
imp_DrawRect         dd  szDrawRect
203
imp_FillRect         dd  szFillRect
203
imp_FillRect         dd  szFillRect
204
imp_Blit             dd  szBlit
204
imp_Blit             dd  szBlit
205
imp_TransparentBlit  dd  szTransparentBlit
205
imp_TransparentBlit  dd  szTransparentBlit
206
 
206
 
207
                     dd  0
207
                     dd  0
208
 
208
 
209
 
209
 
210
;szBlockClip          db  'BlockClip',0
210
;szBlockClip          db  'BlockClip',0
211
;szLineClip           db  'LineClip',0
211
;szLineClip           db  'LineClip',0
212
;imp_BlockClip        dd  szBlockClip
212
;imp_BlockClip        dd  szBlockClip
213
;imp_LineClip         dd  szLineClip
213
;imp_LineClip         dd  szLineClip
214
 
214
 
215
 
215
 
216
align 4
216
align 4
217
 
217
 
218
load_pxlib:
218
load_pxlib:
219
           mov  eax, 68
219
           mov  eax, 68
220
           mov  ebx, 19
220
           mov  ebx, 19
221
           mov  ecx, szPxlib
221
           mov  ecx, szPxlib
222
           int  0x40
222
           int  0x40
223
           test eax, eax
223
           test eax, eax
224
           jz   .fail
224
           jz   .fail
225
 
225
 
226
           mov  edx, eax
226
           mov  edx, eax
227
           mov  esi, px_import
227
           mov  esi, px_import
228
.import_loop:
228
.import_loop:
229
           lodsd
229
           lodsd
230
           test eax, eax
230
           test eax, eax
231
           jz   .import_done
231
           jz   .import_done
232
           push edx
232
           push edx
233
.import_find:
233
.import_find:
234
           mov ebx, [edx]
234
           mov ebx, [edx]
235
           test ebx, ebx
235
           test ebx, ebx
236
           jz .fail         ;import_not_found
236
           jz .fail         ;import_not_found
237
 
237
 
238
           push eax
238
           push eax
239
@@:
239
@@:
240
           mov cl, [eax]
240
           mov cl, [eax]
241
           cmp cl, [ebx]
241
           cmp cl, [ebx]
242
           jnz .import_find_next
242
           jnz .import_find_next
243
 
243
 
244
           test cl, cl
244
           test cl, cl
245
           jz .import_found
245
           jz .import_found
246
 
246
 
247
           inc eax
247
           inc eax
248
           inc ebx
248
           inc ebx
249
           jmp @b
249
           jmp @b
250
.import_find_next:
250
.import_find_next:
251
           pop eax
251
           pop eax
252
           add edx, 8
252
           add edx, 8
253
           jmp .import_find
253
           jmp .import_find
254
.import_found:
254
.import_found:
255
           pop eax
255
           pop eax
256
           mov eax, [edx+4]
256
           mov eax, [edx+4]
257
           mov [esi-4], eax
257
           mov [esi-4], eax
258
           pop edx
258
           pop edx
259
           jmp .import_loop
259
           jmp .import_loop
260
.import_done:
260
.import_done:
261
 
261
 
262
           cmp word [imp_ver], REQ_DLL_VER
262
           cmp word [imp_ver], REQ_DLL_VER
263
           jb .fail
263
           jb .fail
264
           cmp word [imp_ver+2], REQ_DLL_VER
264
           cmp word [imp_ver+2], REQ_DLL_VER
265
           ja .fail
265
           ja .fail
266
 
266
 
267
           push DLL_ENTRY
267
           push DLL_ENTRY
268
           call [imp_start]
268
           call [imp_start]
269
           test eax, eax
269
           test eax, eax
270
           jz .fail
270
           jz .fail
271
 
271
 
272
           ret
272
           ret
273
.fail:
273
.fail:
274
           xor eax, eax
274
           xor eax, eax
275
           ret
275
           ret
276
 
276
 
277
align 4
277
align 4
278
_strrchr:
278
_strrchr:
279
	push	ebp
279
	push	ebp
280
	mov	ebp, esp
280
	mov	ebp, esp
281
	push	edi
281
	push	edi
282
        mov     edi, [8+ebp]
282
        mov     edi, [8+ebp]
283
        mov     ecx, -1
283
        mov     ecx, -1
284
        xor     al, al
284
        xor     al, al
285
        cld
285
        cld
286
        repne
286
        repne
287
        scasb
287
        scasb
288
        not     ecx
288
        not     ecx
289
        dec     edi
289
        dec     edi
290
        mov     al, [12+ebp]
290
        mov     al, [12+ebp]
291
        std
291
        std
292
        repne
292
        repne
293
        scasb
293
        scasb
294
        cld
294
        cld
295
        jne     .failure
295
        jne     .failure
296
        lea     eax, [edi+1]
296
        lea     eax, [edi+1]
297
        pop     edi
297
        pop     edi
298
        pop     ebp
298
        pop     ebp
299
        ret
299
        ret
300
.failure:
300
.failure:
301
        xor     eax, eax
301
        xor     eax, eax
302
        pop     edi
302
        pop     edi
303
        pop     ebp
303
        pop     ebp
304
        ret
304
        ret