Subversion Repositories Kolibri OS

Rev

Rev 5218 | Rev 8069 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5153 IgorA 1
;
2
; Z buffer
3
;
4
 
5
include 'zfeatures.inc'
6
 
7
ZB_Z_BITS equ 16
8
 
9
ZB_POINT_Z_FRAC_BITS equ 14
10
 
6243 IgorA 11
ZB_POINT_TEXEL_SIZE equ 12 ;точность множителя для вычисления координат текселя
12
	;влияет на максимальный размер текстуры
5153 IgorA 13
 
5213 IgorA 14
ZB_POINT_RED_MIN equ (1 shl 8)
15
ZB_POINT_RED_MAX equ ( (1 shl 16)-1 )
16
ZB_POINT_GREEN_MIN equ (1 shl 8)
17
ZB_POINT_GREEN_MAX equ ( (1 shl 16)-1 )
18
ZB_POINT_BLUE_MIN equ (1 shl 8)
19
ZB_POINT_BLUE_MAX equ ( (1 shl 16)-1 )
5153 IgorA 20
 
21
; display modes
22
ZB_MODE_5R6G5B equ 1  ; true color 16 bits
23
ZB_MODE_INDEX  equ 2  ; color index 8 bits
24
ZB_MODE_RGBA   equ 3  ; 32 bit rgba mode
25
ZB_MODE_RGB24  equ 4  ; 24 bit rgb mode
26
ZB_NB_COLORS   equ 225 ; number of colors for 8 bit display
27
 
6243 IgorA 28
if TGL_FEATURE_RENDER_BITS eq 24
5153 IgorA 29
 
30
macro RGB_TO_PIXEL r,g,b
31
{
32
	mov eax,b
33
	shr eax,8
34
	push eax
35
		mov eax,g
36
		and eax,0xff00
37
		or dword[esp],eax
38
		mov eax,r
39
		shl eax,8
40
		or dword[esp],eax
41
	pop eax
42
}
43
 
44
;typedef unsigned char PIXEL;
45
PSZB equ 3
46
PSZSH equ 5
47
 
48
else if TGL_FEATURE_RENDER_BITS eq 32
49
 
50
;#define RGB_TO_PIXEL(r,g,b) \
51
;  ((((r) << 8) & 0xff0000) | ((g) & 0xff00) | ((b) >> 8))
52
;typedef unsigned int PIXEL;
53
;PSZB equ 4
54
;PSZSH equ 5
55
 
56
else
57
 
58
;#error Incorrect number of bits per pixel
59
 
60
end if
61
 
62
struct ZBuffer
63
	xsize dd ? ;int
64
	ysize dd ? ;int
65
	linesize dd ? ;int ;line size, in bytes
66
	mode dd ? ;int
67
 
68
	zbuf dd ? ;*unsigned short
69
	pbuf dd ? ;*PIXEL
70
	frame_buffer_allocated dd ? ;int
71
 
72
	nb_colors dd ? ;int
73
	dctable dd ? ;*unsigned char
74
	ctable dd ? ;*int
75
	current_texture dd ? ;*PIXEL
6243 IgorA 76
	s_log2 dd ? ;unsigned int
77
	s_bound dd ? ;unsigned int
78
	t_bound dd ? ;unsigned int
5153 IgorA 79
ends
80
 
81
offs_zbuf_xsize equ 0
82
offs_zbuf_ysize equ 4
83
offs_zbuf_linesize equ 8
84
offs_zbuf_mode equ 16
85
offs_zbuf_zbuf equ 20
86
offs_zbuf_pbuf equ 24
87
offs_zbuf_frame_buffer_allocated equ 28
88
offs_zbuf_nb_colors equ 32
89
offs_zbuf_dctable equ 36
90
offs_zbuf_ctable equ 40
91
offs_zbuf_current_texture equ 44
6243 IgorA 92
offs_zbuf_s_log2 equ 48
93
offs_zbuf_s_bound equ 52
94
offs_zbuf_t_bound equ 56
5153 IgorA 95
 
96
struct ZBufferPoint
97
	x dd ? ;int ;integer coordinates in the zbuffer
98
	y dd ? ;int
99
	z dd ? ;int
100
	s dd ? ;int ;coordinates for the mapping
101
	t dd ? ;int
102
	r dd ? ;int ;color indexes
103
	g dd ? ;int
104
	b dd ? ;int
105
 
106
	fsz dd ? ;float ;temporary coordinates for mapping
107
	tz dd ? ;float
108
ends
109
 
110
offs_zbup_x equ  0
111
offs_zbup_y equ  4
112
offs_zbup_z equ  8
113
offs_zbup_s equ 12
114
offs_zbup_t equ 16
115
offs_zbup_r equ 20
116
offs_zbup_g equ 24
117
offs_zbup_b equ 28
118
offs_zbup_sz equ 32
119
offs_zbup_tz equ 36
120
 
121
; ztriangle.c
122
 
123
;
124
; Memory allocator for TinyGL
125
;
126
 
127
; modify these functions so that they suit your needs
128
 
129
align 4
5218 IgorA 130
proc gl_free uses eax ebx ecx, mptr:dword
5153 IgorA 131
	mov ecx,[mptr]
132
	or ecx,ecx
133
	jz @f
5218 IgorA 134
		mcall 68, 13
135
	@@:
5153 IgorA 136
	ret
137
endp
138
 
139
;description:
140
; выделение памяти
141
align 4
142
proc gl_malloc uses ebx ecx, size:dword
143
	mcall 68, 12, [size]
144
	ret
145
endp
146
 
147
;description:
148
; выделение очищеной памяти
149
align 4
150
proc gl_zalloc uses ebx ecx edi, size:dword
151
	mov ecx,[size]
152
	stdcall gl_malloc,ecx
5218 IgorA 153
	or eax,eax
154
	jz @f
5153 IgorA 155
		mov ebx,eax
156
		mov edi,eax
157
		xor eax,eax
158
		shr ecx,2
159
		rep stosd ;очистка памяти (пишем везде 0)
160
		mov eax,ebx
161
	@@:
162
	ret
163
endp