Commit Graph
343 Commits
Author SHA1 Message Date
kichikuou dc8a9379d0 Implement DrawSnow HLL
Used in Tsuma Shibori, and some indie System 4 games.

This HLL is a draw plugin that uses SACT2's "custom sprite" mechanism.
Custom sprites do not have a texture. Instead, the plugin's render()
callback draws them directly to the main surface.
2024-11-01 08:53:58 +09:00
kichikuou ecd71896b3 3d: Store 3D engine version in a global variable
So that we don't have to pass it around everywhere.
2024-10-22 10:16:51 +09:00
kichikuou 9b03741288 3d: Pack bone transform matrices
Before this, the BoneTransforms uniform block consumed
(4 * 4 * sizeof(float) * MAX_BONES) = 19712 bytes, which exceeds 16384,
the minimum possible value of GL_MAX_UNIFORM_BLOCK_SIZE in OpenGL ES
3.2.

Since the bone matrices are affine, we can drop the 4th rows and pack
them into a mat4x3 array. Now the BoneTransforms block is 14784 bytes
and it should work with all OpenGL ES 3.2 implementations.
2024-10-20 08:25:39 +09:00
kichikuou d8ad22b638 TapirEngine: Simplify lighting
In TapirEngine, the following lighting features are not used:

- global ambient
- directional lights
- specular lights
- rim lights
- fog

(The setters / getters for these parameters are still there, but they
don't affect rendering.)

This implementation disables those features in GLSL using #ifdefs. The C
code that sets up the lighting remains almost unchanged --
glGetUniformLocation() will return -1 if the specified uniform variable
name is not found, and glUniform*(-1, ...) will be no-op.
2024-10-19 08:43:31 +09:00
kichikuou bff491bbe9 gfx: Add frame rate counter
It is exposed through StoatSpriteEngine functions, and is normally only
visible when the game's debug mode is enabled. It's very useful for
checking graphics performance.
2024-10-17 09:20:26 +09:00
kichikuou c04aa8a844 TapirEngine: Outline rendering
This implements outline (called "edge" in the game config) rendering of
3D objects, using the "inverted hull" method.
2024-10-13 07:18:49 +09:00
kichikuou c1ce2c88c6 3d: Increase MAX_BONES to 308
This is the maximum number of bones in a model for Rance Quest
(pasuteru_full.POL).

Now bone transform matrices are stored in a uniform buffer object,
because its size exceeds GL_MAX_VERTEX_UNIFORM_COMPONENTS in iOS Safari.
2024-10-12 07:35:51 +09:00
kichikuou 09dc9470ae TapirEngine: Proper collision detection
Collision detection is based on a mesh named "collision" in the map's 3D
model. The "collision" mesh specifies the area in which the character
can move in the xz plane, and the y coordinate represents the height of
the map at that point.

Now cglm 0.9.2 is required, for 2D AABB operations.
2024-09-30 09:11:54 +09:00
kichikuou 9a76d472db Implement StoatSpriteEngine.SP_SetDashTextSprite
This implementation creates a temporary "glyph" texture and draws it to
the sprite using gfx_draw_glyph().
2024-09-21 10:35:42 +09:00
Nunuhara Cabbage ea762de937 Merge pull request #186 from kichikuou/DrawDungeon
Implement DrawDungeon.SetWalkedAll
2024-09-17 20:05:31 -07:00
kichikuou 7a87ffc20a Implement DrawDungeon.SetWalkedAll
In GALZOO Island, there are non-debugging code paths that use this.
2024-09-17 15:43:07 +09:00
kichikuou f53ad7d557 Initial implementation of TapirEngine.CalcInstance2DDetection
This is used for collision detection between a map object and the player
character. The current implementation is very simple, only performing
AABB intersection tests, but it is enough to allow the player to walk
around the first dungeon in Rance Quest.
2024-09-16 15:27:11 +09:00
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 71debfbb65 Rance Quest: Do not render suspended TapirEngine sprites 2024-09-15 08:04:14 +09:00
Nunuhara Cabbage 8cc2334692 windows: use 'windows' subsystem for release build
Only show the console on debug builds.

Fixes item 2 in #177.
2024-08-25 10:10:46 -07:00
kichikuou 00aa0c2ae6 Fix build without debugger 2024-08-25 08:08:45 +09:00
Nunuhara Cabbage a13bd155dc dap: send correct reason for stopped event 2024-08-10 18:52:08 -07: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
kichikuou ade7ea9235 Fix signature mismatch in HLL_EXPORT functions
Notable changes:

* The numerator / denominator parameters of AddMotion[HV]GaugeRate are
  int in GoatGUIEngine but float in GUIEngine and PartsEngine.
* AnteaterADVEngine.ADVLogList_AddText has second parameter
  (int WindowNo) since Oyako Rankan.

This also avoids using non-void functions where a void function is
expected. It is fine in most ABIs, but raises a runtime error in wasm32.
2024-08-07 09:14:38 +09:00
kichikuou c4207e4226 Store struct_ptr in local page
It is currently only used to populate a field in RSM v9 save file.

As far as I can tell from examining Rance 01's resume save, this
reference does not seem to increment the target's refcount.
2024-08-06 07:15:54 +09:00
Nunuhara Cabbage 3f36bf29b1 Gpx2Plus: use shaders for fullscreen effects
Use the normal effect system for fullscreen effects. This allows effects
that are implemented via shaders to be used, such as the blind effects
which are used frequently in Daibanchou.
2024-08-05 10:48:22 -07:00
kichikuou 2046ad4d06 Remove delegate field from struct function_call
Now dg_index in the stack is incremented by delegate_call().
2024-08-05 16:25:08 +09:00
kichikuou 12ddb585fb Rework delegate implementation
Delegates "weakly" reference objects, meaning that referenced objects
can be deleted. Delegate invocations must not invoke on deleted objects.
This is achieved as follows:

* Each heap object has a sequential number.
* Each delegate object is backed by a page storing (object, function,
  seq) triples.
* Deleted objects can be detected by comparing the sequential number
  stored in the delegate with the sequential number of the object
  currently on the heap.

This is consistent with the AliceSoft's implementation (presumed from
the contents of resume save).

This implementation removes dead objects from the delegate in DG_CALL
and DG_NUMOF instructions. (We could do that more often, e.g. when an
object is added to a delegate.)

This breaks existing resume saves that contain delegates. For games that
predate delegate support, this does not affect the save format.
2024-08-05 16:25:08 +09:00
kichikuou 0a78489993 Revert delegate memory management changes
This reverts the following commits:

* 4b1257f "Fix delegate memory management"
* 9bb4665 "Add changes to vm.h" (partial revert)
* 75d6386 "Fix ResumeSave/ResumeLoad bugs with delegates" (partial
  revert)

We are going to take a different approach to implementing weak
references in delegates.
2024-08-05 16:25:08 +09:00
Nunuhara Cabbage 21abe6ff9a movie: load case-insensitive filename 2024-08-04 22:25:17 -07:00
Nunuhara Cabbage ab810e8f57 Implement functions for EN Haruka
Implement the NewFont HLL. This is a basic text rendering interface
which supports proportional fonts and kerning

Fixes #154
2024-08-04 21:17:10 -07:00
Nunuhara Cabbage 79ebe443f5 dbg: handle window events while waiting for input
Keep the screen updated while in the debugger.
2024-08-03 09:34:59 -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
Nunuhara Cabbage 07290cc8df Rework effect system
Rework transition effect system so that TRANS_Update uses the current
contents of the main surface rather than a stale copy.
2024-07-31 18:51:10 -07:00
Nunuhara Cabbage bc04af131a parts: implement miscellaneous functions 2024-07-31 07:35:10 -07:00
Nunuhara Cabbage 69deb9ee91 Add --msgskip-delay option
Add an option to insert a delay when skipping messages with CTRL.

This is accomplished by overriding the 'A' function. Since the function
to check the state of a key (CTRL in this case) varies by game, an
xsystem4-specific system call is added for this purpose.

Fixes #119
2024-07-28 10:24:01 -07:00
kichikuou 877ca1f74e Implement vmSystem functions for DALK Gaiden 2024-07-28 09:00:40 +09:00
Nunuhara Cabbage 5cca12b0ce Merge branch 'master' of github.com:nunuhara/xsystem4 2024-07-26 21:01:09 -07:00
kichikuou da86fd4875 vmGraph changes for DALK Gaiden
The effect API is slightly changed so that it can be used from pre-SACT
graphics engines.
2024-07-27 07:55:32 +09:00
Nunuhara Cabbage 103976b2b0 parts: use floats to calculate text width
gfx_render_text uses floats for layout, so the parts_text layout should
use floats to match.

This fixes an issue with off-center text in the English version of Rance
01.
2024-07-26 14:41:28 -07:00
Nunuhara Cabbage 12f3b5d241 Implement ChipmunkSpriteEngine.VIEW_SetOffsetPos
Used for screen quake effect in Rance 01.
2024-07-25 18:29:36 -07:00
kichikuou 0bab7544cd Fix typo 2024-07-23 18:10:34 +09:00
kichikuou b155b4b79f Add a parameter to gfx_draw_glyph() for controlling blending behavior
This adds a new parameter `blend` to `gfx_draw_glyph()`. When `blend` is
true, the function performs normal alpha blending (same as
`gfx_draw_glyph_to_pmap()`).

If `blend` is false, the resulting pixel color will be the text color
and the alpha value will be copied from the glyph texture. However, if
the alpha value is less than 0.01, the pixel will not be written.

If you are drawing on a transparent texture (which will later be blended
into another texture), `blend` should be false. If you are drawing on top
of an image, `blend` should be true.

`gfx_draw_glyph()` used to fill transparent pixels with text color, but
this step is no longer needed and has been removed.
2024-06-15 14:34:58 +09:00
kichikuou 64fd2a6858 Add HLL libraries for Mamanyonyo
== Handles

As a general pattern, these libraries have an interface based on integer
handles allocated by Open() and released by Close(); in the AliceSoft's
implementation, handles are pointers to internal objects. Note that:

* 0 is used to represent an invalid handle, and
* Small numbers cannot be handles. For example, Mamanyonyo has code that
  treats an integer as a CG number if it is less than 10000, and as a
  surface handle otherwise.

In this patch, handles are generated using id_pool.h functions. In order
to achieve the above, the interface is extended so that the minimum ID
value can be specified (the `base` parameter of id_pool_init()).

== Graphics System

Surface objects (implemented in vmSurface.[ch]) plays a central role in
Mamanyonyo's graphics system, and the sprite system (vmSprite.c) is
implemented on top of it. vmSprite.c uses scene.h functions.

== vmChrLoader and vmMapLoader

Since Mamanyonyo's character data format is the same as Widenyo's,
the ChrLoader code has been refactored and used from vmChrLoader.c.
On the other hand, MapLoader and vmMapLoader do not share code because
the map file format is different from Widenyo.
2024-05-31 13:36:29 +09:00
kichikuou 7ef9719cc7 Use little_endian.h in libsys4 2024-05-19 10:59:50 +09:00
kichikuou 58366e199e File.Read/Write: Use the same format as AliceSoft's implementation
This improves interoperability of save files in Rance6, GALZOO, etc.
The old JSON format can still be loaded for backwards compatibility.
2024-04-14 09:23:23 +09:00
kichikuou bc522b27e0 Android: Report ERROR() with a message box 2024-03-16 12:45:07 +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 0b4eb92e95 Fix S_MOD for bool and long int
* The "type" argument of S_MOD is 48 for bool, 56 for long int
* %b, %c, %d can consume any integer types (int, bool, or long int)
* If the value cannot be consumed, S_MOD should return the format
  string instead of an empty string
2023-09-02 11:36:54 +09:00
kichikuou afae3fc9a6 DrawDungeon14: Implement raster effect
It is implemented as a post-processing effect. The hack for the
projection transform matrix has been removed, because now the image is
flipped upside down in the post-processing stage.
2023-09-01 21:45:46 +09:00
kichikuou a301ca1311 DrawGraph, Gpx2Plus: Implement CopyReverseUD() 2023-08-31 14:16:52 +09:00
kichikuou 4cb374dd5d Flash: add support for sprite objects
This implementation supports only single-frame sprites with a single
child object. As far as I know, all Flash effects in AliceSoft games
meet this requirement.
2023-07-09 17:05:25 +09:00
kichikuou 9543bf1761 Flash: sound support
The DefineSound tag in SWF has raw PCM data, so we create a WAV file in-
memory and pass it to audio_play_archive_data(). This is not strictly
necessary since libsndfile can handle raw PCM data, but keeps the audio
and mixer interfaces simple.
2023-07-09 17:05:21 +09:00
kichikuou 588d4f1024 Initial implementation of TapirEngine HLL
TapirEngine is the 3D rendering engine used in RanceQuest.

This implements the minimum functionality that is needed to render the
first battle scene. The lighting is still incorrect.
2023-07-08 08:05:07 +09:00
kichikuou 1730ddebae ChipmunkSpriteEngine: Add DX_{Get,Set}UsePower2Texture 2023-07-03 08:39:45 +09:00