Commit Graph
211 Commits
Author SHA1 Message Date
Nunuhara Cabbage 99b375acce alice-ar: support extracting ALD and AFA files
Support whole archive, by-index and by-name extraction of files from ALD
and AFA archives.
2020-04-24 22:49:42 -07:00
Nunuhara Cabbage 15ef8caa91 Add fnldump utility
Add tool for extracting bitmap fonts from .fnl files (font archives).
This is mainly for testing the underlying .fnl reading code, which is
needed for proper font rendering in the MangaGamer version of Sengoku
Rance. In the future this tool could be updated to support rebuilding
font archives, which would allow adding special glyphs, using condensed
fonts, etc.

Credit to CookieWukk for reverse engineering the .fnl file format.
2020-04-08 20:08:45 -07:00
Nunuhara Cabbage 40ce6e2e82 Add webp CG support
For the MangaGamer version of Sengoku Rance. This makes libwebp a
dependency.

These webp files have a non-standard metadata block appended to them
which specifies the base CG that should be used for unfilled pixels,
where "unfilled" means any pixels with a pure magenta color (255,0,255).
2020-04-07 18:41:01 -07:00
Nunuhara Cabbage 9e0ae18a05 Add stubs for SengokuRanceFont.dll
And enough implementation to run up to the intro without crashing.
2020-04-05 19:36:42 -07:00
Nunuhara Cabbage 15cdb10ee0 Implement NEW instruction 2020-04-05 13:44:37 -07:00
Nunuhara Cabbage e2f7adeed8 SACT2: allow SP_Create with unallocated sprite nr
MangaGamer version of Sengoku Rance does this.
2020-04-05 13:18:04 -07:00
Nunuhara Cabbage 576703d141 ini: combine 'var[n] = val' assignments into lists
Create INI_LIST entries from _INI_LIST_ENTRY entries. E.g.

    VolumeValancer[0] = "BGM"
    VolumeValancer[1] = "Sounds"

is equivalent to,

    VolumeValancer = {
        "BGM",
        "Sounds",
    }
2020-03-11 20:36:19 -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 0d74a3b686 Partial MsgLogManager/MsgLogViewer implementation
Enough to get the message log in Sengoku Rance working.
2020-03-08 17:19:19 -07:00
Nunuhara Cabbage 3e1919e17c AJP alpha channel support
Add PMS decoder from xsystem35 for AJP alpha mask.
2020-03-08 10:53:23 -07:00
Nunuhara Cabbage 2d1b8dad3a Partial AJP CG support
Support for AJP without alpha channel.
2020-03-07 21:47:09 -08:00
Nunuhara Cabbage ad7501f962 Implement system.MsgBoxOkCancel 2020-03-06 22:43:42 -08:00
Nunuhara Cabbage 529c7024c2 Move --audit from aindump to xsystem4
Move --audit option from aindump to xsystem4 proper, and implement
auditing of HLL functions.
2020-03-06 21:14:02 -08:00
Nunuhara Cabbage 7f5e155f3e Implement system.OpenWeb 2020-03-05 19:05:10 -08:00
Nunuhara Cabbage 4826686953 Update ex lexer source file 2020-02-29 22:54:51 -08:00
Nunuhara Cabbage cd2280f28f exbuild: use read_file_utf8 for included files 2020-02-29 17:30:20 -08:00
Nunuhara Cabbage 4242882671 tools: Update README for v0.2.1 2020-02-29 17:16:10 -08: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 40b67ed7f6 Initial afa archive support
Very incomplete implementation. Capable of reading the file table and
not much else.

Also add the "alice-ar" utility for testing. Eventually this tool should
support modifying ald and afa archives. For now only supports dumping
the afa file table.
2020-02-25 20:34:51 -08:00
Nunuhara Cabbage be1b5ecc8f Use abstract archive interface for ALD files
In preparation for AFA support in libsystem4.
2020-02-23 18:49:51 -08:00
Nunuhara Cabbage 6e29fee7ed exdump: fix garbled filenames on Windows
Convert filenames to UTF-16 and use _wfopen().
2020-02-23 14:18:52 -08:00
Nunuhara Cabbage 35a88b8669 Add alice-tools README 2020-02-23 11:22:14 -08:00
Nunuhara Cabbage 46243cc795 aindump: prefix files with block index
Workaround for garbled filenames on Windows.
2020-02-23 10:21:31 -08:00
Nunuhara Cabbage 159774a629 exbuild: add --old option
For building pre-Evenicle .ex files, where the table row/column
quantities are reversed.
2020-02-23 09:47:56 -08:00
Nunuhara Cabbage 00f25d698a exdump/exbuild: multiple files support
The -s,--split option to exdump can be used to split the dump into
multiple files (one per top-level data structure). The output file when
using the split option contains #include directives to stitch the full
dump back together when given to exbuild.
2020-02-23 08:51:49 -08:00
Nunuhara Cabbage 9576a97e05 exbuild: write (binary) ex file to disk
It is now possible to modify .ex files using exdump and exbuild. E.g.

    exdump -o out.x Rance10EX.ex
    $EDITOR out.x
    exbuild -o Rance10EX.ex out.x
2020-02-22 23:06:32 -08:00
Nunuhara Cabbage c58af1c17f exdump: add -d,--decrypt option
For debugging/reversing purposes.
2020-02-22 22:04:47 -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
Nunuhara Cabbage 38048ea9e6 Add exdump utility
Add tool for dumping the contents of .ex files, which contain various
structured data used by the game (tables, lists, trees).

The dump format uses a C-like syntax which should be relatively easy to
parse back in.
2020-02-17 19:51:25 -08:00
Nunuhara Cabbage c9dcf6e104 ainedit: convert .MSG/.STR text to shift-jis 2020-02-15 11:55:22 -08:00
Nunuhara Cabbage b8c9072acf ainedit: convert text back to shift-jis 2020-02-15 09:42:16 -08:00
Nunuhara Cabbage 4429bd0990 Fix NEW instruction args in ain v8 and below
NEW was changed in ain v11 to accept 2 arguments.
2020-02-14 22:16:20 -08:00
Nunuhara Cabbage 608aedb500 Fix various issues with MSYS2/mingw build 2020-02-14 16:29:44 -08:00
Nunuhara Cabbage 623f8c8ebf aindump/ainedit: clean up command line arguments
Use enums for long option values, and run dumps in the order they're
specified on the command line. Also, --no-strings mode is made the
default and a --inline-strings option is added to get the old (broken)
behavior.
2020-02-14 12:11:01 -08:00
Nunuhara Cabbage a898c67983 ainedit: add string/message editing mode
Add -t,--text option to read files produced by 'aindump -t ...'.

The workflow here is:

* dump the text with 'aindump -t -o <outfile> ...'
* $EDITOR <outfile>
* locate the text you want to edit, remove the leading semicolon (i.e.
  uncomment it) and edit the string as desired.
* reinsert the modified text with 'ainedit -t <outfile> ...'
2020-02-13 20:42:51 -08:00
Nunuhara Cabbage 259b06edf1 aindump: add sorted string/message dump mode
Dump strings/messages sorted by function when given the -t,--text
option. This is intended to be read back in again by ainedit.
2020-02-13 17:50:10 -08:00
Nunuhara Cabbage ab670bd3a9 aindump: guess filenames if no FNAM section
If the filenames section isn't present, try to guess the filenames from
the functions defined in the file. This works pretty well for most of
the core engine files but gives pretty crappy results for scenario
files.

This feature is primarily intended to be used when dumping the code
section to multiple files (not yet implemented).
2020-02-12 18:09:37 -08:00
Nunuhara Cabbage 0bb6a7199f ainedit: allow adding switches/strings/messages
Allocate space in switch/string/message tables if index is greater than
the current size. Its up to the user to allocate their own indices.
2020-02-10 21:43:10 -08:00
Nunuhara Cabbage 63b3a9b65c aindump/ainedit: add .DEFAULT pseudo-op
For the default address of switch statements. With this addition,
adding/removing instructions is confirmed working.
2020-02-09 20:33:34 -08:00
Nunuhara Cabbage 0d5e411c3c ainedit: add .STR/.MSG pseudo-ops
These ops allow modifying the string/message tables when using the
--no-strings option.
2020-02-09 16:38:43 -08:00
Nunuhara Cabbage a76b7149d9 aindump/ainedit: add .CASE pseudo instruction
Add a pseudo instruction to represent switch case labels, along with the
infrastructure to support pseudo instructions in general. .CASE takes
two arguments: a switch:case index (e.g. "12:8") and the value to match
against.

Also, add a --no-strings option to both programs to allow modifying the
code without changing the string/message tables. This is needed for now
since rebuilding the string/message tables (as currently implemented)
causes serious bugs in Rance X (and probably other games).

Running the following command should produce an ain file that is almost
bit-for-bit identical to the input file (the only difference being minor
drift in floating point constants):

    aindump -c --no-strings in.ain | ainedit -c - --no-strings -o
        out.ain in.ain
2020-02-09 15:34:10 -08:00
Nunuhara Cabbage dab8deca42 Add ainedit utility
The ainedit utility is a tool capable of modifying AIN files up to
version 12 (Rance X). As far as I know, this is the first publicly
released tool that can handle AIN files above version 7.

The basic mode of operation is as follows:

* dump the CODE section with aindump
* edit the disassembled bytecode
* assemble & insert the edited bytebode back into the original AIN file
  using ainedit

E.g.

    aindump -c -o out.jam /path/to/Rance10.ain
    $EDITOR out.jam
    ainedit -c out.jam -o out.ain /path/to/Rance10.ain
    mv /path/to/Rance10.ain /path/to/Rance10.ain.backup
    mv out.ain /path/to/Rance10.ain

ainedit is also capable of editing declarations (structures, functions,
etc.) using the JSON (-j) output from aindump.

There is currently one major deficiency in this tool: it does not
rebuild the AIN file's switch table (SWI0 section). This means that you
can't insert or delete instructions, as it would render the addresses
stored in the switch table invalid. I hope to fix this soon.

A number of changes have also been made to the aindump utility, since
these tools need to work together.
2020-02-07 19:49:39 -08:00
Nunuhara Cabbage d8304b0e6f Fix bug (?) in utf2sjis
Don't generate SJIS with initial byte 0x80. I'm guessing that sjis2utf
handles initial byte 0x80 the way it does for compatibility reasons, but
there is no reason for utf2sjis to generate this coding.
2020-02-06 21:54:35 -08:00
Nunuhara Cabbage 4d9de80626 aindump: add JSON output format
Dump everything except the code to a JSON file.

With both the disassembled code and this JSON file in hand, it should be
possible to reconstruct the original AIN file.
2020-01-26 17:09:15 -08:00
Nunuhara Cabbage f5446fe1f7 aindump: don't access label table in raw mode 2020-01-24 17:50:07 -08:00
Nunuhara Cabbage 5aa2929b5f aindump: handle nested functions properly
Keep a stack of functions which gets pushed/popped on FUNC and ENDFUNC
instructions, respectively. Since methods do not get an ENDFUNC (for
whatever reason), this stack has to be a fixed size and discard the
oldest value when pushed to (otherwise it would grow indefinitely).

This fixes a bug when dumping the code of Ixseal, where a lambda's
ENDFUNC would clear dasm->func while the parent function was still being
disassembled. Interestingly, this doesn't become an issue in Rance X
because the code is more indirect in how it accesses local variables (no
SH_LOCAL* instructions).
2020-01-16 20:23:42 -08:00
Nunuhara Cabbage 41c39baaba aindump: show function prototype in dasm output
Show full function prototypes in disassembled output.
Also, fix a bug with enum types.
2020-01-16 19:51:50 -08:00
Nunuhara Cabbage 3fa214a22a Implement system.Sleep 2020-01-16 06:04:00 -08:00