summaryrefslogtreecommitdiff
path: root/sid/sidplay-libs-2.1.0/libsidplay/src/sidtune/PP20.h
blob: 74e7f5f7204177e108b89c396b6e850011b5c468 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * /home/ms/files/source/libsidtune/RCS/PP20.h,v
 *
 * PowerPacker (AMIGA) "PP20" format decompressor.
 * Copyright (C) Michael Schwendt <mschwendt@yahoo.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef PP_DECOMPRESSOR_H
#define PP_DECOMPRESSOR_H

#include "PP20_Defs.h"

class PP20
{
 public:
    
    PP20();

    bool isCompressed(const void* source, const udword_ppt size);
    
    // If successful, allocates a new buffer containing the
    // uncompresse data and returns the uncompressed length.
    // Else, returns 0.
    udword_ppt decompress(const void* source, 
                                udword_ppt size,
                                ubyte_ppt** destRef);
    
    const char* getStatusString()  { return statusString; }
    
 private:
    bool checkEfficiency(const void* source);
    
    void bytesTOdword();
    udword_ppt readBits(int count);
    void bytes();
    void sequence();

    static const char* PP_ID;

    ubyte_ppt efficiency[4];
    
    const ubyte_ppt* sourceBeg;
    const ubyte_ppt* readPtr;
    
    const ubyte_ppt* destBeg;
    ubyte_ppt* writePtr;
    
    udword_ppt current;            // compressed data longword
    int bits;                   // number of bits in 'current' to evaluate
    
    bool globalError;           // exception-free version of code

    const char* statusString;
};

#endif  /* PP_DECOMPRESSOR_H */