~ubuntu-branches/ubuntu/trusty/grfcodec/trusty

« back to all changes in this revision

Viewing changes to src/sprites.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Kooijman
  • Date: 2010-08-23 14:45:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100823144552-4qggmf9izixsw8li
Tags: 1.0.0+debian1-1
* [30caa6a] Repackaged upstream source, to remove a duplicate file (which
  the lenny version of tar --keep-old-files doesn't like.
* [331d12b] Update watch file to upstream's new versioning scheme.
* [28b6b51] Mangle the +debian suffix in the watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _SPRITES_H
 
2
#define _SPRITES_H
 
3
 
 
4
/*****************************************\
 
5
*                                         *
 
6
* SPRITES.H - A couple of routines to     *
 
7
*             decode and encode TTD .GRF  *
 
8
*             sprites                     *
 
9
*                                         *
 
10
*                                         *
 
11
* Copyright (C) 2000 by Josef Drexler     *
 
12
*               <jdrexler@julian.uwo.ca>  *
 
13
*                                         *
 
14
* Permission granted to copy and redist-  *
 
15
* ribute under the terms of the GNU GPL.  *
 
16
* For more info please read the file      *
 
17
* COPYING which should have come with     *
 
18
* this file.                              *
 
19
*                                         *
 
20
\*****************************************/
 
21
 
 
22
#include <stdio.h>
 
23
#include <stdarg.h>
 
24
 
 
25
#include "pcxfile.h"
 
26
#include "typesize.h"
 
27
 
 
28
#ifdef _SPRITES_C
 
29
#       define SPRITES_EXTERN
 
30
#       define SPRITES_INIT = 0
 
31
#else
 
32
#       define SPRITES_EXTERN extern
 
33
#       define SPRITES_INIT
 
34
#endif
 
35
 
 
36
 
 
37
// Define some of the bits in info[0]
 
38
#define DONOTCROP(info) (info[0] & 64)
 
39
#define HASTRANSPARENCY(info) (info[0] & 8)
 
40
#define SIZEISCOMPRESSED(info) (info[0] & 2)
 
41
 
 
42
 
 
43
// minimum and maximum overlap to search for in the compression routines
 
44
#define MINOVERLAP 3
 
45
#define MAXOVERLAP 15   // must be <= 15 b/o how it's encoded
 
46
 
 
47
 
 
48
 
 
49
class spriteinfowriter : public bandnotify {
 
50
        public:
 
51
        virtual void addsprite(int /*x*/, U8 /*info*/[8]) { };
 
52
        virtual void adddata(U16 /*size*/, U8 * /*data*/) { };
 
53
};
 
54
 
 
55
class spritestorage {
 
56
        public:
 
57
        virtual ~spritestorage(){}
 
58
        virtual void newsprite() {};
 
59
        virtual void setsize(int /*sx*/, int /*sy*/) {};
 
60
        virtual int  curspritex() {return 0;};
 
61
        virtual void newrow() {};
 
62
        virtual void nextpixel(U8 /*colour*/) {};
 
63
        virtual void spritedone(int /*sx*/, int /*sy*/) {};
 
64
        virtual void spritedone() {};
 
65
};
 
66
 
 
67
 
 
68
SPRITES_EXTERN int maxx SPRITES_INIT, maxy SPRITES_INIT, maxs SPRITES_INIT;
 
69
 
 
70
int decodesprite(FILE *grf, spritestorage *store, spriteinfowriter *writer);
 
71
 
 
72
U16 getlasttilesize();
 
73
U16 encodetile(FILE *grf, const U8 *image, long imgsize, U8 background, int sx, int sy, const U8 inf[8], int docompress, int spriteno);
 
74
U16 encoderegular(FILE *grf, const U8 *image, long imgsize, const U8 inf[8], int docompress);
 
75
 
 
76
#endif /* _SPRITES_H */