home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / pmod01 / source / biosptr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-10  |  2.2 KB  |  86 lines

  1. /****************************************************************************
  2. *
  3. *                          Protected Mode Library
  4. *
  5. *                   Copyright (C) 1994 SciTech Software.
  6. *                            All rights reserved.
  7. *
  8. * Filename:        $RCSfile: biosptr.c $
  9. * Version:        $Revision: 1.1 $
  10. *
  11. * Language:        ANSI C
  12. * Environment:    any
  13. *
  14. * Description:  Test program to check the ability to manipulate the
  15. *                BIOS data area from protected mode using the PMODE
  16. *                library. Compile and link with the appropriate command
  17. *                line for your DOS extender.
  18. *
  19. *                Functions tested:    PMODE_getBIOSPointer()
  20. *                                    PMODE_getLong()
  21. *                                    PMODE_getByte()
  22. *                                    PMODE_getWord()
  23. *
  24. * $Id: biosptr.c 1.1 1994/03/10 09:05:43 kjb release $
  25. *
  26. ****************************************************************************/
  27.  
  28. #include <stdlib.h>
  29. #include <stdio.h>
  30. #include <conio.h>
  31. #include "pmode.h"
  32.  
  33. /* Macros to obtain values from the BIOS data area */
  34.  
  35. #define TICKS()        PMODE_getLong(bios, 0x6C)
  36. #define KB_STAT        PMODE_getByte(bios, 0x17)
  37. #define KB_HEAD        PMODE_getWord(bios, 0x1A)
  38. #define KB_TAIL        PMODE_getWord(bios, 0x1C)
  39.  
  40. /* Macros for working with the keyboard buffer */
  41.  
  42. #define KB_HIT()    (KB_HEAD != KB_TAIL)
  43. #define CTRL()        (KB_STAT & 4)
  44. #define SHIFT()        (KB_STAT & 2)
  45. #define ESC            0x1B
  46.  
  47. /* Pointer to BIOS data area */
  48.  
  49. void *bios = NULL;
  50.  
  51. void main(void)
  52. {
  53.     int    c,done = 0;
  54.  
  55.     printf("Program running in ");
  56.     switch (_PMODE_modeType) {
  57.         case PMODE_realMode:
  58.             printf("real mode.\n\n");
  59.             break;
  60.         case PMODE_286:
  61.             printf("16 bit protected mode.\n\n");
  62.             break;
  63.         case PMODE_386:
  64.             printf("32 bit protected mode.\n\n");
  65.             break;
  66.         }
  67.  
  68.     if ((bios = PMODE_getBIOSPointer()) == NULL) {
  69.         printf("Could not obtain pointer to BIOS data area!!\n");
  70.         exit(1);
  71.         }
  72.  
  73.     printf("Hit any key to test, Ctrl-Shift-Esc to quit\n");
  74.     while (!done) {
  75.         if (KB_HIT()) {
  76.             c = getch();
  77.             printf("TIME=%-8lX ST=%02X CHAR=%02X ", TICKS(), KB_STAT, c);
  78.             if (c == 0)
  79.                 printf("%02X", getch());        /* Extended character */
  80.             printf("\n");
  81.             if ((c == ESC) && SHIFT() && CTRL())/* Ctrl-Shift-Esc */
  82.                 break;
  83.             }
  84.         }
  85. }
  86.