home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Homebrewer's Handbook / vr.iso / vr386 / swdrv.c < prev    next >
C/C++ Source or Header  |  1996-03-19  |  3KB  |  86 lines

  1. // Written by Dave Stampe, 23/12/93
  2. // code for video/LCD switch driver interface and setup
  3.  
  4. // this code supports loadable or internal switching drivers,
  5. // for Sega glasses, VCRs, etc etc.
  6.  
  7. // This module relies on SGSPPT.C and other parts of the PCDEVICE library.
  8.  
  9. /*
  10.  This code is part of the VR-386 project, created by Dave Stampe.
  11.  VR-386 is a desendent of REND386, created by Dave Stampe and
  12.  Bernie Roehl.  Almost all the code has been rewritten by Dave
  13.  Stampre for VR-386.
  14.  
  15.  Copyright (c) 1994 by Dave Stampe:
  16.  May be freely used to write software for release into the public domain
  17.  or for educational use; all commercial endeavours MUST contact Dave Stampe
  18.  (dstampe@psych.toronto.edu) for permission to incorporate any part of
  19.  this software or source code into their products!  Usually there is no
  20.  charge for under 50-100 items for low-cost or shareware products, and terms
  21.  are reasonable.  Any royalties are used for development, so equipment is
  22.  often acceptable payment.
  23.  
  24.  ATTRIBUTION:  If you use any part of this source code or the libraries
  25.  in your projects, you must give attribution to VR-386 and Dave Stampe,
  26.  and any other authors in your documentation, source code, and at startup
  27.  of your program.  Let's keep the freeware ball rolling!
  28.  
  29.  DEVELOPMENT: VR-386 is a effort to develop the process started by
  30.  REND386, improving programmer access by rewriting the code and supplying
  31.  a standard API.  If you write improvements, add new functions rather
  32.  than rewriting current functions.  This will make it possible to
  33.  include you improved code in the next API release.  YOU can help advance
  34.  VR-386.  Comments on the API are welcome.
  35.  
  36.  CONTACT: dstampe@psych.toronto.edu
  37. */
  38.  
  39.  
  40. #include <stdlib.h>
  41. #include <stdio.h>
  42. #include <dos.h>
  43.  
  44. #include "vr_api.h"
  45. #include "pcdevice.h"
  46.  
  47.  
  48. /****************** SWITCHER DRIVER INTERFACE *************/
  49.  
  50.  
  51. #define SW_INIT        0
  52. #define SW_QUIT        1
  53. #define SW_ADV_SWITCH  2
  54. #define SW_SYNC_SWITCH 3
  55.  
  56. int (*switch_driver)() = NULL;   // if NULL, use internal driver
  57.  
  58. static void sdriver_quit()
  59. {
  60.   if (switch_driver) switch_driver(SW_QUIT);
  61. }
  62.  
  63. void init_switch_driver(char *sdname)   // setup whatever switch driver used
  64. {
  65.   if (!stricmp(sdname, "sega"))
  66.     {
  67.       init_frame_lock(6000, switch_sega);
  68.       atexit(sega_off);
  69.       return;
  70.     }
  71.  
  72.   switch_driver = load_driver(sdname);
  73.  
  74.   if (switch_driver == NULL)
  75.     {
  76.       fprintf(stderr,"Cannot read switcher driver %s\n", sdname);
  77.       exit(0);
  78.     }
  79.  
  80.   init_frame_lock(0, switch_LCD_driver);
  81.   switch_driver = MK_FP(FP_SEG(switch_driver), 16+FP_OFF(switch_driver)); /* entry point */
  82.   switch_driver(SW_INIT);
  83.   atexit(sdriver_quit);
  84. }
  85.  
  86.