Commit Graph
78 Commits
Author SHA1 Message Date
kichikuou 9e2f03d8be Add support for group save format v7
V5 is used until Daiteikoku, and v7 since Rance Quest. Since both are
Ain v6, the save version is determined by the presence of the "MainVM"
field in AliceStart.ini.
2024-09-16 09:01:49 +09:00
kichikuou 240c2c9395 Update rsave_read() parameters to specify read mode 2024-08-25 08:00:16 +09:00
kichikuou 1f0fc09294 Implement SoundFilePlayer HLL
Using this, Widenyo plays user-provided BGM files in the
SaveData/MusicData directory.
2024-08-11 07:18:19 +09:00
Nunuhara Cabbage ac298baaec Fix fnl font selection
type 0 -> gothic (ttf)
type 1 -> mincho (ttf)
type >= 256 -> fnl[type - 256]
2024-08-04 09:27:57 -07:00
Nunuhara Cabbage 6b78f53bd7 Implement various functions for Drapeko
The game now runs until after the opening movie, although with some GUI
layout bugs.
2024-08-02 15:08:44 -07:00
kichikuou 9e821a754c Fix system.DeleteSaveFile and vmFile.Delete on Windows 2024-05-19 16:03:48 +09:00
kichikuou 3e9f975213 Update libsys4 2024-03-16 12:43:55 +09:00
kichikuou 05226453d9 Add support for reading / writing System4 resume save files
Writing save files in RSM format is only enabled if `--save-format=rsm`
command line flag is specified, because this implementation does not
create save files that are fully compatible with the AliceSoft's
implementation:

* There is no simple way to determine the RSM format version used by the
  game.
* There are several unknown fields in the RSM format.
* Empty arrays are represented as NULL pages in xsystem4, so type
  information of such objects cannot be saved.

These limitations are not a problem for the following use cases:

* Use the created save files only in xsystem4
* Load save files created by System40.exe

Also, RSM save files are much smaller and faster to read and write than
JSON.
2024-02-14 12:45:37 +09:00
kichikuou c3f39aeb96 Use mt19937_xorcode helper function 2023-12-17 09:01:28 +09:00
kichikuou 0911103949 Update libsys4
And add tests for https://github.com/nunuhara/libsys4/pull/26.
2023-11-18 16:35:58 +09:00
kichikuou 01429fe2a8 Update libsys4 2023-06-17 11:32:47 +09:00
Nunuhara Cabbage 7392d74efe Replace debug_print with to_json
to_json and cJSON_Print are now used when displaying debug information.

The main reason for this change it to support sending objects over DAP.
2023-05-14 20:12:34 -07:00
Nunuhara Cabbage cff6272c18 Always use absolute path for config.home_dir
And by extension config.save_dir. This fixes an issue where paths
retrieved by system.GetSaveFolderName and then passed to gamedir_path
would become invalid.

Fixes #115
2023-05-06 08:29:12 -07:00
Nunuhara Cabbage d4e06db8e2 Initial DAP implementation
So far only basic debugging functionality is implemented (breakpoints,
stepping, stack traces/variables).

This is not tested against an established DAP client. My intention is to
create a custom GUI frontend and extend the protocol to support
xsystem4-specific features, such as inspecting the scene. (This work is
underway.)

Instruction references are hex-encoded address strings. Clients do not
need to obtain them from DAP requests. This is outside the spec, but it
is needed for a binary-only debugger.

Functions that write directly to stdout (e.g. printf) should generally
not be used any more.  Instead, use either sys_message (which respects
sys_silent) or log_message (which will send the message to the debugger
if DAP is enabled). stderr can be used as normal.
2023-04-29 10:32:50 -07:00
Nunuhara Cabbage 75d6386e25 Fix ResumeSave/ResumeLoad bugs with delegates
When loading a delegate, the stored objects must be registered to it.

Also, delegate_call cannot use vm_execute because the VM cannot be
resumed from such a state.

Incidentally, this means that ResumeSave cannot be called from within a
constructor/destructor (since they also use vm_execute), but this is
probably not a problem.
2023-04-14 15:08:45 -07:00
Nunuhara Cabbage e4ed459376 Implement miscellaneous PartsEngine functions 2023-04-10 21:48:09 -07:00
Nunuhara Cabbage 46f25755c5 Add PartsEngine HLL (Oyako Rankan version)
The game currently runs up until the first unimplemented function
(SeekEndMotion) during the intro events, using the existing PE_
functions with a few minor fixes.
2023-04-10 15:16:14 -07:00
Nunuhara Cabbage 249e447920 asset_manager: use built-in afa index
The afa implementation from libsys4 now handles basename indexing, so we
use that instead of creating a separate index. Also, afa v1 is now
properly supported in libsys4, so there is no need for the
id_indexed_afa hack.
2023-04-09 10:02:07 -07:00
Nunuhara Cabbage cc199dcf4e Add notes directory 2023-04-05 19:28:30 -07:00
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
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 cc79f9caee Use global/group save file format compatible with System4
After this, xsystem4 uses the global/group save format used by the
original System4, instead of the JSON format. Existing JSON save files
can still be loaded.

This makes save files interoperable between System4 and xsystem4 in some
games, including Sengoku Rance and Toushin Toshi III.
2023-03-19 11:42:20 +09:00
kichikuou 90a96eb8bb Use UTF8-aware dirname/basename functions
Command line paths containing non-ASCII characters now work on Windows.
2023-02-25 21:05:53 +09:00
Nunuhara Cabbage 267bb8c99a Update libsys4 2023-02-07 21:01:42 -08:00
Nunuhara Cabbage 842d712a31 Fix bug in S_MOD
The 3rd argument to the instruction indicates the type of the second
argument. If there are multiple specifiers in the format string, the
first specifier matching the given type is substituted (NOT the first
specifier encountered when processing the format string).
2023-01-10 18:47:03 -08:00
Nunuhara Cabbage a55893bf2f debugger: improve print command
Now handles arbitrarily complex member/subscript expressions, with
pretty-printing and a configurable recursion depth.
2023-01-08 17:13:33 -08:00
Nunuhara Cabbage 75d8a8b69d Improve usage error reporting
Print usage information when there is an error in the command line
arguments. Also, wait for keypress before exiting on Windows so that the
user can read the error message.
2023-01-01 19:28:59 -08:00
Nunuhara Cabbage 5a5954811f Update libsys4 2023-01-01 13:21:00 -08:00
Nunuhara Cabbage 9a8e3c59ec Fix use-after-free in font_freetype.c
Pointers to `struct font_size` objects are cached in `struct text_style`
objects, so the `sizes` array can't be reallocated.

This fixes a crash in Rance 02 when entering battle.
2022-12-27 10:14:14 -08:00
Nunuhara Cabbage a3e3232825 Update libsys4 2022-11-11 20:28:45 -08:00
Nunuhara Cabbage 73b21210c2 Fix delegate memory management issues
Delegates should be ref'd in vm_copy and unref'd in variable_fini.

This also includes some improvements to the diagnostic reporting of
DEBUG_HEAP.
2022-06-26 17:55:05 -07:00
Nunuhara Cabbage bbe8b4053f Implement CommonSystemData library
Except for the LoadAtStartup function.
2022-06-14 20:41:51 -07:00
Nunuhara Cabbage eaa0baad7f Handle library incompatibilities
Add a mechanism for libraries to resolve incompatibilities between
library versions before linking.

This is currently used for ChipmunkSpriteEngine and GoatGUIEngine,
where early versions used integer IDs when loading CGs (later versions
use strings).
2022-06-06 08:49:12 -07:00
Nunuhara Cabbage 19ac7e6935 Refactor asset_manager (again)
There are now two types of asset management:
    1. ID-indexed assets, where IDs are not necessarily sequential
    2. name-indexed assets

Name-indexed assets can have additional archives added at run-time. This
is to support the CGManager.LoadArchive function used in Rance Quest
Magnum.

Name-indexed assets always use .afa archives. ID-indexed assets mostly
use .ald archives, except for Daiteikoku and Shaman's Sanctuary.

asset_get_by_name is now case insensitive and ignores the file
extension.
2022-06-05 19:15:41 -07:00
Nunuhara Cabbage 7eb620aca7 Refactor asset_manager
asset_exists and asset_get now take 1-indexed IDs.

Custom CG indexing code for Shaman's Sanctuary is now removed and
replaced with a proper implementation of afa v1 archives in libsys4.
2022-06-05 12:26:18 -07:00
kichikuou dca30c3aab Initial implementation of ReignEngine HLL
ReignEngine is the 3D rendering engine used in Toushin Toshi III, and is
the predecessor of the 3D engines for Rance Quest, Rance 9, Evenicle,
etc.

This implements minimal functionality to be able to draw the first 3D
dungeon scene. Many important parts such as motion and lighting are not
implemented yet.
2022-06-04 11:29:07 +09:00
kichikuou 7d7bc00765 Update cglm to v0.8.5 2022-06-04 08:26:45 +09:00
Nunuhara Cabbage 9b83a6d09d Refactor text rendering code
.fnl fonts can now be used outside of SengokuRanceFont, and
SengokuRanceFont now uses the same text layout and caching code as
SACT2, etc.
2022-05-14 23:12:36 -07: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 39ce914bf9 Optimize error checks in hot functions
Use `unlikely` (__builtin_expect) to help the compiler optimize error
checks in some hot functions (in my testing, stack_pop_var was one of
the hottest functions, right behind execute_instruction).
2022-05-06 20:43:30 -07:00
Nunuhara Cabbage 0d771384da Fix SengokuRanceFont.SP_SetTextMetricsClassic
This function doesn't overwrite values in the text style that aren't
contained in the sact_text_metrics_t object.
2022-04-30 06:33:20 -07:00
Nunuhara Cabbage f2dd4def12 Fix bug in gfx_draw_glyph
blend_amap_color_shader now uses the alpha value.
2022-04-29 18:13:22 -07:00
Nunuhara Cabbage 9089fa1fd1 Rewrite fnl font renderer
Only unscaled glyph bitmaps are now cached in regular memory. Scaled
glyphs are stored as textures on the GPU. Only the alpha channel on
glyph textures is used, with the color being provided as an input to the
shader.

Outline and bold rendering is improved by using a simple dilate shader.
This looks okay but could be improved (the result is a bit blurry
still).
2022-04-28 19:13:27 -07:00
Nunuhara Cabbage 8fb0153963 SengokuRanceFont: anti-aliasing and glyph caching
This improves the look and (especially) the performance of text
rendering in the MangaGamer version of Sengoku Rance.

There are still some bugs/unimplemented features, but the game should be
more or less bearable to play in this state.
2022-04-24 17:19:27 -07:00
Nunuhara Cabbage 3b72b88e9c SengokuRanceFont improvements
The game now basically runs, but with very bad performance and lots of
aliasing on text.

Need to implement anti-aliasing and caching of rendered glyphs next.
2022-04-23 22:52:07 -07:00
Nunuhara Cabbage 21cb503c06 Read debugger config at startup
Read .xsys4-debugrc from ~/.xsystem4 and/or the game directory on
startup. This is just a text file with one debugger command per line.
Can be used to set breakpoints or log functions automatically at
startup.

This can also be used to work around a limitation on Windows where the
IME doesn't work in the debugger, making it impossible to input Japanese
text.
2022-04-14 10:54:00 -07:00
Nunuhara Cabbage 9ede2d7af9 debugger: add vm-state command
Add vm-state command, which prints disassembly around the current
instruction pointer and the current contents of the stack.

It was necessary to change how breakpoints are implemented for this.
When adding a breakpoint, the original opcode now remains in the
instruction stream, bitwise-or'd with BREAKPOINT. A hash table indexed
by address is used to store breakpoint objects.
2022-04-14 09:08:57 -07:00
Nunuhara Cabbage 3507ebc609 Fix texture leak in sprite_set_cg_2x 2022-04-10 18:43:41 -07:00
Nunuhara Cabbage 912a73d42a Implement HLLs for English version of Rance VI 2022-04-10 18:24:47 -07:00
Nunuhara Cabbage 1f239c766f Rance 02: render '}' as dash 2022-04-04 20:17:34 -07:00