aboutsummaryrefslogtreecommitdiff
path: root/sky
diff options
context:
space:
mode:
authorRobert Göffringmann2003-05-28 20:55:25 +0000
committerRobert Göffringmann2003-05-28 20:55:25 +0000
commit765366df6ce76a2687e672ec8cb55a70e6ebb7ba (patch)
tree74b3e6437d4205113112f34751bb8c2c17b4ed98 /sky
parent1f70da01556164c5b39bb0e804e2c919dd7b3c83 (diff)
downloadscummvm-rg350-765366df6ce76a2687e672ec8cb55a70e6ebb7ba.tar.gz
scummvm-rg350-765366df6ce76a2687e672ec8cb55a70e6ebb7ba.tar.bz2
scummvm-rg350-765366df6ce76a2687e672ec8cb55a70e6ebb7ba.zip
Screen *kinda* works now.
Though I wonder what the menu sprite is doing on the mainscreen, now. ;) svn-id: r8059
Diffstat (limited to 'sky')
-rw-r--r--sky/disk.cpp90
-rw-r--r--sky/disk.h11
-rw-r--r--sky/logic.cpp11
-rw-r--r--sky/screen.cpp48
-rw-r--r--sky/sky.cpp3
5 files changed, 133 insertions, 30 deletions
diff --git a/sky/disk.cpp b/sky/disk.cpp
index 61f45b05a8..5c59330db8 100644
--- a/sky/disk.cpp
+++ b/sky/disk.cpp
@@ -57,6 +57,9 @@ SkyDisk::SkyDisk(char *gameDataPath) {
_dataDiskHandle->open(dataFilename, _gameDataPath);
if (_dataDiskHandle->isOpen() == false)
error("Error opening %s%s!\n", _gameDataPath, dataFilename);
+
+ memset(_buildList, 0, 60 * 2);
+ memset(_loadedFilesList, 0, 60 * 4);
}
SkyDisk::~SkyDisk(void) {
@@ -254,6 +257,93 @@ uint8 *SkyDisk::getFileInfo(uint16 fileNr) {
return (uint8 *)NULL;
}
+void SkyDisk::fnCacheChip(uint32 list) {
+
+ // fnCacheChip is called after fnCacheFast
+ uint16 cnt = 0;
+ while (_buildList[cnt]) cnt++;
+ uint16 *fList = (uint16*)SkyState::fetchCompact(list);
+ uint16 fCnt = 0;
+ do {
+ _buildList[cnt + fCnt] = fList[fCnt];
+ fCnt++;
+ } while (fList[fCnt-1]);
+ fnCacheFiles();
+}
+
+void SkyDisk::fnCacheFast(uint32 list) {
+
+ if (list == 0) return;
+ uint8 cnt = 0;
+ uint16 *fList = (uint16*)SkyState::fetchCompact(list);
+ do {
+ _buildList[cnt] = fList[cnt];
+ cnt++;
+ } while (fList[cnt-1]);
+}
+
+void SkyDisk::fnCacheFiles(void) {
+
+ // call trash_all_fx
+ uint16 lCnt, bCnt, targCnt;
+ targCnt = lCnt = 0;
+ bool found;
+ while (_loadedFilesList[lCnt]) {
+ bCnt = 0;
+ found = false;
+ while (_buildList[bCnt] && (!found)) {
+ if ((_buildList[bCnt] & 0x7FFF) == _loadedFilesList[lCnt]) found = true;
+ else bCnt++;
+ }
+ if (found) {
+ _loadedFilesList[targCnt] = _loadedFilesList[lCnt];
+ targCnt++;
+ } else {
+ free(SkyState::_itemList[_loadedFilesList[lCnt]]);
+ SkyState::_itemList[_loadedFilesList[lCnt]] = NULL;
+ }
+ lCnt++;
+ }
+ _loadedFilesList[targCnt] = 0; // mark end of list
+ bCnt = 0;
+ while (_buildList[bCnt]) {
+ if ((_buildList[bCnt] & 0x7FF) == 0x7FF) {
+ // amiga dummy files
+ bCnt++;
+ continue;
+ }
+ lCnt = 0;
+ found = false;
+ while (_loadedFilesList[lCnt] && (!found)) {
+ if (_loadedFilesList[lCnt] == (_buildList[bCnt] & 0x7FFF)) found = true;
+ lCnt++;
+ }
+ if (found) {
+ bCnt++;
+ continue;
+ }
+ // ok, we really have to load the file.
+ _loadedFilesList[targCnt] = _buildList[bCnt];
+ targCnt++;
+ _loadedFilesList[targCnt] = 0;
+ SkyState::_itemList[_buildList[bCnt] & 2047] = (void**)loadFile(_buildList[bCnt] & 0x7FFF, NULL);
+ bCnt++;
+ }
+ _buildList[0] = 0;
+}
+
+void SkyDisk::fnFlushBuffers(void) {
+
+ // dump all loaded sprites
+ uint8 lCnt = 0;
+ while (_loadedFilesList[lCnt]) {
+ free(SkyState::_itemList[_loadedFilesList[lCnt] & 2047]);
+ SkyState::_itemList[_loadedFilesList[lCnt] & 2047] = 0;
+ lCnt++;
+ }
+ _loadedFilesList[0] = 0;
+}
+
void SkyDisk::dumpFile(uint16 fileNr) {
char buf[128];
File out;
diff --git a/sky/disk.h b/sky/disk.h
index 38801ad8cf..920ed51676 100644
--- a/sky/disk.h
+++ b/sky/disk.h
@@ -44,7 +44,15 @@ public:
uint32 determineGameVersion();
uint32 _lastLoadedFileSize;
+
+ void fnCacheFast(uint32 list);
+ void fnCacheChip(uint32 list);
+ void fnCacheFiles(void);
+ void fnFlushBuffers(void);
+
protected:
+
+
prefFile *_prefRoot;
uint8 *givePrefetched(uint16 fileNr, uint32 *fSize);
@@ -57,8 +65,7 @@ protected:
uint8 *_dinnerTableArea, *_fixedDest, *_fileDest, *_compDest;
uint32 _fileFlags, _fileOffset, _fileSize, _decompSize, _compFile;
uint16 _buildList[MAX_FILES_IN_LIST];
- uint32 _loadedFileList[MAX_FILES_IN_LIST];
-
+ uint32 _loadedFilesList[MAX_FILES_IN_LIST];
File *_dataDiskHandle;
File *_dnrHandle;
};
diff --git a/sky/logic.cpp b/sky/logic.cpp
index 3b17128dc7..ef662b21ce 100644
--- a/sky/logic.cpp
+++ b/sky/logic.cpp
@@ -1104,12 +1104,16 @@ script:
}
bool SkyLogic::fnCacheChip(uint32 a, uint32 b, uint32 c) {
- warning("Stub: fnCacheChip");
+ //warning("Stub: fnCacheChip");
+ printf("SkyDisk::fnCacheChip(%d);\n",a);
+ _skyDisk->fnCacheChip(a);
return true;
}
bool SkyLogic::fnCacheFast(uint32 a, uint32 b, uint32 c) {
- warning("Stub: fnCacheFast");
+ //warning("Stub: fnCacheFast");
+ printf("SkyDisk::fnCacheFast(%d);\n",a);
+ _skyDisk->fnCacheFast(a);
return true;
}
@@ -1851,7 +1855,8 @@ bool SkyLogic::fnMiniLoad(uint32 a, uint32 b, uint32 c) {
}
bool SkyLogic::fnFlushBuffers(uint32 a, uint32 b, uint32 c) {
- error("Stub: fnFlushBuffers");
+ _skyDisk->fnFlushBuffers();
+ return true;
}
bool SkyLogic::fnFlushChip(uint32 a, uint32 b, uint32 c) {
diff --git a/sky/screen.cpp b/sky/screen.cpp
index 1599e30b2c..afb809e470 100644
--- a/sky/screen.cpp
+++ b/sky/screen.cpp
@@ -182,28 +182,24 @@ void SkyScreen::flip(void) {
uint8 *backPos = _backScreen;
for (uint8 cnty = 0; cnty < GRID_Y; cnty++) {
for (uint8 cntx = 0; cntx < GRID_X; cntx++) {
- if (_gameGrid[cnty * GRID_X +cntx] & 1) {
- _gameGrid[cnty * GRID_X +cntx] &= ~1;
- uint8 *saveBackY = backPos;
- uint8 *saveScreenY = screenPos;
+ if (_gameGrid[cnty * GRID_X + cntx] & 1) {
+ _gameGrid[cnty * GRID_X + cntx] &= ~1;
+ uint8 *copySrc = backPos;
+ uint8 *copyDest = screenPos;
for (uint8 gridLineCnt = 0; gridLineCnt < GRID_H; gridLineCnt++) {
- memcpy(screenPos, backPos, GRID_W);
- screenPos += GAME_SCREEN_WIDTH;
- backPos += GAME_SCREEN_WIDTH;
+ memcpy(copyDest, copySrc, GRID_W);
+ copySrc += GAME_SCREEN_WIDTH;
+ copyDest += GAME_SCREEN_WIDTH;
}
- backPos = saveBackY + GRID_W;
- screenPos = saveBackY + GRID_W;
- } else {
- backPos += GRID_W;
- screenPos += GRID_W;
}
+ backPos += GRID_W;
+ screenPos += GRID_W;
}
screenPos += (GRID_H - 1) * GAME_SCREEN_WIDTH;
backPos += (GRID_H - 1) * GAME_SCREEN_WIDTH;
}
// mouse_flag &= ~MF_NO_UPDATE;
// _skyMouse->restoreDataToBackScreen();
- showScreen(_backScreen);
}
void SkyScreen::fnDrawScreen(uint32 palette, uint32 scroll) {
@@ -214,8 +210,8 @@ void SkyScreen::fnDrawScreen(uint32 palette, uint32 scroll) {
recreate();
spriteEngine();
flip();
+ showScreen(_currentScreen);
fnFadeUp(palette, scroll);
- showScreen(_backScreen);
}
void SkyScreen::fnFadeDown(uint32 scroll) {
@@ -429,16 +425,21 @@ void SkyScreen::sortSprites(void) {
StSortList sortList[30];
uint32 currDrawList = DRAW_LIST_NO;
+ uint32 loadDrawList;
+
bool nextDrawList = false;
while (SkyLogic::_scriptVariables[currDrawList]) {
// big_sort_loop
uint32 spriteCnt = 0;
+ loadDrawList = SkyLogic::_scriptVariables[currDrawList];
+ currDrawList++;
+
do { // a_new_draw_list:
- uint16 *drawListData = (uint16*)SkyState::fetchCompact(SkyLogic::_scriptVariables[currDrawList]);
+ uint16 *drawListData = (uint16*)SkyState::fetchCompact(loadDrawList);
nextDrawList = false;
while ((!nextDrawList) && (drawListData[0])) {
if (drawListData[0] == 0xFFFF) {
- currDrawList = drawListData[1];
+ loadDrawList = drawListData[1];
nextDrawList = true;
} else {
// process_this_id:
@@ -463,7 +464,7 @@ void SkyScreen::sortSprites(void) {
} while (nextDrawList);
// made_list:
if (spriteCnt > 1) { // bubble sort
- for (uint32 cnt1 = 0; cnt1 < spriteCnt; cnt1++)
+ for (uint32 cnt1 = 0; cnt1 < spriteCnt - 1; cnt1++)
for (uint32 cnt2 = cnt1 + 1; cnt2 < spriteCnt; cnt2++)
if (sortList[cnt1].yCood <= sortList[cnt2].yCood) {
StSortList tmp;
@@ -482,7 +483,9 @@ void SkyScreen::sortSprites(void) {
drawSprite((uint8*)sortList[cnt].sprite, sortList[cnt].compact);
if (sortList[cnt].compact->status & 8) vectorToGame(0x81);
else vectorToGame(1);
- if (sortList[cnt].compact->status & 0x200) verticalMask();
+ if (sortList[cnt].compact->status & 0x200) {
+ verticalMask();
+ }
}
}
}
@@ -517,7 +520,6 @@ void SkyScreen::doSprites(uint8 layer) {
uint8 *toBeDrawn = (uint8*)SkyState::fetchItem(spriteData->frame >> 6);
drawSprite(toBeDrawn, spriteData);
if (layer == FORE) verticalMask();
-
if (spriteData->status & 8) vectorToGame(0x81);
else vectorToGame(1);
}
@@ -597,10 +599,9 @@ void SkyScreen::drawSprite(uint8 *spriteInfo, Compact *sprCompact) {
return ;
}
for (uint8 cnty = 0; cnty < _sprHeight; cnty++) {
- spriteData += _maskX1;
for (uint8 cntx = 0; cntx < _sprWidth; cntx++)
- if (spriteData[cntx]) screenPtr[cntx] = spriteData[cntx];
- spriteData += _maskX2;
+ if (spriteData[cntx + _maskX1]) screenPtr[cntx] = spriteData[cntx + _maskX1];
+ spriteData += _sprWidth;
screenPtr += GAME_SCREEN_WIDTH;
}
// Convert the sprite coordinate/size values to blocks for vertical mask and/or vector to game
@@ -618,7 +619,8 @@ void SkyScreen::drawSprite(uint8 *spriteInfo, Compact *sprCompact) {
void SkyScreen::vectorToGame(uint8 gridVal) {
- uint8 *trgGrid = _gameGrid + _sprY * GRID_X +_sprX; // why?!?!
+ if (_sprWidth == 0) return ;
+ uint8 *trgGrid = _gameGrid + _sprY * GRID_X +_sprX;
for (uint32 cnty = 0; cnty < _sprHeight; cnty++) {
for (uint32 cntx = 0; cntx < _sprWidth; cntx++)
trgGrid[cntx] |= gridVal;
diff --git a/sky/sky.cpp b/sky/sky.cpp
index 13a3b7409e..0aaf1d9d0f 100644
--- a/sky/sky.cpp
+++ b/sky/sky.cpp
@@ -203,10 +203,9 @@ void SkyState::initItemList() {
void SkyState::loadBase0(void) {
- //fnEnterSection(0);
+ _skyLogic->fnEnterSection(0, 0, 0);
_skyMusic->startMusic(2);
_skyGrid->loadGrids();
-
}
void SkyState::loadFixedItems(void) {