| 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 | { |