MCPcopy Create free account
hub / github.com/DentonW/DevIL / iLoadDoomInternal

Function iLoadDoomInternal

DevIL/src-IL/src/il_doom.cpp:77–163  ·  view source on GitHub ↗

From the DTE sources (mostly by Denton Woods with corrections by Randy Heit)

Source from the content-addressed store, hash-verified

75
76// From the DTE sources (mostly by Denton Woods with corrections by Randy Heit)
77ILboolean iLoadDoomInternal()
78{
79 ILshort width, height, graphic_header[2], column_loop, row_loop;
80 ILint column_offset, pointer_position, first_pos;
81 ILubyte post, topdelta, length;
82 ILubyte *NewData;
83 ILuint i;
84
85 if (iCurImage == NULL) {
86 ilSetError(IL_ILLEGAL_OPERATION);
87 return IL_FALSE;
88 }
89
90 first_pos = itell(); // Needed to go back to the offset table
91 width = GetLittleShort();
92 height = GetLittleShort();
93 graphic_header[0] = GetLittleShort(); // Not even used
94 graphic_header[1] = GetLittleShort(); // Not even used
95
96 if (!ilTexImage(width, height, 1, 1, IL_COLOUR_INDEX, IL_UNSIGNED_BYTE, NULL)) {
97 return IL_FALSE;
98 }
99 iCurImage->Origin = IL_ORIGIN_UPPER_LEFT;
100
101 iCurImage->Pal.Palette = (ILubyte*)ialloc(IL_DOOMPAL_SIZE);
102 if (iCurImage->Pal.Palette == NULL) {
103 return IL_FALSE;
104 }
105 iCurImage->Pal.PalSize = IL_DOOMPAL_SIZE;
106 iCurImage->Pal.PalType = IL_PAL_RGB24;
107 memcpy(iCurImage->Pal.Palette, ilDefaultDoomPal, IL_DOOMPAL_SIZE);
108
109 // 247 is always the transparent colour (usually cyan)
110 memset(iCurImage->Data, 247, iCurImage->SizeOfData);
111
112 for (column_loop = 0; column_loop < width; column_loop++) {
113 column_offset = GetLittleInt();
114 pointer_position = itell();
115 iseek(first_pos + column_offset, IL_SEEK_SET);
116
117 while (1) {
118 if (iread(&topdelta, 1, 1) != 1)
119 return IL_FALSE;
120 if (topdelta == 255)
121 break;
122 if (iread(&length, 1, 1) != 1)
123 return IL_FALSE;
124 if (iread(&post, 1, 1) != 1)
125 return IL_FALSE; // Skip extra byte for scaling
126
127 for (row_loop = 0; row_loop < length; row_loop++) {
128 if (iread(&post, 1, 1) != 1)
129 return IL_FALSE;
130 if (row_loop + topdelta < height)
131 iCurImage->Data[(row_loop+topdelta) * width + column_loop] = post;
132 }
133 iread(&post, 1, 1); // Skip extra scaling byte
134 }

Callers 2

ilLoadDoomFFunction · 0.85
ilLoadDoomLFunction · 0.85

Calls 4

ilSetErrorFunction · 0.85
GetLittleShortFunction · 0.85
GetLittleIntFunction · 0.85
ilFixImageFunction · 0.85

Tested by

no test coverage detected