mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-16 18:14:05 +02:00
#15 add TR2 PSX title images support
This commit is contained in:
@@ -671,26 +671,31 @@ namespace TR {
|
|||||||
const char* getGameScreen(Version version, LevelID id) {
|
const char* getGameScreen(Version version, LevelID id) {
|
||||||
if (useEasyStart) {
|
if (useEasyStart) {
|
||||||
|
|
||||||
|
#define CHECK_FILE(name) if (Stream::existsContent(name)) return name
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case LVL_TR1_TITLE :
|
case LVL_TR1_TITLE :
|
||||||
if (Stream::existsContent("TITLEH.png")) return "TITLEH.png";
|
CHECK_FILE("TITLEH.png");
|
||||||
if (Stream::existsContent("DATA/TITLEH.PCX")) return "DATA/TITLEH.PCX";
|
CHECK_FILE("DATA/TITLEH.PCX");
|
||||||
if (Stream::existsContent("DELDATA/AMERTIT.RAW")) return "DELDATA/AMERTIT.RAW";
|
CHECK_FILE("DELDATA/AMERTIT.RAW");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LVL_TR2_TITLE :
|
case LVL_TR2_TITLE :
|
||||||
if (Stream::existsContent("TITLE.png")) return "TITLE.png";
|
CHECK_FILE("TITLE.png");
|
||||||
if (Stream::existsContent("data/TITLE.PCX")) return "data/TITLE.PCX";
|
CHECK_FILE("data/TITLE.PCX");
|
||||||
if (Stream::existsContent("pix/title.pcx")) return "pix/title.pcx";
|
CHECK_FILE("pix/title.pcx");
|
||||||
|
CHECK_FILE("PIXUS/TITLEUS.RAW"); // TODO: add other languages
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LVL_TR3_TITLE :
|
case LVL_TR3_TITLE :
|
||||||
if (Stream::existsContent("pix/TITLEUK.BMP")) return "pix/TITLEUK.BMP";
|
CHECK_FILE("pix/TITLEUK.BMP"); // TODO: add other languages
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default : ;
|
default : ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef CHECK_FILE
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case LVL_TR1_TITLE : return "level/1/TITLEH.PCX";
|
case LVL_TR1_TITLE : return "level/1/TITLEH.PCX";
|
||||||
|
@@ -511,15 +511,18 @@ struct Texture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Texture* LoadRNC(Stream &stream) { // https://github.com/lab313ru/rnc_propack_source
|
static Texture* LoadRNC(Stream &stream) { // https://github.com/lab313ru/rnc_propack_source
|
||||||
stream.seek(4); // skip MAGIC
|
uint32 magic, size, csize;
|
||||||
uint32 size = swap32(stream.read(size));
|
stream.read(magic);
|
||||||
uint32 csize = swap32(stream.read(csize));
|
|
||||||
stream.seek(4); // skip CRC
|
|
||||||
uint8 chunks, fkey;
|
|
||||||
stream.read(fkey);
|
|
||||||
stream.read(chunks);
|
|
||||||
|
|
||||||
uint16 key = fkey;
|
if (magic == FOURCC("RNC\002")) {
|
||||||
|
size = swap32(stream.read(size));
|
||||||
|
csize = swap32(stream.read(csize));
|
||||||
|
stream.seek(6);
|
||||||
|
} else {
|
||||||
|
stream.seek(-4);
|
||||||
|
size = 384 * 256 * 2;
|
||||||
|
csize = stream.size;
|
||||||
|
}
|
||||||
|
|
||||||
uint8 *data = new uint8[size];
|
uint8 *data = new uint8[size];
|
||||||
uint8 *cdata = new uint8[csize];
|
uint8 *cdata = new uint8[csize];
|
||||||
@@ -528,13 +531,12 @@ struct Texture {
|
|||||||
|
|
||||||
BitStream bs(cdata, csize);
|
BitStream bs(cdata, csize);
|
||||||
uint8 *dst = data;
|
uint8 *dst = data;
|
||||||
uint8 *end = data + size;
|
|
||||||
|
|
||||||
uint32 length = 0;
|
uint32 length = 0;
|
||||||
uint16 offset = 0;
|
uint16 offset = 0;
|
||||||
|
|
||||||
bs.readBits(2);
|
bs.readBits(2);
|
||||||
while (dst < end) {
|
while (bs.data < bs.end || bs.index > 0) {
|
||||||
if (!bs.readBit()) {
|
if (!bs.readBit()) {
|
||||||
*dst++ = bs.readByte();
|
*dst++ = bs.readByte();
|
||||||
} else {
|
} else {
|
||||||
@@ -578,7 +580,7 @@ struct Texture {
|
|||||||
delete[] cdata;
|
delete[] cdata;
|
||||||
|
|
||||||
int width = 384;
|
int width = 384;
|
||||||
int height = 256;
|
int height = size / width / 2;
|
||||||
int dw = Core::support.texNPOT ? width : nextPow2(width);
|
int dw = Core::support.texNPOT ? width : nextPow2(width);
|
||||||
int dh = Core::support.texNPOT ? height : nextPow2(height);
|
int dh = Core::support.texNPOT ? height : nextPow2(height);
|
||||||
|
|
||||||
@@ -610,13 +612,16 @@ struct Texture {
|
|||||||
static Texture* Load(Stream &stream) {
|
static Texture* Load(Stream &stream) {
|
||||||
uint32 magic;
|
uint32 magic;
|
||||||
stream.read(magic);
|
stream.read(magic);
|
||||||
stream.seek(-int(sizeof(magic)));
|
stream.seek(-4);
|
||||||
|
|
||||||
#ifdef USE_INFLATE
|
#ifdef USE_INFLATE
|
||||||
if (magic == 0x474E5089)
|
if (magic == 0x474E5089)
|
||||||
return LoadPNG(stream);
|
return LoadPNG(stream);
|
||||||
#endif
|
#endif
|
||||||
if (magic == FOURCC("RNC\002"))
|
|
||||||
|
if (stream.name && strstr(stream.name, ".RAW"))
|
||||||
return LoadRNC(stream);
|
return LoadRNC(stream);
|
||||||
|
|
||||||
if ((magic & 0xFFFF) == 0x4D42)
|
if ((magic & 0xFFFF) == 0x4D42)
|
||||||
return LoadBMP(stream);
|
return LoadBMP(stream);
|
||||||
return LoadPCX(stream);
|
return LoadPCX(stream);
|
||||||
|
@@ -1055,6 +1055,9 @@ struct Stream {
|
|||||||
size = ftell(f);
|
size = ftell(f);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
|
this->name = new char[strlen(name) + 1];
|
||||||
|
strcpy(this->name, name);
|
||||||
|
|
||||||
if (callback)
|
if (callback)
|
||||||
callback(this, userData);
|
callback(this, userData);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user