Commit Graph
300 Commits
Author SHA1 Message Date
kichikuou 803bb1a8a4 ReignEngine: Fix BackCG issues
- Enable both alpha map and alpha mod, using the new drawing function
  gfx_copy_stretch_blend_amap_alpha().
- Do not draw if `bcg->show` flag is false.
- Do not WARNING() for SetBackCGNum(0) as it's used to unload the CG.
2022-09-11 21:08:54 +09:00
kichikuou 0ff9c5a62c ReignEngine: Add loader for particle effects
This implements a parser for particle effect definition files (.pae)
and a set of field accessor functions for the RE_ITYPE_PARTICLE_EFFECT
instance type. Rendering of effects is not yet implemented.
2022-09-04 10:17:03 +09:00
kichikuou 06a630ea62 ReignEngine: Implement Fog
There are two types of fog, linear fog and atmospheric scattering. The
formula for light scattering is incorrect (see the comment in
reign.v.glsl) and therefore not physically correct.
2022-08-06 09:38:48 +09:00
Nunuhara Cabbage 3e536af09a Implement DG_ADD, DG_EXIST, DG_ERASE 2022-08-02 18:16:16 -07:00
kichikuou d185ae71bf ReignEngine: Implement CalcInstanceHeightDetection
This is used to compute Y-positions of map objects.

It is called quite often, so this implementation creates and caches a
height map of the instance by (re)using the shader for shadow mapping.
2022-07-30 15:17:08 +09:00
kichikuou 233b2a4f20 ReignEngine: Implement shadow mapping 2022-07-24 16:01:16 +09:00
kichikuou b0e540e67b gfx: Expose low level shader loading function
And use it in 3d/. This gives more flexibility on vertex attribute /
uniform variable configurations.
2022-07-24 16:01:16 +09:00
kichikuou 2918a6310c ReignEngine: Remove hard limit on number of instances
Some maps in Toushin Toshi 3 have more than 32 instances.
2022-07-23 21:41:41 +09:00
kichikuou e7c9410df4 ReignEngine: Implement two functions
GetInstanceBoneIndex and TransInstanceLocalPosToWorldPosByBone.
2022-07-18 13:01:49 +09:00
kichikuou 3343efbcb9 Implement ReignEngine.BuildModel
Instance motions are updated with this function.
2022-07-17 16:20:02 +09:00
kichikuou c86ca5de87 ReignEngine: Implement bump mapping 2022-07-16 12:59:35 +09:00
Nunuhara Cabbage 2e23554162 Implement SACT2.Joypad_GetAnalogStickStatus 2022-07-09 17:35:07 -07:00
kichikuou b42032c9f8 ReignEngine: Implement basic lighting
This implements a Phong shading with ambient, diffuse and specular
components, using up to three directional lights and one specular light.

The light calculation is made to match the "high quality" 3D mode of
Toushin Toshi 3.
2022-07-09 14:36:44 +09: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 9f42ee379d Improve performance of vm_image_to_json
Use a callback-based function to create the heap JSON array. This avoids
the O(n) insertion time of cJSON_AddItemToArray.
2022-06-25 10:00:24 -07:00
Nunuhara Cabbage 96f307838f Merge branch 'master' of github.com:nunuhara/xsystem4 2022-06-24 18:02:14 -07:00
Nunuhara Cabbage fc42c42ef5 parts: refactor parent-child handling
Parent-child relationships are established by the UpdateComponent
function. Parts_SetParentPartsNumber does not establish the relationship
(and it does not create the parent object if it does not exist yet).

Render params are now computed recursively on children when they are set
on the parent (instead of recomputing them every time a child parts is
rendered).
2022-06-24 17:54:25 -07:00
Nunuhara Cabbage 8ee136b287 parts: various fixes and improvements
* SetAddColor and SetMultiplyColor implemented
* additive draw filter implemented
* GetPartsUpperLeftPos{X,Y} implemented
* various parameters are now applied from parent to child parts
* misc. bug fixes

The first dungeon screen in Rance 01 now renders correctly.
2022-06-21 19:57:36 -07:00
kichikuou d11116f647 ReignEngine: Support billboard instance type
Used for 2D objects (e.g. NPCs in dungeons).
2022-06-19 12:19:41 +09:00
kichikuou 3851dc7c6a ReignEngine: Add RE_instance_type enum
This is in preparation for supporting non-polygon instance types.
2022-06-19 11:51:13 +09:00
Nunuhara Cabbage 25695c3e86 parts: implement GUIEngine numerals
Implement Parts_SetNumeralLinedCGNumberWidthWidthList and
Parts_SetNumeralLength.

Also fix bugs where changing numeral properties would not update the
texture until the number was reset.
2022-06-18 10:53:43 -07:00
kichikuou 1568d63117 ReignEngine: Implement background CG functions
This also moves debug print functions to a separate file.
2022-06-18 10:32:49 +09:00
Nunuhara Cabbage a6913af2bc parts: implement more ConstructionProcess ops
Implement Fill, FillAMap, DrawCutCG and CopyCutCG operations.
2022-06-17 16:08:30 -07:00
Nunuhara Cabbage 8ff4fa8666 parts: various fixes and improvements
The title screen in Rance 01 now functions as expected.
2022-06-16 19:13:36 -07:00
Nunuhara Cabbage e68ff819de fnl: adjust for edge width in layout
Account for the edge width when doing text layout in games that use .fnl
fonts (except for the MangaGamer version of Sengoku Rance).
2022-06-14 20:51:34 -07:00
Nunuhara Cabbage d79020656c debugger: command modules
Allow adding groups of commands to the debugger at run time. This is
currently used only by GUIEngine.
2022-06-12 14:29:46 -07:00
kichikuou db97942393 Implement ReignEngine.SetInstanceAlpha 2022-06-12 21:27:49 +09:00
kichikuou 442ebce079 Add debug_print method to draw_plugin
Plugins can implement this so that scene_print will print additional
information for the sprite. RE_plugin implements this to dump the 3D
scene information.
2022-06-11 13:43:59 +09:00
kichikuou a2bbe15b20 ReignEngine: Implement skeletal animation 2022-06-11 13:28:02 +09:00
Nunuhara Cabbage caec854ed8 Implement scene_print function
Add a scene_print function which prints a textual representation of the
current scene. This works by attaching a `debug_print` function to each
entity in the scene. This function is implemented for SACT2 and
GUIEngine entities. A default implementation will be used of none is
provided.

This can be accessed from the debugger via the `scene` command (although
the output is typically too much to view in a terminal; it's better to
run `scene_print` somewhere and redirect stdout to a file).
2022-06-10 19:18:10 -07:00
Nunuhara Cabbage 7e04db958b parts: implement more ConstructionProcess ops
Implement Create, CreatePixelOnly, DrawText and CopyText operations.
2022-06-10 15:28:08 -07:00
Nunuhara Cabbage 1484a207c5 Implement GUIEngine.{Set,Get}DelegateIndex 2022-06-08 17:09:47 -07:00
Nunuhara Cabbage 09f2c3e1ed parts: implement Parts_Set*SurfaceArea functions
These functions apply a clipping rectangle to the parts texture.
2022-06-08 16:51:06 -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 81ff379eb8 Avoid iterating over the scene for plugins update
Now plugin is a member of sact_sprite, and sprite.c manages a list of
sprites with plugins.
2022-05-31 18:13:08 +09:00
kichikuou fd4cd139f8 Introduce draw_plugin
This introduces draw_plugin struct that can be attached to a sprite.
The update() function of attached plugin is called every frame by
sact_Update(). This corresponds to the DrawPlugin mechanism of
System4/SACT2.

This is currently used only from DrawDungeon. The 3D engine for Toushin
Toshi 3 etc. will also use this.
2022-05-30 11:41:20 +09:00
Nunuhara Cabbage 1fd475813d Remove unused headers 2022-05-15 09:23:11 -07: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 128edda6c0 text: fix outline cropping issue
Fix issue where outlines would get cropped when crossing the glyph
texture boundary.

This is accomplished by adding 4 border pixels to each glyph texture.
2022-05-10 19:53:31 -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 0b98e57938 Don't decode little endian on x86/x86_64 2022-05-06 19:27:30 -07:00
Nunuhara Cabbage 6080af3621 Implement Sound_GetGroupNumFromDataNum
Part of StoatSpriteEngine and KiwiSoundEngine.

This fixes an issue with per-channel volume settings not working
correctly in Haruurare (and presumably other games).
2022-05-04 20:30:03 -07:00
Nunuhara Cabbage 5924225bc2 Implement DrawGraph.BrightDestOnly 2022-05-03 21:08:01 -07:00
Nunuhara Cabbage 7fc60f6607 Implement DrawGraph.ScreenDA_DAxSA 2022-05-03 20:48:21 -07:00
Nunuhara Cabbage 44891458f1 Implement DrawGraph.SaturDP_DPxSA 2022-05-03 20:01:48 -07:00
Nunuhara Cabbage 703a66106f Implement DrawGraph.FillMultiply 2022-05-03 18:57:06 -07:00
Nunuhara Cabbage af33413826 Implement DrawGraph.FillScreen 2022-05-03 18:53:55 -07:00