mag_speed is a per-plugin integer (default 1) set by SetMagSpeed on
all existing plugins. use_mag_speed is a per-instance flag (default
true) set by SetInstanceUseMagSpeed. When use_mag_speed is true,
motion delta_frame is multiplied by mag_speed.
This implements Parts_SetDrag and drag/drop event handling. When a part
has drag enabled, clicking and moving the mouse will move the part and
emit DRAG_BEGIN/DRAGGING/DRAG_END messages. Drop target detection emits
DROP_ENTER/DROP_ON/DROPPED/DROP_LEAVE messages on parts under the cursor
during drag.
This adds PARTS_LAYOUT_BOX parts type with support for automatic
horizontal/vertical child positioning. Layout calculation runs during
the component update cycle, repositioning children before their global
parameters are combined.
This implements SetPassCursor/GetPartsPassCursor HLL functions. The
pass_cursor flag controls whether the cursor "passes through" a
component to reach parts behind it.
Key changes to input processing:
- Iteration order changed from back-to-front to front-to-back for proper
cursor consumption
- MOUSE_ENTER / MOUSE_LEAVE now fire for all parts regardless of
clickable
- Click hit test uses clickable || !pass_cursor pre-filter
- pass_cursor=false parts consume the cursor, preventing hover and
click events from reaching parts behind them
PartsEngine in Rance 9 manages multiple "controllers" (called "layers"
in game scripts) that provide part grouping, draw-order control, and
bulk release. This implements the core controller API:
- AddController / RemoveController: push/pop a controller on the
stack. RemoveController releases all parts belonging to the removed
controller and returns their IDs in erase_number_list.
- SetActiveLayer / GetActiveLayer / GetSystemOverlayLayer: control
which controller newly created parts are assigned to. The system
overlay controller is a special controller that always renders on
top and survives ReleaseAllWithoutSystem.
- ReleaseAllWithoutSystem: releases all parts except those in the
system overlay controller and re-initializes the controller stack.
Controllers are identified by their position in the stack (0 = bottom).
Draw ordering uses the scene's two-level sprite sorting: sp.z is set to
the controller's stack index and sp.z2 to the part's Z value, so parts
in higher controllers always render above lower ones regardless of
individual Z values. When the parts_multi_controller flag (see below) is
false, the original Z ordering is preserved (allowing Z-interleaving
with non-parts scene sprites -- see #180) for compatibility with games
that do not use controllers.
Save/load of the controller stack and per-part controller_no is gated on
a parts_multi_controller flag (set at PreLink time when the game's HLL
exports AddController) rather than a save version bump. This keeps the
save format stable for games that do not use controllers, while allowing
the save format to evolve freely during development.
This adds PARTS_MOVIE type which creates a SACT sprite as a render
target for DrawMovie.
The GL texture is shared between the SACT sprite and parts_common, so
movie frames rendered to the sprite are directly visible through the
parts engine's rendering path.
In Rance 9 (and Blade Briders), KiwiSoundEngine looks up BGM and sound
files in archives by name formatted as "%05d" rather than by archive
index. Since the Sound_Seek function only exists in these games' HLL
definitions, its presence is used to switch Music_IsExist, Music_Prepare,
Sound_IsExist and Sound_Prepare to name-based lookups at PreLink time.
The meaning of the method parameter is the same as that of
StoatSpriteEngine.SP_SetDrawMethod.
This fixes a visual issue in Pastel Chime 3's battle scene.
This HLL provides functionality for loading, managing, and rendering
animations stored in the MAD file format. A MAD file consists of a
header followed by a series of QNT image frames.
Previously, the debugger displayed `ref int` variables like this:
ref_int: <unsupported-data-type>
<void>: <unsupported-data-type>
This commit introduces `dbg_variable_to_string()` to dereference these
variables and display their underlying value. Both the command-line and
DAP debugger interfaces have been updated to use this new functionality.
This function is responsible for generating random dungeons for Pastel
Chime Continue.
The dgn_generate_drawfield() function implements the main logic. This
algorithm constructs the dungeon through a multi-step process involving
room creation, recursive expansion, wall placement, treasure room
generation, and corridor pruning/extension.
AutoDungeonE_Create() calls this function to create a layout based on
specified parameters, and then populates arrays with the proposed
coordinates of items, enemies, and traps.
This implementation strives to faithfully reproduce the behavior of
DrawField.dll, including its bugs, although it has not been strictly
verified.
In hll_call(), pointers to heap data passed by reference could become
invalid if the heap was reallocated during the call.
The previous implementation attempted to prevent this by calling
heap_guarantee() to pre-allocate heap space. However, this approach
does not work for certain functions in PastelChime2 HLL, which can
perform an unbounded number of heap allocations.
This commit removes heap_guarantee() and replaces it with a more robust
copy-in/copy-out strategy:
- Before the call (Copy-in): For reference arguments, the pointer value
is copied from the heap to a local variable on the stack. A pointer to
this local variable is then passed to the HLL function.
- After the call (Copy-out): The pointer value, which may have been
modified by the HLL function, is written back from the local variable
to its original slot in the heap.
This HLL implements the core gameplay logic for the 3D dungeon
exploration mode.
Key features:
- Collision and Movement:
- Implements 2D collision detection for player movement against walls.
- Field_CalcMove() function calculates the desired position and
adjusts it to slide along walls upon collision.
- Party and AI Mechanics:
- Field_UpdatePlayersUnit() manages party movement, creating a smooth,
snake-like following behavior for up to two companions.
- Field_UpdateEnemyPos() provides basic enemy AI, enabling them to
chase the player when in line-of-sight and within range, or return
to a base position otherwise.
- Interactive Environment:
- Field_UpdateDoors() implements automatic doors that open and close
based on player proximity.
- Field_CheckObjectHit() detects when the player enters the hit-range
of an object, triggering events.
- 3D Space UI:
- Adds dungeon_project_world_to_screen() to translate 3D world
coordinates into 2D screen positions.
- Field_UpdateObjectNamePlate() and Field_UpdateDoorNamePlate() use
this projection to display and manage interactive nameplates for
objects and doors.
- Data Persistence:
- DungeonDataSave() and DungeonDataLoad() serializes and deserializes
the complete dungeon state to .DSD files.
- Integrates dungeon data with the main save system by copying .DSD
files to/from slot-specific .DSA files.
Note: The most complex function in this HLL, the dungeon generator
AutoDungeonE_Create(), is not implemented in this change.
DrawField is a variant of DrawDungeon. Unlike the first-person
perspective of DrawDungeon, DrawField uses a third-person, bird's-eye
view camera.
Key features include:
- Character Rendering: A new system to render up to 256 billboarded
sprites (characters, enemies, etc.) in the 3D world. The renderer
supports controlling position, sprite animation, and visibility for
each character.
- DrawField HLL API: Functions for loading assets, managing characters,
and manipulating dungeon properties like door locks.
- Renderer: The core renderer is updated to support the DrawField mode.
This includes disabling fog, handling sprite sheets via UV
manipulation, and rendering ceilings as billboards.
- Map: The 2D map has been updated to reflect the DrawField style,
including colored door lock indicators.
* dtx_load_from_dtl() loads lightmap textures.
* dgn_calc_lightmap() calculates lightmap texture index for each cell
based on the state of the surrounding walls.
Early versions of System4 (Sys42VM.dll < 3.0) execute destructors for
global variables on exit.
Dungeons & Dolls saves its game state in the destructors of global
variables (~CDataDoll(), ~CDataItem(), ~CDataMain()), so the game was
not saved in xsystem4 before this.
This behavior has some quirks:
* Destructors for variables on the call stack are not called on exit.
* Destructors are called in the reverse order of the global variable
declarations.
* Inside a destructor, it is possible to access another global variable
whose destructor has already been called (!).
Since this is a problematic behavior that was removed in later versions
of Sys42VM, let's add minimal support for it as a game-specific hack.
Texture.dtl contains multiple sets of wall, floor, and ceiling texture
images. dtx_load_from_dtl() randomly selects a texture set using the
floor number as the random seed and returns it as a dtx structure.
In DrawDungeon2, dungeons are generated randomly using a dedicated
random number generator (mtrand43.c), which is a Mersenne Twister with
N=4, M=3.
The entry point for map generation is dgn_generate_drawdungeon2(),
which deterministically generates a floor map using the floor number as
the random seed.
I verified that generated floor layout, player starting position,
exit, and treasure chest locations match the original DrawDungeon2.dll
up to the 1000th floor.
Some classes in Dungeons & Dolls serialize themselves using
`File.Write(this)` in their destructors. Because `File.Write` takes the
argument by value, a copy of `this` is created. If the destructor is
called on the copied `this`, it falls into an an infinite loop.
Skinned models can have multiple texture images for animation. When a
material colormap in the .pol file is `image.png`, additional images are
stored with names like `image[1].png`, `image[2].png`, etc.
Animation frame information is stored in `<motion_name>.txa` file. This
is a text file containing newline-separated integers, specifying the
texture index for each motion frame.