MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / loadCell

Function loadCell

TheForceEngine/TFE_Asset/spriteAsset.cpp:85–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83 static const char* c_defaultGob = "SPRITES.GOB";
84
85 void loadCell(s32 w, s32 h, s16 compressed, s32 dataSize, const u8* srcData, u8* dstImage)
86 {
87 assert(srcData && dstImage);
88
89 if (compressed == 0)
90 {
91 memcpy(dstImage, srcData, w * h);
92 return;
93 }
94
95 const s32* col = (s32*)srcData;
96 for (s32 x = 0; x < w; x++)
97 {
98 const s32 offs = col[x] - sizeof(FME_Cell);
99 if (offs < 0 || offs >= dataSize) { break; }
100
101 const u8 *colData = &srcData[offs];
102 for (s32 y = 0, b = 0; y < h; )
103 {
104 if (colData[b] <= 128)
105 {
106 const u8 n = colData[b]; b++;
107 for (s32 ii = 0; ii < n; ii++, y++, b++)
108 {
109 dstImage[x*h + y] = colData[b];
110 assert(y < h);
111 }
112 }
113 else
114 {
115 const u8 n = colData[b] - 128; b++;
116 for (s32 ii = 0; ii < n; ii++, y++)
117 {
118 dstImage[x*h + y] = 0;
119 assert(y < h);
120 }
121 }
122 }
123 }
124 }
125
126 Frame* getFrame(const char* name)
127 {

Callers 2

getFrameFunction · 0.85
getSpriteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected