I feel like I’m asking this too early in the development stage, but I7v10’s ability to compile to C and potential use in other engines is much too exciting.
So, can anybody explain to me in layman’s terms how to get inform 7 to compile to C, and whether or not I should be using Basic Inform for this sort of thing?
I’m still figuring out how to use all this and the documentation such as it is right now is all very technical, and I am having a hard time finding the information I’m looking for.
That’s my ultimate goal, to code a game in Unreal or another engine using primarily Inform 7.
Yesterday I did manage to install Inform 7 to my mac’s terminal, and I got a game to ‘run’ and I think I’m very close to getting that c-output but I’m missing a step somewhere that turns it into an .i7 file first.
I followed Zed’s twitter instructions and he says that my c-code went to the build folder in the project, into the file auto.inf, and I opened that file up and it certainly looked like that had happened, so… I imagine just changing it from auto.inf to auto.c would work, but by then it was 4am and I needed to get some sleep.
My plan is then to stick the very simple, inform basic “hello world” into a game engine, and see if it runs.
You get a standalone executable – no additional code is necessary. You may link it with an external Glk library but by default it will use the built-in “Miniglk”.
I was thinking more along the lines of a DOS console program with no GUI, as I’d like to target retro computers.
I’ve never used Inform and the last time I used a C compiler directly was about 30 years ago, so a lot of info in the documentation (and in this thread) is lost on me.
Glk is an I/O spec; it doesn’t imply a GUI. Miniglk only supports things that look like console programs.
But the C that’s produced requires a target that can handle 32-bit words. 16-bit or 8-bit targets could only be supported by compiling to Z-code and using a terp.
Although i haven’t tried it, SDCC is likely not to work. I had huge problems compiling the C output. It definitely needs improving as it generates giant function that makes some compilers fall over. For example emscripten cannot compile the C as emitted. I had to break up functions into smaller pieces.
A mid sized game generates about 16MB of source code into a single file. This is monstrous. The biggest culprit is
void i7_initialiser(i7process_t *proc);
This function alone can be 100,000 lines long. Compilers like to optimise on a function-by-function basis, and this one does have some things to improve it.
It’s clear Inform needs to do some work on the C code emitted. But i can understand the idea was to get it working first then optimise later. Which is the sensible way to go. Hopefully we’ll see an update that is much more optimised. For example, i think i7_initialiser could mostly be a large table.
Nevertheless, i think the C output is most exciting and the way to go for future Inform games.
Much as I dislike using C, I do agree that it was the best choice as the first programming language to export to.
Even if you ignore how many platforms you can get C compilers for, there are also plenty of C translator programs targetting Pascal, Nim, Go, WebAssembly, JavaScript etc.
So I have compiled my very simple “Hello.i7” Which I basically copied from the eg-1:
It has compiled to c with over 86,000 lines of code, turning my 32bit program into a 3mb program, mostly of definitions. I used the -basic command, so I thought it wouldn’t use those, but I guess it’s something that inform does need to translate the english into something the computer will understand.
I did get it to print “hello world” in VS code after a little finagling with paths to inform_clib.
I think I can get it to print to Unreal’s console…
After that I don’t know what to do next, since I am still learning how to make games outside of interactive fiction.