I have a story where the text being printed will sometimes include an aside message from a third-person, included in speech marks & italics. for example:
print "You put the thing on the thing."
new_line; new_line;
# in practice most interpreters render z-machine's "underline" as italics
print "~"; style underline;
print "You chose poorly..."
print "~"; style roman;
new_line; new_line;
print "The thing explodes in your face.";
I’ve wrapped this ‘change of voice’ in some routines, but it’s still a lot of added boilerplate, particularly where most routines can return a single string, but any text that has to include the change of voice has to be broken down into statements.
Is there a way, including z-machine opcodes, to change the font within a string? I know that there are the abbreviations and the “printing-variables” (@nn), but these can only be static strings, not routines.
It’s not a 100% solution, and that’s only because of the particular way I’m writing my game – on a Psion 5 – which gives me only a 66 char width. Because of limited screen width & height, I defined text to be printed as constants at the top of file; thus all the ‘content’ is in one place and isn’t indented, giving maximum room for writing. Below the constants the logic is together and without the game text there, it’s clearer to read and write the logic structures.
About the only downside to this is when a piece of game text has to be broken into multiple statements as this involves *_1, *_2, *_3 etc constants. Being able to change font inline would be more elegant, but your example is definitely a step forward I will be implementing.
Also note that pretty much all string manipulation (including znsi.h) requires printing to memory, something that is rarely (if ever?) supported by Infocom’s z3 interpreters. A lot of the old platforms only have interpreters released by Infocom or interpreters heavily based on Infocom’s interpreters. I’m guessing the Psion 5 can run Frotz or Jzip though.