home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / RAYCAST.ZIP / SPRVOX.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-24  |  2.2 KB  |  80 lines

  1. #include "ray.h"
  2. #include "asm.h"
  3. #include "rayrend.h"
  4. #include "globals.h"
  5. #include "rayspr.h"
  6. #include "sprrend.h"
  7. #include "mymem.h"
  8. #include "prevarr.h"
  9. #include "rayvb.h"
  10. #include "voxel.h"
  11. #include "mem.h"
  12.  
  13. #define NO_ENTRIES_IN_TABLE     0
  14.  
  15. #define VOX_SPRITES_PER_Y       5
  16.  
  17.  
  18. pobject_node next_drawable_node;
  19.  
  20. pobject**       vox_sprite_table;
  21. Byte*            vox_sprite_count;
  22.  
  23. void    Init_Vox_Sprite_Table() {
  24.    short x;
  25.  
  26.    vox_sprite_table=(pobject**)NewPtr(DIST_MAX*DIST_SCALER*sizeof(pobject*));
  27.    for(x=0;x!=(DIST_MAX*DIST_SCALER);x++) {
  28.       vox_sprite_table[x]=(pobject*)NewPtr(VOX_SPRITES_PER_Y*sizeof(pobject));
  29.       }
  30.  
  31.    vox_sprite_count=(Byte *)NewPtr(DIST_MAX*DIST_SCALER*sizeof(Byte));
  32. }
  33.  
  34. void Setup_Vox_Sprite_Rend(pobject_node object_list, short start_line, short end_line) {
  35.    pobject_node cur_object_node=object_list;
  36.    long sprite_y;
  37.    BOOL found_valid_y;
  38.    Translate_Object_Vectors(object_list);
  39.    
  40.    memset(vox_sprite_count, NO_ENTRIES_IN_TABLE ,
  41.         (end_line) * DIST_SCALER * sizeof(Byte));
  42.    while(!OL_Empty_Node(cur_object_node)) {
  43.      sprite_y=Sprite_Y(cur_object_node)>>SHIFT;
  44.      if (cur_object_node->data->type->Render_Func==Draw_Flat_Sprite) {
  45.         sprite_y=1;
  46.      }
  47.      if (sprite_y>0) {
  48.         found_valid_y=FALSE;
  49.         while (sprite_y<(end_line*DIST_SCALER)) {
  50.            if (vox_sprite_count[sprite_y]<VOX_SPRITES_PER_Y) {
  51.               found_valid_y=TRUE;
  52.               break;
  53.            } /* endif */
  54.            sprite_y++;
  55.         }
  56.         if (found_valid_y)
  57.            vox_sprite_table[sprite_y][vox_sprite_count[sprite_y]++]=cur_object_node->data;
  58.      }
  59.      cur_object_node=OL_Next_Node(cur_object_node);
  60.      }              
  61. }
  62.  
  63. void Do_Vox_Sprite_Line(long y) {
  64.    short absolute_y;
  65.    short cur_object;
  66.  
  67.    for(absolute_y=y; absolute_y!=(y+DIST_SCALER);absolute_y++) {
  68.       for(cur_object=0;cur_object!=vox_sprite_count[absolute_y];cur_object++) {
  69.          (*vox_sprite_table[absolute_y][cur_object]->type->Render_Func)(vox_sprite_table[absolute_y][cur_object]);
  70.          }
  71.       }
  72.  
  73. }
  74.  
  75. void Render_Vox_Sprites() {
  76.   if (wall_run_count>0) {
  77.      Render_Sliver_asm();
  78.   } /* endif */
  79. }
  80.