mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-27 05:32:45 +00:00
CHEWY: Use the new TGP image resource loading code
This also effectively removes the TGPDATEI resource handle
This commit is contained in:
parent
90a666d0d0
commit
04193434d9
@ -56,50 +56,6 @@ void datei::assign_filename(const char *fname, const char *ext) {
|
||||
strcat(filename, ext);
|
||||
}
|
||||
|
||||
void datei::load_image(Stream *stream, byte *sp, byte *palette) {
|
||||
Common::SeekableReadStream *rs = dynamic_cast<Common::SeekableReadStream *>(stream);
|
||||
tbf_dateiheader *header = (tbf_dateiheader *)tmp;
|
||||
byte *speicher = sp;
|
||||
int16 *abmess = (int16 *)speicher;
|
||||
|
||||
if ((speicher) && (palette) && (rs)) {
|
||||
if (header->load(rs)) {
|
||||
int16 format = get_id(header->id);
|
||||
if (format != -1) {
|
||||
for (uint16 i = 0; i < 768; i++)
|
||||
palette[i] = header->palette[i];
|
||||
switch (format) {
|
||||
case TBFDATEI:
|
||||
abmess[0] = header->width;
|
||||
abmess[1] = header->height;
|
||||
speicher += 4;
|
||||
read_tbf_image(rs, header->komp, header->entpsize, speicher);
|
||||
break;
|
||||
case TPFDATEI:
|
||||
abmess[0] = header->width;
|
||||
abmess[1] = header->height;
|
||||
speicher += 4;
|
||||
read_tpf_image(rs, header->komp, header->entpsize, speicher);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
error("load_image error");
|
||||
}
|
||||
} else {
|
||||
error("load_image error");
|
||||
}
|
||||
} else {
|
||||
error("load_image error");
|
||||
}
|
||||
|
||||
ChunkHead ch;
|
||||
if (!modul)
|
||||
ch.load(rs);
|
||||
}
|
||||
|
||||
uint16 datei::select_pool_item(Stream *stream, uint16 nr) {
|
||||
Common::SeekableReadStream *rs = dynamic_cast<Common::SeekableReadStream *>(stream);
|
||||
NewPhead *ph = (NewPhead *)tmp;
|
||||
@ -327,29 +283,6 @@ void datei::read_tbf_image(Stream *stream, int16 komp, uint32 size, byte *sp) {
|
||||
}
|
||||
}
|
||||
|
||||
void datei::read_tpf_image(Stream *handle, int16 komp, uint32 size, byte *speicher) {
|
||||
if (komp == 1) {
|
||||
for (int16 plane = 0; plane < 4; plane++) {
|
||||
for (uint32 pos = (uint32)plane; pos < (size + plane);) {
|
||||
uint8 count = chewy_fgetc(handle);
|
||||
char zeichen = chewy_fgetc(handle);
|
||||
for (uint8 i = 0; i < count && pos < (size + plane); i++) {
|
||||
speicher[pos] = zeichen;
|
||||
pos += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int16 plane = 0; plane < 4; plane++) {
|
||||
for (uint32 pos = (uint32)plane; pos < size + plane;) {
|
||||
char zeichen = chewy_fgetc(handle);
|
||||
speicher[pos] = zeichen;
|
||||
pos += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32 datei::load_voc(Stream *handle, byte *speicher) {
|
||||
ChunkHead *ch = (ChunkHead *)tmp;
|
||||
Common::SeekableReadStream *rs = dynamic_cast<Common::SeekableReadStream *>(handle);
|
||||
|
@ -36,10 +36,8 @@ public:
|
||||
|
||||
void load_tafmcga(const char *fname, byte *sp, int16 nr);
|
||||
|
||||
void load_image(Stream *stream, byte *sp, byte *palette);
|
||||
uint16 select_pool_item(Stream *stream, uint16 nr);
|
||||
void load_tafmcga(Stream *stream, int16 komp, uint32 size, byte *speicher);
|
||||
void read_tpf_image(Stream *stream, int16 komp, uint32 size, byte *speicher);
|
||||
uint32 load_voc(Stream *stream, byte *speicher);
|
||||
uint32 load_tmf(Stream *stream, tmf_header *song);
|
||||
|
||||
|
@ -155,8 +155,7 @@ int16 file_menue() {
|
||||
taf_info *ti = mem->taf_adr(OPTION_TAF);
|
||||
//SpriteResource *options = new SpriteResource(OPTION_TAF);
|
||||
ret = 0;
|
||||
room->open_handle("back/gbook.tgp", "rb", R_TGPDATEI);
|
||||
room->load_tgp(1, &room_blk, GBOOK_TGP, 0);
|
||||
room->load_tgp(1, &room_blk, GBOOK_TGP, 0, "back/gbook.tgp");
|
||||
out->setze_zeiger(workptr);
|
||||
out->map_spr2screen(ablage[room_blk.AkAblage], 0, 0);
|
||||
out->setze_zeiger(screen0);
|
||||
@ -348,7 +347,6 @@ int16 file_menue() {
|
||||
if (mode[3]) {
|
||||
tmp = fnames + ((text_off + active_slot) * 40);
|
||||
if (tmp[0]) {
|
||||
room->open_handle(&background[0], "rb", R_TGPDATEI);
|
||||
CurrentSong = -1;
|
||||
iog->load(text_off + active_slot,
|
||||
ioptr.save_path);
|
||||
@ -397,8 +395,7 @@ int16 file_menue() {
|
||||
}
|
||||
free(ti);
|
||||
|
||||
room->open_handle(&background[0], "rb", R_TGPDATEI);
|
||||
room->load_tgp(_G(spieler).PersonRoomNr[P_CHEWY], &room_blk, EPISODE1_TGP, GED_LOAD);
|
||||
room->load_tgp(_G(spieler).PersonRoomNr[P_CHEWY], &room_blk, EPISODE1_TGP, GED_LOAD, EPISODE1);
|
||||
fx_blend = BLEND1;
|
||||
room->set_ak_pal(&room_blk);
|
||||
u_index = ged->ged_idx(spieler_vector[P_CHEWY].Xypos[0] + spieler_mi[P_CHEWY].HotX,
|
||||
@ -424,7 +421,7 @@ void option_menue(taf_info *ti) {
|
||||
//int16 TmpFrame;
|
||||
int16 delay_count;
|
||||
short bar_off;
|
||||
room->load_tgp(0, &room_blk, GBOOK_TGP, 0);
|
||||
room->load_tgp(0, &room_blk, GBOOK_TGP, 0, "back/gbook.tgp");
|
||||
out->setze_zeiger(workptr);
|
||||
out->map_spr2screen(ablage[room_blk.AkAblage], 0, 0);
|
||||
out->setze_zeiger(screen0);
|
||||
@ -627,7 +624,7 @@ void option_menue(taf_info *ti) {
|
||||
--delay_count;
|
||||
}
|
||||
|
||||
room->load_tgp(1, &room_blk, GBOOK_TGP, 0);
|
||||
room->load_tgp(1, &room_blk, GBOOK_TGP, 0, "back/gbook.tgp");
|
||||
out->setze_zeiger(workptr);
|
||||
out->map_spr2screen(ablage[room_blk.AkAblage], 0, 0);
|
||||
out->setze_zeiger(screen0);
|
||||
|
@ -68,12 +68,6 @@ inline int chewy_fseek(Stream *stream, long int offset, int whence) {
|
||||
return rs->seek(offset, whence);
|
||||
}
|
||||
|
||||
inline int chewy_fgetc(Stream *stream) {
|
||||
Common::SeekableReadStream *rs = dynamic_cast<Common::SeekableReadStream *>(stream);
|
||||
assert(rs);
|
||||
return rs->readByte();
|
||||
}
|
||||
|
||||
inline size_t chewy_ftell(Stream *stream) {
|
||||
Common::SeekableReadStream *rs = dynamic_cast<Common::SeekableReadStream *>(stream);
|
||||
assert(rs);
|
||||
|
@ -251,7 +251,6 @@ atdsys *atds;
|
||||
flic *flc;
|
||||
movclass *mov;
|
||||
|
||||
char background[] = { EPISODE1 };
|
||||
char backged[] = { EPISODE1_GEP };
|
||||
|
||||
AutoMov auto_mov[MAX_AUTO_MOV];
|
||||
|
@ -236,7 +236,6 @@ extern flic *flc;
|
||||
extern movclass *mov;
|
||||
extern ailclass *ailsnd;
|
||||
|
||||
extern char background[];
|
||||
extern char backged[];
|
||||
extern char fname[80];
|
||||
extern AutoMov auto_mov[MAX_AUTO_MOV];
|
||||
|
@ -191,7 +191,6 @@ void init_room() {
|
||||
room_blk.AtsLoad = true;
|
||||
strcpy(room_blk.RoomDir, "room/");
|
||||
|
||||
room->open_handle(&background[0], "rb", R_TGPDATEI);
|
||||
room->open_handle(&backged[0], "rb", R_GEPDATEI);
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ TAFChunk *SpriteResource::getSprite(uint num) {
|
||||
return taf;
|
||||
}
|
||||
|
||||
TBFChunk *BackgroundResource::getImage(uint num) {
|
||||
TBFChunk *BackgroundResource::getImage(uint num, bool fixPalette) {
|
||||
assert(num < _chunkList.size());
|
||||
|
||||
Chunk *chunk = &_chunkList[num];
|
||||
@ -207,7 +207,7 @@ TBFChunk *BackgroundResource::getImage(uint num) {
|
||||
tbf->width = _stream.readUint16LE();
|
||||
tbf->height = _stream.readUint16LE();
|
||||
for (int j = 0; j < 3 * 256; j++)
|
||||
tbf->palette[j] = (_stream.readByte() << 2) & 0xff;
|
||||
tbf->palette[j] = fixPalette ? (_stream.readByte() << 2) & 0xff : _stream.readByte();
|
||||
|
||||
tbf->data = new uint8[tbf->size];
|
||||
|
||||
|
@ -159,7 +159,7 @@ public:
|
||||
BackgroundResource(Common::String filename) : Resource(filename) {}
|
||||
virtual ~BackgroundResource() {}
|
||||
|
||||
TBFChunk *getImage(uint num);
|
||||
TBFChunk *getImage(uint num, bool fixPalette);
|
||||
};
|
||||
|
||||
class SoundResource : public Resource {
|
||||
|
@ -137,7 +137,7 @@ void Room::load_room(RaumBlk *Rb, int16 room_nr, Spieler *player) {
|
||||
}
|
||||
if (!modul) {
|
||||
obj->calc_all_static_detail();
|
||||
load_tgp(room_info->BildNr, Rb, EPISODE1_TGP, GED_LOAD);
|
||||
load_tgp(room_info->BildNr, Rb, EPISODE1_TGP, GED_LOAD, "back/episode1.tgp");
|
||||
set_pal(AblagePal[Rb->AkAblage], Rb->LowPalMem);
|
||||
calc_invent(Rb, player);
|
||||
|
||||
@ -280,57 +280,38 @@ void Room::calc_invent(RaumBlk *Rb, Spieler *player) {
|
||||
}
|
||||
}
|
||||
|
||||
int16 Room::load_tgp(int16 nr, RaumBlk *Rb, int16 tgp_idx, int16 mode) {
|
||||
//BackgroundResource *res = new BackgroundResource();
|
||||
int16 Room::load_tgp(int16 nr, RaumBlk *Rb, int16 tgp_idx, int16 mode, const char *fileName) {
|
||||
BackgroundResource *res = new BackgroundResource(fileName);
|
||||
TBFChunk *img = res->getImage(nr, false);
|
||||
|
||||
Common::SeekableReadStream *rs = dynamic_cast<Common::SeekableReadStream *>(roomhandle[R_TGPDATEI]);
|
||||
tbf_dateiheader tb;
|
||||
bool ret = false;
|
||||
Rb->AkAblage = get_ablage(nr + (1000 * tgp_idx), img->size + 4);
|
||||
|
||||
if (rs) {
|
||||
mem->file->select_pool_item(rs, nr);
|
||||
|
||||
if (!tb.load(rs)) {
|
||||
error("Error reading from room data");
|
||||
}
|
||||
|
||||
if (!modul) {
|
||||
rs->seek(-tbf_dateiheader::SIZE(), SEEK_CUR);
|
||||
Rb->AkAblage = get_ablage(nr + (1000 * tgp_idx), tb.entpsize + 4);
|
||||
|
||||
if (Rb->AkAblage == -1) {
|
||||
} else if (Rb->AkAblage >= 1000) {
|
||||
Rb->AkAblage -= 1000;
|
||||
|
||||
} else {
|
||||
mem->file->load_image(rs, Ablage[Rb->AkAblage], AblagePal[Rb->AkAblage]);
|
||||
if (!modul) {
|
||||
set_ablage_info(Rb->AkAblage, nr + (1000 * tgp_idx), tb.entpsize);
|
||||
ret = true;
|
||||
|
||||
if (mode == GED_LOAD) {
|
||||
Common::SeekableReadStream *gstream = dynamic_cast<Common::SeekableReadStream *>(
|
||||
roomhandle[R_GEPDATEI]);
|
||||
ged->load_ged_pool(gstream, &GedInfo[Rb->AkAblage],
|
||||
nr, GedMem[Rb->AkAblage]);
|
||||
if (!modul) {
|
||||
int16 *tmp = (int16 *)Ablage[Rb->AkAblage];
|
||||
GedXAnz[Rb->AkAblage] = tmp[0] / GedInfo[Rb->AkAblage].X;
|
||||
GedYAnz[Rb->AkAblage] = tmp[1] / GedInfo[Rb->AkAblage].Y;
|
||||
} else {
|
||||
error("load_tgp error");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error("load_tgp error");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Rb->AkAblage == -1) {
|
||||
} else if (Rb->AkAblage >= 1000) {
|
||||
Rb->AkAblage -= 1000;
|
||||
} else {
|
||||
error("load_tgp error");
|
||||
// Image width and height is piggy-banked inside the image data
|
||||
uint16 *mem = (uint16 *)Ablage[Rb->AkAblage];
|
||||
mem[0] = img->width;
|
||||
mem[1] = img->height;
|
||||
memcpy(Ablage[Rb->AkAblage] + 4, img->data, img->size);
|
||||
memcpy(AblagePal[Rb->AkAblage], img->palette, 3 * 256);
|
||||
set_ablage_info(Rb->AkAblage, nr + (1000 * tgp_idx), img->size);
|
||||
|
||||
if (mode == GED_LOAD) {
|
||||
Common::SeekableReadStream *gstream = dynamic_cast<Common::SeekableReadStream *>(
|
||||
roomhandle[R_GEPDATEI]);
|
||||
ged->load_ged_pool(gstream, &GedInfo[Rb->AkAblage],
|
||||
nr, GedMem[Rb->AkAblage]);
|
||||
GedXAnz[Rb->AkAblage] = img->width / GedInfo[Rb->AkAblage].X;
|
||||
GedYAnz[Rb->AkAblage] = img->height / GedInfo[Rb->AkAblage].Y;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
delete img;
|
||||
delete res;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Room::init_ablage() {
|
||||
|
@ -39,7 +39,6 @@ extern const int16 SURIMY_TAF19_PHASEN[4][2];
|
||||
#define MAX_ROOM_HANDLE 4
|
||||
#define GED_LOAD 1
|
||||
|
||||
#define R_TGPDATEI 0
|
||||
#define R_VOCDATEI 1
|
||||
#define R_GEPDATEI 2
|
||||
#define R_SPEZTAF 3
|
||||
@ -96,7 +95,7 @@ public:
|
||||
|
||||
void load_taf(const char *filename, byte **speicher, byte *palette, int16 sprnr);
|
||||
|
||||
int16 load_tgp(int16 nr, RaumBlk *Rb, int16 tgp_idx, int16 mode);
|
||||
int16 load_tgp(int16 nr, RaumBlk *Rb, int16 tgp_idx, int16 mode, const char *fileName);
|
||||
void load_sound();
|
||||
|
||||
Stream *get_sound_handle();
|
||||
|
@ -2177,8 +2177,7 @@ void calc_inv_use_txt(int16 test_nr) {
|
||||
_G(spieler).scrollx = 0;
|
||||
_G(spieler).scrolly = 0;
|
||||
|
||||
room->open_handle("BACK/GBOOK.TGP", "rb", R_TGPDATEI);
|
||||
room->load_tgp(BUCH_START, &room_blk, GBOOK_TGP, 0);
|
||||
room->load_tgp(BUCH_START, &room_blk, GBOOK_TGP, 0, "BACK/GBOOK.TGP");
|
||||
out->setze_zeiger(workptr);
|
||||
out->map_spr2screen(ablage[room_blk.AkAblage], _G(spieler).scrollx, _G(spieler).scrolly);
|
||||
out->back2screen(workpage);
|
||||
@ -2192,8 +2191,7 @@ void calc_inv_use_txt(int16 test_nr) {
|
||||
SHOULD_QUIT_RETURN;
|
||||
}
|
||||
|
||||
room->open_handle(EPISODE1, "rb", R_TGPDATEI);
|
||||
room->load_tgp(_G(spieler).PersonRoomNr[P_CHEWY], &room_blk, EPISODE1_TGP, GED_LOAD);
|
||||
room->load_tgp(_G(spieler).PersonRoomNr[P_CHEWY], &room_blk, EPISODE1_TGP, GED_LOAD, EPISODE1);
|
||||
|
||||
_G(spieler).scrollx = scrollx;
|
||||
_G(spieler).scrolly = scrolly;
|
||||
|
Loading…
x
Reference in New Issue
Block a user