KINGDOM: Add some functions and constants (courtesy of TMM), fix the IFFDecoder for chunks with odd size

This commit is contained in:
Strangerke 2017-06-12 07:30:50 +02:00 committed by Eugene Sandulenko
parent 15d07a0cdd
commit f7bdd77d0c
4 changed files with 598 additions and 2 deletions

View File

@ -31,11 +31,15 @@
#include "graphics/font.h"
#include "graphics/fontman.h"
#include "common/system.h"
#include "image/iff.h"
#include "engines/util.h"
#include "common/debug.h"
#include "common/debug-channels.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "kingdom/kingdom.h"
#include "kingdom/reznames.h"
namespace Kingdom {
@ -43,6 +47,10 @@ KingdomGame::KingdomGame(OSystem *syst, const ADGameDescription *gameDesc) : Eng
_console = nullptr;
DebugMan.addDebugChannel(kDebugGeneral, "general", "General debug level");
for (int i = 0; i < 509; i++) {
_RezPointers[i] = nullptr;
_RezSize[i] = 0;
}
}
KingdomGame::~KingdomGame() {
@ -111,11 +119,19 @@ void KingdomGame::drawScreen() {
}
void KingdomGame::SetupPics() {
debug("STUB: SetupPics");
// Load Pics\kingArt.art
LoadAResource(0x97);
_ArtPtr = _RezPointers[0x97 - 1];
}
void KingdomGame::InitTools() {
debug("STUB: InitTools");
//CHECKME: InitTimers?
ShowPic(124);
InitCursor();
SetMouse();
FadeToBlack2();
InitMPlayer();
}
void KingdomGame::TitlePage() {
@ -154,4 +170,54 @@ void KingdomGame::GPLogic4() {
debug("STUB: GPLogic4");
}
void KingdomGame::LoadAResource(int reznum) {
// CHECKME: Weird off-by-one here?
reznum--;
Common::String path = Common::String(_RezNames[reznum]);
path.toUppercase();
debug("Loading resource: %i (%s)\n", reznum, path.c_str());
if(!_RezSize[reznum]) {
Common::File *file = new Common::File();
if(!file->open(path))
error("Failed to open %s", path);
_RezSize[reznum] = file->size();
file->seek(0, SEEK_SET);
_RezPointers[reznum] = file->readStream(_RezSize[reznum]);
file->close();
delete file;
}
}
void KingdomGame::ShowPic(int reznum) {
debug("STUB ShowPic %i\n", reznum);
LoadAResource(reznum);
Image::IFFDecoder decoder;
if (!decoder.loadStream(*_RezPointers[reznum - 1]))
return;
const byte *palette = decoder.getPalette();
int paletteColorCount = decoder.getPaletteColorCount();
g_system->getPaletteManager()->setPalette(palette, 0, paletteColorCount);
const Graphics::Surface *surface = decoder.getSurface();
g_system->copyRectToScreen(surface->getPixels(), 320, 0, 0, 320, 200);
g_system->updateScreen();
}
void KingdomGame::InitCursor() {
debug("STUB: InitCursor");
}
void KingdomGame::SetMouse() {
debug("STUB: SetMouse");
}
void KingdomGame::InitMPlayer() {
debug("STUB: InitMPlayer");
}
} // End of namespace Kingdom

View File

@ -67,6 +67,9 @@ namespace Kingdom {
bool _LoopFlag;
int _GameMode;
int _StatPlay;
Common::SeekableReadStream *_ArtPtr;
Common::SeekableReadStream *_RezPointers[509];
int _RezSize[509];
void drawScreen();
void SetupPics();
@ -80,6 +83,11 @@ namespace Kingdom {
void GPLogic2();
void GPLogic3();
void GPLogic4();
void LoadAResource(int reznum);
void ShowPic(int reznum);
void InitCursor();
void SetMouse();
void InitMPlayer();
};
} // End of namespace Kingdom

511
engines/kingdom/reznames.h Normal file
View File

@ -0,0 +1,511 @@
char *_RezNames[] = {
"Maps/KMAP001.lbm",
"Maps/KMAP002.lbm",
"Maps/KMAP003.lbm",
"Maps/KMAP004.lbm",
"Maps/KMAP005.lbm",
"Maps/KMAP006.lbm",
"Maps/KMAP007.lbm",
"Maps/KMAP008.lbm",
"Maps/KMAP009.lbm",
"Maps/KMAP010.lbm",
"Maps/KMAP011.lbm",
"Maps/KMAP012.lbm",
"Maps/KMAP013.lbm",
"Maps/KMAP014.lbm",
"Maps/KMAP015.lbm",
"Maps/KMAP016.lbm",
"Maps/KMAP017.lbm",
"Maps/KMAP018.lbm",
"Maps/KMAP019.lbm",
"Maps/KMAP020.lbm",
"Maps/KMAP021.lbm",
"Maps/KMAP022.lbm",
"Maps/KMAP023.lbm",
"Maps/KMAP024.lbm",
"Maps/KMAP025.lbm",
"Maps/KMAP026.lbm",
"Maps/KMAP027.lbm",
"Maps/KMAP028.lbm",
"Maps/KMAP029.lbm",
"Maps/KMAP030.lbm",
"Maps/KMAP031.lbm",
"Maps/KMAP032.lbm",
"Maps/KMAP033.lbm",
"Maps/KMAP034.lbm",
"Maps/KMAP035.lbm",
"Maps/KMAP036.lbm",
"Maps/KMAP037.lbm",
"Maps/KMAP038.lbm",
"Maps/KMAP039.lbm",
"Maps/KMAP040.lbm",
"Maps/KMAP041.lbm",
"Maps/KMAP042.lbm",
"Maps/KMAP043.lbm",
"Maps/KMAP044.lbm",
"Maps/KMAP045.lbm",
"Maps/KMAP046.lbm",
"Maps/KMAP047.lbm",
"Maps/KMAP048.lbm",
"Maps/KMAP049.lbm",
"Maps/KMAP050.lbm",
"Maps/KMAP051.lbm",
"Maps/KMAP052.lbm",
"Maps/KMAP053.lbm",
"Maps/KMAP054.lbm",
"Maps/KMAP055.lbm",
"Maps/KMAP056.lbm",
"Maps/KMAP057.lbm",
"Maps/KMAP058.lbm",
"Maps/KMAP059.lbm",
"Maps/KMAP060.lbm",
"Maps/KMAP061.lbm",
"Maps/KMAP062.lbm",
"Maps/KMAP063.lbm",
"Maps/KMAP064.lbm",
"Maps/KMAP065.lbm",
"Maps/KMAP066.lbm",
"Maps/KMAP067.lbm",
"Maps/KMAP068.lbm",
"Maps/KMAP069.lbm",
"Maps/KMAP070.lbm",
"Maps/KMAP071.lbm",
"Maps/KMAP072.lbm",
"Maps/KMAP073.lbm",
"Maps/KMAP074.lbm",
"Maps/KMAP075.lbm",
"Maps/KMAP076.lbm",
"Maps/KMAP077.lbm",
"Maps/KMAP078.lbm",
"Maps/KMAP079.lbm",
"Maps/KMAP080.lbm",
"Maps/KMAP081.lbm",
"Maps/KMAP082.lbm",
"Maps/KMAP083.lbm",
"Maps/KMAP084.lbm",
"Maps/KMAP085.lbm",
"Maps/KMAP086.lbm",
"Maps/KMAP087.lbm",
"Maps/KMAP088.lbm",
"Maps/KMAP089.lbm",
"Maps/KMAP090.lbm",
"Maps/KMAP091.lbm",
"Maps/KMAP092.lbm",
"Maps/KMAP093.lbm",
"Maps/KMAP094.lbm",
"Maps/KMAP095.lbm",
"Maps/KMAP096.lbm",
"Maps/KMAP097.lbm",
"Maps/KMAP098.lbm",
"Maps/KMAP099.lbm",
"Maps/KMAP100.lbm",
"Maps/KMAP101.lbm",
"Maps/KMAP102.lbm",
"Maps/KMAP103.lbm",
"Pics/KSndCard.lbm",
"Pics/KBook.lbm",
"Pics/KInterF.lbm",
"Pics/KGamOver.lbm",
"Pics/KPouch.lbm",
"Pics/KForest.lbm",
"Pics/KArtist.lbm",
"Pics/K4.lbm",
"Pics/K5.lbm",
"Pics/K6.lbm",
"Pics/KRestore.lbm",
"Pics/KINIT.lbm",
"Pics/KASKS1.lbm",
"Pics/KASKS2.lbm",
"Pics/KASKS3.lbm",
"Pics/KIlleSgn.lbm",
"Pics/KTSMAP.lbm",
"Pics/KPORHELH.lbm",
"Pics/KGSaved.lbm",
"Pics/KDoor.lbm",
"Pics/KLogo.lbm",
"Pics/KEOG.lbm",
"Pics/K8.lbm",
"Pics/K9.lbm",
"Pics/KPalace3.lbm",
"Pics/KBKenter.lbm",
"Pics/KIUNDER.lbm",
"Pics/KISEEING.lbm",
"Pics/KIRELESE.lbm",
"Pics/KITRAVEL.lbm",
"Pics/KIXTAL.lbm",
"Pics/KICFIRE.lbm",
"Pics/KIOSEAL.lbm",
"Pics/KISTAFF.lbm",
"Pics/KISWORD.lbm",
"Pics/KISEPTER.lbm",
"Pics/KIBOW.lbm",
"Pics/KICOINS.lbm",
"Pics/KICHALIC.lbm",
"Pics/KIWHEAT.lbm",
"Pics/KIRUNES.lbm",
"Pics/KRMACE.lbm",
"Pics/KRHORN.lbm",
"Pics/KRORB.lbm",
"Pics/K10.lbm",
"Pics/K11.lbm",
"Pics/KEMACE.lbm",
"Pics/kingArt.art",
"Pics/K12.lbm",
"Pics/K13.lbm",
"Pics/K14.lbm",
"Pics/K15.lbm",
"Pics/K16.lbm",
"Pics/K17.lbm",
"Pics/K18.lbm",
"Pics/K19.lbm",
"Pics/K20.lbm",
"Pics/KHelp01.lbm",
"Pics/KHelp02.lbm",
"Pics/KHelp03.lbm",
"Pics/KHelp04.lbm",
"Pics/KHelp05.lbm",
"Pics/KHelp06.lbm",
"Pics/KHelp07.lbm",
"Pics/KHelp08.lbm",
"Pics/KHelp09.lbm",
"Pics/KHelp10.lbm",
"Pics/KHelp11.lbm",
"Pics/KHelp12.lbm",
"Pics/K21.lbm",
"Pics/K22.lbm",
"Pics/K23.lbm",
"Pics/K24.lbm",
"Pics/K25.lbm",
"Pics/KTideOn.lbm",
"Pics/KTideOff.lbm",
"Pics/K26.lbm",
"Pics/K27.lbm",
"Pics/K28.lbm",
"Pics/K29.lbm",
"Pics/K30.lbm",
"Pics/K31.lbm",
"Pics/K32.lbm",
"Pics/K33.lbm",
"Pics/K34.lbm",
"Pics/K35.lbm",
"Pics/K36.lbm",
"Pics/K37.lbm",
"Pics/K38.lbm",
"Pics/K39.lbm",
"Pics/K40.lbm",
"Pics/K41.lbm",
"Pics/K42.lbm",
"Pics/K43.lbm",
"Pics/StrtDemo.lbm",
"Pics/EndDemo.lbm",
"Pics/TST.lbm",
"SoundS/L1.ssd",
"SoundS/L2.ssd",
"SoundS/L3.ssd",
"SoundS/L4.ssd",
"SoundS/L5.ssd",
"SoundS/L6.ssd",
"SoundS/L7.ssd",
"SoundS/L8.ssd",
"SoundS/L9.ssd",
"SoundS/L10.ssd",
"SoundS/L11.ssd",
"SoundS/L12.ssd",
"SoundS/L13.ssd",
"SoundS/L14.ssd",
"SoundS/L15.ssd",
"SoundS/L16.ssd",
"SoundS/L17.ssd",
"SoundS/L18.ssd",
"SoundS/L19.ssd",
"SoundS/L20.ssd",
"SoundS/L21.ssd",
"SoundS/L22.ssd",
"SoundS/L23.ssd",
"SoundS/L24.ssd",
"SoundS/L25.ssd",
"SoundS/L26.ssd",
"SoundS/L27.ssd",
"SoundS/L28.ssd",
"SoundS/L29.ssd",
"SoundS/L30.ssd",
"SoundS/L31.ssd",
"SoundS/L32.ssd",
"SoundS/L33.ssd",
"SoundS/L34.ssd",
"SoundS/L35.ssd",
"SoundS/L36.ssd",
"SoundS/L37.ssd",
"SoundS/L38.ssd",
"SoundS/L39.ssd",
"SoundS/L40.ssd",
"SoundS/L41.ssd",
"SoundS/L42.ssd",
"SoundS/L43.ssd",
"SoundS/L44.ssd",
"SoundS/L45.ssd",
"SoundS/L46.ssd",
"SoundS/L47.ssd",
"SoundS/L48.ssd",
"SoundS/L49.ssd",
"SoundS/L50.ssd",
"SoundM/L1.msd",
"SoundM/L2.msd",
"SoundM/L3.msd",
"SoundM/L4.msd",
"SoundM/L5.msd",
"SoundM/L6.msd",
"SoundM/L7.msd",
"SoundM/L8.msd",
"SoundM/L9.msd",
"SoundM/L10.msd",
"SoundM/L11.msd",
"SoundM/L12.msd",
"SoundM/L13.msd",
"SoundM/L14.msd",
"SoundM/L15.msd",
"SoundM/L16.msd",
"SoundM/L17.msd",
"SoundM/L18.msd",
"SoundM/L19.msd",
"SoundM/L20.msd",
"SoundM/L21.msd",
"SoundM/L22.msd",
"SoundM/L23.msd",
"SoundM/L24.msd",
"SoundM/L25.msd",
"SoundM/L26.msd",
"SoundM/L27.msd",
"SoundM/L28.msd",
"SoundM/L29.msd",
"SoundM/L30.msd",
"SoundM/L31.msd",
"SoundM/L32.msd",
"SoundM/L33.msd",
"SoundM/L34.msd",
"SoundM/L35.msd",
"SoundM/L36.msd",
"SoundM/L37.msd",
"SoundM/L38.msd",
"SoundM/L39.msd",
"SoundM/L40.msd",
"SoundM/L41.msd",
"SoundM/L42.msd",
"SoundM/L43.msd",
"SoundM/L44.msd",
"SoundM/L45.msd",
"SoundM/L46.msd",
"SoundM/L47.msd",
"SoundM/L48.msd",
"SoundM/L49.msd",
"SoundM/L50.msd",
"MovieLF/KLF001.lbm",
"MovieLF/KLF002.lbm",
"MovieLF/KLF003.lbm",
"MovieLF/KLF004.lbm",
"MovieLF/KLF005.lbm",
"MovieLF/KLF006.lbm",
"MovieLF/KLF007.lbm",
"MovieLF/KLF008.lbm",
"MovieLF/KLF009.lbm",
"MovieLF/KLF010.lbm",
"MovieLF/KLF011.lbm",
"MovieLF/KLF012.lbm",
"MovieLF/KLF013.lbm",
"MovieLF/KLF014.lbm",
"MovieLF/KLF015.lbm",
"MovieLF/KLF016.lbm",
"MovieLF/KLF017.lbm",
"MovieLF/KLF018.lbm",
"MovieLF/KLF019.lbm",
"MovieLF/KLF020.lbm",
"MovieLF/KLF021.lbm",
"MovieLF/KLF022.lbm",
"MovieLF/KLF023.lbm",
"MovieLF/KLF024.lbm",
"MovieLF/KLF025.lbm",
"MovieLF/KLF026.lbm",
"MovieLF/KLF027.lbm",
"MovieLF/KLF028.lbm",
"MovieLF/KLF029.lbm",
"MovieLF/KLF030.lbm",
"MovieLF/KLF031.lbm",
"MovieLF/KLF032.lbm",
"MovieLF/KLF033.lbm",
"MovieLF/KLF034.lbm",
"MovieLF/KLF035.lbm",
"MovieLF/KLF036.lbm",
"MovieLF/KLF037.lbm",
"MovieLF/KLF038.lbm",
"MovieLF/KLF039.lbm",
"MovieLF/KLF040.lbm",
"MovieLF/KLF041.lbm",
"MovieLF/KLF042.lbm",
"MovieLF/KLF043.lbm",
"MovieLF/KLF044.lbm",
"MovieLF/KLF045.lbm",
"MovieLF/KLF046.lbm",
"MovieLF/KLF047.lbm",
"MovieLF/KLF048.lbm",
"MovieLF/KLF049.lbm",
"MovieLF/KLF050.lbm",
"MovieLF/KLF051.lbm",
"MovieLF/KLF052.lbm",
"MovieLF/KLF053.lbm",
"MovieLF/KLF054.lbm",
"MovieLF/KLF055.lbm",
"MovieLF/KLF056.lbm",
"MovieLF/KLF057.lbm",
"MovieLF/KLF058.lbm",
"MovieLF/KLF059.lbm",
"MovieLF/KLF060.lbm",
"MovieLF/KLF061.lbm",
"MovieLF/KLF062.lbm",
"MovieLF/KLF063.lbm",
"MovieLF/KLF064.lbm",
"MovieLF/KLF065.lbm",
"MovieLF/KLF066.lbm",
"MovieLF/KLF067.lbm",
"MovieLF/KLF068.lbm",
"MovieLF/KLF069.lbm",
"MovieLF/KLF070.lbm",
"MovieLF/KLF071.lbm",
"MovieLF/KLF072.lbm",
"MovieLF/KLF073.lbm",
"MovieLF/KLF074.lbm",
"MovieLF/KLF075.lbm",
"MovieLF/KLF076.lbm",
"MovieLF/KLF077.lbm",
"MovieLF/KLF078.lbm",
"MovieLF/KLF079.lbm",
"MovieLF/KLF080.lbm",
"MovieLF/KLF081.lbm",
"MovieLF/KLF082.lbm",
"MovieLF/KLF083.lbm",
"MovieLF/KLF084.lbm",
"MovieLF/KLF085.lbm",
"MovieLF/KLF086.lbm",
"MovieLF/KLF087.lbm",
"MovieLF/KLF088.lbm",
"MovieLF/KLF089.lbm",
"MovieLF/KLF090.lbm",
"MovieLF/KLF091.lbm",
"MovieLF/KLF092.lbm",
"MovieLF/KLF093.lbm",
"MovieLF/KLF094.lbm",
"MovieLF/KLF095.lbm",
"MovieLF/KLF096.lbm",
"MovieLF/KLF097.lbm",
"MovieLF/KLF098.lbm",
"MovieLF/KLF099.lbm",
"MovieLF/KLF100.lbm",
"MovieLF/KLF101.lbm",
"MovieLF/KLF102.lbm",
"MovieLF/KLF103.lbm",
"MovieLF/KLF104.lbm",
"MovieLF/KLF105.lbm",
"MovieLF/KLF106.lbm",
"MovieLF/KLF107.lbm",
"MovieLF/KLF108.lbm",
"MovieLF/KLF109.lbm",
"MovieLF/KLF110.lbm",
"MovieLF/KLF111.lbm",
"MovieLF/KLF112.lbm",
"MovieLF/KLF113.lbm",
"MovieLF/KLF114.lbm",
"MovieLF/KLF115.lbm",
"MovieLF/KLF116.lbm",
"MovieLF/KLF117.lbm",
"MovieLF/KLF118.lbm",
"MovieLF/KLF119.lbm",
"MovieLF/KLF120.lbm",
"MovieLF/KLF121.lbm",
"MovieLF/KLF122.lbm",
"MovieLF/KLF123.lbm",
"MovieLF/KLF124.lbm",
"MovieLF/KLF125.lbm",
"MovieLF/KLF126.lbm",
"MovieLF/KLF127.lbm",
"MovieLF/KLF128.lbm",
"MovieLF/KLF129.lbm",
"MovieLF/KLF130.lbm",
"MovieLF/KLF131.lbm",
"MovieLF/KLF132.lbm",
"MovieLF/KLF133.lbm",
"MovieLF/KLF134.lbm",
"MovieLF/KLF135.lbm",
"MovieLF/KLF136.lbm",
"MovieLF/KLF137.lbm",
"MovieLF/KLF138.lbm",
"MovieLF/KLF139.lbm",
"MovieLF/KLF140.lbm",
"MovieLF/KLF141.lbm",
"MovieLF/KLF142.lbm",
"MovieLF/KLF143.lbm",
"MovieLF/KLF144.lbm",
"MovieLF/KLF145.lbm",
"MovieLF/KLF146.lbm",
"MovieLF/KLF147.lbm",
"MovieLF/KLF148.lbm",
"MovieLF/KLF149.lbm",
"MovieLF/KLF150.lbm",
"MovieLF/KLF151.lbm",
"MovieLF/KLF152.lbm",
"MovieLF/KLF153.lbm",
"MovieLF/KLF154.lbm",
"MovieLF/KLF155.lbm",
"MovieLF/KLF156.lbm",
"MovieLF/KLF157.lbm",
"MovieLF/KLF158.lbm",
"MovieLF/KLF159.lbm",
"MovieLF/KLF160.lbm",
"MovieLF/KLF161.lbm",
"MovieLF/KLF162.lbm",
"MovieLF/KLF163.lbm",
"MovieLF/KLF164.lbm",
"MovieLF/KLF165.lbm",
"MovieLF/KLF166.lbm",
"MovieLF/KLF167.lbm",
"MovieLF/KLF168.lbm",
"MovieLF/KLF169.lbm",
"MovieLF/KLF170.lbm",
"MovieLF/KLF171.lbm",
"MovieLF/KLF172.lbm",
"MovieLF/KLF173.lbm",
"MovieLF/KLF174.lbm",
"MovieLF/KLF175.lbm",
"MovieLF/KLF176.lbm",
"MovieLF/KLF177.lbm",
"MovieLF/KLF178.lbm",
"MovieLF/KLF179.lbm",
"MovieLF/KLF180.lbm",
"MovieLF/KLF181.lbm",
"MovieLF/KLF182.lbm",
"MovieLF/KLF183.lbm",
"MovieLF/KLF184.lbm",
"MovieLF/KLF185.lbm",
"MovieLF/KLF186.lbm",
"MovieLF/KLF187.lbm",
"MovieLF/KLF188.lbm",
"MovieLF/KLF189.lbm",
"MovieLF/KLF190.lbm",
"MovieLF/KLF191.lbm",
"MovieLF/KLF192.lbm",
"MovieLF/KLF193.lbm",
"MovieLF/KLF194.lbm",
"MovieLF/KLF195.lbm",
"MovieLF/KLF196.lbm",
"MovieLF/KLF197.lbm",
"MovieLF/KLF198.lbm",
"MovieLF/KLF199.lbm",
"MovieLF/KLF200.lbm",
"MovieLF/KLF201.lbm",
"MovieLF/KLF202.lbm",
"MovieLF/KLF203.lbm",
"MovieLF/KLF204.lbm",
"MovieLF/KLF205.lbm",
"MovieLF/KLF206.lbm",
"MovieLF/KLF207.lbm",
"MovieLF/KLF208.lbm",
"MovieLF/KLF209.lbm",
};

View File

@ -94,8 +94,16 @@ bool IFFDecoder::loadStream(Common::SeekableReadStream &stream) {
}
while (1) {
if (stream.size() < stream.pos() + 8)
break;
const uint32 chunkType = stream.readUint32BE();
const uint32 chunkSize = stream.readUint32BE();
uint32 chunkSize = stream.readUint32BE();
// According to the format specs:
// "If ckData is an odd number of bytes long, a 0 pad byte follows which is not included in ckSize."
// => fix the length
if (chunkSize % 2)
chunkSize++;
if (stream.eos())
break;
@ -114,6 +122,9 @@ bool IFFDecoder::loadStream(Common::SeekableReadStream &stream) {
loadBitmap(stream);
break;
default:
if (stream.size() < stream.pos() + (int32)chunkSize)
break;
stream.skip(chunkSize);
}
}