Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/Graphics/Sprite.hpp
1167 views
1
#ifndef SPRITE_H
2
#define SPRITE_H
3
4
namespace RSDK
5
{
6
7
struct Image {
8
Image()
9
{
10
InitFileInfo(&info);
11
width = 0;
12
height = 0;
13
palette = NULL;
14
pixels = NULL;
15
}
16
#if !RETRO_USE_ORIGINAL_CODE
17
~Image() { RemoveStorageEntry((void **)&palette); }
18
#endif
19
20
virtual bool32 Load(const char *fileName, bool32 loadHeader) { return false; }
21
virtual bool32 Load(String *fileName, bool32 loadHeader)
22
{
23
if (!fileName->chars)
24
return Load("", loadHeader);
25
26
GetCString(textBuffer, fileName);
27
return Load(textBuffer, loadHeader);
28
}
29
virtual void Close() { CloseFile(&info); }
30
31
FileInfo info;
32
int32 width;
33
int32 height;
34
int32 depth;
35
color *palette;
36
uint8 *pixels;
37
};
38
39
struct GifDecoder {
40
int32 depth;
41
int32 clearCode;
42
int32 eofCode;
43
int32 runningCode;
44
int32 runningBits;
45
int32 prevCode;
46
int32 currentCode;
47
int32 maxCodePlusOne;
48
int32 stackPtr;
49
int32 shiftState;
50
int32 fileState;
51
int32 position;
52
int32 bufferSize;
53
uint32 shiftData;
54
uint32 pixelCount;
55
uint8 buffer[256];
56
uint8 stack[4096];
57
uint8 suffix[4096];
58
uint32 prefix[4096];
59
};
60
61
struct ImageGIF : public Image {
62
ImageGIF() { AllocateStorage((void **)&decoder, sizeof(GifDecoder), DATASET_TMP, true); }
63
#if !RETRO_USE_ORIGINAL_CODE
64
~ImageGIF() { RemoveStorageEntry((void **)&decoder); }
65
#endif
66
67
bool32 Load(const char *fileName, bool32 loadHeader);
68
69
GifDecoder *decoder;
70
};
71
72
#if RETRO_REV02
73
enum PNGColorFormats {
74
PNGCLR_GREYSCALE = 0,
75
PNGCLR_RGB = 2,
76
PNGCLR_INDEXED = 3,
77
PNGCLR_GREYSCALEA = 4,
78
PNGCLR_RGBA = 6,
79
};
80
81
enum PNGCompressionFilters {
82
PNGFILTER_NONE,
83
PNGFILTER_SUB,
84
PNGFILTER_UP,
85
PNGFILTER_AVG,
86
PNGFILTER_PAETH,
87
};
88
89
struct ImagePNG : public Image {
90
bool32 Load(const char *fileName, bool32 loadHeader);
91
92
void UnpackPixels_Greyscale(uint8 *pixelData);
93
void UnpackPixels_GreyscaleA(uint8 *pixelData);
94
void UnpackPixels_Indexed(uint8 *pixelData);
95
void UnpackPixels_RGB(uint8 *pixelData);
96
void UnpackPixels_RGBA(uint8 *pixelData);
97
98
void Unfilter(uint8 *recon);
99
100
bool32 AllocatePixels();
101
void ProcessScanlines();
102
103
uint8 bitDepth;
104
uint8 colorFormat;
105
uint8 compression;
106
uint8 filter;
107
uint8 interlaced;
108
int32 chunkHeader;
109
int32 chunkSize;
110
int32 chunkCRC;
111
int32 dataSize;
112
uint8 *chunkBuffer;
113
};
114
#else
115
struct ImageTGA : public Image {
116
bool32 Load(const char *fileName, bool32 loadHeader);
117
};
118
#endif
119
120
uint16 LoadSpriteSheet(const char *filename, uint8 scope);
121
bool32 LoadImage(const char *filename, double displayLength, double fadeSpeed, bool32 (*skipCallback)());
122
123
#if RETRO_REV0U
124
#include "Legacy/SpriteLegacy.hpp"
125
#endif
126
127
} // namespace RSDK
128
129
#endif // SPRITE_H
130