diff options
author | Travis Howell | 2004-08-25 12:48:47 +0000 |
---|---|---|
committer | Travis Howell | 2004-08-25 12:48:47 +0000 |
commit | 468404ab3391958a9dbb8d162a2b4490365e9a8d (patch) | |
tree | 029fe1a7bf6ed2496c2cb4402a1712035f86b85e /scumm | |
parent | daa7d32b75c56872253056bf4e670c4fafaca74b (diff) | |
download | scummvm-rg350-468404ab3391958a9dbb8d162a2b4490365e9a8d.tar.gz scummvm-rg350-468404ab3391958a9dbb8d162a2b4490365e9a8d.tar.bz2 scummvm-rg350-468404ab3391958a9dbb8d162a2b4490365e9a8d.zip |
Add some file opcode difference for HE 7.2
svn-id: r14752
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/intern.h | 5 | ||||
-rw-r--r-- | scumm/script_v72he.cpp | 121 |
2 files changed, 122 insertions, 4 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index 649b5325e9..e70b82f0c7 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -675,6 +675,8 @@ protected: void redimArray(int arrayId, int newDim2start, int newDim2end, int newDim1start, int newDim1end, int type); void shuffleArray(int num, int minIdx, int maxIdx); + int readFileToArray(int slot, int32 size); + void writeFileFromArray(int slot, int resID); void copyScriptString(byte *dst); @@ -700,6 +702,9 @@ protected: void o72_dim2dimArray(); void o72_shuffle(); void o72_jumpToScript(); + void o72_openFile(); + void o72_readFile(); + void o72_writeFile(); void o72_findAllObjects(); void o72_getPixel(); void o72_pickVarRandom(); diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index b952fbd87d..ab9d5d3a8f 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -318,10 +318,10 @@ void ScummEngine_v72he::setupOpcodes() { /* D8 */ OPCODE(o6_isRoomScriptRunning), OPCODE(o6_closeFile), - OPCODE(o6_openFile), - OPCODE(o6_readFile), + OPCODE(o72_openFile), + OPCODE(o72_readFile), /* DC */ - OPCODE(o6_writeFile), + OPCODE(o72_writeFile), OPCODE(o72_findAllObjects), OPCODE(o6_deleteFile), OPCODE(o6_rename), @@ -516,7 +516,8 @@ void ScummEngine_v72he::readArrayFromIndexFile() { void ScummEngine_v72he::copyScriptString(byte *dst) { int a = pop(); int b = 0; - if (a == -1) { + // FIXME Should only be -1 + if (a == 1 || a == -1) { int len = resStrLen(_stringBuffer) + 1; while (len--) *dst++ = _stringBuffer[b++]; @@ -855,6 +856,118 @@ void ScummEngine_v72he::o72_jumpToScript() { runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args); } +void ScummEngine_v72he::o72_openFile() { + int mode, slot, l, r; + byte filename[100]; + + copyScriptString(filename); + printf("File %s\n", filename); + + for (r = strlen((char*)filename); r != 0; r--) { + if (filename[r - 1] == '\\') + break; + } + + mode = pop(); + slot = -1; + for (l = 0; l < 17; l++) { + if (_hFileTable[l].isOpen() == false) { + slot = l; + break; + } + } + + if (slot != -1) { + if (mode == -1) + _hFileTable[slot].open((char*)filename + r, File::kFileReadMode); + else if (mode == -2) + _hFileTable[slot].open((char*)filename + r, File::kFileWriteMode); + else + error("o6_openFile(): wrong open file mode %d", mode); + + if (_hFileTable[slot].isOpen() == false) + slot = -1; + + } + push(slot); +} + +int ScummEngine_v72he::readFileToArray(int slot, int32 size) { + if (size == 0) + size = _hFileTable[slot].size() - _hFileTable[slot].pos(); + + writeVar(0, 0); + + ArrayHeader *ah = defineArray(0, kByteArray, 0, 0, 0, size); + _hFileTable[slot].read(ah->data, size); + + return readVar(0); +} + +void ScummEngine_v72he::o72_readFile() { + int slot, val; + int32 size; + int subOp = fetchScriptByte(); + + switch (subOp) { + case 4: + slot = pop(); + val = _hFileTable[slot].readByte(); + push(val); + break; + case 5: + slot = pop(); + val = _hFileTable[slot].readUint16LE(); + push(val); + break; + case 6: + slot = pop(); + val = _hFileTable[slot].readUint32LE(); + push(val); + break; + case 8: + fetchScriptByte(); + size = pop(); + slot = pop(); + val = readFileToArray(slot, size); + push(val); + break; + default: + error("default case %d", subOp); + } +} + +void ScummEngine_v72he::writeFileFromArray(int slot, int resID) { + ArrayHeader *ah = (ArrayHeader *)getResourceAddress(rtString, resID); + int32 size = (FROM_LE_32(ah->dim1end) - FROM_LE_32(ah->dim1start) + 1) * + (FROM_LE_32(ah->dim2end) - FROM_LE_32(ah->dim2start) + 1); + + _hFileTable[slot].write(ah->data, size); +} + +void ScummEngine_v72he::o72_writeFile() { + int16 resID = pop(); + int slot = pop(); + int subOp = fetchScriptByte(); + + switch (subOp) { + case 4: + _hFileTable[slot].writeByte(resID); + break; + case 5: + _hFileTable[slot].writeUint16LE(resID); + break; + case 6: + _hFileTable[slot].writeUint32LE(resID); + break; + case 8: + writeFileFromArray(slot, resID); + break; + default: + error("default case %d", subOp); + } +} + void ScummEngine_v72he::o72_findAllObjects() { int room = pop(); int i = 1; |