Madable

madable
#include
#include

int main()
{
FILE* f = fopen(“mars.mad”, “rb”);
if (!f) return 1;

char MadHeader[0x1C];
if (fread(MadHeader, 0x1C, 1, f) < 1)
return 2;
madable check more madable

if (strncmp(MadHeader, "WORLD&ART&DIRECTORY", 0x13))
{
printf("Not a valid MAD filen");
return 3;
}

int MadCount = *(int*)(MadHeader+0x14);
int MadOffset = *(int*)(MadHeader+0x18);

madable best of madable
fseek(f, MadOffset, SEEK_SET);

char* MadTable = new char[MadCount*16];
fread(MadTable, 16, MadCount, f);

char* v10 = MadTable;
for (int i = 0; i < MadCount*16; i++)
*v10++ -= 0x30;

// lets convert this bullshit into a WAD file
madable best of madable
FILE* f2 = fopen("mars.wad", "wb");
if (!f2) return 4;

int MadCountReal = MadCount;
int MadOffsetC = MadOffset;

for (int i = 0; i < MadCount; i++)
{
int LumpOffset = *(int*)(MadTable+i*16);
int LumpSize = *(int*)(MadTable+i*16+4);
madable best of madable
char LumpName[9];
LumpName[8] = 0;
memcpy(LumpName, MadTable+i*16+8, 8);

if (LumpSize < 0)
continue;

if (LumpSize)
{
char* lump = new char[LumpSize];
madable check more madable
fseek(f, LumpOffset, SEEK_SET);
fseek(f2, LumpOffset, SEEK_SET);
fread(lump, LumpSize, 1, f);
fwrite(lump, LumpSize, 1, f2);
delete[] lump;
}
}

for (int i = 0; i < MadCount; i++)
{
madable best of madable
int LumpOffset = *(int*)(MadTable+i*16);
int LumpSize = *(int*)(MadTable+i*16+4);
char LumpName[9];
LumpName[8] = 0;
memcpy(LumpName, MadTable+i*16+8, 8);

if (LumpSize < 0)
{
MadCountReal–;
continue;
madable check more madable
}

fseek(f2, MadOffsetC, SEEK_SET);
MadOffsetC += 16;
fwrite(&LumpOffset, 4, 1, f2);
fwrite(&LumpSize, 4, 1, f2);
fwrite(LumpName, 8, 1, f2);
}

fseek(f2, 0, SEEK_SET);
madable check more madable
fwrite("PWAD", 4, 1, f2);
fwrite(&MadCount, 4, 1, f2);
fwrite(&MadOffset, 4, 1, f2);

fclose(f2);
fclose(f);

return 0;
}
madable

Anatolia’s Mercenary

Descent Into Avernus Pdf Free