Ticket #8465: kyra-spritesdiv-v1.patch
File kyra-spritesdiv-v1.patch, 27.2 KB (added by , 19 years ago) |
---|
-
kyra/kyra.cpp
diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur scummcvs/kyra/kyra.cpp scummvm/kyra/kyra.cpp
old new 38 38 #include "kyra/screen.h" 39 39 #include "kyra/script.h" 40 40 #include "kyra/sound.h" 41 #include "kyra/sprites.h" 41 42 #include "kyra/wsamovie.h" 42 43 43 44 using namespace Kyra; … … 163 164 _res = new Resource(this); 164 165 assert(_res); 165 166 _screen = new Screen(this, _system); 167 166 168 assert(_screen); 167 169 170 _sprites = new Sprites(this, _system); 171 assert(_sprites); 172 168 173 _fastMode = false; 169 174 _talkCoords.y = 0x88; 170 175 _talkCoords.x = 0; … … 180 185 delete _screen; 181 186 delete _res; 182 187 delete _midi; 188 delete _sprites; 183 189 } 184 190 185 191 void KyraEngine::errorString(const char *buf1, char *buf2) { … … 196 202 _screen->loadFont(Screen::FID_8_FNT, _res->fileData("8FAT.FNT", &sz)); 197 203 _screen->setScreenDim(0); 198 204 205 _abortIntroFlag = false; 206 199 207 if (_game == KYRA1DEMO) { 200 208 seq_demo(); 201 209 } else { … … 203 211 startup(); 204 212 mainLoop(); 205 213 } 206 207 214 return 0; 208 215 } 209 216 … … 213 220 _screen->setTextColorMap(colorMap); 214 221 // _screen->setFont(Screen::FID_6_FNT); 215 222 _screen->setAnimBlockPtr(3750); 223 _gameSpeed = 50; 216 224 memset(_flagsTable, 0, sizeof(_flagsTable)); 225 setupRooms(); 217 226 // XXX 218 227 } 219 228 229 void KyraEngine::delay(uint32 amount) { 230 231 OSystem::Event event; 232 233 uint32 start = _system->getMillis(); 234 //_keyFlags = _keyPressed = 0; //reset 235 236 do { 237 while (_system->pollEvent(event)) { 238 switch (event.type) { 239 case OSystem::EVENT_KEYDOWN: 240 241 if (event.kbd.keycode == 'q' || event.kbd.keycode == 27) { 242 _quitFlag = true; 243 } 244 else if (event.kbd.keycode == ' ') 245 loadRoom((++_currentRoom) % MAX_NUM_ROOMS); 246 247 //_keyFlags = event.kbd.flags; 248 //_keyPressed = (byte)event.kbd.ascii; 249 break; 250 case OSystem::EVENT_LBUTTONDOWN: 251 //debug(1, "Lbutton pressed at (%i, %i)", event.mouse.x, event.mouse.y); 252 //uint8 pixel = *(_screen->getPagePtr(0) + 320 * event.mouse.y + event.mouse.x); 253 //debug(1, "Value: %i", pixel); 254 loadRoom( (++_currentRoom) % MAX_NUM_ROOMS); 255 break; 256 case OSystem::EVENT_RBUTTONDOWN: 257 loadRoom( (--_currentRoom) % MAX_NUM_ROOMS); 258 break; 259 260 case OSystem::EVENT_QUIT: 261 //if (!SkyEngine::_systemVars.quitting) 262 // _skyControl->showGameQuitMsg(); // will call _system->quit() 263 //break; 264 _quitFlag = true; 265 break; 266 default: 267 break; 268 } 269 } 270 271 if (amount > 0) 272 _system->delayMillis((amount > 10) ? 10 : amount); 273 274 } while (_system->getMillis() < start + amount); 275 } 276 277 void KyraEngine::drawRoom() { 278 //_screen->clearPage(0); 279 _screen->copyRegion(0, 0, 0, 0, 320, 200, 10, 0); 280 _screen->copyRegion(4, 4, 4, 4, 308, 132, 14, 0); 281 _sprites->doAnims(); 282 _sprites->drawSprites(14, 0); 283 } 284 285 void KyraEngine::setCursor(uint8 cursorID) { 286 debug(9, "KyraEngine::setCursor(%i)", cursorID); 287 288 loadBitmap("mouse.cps", 2, 2, _screen->_currentPalette); 289 uint8 *cursor = new uint8[ _cursors[cursorID][2] * _cursors[cursorID][3]]; 290 291 _screen->copyRegionToBuffer(2, _cursors[cursorID][0], _cursors[cursorID][1], _cursors[cursorID][2], _cursors[cursorID][3], cursor); 292 _system->setMouseCursor( cursor, _cursors[cursorID][2], _cursors[cursorID][3], 0, 0, 0); 293 294 _system->showMouse(true); 295 296 delete[] cursor; 297 } 298 299 void KyraEngine::loadRoom(uint16 roomID) { 300 debug(9, "KyraEngine::loadRoom(%i)", roomID); 301 char buf[12]; 302 303 loadPalette("palette.col", _screen->_currentPalette); 304 305 //loadPalette(_rooms[roomID].palFilename, _screen->_currentPalette); 306 //_screen->setScreenPalette(_screen->_currentPalette); 307 308 _screen->clearPage(14); 309 _screen->clearPage(0); 310 _screen->clearPage(10); 311 312 // Loading GUI bitmap 313 if (_game == KYRA1CD) { 314 loadBitmap("MAIN_ENG.CPS", 10, 10, 0); 315 } else { 316 loadBitmap("MAIN15.CPS", 10, 10, 0); 317 } 318 319 // Loading main room background 320 strncpy(buf, _rooms[roomID].filename, 8); 321 strcat(buf, ".cps"); 322 loadBitmap( buf, 14, 14, 0); 323 324 // Loading the room mask 325 strncpy(buf, _rooms[roomID].filename, 8); 326 strcat(buf, ".msc"); 327 loadBitmap( buf, 12, 12, 0); 328 329 // Loading room data 330 strncpy(buf, _rooms[roomID].filename, 8); 331 strcat(buf, ".dat"); 332 _sprites->loadDAT(buf); 333 334 setCursor(0); 335 } 336 220 337 void KyraEngine::mainLoop() { 221 338 debug(9, "KyraEngine::mainLoop()"); 222 // XXX 339 340 _currentRoom = 0; 341 loadRoom(_currentRoom); 342 343 while (!_quitFlag) { 344 int32 frameTime = (int32)_system->getMillis(); 345 346 drawRoom(); 347 _screen->updateScreen(); 348 349 delay((frameTime + _gameSpeed) - _system->getMillis()); 350 } 351 } 352 353 void KyraEngine::loadPalette(const char *filename, uint8 *palData) { 354 debug(9, "KyraEngine::loadPalette('%s' 0x%X)", filename, palData); 355 uint32 fileSize = 0; 356 uint8 *srcData = _res->fileData(filename, &fileSize); 357 358 if (palData && fileSize) { 359 debug(9, "Loading a palette of size %i from %s", fileSize, filename); 360 memcpy(palData, srcData, fileSize); 361 } 223 362 } 224 363 225 364 void KyraEngine::loadBitmap(const char *filename, int tempPage, int dstPage, uint8 *palData) { … … 230 369 uint32 imgSize = READ_LE_UINT32(srcData + 4); 231 370 uint16 palSize = READ_LE_UINT16(srcData + 8); 232 371 if (palData && palSize) { 372 debug(9, "Loading a palette of size %i from %s", palSize, filename); 233 373 memcpy(palData, srcData + 10, palSize); 234 374 } 235 375 uint8 *srcPtr = srcData + 10 + palSize; … … 447 587 _fastMode = !_fastMode; 448 588 } 449 589 } 590 else if( event.kbd.keycode == 13 || event.kbd.keycode == 32 || event.kbd.keycode == 27 ) 591 _abortIntroFlag = true; 592 450 593 break; 451 594 default: 452 595 break; … … 658 801 659 802 bool KyraEngine::seq_skipSequence() const { 660 803 debug(9, "KyraEngine::seq_skipSequence()"); 661 return _quitFlag ;804 return _quitFlag || _abortIntroFlag; 662 805 } 663 806 664 807 bool KyraEngine::seq_playSpecialSequence(const uint8 *seqData, bool skipSeq) { -
kyra/kyra.h
diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur scummcvs/kyra/kyra.h scummvm/kyra/kyra.h
old new 27 27 28 28 namespace Kyra { 29 29 30 #define MAX_NUM_ROOMS 12 31 30 32 enum { 31 33 GF_FLOPPY = 1 << 0, 32 34 GF_TALKIE = 1 << 1, … … 64 66 }; 65 67 66 68 struct Room { 67 uint8 id;69 // uint8 id; 68 70 uint16 northExit; 69 71 uint16 eastExit; 70 72 uint16 southExit; 71 73 uint16 westExit; 72 74 uint8 itemsTable[12]; 75 const char* filename; 73 76 }; 74 77 75 78 struct TalkCoords { … … 86 89 class MusicPlayer; 87 90 class Resource; 88 91 class Screen; 92 class Sprites; 89 93 90 94 class KyraEngine : public Engine { 91 95 friend class MusicPlayer; … … 162 166 void snd_setSoundEffectFile(int file); 163 167 void snd_playSoundEffect(int track); 164 168 void snd_seqMessage(int msg); 165 169 170 void loadRoom(uint16 roomID); 171 void drawRoom(); 172 void delay(uint32 millis); 173 void loadPalette(const char *filename, uint8 *palData); 174 void setCursor(uint8 cursorID); 175 void setupRooms(); 176 166 177 uint8 _game; 167 178 bool _fastMode; 168 179 bool _quitFlag; 169 180 bool _skipIntroFlag; 181 bool _abortIntroFlag; 170 182 char _talkBuffer[300]; 171 183 char _talkSubstrings[TALK_SUBSTRING_LEN * TALK_SUBSTRING_NUM]; 172 184 TalkCoords _talkCoords; … … 174 186 uint16 _talkMessageH; 175 187 bool _talkMessagePrinted; 176 188 uint8 _flagsTable[51]; 189 uint16 _gameSpeed; 177 190 191 uint16 _currentRoom; 178 192 bool _seq_copyViewOffs; 179 193 uint8 *_seq_handShapes[3]; 180 194 181 195 Resource *_res; 182 196 Screen *_screen; 183 197 MusicPlayer *_midi; 198 Sprites *_sprites; 199 Room _rooms[MAX_NUM_ROOMS]; 184 200 201 static const uint16 _cursors[][4]; 202 185 203 // these tables are specific to the demo version 186 204 static const uint8 _seq_demoData_WestwoodLogo[]; 187 205 static const uint8 _seq_demoData_KyrandiaLogo[]; -
kyra/module.mk
diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur scummcvs/kyra/module.mk scummvm/kyra/module.mk
old new 8 8 kyra/script.o \ 9 9 kyra/sound.o \ 10 10 kyra/staticres.o \ 11 kyra/sprites.o \ 11 12 kyra/wsamovie.o 12 13 13 14 MODULE_DIRS += \ -
kyra/screen.cpp
diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur scummcvs/kyra/screen.cpp scummvm/kyra/screen.cpp
old new 224 224 } 225 225 } 226 226 227 void Screen::copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *dest) { 228 assert(x >= 0 && x < Screen::SCREEN_W && y >= 0 && y < Screen::SCREEN_H && dest); 229 230 uint8 *pagePtr = getPagePtr(pageNum); 231 232 for( int i = y; i < y+h; i++ ) 233 memcpy(dest + (i-y)*w, pagePtr + i*SCREEN_W + x, w); 234 235 } 236 227 237 void Screen::copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint8 *src) { 228 238 debug(9, "Screen::copyBlockToPage(%d, %d, %d, %d, %d, 0x%X)", pageNum, x, y, w, h, src); 229 239 assert(x >= 0 && x < Screen::SCREEN_W && y >= 0 && y < Screen::SCREEN_H); -
kyra/screen.h
diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur scummcvs/kyra/screen.h scummvm/kyra/screen.h
old new 110 110 static void decodeFrame4(const uint8 *src, uint8 *dst, uint32 dstSize); 111 111 static void decodeFrameDelta(uint8 *dst, const uint8 *src); 112 112 static void decodeFrameDeltaPage(uint8 *dst, const uint8 *src, int pitch); 113 113 void copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *dest); 114 114 115 int _charWidth; 115 116 int _charOffset; 116 117 int _curPage; -
kyra/script.h
diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur scummcvs/kyra/script.h scummvm/kyra/script.h
old new 19 19 * 20 20 */ 21 21 22 #ifndef SCRIPT_H23 #define SCRIPT_H22 #ifndef KYRASCRIPT_H 23 #define KYRASCRIPT_H 24 24 25 25 namespace Kyra { 26 26 // TODO: -
kyra/sprites.cpp
diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur scummcvs/kyra/sprites.cpp scummvm/kyra/sprites.cpp
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2004-2005 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * 19 */ 20 21 #include "common/stdafx.h" 22 #include "common/stream.h" 23 #include "common/util.h" 24 #include "common/system.h" 25 #include "kyra/screen.h" 26 #include "kyra/kyra.h" 27 #include "kyra/sprites.h" 28 #include "kyra/resource.h" 29 30 namespace Kyra { 31 32 Sprites::Sprites(KyraEngine *engine, OSystem *system) { 33 _engine = engine; 34 _res = engine->resource(); 35 _screen = engine->screen(); 36 _system = system; 37 _dat = 0; 38 _rnd = new Common::RandomSource(); 39 memset(_anims, 0, sizeof(Anim) * MAX_NUM_ANIMS); 40 41 _animDelay = 16; 42 } 43 44 Sprites::~Sprites() { 45 if ( _dat ) 46 delete[] _dat; 47 48 delete _rnd; 49 } 50 51 Sprite Sprites::getSprite(uint8 spriteID) { 52 assert( spriteID < MAX_NUM_SPRITES); 53 return _sprites[spriteID]; 54 } 55 56 void Sprites::drawSprites(uint8 srcPage, uint8 dstPage) { 57 for ( int i = 0; i < MAX_NUM_ANIMS; i++ ) { 58 if ( _anims[i].script == 0 ) 59 break; 60 61 if ( _anims[i].sprite >= 0 ) { 62 assert( _anims[i].sprite < MAX_NUM_SPRITES); 63 Sprite sprite = _sprites[ _anims[i].sprite ]; 64 65 //debug(1, "Drawing from X %i, Y %i, to X %i, Y %i, width %i, height %i, srcPage %i, dstPage %i", 66 // sprite.x, sprite.y, _anims[i].x, _anims[i].y, sprite.width, sprite.height, srcPage, dstPage); 67 68 _screen->copyRegion(sprite.x, sprite.y, _anims[i].x, _anims[i].y, sprite.width, sprite.height, srcPage, dstPage); 69 70 } 71 } 72 } 73 74 void Sprites::doAnims() { 75 uint32 currTime = _system->getMillis(); 76 77 for (int i = 0; i < MAX_NUM_ANIMS; i++) { 78 if ( _anims[i].script == 0 ) 79 break; 80 81 if (_anims[i].play == false ||_anims[i].nextRun != 0 && _anims[i].nextRun > currTime) 82 continue; 83 84 uint8 *data; 85 86 if (_anims[i].reentry == 0) { 87 data = _anims[i].script; 88 89 //debug(1, "---Start of anim script---"); 90 assert( READ_LE_UINT16(data) == 0xff86 ); 91 data += 2; 92 93 //debug(1, "Default X of sprite: %i", READ_LE_UINT16(data + 0x12) ); 94 _anims[i].x = READ_LE_UINT16(data + 0x12); 95 //debug(1, "Default Y of sprite: %i", READ_LE_UINT16(data + 0x16) ); 96 _anims[i].y = READ_LE_UINT16(data + 0x16); 97 98 //debug(1, "Anim %i data: 0h: %i, 2h: %i,4h: %i,6h: %i,8h: %i,ah: %i,ch: %i", i, READ_LE_UINT16(data + 0x0), 99 //READ_LE_UINT16(data + 0x2), READ_LE_UINT16(data + 0x4),READ_LE_UINT16(data + 0x6),READ_LE_UINT16(data + 0x8), 100 //READ_LE_UINT16(data + 0xa),READ_LE_UINT16(data + 0xc)); 101 102 //debug(1, "Anim %i data: eh: %i, 10h: %i,12h: %i,14h: %i,16h: %i,18h: %i,1ah: %i", i, READ_LE_UINT16(data + 0xe), 103 //READ_LE_UINT16(data + 0x10), READ_LE_UINT16(data + 0x12),READ_LE_UINT16(data + 0x14),READ_LE_UINT16(data + 0x16), 104 //READ_LE_UINT16(data + 0x18),READ_LE_UINT16(data + 0x1a)); 105 106 //debug(1, "Anim %i data: 1ch: %i, 1fh: %i,22h: %i,24h: %i,26h: %i,28h: %i,2ah: %i", i, READ_LE_UINT16(data + 0x1c), 107 //READ_LE_UINT16(data + 0x1f), READ_LE_UINT16(data + 0x22),READ_LE_UINT16(data + 0x24),READ_LE_UINT16(data + 0x26), 108 //READ_LE_UINT16(data + 0x28),READ_LE_UINT16(data + 0x2a)); 109 110 // TODO: Find out what the rest of this data (next 38h bytes) does. 111 data += 0x38; 112 } else { 113 data = _anims[i].reentry; 114 _anims[i].reentry = 0; 115 } 116 117 bool endLoop = false; 118 119 while (READ_LE_UINT16(data) != 0xff87 && !endLoop) { 120 assert( (data - _anims[i].script) < _anims[i].length ); 121 122 switch (READ_LE_UINT16(data)) { 123 case 0xff88 : 124 data += 2; 125 debug(9, "func: Set sprite image, and set flag0"); 126 debug(9, "Sprite index %i", READ_LE_UINT16(data)); 127 _anims[i].sprite = READ_LE_UINT16(data); 128 data += 2; 129 debug(9, "Unused %i", READ_LE_UINT16(data)); 130 data += 2; 131 debug(9, "X %i", READ_LE_UINT16(data)); 132 _anims[i].x = READ_LE_UINT16(data); 133 data += 2; 134 debug(9, "Y %i", READ_LE_UINT16(data)); 135 _anims[i].y = READ_LE_UINT16(data); 136 data += 2; 137 _anims[i].flag0 = true; 138 break; 139 140 case 0xff8d : 141 data += 2; 142 debug(9, "func: Set sprite image, and reset flag0"); 143 _anims[i].sprite = READ_LE_UINT16(data); 144 data += 2; 145 //debug(9, "Unused %i", READ_LE_UINT16(data)); 146 data += 2; 147 debug(9, "X %i", READ_LE_UINT16(data)); 148 _anims[i].x = READ_LE_UINT16(data); 149 data += 2; 150 debug(9, "Y %i", READ_LE_UINT16(data)); 151 _anims[i].y = READ_LE_UINT16(data); 152 data += 2; 153 _anims[i].flag0 = false; 154 break; 155 156 case 0xff8a : 157 data += 2; 158 debug(9, "func: Set time to wait"); 159 debug(9, "Time %i", READ_LE_UINT16(data)); 160 _anims[i].nextRun = _system->getMillis() + READ_LE_UINT16(data) * _animDelay; 161 data += 2; 162 break; 163 164 case 0xffb3 : 165 data += 2; 166 debug(9, "func: Set time to wait to random value"); 167 uint16 rndNr = READ_LE_UINT16(data) +_rnd->getRandomNumber( READ_LE_UINT16(data)+2); 168 debug(9, "Minimum time %i", READ_LE_UINT16(data)); 169 data += 2; 170 debug(9, "Maximum time %i", READ_LE_UINT16(data)); 171 data += 2; 172 _anims[i].nextRun = _system->getMillis() + rndNr * _animDelay; 173 break; 174 175 case 0xff8c : 176 data += 2; 177 debug(9, "func: Wait until wait time has elapsed"); 178 _anims[i].reentry = data; 179 endLoop = true; 180 //assert( _anims[i].nextRun > _system->getMillis()); 181 break; 182 183 case 0xff99 : 184 data += 2; 185 debug(1, "TODO func: Set value of animation property 32h to 1"); 186 break; 187 188 case 0xff9a : 189 data += 2; 190 debug(1, "TODO func: Set value of animation property 32h to 0"); 191 break; 192 193 case 0xff97 : 194 data += 2; 195 debug(9, "func: Set default X coordinate of sprite"); 196 debug(9, "X %i", READ_LE_UINT16(data)); 197 _anims[i].x = READ_LE_UINT16(data); 198 data += 2; 199 break; 200 201 case 0xff98 : 202 data += 2; 203 debug(9, "func: Set default Y coordinate of sprite"); 204 debug(9, "Y %i", READ_LE_UINT16(data)); 205 _anims[i].y = READ_LE_UINT16(data); 206 data += 2; 207 break; 208 209 case 0xff8b : 210 debug(9, "func: Jump to start of script section"); 211 //data = scriptStart; 212 _anims[i].nextRun = _system->getMillis(); 213 endLoop = true; 214 break; 215 216 case 0xff8e : 217 data += 2; 218 debug(9, "func: Begin for () loop"); 219 debug(9, "Iterations: %i", READ_LE_UINT16(data)); 220 _anims[i].loopsLeft = READ_LE_UINT16(data); 221 data += 2; 222 _anims[i].loopStart = data; 223 break; 224 225 case 0xff8f : 226 data += 2; 227 debug(9, "func: End for () loop"); 228 if ( _anims[i].loopsLeft > 0 ) { 229 _anims[i].loopsLeft--; 230 data = _anims[i].loopStart; 231 } 232 break; 233 234 case 0xff90 : 235 data += 2; 236 debug(9, "func: Set sprite image using default X and Y (and set flag0)"); 237 debug(9, "Sprite index %i", READ_LE_UINT16(data)); 238 _anims[i].sprite = READ_LE_UINT16(data); 239 _anims[i].flag0 = true; 240 data += 2; 241 break; 242 243 case 0xff91 : 244 data += 2; 245 debug(9, "func: Set sprite image using default X and Y (and reset flag0)"); 246 debug(9, "Sprite index %i", READ_LE_UINT16(data)); 247 _anims[i].sprite = READ_LE_UINT16(data); 248 _anims[i].flag0 = false; 249 data += 2; 250 break; 251 252 case 0xff92 : 253 data += 2; 254 debug(9, "func: Increase value of default X-coordinate"); 255 debug(9, "Increment %i", READ_LE_UINT16(data)); 256 _anims[i].x += READ_LE_UINT16(data); 257 data += 2; 258 break; 259 260 case 0xff93 : 261 data += 2; 262 debug(9, "func: Increase value of default Y-coordinate"); 263 debug(9, "Increment %i", READ_LE_UINT16(data)); 264 _anims[i].y += READ_LE_UINT16(data); 265 data += 2; 266 break; 267 268 case 0xff94 : 269 data += 2; 270 debug(9, "func: Decrease value of default X-coordinate"); 271 debug(9, "Decrement %i", READ_LE_UINT16(data)); 272 _anims[i].x -= READ_LE_UINT16(data); 273 data += 2; 274 break; 275 276 case 0xff95 : 277 data += 2; 278 debug(9, "func: Decrease value of default Y-coordinate"); 279 debug(9, "Decrement %i", READ_LE_UINT16(data)); 280 _anims[i].y -= READ_LE_UINT16(data); 281 data += 2; 282 break; 283 284 case 0xff96 : 285 data += 2; 286 debug(1, "TODO func: Set value of animation property 34h to 1(?)"); 287 debug(1, "Arg1 %i", READ_LE_UINT16(data)); 288 data += 2; 289 debug(1, "Arg2 %i", READ_LE_UINT16(data)); 290 data += 2; 291 break; 292 293 /* 294 case 0xff97 : 295 data += 2; 296 debug(1, "func: Set value of animation property 34h to 0"); 297 break; 298 */ 299 case 0xffad : 300 data += 2; 301 debug(1, "TODO func: Set Brandon's X coordinate"); 302 debug(1, "X %i", READ_LE_UINT16(data)); 303 data += 2; 304 break; 305 306 case 0xffae : 307 data += 2; 308 debug(1, "TODO func: Set Brandon's Y coordinate"); 309 debug(1, "Y %i", READ_LE_UINT16(data)); 310 data += 2; 311 break; 312 313 case 0xffaf : 314 data += 2; 315 debug(1, "TODO func: Set Brandon's X sprite"); 316 debug(1, "Sprite %i", READ_LE_UINT16(data)); 317 data += 2; 318 break; 319 320 case 0xffaa : 321 data += 2; 322 debug(1, "TODO func: Reset Brandon's sprite"); 323 break; 324 325 case 0xffab : 326 data += 2; 327 debug(1, "TODO func: Update Brandon's sprite"); 328 break; 329 330 case 0xffb0 : 331 data += 2; 332 debug(1, "TODO func: Play sound"); 333 debug(1, "Sound index %i", READ_LE_UINT16(data)); 334 data += 2; 335 break; 336 337 case 0xffb1 : 338 data += 2; 339 debug(1, "TODO func: Set unknown global bit"); 340 break; 341 342 case 0xffb2 : 343 data += 2; 344 debug(1, "TODO func: Reset unknown global bit"); 345 break; 346 347 case 0xffb4 : 348 data += 2; 349 debug(1, "TODO func: Play (at random) a certain sound at a certain percentage of time"); 350 debug(1, "Sound index %i", READ_LE_UINT16(data)); 351 data += 2; 352 debug(1, "Percentage %i", READ_LE_UINT16(data)); 353 data += 2; 354 break; 355 356 default : 357 debug(1, "Unsupported anim command %X", READ_LE_UINT16(data)); 358 //endLoop = true; 359 data += 1; 360 } 361 } 362 363 if ( READ_LE_UINT16(data) == 0xff87 ) 364 _anims[i].play = false; 365 366 //debug(1, "---End of anim script---"); 367 } 368 } 369 370 void Sprites::loadDAT(const char *filename) { 371 debug(9, "Sprites::loadDat('%s')", filename); 372 uint32 fileSize; 373 uint8 spritesLoaded = 0; 374 375 if (_dat) 376 delete[] _dat; 377 378 _dat = _res->fileData(filename, &fileSize); 379 380 memset(_anims, 0, sizeof(Anim) * MAX_NUM_ANIMS); 381 uint8 nextAnim = 0; 382 383 assert(fileSize > 0x6d); 384 385 memcpy(_screen->_currentPalette + 745 - 0x3d, _dat + 0x17, 0x3d); 386 _screen->setScreenPalette(_screen->_currentPalette); 387 uint8 *data = _dat + 0x6b; 388 389 uint16 length = READ_LE_UINT16(data); 390 data += 2; 391 392 //debug(1, "DAT body length: %i, filesize %i, current spot %i", length, fileSize, data - _dat); 393 394 if (length > 2) { 395 assert( length < fileSize); 396 uint8 * start = data; 397 398 while (1) { 399 if (((uint16)(data - _dat) >= fileSize) || (data - start) >= length) 400 break; 401 402 if (READ_LE_UINT16(data) == 0xff83) { 403 //debug(1, "Body section end."); 404 data += 2; 405 break; 406 } 407 408 switch (READ_LE_UINT16(data)) { 409 case 0xff81 : 410 data += 2; 411 //debug(1, "Body section start"); 412 break; 413 case 0xff82 : 414 data += 2; 415 //debug(1, "Unknown 0xff82 section"); 416 break; 417 case 0xff84 : 418 data += 2; 419 while (READ_LE_UINT16(data) != 0xff85) { 420 uint16 spriteNum = READ_LE_UINT16(data); 421 //debug(1, "Spritenum: %i", spriteNum); 422 assert( spriteNum < MAX_NUM_SPRITES ); 423 data += 2; 424 _sprites[spriteNum].x = READ_LE_UINT16(data) * 8; 425 data += 2; 426 _sprites[spriteNum].y = READ_LE_UINT16(data); 427 data += 2; 428 _sprites[spriteNum].width = READ_LE_UINT16(data) * 8; 429 data += 2; 430 _sprites[spriteNum].height = READ_LE_UINT16(data); 431 data += 2; 432 433 spritesLoaded++; 434 //debug(1, "Got sprite index: %i", spriteNum); 435 //debug(1, "X: %i", _sprites[spriteNum].x); 436 //debug(1, "Y: %i", _sprites[spriteNum].y); 437 //debug(1, "Width: %i", _sprites[spriteNum].width); 438 //debug(1, "Height: %i", _sprites[spriteNum].height); 439 } 440 //debug(1, "End of sprite images."); 441 data += 2; 442 break; 443 case 0xff86 : 444 assert(nextAnim < MAX_NUM_ANIMS); 445 _anims[nextAnim].script = data; 446 _anims[nextAnim].sprite = -1; 447 _anims[nextAnim].play = true; 448 uint8 *animstart = data; 449 data += 2; 450 451 while (READ_LE_UINT16(data) != 0xff87) { 452 assert( (uint16)(data - _dat) < fileSize ); 453 data += 2; 454 } 455 _anims[nextAnim].length = data - animstart; 456 //debug(1, "Found an anim script of length %i!", _anims[nextAnim].length); 457 nextAnim++; 458 data += 2; 459 break; 460 461 default : 462 debug(1, "Unknown code in DAT file: %x", READ_LE_UINT16(data)); 463 data +=2; 464 } 465 } 466 } else 467 data += 2; 468 469 debug(1, "Room DAT file loaded. Found %i sprite and %i animation scripts.", spritesLoaded, nextAnim); 470 471 //debug(1, "Remainder after script: %i", fileSize - (data - _dat)); 472 assert(fileSize - (data - _dat) == 0xc); 473 474 //TODO: Read in character entry coords here 475 } 476 477 } // end of namespace Kyra -
kyra/sprites.h
diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur scummcvs/kyra/sprites.h scummvm/kyra/sprites.h
old new 1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2004-2005 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * 19 */ 20 21 #ifndef KYRASPRITES_H 22 #define KYRASPRITES_H 23 24 namespace Kyra { 25 26 #define MAX_NUM_SPRITES 50 27 #define MAX_NUM_ANIMS 11 28 29 struct Sprite { 30 uint16 x; 31 uint16 y; 32 uint16 width; 33 uint16 height; 34 }; 35 36 struct Anim { 37 uint8 *script; 38 uint16 length; 39 uint16 x; 40 uint16 y; 41 bool flag0; 42 int8 sprite; 43 uint8 *loopStart; 44 uint16 loopsLeft; 45 uint8 *reentry; 46 uint32 nextRun; 47 bool play; 48 }; 49 50 class Sprites { 51 52 public: 53 54 Sprites(KyraEngine *engine, OSystem *system); 55 ~Sprites(); 56 57 void doAnims(); 58 void loadDAT(const char* filename); 59 Sprite getSprite(uint8 spriteID); 60 void drawSprites(uint8 srcPage, uint8 dstPage); 61 62 protected: 63 KyraEngine* _engine; 64 Resource* _res; 65 OSystem* _system; 66 Screen* _screen; 67 Sprite _sprites[MAX_NUM_SPRITES]; 68 uint8 *_dat; 69 Anim _anims[MAX_NUM_ANIMS]; 70 Common::RandomSource *_rnd; 71 uint8 _animDelay; 72 }; 73 74 } // end of namespace Kyra 75 76 #endif 77 -
kyra/staticres.cpp
diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur scummcvs/kyra/staticres.cpp scummvm/kyra/staticres.cpp
old new 467 467 468 468 const int KyraEngine::_xmidiFilesCount = ARRAYSIZE(_xmidiFiles); 469 469 470 void KyraEngine::setupRooms() { 471 memset(_rooms, 0, sizeof(_rooms)); 472 473 // Just a few sample rooms, most with sprite anims. 474 _rooms[0].filename = "gemcut"; 475 _rooms[1].filename = "arch"; 476 _rooms[2].filename = "sorrow"; 477 _rooms[3].filename = "emcav"; 478 _rooms[4].filename = "extpot"; 479 _rooms[5].filename = "spell"; 480 _rooms[6].filename = "song"; 481 _rooms[7].filename = "belroom"; 482 _rooms[8].filename = "kyragem"; 483 _rooms[9].filename = "lephole"; 484 _rooms[10].filename = "sickwil"; 485 _rooms[11].filename = "temple"; 486 487 } 488 489 const uint16 KyraEngine::_cursors[][4] = { 490 // In mouse.cps: X, Y, width, height 491 {0, 0, 8, 10}, // 0: Regular cursor 492 {80, 18, 15, 10}, // 1: Up arrow 493 {95, 18, 15, 10}, // 2: Right arrow 494 {110, 18, 15, 10}, // 3: Down arrow 495 {125, 18, 15, 10}, // 4: Left arrow 496 {140, 18, 15, 10} // 5: Stopsign 497 }; 498 470 499 } // End of namespace Kyra