[80] | 1 | /********************************************************************** <BR>
|
---|
| 2 | This file is part of Crack dot Com's free source code release of
|
---|
| 3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
| 4 | information about compiling & licensing issues visit this URL</a>
|
---|
| 5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
| 6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
| 7 | ***********************************************************************/
|
---|
| 8 |
|
---|
| 9 | #include "software/r1_software.hh"
|
---|
| 10 | #include "software/r1_software_globals.hh"
|
---|
| 11 |
|
---|
| 12 | r1_software_class r1_software_class_instance;
|
---|
| 13 |
|
---|
| 14 | //global information about the current rendering buffer
|
---|
| 15 |
|
---|
| 16 | i4_bool r1_software_render_buffer_is_locked = i4_F;
|
---|
| 17 | w16 *r1_software_render_buffer_ptr = 0; //pointer to buffer memory
|
---|
| 18 | sw32 r1_software_render_buffer_bpl = 0; //bytes per line
|
---|
| 19 | sw32 r1_software_render_buffer_wpl = 0; //words per line
|
---|
| 20 | sw32 r1_software_render_buffer_height = 0;
|
---|
| 21 | w8 r1_software_render_expand_type = 0; //expanding type
|
---|
| 22 |
|
---|
| 23 | //the directdraw surface which "owns" the buffer
|
---|
| 24 | IDirectDrawSurface3 *r1_software_render_surface = 0;
|
---|
| 25 |
|
---|
| 26 | //global texturemap information (describes the current
|
---|
| 27 | //texturemap being used to draw polygons)
|
---|
| 28 |
|
---|
| 29 | w16 *r1_software_texture_ptr = 0;
|
---|
| 30 | w8 r1_software_twidth_log2 = 0;
|
---|
| 31 | sw32 r1_software_texture_width = 0;
|
---|
| 32 | sw32 r1_software_texture_height = 0;
|
---|
| 33 |
|
---|
| 34 | //------------------------
|
---|
| 35 | //rest of global variables
|
---|
| 36 | //------------------------
|
---|
| 37 |
|
---|
| 38 | sw32 left_l;
|
---|
| 39 |
|
---|
| 40 | sw32 left_s;
|
---|
| 41 | sw32 left_t;
|
---|
| 42 | float left_z;
|
---|
| 43 |
|
---|
| 44 | sw32 right_s;
|
---|
| 45 | sw32 right_t;
|
---|
| 46 | float right_z;
|
---|
| 47 |
|
---|
| 48 | sw32 dsdx_frac,dtdx_frac;
|
---|
| 49 | sw32 temp_dsdx,temp_dtdx;
|
---|
| 50 |
|
---|
| 51 | sw32 s_t_carry[2];
|
---|
| 52 | sw32 dldx_fixed;
|
---|
| 53 | sw32 num_subdivisions;
|
---|
| 54 |
|
---|
| 55 | sw32 s_mask;// = ((r1_software_texture_width -1)<<16) | 0xFFFF;
|
---|
| 56 | sw32 t_mask;// = ((r1_software_texture_height-1)<<16) | 0xFFFF;
|
---|
| 57 |
|
---|
| 58 | float ooz_right;
|
---|
| 59 | float soz_right;
|
---|
| 60 | float toz_right;
|
---|
| 61 |
|
---|
| 62 | w32 pre_blend_and;
|
---|
| 63 | w32 post_blend_and;
|
---|
| 64 |
|
---|
| 65 | sw32 width_global;
|
---|
| 66 | sw32 num_leftover;
|
---|
| 67 |
|
---|
| 68 | //cur_grads is a global set of gradients used by the scanline texturemappers
|
---|
| 69 | //(it needs to be global so that no extra pointer referencing occurs in the asm code)
|
---|
| 70 | tri_gradients cur_grads;
|
---|
| 71 |
|
---|
| 72 | //the 4444 alpha lookup table (2^4 * 2^4 * 2^4 = 2^12 = 4096)
|
---|
| 73 | w16 alpha_table[4096];
|
---|
| 74 |
|
---|
| 75 | w8 small_poly_type;
|
---|
| 76 | w8 big_poly_type;
|
---|
| 77 |
|
---|
| 78 | //we probably only need 16 of these lookups
|
---|
| 79 | float inverse_leftover_lookup[64];
|
---|
| 80 |
|
---|
| 81 | void inverse_leftover_lookup_init()
|
---|
| 82 | {
|
---|
| 83 | sw32 i;
|
---|
| 84 |
|
---|
| 85 | inverse_leftover_lookup[0] = 0.f;
|
---|
| 86 |
|
---|
| 87 | for (i=1; i<64; i++)
|
---|
| 88 | {
|
---|
| 89 | inverse_leftover_lookup[i] = 1.f / (float)i;
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | //unfortunately there is no decent sorted line primitive. all lines get
|
---|
| 94 | //drawn at the end of the frame, if there are any.
|
---|
| 95 |
|
---|
| 96 | software_line software_lines[max_soft_lines];
|
---|
| 97 | sw32 num_buffered_lines=0;
|
---|
| 98 |
|
---|
| 99 | tri_area_struct triangle_info[32];
|
---|
| 100 | float total_poly_area;
|
---|
| 101 |
|
---|
| 102 | //fpu control word storage (used in inline_fpu.hh)
|
---|
| 103 | w16 old_ceil_word;
|
---|
| 104 | w16 new_ceil_word;
|
---|
| 105 |
|
---|
| 106 | w16 old_trunc_word;
|
---|
| 107 | w16 new_trunc_word;
|
---|
| 108 |
|
---|
| 109 | w16 old_single_word;
|
---|
| 110 | w16 new_single_word;
|
---|
| 111 |
|
---|
| 112 | i4_bool do_amd3d = i4_F; |
---|