1 /*************************************************************************** 2 IniConfig.h - Sidplay2 config file reader. 3 ------------------- 4 begin : Sun Mar 25 2001 5 copyright : (C) 2000 by Simon White 6 email : s_a_white@email.com 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 /*************************************************************************** 18 * $Log: IniConfig.h,v $ 19 * Revision 1.5 2001/07/03 17:49:27 s_a_white 20 * External filter no longer supported. This filter is needed internally by the 21 * library. 22 * 23 * Revision 1.4 2001/04/09 17:11:03 s_a_white 24 * Added INI file version number so theres a possibility for automated updates 25 * should the keys/sections change names (or meaning). 26 * 27 * Revision 1.3 2001/03/27 19:00:49 s_a_white 28 * Default record and play lengths can now be set in the sidplay2.ini file. 29 * 30 * Revision 1.2 2001/03/26 18:13:07 s_a_white 31 * Support individual filters for 6581 and 8580. 32 * 33 ***************************************************************************/ 34 35 #ifndef _IniConfig_h_ 36 #define _IniConfig_h_ 37 38 #include <sidplay/sidtypes.h> 39 #include <sidplay/utils/libini.h> 40 #include <sidplay/utils/SidFilter.h> 41 42 43 class IniConfig 44 { 45 public: 46 struct sidplay2_section 47 { 48 int version; 49 char *database; 50 uint_least32_t playLength; 51 uint_least32_t recordLength; 52 }; 53 54 struct console_section 55 { // INI Section - [Console] 56 bool ansi; 57 char topLeft; 58 char topRight; 59 char bottomLeft; 60 char bottomRight; 61 char vertical; 62 char horizontal; 63 char junctionLeft; 64 char junctionRight; 65 }; 66 67 struct audio_section 68 { // INI Section - [Audio] 69 long frequency; 70 sid2_playback_t playback; 71 int precision; 72 }; 73 74 struct emulation_section 75 { // INI Section - [Emulation] 76 sid2_clock_t clockSpeed; 77 bool clockForced; 78 sid2_model_t sidModel; 79 bool filter; 80 char *filter6581; 81 char *filter8580; 82 uint_least8_t optimiseLevel; 83 bool sidSamples; 84 }; 85 86 protected: 87 static const char *DIR_NAME; 88 static const char *FILE_NAME; 89 90 bool status; 91 struct sidplay2_section sidplay2_s; 92 struct console_section console_s; 93 struct audio_section audio_s; 94 struct emulation_section emulation_s; 95 SidFilter filter6581; 96 SidFilter filter8580; 97 98 protected: 99 void clear (); 100 101 bool readInt (ini_fd_t ini, char *key, int &value); 102 bool readString (ini_fd_t ini, char *key, char *&str); 103 bool readBool (ini_fd_t ini, char *key, bool &boolean); 104 bool readChar (ini_fd_t ini, char *key, char &ch); 105 bool readTime (ini_fd_t ini, char *key, int &time); 106 107 bool readSidplay2 (ini_fd_t ini); 108 bool readConsole (ini_fd_t ini); 109 bool readAudio (ini_fd_t ini); 110 bool readEmulation (ini_fd_t ini); 111 112 public: 113 IniConfig (); 114 ~IniConfig (); 115 116 void read (); 117 operator bool () { return status; } 118 119 // Sidplay2 Specific Section sidplay2()120 const sidplay2_section& sidplay2 () { return sidplay2_s; } console()121 const console_section& console () { return console_s; } audio()122 const audio_section& audio () { return audio_s; } emulation()123 const emulation_section& emulation () { return emulation_s; } 124 const sid_filter_t* filter (sid2_model_t model); 125 }; 126 127 #endif // _IniConfig_h_ 128