DOSBox-X
|
00001 /* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher 00002 * Copyright (C) 2011, 2012, 2013 Dean Beeler, Jerome Fisher, Sergey V. Mikayev 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU Lesser General Public License as published by 00006 * the Free Software Foundation, either version 2.1 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef MT32EMU_ROMINFO_H 00019 #define MT32EMU_ROMINFO_H 00020 00021 #include <cstddef> 00022 #include "File.h" 00023 00024 namespace MT32Emu { 00025 00026 // Defines vital info about ROM file to be used by synth and applications 00027 00028 struct ROMInfo { 00029 public: 00030 size_t fileSize; 00031 const char *sha1Digest; 00032 enum Type {PCM, Control, Reverb} type; 00033 const char *shortName; 00034 const char *description; 00035 enum PairType {Full, FirstHalf, SecondHalf, Mux0, Mux1} pairType; 00036 ROMInfo *pairROMInfo; 00037 void *controlROMInfo; 00038 00039 // Returns a ROMInfo struct by inspecting the size and the SHA1 hash 00040 static const ROMInfo* getROMInfo(File *file); 00041 00042 // Currently no-op 00043 static void freeROMInfo(const ROMInfo *romInfo); 00044 00045 // Allows retrieving a NULL-terminated list of ROMInfos for a range of types and pairTypes 00046 // (specified by bitmasks) 00047 // Useful for GUI/console app to output information on what ROMs it supports 00048 static const ROMInfo** getROMInfoList(unsigned int types, unsigned int pairTypes); 00049 00050 // Frees the list of ROMInfos given 00051 static void freeROMInfoList(const ROMInfo **romInfos); 00052 }; 00053 00054 // Synth::open() is to require a full control ROMImage and a full PCM ROMImage to work 00055 00056 class ROMImage { 00057 private: 00058 File *file; 00059 const ROMInfo *romInfo; 00060 00061 public: 00062 00063 // Creates a ROMImage object given a ROMInfo and a File. Keeps a reference 00064 // to the File and ROMInfo given, which must be freed separately by the user 00065 // after the ROMImage is freed 00066 static const ROMImage* makeROMImage(File *file); 00067 00068 // Must only be done after all Synths using the ROMImage are deleted 00069 static void freeROMImage(const ROMImage *romImage); 00070 00071 File *getFile() const; 00072 const ROMInfo *getROMInfo() const; 00073 }; 00074 00075 } 00076 00077 #endif