Commit Graph
998 Commits
Author SHA1 Message Date
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
kichikuou b23d05bcc2 ReignEngine: Load material parameters from .amt file 2022-07-09 14:36:40 +09:00
Nunuhara Cabbage 8b6d4943b3 Implement SH_A_FIND_SREF
Used in Rance 01.
2022-06-26 20:41:56 -07:00
Nunuhara Cabbage a78f5348f3 Fix memory leak in PassRegister 2022-06-26 20:15:52 -07: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 be2b1421f1 Merge pull request #59 from kichikuou/Toushin3Loader
Toushin3Loader: Fix use-after-free after VM reset
2022-06-26 08:26:33 -07:00
kichikuou 60e9696a23 Toushin3Loader: Fix use-after-free after VM reset 2022-06-26 21:15:59 +09: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 3a40542aab parts: fix bug with INT_MIN in numeral object
Use 64-bit integer to avoid overflow when creating numeral for INT_MIN.
2022-06-25 09:22:11 -07:00
Nunuhara Cabbage 841947d544 Fix delegate memory management and FT_ASSIGNS
Each delegate call needs to copy its arguments so that they aren't
double-freed by the next call.

Also fix a bug in FT_ASSIGNS where -1 was returned for non-existant
functions instead of 0.
2022-06-25 09:20:22 -07:00
Nunuhara Cabbage c14e7bd218 Ignore extension in asset_get_by_name
Fixes bug when starting battle in Rance 01.
2022-06-24 18:40:36 -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
Nunuhara Cabbage 37cd4ac179 Fix save/resume issue with delegate pages 2022-06-19 16:52:08 -07:00
Nunuhara Cabbage 57b93839be parts: fix render order (again)
The render order is determined by the sum of the parts' z-value and the
z-values of its parents.
2022-06-19 15:42:00 -07:00
Nunuhara Cabbage ed31e25a38 Merge pull request #58 from kichikuou/billboard
ReignEngine: Support billboard instance type
2022-06-19 08:44:04 -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
Nunuhara Cabbage e1872edb5a parts: fix render order of child parts
The parent's z-value determines the render order of its children.

Alicesoft's implementation of this is a bit weird. The render order only
changes when the parent's visibility is toggled (via Parts_SetShow), NOT
when the parent is set on a child or the parent's z-value changes.

I have chosen to implement this so that the render order is always based
on the current parent/child z-values.

This fixes some bugs in Rance 01.
2022-06-18 09:11:28 -07:00
Nunuhara Cabbage 7ecbc808c6 Merge pull request #57 from kichikuou/backcg
ReignEngine: Implement background CG functions
2022-06-17 19:44:04 -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 790502c51f Merge branch 'master' of github.com:nunuhara/xsystem4 2022-06-17 17:02:42 -07:00
Nunuhara Cabbage ad83a0cd39 Fix ChipmunkSpriteEngine.SP_GetFontWidth
Use gfx_size_text. Fixes text layout issue in Rance 01.
2022-06-17 16:54:14 -07: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 ced0a832cc Implement ChipmunkSpriteEngine.Sleep 2022-06-16 09:47:26 -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 bbe8b4053f Implement CommonSystemData library
Except for the LoadAtStartup function.
2022-06-14 20:41:51 -07:00
Nunuhara Cabbage 554d9708da Merge pull request #56 from kichikuou/MonsterInfo
MonsterInfo: Fix SEGV, clean up
2022-06-13 16:32:43 -07:00
kichikuou 7effe8920a MonsterInfo: Fix SEGV, clean up
Fixes a crash bug when attempted to get a string property of nonexistent
motion.

This also fixes compiler warnings, and simplifies the code by using
helper functions.
2022-06-13 20:54:59 +09:00
Nunuhara Cabbage 20d5820efc parts: add PARTS_UNINITIALIZED parts type 2022-06-12 19:23:02 -07:00
Nunuhara Cabbage e78119bf5a parts: refactor pos/size handling
Move position/size values around and rename them to reflect what they
actually mean:

* parts->offset moved to parts_common->origin_offset
* parts->pos moved to parts_common->hitbox
* x and y coordinates from parts->rect renamed to parts->pos
* width and height from parts->rect moved into parts_common
2022-06-12 19:03:41 -07:00
Nunuhara Cabbage b60cce3e8f parts: handle zero surface area at render time
Check for uninitialized or explicitly zeroed surface area at render
time. This fixes an issue where some construction process parts would
not be rendered (specifically, the button text on the Rance 01 title
screen).
2022-06-12 14:44:08 -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
Nunuhara Cabbage 49774fa4b6 Merge pull request #55 from kichikuou/SetInstanceAlpha
Implement ReignEngine.SetInstanceAlpha
2022-06-12 09:41:07 -07:00
kichikuou db97942393 Implement ReignEngine.SetInstanceAlpha 2022-06-12 21:27:49 +09:00
Nunuhara Cabbage 06949f59e8 Merge pull request #54 from kichikuou/motion
ReignEngine: Implement skeletal animation
2022-06-11 20:24:00 -07:00
kichikuou 315c7e6a50 Fix memory leaks in RE_instance_load_{,next_}motion 2022-06-12 08:52:44 +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 7205570611 parts: make construction process a parts type 2022-06-07 16:25:00 -07:00
Nunuhara Cabbage 7223d4d6aa Fix bug in afa_get_by_id
Fix bug where asset_get would return unloaded files from afa archives.
2022-06-06 18:18:17 -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