Subversion Repositories Kolibri OS

Rev

Rev 5153 | Rev 6108 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5153 Rev 5171
Line 31... Line 31...
31
	mov eax,[eax+offs_cont_shared_state]
31
	mov eax,[eax+offs_cont_shared_state]
32
	mov ebx,[list]
32
	mov ebx,[list]
33
	shl ebx,2
33
	shl ebx,2
34
	add eax,ebx
34
	add eax,ebx
35
	mov eax,[eax]
35
	mov eax,[eax]
-
 
36
if DEBUG ;find_list
-
 
37
push edi
-
 
38
	mov ecx,80
-
 
39
	lea edi,[buf_param]
-
 
40
	stdcall convert_int_to_str,ecx
-
 
41
 
-
 
42
	stdcall str_n_cat,edi,txt_nl,2
-
 
43
	stdcall dbg_print,f_find_l,buf_param
-
 
44
pop edi
-
 
45
end if
36
	ret
46
	ret
37
endp
47
endp
Line 38... Line -...
38
 
-
 
39
;static void delete_list(GLContext *c,int list)
48
 
40
;{
49
align 4
41
;  GLParamBuffer *pb,*pb1;
50
proc delete_list uses eax ebx ecx edx, context:dword, list:dword
42
;  GLList *l;
-
 
43
 
51
	mov ebx,[context]
-
 
52
	stdcall find_list,ebx,[list]
44
;  l=find_list(c,list);
53
	mov edx,eax
Line 45... Line 54...
45
;  assert(l != NULL);
54
;  assert(l != NULL);
46
 
55
 
47
;  /* free param buffer */
-
 
48
;  pb=l->first_op_buffer;
-
 
49
;  while (pb!=NULL) {
-
 
50
;    pb1=pb->next;
-
 
51
;    gl_free(pb);
56
	; free param buffer
52
;    pb=pb1;
57
	mov eax,[edx] ;eax = GLList.first_op_buffer
53
;  }
58
	@@:
54
 
59
	cmp eax,0
55
;  gl_free(l);
-
 
56
;  c->shared_state.lists[list]=NULL;
-
 
57
;}
60
	je .end_w
58
 
-
 
59
;static GLList *alloc_list(GLContext *c,int list)
61
		mov ecx,[eax+offs_gpbu_next]
60
;{
62
		stdcall gl_free,eax
61
;  GLList *l;
63
		mov eax,ecx
62
;  GLParamBuffer *ob;
-
 
63
 
-
 
Line -... Line 64...
-
 
64
		jmp @b
64
;  l=gl_zalloc(sizeof(GLList));
65
	.end_w:
-
 
66
 
-
 
67
	stdcall gl_free,edx
-
 
68
	mov ecx,[list]
65
;  ob=gl_zalloc(sizeof(GLParamBuffer));
69
	shl ecx,2
-
 
70
	mov ebx,[ebx+offs_cont_shared_state] ;ebx = &context.shared_state.lists
-
 
71
	add ebx,ecx
Line -... Line 72...
-
 
72
	mov dword[ebx],0 ;=NULL
-
 
73
	ret
-
 
74
endp
-
 
75
 
-
 
76
align 4
-
 
77
proc alloc_list uses ebx ecx, context:dword, list:dword
-
 
78
	stdcall gl_zalloc,sizeof.GLParamBuffer
-
 
79
	mov ecx,eax
-
 
80
	stdcall gl_zalloc,sizeof.GLList
-
 
81
 
-
 
82
	mov dword[ecx+offs_gpbu_next],0 ;ob.next=NULL
-
 
83
	mov dword[eax],ecx ;l.first_op_buffer=ob
-
 
84
 
-
 
85
	mov dword[ecx+offs_gpbu_ops],OP_EndList ;ob.ops[0].op=OP_EndList
-
 
86
 
-
 
87
	mov ebx,[context]
-
 
88
	mov ebx,[ebx+offs_cont_shared_state]
66
 
89
	mov ecx,[list]
-
 
90
	shl ecx,2
-
 
91
	add ebx,ecx
-
 
92
	mov [ebx],eax ;context.shared_state.lists[list]=l
-
 
93
if DEBUG ;alloc_list
Line 67... Line 94...
67
;  ob->next=NULL;
94
push edi
-
 
95
	mov ecx,80
-
 
96
	lea edi,[buf_param]
-
 
97
	stdcall convert_int_to_str,ecx
68
;  l->first_op_buffer=ob;
98
 
69
 
99
	stdcall str_n_cat,edi,txt_nl,2
Line 70... Line 100...
70
;  ob->ops[0].op=OP_EndList;
100
	stdcall dbg_print,f_alloc_l,buf_param
71
 
101
pop edi
72
;  c->shared_state.lists[list]=l;
102
end if
73
;  return l;
103
	ret
Line 100... Line 130...
100
;  }
130
;  }
101
;  fprintf(f,"\n");
131
;  fprintf(f,"\n");
102
;}
132
;}
Line 103... Line 133...
103
 
133
 
104
align 4
134
align 4
-
 
135
proc gl_compile_op, context:dword, p:dword
105
proc gl_compile_op uses eax ebx, context:dword, p:dword
136
pushad
-
 
137
	mov edx,[context]
106
	mov eax,[context]
138
 
-
 
139
	lea ebx,[op_table_size]
-
 
140
	mov ecx,[p]
-
 
141
	mov ecx,[ecx]
-
 
142
	shl ecx,2
-
 
143
	add ecx,ebx
-
 
144
	mov ecx,[ecx] ;ecx = кол-во параметров в компилируемой функции
-
 
145
	mov ebx,[edx+offs_cont_current_op_buffer_index]
-
 
146
	mov eax,[edx+offs_cont_current_op_buffer]
107
;  int op,op_size;
147
 
-
 
148
	; we should be able to add a NextBuffer opcode
-
 
149
	mov esi,ebx
-
 
150
	add esi,ecx
-
 
151
	cmp esi,(OP_BUFFER_MAX_SIZE-2)
-
 
152
	jle @f
-
 
153
		mov edi,eax
-
 
154
		stdcall gl_zalloc,sizeof.GLParamBuffer
-
 
155
		mov dword[eax+offs_gpbu_next],0 ;=NULL
-
 
156
 
-
 
157
		mov dword[edi+offs_gpbu_next],eax
-
 
158
		mov esi,ebx
108
;  GLParamBuffer *ob,*ob1;
159
		shl esi,2
-
 
160
		add esi,edi
-
 
161
		mov dword[esi+offs_gpbu_ops],OP_NextBuffer
Line 109... Line -...
109
;  int index,i;
-
 
110
 
-
 
111
;  op=p[0].op;
162
		mov dword[esi+offs_gpbu_ops+4],eax
112
;  op_size=op_table_size[op];
-
 
113
;  index=c->current_op_buffer_index;
-
 
114
;  ob=c->current_op_buffer;
-
 
115
 
-
 
116
;  /* we should be able to add a NextBuffer opcode */
-
 
117
;  if ((index + op_size) > (OP_BUFFER_MAX_SIZE-2)) {
-
 
118
 
-
 
119
;    ob1=gl_zalloc(sizeof(GLParamBuffer));
-
 
120
;    ob1->next=NULL;
-
 
121
 
-
 
122
;    ob->next=ob1;
-
 
123
;    ob->ops[index].op=OP_NextBuffer;
-
 
124
;    ob->ops[index+1].p=(void *)ob1;
-
 
125
 
163
 
126
;    c->current_op_buffer=ob1;
-
 
127
;    ob=ob1;
164
		mov dword[edx+offs_cont_current_op_buffer],eax
Line 128... Line 165...
128
;    index=0;
165
		xor ebx,ebx
-
 
166
	@@:
129
;  }
167
 
-
 
168
	mov esi,[p]
130
 
169
	@@:
-
 
170
		mov edi,ebx
-
 
171
		shl edi,2
131
;  for(i=0;i
172
		add edi,eax
132
;    ob->ops[index]=p[i];
173
		movsd
-
 
174
		inc ebx
133
;    index++;
175
	loop @b
134
;  }
176
	mov dword[edx+offs_cont_current_op_buffer_index],ebx
Line 135... Line 177...
135
;  c->current_op_buffer_index=index;
177
popad
136
	ret
178
	ret
137
endp
179
endp
138
 
180
 
139
align 4
181
align 4
140
proc gl_add_op uses eax ebx ecx, p:dword ;GLParam*
182
proc gl_add_op uses eax ebx ecx, p:dword ;GLParam*
141
if DEBUG
183
if DEBUG ;gl_add_op
142
push edi esi
184
push edi esi
Line 207... Line 249...
207
		shl ecx,2
249
		shl ecx,2
208
		lea ebx,[op_table_func]
250
		lea ebx,[op_table_func]
209
		add ecx,ebx
251
		add ecx,ebx
210
		call dword[ecx] ;op_table_func[op](c,p)
252
		call dword[ecx] ;op_table_func[op](c,p)
211
	@@:
253
	@@:
-
 
254
	call gl_get_context
212
	cmp dword[eax+offs_cont_compile_flag],0
255
	cmp dword[eax+offs_cont_compile_flag],0
213
	je @f
256
	je @f
214
		stdcall gl_compile_op,eax,[p]
257
		stdcall gl_compile_op,eax,[p]
215
	@@:
258
	@@:
216
	cmp dword[eax+offs_cont_print_flag],0
259
	cmp dword[eax+offs_cont_print_flag],0
Line 232... Line 275...
232
proc glopNextBuffer, context:dword, p:dword
275
proc glopNextBuffer, context:dword, p:dword
233
;  assert(0);
276
;  assert(0);
234
	ret
277
	ret
235
endp
278
endp
Line -... Line 279...
-
 
279
 
236
 
280
align 4
237
;void glopCallList(GLContext *c,GLParam *p)
-
 
238
;{
281
proc glopCallList uses eax ebx ecx edx edi, context:dword, p:dword
239
;  GLList *l;
282
	mov edx,[context]
Line 240... Line 283...
240
;  int list,op;
283
	mov ebx,[p]
241
 
284
 
-
 
285
	stdcall find_list,edx,[ebx+4]
242
;  list=p[1].ui;
286
	cmp eax,0
-
 
287
	jne @f
243
;  l=find_list(c,list);
288
		;if (eax == NULL) gl_fatal_error("list %d not defined",[ebx+4])
Line -... Line 289...
-
 
289
	@@:
244
;  if (l == NULL) gl_fatal_error("list %d not defined",list);
290
	mov edi,[eax] ;edi = &GLList.first_op_buffer.ops
-
 
291
 
-
 
292
align 4
245
;  p=l->first_op_buffer->ops;
293
	.cycle_0: ;while (1)
-
 
294
if DEBUG ;glopCallList
-
 
295
push ecx edi
-
 
296
	mov eax,[edi]
-
 
297
	mov ecx,80
-
 
298
	lea edi,[buf_param]
-
 
299
	stdcall convert_int_to_str,ecx
-
 
300
 
-
 
301
	stdcall str_n_cat,edi,txt_nl,2
-
 
302
	stdcall dbg_print,txt_op,buf_param
246
 
303
pop edi ecx
-
 
304
end if
247
;  while (1) {
305
	cmp dword[edi],OP_EndList
248
;    op=p[0].op;
306
	je .end_f ;if (op == OP_EndList) break
249
;    if (op == OP_EndList) break;
307
	cmp dword[edi],OP_NextBuffer
-
 
308
	jne .els_0 ;if (op == OP_NextBuffer)
-
 
309
		mov edi,[edi+4] ;p=p[1].p
-
 
310
		jmp .cycle_0
250
;    if (op == OP_NextBuffer) {
311
	.els_0:
-
 
312
		mov ecx,dword[edi] ;ecx = OP_...
-
 
313
		shl ecx,2
-
 
314
		lea ebx,[op_table_func]
-
 
315
		add ecx,ebx
-
 
316
		stdcall dword[ecx],edx,edi ;op_table_func[op](context,p)
251
;      p=(GLParam *)p[1].p;
317
 
-
 
318
		mov ecx,dword[edi] ;ecx = OP_...
-
 
319
		shl ecx,2
-
 
320
		lea ebx,[op_table_size]
-
 
321
		add ecx,ebx
-
 
322
		mov ecx,[ecx]
-
 
323
		shl ecx,2
252
;    } else {
324
		add edi,ecx ;edi += op_table_size[op]
253
;      op_table_func[op](c,p);
325
	jmp .cycle_0
254
;      p+=op_table_size[op];
326
	.end_f:
-
 
327
	ret
-
 
328
endp
-
 
329
 
-
 
330
align 4
Line 255... Line -...
255
;    }
-
 
256
;  }
-
 
257
;}
-
 
258
 
-
 
259
;void glNewList(unsigned int list,int mode)
-
 
260
;{
331
proc glNewList uses eax ebx, list:dword, mode:dword
261
;  GLList *l;
332
	call gl_get_context
262
;  GLContext *c=gl_get_context();
-
 
263
;
-
 
264
;  assert(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE);
-
 
265
;  assert(c->compile_flag == 0);
-
 
266
;
-
 
267
;  l=find_list(c,list);
-
 
268
;  if (l!=NULL) delete_list(c,list);
-
 
269
;  l=alloc_list(c,list);
-
 
270
;
-
 
271
;  c->current_op_buffer=l->first_op_buffer;
-
 
272
;  c->current_op_buffer_index=0;
-
 
Line 273... Line 333...
273
;  
333
	mov ebx,eax
-
 
334
 
274
;  c->compile_flag=1;
335
;  assert(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE);
275
;  c->exec_flag=(mode == GL_COMPILE_AND_EXECUTE);
336
;  assert(ebx->compile_flag == 0);
-
 
337
 
276
;}
338
	stdcall find_list,ebx,[list]
Line -... Line 339...
-
 
339
	cmp eax,0
-
 
340
	je @f
-
 
341
		stdcall delete_list,ebx,[list]
-
 
342
	@@:
277
 
343
	stdcall alloc_list,ebx,[list]
-
 
344
 
-
 
345
	mov eax,[eax] ;eax = GLList.first_op_buffer
-
 
346
	mov [ebx+offs_cont_current_op_buffer],eax
-
 
347
	mov dword[ebx+offs_cont_current_op_buffer_index],0
-
 
348
 
-
 
349
	mov dword[ebx+offs_cont_compile_flag],1
-
 
350
	xor eax,eax
-
 
351
	cmp dword[mode],GL_COMPILE_AND_EXECUTE
Line 278... Line 352...
278
;void glEndList(void)
352
	jne @f
279
;{
353
		inc eax ;eax = (mode == GL_COMPILE_AND_EXECUTE)
-
 
354
	@@:
-
 
355
	mov [ebx+offs_cont_exec_flag],eax
-
 
356
	ret
280
;  GLContext *c=gl_get_context();
357
endp
Line 281... Line 358...
281
;  GLParam p[1];
358
 
-
 
359
align 4
282
 
360
proc glEndList uses eax ebx
-
 
361
locals
-
 
362
	p dd ?
-
 
363
endl
-
 
364
	call gl_get_context
283
;  assert(c->compile_flag == 1);
365
 
-
 
366
;  assert(c->compile_flag == 1);
-
 
367
 
-
 
368
	; end of list
-
 
369
	mov dword[p],OP_EndList
-
 
370
	mov ebx,ebp
-
 
371
	sub ebx,4 ;=sizeof(dd)
-
 
372
	stdcall gl_compile_op,eax,ebx
Line 284... Line 373...
284
 
373
 
285
;  /* end of list */
374
	mov dword[eax+offs_cont_compile_flag],0
286
;  p[0].op=OP_EndList;
375
	mov dword[eax+offs_cont_exec_flag],1
287
;  gl_compile_op(c,p);
376
if DEBUG ;glEndList
Line 298... Line 387...
298
	stdcall find_list, eax,[list]
387
	stdcall find_list, eax,[list]
299
	cmp eax,0 ;NULL
388
	cmp eax,0 ;NULL
300
	je @f
389
	je @f
301
		mov eax,1
390
		mov eax,1
302
	@@:
391
	@@:
-
 
392
if DEBUG ;glIsList
-
 
393
push edi
-
 
394
	mov ecx,80
-
 
395
	lea edi,[buf_param]
-
 
396
	stdcall convert_int_to_str,ecx
-
 
397
 
-
 
398
	stdcall str_n_cat,edi,txt_nl,2
-
 
399
	stdcall dbg_print,f_is_l,buf_param
-
 
400
pop edi
-
 
401
end if
303
	ret
402
	ret
304
endp
403
endp
Line 305... Line -...
305
 
-
 
306
;unsigned int glGenLists(int range)
404
 
307
;{
405
align 4
308
;  GLContext *c=gl_get_context();
406
proc glGenLists uses ebx ecx edx edi esi, range:dword
309
;  int count,i,list;
407
	call gl_get_context
310
;  GLList **lists;
408
	mov edi,eax
311
 
409
 
312
;  lists=c->shared_state.lists;
410
	mov ebx,[eax+offs_cont_shared_state] ;ebx=context.shared_state.lists
-
 
411
	xor edx,edx ;count=0
-
 
412
	mov ecx,MAX_DISPLAY_LISTS
313
;  count=0;
413
	xor esi,esi
314
;  for(i=0;i
414
	.cycle_0: ;for(esi=0;esi
315
;    if (lists[i]==NULL) {
415
		cmp dword[ebx],0 ;if (ebx[i]==NULL)
-
 
416
		je .els_0
316
;      count++;
417
			inc edx
-
 
418
			cmp edx,[range] ;if (count == range)
-
 
419
			jne .els_1
-
 
420
			mov ecx,[range]
317
;      if (count == range) {
421
			inc esi
318
;       list=i-range+1;
422
			sub esi,ecx ;esi = (esi-range+1)
319
;       for(i=0;i
423
			.cycle_1: ;for(i=0;i
-
 
424
				stdcall alloc_list,edi,esi
-
 
425
				inc esi
-
 
426
			loop .cycle_1
-
 
427
			mov eax,esi
-
 
428
			jmp .end_f
-
 
429
		.els_0:
-
 
430
			xor edx,edx ;count=0
-
 
431
		.els_1:
320
;         alloc_list(c,list+i);
432
		add ebx,4
-
 
433
		inc esi
-
 
434
	loop .cycle_0
-
 
435
	xor eax,eax
321
;       }
436
	.end_f:
322
;       return list;
437
if DEBUG ;glGenLists
323
;      }
438
push edi
324
;    } else {
439
	mov ecx,80
-
 
440
	lea edi,[buf_param]
-
 
441
	stdcall convert_int_to_str,ecx
-
 
442
 
-
 
443
	stdcall str_n_cat,edi,txt_nl,2
325
;      count=0;
444
	stdcall dbg_print,f_gen_l,buf_param
326
;    }
445
pop edi
327
;  }
446
end if
328
;  return 0;
447
	ret