Subversion Repositories Kolibri OS

Rev

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