Commit Graph
284 Commits
Author SHA1 Message Date
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 98aa213f41 ainedit: fix bugs identified in #2
Treat CR characters as whitespace and remove redundant/buggy string hash
table from asm.c.
2020-07-12 06:19:38 -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 0113e34eaa jaf: refactor declarations
struct definitions are now a type of declaration, instead of being part
of a type specifier. They can only be declared at top-level, and
variables can no longer be attached to the declaration.
2020-07-10 17:25:36 -07:00
Nunuhara Cabbage 3c3150cf63 jaf: fix bug in string processing
Token passed to jaf_process_string can contain whitespace at the end.
2020-07-06 17:30:02 -07:00
Nunuhara Cabbage d3928c774d jaf: messages and char constants 2020-07-05 22:29:45 -07:00
Nunuhara Cabbage 8fe1001fc3 jaf: process escapes in string constants 2020-07-05 19:35:17 -07:00
Nunuhara Cabbage 0970e0c7da jaf: multi-dimensional arrays 2020-07-05 17:40:39 -07:00
Nunuhara Cabbage 8bf7e2aa2b jaf: function types 2020-07-05 16:26:06 -07:00
Nunuhara Cabbage eca0e39fca jaf: show file name/line number in error messages 2020-07-01 10:01:20 -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 1e87c85588 Fix buffer underflow in alloc_page 2020-06-29 21:41:49 -07:00
Nunuhara Cabbage ee0bd6b5d8 jaf: structs 2020-06-28 10:52:02 -07:00
Nunuhara Cabbage fd60c6329b jaf: arrays 2020-06-27 13:35:09 -07:00
Nunuhara Cabbage 9fc065b1dd jaf: add tests and fix multiple bugs
Test the compiler by running the output with xsystem4.
2020-06-24 20:35:07 -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 b6ca188a34 jaf: support sequence (comma) expressions 2020-06-22 15:13:13 -07:00
Nunuhara Cabbage def93074a6 Fix bug with function lookup
ain->functions can be realloc'd, so storing pointers into it is a bug.
2020-06-22 12:57:56 -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 8680b3aae5 aincmp: add line breaks to messages 2020-06-22 10:13:30 -07:00
Nunuhara Cabbage 7eb6bad336 jaf: fix bug with reference types 2020-06-21 17:25:49 -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 fc0f9a2444 aindump: support dumping misc sections
Support dumping KEYC, MAIN, MSGF, GVER and OJMP sections (single int
value).
2020-06-21 11:05:56 -07:00
Nunuhara Cabbage f1a949dfce jaf: use struct ain_type for type analysis
Once type definitions have been established, use ain_type instead of
jaf_type_specifier to simplify type analysis and compilation.
2020-06-21 09:06:45 -07:00
Nunuhara Cabbage 6e3a3e784a jaf: strings and reference types 2020-06-20 21:05:14 -07:00
Nunuhara Cabbage 0a7239ae0f jaf: loops 2020-06-18 22:03:28 -07:00
Nunuhara Cabbage f46f3ac28a jaf: conditionals and logical operators 2020-06-18 16:40:41 -07:00
Nunuhara Cabbage c283366edd jaf: support assignment expressions 2020-06-17 18:45:20 -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 615b866727 jaf: support parsing struct member access 2020-06-14 18:13:12 -07:00
Nunuhara Cabbage d8e21d0323 jaf: support parsing identifiers & function calls 2020-06-14 15:54:59 -07:00
Nunuhara Cabbage 5ecdd1ceed jaf: support cast expressions
Support both function-style casts (eg. "int(12.3)") and C-style casts
(eg. "(int)12.3").
2020-06-13 23:00:21 -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 7b270e5325 alice-tools version 0.5.0 2020-05-30 14:13:40 -07:00
Nunuhara Cabbage 5b2307f2f2 aindump/ainedit: rename macros
.S_LOCALASSIGN is now named .STACK_LOCALASSIGN
.STRING_LOCALASSIGN is now named .S_LOCALASSIGN

.S_PUSH is removed (redundant)

This is a breaking change.
2020-05-30 13:54:50 -07:00
Nunuhara Cabbage e49a666eaa aindump/ainedit: inline strings
Remove the --inline-strings option and implement this behavior as the
default (removing the old behavior). This is done for string only;
messages are still given as integers.

This implementation is a bit different than the broken implementation it
replaces: instead of trying to completely rebuild the string table from
scratch, we simply leave the string table as-is and do a hash-table
lookup to get the corresponding index for all string arguments. If the
string cannot be found, then it is added at the end of the table.

This is NOT implemented for messages because the message table can
contain many duplicate strings and the message index actually matters
for the purpose of tracking previously read messages.

This is a breaking change.
2020-05-30 13:31:32 -07:00
Nunuhara Cabbage 59eb85245f aindump/ainedit: various macros
.LOCALINC2/.LOCALDEC2 are semantically identical to .LOCALINC/.LOCALDEC
except that they represent an uglier instruction sequence which is
frequently used in Rance 10.

.LOCALPLUSA/.LOCALMINUSA and .STRING_LOCALASSIGN do what you would
expect.
2020-05-29 18:54:32 -07:00
Nunuhara Cabbage b5a1de3559 Merge branch 'master' of https://github.com/nunuhara/xsystem4 2020-05-24 19:24:14 -07:00
Nunuhara Cabbage 1306372a56 exbuild: handle include paths correctly
chdir to directory when including files, so that relative paths are
resolved correctly.
2020-05-24 19:13:35 -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 1b48941f66 Merge branch 'master' of https://github.com/nunuhara/xsystem4 2020-05-23 12:41:55 -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 940fcb6931 Support zlib compressed AJP mask 2020-05-18 19:37:00 -07:00
Nunuhara Cabbage 7ff6128686 alice-tools: update README for version 0.3.0 2020-05-18 11:50:10 -07:00