Commit Graph
998 Commits
Author SHA1 Message Date
Nunuhara Cabbage 11e4880def Handle all font weights
System 4 has 4 font weights: light, medium, bold and heavy bold.
SDL_ttf has 2 (normal and bold). For now, xsystem4 treats light/medium
as normal and bold/heavy-bold as bold.
2022-04-05 19:33:56 -07:00
Nunuhara Cabbage e88ae62c08 Remove scene_flip function
It was a bug to call this function outside of sact_Update, because it
set scene_is_dirty to false without first rendering the scene. This can
cause the scene to not be rendered in a timely manner.
2022-04-05 19:31:13 -07:00
Nunuhara Cabbage 8a131d416b Add 'screen' draw method to StoatSpriteEngine
This fixes an issue in Rance 02 where Sill's fire arrow attack had a
black background (reported in #44).
2022-04-05 16:55:47 -07:00
Nunuhara Cabbage 2ca1ce14c5 Fix memory leak in SH_S_ASSIGN_CALLSYS19 2022-04-05 16:40:59 -07:00
Nunuhara Cabbage 5fe61c14d9 Rance 02: render '^' as 'é' 2022-04-04 21:26:23 -07:00
Nunuhara Cabbage 1f239c766f Rance 02: render '}' as dash 2022-04-04 20:17:34 -07:00
Nunuhara Cabbage 6c8b674f0e CharSpriteManager: fix truncated descenders
Fix issue where text descenders would be truncated in games using
CharSpriteManager (e.g. Alice 2010).
2022-04-04 11:32:27 -07:00
Nunuhara Cabbage 89d8210c14 Compatibility hack for Rance 02 (MangaGamer)
The MangaGamer version of Rance 02 has a custom proportional font
implementation which makes assumptions about the font in use. This is
worked around by rewriting their '_CalculateWidth' function to use
fixed-width logic.

I also tried using TTF_SizeUTF8 to get the proper character width but I
found this made the text overflow even worse than using a fixed width
(at least with the default gothic font, perhaps other fonts would fare
better).
2022-04-04 11:20:47 -07:00
Nunuhara Cabbage 6118eef06a Implement EFFECT_UP_DOWN_CROSSFADE 2022-04-04 06:52:51 -07:00
Nunuhara Cabbage 888b491b38 Implement EFFECT_CROSSFADE_LR 2022-04-03 22:35:37 -07:00
Nunuhara Cabbage 26c8f399cb Fix bug in iarray_write_string
Fix bug affecting non-ASCII text in iarray_write_string. This fixes a
bug in ADVLogList_Save/ADVLogList_Load which would cause log text to
become garbled after loading a save.
2022-04-03 21:05:12 -07:00
Nunuhara Cabbage c73842ae75 Fix major memory leak in ADVSceneKeeper
The VM can under no circumstance store it's own data on the heap. Doing
so causes said data to leak into saved VM images. This is the worst kind
of memory leak: even restarting the game will not fix it, because the
data is permanently leaked into the save files.

This will break save compatibility in games that use ADVSceneKeeper
(e.g. Alice 2010 games).
2022-04-03 20:38:28 -07:00
Nunuhara Cabbage fbfa5bbb5f Fix memory leak in ADVLogList_Save 2022-04-03 15:12:41 -07:00
Nunuhara Cabbage f01f002a54 Improve performance of vm_save_image
cJSON_AddArrayItem is O(n), which made saving arrays O(n^2). This was
causing extremely poor performance when saving large arrays, such as
those created by MultiSprite_Encode.

A special cJSON_CreateIntArray_cb function is now used instead, which
can create and populate an array in O(n).
2022-04-03 13:42:36 -07:00
Nunuhara Cabbage 5713742a99 Implement MultiSprite_Encode/MultiSprite_Decode 2022-04-03 13:41:34 -07:00
Nunuhara Cabbage 47cb99927d Update libsys4 2022-04-02 08:32:48 -07:00
Nunuhara Cabbage ae0832921f Fix build error when chibi scheme not present 2022-04-02 07:44:27 -07:00
Nunuhara Cabbage 9fbc9ec5b7 Implement simple command-based debugger interface
Add a new debugger interface using a simple command language. This is
less powerful than the scheme interface (which still exists) but more
ergonomic for interactive debugging.

This debugger has no external dependencies (it will however use readline
if available) and is included in builds by default.

A sample interaction might look like:

    xsystem4 --debug /path/to/game
    dbg(cmd)> breakpoint bar
    Set breakpoint at function 'bar' (0x00001234)
    dbg(cmd)> continue
    Hit breakpoint at function 'bar' (0x00001234)
    dbg(cmd)> backtrace
    #0 0x00001234 in bar
    #1 0x00002222 in foo
    #2 0x00004444 in main
    dbg(cmd)> locals
    [0] i: 2
    [1] s: "baz"
    dbg(cmd)> locals 1
    [0] j: 3
    [1] obj: { m_i = 0; m_s = "" }
    dbg(cmd)> quit
2022-04-01 19:38:55 -07:00
Nunuhara Cabbage 0780442e13 Install debugger.scm to XSYS4_DATA_DIR 2022-03-28 17:54:26 -07:00
Nunuhara Cabbage ba0b97e163 Use UTF-8 file functions
Use functions which expect UTF-8 encoded file names (and convert them to
UTF-16 on Windows).

This should fix various issues on Windows when reading/writing files
with Japanese characters in their names.
2022-03-28 16:50:45 -07:00
Nunuhara Cabbage 73eb1d0e34 Merge branch 'master' of github.com:nunuhara/xsystem4 2022-03-27 15:47:09 -07:00
Nunuhara Cabbage 5dfb82afd7 parts: ConstructionProcess (WIP)
A very partial implementation of some ConstructionProcess functionality.
2022-03-27 15:40:18 -07:00
Nunuhara Cabbage 411022b0b3 Add -v,--version option alpha-411022b 2022-03-27 14:16:24 -07:00
Nunuhara Cabbage c12ecef566 Display error message for invalid argument
If the game can't be initialized with the given command line argument,
display an error message and exit.
2022-03-27 13:55:07 -07:00
Nunuhara Cabbage bae291bcc9 Merge pull request #43 from kichikuou/widenyo
Support Widenyo
2022-03-26 15:40:48 -07:00
kichikuou e047ae1c85 Do not call destructors on uninitialized structs in json_to_vm_value()
For structs / arrays, json_to_vm_value() calls json_load_page() on
freshly allocated pages for which no constructor has been called.
json_load_page() should not call destructors for such uninitialized
pages.

json_load_page() is also called by BanMisc.LoadStruct and File.Read,
with an initialized struct. In that case destructors should be called.

This fixes crash in Widenyo after system.GroupLoad.
2022-03-25 12:06:00 +09:00
kichikuou f725e4e830 Implement ChrLoader.LoadWavFile 2022-03-25 10:49:25 +09:00
kichikuou ba1dcd6e21 Fix StoatSpriteEngine.SP_SetDrawMethod
The method parameter of this function has a different meaning from that
of SACT2.SP_SetDrawMethod.

I've only checked it in Widenyo, but it seems 0 and 1 are valid values
and 1 is additive blending.
2022-03-25 10:49:25 +09:00
kichikuou 6d34f0e18d Implement ChrLoader HLL
For Widenyo.
2022-03-25 10:30:18 +09:00
kichikuou 2707bc9a7e Implement MapLoader HLL
For Widenyo.

Now sprite_set_cg() takes a struct cg, so that CG can be loaded from
custom sources such as .map file.
2022-03-25 10:29:30 +09:00
kichikuou 94d7e0cd5d Add stub for SoundFilePlayer
For Widenyo.
2022-03-24 22:00:35 +09:00
kichikuou a76948244e Implement two SystemService.dll functions
For Widenyo.
2022-03-24 22:00:35 +09:00
kichikuou 1e3bf3507a Implement FileOperation.ExistFolder
For Widenyo.
2022-03-24 22:00:35 +09:00
kichikuou 382dc0d0bd Implement R_EQUALE, SH_STRUCTREF_GT_IMM and SH_STRUCT_ASSIGN_LOCALREF_ITOB
Used in Widenyo.
2022-03-24 22:00:19 +09:00
kichikuou fc41239175 Remove include/file.h
It was an outdated duplicate of system4/file.h.
2022-03-21 21:23:20 +09:00
kichikuou f53fcf4bf9 Add subprojects/cglm to .gitignore 2022-03-20 14:35:49 +09:00
Nunuhara Cabbage 5b2f9d7536 Refactor GoatGUIEngine and add misc. stubs
Refactor GoatGUIEngine into various files under src/parts/.
The external interface to this code is the functions prefixed with PE_
and generally following the naming of the HLL functions which they
implement.

The reason for this is that there are multiple HLL libraries that
implement more or less the same GUI interface (GoatGUIEngine, GUIEngine
and PartsEngine).

Also added here are a number of miscellaneous stubbed-out HLL functions
that are used by Rance 01 (which now runs up to the point where it tries
to create the title menu).
2022-01-30 10:12:20 -08:00
Nunuhara Cabbage 9904754f06 Add interface for loading CGs by name 2022-01-30 10:03:59 -08:00
Nunuhara Cabbage 6f750e4007 More delegate fixes
1. DG_CALL has to clean up the stack before jumping to the return
   address.
2. DG_SET (contrary to its name) is an append operation; it's basically
   a combination of DG_NEW_FROM_METHOD and DG_PLUSA.
3. DG_SET and DG_PLUSA need to check for and ignore duplicates.
4. Delegate pages store *references* to structs; the VM should NOT copy
   the struct page when copying a delegate page.
2022-01-29 09:55:42 -08:00
Nunuhara Cabbage f0fdb714e5 Implement SH_STRUCTREF_GT_IMM 2022-01-24 15:44:43 -08:00
Nunuhara Cabbage b7aaa1897b Implement A_SORT_MEM
Sorts an array of structs by a given member.
2022-01-23 15:11:48 -08:00
Nunuhara Cabbage 67b9923ee9 Fix system.GetFuncStackName
This function returns the empty string when the index is invalid.
2022-01-23 14:46:55 -08:00
Nunuhara Cabbage bdf79f99d3 Fix delegates implementation
Delegate page+index is stored on the stack, not part of VM state. It
gets shuffled around via DG_CALLBEGIN.
2022-01-23 14:42:39 -08:00
Nunuhara Cabbage bd0b488a75 Don't call "0" function if it doesn't exist
To support .ain files produced by sys4c which doesn't create the global
alloc function (yet).
2022-01-23 10:33:29 -08:00
Nunuhara Cabbage 48ba715e15 Merge pull request #42 from kichikuou/audio
Fix out-of-bounds access in audio_mixer.c
2022-01-09 21:23:18 -08:00
kichikuou 0f4ae8a789 Fix out-of-bounds access in audio_mixer.c
When cb_loop() set ch->voice to -1, out-of-bounds access occured in
refill_stream() here:

    mixers[ch->mixer_no].mixer.voices[ch->voice].gain = gain;

cb_loop() shouldn't need to change ch->voice, because refill_stream()
does that when cb_loop() returns false.
2022-01-10 13:42:10 +09:00
Nunuhara Cabbage 59b908db87 Merge pull request #41 from kichikuou/glsl
Fix shader compilation errors in OpenGL ES
2022-01-08 10:12:46 -08:00
Nunuhara Cabbage 6d70d28be1 Merge pull request #40 from kichikuou/resize
Make the window resizable
2022-01-08 10:08:22 -08:00
kichikuou e0466dfb7c Fix GLSL ES compile errors
Implicit conversion between int and float is not supported in GLSL ES.
2022-01-08 15:10:38 +09:00
kichikuou cf6469c7c4 Print shader compile error messages 2022-01-08 15:06:37 +09:00