home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 565b.lha / TheGuru_v2.0 / GuruSettingsIO.c < prev    next >
C/C++ Source or Header  |  1990-09-16  |  1KB  |  42 lines

  1.  
  2. #include "TheGuru.h"
  3.  
  4. /* Record to hold all settings so we can load/save easier. */
  5. struct Settings {
  6.     short time, sex, vol, rate, pitch, mode;
  7.     };
  8.  
  9. #define sSize        sizeof (struct Settings)
  10.  
  11. /* Variable to indicate if we have already read from current directory. */
  12. static int readfromcd;
  13.  
  14. /*
  15.     Read guru settings from the settings file.
  16.     output - time, sex, vol, rate, pitch and mode hold the settings, but only if
  17.                 the loading succeeded. So init them with the default values before
  18.                 you call this procedure in case the file is not found.
  19. */
  20. void ReadGuruSettings (int *time, int *sex, int *vol, int *rate,
  21.                                                                             int *pitch, int *mode)
  22. {
  23.     struct Settings s;
  24.     BPTR file;
  25.  
  26.     /* Try to open the settings config file (in the current directory first). */
  27.     readfromcd = TRUE;
  28.     file = Open (GURU_SETTINGSFILE_CD, MODE_OLDFILE);
  29.     if (!file) {
  30.         readfromcd = FALSE;
  31.         file = Open (GURU_SETTINGSFILE, MODE_OLDFILE);
  32.         if (!file) return;
  33.         }
  34.     /* Read the settings. */
  35.     if (Read (file, &s, sSize) == sSize) {
  36.         /* If success assign settings to variables. */
  37.         *time = s.time; *sex = s.sex; *vol = s.vol; *rate = s.rate;
  38.         *pitch = s.pitch; *mode = s.mode;
  39.         }
  40.     Close (file);
  41. }
  42.