Array rank can't be inferred from JSON data since arrays and structs are
indistinguishable. So we get it from the ain file instead.
Sengoku Rance is mostly playable as of this commit.
Sprites are now rendered to an off-screen texture which is then rendered
to the screen in gfx_swap. The sprite table in sact_graphics is set up
so that sprites[-1] provides access to this off-screen texture.
Sengoku Rance uses 1400 and 1700 for FW_NORMAL and FW_BOLD rather that
400 and 700.
Text surfaces now have a transparent white background instead of a
transparent black background. This looks better in SR since it uses a
lot of white text/white outlines. The underlying problem is that the
color value of completely transparent pixels is blended with the glyph
color when blitting to the text surface.
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)
...
The "SaveFolder" key in System40.ini gives the name of the save
directory. Earlier versions of system 4 treated this as a relative path
in the game directory, while later versions treated it as a path
relative to "$USER\My Documents\AliceSoft\$GAME_NAME". I've chosen the
latter approach, but using a xsystem4-specific directory to avoid
reading/overwriting saves created by System40.exe.
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.
5 functions:
SACT2.SP_SetDrawMethod
DrawGraph.CopyStretch
DrawGraph.CopyStretchAmap
DrawGraph.CopyReduce
DrawGraph.CopyReduceAmap
SP_SetDrawMethod is not pixel-perfect to System40.exe, but its pretty
close.
I'm not sure what the difference between the Stretch/Reduce functions is
supposed to be. They seem to do the same thing.
Also, the ugly macros in sdl_draw.c are replaced by higher-order
functions.
With this commit, Sengoku Rance runs up to the menu without exiting due
to unimplemented HLL functions.
Sprites are now rendered directly, rather than being blitted to a master
surface which is then copied to a texture. Every sprite now carries an
SDL_Texture in addition to an SDL_Surface (we need both, since
SDL_Texture doesn't give read-access to the pixel data).
All of the image-manipulation code is now in sdl_draw.c, and the
DrawGraph_* functions are now wrappers. Some games (Daibanchou at least)
use an API other than SACT2/DrawGraph, so these operations should be
generic to avoid duplication.