Commit Graph
42 Commits
Author SHA1 Message Date
Nunuhara Cabbage d30689a8fd Add install target
Also allow running from outside of the source directory once installed.
2020-09-04 20:33:47 -07:00
Nunuhara Cabbage 80b8eacab2 Move libsys4 into separate repository
To allow pulling xsystem4 and alice-tools apart.
2020-08-28 21:32:18 -07:00
Nunuhara Cabbage 8f38b6141e alice-ar: various improvements
* Can now extract files from .afa version 3 archives
* Can now extract files from .flat files
  * Includes recursively extracting .flat files contained in other
    archive formats
* Added option to extract images only
* Now converts images to PNG format by default
  * WebP format also supported

Because the table of contents is encrypted in .afa version 3 archives,
the support is a bit limited. Only known file types can be extracted and
they do not retain their original filenames (they are given numbered
filenames instead).
2020-05-23 12:33:40 -07:00
Nunuhara Cabbage 40ce6e2e82 Add webp CG support
For the MangaGamer version of Sengoku Rance. This makes libwebp a
dependency.

These webp files have a non-standard metadata block appended to them
which specifies the base CG that should be used for unfilled pixels,
where "unfilled" means any pixels with a pure magenta color (255,0,255).
2020-04-07 18:41:01 -07:00
Nunuhara Cabbage e4a2e965df Use custom parser for System40.ini
This is not really a standard ini file, so a custom parser is needed to
access all of the information stored in it (specifically, lists like
"LoadDLL").

This commit also makes flex/bison a hard dependency.
2020-03-10 21:36:28 -07:00
Nunuhara Cabbage 2d1b8dad3a Partial AJP CG support
Support for AJP without alpha channel.
2020-03-07 21:47:09 -08:00
Nunuhara Cabbage 6a4d11f3de Use libffi for library calls
Use libffi to portably call arbitrary functions at runtime, rather than
forcing library functions to use a standard prototype.
2020-01-07 22:48:29 -08:00
Nunuhara Cabbage 5d6f148e1b Reorganize project file structure
- Create separate directories for source and header files.
- Build code shared between xsystem4 and aindump as a static library.
- Create header dirs gfx/ system4/ and vm/
- Make CG.c/h usable without a running VM
2019-12-31 17:50:40 -08:00
Nunuhara Cabbage 9b865d15fe Implement crossfade effect 2019-12-30 18:30:39 -08:00
Nunuhara Cabbage c60e804420 tmp 2019-12-26 13:11:47 -08:00
Nunuhara Cabbage 5da0916472 Implement system.ResumeSave/system.ResumeLoad
Save/load VM images as JSON.
2019-12-25 22:28:39 -08:00
Nunuhara Cabbage eb8c7b0fe6 Move heap management code into heap.c 2019-12-23 16:53:00 -08:00
Nunuhara Cabbage a8d1abb483 Stubs for File.dll & ExistsFile syscalls 2019-12-21 07:07:34 -08:00
Nunuhara Cabbage e90821cc20 Use OpenGL instead of SDL's 2D graphics API
This will be necessary for supporting 3D games in the future (Rance VI,
GALZOO, etc.).
2019-12-16 19:59:17 -08:00
Nunuhara Cabbage 1c0869b4fb Add debugger, run REPL on VM_ERROR
If Chibi-Scheme is installed, enable a debugger which can be used to
inspect the state of the VM when an error occurs.

So far only supports printing local/global variables. E.g.

    dbg> (print-variable "g_theSactMenu")
    ...
    dbg> (print-locals)
    ...
2019-12-07 09:24:38 -08:00
Nunuhara Cabbage a0826f69e4 Implement global save/load system calls
system.GlobalSave
system.GlobalLoad
system.GroupSave
system.GroupLoad

Save files are uncompressed JSON objects for now. Compatibility with
System40.exe saves would be nice, but the format appears to be
encrypted.

Minifying & compressing the JSON should be done at some point but for
debugging purposes I've left it totally uncompressed.

This commit also fixes a bunch of undefined behavior when assigning to
'heap[...]' with an rvalue that could initiate a realloc of the heap.
2019-12-03 22:54:41 -08:00
Nunuhara Cabbage 2778d2eb42 Add stubs for PlayMovie.dll 2019-12-01 17:43:30 -08:00
Nunuhara Cabbage b8fbba074b Add stubs for Confirm2.dll 2019-12-01 14:18:36 -08:00
Nunuhara Cabbage a02632590d Add stubs for AliceLogo*.dll 2019-12-01 11:05:14 -08:00
Nunuhara Cabbage 79dde45e44 Add stubs for SystemServiceEx.dll 2019-12-01 10:32:34 -08:00
Nunuhara Cabbage 766f93407b Implement the DrawGraph.Copy* family of functions
Implement all of the simple copy functions, with the exception of
DrawGraph.CopyColorReverse, which is undocumented and appears to be dead
code (at least in the version of SACT2 that shipped with the SDK).
2019-11-25 12:19:14 -08:00
Nunuhara Cabbage 58f070dbb4 Partial implementation of ACXLoader.dll
Enough to read the acx files used by the Rance I/II digest versions.
2019-11-24 16:23:29 -08:00
Nunuhara Cabbage 3542352cf6 Implement SACT2 text rendering functions
Also a lot of bug fixes included here.
2019-11-24 11:48:53 -08:00
Nunuhara Cabbage ee0f72ae2e Refactor SACT2 and fix input
Pull graphics code into sact_graphics.c.
Implement Key_ClearFlag so that SACT2's own input handling code works
properly.
2019-11-21 19:57:24 -08:00
Nunuhara Cabbage 419da7889c Implement mouse and keyboard input support
The popolytan demo now has a functional menu, albeit without text.
2019-11-18 21:58:54 -08:00
Nunuhara Cabbage 70ab217ca0 Fix build
-Wall/-Wextra are enabled automatically.

C11 doesn't define M_PI.
2019-11-18 18:32:03 -08:00
Nunuhara Cabbage a9de3b76fb Implement SACT2.Update()
Really lazy implementation for now, just draws all sprites every frame.
In the future should implement proper compositing with damage tracking.

All CG types other than QNT are removed. From what I've seen, System 4
games use QNT, PNG, AJP (encrypted JPEG) and DCF (seems to be a format
for partial CG updates). QNT is by far the most common format.
2019-11-17 21:44:16 -08:00
Nunuhara Cabbage 4a7075ffef Add stubs for MsgSkip.dll 2019-11-15 21:40:21 -08:00
Nunuhara Cabbage f4551005ba Add stubs for DrawPluginManager.dll 2019-11-15 19:49:51 -08:00
Nunuhara Cabbage 55fc577485 Add stubs for MsgLogManager.dll 2019-11-15 19:36:00 -08:00
Nunuhara Cabbage d3de009e1d Import CG reading code from xsystem35
Plus a bit of SACT2 implementation, and fix a bug where global arrays
were not initialized properly.
2019-11-15 19:01:08 -08:00
Nunuhara Cabbage 13b359058e Read ALD files at startup 2019-11-12 20:43:48 -08:00
Nunuhara Cabbage cc23fc61ea Read System40.ini/AliceStart.ini 2019-11-11 13:44:52 -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 e927f72905 SACT2.dll stubs 2019-11-10 16:24:37 -08:00
Nunuhara Cabbage c370e3eeaf Implement S_MOD (format strings)
Mostly relying on sprintf to do the work.
2019-11-10 13:44:01 -08:00
Nunuhara Cabbage 1e3fbcd95f Change HLL calling convention
...and add OutputLog.dll stubs.

The calling convention no longer has HLL functions reaching into the
stack. The previous implementation didn't even work since the return
value could overwrite an argument that needed to be freed.
2019-11-07 19:26:58 -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 e5ef9f4d2d Implement constructors and methods
Implement CALLMETHOD, SH_STRUCTREF and PUSHSTRUCTPAGE instructions.

Constructors are a bit tricky since SH_LOCALCREATE has to implicitly
call an arbitrary number of functions before it returns (just changing
the instruction pointer only allows for calling a single function).

To get around this, there is now a vm_call() function which is used to
call a function synchronously, before returning from the current
instruction.

Methods are implemented as functions, except that they get a struct page
as local variable -1.

Destructors are still not implemented.
2019-10-20 17:33:22 -07:00
Nunuhara Cabbage 12242c087f strings: handle shift-jis 2019-10-14 18:09:00 -07:00
Nunuhara Cabbage 92710dc06a INC/DEC and DUP* instructions
Random note: The SDK compiler generates some pretty strange code for
'n++' when 'n' is a reference:

    instruction                state of stack after instruction
    -----------                --------------------------------
    PUSHLOCALPAGE              ; P(ref n)
    PUSH <variable index of n> ; P(ref n),V(ref n)
    REFREF                     ; P(n),V(n)
    DUP2                       ; P(n),V(n),P(n),V(n)
    REF                        ; P(n),V(n),n
    DUP_X2                     ; n,P(n),V(n),n
    POP                        ; n,P(n),V(n)
    INC                        ; n
    POP                        ;

This would seem to be completely equivalent to the following:

    PUSHLOCALPAGE
    PUSH <variable index of n>
    REFREF
    INC
2019-10-07 19:32:56 -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