0
|
1 #include "wrapper.h"
|
|
2
|
|
3 /*****/
|
|
4
|
|
5 char txr_wsygn[16*16]={ /* syaani/sininen. hieno. parempi keltapunas„vyiss„? */
|
|
6 0x11,0x19,0x97,0x97,0x97,0x11,0x11,0x11,0x79,0x97,0x97,0x97,0x11,0x11,0x11,0x11,
|
|
7 0x11,0x79,0x97,0x97,0x97,0x79,0x19,0x11,0x79,0x97,0x97,0x97,0x11,0x19,0x11,0x11,
|
|
8 0x11,0x11,0x91,0x97,0x97,0x97,0x19,0x11,0x19,0x97,0x97,0x97,0x79,0x19,0x11,0x11,
|
|
9 0x11,0x19,0x79,0x97,0x97,0x97,0x19,0x11,0x11,0x91,0x97,0x97,0x97,0x19,0x11,0x11,
|
|
10 0x11,0x91,0x97,0x97,0x97,0x91,0x11,0x11,0x19,0x79,0x97,0x97,0x97,0x79,0x11,0x11,
|
|
11 0x11,0x19,0x97,0x77,0x97,0x11,0x11,0x11,0x19,0x97,0x97,0x97,0x91,0x19,0x11,0x11,
|
|
12 0x11,0x79,0x97,0x97,0x97,0x97,0x79,0x19,0x11,0x97,0x97,0x97,0x79,0x19,0x11,0x11,
|
|
13 0x11,0x11,0x91,0x97,0x77,0x97,0x19,0x11,0x11,0x91,0x97,0x97,0x97,0x79,0x10,0x10,
|
|
14 0x11,0x11,0x11,0x97,0x77,0x97,0x19,0x11,0x11,0x11,0x97,0x77,0x97,0x11,0x11,0x10,
|
|
15 0x11,0x19,0x79,0x97,0x97,0x97,0x19,0x11,0x19,0x79,0x97,0x97,0x97,0x19,0x11,0x10,
|
|
16 0x11,0x19,0x97,0x97,0x97,0x91,0x11,0x11,0x19,0x97,0x97,0x97,0x91,0x19,0x11,0x10,
|
|
17 0x11,0x19,0x97,0x77,0x97,0x11,0x11,0x11,0x11,0x97,0x77,0x97,0x79,0x19,0x11,0x11,
|
|
18 0x11,0x79,0x97,0x97,0x97,0x79,0x19,0x11,0x10,0x97,0x97,0x97,0x97,0x19,0x11,0x11,
|
|
19 0x11,0x11,0x91,0x97,0x97,0x97,0x19,0x11,0x19,0x79,0x97,0x97,0x97,0x11,0x11,0x11,
|
|
20 0x11,0x19,0x79,0x97,0x97,0x97,0x19,0x11,0x19,0x97,0x97,0x97,0x91,0x19,0x11,0x11,
|
|
21 0x11,0x79,0x97,0x97,0x97,0x79,0x19,0x11,0x79,0x97,0x97,0x97,0x79,0x19,0x11,0x10
|
|
22 };
|
|
23
|
|
24
|
|
25 char txr_dunneon[16*16]={ /* neonjuovia. k„ytett„v„. */
|
|
26 0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x80,
|
|
27 0x80,0x80,0x80,0x00,0x08,0x80,0x80,0x08,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x80,
|
|
28 0x80,0x80,0x08,0x00,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x80,
|
|
29 0x80,0x80,0x80,0x00,0x08,0x80,0x80,0x00,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x80,
|
|
30 0x80,0x80,0x80,0x08,0x80,0x80,0x08,0x00,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x80,
|
|
31 0x80,0x80,0x80,0x08,0x80,0x80,0x08,0x00,0x80,0x80,0x80,0x00,0x08,0x80,0x80,0x80,
|
|
32 0x80,0x80,0x08,0x00,0x80,0x80,0x08,0x00,0x80,0x80,0x80,0x00,0x08,0x80,0x80,0x80,
|
|
33 0x80,0x80,0x08,0x00,0x80,0x80,0x08,0x08,0x80,0x80,0x80,0x08,0x08,0x80,0x80,0x80,
|
|
34 0x80,0x80,0x08,0x00,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x80,
|
|
35 0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x80,
|
|
36 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x80,
|
|
37 0x80,0x80,0x08,0x00,0x08,0x80,0x80,0x08,0x80,0x80,0x80,0x00,0x08,0x80,0x80,0x80,
|
|
38 0x80,0x80,0x80,0x00,0x08,0x80,0x80,0x08,0x80,0x80,0x08,0x00,0x08,0x80,0x80,0x80,
|
|
39 0x80,0x80,0x08,0x00,0x80,0x80,0x80,0x08,0x80,0x80,0x08,0x08,0x08,0x80,0x80,0x80,
|
|
40 0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x00,0x08,0x80,0x80,0x80,
|
|
41 0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x08,0x80,0x80,0x80,0x80
|
|
42 };
|
|
43
|
|
44 char txr_unneon[16*16]={
|
|
45 0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x78,
|
|
46 0x78,0x78,0x78,0x00,0x07,0x78,0x78,0x07,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x78,
|
|
47 0x78,0x78,0x07,0x00,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x78,
|
|
48 0x78,0x78,0x78,0x00,0x07,0x78,0x78,0x00,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x78,
|
|
49 0x78,0x78,0x78,0x07,0x78,0x78,0x07,0x00,0x78,0x78,0x78,0x00,0x78,0x78,0x78,0x78,
|
|
50 0x78,0x78,0x78,0x07,0x78,0x78,0x07,0x00,0x78,0x78,0x78,0x00,0x07,0x78,0x78,0x78,
|
|
51 0x78,0x78,0x07,0x00,0x78,0x78,0x07,0x00,0x78,0x78,0x78,0x00,0x07,0x78,0x78,0x78,
|
|
52 0x78,0x78,0x07,0x00,0x78,0x78,0x07,0x07,0x78,0x78,0x78,0x07,0x07,0x78,0x78,0x78,
|
|
53 0x78,0x78,0x07,0x00,0x78,0x78,0x78,0x00,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x78,
|
|
54 0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x78,
|
|
55 0x78,0x78,0x78,0x00,0x78,0x78,0x78,0x00,0x78,0x78,0x78,0x00,0x78,0x78,0x78,0x78,
|
|
56 0x78,0x78,0x07,0x00,0x07,0x78,0x78,0x07,0x78,0x78,0x78,0x00,0x07,0x78,0x78,0x78,
|
|
57 0x78,0x78,0x78,0x00,0x07,0x78,0x78,0x07,0x78,0x78,0x07,0x00,0x07,0x78,0x78,0x78,
|
|
58 0x78,0x78,0x07,0x00,0x78,0x78,0x78,0x07,0x78,0x78,0x07,0x07,0x07,0x78,0x78,0x78,
|
|
59 0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x00,0x07,0x78,0x78,0x78,
|
|
60 0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x78,0x78,0x78,0x78,0x07,0x78,0x78,0x78,0x78
|
|
61 };
|
|
62
|
|
63 char txr_neon[16*16]={
|
|
64 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,
|
|
65 0x00,0x00,0x00,0x5c,0x04,0x00,0x00,0x40,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
|
|
66 0x00,0x00,0x04,0x5c,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,
|
|
67 0x00,0x00,0x00,0x5c,0x04,0x00,0x00,0x5c,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,
|
|
68 0x00,0x00,0x00,0x40,0x00,0x00,0x04,0x5c,0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x00,
|
|
69 0x00,0x00,0x00,0x40,0x00,0x00,0x04,0x5c,0x00,0x00,0x00,0x5c,0x04,0x00,0x00,0x00,
|
|
70 0x00,0x00,0x04,0x5c,0x00,0x00,0x04,0x5c,0x00,0x00,0x00,0x5c,0x04,0x00,0x00,0x00,
|
|
71 0x00,0x00,0x04,0x5c,0x00,0x00,0x04,0x40,0x00,0x00,0x00,0x40,0x04,0x00,0x00,0x00,
|
|
72 0x00,0x00,0x04,0x5c,0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
|
|
73 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,
|
|
74 0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x5c,0x00,0x00,0x00,0x00,
|
|
75 0x00,0x00,0x04,0x5c,0x04,0x00,0x00,0x40,0x00,0x00,0x00,0x5c,0x04,0x00,0x00,0x00,
|
|
76 0x00,0x00,0x00,0x5c,0x04,0x00,0x00,0x40,0x00,0x00,0x04,0x5c,0x04,0x00,0x00,0x00,
|
|
77 0x00,0x00,0x04,0x5c,0x00,0x00,0x00,0x04,0x00,0x00,0x04,0x40,0x04,0x00,0x00,0x00,
|
|
78 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x5c,0x04,0x00,0x00,0x00,
|
|
79 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00
|
|
80 };
|
|
81
|
|
82 char txr_gslime[16*16]={
|
|
83 0x88,0x80,0x00,0x80,0x80,0x88,0x88,0x88,0x80,0x08,0x00,0x00,0x08,0x88,0x80,0x00,
|
|
84 0x80,0x08,0x00,0x08,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x80,0x88,0x80,0x08,0x00,
|
|
85 0x08,0x00,0x00,0x00,0x08,0x08,0x80,0x00,0x00,0x00,0x08,0x80,0x80,0x00,0x00,0x88,
|
|
86 0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x80,0x00,0x08,0x88,0x80,
|
|
87 0x00,0x08,0x80,0x08,0x00,0x00,0x08,0x88,0x88,0x88,0x00,0x80,0x00,0x08,0x80,0x00,
|
|
88 0x08,0x80,0x80,0x08,0x00,0x08,0x80,0x88,0x88,0x88,0x08,0x80,0x00,0x00,0x00,0x08,
|
|
89 0x88,0x88,0x88,0x80,0x00,0x08,0x80,0x88,0x88,0x88,0x80,0x80,0x00,0x00,0x08,0x80,
|
|
90 0x88,0x88,0x80,0x80,0x00,0x00,0x08,0x80,0x80,0x08,0x00,0x00,0x00,0x80,0x88,0x88,
|
|
91 0x88,0x88,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x88,0x88,
|
|
92 0x80,0x80,0x00,0x00,0x08,0x08,0x00,0x00,0x08,0x80,0x80,0x80,0x80,0x80,0x08,0x88,
|
|
93 0x08,0x00,0x08,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x08,0x08,0x80,0x80,0x08,0x88,
|
|
94 0x80,0x80,0x80,0x80,0x08,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x80,
|
|
95 0x88,0x88,0x88,0x88,0x88,0x80,0x80,0x80,0x08,0x08,0x00,0x00,0x08,0x08,0x00,0x80,
|
|
96 0x88,0x88,0x88,0x88,0x88,0x80,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,
|
|
97 0x88,0x88,0x88,0x08,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x00,0x00,0x80,0x80,0x00,
|
|
98 0x88,0x08,0x00,0x00,0x00,0x00,0x08,0x08,0x80,0x80,0x80,0x08,0x00,0x88,0x80,0x80
|
|
99 };
|
|
100
|
|
101 char txr_slime[16*16]={ /* vihre„ laikukas. hienokiva. */
|
|
102 0x22,0x20,0x00,0x20,0x20,0x22,0x22,0x22,0x20,0x02,0x00,0x00,0x02,0x22,0x20,0x00,
|
|
103 0x20,0x02,0x00,0x02,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x20,0x22,0x20,0x02,0x00,
|
|
104 0x02,0x00,0x00,0x00,0x02,0x02,0x20,0x00,0x00,0x00,0x02,0x20,0x20,0x00,0x00,0x22,
|
|
105 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x20,0x00,0x02,0x22,0x20,
|
|
106 0x00,0x02,0x20,0x02,0x00,0x00,0x02,0x22,0x22,0x22,0x00,0x20,0x00,0x02,0x20,0x00,
|
|
107 0x02,0x20,0x20,0x02,0x00,0x02,0x20,0x22,0x22,0x22,0x02,0x20,0x00,0x00,0x00,0x02,
|
|
108 0x22,0x22,0x22,0x20,0x00,0x02,0x20,0x22,0x22,0x22,0x20,0x20,0x00,0x00,0x02,0x20,
|
|
109 0x22,0x22,0x20,0x20,0x00,0x00,0x02,0x20,0x20,0x02,0x00,0x00,0x00,0x20,0x22,0x22,
|
|
110 0x22,0x22,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x22,0x22,
|
|
111 0x20,0x20,0x00,0x00,0x02,0x02,0x00,0x00,0x02,0x20,0x20,0x20,0x20,0x20,0x02,0x22,
|
|
112 0x02,0x00,0x02,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x02,0x02,0x20,0x20,0x02,0x22,
|
|
113 0x20,0x20,0x20,0x20,0x02,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x20,
|
|
114 0x22,0x22,0x22,0x22,0x22,0x20,0x20,0x20,0x02,0x02,0x00,0x00,0x02,0x02,0x00,0x20,
|
|
115 0x22,0x22,0x22,0x22,0x22,0x20,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,
|
|
116 0x22,0x22,0x22,0x02,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x20,0x20,0x00,
|
|
117 0x22,0x02,0x00,0x00,0x00,0x00,0x02,0x02,0x20,0x20,0x20,0x02,0x00,0x22,0x20,0x20
|
|
118 };
|
|
119
|
|
120 typedef struct{signed int x,z,y;}xyz;
|
|
121 typedef struct{signed int a,r,y;}cyl;
|
|
122 typedef struct{int p[3]; int nn; char*txrf,*txrb;}face;
|
|
123
|
|
124 typedef struct{
|
|
125
|
|
126 int numvxes;
|
|
127 cyl*vxes;
|
|
128 xyz*rotated;
|
|
129
|
|
130 int numfaces;
|
|
131 face*faces;
|
|
132
|
|
133 }obj3d;
|
|
134
|
|
135 #define sint signed int
|
|
136
|
|
137 /** XWING **/
|
|
138
|
|
139 /*
|
|
140 xyz cube_vxes[]={
|
|
141 -6000,-1000,2000,
|
|
142 -6000,-1000,-2000,
|
|
143 6000,-1000,2000,
|
|
144 6000,-1000,-2000,
|
|
145
|
|
146 -1500,2000,0,
|
|
147 -1500,-1000,0,
|
|
148 1500,2000,0,
|
|
149 1500,-100,0,
|
|
150
|
|
151 0,2500,0,
|
|
152
|
|
153 0,1000,-1500
|
|
154 };
|
|
155
|
|
156 face cube_faces[]={
|
|
157 0,4,5, 0, txr_wsygn,txr_dunneon,
|
|
158 1,5,4, 0, txr_wsygn,txr_dunneon,
|
|
159 2,7,6, 0, txr_wsygn,txr_dunneon,
|
|
160 3,6,7, 0, txr_wsygn,txr_dunneon,
|
|
161
|
|
162 9,8,4, 0, txr_wsygn,NULL,
|
|
163 9,7,8, 0, txr_wsygn,NULL,
|
|
164 9,4,5, 0, txr_unneon,NULL,
|
|
165 9,7,6, 0, txr_unneon,NULL,
|
|
166 9,5,6, 0, txr_unneon,NULL
|
|
167 };
|
|
168 */
|
|
169
|
|
170 /********/
|
|
171 /********/
|
|
172
|
|
173 cyl xwing_vxes[]={
|
|
174 134,6082,1000,
|
|
175 134,6082,-1000,
|
|
176 250,6082,1000,
|
|
177 250,6082,-1000,
|
|
178 91,3000,0, /* 2500 */
|
|
179 151,1802,0,
|
|
180 37,3000,0, /* 2500 */
|
|
181 254,1503,0,
|
|
182 64,2500,0,
|
|
183 64,1000,-750
|
|
184 };
|
|
185
|
|
186 face xwing_faces[]={
|
|
187 4,5,0, 0, txr_wsygn,txr_dunneon,
|
|
188 1,5,4, 0, txr_wsygn,txr_dunneon,
|
|
189 7,6,2, 0, txr_wsygn,txr_dunneon,
|
|
190 3,6,7, 0, txr_wsygn,txr_dunneon,
|
|
191
|
|
192 9,8,4, 0, txr_wsygn,NULL,
|
|
193 9,7,8, 0, txr_wsygn,NULL,
|
|
194 9,4,5, 0, txr_unneon,NULL,
|
|
195 9,7,6, 0, txr_unneon,NULL,
|
|
196 9,5,6, 0, txr_unneon,NULL
|
|
197 };
|
|
198
|
|
199 obj3d xwing={
|
|
200 10,xwing_vxes,NULL,9,xwing_faces
|
|
201 };
|
|
202
|
|
203 cyl bugi_vxes[]={
|
|
204 96,2828,0,
|
|
205 32,2828,0,
|
|
206 224,2828,0,
|
|
207 160,2828,0,
|
|
208 0,0,-800,
|
|
209 45,6708,1000,
|
|
210 238,6708,1000,
|
|
211 173,6708,1000,
|
|
212 110,6708,1000
|
|
213 };
|
|
214
|
|
215 face bugi_faces[]={
|
|
216 4,1,0, 0, txr_slime,NULL,
|
|
217 4,2,1, 0, txr_slime,NULL,
|
|
218 4,3,2, 0, txr_slime,NULL,
|
|
219 4,0,3, 0, txr_slime,NULL,
|
|
220
|
|
221 0,1,5, 0, txr_slime,txr_gslime,
|
|
222 1,2,6, 0, txr_slime,txr_gslime,
|
|
223 2,3,7, 0, txr_slime,txr_gslime,
|
|
224 3,0,8, 0, txr_slime,txr_gslime
|
|
225 };
|
|
226
|
|
227 obj3d bugi={
|
|
228 9,bugi_vxes,NULL,8,bugi_faces
|
|
229 };
|
|
230
|
|
231 obj3d obu;
|
|
232
|
|
233 #include "sini16.h"
|
|
234
|
|
235 sint dvhtab[50];
|
|
236 sint dutab[320];
|
|
237
|
|
238 eggine_init()
|
|
239 {
|
|
240 int i;
|
|
241 dvhtab[0]=32760;
|
|
242 for(i=1;i<50;i++)dvhtab[i]=4096/i;
|
|
243 dutab[0]=32760;
|
|
244 for(i=1;i<320;i++)dutab[i]=(64*256)/i;
|
|
245 }
|
|
246
|
|
247 eggine_load(sint n)
|
|
248 {
|
|
249 obj3d*o;
|
|
250 if(!n)o=&xwing;else o=&bugi;
|
|
251
|
|
252 if(o->rotated==NULL)
|
|
253 o->rotated=malloc(o->numvxes*sizeof(xyz));
|
|
254
|
|
255 memcpy(&obu,o,sizeof(obu));
|
|
256 }
|
|
257
|
|
258 extern int polytxloop
|
|
259 (sint h,char*di,unsigned int x1,sint dx0,sint dx1,char*txr,
|
|
260 sint dv,sint du);
|
|
261
|
|
262 sint polytxr(
|
|
263 char*buf,
|
|
264 sint y,sint h,sint x0,sint x1,sint dx0,sint dx1,
|
|
265 char*txr){
|
|
266
|
|
267 register sint du; char joo=0;
|
|
268
|
|
269 if(y+h>=50)h=49-y;
|
|
270 if(h>0)if(y>=0){
|
|
271
|
|
272 if((x0>x1)||((x0==x1)&&(dx0>dx1)))
|
|
273 {sint tmp=x0;x0=x1;x1=tmp;
|
|
274 tmp=dx0;dx0=dx1;dx1=tmp;
|
|
275 joo=1;}
|
|
276 x1-=x0;dx1-=dx0;
|
|
277
|
|
278 du=x1>>6;
|
|
279 if(!du)du=((dx1-dx0)*h) >>6; /* dx1-dx0?? */
|
|
280 if(du)du=(64*256)/du;/*dutab[du];*/
|
|
281
|
|
282 x1=polytxloop(h,buf+80*y+(x0>>8),
|
|
283 x1,
|
|
284 dx0,
|
|
285 dx1,
|
|
286 txr,
|
|
287 dvhtab[h],
|
|
288 du);
|
|
289
|
|
290 return (!joo)?x0+x1+h*dx0:x1;
|
|
291 }
|
|
292 }
|
|
293
|
|
294 /*******************************/
|
|
295
|
|
296 eggine_do(char*b,sint rot,int zoom,int basex,int basey) {
|
|
297 register sint i; sint j; sint fzed[20],fcez[20];
|
|
298
|
|
299 if(obu.faces==bugi_faces){
|
|
300 bugi_vxes[5].y=bugi_vxes[6].y=
|
75
|
301 1000+mul32(700,sini16[(pwplib_timer()*13)&255]);
|
0
|
302 bugi_vxes[7].y=bugi_vxes[8].y=
|
75
|
303 1000+mul32(700,sini16[(pwplib_timer()*7)&255]);
|
0
|
304 }
|
|
305
|
|
306 /***** rotate vertices *****/
|
|
307
|
|
308 {cyl*v=obu.vxes;xyz*r=obu.rotated;
|
|
309
|
|
310 for(i=obu.numvxes;i;i--) {
|
|
311 r->y=mul32(v->y,zoom)+basey;
|
|
312 r->x=mul32(mul32(v->r,sini16[(rot+v->a)&255]),zoom)+basex;
|
|
313 r->z=mul32(mul32(v->r,sini16[(rot+v->a+64)&255]),zoom);
|
|
314 r++;v++;
|
|
315 }}
|
|
316
|
|
317 /***** calc facezeds, sort faces *****/
|
|
318
|
|
319 {sint *t=fzed;face*f=obu.faces; for(i=obu.numfaces;i;i--){
|
|
320 *t++=obu.rotated[f->p[0]].z+ obu.rotated[f->p[1]].z+
|
|
321 obu.rotated[f->p[2]].z; f++;
|
|
322 }}
|
|
323
|
|
324 {sint *t=fcez;sint j=0; for(i=obu.numfaces;i;i--)*t++=j++; }
|
|
325
|
|
326 /* stupid bubblesort */
|
|
327
|
|
328 for(i=0;i<obu.numfaces-1;i++){ sint min=fzed[i],where=i;
|
|
329 for(j=i+1;j<obu.numfaces;j++){
|
|
330 if(fzed[j]<min){min=fzed[j];where=j;} }
|
|
331
|
|
332 {sint tmp=fzed[i];fzed[i]=fzed[where];fzed[where]=tmp;} {sint
|
|
333 tmp=fcez[i];fcez[i]=fcez[where];fcez[where]=tmp;}
|
|
334 }
|
|
335
|
|
336 /***** draw faces *****/
|
|
337
|
|
338 {sint*fc=fcez; for(i=obu.numfaces;i;i--) {
|
|
339 face*f=&obu.faces[*fc++];
|
|
340
|
|
341 { sint x0,x1,x2,y0,y1,y2,nz; char*txr;
|
|
342
|
|
343 /***************************************/
|
|
344
|
|
345 {xyz*tmp=obu.rotated;
|
|
346 x0=tmp[f->p[0]].x<<3;
|
|
347 y0=tmp[f->p[0]].y>>5;
|
|
348 x1=tmp[f->p[1]].x<<3;
|
|
349 y1=tmp[f->p[1]].y>>5;
|
|
350 x2=tmp[f->p[2]].x<<3;
|
|
351 y2=tmp[f->p[2]].y>>5;
|
|
352 }
|
|
353
|
|
354 nz=((x1-x0)>>8)*(y2-y0)-((x2-x0)>>8)*(y1-y0);
|
|
355 if(nz<0)txr=f->txrf;else txr=f->txrb;
|
|
356 if(txr!=NULL)
|
|
357 {
|
|
358
|
|
359 if(y0!=y2){
|
|
360
|
|
361 sint tmpk,tmpx2;
|
|
362
|
|
363 if (y0!=y1)
|
|
364 tmpx2=polytxr(b,y0,y1-y0,x0,x0,
|
|
365 (x1-x0)/(y1-y0),
|
|
366 tmpk=(x2-x0)/(y2-y0), txr);
|
|
367 else {tmpk=(x2-x0)/(y2-y0);tmpx2=x0;}
|
|
368
|
|
369 if (y1!=y2)
|
|
370 polytxr(b,y1,y2-y1,x1,tmpx2,
|
|
371 (x2-x1)/(y2-y1),
|
|
372 tmpk, txr);
|
|
373 }
|
|
374 }
|
|
375 /***************************************/
|
|
376 }
|
|
377
|
|
378 }}/* end drawfaces*/
|
|
379 }
|