Commit Graph
9 Commits
Author SHA1 Message Date
Nunuhara Cabbage 3f2a69f8ca aindump: fix crash when dumping HLL functions
HLL functions can accept struct arguments, although there is no way to
determine the struct type other than analysing the code.
2019-11-15 19:33:56 -08:00
Nunuhara Cabbage 6cd35320af Add aindump utility
Add utility for dumping information from AIN files.

For now this is pretty simplistic. The main use is to dump HLL function
prototypes to help with writing stubs.

Future features:
    * dump to JSON format
    * full AIN dump which could be rebuilt by a complementary tool, e.g.
      to enable editing bytecode for testing purposes.
2019-11-11 00:37:55 -08:00
Nunuhara Cabbage edffc0ad76 Initial CALLHLL and Math.dll implementation
HLL libraries are compiled into the executable rather than dynamically
loaded as in early versions of System 4. These days AliceSoft does the
same thing.
2019-11-04 20:35:42 -08:00
Nunuhara Cabbage cb236965d8 Support reading AIN files up to v12 (Rance X)
The purpose of the added fields is still unknown.
2019-11-03 15:04:43 -08:00
Nunuhara Cabbage b3a660f8ec strings: copy-on-write
Only copy strings when they are mutated. This avoids copying strings in
cases where neither the copy nor the original would be modified during
the lifetime of the copy, e.g. when passing strings by-value.

This is purely an optimization.
2019-10-20 21:26:51 -07:00
Nunuhara Cabbage b7bdd17a50 Add global variables
PUSHGLOBALPAGE and SH_GLOBALREF instructions.
2019-10-13 20:00:11 -07:00
Nunuhara Cabbage 53dc8a7a44 strings: store size together with text in memory 2019-10-07 16:54:46 -07:00
Nunuhara Cabbage eb63980294 Call system.Exit after returning from main
A bit of a hack: we insert an extra 'CALLSYS 0x0' instruction
(system.Exit) at the end of the code section, then set up a stack frame
so that when main() returns, it jumps to that instruction.
2019-10-06 20:58:03 -07:00
Nunuhara Cabbage 84df756faf Initial commit
An assortment of instructions have been implemented so far, mostly basic
stuff such as stack management. The following program can be executed:

int main(void)
{
    hello(2);
    for (;;) {
        system.Peek();
        system.Sleep(1);
    }
    return 0;
}

void hello(int n)
{
    int i;
    for (i = 0; i < n; i++) {
        system.Output("Hello, world! " + string(i));
    }
}
2019-10-06 19:35:36 -07:00