]> icculus.org git repositories - btb/d2x.git/blob - unused/pa_null/poly_acc.c
Rename include/error.h to include/dxxerror.h
[btb/d2x.git] / unused / pa_null / poly_acc.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 static unsigned poly_count;
15
16 //
17 //                                                         Includes
18 //
19 #include <math.h>
20 #include <limits.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include "pa_enabl.h"        // needs to occur early.
26
27 #if defined(POLY_ACC)
28
29 #include "pstypes.h"
30 #include "fix.h"
31 #include "3d.h"
32 #include "gr.h"
33 #include "grdef.h"
34 #include "texmap.h"
35 #include "mono.h"
36 #include "debug.h"
37 #include "dxxerror.h"
38 #include "poly_acc.h"
39
40 //
41 //                                                          Defines
42 //
43 #define TEX_SIZE        64
44 #define TEX_CACHE       (64)
45 #define CHROMA_COLOR    0x0001
46 #define MODE_110        S3DTK_MODE640x480x15           // 640x480x15
47 #define DMA_SIZE        1024
48 #define DMA_VERT_WORDS  (sizeof(S3DTK_VERTEX_TEX) / sizeof(unsigned long))
49 #define NDL             5               // stolen from main/game.h. how many filter levels there are.
50
51 enum { OP_TMAP, OP_FLAT, OP_BLIT, OP_BLIT_TRANSPARENT, OP_BLIT_SCALE };
52
53 //
54 //                                                           Variables
55 //
56 extern ubyte scale_rle_data[1024];      // from 2d\scale.c
57 unsigned short pa_clut[256];            // translate from 8 bit pixels to 15 bit pixels.
58 static short pa_clut_save_buf[256];     // used to save/restore the clut.
59 int pa_filter_mode = NDL-1;             //  For Virge filtering control, set in Custom Detail Level menu.
60
61
62 static pa_initted = 0;
63 static pa_card_initted = 0;     //$$hack, library doesn't seem to correctly init card twice.
64 static ULONG old_mode;
65
66 /* S3D Toolkit function list */
67 static S3DTK_LPFUNCTIONLIST pS3DTK_Funct;
68 static S3DTK_VERTEX_TEX verts[MAX_TMAP_VERTS];
69 static S3DTK_LPVERTEX_TEX trifan[MAX_TMAP_VERTS];
70
71 /* buffer definitions */
72 static int backBuffer = 1;                    /* index of back buffer                          */
73 static S3DTK_SURFACE displaySurf[2];          /* one for front buffer and one for back buffer  */
74 static S3DTK_RECTAREA fullScreenRect = { 0, 0, 640, 480 };
75
76 /* physical properties */
77 static ULONG screenFormat = S3DTK_VIDEORGB15;   /* format of the surface as defined in S3DTK.H */
78 static float width=640, height=480;             /* screen's dimension                          */
79
80 // memory manager variables.
81 static ULONG totalMemory;                  /* frame buffer size                           */
82 static ULONG memoryUsed;                   /* frame buffer allocated                      */
83 static char *frameBuffer;                  /* linear address of frame buffer starts at    */
84
85 // cache variables.
86 static S3DTK_SURFACE cache_slots[TEX_CACHE];
87 static struct
88 {
89     uint tag;
90     uint age;
91 } cache_tags[TEX_CACHE];
92 static int cache_age = 0;
93
94 // dma vars.
95 static unsigned long dma_buf[DMA_SIZE];     // simulated dma ring buffer.
96 static int dma_head, dma_tail;              // head and tail of ring buffer.
97 static op_extra_words[] =                   // how many extra words are needed besides the vertex info
98 { 7, 5, 10, 11, 5 };                        // plus 1. avoids (head == tail) == (tail == head).
99 static filter_tmap[] = {
100     S3DTK_TEX1TPP, S3DTK_TEXM1TPP, S3DTK_TEX4TPP, S3DTK_TEX4TPP, S3DTK_TEXM4TPP
101 };
102 static filter_scale[] = {
103     S3DTK_TEX1TPP, S3DTK_TEX4TPP, S3DTK_TEX4TPP, S3DTK_TEX4TPP, S3DTK_TEX4TPP
104 };
105 static filter_robot[] = {       // actually how to filter non-perspective triangles.
106     S3DTK_TEX1TPP, S3DTK_TEXM1TPP, S3DTK_TEXM1TPP, S3DTK_TEX4TPP, S3DTK_TEXM4TPP
107 };
108
109 // misc
110 static int pa_3d_x_off = 0, pa_3d_y_off = 0;
111
112 // local prototypes.
113 static int pa_cache_search(grs_bitmap *bp);
114 static BOOL allocSurf(S3DTK_SURFACE *surf, ULONG width, ULONG height, ULONG bpp, ULONG format);
115 extern uint texmerge_get_unique_id( grs_bitmap * bmp );
116 extern void decode_row(grs_bitmap * bmp, int y);
117 static unsigned get_pow2(unsigned wh);
118 static unsigned long dma_get(void);
119 static void dma_put(unsigned long d);
120 static int dma_space(void);
121 static int CheckForSpecificCard(void);
122
123 //
124 //                                                           Routines
125 //
126 int pa_init(void)                       // init library.
127 {
128 }
129
130 void pa_reset(void)                         // cleans up library.
131 {
132 }
133
134 int pa_detect(int mode)                 // detect card and whether mode is supported.
135 {
136 }
137
138 void pa_set_mode(int mode)           // sets display mode if valid PA mode.
139 {
140 }
141
142 // type 0==0..63, 1==0..255.
143 void pa_update_clut(unsigned char *pal, int start, int count, int type)
144 {
145 }
146
147 void pa_save_clut(void)
148 {
149 }
150
151 void pa_restore_clut(void)
152 {
153 }
154
155 void pa_step_up(int r, int g, int b)
156 {
157 }
158
159 // get the address of a card's framebuffer and lock it in.
160 void *pa_get_buffer_address(int which)
161 {
162 }
163
164 void pa_clear_buffer(int buffer, ushort color)
165 {
166 }
167
168
169 void pa_set_3d_offset(int x, int y)     // where on screen the triangles should be drawn.
170 {
171 }
172
173 void pa_draw_tmap(grs_bitmap * srcb, g3ds_tmap * tmap, int transparency_on, int lighting_on, int perspective, fix min_z)
174 {
175 }
176
177 void pa_draw_flat(g3ds_tmap *tmap, int color, int alpha)
178 {
179 }
180
181 //
182 //  perform a blit using hw if screen to screen, otherwise copy mem to mem.
183 //
184 void pa_blit(grs_bitmap *dst, int dx, int dy, grs_bitmap *src, int sx, int sy, int w, int h)
185 {
186 }
187
188 //
189 //  perform a transparent blit using hw if screen to screen, otherwise copy mem to mem.
190 //
191 void pa_blit_transparent(grs_bitmap *dst, int dx, int dy, grs_bitmap *src, int sx, int sy, int w, int h)
192 {
193 }
194
195 //
196 //  performs 2d scaling by applying a bitmap to a 3D sqaure and using the texture mapper to draw it.
197 //  NOTE:Only support RLE bitmaps.
198 //
199 void pa_blit_scale(grs_bitmap *source_bmp, grs_bitmap *dest_bmp,
200     int x0, int y0, int x1, int y1,
201     fix u0, fix v0,  fix u1, fix v1, int orient
202 )
203 {
204 }
205
206 int pa_blit_lit(grs_bitmap *dst, int dx, int dy, grs_bitmap *src, int sx, int sy, int w, int h)
207 {
208 }
209
210 int pa_rect(int sx, int sy, int ex, int ey)
211 {
212 }
213
214 void pa_swap_buffer(void)
215 {
216 }
217
218 #pragma off (unreferenced)
219 void pa_ibitblt(void *src, void *dst, void *mask)
220 #pragma on (unreferenced)
221 {
222 }
223
224 //
225 //    Allocate space for TEX_CACHE textures on the 3D card.
226 //
227 void pa_init_cache(void)
228 {
229 }
230
231 //
232 //  implements a primitive LRU to keep from destroying active textures. Primitive because it uses
233 //  an array search to find the oldest element.
234 //
235 static int pa_cache_search(grs_bitmap *bmp)
236 {
237 }
238
239 /***************************************************************************
240  *
241  *  Memory management routines
242  *
243  ***************************************************************************/
244 static BOOL initMemoryBuffer(void)
245 {
246 }
247
248 static void allocInit(S3DTK_LPFUNCTIONLIST pS3DTK_Funct)
249 {
250 }
251
252 static BOOL allocSurf(S3DTK_SURFACE *surf, ULONG width, ULONG height, ULONG bpp, ULONG format)
253 {
254 }
255
256 /* convert width/height to power of 2; if power of 2, return it. Else
257    subtract 1 from next higher power of 2 */
258 static unsigned get_pow2(unsigned wh)
259 {
260 }
261
262 int pa_dma_poll(void)
263 {
264 }
265
266 static unsigned long dma_get(void)
267 {
268 }
269
270 static void dma_put(unsigned long d)
271 {
272 }
273
274 // return number of free entries in dma_buf
275 static int dma_space(void)
276 {
277 }
278
279 static void dma_add_verts(int nv)
280 {
281 }
282
283 static void dma_get_verts(void)
284 {
285 }
286
287 // see's if a command of 'type' is in dma buffer. Intended use is to serialize access to scale sprite buffer.
288 static int op_pending(int type)
289 {
290 }
291
292 //
293 //  waits for current async op to complete.
294 //
295 static pa_idle_cnt[2];      //$$
296 int pa_idle(void)
297 {
298 }
299
300 void pa_sync(void)
301 {
302 }
303
304 void pa_flush(void)
305 {
306 }
307
308 //used in Rendition version, but not in S3 version
309 void pa_about_to_flip()
310 {
311 }
312
313 // used by 3Dfx
314 void pa_set_write_mode (int mode)
315 {
316 }
317
318 // used by 3Dfx
319 void pa_set_frontbuffer_current(void)
320 {
321 }
322
323 #endif      // defined POLY_ACC
324