Commit Graph
88 Commits
Author SHA1 Message Date
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
Nunuhara Cabbage 6e3a3e784a jaf: strings and reference types 2020-06-20 21:05:14 -07:00
Nunuhara Cabbage 2908e6fcdc jaf: initial compiler implementation
Supports reading from local variables (no assignment) and arithmetic.
2020-06-16 20:38:29 -07:00
Nunuhara Cabbage d8e21d0323 jaf: support parsing identifiers & function calls 2020-06-14 15:54:59 -07:00
Nunuhara Cabbage e618017e78 ainedit: support parsing .jaf functions 2020-06-13 13:36:39 -07:00
Nunuhara Cabbage 897cbde39c ainedit: initial .jaf support
Initial support for compiling .jaf (System 4 language) files. So far
this is limited to adding struct definitions and declaring new globals.
The actual bytecode compilation is not yet implemented.

This Bison grammar is based on a C grammar and should cover 95% of the
System 4 language syntax already, though many AST nodes are not yet
implemented.
2020-06-10 21:23:00 -07:00
Nunuhara Cabbage 767e2afd57 alice-tools 0.4.0
Fix some Windows-specific issues for alice-ar and update READMEs.
2020-05-23 17:46:00 -07:00
Nunuhara Cabbage 8f38b6141e alice-ar: various improvements
* Can now extract files from .afa version 3 archives
* Can now extract files from .flat files
  * Includes recursively extracting .flat files contained in other
    archive formats
* Added option to extract images only
* Now converts images to PNG format by default
  * WebP format also supported

Because the table of contents is encrypted in .afa version 3 archives,
the support is a bit limited. Only known file types can be extracted and
they do not retain their original filenames (they are given numbered
filenames instead).
2020-05-23 12:33:40 -07:00
Nunuhara Cabbage 9ab13af34e DCF CG support
For alice-ar. This is a wrapper format for QNT CGs. I have no idea what
the additional metadata is for.
2020-05-21 16:30:12 -07:00
Nunuhara Cabbage 05d998886f exdump/exbuild: fix issues with Evenicle2EX.ex
Evenicle2EX.ex uses the previously unknown field data in a different way
that what was assumed. Thanks to that, the unknown data is now more or
less understood:
  * uk0 indicates whether there is a value associated with the field
  * uk1 indicates whether the field is an index
  * uk2 is the value associated with the field, which can be an integer,
    float or string (so far, at least...)

Previously it was assumed that uk2 was a single 32-bit integer, but it
can actually store strings as well. Evenicle 2 is the first game to use
a field with a string value other than the empty string, which breaks
this assumption (the empty string is a 32-bit zero, which is why the old
approach worked).

There is now a new syntax for specifying this data. E.g., a field may
now look like this:
    indexed string s = ""
where it would previously have looked like this:
    string s[1,1,0]

The old syntax is still supported in ainbuild for backwards
compatibility, but is no longer emitted by aindump.

This commit also adds the tool "excmp" which compares two ex files to
see if they are equivalent.
2020-05-18 10:34:43 -07:00
Nunuhara Cabbage b617449178 aindump/ainedit: initial ain v14 support
Support for Evenicle 2 and Haha Ranman.

There are a few changes in v14:
* a number of new instructions (semantics yet unknown)
* HLL function arguments and return values can now be complex types
  (e.g. arrays, enums)
* support for nested arrays (this isn't necessarily new, but it doesn't
  occur in Rance X at all)
2020-05-17 13:21:37 -07:00
Nunuhara Cabbage bf9ce85079 exdump: fix for broken table in Rance 03
Rance03.ex has a broken table in which a field type does not match the
type of the data in the corresponding column. So rather than aborting
with an error, exdump will now print a warning when dumping this file.
2020-05-01 17:55:55 -07:00
Nunuhara Cabbage 094ce848b9 aindump/ainedit: STRUCTREF, etc. macros
Same idea as LOCALREF/GLOBALREF, etc. except for accessing struct
members inside of a member function. This is a bit trickier since it
requires knowing which functions belong to which structs, which isn't
directly encoded in the AIN format.
2020-05-01 16:31:12 -07:00