Rev 8069 | 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 | struct ZBufferPoint |
||
82 | x dd ? ;int ;integer coordinates in the zbuffer |
||
83 | y dd ? ;int |
||
84 | z dd ? ;int |
||
85 | s dd ? ;int ;coordinates for the mapping |
||
86 | t dd ? ;int |
||
87 | r dd ? ;int ;color indexes |
||
88 | g dd ? ;int |
||
89 | b dd ? ;int |
||
90 | |||
91 | fsz dd ? ;float ;temporary coordinates for mapping |
||
92 | tz dd ? ;float |
||
93 | ends |
||
94 | |||
95 | ; ztriangle.c |
||
96 | |||
97 | ; |
||
98 | ; Memory allocator for TinyGL |
||
99 | ; |
||
100 | |||
101 | ; modify these functions so that they suit your needs |
||
102 | |||
103 | align 4 |
||
5218 | IgorA | 104 | proc gl_free uses eax ebx ecx, mptr:dword |
5153 | IgorA | 105 | mov ecx,[mptr] |
106 | or ecx,ecx |
||
107 | jz @f |
||
5218 | IgorA | 108 | mcall 68, 13 |
109 | @@: |
||
5153 | IgorA | 110 | ret |
111 | endp |
||
112 | |||
113 | ;description: |
||
114 | ; выделение памяти |
||
115 | align 4 |
||
116 | proc gl_malloc uses ebx ecx, size:dword |
||
117 | mcall 68, 12, [size] |
||
118 | ret |
||
119 | endp |
||
120 | |||
121 | ;description: |
||
122 | ; выделение очищеной памяти |
||
123 | align 4 |
||
124 | proc gl_zalloc uses ebx ecx edi, size:dword |
||
125 | mov ecx,[size] |
||
126 | stdcall gl_malloc,ecx |
||
5218 | IgorA | 127 | or eax,eax |
128 | jz @f |
||
5153 | IgorA | 129 | mov ebx,eax |
130 | mov edi,eax |
||
131 | xor eax,eax |
||
132 | shr ecx,2 |
||
133 | rep stosd ;очистка памяти (пишем везде 0) |
||
134 | mov eax,ebx |
||
135 | @@: |
||
136 | ret |
||
137 | endp><> |