Commit Graph
10 Commits
Author SHA1 Message Date
Nunuhara Cabbage 70a8b9d136 aindump: correct argument types, all syscalls
Use the correct argument types for all instructions, with the exception
of SH_REF_LOCAL_ASSIGN_STRUCTREF2 which I could find an example of.

List all system calls.
2020-01-11 15:05:45 -08:00
Nunuhara Cabbage 8c226ab535 aindump: support code dump up to ain v12 (Rance X)
v11 ain files have 3 new instructions, and 3 modified instructions. It
looks like they decided to break compatibility with this release by
adding arguments to some instructions.

v12 adds one instruction.
2020-01-10 13:38:19 -08:00
Nunuhara Cabbage 302598ace2 aindump: add decrypt mode
Add -d,--decrypt option to dump decrypted ain file (for reverse
engineering).
2020-01-10 12:28:44 -08:00
Nunuhara Cabbage 55e44b881a aindump: support dumping code up to Heartful Maman
The argument types for many of the newer instructions are likely
still incorrect.
2020-01-10 08:49:25 -08:00
Nunuhara Cabbage 61097cfe73 aindump: option to check xsystem4 compatibility
Add -A,--audit option to check an ain file's compatibility with
xsystem4. Currently only checks for unimplemented instructions and
syscalls.
2020-01-09 19:10:06 -08:00
Nunuhara Cabbage e00501346b Fix LI_* instructions
The 'lint' type in system 4 is NOT a 64-bit integer type. It is actually
a signed 32-bit integer type that is clamped between 0 and INT32_MAX.

Negative numbers can be assigned to a lint using SH_LOCALASSIGN (or at
least, the unofficial compiler emits such code) but LI_* instructions
always produce a positive result.

I'm guessing System40.exe converts lints to 64-bit integers for doing
arithmetic, and then clamps the result to the 32-bit integer range
before writing back to a variable.

This fixes a bug in Sengoku Rance where units would become invincible in
commander battles after their HP fell below zero.
2020-01-08 19:14:08 -08:00
Nunuhara Cabbage 6a4d11f3de Use libffi for library calls
Use libffi to portably call arbitrary functions at runtime, rather than
forcing library functions to use a standard prototype.
2020-01-07 22:48:29 -08:00
Nunuhara Cabbage f1cc9082b3 Don't store HLL function pointers in ain struct
Store them in vm.c. The ain structure should not contain data that
wasn't in the ain file on disk.
2020-01-03 18:48:30 -08:00
Nunuhara Cabbage 03e9d59825 aindump: improve disassembler output
Replace many instruction arguments with names/values (strings/messages,
local/global variables, structs, functions, etc.) and add labels to jump
targets.
2020-01-01 20:34:35 -08:00
Nunuhara Cabbage 5d6f148e1b Reorganize project file structure
- Create separate directories for source and header files.
- Build code shared between xsystem4 and aindump as a static library.
- Create header dirs gfx/ system4/ and vm/
- Make CG.c/h usable without a running VM
2019-12-31 17:50:40 -08:00