home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / rflic2 / pcclone.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-27  |  3.9 KB  |  150 lines

  1. /* pcclone.h - machine specific parts of readflic.  Structures and
  2.  * prototypes for polling the keyboard,  checking the time, 
  3.  * writing to the video screen, allocating large blocks of memory
  4.  * and reading files.
  5.  *
  6.  * Copyright (c) 1992 Jim Kent.  This file may be freely used, modified,
  7.  * copied and distributed.  This file was first published as part of
  8.  * an article for Dr. Dobb's Journal March 1993 issue.
  9.  */
  10.  
  11. #ifndef PCCLONE_H    /* Prevent file from being included twice. */
  12. #define PCCLONE_H
  13.  
  14. typedef Uchar Pixel;            /* Pixel type. */
  15.  
  16. typedef struct
  17.     {
  18.     Uchar r,g,b;
  19.     } Color;                    /* One color map entry r,g,b 0-255. */
  20.  
  21. typedef struct
  22.     {
  23.     Pixel pixels[2];
  24.     } Pixels2;                    /* For word-oriented run length encoding */
  25.  
  26. typedef struct
  27.     {
  28.     Pixel far *pixels;    /* Set to AOOO:0000 for hardware. */
  29.     int width, height;    /* Dimensions of screen. (320x200) */
  30.     Uchar old_mode;        /* Mode screen was in originally. */
  31.     Boolean is_open;    /* Is screen open? */
  32.     } Screen;                    /* Device specific screen type. */
  33.  
  34.  
  35.     /* Prototypes for routines that work on display screen. */
  36.  
  37. ErrCode screen_open(Screen *s);
  38.     /* Put machine into graphics mode and fill out screen structure. */
  39.  
  40. void screen_close(Screen *s);
  41.     /* Close screen.  Restore original display mode. */
  42.  
  43. int screen_width(Screen *s);
  44.     /* Return width of screen. */
  45.  
  46. int screen_height(Screen *s);
  47.     /* Return height of screen. */
  48.  
  49. void screen_put_dot(Screen *s, int x, int y, Pixel color);
  50.     /* Set one dot. */
  51.  
  52. void screen_copy_seg(Screen *s, int x, int y, Pixel far *pixels, int count);
  53.     /* Copy pixels from memory into screen. */
  54.  
  55. void screen_repeat_one(Screen *s, int x, int y, Pixel color, int count);
  56.     /* Draw a horizontal line of a solid color */
  57.  
  58. void screen_repeat_two(Screen *s, int x,int y, Pixels2 pixels2, int count);
  59.     /* Repeat 2 pixels count times on screen. */
  60.  
  61. void screen_put_colors(Screen *s, int start, Color far *colors, int count);
  62.     /* Set count colors in color map starting at start.  RGB values
  63.      * go from 0 to 255. */
  64.  
  65. void screen_put_colors_64(Screen *s, int start, Color far *colors, int count);
  66.     /* Set count colors in color map starting at start.  RGB values
  67.      * go from 0 to 64. */
  68.  
  69.  
  70. /* Clock structure and routines. */
  71.  
  72. typedef struct
  73.     {
  74.     Ulong speed;    /* Number of clock ticks per second. */
  75.     } Clock;
  76.  
  77. ErrCode clock_open(Clock *clock);
  78.     /* Set up millisecond clock. */
  79.  
  80. void clock_close(Clock *clock);
  81.     /* Return clock to normal. */
  82.  
  83. Ulong clock_ticks(Clock *clock);
  84.     /* Get time in terms of clock->speed. */
  85.  
  86. /* Keyboard structure and routines. */
  87.  
  88. typedef struct
  89.     {
  90.     Uchar ascii;
  91.     Ushort scancode;
  92.     } Key;
  93.  
  94. ErrCode key_open(Key *key);
  95.     /* Set up keyboard. */
  96.  
  97. void key_close(Key *key);
  98.     /* Close keyboard. */
  99.  
  100. Boolean key_ready(Key *key);
  101.     /* See if a key is ready. */
  102.  
  103. Uchar key_read(Key *key);
  104.     /* Get next key. */
  105.  
  106.  
  107. /** BigBlock - handles allocating big blocks of memory (>64K) on the
  108.  ** PC.  On other machines may be much simpler. */
  109.  
  110. typedef struct
  111.     {
  112.     void huge *hpt;
  113.     void far *fpt;
  114.     } BigBlock;
  115.  
  116. ErrCode big_alloc(BigBlock *bb, Ulong size);
  117.     /* Allocate a big block. */
  118.  
  119. void big_free(BigBlock *bb);
  120.     /* Free up a big block. */
  121.  
  122. /** Stuff for reading files - regular and over 64k blocks at a time. **/
  123.  
  124. ErrCode file_open_to_read(FileHandle *phandle, char *name);
  125.     /* Open a binary file to read. */
  126.  
  127. ErrCode file_read_block(FileHandle handle, void far *block, unsigned size);
  128.     /* Read in a block.  If read less than size return error code. */
  129.  
  130. ErrCode file_read_big_block(FileHandle handle, BigBlock *bb, Ulong size);
  131.     /* Read in a big block.  Could be bigger than 64K. */
  132.  
  133.  
  134.  
  135. /** Machine structure - contains all the machine dependent stuff. **/
  136.  
  137. typedef struct
  138.     {
  139.     Screen screen;
  140.     Clock clock;
  141.     Key key;
  142.     } Machine;
  143.  
  144. ErrCode machine_open(Machine *machine);
  145.     /* Open up machine: keyboard, clock, screen. */
  146.  
  147. void machine_close(Machine *machine);
  148.     /* Close down machine. */
  149. #endif /* PCCLONE_H */
  150.