mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
GLK: SCOTT: Implement decrunchC64
This commit is contained in:
committed by
Eugene Sandulenko
parent
a2ef20d0d7
commit
9f7a9a4493
@@ -252,6 +252,7 @@ MODULE_OBJS := \
|
||||
scott/ring_buffer.o \
|
||||
scott/saga_draw.o \
|
||||
scott/scott.o \
|
||||
scott/unp64/unp64.o \
|
||||
tads/os_banners.o \
|
||||
tads/os_buffer.o \
|
||||
tads/os_glk.o \
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
#include "glk/scott/c64_checksums.h"
|
||||
#include "glk/scott/definitions.h"
|
||||
#include "glk/scott/disk_image.h"
|
||||
#include "glk/scott/game_info.h"
|
||||
#include "glk/scott/resource.h"
|
||||
#include "glk/scott/saga_draw.h"
|
||||
#include "glk/scott/unp64/unp64_interface.h"
|
||||
|
||||
namespace Glk {
|
||||
namespace Scott {
|
||||
@@ -239,9 +243,85 @@ int detectC64(uint8_t **sf, size_t *extent) {
|
||||
return decrunchC64(sf, extent, g_C64Registry[index]);
|
||||
}
|
||||
|
||||
int decrunchC64(uint8_t **sf, size_t *extent, C64Rec entry) {
|
||||
size_t copyData(size_t dest, size_t source, uint8_t** data, size_t dataSize, size_t bytesToMove) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int decrunchC64(uint8_t **sf, size_t *extent, C64Rec record) {
|
||||
uint8_t *uncompressed = nullptr;
|
||||
_G(_fileLength) = *extent;
|
||||
|
||||
size_t decompressedLength = *extent;
|
||||
|
||||
uncompressed = new uint8_t[0xffff];
|
||||
|
||||
char *switches[3];
|
||||
int numSwitches = 0;
|
||||
|
||||
if (record._switches != nullptr) {
|
||||
char string[100];
|
||||
strcpy(string, record._switches);
|
||||
switches[numSwitches] = strtok(string, " ");
|
||||
|
||||
while (switches[numSwitches] != nullptr)
|
||||
switches[++numSwitches] = strtok(nullptr, " ");
|
||||
}
|
||||
|
||||
size_t result = 0;
|
||||
|
||||
for (int i = 1; i <= record._decompressIterations; i++) {
|
||||
/* We only send switches on the iteration specified by parameter */
|
||||
if (i == record._parameter && record._switches != nullptr) {
|
||||
result = unp64(_G(_entireFile), _G(_fileLength), uncompressed, &decompressedLength, switches, numSwitches);
|
||||
} else
|
||||
result = unp64(_G(_entireFile), _G(_fileLength), uncompressed, &decompressedLength, nullptr, 0);
|
||||
if (result) {
|
||||
if (_G(_entireFile) != nullptr)
|
||||
delete[] _G(_entireFile);
|
||||
_G(_entireFile) = new uint8_t[decompressedLength];
|
||||
memcpy(_G(_entireFile), uncompressed, decompressedLength);
|
||||
_G(_fileLength) = decompressedLength;
|
||||
} else {
|
||||
delete[] uncompressed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < NUMGAMES; i++) {
|
||||
if (g_games[i]._gameID == record._id) {
|
||||
delete _G(_game);
|
||||
_G(_game) = &g_games[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_G(_game)->_title == nullptr) {
|
||||
error("decrunchC64: Game not found");
|
||||
}
|
||||
|
||||
int offset;
|
||||
|
||||
DictionaryType dictype = getId(&offset);
|
||||
if (dictype != _G(_game)->_dictionary) {
|
||||
error("decrunchC64: Wrong game?");
|
||||
}
|
||||
|
||||
if (!tryLoading(*_G(_game), offset, 0)) {
|
||||
error("decrunchC64: Game could not be read");
|
||||
}
|
||||
|
||||
if (record._copySource != 0) {
|
||||
result = copyData(record._copyDest, record._copySource, sf, *extent, record._copySize);
|
||||
if (result) {
|
||||
*extent = result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(_G(_game)->_subType & MYSTERIOUS))
|
||||
sagaSetup(record._imgOffset);
|
||||
|
||||
return CURRENT_GAME;
|
||||
}
|
||||
|
||||
} // End of namespace Scott
|
||||
} // End of namespace Glk
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glk/scott/unp64/unp64.h"
|
||||
#include "glk/scott/types.h"
|
||||
|
||||
namespace Glk {
|
||||
namespace Scott {
|
||||
|
||||
int unp64(uint8_t* compressed, size_t length, uint8_t* destinationBuffer, size_t* finalLength, char* settings[], int numSettings) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // End of namespace Scott
|
||||
} // End of namespace Glk
|
||||
@@ -0,0 +1,32 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GLK_SCOTT_UNP64_H
|
||||
#define GLK_SCOTT_UNP64_H
|
||||
|
||||
namespace Glk {
|
||||
namespace Scott {
|
||||
|
||||
|
||||
} // End of namespace Scott
|
||||
} // End of namespace Glk
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GLK_SCOTT_UNP64_INTERFACE_H
|
||||
#define GLK_SCOTT_UNP64_INTERFACE_H
|
||||
|
||||
#include "glk/scott/types.h"
|
||||
|
||||
namespace Glk {
|
||||
namespace Scott {
|
||||
|
||||
int unp64(uint8_t *compressed, size_t length, uint8_t *destinationBuffer, size_t *finalLength, char *settings[], int numSettings);
|
||||
|
||||
} // End of namespace Scott
|
||||
} // End of namespace Glk
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user