[Scummvm-cvs-logs] CVS: scummvm script_v1.cpp,1.114,1.115
Max Horn
fingolfin at users.sourceforge.net
Mon Jun 24 05:33:03 CEST 2002
Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv7386
Modified Files:
script_v1.cpp
Log Message:
implement save/load-string ops (used only by Indy 4 IQ system it seems?)
Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script_v1.cpp,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- script_v1.cpp 4 Jun 2002 23:32:53 -0000 1.114
+++ script_v1.cpp 24 Jun 2002 12:32:32 -0000 1.115
@@ -2032,21 +2032,48 @@
case 13:{ /* save-string */
char buf[256], *s;
+ FILE *out;
+
a = getVarOrDirectByte(0x80);
s = buf;
while ((*s++ = fetchScriptByte()))
;
- warning("roomops:13 save-string(%d,\"%s\") not implemented", a, buf);
+
+ // Use buf as filename
+ out = fopen(buf, "wb");
+ if (out) {
+ byte *ptr;
+ ptr = getResourceAddress(rtString, a);
+ fwrite(ptr, getStringLen(ptr)+1, 1, out);
+ fclose(out);
+ }
+ break;
+ }
+ case 14:{ /* load-string */
+ char buf[256], *s;
+ FILE *in;
+
+ a = getVarOrDirectByte(0x80);
+ s = buf;
+ while ((*s++ = fetchScriptByte()))
+ ;
+
+ // Use buf as filename
+ in = fopen(buf, "rb");
+ if (in) {
+ byte *ptr;
+ int len;
+ fseek(in, 0, SEEK_END);
+ len = ftell(in); // Determine file size
+ ptr = (byte *)calloc(len+1, 1); // Create a zero terminated buffer
+ fseek(in, 0, SEEK_SET);
+ fread(ptr, len, 1, in); // Read in the data
+ fclose(in);
+ loadPtrToResource(rtString, a, ptr);
+ free(ptr);
+ }
break;
}
- case 14: /* load-string */
- char buf[256], *s;
- a = getVarOrDirectByte(0x80);
- s = buf;
- while ((*s++ = fetchScriptByte()))
- ;
- warning("roomops:14 load-string(%d,\"%s\") not implemented", a, buf);
- break;
case 15: /* palmanip */
a = getVarOrDirectByte(0x80);
_opcode = fetchScriptByte();
More information about the Scummvm-git-logs
mailing list