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

  1. #include "ray.h"
  2. #include "globals.h"
  3. #include "rayfile.h"
  4. #include "rgobject.h"
  5. #include "voxel.h"
  6. #include <mem.h>
  7.  
  8. void Reverse_Light_And_Color(PUCHAR source_image, long length);
  9.  
  10. void Load_Vox_Map(PUCHAR & vox_ptr , long offset)
  11. {
  12.    F_Seek(offset);
  13.  
  14.    RCastGobject vox_temp(2);
  15.    char filename[F_NAME_LENGTH];
  16.  
  17.    // load bitmaps from pcx files
  18.    F_Get_String_NT(filename, F_NAME_LENGTH);
  19.    vox_temp.assigninfile(filename);
  20.    vox_temp.load(0);
  21.    F_Get_String_NT(filename, F_NAME_LENGTH);
  22.    vox_temp.assigninfile(filename);
  23.    vox_temp.load(1);
  24.  
  25.    //Palette no longer reversed as one palette is used
  26.    //Reverse_Light_And_Color(vox_temp.Image(1), COL_ARR_SIZE);
  27.  
  28.    // now, this is tricky (i.e. bad code)
  29.    // but is justified due to extreme speed demands
  30.    // the altitudes array and color array are stacked
  31.    // against eachother in memory, which will save time in
  32.    // the essential assembly loop to draw the terrain
  33.  
  34.    vox_ptr=NewPtr(TOTAL_VOX_MEM);
  35.  
  36.    memcpy(vox_ptr, vox_temp.Image(0), ALT_ARR_SIZE);
  37.    memcpy(vox_ptr+ALT_TO_COL_DIFF, vox_temp.Image(1), COL_ARR_SIZE);
  38.  
  39. }
  40.  
  41. void Reverse_Light_And_Color(PUCHAR source_image, long length)
  42. {
  43.    PUCHAR dest_image=NewPtr(length);
  44.    UCHAR cur_light, cur_color;
  45.    for (long cur_pixel=0; cur_pixel<length; cur_pixel++) {
  46.       cur_light=(source_image[cur_pixel] & 0xf0) >> 4;
  47.       cur_color=(source_image[cur_pixel] & 0x0f);
  48.       dest_image[cur_pixel]=cur_light+(cur_color<<4);
  49.       } /* endfor */
  50.  
  51.    memcpy(source_image, dest_image, length);
  52.    DelPtr(dest_image);
  53. }
  54.