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

  1. // This module: routines that affect the PC timer
  2. // these are private to these modules
  3.  
  4. // Prototypes required for the following modules:
  5. // joytimer.asm
  6. // joystick.c
  7. // glovdelh.asm
  8. // sgsppt.c
  9. // timer.c
  10.  
  11. /*
  12.  This code is part of the VR-386 project, created by Dave Stampe.
  13.  VR-386 is a desendent of REND386, created by Dave Stampe and
  14.  Bernie Roehl.  Almost all the code has been rewritten by Dave
  15.  Stampre for VR-386.
  16.  
  17.  Copyright (c) 1994 by Dave Stampe:
  18.  May be freely used to write software for release into the public domain
  19.  or for educational use; all commercial endeavours MUST contact Dave Stampe
  20.  (dstampe@psych.toronto.edu) for permission to incorporate any part of
  21.  this software or source code into their products!  Usually there is no
  22.  charge for under 50-100 items for low-cost or shareware products, and terms
  23.  are reasonable.  Any royalties are used for development, so equipment is
  24.  often acceptable payment.
  25.  
  26.  ATTRIBUTION:  If you use any part of this source code or the libraries
  27.  in your projects, you must give attribution to VR-386 and Dave Stampe,
  28.  and any other authors in your documentation, source code, and at startup
  29.  of your program.  Let's keep the freeware ball rolling!
  30.  
  31.  DEVELOPMENT: VR-386 is a effort to develop the process started by
  32.  REND386, improving programmer access by rewriting the code and supplying
  33.  a standard API.  If you write improvements, add new functions rather
  34.  than rewriting current functions.  This will make it possible to
  35.  include you improved code in the next API release.  YOU can help advance
  36.  VR-386.  Comments on the API are welcome.
  37.  
  38.  CONTACT: dstampe@psych.toronto.edu
  39. */
  40.  
  41.  
  42.  
  43. /************ PRIVATE TIMER SUPPORT **********/
  44.  
  45. /* for joytimer.asm */
  46.  
  47. extern timer_tick_count;    // number of interrupts so far
  48. extern timer_vsync_count;     // timer counts per video frame
  49. extern ticks_per_second;     // counter time basis
  50. extern counts_per_tick;     // counter time setting (keep current!)
  51.  
  52. extern int timer_frame_interval;  // number of ticks per frame
  53. extern int frame_resync_interval; // number of frames between resyncs
  54.  
  55.                    // tf is ticks till frame end:
  56.                    // if 0, at end of frame!
  57.                    // called once per tick
  58. extern void (*timer_interrupt_hook)(int tf); // timer tick interrupt
  59. extern void (*frame_interrupt_hook)(int tf); //frame-end interrupt (arg=0)
  60.  
  61. unsigned find_vsync_count();     // returns frame time in 1.19 MHz counts
  62. int write_timer(unsigned count); // sets timer count
  63.  
  64. void __interrupt __far kbrd_isr();  // hooks kbrd interrupt
  65. void __interrupt __far timer_isr();  // does timer interrupt stuff
  66.  
  67.  
  68. /************ JOYSTICK LOW_LEVEL I/O *************/
  69.  
  70. extern int joystick_j1;       /* raw joystick results */
  71. extern int joystick_j2;       /* updates after raw_joystick_read() */
  72. extern int joystick_j3;
  73. extern int joystick_j4;
  74. extern int joystick_buttons;
  75.                  // range of 0 to 1200 on read
  76.                  // buttons has 4 bits
  77.                  // mask is 3 for joy1, 12 for joy2
  78.                  // and 15 for both
  79.  
  80. int raw_joystick_read(int mask); /* reads joystick to above variables */
  81.                  /* returns 0 if read successful      */
  82.                  /* else try repeating it later       */
  83.  
  84. /*********** TIMER ROUTINES ************/
  85.  
  86. unsigned read_timer();    // reads current timer count: scale varies
  87.  
  88. long current_time();       // returns time in msec
  89.  
  90. /************ KEYBOARD MONITOR ROUTINES *********/
  91.  
  92. extern int init_key_monitor();    // enables key monitor
  93.     // useful to turn it off, cause debuggers hate it!
  94.     // returns 0 if already on, else 1
  95.  
  96. extern int is_key_down(int keycode);    // tests if key(keycode) is down
  97.                 // some useful keycodes:
  98.  
  99. #define UP_CURSOR_KEYCODE    0x48
  100. #define DOWN_CURSOR_KEYCODE    0x50
  101. #define LEFT_CURSOR_KEYCODE    0x4B
  102. #define RIGHT_CURSOR_KEYCODE    0x4D
  103.  
  104. #define LEFT_SHIFT_KEYCODE    0x2A
  105. #define RIGHT_SHIFT_KEYCODE    0x36
  106.  
  107.  
  108. /************* POWERGLOVE AND SEGA *********/
  109. // mainly for pwrglvio.asm
  110.  
  111. extern int port_image;
  112. extern int sega_port_image;
  113.  
  114. extern unsigned int timed_glove_delay(int count);
  115.     /* returns time in 1.1925 MHZ ticks */
  116.     /* to perform <count> delay steps   */
  117.     /* call with timer at 18.2 Hz rate  */
  118.  
  119. extern int glove_delay(int count);  /* performs <count> delay steps   */
  120.  
  121. extern int get_glove_byte(void);  /* reads a byte from glove */
  122.  
  123. extern void set_glove_bits(int data);  /* sets glove clock, data lines */
  124.                        /* and does a bit delay         */
  125.  
  126. extern void glove_int_handler();    // powerglove isr routine
  127.  
  128.  
  129. // more stuff for Sega
  130.  
  131. extern int left_page;      /* left image */
  132. extern int right_page;     /* right image */
  133. extern volatile int has_switched;   /* = 3 once both switched in */
  134.  
  135. extern int sega_left;    // LCD driver config fdata
  136. extern int sega_right;
  137. extern int sega_address;
  138. extern int sega_mask;
  139. extern int sega_doff;
  140.  
  141.  
  142. extern void select_sega_port(int port);  /* sets up default Sega data */
  143.  
  144. extern void switch_sega(int to_go);   // LCD ISR routine
  145.  
  146. extern void sega_off();     // disable LCD to prolong life
  147.  
  148.  
  149. #define SW_INIT        0    // commands to switch ptr driver
  150. #define SW_QUIT        1
  151. #define SW_ADV_SWITCH  2
  152. #define SW_SYNC_SWITCH 3
  153.  
  154.  
  155. extern int (*switch_driver)();   // if NULL, use internal driver
  156.  
  157.  
  158.  
  159.  
  160.