libsidplayfp 1.0.3
romCheck.h
00001 /*
00002  * This file is part of libsidplayfp, a SID player engine.
00003  *
00004  * Copyright 2012-2013 Leandro Nini <drfiemost@users.sourceforge.net>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019  */
00020 
00021 #ifndef ROMCHECK_H
00022 #define ROMCHECK_H
00023 
00024 #include <stdint.h>
00025 #include <map>
00026 #include <string>
00027 #include <utility>
00028 
00029 #include "sidplayfp/sidmd5.h"
00030 
00034 class romCheck
00035 {
00036 private:
00037     typedef std::map<std::string, const char*> md5map;
00038 
00039 private:
00044     md5map m_checksums;
00045 
00049     const uint8_t* m_rom;
00050 
00054     unsigned int m_size;
00055 
00056 private:
00057     romCheck();
00058 
00062     std::string checksum() const
00063     {
00064         sidmd5 md5;
00065         md5.append (m_rom, m_size);
00066         md5.finish();
00067 
00068         return md5.getDigest();
00069     }
00070 
00071 protected:
00078     romCheck(const uint8_t* rom, int size) :
00079       m_rom(rom),
00080       m_size(size) {}
00081 
00082     void add(const char* md5, const char* desc)
00083     {
00084         m_checksums.insert(std::make_pair(md5, desc));
00085     }
00086 
00087 public:
00093     const char* info() const
00094     {
00095         md5map::const_iterator res = m_checksums.find(checksum());
00096         return (res!=m_checksums.end())?res->second:"Unknown Rom";
00097     }
00098 };
00099 
00103 class kernalCheck : public romCheck
00104 {
00105 public:
00106     kernalCheck(const uint8_t* kernal) :
00107         romCheck(kernal, 0x2000)
00108     {
00109         add("1ae0ea224f2b291dafa2c20b990bb7d4", "C64 KERNAL first revision");
00110         add("7360b296d64e18b88f6cf52289fd99a1", "C64 KERNAL second revision");
00111         add("479553fd53346ec84054f0b1c6237397", "C64 KERNAL second revision (Japanese)");
00112         add("39065497630802346bce17963f13c092", "C64 KERNAL third revision");
00113         add("27e26dbb267c8ebf1cd47105a6ca71e7", "C64 KERNAL third revision (Swedish)");
00114         add("187b8c713b51931e070872bd390b472a", "Commodore SX-64 KERNAL");
00115         add("b7b1a42e11ff8efab4e49afc4faedeee", "Commodore SX-64 KERNAL (Swedish)");
00116         add("3abc938cac3d622e1a7041c15b928707", "Cockroach Turbo-ROM");
00117         add("631ea2ca0dcda414a90aeefeaf77fe45", "Cockroach Turbo-ROM (SX-64)");
00118         add("a9de1832e9be1a8c60f4f979df585681", "Datel DOS-ROM 1.2");
00119         add("da43563f218b46ece925f221ef1f4bc2", "Datel Mercury 3 (NTSC)");
00120         add("b7dc8ed82170c81773d4f5dc8069a000", "Datel Turbo ROM II (PAL)");
00121         add("6b309c76473dcf555c52c598c6a51011", "Dolphin DOS v1.0");
00122         add("c3c93b9a46f116acbfe7ee147c338c60", "Dolphin DOS v2.0-1 AU");
00123         add("2a441f4abd272d50f94b43c7ff3cc629", "Dolphin DOS v2.0-1");
00124         add("c7a175217e67dcb425feca5fcf2a01cc", "Dolphin DOS v2.0-2");
00125         add("7a9b1040cfbe769525bb9cdc28427be6", "Dolphin DOS v2.0-3");
00126         add("fc8fb5ec89b34ae41c8dc20907447e06", "Dolphin DOS v3.0");
00127         add("9a6e1c4b99c6f65323aa96940c7eb7f7", "ExOS v3 fertig");
00128         add("3241a4fcf2ba28ba3fc79826bc023814", "ExOS v3");
00129         add("cffd2616312801da56bcc6728f0e39ca", "ExOS v4");
00130         add("e6e2bb24a0fa414182b0fd149bde689d", "TurboAccess");
00131         add("c5c5990f0826fcbd372901e761fab1b7", "TurboTrans v3.0-1");
00132         add("042ffc11383849bdf0e600474cefaaaf", "TurboTrans v3.0-2");
00133         add("9d62852013fc2c29c3111c765698664b", "Turbo-Process US");
00134         add("f9c9838e8d6752dc6066a8c9e6c2e880", "Turbo-Process");
00135     }
00136 };
00137 
00141 class basicCheck : public romCheck
00142 {
00143 public:
00144     basicCheck(const uint8_t* basic) :
00145         romCheck(basic, 0x2000)
00146     {
00147         add("57af4ae21d4b705c2991d98ed5c1f7b8", "C64 BASIC V2");
00148     }
00149 };
00150 
00154 class chargenCheck : public romCheck
00155 {
00156 public:
00157     chargenCheck(const uint8_t* chargen) :
00158         romCheck(chargen, 0x1000)
00159     {
00160         add("12a4202f5331d45af846af6c58fba946", "C64 character generator");
00161         add("cf32a93c0a693ed359a4f483ef6db53d", "C64 character generator (Japanese)");
00162     }
00163 };
00164 
00165 #endif // ROMCHECK_H