Commit Graph
617 Commits
Author SHA1 Message Date
kichikuou 68eff9a122 ReignEngine: Fix out-of-bounds access in calc_motion_frame
Happens when frame range in MonsterInfo.txt is wrong.
2022-12-28 13:18:41 +09:00
kichikuou 1edf95bcde ReignEngine: Fix height detection
This fixes an issue where height detection fails due to gaps in
suspension bridge planks.

If the depth map has no value for the given point, return the average
of 4 neighbors.
2022-12-28 13:18:41 +09:00
kichikuou 6e63b4a5e9 ReignEngine: Do not draw particle effect if current_frame == end_frame 2022-12-28 13:18:41 +09:00
kichikuou 9465ee1c63 ReignEngine: Cache parsed motions
Motions are cached in `struct model`.
2022-12-28 13:18:41 +09:00
kichikuou 10710e9908 ReignEngine: Cache parsed particle effects
Now parsed particle-effect definitions are cached in a hash map in the
plugin object. To make it possible, static part of `struct
particle_effect` and `struct particle_object` are factored out to
`struct pae` and `struct pae_object` respectively.
2022-12-28 13:18:41 +09:00
kichikuou defeb0ba17 ReignEngine: Cache loaded models
When there are multiple instances of a model, now they share a single
model object. Model objects are retained in a hash table until the
plugin is released, which is fine because Toushin Toshi 3 doesn't reuse
a plugin across scenes.
2022-12-28 13:18:41 +09: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 f23d713f46 Merge pull request #91 from kichikuou/effect
Implement EFFECT_NOISE_CROSSFADE and EFFECT_SEPIA_NOISE_CROSSFADE
2022-12-27 10:11:54 -08:00
kichikuou 8aafb271f9 Implement EFFECT_NOISE_CROSSFADE and EFFECT_SEPIA_NOISE_CROSSFADE
EFFECT_SEPIA_NOISE_CROSSFADE is frequently used in Toushin Toshi 3.
2022-12-27 21:13:01 +09:00
kichikuou c7cebb9ea9 ReignEngine: Fix out-of-range material index in .POL
Without this, some maps (e.g. map059) and battle backgrounds
(e.g. bg101) in Toushin Toshi 3 are not rendered correctly.
2022-12-24 16:54:41 +09:00
kichikuou 2de5132803 ReignEngine: Support (sprite) mesh attribute
It has the same effect as the (sprite) material attribute.

Also, now sprite objects are rendered in the DRAW_OPAQUE phase.
2022-12-24 16:54:40 +09:00
kichikuou 70b4071350 ReignEngine: Support "shadow darkness" material parameter
It is a value between 0.0 and 1.0, where 0.0 means no shadows are drawn
on the material.
2022-12-24 16:54:40 +09:00
kichikuou eb13ae0cc1 ReignEngine: Fix rendering issue of skinned models without motion
This fixes a bug where skinned instances with no motion loaded were not
drawn.
2022-12-24 16:54:40 +09:00
kichikuou 06b9da800c Implement ReignEngine.SetInstanceDebugDrawShadowVolume
It visualizes the bounding sphere of the instance. Although it is only
called from dead code in Toushin Toshi 3, it's useful for debugging
shadow mapping.
2022-12-24 16:54:37 +09:00
kichikuou fdd0af8dcf ReignEngine: Improve shadow view-frustum calculation
This fixes broken shadow rendering e.g. when Nacht climbs a ladder.

Now update_bones() calculates the instance's bounding sphere which
is the minimum sphere containing the AABB of current bone coordinates.
This corresponds to the sphere that is displayed when calling
SetInstanceDebugDrawShadowVolume on the original ReignEngine.dll.
2022-12-24 16:25:05 +09:00
Nunuhara Cabbage cfaed35f23 Merge pull request #89 from kichikuou/half-width
font_freetype: Fix display width of half-width kana and some symbols
2022-12-21 18:52:05 -08:00
kichikuou 1bcf026f25 font_freetype: Fix display width of half-width kana and some symbols
Halfwidth katakana are now displayed in half-width.

This also fixes an issue where some symbols with codepoint <256 (e.g.
MULTIPLICATION SIGN) were considered half-width, while the bundled font
has full width glyphs for those codepoints.
2022-12-18 14:57:04 +09:00
kichikuou acb814021c Add stubs for DrawMovie library
Used in Toushin Toshi 3. The interface is the same as DrawMovie2.
2022-12-18 10:27:34 +09:00
kichikuou 9a6553f215 ReignEngine: Fix glTexImage2D arguments for shadow renderer
GL_DEPTH_COMPONENT is not a valid value for internalFormat in OpenGL ES.
2022-12-17 10:59:16 +09:00
kichikuou 3ef252c68b ReignEngine: Improve z-sorting
This fixes billboard rendering issue in some dungeons.

* For polygon models, use its AABB's center coordinates.
* Consider the camera angle, i.e. sort by view-space Z-coordinate
  instead of world-space Z-coordinate.
2022-12-17 10:59:16 +09:00
kichikuou 6cc0bd7cb4 ReignEngine: Implement (both) mesh attribute
I'm not sure what it means exactly, but at least it disables shadow
drawing (but does not disable shadow casting).
2022-12-17 10:59:16 +09:00
kichikuou 02b0c8c80c ReignEngine: Implement (nomakeshadow) mesh attribute 2022-12-17 10:59:16 +09:00
kichikuou 86bee21a9d Implement EFFECT_TV_SWITCH_ON
Used in Toushin Toshi 3.
2022-12-11 21:48:02 +09:00
kichikuou b79eb9ccea ReignEngine: Do not WARNING() on SetBackCGName("")
It just unloads current CG.
2022-12-10 11:34:34 +09:00
kichikuou 408f35f4ec Fix ReignEngine.SetInstanceScaleZ 2022-12-10 11:26:14 +09:00
kichikuou 5b9e7ac7e4 ReignEngine: Correctly mark transparent materials
There are two types of transparent materials: materials that have an
alpha map and materials that have a color map with an alpha channel.
This change makes the latter to be considered transparent.
2022-12-10 11:25:42 +09:00
kichikuou c5b0122d72 ReignEngine: Use glDepthFunc(GL_LEQUAL) when drawing billboards
So that multiple billboards overlapping on a plane are rendered
correctly.
2022-12-10 11:24:38 +09:00
kichikuou f78013b70b Implement R_NOTE instruction
It corresponds to the !== operator.
2022-12-04 17:14:19 +09:00
kichikuou f152f41d0a Implement Data.hll
No AliceSoft game uses this, but it's included in the System4 SDK and
used by some indie games.
2022-12-03 09:47:16 +09:00
kichikuou 6efa31454d Do not use ARCHIVE_MMAP on 32-bit systems
Some games have assets that are too large to mmap everything on a 32-bit
address space. For example, TT3 has a total of 2.82GB of assets, which
is too large for the 3GB address space limit of 32-bit Linux. On Android
it's even stricter and mmaps of hundreds of MB can fail.
2022-11-26 22:29:57 +09:00
Nunuhara Cabbage 31e91cc3ad Merge pull request #81 from kichikuou/font
font_freetype: Consider glyph information for horizontal positioning
2022-11-24 19:25:08 -08:00
kichikuou 638de2057a font_freetype: Consider glyph information for horizontal positioning
When creating a block-sized texture from a glyph, use the bitmap_left
field of FT_GlyphSlot instead of just centering it horizontally.

This improves positioning of punctuation marks in Japanese text.
2022-11-20 12:02:18 +09:00
kichikuou 28f95bfe38 ReignEngine: Implement {Get,Set}InstanceDrawType
Billboards of draw type 1 are drawn with additive blending.
2022-11-20 09:47:10 +09:00
kichikuou 33760da0fa Implement Cursor.Set HLL function
In Toushin Toshi 3, it is used only to show / hide the mouse cursor.
2022-11-19 21:46:11 +09:00
kichikuou 00d1d01353 ReignEngine: Per-mesh control of drawing order
Before this, the order of drawing was determined on an instance-by-
instance basis. Instances with even a single transparent material were
drawn after fully opaque instances.

After this, first the opaque meshes in all instances are drawn, and then
the transparent meshes are drawn from the nearest to the farthest.
2022-11-13 14:20:31 +09:00
Nunuhara Cabbage a3e3232825 Update libsys4 2022-11-11 20:28:45 -08:00
kichikuou 5f17dafdf8 ReignEngine: Set correct initial value for fog parameters
This fixes rendering issue of the model viewer in Alice's Mansion.
2022-11-05 22:17:38 +09:00
kichikuou 581593f9b5 ReignEngine: Support (env) mesh attribute
If specified, the mesh should be rendered with environment mapping
using the material's COLOR_MAP as a matcap texture.
2022-11-05 20:56:26 +09:00
kichikuou 241f631d9d ReignEngine: Set loop frame range for particle effects
Without this, update_motion cannot calculate current_frame correctly
when the effect is used with RE_MOTION_STATE_LOOP state.
2022-11-05 20:56:26 +09:00
kichikuou 814ebb7d3d ReignEngine: Support (sprite) material attribute
If specified, alpha test is used instead of alpha blend.
2022-11-05 20:56:25 +09:00
kichikuou 1a9a2e9753 ReignEngine: Support (nolighting) mesh attribute
In ReignEngine, the mesh name field may contain keywords that change
rendering behavior. The "(nolighting)" keyword disables lighting and
fog.
2022-11-05 20:56:25 +09:00
kichikuou 31823f5731 ReignEngine: Draw instances in z-order
To get correct blending effect for overlapped transparent objects.
2022-11-05 20:56:25 +09:00
kichikuou 88268b084c Fix integer overflow in audio_mixer.c
This fixes a bug in Toushin Toshi 3 where the audio thread crashes when
battle ended, after exploring the second dungeon for (INT_MAX / 44100)
milliseconds (~= 50 secs).
2022-10-22 10:23:22 +09:00
kichikuou 2370052b54 ReignEngine: Fix bone mapping between model and motion
Some motion files (e.g. maidsan_ahoge_* and otokomae_*) have wrong bone
IDs, so bone names should be used to look up matching bones in the
model.

However, this does not always work because masokan.POL has multiple
bones with the same name. In that case ID matching must be used.
2022-10-10 14:20:20 +09:00
kichikuou 252f1b5464 Fix out-of-bounds access in MsgSkip HLL
Toushin Toshi 3 calls MsgSkip.{Get,Set}Flag with msgnum = -1.
2022-10-10 14:20:20 +09:00
kichikuou 5c288f87e5 Implement EFFECT_TV_SWITCH_OFF
Used in Toushin Toshi 3.
2022-10-10 14:20:20 +09:00
kichikuou 3f1d76cd9f Fix text rendering issue in OpenGL ES
This fixes an issue where text is not rendered on Android.

In OpenGL ES3.0, GL_RED is not a valid value for the internalFormat
parameter of glTexImage2D.
2022-10-03 21:59:30 +09:00
Nunuhara Cabbage bc852567f2 Merge pull request #73 from kichikuou/gles
Fix shader compilation errors in OpenGL ES
2022-10-01 10:37:52 -07:00
kichikuou 1ae812ff03 Fix shader compilation errors in OpenGL ES 2022-10-01 16:41:51 +09:00
kichikuou 3615223b52 ReignEngine: Implement alpha mapping 2022-10-01 16:24:20 +09:00