home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / tt / tt2sthi / tt2sthi.c < prev    next >
C/C++ Source or Header  |  1991-04-08  |  2KB  |  86 lines

  1. #include<stdlib.h>
  2. #include<stdio.h>
  3. #include<tos.h>
  4. #include<string.h>
  5.  
  6. typedef enum {FALSE, TRUE} boolean;
  7.  
  8. #define ST_LORES 0
  9. #define ST_HIRES 2
  10.  
  11. boolean set_st_hires(void);
  12. boolean get_cookie(char *cookie, long *value);
  13.  
  14. main()
  15.   if (set_st_hires())
  16.       puts("Resolution changed to ST-high.");
  17.   else
  18.       puts("Resolution not changed.");
  19.     return 0;
  20. }
  21.  
  22. boolean set_st_hires(void)
  23. { long _VDO;
  24.    
  25.   /* Change resolution to ST_HIRES */
  26.   /* First check whether we started from ST_LORES */
  27.   /* We may already be in a higer resolution */
  28.  
  29.    
  30.   if (Getrez() > ST_LORES)
  31.       return FALSE;
  32.  
  33.     /* Get the _VDO (video) cookie, if it doesn't exist we have */
  34.     /* some old TOS version, no resolution change */
  35.     
  36.     if (!get_cookie("_VDO", &_VDO) || _VDO < 0x200)
  37.         return FALSE;
  38.         
  39.     /* values for _VDO are: */
  40.     /* 0x000 for normal ST, 0x100 for STe and 0x200 for TT */
  41.     /* return if we do not have TT video hardware */    
  42.        
  43.   /* change the resolution to ST_HIRES */    
  44.     Setscreen((long *) -1,(long *) -1, 2);
  45.     
  46.   /* Set colors to normal monochrome*/
  47.     EsetColor(254, 0);
  48.     EsetColor(255, 4095);
  49.  
  50.     return TRUE;
  51. }
  52.  
  53. /* function get_cookie*/
  54. /* return true if cookie found, cookie value in value */
  55. /* adapted from Rolf Kotzian, St Computer januar 91 */
  56.  
  57. boolean get_cookie(char *cookie, long *value)
  58. {    long old_stack;
  59.     long *cookiejar;
  60.     
  61.     /* get pointer to cookiejar*/
  62.     if ((int) Super((long *) 1L)== -1)         /*already in supervisor mode*/
  63.         cookiejar=*((long **) 0x5a0L);
  64.     else
  65.     {    old_stack=Super(0L);
  66.         cookiejar=*((long **) 0x5a0L);
  67.       Super((void *) old_stack);
  68.     }
  69.         
  70.     if (!cookiejar)          /*No cookie jar*/
  71.         return FALSE;
  72.     
  73.     do
  74.     {    if (!strncmp((char *)cookiejar, cookie, 4))
  75.         {    if (value)
  76.             { *value=cookiejar[1];
  77.                 return TRUE;
  78.             }    
  79.         }
  80.         else
  81.         cookiejar=&cookiejar[2];
  82.     } while (cookiejar[0]);  /*NULL-cookie?*/
  83.     return FALSE;
  84. }     
  85.