Commit Graph
300 Commits
Author SHA1 Message Date
kichikuou e5cb875f9b Implement DrawGraph.BlendAMapColor and DrawGraph.BlendDA_DAxSA
And fixes DrawGraph.SubDA_DAxSA.
2021-05-08 20:52:48 +09:00
Nunuhara Cabbage 058eee03e5 Fix various issues with SACT2
Ensure that sact_get_sprite always returns a sprite object if sprite
number is not negative. SACT2 functions in general should work before
pixel data is attached to a sprite.

This also fixes the default for the 'show' property (true) and changes
the logic for adding/removing sprites from the scene to be less
error-prone (checked whenever a sprite is dirtied).
2021-05-06 20:11:33 -07:00
Nunuhara Cabbage 9202454ed1 Add stubs for StoatSpriteEngine.SYSTEM_* functions
Also implement StoatSpriteEngine.SP_DeleteAll
2021-05-03 17:41:53 -07:00
Nunuhara Cabbage 0fb1ef1c05 Implement DrawGraph.FillWithAlpha
Used in Vanish!
2021-05-02 18:05:40 -07:00
Nunuhara Cabbage b986789b64 Initial implementation of StoatSpriteEngine
Implement the SP_SetText* and MultiSprite_* functions added by
StoatSpriteEngine (as well as the TRANS_* functions introduced in
SACTDX). Enough to get to the opening movie in Vanish!
2021-05-02 16:07:06 -07:00
Nunuhara Cabbage 863666ed6d Move StoatSpriteEngine impl to separate file
Also clean up some redundant functions in hll/SACT2.c
2021-05-01 22:04:49 -07:00
Nunuhara Cabbage 4f75f2d7ed Refactor sact_graphics.c
Split the code from sact_graphics.c into sprite.c and hll/SACT2.c.
sprite.c contains an index-independent sprite/scene interface, whereas
hll/SACT2.c handles the indexing of sprites.

This is to better support the StoatSpriteEngine.MultiSprite_* functions,
which use a different indexing system.
2021-05-01 13:55:08 -07:00
Nunuhara Cabbage f0fc236903 Implement system.DeleteSaveFile
Used in Vanish!
2021-04-25 19:25:13 -07:00
Nunuhara Cabbage 152aa8275a Implement various things used in Haruka
* system.ExistFunc
* Math.log + Math.log10
* SystemService mixer functions
2021-04-25 15:40:15 -07:00
Nunuhara Cabbage df0f7a590b Implement system.Resume{Read,Write}Comment
Used in お嬢様をいいなりにするゲーム.
2021-04-24 11:00:52 -07:00
Nunuhara Cabbage ffc08d40f0 Implement DrawGraph.SubDA_DAxSA
Used in ほいっぷハニー.
2021-04-22 20:25:47 -07:00
Nunuhara Cabbage f282c69266 Implement DrawGraph.CopyColorReverse
Just a copy operation that inverts colors. Used in Rance VI Sonogo.
2021-04-22 19:20:12 -07:00
kichikuou 843a8cf212 system.GlobalLoad() should not call destructors
Fixes #16.
2021-03-07 10:40:05 +09:00
kichikuou 7fcffc9b34 Use mt19937int in libsys4 2021-02-27 17:23:25 +09:00
kichikuou 3d822bfb37 Gpx2Plus: Implement some basic visual effects
The effect IDs are common with SACT.

Unimplemented effects will fall back to crossfade.
2021-02-21 21:13:56 +09:00
Nunuhara Cabbage 851a19acc1 Work around for FFI heap reallocation bugs
ref types are currently passed to HLL functions as pointers into the
heap. If the HLL function itself needs to allocate memory from the heap,
it can cause the heap to be reallocated, rendering these heap pointers
invalid.

In order to work around this, hll_call now guarantees 64 slots are
available on the heap before calling any HLL function. This is not a
great solution, but it should work to the extent that HLL functions only
allocate a fixed number of heap slots < 64.

This bug could be easily triggered by scrolling up on the message log in
Sengoku Rance.
2021-02-20 20:41:05 -08:00
kichikuou 89c9c9128e Implement DataFile HLL library
It provides access to data tables in *DA.ald, and is used in Big Bang Age.

mt19937int.c is the first standard version of Mersenne Twister,
downloaded from
http://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/VERSIONS/C-LANG/ver980409.html.
2021-02-20 10:17:55 +09:00
Nunuhara Cabbage 2bda2b0ea8 SACT2: only render when scene changes
Track dirty status of scene. This cuts the CPU usage roughly in half at
idle. Could be improved further with damage tracking.
2020-09-06 11:06:43 -07:00
Nunuhara Cabbage 7a5db00085 Merge branch 'mac-opengl' of https://github.com/kichikuou/xsystem4 into kichikuou-mac-opengl 2020-09-03 10:18:43 -07:00
Nunuhara Cabbage a901404d3c Declare global variables extern in headers
Recent versions of gcc seem to emit symbols for unadorned declarations,
leading to linker errors.
2020-09-03 10:15:25 -07:00
kichikuou 7fcacb3c16 Fix OpenGL issues on MacOS
MacOS does not support OpenGL compatibility profile, so the following
changes had to be made:

- Replaced deprecated texture2D() with texture() in shaders
- Renamed `texture` uniform variable to `tex`, to avoid name conflict
- Use VAO, which is mandatory in OpenGL 3 core profile
2020-09-03 23:16:08 +09:00
Nunuhara Cabbage 300f85db72 Clean up ain_get/ain_add functions
These functions should NEVER return a pointer into the ain object, since
its storage can be realloc'd. Now all get/add functions return an index
which can safely be stored for later use.
2020-08-28 19:28:06 -07:00
Nunuhara Cabbage d9e50ab809 Implement DrawGraph.blend 2020-08-27 17:22:03 -07:00
Nunuhara Cabbage b04b0c3018 Implement system.Reset 2020-08-25 17:47:45 -07:00
Nunuhara Cabbage 2813767648 Fix memory leaks in A_PUSHBACK and A_FILL 2020-08-23 12:52:19 -07:00
Nunuhara Cabbage d9d8a201e8 Implement miscellaneous HLL functions
Reduce console spam by implementing some commonly used functions.

DrawGraph.SetFontName
SACT2.Mouse_SetPos
SACT2.Sound_ReverseLR
2020-08-16 19:57:46 -07:00
Nunuhara Cabbage 45ebe96220 Handle explicitly set char spacing
Handle char spacing set up by SACT2.SP_SetTextCharSpace and
DrawGraph.SetFontSpace.
2020-08-15 10:33:23 -07:00
Nunuhara Cabbage 76f7e21c95 Improve stack trace
Stack traces now list addresses in addition to function names.
Additionally, debugger stack traces number each frame, and the numbers
can be used together with the PRINT-LOCALS function to print the values
of local variables for any frame on the stack.
2020-08-10 15:51:33 -07:00
Nunuhara Cabbage 1a0a0e0c12 debugger: breakpoints
This is implemented by inserting special opcodes into the game's code.
When the breakpoint handler is finished, it returns the original opcode
so that execute_instruction can continue executing normally.

E.g.

* start xsystem4 with --debug option to drop into debugger immediately
* run (bp "game_main")
* ^d or \exit to close debugger REPL
* ...drop into a debugger REPL again at the game_main function
2020-08-09 12:41:33 -07:00
Nunuhara Cabbage bd8ad5583a Read configuration from .xsys4rc config file
global config in $XSYSTEM4_HOME/.xsys4rc (default ~/.xsys4rc)
game-specific config in <game-dir>/.xsys4rc

Supported options so far are "font-mincho" and "font-gothic". Syntax is
the same as System40.ini. E.g.

    font-mincho = "/home/user/.fonts/msmincho.ttc"
2020-08-07 19:12:51 -07:00
Nunuhara Cabbage 80f0e7b436 Allow specifying font paths on command line 2020-08-05 19:53:23 -07:00
Nunuhara Cabbage 3f91d84005 Add acxdump and acxbuild tools
Tools for dumping .acx files to csv format and rebuilding them.
2020-08-05 18:59:28 -07:00
Nunuhara Cabbage 3d70c81404 ainedit: support reading HLL declarations 2020-08-01 22:19:00 -07:00
Nunuhara Cabbage 44802acb48 aindump: support Hentai Labyrinth
Even though this game is still ain v14, it makes an incompatible change
to the file format: struct definitions now contain a list of functions
at the end (I believe this is a listing of the struct's vtable).

There is now a system for tracking the minor version of the ain file
format. This is a made up value, determined by the file name of the ain
file.

This commit also fixes an issue where the empty string was being added
as a new string to the string table when rebuilding ain files with
ainedit.
2020-07-31 20:42:08 -07:00
Nunuhara Cabbage c2aae50dca Various improvements to SengokuRanceFont/fnl 2020-07-30 20:55:17 -07:00
Nunuhara Cabbage a8b2e91053 alice-ar: fix bug when extracting linked webp
Need to pass the archive as an argument so that base CGs can be
retrieved.
2020-07-30 20:41:24 -07:00
Nunuhara Cabbage 81a947d74d Partial InputString hll implementation
Not implemented: display of intermediate results.
2020-07-12 16:10:10 -07:00
Nunuhara Cabbage 0e4e52a25d Refactor audio to enable bgm looping
SDL_mixer reads loop information from WAV files if you use the Mix_Music
interface, but NOT the Mix_Chunk interface. So bgm now uses the
Mix_Music interface to get proper looping.

There's also some code here for reading bgi files (taken from xsystem35)
but it's not actually used. There doesn't seem to be a simple way to set
up custom loops with SDL_mixer.
2020-07-12 12:07:40 -07:00
Nunuhara Cabbage 58da6dc167 Refactor system4.h
Move xsystem4-specific declarations to xsystem4.h.
2020-07-12 09:17:52 -07:00
Nunuhara Cabbage f9eaef7717 Fix encoding issue with macro generation
Fixes #2.

The problem here was that init_member_functions assumed ASCII or SJIS
encoding of function/struct names in the ain file. Now it will convert
to UTF-8 when analyzing member functions.

This commit also removes the --ain-encoding option to ainedit.
--output-encoding should always match the encoding of the input ain
file. --transcode can be used to change the encoding before running
running further ainedit commands.
2020-07-11 11:10:18 -07:00
Nunuhara Cabbage d3928c774d jaf: messages and char constants 2020-07-05 22:29:45 -07:00
Nunuhara Cabbage 8bf7e2aa2b jaf: function types 2020-07-05 16:26:06 -07:00
Nunuhara Cabbage 5bc3a05167 ainedit: initial .pje support
Support building from project files used by the official SDK.
2020-07-01 09:41:17 -07:00
Nunuhara Cabbage fd60c6329b jaf: arrays 2020-06-27 13:35:09 -07:00
Nunuhara Cabbage 2331073e7f Use main() return value as exit code 2020-06-22 17:02:58 -07:00
Nunuhara Cabbage 85708c6af1 ainedit: add --silent option
For running compiler tests.
2020-06-22 16:04:49 -07:00
Nunuhara Cabbage ad868aec86 Allow disabling debugger at run time
For running compiler tests.
2020-06-22 16:00:09 -07:00
Nunuhara Cabbage a2012a56ce jaf: support system calls
Only for ain version < 11. Starting with v11 system calls are actually
HLL calls.
2020-06-22 10:14:11 -07:00
Nunuhara Cabbage b41275f6f4 jaf: support multiple input files 2020-06-21 16:50:04 -07:00
Nunuhara Cabbage d4f1b5ba46 ainedit: support creating new ain files
This is mainly for testing purposes. Defaults to creating an ain v4
file, which is the same version produced by the SDK compiler.

Also various small improvements so that output matches the SDK compiler:
* add "0" function (currently does nothing)
* add "NULL" function
* compile null return at the end of every function
* set main function index in ain file
2020-06-21 14:52:05 -07:00