NERPs
This article is an unfinished work in progress or contains transferred information that needs to be rewritten or reformatted to fit our standards. Please excuse the mess and do not mark for deletion.
NERPs is a C++-based scripting system created by Data Design Interactive which is used in the Windows version of LEGO Rock Raiders.
It consists of a bytecode language that is stored in NPL files, each level then has a NERPFile parameter in Lego.cfg that tells it which script to use. This script is called at regular intervals by the game engine, unknown how often but presumed to be once per game tick, 25 times per second. It will run to completion on each execution, only stopping when the function named "Stop" is called.
The source code of a NERP script is a NRN file, which is then processed through a C Preprocess to generate a nrM file. This file can then be compiled into bytecode using the appropriate tool.
Each operation in the bytecode is a double word, where the top word designates the opcode and the lower word designates the operand. Of course this is stored in little endian format in the file itself.
The opcodes are as follows:
Value | Opcode | Function |
---|---|---|
0x0000 | Constant | Load an integer constant, operand is the value |
0x0001 | Compares | Comparison operators, operand is the comparator function. |
0x0002 | Function | Calls a function, operand is the functions ID |
0x0004 | Label definition | Defines a label that can be jumped to, operand is just an ID number |
0x0008 | Goto | Jumps to a bytecode offset, operand is address to jump to |
Also involved are a couple of register named R0 to R7, the contents of which are saved between executions. There are also four timers, Timer0 to Timer3. The function of these is unknown at this time.