Commit Graph
42 Commits
Author SHA1 Message Date
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 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 85708c6af1 ainedit: add --silent option
For running compiler tests.
2020-06-22 16:04:49 -07:00
Nunuhara Cabbage b6ca188a34 jaf: support sequence (comma) expressions 2020-06-22 15:13:13 -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 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 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 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 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 43818e636a ainedit: .S_PUSH/.MSG assembler ops
Assembler ops which add a new string/message to the ain file and emit an
S_PUSH/MSG instruction. E.g. to display a message box in Rance 10:

    .S_PUSH "test"
    CALLHLL system MsgBox -1
    DELETE

The .STR and (old) .MSG ops are renamed to .SETSTR and .SETMSG.
This is a breaking change.
2020-05-06 17:23:38 -07:00
Nunuhara Cabbage 3f57ed1b74 aindump/ainedit: F_STRUCTASSIGN macro
Instruction sequence to assign a float to a struct member.
2020-05-05 16:42:11 -07:00
Nunuhara Cabbage 7c9ad0e69e aindump/ainedit: F_GLOBALASSIGN macro
Instruction sequence for assigning to a global float variable.
2020-05-05 16:36:43 -07:00
Nunuhara Cabbage 3625f53b26 aindump/ainedit: F_LOCALASSIGN macro
Instruction sequence for assigning to a local float variable.
2020-05-04 17:44:55 -07:00
Nunuhara Cabbage 758ac2b505 aindump/ainedit: add S_LOCALASSIGN macro
Instruction sequence for assigning to a local struct variable.
2020-05-04 17:03:14 -07:00
Nunuhara Cabbage 34950cda38 aindump/ainedit: .LOCALASSIGN2 macro
This macro represents the instruction sequence to assign a value on the
stack to a local variable.
2020-05-03 09:20:42 -07:00
Nunuhara Cabbage 09ab45d6ea aindump/ainedit: .PUSHVMETHOD macro
This macro represents the instruction sequence to load a virtual method
number from the currect struct page's vtable onto the stack.
2020-05-03 08:49:03 -07:00
Nunuhara Cabbage 6694eeb683 aindump/ainedit: add POP to *ASSIGN macros
Add the final POP after the ASSIGN to the LOCALASSIGN, GLOBALASSIGN and
STRUCTASSIGN macros. This makes the macros stack-clean.
2020-05-01 16:48:14 -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
Nunuhara Cabbage cb085f6c5c tools: improve error messages
Add line numbers to error messages
2020-04-28 21:07:40 -07:00
Nunuhara Cabbage 38edfe8a98 aindump/ainedit: more macros
.LOCALINC
.LOCALDEC
.LOCALASSIGN
.LOCALDELETE
.LOCALCREATE
.GLOBALINC
.GLOBALDEC
.GLOBALASSIGN
2020-04-27 22:34:23 -07:00
Nunuhara Cabbage 166854f2c3 aindump/ainedit: .LOCALREF/.GLOBALREF macros
Use macros for some common instruction sequences. E.g.

    PUSHLOCALPAGE
    PUSH <varno>
    REF

becomes,

    .LOCALREF <varname>
2020-04-26 20:58:49 -07:00
Nunuhara Cabbage e4a2e965df Use custom parser for System40.ini
This is not really a standard ini file, so a custom parser is needed to
access all of the information stored in it (specifically, lists like
"LoadDLL").

This commit also makes flex/bison a hard dependency.
2020-03-10 21:36:28 -07:00
Nunuhara Cabbage 09dcdb3d14 tools: fix iconv issues on Windows
Need to use libiconv on Windows. libiconv doesn't accept all of the same
encoding names as the glibc iconv. In particular, CP932 needs to be used
instead of SJIS-WIN.
2020-02-29 16:49:26 -08:00
Nunuhara Cabbage 2be530b65f ainedit: add --transcode option
Add option to change text encoding of an ain file. E.g.

    ainedit --transcode GBK//TRANSLIT -o out.ain in.ain
2020-02-29 15:07:01 -08:00
Nunuhara Cabbage b7c12b1ce0 tools: allow changing input/output text encoding
Use iconv instead of utfsjis.h so that text encodings other than UTF-8
and SJIS can be used. For three reasons:

* to allow using other encodings for dumped files (e.g. UTF-16, SJIS)
* to support existing Chinese translations, which use GBK-encoded text
* to support theoretical translations to other languages that can't be
  represented in SJIS
2020-02-28 20:18:28 -08:00
Nunuhara Cabbage 4a9b928500 Add ainbuild utility
Tool for reading and rebuilding dumped .ex files. Currently this only
reads a file on stdin then redumps it to stdout.

Also, move tools code into src/tools/
2020-02-20 21:14:13 -08:00