I have RE'ed the script systems for Ultima 4 and 5. They use a more limited scripting system than what you have described, so that's probably not going to be of much use to you
My opinion is that if you don't care about internationalization then one-byte codes should be fine. This gives you 128 possible op-codes for your script system. If you make these op-codes parameterizable that should be plenty.
An example of a parameterized code might be with your menus:
Code: Select all
.byte MENU, 3 ; A menu definition follows with 3 entries
.byte "My first choice" ; Menu choices
.byte "My second choice"
.byte "My third choice"
.word first_response, second_response, third_response ; Response vectors
If on the other hand you do care about internationalization, then try the following:
Codes 0-127 have their normal ASCII meaning.
Codes 128 - 253 are reserved for an extended character set.
Code 254 means the next byte (or word) is an index into another extended character set table.
Code 255 means the next byte is one of 256 possible opcodes.
The script system I wrote for my C64 game (that I never finished) used a C program to parse a script and do various craziness to make my script data binary. I like your approach better using macros and aliases.
One thing that has not been touched on yet is word compression. Many RPGs (even in the SNES era) had special op-codes for particular words. For instance, if you use the word internationalization a lot in your game that's going to take up an awful lot of space. You could have an opcode that indexes a dictionary of commonly-used long words and inline's that into the output stream.
That's where the script pre-processor comes in real handy. You can lay out your text in a regular text file, then run it through the compiler / compressor. The compressor portion would calculate how many bytes in the output each word uses, then take the top 256 words and generate a dictionary for them, then replace all occurrences of these words in the script output with the dictionary op-codes.
Many games even include spaces and punctuation along with their compressed words. I can't remember what game it was I was slogging through but I found both " that" and " that." in their dictionary.