Add a new debugger interface using a simple command language. This is
less powerful than the scheme interface (which still exists) but more
ergonomic for interactive debugging.
This debugger has no external dependencies (it will however use readline
if available) and is included in builds by default.
A sample interaction might look like:
xsystem4 --debug /path/to/game
dbg(cmd)> breakpoint bar
Set breakpoint at function 'bar' (0x00001234)
dbg(cmd)> continue
Hit breakpoint at function 'bar' (0x00001234)
dbg(cmd)> backtrace
#0 0x00001234 in bar
#1 0x00002222 in foo
#2 0x00004444 in main
dbg(cmd)> locals
[0] i: 2
[1] s: "baz"
dbg(cmd)> locals 1
[0] j: 3
[1] obj: { m_i = 0; m_s = "" }
dbg(cmd)> quit
Replace SDL_mixer with an audio implementation using libsndfile,
sts_mixer (a single-file header library) and SDL's basic audio
interface.
This allows for much more flexibility in controlling audio playback.
Fading is now properly implemented, as well as various other functions
from the SACT2/KiwiSoundEngine interface.
sts_mixer can support recursive mixing, so it will be possible to
implement the "VolumeValancer" mixer channels specified in
System40.ini in the future (once I figure out how the mapping of audio
files to mixer channels is supposed to work).
In addition to DrawDungeon.c, this adds the following files in
{src,include}/dungeon/:
- dgn.{h,c}: Parser for .dgn (map data)
- dtx.{h,c}: Parser for .dtx (textures)
- tes.{h,c}: Parser for .tes (sound IDs associated with textures)
- dungeon.{h,c}: Renderer main routines
- mesh.{h,c}: Renderer for walls and stairs
- skybox.{h,c}: Renderer for background cubemap
- event_markers.{h,c}: Renderer for event markers
And the following changes are made to the existing graphics code:
- sact_Update() calls dungeon_update(), so that event markers animate
- gfx_render_texture() renders vertically flipped image when
texture.flip_y == true (see the comment in dungeon_context_create())
Some features are not implemented yet, including 2D maps and door
animation.
This makes cglm a dependency.
* 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).
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).
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.
- 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
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)
...
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.
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).
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.
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.
...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.
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.
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.
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
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));
}
}