home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / RiscPc / jeux / biohazard.arc / c / BioHazard
Text File  |  1995-10-29  |  146KB  |  4,750 lines

  1. #include "baricon.h"
  2. #include "dbox.h"
  3. #include "event.h"
  4. #include "menu.h"
  5. #include "res.h"
  6. #include "resspr.h"
  7. #include "sprite.h"
  8. #include "template.h"
  9. #include "wimp.h"
  10. #include "wimpt.h"
  11. #include "win.h"
  12. #include "werr.h"
  13. #include "wolfhead.h"
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <bbc.h>
  18. #include <math.h>
  19.  
  20. #define saving_name      "screensave savescrn"
  21. #define hourglass_on     "hourglass on"
  22. #define hourglass_off    "hourglass off"
  23.  
  24. #define spritedata_name  "data.sprites"
  25. #define Chainsaw_name    "data.chainsaw"
  26. #define Chaingun_name    "data.cgun"
  27. #define Grenade_name     "data.grenade"
  28. #define MGun_name        "data.uzi"
  29. #define Number_name      "data.1234"
  30. #define mapdata_name     "data.map"
  31. #define blockdata_name   "data.blocks"
  32. #define screensave       "screensave wolfscreen"
  33. #define loadscreen       "screenload LoadScr"
  34. #define loadscreenVGA    "screenload LoadScrVGA"
  35. #define Song_Name        "data.CSsound"
  36. #define floorsprite1_name "data.floor1"
  37. #define floorsprite2_name "data.floor2"
  38. #define bar_name         "data.bar"
  39. #define blackbox_name    "data.blackbox"
  40. #define lastfloor_name   "data.lastfloor"
  41. #define backdrop_name   "data.backdrop"
  42.  
  43. #define pointer_on "pointer 1"
  44.  
  45. #define broadcast 0
  46. #define VGA 1
  47.  
  48. #define Single 0
  49. #define Multi 1
  50.  
  51. #define Chainsaw 0
  52. #define Grenade  1
  53. #define Chaingun 3
  54. #define MGun     2
  55.  
  56. #define Game_On   6
  57. #define Game_Over 7
  58. #define Level_1   8
  59.  
  60. #define On        9
  61. #define Off       10
  62.  
  63. #define Player_1  11
  64. #define Player_2  12
  65. #define Player_3  13
  66. #define Player_4  14
  67.  
  68. #define Warning   15
  69.  
  70. #define Weapon_1  16
  71. #define Weapon_2  17
  72. #define Weapon_3  18
  73. #define Weapon_4  19
  74.  
  75. #define Full_Screen  1
  76. #define Tactical_Map 2
  77. #define Main_Player  3
  78.  
  79. /*#define RISCPC*/
  80.  
  81. int block_data[32][1024];
  82. int sprite_data[39680];
  83. int weapon_data[39680];
  84. int Number_Data[320];
  85.  
  86. #if defined(RISCPC)
  87. int virtual_screen[20480];
  88. #endif
  89. int virtual_screen_pointer;
  90.  
  91. struct door_type {
  92.   int door_frame_counter;
  93.   int door_position_x;
  94.   int door_position_y;
  95.   int next_door;
  96.   int previous_door;
  97. };
  98.  
  99. struct door_type Door_List[64];
  100. int First_Door = 0, Last_Door = 0, Doors_Active = 0, Next_Free = 0;
  101. int Next_Free_List[64], Current_Door;
  102.  
  103. int data_address[320];
  104. int distance[320];
  105.  
  106. struct sprite_type {
  107.   int sprite_frame_counter;
  108.   int sprite_position_x;
  109.   int sprite_position_y;
  110.   int sprite_info;
  111. };
  112.  
  113. struct sprite_type Sprite_List[64];
  114.  
  115. os_regset registers;
  116. os_regset *point_registers = ®isters;
  117.  
  118. int paused = TRUE,input_focus=FALSE;
  119.  
  120. int player_map[4] = {1,2,3,4};
  121.  
  122. int new_time,old_time = 0,mono_time=2;
  123.  
  124. int gradient_table[1024];
  125. int map[64][64]; /* the map! */
  126. char Map_Data[64][64]; /* the map data for display */
  127. int door_map[64][64]; /* door map */
  128. int tan_table[961];  /* tan in range 0-30/0.1875 */
  129. int cos_div_table[961];
  130. int view_cos_table[320];
  131. int tactical_view_cos_table[320];
  132. int main_view_cos_table[320];
  133. int x_move_table[3840];
  134. int y_move_table[3840];
  135. int increment[961];
  136. int screen_vars[8] = {149,11,12,-1,0,0,0,0};
  137. int mode = 1,PersTrans = 0;
  138. int PT_EDDIE[320],PT_Tactical[320],PT_main[320]; /* casting angle lookup tables */
  139. int Vector_Distance[320]; /* initial vector offsets for rays cast */
  140. int Tactical_Vector_Distance[320],main_Vector_Distance[320]; /* initial vector offsets for rays cast */
  141.  
  142. int State_Frame = 0, State_Counter = 0, Direction = 1, State_Frame_Counter = 0;
  143.  
  144. int ColourMap[256],pallette_entry,pallette_entry_red,pallette_entry_green,pallette_entry_blue;
  145.  
  146. int Secret_Door_Position,Secret_Door_Orientation,result,temp_counter=1,temp_direction = 1;
  147.  
  148. int Weapon_Active = 0, Weapon_Type = 0;
  149. int current_screen_mode,colour_red = 255,colour_green = 255,colour_blue = 255;
  150.  
  151. sprite_area *sprite_pointer,*sprite_mode_pointer;
  152. sprite_area sprite_address;
  153. sprite_area *sprite_data_offset;
  154. int sprite_data_address,*sprite_mode_address;
  155. int *sprite_data_address_pointer;
  156.  
  157. int Floor_Data[2][128][4]; /* floor data array */
  158. int Tactical_Floor_Data[2][128][4]; /* floor data array */
  159. int main_Floor_Data[2][128][4]; /* floor data array */
  160. int Floor_Sprite[2][4096];
  161. int Floor_Block[10];
  162. int Floor_On_Off = 1,Frame_Number = 1, Frame_Increment = 1;
  163. float rotate_cos[121];
  164. int scale_factor,tactical_scale_factor,main_scale_factor;
  165. float rotate_sin[121];
  166. int int_rotate_cos[121];
  167. int int_rotate_sin[121];
  168.  
  169. int Bar_Data[1280];
  170.  
  171. int Screen_Mode = broadcast,Tasking_Mode = Multi;
  172. int Play_Mode = 1;
  173.  
  174. int OS_X_Pixels, OS_Y_Pixels, OS_Bits_Per_Pixel;
  175. wimp_wind main_window,*main_window_pointer;    /* Pointer to main window definition */
  176. int main_window_size[5];
  177. wimp_openstr biohazard_open;
  178.  
  179. int rotate_position;
  180. int Right_Rotation_Counter,Left_Rotation_Counter,Rotation_Value;
  181.  
  182. int screen_address,Frame_Size=192,sprite_x,sprite_y;
  183.  
  184. int screen_height=238,screen_width=320;
  185. int current_screen_height=72,current_screen_width=96;
  186. int tactical_screen_height=60,tactical_screen_width=80;
  187. int main_screen_height=120,main_screen_width=160;
  188.  
  189. int Sprite_Plot_Block[30];
  190. int Weapon_Plot_Block[30];
  191.  
  192. const int door_code = 2<<8;
  193. const int door_wall_code = 4<<8;
  194. const int Secret_Door_Code = 254<<8;
  195.  
  196. /* moved from BioHazard app */
  197. float theta,angle,scanline,move,temp_move,move2; /* trig & div table calc variables */
  198. float c,sn,ang,vx,vz,a1,PI = 3.141592654,toround; /* perspective lookup variables */
  199.  
  200. float x1,y1,x2,y2,xa,ya,xg,yg; /* floor data table calc variables */
  201. float rotate_angle;
  202.  
  203. int Quit = 0,Buttons,Players = 1,FrameCounter=0, Wait_Mode = 0,loopA;
  204.  
  205. int door_active[2], door_frame_counter[2], door_position[2][2];
  206.  
  207. int X=384<<16,Y=224<<16,direction_angle = 2880,X_conv1,Y_conv1;
  208. int loop1,loop2,s = 0,FastMode = 0, rotate_offset,floor_flag=0,floor_test=64;
  209.  
  210. int Backdrop[20480];
  211. int Black_Box[1];
  212. int BB_Flag = 1;
  213. int BB_Pointer = 1;
  214. int BB_Value = 0;
  215.  
  216. int Last_Floor, Map_Magnification = 32;
  217.  
  218. void Draw_Map(int Yahoo_address)
  219. {
  220.    /* Compute map coordinates from current X,Y coords.
  221.  
  222.    The points are calculated in the following order:
  223.  
  224.        2-------1 ^
  225.        |       | |
  226.        |   +   | |Map_Magnification.
  227.        |    X,Y| |
  228.        3-------4 v
  229.  
  230.    They are then rotated in accordance with Direction_Angle.*/
  231.  
  232.    float rotate_x1,rotate_y1;
  233.    float rotate_x2,rotate_y2;
  234.    float rotate_x3,rotate_y3;
  235.    float rotate_x4,rotate_y4;
  236.    float temp,map_angle,map_cos,map_sin;
  237.  
  238.    int   x_pixel_increment,y_pixel_increment;
  239.    int   x_line_increment,y_line_increment;
  240.    int   Map_Plot_Block[10],map_line_length=192;
  241.  
  242.    rotate_x1 = -(Map_Magnification/2);
  243.    rotate_y1 = (Map_Magnification/2);
  244.  
  245.    rotate_x2 = (Map_Magnification/2);
  246.    rotate_y2 = (Map_Magnification/2);
  247.  
  248.    rotate_x3 = (Map_Magnification/2);
  249.    rotate_y3 = -(Map_Magnification/2);
  250.  
  251.    rotate_x4 = -(Map_Magnification/2);
  252.    rotate_y4 = -(Map_Magnification/2);
  253.  
  254.    /* rotate about X,Y */
  255.    map_angle = direction_angle * 1.63624617374E-03;
  256.    map_cos = cos(map_angle);
  257.    map_sin = sin(map_angle);
  258.  
  259.    temp = (rotate_x1 * map_cos) - (rotate_y1 * map_sin);
  260.    rotate_y1 = (rotate_x1 * map_sin) + (rotate_y1 * map_cos);
  261.    rotate_x1 = temp;
  262.  
  263.    temp = (rotate_x2 * map_cos) - (rotate_y2 * map_sin);
  264.    rotate_y2 = (rotate_x2 * map_sin) + (rotate_y2 * map_cos);
  265.    rotate_x2 = temp;
  266.  
  267.    temp = (rotate_x3 * map_cos) - (rotate_y3 * map_sin);
  268.    rotate_y3 = (rotate_x3 * map_sin) + (rotate_y3 * map_cos);
  269.    rotate_x3 = temp;
  270.  
  271.    /*temp = (rotate_x4 * map_cos) - (rotate_y4 * map_sin);
  272.    rotate_y4 = (rotate_x4 * map_sin) + (rotate_y4 * map_cos);
  273.    rotate_x4 = temp;*/
  274.  
  275.    /* compute pixel increments */
  276.    x_pixel_increment = (int)(((rotate_x1 - rotate_x2)/map_line_length)*65536);
  277.    y_pixel_increment = (int)(((rotate_y1 - rotate_y2)/map_line_length)*65536);
  278.  
  279.    /* compute line increments */
  280.    x_line_increment = -(int)(((rotate_x2 - rotate_x3)/map_line_length)*65536);
  281.    y_line_increment = -(int)(((rotate_y2 - rotate_y3)/map_line_length)*65536);
  282.  
  283.    Map_Plot_Block[0] = (int)(rotate_x2*65536)+(Y>>6);
  284.    Map_Plot_Block[1] = (int)(rotate_y2*65536)+(X>>6);
  285.    Map_Plot_Block[2] = Yahoo_address;
  286.    Map_Plot_Block[3] = (int)&Map_Data[0];
  287.    Map_Plot_Block[4] = x_pixel_increment;
  288.    Map_Plot_Block[5] = y_pixel_increment;
  289.    Map_Plot_Block[6] = x_line_increment;
  290.    Map_Plot_Block[7] = y_line_increment;
  291.  
  292.    if (Screen_Mode == VGA)
  293.    {
  294.       PlotMapVGA((int)&Map_Plot_Block[0]);
  295.    }
  296.    else
  297.    {
  298.       PlotMap((int)&Map_Plot_Block[0]);
  299.    }
  300. }
  301.  
  302. void DrawSmallMap(int Yahoo_address,int Fade_Type)
  303. {
  304.    /* Compute map coordinates from current X,Y coords.
  305.  
  306.    The points are calculated in the following order:
  307.  
  308.        2-------1 ^
  309.        |       | |
  310.        |   +   | |Map_Magnification.
  311.        |    X,Y| |
  312.        3-------4 v
  313.  
  314.    They are then rotated in accordance with Direction_Angle.*/
  315.  
  316.    float rotate_x1,rotate_y1;
  317.    float rotate_x2,rotate_y2;
  318.    float rotate_x3,rotate_y3;
  319.    float rotate_x4,rotate_y4;
  320.    float temp,map_angle,map_cos,map_sin;
  321.  
  322.    int   x_pixel_increment,y_pixel_increment;
  323.    int   x_line_increment,y_line_increment;
  324.    int   Map_Plot_Block[10],map_line_length=64;
  325.  
  326.    rotate_x1 = -(Map_Magnification/2);
  327.    rotate_y1 = (Map_Magnification/2);
  328.  
  329.    rotate_x2 = (Map_Magnification/2);
  330.    rotate_y2 = (Map_Magnification/2);
  331.  
  332.    rotate_x3 = (Map_Magnification/2);
  333.    rotate_y3 = -(Map_Magnification/2);
  334.  
  335.    rotate_x4 = -(Map_Magnification/2);
  336.    rotate_y4 = -(Map_Magnification/2);
  337.  
  338.    /* rotate about X,Y */
  339.    map_angle = direction_angle * 1.63624617374E-03;
  340.    map_cos = cos(map_angle);
  341.    map_sin = sin(map_angle);
  342.  
  343.    temp = (rotate_x1 * map_cos) - (rotate_y1 * map_sin);
  344.    rotate_y1 = (rotate_x1 * map_sin) + (rotate_y1 * map_cos);
  345.    rotate_x1 = temp;
  346.  
  347.    temp = (rotate_x2 * map_cos) - (rotate_y2 * map_sin);
  348.    rotate_y2 = (rotate_x2 * map_sin) + (rotate_y2 * map_cos);
  349.    rotate_x2 = temp;
  350.  
  351.    temp = (rotate_x3 * map_cos) - (rotate_y3 * map_sin);
  352.    rotate_y3 = (rotate_x3 * map_sin) + (rotate_y3 * map_cos);
  353.    rotate_x3 = temp;
  354.  
  355.    /*temp = (rotate_x4 * map_cos) - (rotate_y4 * map_sin);
  356.    rotate_y4 = (rotate_x4 * map_sin) + (rotate_y4 * map_cos);
  357.    rotate_x4 = temp;*/
  358.  
  359.    /* compute pixel increments */
  360.    x_pixel_increment = (int)(((rotate_x1 - rotate_x2)/map_line_length)*65536);
  361.    y_pixel_increment = (int)(((rotate_y1 - rotate_y2)/map_line_length)*65536);
  362.  
  363.    /* compute line increments */
  364.    x_line_increment = -(int)(((rotate_x2 - rotate_x3)/map_line_length)*65536);
  365.    y_line_increment = -(int)(((rotate_y2 - rotate_y3)/map_line_length)*65536);
  366.  
  367.    Map_Plot_Block[0] = (int)(rotate_x2*65536)+(Y>>6);
  368.    Map_Plot_Block[1] = (int)(rotate_y2*65536)+(X>>6);
  369.    Map_Plot_Block[2] = Yahoo_address;
  370.    Map_Plot_Block[3] = (int)&Map_Data[0];
  371.    Map_Plot_Block[4] = x_pixel_increment;
  372.    Map_Plot_Block[5] = y_pixel_increment;
  373.    Map_Plot_Block[6] = x_line_increment;
  374.    Map_Plot_Block[7] = y_line_increment;
  375.  
  376.    if (Screen_Mode == VGA)
  377.    {
  378.      if (Fade_Type == 0)
  379.      {
  380.        PlotSmallMapVGA((int)&Map_Plot_Block[0]);
  381.      }
  382.      else
  383.      {
  384.        PlotSmallFadedMapVGA((int)&Map_Plot_Block[0]);
  385.      }
  386.    }
  387.    else
  388.    {
  389.      if (Fade_Type == 0)
  390.      {
  391.         PlotSmallMap((int)&Map_Plot_Block[0]);
  392.      }
  393.      else
  394.      {
  395.         PlotSmallFadedMap((int)&Map_Plot_Block[0]);
  396.      }
  397.    }
  398. }
  399.  
  400.  
  401. int convert_colour(int R,int G,int B)
  402. {
  403.  
  404.     int result;
  405.  
  406.     R = R >> 4;
  407.     G = G >> 3;
  408.     B = B >> 4;
  409.  
  410.     result = (R & 7)|(G & 3)|(B & 3);
  411.     result = result|((R & 8)<<1);
  412.     result = result|((G & 12)<<3);
  413.     result = result|((B & 4)<<1)|((B & 8)<<4);
  414.  
  415.     /*pallette_entry_red = ((loop1 & 7)<<4) + ((loop1 & 16)<<3);
  416.     pallette_entry_green = ((loop1 & 3)<<4) + ((loop1 & 96)<<1);
  417.     pallette_entry_blue = ((loop1 & 3)<<4) + ((loop1 & 4)<<3) + (loop1 & 128);
  418.     pallette_entry = (pallette_entry_red<<8)+(pallette_entry_green<<16)+(pallette_entry_blue<<24);
  419.     registers.r[0] = pallette_entry;*/
  420.  
  421.     return result;
  422. }
  423.  
  424. void Resize_Screen()
  425. {
  426.  
  427.   int  Quit_Resize = 0;
  428.  
  429.   /* draw screen border */
  430.   if (Screen_Mode == VGA)
  431.   {
  432.     DrawBorderVGA((screen_vars[0]),screen_width,screen_height,(int)&Backdrop[0]);
  433.     DrawBorderVGA((screen_vars[0]+153600),screen_width,screen_height,(int)&Backdrop[0]);
  434.   }
  435.   else
  436.   {
  437.     if (Tasking_Mode == Single)
  438.     {
  439.       DrawBorder((screen_vars[0]),screen_width,screen_height,(int)&Backdrop[0]);
  440.       DrawBorder((screen_vars[0]+81920),screen_width,screen_height,(int)&Backdrop[0]);
  441.     }
  442.     else
  443.     {
  444.       DrawBorder(virtual_screen_pointer,screen_width,screen_height,(int)&Backdrop[0]);
  445.     }
  446.   }
  447.  
  448.   if (screen_height == 238)
  449.   {
  450.     screen_height = 240;
  451.   }
  452.  
  453.   while (Quit_Resize != 1)
  454.   {
  455.  
  456.     /* read keyboard inputs scan for A */
  457.     registers.r[0] = 129;
  458.     registers.r[1] = -66;
  459.     registers.r[2] = 255;
  460.     os_swi(6, point_registers); /* OS_Byte */
  461.     if ((registers.r[1] == 255) && (registers.r[2] == 255))
  462.     {
  463.        if (screen_width < 320)
  464.        {
  465.          screen_width  += 16;
  466.          screen_height += 12;
  467.  
  468.          /* draw screen border */
  469.          if (Screen_Mode == VGA)
  470.          {
  471.            DrawBorderVGA((screen_vars[0]),screen_width,screen_height,(int)&Backdrop[0]);
  472.            DrawBorderVGA((screen_vars[0]+153600),screen_width,screen_height,(int)&Backdrop[0]);
  473.          }
  474.          else
  475.          {
  476.            if (Tasking_Mode == Single )
  477.            {
  478.              DrawBorder((screen_vars[0]),screen_width,screen_height,(int)&Backdrop[0]);
  479.              DrawBorder((screen_vars[0]+81920),screen_width,screen_height,(int)&Backdrop[0]);
  480.            }
  481.            else
  482.            {
  483.              DrawBorder(virtual_screen_pointer,screen_width,screen_height,(int)&Backdrop[0]);
  484.            }
  485.          }
  486.  
  487.            /* Wait */
  488.            registers.r[0] = 19;
  489.            os_swi(6, point_registers);
  490.            registers.r[0] = 19;
  491.            os_swi(6, point_registers);
  492.            registers.r[0] = 19;
  493.            os_swi(6, point_registers);
  494.            registers.r[0] = 19;
  495.            os_swi(6, point_registers);
  496.            registers.r[0] = 19;
  497.            os_swi(6, point_registers);
  498.  
  499.        }
  500.     }
  501.  
  502.     /* read keyboard inputs scan for S */
  503.     registers.r[0] = 129;
  504.     registers.r[1] = -82;
  505.     registers.r[2] = 255;
  506.     os_swi(6, point_registers); /* OS_Byte */
  507.     if ((registers.r[1] == 255) && (registers.r[2] == 255))
  508.     {
  509.        if (screen_width > 80)
  510.        {
  511.          screen_width  -= 16;
  512.          screen_height -= 12;
  513.  
  514.          /* draw screen border */
  515.          if (Screen_Mode == VGA)
  516.          {
  517.            DrawBorderVGA((screen_vars[0]),screen_width,screen_height,(int)&Backdrop[0]);
  518.            DrawBorderVGA((screen_vars[0]+153600),screen_width,screen_height,(int)&Backdrop[0]);
  519.          }
  520.          else
  521.          {
  522.            if (Tasking_Mode == Single)
  523.            {
  524.              DrawBorder((screen_vars[0]),screen_width,screen_height,(int)&Backdrop[0]);
  525.              DrawBorder((screen_vars[0]+81920),screen_width,screen_height,(int)&Backdrop[0]);
  526.            }
  527.            else
  528.            {
  529.              DrawBorder(virtual_screen_pointer,screen_width,screen_height,(int)&Backdrop[0]);
  530.            }
  531.          }
  532.  
  533.            /* Wait */
  534.            registers.r[0] = 19;
  535.            os_swi(6, point_registers);
  536.            registers.r[0] = 19;
  537.            os_swi(6, point_registers);
  538.            registers.r[0] = 19;
  539.            os_swi(6, point_registers);
  540.            registers.r[0] = 19;
  541.            os_swi(6, point_registers);
  542.            registers.r[0] = 19;
  543.            os_swi(6, point_registers);
  544.  
  545.        }
  546.     }
  547.  
  548.     /* read keyboard inputs scan for SPACE */
  549.     registers.r[0] = 129;
  550.     registers.r[1] = -99;
  551.     registers.r[2] = 255;
  552.     os_swi(6, point_registers); /* OS_Byte */
  553.     if ((registers.r[1] == 255) && (registers.r[2] == 255))
  554.     {
  555.         Quit_Resize = 1;
  556.     }
  557.   }
  558.  
  559.   if (screen_height == 240)
  560.   {
  561.     screen_height = 238;
  562.   }
  563.  
  564. }
  565.  
  566. void Calculate_Tactical_Tables()
  567. {
  568.     float angle,scanline,move,tactical_scaling_factor; /* trig & div table calc variables */
  569.     float c,sn,ang,vx,vz,a1,PI = 3.141592654,toround; /* perspective lookup variables */
  570.  
  571.     float x1,y1,x2,y2,xa,ya,xg,yg; /* floor data table calc variables */
  572.     float rotate_angle,move2,gradient;
  573.     float PIdiv2 = PI/2.0;
  574.     float PIdiv180 = PI/180.0;
  575.     float PIdiv180div09375  = (PI/180.0)/0.09375;
  576.  
  577.     int loop2;
  578.  
  579.   /* Set up floor table */
  580.   /*PIdiv180 = PI/180.0;
  581.   PIdiv2 = PI/2.0;
  582.   PIdiv180div09375 = (PI/180.0)/0.09375;*/
  583.  
  584.   /* precalc cos & sin values */
  585.   for (rotate_position = 0; rotate_position < 121; rotate_position++)
  586.   {
  587.     rotate_angle = rotate_position * (3*(PIdiv180));
  588.     rotate_cos[rotate_position] = cos(rotate_angle);
  589.     rotate_sin[rotate_position] = sin(rotate_angle);
  590.     int_rotate_cos[rotate_position] = (int)((cos(rotate_angle))*65536);
  591.     int_rotate_sin[rotate_position] = (int)((sin(rotate_angle))*65536);
  592.   }
  593.  
  594.     tactical_scaling_factor = tactical_screen_height>>1;
  595.  
  596.     tactical_scaling_factor = (tactical_scaling_factor*1.3)/120.0;
  597.  
  598.     tactical_scale_factor = (int)(tactical_scaling_factor * 65536);
  599.  
  600.     tactical_scaling_factor = tactical_scaling_factor*8192.0;
  601.  
  602.  
  603.   /*proj_angle = tan(0.4636476091);*/
  604.   for (loop2= 1; loop2 < ((tactical_screen_height/2)+1); loop2++)
  605.   {
  606.     /* calculate z distances from raster lines on screen*/
  607.     move = (tactical_scaling_factor)/loop2;
  608.  
  609.     /* calculate intercepts for x1,y1 & x2,y2 co-ordinates */
  610.     for (rotate_position = 120; rotate_position < 121; rotate_position++)
  611.     {
  612.       xa = -move*0.5;
  613.       ya = move;
  614.  
  615.       x1 = (xa * rotate_cos[rotate_position])-(ya * rotate_sin[rotate_position]);
  616.       y1 = (xa * rotate_sin[rotate_position])+(ya * rotate_cos[rotate_position]);
  617.  
  618.       xa = move*0.5;
  619.       ya = move;
  620.  
  621.       x2 = (xa * rotate_cos[rotate_position])-(ya * rotate_sin[rotate_position]);
  622.       y2 = (xa * rotate_sin[rotate_position])+(ya * rotate_cos[rotate_position]);
  623.  
  624.       xg = (x2-x1)/tactical_screen_width;
  625.       yg = (y2-y1)/tactical_screen_width;
  626.  
  627.       /* store results in array */
  628.       Tactical_Floor_Data[120-rotate_position][loop2-1][0] = (int)(x1*65536);
  629.       /*Floor_Data[120-rotate_position][loop2-1][0] = Floor_Data[120-rotate_position][loop2-1][0]&4194303;*/
  630.  
  631.       Tactical_Floor_Data[120-rotate_position][loop2-1][1] = (int)(y1*65536);
  632.       /*Floor_Data[120-rotate_position][loop2-1][1] = Floor_Data[120-rotate_position][loop2-1][1]&4194303;
  633.       Floor_Data[120-rotate_position][loop2-1][0] -= Floor_Data[120-rotate_position][loop2-1][1]<<6;*/
  634.  
  635.       Tactical_Floor_Data[120-rotate_position][loop2-1][2] = (int)(xg*65536);
  636.       Tactical_Floor_Data[120-rotate_position][loop2-1][3] = (int)(yg*65536);
  637.  
  638.       /*Floor_Data[120-rotate_position][loop2-1][2] = (int)((xg)*65536);*/
  639.  
  640.     }
  641.   }
  642.  
  643.   PIdiv2 = PI/2.0;
  644.   PIdiv180div09375 = (PI/180.0)/0.09375;
  645.   /* Set up angle casting tables & vector direction offsets */
  646.   ang = 270*(PIdiv180);
  647.   c = cos(ang);
  648.   sn = sin(ang);
  649.   scanline = -(tactical_screen_width/2);
  650.   for (loop2=0; loop2<(tactical_screen_width>>1); loop2++)
  651.   {
  652.     /* Eddie's transform */
  653.     vx = (scanline*c) + (tactical_screen_width * sn);
  654.     vz = (tactical_screen_width*c) - (scanline*sn);
  655.     angle = atan(vx/vz);
  656.     toround = (angle/PIdiv180)/0.09375;
  657.     PT_Tactical[loop2] = toround;
  658.     tactical_view_cos_table[loop2] = (int)((cos((PIdiv2)-angle))*262144);
  659.     tactical_view_cos_table[(tactical_screen_width-1)-loop2] = (int)((cos(-((PIdiv2)-angle)))*262144);
  660.     if ((toround - PT_Tactical[loop2]) > 0.5)
  661.     {
  662.       PT_Tactical[loop2] += 1;
  663.     }
  664.     PT_Tactical[loop2] = 960-PT_Tactical[loop2];
  665.     PT_Tactical[(tactical_screen_width-1)-loop2] = -PT_Tactical[loop2];
  666.     Tactical_Vector_Distance[loop2] = (32/cos((PIdiv2)-angle));
  667.     Tactical_Vector_Distance[(tactical_screen_width-1)-loop2] = Tactical_Vector_Distance[loop2];
  668.  
  669.     scanline += 1.0;
  670.   }
  671. }
  672.  
  673. void Calculate_main_Tables()
  674. {
  675.     float angle,scanline,move,main_scaling_factor; /* trig & div table calc variables */
  676.     float c,sn,ang,vx,vz,a1,PI = 3.141592654,toround; /* perspective lookup variables */
  677.  
  678.     float x1,y1,x2,y2,xa,ya,xg,yg; /* floor data table calc variables */
  679.     float rotate_angle,move2,gradient;
  680.     float PIdiv2 = PI/2.0;
  681.     float PIdiv180 = PI/180.0;
  682.     float PIdiv180div09375  = (PI/180.0)/0.09375;
  683.  
  684.     int loop2;
  685.  
  686.   /* Set up floor table */
  687.   /*PIdiv180 = PI/180.0;
  688.   PIdiv2 = PI/2.0;
  689.   PIdiv180div09375 = (PI/180.0)/0.09375;*/
  690.  
  691.   /* precalc cos & sin values */
  692.   for (rotate_position = 0; rotate_position < 121; rotate_position++)
  693.   {
  694.     rotate_angle = rotate_position * (3*(PIdiv180));
  695.     rotate_cos[rotate_position] = cos(rotate_angle);
  696.     rotate_sin[rotate_position] = sin(rotate_angle);
  697.     int_rotate_cos[rotate_position] = (int)((cos(rotate_angle))*65536);
  698.     int_rotate_sin[rotate_position] = (int)((sin(rotate_angle))*65536);
  699.   }
  700.  
  701.     main_scaling_factor = main_screen_height>>1;
  702.  
  703.     main_scaling_factor = (main_scaling_factor*1.3)/120.0;
  704.  
  705.     main_scale_factor = (int)(main_scaling_factor * 65536);
  706.  
  707.     main_scaling_factor = main_scaling_factor*8192.0;
  708.  
  709.  
  710.   /*proj_angle = tan(0.4636476091);*/
  711.   for (loop2= 1; loop2 < ((main_screen_height/2)+1); loop2++)
  712.   {
  713.     /* calculate z distances from raster lines on screen*/
  714.     move = (main_scaling_factor)/loop2;
  715.  
  716.     /* calculate intercepts for x1,y1 & x2,y2 co-ordinates */
  717.     for (rotate_position = 120; rotate_position < 121; rotate_position++)
  718.     {
  719.       xa = -move*0.5;
  720.       ya = move;
  721.  
  722.       x1 = (xa * rotate_cos[rotate_position])-(ya * rotate_sin[rotate_position]);
  723.       y1 = (xa * rotate_sin[rotate_position])+(ya * rotate_cos[rotate_position]);
  724.  
  725.       xa = move*0.5;
  726.       ya = move;
  727.  
  728.       x2 = (xa * rotate_cos[rotate_position])-(ya * rotate_sin[rotate_position]);
  729.       y2 = (xa * rotate_sin[rotate_position])+(ya * rotate_cos[rotate_position]);
  730.  
  731.       xg = (x2-x1)/main_screen_width;
  732.       yg = (y2-y1)/main_screen_width;
  733.  
  734.       /* store results in array */
  735.       main_Floor_Data[120-rotate_position][loop2-1][0] = (int)(x1*65536);
  736.       /*Floor_Data[120-rotate_position][loop2-1][0] = Floor_Data[120-rotate_position][loop2-1][0]&4194303;*/
  737.  
  738.       main_Floor_Data[120-rotate_position][loop2-1][1] = (int)(y1*65536);
  739.       /*Floor_Data[120-rotate_position][loop2-1][1] = Floor_Data[120-rotate_position][loop2-1][1]&4194303;
  740.       Floor_Data[120-rotate_position][loop2-1][0] -= Floor_Data[120-rotate_position][loop2-1][1]<<6;*/
  741.  
  742.       main_Floor_Data[120-rotate_position][loop2-1][2] = (int)(xg*65536);
  743.       main_Floor_Data[120-rotate_position][loop2-1][3] = (int)(yg*65536);
  744.  
  745.       /*Floor_Data[120-rotate_position][loop2-1][2] = (int)((xg)*65536);*/
  746.  
  747.     }
  748.   }
  749.  
  750.   PIdiv2 = PI/2.0;
  751.   PIdiv180div09375 = (PI/180.0)/0.09375;
  752.   /* Set up angle casting tables & vector direction offsets */
  753.   ang = 270*(PIdiv180);
  754.   c = cos(ang);
  755.   sn = sin(ang);
  756.   scanline = -(main_screen_width/2);
  757.   for (loop2=0; loop2<(main_screen_width>>1); loop2++)
  758.   {
  759.     /* Eddie's transform */
  760.     vx = (scanline*c) + (main_screen_width * sn);
  761.     vz = (main_screen_width*c) - (scanline*sn);
  762.     angle = atan(vx/vz);
  763.     toround = (angle/PIdiv180)/0.09375;
  764.     PT_main[loop2] = toround;
  765.     main_view_cos_table[loop2] = (int)((cos((PIdiv2)-angle))*262144);
  766.     main_view_cos_table[(main_screen_width-1)-loop2] = (int)((cos(-((PIdiv2)-angle)))*262144);
  767.     if ((toround - PT_main[loop2]) > 0.5)
  768.     {
  769.       PT_main[loop2] += 1;
  770.     }
  771.     PT_main[loop2] = 960-PT_main[loop2];
  772.     PT_main[(main_screen_width-1)-loop2] = -PT_main[loop2];
  773.     main_Vector_Distance[loop2] = (32/cos((PIdiv2)-angle));
  774.     main_Vector_Distance[(main_screen_width-1)-loop2] = main_Vector_Distance[loop2];
  775.  
  776.     scanline += 1.0;
  777.   }
  778. }
  779.  
  780.  
  781. void Calculate_Tables()
  782. {
  783.     float angle,scanline,move,scaling_factor; /* trig & div table calc variables */
  784.     float c,sn,ang,vx,vz,a1,PI = 3.141592654,toround; /* perspective lookup variables */
  785.  
  786.     float x1,y1,x2,y2,xa,ya,xg,yg; /* floor data table calc variables */
  787.     float rotate_angle,move2,gradient;
  788.     float PIdiv2 = PI/2.0;
  789.     float PIdiv180 = PI/180.0;
  790.     float PIdiv180div09375  = (PI/180.0)/0.09375;
  791.  
  792.     int loop2;
  793.  
  794.   /* Set up floor table */
  795.   /*PIdiv180 = PI/180.0;
  796.   PIdiv2 = PI/2.0;
  797.   PIdiv180div09375 = (PI/180.0)/0.09375;*/
  798.  
  799.   /* precalc cos & sin values */
  800.   for (rotate_position = 0; rotate_position < 121; rotate_position++)
  801.   {
  802.     rotate_angle = rotate_position * (3*(PIdiv180));
  803.     rotate_cos[rotate_position] = cos(rotate_angle);
  804.     rotate_sin[rotate_position] = sin(rotate_angle);
  805.     int_rotate_cos[rotate_position] = (int)((cos(rotate_angle))*65536);
  806.     int_rotate_sin[rotate_position] = (int)((sin(rotate_angle))*65536);
  807.   }
  808.  
  809.     scaling_factor = screen_height>>1;
  810.  
  811.     scaling_factor = (scaling_factor*1.3)/120.0;
  812.  
  813.     scale_factor = (int)(scaling_factor * 65536);
  814.  
  815.     scaling_factor = scaling_factor*8192.0;
  816.  
  817.  
  818.   /*proj_angle = tan(0.4636476091);*/
  819.   for (loop2= 1; loop2 < ((screen_height/2)+1); loop2++)
  820.   {
  821.     /* calculate z distances from raster lines on screen*/
  822.     move = (scaling_factor)/loop2;
  823.  
  824.     /* calculate intercepts for x1,y1 & x2,y2 co-ordinates */
  825.     for (rotate_position = 120; rotate_position < 121; rotate_position++)
  826.     {
  827.       xa = -move*0.5;
  828.       ya = move;
  829.  
  830.       x1 = (xa * rotate_cos[rotate_position])-(ya * rotate_sin[rotate_position]);
  831.       y1 = (xa * rotate_sin[rotate_position])+(ya * rotate_cos[rotate_position]);
  832.  
  833.       xa = move*0.5;
  834.       ya = move;
  835.  
  836.       x2 = (xa * rotate_cos[rotate_position])-(ya * rotate_sin[rotate_position]);
  837.       y2 = (xa * rotate_sin[rotate_position])+(ya * rotate_cos[rotate_position]);
  838.  
  839.       xg = (x2-x1)/screen_width;
  840.       yg = (y2-y1)/screen_width;
  841.  
  842.       /* store results in array */
  843.       Floor_Data[120-rotate_position][loop2-1][0] = (int)(x1*65536);
  844.       /*Floor_Data[120-rotate_position][loop2-1][0] = Floor_Data[120-rotate_position][loop2-1][0]&4194303;*/
  845.  
  846.       Floor_Data[120-rotate_position][loop2-1][1] = (int)(y1*65536);
  847.       /*Floor_Data[120-rotate_position][loop2-1][1] = Floor_Data[120-rotate_position][loop2-1][1]&4194303;
  848.       Floor_Data[120-rotate_position][loop2-1][0] -= Floor_Data[120-rotate_position][loop2-1][1]<<6;*/
  849.  
  850.       Floor_Data[120-rotate_position][loop2-1][2] = (int)(xg*65536);
  851.       Floor_Data[120-rotate_position][loop2-1][3] = (int)(yg*65536);
  852.  
  853.       /*Floor_Data[120-rotate_position][loop2-1][2] = (int)((xg)*65536);*/
  854.  
  855.     }
  856.   }
  857.  
  858.   PIdiv2 = PI/2.0;
  859.   PIdiv180div09375 = (PI/180.0)/0.09375;
  860.   /* Set up angle casting tables & vector direction offsets */
  861.   ang = 270*(PIdiv180);
  862.   c = cos(ang);
  863.   sn = sin(ang);
  864.   scanline = -(screen_width/2);
  865.   for (loop2=0; loop2<(screen_width>>1); loop2++)
  866.   {
  867.     /* Eddie's transform */
  868.     vx = (scanline*c) + (screen_width * sn);
  869.     vz = (screen_width*c) - (scanline*sn);
  870.     angle = atan(vx/vz);
  871.     toround = (angle/PIdiv180)/0.09375;
  872.     PT_EDDIE[loop2] = toround;
  873.     view_cos_table[loop2] = (int)((cos((PIdiv2)-angle))*262144);
  874.     view_cos_table[(screen_width-1)-loop2] = (int)((cos(-((PIdiv2)-angle)))*262144);
  875.     if ((toround - PT_EDDIE[loop2]) > 0.5)
  876.     {
  877.       PT_EDDIE[loop2] += 1;
  878.     }
  879.     PT_EDDIE[loop2] = 960-PT_EDDIE[loop2];
  880.     PT_EDDIE[(screen_width-1)-loop2] = -PT_EDDIE[loop2];
  881.     Vector_Distance[loop2] = (32/cos((PIdiv2)-angle));
  882.     Vector_Distance[(screen_width-1)-loop2] = Vector_Distance[loop2];
  883.  
  884.     scanline += 1.0;
  885.   }
  886. }
  887.  
  888.  
  889.  
  890. void Read_Keys()
  891. {
  892.         Map_Data[X>>22][Y>>22] = 0;
  893.       /* read keyboard inputs scan for SHIFT */
  894.       registers.r[0] = 129;
  895.       registers.r[1] = -1;
  896.       registers.r[2] = 255;
  897.       os_swi(6, point_registers); /* OS_Byte */
  898.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  899.       {
  900.             Floor_On_Off++;
  901.             if (Floor_On_Off == 2)
  902.             {
  903.               Floor_On_Off = 0;
  904.             }
  905.       }
  906.  
  907.       /* read keyboard inputs scan for RETURN */
  908.       registers.r[0] = 129;
  909.       registers.r[1] = -74;
  910.       registers.r[2] = 255;
  911.       os_swi(6, point_registers); /* OS_Byte */
  912.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  913.       {
  914.             Weapon_Active = 1;
  915.             if (State_Counter == 0)
  916.             {
  917.               State_Counter=1;
  918.             }
  919.        }
  920.  
  921.       /* read keyboard inputs scan for F1 */
  922.       registers.r[0] = 129;
  923.       registers.r[1] = -114;
  924.       registers.r[2] = 255;
  925.       os_swi(6, point_registers); /* OS_Byte */
  926.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  927.       {
  928.             Weapon_Type++;
  929.             if (Weapon_Type == 4)
  930.             {
  931.               Weapon_Type = 0;
  932.             }
  933.             /* Load weapondata into sprite_data space */
  934.             registers.r[0] = 255;
  935.             if (Weapon_Type == Chainsaw)
  936.             {
  937.               registers.r[1] = (int)Chainsaw_name;
  938.             }
  939.             else if (Weapon_Type == Grenade)
  940.             {
  941.               registers.r[1] = (int)Grenade_name;
  942.             }
  943.             else if (Weapon_Type == Chaingun)
  944.             {
  945.               registers.r[1] = (int)Chaingun_name;
  946.             }
  947.             else
  948.             {
  949.               registers.r[1] = (int)MGun_name;
  950.             }
  951.             registers.r[2] = (int)&weapon_data[0];
  952.             registers.r[3] = 0;
  953.             os_swi(8, point_registers); /* OS_File */
  954.             /* play Weapon sample */
  955.             registers.r[0] = 0;
  956.             registers.r[1] = 29;
  957.             if (Weapon_Type == Chainsaw)
  958.             {
  959.               registers.r[2] = Weapon_1;
  960.             }
  961.             else if (Weapon_Type == Grenade)
  962.             {
  963.               registers.r[2] = Weapon_2;
  964.             }
  965.             else if (Weapon_Type == Chaingun)
  966.             {
  967.               registers.r[2] = Weapon_4;
  968.             }
  969.             else
  970.             {
  971.               registers.r[2] = Weapon_3;
  972.             }
  973.             registers.r[3] = 0;
  974.             registers.r[4] = 0;
  975.             registers.r[5] = 0;
  976.             registers.r[6] = 0;
  977.             os_swi(284806, point_registers); /* Dsym */
  978.  
  979.        }
  980.  
  981.       /* read keyboard inputs scan for F2 */
  982.       registers.r[0] = 129;
  983.       registers.r[1] = -115;
  984.       registers.r[2] = 255;
  985.       os_swi(6, point_registers); /* OS_Byte */
  986.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  987.       {
  988.         /*colour_red++;
  989.         if (colour_red > 255)
  990.         {
  991.           colour_red = 0;
  992.         }*/
  993.         Map_Magnification++;
  994.       }
  995.  
  996.       /* read keyboard inputs scan for F3 */
  997.       registers.r[0] = 129;
  998.       registers.r[1] = -116;
  999.       registers.r[2] = 255;
  1000.       os_swi(6, point_registers); /* OS_Byte */
  1001.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  1002.       {
  1003.         colour_green++;
  1004.         if (colour_green > 255)
  1005.         {
  1006.           colour_green = 0;
  1007.         }
  1008.       }
  1009.  
  1010.       /* read keyboard inputs scan for F4 */
  1011.       registers.r[0] = 129;
  1012.       registers.r[1] = -21;
  1013.       registers.r[2] = 255;
  1014.       os_swi(6, point_registers); /* OS_Byte */
  1015.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  1016.       {
  1017.         /*colour_blue++;
  1018.         if (colour_blue > 255)
  1019.         {
  1020.           colour_blue = 0;
  1021.         }*/
  1022.         Map_Magnification--;
  1023.       }
  1024.  
  1025.       /* read keyboard inputs scan for F5 */
  1026.       registers.r[0] = 129;
  1027.       registers.r[1] = -117;
  1028.       registers.r[2] = 255;
  1029.       os_swi(6, point_registers); /* OS_Byte */
  1030.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  1031.       {
  1032.             /* draw screen border */
  1033.             if (Screen_Mode == VGA)
  1034.             {
  1035.               DrawBorderVGA((screen_vars[0]),screen_width,screen_height,(int)&Backdrop[0]);
  1036.               DrawBorderVGA((screen_vars[0]+153600),screen_width,screen_height,(int)&Backdrop[0]);
  1037.             }
  1038.             else
  1039.             {
  1040.               if (Tasking_Mode == Single)
  1041.               {
  1042.                 DrawBorder((screen_vars[0]),screen_width,screen_height,(int)&Backdrop[0]);
  1043.                 DrawBorder((screen_vars[0]+81920),screen_width,screen_height,(int)&Backdrop[0]);
  1044.               }
  1045.               else
  1046.               {
  1047.                 DrawBorder(virtual_screen_pointer,screen_width,screen_height,(int)&Backdrop[0]);
  1048.               }
  1049.             }
  1050.             Play_Mode = Full_Screen;
  1051.             /* play Player sample */
  1052.             registers.r[0] = 1;
  1053.             registers.r[1] = 29;
  1054.             registers.r[2] = Player_1;
  1055.             registers.r[3] = 0;
  1056.             registers.r[4] = 0;
  1057.             registers.r[5] = 0;
  1058.             registers.r[6] = 0;
  1059.             os_swi(284806, point_registers); /* Dsym */
  1060.       }
  1061.  
  1062.       /* read keyboard inputs scan for F6 */
  1063.       registers.r[0] = 129;
  1064.       registers.r[1] = -118;
  1065.       registers.r[2] = 255;
  1066.       os_swi(6, point_registers); /* OS_Byte */
  1067.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  1068.       {
  1069.             /* draw screen border */
  1070.             if (Screen_Mode == VGA)
  1071.             {
  1072.               DrawBorderVGA((screen_vars[0]),tactical_screen_width,tactical_screen_height,(int)&Backdrop[0]);
  1073.               DrawBorderVGA((screen_vars[0]+153600),tactical_screen_width,tactical_screen_height,(int)&Backdrop[0]);
  1074.             }
  1075.             else
  1076.             {
  1077.               if (Tasking_Mode == Single)
  1078.               {
  1079.                 DrawBorder((screen_vars[0]),tactical_screen_width,tactical_screen_height,(int)&Backdrop[0]);
  1080.                 DrawBorder((screen_vars[0]+81920),tactical_screen_width,tactical_screen_height,(int)&Backdrop[0]);
  1081.               }
  1082.               else
  1083.               {
  1084.                 DrawBorder(virtual_screen_pointer,tactical_screen_width,tactical_screen_height,(int)&Backdrop[0]);
  1085.               }
  1086.             }
  1087.             Play_Mode = Tactical_Map;
  1088.             /* play Player sample */
  1089.             registers.r[0] = 1;
  1090.             registers.r[1] = 29;
  1091.             registers.r[2] = Player_2;
  1092.             registers.r[3] = 0;
  1093.             registers.r[4] = 0;
  1094.             registers.r[5] = 0;
  1095.             registers.r[6] = 0;
  1096.             os_swi(284806, point_registers); /* Dsym */
  1097.           }
  1098.  
  1099.       /* read keyboard inputs scan for F7 */
  1100.       registers.r[0] = 129;
  1101.       registers.r[1] = -119;
  1102.       registers.r[2] = 255;
  1103.       os_swi(6, point_registers); /* OS_Byte */
  1104.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  1105.       {
  1106.             /* draw screen border */
  1107.             if (Screen_Mode == VGA)
  1108.             {
  1109.               DrawBorderVGA((screen_vars[0]),main_screen_width,main_screen_height,(int)&Backdrop[0]);
  1110.               DrawBorderVGA((screen_vars[0]+153600),main_screen_width,main_screen_height,(int)&Backdrop[0]);
  1111.             }
  1112.             else
  1113.             {
  1114.               if (Tasking_Mode == Single)
  1115.               {
  1116.                 DrawBorder((screen_vars[0]),main_screen_width,main_screen_height,(int)&Backdrop[0]);
  1117.                 DrawBorder((screen_vars[0]+81920),main_screen_width,main_screen_height,(int)&Backdrop[0]);
  1118.               }
  1119.               else
  1120.               {
  1121.                 DrawBorder(virtual_screen_pointer,main_screen_width,main_screen_height,(int)&Backdrop[0]);
  1122.               }
  1123.             }
  1124.             Play_Mode = Main_Player;
  1125.             /* play Player sample */
  1126.             registers.r[0] = 1;
  1127.             registers.r[1] = 29;
  1128.             registers.r[2] = Player_3;
  1129.             registers.r[3] = 0;
  1130.             registers.r[4] = 0;
  1131.             registers.r[5] = 0;
  1132.             registers.r[6] = 0;
  1133.             os_swi(284806, point_registers); /* Dsym */
  1134.       }
  1135.  
  1136.  
  1137.       /* read keyboard inputs scan for F8 */
  1138.       registers.r[0] = 129;
  1139.       registers.r[1] = -120;
  1140.       registers.r[2] = 255;
  1141.       os_swi(6, point_registers); /* OS_Byte */
  1142.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  1143.       {
  1144.           /* show loading screen */
  1145.         registers.r[0] = (int)saving_name;
  1146.         os_swi(5, point_registers); /* OS_CLI */
  1147.           }
  1148.  
  1149.       /* read keyboard inputs scan for D */
  1150.       registers.r[0] = 129;
  1151.       registers.r[1] = -51;
  1152.       registers.r[2] = 255;
  1153.       os_swi(6, point_registers); /* OS_Byte */
  1154.       if (((registers.r[1] == 255) && (registers.r[2] == 255))||((BB_Value & 16) == 16))
  1155.       {
  1156.         /* set black box value */
  1157.         if (BB_Flag == 0)
  1158.         {
  1159.           BB_Value += 16;
  1160.         }
  1161.  
  1162.         X = X + ((x_move_table[direction_angle]>>3)<<FastMode);
  1163.         Y = Y - ((y_move_table[direction_angle]>>3)<<FastMode);
  1164.  
  1165.         if ((X & 4194303) > 2621440 && map[(X>>22)+1][Y>>22] != 0)
  1166.         {
  1167.           X = X - (X & 4194303) + 2621440;
  1168.         }
  1169.         else if ((X & 4194303) < 1572864 && map[(X>>22)-1][Y>>22] != 0)
  1170.         {
  1171.           X = X - (X & 4194303) + 1572864;
  1172.         }
  1173.  
  1174.         if ((Y & 4194303) > 2621440 && map[X>>22][(Y>>22)+1] != 0)
  1175.         {
  1176.           Y = Y - (Y & 4194303) + 2621440;
  1177.         }
  1178.         else if ((Y & 4194303) < 1572864 && map[X>>22][(Y>>22)-1] != 0)
  1179.         {
  1180.           Y = Y - (Y & 4194303) + 1572864;
  1181.         }
  1182.              }
  1183.  
  1184.       /* read keyboard inputs scan for C */
  1185.       registers.r[0] = 129;
  1186.       registers.r[1] = -83;
  1187.       registers.r[2] = 255;
  1188.       os_swi(6, point_registers); /* OS_Byte */
  1189.       if (((registers.r[1] == 255) && (registers.r[2] == 255))||((BB_Value & 8) == 8))
  1190.       {
  1191.         /* set black box value */
  1192.         if (BB_Flag == 0)
  1193.         {
  1194.           BB_Value += 8;
  1195.         }
  1196.  
  1197.         X = X - ((x_move_table[direction_angle]>>3)<<FastMode);
  1198.         Y = Y + ((y_move_table[direction_angle]>>3)<<FastMode);
  1199.  
  1200.         if ((X & 4194303) > 2621440 && map[(X>>22)+1][Y>>22] != 0)
  1201.         {
  1202.           X = X - (X & 4194303) + 2621440;
  1203.         }
  1204.         else if ((X & 4194303) < 1572864 && map[(X>>22)-1][Y>>22] != 0)
  1205.         {
  1206.           X = X - (X & 4194303) + 1572864;
  1207.         }
  1208.  
  1209.         if ((Y & 4194303) > 2621440 && map[X>>22][(Y>>22)+1] != 0)
  1210.         {
  1211.           Y = Y - (Y & 4194303) + 2621440;
  1212.         }
  1213.         else if ((Y & 4194303) < 1572864 && map[X>>22][(Y>>22)-1] != 0)
  1214.         {
  1215.           Y = Y - (Y & 4194303) + 1572864;
  1216.         }
  1217.       }
  1218.  
  1219.       /* read keyboard inputs scan for A */
  1220.       registers.r[0] = 129;
  1221.       registers.r[1] = -66;
  1222.       registers.r[2] = 255;
  1223.       os_swi(6, point_registers); /* OS_Byte */
  1224.       if (((registers.r[1] == 255) && (registers.r[2] == 255))||((BB_Value & 4) == 4))
  1225.       {
  1226.         /* set black box value */
  1227.         if (BB_Flag == 0)
  1228.         {
  1229.           BB_Value += 4;
  1230.         }
  1231.  
  1232.         if (Left_Rotation_Counter < 5)
  1233.         {
  1234.           Rotation_Value = 4;
  1235.         }
  1236.         else if (Left_Rotation_Counter < 10)
  1237.         {
  1238.           Rotation_Value = 8;
  1239.         }
  1240.         else if (Left_Rotation_Counter < 20)
  1241.         {
  1242.           Rotation_Value = 12;
  1243.         }
  1244.         else if (Left_Rotation_Counter < 30)
  1245.         {
  1246.           Rotation_Value = 16;
  1247.         }
  1248.         else if (Left_Rotation_Counter < 40)
  1249.         {
  1250.           Rotation_Value = 20;
  1251.         }
  1252.         else if (Left_Rotation_Counter < 80)
  1253.         {
  1254.           Rotation_Value = 24;
  1255.         }
  1256.         else
  1257.         {
  1258.           Rotation_Value = 32;
  1259.         }
  1260.  
  1261.         direction_angle = direction_angle - (Rotation_Value<<FastMode);
  1262.         if (direction_angle < 0)
  1263.         {
  1264.           direction_angle = 3840 + direction_angle;
  1265.         }
  1266.         Left_Rotation_Counter++;
  1267.       }
  1268.           else
  1269.           {
  1270.             Left_Rotation_Counter = 0;
  1271.           }
  1272.  
  1273.       /* read keyboard inputs scan for S */
  1274.       registers.r[0] = 129;
  1275.       registers.r[1] = -82;
  1276.       registers.r[2] = 255;
  1277.       os_swi(6, point_registers); /* OS_Byte */
  1278.       if (((registers.r[1] == 255) && (registers.r[2] == 255))||((BB_Value & 2) == 2))
  1279.       {
  1280.         /* set black box value */
  1281.         if (BB_Flag == 0)
  1282.         {
  1283.           BB_Value += 2;
  1284.         }
  1285.  
  1286.         if (Right_Rotation_Counter < 5)
  1287.         {
  1288.           Rotation_Value = 4;
  1289.         }
  1290.         else if (Right_Rotation_Counter < 10)
  1291.         {
  1292.           Rotation_Value = 8;
  1293.         }
  1294.         else if (Right_Rotation_Counter < 20)
  1295.         {
  1296.           Rotation_Value = 12;
  1297.         }
  1298.         else if (Right_Rotation_Counter < 30)
  1299.         {
  1300.           Rotation_Value = 16;
  1301.         }
  1302.         else if (Right_Rotation_Counter < 40)
  1303.         {
  1304.           Rotation_Value = 20;
  1305.         }
  1306.         else if (Right_Rotation_Counter < 80)
  1307.         {
  1308.           Rotation_Value = 24;
  1309.         }
  1310.         else
  1311.         {
  1312.           Rotation_Value = 32;
  1313.         }
  1314.  
  1315.         direction_angle = direction_angle + (Rotation_Value<<FastMode);
  1316.         if (direction_angle > 3839)
  1317.         {
  1318.           direction_angle = direction_angle - 3840;
  1319.         }
  1320.             Right_Rotation_Counter++;
  1321.       }
  1322.           else
  1323.           {
  1324.             Right_Rotation_Counter = 0;
  1325.           }
  1326.  
  1327.       /* read keyboard inputs scan for P */
  1328.       registers.r[0] = 129;
  1329.       registers.r[1] = -56;
  1330.       registers.r[2] = 255;
  1331.       os_swi(6, point_registers); /* OS_Byte */
  1332.       if ((registers.r[1] == 255) && (registers.r[2] == 255))
  1333.       {
  1334.         /*X=240<<16;
  1335.         Y=240<<16;
  1336.         direction_angle = 0;
  1337.         Black_Box[0] = BB_Pointer;
  1338.         BB_Flag = 1;
  1339.         BB_Pointer = 0;*/
  1340.  
  1341.             /* Save black box data */
  1342.             /*registers.r[0] = 10;
  1343.             registers.r[1] = (int)blackbox_name;
  1344.             registers.r[2] = 0;
  1345.             registers.r[3] = 0;
  1346.             registers.r[4] = (int)&Black_Box[0];
  1347.         registers.r[5] = ((int)&Black_Box[0])+40960;
  1348.             os_swi(8, point_registers);*/ /* OS_File */
  1349.  
  1350.             /* play Player sample */
  1351.             registers.r[0] = 1;
  1352.             registers.r[1] = 29;
  1353.             registers.r[2] = On;
  1354.             registers.r[3] = 0;
  1355.             registers.r[4] = 0;
  1356.             registers.r[5] = 0;
  1357.             registers.r[6] = 0;
  1358.             os_swi(284806, point_registers); /* Dsym */
  1359.  
  1360.         Resize_Screen();
  1361.         Calculate_Tables();
  1362.  
  1363.             /* play Player sample */
  1364.             registers.r[0] = 1;
  1365.             registers.r[1] = 29;
  1366.             registers.r[2] = Off;
  1367.             registers.r[3] = 0;
  1368.             registers.r[4] = 0;
  1369.             registers.r[5] = 0;
  1370.             registers.r[6] = 0;
  1371.             os_swi(284806, point_registers); /* Dsym */
  1372.  
  1373.       }
  1374.  
  1375.  
  1376.       /* read keyboard inputs scan for SPACE */
  1377.       registers.r[0] = 129;
  1378.       registers.r[1] = -99;
  1379.       registers.r[2] = 255;
  1380.       os_swi(6, point_registers); /* OS_Byte */
  1381.       if (((registers.r[1] == 255) && (registers.r[2] == 255))||((BB_Value & 1) == 1))
  1382.       {
  1383.         /* set black box value */
  1384.         if (BB_Flag == 0)
  1385.         {
  1386.           BB_Value += 1;
  1387.         }
  1388.  
  1389.         /* if facing forwards, check in right direction */
  1390.         if (direction_angle >= 3360||direction_angle < 480)
  1391.         {
  1392.           /* check if door exists in forwards direction */
  1393.           if (map[(X>>22)+1][(Y>>22)] == door_code)
  1394.           {
  1395.             /* check if doors are active */
  1396.             if ((door_active[0] == 0)&(door_map[(X>>22)+1][(Y>>22)] == 0))
  1397.             {
  1398.               /* if not, assign door active & stuff */
  1399.               door_active[0] = 1;
  1400.               door_frame_counter[0] = 0;
  1401.               door_position[0][0] = (X>>22)+1;
  1402.               door_position[0][1] = (Y>>22);
  1403.               /* play door opening sample */
  1404.               registers.r[0] = 0;
  1405.               registers.r[1] = 10;
  1406.               registers.r[2] = 4;
  1407.               registers.r[3] = 0;
  1408.               registers.r[4] = 0;
  1409.               registers.r[5] = 0;
  1410.               registers.r[6] = 0;
  1411.                /*os_swi(284806, point_registers);*/ /* Dsym */
  1412.             }
  1413.             else if ((door_active[1] == 0)&(door_map[(X>>22)+1][(Y>>22)] == 0))
  1414.             {
  1415.               door_active[1] = 1;
  1416.               door_frame_counter[1] = 0;
  1417.               door_position[1][0] = (X>>22)+1;
  1418.               door_position[1][1] = (Y>>22);
  1419.               /* play door opening sample */
  1420.               registers.r[0] = 0;
  1421.               registers.r[1] = 10;
  1422.               registers.r[2] = 4;
  1423.               registers.r[3] = 0;
  1424.               registers.r[4] = 0;
  1425.               registers.r[5] = 0;
  1426.               registers.r[6] = 0;
  1427.                /*os_swi(284806, point_registers);*/ /* Dsym */
  1428.             }
  1429.           }
  1430.         }
  1431.         else if (direction_angle >= 480&&direction_angle < 1440)
  1432.         {
  1433.           /* check if door exists in backwards direction */
  1434.           if (map[(X>>22)][(Y>>22)-1] == door_code)
  1435.           {
  1436.             /* check if doors are active */
  1437.             if ((door_active[0] == 0)&(door_map[(X>>22)][(Y>>22)-1] == 0))
  1438.             {
  1439.               /* if not, assign door active & stuff */
  1440.               door_active[0] = 1;
  1441.               door_frame_counter[0] = 0;
  1442.               door_position[0][0] = (X>>22);
  1443.               door_position[0][1] = (Y>>22)-1;
  1444.               /* play door opening sample */
  1445.               registers.r[0] = 0;
  1446.               registers.r[1] = 10;
  1447.               registers.r[2] = 4;
  1448.               registers.r[3] = 0;
  1449.               registers.r[4] = 0;
  1450.               registers.r[5] = 0;
  1451.               registers.r[6] = 0;
  1452.                /*os_swi(284806, point_registers);*/ /* Dsym */
  1453.             }
  1454.             else if ((door_active[1] == 0)&(door_map[(X>>22)][(Y>>22)-1] == 0))
  1455.             {
  1456.               door_active[1] = 1;
  1457.               door_frame_counter[1] = 0;
  1458.               door_position[1][0] = (X>>22);
  1459.               door_position[1][1] = (Y>>22)-1;
  1460.               /* play door opening sample */
  1461.               registers.r[0] = 0;
  1462.               registers.r[1] = 10;
  1463.               registers.r[2] = 4;
  1464.               registers.r[3] = 0;
  1465.               registers.r[4] = 0;
  1466.               registers.r[5] = 0;
  1467.               registers.r[6] = 0;
  1468.                /*os_swi(284806, point_registers);*/ /* Dsym */
  1469.             }
  1470.           }
  1471.         }
  1472.         else if (direction_angle >= 1440&&direction_angle < 2400)
  1473.         {
  1474.           /* check if door exists in left direction */
  1475.           if (map[(X>>22)-1][(Y>>22)] == door_code)
  1476.           {
  1477.             /* check if doors are active and if door is closed */
  1478.             if ((door_active[0] == 0)&(door_map[(X>>22)-1][(Y>>22)] == 0))
  1479.             {
  1480.               /* if not, assign door active & stuff */
  1481.               door_active[0] = 1;
  1482.               door_frame_counter[0] = 0;
  1483.               door_position[0][0] = (X>>22)-1;
  1484.               door_position[0][1] = (Y>>22);
  1485.               /* play door opening sample */
  1486.               registers.r[0] = 0;
  1487.               registers.r[1] = 10;
  1488.               registers.r[2] = 4;
  1489.               registers.r[3] = 0;
  1490.               registers.r[4] = 0;
  1491.               registers.r[5] = 0;
  1492.               registers.r[6] = 0;
  1493.                /*os_swi(284806, point_registers);*/ /* Dsym */
  1494.             }
  1495.             else if ((door_active[1] == 0)&(door_map[(X>>22)-1][(Y>>22)] == 0))
  1496.             {
  1497.               door_active[1] = 1;
  1498.               door_frame_counter[1] = 0;
  1499.               door_position[1][0] = (X>>22)-1;
  1500.               door_position[1][1] = (Y>>22);
  1501.               /* play door opening sample */
  1502.               registers.r[0] = 0;
  1503.               registers.r[1] = 10;
  1504.               registers.r[2] = 4;
  1505.               registers.r[3] = 0;
  1506.               registers.r[4] = 0;
  1507.               registers.r[5] = 0;
  1508.               registers.r[6] = 0;
  1509.                /*os_swi(284806, point_registers);*/ /* Dsym */
  1510.             }
  1511.           }
  1512.         }
  1513.         else if (direction_angle >= 2400&&direction_angle < 3360)
  1514.         {
  1515.           /* check if door exists in upwards direction */
  1516.           if (map[(X>>22)][(Y>>22)+1] == door_code)
  1517.           {
  1518.             /* check if doors are active & if door is closed */
  1519.             if ((door_active[0] == 0)&(door_map[(X>>22)][(Y>>22)+1] == 0))
  1520.             {
  1521.               /* if not, assign door active & stuff */
  1522.               door_active[0] = 1;
  1523.               door_frame_counter[0] = 0;
  1524.               door_position[0][0] = (X>>22);
  1525.               door_position[0][1] = (Y>>22)+1;
  1526.               /* play door opening sample */
  1527.               registers.r[0] = 0;
  1528.               registers.r[1] = 10;
  1529.               registers.r[2] = 4;
  1530.               registers.r[3] = 0;
  1531.               registers.r[4] = 0;
  1532.               registers.r[5] = 0;
  1533.               registers.r[6] = 0;
  1534.                /*os_swi(284806, point_registers);*/ /* Dsym */
  1535.             }
  1536.             else if ((door_active[1] == 0)&(door_map[(X>>22)][(Y>>22)+1] == 0))
  1537.             {
  1538.               door_active[1] = 1;
  1539.               door_frame_counter[1] = 0;
  1540.               door_position[1][0] = (X>>22);
  1541.               door_position[1][1] = (Y>>22)+1;
  1542.               /* play door opening sample */
  1543.               registers.r[0] = 0;
  1544.               registers.r[1] = 10;
  1545.               registers.r[2] = 4;
  1546.               registers.r[3] = 0;
  1547.               registers.r[4] = 0;
  1548.               registers.r[5] = 0;
  1549.               registers.r[6] = 0;
  1550.                /*os_swi(284806, point_registers);*/ /* Dsym */
  1551.             }
  1552.           }
  1553.         }
  1554.       }
  1555.  
  1556.  
  1557.       Map_Data[X>>22][Y>>22] = 255;
  1558.  
  1559. }
  1560.  
  1561. void RayCastScene(int Xb,int Yb,int angle_of_player,int screen_addr,int players,int *Perspective_Array,int scale_factor,int current_screen_width,int current_screen_height,int *current_view_cos_table)
  1562. {
  1563.     const int map_x_max = (63*64)<<16;
  1564.     const int map_x_min = 0;
  1565.     const int map_y_max = (63*64)<<16;
  1566.     const int map_y_min = 0;
  1567.  
  1568.     float move,move2,move3;
  1569.  
  1570.     int ScanLine,height,Xa,Ya;
  1571.     int viewing_angle,offset_angleX,offset_angleY;
  1572.  
  1573.     int x_position,x_intercept,y_intercept;
  1574.     int y_position,x_distance,y_distance;
  1575.     int initial_x_intercept,initial_y_intercept,quadrant;
  1576.     int x_door_hit,y_door_hit,door_intercept,x_door_offset,y_door_offset;
  1577.     int Plot_Block[20];
  1578.     int last_intercept = 0, Inner_Four;
  1579.     int smallest_height = 1<<26;
  1580.     int Big_X,Big_Y,X_sprite_distance,Y_sprite_distance;
  1581.     Big_X = Xb>>14;
  1582.     Big_Y = Yb>>14;
  1583.  
  1584.     Plot_Block[6] = players;
  1585.     Xa = Xb>>16;
  1586.     /* round Xa */
  1587.     /*if ((Xb-(Xa<<16)) > 32767)
  1588.     {
  1589.       Xa++;
  1590.     }*/
  1591.  
  1592.     Ya = Yb>>16;
  1593.     /* round Ya */
  1594.     /*if ((Yb-(Ya<<16)) > 32767)
  1595.     {
  1596.       Ya++;
  1597.     }*/
  1598.  
  1599.     Xb = Xa<<16;
  1600.     Yb = Ya<<16;
  1601.  
  1602.     for (ScanLine = 0; ScanLine < current_screen_width; ScanLine++)
  1603.     {
  1604.       /*  viewing_angle = angle_of_player - (PT_EDDIE[ScanLine]);*/
  1605.       viewing_angle = angle_of_player - (Perspective_Array[ScanLine]);
  1606.  
  1607.       if (viewing_angle<0)
  1608.       {
  1609.         viewing_angle = viewing_angle + 3840;
  1610.       }
  1611.       if (viewing_angle>3839)
  1612.       {
  1613.         viewing_angle = viewing_angle - 3840;
  1614.       }
  1615.  
  1616.       /* compute quadrant of ray */
  1617.       if ((viewing_angle>=0)&(viewing_angle<960))
  1618.       {
  1619.         quadrant = 0;
  1620.       }
  1621.       else if ((viewing_angle>959)&(viewing_angle<1920))
  1622.       {
  1623.         quadrant = 1;
  1624.       }
  1625.       else if ((viewing_angle>1919)&(viewing_angle<2880))
  1626.       {
  1627.         quadrant = 2;
  1628.       }
  1629.       else if ((viewing_angle>2879)&(viewing_angle<3840))
  1630.       {
  1631.         quadrant = 3;
  1632.       }
  1633.  
  1634.       offset_angleY = viewing_angle - (quadrant * 960);
  1635.       offset_angleX = 960-offset_angleY;
  1636.       x_intercept = 0;
  1637.       y_intercept = 0;
  1638.       x_door_hit = 0;
  1639.       y_door_hit = 0;
  1640.       x_distance = (5120<<16);
  1641.       y_distance = (5120<<16);
  1642.  
  1643.       /* compute initial x & y intercepts for current ray */
  1644.       if (quadrant == 3)
  1645.       {
  1646.         /* x intercept on right & bottom side of squares */
  1647.         /*initial_y_intercept = (Big_Y<<14)+(((256-(Big_X & 255))*tan_table[offset_angleX])>>2);
  1648.         initial_x_intercept = (Big_X<<14)+(((256-(Big_Y & 255))*tan_table[offset_angleY])>>2);*/
  1649.         initial_y_intercept = (Yb)+((64-(Xa & 63))*tan_table[offset_angleX]);
  1650.         initial_x_intercept = (Xb)+((64-(Ya & 63))*tan_table[offset_angleY]);
  1651.  
  1652.         if ((Ya & 65535) > 32767)
  1653.         {
  1654.           Ya += 65536;
  1655.         }
  1656.         if ((Xa & 65535) > 32767)
  1657.         {
  1658.           Xa += 65536;
  1659.         }
  1660.  
  1661.         if ((initial_x_intercept < map_x_max)&((viewing_angle != 0)&(viewing_angle != 1920)))
  1662.         {
  1663.           /* fire x ray & test for intersections */
  1664.           y_position = ((Ya>>6)+1);
  1665.           x_intercept = map[initial_x_intercept>>22][y_position];
  1666.           if (x_intercept != 0)
  1667.           {
  1668.             if (x_intercept == door_code)
  1669.             {
  1670.               door_intercept = initial_x_intercept; /*preserve initial intercept val */
  1671.  
  1672.               if (door_map[initial_x_intercept>>22][y_position] == Secret_Door_Code)
  1673.               {
  1674.                 /* check if door is moving in y direction */
  1675.                 if (Secret_Door_Orientation < 4)
  1676.                 {
  1677.                   /* find magnitude of x offset */
  1678.                   x_door_offset = Secret_Door_Position * tan_table[viewing_angle-2880];
  1679.                   door_intercept = (x_door_offset>>16) + ((initial_x_intercept >> 16) & 63);
  1680.                   /* if interception exceeds bounds of door resume tracing */
  1681.                   if (door_intercept > 63)
  1682.                   {
  1683.                     x_intercept = 0;
  1684.                   }
  1685.                   else
  1686.                   {
  1687.                     x_door_hit = 2;
  1688.                     initial_x_intercept += x_door_offset;
  1689.                   }
  1690.                 }
  1691.               }
  1692.               else
  1693.               {
  1694.  
  1695.                 x_door_hit = 1;
  1696.                 initial_x_intercept = initial_x_intercept + (increment[offset_angleY]>>1);
  1697.  
  1698.                 /* if door is open... */
  1699.                 if (door_map[initial_x_intercept>>22][y_position] != 0)
  1700.                 {
  1701.                   if (door_map[door_intercept>>22][y_position] >= ((initial_x_intercept>>16) & 63))
  1702.                   {
  1703.                     x_door_hit = 0;
  1704.                     x_intercept = 0;
  1705.                     initial_x_intercept = door_intercept;
  1706.                   }
  1707.                   else
  1708.                   {
  1709.                     initial_x_intercept -= ((door_map[door_intercept>>22][y_position]+1)<<16);
  1710.                   }
  1711.                 }
  1712.            }
  1713.             }
  1714.             else
  1715.             {
  1716.               if (x_intercept < 256)
  1717.               {
  1718.                 if (Sprite_Plot_Block[1] > 960)
  1719.                 {
  1720.                   Sprite_Plot_Block[1] = ScanLine+((320-current_screen_width)>>1);
  1721.                       Sprite_Plot_Block[2] = Sprite_Plot_Block[1];
  1722.                       X_sprite_distance = (Sprite_List[0].sprite_position_x - Xb);
  1723.                       Y_sprite_distance = (Sprite_List[0].sprite_position_y - Yb);
  1724.                       if (X_sprite_distance == 0)
  1725.                       {
  1726.                         X_sprite_distance = 1;
  1727.                       }
  1728.                       if (Y_sprite_distance == 0)
  1729.                       {
  1730.                         Y_sprite_distance = 1;
  1731.                       }
  1732.  
  1733.               move = Y_sprite_distance;
  1734.               move2 =X_sprite_distance;
  1735.               move = move/move2;
  1736.                       Sprite_Plot_Block[5] = (atan(move)/1.63624617374E-03);
  1737.                       move = atan(move);
  1738.                       Sprite_Plot_Block[5] = (((960-(direction_angle - 2880)) - Sprite_Plot_Block[5])/2)+160;
  1739.  
  1740.                       if (move == 0.0)
  1741.                       {
  1742.                         move = 0.1;
  1743.                       }
  1744.                       Y_sprite_distance = move2/cos(move);
  1745.                       Sprite_Plot_Block[3] = (64<<14)/(Y_sprite_distance>>10);
  1746.                       Sprite_Plot_Block[3] = (Sprite_Plot_Block[3] * scale_factor);
  1747.                       Sprite_Plot_Block[3] = Sprite_Plot_Block[3]>>16;
  1748.                       if (Sprite_Plot_Block[3] > (240))
  1749.                       {
  1750.                         Sprite_Plot_Block[3] = 240;
  1751.                       }
  1752.                       Sprite_Plot_Block[4] = (128<<20)/Sprite_Plot_Block[3];
  1753.                  }
  1754.                 else
  1755.                 {
  1756.                        Sprite_Plot_Block[2]++;
  1757.                     }
  1758.                     x_intercept = 0;
  1759.                   }
  1760.                 }
  1761.               }
  1762.  
  1763.           while (((initial_x_intercept < map_x_max)&(y_position < (map_y_max>>22)))&(x_intercept == 0))
  1764.           {
  1765.             y_position = y_position + 1;
  1766.             initial_x_intercept = initial_x_intercept + increment[offset_angleY];
  1767.             x_intercept = map[initial_x_intercept>>22][y_position];
  1768.             if (x_intercept != 0)
  1769.             {
  1770.               if (x_intercept == door_code)
  1771.               {
  1772.                 door_intercept = initial_x_intercept; /*preserve initial intercept val */
  1773.  
  1774.                 if (door_map[initial_x_intercept>>22][y_position] == Secret_Door_Code)
  1775.                 {
  1776.                   /* check if door is moving in y direction */
  1777.                   if (Secret_Door_Orientation < 4)
  1778.                   {
  1779.                     /* find magnitude of x offset */
  1780.                     x_door_offset = Secret_Door_Position * tan_table[viewing_angle-2880];
  1781.                     door_intercept = (x_door_offset>>16) + ((initial_x_intercept >> 16) & 63);
  1782.                     /* if interception exceeds bounds of door resume tracing */
  1783.                     if (door_intercept > 63)
  1784.                     {
  1785.                       x_intercept = 0;
  1786.                     }
  1787.                     else
  1788.                     {
  1789.                       x_door_hit = 2;
  1790.                       initial_x_intercept += x_door_offset;
  1791.                     }
  1792.                   }
  1793.                 }
  1794.                 else
  1795.                 {
  1796.  
  1797.                   x_door_hit = 1;
  1798.                   initial_x_intercept = initial_x_intercept + (increment[offset_angleY]>>1);
  1799.  
  1800.                   /* if door is open... */
  1801.                   if (door_map[initial_x_intercept>>22][y_position] != 0)
  1802.                   {
  1803.                     if (door_map[door_intercept>>22][y_position] >= ((initial_x_intercept>>16) & 63))
  1804.                     {
  1805.                       x_door_hit = 0;
  1806.                       x_intercept = 0;
  1807.                       initial_x_intercept = door_intercept;
  1808.                     }
  1809.                     else
  1810.                     {
  1811.                       initial_x_intercept -= ((door_map[door_intercept>>22][y_position]+1)<<16);
  1812.                     }
  1813.                }
  1814.              }
  1815.            }
  1816.               else
  1817.               {
  1818.                 if (x_intercept < 256)
  1819.                 {
  1820.                   if (Sprite_Plot_Block[1] > 960)
  1821.                   {
  1822.                     Sprite_Plot_Block[1] = ScanLine+((320-current_screen_width)>>1);
  1823.                         Sprite_Plot_Block[2] = Sprite_Plot_Block[1];
  1824.                         X_sprite_distance = (Sprite_List[0].sprite_position_x - Xb);
  1825.                         Y_sprite_distance = (Sprite_List[0].sprite_position_y - Yb);
  1826.                       if (X_sprite_distance == 0)
  1827.                       {
  1828.                         X_sprite_distance = 1;
  1829.                       }
  1830.                       if (Y_sprite_distance == 0)
  1831.                       {
  1832.                         Y_sprite_distance = 1;
  1833.                       }
  1834.  
  1835.               move = Y_sprite_distance;
  1836.               move2 =X_sprite_distance;
  1837.               move = move/move2;
  1838.                       Sprite_Plot_Block[5] = (atan(move)/1.63624617374E-03);
  1839.                       move = atan(move);
  1840.                         Sprite_Plot_Block[5] = (((960-(direction_angle - 2880)) - Sprite_Plot_Block[5])/2)+160;
  1841.  
  1842.                       if (move == 0.0)
  1843.                       {
  1844.                         move = 0.1;
  1845.                       }
  1846.                       Y_sprite_distance = move2/cos(move);
  1847.  
  1848.                       Sprite_Plot_Block[3] = (64<<14)/(Y_sprite_distance>>10);
  1849.                       Sprite_Plot_Block[3] = (Sprite_Plot_Block[3] * scale_factor);
  1850.                       Sprite_Plot_Block[3] = Sprite_Plot_Block[3]>>16;
  1851.                       if (Sprite_Plot_Block[3] > (240))
  1852.                       {
  1853.                         Sprite_Plot_Block[3] = 240;
  1854.                       }
  1855.                       Sprite_Plot_Block[4] = (128<<20)/Sprite_Plot_Block[3];
  1856.                    }
  1857.                   else
  1858.                   {
  1859.                          Sprite_Plot_Block[2]++;
  1860.                       }
  1861.                       x_intercept = 0;
  1862.                     }
  1863.                   }
  1864.             }
  1865.           }
  1866.         }
  1867.  
  1868.         if ((initial_y_intercept < map_y_max)&&((viewing_angle != 960)&(viewing_angle != 2880)))
  1869.         {
  1870.           /* fire y ray & test for intersections */
  1871.           x_position = ((Xa>>6)+1);
  1872.           y_intercept = map[x_position][initial_y_intercept>>22];
  1873.           if (y_intercept != 0)
  1874.           {
  1875.             if (y_intercept == door_code)
  1876.             {
  1877.               door_intercept = initial_y_intercept; /*preserve initial intercept val */
  1878.  
  1879.               if (door_map[x_position][initial_y_intercept>>22] == Secret_Door_Code)
  1880.               {
  1881.                 /* check if door is moving in y direction */
  1882.                 if (Secret_Door_Orientation > 2)
  1883.                 {
  1884.                   /* find magnitude of y offset */
  1885.                   y_door_offset = Secret_Door_Position * tan_table[960-(viewing_angle-2880)];
  1886.                   door_intercept = (y_door_offset>>16) + ((initial_y_intercept >> 16) & 63);
  1887.                   /* if interception exceeds bounds of door resume tracing */
  1888.                   if (door_intercept > 63)
  1889.                   {
  1890.                     y_intercept = 0;
  1891.                   }
  1892.                   else
  1893.                   {
  1894.                     y_door_hit = 2;
  1895.                     initial_y_intercept += y_door_offset;
  1896.                   }
  1897.                 }
  1898.               }
  1899.               else
  1900.               {
  1901.  
  1902.                 y_door_hit = 1;
  1903.                 initial_y_intercept = initial_y_intercept + (increment[offset_angleX]>>1);
  1904.  
  1905.                 /* if door is open... */
  1906.                 if (door_map[x_position][initial_y_intercept>>22] != 0)
  1907.                 {
  1908.                   if (door_map[x_position][initial_y_intercept>>22] >= ((initial_y_intercept>>16) & 63))
  1909.                   {
  1910.                     y_door_hit = 0;
  1911.                     y_intercept = 0;
  1912.                     initial_y_intercept = door_intercept;
  1913.                   }
  1914.                   else
  1915.                   {
  1916.                     initial_y_intercept -= ((door_map[x_position][door_intercept>>22]+1)<<16);
  1917.                   }
  1918.              }
  1919.               }
  1920.                 }
  1921.             else
  1922.             {
  1923.               if (y_intercept < 256)
  1924.               {
  1925.                 if (Sprite_Plot_Block[1] > 960)
  1926.                 {
  1927.                   Sprite_Plot_Block[1] = ScanLine+((320-current_screen_width)>>1);
  1928.                       Sprite_Plot_Block[2] = Sprite_Plot_Block[1];
  1929.                       X_sprite_distance = (Sprite_List[0].sprite_position_x - Xb);
  1930.                       Y_sprite_distance = (Sprite_List[0].sprite_position_y - Yb);
  1931.                       if (X_sprite_distance == 0)
  1932.                       {
  1933.                         X_sprite_distance = 1;
  1934.                       }
  1935.                       if (Y_sprite_distance == 0)
  1936.                       {
  1937.                         Y_sprite_distance = 1;
  1938.                       }
  1939.  
  1940.               move = Y_sprite_distance;
  1941.               move2 =X_sprite_distance;
  1942.               move = move/move2;
  1943.                       Sprite_Plot_Block[5] = (atan(move)/1.63624617374E-03);
  1944.                       move = atan(move);
  1945.                       Sprite_Plot_Block[5] = (((960-(direction_angle - 2880)) - Sprite_Plot_Block[5])/2)+160;
  1946.  
  1947.                       if (Y_sprite_distance == 0)
  1948.                       {
  1949.                         Y_sprite_distance = 1;
  1950.                       }
  1951.                       Y_sprite_distance = move2/cos(move);
  1952.  
  1953.                       Sprite_Plot_Block[3] = (64<<14)/(Y_sprite_distance>>10);
  1954.                       Sprite_Plot_Block[3] = (Sprite_Plot_Block[3] * scale_factor);
  1955.                       Sprite_Plot_Block[3] = Sprite_Plot_Block[3]>>16;
  1956.                       if (Sprite_Plot_Block[3] > (240))
  1957.                       {
  1958.                         Sprite_Plot_Block[3] = 240;
  1959.                       }
  1960.                       Sprite_Plot_Block[4] = (128<<20)/Sprite_Plot_Block[3];
  1961.                  }
  1962.                 else
  1963.                 {
  1964.                        Sprite_Plot_Block[2]++;
  1965.                     }
  1966.                     y_intercept = 0;
  1967.                   }
  1968.                 }
  1969.               }
  1970.  
  1971.           while (((initial_y_intercept < map_y_max)&(x_position < (map_x_max>>22)))&(y_intercept == 0))
  1972.           {
  1973.             x_position = x_position + 1;
  1974.             initial_y_intercept = initial_y_intercept + increment[offset_angleX];
  1975.             y_intercept = map[x_position][(initial_y_intercept>>22)];
  1976.             if (y_intercept != 0)
  1977.             {
  1978.               if (y_intercept == door_code)
  1979.               {
  1980.                 door_intercept = initial_y_intercept; /*preserve initial intercept val */
  1981.  
  1982.                 if (door_map[x_position][initial_y_intercept>>22] == Secret_Door_Code)
  1983.                 {
  1984.                   /* check if door is moving in y direction */
  1985.                   if (Secret_Door_Orientation > 2)
  1986.                   {
  1987.                     /* find magnitude of y offset */
  1988.                     y_door_offset = Secret_Door_Position * tan_table[960-(viewing_angle-2880)];
  1989.                     door_intercept = (y_door_offset>>16) + ((initial_y_intercept >> 16) & 63);
  1990.                     /* if interception exceeds bounds of door resume tracing */
  1991.                     if (door_intercept > 63)
  1992.                     {
  1993.                       y_intercept = 0;
  1994.                     }
  1995.                     else
  1996.                     {
  1997.                       y_door_hit = 2;
  1998.                       initial_y_intercept += y_door_offset;
  1999.                     }
  2000.                   }
  2001.                 }
  2002.                 else
  2003.                 {
  2004.  
  2005.                   y_door_hit = 1;
  2006.                   initial_y_intercept = initial_y_intercept + (increment[offset_angleX]>>1);
  2007.  
  2008.                   /* if door is open... */
  2009.                   if (door_map[x_position][initial_y_intercept>>22] != 0)
  2010.                   {
  2011.                     if (door_map[x_position][initial_y_intercept>>22] >= ((initial_y_intercept>>16) & 63))
  2012.                     {
  2013.                       y_door_hit = 0;
  2014.                       y_intercept = 0;
  2015.                       initial_y_intercept = door_intercept;
  2016.                     }
  2017.                     else
  2018.                     {
  2019.                       initial_y_intercept -= ((door_map[x_position][door_intercept>>22]+1)<<16);
  2020.                     }
  2021.                }
  2022.              }
  2023.            }
  2024.               else
  2025.               {
  2026.                 if (y_intercept < 256)
  2027.                 {
  2028.                   if (Sprite_Plot_Block[1] > 960)
  2029.                   {
  2030.                     Sprite_Plot_Block[1] = ScanLine+((320-current_screen_width)>>1);
  2031.                         Sprite_Plot_Block[2] = Sprite_Plot_Block[1];
  2032.                         X_sprite_distance = (Sprite_List[0].sprite_position_x - Xb);
  2033.                         Y_sprite_distance = (Sprite_List[0].sprite_position_y - Yb);
  2034.                       if (X_sprite_distance == 0)
  2035.                       {
  2036.                         X_sprite_distance = 1;
  2037.                       }
  2038.                       if (Y_sprite_distance == 0)
  2039.                       {
  2040.                         Y_sprite_distance = 1;
  2041.                       }
  2042.  
  2043.               move = Y_sprite_distance;
  2044.               move2 =X_sprite_distance;
  2045.               move = move/move2;
  2046.                       Sprite_Plot_Block[5] = (atan(move)/1.63624617374E-03);
  2047.                       move = atan(move);
  2048.                         Sprite_Plot_Block[5] = (((960-(direction_angle - 2880)) - Sprite_Plot_Block[5])/2)+160;
  2049.  
  2050.                       if (move == 0.0)
  2051.                       {
  2052.                         move = 0.1;
  2053.                       }
  2054.                       Y_sprite_distance = move2/cos(move);
  2055.  
  2056.                       Sprite_Plot_Block[3] = (64<<14)/(Y_sprite_distance>>10);
  2057.                       Sprite_Plot_Block[3] = (Sprite_Plot_Block[3] * scale_factor);
  2058.                       Sprite_Plot_Block[3] = Sprite_Plot_Block[3]>>16;
  2059.                       if (Sprite_Plot_Block[3] > (240))
  2060.                       {
  2061.                         Sprite_Plot_Block[3] = 240;
  2062.                       }
  2063.                         Sprite_Plot_Block[4] = (128<<20)/Sprite_Plot_Block[3];
  2064.                    }
  2065.                   else
  2066.                   {
  2067.                          Sprite_Plot_Block[2]++;
  2068.                       }
  2069.                       y_intercept = 0;
  2070.                     }
  2071.               }
  2072.             }
  2073.           }
  2074.         }
  2075.  
  2076.         /* validate intercept */
  2077.         if (initial_x_intercept > map_x_max || initial_x_intercept < map_x_min)
  2078.         {
  2079.           x_intercept = 0;
  2080.         }
  2081.         if (initial_y_intercept > map_y_max || initial_y_intercept < map_y_min)
  2082.         {
  2083.           y_intercept = 0;
  2084.         }
  2085.  
  2086.         /* compute distance for x ray */
  2087.         initial_x_intercept = initial_x_intercept>>16;
  2088.         if (x_intercept != 0)
  2089.         {
  2090.           if (x_door_hit == 0)
  2091.           {
  2092.             x_distance = ((y_position<<6) - Ya) * cos_div_table[offset_angleY];
  2093.           }
  2094.           else if (x_door_hit == 1)
  2095.           {
  2096.             x_distance = (((y_position<<6)+32) - Ya) * cos_div_table[offset_angleY];
  2097.               }
  2098.               else if (x_door_hit == 2)
  2099.               {
  2100.             x_distance = (((y_position<<6)+Secret_Door_Position) - Ya) * cos_div_table[offset_angleY];
  2101.               }
  2102.             }
  2103.  
  2104.         /* compute distance for y ray */
  2105.         initial_y_intercept = initial_y_intercept>>16;
  2106.         if (y_intercept != 0)
  2107.         {
  2108.           if (y_door_hit == 0)
  2109.           {
  2110.             initial_y_intercept = initial_y_intercept-(initial_y_intercept & 63)+(63-(initial_y_intercept & 63));
  2111.             y_distance = ((x_position<<6) - Xa) * cos_div_table[offset_angleX];
  2112.           }
  2113.           else if (y_door_hit == 1)
  2114.           {
  2115.             y_distance = (((x_position<<6)+32) - Xa) * cos_div_table[offset_angleX];
  2116.               }
  2117.               else if (y_door_hit == 2)
  2118.               {
  2119.             y_distance = (((x_position<<6)+Secret_Door_Position) - Xa) * cos_div_table[offset_angleX];
  2120.           }
  2121.             }
  2122.  
  2123.       }
  2124.       else if (quadrant == 0)
  2125.       {
  2126.         initial_y_intercept = (Yb)-((64-(Xa & 63))*tan_table[offset_angleY]);
  2127.         initial_x_intercept = (Xb)+((Ya & 63)*tan_table[offset_angleX]);
  2128.  
  2129.         if ((initial_x_intercept < map_x_max)&((viewing_angle != 0)&(viewing_angle != 1920)))
  2130.         {
  2131.           /* fire x ray & test for intersections */
  2132.           y_position = (Ya>>6);
  2133.           x_intercept = map[initial_x_intercept>>22][(y_position)-1];
  2134.           if (x_intercept != 0)
  2135.           {
  2136.             if (x_intercept == door_code)
  2137.             {
  2138.               door_intercept = initial_x_intercept; /*preserve initial intercept val */
  2139.  
  2140.               if (door_map[initial_x_intercept>>22][(y_position)-1] == Secret_Door_Code)
  2141.               {
  2142.                 /* check if door is moving in y direction */
  2143.                 if (Secret_Door_Orientation < 4)
  2144.                 {
  2145.                   /* find magnitude of x offset */
  2146.                   x_door_offset = Secret_Door_Position * tan_table[960-viewing_angle];
  2147.                   door_intercept = (x_door_offset>>16) + ((initial_x_intercept >> 16) & 63);
  2148.                   /* if interception exceeds bounds of door resume tracing */
  2149.                   if (door_intercept > 63)
  2150.                   {
  2151.                     x_intercept = 0;
  2152.                   }
  2153.                   else
  2154.                   {
  2155.                     x_door_hit = 2;
  2156.                     initial_x_intercept += x_door_offset;
  2157.                   }
  2158.                 }
  2159.               }
  2160.               else
  2161.               {
  2162.  
  2163.                 x_door_hit = 1;
  2164.                 initial_x_intercept = initial_x_intercept + (increment[offset_angleX]>>1);
  2165.  
  2166.                 /* if door is open... */
  2167.                 if (door_map[initial_x_intercept>>22][y_position-1] != 0)
  2168.                 {
  2169.                   if (door_map[door_intercept>>22][y_position-1] >= ((initial_x_intercept>>16) & 63))
  2170.                   {
  2171.                     x_door_hit = 0;
  2172.                     x_intercept = 0;
  2173.                     initial_x_intercept = door_intercept;
  2174.                   }
  2175.                   else
  2176.                   {
  2177.                     initial_x_intercept -= ((door_map[door_intercept>>22][y_position-1]+1)<<16);
  2178.                   }
  2179.              }
  2180.               }
  2181.                 }
  2182.               }
  2183.  
  2184.           while (((initial_x_intercept < map_x_max)&(y_position > (map_y_min>>22)))&(x_intercept == 0))
  2185.           {
  2186.             y_position = y_position - 1;
  2187.             initial_x_intercept = initial_x_intercept + increment[offset_angleX];
  2188.             x_intercept = map[initial_x_intercept>>22][(y_position)-1];
  2189.             if (x_intercept != 0)
  2190.             {
  2191.               if (x_intercept == door_code)
  2192.               {
  2193.                 door_intercept = initial_x_intercept; /*preserve initial intercept val */
  2194.  
  2195.                 if (door_map[initial_x_intercept>>22][(y_position)-1] == Secret_Door_Code)
  2196.                 {
  2197.                   /* check if door is moving in y direction */
  2198.                   if (Secret_Door_Orientation < 4)
  2199.                   {
  2200.                     /* find magnitude of x offset */
  2201.                     x_door_offset = Secret_Door_Position * tan_table[960-viewing_angle];
  2202.                     door_intercept = (x_door_offset>>16) + ((initial_x_intercept >> 16) & 63);
  2203.                     /* if interception exceeds bounds of door resume tracing */
  2204.                     if (door_intercept > 63)
  2205.                     {
  2206.                       x_intercept = 0;
  2207.                     }
  2208.                     else
  2209.                     {
  2210.                       x_door_hit = 2;
  2211.                       initial_x_intercept += x_door_offset;
  2212.                     }
  2213.                   }
  2214.                 }
  2215.                 else
  2216.                 {
  2217.  
  2218.                   x_door_hit = 1;
  2219.                   initial_x_intercept = initial_x_intercept + (increment[offset_angleX]>>1);
  2220.  
  2221.                   /* if door is open... */
  2222.                   if (door_map[initial_x_intercept>>22][y_position-1] != 0)
  2223.                   {
  2224.                     if (door_map[door_intercept>>22][y_position-1] >= ((initial_x_intercept>>16) & 63))
  2225.                     {
  2226.                       x_door_hit = 0;
  2227.                       x_intercept = 0;
  2228.                       initial_x_intercept = door_intercept;
  2229.                     }
  2230.                     else
  2231.                     {
  2232.                       initial_x_intercept -= ((door_map[door_intercept>>22][y_position-1]+1)<<16);
  2233.                     }
  2234.                   }
  2235.              }
  2236.               }
  2237.             }
  2238.           }
  2239.             }
  2240.  
  2241.         if ((initial_y_intercept > map_y_min)&((viewing_angle != 960)&(viewing_angle != 2880)))
  2242.         {
  2243.           /* fire y ray & test for intersections */
  2244.           x_position = (Xa>>6)+1;
  2245.           y_intercept = map[x_position][(initial_y_intercept>>22)];
  2246.           if (y_intercept == door_code)
  2247.           {
  2248.             door_intercept = initial_y_intercept; /*preserve initial intercept val */
  2249.  
  2250.             if (door_map[x_position][initial_y_intercept>>22] == Secret_Door_Code)
  2251.             {
  2252.               /* check if door is moving in y direction */
  2253.               if (Secret_Door_Orientation > 2)
  2254.               {
  2255.                 /* find magnitude of y offset */
  2256.                 y_door_offset = Secret_Door_Position * tan_table[viewing_angle];
  2257.                 door_intercept = (y_door_offset>>16) - ((initial_y_intercept >> 16) & 63);
  2258.                 /* if interception exceeds bounds of door resume tracing */
  2259.                 if (door_intercept > 63)
  2260.                 {
  2261.                   y_intercept = 0;
  2262.                 }
  2263.                 else
  2264.                 {
  2265.                   y_door_hit = 2;
  2266.                   initial_y_intercept -= y_door_offset;
  2267.                 }
  2268.               }
  2269.             }
  2270.             else
  2271.             {
  2272.  
  2273.               y_door_hit = 1;
  2274.               initial_y_intercept = initial_y_intercept - (increment[offset_angleY]>>1);
  2275.               /* if door is open... */
  2276.               if (door_map[x_position][initial_y_intercept>>22] != 0)
  2277.               {
  2278.                 if (door_map[x_position][initial_y_intercept>>22] >= ((initial_y_intercept>>16) & 63))
  2279.                 {
  2280.                   y_door_hit = 0;
  2281.                   y_intercept = 0;
  2282.                   initial_y_intercept = door_intercept;
  2283.                 }
  2284.                 else
  2285.                 {
  2286.                   initial_y_intercept -= ((door_map[x_position][door_intercept>>22]+1)<<16);
  2287.                 }
  2288.            }
  2289.             }
  2290.               }
  2291.  
  2292.           while (((initial_y_intercept > map_y_min)&(x_position < (map_x_max>>22)))&(y_intercept == 0))
  2293.           {
  2294.             x_position = x_position + 1;
  2295.             initial_y_intercept = initial_y_intercept - increment[offset_angleY];
  2296.             y_intercept = map[x_position][(initial_y_intercept>>22)];
  2297.             if (y_intercept == door_code)
  2298.             {
  2299.               door_intercept = initial_y_intercept; /*preserve initial intercept val */
  2300.  
  2301.               if (door_map[x_position][initial_y_intercept>>22] == Secret_Door_Code)
  2302.               {
  2303.                 /* check if door is moving in y direction */
  2304.                 if (Secret_Door_Orientation > 2)
  2305.                 {
  2306.                   /* find magnitude of y offset */
  2307.                   y_door_offset = Secret_Door_Position * tan_table[viewing_angle];
  2308.                   door_intercept = (y_door_offset>>16) - ((initial_y_intercept >> 16) & 63);
  2309.                   /* if interception exceeds bounds of door resume tracing */
  2310.                   if (door_intercept > 63)
  2311.                   {
  2312.                     y_intercept = 0;
  2313.                   }
  2314.                   else
  2315.                   {
  2316.                     y_door_hit = 2;
  2317.                     initial_y_intercept -= y_door_offset;
  2318.                   }
  2319.                 }
  2320.               }
  2321.               else
  2322.               {
  2323.  
  2324.                 y_door_hit = 1;
  2325.                 initial_y_intercept = initial_y_intercept - (increment[offset_angleY]>>1);
  2326.  
  2327.                 /* if door is open... */
  2328.                 if (door_map[x_position][initial_y_intercept>>22] != 0)
  2329.                 {
  2330.                   if (door_map[x_position][initial_y_intercept>>22] >= ((initial_y_intercept>>16) & 63))
  2331.                   {
  2332.                     y_door_hit = 0;
  2333.                     y_intercept = 0;
  2334.                     initial_y_intercept = door_intercept;
  2335.                   }
  2336.                   else
  2337.                   {
  2338.                     initial_y_intercept -= ((door_map[x_position][door_intercept>>22]+1)<<16);
  2339.                   }
  2340.              }
  2341.            }
  2342.             }
  2343.           }
  2344.         }
  2345.  
  2346.         /* validate intercept */
  2347.         if (initial_x_intercept > map_x_max || initial_x_intercept < map_x_min)
  2348.         {
  2349.           x_intercept = 0;
  2350.         }
  2351.         if (initial_y_intercept > map_y_max || initial_y_intercept < map_y_min)
  2352.         {
  2353.           y_intercept = 0;
  2354.         }
  2355.  
  2356.         /* compute distance for x ray */
  2357.         initial_x_intercept = initial_x_intercept>>16;
  2358.         if (x_intercept != 0)
  2359.         {
  2360.           if (x_door_hit == 0)
  2361.           {
  2362.             initial_x_intercept = initial_x_intercept-(initial_x_intercept & 63)+(63-(initial_x_intercept & 63));
  2363.             x_distance = (Ya - (y_position<<6)) * cos_div_table[offset_angleX];
  2364.           }
  2365.           else if (x_door_hit == 1)
  2366.           {
  2367.             x_distance = (Ya - ((y_position<<6)-32)) * cos_div_table[offset_angleX];
  2368.               }
  2369.               else if (x_door_hit == 2)
  2370.               {
  2371.             x_distance = (Ya - ((y_position<<6)-Secret_Door_Position)) * cos_div_table[offset_angleX];
  2372.               }
  2373.             }
  2374.  
  2375.  
  2376.         /* compute distance for y ray */
  2377.         initial_y_intercept = initial_y_intercept>>16;
  2378.         if (y_intercept != 0)
  2379.         {
  2380.           if (y_door_hit == 0)
  2381.           {
  2382.             initial_y_intercept = initial_y_intercept-(initial_y_intercept & 63)+(63-(initial_y_intercept & 63));
  2383.             y_distance = ((x_position<<6) - Xa) * cos_div_table[offset_angleY];
  2384.           }
  2385.           else if (y_door_hit == 1)
  2386.           {
  2387.             y_distance = (((x_position<<6)+32) - Xa) * cos_div_table[offset_angleY];
  2388.               }
  2389.           else if (y_door_hit == 2)
  2390.           {
  2391.             y_distance = (((x_position<<6)+Secret_Door_Position) - Xa) * cos_div_table[offset_angleY];
  2392.               }
  2393.             }
  2394.             y_position--;
  2395.       }
  2396.       else if (quadrant == 1)
  2397.       {
  2398.         initial_y_intercept = (Yb)-((Xa & 63)*tan_table[offset_angleX]);
  2399.         initial_x_intercept = (Xb)-((Ya & 63)*tan_table[offset_angleY]);
  2400.  
  2401.         if ((initial_x_intercept > map_x_min)&((viewing_angle != 0)&(viewing_angle != 1920)))
  2402.         {
  2403.           /* fire x ray & test for intersections */
  2404.           y_position = (Ya>>6);
  2405.           x_intercept = map[initial_x_intercept>>22][(y_position)-1];
  2406.           if (x_intercept == door_code)
  2407.           {
  2408.             door_intercept = initial_x_intercept; /*preserve initial intercept val */
  2409.  
  2410.             if (door_map[initial_x_intercept>>22][(y_position)-1] == Secret_Door_Code)
  2411.             {
  2412.               /* check if door is moving in y direction */
  2413.               if (Secret_Door_Orientation < 4)
  2414.               {
  2415.                 /* find magnitude of x offset */
  2416.                 x_door_offset = Secret_Door_Position * tan_table[viewing_angle-960];
  2417.                 door_intercept = ((initial_x_intercept >> 16) & 63) - (x_door_offset>>16);
  2418.                 /* if interception exceeds bounds of door resume tracing */
  2419.                 if (door_intercept > 63)
  2420.                 {
  2421.                   x_intercept = 0;
  2422.                 }
  2423.                 else
  2424.                 {
  2425.                   x_door_hit = 2;
  2426.                   initial_x_intercept -= x_door_offset;
  2427.                 }
  2428.               }
  2429.             }
  2430.             else
  2431.             {
  2432.  
  2433.               x_door_hit = 1;
  2434.               initial_x_intercept = initial_x_intercept - (increment[offset_angleY]>>1);
  2435.  
  2436.               /* if door is open... */
  2437.               if (door_map[initial_x_intercept>>22][y_position-1] != 0)
  2438.               {
  2439.                 if (door_map[door_intercept>>22][y_position-1] >= ((initial_x_intercept>>16) & 63))
  2440.                 {
  2441.                   x_door_hit = 0;
  2442.                   x_intercept = 0;
  2443.                   initial_x_intercept = door_intercept;
  2444.                 }
  2445.                 else
  2446.                 {
  2447.                   initial_x_intercept -= ((door_map[door_intercept>>22][y_position-1]+1)<<16);
  2448.                 }
  2449.            }
  2450.             }
  2451.           }
  2452.  
  2453.           while (((initial_x_intercept > map_x_min)&(y_position > (map_y_min>>22)))&(x_intercept == 0))
  2454.           {
  2455.             y_position = y_position - 1;
  2456.             initial_x_intercept = initial_x_intercept - increment[offset_angleY];
  2457.             x_intercept = map[initial_x_intercept>>22][(y_position)-1];
  2458.             if (x_intercept == door_code)
  2459.             {
  2460.               door_intercept = initial_x_intercept; /*preserve initial intercept val */
  2461.  
  2462.               if (door_map[initial_x_intercept>>22][(y_position)-1] == Secret_Door_Code)
  2463.               {
  2464.                 /* check if door is moving in y direction */
  2465.                 if (Secret_Door_Orientation < 4)
  2466.                 {
  2467.                   /* find magnitude of x offset */
  2468.                   x_door_offset = Secret_Door_Position * tan_table[viewing_angle-960];
  2469.                   door_intercept = ((initial_x_intercept >> 16) & 63) - (x_door_offset>>16);
  2470.                   /* if interception exceeds bounds of door resume tracing */
  2471.                   if (door_intercept > 63)
  2472.                   {
  2473.                     x_intercept = 0;
  2474.                   }
  2475.                   else
  2476.                   {
  2477.                     x_door_hit = 2;
  2478.                     initial_x_intercept -= x_door_offset;
  2479.                   }
  2480.                 }
  2481.               }
  2482.               else
  2483.               {
  2484.  
  2485.                 x_door_hit = 1;
  2486.                 initial_x_intercept = initial_x_intercept - (increment[offset_angleY]>>1);
  2487.  
  2488.                 /* if door is open... */
  2489.                 if (door_map[initial_x_intercept>>22][y_position-1] != 0)
  2490.                 {
  2491.                   if (door_map[door_intercept>>22][y_position-1] >= ((initial_x_intercept>>16) & 63))
  2492.                   {
  2493.                     x_door_hit = 0;
  2494.                     x_intercept = 0;
  2495.                     initial_x_intercept = door_intercept;
  2496.                   }
  2497.                   else
  2498.                   {
  2499.                     initial_x_intercept -= ((door_map[door_intercept>>22][y_position-1]+1)<<16);
  2500.                   }
  2501.              }
  2502.               }
  2503.             }
  2504.            }
  2505.          }
  2506.  
  2507.         if ((initial_y_intercept > map_y_min)&((viewing_angle != 960)&(viewing_angle != 2880)))
  2508.         {
  2509.           /* fire y ray & test for intersections */
  2510.           x_position = (Xa>>6);
  2511.           y_intercept = map[(x_position)-1][initial_y_intercept>>22];
  2512.           if (y_intercept == door_code)
  2513.           {
  2514.             door_intercept = initial_y_intercept; /*preserve initial intercept val */
  2515.  
  2516.             if (door_map[x_position-1][initial_y_intercept>>22] == Secret_Door_Code)
  2517.             {
  2518.               /* check if door is moving in y direction */
  2519.               if (Secret_Door_Orientation > 2)
  2520.               {
  2521.                 /* find magnitude of y offset */
  2522.                 y_door_offset = Secret_Door_Position * tan_table[960-(viewing_angle-960)];
  2523.                 door_intercept = (y_door_offset>>16) - ((initial_y_intercept >> 16) & 63);
  2524.                 /* if interception exceeds bounds of door resume tracing */
  2525.                 if (door_intercept > 63)
  2526.                 {
  2527.                   y_intercept = 0;
  2528.                 }
  2529.                 else
  2530.                 {
  2531.                   y_door_hit = 2;
  2532.                   initial_y_intercept -= y_door_offset;
  2533.                 }
  2534.               }
  2535.             }
  2536.             else
  2537.             {
  2538.  
  2539.               y_door_hit = 1;
  2540.               initial_y_intercept = initial_y_intercept - (increment[offset_angleX]>>1);
  2541.  
  2542.               /* if door is open... */
  2543.               if (door_map[x_position-1][initial_y_intercept>>22] != 0)
  2544.               {
  2545.                 if (door_map[x_position-1][initial_y_intercept>>22] >= ((initial_y_intercept>>16) & 63))
  2546.                 {
  2547.                   y_door_hit = 0;
  2548.                   y_intercept = 0;
  2549.                   initial_y_intercept = door_intercept;
  2550.                 }
  2551.                 else
  2552.                 {
  2553.                   initial_y_intercept -= ((door_map[x_position-1][door_intercept>>22]+1)<<16);
  2554.                 }
  2555.            }
  2556.             }
  2557.               }
  2558.  
  2559.           while (((initial_y_intercept > map_y_min)&(x_position > (map_x_min>>22)))&(y_intercept == 0))
  2560.           {
  2561.             x_position = x_position - 1;
  2562.             initial_y_intercept = initial_y_intercept - increment[offset_angleX];
  2563.             y_intercept = map[(x_position)-1][initial_y_intercept>>22];
  2564.             if (y_intercept == door_code)
  2565.             {
  2566.               door_intercept = initial_y_intercept; /*preserve initial intercept val */
  2567.  
  2568.               if (door_map[x_position-1][initial_y_intercept>>22] == Secret_Door_Code)
  2569.               {
  2570.                 /* check if door is moving in y direction */
  2571.                 if (Secret_Door_Orientation > 2)
  2572.                 {
  2573.                   /* find magnitude of y offset */
  2574.                   y_door_offset = Secret_Door_Position * tan_table[960-(viewing_angle-960)];
  2575.                   door_intercept = (y_door_offset>>16) - ((initial_y_intercept >> 16) & 63);
  2576.                   /* if interception exceeds bounds of door resume tracing */
  2577.                   if (door_intercept > 63)
  2578.                   {
  2579.                     y_intercept = 0;
  2580.                   }
  2581.                   else
  2582.                   {
  2583.                     y_door_hit = 2;
  2584.                     initial_y_intercept -= y_door_offset;
  2585.                   }
  2586.                 }
  2587.               }
  2588.               else
  2589.               {
  2590.  
  2591.                 y_door_hit = 1;
  2592.                 initial_y_intercept = initial_y_intercept - (increment[offset_angleX]>>1);
  2593.  
  2594.                 /* if door is open... */
  2595.                 if (door_map[x_position-1][initial_y_intercept>>22] != 0)
  2596.                 {
  2597.                   if (door_map[x_position-1][initial_y_intercept>>22] >= ((initial_y_intercept>>16) & 63))
  2598.                   {
  2599.                     y_door_hit = 0;
  2600.                     y_intercept = 0;
  2601.                     initial_y_intercept = door_intercept;
  2602.                   }
  2603.                   else
  2604.                   {
  2605.                     initial_y_intercept -= ((door_map[x_position-1][door_intercept>>22]+1)<<16);
  2606.                   }
  2607.              }
  2608.            }
  2609.             }
  2610.           }
  2611.         }
  2612.  
  2613.         /* validate intercept */
  2614.         if (initial_x_intercept > map_x_max || initial_x_intercept < map_x_min)
  2615.         {
  2616.           x_intercept = 0;
  2617.         }
  2618.         if (initial_y_intercept > map_y_max || initial_y_intercept < map_y_min)
  2619.         {
  2620.           y_intercept = 0;
  2621.         }
  2622.  
  2623.         /* compute distance for x ray */
  2624.         initial_x_intercept = initial_x_intercept>>16;
  2625.         if (x_intercept != 0)
  2626.         {
  2627.           if (x_door_hit == 0)
  2628.           {
  2629.             initial_x_intercept = initial_x_intercept-(initial_x_intercept & 63)+(63-(initial_x_intercept & 63));
  2630.             x_distance = (Ya - (y_position<<6)) * cos_div_table[offset_angleY];
  2631.           }
  2632.           else if (x_door_hit == 1)
  2633.           {
  2634.             x_distance = (Ya - ((y_position<<6)-32)) * cos_div_table[offset_angleY];
  2635.               }
  2636.           else if (x_door_hit == 2)
  2637.           {
  2638.             x_distance = (Ya - ((y_position<<6)-Secret_Door_Position)) * cos_div_table[offset_angleY];
  2639.               }
  2640.             }
  2641.  
  2642.         /* compute distance for y ray */
  2643.         initial_y_intercept = initial_y_intercept>>16;
  2644.         if (y_intercept != 0)
  2645.         {
  2646.           if (y_door_hit == 0)
  2647.           {
  2648.             y_distance = (Xa - (x_position<<6)) * cos_div_table[offset_angleX];
  2649.           }
  2650.           else if (y_door_hit == 1)
  2651.           {
  2652.             y_distance = (Xa - ((x_position<<6)-32)) * cos_div_table[offset_angleX];
  2653.               }
  2654.           else if (y_door_hit == 2)
  2655.           {
  2656.             y_distance = (Xa - ((x_position<<6)-Secret_Door_Position)) * cos_div_table[offset_angleX];
  2657.               }
  2658.             }
  2659.             x_position--;
  2660.             y_position--;
  2661.       }
  2662.       else if (quadrant == 2)
  2663.       {
  2664.         initial_y_intercept = (Yb)+((Xa & 63)*tan_table[offset_angleY]);
  2665.         initial_x_intercept = (Xb)-((64-(Ya & 63))*tan_table[offset_angleX]);
  2666.  
  2667.         if ((initial_x_intercept > map_x_min)&((viewing_angle != 0)&(viewing_angle != 1920)))
  2668.         {
  2669.           /* fire x ray & test for intersections */
  2670.           y_position = (Ya>>6)+1;
  2671.           x_intercept = map[initial_x_intercept>>22][y_position];
  2672.  
  2673.           if (x_intercept == door_code)
  2674.           {
  2675.             door_intercept = initial_x_intercept; /*preserve initial intercept val */
  2676.  
  2677.             if (door_map[initial_x_intercept>>22][y_position] == Secret_Door_Code)
  2678.             {
  2679.               /* check if door is moving in y direction */
  2680.               if (Secret_Door_Orientation < 4)
  2681.               {
  2682.                 /* find magnitude of x offset */
  2683.                 x_door_offset = Secret_Door_Position * tan_table[960-(viewing_angle-1920)];
  2684.                 door_intercept = ((initial_x_intercept >> 16) & 63) - (x_door_offset>>16);
  2685.                 /* if interception exceeds bounds of door resume tracing */
  2686.                 if (door_intercept > 63)
  2687.                 {
  2688.                   x_intercept = 0;
  2689.                 }
  2690.                 else
  2691.                 {
  2692.                   x_door_hit = 2;
  2693.                   initial_x_intercept -= x_door_offset;
  2694.                 }
  2695.               }
  2696.             }
  2697.             else
  2698.             {
  2699.               x_door_hit = 1;
  2700.               initial_x_intercept = initial_x_intercept - (increment[offset_angleX]>>1);
  2701.  
  2702.               /* if door is open... */
  2703.               if (door_map[initial_x_intercept>>22][y_position] != 0)
  2704.               {
  2705.                 if (door_map[door_intercept>>22][y_position] >= ((initial_x_intercept>>16) & 63))
  2706.                 {
  2707.                   x_door_hit = 0;
  2708.                   x_intercept = 0;
  2709.                   initial_x_intercept = door_intercept;
  2710.                 }
  2711.                 else
  2712.                 {
  2713.                   initial_x_intercept -= ((door_map[door_intercept>>22][y_position]+1)<<16);
  2714.                 }
  2715.            }
  2716.          }
  2717.               }
  2718.  
  2719.           while (((initial_x_intercept > map_x_min)&(y_position < (map_y_max>>22)))&(x_intercept == 0))
  2720.           {
  2721.             y_position = y_position + 1;
  2722.             initial_x_intercept = initial_x_intercept - increment[offset_angleX];
  2723.             x_intercept = map[initial_x_intercept>>22][y_position];
  2724.  
  2725.             if (x_intercept == door_code)
  2726.             {
  2727.               door_intercept = initial_x_intercept; /*preserve initial intercept val */
  2728.  
  2729.               if (door_map[initial_x_intercept>>22][y_position] == Secret_Door_Code)
  2730.               {
  2731.                 /* check if door is moving in y direction */
  2732.                 if (Secret_Door_Orientation < 4)
  2733.                 {
  2734.                   /* find magnitude of x offset */
  2735.                   x_door_offset = Secret_Door_Position * tan_table[960-(viewing_angle-1920)];
  2736.                   door_intercept = ((initial_x_intercept >> 16) & 63) - (x_door_offset>>16);
  2737.                   /* if interception exceeds bounds of door resume tracing */
  2738.                   if (door_intercept > 63)
  2739.                   {
  2740.                     x_intercept = 0;
  2741.                   }
  2742.                   else
  2743.                   {
  2744.                     x_door_hit = 2;
  2745.                     initial_x_intercept -= x_door_offset;
  2746.                   }
  2747.                 }
  2748.               }
  2749.               else
  2750.               {
  2751.                 x_door_hit = 1;
  2752.                 initial_x_intercept = initial_x_intercept - (increment[offset_angleX]>>1);
  2753.  
  2754.                 /* if door is open... */
  2755.                 if (door_map[initial_x_intercept>>22][y_position] != 0)
  2756.                 {
  2757.                   if (door_map[door_intercept>>22][y_position] >= ((initial_x_intercept>>16) & 63))
  2758.                   {
  2759.                     x_door_hit = 0;
  2760.                     x_intercept = 0;
  2761.                     initial_x_intercept = door_intercept;
  2762.                   }
  2763.                   else
  2764.                   {
  2765.                     initial_x_intercept -= ((door_map[door_intercept>>22][y_position]+1)<<16);
  2766.                   }
  2767.                 }
  2768.            }
  2769.             }
  2770.           }
  2771.         }
  2772.  
  2773.         if ((initial_y_intercept < map_y_max)&((viewing_angle != 960)&(viewing_angle != 2880)))
  2774.         {
  2775.           /* fire y ray & test for intersections */
  2776.           x_position = (Xa>>6);
  2777.           y_intercept = map[(x_position)-1][initial_y_intercept>>22];
  2778.  
  2779.           if (y_intercept == door_code)
  2780.           {
  2781.             door_intercept = initial_y_intercept; /*preserve initial intercept val */
  2782.  
  2783.             if (door_map[x_position-1][initial_y_intercept>>22] == Secret_Door_Code)
  2784.             {
  2785.               /* check if door is moving in y direction */
  2786.               if (Secret_Door_Orientation > 2)
  2787.               {
  2788.                 /* find magnitude of y offset */
  2789.                 y_door_offset = Secret_Door_Position * tan_table[viewing_angle-1920];
  2790.                 door_intercept = (y_door_offset>>16) + ((initial_y_intercept >> 16) & 63);
  2791.                 /* if interception exceeds bounds of door resume tracing */
  2792.                 if (door_intercept > 63)
  2793.                 {
  2794.                   y_intercept = 0;
  2795.                 }
  2796.                 else
  2797.                 {
  2798.                   y_door_hit = 2;
  2799.                   initial_y_intercept += y_door_offset;
  2800.                 }
  2801.               }
  2802.             }
  2803.             else
  2804.             {
  2805.  
  2806.               y_door_hit = 1;
  2807.               initial_y_intercept = initial_y_intercept + (increment[offset_angleY]>>1);
  2808.  
  2809.               /* if door is open... */
  2810.               if (door_map[x_position-1][initial_y_intercept>>22] != 0)
  2811.               {
  2812.                 if (door_map[x_position-1][initial_y_intercept>>22] >= ((initial_y_intercept>>16) & 63))
  2813.                 {
  2814.                   y_door_hit = 0;
  2815.                   y_intercept = 0;
  2816.                   initial_y_intercept = door_intercept;
  2817.                 }
  2818.                 else
  2819.                 {
  2820.                   initial_y_intercept -= ((door_map[x_position-1][door_intercept>>22]+1)<<16);
  2821.                 }
  2822.            }
  2823.          }
  2824.           }
  2825.  
  2826.           while (((initial_y_intercept < map_y_max)&(x_position > (map_x_min>>22)))&(y_intercept == 0))
  2827.           {
  2828.             x_position = x_position - 1;
  2829.             initial_y_intercept = initial_y_intercept + increment[offset_angleY];
  2830.             y_intercept = map[(x_position)-1][initial_y_intercept>>22];
  2831.  
  2832.             if (y_intercept == door_code)
  2833.             {
  2834.               door_intercept = initial_y_intercept; /*preserve initial intercept val */
  2835.  
  2836.               if (door_map[x_position-1][initial_y_intercept>>22] == Secret_Door_Code)
  2837.               {
  2838.                 /* check if door is moving in y direction */
  2839.                 if (Secret_Door_Orientation > 2)
  2840.                 {
  2841.                   /* find magnitude of y offset */
  2842.                   y_door_offset = Secret_Door_Position * tan_table[viewing_angle-1920];
  2843.                   door_intercept = (y_door_offset>>16) + ((initial_y_intercept >> 16) & 63);
  2844.                   /* if interception exceeds bounds of door resume tracing */
  2845.                   if (door_intercept > 63)
  2846.                   {
  2847.                     y_intercept = 0;
  2848.                   }
  2849.                   else
  2850.                   {
  2851.                     y_door_hit = 2;
  2852.                     initial_y_intercept += y_door_offset;
  2853.                   }
  2854.                 }
  2855.               }
  2856.               else
  2857.               {
  2858.  
  2859.                 y_door_hit = 1;
  2860.                 initial_y_intercept = initial_y_intercept + (increment[offset_angleY]>>1);
  2861.  
  2862.                 /* if door is open... */
  2863.                 if (door_map[x_position-1][initial_y_intercept>>22] != 0)
  2864.                 {
  2865.                   if (door_map[x_position-1][initial_y_intercept>>22] >= ((initial_y_intercept>>16) & 63))
  2866.                   {
  2867.                     y_door_hit = 0;
  2868.                     y_intercept = 0;
  2869.                     initial_y_intercept = door_intercept;
  2870.                   }
  2871.                   else
  2872.                   {
  2873.                     initial_y_intercept -= ((door_map[x_position-1][door_intercept>>22]+1)<<16);
  2874.                   }
  2875.              }
  2876.               }
  2877.             }
  2878.           }
  2879.         }
  2880.  
  2881.         /* validate intercept */
  2882.         if (initial_x_intercept > map_x_max || initial_x_intercept < map_x_min)
  2883.         {
  2884.           x_intercept = 0;
  2885.         }
  2886.         if (initial_y_intercept > map_y_max || initial_y_intercept < map_y_min)
  2887.         {
  2888.           y_intercept = 0;
  2889.         }
  2890.  
  2891.         /* compute distance for x ray */
  2892.         initial_x_intercept = initial_x_intercept>>16;
  2893.         if (x_intercept != 0)
  2894.         {
  2895.           if (x_door_hit == 0)
  2896.           {
  2897.             x_distance = ((y_position<<6) - Ya) * cos_div_table[offset_angleX];
  2898.           }
  2899.           else if (x_door_hit == 1)
  2900.           {
  2901.             x_distance = (((y_position<<6)+32) - Ya) * cos_div_table[offset_angleX];
  2902.               }
  2903.               else if (x_door_hit == 2)
  2904.               {
  2905.             x_distance = (((y_position<<6)+Secret_Door_Position) - Ya) * cos_div_table[offset_angleX];
  2906.           }
  2907.             }
  2908.  
  2909.         /* compute distance for y ray */
  2910.         initial_y_intercept = initial_y_intercept>>16;
  2911.         if (y_intercept != 0)
  2912.         {
  2913.           if (y_door_hit == 0)
  2914.           {
  2915.             y_distance = (Xa - (x_position<<6)) * cos_div_table[offset_angleY];
  2916.           }
  2917.           else if (y_door_hit == 1)
  2918.           {
  2919.             y_distance = (Xa - ((x_position<<6)-32)) * cos_div_table[offset_angleY];
  2920.               }
  2921.           else if (y_door_hit == 2)
  2922.           {
  2923.             y_distance = (Xa - ((x_position<<6)-Secret_Door_Position)) * cos_div_table[offset_angleY];
  2924.               }
  2925.             }
  2926.             x_position--;
  2927.       }
  2928.  
  2929.  
  2930.           if (y_distance < 0)
  2931.           {
  2932.             y_intercept = 0;
  2933.           }
  2934.  
  2935.           if (x_distance < 0)
  2936.           {
  2937.             x_intercept = 0;
  2938.           }
  2939.  
  2940.  
  2941.       /* round distance values */
  2942.       if ((y_distance & 65535) > 32767)
  2943.       {
  2944.         y_distance += 65536;
  2945.       }
  2946.       if ((x_distance & 65535) > 32767)
  2947.       {
  2948.         x_distance += 65536;
  2949.       }
  2950.  
  2951.       /* round intercept values */
  2952.       if ((initial_y_intercept & 65535) > 32767)
  2953.       {
  2954.         initial_y_intercept += 65536;
  2955.       }
  2956.       if ((initial_x_intercept & 65535) > 32767)
  2957.       {
  2958.         initial_x_intercept += 65536;
  2959.       }
  2960.  
  2961.       /* draw distance scaled vertical scan lines */
  2962.       x_distance = x_distance >> 16;
  2963.       y_distance = y_distance >> 16;
  2964.  
  2965.       /* check for same distances */
  2966.       if (x_distance == y_distance)
  2967.       {
  2968.         if (x_intercept !=0 && last_intercept == 0)
  2969.         {
  2970.           y_intercept = 0;
  2971.         }
  2972.         else
  2973.         {
  2974.           if (y_intercept != 0)
  2975.           {
  2976.             x_intercept = 0;
  2977.           }
  2978.         }
  2979.       }
  2980.  
  2981.       /*if (x_distance > 65536||x_distance < 0)
  2982.       {
  2983.         x_intercept = 0;
  2984.         x_distance = 65536;
  2985.       }
  2986.  
  2987.       if (y_distance > 65536||y_distance < 0)
  2988.       {
  2989.         y_intercept = 0;
  2990.         y_distance = 65536;
  2991.       }*/
  2992.  
  2993.       /* check for door walls */
  2994.       if (x_intercept >= 65536)
  2995.       {
  2996.         if ((x_intercept >> 16) == 2)
  2997.         {
  2998.           x_intercept = door_wall_code;
  2999.         }
  3000.         x_intercept = x_intercept & 65535;
  3001.       }
  3002.       if (y_intercept >= 65536)
  3003.       {
  3004.         if ((y_intercept >> 16) == 4)
  3005.         {
  3006.           y_intercept = door_wall_code;
  3007.         }
  3008.         y_intercept = y_intercept & 65535;
  3009.       }
  3010.  
  3011.  
  3012.       if (x_distance <= y_distance && x_intercept != 0)
  3013.       {
  3014.         if ((initial_x_intercept > map_x_min)&(initial_x_intercept < map_x_max))
  3015.          {
  3016.            if (x_intercept < 122880)
  3017.            {
  3018.               /* modify distance to avoid bowing */
  3019.              height = (x_distance*current_view_cos_table[ScanLine]);
  3020.             if (height > smallest_height)
  3021.             {
  3022.               smallest_height = height;
  3023.             }
  3024.              if ((height & 262143) > 131071)
  3025.              {
  3026.                height += 262144;
  3027.              }
  3028.              distance[ScanLine] = height;
  3029.             Map_Data[initial_x_intercept>>6][y_position] =103;
  3030.              initial_x_intercept = ((initial_x_intercept & 63)<<6);
  3031.              data_address[ScanLine] = (((x_intercept)>>8)<<12)+initial_x_intercept;
  3032.             last_intercept = 0;
  3033.           }
  3034.           else
  3035.           {
  3036.             distance[ScanLine] = 1;
  3037.             data_address[ScanLine] = 0;
  3038.               }
  3039.         }
  3040.         else
  3041.         {
  3042.           distance[ScanLine] = 1;
  3043.           data_address[ScanLine] = 0;
  3044.         }
  3045.       }
  3046.       else if (x_distance > y_distance || x_intercept == 0)
  3047.       {
  3048.         if ((y_intercept != 0)&(initial_y_intercept > map_y_min)&(initial_y_intercept < map_y_max))
  3049.         {
  3050.           if (y_intercept < 122880)
  3051.           {
  3052.             height = (y_distance*current_view_cos_table[ScanLine]);
  3053.             if (height > smallest_height)
  3054.             {
  3055.               smallest_height = height;
  3056.             }
  3057.              if ((height & 262143) > 131071)
  3058.              {
  3059.                height += 262144;
  3060.              }
  3061.             distance[ScanLine] = height;
  3062.             Map_Data[x_position][initial_y_intercept>>6] =103;
  3063.             initial_y_intercept = ((initial_y_intercept & 63)<<6);
  3064.             data_address[ScanLine] = (((y_intercept>>8)+1)<<12)+initial_y_intercept;
  3065.             last_intercept = 1;
  3066.           }
  3067.           else
  3068.           {
  3069.             distance[ScanLine] = 1;
  3070.             data_address[ScanLine] = 0;
  3071.               }
  3072.         }
  3073.         else
  3074.         {
  3075.           distance[ScanLine] = 1;
  3076.           data_address[ScanLine] = 0;
  3077.         }
  3078.       }
  3079.     }
  3080.  
  3081.     smallest_height = ((64<<14)/((smallest_height>>15)<<1))>>1;
  3082.     smallest_height = (smallest_height * scale_factor);
  3083.     smallest_height = smallest_height>>16;
  3084.     if (smallest_height < (current_screen_height>>1))
  3085.     {
  3086.       if (Floor_On_Off == 1)
  3087.       {
  3088.         if (Play_Mode == Full_Screen)
  3089.         {
  3090.           Floor_Block[0] = (int)&Floor_Data[0][smallest_height][0];
  3091.         }
  3092.         else if (Play_Mode == Tactical_Map)
  3093.         {
  3094.           Floor_Block[0] = (int)&Tactical_Floor_Data[0][smallest_height][0];
  3095.         }
  3096.         else if (Play_Mode == Main_Player)
  3097.         {
  3098.           Floor_Block[0] = (int)&main_Floor_Data[0][smallest_height][0];
  3099.         }
  3100.         if (Screen_Mode == VGA)
  3101.         {
  3102.           Floor_Block[1] = screen_addr+76800+(640*smallest_height);
  3103.         }
  3104.         else
  3105.         {
  3106.           Floor_Block[1] = screen_addr+38400-320+(320*smallest_height);
  3107.             }
  3108.         Floor_Block[3] = (current_screen_height/2)-smallest_height;
  3109.         if (Screen_Mode == VGA)
  3110.         {
  3111.           PlotFloorVGA((int)&Floor_Block[0]);
  3112.           /*AdaptiveRedrawScreenVGA(screen_address,screen_width,screen_height);*/
  3113.         }
  3114.         else
  3115.         {
  3116.           PlotFloor((int)&Floor_Block[0]);
  3117.         }
  3118.       }
  3119.       else
  3120.       {
  3121.         if (Screen_Mode ==VGA)
  3122.         {
  3123.           AdaptiveRedrawScreenVGA(screen_addr,current_screen_width,current_screen_height);
  3124.         }
  3125.         else
  3126.         {
  3127.           AdaptiveRedrawScreen(screen_addr,current_screen_width,current_screen_height);
  3128.         }
  3129.       }
  3130.     }
  3131.  
  3132.     Plot_Block[0] = (int)&distance[0];
  3133.     Plot_Block[1] = (int)&data_address[0];
  3134.     Plot_Block[2] = current_screen_width;
  3135.  
  3136.     Plot_Block[17] = (int)&block_data[0][0];
  3137.     Plot_Block[19] = current_screen_height;
  3138.     Plot_Block[20] = (int)&gradient_table[0];
  3139.     Plot_Block[21] = scale_factor;
  3140.  
  3141.     Plot_Block[22] = convert_colour(colour_red,colour_green,colour_blue)<<16;
  3142.  
  3143.     if (Screen_Mode == VGA)
  3144.     {
  3145.       Plot_Block[16] = screen_addr-76800-8;
  3146.       DrawScaledLineVGA((int)&Plot_Block[0]);
  3147.     }
  3148.     else
  3149.     {
  3150.       Plot_Block[16] = screen_addr-8;
  3151.       DrawScaledLine((int)&Plot_Block[0]);
  3152.     }
  3153.  
  3154.     /* Draw Sprite */
  3155.         Sprite_Plot_Block[0] = temp_counter;
  3156.         temp_counter = temp_counter + temp_direction;
  3157.         if ((temp_counter > 14)|(temp_counter < 2))
  3158.         {
  3159.           temp_direction = -temp_direction;
  3160.         }
  3161.  
  3162.         Frame_Size = current_screen_height;
  3163.     /*Sprite_Plot_Block[1] = 8;
  3164.         Sprite_Plot_Block[2] = 312;
  3165.         Sprite_Plot_Block[3] = Frame_Size;
  3166.         Sprite_Plot_Block[4] = (128<<20)/(Frame_Size);
  3167.         Sprite_Plot_Block[5] = 160;*/
  3168.         Sprite_Plot_Block[7] = (int)&sprite_data[0];
  3169.         Sprite_Plot_Block[8] = 320;
  3170.         Sprite_Plot_Block[9] = 240;
  3171.         Sprite_Plot_Block[11] = (Frame_Size*1048576)/128;
  3172.  
  3173.         if (Sprite_Plot_Block[1] < 320)
  3174.     {
  3175.           if (Screen_Mode == VGA)
  3176.       {
  3177.             Sprite_Plot_Block[6] = screen_addr-((320-current_screen_width)>>1)+320;
  3178.             PlotSpriteVGA((int)&Sprite_Plot_Block[0]);
  3179.           }
  3180.           else
  3181.           {
  3182.             Sprite_Plot_Block[6] = screen_addr-((320-current_screen_width)>>1)-320;
  3183.             PlotSprite((int)&Sprite_Plot_Block[0]);
  3184.           }
  3185.         }
  3186.  
  3187.     /* Draw Gun */
  3188.         Weapon_Plot_Block[0] = Frame_Number;
  3189.  
  3190.         Frame_Size = current_screen_height;
  3191.     Weapon_Plot_Block[1] = 8;
  3192.         Weapon_Plot_Block[2] = 312;
  3193.         Weapon_Plot_Block[3] = Frame_Size;
  3194.         Weapon_Plot_Block[4] = (240<<20)/(Frame_Size);
  3195.         Weapon_Plot_Block[5] = 160;
  3196.         Weapon_Plot_Block[7] = (int)&weapon_data[0];
  3197.         Weapon_Plot_Block[8] = 320;
  3198.         Weapon_Plot_Block[9] = 240;
  3199.         Weapon_Plot_Block[11] = (Frame_Size*1048576)/240;
  3200.  
  3201.           if (Screen_Mode == VGA)
  3202.       {
  3203.             Weapon_Plot_Block[6] = screen_addr-((320-current_screen_width)>>1)+320;
  3204.             PlotWeaponVGA((int)&Weapon_Plot_Block[0]);
  3205.           }
  3206.           else
  3207.           {
  3208.             Weapon_Plot_Block[6] = screen_addr-((320-current_screen_width)>>1)-320;
  3209.             PlotWeapon((int)&Weapon_Plot_Block[0]);
  3210.           }
  3211.  
  3212.  
  3213.  
  3214. }
  3215.  
  3216.  
  3217. int BioHazard()
  3218. {
  3219.  
  3220.     /* Turn off cursor */
  3221.     os_swi(54, point_registers);
  3222.  
  3223.     /*printf("Please wait - calculating tables...");*/
  3224.  
  3225.     /*InitiateScreenEvent();*/
  3226.  
  3227.     /* Turn off cursor */
  3228.     os_swi(54, point_registers);
  3229.  
  3230.     Quit = 0;
  3231.     while (Quit != 1)
  3232.     {
  3233.  
  3234.       if (BB_Flag == 1)
  3235.       {
  3236.         BB_Value = Black_Box[BB_Pointer];
  3237.       }
  3238.       else
  3239.       {
  3240.         BB_Value = 0;
  3241.       }
  3242.  
  3243.       /* get mouse X,Y co-ords & button state */
  3244.       os_swi(28, point_registers); /* OS_Mouse */
  3245.       Buttons = registers.r[2];
  3246.  
  3247.       if ((Buttons == 2)&&(Tasking_Mode == Single))
  3248.       {
  3249.         Quit = 1;
  3250.       }
  3251.  
  3252.       if (Play_Mode == Full_Screen)
  3253.       {
  3254.         current_screen_width = screen_width;
  3255.         current_screen_height = screen_height;
  3256.       }
  3257.       else if (Play_Mode == Tactical_Map)
  3258.       {
  3259.         current_screen_width = tactical_screen_width;
  3260.         current_screen_height = tactical_screen_height;
  3261.       }
  3262.       else if (Play_Mode == Main_Player)
  3263.       {
  3264.         current_screen_width = main_screen_width;
  3265.         current_screen_height = main_screen_height;
  3266.       }
  3267.  
  3268.           if ((input_focus == TRUE)||(Tasking_Mode == Single))
  3269.           {
  3270.             Read_Keys();
  3271.           }
  3272.  
  3273.       for (loop1=0; loop1<2; loop1++)
  3274.       {
  3275.         if (door_active[loop1] == 1)
  3276.         {
  3277.           door_frame_counter[loop1]++;
  3278.           if (door_frame_counter[loop1] < 32)
  3279.           {
  3280.             door_map[door_position[loop1][0]][door_position[loop1][1]] = (door_frame_counter[loop1])<<1;
  3281.           }
  3282.           else if ((door_frame_counter[loop1] >= 32)&(door_frame_counter[loop1] < 64))
  3283.           {
  3284.             map[door_position[loop1][0]][door_position[loop1][1]] = 0;
  3285.           }
  3286.           else if ((door_frame_counter[loop1] >= 64)&(door_frame_counter[loop1] < 96))
  3287.           {
  3288.  
  3289.             if (((X>>22)==(door_position[loop1][0]))&((Y>>22)==(door_position[loop1][1])))
  3290.             {
  3291.               door_frame_counter[loop1] = 64;
  3292.               /* play door grinding sample */
  3293.               registers.r[0] = 1;
  3294.               registers.r[1] = 10;
  3295.               registers.r[2] = 3;
  3296.               registers.r[3] = 0;
  3297.               registers.r[4] = 0;
  3298.               registers.r[5] = 15;
  3299.               registers.r[6] = 0;
  3300.                /*os_swi(284806, point_registers);*/ /* Dsym */
  3301.             }
  3302.             else
  3303.             {
  3304.               if (door_frame_counter[loop1] == 64)
  3305.               {
  3306.                 /* play door closing sample */
  3307.                 registers.r[0] = 1;
  3308.                 registers.r[1] = 10;
  3309.                 registers.r[2] = 3;
  3310.                 registers.r[3] = 0;
  3311.                 registers.r[4] = 0;
  3312.                 registers.r[5] = 0;
  3313.                 registers.r[6] = 0;
  3314.                  /*os_swi(284806, point_registers);*/ /* Dsym */
  3315.              }
  3316.               map[door_position[loop1][0]][door_position[loop1][1]] = door_code;
  3317.               door_map[door_position[loop1][0]][door_position[loop1][1]] = (31 - (door_frame_counter[loop1] & 31))<<1;
  3318.             }
  3319.           }
  3320.           else if (door_frame_counter[loop1] >= 96)
  3321.           {
  3322.             door_active[loop1] = 0;
  3323.             door_frame_counter[loop1] = 0;
  3324.             door_map[door_position[loop1][0]][door_position[loop1][1]] = 0;
  3325.           }
  3326.         }
  3327.       }
  3328.  
  3329.           /* weaponry state machines */
  3330.           if (Weapon_Type == Chainsaw)
  3331.           {
  3332.             if (State_Counter == 1)
  3333.             {
  3334.               if (State_Frame == 1)
  3335.               {
  3336.              registers.r[0] = 0;
  3337.             registers.r[1] = 17;
  3338.             registers.r[2] = 3;
  3339.             registers.r[3] = 0;
  3340.             registers.r[4] = 0;
  3341.             registers.r[5] = 0;
  3342.             registers.r[6] = 0;
  3343.              os_swi(284806, point_registers);
  3344.               }
  3345.               State_Frame++;
  3346.               State_Frame_Counter++;
  3347.               if (State_Frame_Counter == 8)
  3348.               {
  3349.                 Frame_Number++;
  3350.                 State_Frame_Counter = 0;
  3351.               }
  3352.               if (Frame_Number == 10)
  3353.               {
  3354.                 Frame_Number = 8;
  3355.               }
  3356.               if (State_Frame == 100)
  3357.               {
  3358.                 State_Counter=2;
  3359.                 State_Frame_Counter = 0;
  3360.                 State_Frame = 0;
  3361.                 Frame_Number = 10;
  3362.                 Direction = 1;
  3363.  
  3364.              registers.r[0] = 0;
  3365.             registers.r[1] = 17;
  3366.             registers.r[2] = 4;
  3367.             registers.r[3] = 0;
  3368.             registers.r[4] = 0;
  3369.             registers.r[5] = 0;
  3370.             registers.r[6] = 0;
  3371.              os_swi(284806, point_registers);
  3372.               }
  3373.             }
  3374.             else if (State_Counter == 2)
  3375.             {
  3376.               State_Frame++;
  3377.               State_Frame_Counter++;
  3378.               if (State_Frame_Counter == 8)
  3379.               {
  3380.                 Frame_Number=Frame_Number+Direction;
  3381.                 State_Frame_Counter = 0;
  3382.               }
  3383.               if (Frame_Number == 15)
  3384.               {
  3385.                 Direction = -1;
  3386.               }
  3387.               if (Frame_Number == 11)
  3388.               {
  3389.                 Direction = 1;
  3390.               }
  3391.               if (State_Frame == 80)
  3392.               {
  3393.                 if (Weapon_Active == 0)
  3394.                 {
  3395.                   State_Counter=0;
  3396.                   State_Frame = 0;
  3397.                   Frame_Number = 1;
  3398.                   Direction = 1;
  3399.                   State_Frame_Counter = 0;
  3400.  
  3401.               registers.r[0] = 0;
  3402.               registers.r[1] = 17;
  3403.               registers.r[2] = 1;
  3404.               registers.r[3] = 0;
  3405.               registers.r[4] = 0;
  3406.               registers.r[5] = 0;
  3407.               registers.r[6] = 0;
  3408.                os_swi(284806, point_registers);
  3409.                 }
  3410.                 Weapon_Active = 0;
  3411.                 State_Frame = 0;
  3412.               }
  3413.             }
  3414.           }
  3415.  
  3416.           if (Weapon_Type == MGun)
  3417.           {
  3418.             if (State_Counter == 1)
  3419.             {
  3420.               State_Frame++;
  3421.               State_Frame_Counter++;
  3422.               if (State_Frame_Counter == 4)
  3423.               {
  3424.                 Frame_Number++;
  3425.                 State_Frame_Counter = 0;
  3426.               }
  3427.               if (Frame_Number == 8)
  3428.               {
  3429.                 State_Counter=2;
  3430.                 State_Frame_Counter = 0;
  3431.                 State_Frame = 0;
  3432.                 Frame_Number = 8;
  3433.  
  3434.              registers.r[0] = 0;
  3435.             registers.r[1] = 25;
  3436.             registers.r[2] = 5;
  3437.             registers.r[3] = 0;
  3438.             registers.r[4] = 0;
  3439.             registers.r[5] = 0;
  3440.             registers.r[6] = 0;
  3441.              os_swi(284806, point_registers);
  3442.               }
  3443.             }
  3444.             else if (State_Counter == 2)
  3445.             {
  3446.               State_Frame++;
  3447.               State_Frame_Counter++;
  3448.               if (State_Frame_Counter == 4)
  3449.               {
  3450.                 Frame_Number++;
  3451.                 State_Frame_Counter = 0;
  3452.               }
  3453.               if (Frame_Number == 8)
  3454.               {
  3455.                 Frame_Number = 6;
  3456.              registers.r[0] = 0;
  3457.             registers.r[1] = 25;
  3458.             registers.r[2] = 5;
  3459.             registers.r[3] = 0;
  3460.             registers.r[4] = 0;
  3461.             registers.r[5] = 0;
  3462.             registers.r[6] = 0;
  3463.              os_swi(284806, point_registers);
  3464.               }
  3465.               if (State_Frame == 8)
  3466.               {
  3467.                 if (Weapon_Active == 0)
  3468.                 {
  3469.                   State_Counter=0;
  3470.                   State_Frame = 0;
  3471.                   Frame_Number = 1;
  3472.                   Direction = 1;
  3473.                   State_Frame_Counter = 0;
  3474.  
  3475.               registers.r[0] = 0;
  3476.               registers.r[1] = 25;
  3477.               registers.r[2] = 5;
  3478.               registers.r[3] = 0;
  3479.               registers.r[4] = 0;
  3480.               registers.r[5] = 0;
  3481.               registers.r[6] = 0;
  3482.                os_swi(284806, point_registers);
  3483.                 }
  3484.                 Weapon_Active = 0;
  3485.                 State_Frame = 0;
  3486.               }
  3487.             }
  3488.           }
  3489.  
  3490.           if (Weapon_Type == Grenade)
  3491.           {
  3492.             if (State_Counter == 1)
  3493.             {
  3494.               State_Frame++;
  3495.               State_Frame_Counter++;
  3496.               if (State_Frame_Counter == 4)
  3497.               {
  3498.                 Frame_Number++;
  3499.                 State_Frame_Counter = 0;
  3500.               }
  3501.               if (Frame_Number == 15)
  3502.               {
  3503.                 State_Counter=0;
  3504.                 State_Frame_Counter = 0;
  3505.                 State_Frame = 0;
  3506.                 Frame_Number = 0;
  3507.  
  3508.              registers.r[0] = 0;
  3509.             registers.r[1] = 25;
  3510.             registers.r[2] = 5;
  3511.             registers.r[3] = 0;
  3512.             registers.r[4] = 0;
  3513.             registers.r[5] = 0;
  3514.             registers.r[6] = 0;
  3515.              os_swi(284806, point_registers);
  3516.               }
  3517.             }
  3518.           }
  3519.  
  3520.           if (Weapon_Type == Chaingun)
  3521.           {
  3522.             if (State_Counter == 1)
  3523.             {
  3524.               State_Frame++;
  3525.               State_Frame_Counter++;
  3526.               if (State_Frame_Counter == 4)
  3527.               {
  3528.                 Frame_Number++;
  3529.                 State_Frame_Counter = 0;
  3530.               }
  3531.               if (Frame_Number == 8)
  3532.               {
  3533.                 State_Counter=2;
  3534.                 State_Frame_Counter = 0;
  3535.                 State_Frame = 0;
  3536.                 Frame_Number = 8;
  3537.  
  3538.              registers.r[0] = 0;
  3539.             registers.r[1] = 25;
  3540.             registers.r[2] = 5;
  3541.             registers.r[3] = 0;
  3542.             registers.r[4] = 0;
  3543.             registers.r[5] = 0;
  3544.             registers.r[6] = 0;
  3545.              os_swi(284806, point_registers);
  3546.               }
  3547.             }
  3548.             else if (State_Counter == 2)
  3549.             {
  3550.               State_Frame++;
  3551.               State_Frame_Counter++;
  3552.               if (State_Frame_Counter == 4)
  3553.               {
  3554.                 Frame_Number++;
  3555.                 State_Frame_Counter = 0;
  3556.               }
  3557.               if (Frame_Number == 9)
  3558.               {
  3559.                 Frame_Number = 7;
  3560.              registers.r[0] = 0;
  3561.             registers.r[1] = 25;
  3562.             registers.r[2] = 5;
  3563.             registers.r[3] = 0;
  3564.             registers.r[4] = 0;
  3565.             registers.r[5] = 0;
  3566.             registers.r[6] = 0;
  3567.              os_swi(284806, point_registers);
  3568.               }
  3569.               if (State_Frame == 32)
  3570.               {
  3571.                 if (Weapon_Active == 0)
  3572.                 {
  3573.                   State_Counter=0;
  3574.                   State_Frame = 0;
  3575.                   Frame_Number = 1;
  3576.                   Direction = 1;
  3577.                   State_Frame_Counter = 0;
  3578.  
  3579.               registers.r[0] = 0;
  3580.               registers.r[1] = 25;
  3581.               registers.r[2] = 5;
  3582.               registers.r[3] = 0;
  3583.               registers.r[4] = 0;
  3584.               registers.r[5] = 0;
  3585.               registers.r[6] = 0;
  3586.                os_swi(284806, point_registers);
  3587.                 }
  3588.                 Weapon_Active = 0;
  3589.                 State_Frame = 0;
  3590.               }
  3591.             }
  3592.           }
  3593.  
  3594.       rotate_offset = direction_angle + 1920;
  3595.       if (rotate_offset > 3839)
  3596.       {
  3597.         rotate_offset = rotate_offset - 3840;
  3598.       }
  3599.  
  3600.       X_conv1 = X + (x_move_table[rotate_offset]);
  3601.       Y_conv1 = Y - (y_move_table[rotate_offset]);
  3602.  
  3603.  
  3604.  
  3605.       /*
  3606.       else if (s == 3)
  3607.       {
  3608.         screen_address = screen_vars[0]+163840;
  3609.       }
  3610.  
  3611.       VerifyBufferClear(s);*/
  3612.  
  3613.  
  3614.       /* Clear screen */
  3615.       /*BigRedrawScreen(screen_address);*/
  3616.       rotate_offset = 3839-direction_angle;
  3617.       Floor_Block[2] = (int)&Floor_Sprite[0][0];
  3618.       Floor_Block[4] = ((X>>16)&127)<<16;
  3619.       Floor_Block[5] = ((Y>>16)&127)<<16;
  3620.       Floor_Block[6] = current_screen_width;
  3621.       Floor_Block[7] = current_screen_height;
  3622.       Floor_Block[8] = (int)(cos(rotate_offset*1.6362461737E-03)*65536);
  3623.       Floor_Block[9] = (int)(sin(rotate_offset*1.6362461737E-03)*65536);
  3624.       rotate_position = 0;
  3625.       /*Floor_Block[4] = X_conv1&4194303;
  3626.       Floor_Block[5] = Y_conv1&4194303;*/
  3627.  
  3628.       map[6][6] = 128;
  3629.       sprite_x = 352;
  3630.       sprite_y = 352;
  3631.  
  3632.           if (mono_time == 0)
  3633.           {
  3634.         /* read monotonic time, calculate interval */
  3635.             os_swi(0x42, point_registers); /* Read Monotonic Timer */
  3636.             old_time = registers.r[0];
  3637.  
  3638.         /* Wait */
  3639.         if (Wait_Mode == 1)
  3640.         {
  3641.           registers.r[0] = 19;
  3642.           os_swi(6, point_registers);
  3643.             }
  3644.  
  3645.         if (Tasking_Mode == Single)
  3646.         {
  3647.           /* Flip screen banks */
  3648.           registers.r[0] = 112;
  3649.           registers.r[1] = 3-s;
  3650.           os_swi(6, point_registers);
  3651.  
  3652.           registers.r[0] = 113;
  3653.           registers.r[1] = s;
  3654.           os_swi(6, point_registers);
  3655.  
  3656.           /* Modify screen bank variables */
  3657.           s++;
  3658.  
  3659.           if (s > 2)
  3660.           {
  3661.             s = 1;
  3662.           }
  3663.         }
  3664.  
  3665.         if (s == 1)
  3666.         {
  3667.           if (Play_Mode == 1)
  3668.           {
  3669.               if (Tasking_Mode == Single)
  3670.             {
  3671.               screen_address = screen_vars[0]+((320-current_screen_width)>>1);
  3672.             }
  3673.             else
  3674.             {
  3675.               screen_address = virtual_screen_pointer+((320-current_screen_width)>>1);
  3676.             }
  3677.           }
  3678.           else if (Play_Mode == Tactical_Map)
  3679.           {
  3680.             if (Screen_Mode == VGA)
  3681.             {
  3682.               screen_address = screen_vars[0]+40376-160+((320-current_screen_width)>>1);
  3683.             }
  3684.               else
  3685.               {
  3686.                 if (Tasking_Mode == Single)
  3687.               {
  3688.                 screen_address = screen_vars[0]+20376+((320-current_screen_width)>>1);
  3689.               }
  3690.               else
  3691.               {
  3692.                 screen_address = virtual_screen_pointer+20376+((320-current_screen_width)>>1);
  3693.               }
  3694.             }
  3695.               }
  3696.           else if (Play_Mode == Main_Player)
  3697.           {
  3698.             if (Screen_Mode == VGA)
  3699.             {
  3700.               screen_address = screen_vars[0]+25600+((320-current_screen_width)>>1);
  3701.             }
  3702.               else
  3703.               {
  3704.                 if (Tasking_Mode == Single)
  3705.               {
  3706.                 screen_address = screen_vars[0]+12800+((320-current_screen_width)>>1);
  3707.               }
  3708.               else
  3709.               {
  3710.                 screen_address = virtual_screen_pointer+12800+((320-current_screen_width)>>1);
  3711.               }
  3712.             }
  3713.               }
  3714.         }
  3715.         else
  3716.         {
  3717.           if (Play_Mode == 1)
  3718.           {
  3719.             if (Screen_Mode == VGA)
  3720.             {
  3721.               screen_address = screen_vars[0]+153600+((320-current_screen_width)>>1);
  3722.             }
  3723.             else
  3724.             {
  3725.               if (Tasking_Mode == Single)
  3726.               {
  3727.                 screen_address = screen_vars[0]+81920+((320-current_screen_width)>>1);
  3728.               }
  3729.               else
  3730.               {
  3731.                   screen_address = virtual_screen_pointer+((320-current_screen_width)>>1);
  3732.                 }
  3733.               }
  3734.           }
  3735.           else if (Play_Mode == Tactical_Map)
  3736.           {
  3737.             if (Screen_Mode == VGA)
  3738.             {
  3739.               screen_address = screen_vars[0]+153600+40376-160+((320-current_screen_width)>>1);
  3740.             }
  3741.             else
  3742.             {
  3743.               if (Tasking_Mode == Single)
  3744.               {
  3745.                 screen_address = screen_vars[0]+81920+20376+((320-current_screen_width)>>1);
  3746.               }
  3747.               else
  3748.               {
  3749.                   screen_address = virtual_screen_pointer+20376+((320-current_screen_width)>>1);
  3750.                 }
  3751.               }
  3752.           }
  3753.           else if (Play_Mode == Main_Player)
  3754.           {
  3755.             if (Screen_Mode == VGA)
  3756.             {
  3757.               screen_address = screen_vars[0]+153600+25600+((320-current_screen_width)>>1);
  3758.             }
  3759.             else
  3760.             {
  3761.               if (Tasking_Mode == Single)
  3762.               {
  3763.                 screen_address = screen_vars[0]+81920+12800+((320-current_screen_width)>>1);
  3764.               }
  3765.               else
  3766.               {
  3767.                   screen_address = virtual_screen_pointer+12800+((320-current_screen_width)>>1);
  3768.                 }
  3769.               }
  3770.           }
  3771.         }
  3772.  
  3773.         Sprite_Plot_Block[1] = 1024;
  3774.  
  3775.         if (Play_Mode == Full_Screen)
  3776.         {
  3777.           RayCastScene(X,Y,direction_angle,screen_address,0,&PT_EDDIE[0],scale_factor,screen_width,screen_height,&view_cos_table[0]);
  3778.           if (Screen_Mode == VGA)
  3779.           {
  3780.             DrawNumberVGA(screen_address,1,(int)&Number_Data[0]);
  3781.           }
  3782.           else
  3783.           {
  3784.             DrawNumber(screen_address,1,(int)&Number_Data[0]);
  3785.           }
  3786.           DrawSmallMap(screen_address+64000-64,1);
  3787.         }
  3788.         else if (Play_Mode == Tactical_Map)
  3789.         {
  3790.           RayCastScene(X,Y,direction_angle,screen_address,0,&PT_Tactical[0],tactical_scale_factor,tactical_screen_width,tactical_screen_height,&tactical_view_cos_table[0]);
  3791.           if (Screen_Mode == VGA)
  3792.           {
  3793.             Draw_Map(screen_address-((320-tactical_screen_width)>>1)+13024-40376+50);
  3794.             DrawNumberVGA(screen_address+(320*tactical_screen_height),1,(int)&Number_Data[0]);
  3795.           }
  3796.           else
  3797.           {
  3798.             Draw_Map(screen_address-((320-tactical_screen_width)>>1)+6512-20376);
  3799.             DrawNumber(screen_address+(160*tactical_screen_height),1,(int)&Number_Data[0]);
  3800.           }
  3801.         }
  3802.         else if (Play_Mode == Main_Player)
  3803.         {
  3804.           RayCastScene(X,Y,direction_angle,screen_address-64,0,&PT_main[0],main_scale_factor,main_screen_width,main_screen_height,&main_view_cos_table[0]);
  3805.  
  3806.           if (Screen_Mode == VGA)
  3807.           {
  3808.                 current_screen_width = tactical_screen_width;
  3809.                 current_screen_height = tactical_screen_height;
  3810.                 Play_Mode = Tactical_Map;
  3811.             Floor_Block[6] = current_screen_width;
  3812.             Floor_Block[7] = current_screen_height;
  3813.             RayCastScene(384<<16,224<<16,direction_angle,screen_address-64000-68,0,&PT_Tactical[0],tactical_scale_factor,tactical_screen_width,tactical_screen_height,&tactical_view_cos_table[0]);
  3814.             RayCastScene(X,Y,direction_angle,screen_address-64000+132,0,&PT_Tactical[0],tactical_scale_factor,tactical_screen_width,tactical_screen_height,&tactical_view_cos_table[0]);
  3815.             RayCastScene(X,Y,direction_angle,screen_address-64000+32,0,&PT_Tactical[0],tactical_scale_factor,tactical_screen_width,tactical_screen_height,&tactical_view_cos_table[0]);
  3816.             DrawSmallMap(screen_address+64000-64,0);
  3817.             DrawNumberVGA(screen_address-19200-68,player_map[1],(int)&Number_Data[0]);
  3818.             DrawNumberVGA(screen_address+32-19200,player_map[2],(int)&Number_Data[0]);
  3819.             DrawNumberVGA(screen_address+132-19200,player_map[3],(int)&Number_Data[0]);
  3820.             DrawNumberVGA(screen_address+19200+19200+96,player_map[0],(int)&Number_Data[0]);
  3821.           }
  3822.           else
  3823.           {
  3824.                 current_screen_width = tactical_screen_width;
  3825.                 current_screen_height = tactical_screen_height;
  3826.                 Play_Mode = Tactical_Map;
  3827.             Floor_Block[6] = current_screen_width;
  3828.             Floor_Block[7] = current_screen_height;
  3829.             RayCastScene(384<<16,224<<16,direction_angle,screen_address-32000-68,0,&PT_Tactical[0],tactical_scale_factor,tactical_screen_width,tactical_screen_height,&tactical_view_cos_table[0]);
  3830.             RayCastScene(X,Y,direction_angle,screen_address-32000+132,0,&PT_Tactical[0],tactical_scale_factor,tactical_screen_width,tactical_screen_height,&tactical_view_cos_table[0]);
  3831.             RayCastScene(X,Y,direction_angle,screen_address-32000+32,0,&PT_Tactical[0],tactical_scale_factor,tactical_screen_width,tactical_screen_height,&tactical_view_cos_table[0]);
  3832.             DrawSmallMap(screen_address-((320-tactical_screen_width)>>1)+32000-64,0);
  3833.             DrawNumber(screen_address-9600-68,player_map[1],(int)&Number_Data[0]);
  3834.             DrawNumber(screen_address+32-9600,player_map[2],(int)&Number_Data[0]);
  3835.             DrawNumber(screen_address+132-9600,player_map[3],(int)&Number_Data[0]);
  3836.             DrawNumber(screen_address+19200+96,player_map[0],(int)&Number_Data[0]);
  3837.           }
  3838.               current_screen_width = main_screen_width;
  3839.               current_screen_height = main_screen_height;
  3840.               Play_Mode = Main_Player;
  3841.         }
  3842.  
  3843.         if ((Tasking_Mode == Multi)&&(mono_time==0))
  3844.         {
  3845.           Quit = 1;
  3846.         }
  3847.  
  3848.         /* read monotonic time, calculate interval */
  3849.             os_swi(0x42, point_registers); /* Read Monotonic Timer */
  3850.             new_time = registers.r[0];
  3851.  
  3852.             mono_time = new_time - old_time;
  3853.             if (mono_time < 2)
  3854.             {
  3855.               mono_time = 1;
  3856.             }
  3857.           }
  3858.  
  3859.       FrameCounter++;
  3860.           mono_time--;
  3861.  
  3862.       if (BB_Flag == 0)
  3863.       {
  3864.         Black_Box[BB_Pointer] = BB_Value;
  3865.       }
  3866.  
  3867.       /*BB_Pointer++;*/
  3868.  
  3869.       if (BB_Pointer == Black_Box[0])
  3870.       {
  3871.         Quit = 1;
  3872.       }
  3873.  
  3874.       /*Secret_Door_Position = ((Secret_Door_Position+2)&63);*/
  3875.  
  3876.       /*SetFlagBufferUsed(s);
  3877.       ScreenEvent();*/
  3878.     }
  3879.  
  3880.     /* Fade out music */
  3881.     for (loopA=64; loopA>1; loopA--)
  3882.     {
  3883.  
  3884.       /* Waits added for timed fade, otherwise too fast
  3885.       registers.r[0] = 19;
  3886.       os_swi(6, point_registers);
  3887.  
  3888.        Wait
  3889.       registers.r[0] = 19;
  3890.       os_swi(6, point_registers);
  3891.  
  3892.        set volume
  3893.       registers.r[0] = loopA;
  3894.       os_swi(284802, point_registers);  Dsym */
  3895.     }
  3896.  
  3897.     /* pause music
  3898.     os_swi(284814, point_registers);  Dsym */
  3899.  
  3900.     /* reset volume
  3901.     registers.r[0] = 64;
  3902.     os_swi(284802, point_registers);  Dsym */
  3903.  
  3904.     return 0;
  3905.  
  3906. }
  3907.  
  3908.  
  3909. /********************************* CONSTANTS ********************************/
  3910.  
  3911. /* Menu items */
  3912. #define biohazard_menu_info     1
  3913. #define biohazard_menu_task     2
  3914. #define biohazard_menu_config   3
  3915. #define biohazard_menu_pause    4
  3916. #define biohazard_menu_quit     5
  3917.  
  3918. /* Info box field for the version string */
  3919. #define biohazard_info_field    4
  3920.  
  3921. /******************************** GLOBAL DATA *******************************/
  3922.  
  3923. /* Application version */
  3924. static char *biohazard_Version_String = "0.7x (not for distribution!!!)";
  3925.  
  3926. /* The top of the menu tree */
  3927. static menu biohazard_menu;
  3928.  
  3929. /* Handle for the biohazard window */
  3930. static wimp_w biohazard_win_handle;
  3931.  
  3932. /* Handle for the biohazard window */
  3933. static wimp_w config_win_handle;
  3934.  
  3935. /* Handle for the init window */
  3936. static wimp_w biohazard_init_handle;
  3937.  
  3938. /* Flag - is the window open */
  3939. static BOOL biohazard_window_open = FALSE;
  3940.  
  3941. /***************************** WINDOW FUNCTIONS *****************************/
  3942.  
  3943. /*--- Create the window, yielding its handle. Return TRUE if ok. ---*/
  3944. static BOOL biohazard_create_window(char *name, wimp_w *handle)
  3945. {
  3946.   wimp_wind *window;    /* Pointer to window definition */
  3947.  
  3948.   /* Find template for the window */
  3949.     window = template_syshandle(name);
  3950.     if (window == 0)
  3951.       return FALSE;
  3952.  
  3953.   /* Create the window, dealing with errors */
  3954.   return (wimpt_complain(wimp_create_wind(window, handle)) == 0);
  3955. }
  3956.  
  3957. /*--- Create the window, yielding its handle. Return TRUE if ok. ---*/
  3958. static BOOL biohazard_create_main_window(char *name, wimp_w *handle)
  3959. {
  3960.     /* Find template for the window */
  3961.     main_window_pointer = template_syshandle(name);
  3962.     if (main_window_pointer == 0)
  3963.       return FALSE;
  3964.  
  3965.     AdjustWindowSize(main_window_pointer,(int)&main_window_size);
  3966.  
  3967.   /* Create the window, dealing with errors */
  3968.   return (wimpt_complain(wimp_create_wind(main_window_pointer, handle)) == 0);
  3969. }
  3970.  
  3971.  
  3972. /*--- Individual event routines for the window ---*/
  3973. static void biohazard_redraw_window(wimp_w handle)
  3974. {
  3975.   /* Redrawing the window here does nothing - just go through the loop */
  3976.   int            more;
  3977.   wimp_redrawstr r;
  3978.  
  3979.   /* Start the redraw */
  3980.   r.w = handle;
  3981.   wimpt_noerr(wimp_redraw_wind(&r, &more));
  3982.  
  3983.   /* Do the redraw loop */
  3984.   while (more)
  3985.   {
  3986.     wimp_get_rectangle(&r, &more);
  3987.   }
  3988. }
  3989.  
  3990. static void biohazard_open_window(wimp_openstr *o)
  3991. {
  3992.   /* Just pass the open request on to the wimp */
  3993.   wimpt_noerr(wimp_open_wind(o));
  3994. }
  3995.  
  3996. /****************************** EVENT HANDLERS ******************************/
  3997.  
  3998. /*--- Event handler called on a left click on the icon. ---*/
  3999. static void biohazard_iconclick(wimp_i icon)
  4000. {
  4001.   icon = icon; /* We don't need the handle: this stops compiler warning */
  4002.  
  4003.   /* Open the window - only one allowed */
  4004.   if (biohazard_window_open)
  4005.     werr(FALSE, "BioHazard already running");
  4006.   else
  4007.   {
  4008.     wimp_wstate  state;
  4009.  
  4010.     /* Get the state of the window */
  4011.     if (wimpt_complain(wimp_get_wind_state(biohazard_win_handle, &state)) == 0)
  4012.     {
  4013.       state.o.behind = -1;           /* Make sure window is opened in front */
  4014.       wimpt_noerr(wimp_open_wind(&state.o));
  4015.       biohazard_window_open = TRUE;
  4016.       paused = FALSE;
  4017.     }
  4018.   }
  4019.   result = BioHazard();
  4020. }
  4021.  
  4022. /*--- Display the program info box - called from the menu processor. ---*/
  4023. static void biohazard_info_about_program(void)
  4024. {
  4025.   dbox  d;  /* Dialogue box handle */
  4026.  
  4027.   /* Create the dialogue box */
  4028.   if (d = dbox_new("ProgInfo"), d != NULL)
  4029.   {
  4030.     /* Fill in the version number */
  4031.     dbox_setfield(d, biohazard_info_field, biohazard_Version_String);
  4032.  
  4033.     /* Show the dialogue box */
  4034.     dbox_show(d);
  4035.  
  4036.     /* Keep it on the screen as long as needed */
  4037.     dbox_fillin(d);
  4038.  
  4039.     /* Dispose of the dialogue box */
  4040.     dbox_dispose(&d);
  4041.   }
  4042. }
  4043.  
  4044. /*--- Event handler for the menu. ---*/
  4045. static void biohazard_menuproc(void *handle, char *hit)
  4046. {
  4047.   wimp_wstate  state;
  4048.  
  4049.   handle = handle; /* We don't need handle: this stops compiler warning */
  4050.  
  4051.   /* Find which menu item was hit and take action as appropriate */
  4052.   switch (hit[0])
  4053.   {
  4054.     case biohazard_menu_info:
  4055.       biohazard_info_about_program();
  4056.       break;
  4057.  
  4058.     case biohazard_menu_task:
  4059.       /* Start single tasking */
  4060.       Tasking_Mode = Single;
  4061.  
  4062.       /* Determine screen mode to change to */
  4063.       /* get current mode info & determine Screen_Mode */
  4064.       registers.r[0] = -1;
  4065.       registers.r[1] = 12;
  4066.       os_swi(53, point_registers); /* OS_ReadModeVars */
  4067.       if (registers.r[2] > 470)
  4068.       {
  4069.     Screen_Mode = VGA;
  4070.       }
  4071.       else
  4072.       {
  4073.     Screen_Mode = broadcast;
  4074.       }
  4075.  
  4076.       registers.r[0] = 135;
  4077.       os_swi(0x06, point_registers); /* read current screen mode */
  4078.       current_screen_mode = registers.r[2];
  4079.  
  4080.       screen_vars[0] = 149;
  4081.       screen_vars[1] = 11;
  4082.       screen_vars[2] = 12;
  4083.       screen_vars[3] = -1;
  4084.       screen_vars[4] = 0;
  4085.       screen_vars[5] = 0;
  4086.       screen_vars[6] = 0;
  4087.       screen_vars[7] = 0;
  4088.  
  4089.       /* draw screen border */
  4090.       if (Screen_Mode == VGA)
  4091.       {
  4092.     /* check 320k of screen memory can be allocated */
  4093.         bbc_mode(28);
  4094.     bbc_mode(49);
  4095.  
  4096.         /* get screen address & set in line block */
  4097.         registers.r[0] = (int)&screen_vars[0];
  4098.         registers.r[1] = (int)&screen_vars[0];
  4099.         os_swi(49, point_registers);  /* OS_ReadVduVars */
  4100.         screen_address = (screen_vars[0]);
  4101.  
  4102.         DrawBorderVGA(screen_address,screen_width,screen_height,(int)&Backdrop[0]);
  4103.         DrawBorderVGA((screen_address+153600),screen_width,screen_height,(int)&Backdrop[0]);
  4104.       }
  4105.       else
  4106.       {
  4107.     /* check 160k of screen memory can be allocated */
  4108.     bbc_mode(15);
  4109.     bbc_mode(13);
  4110.  
  4111.         /* get screen address & set in line block */
  4112.         registers.r[0] = (int)&screen_vars[0];
  4113.         registers.r[1] = (int)&screen_vars[0];
  4114.         os_swi(49, point_registers); /* OS_ReadVduVars */
  4115.         screen_address = (screen_vars[0]);
  4116.  
  4117.         DrawBorder(screen_address,screen_width,screen_height,(int)&Backdrop[0]);
  4118.         DrawBorder((screen_address+81920),screen_width,screen_height,(int)&Backdrop[0]);
  4119.         DrawBar((screen_address+76800),(int)&Bar_Data[0]);
  4120.         DrawBar((screen_address+76800+81920),(int)&Bar_Data[0]);
  4121.       }
  4122.  
  4123.       if (Weapon_Type == Chainsaw)
  4124.       {
  4125.         /* play turnover sample */
  4126.     registers.r[0] = 0;
  4127.     registers.r[1] = 17;
  4128.     registers.r[2] = 1;
  4129.     registers.r[3] = 0;
  4130.     registers.r[4] = 0;
  4131.     registers.r[5] = 0;
  4132.     registers.r[6] = 0;
  4133.      os_swi(284806, point_registers); /* Dsym */
  4134.       }
  4135.  
  4136.       /* play Game_On opening sample */
  4137.       registers.r[0] = 1;
  4138.       registers.r[1] = 29;
  4139.       registers.r[2] = Level_1;
  4140.       registers.r[3] = 0;
  4141.       registers.r[4] = 0;
  4142.       registers.r[5] = 0;
  4143.       registers.r[6] = 0;
  4144.       os_swi(284806, point_registers); /* Dsym */
  4145.  
  4146.       /* run main program */
  4147.       s = 0;
  4148.       Quit = 0;
  4149.       result = BioHazard();
  4150.  
  4151.       Screen_Mode = broadcast;
  4152.       Tasking_Mode = Multi;
  4153.       screen_address = virtual_screen_pointer;
  4154.  
  4155.       DrawBorder(virtual_screen_pointer,screen_width,screen_height,(int)&Backdrop[0]);
  4156.       result = BioHazard(); /* update sprite */
  4157.  
  4158.       /* reset old screen mode */
  4159.       registers.r[0] = current_screen_mode;
  4160.       os_swi(0x400E3, point_registers); /* set old wimpmode */
  4161.       registers.r[0] = (int)pointer_on;
  4162.       os_swi(0x05, point_registers); /* turn on pointer */
  4163.  
  4164.       registers.r[0] = -1;
  4165.       registers.r[1] = 0;
  4166.       registers.r[2] = 0;
  4167.       registers.r[3] = 3200;
  4168.       registers.r[4] = 1600;
  4169.       os_swi(0x400D1, point_registers); /* Force window redraw */
  4170.  
  4171.       if (input_focus == TRUE)
  4172.       {
  4173.         /* get the input focus */
  4174.         registers.r[0] = biohazard_win_handle;
  4175.         registers.r[1] = -1;
  4176.         registers.r[2] = 0;
  4177.         registers.r[3] = 0;
  4178.         registers.r[4] = 16;
  4179.         registers.r[5] = 1;
  4180.         os_swi(0x400D2, point_registers); /* Wimp_SetCaretPosition */
  4181.       }
  4182.       break;
  4183.  
  4184.     case biohazard_menu_config:
  4185.       /* Open configuration window */
  4186.  
  4187.       /* Get the state of the window */
  4188.       if (wimpt_complain(wimp_get_wind_state(config_win_handle, &state)) == 0)
  4189.       {
  4190.         state.o.behind = -1;           /* Make sure window is opened in front */
  4191.         wimpt_noerr(wimp_open_wind(&state.o));
  4192.       }
  4193.       break;
  4194.  
  4195.     case biohazard_menu_pause:
  4196.       break;
  4197.  
  4198.     case biohazard_menu_quit:
  4199.       /* play Game_Over sample */
  4200.       registers.r[0] = 0;
  4201.       registers.r[1] = 29;
  4202.       registers.r[2] = Game_Over;
  4203.       registers.r[3] = 0;
  4204.       registers.r[4] = 0;
  4205.       registers.r[5] = 0;
  4206.       registers.r[6] = 0;
  4207.       os_swi(284806, point_registers); /* Dsym */
  4208.       /* Exit from the program. The wimp gets rid of the window and icon */
  4209.       exit(0);
  4210.  
  4211.   }
  4212. }
  4213.  
  4214. /*--- Event handler for window. ---*/
  4215. static void biohazard_event_handler(wimp_eventstr *e, void *handle)
  4216. {
  4217.   handle = handle; /* We don't need handle: this stops compiler warning */
  4218.  
  4219.   /* Deal with event */
  4220.   switch (e->e)
  4221.   {
  4222.     case wimp_ENULL:
  4223.       if (paused == FALSE)
  4224.       {
  4225.         result = BioHazard();
  4226.       }
  4227.  
  4228. #if defined(RISCPC)
  4229.       ConvertRPC(virtual_screen_pointer,sprite_data_address,OS_Bits_Per_Pixel,(int)&ColourMap[0]);
  4230. #else
  4231.       ConvertScreen(virtual_screen_pointer,sprite_data_address,OS_Bits_Per_Pixel,(int)&ColourMap[0]);
  4232. #endif
  4233.  
  4234.       registers.r[0] = biohazard_win_handle;
  4235.       registers.r[1] = -1280;
  4236.       registers.r[2] = -1024;
  4237.       registers.r[3] = 0;
  4238.       registers.r[4] = 0;
  4239.       os_swi(0x400D1, point_registers); /* Force window redraw */
  4240.       break;
  4241.  
  4242.     case wimp_EBUT:
  4243.       registers.r[0] = biohazard_win_handle;
  4244.       registers.r[1] = -1;
  4245.       registers.r[2] = 0;
  4246.       registers.r[3] = 0;
  4247.       registers.r[4] = 16;
  4248.       registers.r[5] = 1;
  4249.       os_swi(0x400D2, point_registers); /* Wimp_SetCaretPosition */
  4250.       break;
  4251.  
  4252.     case wimp_ELOSECARET:
  4253.       input_focus = FALSE;
  4254.       break;
  4255.  
  4256.     case wimp_EGAINCARET:
  4257.       input_focus = TRUE;
  4258.       break;
  4259.  
  4260.     case wimp_EREDRAW:
  4261.       biohazard_redraw_window(e->data.o.w);
  4262.       break;
  4263.  
  4264.     case wimp_EOPEN:
  4265.       biohazard_open_window(&e->data.o);
  4266.       /* get the input focus */
  4267.       registers.r[0] = biohazard_win_handle;
  4268.       registers.r[1] = -1;
  4269.       registers.r[2] = 0;
  4270.       registers.r[3] = 0;
  4271.       registers.r[4] = 16;
  4272.       registers.r[5] = 1;
  4273.       os_swi(0x400D2, point_registers); /* Wimp_SetCaretPosition */
  4274.       if (Weapon_Type == Chainsaw)
  4275.       {
  4276.         /* play turnover sample */
  4277.     registers.r[0] = 0;
  4278.     registers.r[1] = 17;
  4279.     registers.r[2] = 1;
  4280.     registers.r[3] = 0;
  4281.     registers.r[4] = 0;
  4282.     registers.r[5] = 0;
  4283.     registers.r[6] = 0;
  4284.      os_swi(284806, point_registers); /* Dsym */
  4285.       }
  4286.       break;
  4287.  
  4288.     case wimp_ECLOSE:  /* Pass on close request */
  4289.       wimpt_noerr(wimp_close_wind(e->data.o.w));
  4290.       biohazard_window_open = FALSE;
  4291.       break;
  4292.  
  4293.     case wimp_ESEND:
  4294.     case wimp_ESENDWANTACK:     /*
  4295.                                  * this code checks for mode/palette
  4296.                                  * broadcasts
  4297.                                  */
  4298.       switch(e->data.msg.hdr.action)
  4299.       {
  4300.         case wimp_PALETTECHANGE:
  4301.           /* calculate colour map positions */
  4302.           for (loop1=0; loop1 < 256; loop1++)
  4303.           {
  4304.             /* convert 256 col mode byte to pallette entry */
  4305.             pallette_entry_red = ((loop1 & 7)<<4) + ((loop1 & 16)<<3);
  4306.             pallette_entry_green = ((loop1 & 3)<<4) + ((loop1 & 96)<<1);
  4307.             pallette_entry_blue = ((loop1 & 3)<<4) + ((loop1 & 4)<<3) + (loop1 & 128);
  4308.             pallette_entry = (pallette_entry_red<<8)+(pallette_entry_green<<16)+(pallette_entry_blue<<24);
  4309.             registers.r[0] = pallette_entry;
  4310.             os_swi(0x40742, point_registers); /* ColourTrans_ReturnColourNumber */
  4311.             ColourMap[loop1] = registers.r[0];
  4312.           }
  4313.           break;
  4314.  
  4315.         case wimp_MMODECHANGE:
  4316.           wimpt_checkmode();
  4317.           OS_X_Pixels = wimpt_dx();
  4318.           OS_Y_Pixels = wimpt_dy();
  4319.           OS_Bits_Per_Pixel = wimpt_bpp();
  4320.  
  4321. #if defined(RISCPC)
  4322.             virtual_screen_pointer = (int)&virtual_screen[0];
  4323. #else
  4324.             virtual_screen_pointer = sprite_data_address;
  4325. #endif
  4326.           registers.r[0] = 135;
  4327.           os_swi(0x06, point_registers); /* read current screen mode */
  4328.           current_screen_mode = registers.r[2];
  4329.           SpriteSetMode(sprite_mode_pointer,current_screen_mode);
  4330.  
  4331.           wimp_delete_wind(biohazard_win_handle);
  4332.  
  4333.           main_window_size[0] = -1280;
  4334.           main_window_size[1] = -1024;
  4335.           main_window_size[2] = -(1280-(320*OS_X_Pixels));
  4336.           main_window_size[3] = -(1024-(256*OS_Y_Pixels));
  4337.           main_window_size[4] = (-640)+((-512)<<16);
  4338.  
  4339.           /* Create the main window, and declare its event handler */
  4340.           !biohazard_create_main_window("MainWindow", &biohazard_win_handle);
  4341.           win_register_event_handler(biohazard_win_handle, biohazard_event_handler, 0);
  4342.  
  4343.           if (biohazard_window_open == TRUE)
  4344.           {
  4345.             biohazard_open.w = biohazard_win_handle;
  4346.             biohazard_open.box.x0 = main_window_size[0];
  4347.             biohazard_open.box.y0 = main_window_size[1];
  4348.             biohazard_open.box.x1 = main_window_size[2];
  4349.             biohazard_open.box.y1 = main_window_size[3];
  4350.  
  4351.             biohazard_open.x = 0;
  4352.             biohazard_open.y = 0;
  4353.             biohazard_open.behind = -1;
  4354.  
  4355.             wimp_open_wind(&biohazard_open);
  4356.           }
  4357.  
  4358.           break;
  4359.       }
  4360.  
  4361.     default:   /* Ignore any other event */
  4362.        break;
  4363.   }
  4364. }
  4365.  
  4366.  
  4367. /****************************** INITIALISATION ******************************/
  4368.  
  4369. /*--- Initialise the program, returning TRUE if it was all OK. ---*/
  4370. static BOOL biohazard_initialise(void)
  4371. {
  4372.   wimp_wstate  state;
  4373.  
  4374.   /* turn on hourglass mouse pointer */
  4375.   registers.r[0] = (int)Song_Name;
  4376.   registers.r[2] = 0;
  4377.   os_swi(0x000406C0, point_registers); /* hourglass on */
  4378.  
  4379.   /* RISC_OSlib initialisation */
  4380.   wimpt_init("BioHazard");/* Main Wimp initialisation */
  4381.   res_init("BioHazard");            /* Resources */
  4382.   resspr_init();                   /* Application sprites */
  4383.   sprite_pointer = resspr_area();                   /* Application sprites */
  4384.   sprite_address = *sprite_pointer;
  4385.   sprite_mode_pointer = sprite_pointer;
  4386.  
  4387.   registers.r[0] = 135;
  4388.   os_swi(0x06, point_registers); /* read current screen mode */
  4389.   current_screen_mode = registers.r[2];
  4390.   SpriteSetMode(sprite_mode_pointer,current_screen_mode);
  4391.  
  4392.   sprite_pointer = sprite_pointer + sprite_address.sproff;
  4393.   sprite_data_address = (int)sprite_pointer;
  4394.   sprite_data_address = sprite_data_address - 196;
  4395.  
  4396.   template_init();                 /* Templates */
  4397.   dbox_init();                     /* Dialogue boxes */
  4398.  
  4399.   wimpt_checkmode();
  4400.   OS_X_Pixels = wimpt_dx();
  4401.   OS_Y_Pixels = wimpt_dy();
  4402.   OS_Bits_Per_Pixel = wimpt_bpp();
  4403.  
  4404. #if defined(RISCPC)
  4405.             virtual_screen_pointer = (int)&virtual_screen[0];
  4406. #else
  4407.             virtual_screen_pointer = sprite_data_address;
  4408. #endif
  4409.  
  4410.  
  4411.   main_window_size[0] = -1280;
  4412.   main_window_size[1] = -1024;
  4413.   main_window_size[2] = -(1280-(320*OS_X_Pixels));
  4414.   main_window_size[3] = -(1024-(256*OS_Y_Pixels));
  4415.   main_window_size[4] = (-640)+((-512)<<16);
  4416.  
  4417.   /* Create the main window, and declare its event handler */
  4418.   if (!biohazard_create_main_window("MainWindow", &biohazard_win_handle))
  4419.     return FALSE; /* Window creation failed */
  4420.   win_register_event_handler(biohazard_win_handle, biohazard_event_handler, 0);
  4421.  
  4422.   /* Create the configuration window, and declare its event handler */
  4423.   if (!biohazard_create_window("config", &config_win_handle))
  4424.     return FALSE; /* Window creation failed */
  4425.   win_register_event_handler(biohazard_win_handle, biohazard_event_handler, 0);
  4426.  
  4427.   /* Create the init window, and declare its event handler */
  4428.   if (!biohazard_create_window("init", &biohazard_init_handle))
  4429.     return FALSE; /* Window creation failed */
  4430.   win_register_event_handler(biohazard_init_handle, biohazard_event_handler, 0);
  4431.  
  4432.  
  4433.   /* Get the state of the window */
  4434.   if (wimpt_complain(wimp_get_wind_state(biohazard_init_handle, &state)) == 0)
  4435.   {
  4436.     state.o.behind = -1;          /* Make sure window is opened in front */
  4437.     wimpt_noerr(wimp_open_wind(&state.o));
  4438.   }
  4439.  
  4440.   /* Create the menu tree */
  4441.   if (biohazard_menu = menu_new("BioHazard", ">Info,Single Task,Configure,Pause,Quit"), biohazard_menu == NULL)
  4442.     return FALSE; /* Menu create failed */
  4443.  
  4444.   /* Set up the icon on the icon bar, and declare its event handlers */
  4445.   baricon("!biohazard", (int)resspr_area(), biohazard_iconclick);
  4446.   if (!event_attachmenu(win_ICONBAR, biohazard_menu, biohazard_menuproc, 0))
  4447.     return FALSE; /* Unable to attach menu */
  4448.  
  4449.  
  4450.   screen_address = sprite_data_address;
  4451.  
  4452.     /* Start tune... */
  4453.     /*os_swi(284801, point_registers);*/  /* Dsym */
  4454.  
  4455.     /* Load symphony from disc */
  4456.     /*registers.r[0] = (int)Song_Name;
  4457.     registers.r[2] = 0;
  4458.     os_swi(284800, point_registers);*/ /* Dsym */
  4459.  
  4460.     /* 4 voices */
  4461.     registers.r[0] = 4;
  4462.     os_swi(284815, point_registers); /* Dsym */
  4463.  
  4464.     /* set sample rate */
  4465.     registers.r[0] = 52;
  4466.     os_swi(284823, point_registers); /* Dsym */
  4467.  
  4468.     /* Reconfigure to new settings */
  4469.     registers.r[0] = 1;
  4470.     os_swi(284824, point_registers); /* Dsym */
  4471.  
  4472.     /* Start tune... */
  4473.     /*os_swi(284801, point_registers);  Dsym */
  4474.  
  4475.     /* set stereo positions */
  4476.     registers.r[0] = 0;
  4477.     registers.r[1] = 0;
  4478.     os_swi(284803, point_registers); /* Dsym */
  4479.     registers.r[0] = 1;
  4480.     registers.r[1] = 0;
  4481.     os_swi(284803, point_registers); /* Dsym */
  4482.  
  4483.   /* Load Last_Floor */
  4484.   registers.r[0] = 255;
  4485.   registers.r[1] = (int)lastfloor_name;
  4486.   registers.r[2] = (int)&Last_Floor;
  4487.   registers.r[3] = 0;
  4488.   os_swi(8, point_registers); /* OS_File */
  4489.  
  4490.   if (Last_Floor == 1)
  4491.   {
  4492.     /* Load floor sprite 1 into Floor_Sprite space */
  4493.     registers.r[0] = 255;
  4494.     registers.r[1] = (int)floorsprite1_name;
  4495.     registers.r[2] = (int)&Floor_Sprite[0][0];
  4496.     registers.r[3] = 0;
  4497.     os_swi(8, point_registers); /* OS_File */
  4498.     Last_Floor = 2;
  4499.   }
  4500.   else
  4501.   {
  4502.     /* Load floor sprite 1 into Floor_Sprite space */
  4503.     registers.r[0] = 255;
  4504.     registers.r[1] = (int)floorsprite2_name;
  4505.     registers.r[2] = (int)&Floor_Sprite[0][0];
  4506.     registers.r[3] = 0;
  4507.     os_swi(8, point_registers); /* OS_File */
  4508.     Last_Floor = 1;
  4509.   }
  4510.  
  4511.   /* Save last floor data */
  4512.   registers.r[0] = 10;
  4513.   registers.r[1] = (int)lastfloor_name;
  4514.   registers.r[2] = 0;
  4515.   registers.r[3] = 0;
  4516.   registers.r[4] = (int)&Last_Floor;
  4517.   registers.r[5] = ((int)&Last_Floor)+4;
  4518.   os_swi(8, point_registers); /* OS_File */
  4519.  
  4520.   /* Load backdrop data into backdrop space */
  4521.   registers.r[0] = 255;
  4522.   registers.r[1] = (int)backdrop_name;
  4523.   registers.r[2] = (int)&Backdrop[0];
  4524.   registers.r[3] = 0;
  4525.   os_swi(8, point_registers); /* OS_File */
  4526.  
  4527.   /* Load weapondata into weapon_data space */
  4528.   registers.r[0] = 255;
  4529.   registers.r[1] = (int)Chainsaw_name;
  4530.   registers.r[2] = (int)&weapon_data[0];
  4531.   registers.r[3] = 0;
  4532.   os_swi(8, point_registers); /* OS_File */
  4533.  
  4534.   /* Load numberdata into Number_Data space */
  4535.   registers.r[0] = 255;
  4536.   registers.r[1] = (int)Number_name;
  4537.   registers.r[2] = (int)&Number_Data[0];
  4538.   registers.r[3] = 0;
  4539.   os_swi(8, point_registers); /* OS_File */
  4540.  
  4541.  
  4542.   /* Load spritedata into sprite_data space */
  4543.   registers.r[0] = 255;
  4544.   registers.r[1] = (int)spritedata_name;
  4545.   registers.r[2] = (int)&sprite_data[0];
  4546.   registers.r[3] = 0;
  4547.   os_swi(8, point_registers); /* OS_File */
  4548.  
  4549.   /* Load bar sprite into Bar_Data space */
  4550.   registers.r[0] = 255;
  4551.   registers.r[1] = (int)bar_name;
  4552.   registers.r[2] = (int)&Bar_Data[0];
  4553.   registers.r[3] = 0;
  4554.   os_swi(8, point_registers); /* OS_File */
  4555.  
  4556.   /* Load mapdata into map space */
  4557.   registers.r[0] = 255;
  4558.   registers.r[1] = (int)mapdata_name;
  4559.   registers.r[2] = (int)&map[0][0];
  4560.   registers.r[3] = 0;
  4561.   os_swi(8, point_registers); /* OS_File */
  4562.   map[X>>22][Y>>22] = 0;
  4563.  
  4564.   /* convert word map to data map */
  4565.   for (loop1 = 0; loop1 < 64; loop1++)
  4566.   {
  4567.     for (loop2 = 0; loop2 < 64; loop2++)
  4568.     {
  4569.       if (map[loop1][loop2] != 0)
  4570.       {
  4571.         Map_Data[loop1][loop2] = 0;
  4572.       }
  4573.       else
  4574.       {
  4575.         Map_Data[loop1][loop2] = 0;
  4576.       }
  4577.     }
  4578.   }
  4579.  
  4580.  
  4581.   /* Load blockdata into block_data space */
  4582.   registers.r[0] = 255;
  4583.   registers.r[1] = (int)blockdata_name;
  4584.   registers.r[2] = (int)&block_data[0][0];
  4585.   registers.r[3] = 0;
  4586.   os_swi(8, point_registers); /* OS_File */
  4587.  
  4588.   /* Set up trigonometric tables */
  4589.   theta = 0;
  4590.   angle = PI/1920;
  4591.  
  4592.   /* Set up cos & sin division tables */
  4593.   theta = angle;
  4594.   for (loop2=1; loop2<960; loop2++)
  4595.   {
  4596.     cos_div_table[loop2] = (int)((1/(cos(theta)))*262144);
  4597.     theta = theta + angle;
  4598.   }
  4599.   cos_div_table[960] = 262144;
  4600.   cos_div_table[0] = 262144;
  4601.  
  4602.   /* tan & interception */
  4603.   theta = 0.0;
  4604.   for (loop2=0; loop2<959; loop2++)
  4605.   {
  4606.     tan_table[loop2] = (int)(tan(theta)*65536);
  4607.     increment[loop2] = (int)(tan(theta)*4194304);
  4608.  
  4609.     if (increment[loop2] > (1<<29))
  4610.     {
  4611.       increment[loop2] = (1<<29);
  4612.     }
  4613.       theta = theta + angle;
  4614.   }
  4615.   tan_table[959] = tan_table[958]+(100<<16);
  4616.   tan_table[960] = tan_table[959]+(500<<16);
  4617.   increment[959] = (1<<29)+(1<<28);
  4618.   increment[960] = (1<<29)+(2<<28);
  4619.  
  4620.   /* Set up movement */
  4621.   theta = 0;
  4622.   for (loop2=0; loop2<3840; loop2++)
  4623.   {
  4624.     move = 24*(cos(theta))*65536;
  4625.     if ((move - (int)move) > 0.5)
  4626.     {
  4627.       move += 1.0;
  4628.     }
  4629.     else if ((move - (int)move) < -0.5)
  4630.     {
  4631.       move -= 1.0;
  4632.     }
  4633.     x_move_table[loop2] = move;
  4634.  
  4635.     move = 24*(sin(theta))*65536;
  4636.     if ((move - (int)move) > 0.5)
  4637.     {
  4638.       move += 1.0;
  4639.     }
  4640.     else if ((move - (int)move) < -0.5)
  4641.     {
  4642.       move -= 1.0;
  4643.     }
  4644.     y_move_table[loop2] = move;
  4645.     theta = theta + angle;
  4646.   }
  4647.  
  4648.   /* set up gradient tables */
  4649.   for (loop2=1; loop2<1024; loop2++)
  4650.   {
  4651.     move = 64.0/((float)loop2);
  4652.     gradient_table[loop2] = (int)(move * 16384);
  4653.   }
  4654.  
  4655.   /* set up next free door list */
  4656.   for (loop2=0; loop2<64; loop2++)
  4657.   {
  4658.     Next_Free_List[loop2] = loop2;
  4659.   }
  4660.  
  4661.  
  4662.   Calculate_Tables();
  4663.   Calculate_Tactical_Tables();
  4664.   Calculate_main_Tables();
  4665.  
  4666.   /* calculate colour map positions */
  4667.   for (loop1=0; loop1 < 256; loop1++)
  4668.   {
  4669.     /* convert 256 col mode byte to pallette entry */
  4670.     pallette_entry_red = ((loop1 & 7)<<4) + ((loop1 & 16)<<3);
  4671.     pallette_entry_green = ((loop1 & 3)<<4) + ((loop1 & 96)<<1);
  4672.     pallette_entry_blue = ((loop1 & 3)<<4) + ((loop1 & 4)<<3) + (loop1 & 128);
  4673.     pallette_entry = (pallette_entry_red<<8)+(pallette_entry_green<<16)+(pallette_entry_blue<<24);
  4674.     registers.r[0] = pallette_entry;
  4675.     os_swi(0x40742, point_registers); /* ColourTrans_ReturnColourNumber */
  4676.     ColourMap[loop1] = registers.r[0];
  4677.   }
  4678.  
  4679.   /* set door positions */
  4680.   /*for (loop1=0; loop1 < 32; loop1++)
  4681.   {
  4682.     for (loop2=0; loop2 < 32; loop2++)
  4683.     {
  4684.       door_map[loop1][loop2] = 64;
  4685.       if (map[loop1][loop2] == door_code)
  4686.       {
  4687.         map[loop1][loop2] = 0;
  4688.       }
  4689.     }
  4690.   }*/
  4691.   /*Secret_Door_Position = 48;
  4692.   Secret_Door_Orientation = 4;
  4693.   door_map[1][6] = Secret_Door_Code;
  4694.   map[1][6] = door_code;*/
  4695.  
  4696.   door_active[0] = 0;
  4697.   door_active[1] = 0;
  4698.  
  4699.   DrawBorder(sprite_data_address,screen_width,screen_height,(int)&Backdrop[0]);
  4700.  
  4701.   wimpt_noerr(wimp_close_wind(biohazard_init_handle));
  4702.  
  4703.   win_claim_idle_events(biohazard_win_handle);
  4704.   win_claim_unknown_events(biohazard_win_handle);
  4705.  
  4706.   Sprite_List[0].sprite_position_x = ((6*64)+32)<<16;
  4707.   Sprite_List[0].sprite_position_y = ((6*64)+32)<<16;
  4708.  
  4709.   /* play Game_On opening sample */
  4710.   registers.r[0] = 0;
  4711.   registers.r[1] = 29;
  4712.   registers.r[2] = Game_On;
  4713.   registers.r[3] = 0;
  4714.   registers.r[4] = 0;
  4715.   registers.r[5] = 0;
  4716.   registers.r[6] = 0;
  4717.   os_swi(284806, point_registers); /* Dsym */
  4718.  
  4719.   /* turn off hourglass mouse pointer */
  4720.   registers.r[0] = (int)Song_Name;
  4721.   registers.r[2] = 0;
  4722.   os_swi(0x000406C1, point_registers); /* hourglass off */
  4723.  
  4724.   /* All went ok */
  4725.   return TRUE;
  4726. }
  4727.  
  4728. /******************************* MAIN PROGRAM ********************************/
  4729.  
  4730. /*--- Main entry point. ---*/
  4731. int main()
  4732. {
  4733.   if (biohazard_initialise())
  4734.   {
  4735.     /* --- mask off the events we're not interested in --- */
  4736.     event_setmask(wimp_EMPTRENTER|wimp_EMPTRLEAVE);
  4737.  
  4738.     /* The main event loop */
  4739.     while (TRUE)
  4740.       event_process();
  4741.   }
  4742.  
  4743.   return 0;
  4744. }
  4745.  
  4746.  
  4747.  
  4748.  
  4749.  
  4750.