Commit Graph
54 Commits
Author SHA1 Message Date
Nunuhara Cabbage baae8f5237 Document Windows FFmpeg build, etc.
Statically link FFmpeg on Windows. This requires building a slimmed-down
version of FFmpeg from source. The build process is documented in the
README.

Also add ffmpeg dependency to the nix flake.
2023-04-02 19:34:45 -07:00
kichikuou b11a173b67 Add FFmpeg movie backend
This allows playback of videos in encodings other than MPEG-1, e.g. VC-1
used in the English version of Rance VI.

The FFmpeg dependency is optional. If it's not available, the PL_MPEG
backend will be used.
2023-04-01 13:59:55 +09:00
Nunuhara Cabbage 0e18f69cbf build: require meson >= 0.59 and cglm >= 0.8.3
get_option('<option>').allowed() requires meson >= 0.59.

glm_quat_nlerp requres cglm >= 0.8.3.
2023-03-28 22:41:49 -07:00
Nunuhara Cabbage c3f9d93917 Link statically on Windows
Try to link statically as much as possible on Windows, to reduce the
number of DLLs that have to be shipped with Windows builds.

Also document the build process on Windows.
2023-03-29 03:09:20 -07:00
kichikuou ec5a2c054c Use OpenGL ES by default
This replaces `use_gles` boolean build option with `opengles` feature
option. If OpenGL ES3 is available, it is preferred over desktop OpenGL.
This can be overridden by `-Dopengles=disabled` meson flag.
2023-01-01 13:25:45 +09:00
Nunuhara Cabbage 2262f7067c Use FreeType2 instead of SDL_ttf
SDL_ttf isn't really designed to be used with OpenGL. It caches glyph
bitmaps in memory, whereas we want to cache glyph textures on the GPU.
By using FreeType directly we avoid creating and destroying a new
texture every time a glyph is rendered.

Additionally, all glyph textures (including fnl-derived glyphs) now use
the GL_RED internal format instead of GL_RGBA.
2022-05-08 16:11:25 -07:00
Nunuhara Cabbage 9fbc9ec5b7 Implement simple command-based debugger interface
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
2022-04-01 19:38:55 -07:00
Nunuhara Cabbage 0780442e13 Install debugger.scm to XSYS4_DATA_DIR 2022-03-28 17:54:26 -07:00
kichikuou 7caf009209 Add use_gles meson build option 2021-12-21 13:37:53 +09:00
Nunuhara Cabbage fc8e7eee22 Replace SDL_mixer with libsndfile + sts_mixer
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).
2021-09-30 22:07:04 -07:00
kichikuou 89e37c2428 Add dependency wrap file for cglm
Since libcglm-dev is not available in Debian buster (added in bullseye).
2021-05-08 22:42:57 +09:00
kichikuou adb558c67c Initial implementation of DrawDungeon.hll (Rance VI)
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.
2021-05-08 22:42:57 +09:00
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