| 1 | /* dvdisaster: Additional error correction for optical media. |
| 2 | * Copyright (C) 2004-2007 Carsten Gnoerlich. |
| 3 | * Project home page: http://www.dvdisaster.com |
| 4 | * Email: [email protected] -or- [email protected] |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, |
| 19 | * or direct your browser at http://www.gnu.org. |
| 20 | */ |
| 21 | |
| 22 | #ifndef DVDISASTER_H |
| 23 | #define DVDISASTER_Hcxx . . $ `mednafen/cdrom/dvdisaster.h:23:9`! |
| 24 | |
| 25 | /* "Dare to be gorgeous and unique. |
| 26 | * But don't ever be cryptic or otherwise unfathomable. |
| 27 | * Make it unforgettably great." |
| 28 | * |
| 29 | * From "A Final Note on Style", |
| 30 | * Amiga Intuition Reference Manual, 1986, p. 231 |
| 31 | */ |
| 32 | |
| 33 | /*** |
| 34 | *** I'm too lazy to mess with #include dependencies. |
| 35 | *** Everything #includeable is rolled up herein... |
| 36 | */ |
| 37 | |
| 38 | #include "../mednafen-types.h"cxx . . $ `<file>/mednafen/mednafen-types.h`/ |
| 39 | |
| 40 | #include <ctype.h> |
| 41 | #include <errno.h> |
| 42 | #include <fcntl.h> |
| 43 | #include <math.h> |
| 44 | #include <sys/types.h> |
| 45 | #include <stdarg.h> |
| 46 | #include <stddef.h> |
| 47 | #include <stdio.h> |
| 48 | #include <stdlib.h> |
| 49 | #include <string.h> |
| 50 | #ifdef _WIN32 |
| 51 | #include <direct.h> |
| 52 | #else |
| 53 | #include <unistd.h> |
| 54 | #endif |
| 55 | |
| 56 | /*** |
| 57 | *** dvdisaster.c |
| 58 | ***/ |
| 59 | |
| 60 | void PrepareDeadSectorcxx . . $ PrepareDeadSector(49f6e7a06ebc5aa8).(void); |
| 61 | |
| 62 | void CreateEcccxx . . $ CreateEcc(49f6e7a06ebc5aa8).(void); |
| 63 | void FixEcccxx . . $ FixEcc(49f6e7a06ebc5aa8).(void); |
| 64 | void Verifycxx . . $ Verify(49f6e7a06ebc5aa8).(void); |
| 65 | |
| 66 | uint32cxx . . $ uint32# EDCCrc32cxx . . $ EDCCrc32(f38ae389a4b85ca).(const unsigned char*, int); |
| 67 | |
| 68 | /*** |
| 69 | *** galois.c |
| 70 | *** |
| 71 | * This is currently the hardcoded GF(2**8). |
| 72 | * int32 gives abundant space for the GF. |
| 73 | * Squeezing it down to uint8 won't probably gain much, |
| 74 | * so we implement this defensively here. |
| 75 | * |
| 76 | * Note that some performance critical stuff needs to |
| 77 | * be #included from galois-inlines.h |
| 78 | */ |
| 79 | |
| 80 | /* Galois field parameters for 8bit symbol Reed-Solomon code */ |
| 81 | |
| 82 | #define GF_SYMBOLSIZEcxx . . $ `mednafen/cdrom/dvdisaster.h:82:9`! 8 |
| 83 | #define GF_FIELDSIZEcxx . . $ `mednafen/cdrom/dvdisaster.h:83:9`! (1<<GF_SYMBOLSIZE) |
| 84 | #define GF_FIELDMAXcxx . . $ `mednafen/cdrom/dvdisaster.h:84:9`! (GF_FIELDSIZE-1) |
| 85 | #define GF_ALPHA0cxx . . $ `mednafen/cdrom/dvdisaster.h:85:9`! GF_FIELDMAX |
| 86 | |
| 87 | /* Lookup tables for Galois field arithmetic */ |
| 88 | |
| 89 | typedef struct _GaloisTablescxx . . $ _GaloisTables# |
| 90 | { int32cxx . . $ int32# gfGeneratorcxx . . $ _GaloisTables#gfGenerator.; /* GF generator polynomial */ |
| 91 | int32cxx . . $ int32# *indexOfcxx . . $ _GaloisTables#indexOf.; /* log */ |
| 92 | int32cxx . . $ int32# *alphaTocxx . . $ _GaloisTables#alphaTo.; /* inverse log */ |
| 93 | int32cxx . . $ int32# *encAlphaTocxx . . $ _GaloisTables#encAlphaTo.; /* inverse log optimized for encoder */ |
| 94 | } GaloisTablescxx . . $ GaloisTables#; |
| 95 | |
| 96 | /* Lookup and working tables for the ReedSolomon codecs */ |
| 97 | |
| 98 | typedef struct _ReedSolomonTablescxx . . $ _ReedSolomonTables# |
| 99 | { GaloisTablescxx . . $ GaloisTables# *gfTablescxx . . $ _ReedSolomonTables#gfTables.;/* from above */ |
| 100 | int32cxx . . $ int32# *gpolycxx . . $ _ReedSolomonTables#gpoly.; /* RS code generator polynomial */ |
| 101 | int32cxx . . $ int32# fcrcxx . . $ _ReedSolomonTables#fcr.; /* first consecutive root of RS generator polynomial */ |
| 102 | int32cxx . . $ int32# primElemcxx . . $ _ReedSolomonTables#primElem.; /* primitive field element */ |
| 103 | int32cxx . . $ int32# nrootscxx . . $ _ReedSolomonTables#nroots.; /* degree of RS generator polynomial */ |
| 104 | int32cxx . . $ int32# ndatacxx . . $ _ReedSolomonTables#ndata.; /* data bytes per ecc block */ |
| 105 | } ReedSolomonTablescxx . . $ ReedSolomonTables#; |
| 106 | |
| 107 | GaloisTablescxx . . $ GaloisTables#* CreateGaloisTablescxx . . $ CreateGaloisTables(d23602e4c396cb3b).(int32cxx . . $ int32#); |
| 108 | void FreeGaloisTablescxx . . $ FreeGaloisTables(96bf5e7dfcec2c6b).(GaloisTablescxx . . $ GaloisTables#*); |
| 109 | |
| 110 | ReedSolomonTablescxx . . $ ReedSolomonTables# *CreateReedSolomonTablescxx . . $ CreateReedSolomonTables(3ca6ffdd841c0c54).(GaloisTablescxx . . $ GaloisTables#*, int32cxx . . $ int32#, int32cxx . . $ int32#, int); |
| 111 | void FreeReedSolomonTablescxx . . $ FreeReedSolomonTables(3061629492dcb198).(ReedSolomonTablescxx . . $ ReedSolomonTables#*); |
| 112 | |
| 113 | /*** |
| 114 | *** l-ec.c |
| 115 | ***/ |
| 116 | |
| 117 | #define N_P_VECTORScxx . . $ `mednafen/cdrom/dvdisaster.h:117:9`! 86 /* 43 16bit p vectors */ |
| 118 | #define P_VECTOR_SIZEcxx . . $ `mednafen/cdrom/dvdisaster.h:118:9`! 26 /* using RS(26,24) ECC */ |
| 119 | |
| 120 | #define N_Q_VECTORScxx . . $ `mednafen/cdrom/dvdisaster.h:120:9`! 52 /* 26 16bit q vectors */ |
| 121 | #define Q_VECTOR_SIZEcxx . . $ `mednafen/cdrom/dvdisaster.h:121:9`! 45 /* using RS(45,43) ECC */ |
| 122 | |
| 123 | #define P_PADDINGcxx . . $ `mednafen/cdrom/dvdisaster.h:123:9`! 229 /* padding values for */ |
| 124 | #define Q_PADDINGcxx . . $ `mednafen/cdrom/dvdisaster.h:124:9`! 210 /* shortened RS code */ |
| 125 | |
| 126 | int PToByteIndexcxx . . $ PToByteIndex(9b79fb6aee4c0440).(int, int); |
| 127 | int QToByteIndexcxx . . $ QToByteIndex(9b79fb6aee4c0440).(int, int); |
| 128 | void ByteIndexToPcxx . . $ ByteIndexToP(5768b2fa0fe719ec).(int, int*, int*); |
| 129 | void ByteIndexToQcxx . . $ ByteIndexToQ(5768b2fa0fe719ec).(int, int*, int*); |
| 130 | |
| 131 | void GetPVectorcxx . . $ GetPVector(233e998648c71b4e).(unsigned char*, unsigned char*, int); |
| 132 | void SetPVectorcxx . . $ SetPVector(233e998648c71b4e).(unsigned char*, unsigned char*, int); |
| 133 | void FillPVectorcxx . . $ FillPVector(ec9eb39fc993c7e5).(unsigned char*, unsigned char, int); |
| 134 | void AndPVectorcxx . . $ AndPVector(ec9eb39fc993c7e5).(unsigned char*, unsigned char, int); |
| 135 | void OrPVectorcxx . . $ OrPVector(ec9eb39fc993c7e5).(unsigned char*, unsigned char, int); |
| 136 | |
| 137 | void GetQVectorcxx . . $ GetQVector(233e998648c71b4e).(unsigned char*, unsigned char*, int); |
| 138 | void SetQVectorcxx . . $ SetQVector(233e998648c71b4e).(unsigned char*, unsigned char*, int); |
| 139 | void FillQVectorcxx . . $ FillQVector(ec9eb39fc993c7e5).(unsigned char*, unsigned char, int); |
| 140 | void AndQVectorcxx . . $ AndQVector(ec9eb39fc993c7e5).(unsigned char*, unsigned char, int); |
| 141 | void OrQVectorcxx . . $ OrQVector(ec9eb39fc993c7e5).(unsigned char*, unsigned char, int); |
| 142 | |
| 143 | int DecodePQcxx . . $ DecodePQ(2977444feebd832d).(ReedSolomonTablescxx . . $ ReedSolomonTables#*, unsigned char*, int, int*, int); |
| 144 | |
| 145 | int CountC2Errorscxx . . $ CountC2Errors(b2e27cdb9bef2230).(unsigned char*); |
| 146 | |
| 147 | /*** |
| 148 | *** misc.c |
| 149 | ***/ |
| 150 | |
| 151 | char* sgettextcxx . . $ sgettext(7a9722d75b371431).(char*); |
| 152 | char* sgettext_utf8cxx . . $ sgettext_utf8(7a9722d75b371431).(char*); |
| 153 | |
| 154 | int64cxx . . $ int64# uchar_to_int64cxx . . $ uchar_to_int64(bd0145a4d051b1bb).(unsigned char*); |
| 155 | void int64_to_ucharcxx . . $ int64_to_uchar(112694c12570de7f).(unsigned char*, int64cxx . . $ int64#); |
| 156 | |
| 157 | void CalcSectorscxx . . $ CalcSectors(5f0ed43c7cfacc69).(int64cxx . . $ int64#, int64cxx . . $ int64#*, int*); |
| 158 | |
| 159 | /*** |
| 160 | *** recover-raw.c |
| 161 | ***/ |
| 162 | |
| 163 | #define CD_RAW_SECTOR_SIZEcxx . . $ `mednafen/cdrom/dvdisaster.h:163:9`! 2352 |
| 164 | #define CD_RAW_C2_SECTOR_SIZEcxx . . $ `mednafen/cdrom/dvdisaster.h:164:9`! (2352+294) /* main channel plus C2 vector */ |
| 165 | |
| 166 | int CheckEDCcxx . . $ CheckEDC(71bb053df918a28d).(const unsigned char*, bool); |
| 167 | int CheckMSFcxx . . $ CheckMSF(7405b416d0535413).(unsigned char*, int); |
| 168 | |
| 169 | |
| 170 | int ValidateRawSectorcxx . . $ ValidateRawSector(b17e68b5352f9945).(unsigned char *frame, bool xaMode); |
| 171 | bool Init_LEC_Correctcxx . . $ Init_LEC_Correct(c9857a73d68e59ba).(void); |
| 172 | void Kill_LEC_Correctcxx . . $ Kill_LEC_Correct(49f6e7a06ebc5aa8).(void); |
| 173 | |
| 174 | |
| 175 | #endif /* DVDISASTER_H */ |