Hacking Xconq - Porting the Kernel

Go to the first, previous, next, last section, table of contents.

## Porting the Kernel

The kernel must be in ANSI C. Although the kernel uses stdio, it does not assume the presence of a console (stdin, stdout, stderr). For instance, a graphical interface can arrange to disable stdin entirely and direct stdout/stderr into a file (see the Mac interface sources for an example).

You should be careful about memory consumption. In general, the kernel takes the attitude that if it was worth allocating, it's worth hanging onto; and so the program does not free much storage. Also, nearly all of the allocation happens during startup. Since a game may run for a very long time (thousands of turns perhaps), it is important not to run the risk of exhausting memory at a climactic moment in the game!

Also, the kernel should not exit on its own. The only permissible times are when the internal state is so damaged that interface error-handling routines (see below) cannot be called safely. Such situations are rare. If you add something to the kernel and need to handle error situations, then you should call one of the interface's error-handling routines. There are distinct routines for problems during initializations vs problems while running, and both error and warning routines. Warning routines may return, so kernel code should be prepared to continue on, while error routines will never return.

Go to the first, previous, next, last section, table of contents.