On 4 Dec 2006, at 12:44, Alban Bedel wrote:

On Fri, 1 Dec 2006 14:30:05 -0800
"Jesse McGrew" <[EMAIL PROTECTED]> wrote:

On 12/1/06, Alban Bedel <[EMAIL PROTECTED]> wrote:
Some more compiler support for strings could help here too. The code
gets repetitive having to type this all the time:

   sentence = 0;
   sentence[0] = "...";
   dialogAdd(sentence);

(This compiles, but crashes the VM: sentence = "...";)

If the compiler allocated some of the array addresses for its own use,
we could directly use strings (or lists?) in script calls, and they'd
be passed via temporary arrays:

   dialogAdd("foo bar baz");
   // same as: TEMP1 = 0; TEMP1[0] = "foo bar baz"; dialogAdd(TEMP1);

I thought a bit about that too. However it probably won't be trivial.
Currently there is no checks done on the arguments passed to scripts.
There is 2 reasons, first there is only one internal type (int), second
if some arguments are "missing" the VM set them to 0 and this is
sometimes used to have optional arguments.
So the first step would be to implement arg type checking and add some
syntax to show optional arguments (like in C++). Type checking is
requiered if the compiler need to handle some types in a special way.
Then some extra code would be needed to handle such "hidden" variables
(ie. check that there is some free variable to use, generate the extra
 code, etc).


I was just thinking. The above example could be simplified a bit by having macro's #define'd to reduce the repetitive typing to just 1 line, e.g.:

#define GEN_SENTENCE(str) sentence = 0; sentence[0] = str;
dialogAdd(GEN_SENTENCE("You code like a dairy farmer"));
dialogAdd(GEN_SENTENCE("Your COBOL coding days are over!"));
dialogAdd(GEN_SENTENCE("Run Away!!!");

Although i haven't even tested macro's in scummc (apart from the typical #include), so for all i know they might not be fully supported.

In any case, its great to see some progress being made. I checked out a copy of the room example from svn, and was quite impressed by the conversation with santa - although i noticed the actor speech text was being printed in the middle of the screen, nowhere near the characters, which seemed quite odd. And then there's Santa being an actor and an object, though i guess if it works, there's nothing wrong with it :)

- SJU


_______________________________________________
ScummC-general mailing list
[email protected]
https://mail.gna.org/listinfo/scummc-general

Reply via email to