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

  1. #include "ray.h"
  2. #include "globals.h"
  3. #ifdef OS_DOS
  4. #include "asm.h"
  5. #include "gamerun.h"
  6. #include "scrcntl.h"
  7. #include "palette.h"
  8. #include <conio.h>
  9. #include <i86.h>
  10. #include <dos.h>
  11.  
  12. #define VGA_WIDTH 320
  13. #define VGA_HEIGHT 200
  14. #define SVGA_WIDTH 640
  15. #define SVGA_HEIGHT 480
  16.  
  17. union REGS tempregs; // required for int386 calls. Have no other use
  18.  
  19. void SetCursorXY(unsigned char column, unsigned char row)
  20. {
  21.    tempregs.h.ah=2;
  22.    tempregs.h.bl=0;
  23.    tempregs.h.dl=column;
  24.    tempregs.h.dh=row;
  25.    int386(0x10, &tempregs, &tempregs);
  26. }
  27.  
  28. // VGA status stuff
  29.  
  30. #define VGA_INPUT_STATUS_1   0x3DA // vga status reg 1, bit 3 is the vsync
  31.                                    // when 1 - retrace in progress
  32.                                    // when 0 - no retrace
  33.  
  34. #define VGA_VSYNC_MASK       0x08  // masks off unwanted bits of status reg
  35.  
  36. void Wait_For_Vsync(void)
  37. {
  38. // this function waits for the start of a vertical retrace, if a vertical
  39. // retrace is in progress then it waits until the next one
  40.  
  41. while(!inp(VGA_INPUT_STATUS_1) & VGA_VSYNC_MASK)
  42.      {
  43.      // do nothing, vga is in retrace
  44.      } // end while
  45.  
  46. // now wait for vysnc and exit
  47.  
  48. while((inp(VGA_INPUT_STATUS_1) & VGA_VSYNC_MASK))
  49.      {
  50.      // do nothing, wait for start of retrace
  51.      } // end while
  52.  
  53. // at this point a vertical retrace is occuring, so return back to caller
  54.  
  55. } // Wait_For_Vsync
  56.  
  57. void Dos_Copy_Buff() {
  58.    Wait_For_Vsync();
  59.    copyBuff();
  60. }
  61.  
  62. void Dos_Init() {
  63.    Init_Screen(VGA_WIDTH, VGA_HEIGHT);
  64.    Global_Initialize();
  65.    Activate_Graphics();
  66.    Activate_Palette(TRUE);
  67. }
  68.  
  69. void Dos_Run() {
  70. Init_Main_Cycle();
  71. while (!Main_Cycle_Done())
  72.    Do_Main_Cycle();
  73. }
  74.  
  75. void Dos_Close() {
  76.    Global_Close();
  77. }
  78.  
  79. void main() {
  80.    Dos_Init();
  81.    Dos_Run();
  82.    Dos_Close();
  83. }
  84.  
  85. #endif
  86.