Commit Graph
97 Commits
Author SHA1 Message Date
Nunuhara Cabbage 81455baeb4 Implement more DrawGraph/SACT2 functions
5 functions:

    SACT2.SP_SetDrawMethod
    DrawGraph.CopyStretch
    DrawGraph.CopyStretchAmap
    DrawGraph.CopyReduce
    DrawGraph.CopyReduceAmap

SP_SetDrawMethod is not pixel-perfect to System40.exe, but its pretty
close.

I'm not sure what the difference between the Stretch/Reduce functions is
supposed to be. They seem to do the same thing.

Also, the ugly macros in sdl_draw.c are replaced by higher-order
functions.

With this commit, Sengoku Rance runs up to the menu without exiting due
to unimplemented HLL functions.
2019-12-01 19:50:47 -08:00
Nunuhara Cabbage 365df39093 Floating point assignment instructions 2019-12-01 17:44:14 -08:00
Nunuhara Cabbage 2778d2eb42 Add stubs for PlayMovie.dll 2019-12-01 17:43:30 -08:00
Nunuhara Cabbage b8fbba074b Add stubs for Confirm2.dll 2019-12-01 14:18:36 -08:00
Nunuhara Cabbage 61f0d61cbd Implement ITOLI instruction 2019-12-01 14:17:34 -08:00
Nunuhara Cabbage f573614025 Implement SACT2.IntToHankaku + SACT2.IntToZenkaku 2019-12-01 14:08:44 -08:00
Nunuhara Cabbage a02632590d Add stubs for AliceLogo*.dll 2019-12-01 11:05:14 -08:00
Nunuhara Cabbage 79dde45e44 Add stubs for SystemServiceEx.dll 2019-12-01 10:32:34 -08:00
Nunuhara Cabbage ce58a58c2c Improve readability of execute_instruction()
Use scopes in switch so that each case can have its own local variables.
2019-12-01 10:30:09 -08:00
Nunuhara Cabbage 91af527def Implement A_FIND instruction
This one is not supported by the SDK compiler, so no automated tests.
2019-11-30 15:47:06 -08:00
Nunuhara Cabbage b11319eb66 Initialize struct members with variable_initval
Fix bug where ref members were initialized to 0 instead of -1 (NULL).
2019-11-30 11:57:29 -08:00
Nunuhara Cabbage 4b158d3103 Don't assume 0() is last function
It's not always true that 0() is the last function in the ain file, so
it's necessary to store its index when loading the file.
2019-11-30 09:01:03 -08:00
Nunuhara Cabbage 4eb5a256fd Refactor graphics code
Sprites are now rendered directly, rather than being blitted to a master
surface which is then copied to a texture. Every sprite now carries an
SDL_Texture in addition to an SDL_Surface (we need both, since
SDL_Texture doesn't give read-access to the pixel data).

All of the image-manipulation code is now in sdl_draw.c, and the
DrawGraph_* functions are now wrappers. Some games (Daibanchou at least)
use an API other than SACT2/DrawGraph, so these operations should be
generic to avoid duplication.
2019-11-29 23:16:40 -08:00
Nunuhara Cabbage ae6b558813 Enumerate effects
and print the name of the unimplemented effect when SACT.Effect is
called.
2019-11-28 16:24:09 -08:00
Nunuhara Cabbage 6039ab9bd0 Fix multiple VM memory leaks
Also implement a feature to track leaked heap memory (DEBUG_HEAP).

With this, it is now possible to hold CTRL through the entire Rance II
digest version without crashing.
2019-11-27 18:11:07 -08:00
Nunuhara Cabbage becda2c61d Implement SACT2.CG_GetMetrics 2019-11-26 19:22:13 -08:00
Nunuhara Cabbage c7f48794c5 Check for errors from SDL_ttf
Check if returned surface is NULL.
2019-11-26 17:29:53 -08:00
Nunuhara Cabbage 6517e9d8d8 Implement SACT2.SP_CreatePixelOnly 2019-11-26 17:20:47 -08:00
Nunuhara Cabbage 4a7f703af1 Implement more SACT2 text functions 2019-11-26 16:32:24 -08:00
Nunuhara Cabbage 36111e069c Implement simple DrawGraph.Fill* functions
DrawGraph.Fill - fill solid color
DrawGraph.FillAlphaColor - blend solid color
DrawGraph.FillAMap - fill alpha channel
2019-11-25 20:10:44 -08:00
Nunuhara Cabbage a40467fe92 Allocate global structs before calling ctors
Global constructors can write to other global structs, so memory must be
allocated for all global structs before any constructors are called.
2019-11-25 18:40:49 -08:00
Nunuhara Cabbage 82d6f8c203 Use variable_initval to initialize globals
Fix bug where some globals weren't initialized
2019-11-25 15:39:19 -08:00
Nunuhara Cabbage 766f93407b Implement the DrawGraph.Copy* family of functions
Implement all of the simple copy functions, with the exception of
DrawGraph.CopyColorReverse, which is undocumented and appears to be dead
code (at least in the version of SACT2 that shipped with the SDK).
2019-11-25 12:19:14 -08:00
Nunuhara Cabbage 58f070dbb4 Partial implementation of ACXLoader.dll
Enough to read the acx files used by the Rance I/II digest versions.
2019-11-24 16:23:29 -08:00
Nunuhara Cabbage a8c56105d6 Convert ain filename to UTF-8
Allow loading ain files with non-ASCII filenames.
2019-11-24 15:45:28 -08:00
Nunuhara Cabbage 3542352cf6 Implement SACT2 text rendering functions
Also a lot of bug fixes included here.
2019-11-24 11:48:53 -08:00
Nunuhara Cabbage 029b013778 Call global constructors after setting initvals
Prevents clobbering of globals assigned in constructors.
2019-11-22 22:55:04 -08:00
Nunuhara Cabbage 2511a42378 Fix vm_time()
This code was clamping the timer between 0 and 1000 since the seconds
value was not used.
2019-11-22 22:45:20 -08:00
Nunuhara Cabbage b63a28e5ad Fix bug in sact_get_sprite 2019-11-21 21:51:04 -08:00
Nunuhara Cabbage eef6eb5580 Use standard pixel format for CGs
Don't use explicit masks.
2019-11-21 20:39:09 -08:00
Nunuhara Cabbage ee0f72ae2e Refactor SACT2 and fix input
Pull graphics code into sact_graphics.c.
Implement Key_ClearFlag so that SACT2's own input handling code works
properly.
2019-11-21 19:57:24 -08:00
Nunuhara Cabbage 71c74fe910 Fix QNT CGs with alpha channel
Properly specift pixel format.
2019-11-20 19:00:59 -08:00
Nunuhara Cabbage e6f41f55b8 Implement S_LENGTH2 instruction 2019-11-19 21:23:12 -08:00
Nunuhara Cabbage 80ff1902e6 Implement MSG instruction 2019-11-19 20:34:31 -08:00
Nunuhara Cabbage 7ec7124d01 Implement CALLONJUMP and SJUMP instructions
Add support for scenario functions (functions which clear the call stack
upon entry and never return).
2019-11-19 19:56:18 -08:00
Nunuhara Cabbage 419da7889c Implement mouse and keyboard input support
The popolytan demo now has a functional menu, albeit without text.
2019-11-18 21:58:54 -08:00
Nunuhara Cabbage 00c4e7bf1f Fix bug in S_MOD 2019-11-18 21:53:51 -08:00
Nunuhara Cabbage 70ab217ca0 Fix build
-Wall/-Wextra are enabled automatically.

C11 doesn't define M_PI.
2019-11-18 18:32:03 -08:00
Nunuhara Cabbage a9de3b76fb Implement SACT2.Update()
Really lazy implementation for now, just draws all sprites every frame.
In the future should implement proper compositing with damage tracking.

All CG types other than QNT are removed. From what I've seen, System 4
games use QNT, PNG, AJP (encrypted JPEG) and DCF (seems to be a format
for partial CG updates). QNT is by far the most common format.
2019-11-17 21:44:16 -08:00
Nunuhara Cabbage ffdd12a8d9 More SACT2 stubs
Enough to get to SACT2.Update in the "popolytan" demo program.
2019-11-17 13:26:36 -08:00
Nunuhara Cabbage 586a59d932 Call function "0" before main 2019-11-16 16:03:09 -08:00
Nunuhara Cabbage 6bfbce34b8 Add stubs for SACT2.Music_* 2019-11-16 14:51:45 -08:00
Nunuhara Cabbage 0e54f24941 Initialize ref variables to -1 (NULL) 2019-11-16 14:49:06 -08:00
Nunuhara Cabbage 4a7075ffef Add stubs for MsgSkip.dll 2019-11-15 21:40:21 -08:00
Nunuhara Cabbage 0eefcaab36 Implement system.GetSaveFolderName() 2019-11-15 21:39:43 -08:00
Nunuhara Cabbage 89cee10c51 Implement system.GetTime() 2019-11-15 21:20:27 -08:00
Nunuhara Cabbage f4551005ba Add stubs for DrawPluginManager.dll 2019-11-15 19:49:51 -08:00
Nunuhara Cabbage 9dfc6c480c Fix segfault when copying struct with array member
If the array member is unallocated, its page is NULL. So we have to
handle this case in copy_page.
2019-11-15 19:40:24 -08:00
Nunuhara Cabbage 55fc577485 Add stubs for MsgLogManager.dll 2019-11-15 19:36:00 -08:00
Nunuhara Cabbage 3f2a69f8ca aindump: fix crash when dumping HLL functions
HLL functions can accept struct arguments, although there is no way to
determine the struct type other than analysing the code.
2019-11-15 19:33:56 -08:00