Compare commits

...

534 Commits

Author SHA1 Message Date
Amaryllis Kulla 6a875b30d2 README: Update matrix space link 2023-10-12 20:53:19 +02:00
Amaryllis Kulla 998aa9f846 README: Update soundfont link 2023-10-05 21:18:55 +02:00
Amaryllis Kulla b4c439c6eb README: Update links 2023-09-08 20:54:46 +02:00
Amaryllis Kulla 380b676777
README: Point binary links at mapleshrine.eu 2021-11-06 00:04:25 +01:00
Amaryllis Kulla a962c158db Update copyright notice again
Keep information on first file creation year,
and update my email address yet again.
2021-10-16 22:57:08 +02:00
Jaiden cf6403ae65 Update glstate.cpp
Fixes the GL blend formula for Subtractive blending
2021-09-19 15:24:12 +02:00
Ancurio f138731f7c Update copyright notice 2021-09-06 20:50:44 +02:00
mara ac8f4b1594 build: Support SDL_sound in different prefix as SDL2
As the required SDL_sound is a custom fork which is not packaged as
system package, it could plausibly be installed in a different path.
2021-09-03 07:43:11 +02:00
Jari Vetoniemi 990843a50b Compile with newer openal-soft 2021-08-28 07:40:15 +02:00
Jari Vetoniemi 66dc9309db Add .editorconfig to the project
Saves time and hassle
2020-08-12 22:17:37 +02:00
Jonas Kulla 5c117a55bf
README: Remember that markdown is a thing 2020-08-10 09:42:00 +02:00
Jonas Kulla cb09036c55
README: Add project discord link 2020-08-10 09:41:19 +02:00
Jonas Kulla 6903f2ab43 README: Add link to gist document 2020-05-06 07:38:25 +02:00
Jonas Kulla 9dc42914de README: Clarify target group of project 2019-06-20 06:01:20 +02:00
Jonas Kulla 86194118a3 FileSystem: Check PHYSFS_registerArchiver() for success 2019-05-18 16:48:17 +02:00
Jonas Kulla 98bdfcf758 FileSystem: Check PHYSFS_init() for success
Move it above the allocations so exceptions don't leak memory.
2019-05-18 16:42:56 +02:00
Jonas Kulla 6fa5b8c856 Sprite: Define M_PI manually
Apparently (older?) mingw-w64 with C++11 enabled doesn't have it.
2019-05-18 16:21:21 +02:00
Jonas Kulla d6b477b887 qmake.pro: Add explicit C++11 flags 2019-05-18 16:17:09 +02:00
Jonas Kulla 9dcfb66e86 fluid-fun: Define destructor signature based on fluidsynth version
As per @carstene1ns 's suggestion.
2019-03-22 21:16:57 +01:00
Jonas Kulla d4b9adc1d1 fluid-fun: Adjust function signature to fluidsynth 2.0
This breaks compilation with FLUID_SHARED against <2.0 versions,
which should be reasonable given that the default mode can still
dynamically load both variants.

Fixes #219.
2019-03-21 08:07:02 +01:00
Luis Caceres 43cb318862 Config: Add case-insensitive ini file parser 2019-03-19 19:26:50 +01:00
Eliza Velasquez bab22d87be Fix font enumeration
Currently, the font enumeration callback erroneously stops searching if
it finds any files that aren't fonts. In the case that you have, say, a
desktop.ini or a .DS_Store or a license file, it may prevent all of the
fonts from being loaded. This commit resolves this.
2018-10-13 20:28:36 +02:00
Jonas Kulla ae59fcd112 Graphics: Fix transition when new scene has gray tone effect
Rendering the scene may cause PingPong swaps of front / backbuffer,
so don't take references to those buffers until after rendering.

Fixes #199
2018-05-21 12:22:23 +02:00
ReinUsesLisp b5e5a26d8b Config: Set debug editor's debug variables into ruby 2018-02-22 09:08:45 +01:00
Jonas Kulla 9f44ee5068 FileSystem: Fix while termination condition 2018-01-22 10:54:21 +01:00
Jonas Kulla 183ebbed65 RGSSAD: Fix parsing of top level directory entries
We were spamming every path into the hash (including the top
level ones) without noticing... oh well.
2017-12-12 22:46:25 +01:00
Jonas Kulla 7902d0942d Filesystem: Properly iterate top level dir entries
"." seemed to have worked in earlier PhysFS versions,
but it was never the correct way.
2017-12-12 22:45:01 +01:00
Jonas Kulla 947974cac6 Config: Properly use windowTitle everywhere instead of game.title 2017-12-12 17:57:02 +01:00
Jonas Kulla 2f81fbbf4b Fix ordering 2017-12-11 00:51:21 +01:00
Jonas Kulla 7d9a85dbbd Config: Add entry to override the game window title 2017-12-11 00:48:35 +01:00
Carsten Teibes d427df0c2b Adapt RGSS archivers and filesystem to physfs 3.0 API 2017-10-12 14:27:19 +02:00
Carsten Teibes b1bdf1e445 Fix CMake build, only use `resource.h` on Windows
This was broken in commit 01e17ed5c6 (move windows specific files).
2017-08-18 22:42:27 +02:00
Carsten Teibes fde6a92197 Fix deprecation warning on build with MRI>2.3
Fixes #158.

The old alias is deprecated since: ruby/ruby@fdb957925f.
2017-08-18 22:41:16 +02:00
Marty Plummer 01e17ed5c6 windows: move windows specific files
Moved the windows-specific files into their own subdir for
cleanliness's sake and mesonbuild organization.

Signed-off-by: Marty Plummer <ntzrmtthihu777@gmail.com>
2017-08-10 21:58:31 +02:00
Jonas Kulla f172f58c74 Sprite: Fix regression with "mirror" attribute
FloatRect::hFlipped() returns a rectangle with negative width,
which was clobbered by the clamping further down.

Regression introduced in 55cec53911.
2017-08-10 21:39:17 +02:00
Jonas Kulla fba20e6294 Sprite: Check for disposed state before accessing bitmap 2017-07-30 23:00:18 +02:00
Marty Plummer f5c30affaa mingw-w64: allow cmake cross-compile
Tested on gentoo with x86_64-w64-mingw32 toolchain and libraries.

Signed-off-by: Marty Plummer <ntzrmtthihu777@gmail.com>
2017-05-25 13:01:11 +02:00
Jonas Kulla bd694f9f99 Graphics: Remove superfluous TEXFBOs while reusing existing ones
While the PingPong buffers were always texture-backed, currentScene
and transBuffer used to be backed by renderbuffers, which might have
been more optimized as render targets on older hardware; but since
all buffers in Graphics got switched to being texture backed to allow
blitting via rendering (when hardware blitting isn't available or broken,
eg. on mobile platforms), their reason to exist vanished.

For transBuffer, we can reuse the backbuffer of the PingPong structure,
while currentScene might have been useless from the start.
2017-05-11 12:37:15 +02:00
Jonas Kulla cab453ac3a Graphics: Use proper resizing function for TEXFBOs
Manually resizing the contained TEX objects skips updating the
width/height TEXFBO properties, which GLMeta::blit relies on.
2017-05-11 12:32:56 +02:00
Jonas Kulla 006f701fec Config: Add "enableBlitting" entry to toggle GL_EXT_framebuffer_blit 2017-04-23 14:32:11 +02:00
Jonas Kulla 1478e1e0f9 Config: Add "maxTextureSize" entry to artificially limit texture sizes 2017-04-23 14:10:54 +02:00
Jonas Kulla 06feafe9ef Add missing include 2017-04-08 20:06:12 +02:00
Jonas Kulla e4079d5738 Fix build on OSX after 60e967e3b7 2017-04-08 19:13:31 +02:00
Jonas Kulla 0481f920b0 Input: Remove ugly [-20,-20] mouse position hack
This was supposed to disappear shortly after To the Moon's release,
but it unfortunately survived a bit longer :)

The status of the mouse cursor being inside / outside the game window
is now properly exposed (in MRI) via MKXP.mouse_in_window.
2017-04-08 18:45:24 +02:00
Jonas Kulla 3ea24bd757 EventThread: Make system cursor visible over black aspect ratio bars
Should be less confusing for the player.
2017-04-08 18:45:24 +02:00
Marty Plummer 60e967e3b7 Add icon and resource files for windows
Signed-off-by: Marty Plummer <ntzrmtthihu777@gmail.com>
2017-03-09 08:24:13 +01:00
Jonas Kulla 0f9b5f274a Filesystem: Search for "Fonts/" with case-insensitivity 2017-03-08 16:30:07 +01:00
Jonas Kulla 6349146e01 main: Only set window icon on Linux
OSX carries high-resolution icons in its bundles, and windows uses
windres to embed .ico files, so don't interfere with those.
2017-03-04 11:04:02 +01:00
Jonas Kulla c4dd3ffaf6 Config: Use set for preloadScripts
Would probably make sense for all other string vectors too.
2017-03-03 19:37:19 +01:00
Jonas Kulla 55cec53911 Sprite: Clamp src_rect to bitmap bounds 2017-02-17 19:29:38 +01:00
Jonas Kulla 541e24f678 Bitmap: Use more accurate HSV-based hue shift algorithm
The previously YIQ-based algorithm turned out to be both slow,
and horribly inaccurate.

Another algorithm based on rotating the color value in the
RGB cube along the diagonal axis was also considered, which was
acceptable in terms of accuracy, and very fast.

In the end, I decided on a HSV-based one, because it is by far
the most accurate one, while still being a tad faster than the
YIQ solution.
Algorithm source: gamedev.stackexchange.com/a/59808/24839

A very simple GPU time benchmark when shifting a 2048^2 bitmap:

         YIQ rot   RGB rot   HSV shift
radeon   13.4 ms   2.8 ms    11.4 ms
intel    13.0 ms   6.0 ms    10.5 ms

radeon: HD 3650 mobility
intel:  N3540 integrated (Baytrail)

However hue shifting has never shown up as a bottleneck before,
so these are more academic.
2016-10-30 08:50:45 +01:00
Jonas Kulla 0ec1fce4ac MRI: Bind Audio.setup_midi 2016-09-12 20:20:56 +02:00
Jonas Kulla d4e09f55bd WindowVX: Fix move() not setting the correct dirty flags 2016-07-27 12:03:45 +02:00
Jonas Kulla e98c2e0535 Bitmap: Don't throw away cached surface in setPixel()
Instead, update the surface with the same change. For many
consecutive getPixel() -> setPixel() calls on the same bitmap,
this avoids calling glReadPixels at every iteration.
2016-07-27 11:59:08 +02:00
Jonas Kulla fdaf6c3611 Bitmap: Split surface pixel address calculation into helper 2016-07-27 11:56:43 +02:00
Jonas Kulla 47ef36ca19 EventThread: ifdef out broken SDL function on OSX 2016-02-24 17:55:28 +01:00
Jonas Kulla de74fc1bc3 EventThread: Fix mouse cursor not being hidden 2016-02-24 17:45:55 +01:00
Jonas Kulla 5d776319b5 Font/MRI: Improve handling of (default_)name attributes
More accurate behavior, such as Font objects properly inheriting
their name attributes, and centralization of code for picking
the first existing name from a passed string array.

Also centralizes initial default_name population in core.

Note: This currently breaks the mruby binding build.
2016-01-05 08:47:52 +01:00
Jonas Kulla 53b5b923d4 Merge pull request #138 from mook/graphics-playmovie-stub
MRI: Stub out Graphics.play_movie
2015-10-30 16:20:47 +01:00
Mook 8e411cbcfe Graphics: Stub out play_movie
Some people are using it to detect the RGSS version.
2015-10-30 08:01:36 -07:00
Jonas Kulla 7bf6eca362 EventThread: Comment out unneeded SDL2 constants 2015-07-26 23:56:50 +02:00
Jonas Kulla 4d97a17c44 TilemapVX: Ensure legs of out-of-view table tiles are drawn 2015-07-21 12:13:25 +02:00
Jonas Kulla 7017ca1c53 Use static lifetime for constant array 2015-07-21 12:13:25 +02:00
Jonas Kulla 30465691ae Tilemap: Fix map viewport calculation
Calculation was completely off as it didn't take into
account the imposed viewport origin.

All in all, similar fixes as the previous ones to TilemapVX.
2015-07-21 12:13:25 +02:00
Jonas Kulla dd7545fcf2 TilemapVX: Clean up the horrible map viewport calculation code
Also rename "offset" to "origin" which makes a lot more sense
for ox/oy attributes.
2015-07-21 12:13:24 +02:00
Jonas Kulla 5aaeb0206c Remove some stuff that was accidentally committed 2015-07-21 12:13:24 +02:00
Jonas Kulla 9a3dd2d554 Config: Enable smoothScaling by default
There's really no reason not to.
2015-07-21 12:13:24 +02:00
Jonas Kulla 384249c31a Unify float literals to use f suffix and avoid double promotions
I might have missed some.
2015-07-21 12:13:24 +02:00
Jonas Kulla d1ee507ec4 Vec2i, IntRect: Add unequal operator 2015-07-21 12:13:24 +02:00
Jonas Kulla 21247b18b5 Merge pull request #127 from cremno/add-sprite-bush_opacity
MRI: add Sprite#{bush_opacity,bush_opacity=} bindings
2015-07-21 12:12:24 +02:00
cremno 861d261af2 add Sprite#{bush_opacity,bush_opacity=} 2015-07-21 07:27:53 +02:00
Jonas Kulla fe6799d00b TilemapVX: Fix map viewport calculation 2015-07-10 04:58:28 +02:00
Jonas Kulla fe709b6010 Use vector math 2015-07-10 04:51:29 +02:00
Jonas Kulla 54c1107f19 FileSystem: Fix file lookup if unrelated files with same name exist
Before, even though we did match all possible extensions,
we only took the first match and tried opening it.
If we were looking for a .png image, but there was an unrelated
.txt file with the same name (as it actually happens in RTPs),
we would potentially see the .txt first, try opening it,
and fail alltogether, even though the image file existed.

Now we try opening all matching files until we find one that
we can parse.

This fixes #101.
2015-07-09 15:38:50 +02:00
Jonas Kulla 533e69275a Constify 2015-07-09 14:53:59 +02:00
Jonas Kulla e4558c9dfb Use FS::openReadRaw() where ext supplementing makes no sense
Specifically, in places where the full filename is always supplied,
eg. when reading .rxdata type files.
2015-07-09 12:58:01 +02:00
Jonas Kulla 5382cc11a3 MidiSource: Close source SDL_RWops before throwing error 2015-07-09 12:38:04 +02:00
Jonas Kulla 1e9e24e45c README: Add note about RGSS version support 2015-07-09 12:33:55 +02:00
Jonas Kulla 9acdd206f6 Vec4: Rename 'xyzHasEffect()' to something that makes sense 2015-07-07 16:07:04 +02:00
Jonas Kulla 6e176a454c Constify 2015-07-07 16:06:45 +02:00
Jonas Kulla afab51279e Graphics: Fix viewport color/flash effectiveness calculation
Fixes #121.
2015-07-07 16:06:11 +02:00
Jonas Kulla 61849a9158 GLMeta: Eliminate redundant parameter 2015-07-07 15:25:48 +02:00
Jonas Kulla 2d31d08fa6 Add some general fixes from #111 found by @chosenofbear 2015-06-18 07:21:55 +02:00
Jonas Kulla e778dc17c5 Relocate SDL_sound patches into forked repo 2015-06-18 07:11:38 +02:00
Jonas Kulla 6380a93cec Graphics: Fix ::transition() "filename" default value
The default value is an empty string, which triggers the simple
transition. Passing null is not legal (and wasn't possible in
mkxp from Ruby side anyway).

Fixes #108.
2015-06-10 13:30:26 +02:00
Jonas Kulla 064b7ac80d README: Add link to dependency kit 2015-06-03 16:01:29 +02:00
Jonas Kulla d5bacf50f5 TileAtlasVX: Fix table extents being covered by below tiles
Fixes the appearance of tables in VX, which place table
tiles on the same layer as ground tiles.
2015-05-31 20:58:05 +02:00
Jonas Kulla e4bc08e972 Fix for old, broken OpenAL-Soft headers
See 4219b91bbb
2015-05-26 01:40:53 +02:00
Jonas Kulla 88eca58268 Revert "check Ruby strings for embedded null bytes"
This reverts commit 29dfda0011.
It turned out to be a bad idea after all.
2015-05-11 23:13:02 +02:00
Jonas Kulla e72bced0f7 'snprintf()' guarantees null termination of buffer
Thanks @cremno.
2015-03-27 08:21:47 +01:00
Jonas Kulla 794e86d0ab AudioStream: Prevent MeWatch from restarting fully faded out stream 2015-03-22 09:06:29 +01:00
Jonas Kulla 7260c467b8 AudioStream: Clarify thread-safe usage of stream flags 2015-03-22 08:42:43 +01:00
Jonas Kulla 8d7166f3d2 MRI: Fix Font.name returning nil
I wish I had tests..
2015-03-16 08:36:29 +01:00
Jonas Kulla 5379511d95 Bitmap: Fix vertical alignment for some letters with outline 2015-03-04 23:34:56 +01:00
Jonas Kulla 91c9bfd0f4 Fix compilation failure inside OSX ifdef block 2015-02-26 19:44:05 +01:00
Jonas Kulla 7393f7e951 Config: Add "execName" to specify ini and rgssad filenames 2015-02-19 02:23:23 +01:00
Jonas Kulla 531441d4e3 Make audio asset decoding failures non-fatal
Matches RMXP behavior. This is also useful in case midi files
are to be played, but fluidsynth isn't available.
2015-02-17 02:09:55 +01:00
Jonas Kulla 0f91bdefea Fix indentation 2015-02-17 01:48:05 +01:00
Jonas Kulla 44eaaf5985 FileSystem: Change file lookup to match all extensions
Previously, file lookup (ie. extension supplementing) would only
try out a few predetermined extensions based on the asset type.
This was not accurate in regard to RMXP's behavior, which will
happily match "some_asset" against "some_asset.abcef" and try
to open it.

Some games make use of this quirk and rename their ogg audio files
to "*.dat" or similar to thwart users from copying them.

This change also makes it easier to read arbitrary formats
supported by SDL_image without modifying mkxp.
2015-02-17 01:42:11 +01:00
Jonas Kulla 87462fd7b0 Use more explicit vector math via method overloads 2015-02-10 17:04:00 +01:00
Jonas Kulla a4b1be1da5 Remove superfluous lines 2015-02-10 15:53:58 +01:00
Jonas Kulla c328ebee04 Typo 2015-02-10 15:53:12 +01:00
Jonas Kulla 713ea07558 SDL hints need to be set before initialization 2015-02-10 15:51:33 +01:00
Jonas Kulla b2631d4c23 Bitmap: Fix scaled blit from mega surface to texture
SDL's default blend mode for surfaces (SDL_BLENDMODE_BLEND)
renders the source surface unusable for further use.
2015-02-10 15:34:42 +01:00
Jonas Kulla 4864f63c6c Sprite: Fix visibility calculation
The previous code assumed the scene origin to always be 0,0.
2015-02-04 15:17:45 +01:00
Jonas Kulla e339964076 MidiSource: Fix some channels being mute after looping 2015-01-22 13:13:57 +01:00
Jonas Kulla 64a3ac3769 README: Add soundfont link and mark font outlines as done 2015-01-21 14:58:54 +01:00
Jonas Kulla fa0459ad93 Fix code formatting 2015-01-15 11:09:12 +01:00
Jonas Kulla 74f8c91bf4 Oops 2015-01-15 09:05:51 +01:00
Jonas Kulla 7cbe1eef94 Graphics: Improve transition "vague" parameter accuracy 2015-01-15 08:26:33 +01:00
Jonas Kulla f6604a88b8 sdl-util.h: Consider physical filesystem when opening raw files
This is necessary so games stored on external SD cards can be
run under Android.
2015-01-15 08:11:01 +01:00
Jonas Kulla c92df0ce3a EventThread: Pause OpenAL device when entering background
This requires ALC_SOFT_pause_device to be present. It stops the
alc thread from needlessly consuming CPU resources.
2015-01-15 08:07:22 +01:00
Jonas Kulla 7c6a2b2c62 Pause RGSS execution when moving into background on Android
Assuming that there is enough memory for mkxp to stay in the
background and that the OS doesn't kill the process, this should
allow smooth resuming after moving back into the foreground.

For now, EGL context loss is not handled.
2015-01-15 08:02:21 +01:00
Jonas Kulla 012d87d05a Disable accelerometer joystick emulation on Android 2015-01-15 07:21:07 +01:00
Jonas Kulla f1da585f33 Be explicit about how relative paths are resolved in mkxp.conf 2015-01-15 07:18:02 +01:00
Jonas Kulla a05a3deff6 EventThread: Factor out event discarding code 2015-01-03 20:48:31 +01:00
Jonas Kulla 6f88ddc51c Config: Move default entry values into PO_DESC macro list 2015-01-03 19:28:23 +01:00
Jonas Kulla 7003039e56 EventThread: Track touch state (maximum 4 fingers) 2015-01-03 19:18:52 +01:00
Jonas Kulla 146e0294b4 Add option to fix the framerate to the native screen refresh rate
Useful on mobile devices where using non-standard framerates
looks absolutely horrible and screen refresh rates vary highly.
2015-01-03 18:58:13 +01:00
Jonas Kulla 4fb94aaf10 FileSystem: Add fallback to wrapped SDL_RWops if normal mounting fails
Makes it easy to mount archives on Android residing in "assets/".
2015-01-02 14:50:14 +01:00
Jonas Kulla 3411435138 Factor out some thread communication code (window size, bindings) 2015-01-02 01:41:23 +01:00
Jonas Kulla c63a8947ce Tilemap: Don't emit draw with zero quads
This is illegal on some mobile drivers.
2015-01-02 00:09:53 +01:00
Jonas Kulla b42725ea20 Add config option working around buggy graphics drivers
"subImageFix=true" should fix missing text on radeonsi fglrx
as well as most mobile drivers. Also fixes tileset atlas on
mobile.
2015-01-01 23:38:11 +01:00
Jonas Kulla 9122446b23 EventThread: Discard fake mouse events on mobile 2014-12-31 18:52:21 +01:00
Jonas Kulla 7cbf81c83a Add 'printFPS' config entry to continuously print FPS to console
Useful on platforms that don't have window decorations.
2014-12-31 18:52:21 +01:00
Jonas Kulla b4bca7ea3b GLState: Constify 2014-12-31 18:52:21 +01:00
Jonas Kulla 725af97e7b gl-util.h: Unify function qualifier use 2014-12-31 18:52:21 +01:00
Jonas Kulla 35077793a0 Add std::streambuf wrapper around SDL_RWops for boost
Also add SDL_RWops version of the readFile utility function.
2014-12-31 18:52:21 +01:00
Jonas Kulla 5974d05380 Create OpenAL device in main() and store in RGSSThreadData 2014-12-31 18:52:21 +01:00
Jonas Kulla 3596fc568d main.cpp: Immediately query the actual window size after creation 2014-12-31 18:52:21 +01:00
Jonas Kulla 69795be30b Android uses the Linux shared object naming convention 2014-12-31 18:52:21 +01:00
Jonas Kulla 0a484c8a31 std::string constructor doesn't like null pointers 2014-12-31 18:52:20 +01:00
Jonas Kulla 4560589e25 Audio: Set overall volume of OpenAL output to 0.8 2014-12-31 18:52:20 +01:00
Jonas Kulla 4b08d82ea4 MRI: dataDirectory: Return "." if customDataPath is not defined 2014-12-31 18:52:20 +01:00
Jonas Kulla 88c41bcc62 Debug: Use native logging on Android 2014-12-31 18:52:20 +01:00
Jonas Kulla a112529f53 Use compile time strlen 2014-12-31 18:52:20 +01:00
Jonas Kulla b963c67339 SharedState: Don't reallocate global tex on every bind 2014-12-31 18:52:20 +01:00
Jonas Kulla ee17bb2137 Call glReleaseShaderCompiler on GLES 2014-12-31 18:52:20 +01:00
Jonas Kulla 3fb4108306 gl-fun.h: Add some enums missing in gl2.h 2014-12-31 18:52:20 +01:00
Jonas Kulla fcfa079e7b Perform chdir(gameFolder) early in main() 2014-12-31 18:52:20 +01:00
Jonas Kulla 03a6c657c4 main.cpp: Always display errors in a message box 2014-12-31 18:52:20 +01:00
Jonas Kulla b39964a49a MRI: Make error handling during script load more robust 2014-12-31 18:52:20 +01:00
Jonas Kulla 2f95c0613a Shaders: Prefer arithmetic conditionals to branching 2014-12-31 18:52:20 +01:00
Jonas Kulla 373b90af00 Graphics: Optimize Viewport effect rendering
Using the kitchen sink plane shader for viewport effects, even
if only a small part of them are active, incurs great performance
loss on mobile, so split the rendering into multiple optional
passes which additionally use the blending hardware for faster
mixing (lerping).
Also, don't mirror the PingPong textures if the viewport effect
covers the entire screen area anyway.
2014-12-31 18:52:19 +01:00
Jonas Kulla 3c0a530eba Sprite: Add special case shader for translucent effect
Translucent sprites (opacity < 255) are very common,
so using a custom shader instead of the full blown effect one
helps a lot, especially on mobile.
2014-12-31 18:52:19 +01:00
Jonas Kulla a53163660f Shader: Refine preprocessing on GLES platform
Don't globally set float precision to mediump, only fragment
shaders need that and defining it for vertex shaders causes
tilemap cracks.

Also manually define low precision for variables that hold
color / alpha values.
2014-12-31 18:52:19 +01:00
Jonas Kulla a501e4f22f Add ruby patch for statically linking zlib extension 2014-12-31 18:52:19 +01:00
Jonas Kulla 02f19c03c9 Merge pull request #86 from Daverball/controller-fix
Xbox controllers require JoyHat events to be tracked on windows
2014-12-31 18:50:57 +01:00
David Salvisberg 90e1c09711 Added support for JHat events. 2014-12-31 16:39:28 +01:00
Jonas Kulla d18e3e6a53 Merge pull request #84 from Daverball/hue-shader-fix
hue shader turns pure white pixels black on some GPUs.
2014-12-31 16:12:08 +01:00
David Salvisberg 8240f3333f Fixed hue shader turning pure white pixel to pure black on some GPUs. 2014-12-31 16:02:10 +01:00
Jonas Kulla 150abff1c0 Merge pull request #85 from Daverball/save-button-config
Button config menu should save config to disk whenever changes are accepted.
2014-12-31 14:13:53 +01:00
Jonas Kulla 78e246c11d Merge pull request #83 from Daverball/master
Added rudimentary support for font outlines.
2014-12-31 13:51:44 +01:00
David Salvisberg b1e1d28879 Added rudimentary support for font outlines. 2014-12-31 13:49:18 +01:00
David Salvisberg 6829ddc09f Removed store keybindings from main, since it now already gets stored onAccept. 2014-12-28 06:06:28 +01:00
David Salvisberg 7413c3d994 Make button config menu save changes to disk whenever the changes are accepted. 2014-12-27 14:40:08 +01:00
Jonas Kulla 11cfe887c2 Fix several classes not accepting disposed bitmaps
Fixes an error in Alpha Kimori.
2014-12-22 08:22:45 +01:00
Jonas Kulla 685f8b63b3 Input: Integer button codes are still allowed in RGSS3 2014-12-09 04:21:48 +01:00
Jonas Kulla 6c92101e05 icon.svg: Resize page to drawing for easier rasterization 2014-11-30 21:46:18 +01:00
Jonas Kulla 3faaed89d0 icon.svg: Use 'inkscape -l' to strip inkscape specific tags 2014-11-30 21:09:11 +01:00
Jonas Kulla 98b0b71359 Don't use relative paths when #including xxd output 2014-11-30 17:50:24 +01:00
Jonas Kulla 60f101f2e6 Tilemap(VX): Factor out common code into tilemap-common.h
Renamed flashmap.h to tilemap-common.h as it already contained
shared functions.
2014-11-30 17:46:28 +01:00
Jonas Kulla faef0e8503 README: Add prebuilt windows binaries link 2014-11-30 17:41:34 +01:00
Jonas Kulla f00cb60707 debugwriter.h: Use unbuffered cerr instead of clog 2014-11-29 17:55:18 +01:00
Jonas Kulla c1aab96454 Rename src/debuglogger -> src/gl-debug 2014-11-29 17:51:37 +01:00
Jonas Kulla bc31922c33 Allow inserting GL string markers (GREMEDY_string_marker) 2014-11-29 17:33:39 +01:00
Jonas Kulla 5979c5f778 Add placeholder application icon 2014-11-29 17:30:53 +01:00
Jonas Kulla cfd9345e87 MRuby: Update module_rpg.c to newest bytecode format 2014-11-29 14:55:43 +01:00
Jonas Kulla c2f8b6b749 SettingsMenu: Fix help label sometimes not appearing 2014-11-28 06:04:34 +01:00
Jonas Kulla 276160f0d5 gl-fun.h: Fix compilation with outdated SDL headers 2014-11-22 17:03:16 +01:00
Jonas Kulla f236e34e2d Serializable, Table: Some general cleanups 2014-11-20 14:45:54 +01:00
Jonas Kulla 33c571e691 MRI: Fix mingw build crash when linking with -mwindows 2014-11-20 13:51:35 +01:00
Jonas Kulla 9ac14800da Keybindings: SDL_GetPrefPath result always ends with separator 2014-11-17 07:24:22 +01:00
Jonas Kulla 5c3f4b905a Use fopen with binary mode everywhere (for Windows compat) 2014-11-17 07:18:39 +01:00
Jonas Kulla f7a3e3c5d2 Table: General clean up and code reduction
- Use STL vector instead of doing manual mallocs
- Throw away the resize optimizations; hardly useful
- Marshal.dump data layout is the same as ours (in LE),
  so we can just memcpy everything instead of copying
  one by one

Throwing away part of the very first code I wrote for mkxp
felt very refreshing I must say.
2014-11-02 23:37:35 +01:00
Jonas Kulla a98ad3134b TilemapVX: Implement flash tiles 2014-10-27 15:52:41 +01:00
Jonas Kulla 577f606dac Tilemap: Factor out flash tile code
This will be reused later in TilemapVX.
2014-10-26 20:00:56 +01:00
Jonas Kulla 05b32d76ca Minor cleanup 2014-10-25 23:38:19 +02:00
Jonas Kulla c9d5059238 Pass value object attributes by reference (instead of pointer)
This underlines that no reference inside the setter is taken,
and that these attributes are non-nullable.

Also removes a couple of superfluous attribute macros.
2014-10-25 23:33:41 +02:00
Jonas Kulla 5549ff78f0 Bindings: Viewport: Don't dispose children in RGSS2/3 2014-10-24 18:55:03 +02:00
Jonas Kulla 1a489aafaf Bindings: Fix inconsistency in Viewport dispose (RGSS1)
As noted, on Viewport dispose, RMXP always calls the core
dispose method for child objects regardless of whether
user scripts override it in sub classes.

Implement this behavior in mkxp to prevent infinite recursion.
2014-10-24 18:35:05 +02:00
Jonas Kulla 8b31f97bb4 MRuby: Fix compilation 2014-10-24 18:26:10 +02:00
Jonas Kulla ecf9b065c8 MRI: Revise 'MKXP.data_directory' behavior
This function which was formerly a simple wrapper around
SLD_GetPrefPath() is changed to instead return the directory
assembled from org/app name specified in mkxp.conf, so one
can be sure that both mkxp and user scripts will always write
into the same directory when a custom path is preferred.
2014-10-22 04:16:15 +02:00
Jonas Kulla af8f3a36d2 MRI: Move former 'System' module into 'MKXP' module
This breaks script compatibility.

'System' is way too generic of a name to reserve for mkxp use,
and I have already seen at least one occurance in the wild of
it being used by user scripts.

Ideally, all mkxp RGSS extensions would be moved under this
module, but I feel like the core modules (Input, Graphics etc)
are more safe as users are hesitant to directly extend these.
2014-10-22 04:15:40 +02:00
Jonas Kulla 8e1852a281 Remove left-over dead code 2014-10-21 19:51:08 +02:00
Jonas Kulla 4a8b0f30c8 MRI: Add 'System.raw_key_states' to query full keyboard state
Returns a byte array with all key states (0 = released,
1 = pressed) indexed via SDL_SCANCODE_* enums.
2014-10-20 10:27:01 +02:00
Jonas Kulla e44a1e32fa Reorder some lines 2014-10-20 10:20:08 +02:00
Jonas Kulla 6145c59305 fluid-fun: Don't dlclose libfluidsynth, ever
Some versions of the library do nasty things with thread
local storage without cleaning up after themselves.
2014-10-20 10:17:48 +02:00
Jonas Kulla 1c1d72b03e README: VX / VX Ace support is no longer experimental 2014-10-18 02:21:19 +02:00
Jonas Kulla e1a45c29e2 README: Add OSX build by Ali and clarify SDL2 patch note 2014-10-18 02:15:00 +02:00
Jonas Kulla 5094f5c7c1 Add minor assert 2014-10-16 09:10:27 +02:00
Jonas Kulla 47851718eb MRI: Handle exceptions raised in preloaded scripts 2014-10-15 06:27:43 +02:00
Jonas Kulla 2cd70b9edd Window: Don't update anything if width*height == 0
Fixes GL errors.
2014-10-15 06:26:46 +02:00
Jonas Kulla 19b1c3d7c2 README: Mention SDL patch needed for F1 menu 2014-10-12 14:54:30 +02:00
Jonas Kulla 64a26b4911 README: Add link to prebuilt binaries 2014-10-12 02:38:28 +02:00
Jonas Kulla dd73db2e9d Introduce F1 menu to reconfigure key bindings at runtime 2014-10-11 20:48:44 +02:00
Jonas Kulla af145c3a01 mkxp.pro: Make MRI version a qmake config option
Example: qmake MRIVERSION=2.2
2014-10-11 15:36:21 +02:00
Jonas Kulla 520162f36a Use safe way to get at a vector's data pointer
&std::vector<C>[0] is not guaranteed to not throw if the
vector is empty. Better safe than sorry.
2014-10-09 19:02:29 +02:00
Jonas Kulla 1b7ed5ed78 Font: Fix default 'shadow' value for RGSS1 2014-10-09 18:53:24 +02:00
Jonas Kulla 0c08fc2d16 gl-fun.h: Fix function type signature 2014-10-06 21:10:19 +02:00
Jonas Kulla 18076c9ae4 Merge branch 'master' of github.com:Ancurio/mkxp
Conflicts:
	src/tileatlasvx.cpp

I fucked up somehow.
2014-10-03 20:21:07 +02:00
Jonas Kulla c1d89e4f8d CMakeLists.txt: Bump default MRI version to 2.1 2014-10-03 20:15:52 +02:00
Jonas Kulla 55a2cf562e TileAtlasVX: Followup fix
Use rectangle intersection to correctly clip source
rectangles with origin != (0,0).
2014-10-03 06:58:54 +02:00
Jonas Kulla df73045d81 TileAtlasVX: Followup fix
Use rectangle intersection to correctly clip source
rectangles with origin != (0,0).
2014-10-03 06:51:39 +02:00
Jonas Kulla db78e55371 TileAtlasVX: Clamp blit src rect to tileset bitmap size 2014-10-02 16:41:53 +02:00
Jonas Kulla 95cda4035e fluid-fun: Fix fluidsynth soname on OSX 2014-10-01 19:19:25 +02:00
Jonas Kulla 7b65977eb9 Silence "uninitialized" warnings 2014-10-01 06:29:47 +02:00
Jonas Kulla fa911b8018 gl-fun: Don't rely on SDL_opengl.h for function type definitions 2014-10-01 04:48:23 +02:00
Jonas Kulla 5ea964eee8 CMakeLists.txt: Link against libiconv on OSX 2014-09-30 14:17:33 +02:00
Jonas Kulla 51a0f3903c Audio: Clean up threading and add AudioStream fadein (RGSS3) 2014-09-30 09:13:12 +02:00
Jonas Kulla 46497eae01 CMakeLists.txt: Add missing shader source 2014-09-30 01:34:10 +02:00
Jonas Kulla 3dd703f732 MRI: Use ruby 2.0 compatible function name 2014-09-30 00:48:22 +02:00
Jonas Kulla 4a015c6397 Bitmap: Add font shadow rendering 2014-09-29 10:30:41 +02:00
Jonas Kulla 9e64dff01c Bitmap: Fix mem leak 2014-09-29 10:30:16 +02:00
Jonas Kulla 9758e660c4 Tilemap/VX: Ensure proxy objects don't outlive their parents
Either of these would previously crash (same for VX):

tm = Tilemap.new
at = tm.autotiles
tm = nil
GC.start
at[0] = Bitmap.new(1, 1)

tm = Tilemap.new
at = tm.autotiles
tm.dispose
at[0] = Bitmap.new(1, 1)

Funnily, this makes RMXP itself crash too, but crashing is
never acceptable except for possibly resource exhaustion.
2014-09-26 18:21:50 +02:00
Jonas Kulla e9d0d0566b RGSSError is a subclass of StandardError 2014-09-26 18:20:27 +02:00
Jonas Kulla d223d83cbf Implement F12 game reset (MRI only)
Can be disabled with "enableReset=false".

While at it, also replace the flakey volatile bool flags
with proper atomics.
2014-09-26 06:25:47 +02:00
Jonas Kulla 3a2e560139 Input: Fix default keybinds 2014-09-26 06:25:47 +02:00
Jonas Kulla 2550fd8ccc WindowVX: Initialize all dirty flags and connect tmp tone 2014-09-26 06:24:43 +02:00
Jonas Kulla 81ac0780f8 Revert Disposable concept back into core
Pretty much a revert of
e858bbdcf5.

We need this in core to properly implement F12 reset.
2014-09-23 21:12:58 +02:00
Jonas Kulla 3983fe66e9 Config: Print parsing errors instead of ignoring them 2014-09-23 19:23:11 +02:00
Jonas Kulla 17efcbbbbd tl;dr: I fucking suck at coding (fix double free)
MRI: Filesystem: A garbage collected SDL_RWops file handle
will call close on itself even if 'close' was explicitly
called on it on the script side before.
2014-09-23 17:26:30 +02:00
Jonas Kulla 8d67b7c91d MRI: Init default font names to correct value (RGSS2) 2014-09-23 12:05:28 +02:00
Jonas Kulla 5c3c73ee94 README: Remove erroneous line about cmake 2014-09-15 09:42:09 +02:00
Jonas Kulla 3a29385df0 MRI: load_data: Catch exceptions and pass onto ruby 2014-09-13 07:26:42 +02:00
Jonas Kulla 05041fdb03 Couple fixes to last SDL_sound patch 2014-09-13 07:26:42 +02:00
Jonas Kulla 61b77c2027 Merge pull request #69 from cremno/check-ruby-string-for-embedded-null-bytes
MRI: check Ruby strings for embedded null bytes
2014-09-12 23:30:07 +02:00
Jonas Kulla f49cd4391a Merge pull request #68 from cremno/vxtilemap-has-9-bitmaps
VX tilemap has 9 bitmaps
2014-09-12 23:13:08 +02:00
cremno 6abc207f1e VX tilemap has 9 bitmaps 2014-09-12 15:21:20 +02:00
cremno 29dfda0011 check Ruby strings for embedded null bytes
The RGSS doesn't do it. But doing it shouldn't be a problem, as it's the
correct way. If a game is broken by this commit (unlikely), then the game
needs to be fixed as silent truncation is highly unlikely to be wanted.
2014-09-12 15:20:12 +02:00
Jonas Kulla a365a7a754 Spacing 2014-09-12 06:42:18 +02:00
Jonas Kulla 0c318ee0b2 SDL_sound: Add wave IMA ADPCM (4bit) support patch 2014-09-12 06:39:49 +02:00
Jonas Kulla 757a1d5e39 Load fluidsynth entrypoints dynamically (and make them optional)
This removes the static dependency on fluidsynth being present
at buildtime (even headers aren't needed anymore).

Even though midi is a default format for the RPG XP/VX series,
it has fallen more and more out of use, with VX Ace completely
abandoning it from the RTP and making ogg vorbis the de facto
standard. Midi support is kept for legacy reasons, but isn't
encouraged. On top of all this, fluidsynth together with glib
is a heavy dependency that often times won't even be used.
Making it optional at build time is an attempt to unify and
keep build config fragmentation low.

In RGSS3, fluidsynth / midi is not initialized at all by
default, but rather on demand when either a midi track is
played back or Audio.setup_midi is called.
2014-09-09 00:08:32 +02:00
Jonas Kulla 673a25f811 Bitmap: Don't use 'pixman_region_clear'
It's not included in older pixman versions.
2014-09-07 19:11:20 +02:00
Jonas Kulla ac9b98157e TilemapVX: Use SimpleShader for unanimated ground layers
Also remove some useless member variables.
2014-09-06 22:02:00 +02:00
Jonas Kulla 6bc3460294 Core, MRI: Don't expose RGSS3 functionality in 2 2014-09-06 02:01:20 +02:00
Jonas Kulla bca95adc0e MRI: WindowVX dummy contents object is always created
The check was against rgssVer >= 2, but since that's always
true if WindowVX is used, it was pointless.
2014-09-05 22:54:57 +02:00
Jonas Kulla 9461449cc9 MRuby: Fix handling of Etc/Font properties
Port of f8c26fc515.
2014-09-05 22:53:19 +02:00
Jonas Kulla 7f41b9cc45 Config: Correctly setup rgssVer / screen size with customScript 2014-09-05 21:54:16 +02:00
Jonas Kulla 4d54fce8ee Small compilation fix (mruby is still broken though) 2014-09-05 01:59:01 +02:00
Jonas Kulla 0131ed09f0 Bindings: Remove 'wrapNilProperty'
It's completely useless lol.
2014-09-05 01:59:01 +02:00
Jonas Kulla f8c26fc515 Core/MRI: Fix handling of Etc/Font properties
The gist of it is that for Etc and Font props, the assignment
operator (eg. 'sprite.color=') does not take a reference of the
right hand parameter and replaces its previous one with it (this
was the old behavior). Rather, it keeps its internal property
object and copies the parameter object into it by value.
The getter is unchanged; it still returns a reference to the
internal property object.

s = Sprite.new
c = Color.new
s.color = c
p s.color == c # => true
p s.color.object_id == c.object_id # => false (true before)
c = s.color
p s.color.object_id == c.object_id # => true
2014-09-05 01:58:41 +02:00
Jonas Kulla f665d8b41c BoostSet: Add 'remove' and rename BoostHash::erase to remove
This is more consistent with Qt's method naming.
2014-09-05 01:06:08 +02:00
Jonas Kulla 10186e8dcc Input: Fix isRepeated off-by-one error and do small optim. 2014-09-03 02:35:57 +02:00
Jonas Kulla d2d86e7002 Merge pull request #66 from cremno/add-rgss2-3-input.repeat
Input: add RGSS2/3 Input.repeat?
2014-09-02 23:42:14 +02:00
Jonas Kulla 8c1cf27b7c Merge pull request #67 from cremno/add-rgss-3-0-1-etc-classes-equality-comparison
add RGSS 3.0.1 etc classes equality comparison
2014-09-02 20:09:10 +02:00
Jonas Kulla 8975255ecf Merge pull request #65 from cremno/define-case-and-hash-equality-for-etc-classes
define case and hash equality for etc classes
2014-09-02 20:02:47 +02:00
cremno fd4f7c66d1 bump RGSS_VERSION to 3.0.1 2014-09-02 19:53:09 +02:00
cremno 7acbb06fbd add RGSS 3.0.1 etc classes equality comparison
RGSS 3.0.1 finally fixed #==, #===, #eql? for Color, Tone, and Rect.
Now instances of them can be compared to other kinds of objects.
2014-09-02 19:53:05 +02:00
Jonas Kulla 48b1af1e43 Merge pull request #64 from Ancurio/show_exc_fixes
MRI: Fix exception message box script name and display script index
2014-09-02 19:48:10 +02:00
cremno a366862076 define case and hash equality for etc classes
RGSS also defines #=== and #eql? for Color, Tone, and Rect:

  Color.instance_method(:==) == Color.instance_method(:===)   # => true
  Color.instance_method(:==) == Color.instance_method(:eql?)  # => true
2014-09-02 19:18:51 +02:00
cremno 4b08eee81f add RGSS2/3 Input.repeat? 2014-09-02 19:14:05 +02:00
Jonas Kulla 3b7b8657ea MRI: Fix exception message box script name and display script index
Previously, when the script names in the backtrace were in the form
'SectionXXX'/'{XXXX}' (default RMXP behavior), this same name would
be shown in the error message box, whereas RMXP always displays the
actual script name (eg. 'Scene_Map') instead; only with
useScriptNames=true was mkxp's behavior mostly correct.
Fix this by keeping a backtrace format -> actual script name mapping
and always using the script name in the message box.
The script name and line would also be parsed wrongly if the name
contained any colons, fix this by walking the exception string
back to front instead.

Also prepend the script index to the name when useScriptNames=true;
this is invaluable when debugging projects where multiple scripts
carry the same name. The format is 'XXX:Script_Name'.
2014-09-02 17:16:14 +02:00
Jonas Kulla 7bc07301db Merge pull request #62 from cremno/mri-bitmap-fix-obj2str-conversion
fix Bitmap's object to string conversion
2014-08-31 14:06:54 +02:00
Jonas Kulla 360cf240f6 Merge pull request #61 from cremno/mri-add-rgss_version
add RGSS_VERSION (RGSS3)
2014-08-31 12:58:11 +02:00
Jonas Kulla 91209fa4bb Merge pull request #60 from cremno/mri-table-fix-conversions
fix some integer conversions in the Table class
2014-08-31 11:20:09 +02:00
cremno 53cd5e1fbc use std::max instead of ?: 2014-08-31 11:10:57 +02:00
cremno b8fc8cf9b6 fix Bitmap's object to string conversion
Calling #to_s might not return a string (it should though).
2014-08-31 09:52:04 +02:00
cremno 95c53899be add RGSS_VERSION (RGSS3)
Even though 3.0.1 is the current version, 3.0.0 is used, because mkxp doesn't
implement the changes like not raising a TypeError for 'Color.new == nil' yet.
3.0.1 (finally) returns false. Other changes don't affect mkxp (I think).

See <http://tkool.jp/support/download/rpgvxace/rpgvxace_update> (Japanese).
2014-08-31 05:46:04 +02:00
cremno acf826eb7a fix some integer conversions in the Table class
Sizes (x, y, z) are clamped to a non-negative int value.
Use NUM2INT instead of FIX2INT as the argument might not be a Fixnum.
2014-08-31 04:46:51 +02:00
Jonas Kulla d8bb6aa2fc Replicate RMVX/VXA's broken sprite Z sorting implementation
Fixes Window_NameBox visual appearance in Skyborn.

Also nuke the second SceneElement constructor that has been
obsolete since the Tilemap mapViewport rewrite.
2014-08-31 01:10:32 +02:00
Jonas Kulla 1a98760b31 Config: Properly clamp rgssVersion to allowed range 2014-08-30 12:00:56 +02:00
Jonas Kulla 3da785b293 FileSystem: RGSS2 means ogg vorbis support is always available 2014-08-30 12:00:56 +02:00
Jonas Kulla 2ba9f6589b Merge pull request #57 from cremno/mri-use-rb_type_p-instead-of-rb_type
MRI: use RB_TYPE_P() instead of rb_type()
2014-08-30 03:56:37 +02:00
Jonas Kulla f7d7b16eaf Merge pull request #58 from cremno/mri-use-rb_data_type_t
MRI: use rb_data_type_t and initialize in definition
2014-08-29 22:17:25 +02:00
Jonas Kulla 3cdbf2b035 Merge pull request #59 from cremno/mri-add-global-function-rgss_stop
MRI: add global function rgss_stop
2014-08-29 22:15:31 +02:00
cremno 173ee07959 get rid of INIT_TYPE() / initType()
A function to initialize rb_data_type_t variables is not needed.

Also fix a FIXME (WindowVX's name is now "Window") on the way.
2014-08-29 21:01:53 +02:00
cremno 4920931d33 add global function rgss_stop
It's only useful for testing code. Also RGSS3's rgss_stop (and rgss_main)
is written in Ruby and not in C++. But I doubt someone relies on that.
2014-08-29 14:32:43 +02:00
cremno 0203e28436 use rb_data_type_t instead rb_data_type_struct
For some reason the struct tag and typedef name differ and
nobody uses rb_data_type_struct.
2014-08-29 14:13:40 +02:00
cremno 70c40fe530 MRI: use RB_TYPE_P() instead of rb_type()
Just a very small optimization.
2014-08-29 13:11:39 +02:00
Jonas Kulla 6d414c0777 Print RGSS version on startup 2014-08-29 03:16:12 +02:00
Jonas Kulla 55f1542c76 Merge separate RGSS version build configs into one
Setup active RGSS version at runtime. Desired version can be
specified via config, or as default, auto detected from the game
files. This removes the need to build specifically for each
version, which should help packaging a lot.

This also greatly reduces the danger of introducing code that
wouldn't compile on all RGSS version paths (as certain code paths
were completely ifdef'd out).

This can be optimized more, eg. not compiling shaders that aren't
needed in the active version.
2014-08-28 23:22:05 +02:00
Jonas Kulla b1981055e1 Core: Remove ifdefs that don't influence RGSS specific behavior
This is the first step in eliminating the build time RGSS
versioning.
2014-08-28 19:43:13 +02:00
Jonas Kulla 28421a0ce5 Tilemap: Remove RGSS2 viewport setter
This class is not used in RGSS2 at all.
2014-08-28 15:37:04 +02:00
Jonas Kulla c88b4b03d6 Bitmap: Fix blitshader draw_text path not taking squeezing into account 2014-08-28 14:53:28 +02:00
Jonas Kulla 20081cb07e Wrap include in feature macro 2014-08-28 11:27:36 +02:00
Jonas Kulla 7bcc31fb53 Silence "unused param" warning in release mode 2014-08-28 11:26:20 +02:00
Jonas Kulla 18c74e0f24 SoundEmitter: Only detach/attach buffer if necessary 2014-08-25 05:35:46 +02:00
Jonas Kulla b1ebc655f9 SoundEmitter: Make SE source count configurable
Default is still 6.
2014-08-25 05:34:19 +02:00
Jonas Kulla 5ee62ba0fd SoundEmitter: Optimize source allocation strategy a bit
If no source is free, instead of seizing the lowest priority one,
first try to find the lowest priority source with the same buffer
that is about to be played and use it. Otherwise, take lowest priority
one as before.
2014-08-24 09:19:54 +02:00
Jonas Kulla ce72e6d0ee Input: Fix keyboard bindings (RGSS1 and 2 differ), add numpad enter -> C binding 2014-08-24 08:03:12 +02:00
Jonas Kulla 117ddeee5c Config: Add 'preloadScript' entry to run raw scripts before the game scripts
Useful to insert common code, wrappers etc. without touching Scripts.rxdata.
2014-08-24 07:32:44 +02:00
Jonas Kulla d2fd692041 MRI: Actually define '$MKXP' 2014-08-24 07:21:26 +02:00
Jonas Kulla dbb2249ff3 MRI: Graphics: Bind resize_screen 2014-08-24 07:20:44 +02:00
Jonas Kulla 3968ebb538 Graphics: Transition without previous freeze is a noop 2014-08-23 21:26:50 +02:00
Jonas Kulla 4baf7b5a5a Spacing 2014-08-23 13:53:13 +02:00
Jonas Kulla b380a0ebdd SharedState: Fix asset path priority (rgssad -> "." -> RTPs) 2014-08-22 23:58:14 +02:00
Jonas Kulla f76ecfdba8 MRI: WindowVX: Bind RGSS2 constructor (same as RGSS1) 2014-08-22 23:57:12 +02:00
Jonas Kulla b751858b16 Graphics: Fadein/out should interpolate from current brightness 2014-08-22 23:57:12 +02:00
Jonas Kulla 24ad0990da TilemapVX: Deal correctly with Graphics.resize_screen 2014-08-22 23:57:12 +02:00
Jonas Kulla 50e393fe6e Graphics: Fix resize_screen 2014-08-22 23:57:12 +02:00
Jonas Kulla c5c58fa9cd SoundEmitter: Show filename that caused the SDL_Sound error 2014-08-22 23:50:52 +02:00
Jonas Kulla ee8a3ca402 MRI-Binding: Font: Add get/set_default_out_color binding 2014-08-22 23:49:18 +02:00
Jonas Kulla 10bfcb57b7 Config: Convert game title to valid UTF-8 (if it isn't already)
Removes the need to manually convert the Game.ini to UTF-8 every
time with eg. Japanese games. Also, setting the window title on
OSX with invalid UTF-8 crashes.

This functionality and the dependency on libiconv and libguess
are optional and can be enabled with `CONFIG+=INI_ENCODING`.
If turned off and invalid UTF-8 is encountered, the game title
is treated as being empty (ie. the folder name is used instead).
2014-08-20 23:32:18 +02:00
Jonas Kulla 622845a404 TileAtlasVX: Handle table autotiles properly 2014-08-19 19:47:22 +02:00
Jonas Kulla fb2b2b7260 WindowVX: Fix scroll arrows not showing initially 2014-08-19 19:47:22 +02:00
Jonas Kulla 0c72659025 Remove stale code 2014-08-19 19:47:22 +02:00
Jonas Kulla 9c3d40de5e Merge pull request #55 from mathewv/master
NFD filename translation on OS X
2014-08-19 19:44:34 +02:00
Mathew f89216368d NFD filename translation on OS X 2014-08-19 10:57:03 -04:00
Jonas Kulla 7452331e04 Bitmap: Normalize rect passed to glState.scissorBox
glScissorBox doesn't like negative values.
2014-08-17 15:43:03 +02:00
Jonas Kulla b0eeb6d1bd README: Add some info on experimental RGSS2/RGSS3 support 2014-08-17 04:07:23 +02:00
Jonas Kulla 724d52f61e Tilemap: Finally get rid of that terrible name 'ScanRow'
Replacement: ZLayer
I'd really have loved to have used something alluding to physical
roof tiles (as that's the closest image I have to them), but without
reusing the word "tiles".. yeah, impossible.
2014-08-17 03:58:01 +02:00
Jonas Kulla 9311aff017 Bitmap: Draw line feed and carriage return as whitespace 2014-08-17 03:07:53 +02:00
Jonas Kulla 858c40591b mkxp.pro: Add proper method to define RGSS version
Eg. `qmake RGSS_VER=3` for VX Ace. Default is 1 (XP).
2014-08-17 00:27:08 +02:00
Jonas Kulla 52e2f2304a Spacing 2014-08-17 00:27:08 +02:00
Jonas Kulla d075bd255c MRI-Binding: WindowVX: Since RGSS2 'contents' has a 1x1 dummy bitmap 2014-08-17 00:27:07 +02:00
Jonas Kulla 169f9e9285 MRI-Binding: Audio: Bind RGSS3 functions 2014-08-17 00:27:07 +02:00
Jonas Kulla f0e045d057 Font: Add RGSS2 default values 2014-08-17 00:27:07 +02:00
Jonas Kulla 4daff93e29 Put bundled font into its own translation unit 2014-08-17 00:26:35 +02:00
Jonas Kulla cbdd19e525 WindowVX: Make more compatible with RGSS2 2014-08-16 22:32:06 +02:00
Jonas Kulla 8042289291 WindowVX: Fix window resizing from big to small 2014-08-16 20:11:46 +02:00
Jonas Kulla e7882c0d3e Plane: Fix screen shaking in wrong direction 2014-08-16 16:14:00 +02:00
Jonas Kulla 9c421aed45 Add minor comments 2014-08-16 16:14:00 +02:00
Jonas Kulla e208bc49e8 Sprite: Implement Y based Z draw ordering (RGSS2)
If two sprites have the same Z, their order is decided based
on their Y coordinate first, and only then (if equal) by creation
time.
2014-08-16 16:12:51 +02:00
Jonas Kulla 3887342439 Disposable: Emit 'wasDisposed' on destruction, not dispose()
Fixes segfaults when objects that were not explicitly disposed
were collected by the GC.
2014-08-16 11:47:07 +02:00
Jonas Kulla b32d6c69cb SharedState: Add RGSS2 default encrypted archive filename 2014-08-16 11:47:07 +02:00
Jonas Kulla 840ecee084 Fix 'uninitialized value used' warnings 2014-08-16 11:47:07 +02:00
Jonas Kulla f58e4ab00d WindowVX: Don't use uninitialized index value 2014-08-16 11:47:07 +02:00
Jonas Kulla 1195dc15bd WindowVX: Add small hack to visually improve background
Make the stretched background source rect smaller by one pixel.
Greatly improves look of Windows in Majo no Ie.
2014-08-16 11:47:07 +02:00
Jonas Kulla 7f69786c47 MRI-Binding: TilemapVX: 'flags' is called 'passages' in RGSS2 2014-08-16 11:47:06 +02:00
Jonas Kulla ded18f9a02 TileAtlasVX: RGSS2 knows no shadow layer 2014-08-16 11:47:06 +02:00
Jonas Kulla d439b1d833 MRI-Binding: Add RGSS2 RPG module 2014-08-16 11:47:06 +02:00
Jonas Kulla f036e83a2d WindowVX: Remove faulty cursor rect positioning logic 2014-08-16 11:47:06 +02:00
Jonas Kulla 3277663944 WindowVX: Fix padding rect not updating on size change 2014-08-16 11:47:06 +02:00
Jonas Kulla bce4eb2bee WindowVX: Fix cursor rectangle geometry not updating 2014-08-16 11:47:06 +02:00
Jonas Kulla 062c7267d7 TilemapVX: Fix map viewport not updating on scene geometry change 2014-08-16 11:47:06 +02:00
Jonas Kulla 9003f9a435 Font: Add missing RGSS2+ props basic plumbing (and bind most in MRI)
No core implementations yet for shadow and outline color.
2014-08-16 11:46:25 +02:00
Jonas Kulla 36eea09c7e SharedState: Add RGSS3 default encrypted archive filename 2014-08-16 06:04:02 +02:00
Jonas Kulla de8773fb5c MRI-Binding: WindowVX: Fix method name typo 2014-08-16 06:04:02 +02:00
Jonas Kulla 931755cb64 MRI-Binding: Add RGSS3 RPG module 2014-08-16 06:04:02 +02:00
Jonas Kulla bdd60291a7 Bitmap: Fix vertical gradient direction 2014-08-16 06:04:02 +02:00
Jonas Kulla 8d375b5cac Graphics: Execute one frame reset at construction
Fixes RGSS3 title screen transition looking skipped
2014-08-16 06:04:02 +02:00
Jonas Kulla 150c280c1e Graphics: Default framerate in RGSS2 is 60 2014-08-16 06:04:02 +02:00
Jonas Kulla deb5696ddb MRI-Binding: Graphics: Bind 'brightness' prop (RGSS2) 2014-08-16 06:04:02 +02:00
Jonas Kulla 7a655528e4 Viewport: Add zero arg constructor (RGSS3) and bind in MRI 2014-08-16 06:03:48 +02:00
Jonas Kulla 5bc6f6f32c Etc: Implement missing RGSS3 functionality (and bind in MRI) 2014-08-15 22:58:08 +02:00
Jonas Kulla 0c5e84eb4b MRI-Binding: Bitmap: Bind missing RGSS2 methods 2014-08-15 22:51:32 +02:00
Jonas Kulla 5b319020ea MRI-Binding: Bitmap: 'draw_text' and 'text_size' should call #to_s (RGSS2) 2014-08-15 22:49:22 +02:00
Jonas Kulla 3224950a1c MRI-Binding: Add crude 'rgss_main' implementation (RGSS3)
No F12 reset yet.
2014-08-15 22:35:57 +02:00
Jonas Kulla 29995bee7f mkxp.pro: sharedmidistate.h is a header 2014-08-15 22:33:22 +02:00
Jonas Kulla 7790bd6c2c Implement RGSS2 Tilemap class (TilemapVX) 2014-08-15 15:20:32 +02:00
Jonas Kulla 3717609142 Tilemap: Make Autotiles con/destructor private 2014-08-15 15:20:32 +02:00
Jonas Kulla 4742226e7c Tilemap: Fix typo 2014-08-15 15:20:32 +02:00
Jonas Kulla 91d19d0a73 Implement RGSS2 Window class (WindowVX) 2014-08-15 15:20:15 +02:00
Jonas Kulla d654fb7dd6 Add internal 'KeepDestAlpha' BlendType (for use in WindowVX) 2014-08-12 22:26:54 +02:00
Jonas Kulla d95e90db34 Tone: Add 'valueChanged' signal 2014-08-12 22:26:54 +02:00
Jonas Kulla 3550cc0ff5 Use correct default resolution for RGSS2/3 (544x416) 2014-08-12 22:21:57 +02:00
Jonas Kulla d128375d62 DisposeWatch: Make private and constify members 2014-08-12 21:41:59 +02:00
Jonas Kulla 194f70c48c SharedState: Constify most getter methods 2014-08-12 21:41:59 +02:00
Jonas Kulla 18022bf809 quadarray.h: Use size_t for everything (quad) count related 2014-08-12 21:41:59 +02:00
Jonas Kulla 7d30ce1a00 quad.h: Cleanup static functions to use templated Vertex parameter
Collapses all the different Vertex/SVertex/CVertex variants
into one generic one per function.
2014-08-12 21:41:59 +02:00
Jonas Kulla 0af5e9d66c gl-util.h: Add GL ID != operator and TEXFBO::clear
TEXFBO::clear resets the struct into its state right
after creation, nulling all IDs inside so they're invaid.
2014-08-12 21:41:59 +02:00
Jonas Kulla 1767b200c7 etc.h: Constify methods 2014-08-12 21:41:28 +02:00
Jonas Kulla 9967ae022d window.cpp: small cleanups
Constify static numbers
'unsigned char' -> 'uint8_t'
2014-08-12 19:38:31 +02:00
Jonas Kulla 3b35fb219c MRuby-Binding: Bind #initialize_copy for clonable classes
Port of b7a2ba830c.
2014-08-09 21:24:50 +02:00
Jonas Kulla 1cc1541377 MRuby-Binding: Input constants are symbols in RGSS3
Port of 88bb92aadc.
2014-08-09 21:23:26 +02:00
Jonas Kulla e858bbdcf5 Lift 'Disposable' concept from core into bindings
Instead of replicating the RGSS Disposable interface in C++
and merely binding it, redefine the 'disposed' state as the
entire core object being deleted (and the binding object's
private pointer being null).

This makes the behavior more accurate in regard to RMXP.
It is now for example possible to subclass disposable classes
and access their 'dispose'/'disposed?' methods without
initializing the base class first (because the internal pointer
is simply null before initialization). Accessing any other
base methods will still raise an exception.

There are some quirks and irregular behavior in RMXP; eg.
most nullable bitmap attributes of disposable classes
(Sprite, Plane etc.) can still be queried afterwards, but
some cannot (Tilemap#tileset), and disposing certain
attributes crashes RMXP entirely (Tilemap#autotiles[n]).
mkxp tries to behave as close possible, but will be more
lenient some circumstances.

To the core, disposed bitmap attributes will look
identically to null, which slightly diverges from RMXP
(where they're treated as still existing, but aren't drawn).
The Disposable interface has been retained containing a
single signal, for the binding to inform core when
objects are disposed (so active attributes can be set to null).
2014-08-09 21:21:38 +02:00
Jonas Kulla b7af8cc92f MRI-Binding: Typo in Flashable binding 2014-08-09 21:21:38 +02:00
Jonas Kulla cc0ab35f10 Font: 'exist?' allows any object (returns false if not string) 2014-08-09 21:21:38 +02:00
Jonas Kulla 6c9fbc1465 Bitmap: Clip dest rect when blitting from mega surface 2014-08-09 21:21:38 +02:00
Jonas Kulla 0ab543fd75 MRuby-Binding: Reduce number of object allocations
This is the same change as f067e0eff8,
applied to the mruby backend.
2014-08-09 21:21:38 +02:00
Jonas Kulla bdcf1503bd Bitmap: Normalize rectangle passed to pixman 2014-08-09 21:21:38 +02:00
Jonas Kulla 88bb92aadc MRI-Binding: Input constants are symbols in RGSS3 2014-08-09 21:21:15 +02:00
Jonas Kulla 656c5099ea autotiles.cpp: Fix subrect pattern for indices 23 and 46
Fixes #51.
2014-08-07 10:46:58 +02:00
Jonas Kulla 24759fb97b EventThread: Simplify user event handling 2014-08-06 15:54:44 +02:00
Jonas Kulla 151a1f0d1b Table: Add clone constructor (and bind in MRI)
Fixes #50.
2014-08-05 05:24:13 +02:00
Jonas Kulla 59aed37d3e MidiSource: Improve pitch shifting accuracy
Also drop note events whose keys are shifted out of range
instead of clamping them.
2014-08-02 16:15:11 +02:00
Jonas Kulla 5eb5b0dc83 MidiSource: Fix memory leak and simplify code 2014-08-02 16:14:22 +02:00
Jonas Kulla dc43af3b6a README: Document command line option usage 2014-08-02 10:30:52 +02:00
Jonas Kulla 3bcf995832 Add option to turn off switching into executable dir on startup 2014-08-02 09:30:17 +02:00
Jonas Kulla cc7218c19d Spacing 2014-08-02 06:50:14 +02:00
Jonas Kulla 751fdc599e Audio: Add MIDI format playback support
This adds a new dependency with libfuildsynth. MIDI support
is built by default, but can be disabled if not desired.

All RTP songs should work well, but there are known problems
with other files (see README). Also, the pitch shift implementation
is somewhat poor and doesn't match RMXP (at least subjectively).

A soundfont is not included and must be provided by
the user themself.
2014-08-02 06:42:55 +02:00
Jonas Kulla 818ca18ebb ALStream: Actually fix issue referenced in prev commit
This bug occured when starting playback of a stream, then immediately
stopping it, loading a different source, and starting playback again.

The real issue was that in stopStream(),  the streaming thread had
not even queued anything yet, so it first decoded some data, then
started playing the source (which had already been stopped in the main
thread), and then finally saw the term request and stopped.

Instead stopping the source after the thread has definitely
terminated fixed the problem.
2014-07-31 05:12:35 +02:00
Jonas Kulla 80937d0d06 ALStream: Fix sometimes not unqueuing all buffers before play
Very rarely rogue buffers would remain and play on loop on song
switch because we only ever cleared processed, not queued, buffers
from the source.

The correct way to completely clear a source's queue is to
simply attach a null buffer to it.
2014-07-31 03:39:36 +02:00
Jonas Kulla d7e0429ea6 CMakeLists.txt: Add 'vorbisfile' to dependencies if RGSS2=ON
Also add missing define.
2014-07-25 15:19:10 +02:00
Jonas Kulla 0a94b518dc Add missing header 2014-07-25 14:58:11 +02:00
Jonas Kulla 0d96207b39 CMakeLists.txt: Don't turn on "RGSS2" by default 2014-07-25 14:47:08 +02:00
Jonas Kulla e38ec7be98 Simplify earlier patch 2014-07-25 07:57:01 +02:00
Jonas Kulla 262023b088 MRI-Binding: Fix typo and don't set $LOAD_PATH (thanks @cremno)
'$:' and '$LOAD_PATH' point to the same array.
2014-07-25 00:40:36 +02:00
Jonas Kulla ec16210f8a MRI-Binding: Allow manually specifying load paths in config 2014-07-24 23:11:12 +02:00
Jonas Kulla 393a283d99 Minor cleanups 2014-07-24 23:02:38 +02:00
Jonas Kulla 2f831aea60 RGSSAD: Add RGSS3 archive reader
Everything except the entry table parsing is the same as RGSS1.
2014-07-24 02:45:20 +02:00
Jonas Kulla 6726493ee7 RGSSAD: Add RGSS2 archive reader
Exactly the same as RGSS1 but different file extension.
Also remove some redundant strings.
2014-07-23 23:05:24 +02:00
Jonas Kulla 1ecdd9f980 filesystem.cpp: Split out RGSSAD parts 2014-07-23 22:57:39 +02:00
Jonas Kulla 7b947a50c9 Use macro from util.h for static array size 2014-07-23 21:26:44 +02:00
Jonas Kulla f73b0ba4b5 audio.cpp: Split up into smaller parts 2014-07-23 17:28:20 +02:00
Jonas Kulla e341dca579 Squash more "may be uninitialized" warnings 2014-07-23 17:28:03 +02:00
Jonas Kulla 492be508da gl-fun.h: Allow to alternatively be compiled with GLES2 headers
Requires your typical "GLES2/{gl2,gl2ext,gl2platform}.h bundle.
Define "GLES2_HEADER" to use.
2014-07-21 01:49:06 +00:00
Jonas Kulla ca9f83c6de Bitmap: Always upload data in GL_RGBA format 2014-07-21 01:38:22 +00:00
Jonas Kulla c1d627e0ae GLMeta: Disable blending when blitting via quad draw 2014-07-20 13:20:43 +02:00
Jonas Kulla 27b7815f52 GLState: Remove 'BlendNone' mode in favor of disabling blending alltogether 2014-07-20 13:17:12 +02:00
Jonas Kulla 7ce747d34d GLProperty: Assert proper stack usage 2014-07-20 13:15:03 +02:00
Jonas Kulla c44f4d7d28 gl-util.h: GL_RGBA8 is not a legal internalformat under GLES2
GL_RGBA ought to be synonymous.
2014-07-19 15:40:40 +00:00
Jonas Kulla 6f17b6ff46 Hookup mkxp to run under a OpenGL ES 2.0 context 2014-07-19 14:26:42 +00:00
Jonas Kulla a310318c65 MRuby-Binding: Account for 'char' not being signed everywhere 2014-07-19 11:13:11 +00:00
Jonas Kulla 83ceed5592 'fgetc()' returns int 2014-07-19 11:11:27 +00:00
Jonas Kulla a56d446664 More size_t fixes 2014-07-19 09:57:41 +02:00
Jonas Kulla 86b207e389 Actually switch to 16 bit index buffers 2014-07-19 09:31:39 +02:00
Jonas Kulla 5640c3d04b Print RGSS thread error message to console 2014-07-19 02:59:05 +02:00
Jonas Kulla 813130fbf6 More size_t fixes 2014-07-19 02:58:57 +02:00
Jonas Kulla 48db6fbeda Binding-MRuby: Make stuff work with latest mruby git 2014-07-19 02:22:22 +02:00
Jonas Kulla ccba946973 util.h: Use size_t for static array sizes 2014-07-19 00:52:00 +02:00
Jonas Kulla 20e46a98dd Plane: Add fallback without GL_REPEAT texture wrapping
This isn't supported under GLES 2.0 for npot textures.
2014-07-17 10:09:58 +02:00
Jonas Kulla a17043f785 MRI-Binding: Bitmap#get_pixel always returns a Color object 2014-07-16 17:39:39 +02:00
Jonas Kulla 3a3ccf590e Plane: Don't set dirty flags when settings props to existing value 2014-07-16 13:43:13 +02:00
Jonas Kulla b878149f5c MRI-Binding: Properly init Bitmap in Graphics#snap_to_bitmap 2014-07-16 05:27:16 +02:00
Jonas Kulla b8d861b4cd gl-util.h: Remove wrappers for things abstracted via GLMeta 2014-07-16 05:22:43 +02:00
Jonas Kulla bae977d4ab GLMeta: "Finish" -> "End" 2014-07-16 04:53:08 +02:00
Jonas Kulla a26c73930d GLMeta: Add framebuffer blitting support 2014-07-16 04:48:40 +02:00
Jonas Kulla 7ad6b7b5df MRI-Binding: Add some RGSS2 Graphics bindings 2014-07-15 12:34:58 +02:00
Jonas Kulla 4a3a769b15 Graphics: Properly initialize uniform before drawing 2014-07-15 11:54:31 +02:00
Jonas Kulla 97f18beb91 Graphics: Remove dubious optimization 2014-07-15 11:53:34 +02:00
Jonas Kulla c5f18ee535 Print SDL error message if window creation fails 2014-07-14 06:22:49 +02:00
Jonas Kulla 35dbaab0c3 Shader: Use GetShader/Programiv instead of GetObjectParameterivARB
The former are core 2.0 while the latter is part of GL_ARB_shader_objects.
2014-07-14 04:13:15 +02:00
Jonas Kulla f7d63bafd0 Merge pull request #46 from BlackLotus/master
Added new source files to CMakeLists.txt
2014-07-13 23:54:10 +02:00
Thomas Schneider 20db1a7b39 Added some cmake deps 2014-07-13 22:18:27 +02:00
Jonas Kulla 97708d25b6 Tilemap: Reduce a few unnecessary blits
No need to replicate static autotiles if we're not animating
at all.
2014-07-13 14:05:56 +02:00
Jonas Kulla efb2fd2695 GLMeta: Add vertex array object support 2014-07-13 14:05:12 +02:00
Jonas Kulla dac1407120 Add some comments 2014-07-13 13:38:50 +02:00
Jonas Kulla b73461721c Add meta path with fallback for EXT_unpack_subimage parameters 2014-07-13 05:51:04 +02:00
Jonas Kulla a541cb1205 Some RGSS2/RGSS3 compile fixes 2014-07-13 05:34:18 +02:00
Jonas Kulla 91aefdc17a Tilemap: Fix map wrap around 2014-07-11 08:43:39 +02:00
Jonas Kulla d1bad9b45f Bitmap#get_pixel: Use cached client side copy of pixels
A very simplistic optimization for games that create a
Bitmap and then only ever query pixels from it.
2014-07-11 03:25:28 +02:00
Jonas Kulla caae9c5689 Wrap IBO index type into one definition
Makes it easier to switch between types (eg. 32 -> 16 bit).
2014-07-11 02:09:53 +02:00
Jonas Kulla 295e0e5b15 Tilemap: Rewrite to only process and render visible region
Previously, on creation, we would parse the entire map data,
translating it into and uploading vertices once, then rendering
the entire map on every draw (to keep the draw calls minimal).
This worked great for smaller and medium sized maps, but starting
with larger maps (200x200+) it doesn't scale as the GPUs vertex
processing/culling is overwhelmed by the amount of data each frame.

This rewrite instead changes the strategy to only processing and
uploading a small subregion of the map (the currently visible part)
and regenerating all buffers if this subregion changes. The amount
of data transferred is small enough that it can be done every frame
without causing lag.

The changes also have the convenient side effect that we no longer
require 32 bit indices in mkxp, easing the road to possible GLES2
support in the future.
2014-07-11 02:00:30 +02:00
Jonas Kulla 300e61c64b TileAtlas: Fix broken atlas generation
The stuff committed in 56226c40c6
was actually completely broken.. oops.
2014-07-10 21:48:33 +02:00
Jonas Kulla c0f25548bd CMakeLists.txt: Add new file "tilemap.vert" 2014-07-09 17:11:05 +02:00
Jonas Kulla 6bbdf7e183 Bitmap#blt: Clamp source rect to source bitmap bounds
RGSS allows the source rectangle in both `blt` and
`stretch_blt` to lie outside the source bitmap bounds
(treating the missing data as (0, 0, 0, 0)) and to be
inverted (in which case the blitted image is also inverted).

This commit only hanldes a corner case that
arises in the game "Last Scenario"; emulating the full
RGSS behavior is however desirable.
2014-07-09 03:06:43 +02:00
Jonas Kulla 527a372bd3 Window: Fix contents not being drawn if no windowskin is set 2014-07-09 02:47:32 +02:00
Jonas Kulla 56226c40c6 Tilemap: Use vertex shader based autotile animation strategy
Previously, we would just stuff the entire tilemap vertex data
four times into the buffers, with only the autotile vertices
offset according to the animation frame. This meant we could
prepare the buffers once, and then just bind a different offset
for each animation frame without any shader changes, but it also
lead to a huge amount of data being duplicated (and blowing up
the buffer sizes).

The new method only requires one buffer, and instead animates by
recognizing vertices belonging to autotiles in a custom vertex
shader, which offsets them on the fly according to the animation
index.

With giant tilemaps, this method would turn out to be a little
less efficient, but considering the Tilemap is planned to be
rewritten to only hold the range of tiles visible on the screen
in its buffers, the on the fly offsetting will become neglient,
while at the same time the amount of data we have to send to the
GPU everytime the tilemap is updated is greatly reduced; so a
net win in the end.
2014-07-06 19:44:19 +02:00
Jonas Kulla 033d46a293 Window: Use bilinear filtering for drawing controls
See #44
2014-07-03 14:32:03 +02:00
Jonas Kulla 4a0084801e Graphics: Respect non-default initial window size 2014-07-03 02:48:28 +02:00
Jonas Kulla 843a7bf571 gl-fun.h: Fix KHR_debug function signatures 2014-06-24 23:56:13 +02:00
Jonas Kulla 902a5e8c76 README: Clarify SDL_sound version 2014-06-21 17:01:05 +02:00
Jonas Kulla a4615fb8cc Add copyright notice to gl-fun.{cpp,h} 2014-06-15 07:52:26 +02:00
Jonas Kulla 6808b9a6dd SoundEmitter: Optimize source allocation strategy
Before, we would blindly rotate through the sources (like a
revolver through its chambers), which worked great if one
assumed all sounds to be relatively short and therefore oldest
use == most likely to be free, but breaks if there is one long
sound playing, which would be stopped and overtaken if we rotated
back to it even though there might be other free sources available.

Instead, keep an ascending priority list of sources with last
used == highest priorty that is iterated through for the first
free one, and only if none is found overtake the one with lowest
priority. This also ensures we're always able to play 'SE_SOURCES'
sounds at once independently of their length.

Fixes #37.
2014-06-15 06:26:34 +02:00
Jonas Kulla 282d547ad4 Remove Perftimer classes
Performance can still be crudely measured by turning off
the framelimit and observing the FPS count. For everything
else, there's always callgrind / apitrace.
2014-06-13 19:01:15 +02:00
Jonas Kulla 6c481e5eb8 Eliminate GLEW dependency
GL entrypoint resolution is now done manually. This has a couple
immediate benefits, such as not having to retrieve hundreds of
functions pointers that we'll never use. It's also nice to have
an exact overview of all the entrypoints used by mkxp.

This change allows mkxp to run fine with core contexts, not sure
how relevant that is going to be in the future.

What's noteworthy is that  _all_ entrypoints, even the ones core
in 1.1 and guaranteed to be in every libGL, are resolved
dynamically.
This has the added benefit of not having to link directly against
libGL anymore, which also cleans up the output of `ldd` quite
a bit (SDL2 loads most system deps dynamically at runtime).

GL headers are still required at build time.
2014-06-13 18:46:45 +02:00
Jonas Kulla 640b01e518 Graphics: Fix double calculation being a fixed point division 2014-06-12 14:31:29 +02:00
Jonas Kulla 3ac8f1e8aa Actually, don't disable that on Windows 2014-06-12 12:54:10 +02:00
Jonas Kulla aed7ba6672 Graphics: Check for nanosleep errors, disable on Windows (for now) 2014-06-12 10:40:17 +02:00
Jonas Kulla 06b218d5d7 Don't rely on non-standard typedef (thanks @ntzrmtthihu777) 2014-06-08 06:59:35 +02:00
Jonas Kulla 013437074b gitignore: Add codeblocks files 2014-06-08 06:55:37 +02:00
Jonas Kulla 2cc2ebca31 GLState: Get rid of GL_TEXTURE_2D enable/disable
This bit was deprecated/removed in core GL.

There was only one place where this was used (flash tiles
in Tilemap), and since the full shader rewrite, it was
effectively a no-op anyway (flash shader doesn't sample texture).
2014-05-30 23:13:58 +02:00
Jonas Kulla 7b1f599dd6 mkxp.pro: Add 'BOOST_LIB_SUFFIX'
Boost being boost.
2014-05-30 23:13:58 +02:00
Jonas Kulla 5ba40369cc Don't unnecessarily expose internal constant 2014-05-30 23:13:58 +02:00
Jonas Kulla ad63c962c6 Merge pull request #32 from cremno/use-rb_funcall2-instead-of-rb_funcallv
use `rb_funcall2` instead of `rb_funcallv`
2014-05-25 13:28:31 +02:00
cremno e6a116f43f use `rb_funcall2` instead of `rb_funcallv`
In 2.1 `rb_funcall2`  was renamed to `rb_funcallv` and
a macro for backward compatibility was added.
2014-05-25 12:57:04 +02:00
Jonas Kulla 0ef68a2eb7 Audio: Remove unused float helper code
Let's us get rid of 'alext.h' include,
which doesn't exist on OSX.
2014-05-24 18:26:04 +02:00
Jonas Kulla ce0fee0641 Spacing 2014-05-24 18:24:51 +02:00
Jonas Kulla 70279f0fdc mkxp.pro: Remove stray linker parameter 2014-05-24 18:24:10 +02:00
Jonas Kulla ea20154978 Spacing 2014-05-22 05:49:06 +02:00
Jonas Kulla 66fe932a8e Remove useless code 2014-05-21 18:11:31 +02:00
Jonas Kulla 2d30301aef DebugWriter: Add std::vector print handler 2014-05-21 18:10:46 +02:00
Jonas Kulla 32bb18d93f Spacing 2014-05-21 18:10:14 +02:00
Jonas Kulla d09f4a1bae Typo 2014-05-21 18:08:31 +02:00
Jonas Kulla e74f889bc5 Quad: Don't discard VBO on each update
This never yielded any traceable performance gains.
I also apparently forgot to unbind the buffer after
updating.
2014-05-16 21:39:26 +02:00
Jonas Kulla 8dd7c1b48c Spacing/spelling 2014-05-07 17:52:11 +02:00
Jonas Kulla 72fc659a4c MRI-Binding: Don't refine Kernel#caller in RGSS3 2014-05-07 03:19:06 +02:00
Jonas Kulla 1bdcfa7b04 MRI-Binding: Adjust 'Kernel#caller' output to match RMXP 2014-05-06 12:13:12 +02:00
Jonas Kulla c6a3c5aa59 Graphics: Setting 'fixedFramerate' to -1 disables frame limit
Can be useful for benchmarking
2014-05-05 09:21:20 +02:00
Jonas Kulla 627ff66e7a mkxp.pro: Add 'EMBED' files to 'OTHER_FILES'
So they show up in the project tree in QtCreator.
2014-05-03 04:07:07 +02:00
Jonas Kulla 80b2768e73 Fix "unused variable" warning 2014-05-03 04:05:11 +02:00
Jonas Kulla 58d86039d5 Merge branch 'dev' 2014-04-17 08:19:24 +02:00
Jonas Kulla 4cb1c10c3a Minor declaration fix 2014-04-16 20:54:29 +02:00
Jonas Kulla 4e346cac27 Merge pull request #25 from cremno/mri-improve-error-printing
MRI: improve error printing
2014-04-16 20:22:58 +02:00
cremno bd6764450f fix comment style 2014-04-16 20:05:15 +02:00
Jonas Kulla f11cc182df Remove screenshot functionality
It was only meant for debugging and brought with it
unneeded platform dependant issues.
2014-04-16 13:48:45 +02:00
Jonas Kulla 1ef6e04520 Font: Overhaul font asset discovery
Previously, any font names requested by RGSS would be translated
directly to filenames by lowercasing and replacing spaces with
underscores (and finally doing some extension substitution).
To make this whole thing work smoother as well as get closer to
how font discovery is done in VX, we now scan the "Fonts/" folder
at startup and index all present font assets by their family name;
now, if an "Open Sans" font is present in "Fonts/", it will be
used regardless of filename.

Font assets with "Regular" style are preferred, but in their
absence, mkxp will make use of any other style it can find for
the respective family. This is not the exact same behavior as
VX, but it should cover 95% of use cases.

Previously, one could substitute fonts via filenames, ie. to
substitute "Arial" with "Open Sans", one would just rename
"OpenSans.ttf" to "arial.ttf" and put it in "Fonts/". With the
above change, this is no longer possible. As an alternative, one
can now explicitly specify font family substitutions via mkxp.conf;
eg. for the above case, one would add

fontSub=Arial>Open Sans

to the configuration file. Multiple such rules can be specified.

In the process, I also added the ability to provide
'Font.(default_)name' with an array of font families to search
for the first existing one instead of a plain string.
This makes the behavior closer to RMXP; however, it doesn't
work 100% the same: when a reference to the 'Font.name' array is
held and additional strings are added to it without re-assignig
the array to 'Font.name', those will be ignored.
2014-04-16 13:37:22 +02:00
Jonas Kulla 31626c9acc Spacing 2014-04-16 13:06:16 +02:00
Jonas Kulla 51c5ca1410 Graphics: Taint entire Bitmap in #snap_to_bitmap 2014-04-15 19:05:36 +02:00
Jonas Kulla f25d2db63c MRI-Binding: Add RGSS3 '__FILE__' variant 2014-04-15 11:54:22 +02:00
Jonas Kulla 711060db8f Spacing / minor fixes 2014-04-14 09:39:23 +02:00
cremno 4ca9e82a14 MRI: improve error printing
`Debug()` is CRuby-style and `showMsg` is RGSS-style.
The `Debug()` output is safe, `showMsg` might be fragile.
2014-04-14 00:07:51 +02:00
Jonas Kulla ab9464006b Merge pull request #24 from cremno/mri-rewrite-script-eval
MRI: rewrite script eval
2014-04-12 11:54:13 +02:00
cremno 95c112bbe4 MRI: add option to use a script's name as filename 2014-04-11 18:11:32 +02:00
cremno 8bc17a9a98 MRI: less `strlen` calls, use custom script's filename 2014-04-11 17:13:25 +02:00
Jonas Kulla 6dfa4f6b7d MRI-Binding: Add 'Graphics.width/height' bindings (RGSS2) 2014-04-11 13:34:19 +02:00
Jonas Kulla 8203e32900 MRI-Binding: Define 'msgbox' p/print aliases (RGSS3) 2014-04-11 13:31:09 +02:00
cremno f6ec364632 MRI: rewrite script eval
- set __FILE__ (RGSS 1 and 2)
 - set Ruby string encoding to UTF-8
   instead of using a magic comment
2014-04-10 14:00:05 +02:00
cremno 06b877a78c MRI: don't set $0 (see #24) 2014-04-10 02:14:25 +02:00
cremno 4e0262d2a7 MRI: fix $RGSS_SCRIPTS 2014-04-10 01:16:31 +02:00
cremno f8b87eb188 MRI: don't manually peform GC 2014-04-09 23:45:24 +02:00
cremno 804a697c03 MRI: add $RGSS_SCRIPTS 2014-04-09 22:36:56 +02:00
Jonas Kulla 4219b91bbb al-util.h: Add include fix for older OpenAL releases
Apparently older versions of 'alext.h' didn't include
'alc.h' despite dependencies on ALC types.
2014-02-06 04:27:17 +01:00
Jonas Kulla af9039f58d Sprite: Implement wave effect (RGSS2)
This initial implementation emulates the way RMVX splits
the sprite into "chunks" of about 8 pixels, which it then
scrolls left/right on a vertical sine wave. It even
replicates the weird behavior when wave_amp < 0, namely
"shrinking" the src_rect horizontally.

As with bush_opacity, this effect in combination with
rotation will render differently from RMVX.
2014-02-03 15:32:50 +01:00
Jonas Kulla 42b10fd2ee mkxp.pro: Add RGSS3 config define 2014-02-03 15:24:10 +01:00
Jonas Kulla 64f1e32fdc Input: Implement RGSS3 functionality in bindings
Ie. using symbols instead of Input:: constants to query
button states.
2014-02-03 15:04:57 +01:00
Jonas Kulla 5a6c0c14ed MRuby-Binding: Fix etc accessors not using getter/setter functions 2014-02-03 14:07:08 +01:00
Jonas Kulla bb8f2351cc Bitmap: Remove leftover 'flush()' calls 2014-02-02 23:36:01 +01:00
Jonas Kulla e0a4dfe372 Bitmap: Make #get_pixel/#set_pixel more accurate
This gets rid of the "batch/flush" semantics for #set_pixel
and instead just directly uploads the pixel color to the
texture, circumventing the float conversion entirely.
Also makes a lot of code simpler in many places as calling
'flush()' is no longer required for bitmaps.
2014-01-31 10:19:16 +01:00
Jonas Kulla 1b0eb2797d BltShader: Correct algorithm as provided my /cremno
The color calculation is now actually 99% correct!
Fixes #14.
2014-01-31 10:08:05 +01:00
Jonas Kulla b6a299541f Bitmap: Fix #get_pixel returning bogus values
We never bound the Bitmap FBO to the READ binding point,
so glReadPixels was blindly reading data off of whatever
was last bound there.
2014-01-28 16:38:10 +01:00
Jonas Kulla 96d2707edb Bitmap: Fix #get_pixel returning bogus values
We never bound the Bitmap FBO to the READ binding point,
so glReadPixels was blindly reading data off of whatever
was last bound there.
2014-01-28 16:34:28 +01:00
Jonas Kulla f956f21ce1 Revert "Font: Adhere to spec and set Font.default_name to "MS PGothic""
This reverts commit c9423164d4.

Turns out the spec was not adjusted correctly for the
English RGSS version; the de facto default is "Arial"
after all.
2014-01-26 08:06:54 +01:00
Jonas Kulla b28863d8eb Add comment 2014-01-25 09:30:48 +01:00
Jonas Kulla 53718d0428 README: Mention cmake and fix some wording 2014-01-25 09:30:05 +01:00
Jonas Kulla 643000d4a0 Merge pull request #16 from cremno/mri-minor-optimizations
MRI-Binding: some minor optimizations
2014-01-25 00:23:26 -08:00
cremno f06769b434 MRI: some minor optimizations 2014-01-24 22:30:19 +01:00
Jonas Kulla 87c1e376b9 GLState: Add bound shader program to managed state
Squishes a handful of redundant binds per frame.
2014-01-20 00:58:39 +01:00
Jonas Kulla b729da249b Graphics: Don't unbind shader 2014-01-20 00:56:00 +01:00
Jonas Kulla e93e1fd292 debugwriter.h: Use std::newl instead of '\n' 2014-01-20 00:54:42 +01:00
Jonas Kulla f3572f5ba4 Bitmap: Don't unbind shader after render op
Since all rendering is now shader based, there's normally
no reason to ever unbind a shader program.
2014-01-20 00:53:58 +01:00
Jonas Kulla f39d1239bb TileAtlas: Slightly optimize out some allocation
User vector instead of list for colums.s
2014-01-16 19:17:46 +01:00
Jonas Kulla b0a41a23e0 Rename typedef and fix wrong documenting comment 2014-01-16 19:16:09 +01:00
Jonas Kulla 316457b988 Refactoring 2014-01-16 04:19:22 +01:00
Jonas Kulla 91efcfa06d FileSystem: More stringent RGSSAD header checks 2014-01-16 01:06:59 +01:00
Jonas Kulla cb39c2f345 Documentation: Move mkxp.conf description into sample conf 2014-01-15 03:23:25 +01:00
Jonas Kulla 9b92a7bc14 Documentation: Move mkxp.conf description into sample conf 2014-01-15 03:20:05 +01:00
Jonas Kulla 81ec731e5a Merge branch 'dev' 2014-01-15 01:56:58 +01:00
Jonas Kulla bbb9bff239 FileSystem: Fix path cache for mounted zip archives 2014-01-15 01:51:56 +01:00
Jonas Kulla f14a379ee9 FileSystem: Trim redundant error message on ENOENT
MRI adds the "No such file or directory - " itself;
I guess we can just emulate this behavior everywhere else.
2014-01-15 01:47:16 +01:00
Jonas Kulla 64cb4ee4f1 Use stdint types 2014-01-15 01:43:46 +01:00
Jonas Kulla 0f004b8601 Spacing 2014-01-15 00:48:34 +01:00
Jonas Kulla 20e323c699 Config: Parse from command line options on top of config file
Any options that are not arrays (ie. RTP paths) specified
as command line options will override entries in mkxp.conf.

The syntax is: --<option>=<value>
2014-01-13 00:06:34 +01:00
Jonas Kulla c33144552a Config: Parse from command line options on top of config file
Any options that are not arrays (ie. RTP paths) specified
as command line options will override entries in mkxp.conf.

The syntax is: --<option>=<value>
2014-01-10 20:16:34 +01:00
Jonas Kulla b8fc5e25b9 Audio: Make thread names more descriptive 2014-01-07 16:06:50 +01:00
Jonas Kulla 0a53a894dc Merge branch 'master' of github.com:Ancurio/mkxp 2014-01-07 05:26:05 +01:00
Jonas Kulla 063793c4d9 Turn screenshots (F3) off by default 2014-01-07 05:25:00 +01:00
Jonas Kulla 4c5b21496a Merge pull request #13 from humble/baseNameFix
Fix npos comparison check in baseName
2014-01-06 16:33:46 -08:00
Edward Rudd c60ffa6384 fix npos comparison check in baseName method 2014-01-06 12:45:01 -05:00
Jonas Kulla 953f903149 Spacing 2014-01-05 16:09:00 +01:00
Jonas Kulla e9cf77dbce Config: Fix preceeding '/' in deducted game title
Also factor out the common code path
2014-01-05 10:31:15 +01:00
Jonas Kulla 19dc83a5d5 Bitmap: Supply image filename on loading error 2014-01-05 10:28:35 +01:00
Jonas Kulla 8ed6de22a4 Input: Return const -20 mouse position when outside window 2014-01-05 01:15:33 +01:00
Edward Rudd 318162a229 fix screen grab crash when in fullscreen
- read the FBO size NOT the screen size.
2014-01-04 13:52:11 +01:00
Jonas Kulla 56b49acf39 Spacing 2014-01-04 13:50:07 +01:00
Jonas Kulla 43321b8ed7 Coding style fixes 2014-01-04 13:49:32 +01:00
Jonas Kulla 092e6ad948 Typo 2014-01-04 13:48:23 +01:00
Jonas Kulla d93c1280aa Font: Open TTF font as late as possible
This reduces opened fonts that were never going
to be used anyway.
2014-01-04 13:47:00 +01:00
Jonas Kulla 857693d4a1 Font: Fix 'Font#set_name' not actually changing underlying TTF_Font 2014-01-04 13:00:38 +01:00
Jonas Kulla 78f9272e3d Typo 2014-01-04 13:00:04 +01:00
Jonas Kulla c9423164d4 Font: Adhere to spec and set Font.default_name to "MS PGothic" 2014-01-04 12:58:03 +01:00
Jonas Kulla a8bff666eb Audio: Don't try to fill and queue null buffer
Fixes skipping audio after interrupting and resuming
the program via eg. a debugger.
2014-01-04 12:28:16 +01:00
195 changed files with 23883 additions and 8845 deletions

5
.editorconfig Normal file
View File

@ -0,0 +1,5 @@
root=true
[*]
end_of_line = lf
indent_style = tab
indent_size = 4

7
.gitignore vendored
View File

@ -10,4 +10,9 @@ Makefile
mkxp
xxd+
/build
/build
# Codeblocks
mkxp.layout
mkxp.cbp

View File

@ -3,7 +3,8 @@ Project(mkxp)
## Setup options ##
option(RGSS2 "Enable RGSS2" ON)
option(SHARED_FLUID "Dynamically link fluidsynth at build time" OFF)
option(WORKDIR_CURRENT "Keep current directory on startup" OFF)
option(FORCE32 "Force 32bit compile on 64bit OS" OFF)
set(BINDING "MRI" CACHE STRING "The Binding Type (MRI, MRUBY, NULL)")
set(EXTERNAL_LIB_PATH "" CACHE PATH "External precompiled lib prefix")
@ -18,6 +19,12 @@ IF("${CMAKE_SYSTEM}" MATCHES "Linux")
SET(LINUX ON)
ENDIF()
IF(WORKDIR_CURRENT)
list(APPEND DEFINES
WORKDIR_CURRENT
)
ENDIF()
IF(FORCE32)
if(APPLE)
SET(CMAKE_OSX_ARCHITECTURES "i386")
@ -79,15 +86,14 @@ endif()
pkg_check_modules(SIGCXX REQUIRED sigc++-2.0)
pkg_check_modules(PIXMAN REQUIRED pixman-1)
pkg_check_modules(PHYSFS REQUIRED physfs>=2.1)
pkg_check_modules(VORBISFILE REQUIRED vorbisfile)
pkg_check_modules(SDL2 REQUIRED sdl2)
pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf)
pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image)
pkg_check_modules(SDL_SOUND REQUIRED SDL_sound)
find_package(GLEW 1.9.0 REQUIRED)
find_package(Boost 1.49 COMPONENTS program_options REQUIRED)
find_package(OpenAL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(ZLIB REQUIRED)
## Setup main source ##
@ -104,6 +110,7 @@ set(MAIN_HEADERS
src/flashable.h
src/font.h
src/input.h
src/iniconfig.h
src/plane.h
src/scene.h
src/sprite.h
@ -118,8 +125,9 @@ set(MAIN_HEADERS
src/glstate.h
src/quad.h
src/tilemap.h
src/tilemap-common.h
src/graphics.h
src/debuglogger.h
src/gl-debug.h
src/global-ibo.h
src/exception.h
src/filesystem.h
@ -129,12 +137,27 @@ set(MAIN_HEADERS
src/gl-util.h
src/util.h
src/config.h
src/settingsmenu.h
src/keybindings.h
src/tileatlas.h
src/perftimer.h
src/sharedstate.h
src/al-util.h
src/boost-hash.h
src/debugwriter.h
src/gl-fun.h
src/gl-meta.h
src/vertex.h
src/soundemitter.h
src/aldatasource.h
src/alstream.h
src/audiostream.h
src/rgssad.h
src/windowvx.h
src/tilemapvx.h
src/tileatlasvx.h
src/sharedmidistate.h
src/fluid-fun.h
src/sdl-util.h
)
set(MAIN_SOURCE
@ -145,6 +168,7 @@ set(MAIN_SOURCE
src/filesystem.cpp
src/font.cpp
src/input.cpp
src/iniconfig.cpp
src/plane.cpp
src/scene.cpp
src/sprite.cpp
@ -158,41 +182,79 @@ set(MAIN_SOURCE
src/tilemap.cpp
src/autotiles.cpp
src/graphics.cpp
src/debuglogger.cpp
src/gl-debug.cpp
src/etc.cpp
src/config.cpp
src/settingsmenu.cpp
src/keybindings.cpp
src/tileatlas.cpp
src/perftimer.cpp
src/sharedstate.cpp
src/gl-fun.cpp
src/gl-meta.cpp
src/vertex.cpp
src/soundemitter.cpp
src/sdlsoundsource.cpp
src/alstream.cpp
src/audiostream.cpp
src/rgssad.cpp
src/bundledfont.cpp
src/vorbissource.cpp
src/windowvx.cpp
src/tilemapvx.cpp
src/tileatlasvx.cpp
src/autotilesvx.cpp
src/midisource.cpp
src/fluid-fun.cpp
)
if(WIN32)
list(APPEND MAIN_HEADERS windows/resource.h)
list(APPEND MAIN_SOURCE windows/resource.rc)
endif()
source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS})
## Setup embedded source ##
set(EMBEDDED_INPUT
shader/common.h
shader/transSimple.frag
shader/trans.frag
shader/hue.frag
shader/sprite.frag
shader/plane.frag
shader/gray.frag
shader/bitmapBlit.frag
shader/flatColor.frag
shader/simple.frag
shader/simpleColor.frag
shader/simpleAlpha.frag
shader/simpleAlphaUni.frag
shader/flashMap.frag
shader/minimal.vert
shader/simple.vert
shader/simpleColor.vert
shader/sprite.vert
shader/tilemap.vert
shader/tilemapvx.vert
shader/blur.frag
shader/blurH.vert
shader/blurV.vert
shader/simpleMatrix.vert
assets/liberation.ttf
assets/icon.png
)
if (RGSS2)
list(APPEND EMBEDDED_INPUT
shader/blur.frag
shader/blurH.vert
shader/blurV.vert
shader/simpleMatrix.vert
list(APPEND DEFINES
RGSS2
)
endif()
if (SHARED_FLUID)
pkg_check_modules(FLUID REQUIRED fluidsynth)
list(APPEND DEFINES
SHARED_FLUID
)
endif()
@ -232,7 +294,7 @@ source_group("Embedded Source" FILES ${EMBEDDED_INPUT} ${EMBEDDED_SOURCE})
## Setup binding source ##
if (BINDING STREQUAL "MRI")
set(MRIVERSION "2.0" CACHE STRING "Version of MRI to link with")
set(MRIVERSION "2.1" CACHE STRING "Version of MRI to link with")
pkg_check_modules(MRI REQUIRED ruby-${MRIVERSION})
list(APPEND DEFINES
BINDING_MRI
@ -263,6 +325,8 @@ if (BINDING STREQUAL "MRI")
binding-mri/audio-binding.cpp
binding-mri/module_rpg.cpp
binding-mri/filesystem-binding.cpp
binding-mri/windowvx-binding.cpp
binding-mri/tilemapvx-binding.cpp
)
elseif(BINDING STREQUAL "MRUBY")
message(FATAL_ERROR "Mruby support in CMake needs to be finished")
@ -322,6 +386,7 @@ if(APPLE)
list(APPEND PLATFORM_LIBRARIES
${CARBON_LIBRARY}
${IOKIT_LIBRARY}
"-liconv"
)
endif()
@ -347,13 +412,16 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
)
target_include_directories(${PROJECT_NAME} PRIVATE
src
windows
${SIGCXX_INCLUDE_DIRS}
${PIXMAN_INCLUDE_DIRS}
${PHYSFS_INCLUDE_DIRS}
${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory
${SDL_SOUND_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}/GL
${MRI_INCLUDE_DIRS}
${VORBISFILE_INCLUDE_DIRS}
${FLUID_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR}
)
@ -367,9 +435,9 @@ target_link_libraries(${PROJECT_NAME}
${PIXMAN_LIBRARIES}
${Boost_LIBRARIES}
${MRI_LIBRARIES}
${VORBISFILE_LIBRARIES}
${FLUID_LIBRARIES}
${OPENAL_LIBRARY}
${OPENGL_gl_LIBRARY}
${GLEW_LIBRARY}
${ZLIB_LIBRARY}
${PLATFORM_LIBRARIES}

View File

@ -1,9 +1,20 @@
# mkxp
mkxp is a project that seeks to provide a fully open source implementation of the Ruby Game Scripting System (RGSS) interface used in the popular game creation software "RPG Maker XP" (trademark by Enterbrain, Inc.), with focus on Linux. The goal is to be able to run games created with the above software natively without changing a single file.
Discord community: https://discord.gg/A8xHE8P
Matrix space: https://matrix.to/#/#rpgmaker:mapleshrine.eu
Further links: https://mapleshrine.eu
mkxp is a project that seeks to provide a fully open source implementation of the Ruby Game Scripting System (RGSS) interface used in the popular game creation software "RPG Maker XP", "RPG Maker VX" and "RPG Maker VX Ace" (trademark by Enterbrain, Inc.), with focus on Linux. The goal is to be able to run games created with the above software natively without changing a single file.
It is licensed under the GNU General Public License v2+.
## Prebuilt binaries
[**Linux / Windows**](https://www.mapleshrine.eu/releases/)
[**OSX**](https://app.box.com/mkxpmacbuilds) by Ali
## Should I use mkxp
mkxp primarily targets technically versed users that are comfortable with Ruby / RGSS, and ideally know how to compile the project themselves. The reason for this is that for most games, due to Win32-API usage, mkxp is simply not a plug-and-play solution, but a building block with which a fully cross-platform version can be created in time.
## Bindings
Bindings provide the glue code for an interpreted language environment to run game scripts in. Currently there are three bindings:
@ -15,6 +26,8 @@ Matz's Ruby Interpreter, also called CRuby, is the most widely deployed version
For a list of differences, see:
http://stackoverflow.com/questions/21574/what-is-the-difference-between-ruby-1-8-and-ruby-1-9
This binding supports RGSS1, RGSS2 and RGSS3.
### mruby (Lightweight Ruby)
Website: https://github.com/mruby/mruby
@ -24,6 +37,8 @@ Due to heavy differences between mruby and MRI as well as lacking modules, runni
Some extensions to the standard classes/modules are provided, taking the RPG Maker XP helpfile as a quasi "reference". These include Marshal, File, FileTest and Time.
This binding only supports RGSS1.
**Important:** If you decide to use [mattn's oniguruma regexp gem](https://github.com/mattn/mruby-onig-regexp), don't forget to add `-lonig` to the linker flags to avoid ugly symbol overlaps with libc.
### null
@ -35,22 +50,33 @@ This binding only exists for testing purposes and does nothing (the engine quits
* Boost.Program_options
* libsigc++ 2.0
* PhysFS (latest hg)
* GLEW >= 1.7
* OpenAL
* SDL2
* SDL2*
* SDL2_image
* SDL2_ttf
* SDL_sound (apply provided patches!)
* [my SDL_sound fork](https://github.com/Ancurio/SDL_sound)
* vorbisfile
* pixman
* zlib (only ruby bindings)
* OpenGL header (alternatively GLES2 with `DEFINES+=GLES2_HEADER`)
* libiconv (on Windows, optional with INI_ENCODING)
* libguess (optional with INI_ENCODING)
mkxp employs Qt's qmake build system, so you'll need to install that beforehand.
(* For the F1 menu to work correctly under Linux/X11, you need latest hg + [this patch](https://bugzilla.libsdl.org/show_bug.cgi?id=2745))
mkxp employs Qt's qmake build system, so you'll need to install that beforehand. Alternatively, you can build with cmake (FIXME: add cmake instructions).
qmake will use pkg-config to locate the respective include/library paths. If you installed any dependencies into non-standard prefixes, make sure to adjust your `PKG_CONFIG_PATH` variable accordingly.
The exception is boost, which is weird in that it still hasn't managed to pull off pkg-config support (seriously?). *If you installed boost in a non-standard prefix*, you will need to pass its include path via `BOOST_I` and library path via `BOOST_L`, either as direct arguments to qmake (`qmake BOOST_I="/usr/include" ...`) or via environment variables.
The exception is boost, which is weird in that it still hasn't managed to pull off pkg-config support (seriously?). *If you installed boost in a non-standard prefix*, you will need to pass its include path via `BOOST_I` and library path via `BOOST_L`, either as direct arguments to qmake (`qmake BOOST_I="/usr/include" ...`) or via environment variables. You can specify a library suffix (eg. "-mt") via `BOOST_LIB_SUFFIX` if needed.
**MRI-Binding**: pkg-config will look for `ruby-2.1.pc`, but you can modify mkxp.pro to use 2.0 instead. This is the default binding, so no arguments to qmake needed (`BINDING=MRI` to be explicit).
Midi support is enabled by default and requires fluidsynth to be present at runtime (not needed for building); if mkxp can't find it at runtime, midi playback is disabled. It looks for `libfluidsynth.so.1` on Linux, `libfluidsynth.dylib.1` on OSX and `fluidsynth.dll` on Windows, so make sure to have one of these in your link path. If you still need fluidsynth to be hard linked at buildtime, use `CONFIG+=SHARED_FLUID`. When building fluidsynth yourself, you can disable almost all options (audio drivers etc.) as they are not used. Note that upstream fluidsynth has support for sharing soundfont data between synthesizers (mkxp uses multiple synths), so if your memory usage is very high, you might want to try compiling fluidsynth from git master.
By default, mkxp switches into the directory where its binary is contained and then starts reading the configuration and resolving relative paths. In case this is undesired (eg. when the binary is to be installed to a system global, read-only location), it can be turned off by adding `DEFINES+=WORKDIR_CURRENT` to qmake's arguments.
To auto detect the encoding of the game title in `Game.ini` and auto convert it to UTF-8, build with `CONFIG+=INI_ENCODING`. Requires iconv implementation and libguess. If the encoding is wrongly detected, you can set the "titleLanguage" hint in mkxp.conf.
**MRI-Binding**: pkg-config will look for `ruby-2.1.pc`, but you can override the version with `MRIVERSION=2.2` ('2.2' being an example). This is the default binding, so no arguments to qmake needed (`BINDING=MRI` to be explicit).
**MRuby-Binding**: place the "mruby" folder into the project folder and build it first. Add `BINDING=MRUBY` to qmake's arguments.
@ -59,34 +85,27 @@ The exception is boost, which is weird in that it still hasn't managed to pull o
### Supported image/audio formats
These depend on the SDL auxiliary libraries. For maximum RGSS compliance, build SDL2_image with png/jpg support, and SDL_sound with oggvorbis/wav/mp3 support.
To run mkxp, you should have a graphics card capable of at least **OpenGL 2.0** with an up-to-date driver installed.
To run mkxp, you should have a graphics card capable of at least **OpenGL (ES) 2.0** with an up-to-date driver installed.
## Dependency kit
To facilitate hacking, I have assembled a package containing all dependencies to compile mkxp on a bare-bones Ubuntu 12.04 64bit installation. Compatibility with other distributions has not been tested. You can download it [here](https://mapleshrine.eu/depkits/linux64.tar.xz). Read the "README" for instructions.
## Configuration
mkxp reads configuration data from the file "mkxp.conf" contained in the current directory. The format is ini-style. Do *not* use quotes around file paths (spaces won't break). Lines starting with '#' are comments. Following entries are interpreted:
mkxp reads configuration data from the file "mkxp.conf". The format is ini-style. Do *not* use quotes around file paths (spaces won't break). Lines starting with '#' are comments. See 'mkxp.conf.sample' for a list of accepted entries.
| Key | Type | Default | Description |
| ---------------- | ------ | ------- | ------------------------------------------------------------------------------- |
| debugMode | bool | false | Log OpenGL debug information to the console |
| winResizable | bool | false | Game window is resizable |
| fullscreen | bool | false | Start game in fullscreen (this can always be toggled with Alt-Enter at runtime) |
| fixedAspectRatio | bool | true | Don't stretch the game screen to fit the window size |
| smoothScaling | bool | false | Apply linear interpolation when game screen is stretched |
| vsync | bool | false | Sync screen redraws to the monitor refresh rate |
| defScreenW | int | 640 | Width the game window starts in (this is **not** the game resolution) |
| defScreenH | int | 480 | Height the game window starts in |
| fixedFramerate | int | 0 | FPS will be fixed to this amount. Ignored if 0. |
| frameSkip | bool | true | Skip frames to catch up (useful to disable eg. with Valgrind) |
| solidFonts | bool | false | Don't use alpha blending for fonts |
| gameFolder | string | "." | mkxp will look for all game related files here |
| allowSymlinks | bool | false | Allow symlinks to be followed in the game folder. |
| pathCache | bool | true | Scan and cache asset paths at startup. Allows for case insensitive paths. |
| customScript | string | "" | Execute a raw ruby script file instead of an RPG Maker game. |
| RTP | string | "" | Path to a Run Time Package to be used. Can be specified multiple times. |
All option entries can alternatively be specified as command line options. Any options that are not arrays (eg. RTP paths) specified as command line options will override entries in mkxp.conf. Note that you will have to wrap values containing spaces in quotes (unlike in mkxp.conf).
## RTPs
The syntax is: `--<option>=<value>`
As of right now, mkxp doesn't support midi files, so to use the default RTPs provided by Enterbrain you will have to convert all midi tracks (those in BGM and ME) to ogg or wav. Make sure that the file names match up, ie. "foobar.mid" should be converted to "foobar.ogg".
Example: `./mkxp --gameFolder="my game" --vsync=true --fixedFramerate=60`
## Midi music
mkxp doesn't come with a soundfont by default, so you will have to supply it yourself (set its path in the config). Playback has been tested and should work reasonably well with all RTP assets.
You can use this public domain soundfont: [GMGSx.sf2](https://mapleshrine.eu/unsorted/GMGSx.sf2)
## Fonts
@ -96,9 +115,9 @@ If a requested font is not found, no error is generated. Instead, a built-in fon
## What doesn't work (yet)
* midi and wma audio files
* Movie playback
* wma audio files
* The Win32API ruby class (for obvious reasons)
* Restarting the game with F12
* Creating Bitmaps with sizes greater than the OpenGL texture size limit (around 8192 on modern cards)*
\* There is an exception to this, called *mega surface*. When a Bitmap bigger than the texture limit is created from a file, it is not stored in VRAM, but regular RAM. Its sole purpose is to be used as a tileset bitmap. Any other operation to it (besides blitting to a regular Bitmap) will result in an error.
@ -108,5 +127,5 @@ If a requested font is not found, no error is generated. Instead, a built-in fon
To alleviate possible porting of heavily Win32API reliant scripts, I have added certain functionality that you won't find in the RGSS spec. Currently this amounts to the following:
* The `Input.press?` family of functions accepts three additional button constants: `::MOUSELEFT`, `::MOUSEMIDDLE` and `::MOUSERIGHT` for the respective mouse buttons.
* The `Input` module has two additional functions, `#mouse_x` and `#mouse_y` to query the mouse pointer position relative to the game window.
* The `Input` module has two additional functions, `#mouse_x` and `#mouse_y` to query the mouse pointer position relative to the game screen.
* The `Graphics` module has two additional properties: `fullscreen` represents the current fullscreen mode (`true` = fullscreen, `false` = windowed), `show_cursor` hides the system cursor inside the game window when `false`.

BIN
assets/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

50
assets/icon.svg Normal file
View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="100"
height="100"
id="svg2">
<defs
id="defs4">
<linearGradient
id="linearGradient3821">
<stop
id="stop3823"
style="stop-color:#00ff88;stop-opacity:1"
offset="0" />
<stop
id="stop3825"
style="stop-color:#00ff86;stop-opacity:1"
offset="1" />
</linearGradient>
</defs>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(-323.76562,-436.67187)"
id="layer1">
<path
d="m 373.76195,439.49229 c -26.05643,0 -47.17591,21.12683 -47.17591,47.18326 0,26.05643 21.11948,47.17591 47.17591,47.17591 26.05643,0 47.18326,-21.11948 47.18326,-47.17591 0,-26.05643 -21.12683,-47.18326 -47.18326,-47.18326 z m 0,26.80867 c 11.25095,0 20.37459,9.12364 20.37459,20.37459 0,11.25094 -9.12364,20.36724 -20.37459,20.36724 -11.25094,0 -20.36724,-9.1163 -20.36724,-20.36724 0,-11.25095 9.1163,-20.37459 20.36724,-20.37459 z"
inkscape:connector-curvature="0"
id="path2985"
style="fill:#00ff87;fill-opacity:1;stroke:#000000;stroke-width:5.64083672;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -24,6 +24,33 @@
#include "binding-util.h"
#include "exception.h"
#define DEF_PLAY_STOP_POS(entity) \
RB_METHOD(audio_##entity##Play) \
{ \
RB_UNUSED_PARAM; \
const char *filename; \
int volume = 100; \
int pitch = 100; \
double pos = 0.0; \
if (rgssVer >= 3) \
rb_get_args(argc, argv, "z|iif", &filename, &volume, &pitch, &pos RB_ARG_END); \
else \
rb_get_args(argc, argv, "z|ii", &filename, &volume, &pitch RB_ARG_END); \
GUARD_EXC( shState->audio().entity##Play(filename, volume, pitch, pos); ) \
return Qnil; \
} \
RB_METHOD(audio_##entity##Stop) \
{ \
RB_UNUSED_PARAM; \
shState->audio().entity##Stop(); \
return Qnil; \
} \
RB_METHOD(audio_##entity##Pos) \
{ \
RB_UNUSED_PARAM; \
return rb_float_new(shState->audio().entity##Pos()); \
}
#define DEF_PLAY_STOP(entity) \
RB_METHOD(audio_##entity##Play) \
{ \
@ -52,15 +79,41 @@ RB_METHOD(audio_##entity##Fade) \
return Qnil; \
}
#define DEF_PLAY_STOP_FADE(entity) \
DEF_PLAY_STOP(entity) \
DEF_FADE(entity)
#define DEF_POS(entity) \
RB_METHOD(audio_##entity##Pos) \
{ \
RB_UNUSED_PARAM; \
return rb_float_new(shState->audio().entity##Pos()); \
}
DEF_PLAY_STOP_FADE( bgm )
DEF_PLAY_STOP_FADE( bgs )
DEF_PLAY_STOP_FADE( me )
DEF_PLAY_STOP_POS( bgm )
DEF_PLAY_STOP_POS( bgs )
DEF_PLAY_STOP( se )
DEF_PLAY_STOP( me )
DEF_FADE( bgm )
DEF_FADE( bgs )
DEF_FADE( me )
DEF_PLAY_STOP( se )
RB_METHOD(audioSetupMidi)
{
RB_UNUSED_PARAM;
shState->audio().setupMidi();
return Qnil;
}
RB_METHOD(audioReset)
{
RB_UNUSED_PARAM;
shState->audio().reset();
return Qnil;
}
#define BIND_PLAY_STOP(entity) \
@ -74,15 +127,28 @@ DEF_PLAY_STOP( se )
BIND_PLAY_STOP(entity) \
BIND_FADE(entity)
#define BIND_POS(entity) \
_rb_define_module_function(module, #entity "_pos", audio_##entity##Pos);
void
audioBindingInit()
{
VALUE module = rb_define_module("Audio");
BIND_PLAY_STOP_FADE( bgm )
BIND_PLAY_STOP_FADE( bgs )
BIND_PLAY_STOP_FADE( me )
BIND_PLAY_STOP_FADE( bgm );
BIND_PLAY_STOP_FADE( bgs );
BIND_PLAY_STOP_FADE( me );
if (rgssVer >= 3)
{
BIND_POS( bgm );
BIND_POS( bgs );
_rb_define_module_function(module, "setup_midi", audioSetupMidi);
}
BIND_PLAY_STOP( se )
_rb_define_module_function(module, "__reset__", audioReset);
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -25,26 +25,34 @@
#include "eventthread.h"
#include "filesystem.h"
#include "util.h"
#include "sdl-util.h"
#include "debugwriter.h"
#include "graphics.h"
#include "audio.h"
#include "boost-hash.h"
#include <ruby.h>
#include <ruby/encoding.h>
#include <assert.h>
#include <string>
#include <zlib.h>
#include <SDL_filesystem.h>
extern const char module_rpg[];
extern const char module_rpg1[];
extern const char module_rpg2[];
extern const char module_rpg3[];
static void mriBindingExecute();
static void mriBindingTerminate();
static void mriBindingReset();
ScriptBinding scriptBindingImpl =
{
mriBindingExecute,
mriBindingTerminate
mriBindingTerminate,
mriBindingReset
};
ScriptBinding *scriptBinding = &scriptBindingImpl;
@ -58,6 +66,8 @@ void viewportBindingInit();
void planeBindingInit();
void windowBindingInit();
void tilemapBindingInit();
void windowVXBindingInit();
void tilemapVXBindingInit();
void inputBindingInit();
void audioBindingInit();
@ -67,8 +77,14 @@ void fileIntBindingInit();
RB_METHOD(mriPrint);
RB_METHOD(mriP);
RB_METHOD(mriDataDirectory);
RB_METHOD(mkxpDataDirectory);
RB_METHOD(mkxpPuts);
RB_METHOD(mkxpRawKeyStates);
RB_METHOD(mkxpMouseInWindow);
RB_METHOD(mriRgssMain);
RB_METHOD(mriRgssStop);
RB_METHOD(_kernelCaller);
static void mriBindingInit()
{
@ -79,8 +95,17 @@ static void mriBindingInit()
spriteBindingInit();
viewportBindingInit();
planeBindingInit();
windowBindingInit();
tilemapBindingInit();
if (rgssVer == 1)
{
windowBindingInit();
tilemapBindingInit();
}
else
{
windowVXBindingInit();
tilemapVXBindingInit();
}
inputBindingInit();
audioBindingInit();
@ -88,16 +113,50 @@ static void mriBindingInit()
fileIntBindingInit();
_rb_define_module_function(rb_mKernel, "print", mriPrint);
_rb_define_module_function(rb_mKernel, "p", mriP);
if (rgssVer >= 3)
{
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
_rb_define_module_function(rb_mKernel, "rgss_stop", mriRgssStop);
rb_eval_string(module_rpg);
_rb_define_module_function(rb_mKernel, "msgbox", mriPrint);
_rb_define_module_function(rb_mKernel, "msgbox_p", mriP);
VALUE mod = rb_define_module("System");
_rb_define_module_function(mod, "data_directory", mriDataDirectory);
rb_define_global_const("RGSS_VERSION", rb_str_new_cstr("3.0.1"));
}
else
{
_rb_define_module_function(rb_mKernel, "print", mriPrint);
_rb_define_module_function(rb_mKernel, "p", mriP);
rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller");
_rb_define_module_function(rb_mKernel, "caller", _kernelCaller);
}
if (rgssVer == 1)
rb_eval_string(module_rpg1);
else if (rgssVer == 2)
rb_eval_string(module_rpg2);
else if (rgssVer == 3)
rb_eval_string(module_rpg3);
else
assert(!"unreachable");
VALUE mod = rb_define_module("MKXP");
_rb_define_module_function(mod, "data_directory", mkxpDataDirectory);
_rb_define_module_function(mod, "puts", mkxpPuts);
_rb_define_module_function(mod, "raw_key_states", mkxpRawKeyStates);
_rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow);
rb_define_global_const("MKXP", Qtrue);
/* Load global constants */
rb_gv_set("MKXP", Qtrue);
VALUE debug = rb_bool_new(shState->config().editor.debug);
if (rgssVer == 1)
rb_gv_set("DEBUG", debug);
else if (rgssVer >= 2)
rb_gv_set("TEST", debug);
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
}
static void
@ -106,18 +165,6 @@ showMsg(const std::string &msg)
shState->eThread().showMessageBox(msg.c_str());
}
RB_METHOD(mkxpPuts)
{
RB_UNUSED_PARAM;
const char *str;
rb_get_args(argc, argv, "z", &str RB_ARG_END);
Debug() << str;
return Qnil;
}
static void printP(int argc, VALUE *argv,
const char *convMethod, const char *sep)
{
@ -126,7 +173,7 @@ static void printP(int argc, VALUE *argv,
for (int i = 0; i < argc; ++i)
{
VALUE str = rb_funcall(argv[i], conv, 0);
VALUE str = rb_funcall2(argv[i], conv, 0, NULL);
rb_str_buf_append(dispString, str);
if (i < argc)
@ -154,41 +201,187 @@ RB_METHOD(mriP)
return Qnil;
}
RB_METHOD(mriDataDirectory)
RB_METHOD(mkxpDataDirectory)
{
RB_UNUSED_PARAM;
const std::string &path = shState->config().customDataPath;
const char *s = path.empty() ? "." : path.c_str();
return rb_str_new_cstr(s);
}
RB_METHOD(mkxpPuts)
{
RB_UNUSED_PARAM;
const char *org, *app;
const char *str;
rb_get_args(argc, argv, "z", &str RB_ARG_END);
rb_get_args(argc, argv, "zz", &org, &app RB_ARG_END);
Debug() << str;
char *path = SDL_GetPrefPath(org, app);
VALUE pathStr = rb_str_new_cstr(path);
SDL_free(path);
return pathStr;
return Qnil;
}
static void runCustomScript(const char *filename)
RB_METHOD(mkxpRawKeyStates)
{
std::string scriptData("#encoding:utf-8\n");
RB_UNUSED_PARAM;
if (!readFile(filename, scriptData))
VALUE str = rb_str_new(0, sizeof(EventThread::keyStates));
memcpy(RSTRING_PTR(str), EventThread::keyStates, sizeof(EventThread::keyStates));
return str;
}
RB_METHOD(mkxpMouseInWindow)
{
RB_UNUSED_PARAM;
return rb_bool_new(EventThread::mouseState.inWindow);
}
static VALUE rgssMainCb(VALUE block)
{
rb_funcall2(block, rb_intern("call"), 0, 0);
return Qnil;
}
static VALUE rgssMainRescue(VALUE arg, VALUE exc)
{
VALUE *excRet = (VALUE*) arg;
*excRet = exc;
return Qnil;
}
static void processReset()
{
shState->graphics().reset();
shState->audio().reset();
shState->rtData().rqReset.clear();
shState->graphics().repaintWait(shState->rtData().rqResetFinish,
false);
}
RB_METHOD(mriRgssMain)
{
RB_UNUSED_PARAM;
while (true)
{
VALUE exc = Qnil;
rb_rescue2((VALUE(*)(ANYARGS)) rgssMainCb, rb_block_proc(),
(VALUE(*)(ANYARGS)) rgssMainRescue, (VALUE) &exc,
rb_eException, (VALUE) 0);
if (NIL_P(exc))
break;
if (rb_obj_class(exc) == getRbData()->exc[Reset])
processReset();
else
rb_exc_raise(exc);
}
return Qnil;
}
RB_METHOD(mriRgssStop)
{
RB_UNUSED_PARAM;
while (true)
shState->graphics().update();
return Qnil;
}
RB_METHOD(_kernelCaller)
{
RB_UNUSED_PARAM;
VALUE trace = rb_funcall2(rb_mKernel, rb_intern("_mkxp_kernel_caller_alias"), 0, 0);
if (!RB_TYPE_P(trace, RUBY_T_ARRAY))
return trace;
long len = RARRAY_LEN(trace);
if (len < 2)
return trace;
/* Remove useless "ruby:1:in 'eval'" */
rb_ary_pop(trace);
/* Also remove trace of this helper function */
rb_ary_shift(trace);
len -= 2;
if (len == 0)
return trace;
/* RMXP does this, not sure if specific or 1.8 related */
VALUE args[] = { rb_str_new_cstr(":in `<main>'"), rb_str_new_cstr("") };
rb_funcall2(rb_ary_entry(trace, len-1), rb_intern("gsub!"), 2, args);
return trace;
}
static VALUE newStringUTF8(const char *string, long length)
{
return rb_enc_str_new(string, length, rb_utf8_encoding());
}
struct evalArg
{
VALUE string;
VALUE filename;
};
static VALUE evalHelper(evalArg *arg)
{
VALUE argv[] = { arg->string, Qnil, arg->filename };
return rb_funcall2(Qnil, rb_intern("eval"), ARRAY_SIZE(argv), argv);
}
static VALUE evalString(VALUE string, VALUE filename, int *state)
{
evalArg arg = { string, filename };
return rb_protect((VALUE (*)(VALUE))evalHelper, (VALUE)&arg, state);
}
static void runCustomScript(const std::string &filename)
{
std::string scriptData;
if (!readFileSDL(filename.c_str(), scriptData))
{
showMsg(std::string("Unable to open '") + filename + "'");
return;
}
rb_eval_string_protect(scriptData.c_str(), 0);
evalString(newStringUTF8(scriptData.c_str(), scriptData.size()),
newStringUTF8(filename.c_str(), filename.size()), NULL);
}
VALUE kernelLoadDataInt(const char *filename);
VALUE kernelLoadDataInt(const char *filename, bool rubyExc);
static void runRMXPScripts()
struct BacktraceData
{
const std::string &scriptPack = shState->rtData().config.game.scripts;
/* Maps: Ruby visible filename, To: Actual script name */
BoostHash<std::string, std::string> scriptNames;
};
#define SCRIPT_SECTION_FMT (rgssVer >= 3 ? "{%04ld}" : "Section%03ld")
static void runRMXPScripts(BacktraceData &btData)
{
const Config &conf = shState->rtData().config;
const std::string &scriptPack = conf.game.scripts;
if (scriptPack.empty())
{
@ -202,24 +395,38 @@ static void runRMXPScripts()
return;
}
VALUE scriptArray = kernelLoadDataInt(scriptPack.c_str());
VALUE scriptArray;
if (rb_type(scriptArray) != RUBY_T_ARRAY)
/* We checked if Scripts.rxdata exists, but something might
* still go wrong */
try
{
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
}
catch (const Exception &e)
{
showMsg(std::string("Failed to read script data: ") + e.msg);
return;
}
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY))
{
showMsg("Failed to read script data");
return;
}
size_t scriptCount = RARRAY_LEN(scriptArray);
rb_gv_set("$RGSS_SCRIPTS", scriptArray);
long scriptCount = RARRAY_LEN(scriptArray);
std::string decodeBuffer;
decodeBuffer.resize(0x1000);
for (size_t i = 0; i < scriptCount; ++i)
for (long i = 0; i < scriptCount; ++i)
{
VALUE script = rb_ary_entry(scriptArray, i);
if (rb_type(script) != RUBY_T_ARRAY)
if (!RB_TYPE_P(script, RUBY_T_ARRAY))
continue;
VALUE scriptName = rb_ary_entry(script, 1);
@ -251,8 +458,7 @@ static void runRMXPScripts()
if (result != Z_OK)
{
static char buffer[256];
/* FIXME: '%zu' apparently gcc only? */
snprintf(buffer, sizeof(buffer), "Error decoding script %zu: '%s'",
snprintf(buffer, sizeof(buffer), "Error decoding script %ld: '%s'",
i, RSTRING_PTR(scriptName));
showMsg(buffer);
@ -260,61 +466,168 @@ static void runRMXPScripts()
break;
}
/* Store encoding header + the decoded script
* in 'sc.decData' */
std::string decData = "#encoding:utf-8\n";
size_t hdSize = decData.size();
decData.resize(hdSize + bufferLen);
memcpy(&decData[hdSize], decodeBuffer.c_str(), bufferLen);
rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str()));
}
ruby_script(RSTRING_PTR(scriptName));
/* Execute preloaded scripts */
for (std::set<std::string>::iterator i = conf.preloadScripts.begin();
i != conf.preloadScripts.end(); ++i)
runCustomScript(*i);
rb_gc_start();
VALUE exc = rb_gv_get("$!");
if (exc != Qnil)
return;
/* Execute code */
rb_eval_string_protect(decData.c_str(), 0);
while (true)
{
for (long i = 0; i < scriptCount; ++i)
{
VALUE script = rb_ary_entry(scriptArray, i);
VALUE scriptDecoded = rb_ary_entry(script, 3);
VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded),
RSTRING_LEN(scriptDecoded));
VALUE fname;
const char *scriptName = RSTRING_PTR(rb_ary_entry(script, 1));
char buf[512];
int len;
if (conf.useScriptNames)
len = snprintf(buf, sizeof(buf), "%03ld:%s", i, scriptName);
else
len = snprintf(buf, sizeof(buf), SCRIPT_SECTION_FMT, i);
fname = newStringUTF8(buf, len);
btData.scriptNames.insert(buf, scriptName);
int state;
evalString(string, fname, &state);
if (state)
break;
}
VALUE exc = rb_gv_get("$!");
if (rb_type(exc) != RUBY_T_NIL)
if (rb_obj_class(exc) != getRbData()->exc[Reset])
break;
processReset();
}
}
static void showExc(VALUE exc, const BacktraceData &btData)
{
VALUE bt = rb_funcall2(exc, rb_intern("backtrace"), 0, NULL);
VALUE msg = rb_funcall2(exc, rb_intern("message"), 0, NULL);
VALUE bt0 = rb_ary_entry(bt, 0);
VALUE name = rb_class_path(rb_obj_class(exc));
VALUE ds = rb_sprintf("%" PRIsVALUE ": %" PRIsVALUE " (%" PRIsVALUE ")",
bt0, exc, name);
/* omit "useless" last entry (from ruby:1:in `eval') */
for (long i = 1, btlen = RARRAY_LEN(bt) - 1; i < btlen; ++i)
rb_str_catf(ds, "\n\tfrom %" PRIsVALUE, rb_ary_entry(bt, i));
Debug() << StringValueCStr(ds);
char *s = RSTRING_PTR(bt0);
char line[16];
std::string file(512, '\0');
char *p = s + strlen(s);
char *e;
while (p != s)
if (*--p == ':')
break;
e = p;
while (p != s)
if (*--p == ':')
break;
/* s p e
* SectionXXX:YY: in 'blabla' */
*e = '\0';
strncpy(line, *p ? p+1 : p, sizeof(line));
line[sizeof(line)-1] = '\0';
*e = ':';
e = p;
/* s e
* SectionXXX:YY: in 'blabla' */
*e = '\0';
strncpy(&file[0], s, file.size());
*e = ':';
/* Shrink to fit */
file.resize(strlen(file.c_str()));
file = btData.scriptNames.value(file, file);
std::string ms(640, '\0');
snprintf(&ms[0], ms.size(), "Script '%s' line %s: %s occured.\n\n%s",
file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg));
showMsg(ms);
}
static void mriBindingExecute()
{
/* Normally only a ruby executable would do a sysinit,
* but not doing it will lead to crashes due to closed
* stdio streams on some platforms (eg. Windows) */
int argc = 0;
char **argv = 0;
ruby_sysinit(&argc, &argv);
ruby_setup();
rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));
Config &conf = shState->rtData().config;
if (!conf.rubyLoadpaths.empty())
{
/* Setup custom load paths */
VALUE lpaths = rb_gv_get(":");
for (size_t i = 0; i < conf.rubyLoadpaths.size(); ++i)
{
std::string &path = conf.rubyLoadpaths[i];
VALUE pathv = rb_str_new(path.c_str(), path.size());
rb_ary_push(lpaths, pathv);
}
}
RbData rbData;
shState->setBindingData(&rbData);
BacktraceData btData;
mriBindingInit();
std::string &customScript = shState->rtData().config.customScript;
std::string &customScript = conf.customScript;
if (!customScript.empty())
runCustomScript(customScript.c_str());
runCustomScript(customScript);
else
runRMXPScripts();
runRMXPScripts(btData);
VALUE exc = rb_gv_get("$!");
if (rb_type(exc) != RUBY_T_NIL && !rb_eql(rb_obj_class(exc), rb_eSystemExit))
{
Debug() << "Had exception:" << rb_class2name(rb_obj_class(exc));
VALUE bt = rb_funcall(exc, rb_intern("backtrace"), 0);
rb_p(bt);
VALUE msg = rb_funcall(exc, rb_intern("message"), 0);
if (RSTRING_LEN(msg) < 256)
showMsg(RSTRING_PTR(msg));
else
Debug() << (RSTRING_PTR(msg));
}
VALUE exc = rb_errinfo();
if (!NIL_P(exc) && !rb_obj_is_kind_of(exc, rb_eSystemExit))
showExc(exc, btData);
ruby_cleanup(0);
shState->rtData().rqTermAck = true;
shState->rtData().rqTermAck.set();
}
static void mriBindingTerminate()
{
rb_raise(rb_eSystemExit, " ");
}
static void mriBindingReset()
{
rb_raise(getRbData()->exc[Reset], " ");
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -26,21 +26,9 @@
#include "util.h"
#include <stdarg.h>
#include <string.h>
#include <assert.h>
void initType(rb_data_type_struct &type,
const char *name,
void (*freeInst)(void *))
{
type.wrap_struct_name = name;
type.function.dmark = 0;
type.function.dsize = 0;
type.function.dfree = freeInst;
type.function.reserved[0] =
type.function.reserved[1] = 0;
type.parent = 0;
}
RbData *getRbData()
{
return static_cast<RbData*>(shState->bindingData());
@ -53,7 +41,6 @@ struct
} static customExc[] =
{
{ MKXP, "MKXPError" },
{ RGSS, "RGSSError" },
{ PHYSFS, "PHYSFSError" },
{ SDL, "SDLError" }
};
@ -63,6 +50,9 @@ RbData::RbData()
for (size_t i = 0; i < ARRAY_SIZE(customExc); ++i)
exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException);
exc[RGSS] = rb_define_class("RGSSError", rb_eStandardError);
exc[Reset] = rb_define_class(rgssVer >= 3 ? "RGSSReset" : "Reset", rb_eException);
exc[ErrnoENOENT] = rb_const_get(rb_const_get(rb_cObject, rb_intern("Errno")), rb_intern("ENOENT"));
exc[IOError] = rb_eIOError;
exc[TypeError] = rb_eTypeError;
@ -97,6 +87,18 @@ void raiseRbExc(const Exception &exc)
rb_raise(excClass, "%s", exc.msg.c_str());
}
void
raiseDisposedAccess(VALUE self)
{
const char *klassName = RTYPEDDATA_TYPE(self)->wrap_struct_name;
char buf[32];
strncpy(buf, klassName, sizeof(buf));
buf[0] = tolower(buf[0]);
rb_raise(getRbData()->exc[RGSS], "disposed %s", buf);
}
int
rb_get_args(int argc, VALUE *argv, const char *format, ...)
{
@ -148,7 +150,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
VALUE *str = va_arg(ap, VALUE*);
VALUE tmp = *arg;
if (!(rb_type(tmp) == RUBY_T_STRING))
if (!RB_TYPE_P(tmp, RUBY_T_STRING))
rb_raise(rb_eTypeError, "Argument %d: Expected string", argI);
*str = tmp;
@ -167,7 +169,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
VALUE tmp = *arg;
if (!(rb_type(tmp) == RUBY_T_STRING))
if (!RB_TYPE_P(tmp, RUBY_T_STRING))
rb_raise(rb_eTypeError, "Argument %d: Expected string", argI);
*s = RSTRING_PTR(tmp);
@ -186,7 +188,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
VALUE tmp = *arg++;
if (!(rb_type(tmp) == RUBY_T_STRING))
if (!RB_TYPE_P(tmp, RUBY_T_STRING))
rb_raise(rb_eTypeError, "Argument %d: Expected string", argI);
*s = RSTRING_PTR(tmp);
@ -237,6 +239,24 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
break;
}
case 'n' :
{
if (argI >= argc)
break;
ID *sym = va_arg(ap, ID*);
VALUE symVal = *arg++;
if (!SYMBOL_P(symVal))
rb_raise(rb_eTypeError, "Argument %d: Expected symbol", argI);
*sym = SYM2ID(symVal);
++argI;
break;
}
case '|' :
opt = true;
break;

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -29,6 +29,7 @@
enum RbException
{
RGSS = 0,
Reset,
PHYSFS,
SDL,
MKXP,
@ -47,6 +48,9 @@ struct RbData
{
VALUE exc[RbExceptionsMax];
/* Input module (RGSS3) */
VALUE buttoncodeHash;
RbData();
~RbData();
};
@ -59,19 +63,39 @@ void
raiseRbExc(const Exception &exc);
#define DECL_TYPE(Klass) \
extern rb_data_type_struct Klass##Type
extern rb_data_type_t Klass##Type
#define DEF_TYPE(Klass) \
rb_data_type_struct Klass##Type
/* 2.1 has added a new field (flags) to rb_data_type_t */
#include <ruby/version.h>
#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 1
/* TODO: can mkxp use RUBY_TYPED_FREE_IMMEDIATELY here? */
#define DEF_TYPE_FLAGS 0
#else
#define DEF_TYPE_FLAGS
#endif
void initType(rb_data_type_struct &type,
const char *name,
void (*freeInst)(void*));
#define DEF_TYPE_CUSTOMNAME_AND_FREE(Klass, Name, Free) \
rb_data_type_t Klass##Type = { \
Name, { 0, Free, 0, { 0, 0 } }, 0, 0, DEF_TYPE_FLAGS \
}
#define DEF_TYPE_CUSTOMFREE(Klass, Free) \
DEF_TYPE_CUSTOMNAME_AND_FREE(Klass, #Klass, Free)
#define DEF_TYPE_CUSTOMNAME(Klass, Name) \
DEF_TYPE_CUSTOMNAME_AND_FREE(Klass, Name, freeInstance<Klass>)
#define DEF_TYPE(Klass) DEF_TYPE_CUSTOMNAME(Klass, #Klass)
template<rb_data_type_t *rbType>
static VALUE classAllocate(VALUE klass)
{
/* 2.3 has changed the name of this function */
#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 3
return rb_data_typed_object_wrap(klass, 0, rbType);
#else
return rb_data_typed_object_alloc(klass, 0, rbType);
#endif
}
template<class C>
@ -80,18 +104,21 @@ static void freeInstance(void *inst)
delete static_cast<C*>(inst);
}
#define INIT_TYPE(Klass) initType(Klass##Type, #Klass, freeInstance<Klass>)
void
raiseDisposedAccess(VALUE self);
template<class C>
static inline C *
inline C *
getPrivateData(VALUE self)
{
return static_cast<C*>(RTYPEDDATA_DATA(self));
C *c = static_cast<C*>(RTYPEDDATA_DATA(self));
return c;
}
template<class C>
static inline C *
getPrivateDataCheck(VALUE self, const rb_data_type_struct &type)
getPrivateDataCheck(VALUE self, const rb_data_type_t &type)
{
void *obj = Check_TypedStruct(self, &type);
return static_cast<C*>(obj);
@ -104,9 +131,10 @@ setPrivateData(VALUE self, void *p)
}
inline VALUE
wrapObject(void *p, const rb_data_type_struct &type)
wrapObject(void *p, const rb_data_type_t &type,
VALUE underKlass = rb_cObject)
{
VALUE klass = rb_const_get(rb_cObject, rb_intern(type.wrap_struct_name));
VALUE klass = rb_const_get(underKlass, rb_intern(type.wrap_struct_name));
VALUE obj = rb_obj_alloc(klass);
setPrivateData(obj, p);
@ -116,22 +144,17 @@ wrapObject(void *p, const rb_data_type_struct &type)
inline VALUE
wrapProperty(VALUE self, void *prop, const char *iv,
const rb_data_type_struct &type)
const rb_data_type_t &type,
VALUE underKlass = rb_cObject)
{
VALUE propObj = wrapObject(prop, type);
VALUE propObj = wrapObject(prop, type, underKlass);
rb_iv_set(self, iv, propObj);
return propObj;
}
inline void
wrapNilProperty(VALUE self, const char *iv)
{
rb_iv_set(self, iv, Qnil);
}
/* Implemented: oSszfib| */
/* Implemented: oSszfibn| */
int
rb_get_args(int argc, VALUE *argv, const char *format, ...);
@ -281,17 +304,38 @@ rb_check_argc(int actual, int expected)
return self; \
}
/* If we're not binding a disposable class,
* we want to #undef DEF_PROP_CHK_DISP */
#define DEF_PROP_CHK_DISP \
checkDisposed(k, DISP_CLASS_NAME);
#define DEF_PROP_OBJ(Klass, PropKlass, PropName, prop_iv) \
/* Object property which is copied by reference, with allowed NIL
* FIXME: Getter assumes prop is disposable,
* because self.disposed? is not checked in this case.
* Should make this more clear */
#define DEF_PROP_OBJ_REF(Klass, PropKlass, PropName, prop_iv) \
RB_METHOD(Klass##Get##PropName) \
{ \
RB_UNUSED_PARAM; \
Klass *k = getPrivateData<Klass>(self); (void) k; \
DEF_PROP_CHK_DISP \
return rb_iv_get(self, prop_iv); \
} \
RB_METHOD(Klass##Set##PropName) \
{ \
RB_UNUSED_PARAM; \
rb_check_argc(argc, 1); \
Klass *k = getPrivateData<Klass>(self); \
VALUE propObj = *argv; \
PropKlass *prop; \
if (NIL_P(propObj)) \
prop = 0; \
else \
prop = getPrivateDataCheck<PropKlass>(propObj, PropKlass##Type); \
GUARD_EXC( k->set##PropName(prop); ) \
rb_iv_set(self, prop_iv, propObj); \
return propObj; \
}
/* Object property which is copied by value, not reference */
#define DEF_PROP_OBJ_VAL(Klass, PropKlass, PropName, prop_iv) \
RB_METHOD(Klass##Get##PropName) \
{ \
RB_UNUSED_PARAM; \
checkDisposed<Klass>(self); \
return rb_iv_get(self, prop_iv); \
} \
RB_METHOD(Klass##Set##PropName) \
@ -301,33 +345,7 @@ rb_check_argc(int actual, int expected)
VALUE propObj = *argv; \
PropKlass *prop; \
prop = getPrivateDataCheck<PropKlass>(propObj, PropKlass##Type); \
GUARD_EXC( k->set##PropName(prop); ) \
rb_iv_set(self, prop_iv, propObj); \
return propObj; \
}
/* Object property with allowed NIL */
#define DEF_PROP_OBJ_NIL(Klass, PropKlass, PropName, prop_iv) \
RB_METHOD(Klass##Get##PropName) \
{ \
RB_UNUSED_PARAM; \
Klass *k = getPrivateData<Klass>(self); (void) k; \
DEF_PROP_CHK_DISP \
return rb_iv_get(self, prop_iv); \
} \
RB_METHOD(Klass##Set##PropName) \
{ \
RB_UNUSED_PARAM; \
rb_check_argc(argc, 1); \
Klass *k = getPrivateData<Klass>(self); \
VALUE propObj = *argv; \
PropKlass *prop; \
if (rb_type(propObj) == RUBY_T_NIL) \
prop = 0; \
else \
prop = getPrivateDataCheck<PropKlass>(propObj, PropKlass##Type); \
GUARD_EXC( k->set##PropName(prop); ) \
rb_iv_set(self, prop_iv, propObj); \
GUARD_EXC( k->set##PropName(*prop); ) \
return propObj; \
}
@ -336,8 +354,9 @@ rb_check_argc(int actual, int expected)
{ \
RB_UNUSED_PARAM; \
Klass *k = getPrivateData<Klass>(self); \
DEF_PROP_CHK_DISP \
return value_fun(k->get##PropName()); \
type value = 0; \
GUARD_EXC( value = k->get##PropName(); ) \
return value_fun(value); \
} \
RB_METHOD(Klass##Set##PropName) \
{ \

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -22,14 +22,32 @@
#include "bitmap.h"
#include "font.h"
#include "exception.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "binding-util.h"
#include "binding-types.h"
#define DISP_CLASS_NAME "bitmap"
DEF_TYPE(Bitmap);
static const char *objAsStringPtr(VALUE obj)
{
VALUE str = rb_obj_as_string(obj);
return RSTRING_PTR(str);
}
void bitmapInitProps(Bitmap *b, VALUE self)
{
/* Wrap properties */
VALUE fontKlass = rb_const_get(rb_cObject, rb_intern("Font"));
VALUE fontObj = rb_obj_alloc(fontKlass);
rb_obj_call_init(fontObj, 0, 0);
Font *font = getPrivateData<Font>(fontObj);
b->setInitFont(font);
rb_iv_set(self, "font", fontObj);
}
RB_METHOD(bitmapInitialize)
{
Bitmap *b = 0;
@ -50,14 +68,7 @@ RB_METHOD(bitmapInitialize)
}
setPrivateData(self, b);
/* Wrap properties */
Font *font = new Font();
b->setFont(font);
font->setColor(new Color(*font->getColor()));
VALUE fontProp = wrapProperty(self, font, "font", FontType);
wrapProperty(fontProp, font->getColor(), "color", ColorType);
bitmapInitProps(b, self);
return self;
}
@ -197,12 +208,7 @@ RB_METHOD(bitmapGetPixel)
rb_get_args(argc, argv, "ii", &x, &y RB_ARG_END);
GUARD_EXC(
if (x < 0 || y < 0 || x >= b->width() || y >= b->height())
return Qnil;
)
Vec4 value;
Color value;
GUARD_EXC( value = b->getPixel(x, y); );
Color *color = new Color(value);
@ -223,7 +229,7 @@ RB_METHOD(bitmapSetPixel)
color = getPrivateDataCheck<Color>(colorObj, ColorType);
GUARD_EXC( b->setPixel(x, y, color->norm); );
GUARD_EXC( b->setPixel(x, y, *color); );
return self;
}
@ -253,7 +259,17 @@ RB_METHOD(bitmapDrawText)
VALUE rectObj;
Rect *rect;
rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END);
if (rgssVer >= 2)
{
VALUE strObj;
rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END);
str = objAsStringPtr(strObj);
}
else
{
rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END);
}
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
@ -263,7 +279,17 @@ RB_METHOD(bitmapDrawText)
{
int x, y, width, height;
rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END);
if (rgssVer >= 2)
{
VALUE strObj;
rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END);
str = objAsStringPtr(strObj);
}
else
{
rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END);
}
GUARD_EXC( b->drawText(x, y, width, height, str, align); );
}
@ -277,7 +303,17 @@ RB_METHOD(bitmapTextSize)
const char *str;
rb_get_args(argc, argv, "z", &str RB_ARG_END);
if (rgssVer >= 2)
{
VALUE strObj;
rb_get_args(argc, argv, "o", &strObj RB_ARG_END);
str = objAsStringPtr(strObj);
}
else
{
rb_get_args(argc, argv, "z", &str RB_ARG_END);
}
IntRect value;
GUARD_EXC( value = b->textSize(str); );
@ -287,28 +323,127 @@ RB_METHOD(bitmapTextSize)
return wrapObject(rect, RectType);
}
DEF_PROP_OBJ(Bitmap, Font, Font, "font")
DEF_PROP_OBJ_VAL(Bitmap, Font, Font, "font")
// FIXME: This isn't entire correct as the cloned bitmap
// does not get a cloned version of the original bitmap's 'font'
// attribute (the internal font attrb is the default one, whereas
// the stored iv visible to ruby would still be the same as the original)
// Not sure if this needs fixing though
INITCOPY_FUN(Bitmap)
RB_METHOD(bitmapGradientFillRect)
{
Bitmap *b = getPrivateData<Bitmap>(self);
VALUE color1Obj, color2Obj;
Color *color1, *color2;
bool vertical = false;
if (argc == 3 || argc == 4)
{
VALUE rectObj;
Rect *rect;
rb_get_args(argc, argv, "ooo|b", &rectObj,
&color1Obj, &color2Obj, &vertical RB_ARG_END);
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
color1 = getPrivateDataCheck<Color>(color1Obj, ColorType);
color2 = getPrivateDataCheck<Color>(color2Obj, ColorType);
GUARD_EXC( b->gradientFillRect(rect->toIntRect(), color1->norm, color2->norm, vertical); );
}
else
{
int x, y, width, height;
rb_get_args(argc, argv, "iiiioo|b", &x, &y, &width, &height,
&color1Obj, &color2Obj, &vertical RB_ARG_END);
color1 = getPrivateDataCheck<Color>(color1Obj, ColorType);
color2 = getPrivateDataCheck<Color>(color2Obj, ColorType);
GUARD_EXC( b->gradientFillRect(x, y, width, height, color1->norm, color2->norm, vertical); );
}
return self;
}
RB_METHOD(bitmapClearRect)
{
Bitmap *b = getPrivateData<Bitmap>(self);
if (argc == 1)
{
VALUE rectObj;
Rect *rect;
rb_get_args(argc, argv, "o", &rectObj RB_ARG_END);
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
GUARD_EXC( b->clearRect(rect->toIntRect()); );
}
else
{
int x, y, width, height;
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
GUARD_EXC( b->clearRect(x, y, width, height); );
}
return self;
}
RB_METHOD(bitmapBlur)
{
RB_UNUSED_PARAM;
Bitmap *b = getPrivateData<Bitmap>(self);
b->blur();
return Qnil;
}
RB_METHOD(bitmapRadialBlur)
{
Bitmap *b = getPrivateData<Bitmap>(self);
int angle, divisions;
rb_get_args(argc, argv, "ii", &angle, &divisions RB_ARG_END);
b->radialBlur(angle, divisions);
return Qnil;
}
RB_METHOD(bitmapInitializeCopy)
{
rb_check_argc(argc, 1);
VALUE origObj = argv[0];
if (!OBJ_INIT_COPY(self, origObj))
return self;
Bitmap *orig = getPrivateData<Bitmap>(origObj);
Bitmap *b = 0;
GUARD_EXC( b = new Bitmap(*orig); );
bitmapInitProps(b, self);
b->setFont(orig->getFont());
setPrivateData(self, b);
return self;
}
void
bitmapBindingInit()
{
INIT_TYPE(Bitmap);
VALUE klass = rb_define_class("Bitmap", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&BitmapType>);
disposableBindingInit<Bitmap>(klass);
_rb_define_method(klass, "initialize", bitmapInitialize);
_rb_define_method(klass, "initialize_copy", BitmapInitializeCopy);
_rb_define_method(klass, "initialize_copy", bitmapInitializeCopy);
_rb_define_method(klass, "width", bitmapWidth);
_rb_define_method(klass, "height", bitmapHeight);
@ -323,5 +458,13 @@ bitmapBindingInit()
_rb_define_method(klass, "draw_text", bitmapDrawText);
_rb_define_method(klass, "text_size", bitmapTextSize);
if (rgssVer >= 2)
{
_rb_define_method(klass, "gradient_fill_rect", bitmapGradientFillRect);
_rb_define_method(klass, "clear_rect", bitmapClearRect);
_rb_define_method(klass, "blur", bitmapBlur);
_rb_define_method(klass, "radial_blur", bitmapRadialBlur);
}
INIT_PROP_BIND(Bitmap, Font, "font");
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -25,12 +25,54 @@
#include "disposable.h"
#include "binding-util.h"
/* 'Children' are disposables that are disposed together
* with their parent. Currently this is only used by Viewport
* in RGSS1. */
inline void
disposableAddChild(VALUE disp, VALUE child)
{
VALUE children = rb_iv_get(disp, "children");
if (NIL_P(children))
{
children = rb_ary_new();
rb_iv_set(disp, "children", children);
}
/* Assumes children are never removed until destruction */
rb_ary_push(children, child);
}
inline void
disposableDisposeChildren(VALUE disp)
{
VALUE children = rb_iv_get(disp, "children");
if (NIL_P(children))
return;
ID dispFun = rb_intern("_mkxp_dispose_alias");
for (long i = 0; i < RARRAY_LEN(children); ++i)
rb_funcall2(rb_ary_entry(children, i), dispFun, 0, 0);
}
template<class C>
RB_METHOD(disposableDispose)
{
RB_UNUSED_PARAM;
Disposable *d = getPrivateData<C>(self);
C *d = getPrivateData<C>(self);
if (!d)
return Qnil;
/* Nothing to do if already disposed */
if (d->isDisposed())
return Qnil;
if (rgssVer == 1)
disposableDisposeChildren(self);
d->dispose();
@ -42,7 +84,10 @@ RB_METHOD(disposableIsDisposed)
{
RB_UNUSED_PARAM;
Disposable *d = getPrivateData<C>(self);
C *d = getPrivateData<C>(self);
if (!d)
return Qtrue;
return rb_bool_new(d->isDisposed());
}
@ -52,14 +97,19 @@ static void disposableBindingInit(VALUE klass)
{
_rb_define_method(klass, "dispose", disposableDispose<C>);
_rb_define_method(klass, "disposed?", disposableIsDisposed<C>);
/* Make sure we always have access to the original method, even
* if it is overridden by user scripts */
if (rgssVer == 1)
rb_define_alias(klass, "_mkxp_dispose_alias", "dispose");
}
inline void checkDisposed(Disposable *d, const char *klassName)
template<class C>
inline void
checkDisposed(VALUE self)
{
RbData *data = getRbData(); (void) data;
if (d->isDisposed())
rb_raise(getRbData()->exc[RGSS], "disposed %s", klassName);
if (disposableIsDisposed<C>(0, 0, self) == Qtrue)
raiseDisposedAccess(self);
}
#endif // DISPOSABLEBINDING_H

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -22,6 +22,7 @@
#include "etc.h"
#include "binding-util.h"
#include "serializable-binding.h"
#include "sharedstate.h"
DEF_TYPE(Color);
DEF_TYPE(Tone);
@ -68,6 +69,9 @@ ATTR_INT_RW(Rect, Height)
VALUE otherObj; \
Klass *other; \
rb_get_args(argc, argv, "o", &otherObj RB_ARG_END); \
if (rgssVer >= 3) \
if (!rb_typeddata_is_kind_of(otherObj, &Klass##Type)) \
return Qfalse; \
other = getPrivateDataCheck<Klass>(otherObj, Klass##Type); \
return rb_bool_new(*p == *other); \
}
@ -79,9 +83,17 @@ EQUAL_FUN(Rect)
#define INIT_FUN(Klass, param_type, param_t_s, last_param_def) \
RB_METHOD(Klass##Initialize) \
{ \
param_type p1, p2, p3, p4 = last_param_def; \
rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
Klass *k = new Klass(p1, p2, p3, p4); \
Klass *k; \
if (argc == 0) \
{ \
k = new Klass(); \
} \
else \
{ \
param_type p1, p2, p3, p4 = last_param_def; \
rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
k = new Klass(p1, p2, p3, p4); \
} \
setPrivateData(self, k); \
return self; \
}
@ -93,10 +105,19 @@ INIT_FUN(Rect, int, "iiii", 0)
#define SET_FUN(Klass, param_type, param_t_s, last_param_def) \
RB_METHOD(Klass##Set) \
{ \
param_type p1, p2, p3, p4 = last_param_def; \
rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
Klass *k = getPrivateData<Klass>(self); \
k->set(p1, p2, p3, p4); \
if (argc == 1) \
{ \
VALUE otherObj = argv[0]; \
Klass *other = getPrivateDataCheck<Klass>(otherObj, Klass##Type); \
*k = *other; \
} \
else \
{ \
param_type p1, p2, p3, p4 = last_param_def; \
rb_get_args(argc, argv, param_t_s, &p1, &p2, &p3, &p4 RB_ARG_END); \
k->set(p1, p2, p3, p4); \
} \
return self; \
}
@ -152,7 +173,6 @@ INITCOPY_FUN(Rect)
#define INIT_BIND(Klass) \
{ \
INIT_TYPE(Klass); \
klass = rb_define_class(#Klass, rb_cObject); \
rb_define_alloc_func(klass, classAllocate<&Klass##Type>); \
rb_define_class_method(klass, "_load", Klass##Load); \
@ -161,6 +181,8 @@ INITCOPY_FUN(Rect)
_rb_define_method(klass, "initialize_copy", Klass##InitializeCopy); \
_rb_define_method(klass, "set", Klass##Set); \
_rb_define_method(klass, "==", Klass##Equal); \
_rb_define_method(klass, "===", Klass##Equal); \
_rb_define_method(klass, "eql?", Klass##Equal); \
_rb_define_method(klass, "to_s", Klass##Stringify); \
_rb_define_method(klass, "inspect", Klass##Stringify); \
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -23,17 +23,40 @@
#include "sharedstate.h"
#include "filesystem.h"
#include "util.h"
#include "ruby/encoding.h"
#include "ruby/intern.h"
DEF_TYPE(FileInt);
static void
fileIntFreeInstance(void *inst)
{
SDL_RWops *ops = static_cast<SDL_RWops*>(inst);
SDL_RWclose(ops);
SDL_FreeRW(ops);
}
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
static VALUE
fileIntForPath(const char *path)
fileIntForPath(const char *path, bool rubyExc)
{
SDL_RWops *ops = SDL_AllocRW();
shState->fileSystem().openRead(*ops, path);
try
{
shState->fileSystem().openReadRaw(*ops, path);
}
catch (const Exception &e)
{
SDL_FreeRW(ops);
if (rubyExc)
raiseRbExc(e);
else
throw e;
}
VALUE klass = rb_const_get(rb_cObject, rb_intern("FileInt"));
@ -99,28 +122,19 @@ RB_METHOD(fileIntBinmode)
return Qnil;
}
static void
fileIntFreeInstance(void *inst)
{
SDL_RWops *ops = static_cast<SDL_RWops*>(inst);
SDL_RWclose(ops);
SDL_FreeRW(ops);
}
VALUE
kernelLoadDataInt(const char *filename)
kernelLoadDataInt(const char *filename, bool rubyExc)
{
rb_gc_start();
VALUE port = fileIntForPath(filename);
VALUE port = fileIntForPath(filename, rubyExc);
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
// FIXME need to catch exceptions here with begin rescue
VALUE result = rb_funcall(marsh, rb_intern("load"), 1, port);
VALUE result = rb_funcall2(marsh, rb_intern("load"), 1, &port);
rb_funcall(port, rb_intern("close"), 0);
rb_funcall2(port, rb_intern("close"), 0, NULL);
return result;
}
@ -132,7 +146,7 @@ RB_METHOD(kernelLoadData)
const char *filename;
rb_get_args(argc, argv, "z", &filename RB_ARG_END);
return kernelLoadDataInt(filename);
return kernelLoadDataInt(filename, true);
}
RB_METHOD(kernelSaveData)
@ -144,20 +158,21 @@ RB_METHOD(kernelSaveData)
rb_get_args(argc, argv, "oS", &obj, &filename RB_ARG_END);
VALUE file = rb_funcall(rb_cFile, rb_intern("open"), 2, filename, rb_str_new_cstr("w"));
VALUE file = rb_file_open_str(filename, "wb");
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
rb_funcall(marsh, rb_intern("dump"), 2, obj, file);
VALUE v[] = { obj, file };
rb_funcall2(marsh, rb_intern("dump"), ARRAY_SIZE(v), v);
rb_funcall(file, rb_intern("close"), 0);
rb_io_close(file);
return Qnil;
}
static VALUE stringForceUTF8(VALUE arg)
{
if (rb_type(arg) == RUBY_T_STRING && ENCODING_IS_ASCII8BIT(arg))
if (RB_TYPE_P(arg, RUBY_T_STRING) && ENCODING_IS_ASCII8BIT(arg))
rb_enc_associate_index(arg, rb_utf8_encindex());
return arg;
@ -187,14 +202,13 @@ RB_METHOD(_marshalLoad)
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
return rb_funcall(marsh, rb_intern("_mkxp_load_alias"), 2, port, utf8Proc);
VALUE v[] = { port, utf8Proc };
return rb_funcall2(marsh, rb_intern("_mkxp_load_alias"), ARRAY_SIZE(v), v);
}
void
fileIntBindingInit()
{
initType(FileIntType, "FileInt", fileIntFreeInstance);
VALUE klass = rb_define_class("FileInt", rb_cIO);
rb_define_alloc_func(klass, classAllocate<&FileIntType>);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -38,7 +38,7 @@ RB_METHOD(flashableFlash)
rb_get_args(argc, argv, "oi", &colorObj, &duration RB_ARG_END);
if (rb_type(colorObj) == RUBY_T_NIL)
if (NIL_P(colorObj))
{
f->flash(0, duration);
return Qnil;

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -23,6 +23,32 @@
#include "binding-util.h"
#include "binding-types.h"
#include "exception.h"
#include "sharedstate.h"
#include <string.h>
static void
collectStrings(VALUE obj, std::vector<std::string> &out)
{
if (RB_TYPE_P(obj, RUBY_T_STRING))
{
out.push_back(RSTRING_PTR(obj));
}
else if (RB_TYPE_P(obj, RUBY_T_ARRAY))
{
for (long i = 0; i < RARRAY_LEN(obj); ++i)
{
VALUE str = rb_ary_entry(obj, i);
/* Non-string objects are tolerated (ignored) */
if (!RB_TYPE_P(str, RUBY_T_STRING))
continue;
out.push_back(RSTRING_PTR(str));
}
}
}
DEF_TYPE(Font);
@ -30,26 +56,55 @@ RB_METHOD(fontDoesExist)
{
RB_UNUSED_PARAM;
const char *name;
rb_get_args(argc, argv, "z", &name RB_ARG_END);
const char *name = 0;
VALUE nameObj;
rb_get_args(argc, argv, "o", &nameObj RB_ARG_END);
if (RB_TYPE_P(nameObj, RUBY_T_STRING))
name = rb_string_value_cstr(&nameObj);
return rb_bool_new(Font::doesExist(name));
}
RB_METHOD(FontSetName);
RB_METHOD(fontInitialize)
{
const char *name = 0;
VALUE namesObj = Qnil;
int size = 0;
rb_get_args(argc, argv, "|zi", &name, &size RB_ARG_END);
rb_get_args(argc, argv, "|oi", &namesObj, &size RB_ARG_END);
Font *f = new Font(name, size);
Font *f;
if (NIL_P(namesObj))
{
namesObj = rb_iv_get(rb_obj_class(self), "default_name");
f = new Font(0, size);
}
else
{
std::vector<std::string> names;
collectStrings(namesObj, names);
f = new Font(&names, size);
}
/* This is semantically wrong; the new Font object should take
* a dup'ed object here in case of an array. Ditto for the setters.
* However the same bug/behavior exists in all RM versions. */
rb_iv_set(self, "name", namesObj);
setPrivateData(self, f);
/* Wrap property objects */
f->setColor(new Color(*f->getColor()));
wrapProperty(self, f->getColor(), "color", ColorType);
f->initDynAttribs();
wrapProperty(self, &f->getColor(), "color", ColorType);
if (rgssVer >= 3)
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
return self;
}
@ -67,8 +122,12 @@ RB_METHOD(fontInitializeCopy)
setPrivateData(self, f);
/* Wrap property objects */
f->setColor(new Color(*f->getColor()));
wrapProperty(self, f->getColor(), "color", ColorType);
f->initDynAttribs();
wrapProperty(self, &f->getColor(), "color", ColorType);
if (rgssVer >= 3)
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
return self;
}
@ -77,30 +136,36 @@ RB_METHOD(FontGetName)
{
RB_UNUSED_PARAM;
Font *f = getPrivateData<Font>(self);
return rb_str_new_cstr(f->getName());
return rb_iv_get(self, "name");
}
RB_METHOD(FontSetName)
{
Font *f = getPrivateData<Font>(self);
VALUE name;
rb_get_args(argc, argv, "S", &name RB_ARG_END);
rb_check_argc(argc, 1);
f->setName(RSTRING_PTR(name));
std::vector<std::string> namesObj;
collectStrings(argv[0], namesObj);
return name;
f->setName(namesObj);
rb_iv_set(self, "name", argv[0]);
return argv[0];
}
#undef DEF_PROP_CHK_DISP
#define DEF_PROP_CHK_DISP
template<class C>
static void checkDisposed(VALUE) {}
DEF_PROP_OBJ_VAL(Font, Color, Color, "color")
DEF_PROP_OBJ_VAL(Font, Color, OutColor, "out_color")
DEF_PROP_I(Font, Size)
DEF_PROP_B(Font, Bold)
DEF_PROP_B(Font, Italic)
DEF_PROP_OBJ(Font, Color, Color, "color")
DEF_PROP_B(Font, Shadow)
DEF_PROP_B(Font, Outline)
#define DEF_KLASS_PROP(Klass, type, PropName, param_t_s, value_fun) \
RB_METHOD(Klass##Get##PropName) \
@ -117,25 +182,52 @@ DEF_PROP_OBJ(Font, Color, Color, "color")
return value_fun(value); \
}
DEF_KLASS_PROP(Font, int, DefaultSize, "i", rb_fix_new)
DEF_KLASS_PROP(Font, bool, DefaultBold, "b", rb_bool_new)
DEF_KLASS_PROP(Font, bool, DefaultItalic, "b", rb_bool_new)
DEF_KLASS_PROP(Font, int, DefaultSize, "i", rb_fix_new)
DEF_KLASS_PROP(Font, bool, DefaultBold, "b", rb_bool_new)
DEF_KLASS_PROP(Font, bool, DefaultItalic, "b", rb_bool_new)
DEF_KLASS_PROP(Font, bool, DefaultShadow, "b", rb_bool_new)
DEF_KLASS_PROP(Font, bool, DefaultOutline, "b", rb_bool_new)
RB_METHOD(FontGetDefaultOutColor)
{
RB_UNUSED_PARAM;
return rb_iv_get(self, "default_out_color");
}
RB_METHOD(FontSetDefaultOutColor)
{
RB_UNUSED_PARAM;
VALUE colorObj;
rb_get_args(argc, argv, "o", &colorObj RB_ARG_END);
Color *c = getPrivateDataCheck<Color>(colorObj, ColorType);
Font::setDefaultOutColor(*c);
return colorObj;
}
RB_METHOD(FontGetDefaultName)
{
RB_UNUSED_PARAM;
return rb_str_new_cstr(Font::getDefaultName());
return rb_iv_get(self, "default_name");
}
RB_METHOD(FontSetDefaultName)
{
RB_UNUSED_PARAM;
VALUE nameObj;
rb_get_args(argc, argv, "S", &nameObj RB_ARG_END);
Font::setDefaultName(RSTRING_PTR(nameObj));
rb_check_argc(argc, 1);
return nameObj;
std::vector<std::string> namesObj;
collectStrings(argv[0], namesObj);
Font::setDefaultName(namesObj, shState->fontState());
rb_iv_set(self, "default_name", argv[0]);
return argv[0];
}
RB_METHOD(FontGetDefaultColor)
@ -147,13 +239,14 @@ RB_METHOD(FontGetDefaultColor)
RB_METHOD(FontSetDefaultColor)
{
RB_UNUSED_PARAM;
VALUE colorObj;
rb_get_args(argc, argv, "o", &colorObj RB_ARG_END);
Color *c = getPrivateDataCheck<Color>(colorObj, ColorType);
Font::setDefaultColor(c);
rb_iv_set(self, "default_color", colorObj);
Font::setDefaultColor(*c);
return colorObj;
}
@ -167,13 +260,32 @@ RB_METHOD(FontSetDefaultColor)
void
fontBindingInit()
{
INIT_TYPE(Font);
VALUE klass = rb_define_class("Font", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&FontType>);
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
wrapProperty(klass, Font::getDefaultColor(), "default_color", ColorType);
Font::initDefaultDynAttribs();
wrapProperty(klass, &Font::getDefaultColor(), "default_color", ColorType);
/* Initialize default names */
const std::vector<std::string> &defNames = Font::getInitialDefaultNames();
VALUE defNamesObj;
if (defNames.size() == 1)
{
defNamesObj = rb_str_new_cstr(defNames[0].c_str());
}
else
{
defNamesObj = rb_ary_new2(defNames.size());
for (size_t i = 0; i < defNames.size(); ++i)
rb_ary_push(defNamesObj, rb_str_new_cstr(defNames[i].c_str()));
}
rb_iv_set(klass, "default_name", defNamesObj);
if (rgssVer >= 3)
wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color", ColorType);
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
@ -181,6 +293,17 @@ fontBindingInit()
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
if (rgssVer >= 2)
{
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
}
if (rgssVer >= 3)
{
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
}
rb_define_class_method(klass, "exist?", fontDoesExist);
_rb_define_method(klass, "initialize", fontInitialize);
@ -191,4 +314,15 @@ fontBindingInit()
INIT_PROP_BIND(Font, Bold, "bold");
INIT_PROP_BIND(Font, Italic, "italic");
INIT_PROP_BIND(Font, Color, "color");
if (rgssVer >= 2)
{
INIT_PROP_BIND(Font, Shadow, "shadow");
}
if (rgssVer >= 3)
{
INIT_PROP_BIND(Font, Outline, "outline");
INIT_PROP_BIND(Font, OutColor, "out_color");
}
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -22,6 +22,7 @@
#include "graphics.h"
#include "sharedstate.h"
#include "binding-util.h"
#include "binding-types.h"
#include "exception.h"
RB_METHOD(graphicsUpdate)
@ -47,7 +48,7 @@ RB_METHOD(graphicsTransition)
RB_UNUSED_PARAM;
int duration = 8;
const char *filename = 0;
const char *filename = "";
int vague = 40;
rb_get_args(argc, argv, "|izi", &duration, &filename, &vague RB_ARG_END);
@ -96,8 +97,107 @@ RB_METHOD(graphicsFrameReset)
return rb_bool_new(value); \
}
RB_METHOD(graphicsWidth)
{
RB_UNUSED_PARAM;
return rb_fix_new(shState->graphics().width());
}
RB_METHOD(graphicsHeight)
{
RB_UNUSED_PARAM;
return rb_fix_new(shState->graphics().height());
}
RB_METHOD(graphicsWait)
{
RB_UNUSED_PARAM;
int duration;
rb_get_args(argc, argv, "i", &duration RB_ARG_END);
shState->graphics().wait(duration);
return Qnil;
}
RB_METHOD(graphicsFadeout)
{
RB_UNUSED_PARAM;
int duration;
rb_get_args(argc, argv, "i", &duration RB_ARG_END);
shState->graphics().fadeout(duration);
return Qnil;
}
RB_METHOD(graphicsFadein)
{
RB_UNUSED_PARAM;
int duration;
rb_get_args(argc, argv, "i", &duration RB_ARG_END);
shState->graphics().fadein(duration);
return Qnil;
}
void bitmapInitProps(Bitmap *b, VALUE self);
RB_METHOD(graphicsSnapToBitmap)
{
RB_UNUSED_PARAM;
Bitmap *result = 0;
GUARD_EXC( result = shState->graphics().snapToBitmap(); );
VALUE obj = wrapObject(result, BitmapType);
bitmapInitProps(result, obj);
return obj;
}
RB_METHOD(graphicsResizeScreen)
{
RB_UNUSED_PARAM;
int width, height;
rb_get_args(argc, argv, "ii", &width, &height RB_ARG_END);
shState->graphics().resizeScreen(width, height);
return Qnil;
}
RB_METHOD(graphicsReset)
{
RB_UNUSED_PARAM;
shState->graphics().reset();
return Qnil;
}
RB_METHOD(graphicsPlayMovie)
{
RB_UNUSED_PARAM;
const char *filename;
rb_get_args(argc, argv, "z", &filename RB_ARG_END);
shState->graphics().playMovie(filename);
return Qnil;
}
DEF_GRA_PROP_I(FrameRate)
DEF_GRA_PROP_I(FrameCount)
DEF_GRA_PROP_I(Brightness)
DEF_GRA_PROP_B(Fullscreen)
DEF_GRA_PROP_B(ShowCursor)
@ -117,9 +217,29 @@ void graphicsBindingInit()
_rb_define_module_function(module, "transition", graphicsTransition);
_rb_define_module_function(module, "frame_reset", graphicsFrameReset);
_rb_define_module_function(module, "__reset__", graphicsReset);
INIT_GRA_PROP_BIND( FrameRate, "frame_rate" );
INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
if (rgssVer >= 2)
{
_rb_define_module_function(module, "width", graphicsWidth);
_rb_define_module_function(module, "height", graphicsHeight);
_rb_define_module_function(module, "wait", graphicsWait);
_rb_define_module_function(module, "fadeout", graphicsFadeout);
_rb_define_module_function(module, "fadein", graphicsFadein);
_rb_define_module_function(module, "snap_to_bitmap", graphicsSnapToBitmap);
_rb_define_module_function(module, "resize_screen", graphicsResizeScreen);
INIT_GRA_PROP_BIND( Brightness, "brightness" );
}
if (rgssVer >= 3)
{
_rb_define_module_function(module, "play_movie", graphicsPlayMovie);
}
INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" );
INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -23,6 +23,7 @@
#include "sharedstate.h"
#include "exception.h"
#include "binding-util.h"
#include "util.h"
RB_METHOD(inputUpdate)
{
@ -33,40 +34,56 @@ RB_METHOD(inputUpdate)
return Qnil;
}
static int getButtonArg(int argc, VALUE *argv)
{
int num;
rb_check_argc(argc, 1);
if (FIXNUM_P(argv[0]))
{
num = FIX2INT(argv[0]);
}
else if (SYMBOL_P(argv[0]) && rgssVer >= 3)
{
VALUE symHash = getRbData()->buttoncodeHash;
num = FIX2INT(rb_hash_lookup2(symHash, argv[0], INT2FIX(Input::None)));
}
else
{
// FIXME: RMXP allows only few more types that
// don't make sense (symbols in pre 3, floats)
num = 0;
}
return num;
}
RB_METHOD(inputPress)
{
RB_UNUSED_PARAM;
int num;
rb_get_args(argc, argv, "i", &num RB_ARG_END);
int num = getButtonArg(argc, argv);
Input::ButtonCode bc = (Input::ButtonCode) num;
return rb_bool_new(shState->input().isPressed(bc));
return rb_bool_new(shState->input().isPressed(num));
}
RB_METHOD(inputTrigger)
{
RB_UNUSED_PARAM;
int num;
rb_get_args(argc, argv, "i", &num RB_ARG_END);
int num = getButtonArg(argc, argv);
Input::ButtonCode bc = (Input::ButtonCode) num;
return rb_bool_new(shState->input().isTriggered(bc));
return rb_bool_new(shState->input().isTriggered(num));
}
RB_METHOD(inputRepeat)
{
RB_UNUSED_PARAM;
int num;
rb_get_args(argc, argv, "i", &num RB_ARG_END);
int num = getButtonArg(argc, argv);
Input::ButtonCode bc = (Input::ButtonCode) num;
return rb_bool_new(shState->input().isRepeated(bc));
return rb_bool_new(shState->input().isRepeated(num));
}
RB_METHOD(inputDir4)
@ -98,8 +115,44 @@ RB_METHOD(inputMouseY)
return rb_fix_new(shState->input().mouseY());
}
#define DEF_CONST_I(name, value) \
rb_const_set(module, rb_intern(name), rb_fix_new(value))
struct
{
const char *str;
Input::ButtonCode val;
}
static buttonCodes[] =
{
{ "DOWN", Input::Down },
{ "LEFT", Input::Left },
{ "RIGHT", Input::Right },
{ "UP", Input::Up },
{ "A", Input::A },
{ "B", Input::B },
{ "C", Input::C },
{ "X", Input::X },
{ "Y", Input::Y },
{ "Z", Input::Z },
{ "L", Input::L },
{ "R", Input::R },
{ "SHIFT", Input::Shift },
{ "CTRL", Input::Ctrl },
{ "ALT", Input::Alt },
{ "F5", Input::F5 },
{ "F6", Input::F6 },
{ "F7", Input::F7 },
{ "F8", Input::F8 },
{ "F9", Input::F9 },
{ "MOUSELEFT", Input::MouseLeft },
{ "MOUSEMIDDLE", Input::MouseMiddle },
{ "MOUSERIGHT", Input::MouseRight }
};
static elementsN(buttonCodes);
void
inputBindingInit()
@ -113,34 +166,35 @@ inputBindingInit()
_rb_define_module_function(module, "dir4", inputDir4);
_rb_define_module_function(module, "dir8", inputDir8);
DEF_CONST_I("DOWN", Input::Down );
DEF_CONST_I("LEFT", Input::Left );
DEF_CONST_I("RIGHT", Input::Right);
DEF_CONST_I("UP", Input::Up );
DEF_CONST_I("A", Input::A );
DEF_CONST_I("B", Input::B );
DEF_CONST_I("C", Input::C );
DEF_CONST_I("X", Input::X );
DEF_CONST_I("Y", Input::Y );
DEF_CONST_I("Z", Input::Z );
DEF_CONST_I("L", Input::L );
DEF_CONST_I("R", Input::R );
DEF_CONST_I("SHIFT", Input::Shift);
DEF_CONST_I("CTRL", Input::Ctrl );
DEF_CONST_I("ALT", Input::Alt );
DEF_CONST_I("F5", Input::F5 );
DEF_CONST_I("F6", Input::F6 );
DEF_CONST_I("F7", Input::F7 );
DEF_CONST_I("F8", Input::F8 );
DEF_CONST_I("F9", Input::F9 );
_rb_define_module_function(module, "mouse_x", inputMouseX);
_rb_define_module_function(module, "mouse_y", inputMouseY);
DEF_CONST_I("MOUSELEFT", Input::MouseLeft );
DEF_CONST_I("MOUSEMIDDLE", Input::MouseMiddle);
DEF_CONST_I("MOUSERIGHT", Input::MouseRight );
if (rgssVer >= 3)
{
VALUE symHash = rb_hash_new();
for (size_t i = 0; i < buttonCodesN; ++i)
{
ID sym = rb_intern(buttonCodes[i].str);
VALUE val = INT2FIX(buttonCodes[i].val);
/* In RGSS3 all Input::XYZ constants are equal to :XYZ symbols,
* to be compatible with the previous convention */
rb_const_set(module, sym, ID2SYM(sym));
rb_hash_aset(symHash, ID2SYM(sym), val);
}
rb_iv_set(module, "buttoncodes", symHash);
getRbData()->buttoncodeHash = symHash;
}
else
{
for (size_t i = 0; i < buttonCodesN; ++i)
{
ID sym = rb_intern(buttonCodes[i].str);
VALUE val = INT2FIX(buttonCodes[i].val);
rb_const_set(module, sym, val);
}
}
}

View File

@ -1 +1,4 @@
#include "module_rpg.rb.xxd"
# include "module_rpg1.rb.xxd"
# include "module_rpg2.rb.xxd"
# include "module_rpg3.rb.xxd"

View File

@ -1,4 +1,4 @@
extern const char module_rpg[] = {
extern const char module_rpg1[] = {
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x52, 0x50, 0x47, 0x0a, 0x20, 0x20, 0x6d, 0x6f, 0x64,
0x75, 0x6c, 0x65, 0x20, 0x43, 0x61, 0x63, 0x68, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x63,
0x61, 0x63, 0x68, 0x65, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65,
@ -2404,4 +2404,4 @@ extern const char module_rpg[] = {
0x74, 0x72, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x20, 0x3a, 0x70, 0x69, 0x74,
0x63, 0x68, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x00
};
extern const unsigned int module_rpg_len = 38461;
extern const unsigned int module_rpg1_len = 38461;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -33,21 +33,17 @@ RB_METHOD(planeInitialize)
setPrivateData(self, p);
p->setColor(new Color);
p->setTone(new Tone);
p->initDynAttribs();
wrapNilProperty(self, "bitmap");
wrapProperty(self, p->getColor(), "color", ColorType);
wrapProperty(self, p->getTone(), "tone", ToneType);
wrapProperty(self, &p->getColor(), "color", ColorType);
wrapProperty(self, &p->getTone(), "tone", ToneType);
return self;
}
#define DISP_CLASS_NAME "plane"
DEF_PROP_OBJ_NIL(Plane, Bitmap, Bitmap, "bitmap")
DEF_PROP_OBJ(Plane, Color, Color, "color")
DEF_PROP_OBJ(Plane, Tone, Tone, "tone")
DEF_PROP_OBJ_REF(Plane, Bitmap, Bitmap, "bitmap")
DEF_PROP_OBJ_VAL(Plane, Color, Color, "color")
DEF_PROP_OBJ_VAL(Plane, Tone, Tone, "tone")
DEF_PROP_I(Plane, OX)
DEF_PROP_I(Plane, OY)
@ -61,8 +57,6 @@ DEF_PROP_F(Plane, ZoomY)
void
planeBindingInit()
{
INIT_TYPE(Plane);
VALUE klass = rb_define_class("Plane", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&PlaneType>);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -20,6 +20,7 @@
*/
#include "sprite.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "flashable-binding.h"
#include "sceneelement-binding.h"
@ -36,44 +37,66 @@ RB_METHOD(spriteInitialize)
setPrivateData(self, s);
/* Wrap property objects */
s->setSrcRect(new Rect);
s->setColor(new Color);
s->setTone(new Tone);
s->initDynAttribs();
wrapNilProperty(self, "bitmap");
wrapProperty(self, s->getSrcRect(), "src_rect", RectType);
wrapProperty(self, s->getColor(), "color", ColorType);
wrapProperty(self, s->getTone(), "tone", ToneType);
wrapProperty(self, &s->getSrcRect(), "src_rect", RectType);
wrapProperty(self, &s->getColor(), "color", ColorType);
wrapProperty(self, &s->getTone(), "tone", ToneType);
return self;
}
#define DISP_CLASS_NAME "sprite"
DEF_PROP_OBJ_NIL(Sprite, Bitmap, Bitmap, "bitmap")
DEF_PROP_OBJ(Sprite, Rect, SrcRect, "src_rect")
DEF_PROP_OBJ(Sprite, Color, Color, "color")
DEF_PROP_OBJ(Sprite, Tone, Tone, "tone")
DEF_PROP_OBJ_REF(Sprite, Bitmap, Bitmap, "bitmap")
DEF_PROP_OBJ_VAL(Sprite, Rect, SrcRect, "src_rect")
DEF_PROP_OBJ_VAL(Sprite, Color, Color, "color")
DEF_PROP_OBJ_VAL(Sprite, Tone, Tone, "tone")
DEF_PROP_I(Sprite, X)
DEF_PROP_I(Sprite, Y)
DEF_PROP_I(Sprite, OX)
DEF_PROP_I(Sprite, OY)
DEF_PROP_I(Sprite, BushDepth)
DEF_PROP_I(Sprite, BushOpacity)
DEF_PROP_I(Sprite, Opacity)
DEF_PROP_I(Sprite, BlendType)
DEF_PROP_I(Sprite, WaveAmp)
DEF_PROP_I(Sprite, WaveLength)
DEF_PROP_I(Sprite, WaveSpeed)
DEF_PROP_F(Sprite, ZoomX)
DEF_PROP_F(Sprite, ZoomY)
DEF_PROP_F(Sprite, Angle)
DEF_PROP_F(Sprite, WavePhase)
DEF_PROP_B(Sprite, Mirror)
RB_METHOD(spriteWidth)
{
RB_UNUSED_PARAM;
Sprite *s = getPrivateData<Sprite>(self);
int value = 0;
GUARD_EXC( value = s->getWidth(); )
return rb_fix_new(value);
}
RB_METHOD(spriteHeight)
{
RB_UNUSED_PARAM;
Sprite *s = getPrivateData<Sprite>(self);
int value = 0;
GUARD_EXC( value = s->getHeight(); )
return rb_fix_new(value);
}
void
spriteBindingInit()
{
INIT_TYPE(Sprite);
VALUE klass = rb_define_class("Sprite", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&SpriteType>);
@ -98,4 +121,17 @@ spriteBindingInit()
INIT_PROP_BIND( Sprite, BlendType, "blend_type" );
INIT_PROP_BIND( Sprite, Color, "color" );
INIT_PROP_BIND( Sprite, Tone, "tone" );
if (rgssVer >= 2)
{
_rb_define_method(klass, "width", spriteWidth);
_rb_define_method(klass, "height", spriteHeight);
INIT_PROP_BIND( Sprite, BushOpacity, "bush_opacity" );
INIT_PROP_BIND( Sprite, WaveAmp, "wave_amp" );
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
}
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -19,18 +19,44 @@
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#include <algorithm>
#include "table.h"
#include "binding-util.h"
#include "serializable-binding.h"
static int num2TableSize(VALUE v)
{
int i = NUM2INT(v);
return std::max(0, i);
}
static void parseArgsTableSizes(int argc, VALUE *argv, int *x, int *y, int *z)
{
*y = *z = 1;
switch (argc)
{
case 3:
*z = num2TableSize(argv[2]);
/* fall through */
case 2:
*y = num2TableSize(argv[1]);
/* fall through */
case 1:
*x = num2TableSize(argv[0]);
break;
default:
rb_error_arity(argc, 1, 3);
}
}
DEF_TYPE(Table);
RB_METHOD(tableInitialize)
{
int x, y, z;
x = y = z = 1;
rb_get_args(argc, argv, "i|ii", &x, &y, &z RB_ARG_END);
parseArgsTableSizes(argc, argv, &x, &y, &z);
Table *t = new Table(x, y, z);
@ -43,24 +69,12 @@ RB_METHOD(tableResize)
{
Table *t = getPrivateData<Table>(self);
switch (argc)
{
default:
case 1:
t->resize(FIX2INT(argv[0]));
return Qnil;
int x, y, z;
parseArgsTableSizes(argc, argv, &x, &y, &z);
case 2:
t->resize(FIX2INT(argv[0]),
FIX2INT(argv[1]));
return Qnil;
t->resize(x, y, z);
case 3:
t->resize(FIX2INT(argv[0]),
FIX2INT(argv[1]),
FIX2INT(argv[2]));
return Qnil;
}
return Qnil;
}
#define TABLE_SIZE(d, D) \
@ -68,7 +82,7 @@ RB_METHOD(tableResize)
{ \
RB_UNUSED_PARAM \
Table *t = getPrivateData<Table>(self); \
return rb_int2inum(t->d##Size()); \
return INT2NUM(t->d##Size()); \
}
TABLE_SIZE(x, X)
@ -98,9 +112,9 @@ RB_METHOD(tableGetAt)
return Qnil;
}
int result = t->get(x, y, z);
short result = t->get(x, y, z);
return rb_int2inum(result);
return INT2FIX(result); /* short always fits in a Fixnum */
}
RB_METHOD(tableSetAt)
@ -117,37 +131,36 @@ RB_METHOD(tableSetAt)
{
default:
case 2 :
x = FIX2INT(argv[0]);
value = FIX2INT(argv[1]);
x = NUM2INT(argv[0]);
value = NUM2INT(argv[1]);
break;
case 3 :
x = FIX2INT(argv[0]);
y = FIX2INT(argv[1]);
value = FIX2INT(argv[2]);
x = NUM2INT(argv[0]);
y = NUM2INT(argv[1]);
value = NUM2INT(argv[2]);
break;
case 4 :
x = FIX2INT(argv[0]);
y = FIX2INT(argv[1]);
z = FIX2INT(argv[2]);
value = FIX2INT(argv[3]);
x = NUM2INT(argv[0]);
y = NUM2INT(argv[1]);
z = NUM2INT(argv[2]);
value = NUM2INT(argv[3]);
break;
}
t->set(value, x, y, z);
return rb_int2inum(value);
return argv[argc - 1];
}
MARSH_LOAD_FUN(Table)
INITCOPY_FUN(Table)
void
tableBindingInit()
{
INIT_TYPE(Table);
VALUE klass = rb_define_class("Table", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&TableType>);
@ -156,6 +169,7 @@ tableBindingInit()
rb_define_class_method(klass, "_load", TableLoad);
_rb_define_method(klass, "initialize", tableInitialize);
_rb_define_method(klass, "initialize_copy", TableInitializeCopy);
_rb_define_method(klass, "resize", tableResize);
_rb_define_method(klass, "xsize", tableXSize);
_rb_define_method(klass, "ysize", tableYSize);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -28,7 +28,7 @@
#include "binding-util.h"
#include "binding-types.h"
rb_data_type_struct TilemapAutotilesType;
DEF_TYPE_CUSTOMFREE(TilemapAutotiles, RUBY_TYPED_NEVER_FREE);
RB_METHOD(tilemapAutotilesSet)
{
@ -74,7 +74,7 @@ RB_METHOD(tilemapInitialize)
rb_get_args(argc, argv, "|o", &viewportObj RB_ARG_END);
if (rb_type(viewportObj) != RUBY_T_NIL)
if (!NIL_P(viewportObj))
viewport = getPrivateDataCheck<Viewport>(viewportObj, ViewportType);
/* Construct object */
@ -94,6 +94,10 @@ RB_METHOD(tilemapInitialize)
rb_iv_set(autotilesObj, "array", ary);
/* Circular reference so both objects are always
* alive at the same time */
rb_iv_set(autotilesObj, "tilemap", self);
return self;
}
@ -101,6 +105,8 @@ RB_METHOD(tilemapGetAutotiles)
{
RB_UNUSED_PARAM;
checkDisposed<Tilemap>(self);
return rb_iv_get(self, "autotiles");
}
@ -115,23 +121,19 @@ RB_METHOD(tilemapUpdate)
return Qnil;
}
#define DISP_CLASS_NAME "tilemap"
RB_METHOD(tilemapGetViewport)
{
RB_UNUSED_PARAM;
Tilemap *t = getPrivateData<Tilemap>(self);
checkDisposed(t, DISP_CLASS_NAME);
checkDisposed<Tilemap>(self);
return rb_iv_get(self, "viewport");
}
DEF_PROP_OBJ(Tilemap, Bitmap, Tileset, "tileset")
DEF_PROP_OBJ(Tilemap, Table, MapData, "map_data")
DEF_PROP_OBJ(Tilemap, Table, FlashData, "flash_data")
DEF_PROP_OBJ(Tilemap, Table, Priorities, "priorities")
DEF_PROP_OBJ_REF(Tilemap, Bitmap, Tileset, "tileset")
DEF_PROP_OBJ_REF(Tilemap, Table, MapData, "map_data")
DEF_PROP_OBJ_REF(Tilemap, Table, FlashData, "flash_data")
DEF_PROP_OBJ_REF(Tilemap, Table, Priorities, "priorities")
DEF_PROP_B(Tilemap, Visible)
@ -141,16 +143,12 @@ DEF_PROP_I(Tilemap, OY)
void
tilemapBindingInit()
{
initType(TilemapAutotilesType, "TilemapAutotiles", 0);
VALUE klass = rb_define_class("TilemapAutotiles", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&TilemapAutotilesType>);
_rb_define_method(klass, "[]=", tilemapAutotilesSet);
_rb_define_method(klass, "[]", tilemapAutotilesGet);
INIT_TYPE(Tilemap);
klass = rb_define_class("Tilemap", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&TilemapType>);
@ -170,4 +168,3 @@ tilemapBindingInit()
INIT_PROP_BIND( Tilemap, OX, "ox" );
INIT_PROP_BIND( Tilemap, OY, "oy" );
}

View File

@ -0,0 +1,169 @@
/*
** tilemapvx-binding.cpp
**
** This file is part of mkxp.
**
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tilemapvx.h"
#include "viewport.h"
#include "bitmap.h"
#include "table.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "binding-util.h"
#include "binding-types.h"
DEF_TYPE_CUSTOMNAME(TilemapVX, "Tilemap");
DEF_TYPE_CUSTOMFREE(BitmapArray, RUBY_TYPED_NEVER_FREE);
RB_METHOD(tilemapVXInitialize)
{
TilemapVX *t;
/* Get parameters */
VALUE viewportObj = Qnil;
Viewport *viewport = 0;
rb_get_args(argc, argv, "|o", &viewportObj RB_ARG_END);
if (!NIL_P(viewportObj))
viewport = getPrivateDataCheck<Viewport>(viewportObj, ViewportType);
/* Construct object */
t = new TilemapVX(viewport);
setPrivateData(self, t);
rb_iv_set(self, "viewport", viewportObj);
wrapProperty(self, &t->getBitmapArray(), "bitmap_array", BitmapArrayType,
rb_const_get(rb_cObject, rb_intern("Tilemap")));
VALUE autotilesObj = rb_iv_get(self, "bitmap_array");
VALUE ary = rb_ary_new2(9);
for (int i = 0; i < 9; ++i)
rb_ary_push(ary, Qnil);
rb_iv_set(autotilesObj, "array", ary);
/* Circular reference so both objects are always
* alive at the same time */
rb_iv_set(autotilesObj, "tilemap", self);
return self;
}
RB_METHOD(tilemapVXGetBitmapArray)
{
RB_UNUSED_PARAM;
checkDisposed<TilemapVX>(self);
return rb_iv_get(self, "bitmap_array");
}
RB_METHOD(tilemapVXUpdate)
{
RB_UNUSED_PARAM;
TilemapVX *t = getPrivateData<TilemapVX>(self);
t->update();
return Qnil;
}
DEF_PROP_OBJ_REF(TilemapVX, Viewport, Viewport, "viewport")
DEF_PROP_OBJ_REF(TilemapVX, Table, MapData, "map_data")
DEF_PROP_OBJ_REF(TilemapVX, Table, FlashData, "flash_data")
DEF_PROP_OBJ_REF(TilemapVX, Table, Flags, "flags")
DEF_PROP_B(TilemapVX, Visible)
DEF_PROP_I(TilemapVX, OX)
DEF_PROP_I(TilemapVX, OY)
RB_METHOD(tilemapVXBitmapsSet)
{
TilemapVX::BitmapArray *a = getPrivateData<TilemapVX::BitmapArray>(self);
int i;
VALUE bitmapObj;
rb_get_args(argc, argv, "io", &i, &bitmapObj RB_ARG_END);
Bitmap *bitmap = getPrivateDataCheck<Bitmap>(bitmapObj, BitmapType);
a->set(i, bitmap);
VALUE ary = rb_iv_get(self, "array");
rb_ary_store(ary, i, bitmapObj);
return self;
}
RB_METHOD(tilemapVXBitmapsGet)
{
int i;
rb_get_args (argc, argv, "i", &i RB_ARG_END);
if (i < 0 || i > 8)
return Qnil;
VALUE ary = rb_iv_get(self, "array");
return rb_ary_entry(ary, i);
}
void
tilemapVXBindingInit()
{
VALUE klass = rb_define_class("Tilemap", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&TilemapVXType>);
disposableBindingInit<TilemapVX>(klass);
_rb_define_method(klass, "initialize", tilemapVXInitialize);
_rb_define_method(klass, "bitmaps", tilemapVXGetBitmapArray);
_rb_define_method(klass, "update", tilemapVXUpdate);
INIT_PROP_BIND( TilemapVX, Viewport, "viewport" );
INIT_PROP_BIND( TilemapVX, MapData, "map_data" );
INIT_PROP_BIND( TilemapVX, FlashData, "flash_data" );
INIT_PROP_BIND( TilemapVX, Visible, "visible" );
INIT_PROP_BIND( TilemapVX, OX, "ox" );
INIT_PROP_BIND( TilemapVX, OY, "oy" );
if (rgssVer == 3)
{
INIT_PROP_BIND( TilemapVX, Flags, "flags" );
}
else
{
INIT_PROP_BIND( TilemapVX, Flags, "passages" );
}
klass = rb_define_class_under(klass, "BitmapArray", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&BitmapArrayType>);
_rb_define_method(klass, "[]=", tilemapVXBitmapsSet);
_rb_define_method(klass, "[]", tilemapVXBitmapsGet);
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -20,6 +20,7 @@
*/
#include "viewport.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "flashable-binding.h"
#include "sceneelement-binding.h"
@ -32,7 +33,11 @@ RB_METHOD(viewportInitialize)
{
Viewport *v;
if (argc == 1)
if (argc == 0 && rgssVer >= 3)
{
v = new Viewport();
}
else if (argc == 1)
{
/* The rect arg is only used to init the viewport,
* and does NOT replace its 'rect' property */
@ -57,22 +62,23 @@ RB_METHOD(viewportInitialize)
setPrivateData(self, v);
/* Wrap property objects */
v->setRect(new Rect(*v->getRect()));
v->setColor(new Color);
v->setTone(new Tone);
v->initDynAttribs();
wrapProperty(self, v->getRect(), "rect", RectType);
wrapProperty(self, v->getColor(), "color", ColorType);
wrapProperty(self, v->getTone(), "tone", ToneType);
wrapProperty(self, &v->getRect(), "rect", RectType);
wrapProperty(self, &v->getColor(), "color", ColorType);
wrapProperty(self, &v->getTone(), "tone", ToneType);
/* 'elements' holds all SceneElements that become children
* of this viewport, so we can dispose them when the viewport
* is disposed */
rb_iv_set(self, "elements", rb_ary_new());
return self;
}
#define DISP_CLASS_NAME "viewport"
DEF_PROP_OBJ(Viewport, Rect, Rect, "rect")
DEF_PROP_OBJ(Viewport, Color, Color, "color")
DEF_PROP_OBJ(Viewport, Tone, Tone, "tone")
DEF_PROP_OBJ_VAL(Viewport, Rect, Rect, "rect")
DEF_PROP_OBJ_VAL(Viewport, Color, Color, "color")
DEF_PROP_OBJ_VAL(Viewport, Tone, Tone, "tone")
DEF_PROP_I(Viewport, OX)
DEF_PROP_I(Viewport, OY)
@ -81,8 +87,6 @@ DEF_PROP_I(Viewport, OY)
void
viewportBindingInit()
{
INIT_TYPE(Viewport);
VALUE klass = rb_define_class("Viewport", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&ViewportType>);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -23,25 +23,23 @@
#define VIEWPORTELEMENTBINDING_H
#include "viewport.h"
#include "sharedstate.h"
#include "binding-util.h"
#include "binding-types.h"
#include "sceneelement-binding.h"
#include "disposable-binding.h"
template<class C>
RB_METHOD(viewportElementGetViewport)
{
RB_UNUSED_PARAM;
ViewportElement *ve = getPrivateData<C>(self);
GUARD_EXC( ve->aboutToAccess(); );
checkDisposed<C>(self);
return rb_iv_get(self, "viewport");
}
#ifdef RGSS2
template<class C>
RB_METHOD(viewportElementSetViewport)
{
@ -54,7 +52,7 @@ RB_METHOD(viewportElementSetViewport)
rb_get_args(argc, argv, "o", &viewportObj RB_ARG_END);
if (rb_type(viewportObj) != RUBY_T_NIL)
if (!NIL_P(viewportObj))
viewport = getPrivateDataCheck<Viewport>(viewportObj, ViewportType);
GUARD_EXC( ve->setViewport(viewport); );
@ -64,8 +62,6 @@ RB_METHOD(viewportElementSetViewport)
return viewportObj;
}
#endif
template<class C>
static C *
viewportElementInitialize(int argc, VALUE *argv, VALUE self)
@ -76,9 +72,14 @@ viewportElementInitialize(int argc, VALUE *argv, VALUE self)
rb_get_args(argc, argv, "|o", &viewportObj RB_ARG_END);
if (rb_type(viewportObj) != RUBY_T_NIL)
if (!NIL_P(viewportObj))
{
viewport = getPrivateDataCheck<Viewport>(viewportObj, ViewportType);
if (rgssVer == 1)
disposableAddChild(viewportObj, self);
}
/* Construct object */
C *ve = new C(viewport);
@ -96,9 +97,10 @@ viewportElementBindingInit(VALUE klass)
_rb_define_method(klass, "viewport", viewportElementGetViewport<C>);
#ifdef RGSS2
if (rgssVer >= 2)
{
_rb_define_method(klass, "viewport=", viewportElementSetViewport<C>);
#endif
}
}
#endif // VIEWPORTELEMENTBINDING_H

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -32,10 +32,9 @@ RB_METHOD(windowInitialize)
setPrivateData(self, w);
w->setCursorRect(new Rect);
wrapNilProperty(self, "windowskin");
wrapNilProperty(self, "contents");
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
w->initDynAttribs();
wrapProperty(self, &w->getCursorRect(), "cursor_rect", RectType);
return self;
}
@ -51,11 +50,9 @@ RB_METHOD(windowUpdate)
return Qnil;
}
#define DISP_CLASS_NAME "window"
DEF_PROP_OBJ_NIL(Window, Bitmap, Windowskin, "windowskin")
DEF_PROP_OBJ_NIL(Window, Bitmap, Contents, "contents")
DEF_PROP_OBJ(Window, Rect, CursorRect, "cursor_rect")
DEF_PROP_OBJ_REF(Window, Bitmap, Windowskin, "windowskin")
DEF_PROP_OBJ_REF(Window, Bitmap, Contents, "contents")
DEF_PROP_OBJ_VAL(Window, Rect, CursorRect, "cursor_rect")
DEF_PROP_B(Window, Stretch)
DEF_PROP_B(Window, Active)
@ -75,8 +72,6 @@ DEF_PROP_I(Window, ContentsOpacity)
void
windowBindingInit()
{
INIT_TYPE(Window);
VALUE klass = rb_define_class("Window", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&WindowType>);

View File

@ -0,0 +1,172 @@
/*
** window-binding.cpp
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#include "windowvx.h"
#include "disposable-binding.h"
#include "viewportelement-binding.h"
#include "binding-util.h"
#include "bitmap.h"
DEF_TYPE_CUSTOMNAME(WindowVX, "Window");
void bitmapInitProps(Bitmap *b, VALUE self);
RB_METHOD(windowVXInitialize)
{
WindowVX *w;
if (rgssVer >= 3)
{
int x, y, width, height;
x = y = width = height = 0;
if (argc == 4)
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
w = new WindowVX(x, y, width, height);
}
else
{
w = viewportElementInitialize<WindowVX>(argc, argv, self);
}
setPrivateData(self, w);
w->initDynAttribs();
wrapProperty(self, &w->getCursorRect(), "cursor_rect", RectType);
if (rgssVer >= 3)
wrapProperty(self, &w->getTone(), "tone", ToneType);
Bitmap *contents = new Bitmap(1, 1);
VALUE contentsObj = wrapObject(contents, BitmapType);
bitmapInitProps(contents, contentsObj);
rb_iv_set(self, "contents", contentsObj);
return self;
}
RB_METHOD(windowVXUpdate)
{
RB_UNUSED_PARAM;
WindowVX *w = getPrivateData<WindowVX>(self);
w->update();
return Qnil;
}
RB_METHOD(windowVXMove)
{
WindowVX *w = getPrivateData<WindowVX>(self);
int x, y, width, height;
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
w->move(x, y, width, height);
return Qnil;
}
RB_METHOD(windowVXIsOpen)
{
RB_UNUSED_PARAM;
WindowVX *w = getPrivateData<WindowVX>(self);
return rb_bool_new(w->isOpen());
}
RB_METHOD(windowVXIsClosed)
{
RB_UNUSED_PARAM;
WindowVX *w = getPrivateData<WindowVX>(self);
return rb_bool_new(w->isClosed());
}
DEF_PROP_OBJ_REF(WindowVX, Bitmap, Windowskin, "windowskin")
DEF_PROP_OBJ_REF(WindowVX, Bitmap, Contents, "contents")
DEF_PROP_OBJ_VAL(WindowVX, Rect, CursorRect, "cursor_rect")
DEF_PROP_OBJ_VAL(WindowVX, Tone, Tone, "tone")
DEF_PROP_I(WindowVX, X)
DEF_PROP_I(WindowVX, Y)
DEF_PROP_I(WindowVX, OX)
DEF_PROP_I(WindowVX, OY)
DEF_PROP_I(WindowVX, Width)
DEF_PROP_I(WindowVX, Height)
DEF_PROP_I(WindowVX, Padding)
DEF_PROP_I(WindowVX, PaddingBottom)
DEF_PROP_I(WindowVX, Opacity)
DEF_PROP_I(WindowVX, BackOpacity)
DEF_PROP_I(WindowVX, ContentsOpacity)
DEF_PROP_I(WindowVX, Openness)
DEF_PROP_B(WindowVX, Active)
DEF_PROP_B(WindowVX, ArrowsVisible)
DEF_PROP_B(WindowVX, Pause)
void
windowVXBindingInit()
{
VALUE klass = rb_define_class("Window", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&WindowVXType>);
disposableBindingInit <WindowVX>(klass);
viewportElementBindingInit<WindowVX>(klass);
_rb_define_method(klass, "initialize", windowVXInitialize);
_rb_define_method(klass, "update", windowVXUpdate);
INIT_PROP_BIND( WindowVX, Windowskin, "windowskin" );
INIT_PROP_BIND( WindowVX, Contents, "contents" );
INIT_PROP_BIND( WindowVX, CursorRect, "cursor_rect" );
INIT_PROP_BIND( WindowVX, Active, "active" );
INIT_PROP_BIND( WindowVX, Pause, "pause" );
INIT_PROP_BIND( WindowVX, X, "x" );
INIT_PROP_BIND( WindowVX, Y, "y" );
INIT_PROP_BIND( WindowVX, Width, "width" );
INIT_PROP_BIND( WindowVX, Height, "height" );
INIT_PROP_BIND( WindowVX, OX, "ox" );
INIT_PROP_BIND( WindowVX, OY, "oy" );
INIT_PROP_BIND( WindowVX, Opacity, "opacity" );
INIT_PROP_BIND( WindowVX, BackOpacity, "back_opacity" );
INIT_PROP_BIND( WindowVX, ContentsOpacity, "contents_opacity" );
INIT_PROP_BIND( WindowVX, Openness, "openness" );
if (rgssVer >= 3)
{
_rb_define_method(klass, "move", windowVXMove);
_rb_define_method(klass, "open?", windowVXIsOpen);
_rb_define_method(klass, "close?", windowVXIsClosed);
INIT_PROP_BIND( WindowVX, ArrowsVisible, "arrows_visible" );
INIT_PROP_BIND( WindowVX, Padding, "padding" );
INIT_PROP_BIND( WindowVX, PaddingBottom, "padding_bottom" );
INIT_PROP_BIND( WindowVX, Tone, "tone" );
}
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -51,11 +51,13 @@
static void mrbBindingExecute();
static void mrbBindingTerminate();
static void mrbBindingReset();
ScriptBinding scriptBindingImpl =
{
mrbBindingExecute,
mrbBindingTerminate
mrbBindingTerminate,
mrbBindingReset
};
ScriptBinding *scriptBinding = &scriptBindingImpl;
@ -112,8 +114,17 @@ static void mrbBindingInit(mrb_state *mrb)
/* Load RPG module */
mrb_load_irep(mrb, mrbModuleRPG);
/* Load global constants */
mrb_define_global_const(mrb, "MKXP", mrb_true_value());
mrb_value debug = rb_bool_new(shState->config().editor.debug);
if (rgssVer == 1)
mrb_define_global_const(mrb, "DEBUG", debug);
else if (rgssVer >= 2)
mrb_define_global_const(mrb, "TEST", debug);
mrb_define_global_const(mrb, "BTEST", mrb_bool_value(shState->config().editor.battleTest));
mrb_gc_arena_restore(mrb, arena);
}
@ -140,7 +151,7 @@ mkxpTimeOp(mrb_state *mrb, mrb_value)
printf("<%s> [%f ms]\n", opName, ms);
fflush(stdout);
return mrb__float_value(ms);
return mrb_float_value(mrb, ms);
}
static const char *
@ -159,7 +170,7 @@ showExcMessageBox(mrb_state *mrb, mrb_value exc)
const char *excClass = mrb_class_name(mrb, mrb_class(mrb, exc));
char msgBoxText[512];
snprintf(msgBoxText, 512, "Script '%s' line %d: %s occured.\n\n%s",
snprintf(msgBoxText, sizeof(msgBoxText), "Script '%s' line %d: %s occured.\n\n%s",
mrbValueString(file), mrb_fixnum(line), excClass, mrbValueString(mesg));
shState->eThread().showMessageBox(msgBoxText, SDL_MESSAGEBOX_ERROR);
@ -190,7 +201,7 @@ static void
runCustomScript(mrb_state *mrb, mrbc_context *ctx, const char *filename)
{
/* Execute custom script */
FILE *f = fopen(filename, "r");
FILE *f = fopen(filename, "rb");
if (!f)
{
@ -215,7 +226,7 @@ static void
runMrbFile(mrb_state *mrb, const char *filename)
{
/* Execute compiled script */
FILE *f = fopen(filename, "r");
FILE *f = fopen(filename, "rb");
if (!f)
{
@ -264,7 +275,7 @@ runRMXPScripts(mrb_state *mrb, mrbc_context *ctx)
mrb_state *scriptMrb = mrb_open();
SDL_RWops ops;
shState->fileSystem().openRead(ops, scriptPack.c_str());
shState->fileSystem().openReadRaw(ops, scriptPack.c_str());
mrb_value scriptArray = mrb_nil_value();
std::string readError;
@ -384,7 +395,7 @@ static void mrbBindingExecute()
checkException(mrb);
shState->rtData().rqTermAck = true;
shState->rtData().rqTermAck.set();
shState->texPool().disable();
mrbc_context_free(mrb, ctx);
@ -398,3 +409,8 @@ static void mrbBindingTerminate()
mrb_raise(mrb, data->exc[Shutdown], "");
}
static void mrbBindingReset()
{
// No idea how to do this with mruby yet
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -23,6 +23,8 @@
#include "util.h"
#include "exception.h"
#include <string.h>
#define SYMD(symbol) { CS##symbol, #symbol }
struct
@ -31,14 +33,15 @@ struct
const char *str;
} static const symData[] =
{
SYMD(priv_iv),
SYMD(font),
SYMD(viewport),
SYMD(bitmap),
SYMD(color),
SYMD(out_color),
SYMD(tone),
SYMD(rect),
SYMD(src_rect),
SYMD(tilemap),
SYMD(tileset),
SYMD(autotiles),
SYMD(map_data),
@ -49,7 +52,10 @@ struct
SYMD(cursor_rect),
SYMD(path),
SYMD(array),
SYMD(default_color)
SYMD(default_color),
SYMD(default_out_color),
SYMD(children),
SYMD(_mkxp_dispose_alias)
};
static elementsN(symData);
@ -63,7 +69,6 @@ struct MrbExcData
static const MrbExcData excData[] =
{
{ Shutdown, "SystemExit" },
{ RGSS, "RGSSError" },
{ PHYSFS, "PHYSFSError" },
{ SDL, "SDLError" },
{ MKXP, "MKXPError" },
@ -100,19 +105,21 @@ MrbData::MrbData(mrb_state *mrb)
{
int arena = mrb_gc_arena_save(mrb);
for (int i = 0; i < excDataN; ++i)
for (size_t i = 0; i < excDataN; ++i)
exc[excData[i].ind] = mrb_define_class(mrb, excData[i].str, mrb->eException_class);
exc[RGSS] = mrb_define_class(mrb, "RGSSError", mrb->eStandardError_class);
RClass *errnoMod = mrb_define_module(mrb, "Errno");
for (int i = 0; i < enoExcDataN; ++i)
for (size_t i = 0; i < enoExcDataN; ++i)
exc[enoExcData[i].ind] =
mrb_define_class_under(mrb, errnoMod, enoExcData[i].str, mrb->eStandardError_class);
exc[TypeError] = mrb_class_get(mrb, "TypeError");
exc[ArgumentError] = mrb_class_get(mrb, "ArgumentError");
for (int i = 0; i < symDataN; ++i)
for (size_t i = 0; i < symDataN; ++i)
symbols[symData[i].ind] = mrb_intern_cstr(mrb, symData[i].str);
mrb_gc_arena_restore(mrb, arena);
@ -141,12 +148,23 @@ void raiseMrbExc(mrb_state *mrb, const Exception &exc)
mrb_raise(mrb, excClass, exc.msg.c_str());
}
void
raiseDisposedAccess(mrb_state *mrb, mrb_value self)
{
const char *klassName = DATA_TYPE(self)->struct_name;
char buf[32];
strncpy(buf, klassName, sizeof(buf));
buf[0] = tolower(buf[0]);
mrb_raisef(mrb, getMrbData(mrb)->exc[RGSS],
"disposed %S", mrb_str_new_cstr(mrb, buf));
}
MRB_METHOD_PUB(inspectObject)
{
mrb_value priv = mrb_obj_iv_get(mrb, mrb_obj_ptr(self), getSym(mrb, CSpriv_iv));
static char buffer[64];
snprintf(buffer, sizeof(buffer), "#<%s:%p>", DATA_TYPE(priv)->struct_name, DATA_PTR(priv));
snprintf(buffer, sizeof(buffer), "#<%s:%p>", DATA_TYPE(self)->struct_name, DATA_PTR(self));
return mrb_str_new_cstr(mrb, buffer);
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -22,6 +22,8 @@
#ifndef BINDINGUTIL_H
#define BINDINGUTIL_H
#include "exception.h"
#include <mruby.h>
#include <mruby/data.h>
#include <mruby/variable.h>
@ -32,17 +34,15 @@
enum CommonSymbol
{
CSpriv_iv = 0, /* private data */
/* From here on out all symbols
* have implicit '@' prefix */
CSfont,
CSfont = 0,
CSviewport,
CSbitmap,
CScolor,
CSout_color,
CStone,
CSrect,
CSsrc_rect,
CStilemap,
CStileset,
CSautotiles,
CSmap_data,
@ -54,6 +54,9 @@ enum CommonSymbol
CSpath,
CSarray,
CSdefault_color,
CSdefault_out_color,
CSchildren,
CS_mkxp_dispose_alias,
CommonSymbolsMax
};
@ -98,6 +101,8 @@ struct MrbData
* so I can measure how much of a speed difference they make */
mrb_sym symbols[CommonSymbolsMax];
mrb_value buttoncodeHash;
MrbData(mrb_state *mrb);
};
@ -112,6 +117,15 @@ getMrbData(mrb_state *mrb)
return static_cast<MrbData*>(mrb->ud);
}
inline RClass*
defineClass(mrb_state *mrb, const char *name)
{
RClass *klass = mrb_define_class(mrb, name, mrb->object_class);
MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
return klass;
}
#define GUARD_EXC(exp) \
{ try { exp } catch (Exception &exc) { raiseMrbExc(mrb, exc); } }
@ -138,16 +152,11 @@ getMrbData(mrb_state *mrb)
#define MRB_FUN_UNUSED_PARAM { (void) mrb; }
/* If we're not binding a disposable class,
* we want to #undef DEF_PROP_CHK_DISP */
#define DEF_PROP_CHK_DISP \
checkDisposed(mrb, k, DISP_CLASS_NAME);
#define DEF_PROP_OBJ(Klass, PropKlass, PropName, prop_iv) \
/* Object property which is copied by value, not reference */
#define DEF_PROP_OBJ_VAL(Klass, PropKlass, PropName, prop_iv) \
MRB_METHOD(Klass##Get##PropName) \
{ \
Klass *k = getPrivateData<Klass>(mrb, self); (void) k; \
DEF_PROP_CHK_DISP \
checkDisposed<Klass>(mrb, self); \
return getProperty(mrb, self, prop_iv); \
} \
MRB_METHOD(Klass##Set##PropName) \
@ -157,17 +166,14 @@ getMrbData(mrb_state *mrb)
PropKlass *prop; \
mrb_get_args(mrb, "o", &propObj); \
prop = getPrivateDataCheck<PropKlass>(mrb, propObj, PropKlass##Type); \
GUARD_EXC( k->set##PropName(prop); ) \
setProperty(mrb, self, prop_iv, propObj); \
GUARD_EXC( k->set##PropName(*prop); ) \
return propObj; \
}
/* Object property with allowed NIL */
#define DEF_PROP_OBJ_NIL(Klass, PropKlass, PropName, prop_iv) \
/* Object property which is copied by reference, with allowed NIL */
#define DEF_PROP_OBJ_REF(Klass, PropKlass, PropName, prop_iv) \
MRB_METHOD(Klass##Get##PropName) \
{ \
Klass *k = getPrivateData<Klass>(mrb, self); (void) k; \
DEF_PROP_CHK_DISP \
return getProperty(mrb, self, prop_iv); \
} \
MRB_METHOD(Klass##Set##PropName) \
@ -189,8 +195,9 @@ getMrbData(mrb_state *mrb)
MRB_METHOD(Klass##Get##PropName) \
{ \
Klass *k = getPrivateData<Klass>(mrb, self); \
DEF_PROP_CHK_DISP \
return mrb_##conv_t##_value(k->get##PropName()); \
mrb_type value = 0; \
GUARD_EXC( value = k->get##PropName(); ) \
return mrb_##conv_t##_value(value); \
} \
MRB_METHOD(Klass##Set##PropName) \
{ \
@ -210,14 +217,16 @@ getMrbData(mrb_state *mrb)
#define DEF_PROP_B(Klass, PropName) \
DEF_PROP(Klass, mrb_bool, PropName, "b", bool)
#define CLONE_FUN(Klass) \
MRB_METHOD(Klass##Clone) \
#define INITCOPY_FUN(Klass) \
MRB_METHOD(Klass##InitializeCopy) \
{ \
Klass *k = getPrivateData<Klass>(mrb, self); \
mrb_value dupObj = mrb_obj_clone(mrb, self); \
Klass *dupK = new Klass(*k); \
setPrivateData(mrb, dupObj, dupK, Klass##Type); \
return dupObj; \
mrb_value origObj; \
mrb_get_args(mrb, "o", &origObj); \
Klass *orig = getPrivateData<Klass>(mrb, origObj); \
Klass *k = 0; \
GUARD_EXC( k = new Klass(*orig); ) \
setPrivateData(self, k, Klass##Type); \
return self; \
}
#define MARSH_LOAD_FUN(Klass) \
@ -235,10 +244,10 @@ getMrbData(mrb_state *mrb)
static inline mrb_value
mrb__float_value(mrb_float f)
{
mrb_value v;
mrb_value v;
MRB_SET_VALUE(v, MRB_TT_FLOAT, value.f, f);
return v;
SET_FLOAT_VALUE(0, v, f);
return v;
}
inline mrb_sym
@ -247,71 +256,47 @@ getSym(mrb_state *mrb, CommonSymbol sym)
return getMrbData(mrb)->symbols[sym];
}
template<typename T>
inline T *
getPrivateData(mrb_state *mrb, mrb_value self)
{
mrb_value priv = mrb_obj_iv_get(mrb,
mrb_obj_ptr(self),
getSym(mrb, CSpriv_iv));
void
raiseDisposedAccess(mrb_state *mrb, mrb_value self);
return static_cast<T*>(DATA_PTR(priv));
template<class C>
inline C *
getPrivateData(mrb_state *, mrb_value self)
{
C *c = static_cast<C*>(DATA_PTR(self));
return c;
}
template<typename T>
inline T *
getPrivateDataCheck(mrb_state *mrb, mrb_value obj, const mrb_data_type &type)
{
static const char mesg[] = "wrong argument type %S (expected %S)";
if (mrb_type(obj) != MRB_TT_OBJECT)
mrb_raisef(mrb, E_TYPE_ERROR, mesg,
mrb_str_new_cstr(mrb, (mrb_class_name(mrb, mrb_class(mrb, obj)))),
mrb_str_new_cstr(mrb, type.struct_name));
RObject *objP = mrb_obj_ptr(obj);
if (!mrb_obj_iv_defined(mrb, objP, getSym(mrb, CSpriv_iv)))
mrb_raisef(mrb, E_TYPE_ERROR, mesg,
mrb_str_new_cstr(mrb, (mrb_class_name(mrb, mrb_class(mrb, obj)))),
mrb_str_new_cstr(mrb, type.struct_name));
mrb_value priv = mrb_obj_iv_get(mrb, objP, getSym(mrb, CSpriv_iv));
void *p = mrb_check_datatype(mrb, priv, &type);
return static_cast<T*>(p);
void *ptr = mrb_check_datatype(mrb, obj, &type);
return static_cast<T*>(ptr);
}
inline void
setPrivateData(mrb_state *mrb, mrb_value self, void *p, const mrb_data_type &type)
setPrivateData(mrb_value self, void *p, const mrb_data_type &type)
{
RData *data =
mrb_data_object_alloc(mrb,
mrb_obj_class(mrb, self),
p,
&type);
mrb_obj_iv_set(mrb,
mrb_obj_ptr(self),
getSym(mrb, CSpriv_iv),
mrb_obj_value(data));
DATA_PTR(self) = p;
DATA_TYPE(self) = &type;
}
inline mrb_value
wrapObject(mrb_state *mrb, void *p, const mrb_data_type &type)
{
RClass *c = mrb_class_get(mrb, type.struct_name);
RObject *o = (RObject*) mrb_obj_alloc(mrb, MRB_TT_OBJECT, c);
mrb_value obj = mrb_obj_value(o);
RClass *klass = mrb_class_get(mrb, type.struct_name);
RData *data = mrb_data_object_alloc(mrb, klass, p, &type);
mrb_value obj = mrb_obj_value(data);
setPrivateData(mrb, obj, p, type);
setPrivateData(obj, p, type);
return obj;
}
inline void
inline mrb_value
wrapProperty(mrb_state *mrb, mrb_value self,
void *prop, CommonSymbol iv, const mrb_data_type &type)
{
@ -320,16 +305,9 @@ wrapProperty(mrb_state *mrb, mrb_value self,
mrb_obj_iv_set(mrb,
mrb_obj_ptr(self),
getSym(mrb, iv),
propObj);
}
propObj);
inline void
wrapNilProperty(mrb_state *mrb, mrb_value self, CommonSymbol iv)
{
mrb_obj_iv_set(mrb,
mrb_obj_ptr(self),
getSym(mrb, iv),
mrb_nil_value());
return propObj;
}
inline mrb_value
@ -378,12 +356,10 @@ objectLoad(mrb_state *mrb, mrb_value self, const mrb_data_type &type)
int data_len;
mrb_get_args(mrb, "s", &data, &data_len);
RObject *obj = (RObject*) mrb_obj_alloc(mrb, MRB_TT_OBJECT, klass);
mrb_value obj_value = mrb_obj_value(obj);
C *c = C::deserialize(data, data_len);
setPrivateData(mrb, obj_value, c, type);
RData *obj = mrb_data_object_alloc(mrb, klass, c, &type);
mrb_value obj_value = mrb_obj_value(obj);
return obj_value;
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -22,12 +22,11 @@
#include "bitmap.h"
#include "font.h"
#include "exception.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "binding-util.h"
#include "binding-types.h"
#define DISP_CLASS_NAME "bitmap"
DEF_TYPE(Bitmap);
MRB_METHOD(bitmapInitialize)
@ -49,15 +48,19 @@ MRB_METHOD(bitmapInitialize)
GUARD_EXC( b = new Bitmap(width, height); )
}
setPrivateData(mrb, self, b, BitmapType);
setPrivateData(self, b, BitmapType);
/* Wrap properties */
Font *font = new Font();
b->setFont(font);
font->setColor(new Color(*font->getColor()));
b->setInitFont(font);
font->initDynAttribs();
wrapProperty(mrb, self, font, CSfont, FontType);
wrapProperty(mrb, getProperty(mrb, self, CSfont), font->getColor(), CScolor, ColorType);
mrb_value fontProp = wrapProperty(mrb, self, font, CSfont, FontType);
wrapProperty(mrb, fontProp, &font->getColor(), CScolor, ColorType);
if (rgssVer >= 3)
wrapProperty(mrb, fontProp, &font->getOutColor(), CSout_color, ColorType);
return self;
}
@ -189,12 +192,7 @@ MRB_METHOD(bitmapGetPixel)
mrb_get_args(mrb, "ii", &x, &y);
GUARD_EXC(
if (x < 0 || y < 0 || x >= b->width() || y >= b->height())
return mrb_nil_value();
)
Vec4 value;
Color value;
GUARD_EXC( value = b->getPixel(x, y); )
Color *color = new Color(value);
@ -215,7 +213,7 @@ MRB_METHOD(bitmapSetPixel)
color = getPrivateDataCheck<Color>(mrb, colorObj, ColorType);
GUARD_EXC( b->setPixel(x, y, color->norm); )
GUARD_EXC( b->setPixel(x, y, *color); )
return mrb_nil_value();
}
@ -282,8 +280,7 @@ MRB_METHOD(bitmapTextSize)
MRB_METHOD(bitmapGetFont)
{
Bitmap *b = getPrivateData<Bitmap>(mrb, self);
checkDisposed(mrb, b, "bitmap");
checkDisposed<Bitmap>(mrb, self);
return getProperty(mrb, self, CSfont);
}
@ -299,23 +296,23 @@ MRB_METHOD(bitmapSetFont)
font = getPrivateDataCheck<Font>(mrb, fontObj, FontType);
GUARD_EXC( b->setFont(font); )
setProperty(mrb, self, CSfont, fontObj);
GUARD_EXC( b->setFont(*font); )
return mrb_nil_value();
}
CLONE_FUN(Bitmap)
INITCOPY_FUN(Bitmap)
void
bitmapBindingInit(mrb_state *mrb)
{
RClass *klass = mrb_define_class(mrb, "Bitmap", 0);
RClass *klass = defineClass(mrb, "Bitmap");
disposableBindingInit<Bitmap>(mrb, klass);
mrb_define_method(mrb, klass, "initialize", bitmapInitialize, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1));
mrb_define_method(mrb, klass, "initialize", bitmapInitialize, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1));
mrb_define_method(mrb, klass, "initialize_copy", BitmapInitializeCopy, MRB_ARGS_REQ(1));
mrb_define_method(mrb, klass, "width", bitmapWidth, MRB_ARGS_NONE());
mrb_define_method(mrb, klass, "height", bitmapHeight, MRB_ARGS_NONE());
@ -334,5 +331,4 @@ bitmapBindingInit(mrb_state *mrb)
mrb_define_method(mrb, klass, "font=", bitmapSetFont, MRB_ARGS_REQ(1));
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
mrb_define_method(mrb, klass, "clone", BitmapClone, MRB_ARGS_NONE());
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -25,12 +25,57 @@
#include "disposable.h"
#include "binding-util.h"
#include "mruby/array.h"
#include <string.h>
/* 'Children' are disposables that are disposed together
* with their parent. Currently this is only used by Viewport
* in RGSS1.
* FIXME: Disable this behavior when RGSS2 or 3 */
inline void
disposableAddChild(mrb_state *mrb, mrb_value disp, mrb_value child)
{
mrb_sym sym = getMrbData(mrb)->symbols[CSchildren];
mrb_value children = mrb_iv_get(mrb, disp, sym);
if (mrb_nil_p(children))
{
children = mrb_ary_new(mrb);
mrb_iv_set(mrb, disp, sym, children);
}
/* Assumes children are never removed until destruction */
mrb_ary_push(mrb, children, child);
}
inline void
disposableDisposeChildren(mrb_state *mrb, mrb_value disp)
{
MrbData *mrbData = getMrbData(mrb);
mrb_value children = mrb_iv_get(mrb, disp, mrbData->symbols[CSchildren]);
if (mrb_nil_p(children))
return;
for (mrb_int i = 0; i < RARRAY_LEN(children); ++i)
mrb_funcall_argv(mrb, mrb_ary_entry(children, i),
mrbData->symbols[CS_mkxp_dispose_alias], 0, 0);
}
template<class C>
MRB_METHOD(disposableDispose)
{
Disposable *d = getPrivateData<C>(mrb, self);
C *d = static_cast<C*>(DATA_PTR(self));
if (!d)
return mrb_nil_value();
if (d->isDisposed())
return mrb_nil_value();
if (rgssVer == 1)
disposableDisposeChildren(mrb, self);
d->dispose();
@ -38,9 +83,14 @@ MRB_METHOD(disposableDispose)
}
template<class C>
MRB_METHOD(disposableDisposed)
MRB_METHOD(disposableIsDisposed)
{
Disposable *d = getPrivateData<C>(mrb, self);
MRB_UNUSED_PARAM;
C *d = static_cast<C*>(DATA_PTR(self));
if (!d)
return mrb_true_value();
return mrb_bool_value(d->isDisposed());
}
@ -49,16 +99,19 @@ template<class C>
static void disposableBindingInit(mrb_state *mrb, RClass *klass)
{
mrb_define_method(mrb, klass, "dispose", disposableDispose<C>, MRB_ARGS_NONE());
mrb_define_method(mrb, klass, "disposed?", disposableDisposed<C>, MRB_ARGS_NONE());
mrb_define_method(mrb, klass, "disposed?", disposableIsDisposed<C>, MRB_ARGS_NONE());
if (rgssVer == 1)
mrb_alias_method(mrb, klass, getMrbData(mrb)->symbols[CS_mkxp_dispose_alias],
mrb_intern_lit(mrb, "dispose"));
}
inline void checkDisposed(mrb_state *mrb, Disposable *d, const char *klassName)
template<class C>
inline void
checkDisposed(mrb_state *mrb, mrb_value self)
{
MrbData *data = getMrbData(mrb);
if (d->isDisposed())
mrb_raisef(mrb, data->exc[RGSS], "disposed %S",
mrb_str_new_static(mrb, klassName, strlen(klassName)));
if (mrb_test(disposableIsDisposed<C>(0, self)))
raiseDisposedAccess(mrb, self);
}
#endif // DISPOSABLEBINDING_H

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -24,22 +24,22 @@
#include "binding-types.h"
#include "serializable-binding.h"
#define ATTR_RW(Type, attr, arg_type, mrb_val, arg_t_s) \
MRB_METHOD(Type##Get_##attr) \
#define ATTR_RW(Type, Attr, arg_type, mrb_val, arg_t_s) \
MRB_METHOD(Type##Get##Attr) \
{ \
Type *p = getPrivateData<Type>(mrb, self); \
\
return mrb_##mrb_val##_value(p->attr); \
return mrb_##mrb_val##_value(p->get##Attr()); \
} \
\
MRB_METHOD(Type##Set_##attr) \
MRB_METHOD(Type##Set##Attr) \
{ \
Type *p = getPrivateData<Type>(mrb, self); \
\
arg_type arg; \
mrb_get_args(mrb, arg_t_s, &arg); \
\
p->attr = arg; \
p->set##Attr(arg); \
UPDATE_F \
\
return mrb_##mrb_val##_value(arg); \
@ -64,22 +64,22 @@
#define ATTR_INT_RW(Type, attr) ATTR_RW(Type, attr, mrb_int, fixnum, "i")
#define UPDATE_F p->updateInternal();
ATTR_FLOAT_RW(Color, red)
ATTR_FLOAT_RW(Color, green)
ATTR_FLOAT_RW(Color, blue)
ATTR_FLOAT_RW(Color, alpha)
ATTR_FLOAT_RW(Color, Red)
ATTR_FLOAT_RW(Color, Green)
ATTR_FLOAT_RW(Color, Blue)
ATTR_FLOAT_RW(Color, Alpha)
ATTR_FLOAT_RW(Tone, red)
ATTR_FLOAT_RW(Tone, green)
ATTR_FLOAT_RW(Tone, blue)
ATTR_FLOAT_RW(Tone, gray)
ATTR_FLOAT_RW(Tone, Red)
ATTR_FLOAT_RW(Tone, Green)
ATTR_FLOAT_RW(Tone, Blue)
ATTR_FLOAT_RW(Tone, Gray)
#undef UPDATE_F
#define UPDATE_F
ATTR_INT_RW(Rect, x)
ATTR_INT_RW(Rect, y)
ATTR_INT_RW(Rect, width)
ATTR_INT_RW(Rect, height)
ATTR_INT_RW(Rect, X)
ATTR_INT_RW(Rect, Y)
ATTR_INT_RW(Rect, Width)
ATTR_INT_RW(Rect, Height)
EQUAL_FUN(Color)
EQUAL_FUN(Tone)
@ -95,7 +95,7 @@ DEF_TYPE(Rect);
param_type p1, p2, p3, p4 = last_param_def; \
mrb_get_args(mrb, param_t_s, &p1, &p2, &p3, &p4); \
Klass *k = new Klass(p1, p2, p3, p4); \
setPrivateData(mrb, self, k, Klass##Type); \
setPrivateData(self, k, Klass##Type); \
return self; \
}
@ -159,28 +159,22 @@ MARSH_LOAD_FUN(Color)
MARSH_LOAD_FUN(Tone)
MARSH_LOAD_FUN(Rect)
CLONE_FUN(Tone)
CLONE_FUN(Color)
CLONE_FUN(Rect)
INITCOPY_FUN(Tone)
INITCOPY_FUN(Color)
INITCOPY_FUN(Rect)
#define MRB_ATTR_R(Class, attr) mrb_define_method(mrb, klass, #attr, Class##Get_##attr, MRB_ARGS_NONE())
#define MRB_ATTR_W(Class, attr) mrb_define_method(mrb, klass, #attr "=", Class##Set_##attr, MRB_ARGS_REQ(1))
#define MRB_ATTR_RW(Class, attr) { MRB_ATTR_R(Class, attr); MRB_ATTR_W(Class, attr); }
#define MRB_ATTR_RW_A(Class, attr, alias) \
{ \
mrb_define_method(mrb, klass, #alias, Class##Get_##attr, MRB_ARGS_NONE()); \
mrb_define_method(mrb, klass, #alias "=", Class##Set_##attr, MRB_ARGS_REQ(1)); \
}
#define MRB_ATTR_R(Class, Attr, sym) mrb_define_method(mrb, klass, sym, Class##Get##Attr, MRB_ARGS_NONE())
#define MRB_ATTR_W(Class, Attr, sym) mrb_define_method(mrb, klass, sym "=", Class##Set##Attr, MRB_ARGS_REQ(1))
#define MRB_ATTR_RW(Class, Attr, sym) { MRB_ATTR_R(Class, Attr, sym); MRB_ATTR_W(Class, Attr, sym); }
#define INIT_BIND(Klass) \
{ \
klass = mrb_define_class(mrb, #Klass, 0); \
klass = defineClass(mrb, #Klass); \
mrb_define_class_method(mrb, klass, "_load", Klass##Load, MRB_ARGS_REQ(1)); \
serializableBindingInit<Klass>(mrb, klass); \
mrb_define_method(mrb, klass, "initialize", Klass##Initialize, MRB_ARGS_REQ(3) | MRB_ARGS_OPT(1)); \
mrb_define_method(mrb, klass, "initialize_copy", Klass##InitializeCopy, MRB_ARGS_REQ(1)); \
mrb_define_method(mrb, klass, "set", Klass##Set, MRB_ARGS_REQ(3) | MRB_ARGS_OPT(1)); \
mrb_define_method(mrb, klass, "clone", Klass##Clone, MRB_ARGS_NONE()); \
mrb_define_method(mrb, klass, "==", Klass##Equal, MRB_ARGS_REQ(1)); \
mrb_define_method(mrb, klass, "to_s", Klass##Stringify, MRB_ARGS_NONE()); \
mrb_define_method(mrb, klass, "inspect", Klass##Stringify, MRB_ARGS_NONE()); \
@ -191,21 +185,21 @@ void etcBindingInit(mrb_state *mrb)
RClass *klass;
INIT_BIND(Color);
MRB_ATTR_RW(Color, red);
MRB_ATTR_RW(Color, green);
MRB_ATTR_RW(Color, blue);
MRB_ATTR_RW(Color, alpha);
MRB_ATTR_RW(Color, Red, "red" );
MRB_ATTR_RW(Color, Green, "green");
MRB_ATTR_RW(Color, Blue, "blue" );
MRB_ATTR_RW(Color, Alpha, "alpha");
INIT_BIND(Tone);
MRB_ATTR_RW(Tone, red);
MRB_ATTR_RW(Tone, green);
MRB_ATTR_RW(Tone, blue);
MRB_ATTR_RW(Tone, gray);
MRB_ATTR_RW(Tone, Red, "red" );
MRB_ATTR_RW(Tone, Green, "green");
MRB_ATTR_RW(Tone, Blue, "blue" );
MRB_ATTR_RW(Tone, Gray, "gray" );
INIT_BIND(Rect);
MRB_ATTR_RW(Rect, x);
MRB_ATTR_RW(Rect, y);
MRB_ATTR_RW(Rect, width);
MRB_ATTR_RW(Rect, height);
MRB_ATTR_RW(Rect, X, "x" );
MRB_ATTR_RW(Rect, Y, "y" );
MRB_ATTR_RW(Rect, Width, "width" );
MRB_ATTR_RW(Rect, Height, "height");
mrb_define_method(mrb, klass, "empty", RectEmpty, MRB_ARGS_NONE());
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -20,6 +20,7 @@
*/
#include "font.h"
#include "sharedstate.h"
#include "binding-util.h"
#include "binding-types.h"
#include "exception.h"
@ -30,8 +31,13 @@ DEF_TYPE(Font);
MRB_FUNCTION(fontDoesExist)
{
const char *name;
mrb_get_args(mrb, "z", &name);
const char *name = 0;
mrb_value nameObj;
mrb_get_args(mrb, "o", &nameObj);
if (mrb_string_p(nameObj))
name = mrb_string_value_cstr(mrb, &nameObj);
return mrb_bool_value(Font::doesExist(name));
}
@ -45,11 +51,35 @@ MRB_METHOD(fontInitialize)
Font *f = new Font(name, size);
setPrivateData(mrb, self, f, FontType);
setPrivateData(self, f, FontType);
/* Wrap property objects */
f->setColor(new Color(*f->getColor()));
wrapProperty(mrb, self, f->getColor(), CScolor, ColorType);
f->initDynAttribs();
wrapProperty(mrb, self, &f->getColor(), CScolor, ColorType);
if (rgssVer >= 3)
wrapProperty(mrb, self, &f->getOutColor(), CSout_color, ColorType);
return self;
}
MRB_METHOD(fontInitializeCopy)
{
mrb_value origObj;
mrb_get_args(mrb, "o", &origObj);
Font *orig = getPrivateData<Font>(mrb, origObj);
Font *f = new Font(*orig);
setPrivateData(self, f, FontType);
/* Wrap property objects */
f->initDynAttribs();
wrapProperty(mrb, self, &f->getColor(), CScolor, ColorType);
if (rgssVer >= 3)
wrapProperty(mrb, self, &f->getOutColor(), CSout_color, ColorType);
return self;
}
@ -73,13 +103,16 @@ MRB_METHOD(FontSetName)
return name;
}
#undef DEF_PROP_CHK_DISP
#define DEF_PROP_CHK_DISP
template<class C>
static void checkDisposed(mrb_state *, mrb_value) {}
DEF_PROP_I(Font, Size)
DEF_PROP_B(Font, Bold)
DEF_PROP_B(Font, Italic)
DEF_PROP_OBJ(Font, Color, Color, CScolor)
DEF_PROP_B(Font, Outline)
DEF_PROP_B(Font, Shadow)
DEF_PROP_OBJ_VAL(Font, Color, Color, CScolor)
DEF_PROP_OBJ_VAL(Font, Color, OutColor, CSout_color)
#define DEF_KLASS_PROP(Klass, mrb_type, PropName, arg_type, conv_t) \
static mrb_value \
@ -96,9 +129,11 @@ DEF_PROP_OBJ(Font, Color, Color, CScolor)
return mrb_##conv_t##_value(value); \
}
DEF_KLASS_PROP(Font, mrb_int, DefaultSize, "i", fixnum)
DEF_KLASS_PROP(Font, mrb_bool, DefaultBold, "b", bool)
DEF_KLASS_PROP(Font, mrb_bool, DefaultItalic, "b", bool)
DEF_KLASS_PROP(Font, mrb_int, DefaultSize, "i", fixnum)
DEF_KLASS_PROP(Font, mrb_bool, DefaultBold, "b", bool)
DEF_KLASS_PROP(Font, mrb_bool, DefaultItalic, "b", bool)
DEF_KLASS_PROP(Font, mrb_bool, DefaultOutline, "b", bool)
DEF_KLASS_PROP(Font, mrb_bool, DefaultShadow, "b", bool)
MRB_FUNCTION(FontGetDefaultName)
{
@ -122,13 +157,33 @@ MRB_METHOD(FontGetDefaultColor)
MRB_METHOD(FontSetDefaultColor)
{
MRB_UNUSED_PARAM;
mrb_value colorObj;
mrb_get_args(mrb, "o", &colorObj);
Color *c = getPrivateDataCheck<Color>(mrb, colorObj, ColorType);
Font::setDefaultColor(c);
setProperty(mrb, self, CSdefault_color, colorObj);
Font::setDefaultColor(*c);
return colorObj;
}
MRB_METHOD(FontGetDefaultOutColor)
{
return getProperty(mrb, self, CSdefault_out_color);
}
MRB_METHOD(FontSetDefaultOutColor)
{
MRB_UNUSED_PARAM;
mrb_value colorObj;
mrb_get_args(mrb, "o", &colorObj);
Color *c = getPrivateDataCheck<Color>(mrb, colorObj, ColorType);
Font::setDefaultOutColor(*c);
return colorObj;
}
@ -142,26 +197,50 @@ MRB_METHOD(FontSetDefaultColor)
void
fontBindingInit(mrb_state *mrb)
{
RClass *klass = mrb_define_class(mrb, "Font", 0);
RClass *klass = defineClass(mrb, "Font");
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
wrapProperty(mrb, mrb_obj_value(klass), Font::getDefaultColor(), CSdefault_color, ColorType);
Font::initDefaultDynAttribs();
wrapProperty(mrb, mrb_obj_value(klass), &Font::getDefaultColor(), CSdefault_color, ColorType);
mrb_define_class_method(mrb, klass, "exist?", fontDoesExist, MRB_ARGS_REQ(1));
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
mrb_define_method(mrb, klass, "initialize", fontInitialize, MRB_ARGS_OPT(2));
if (rgssVer >= 2)
{
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
}
INIT_PROP_BIND(Font, Name, "name");
INIT_PROP_BIND(Font, Size, "size");
INIT_PROP_BIND(Font, Bold, "bold");
INIT_PROP_BIND(Font, Italic, "italic");
INIT_PROP_BIND(Font, Color, "color");
if (rgssVer >= 3)
{
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
wrapProperty(mrb, mrb_obj_value(klass), &Font::getDefaultOutColor(), CSdefault_out_color, ColorType);
}
mrb_define_method(mrb, klass, "initialize", fontInitialize, MRB_ARGS_OPT(2));
mrb_define_method(mrb, klass, "initialize_copy", fontInitializeCopy, MRB_ARGS_REQ(1));
INIT_PROP_BIND(Font, Name, "name");
INIT_PROP_BIND(Font, Size, "size");
INIT_PROP_BIND(Font, Bold, "bold");
INIT_PROP_BIND(Font, Italic, "italic");
INIT_PROP_BIND(Font, Color, "color");
if (rgssVer >= 2)
{
INIT_PROP_BIND(Font, Shadow, "shadow");
}
if (rgssVer >= 3)
{
INIT_PROP_BIND(Font, Outline, "outline");
INIT_PROP_BIND(Font, OutColor, "out_color");
}
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -45,7 +45,7 @@ MRB_FUNCTION(graphicsFreeze)
MRB_FUNCTION(graphicsTransition)
{
mrb_int duration = 8;
const char *filename = 0;
const char *filename = "";
mrb_int vague = 40;
mrb_get_args(mrb, "|izi", &duration, &filename, &vague);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -23,6 +23,10 @@
#include "sharedstate.h"
#include "exception.h"
#include "binding-util.h"
#include "util.h"
#include <mruby/hash.h>
#include <string.h>
MRB_FUNCTION(inputUpdate)
{
@ -33,34 +37,59 @@ MRB_FUNCTION(inputUpdate)
return mrb_nil_value();
}
MRB_FUNCTION(inputPress)
static mrb_int getButtonArg(mrb_state *mrb)
{
mrb_int num;
mrb_get_args(mrb, "i", &num);
mrb_value arg;
Input::ButtonCode bc = (Input::ButtonCode) num;
mrb_get_args(mrb, "o", &arg);
return mrb_bool_value(shState->input().isPressed(bc));
if (mrb_fixnum_p(arg))
{
num = mrb_fixnum(arg);
}
else if (mrb_symbol_p(arg) && rgssVer >= 3)
{
mrb_value symHash = getMrbData(mrb)->buttoncodeHash;
mrb_value numVal = mrb_hash_fetch(mrb, symHash, arg,
mrb_fixnum_value(Input::None));
num = mrb_fixnum(numVal);
}
else
{
// FIXME: RMXP allows only few more types that
// don't make sense (symbols in pre 3, floats)
num = 0;
}
return num;
}
MRB_FUNCTION(inputTrigger)
MRB_METHOD(inputPress)
{
mrb_int num;
mrb_get_args(mrb, "i", &num);
MRB_UNUSED_PARAM;
Input::ButtonCode bc = (Input::ButtonCode) num;
mrb_int num = getButtonArg(mrb);
return mrb_bool_value(shState->input().isTriggered(bc));
return mrb_bool_value(shState->input().isPressed(num));
}
MRB_FUNCTION(inputRepeat)
MRB_METHOD(inputTrigger)
{
mrb_int num;
mrb_get_args(mrb, "i", &num);
MRB_UNUSED_PARAM;
Input::ButtonCode bc = (Input::ButtonCode) num;
mrb_int num = getButtonArg(mrb);
return mrb_bool_value(shState->input().isRepeated(bc));
return mrb_bool_value(shState->input().isTriggered(num));
}
MRB_METHOD(inputRepeat)
{
MRB_UNUSED_PARAM;
mrb_int num = getButtonArg(mrb);
return mrb_bool_value(shState->input().isRepeated(num));
}
MRB_FUNCTION(inputDir4)
@ -92,8 +121,43 @@ MRB_FUNCTION(inputMouseY)
return mrb_fixnum_value(shState->input().mouseY());
}
#define DEF_CONST_I(name, value) \
mrb_const_set(mrb, mrb_obj_value(module), mrb_intern_lit(mrb, name), mrb_fixnum_value(value))
struct
{
const char *str;
Input::ButtonCode val;
}
static buttonCodes[] =
{
{ "DOWN", Input::Down },
{ "LEFT", Input::Left },
{ "RIGHT", Input::Right },
{ "UP", Input::Up },
{ "A", Input::A },
{ "B", Input::B },
{ "C", Input::C },
{ "X", Input::X },
{ "Y", Input::Y },
{ "Z", Input::Z },
{ "L", Input::L },
{ "R", Input::R },
{ "SHIFT", Input::Shift },
{ "CTRL", Input::Ctrl },
{ "ALT", Input::Alt },
{ "F5", Input::F5 },
{ "F6", Input::F6 },
{ "F7", Input::F7 },
{ "F8", Input::F8 },
{ "F9", Input::F9 },
{ "MOUSELEFT", Input::MouseLeft },
{ "MOUSEMIDDLE", Input::MouseMiddle },
{ "MOUSERIGHT", Input::MouseRight }
};
static elementsN(buttonCodes);
void
inputBindingInit(mrb_state *mrb)
@ -107,34 +171,40 @@ inputBindingInit(mrb_state *mrb)
mrb_define_module_function(mrb, module, "dir4", inputDir4, MRB_ARGS_NONE());
mrb_define_module_function(mrb, module, "dir8", inputDir8, MRB_ARGS_NONE());
DEF_CONST_I("DOWN", Input::Down );
DEF_CONST_I("LEFT", Input::Left );
DEF_CONST_I("RIGHT", Input::Right);
DEF_CONST_I("UP", Input::Up );
DEF_CONST_I("A", Input::A );
DEF_CONST_I("B", Input::B );
DEF_CONST_I("C", Input::C );
DEF_CONST_I("X", Input::X );
DEF_CONST_I("Y", Input::Y );
DEF_CONST_I("Z", Input::Z );
DEF_CONST_I("L", Input::L );
DEF_CONST_I("R", Input::R );
DEF_CONST_I("SHIFT", Input::Shift);
DEF_CONST_I("CTRL", Input::Ctrl );
DEF_CONST_I("ALT", Input::Alt );
DEF_CONST_I("F5", Input::F5 );
DEF_CONST_I("F6", Input::F6 );
DEF_CONST_I("F7", Input::F7 );
DEF_CONST_I("F8", Input::F8 );
DEF_CONST_I("F9", Input::F9 );
mrb_define_module_function(mrb, module, "mouse_x", inputMouseX, MRB_ARGS_NONE());
mrb_define_module_function(mrb, module, "mouse_y", inputMouseY, MRB_ARGS_NONE());
DEF_CONST_I("MOUSELEFT", Input::MouseLeft );
DEF_CONST_I("MOUSEMIDDLE", Input::MouseMiddle);
DEF_CONST_I("MOUSERIGHT", Input::MouseRight );
mrb_value modVal = mrb_obj_value(module);
if (rgssVer >= 3)
{
mrb_value symHash = mrb_hash_new_capa(mrb, buttonCodesN);
for (size_t i = 0; i < buttonCodesN; ++i)
{
const char *str = buttonCodes[i].str;
mrb_sym sym = mrb_intern_static(mrb, str, strlen(str));
mrb_value symVal = mrb_symbol_value(sym);
mrb_value val = mrb_fixnum_value(buttonCodes[i].val);
/* In RGSS3 all Input::XYZ constants are equal to :XYZ symbols,
* to be compatible with the previous convention */
mrb_const_set(mrb, modVal, sym, symVal);
mrb_hash_set(mrb, symHash, symVal, val);
}
mrb_iv_set(mrb, modVal, mrb_intern_lit(mrb, "buttoncodes"), symHash);
getMrbData(mrb)->buttoncodeHash = symHash;
}
else
{
for (size_t i = 0; i < buttonCodesN; ++i)
{
const char *str = buttonCodes[i].str;
mrb_sym sym = mrb_intern_static(mrb, str, strlen(str));
mrb_value val = mrb_fixnum_value(buttonCodes[i].val);
mrb_const_set(mrb, modVal, sym, val);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -227,7 +227,7 @@ MRB_FUNCTION(fileExpandPath)
if (defDir)
Debug() << "FIXME: File.expand_path: default_dir not implemented";
char buffer[512];
char buffer[PATH_MAX];
char *unused = realpath(path, buffer);
(void) unused;
@ -321,7 +321,7 @@ readLine(FILE *f, std::vector<char> &buffer)
if (feof(f))
break;
char c = fgetc(f);
int c = fgetc(f);
if (c == '\n' || c == EOF)
break;
@ -568,7 +568,7 @@ fileBindingInit(mrb_state *mrb)
{
mrb_define_method(mrb, mrb->kernel_module, "open", fileOpen, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1) | MRB_ARGS_BLOCK());
RClass *klass = mrb_define_class(mrb, "IO", 0);
RClass *klass = defineClass(mrb, "IO");
klass = mrb_define_class(mrb, "File", klass);
mrb_define_class_method(mrb, klass, "basename", fileBasename, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(1));

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -114,7 +114,7 @@ struct LinkBuffer
return hash.contains(value);
}
bool containsIdx(int idx)
bool containsIdx(size_t idx)
{
if (vec.empty())
return false;
@ -132,7 +132,7 @@ struct LinkBuffer
return idx;
}
T lookup(int idx)
T lookup(size_t idx)
{
return vec[idx];
}
@ -153,9 +153,9 @@ struct MarshalContext
LinkBuffer<mrb_sym> symbols;
LinkBuffer<mrb_value> objects;
char readByte()
int8_t readByte()
{
char byte;
int8_t byte;
int result = SDL_RWread(ops, &byte, 1, 1);
if (result < 1)
@ -172,7 +172,7 @@ struct MarshalContext
throw Exception(Exception::ArgumentError, "dump format error");
}
void writeByte(char byte)
void writeByte(int8_t byte)
{
int result = SDL_RWwrite(ops, &byte, 1, 1);
@ -193,7 +193,7 @@ struct MarshalContext
static int
read_fixnum(MarshalContext *ctx)
{
char head = ctx->readByte();
int8_t head = ctx->readByte();
if (head == 0)
return 0;
@ -202,10 +202,10 @@ read_fixnum(MarshalContext *ctx)
else if (head < -4)
return head + 5;
int pos = (head > 0);
int len = pos ? head : head * -1;
int8_t pos = (head > 0);
int8_t len = pos ? head : head * -1;
char n1, n2, n3, n4;
int8_t n1, n2, n3, n4;
if (pos)
n2 = n3 = n4 = 0;
@ -259,21 +259,13 @@ read_string_value(MarshalContext *ctx)
mrb_state *mrb = ctx->mrb;
int len = read_fixnum(ctx);
struct RString *str =
(struct RString*) mrb_obj_alloc
(mrb, MRB_TT_STRING, mrb->string_class);
mrb_value str = mrb_str_new(mrb, 0, len);
char *ptr = RSTR_PTR(RSTRING(str));
str->c = mrb->string_class;
str->len = len;
str->aux.capa = len;
str->ptr = (char*) mrb_malloc(mrb, len+1);
ctx->readData(ptr, len);
ptr[len] = '\0';
ctx->readData(str->ptr, len);
str->ptr[len] = '\0';
mrb_value str_obj = mrb_obj_value(str);
return str_obj;
return str;
}
static mrb_value read_value(MarshalContext *ctx);
@ -479,7 +471,7 @@ static mrb_value
read_value(MarshalContext *ctx)
{
mrb_state *mrb = ctx->mrb;
char type = ctx->readByte();
int8_t type = ctx->readByte();
mrb_value value;
if (mrb->arena_idx > maxArena)
maxArena = mrb->arena_idx;
@ -567,16 +559,16 @@ write_fixnum(MarshalContext *ctx, int value)
}
else if (value > 0 && value < 123)
{
ctx->writeByte((char) value + 5);
ctx->writeByte((int8_t) value + 5);
return;
}
else if (value < 0 && value > -124)
{
ctx->writeByte((char) value - 5);
ctx->writeByte((int8_t) value - 5);
return;
}
char len;
int8_t len;
if (value > 0)
{
@ -724,7 +716,7 @@ write_symbol(MarshalContext *ctx, mrb_value symbol)
{
mrb_state *mrb = ctx->mrb;
mrb_sym sym = mrb_symbol(symbol);
size_t len;
mrb_int len;
const char *p = mrb_sym2name_len(mrb, sym, &len);
write_string(ctx, p);
@ -883,8 +875,8 @@ writeMarshalHeader(MarshalContext *ctx)
static void
verifyMarshalHeader(MarshalContext *ctx)
{
char maj = ctx->readByte();
char min = ctx->readByte();
int8_t maj = ctx->readByte();
int8_t min = ctx->readByte();
if (maj != MARSHAL_MAJOR || min != MARSHAL_MINOR)
throw Exception(Exception::TypeError, "incompatible marshal file format (can't be read)");

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -20,6 +20,7 @@
*/
#include "rwmem.h"
#include "util.h"
#include <SDL_rwops.h>
@ -101,7 +102,7 @@ int RWMemGetData(SDL_RWops *ops, void *buffer)
ByteVec *v = getRWPrivate(ops);
if (buffer)
memcpy(buffer, &(*v)[0], v->size());
memcpy(buffer, dataPtr(*v), v->size());
return v->size();
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -197,8 +197,8 @@ TIME_ATTR(wday)
void
timeBindingInit(mrb_state *mrb)
{
RClass *klass = mrb_define_class(mrb, "Time", 0);
mrb_include_module(mrb, klass, mrb_class_get(mrb, "Comparable"));
RClass *klass = defineClass(mrb, "Time");
mrb_include_module(mrb, klass, mrb_module_get(mrb, "Comparable"));
mrb_define_class_method(mrb, klass, "now", timeNow, MRB_ARGS_NONE());
mrb_define_class_method(mrb, klass, "at", timeAt, MRB_ARGS_REQ(1));

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -31,23 +31,19 @@ MRB_METHOD(planeInitialize)
{
Plane *p = viewportElementInitialize<Plane>(mrb, self);
setPrivateData(mrb, self, p, PlaneType);
setPrivateData(self, p, PlaneType);
p->setColor(new Color);
p->setTone(new Tone);
p->initDynAttribs();
wrapNilProperty(mrb, self, CSbitmap);
wrapProperty(mrb, self, p->getColor(), CScolor, ColorType);
wrapProperty(mrb, self, p->getTone(), CStone, ToneType);
wrapProperty(mrb, self, &p->getColor(), CScolor, ColorType);
wrapProperty(mrb, self, &p->getTone(), CStone, ToneType);
return self;
}
#define DISP_CLASS_NAME "plane"
DEF_PROP_OBJ(Plane, Bitmap, Bitmap, CSbitmap)
DEF_PROP_OBJ(Plane, Color, Color, CScolor)
DEF_PROP_OBJ(Plane, Tone, Tone, CStone)
DEF_PROP_OBJ_REF(Plane, Bitmap, Bitmap, CSbitmap)
DEF_PROP_OBJ_VAL(Plane, Color, Color, CScolor)
DEF_PROP_OBJ_VAL(Plane, Tone, Tone, CStone)
DEF_PROP_I(Plane, OX)
DEF_PROP_I(Plane, OY)
@ -61,7 +57,7 @@ DEF_PROP_F(Plane, ZoomY)
void
planeBindingInit(mrb_state *mrb)
{
RClass *klass = mrb_define_class(mrb, "Plane", 0);
RClass *klass = defineClass(mrb, "Plane");
disposableBindingInit<Plane> (mrb, klass);
viewportElementBindingInit<Plane>(mrb, klass);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -20,6 +20,7 @@
*/
#include "sprite.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "flashable-binding.h"
#include "sceneelement-binding.h"
@ -32,27 +33,22 @@ MRB_METHOD(spriteInitialize)
{
Sprite *s = viewportElementInitialize<Sprite>(mrb, self);
setPrivateData(mrb, self, s, SpriteType);
setPrivateData(self, s, SpriteType);
/* Wrap property objects */
s->setSrcRect(new Rect);
s->setColor(new Color);
s->setTone(new Tone);
s->initDynAttribs();
wrapNilProperty(mrb, self, CSbitmap);
wrapProperty(mrb, self, s->getSrcRect(), CSsrc_rect, RectType);
wrapProperty(mrb, self, s->getColor(), CScolor, ColorType);
wrapProperty(mrb, self, s->getTone(), CStone, ToneType);
wrapProperty(mrb, self, &s->getSrcRect(), CSsrc_rect, RectType);
wrapProperty(mrb, self, &s->getColor(), CScolor, ColorType);
wrapProperty(mrb, self, &s->getTone(), CStone, ToneType);
return self;
}
#define DISP_CLASS_NAME "sprite"
DEF_PROP_OBJ_NIL(Sprite, Bitmap, Bitmap, CSbitmap)
DEF_PROP_OBJ(Sprite, Rect, SrcRect, CSsrc_rect)
DEF_PROP_OBJ(Sprite, Color, Color, CScolor)
DEF_PROP_OBJ(Sprite, Tone, Tone, CStone)
DEF_PROP_OBJ_REF(Sprite, Bitmap, Bitmap, CSbitmap)
DEF_PROP_OBJ_VAL(Sprite, Rect, SrcRect, CSsrc_rect)
DEF_PROP_OBJ_VAL(Sprite, Color, Color, CScolor)
DEF_PROP_OBJ_VAL(Sprite, Tone, Tone, CStone)
DEF_PROP_I(Sprite, X)
DEF_PROP_I(Sprite, Y)
@ -61,17 +57,41 @@ DEF_PROP_I(Sprite, OY)
DEF_PROP_I(Sprite, BushDepth)
DEF_PROP_I(Sprite, Opacity)
DEF_PROP_I(Sprite, BlendType)
DEF_PROP_I(Sprite, WaveAmp)
DEF_PROP_I(Sprite, WaveLength)
DEF_PROP_I(Sprite, WaveSpeed)
DEF_PROP_F(Sprite, ZoomX)
DEF_PROP_F(Sprite, ZoomY)
DEF_PROP_F(Sprite, Angle)
DEF_PROP_F(Sprite, WavePhase)
DEF_PROP_B(Sprite, Mirror)
MRB_METHOD(spriteWidth)
{
Sprite *s = getPrivateData<Sprite>(mrb, self);
int value = 0;
GUARD_EXC( value = s->getWidth(); )
return mrb_fixnum_value(value);
}
MRB_METHOD(spriteHeight)
{
Sprite *s = getPrivateData<Sprite>(mrb, self);
int value = 0;
GUARD_EXC( value = s->getHeight(); )
return mrb_fixnum_value(value);
}
void
spriteBindingInit(mrb_state *mrb)
{
RClass *klass = mrb_define_class(mrb, "Sprite", 0);
RClass *klass = defineClass(mrb, "Sprite");
disposableBindingInit <Sprite>(mrb, klass);
flashableBindingInit <Sprite>(mrb, klass);
@ -95,5 +115,16 @@ spriteBindingInit(mrb_state *mrb)
INIT_PROP_BIND( Sprite, Color, "color" );
INIT_PROP_BIND( Sprite, Tone, "tone" );
if (rgssVer >= 2)
{
mrb_define_method(mrb, klass, "width", spriteWidth, MRB_ARGS_NONE());
mrb_define_method(mrb, klass, "height", spriteHeight, MRB_ARGS_NONE());
INIT_PROP_BIND( Sprite, WaveAmp, "wave_amp" );
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
}
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -35,7 +35,7 @@ MRB_METHOD(tableInitialize)
Table *t = new Table(x, y, z);
setPrivateData(mrb, self, t, TableType);
setPrivateData(self, t, TableType);
return self;
}
@ -141,16 +141,19 @@ MRB_METHOD(tableSetAt)
}
MARSH_LOAD_FUN(Table)
INITCOPY_FUN(Table)
void
tableBindingInit(mrb_state *mrb)
{
RClass *klass = mrb_define_class(mrb, "Table", 0);
RClass *klass = defineClass(mrb, "Table");
mrb_define_class_method(mrb, klass, "_load", TableLoad, MRB_ARGS_REQ(1));
serializableBindingInit<Table>(mrb, klass);
mrb_define_method(mrb, klass, "initialize", tableInitialize, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(2));
mrb_define_method(mrb, klass, "initialize", tableInitialize, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(2));
mrb_define_method(mrb, klass, "initialize_copy", TableInitializeCopy, MRB_ARGS_REQ(1));
mrb_define_method(mrb, klass, "resize", tableResize, MRB_ARGS_REQ(1) | MRB_ARGS_OPT(2));
mrb_define_method(mrb, klass, "xsize", tableXSize, MRB_ARGS_NONE() );
mrb_define_method(mrb, klass, "ysize", tableYSize, MRB_ARGS_NONE() );

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -87,25 +87,32 @@ MRB_METHOD(tilemapInitialize)
/* Construct object */
t = new Tilemap(viewport);
setPrivateData(mrb, self, t, TilemapType);
setPrivateData(self, t, TilemapType);
setProperty(mrb, self, CSviewport, viewportObj);
wrapProperty(mrb, self, &t->getAutotiles(), CSautotiles, TilemapAutotilesType);
mrb_value autotilesObj = mrb_iv_get(mrb, self, getMrbData(mrb)->symbols[CSautotiles]);
MrbData &mrbData = *getMrbData(mrb);
mrb_value autotilesObj = mrb_iv_get(mrb, self, mrbData.symbols[CSautotiles]);
mrb_value ary = mrb_ary_new_capa(mrb, 7);
for (int i = 0; i < 7; ++i)
mrb_ary_push(mrb, ary, mrb_nil_value());
mrb_iv_set(mrb, autotilesObj, getMrbData(mrb)->symbols[CSarray], ary);
mrb_iv_set(mrb, autotilesObj, mrbData.symbols[CSarray], ary);
/* Circular reference so both objects are always
* alive at the same time */
mrb_iv_set(mrb, autotilesObj, mrbData.symbols[CStilemap], self);
return self;
}
MRB_METHOD(tilemapGetAutotiles)
{
checkDisposed<Tilemap>(mrb, self);
return getProperty(mrb, self, CSautotiles);
}
@ -118,21 +125,17 @@ MRB_METHOD(tilemapUpdate)
return mrb_nil_value();
}
#define DISP_CLASS_NAME "tilemap"
MRB_METHOD(tilemapGetViewport)
{
Tilemap *t = getPrivateData<Tilemap>(mrb, self);
checkDisposed(mrb, t, DISP_CLASS_NAME);
checkDisposed<Tilemap>(mrb, self);
return getProperty(mrb, self, CSviewport);
}
DEF_PROP_OBJ(Tilemap, Bitmap, Tileset, CStileset)
DEF_PROP_OBJ(Tilemap, Table, MapData, CSmap_data)
DEF_PROP_OBJ(Tilemap, Table, FlashData, CSflash_data)
DEF_PROP_OBJ(Tilemap, Table, Priorities, CSpriorities)
DEF_PROP_OBJ_REF(Tilemap, Bitmap, Tileset, CStileset)
DEF_PROP_OBJ_REF(Tilemap, Table, MapData, CSmap_data)
DEF_PROP_OBJ_REF(Tilemap, Table, FlashData, CSflash_data)
DEF_PROP_OBJ_REF(Tilemap, Table, Priorities, CSpriorities)
DEF_PROP_B(Tilemap, Visible)
@ -142,13 +145,13 @@ DEF_PROP_I(Tilemap, OY)
void
tilemapBindingInit(mrb_state *mrb)
{
RClass *klass = mrb_define_class(mrb, "TilemapAutotiles", 0);
RClass *klass = defineClass(mrb, "TilemapAutotiles");
mrb_define_method(mrb, klass, "[]=", tilemapAutotilesSet, MRB_ARGS_REQ(2));
mrb_define_method(mrb, klass, "[]", tilemapAutotilesGet, MRB_ARGS_REQ(1));
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
klass = mrb_define_class(mrb, "Tilemap", 0);
klass = defineClass(mrb, "Tilemap");
disposableBindingInit<Tilemap>(mrb, klass);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -54,25 +54,21 @@ MRB_METHOD(viewportInitialize)
v = new Viewport(x, y, width, height);
}
setPrivateData(mrb, self, v, ViewportType);
setPrivateData(self, v, ViewportType);
/* Wrap property objects */
v->setRect(new Rect(*v->getRect()));
v->setColor(new Color);
v->setTone(new Tone);
v->initDynAttribs();
wrapProperty(mrb, self, v->getRect(), CSrect, RectType);
wrapProperty(mrb, self, v->getColor(), CScolor, ColorType);
wrapProperty(mrb, self, v->getTone(), CStone, ToneType);
wrapProperty(mrb, self, &v->getRect(), CSrect, RectType);
wrapProperty(mrb, self, &v->getColor(), CScolor, ColorType);
wrapProperty(mrb, self, &v->getTone(), CStone, ToneType);
return self;
}
#define DISP_CLASS_NAME "viewport"
DEF_PROP_OBJ(Viewport, Rect, Rect, CSrect)
DEF_PROP_OBJ(Viewport, Color, Color, CScolor)
DEF_PROP_OBJ(Viewport, Tone, Tone, CStone)
DEF_PROP_OBJ_VAL(Viewport, Rect, Rect, CSrect)
DEF_PROP_OBJ_VAL(Viewport, Color, Color, CScolor)
DEF_PROP_OBJ_VAL(Viewport, Tone, Tone, CStone)
DEF_PROP_I(Viewport, OX)
DEF_PROP_I(Viewport, OY)
@ -81,7 +77,7 @@ DEF_PROP_I(Viewport, OY)
void
viewportBindingInit(mrb_state *mrb)
{
RClass *klass = mrb_define_class(mrb, "Viewport", 0);
RClass *klass = defineClass(mrb, "Viewport");
disposableBindingInit <Viewport>(mrb, klass);
flashableBindingInit <Viewport>(mrb, klass);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -27,13 +27,12 @@
#include "binding-types.h"
#include "sceneelement-binding.h"
#include "disposable-binding.h"
template<class C>
MRB_METHOD(viewportElementGetViewport)
{
ViewportElement *ve = getPrivateData<C>(mrb, self);
GUARD_EXC( ve->aboutToAccess(); )
checkDisposed<C>(mrb, self);
return getProperty(mrb, self, CSviewport);
}
@ -49,8 +48,13 @@ viewportElementInitialize(mrb_state *mrb, mrb_value self)
mrb_get_args(mrb, "|o", &viewportObj);
if (!mrb_nil_p(viewportObj))
{
viewport = getPrivateDataCheck<Viewport>(mrb, viewportObj, ViewportType);
if (rgssVer == 1)
disposableAddChild(mrb, viewportObj, self);
}
/* Construct object */
C *ve = new C(viewport);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -30,12 +30,10 @@ MRB_METHOD(windowInitialize)
{
Window *w = viewportElementInitialize<Window>(mrb, self);
setPrivateData(mrb, self, w, WindowType);
setPrivateData(self, w, WindowType);
w->setCursorRect(new Rect);
wrapNilProperty(mrb, self, CSwindowskin);
wrapNilProperty(mrb, self, CScontents);
wrapProperty(mrb, self, w->getCursorRect(), CScursor_rect, RectType);
w->initDynAttribs();
wrapProperty(mrb, self, &w->getCursorRect(), CScursor_rect, RectType);
return self;
}
@ -49,11 +47,9 @@ MRB_METHOD(windowUpdate)
return mrb_nil_value();
}
#define DISP_CLASS_NAME "window"
DEF_PROP_OBJ_NIL(Window, Bitmap, Windowskin, CSwindowskin)
DEF_PROP_OBJ_NIL(Window, Bitmap, Contents, CScontents)
DEF_PROP_OBJ(Window, Rect, CursorRect, CScursor_rect)
DEF_PROP_OBJ_REF(Window, Bitmap, Windowskin, CSwindowskin)
DEF_PROP_OBJ_REF(Window, Bitmap, Contents, CScontents)
DEF_PROP_OBJ_VAL(Window, Rect, CursorRect, CScursor_rect)
DEF_PROP_B(Window, Stretch)
DEF_PROP_B(Window, Active)
@ -73,7 +69,7 @@ DEF_PROP_I(Window, ContentsOpacity)
void
windowBindingInit(mrb_state *mrb)
{
RClass *klass = mrb_define_class(mrb, "Window", 0);
RClass *klass = defineClass(mrb, "Window");
disposableBindingInit <Window>(mrb, klass);
viewportElementBindingInit<Window>(mrb, klass);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -27,7 +27,7 @@
static void nullBindingExecute()
{
Debug() << "The null binding doesn't do anything, so we're done!";
shState->rtData().rqTermAck = true;
shState->rtData().rqTermAck.set();
}
static void nullBindingTerminate()
@ -35,10 +35,16 @@ static void nullBindingTerminate()
}
static void nullBindingReset()
{
}
ScriptBinding scriptBindingImpl =
{
nullBindingExecute,
nullBindingTerminate
nullBindingTerminate,
nullBindingReset
};
ScriptBinding *scriptBinding = &scriptBindingImpl;

View File

@ -1,13 +1,304 @@
# This is a comment
debugMode=false
winResizable=false
fullscreen=false
fixedAspectRatio=true
smoothScaling=false
vsync=false
defScreenW=640
defScreenH=480
solidFonts=false
gameFolder=.
customScript=
RTPs=
# Lines starting with '#' are comments.
#
# About filesystem paths specified in this config:
# The "gameFolder" path is resolved either relative
# to the directory containing the mkxp executable
# (the default behavior), or relative to the current
# working directory (when compiled with
# -DWORKDIR_CURRENT). All other paths are resolved
# relative to gameFolder and ignoring both RTPs and
# encrypted archives.
# Specify the RGSS version to run under.
# Possible values are 0, 1, 2, 3. If set to 0,
# mkxp will try to guess the required version
# based on the game files found in gameFolder.
# If this fails, the version defaults to 1.
# (default: 0)
#
# rgssVersion=1
# Create a debug context and log
# OpenGL debug information to the console
# (default: disabled)
#
# debugMode=false
# Continuously print average FPS to console.
# This setting does not affect the window title
# FPS display toggled via F2
# (default: disabled)
#
# printFPS=false
# Game window is resizable
# (default: disabled)
#
# winResizable=false
# Start game in fullscreen (this can
# always be toggled with Alt-Enter at runtime)
# (default: disabled)
#
# fullscreen=false
# Preserve game screen aspect ratio,
# as opposed to stretch-to-fill
# (default: enabled)
#
# fixedAspectRatio=true
# Apply linear interpolation when game screen
# is upscaled
# (default: enabled)
#
# smoothScaling=true
# Sync screen redraws to the monitor refresh rate
# (default: disabled)
#
# vsync=false
# Specify the window width on startup. If set to 0,
# it will default to the default resolution width
# specific to the RGSS version (640 in RGSS1, 544
# in RGSS2 or higher).
# (default: 0)
#
# defScreenW=640
# Specify the window height on startup. If set to 0,
# it will default to the default resolution height
# specific to the RGSS version (480 in RGSS1, 416
# in RGSS2 or higher).
# (default: 0)
#
# defScreenH=480
# Override the game window title
# (default: none)
#
# windowTitle=Custom Title
# Enforce a static frame rate
# (0 = disabled)
#
# fixedFramerate=0
# Skip (don't draw) frames when behind
# (default: enabled)
#
# frameSkip=true
# Use a fixed framerate that is approx. equal to the
# native screen refresh rate. This is different from
# "fixedFramerate" because the actual frame rate is
# reported back to the game, ensuring correct timers.
# If the screen refresh rate cannot be determined,
# this option is force-disabled
# (default: disabled)
#
# syncToRefreshrate=false
# Don't use alpha blending when rendering text
# (default: disabled)
#
# solidFonts=false
# Work around buggy graphics drivers which don't
# properly synchronize texture access, most
# apparent when text doesn't show up or the map
# tileset doesn't render at all
# (default: disabled)
#
# subImageFix=false
# Enable framebuffer blitting if the driver is
# capable of it. Some drivers carry buggy
# implementations of this functionality, so
# disabling it can be used as a workaround
# (default: enabled)
#
# enableBlitting=true
# Limit the maximum size (width, height) of
# most textures mkxp will create (exceptions are
# rendering backbuffers and similar).
# If set to 0, the hardware maximum is used.
# This is useful for recording traces that can
# be played back on machines with lower specs.
# (default: 0)
#
# maxTextureSize=0
# Set the base path of the game to '/path/to/game'
# (default: executable directory)
#
# gameFolder=/path/to/game
# Use either right or left Alt + Enter to toggle
# fullscreen
# (default: disabled)
#
# anyAltToggleFS=false
# Enable F12 game reset
# (default: enabled)
#
# enableReset=true
# Allow symlinks for game assets to be followed
# (default: disabled)
#
# allowSymlinks=false
# Organisation / company and application / game
# name to build the directory path where mkxp
# will store game specific data (eg. key bindings).
# If not specified, mkxp will save to a common
# directory shared by all games. Note that these
# are TWO individual config entries, and both need
# to be defined for this to take effect.
# (default: none)
#
# dataPathOrg=mycompany
# dataPathApp=mygame
# Set the game window icon to 'path/to/icon.png'
# (default: none)
#
# iconPath=/path/to/icon.png
# Instead of playing an RPG Maker game,
# execute a single plain text script instead
# (default: none)
#
# customScript=/path/to/script.rb
# Define raw scripts to be executed before the
# actual Scripts.rxdata execution starts
# (default: none)
#
# preloadScript=my_win32_wrapper.rb
# preloadScript=ruby18_fixes.rb
# Index all accesible assets via their lower case path
# (emulates windows case insensitivity)
# (default: enabled)
#
# pathCache=true
# Add 'rtp1', 'rtp2.zip' and 'game.rgssad' to the
# asset search path (multiple allowed)
# (default: none)
#
# RTP=/path/to/rtp1
# RTP=/path/to/rtp2.zip
# RTP=/path/to/game.rgssad
# Use the script's name as filename in warnings and error messages
# (default: disabled)
#
# useScriptNames=false
# Font substitutions allow drop-in replacements of fonts
# to be used without changing the RGSS scripts,
# eg. providing 'Open Sans' when the game thinkgs it's
# using 'Arial'. Font family to be substituted and
# replacement family are separated by one sole '>'.
# Be careful not to include any spaces.
# This is not connected to the built-in font, which is
# always used when a non-existing font family is
# requested by RGSS.
# (default: none)
#
# fontSub=Arial>Open Sans
# fontSub=Times New Roman>Liberation Serif
# Because mkxp is usually distributed as a stand alone
# build, no predefined load paths are initialized
# ($:, $LOAD_PATH) in the MRI backend. With this option,
# they can be specified manually (eg. when using a system
# libruby.so). It is however recommended to statically
# link all required gems into libruby.so.
# (default: none)
#
# rubyLoadpath=/usr/lib64/ruby/
# rubyLoadpath=/usr/local/share/ruby/site_ruby
# SoundFont to use for midi playback (via fluidsynth)
# (default: none)
#
# midi.soundFont=/usr/share/mysoundfont.sf2
# Activate "chorus" effect for midi playback
#
# midi.chorus=false
# Activate "reverb" effect for midi playback
#
# midi.reverb=false
# Number of OpenAL sources to allocate for SE playback.
# If there are a lot of sounds playing at the same time
# and audibly cutting each other off, try increasing
# this number. Maximum: 64.
#
# SE.sourceCount=6
# The Windows game executable name minus ".exe". By default
# this is "Game", but some developers manually rename it.
# mkxp needs this name because both the .ini (game
# configuration) and .rgssad (encrypted data archive) must
# carry the same name minus their extension, and we cannot
# guess the executable's name.
# You could just as well rename them both to "Game.ini" and
# "Game.rgssad", but specifying the executable name here
# is a tiny bit less intrusive.
#
# execName=Game
# Give a hint on which language the game title as
# specified in the Game.ini is, useful if the encoding
# is being falsely detected. Relevant only if mkxp was
# built with automatic encoding conversion (INI_ENCODING).
# (default: none)
#
# titleLanguage=japanese

106
mkxp.pro
View File

@ -5,10 +5,13 @@ QT =
TARGET = mkxp
DEPENDPATH += src shader assets
INCLUDEPATH += . src
LIBS += -lGL
CONFIG(release, debug|release): DEFINES += NDEBUG
CONFIG += c++11
# And for older qmake versions..
QMAKE_CXXFLAGS += -std=c++11
isEmpty(BINDING) {
BINDING = MRI
}
@ -40,17 +43,17 @@ contains(BINDING, NULL) {
CONFIG += BINDING_NULL
}
RGSS2 {
DEFINES += RGSS2
}
unix {
CONFIG += link_pkgconfig
PKGCONFIG += sigc++-2.0 glew pixman-1 zlib physfs \
PKGCONFIG += sigc++-2.0 pixman-1 zlib physfs vorbisfile \
sdl2 SDL2_image SDL2_ttf SDL_sound openal
RGSS2 {
PKGCONFIG += vorbisfile
SHARED_FLUID {
PKGCONFIG += fluidsynth
}
INI_ENCODING {
PKGCONFIG += libguess
}
# Deal with boost paths...
@ -70,7 +73,11 @@ unix {
LIBS += -L$$BOOST_L
}
LIBS += -lboost_program_options
isEmpty(BOOST_LIB_SUFFIX) {
BOOST_LIB_SUFFIX = $$(BOOST_LIB_SUFFIX)
}
LIBS += -lboost_program_options$$BOOST_LIB_SUFFIX
}
# Input
@ -86,6 +93,7 @@ HEADERS += \
src/flashable.h \
src/font.h \
src/input.h \
src/iniconfig.h \
src/plane.h \
src/scene.h \
src/sprite.h \
@ -100,8 +108,9 @@ HEADERS += \
src/glstate.h \
src/quad.h \
src/tilemap.h \
src/tilemap-common.h \
src/graphics.h \
src/debuglogger.h \
src/gl-debug.h \
src/global-ibo.h \
src/exception.h \
src/filesystem.h \
@ -111,12 +120,27 @@ HEADERS += \
src/gl-util.h \
src/util.h \
src/config.h \
src/settingsmenu.h \
src/keybindings.h \
src/tileatlas.h \
src/perftimer.h \
src/sharedstate.h \
src/al-util.h \
src/boost-hash.h \
src/debugwriter.h
src/debugwriter.h \
src/gl-fun.h \
src/gl-meta.h \
src/vertex.h \
src/soundemitter.h \
src/aldatasource.h \
src/alstream.h \
src/audiostream.h \
src/rgssad.h \
src/windowvx.h \
src/tilemapvx.h \
src/tileatlasvx.h \
src/sharedmidistate.h \
src/fluid-fun.h \
src/sdl-util.h
SOURCES += \
src/main.cpp \
@ -126,6 +150,7 @@ SOURCES += \
src/filesystem.cpp \
src/font.cpp \
src/input.cpp \
src/iniconfig.cpp \
src/plane.cpp \
src/scene.cpp \
src/sprite.cpp \
@ -139,35 +164,64 @@ SOURCES += \
src/tilemap.cpp \
src/autotiles.cpp \
src/graphics.cpp \
src/debuglogger.cpp \
src/gl-debug.cpp \
src/etc.cpp \
src/config.cpp \
src/settingsmenu.cpp \
src/keybindings.cpp \
src/tileatlas.cpp \
src/perftimer.cpp \
src/sharedstate.cpp
src/sharedstate.cpp \
src/gl-fun.cpp \
src/gl-meta.cpp \
src/vertex.cpp \
src/soundemitter.cpp \
src/sdlsoundsource.cpp \
src/alstream.cpp \
src/audiostream.cpp \
src/rgssad.cpp \
src/bundledfont.cpp \
src/vorbissource.cpp \
src/windowvx.cpp \
src/tilemapvx.cpp \
src/tileatlasvx.cpp \
src/autotilesvx.cpp \
src/midisource.cpp \
src/fluid-fun.cpp
EMBED = \
shader/common.h \
shader/transSimple.frag \
shader/trans.frag \
shader/hue.frag \
shader/sprite.frag \
shader/plane.frag \
shader/gray.frag \
shader/bitmapBlit.frag \
shader/flatColor.frag \
shader/simple.frag \
shader/simpleColor.frag \
shader/simpleAlpha.frag \
shader/simpleAlphaUni.frag \
shader/flashMap.frag \
shader/minimal.vert \
shader/simple.vert \
shader/simpleColor.vert \
shader/sprite.vert \
assets/liberation.ttf
RGSS2 {
EMBED += \
shader/tilemap.vert \
shader/blur.frag \
shader/blurH.vert \
shader/blurV.vert \
shader/simpleMatrix.vert
shader/simpleMatrix.vert \
shader/tilemapvx.vert \
assets/liberation.ttf \
assets/icon.png
SHARED_FLUID {
DEFINES += SHARED_FLUID
}
INI_ENCODING {
DEFINES += INI_ENCODING
}
defineReplace(xxdOutput) {
@ -230,7 +284,11 @@ BINDING_MRUBY {
}
BINDING_MRI {
PKGCONFIG += ruby-2.1
isEmpty(MRIVERSION) {
MRIVERSION = 2.1
}
PKGCONFIG += ruby-$$MRIVERSION
DEFINES += BINDING_MRI
# EMBED2 = binding-mri/module_rpg.rb
@ -266,5 +324,9 @@ BINDING_MRI {
binding-mri/tilemap-binding.cpp \
binding-mri/audio-binding.cpp \
binding-mri/module_rpg.cpp \
binding-mri/filesystem-binding.cpp
binding-mri/filesystem-binding.cpp \
binding-mri/windowvx-binding.cpp \
binding-mri/tilemapvx-binding.cpp
}
OTHER_FILES += $$EMBED

View File

@ -1,54 +0,0 @@
diff -r 719dade41745 Makefile.am
--- a/Makefile.am Wed Aug 15 23:52:18 2012 -0400
+++ b/Makefile.am Thu Nov 28 18:42:40 2013 +0100
@@ -1,8 +1,8 @@
lib_LTLIBRARIES = libSDL_sound.la
-SUBDIRS = decoders . playsound
+SUBDIRS = decoders .
-libSDL_soundincludedir = $(includedir)/SDL
+libSDL_soundincludedir = $(includedir)/SDL2
libSDL_soundinclude_HEADERS = \
SDL_sound.h
@@ -49,3 +49,5 @@
echo >> $(distdir)/docs/README
rm -rf `find $(distdir) -type d -name ".svn"`
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = SDL_sound.pc
diff -r 719dade41745 SDL_sound.pc.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SDL_sound.pc.in Thu Nov 28 18:42:40 2013 +0100
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: SDL_sound
+Description: audio decoding library for Simple DirectMedia Layer
+Version: @VERSION@
+Requires: sdl2 >= @SDL_VERSION@
+Libs: -L${libdir} -lSDL_sound
+Cflags: -I${includedir}/SDL2
diff -r 719dade41745 configure.in
--- a/configure.in Wed Aug 15 23:52:18 2012 -0400
+++ b/configure.in Thu Nov 28 18:42:40 2013 +0100
@@ -107,7 +107,8 @@
dnl ---------------------------------------------------------------------
dnl Check for SDL
-SDL_VERSION=1.2.0
+SDL_VERSION=2.0.0
+AC_SUBST(SDL_VERSION)
AM_PATH_SDL($SDL_VERSION,
:,
AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
@@ -339,4 +340,5 @@
decoders/timidity/Makefile
decoders/libmpg123/Makefile
playsound/Makefile
+SDL_sound.pc
])

View File

@ -0,0 +1,43 @@
--- a/common.mk
+++ b/common.mk
@@ -95,6 +95,7 @@ COMMONOBJS = array.$(OBJEXT) \
vm_trace.$(OBJEXT) \
thread.$(OBJEXT) \
cont.$(OBJEXT) \
+ ext/zlib/zlib.$(OBJEXT) \
$(BUILTIN_ENCOBJS) \
$(BUILTIN_TRANSOBJS) \
$(MISSING)
diff --git a/ruby-2.1.5.orig/configure b/ruby-2.1.5/configure
index d0f1f68..45ab642 100755
--- a/configure
+++ b/configure
@@ -2838,6 +2838,8 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+LIBS="$LIBS -lz"
+
{ # environment section
--- a/configure.in
+++ b/configure.in
@@ -31,6 +31,8 @@ rm() {
}
])])])
+LIBS="$LIBS -lz"
+
{ # environment section
AC_ARG_WITH(baseruby,
--- a/inits.c
+++ b/inits.c
@@ -61,5 +61,6 @@ rb_call_inits(void)
CALL(Complex);
CALL(version);
CALL(vm_trace);
+ CALL(zlib);
}
#undef CALL

View File

@ -6,7 +6,7 @@ uniform sampler2D destination;
uniform vec4 subRect;
uniform float opacity;
uniform lowp float opacity;
varying vec2 v_texCoord;
@ -20,18 +20,14 @@ void main()
vec4 resFrag;
float ab = opacity;
float as = srcFrag.a;
float ad = dstFrag.a;
float co1 = srcFrag.a * opacity;
float co2 = dstFrag.a * (1.0 - co1);
resFrag.a = co1 + co2;
float at = ab*as;
resFrag.a = at + ad - ad*at;
// Sigh...
if (ad == 0.0)
if (resFrag.a == 0.0)
resFrag.rgb = srcFrag.rgb;
else
resFrag.rgb = as*srcFrag.rgb + (1.0-at) * ad * dstFrag.rgb;
resFrag.rgb = (co1*srcFrag.rgb + co2*dstFrag.rgb) / resFrag.a;
gl_FragColor = resFrag;
}

View File

@ -6,7 +6,7 @@ varying vec2 v_blurCoord[2];
void main()
{
vec4 frag = vec4(0, 0, 0, 0);
lowp vec4 frag = vec4(0, 0, 0, 0);
frag += texture2D(texture, v_texCoord);
frag += texture2D(texture, v_blurCoord[0]);

15
shader/common.h Normal file
View File

@ -0,0 +1,15 @@
#ifdef GLSLES
#ifdef FRAGMENT_SHADER
/* Only the fragment shader has no default float precision */
precision mediump float;
#endif
#else
/* Desktop GLSL doesn't know about these */
#define highp
#define mediump
#define lowp
#endif

View File

@ -1,7 +1,7 @@
uniform float alpha;
uniform lowp float alpha;
varying vec4 v_color;
varying lowp vec4 v_color;
void main()
{

7
shader/flatColor.frag Normal file
View File

@ -0,0 +1,7 @@
uniform lowp vec4 color;
void main()
{
gl_FragColor = color;
}

19
shader/gray.frag Normal file
View File

@ -0,0 +1,19 @@
uniform sampler2D texture;
uniform lowp float gray;
varying vec2 v_texCoord;
const vec3 lumaF = vec3(.299, .587, .114);
void main()
{
/* Sample source color */
vec4 frag = texture2D(texture, v_texCoord);
/* Apply gray */
float luma = dot(frag.rgb, lumaF);
frag.rgb = mix(frag.rgb, vec3(luma), gray);
gl_FragColor = frag;
}

View File

@ -1,44 +1,40 @@
uniform sampler2D inputTexture;
uniform float hueAdjust;
uniform sampler2D texture;
uniform mediump float hueAdjust;
varying vec2 v_texCoord;
/* Source: gamedev.stackexchange.com/a/59808/24839 */
vec3 rgb2hsv(vec3 c)
{
const vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
/* Avoid divide-by-zero situations by adding a very tiny delta.
* Since we always deal with underlying 8-Bit color values, this
* should never mask a real value */
const float eps = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + eps)), d / (q.x + eps), q.x);
}
vec3 hsv2rgb(vec3 c)
{
const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main ()
{
const vec4 kRGBToYPrime = vec4 (0.299, 0.587, 0.114, 0.0);
const vec4 kRGBToI = vec4 (0.596, -0.275, -0.321, 0.0);
const vec4 kRGBToQ = vec4 (0.212, -0.523, 0.311, 0.0);
vec4 color = texture2D (texture, v_texCoord.xy);
vec3 hsv = rgb2hsv(color.rgb);
const vec4 kYIQToR = vec4 (1.0, 0.956, 0.621, 0.0);
const vec4 kYIQToG = vec4 (1.0, -0.272, -0.647, 0.0);
const vec4 kYIQToB = vec4 (1.0, -1.107, 1.704, 0.0);
hsv.x += hueAdjust;
color.rgb = hsv2rgb(hsv);
/* Sample the input pixel */
vec4 color = texture2D (inputTexture, v_texCoord.xy);
/* Convert to YIQ */
float YPrime = dot (color, kRGBToYPrime);
float I = dot (color, kRGBToI);
float Q = dot (color, kRGBToQ);
/* Calculate the hue and chroma */
float hue = atan (Q, I);
float chroma = sqrt (I * I + Q * Q);
/* Make the user's adjustments */
hue += hueAdjust;
// Convert back to YIQ
Q = chroma * sin (hue);
I = chroma * cos (hue);
/* Convert back to RGB */
vec4 yIQ = vec4 (YPrime, I, Q, 0.0);
color.r = dot (yIQ, kYIQToR);
color.g = dot (yIQ, kYIQToG);
color.b = dot (yIQ, kYIQToB);
/* Save the result */
gl_FragColor = color;
}

8
shader/minimal.vert Normal file
View File

@ -0,0 +1,8 @@
uniform mat4 projMat;
attribute vec2 position;
void main()
{
gl_Position = projMat * vec4(position, 0, 1);
}

View File

@ -1,11 +1,11 @@
uniform sampler2D texture;
uniform vec4 tone;
uniform lowp vec4 tone;
uniform float opacity;
uniform vec4 color;
uniform vec4 flash;
uniform lowp float opacity;
uniform lowp vec4 color;
uniform lowp vec4 flash;
varying vec2 v_texCoord;

View File

@ -2,7 +2,7 @@
uniform sampler2D texture;
varying vec2 v_texCoord;
varying vec4 v_color;
varying lowp vec4 v_color;
void main()
{

View File

@ -0,0 +1,11 @@
uniform sampler2D texture;
uniform lowp float alpha;
varying vec2 v_texCoord;
void main()
{
gl_FragColor = texture2D(texture, v_texCoord);
gl_FragColor.a *= alpha;
}

View File

@ -1,5 +1,5 @@
varying vec4 v_color;
varying lowp vec4 v_color;
void main()
{

View File

@ -6,10 +6,10 @@ uniform vec2 translation;
attribute vec2 position;
attribute vec2 texCoord;
attribute vec4 color;
attribute lowp vec4 color;
varying vec2 v_texCoord;
varying vec4 v_color;
varying lowp vec4 v_color;
void main()
{

View File

@ -6,10 +6,10 @@ uniform vec2 texSizeInv;
attribute vec2 position;
attribute vec2 texCoord;
attribute vec4 color;
attribute lowp vec4 color;
varying vec2 v_texCoord;
varying vec4 v_color;
varying lowp vec4 v_color;
void main()
{

View File

@ -1,13 +1,13 @@
uniform sampler2D texture;
uniform vec4 tone;
uniform lowp vec4 tone;
uniform float opacity;
uniform vec4 color;
uniform lowp float opacity;
uniform lowp vec4 color;
uniform float bushDepth;
uniform float bushOpacity;
uniform lowp float bushOpacity;
varying vec2 v_texCoord;
@ -32,7 +32,7 @@ void main()
frag.rgb = mix(frag.rgb, color.rgb, color.a);
/* Apply bush alpha by mathematical if */
float underBush = float(v_texCoord.y < bushDepth);
lowp float underBush = float(v_texCoord.y < bushDepth);
frag.a *= clamp(bushOpacity + underBush, 0.0, 1.0);
gl_FragColor = frag;

28
shader/tilemap.vert Normal file
View File

@ -0,0 +1,28 @@
uniform mat4 projMat;
uniform vec2 texSizeInv;
uniform vec2 translation;
uniform float aniIndex;
attribute vec2 position;
attribute vec2 texCoord;
varying vec2 v_texCoord;
const float atAreaW = 96.0;
const float atAreaH = 128.0*7.0;
const float atAniOffset = 32.0*3.0;
void main()
{
vec2 tex = texCoord;
lowp float pred = float(tex.x <= atAreaW && tex.y <= atAreaH);
tex.x += aniIndex * atAniOffset * pred;
gl_Position = projMat * vec4(position + translation, 0, 1);
v_texCoord = tex * texSizeInv;
}

34
shader/tilemapvx.vert Normal file
View File

@ -0,0 +1,34 @@
uniform mat4 projMat;
uniform vec2 texSizeInv;
uniform vec2 translation;
uniform vec2 aniOffset;
attribute vec2 position;
attribute vec2 texCoord;
varying vec2 v_texCoord;
const vec2 atAreaA = vec2(9.0*32.0, 12.0*32.0);
const float atAreaCX = 12.0*32.0;
const float atAreaCW = 4.0*32.0;
void main()
{
vec2 tex = texCoord;
lowp float pred;
/* Type A autotiles shift horizontally */
pred = float(tex.x <= atAreaA.x && tex.y <= atAreaA.y);
tex.x += aniOffset.x * pred;
/* Type C autotiles shift vertically */
pred = float(tex.x >= atAreaCX && tex.x <= (atAreaCX+atAreaCW) && tex.y <= atAreaA.y);
tex.y += aniOffset.y * pred;
gl_Position = projMat * vec4(position + translation, 0, 1);
v_texCoord = tex * texSizeInv;
}

View File

@ -14,7 +14,7 @@ void main()
{
float transV = texture2D(transMap, v_texCoord).r;
float cTransV = clamp(transV, prog, prog+vague);
float alpha = (cTransV - prog) / vague;
lowp float alpha = (cTransV - prog) / vague;
vec4 newFrag = texture2D(currentScene, v_texCoord);
vec4 oldFrag = texture2D(frozenScene, v_texCoord);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -23,7 +23,8 @@
#define ALUTIL_H
#include <al.h>
#include <alext.h>
#include <SDL_audio.h>
#include <assert.h>
namespace AL
{
@ -132,6 +133,11 @@ namespace Source
return buffer;
}
inline void clearQueue(Source::ID id)
{
attachBuffer(id, Buffer::ID(0));
}
inline ALint getInteger(Source::ID id, ALenum prop)
{
ALint value;
@ -186,4 +192,52 @@ namespace Source
}
inline uint8_t formatSampleSize(int sdlFormat)
{
switch (sdlFormat)
{
case AUDIO_U8 :
case AUDIO_S8 :
return 1;
case AUDIO_U16LSB :
case AUDIO_U16MSB :
case AUDIO_S16LSB :
case AUDIO_S16MSB :
return 2;
default :
assert(!"Unhandled sample format");
}
return 0;
}
inline ALenum chooseALFormat(int sampleSize, int channelCount)
{
switch (sampleSize)
{
case 1 :
switch (channelCount)
{
case 1 : return AL_FORMAT_MONO8;
case 2 : return AL_FORMAT_STEREO8;
}
case 2 :
switch (channelCount)
{
case 1 : return AL_FORMAT_MONO16;
case 2 : return AL_FORMAT_STEREO16;
}
default :
assert(!"Unhandled sample size / channel count");
}
return 0;
}
#define AUDIO_SLEEP 10
#define STREAM_BUF_SIZE 32768
#define GLOBAL_VOLUME 0.8f
#endif // ALUTIL_H

67
src/aldatasource.h Normal file
View File

@ -0,0 +1,67 @@
/*
** aldatasource.h
**
** This file is part of mkxp.
**
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ALDATASOURCE_H
#define ALDATASOURCE_H
#include "al-util.h"
struct ALDataSource
{
enum Status
{
NoError,
EndOfStream,
WrapAround,
Error
};
virtual ~ALDataSource() {}
/* Read/process next chunk of data, and attach it
* to provided AL buffer */
virtual Status fillBuffer(AL::Buffer::ID alBuffer) = 0;
virtual int sampleRate() = 0;
/* If the source doesn't support seeking, it will
* reset back to the beginning */
virtual void seekToOffset(float seconds) = 0;
/* The frame count right after wrap around */
virtual uint32_t loopStartFrames() = 0;
/* Returns false if not supported */
virtual bool setPitch(float value) = 0;
};
ALDataSource *createSDLSource(SDL_RWops &ops,
const char *extension,
uint32_t maxBufSize,
bool looped);
ALDataSource *createVorbisSource(SDL_RWops &ops,
bool looped);
ALDataSource *createMidiSource(SDL_RWops &ops,
bool looped);
#endif // ALDATASOURCE_H

479
src/alstream.cpp Normal file
View File

@ -0,0 +1,479 @@
/*
** alstream.cpp
**
** This file is part of mkxp.
**
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#include "alstream.h"
#include "sharedstate.h"
#include "sharedmidistate.h"
#include "eventthread.h"
#include "filesystem.h"
#include "exception.h"
#include "aldatasource.h"
#include "fluid-fun.h"
#include "sdl-util.h"
#include "debugwriter.h"
#include <SDL_mutex.h>
#include <SDL_thread.h>
#include <SDL_timer.h>
ALStream::ALStream(LoopMode loopMode,
const std::string &threadId)
: looped(loopMode == Looped),
state(Closed),
source(0),
thread(0),
preemptPause(false),
pitch(1.0f)
{
alSrc = AL::Source::gen();
AL::Source::setVolume(alSrc, 1.0f);
AL::Source::setPitch(alSrc, 1.0f);
AL::Source::detachBuffer(alSrc);
for (int i = 0; i < STREAM_BUFS; ++i)
alBuf[i] = AL::Buffer::gen();
pauseMut = SDL_CreateMutex();
threadName = std::string("al_stream (") + threadId + ")";
}
ALStream::~ALStream()
{
close();
AL::Source::clearQueue(alSrc);
AL::Source::del(alSrc);
for (int i = 0; i < STREAM_BUFS; ++i)
AL::Buffer::del(alBuf[i]);
SDL_DestroyMutex(pauseMut);
}
void ALStream::close()
{
checkStopped();
switch (state)
{
case Playing:
case Paused:
stopStream();
case Stopped:
closeSource();
state = Closed;
case Closed:
return;
}
}
void ALStream::open(const std::string &filename)
{
checkStopped();
switch (state)
{
case Playing:
case Paused:
stopStream();
case Stopped:
closeSource();
case Closed:
openSource(filename);
}
state = Stopped;
}
void ALStream::stop()
{
checkStopped();
switch (state)
{
case Closed:
case Stopped:
return;
case Playing:
case Paused:
stopStream();
}
state = Stopped;
}
void ALStream::play(float offset)
{
if (!source)
return;
checkStopped();
switch (state)
{
case Closed:
case Playing:
return;
case Stopped:
startStream(offset);
break;
case Paused :
resumeStream();
}
state = Playing;
}
void ALStream::pause()
{
checkStopped();
switch (state)
{
case Closed:
case Stopped:
case Paused:
return;
case Playing:
pauseStream();
}
state = Paused;
}
void ALStream::setVolume(float value)
{
AL::Source::setVolume(alSrc, value);
}
void ALStream::setPitch(float value)
{
/* If the source supports setting pitch natively,
* we don't have to do it via OpenAL */
if (source && source->setPitch(value))
AL::Source::setPitch(alSrc, 1.0f);
else
AL::Source::setPitch(alSrc, value);
}
ALStream::State ALStream::queryState()
{
checkStopped();
return state;
}
float ALStream::queryOffset()
{
if (state == Closed)
return 0;
float procOffset = static_cast<float>(procFrames) / source->sampleRate();
return procOffset + AL::Source::getSecOffset(alSrc);
}
void ALStream::closeSource()
{
delete source;
}
struct ALStreamOpenHandler : FileSystem::OpenHandler
{
SDL_RWops *srcOps;
bool looped;
ALDataSource *source;
std::string errorMsg;
ALStreamOpenHandler(SDL_RWops &srcOps, bool looped)
: srcOps(&srcOps), looped(looped), source(0)
{}
bool tryRead(SDL_RWops &ops, const char *ext)
{
/* Copy this because we need to keep it around,
* as we will continue reading data from it later */
*srcOps = ops;
/* Try to read ogg file signature */
char sig[5] = { 0 };
SDL_RWread(srcOps, sig, 1, 4);
SDL_RWseek(srcOps, 0, RW_SEEK_SET);
try
{
if (!strcmp(sig, "OggS"))
{
source = createVorbisSource(*srcOps, looped);
return true;
}
if (!strcmp(sig, "MThd"))
{
shState->midiState().initIfNeeded(shState->config());
if (HAVE_FLUID)
{
source = createMidiSource(*srcOps, looped);
return true;
}
}
source = createSDLSource(*srcOps, ext, STREAM_BUF_SIZE, looped);
}
catch (const Exception &e)
{
/* All source constructors will close the passed ops
* before throwing errors */
errorMsg = e.msg;
return false;
}
return true;
}
};
void ALStream::openSource(const std::string &filename)
{
ALStreamOpenHandler handler(srcOps, looped);
shState->fileSystem().openRead(handler, filename.c_str());
source = handler.source;
needsRewind.clear();
if (!source)
{
char buf[512];
snprintf(buf, sizeof(buf), "Unable to decode audio stream: %s: %s",
filename.c_str(), handler.errorMsg.c_str());
Debug() << buf;
}
}
void ALStream::stopStream()
{
threadTermReq.set();
if (thread)
{
SDL_WaitThread(thread, 0);
thread = 0;
needsRewind.set();
}
/* Need to stop the source _after_ the thread has terminated,
* because it might have accidentally started it again before
* seeing the term request */
AL::Source::stop(alSrc);
procFrames = 0;
}
void ALStream::startStream(float offset)
{
AL::Source::clearQueue(alSrc);
preemptPause = false;
streamInited.clear();
sourceExhausted.clear();
threadTermReq.clear();
startOffset = offset;
procFrames = offset * source->sampleRate();
thread = createSDLThread
<ALStream, &ALStream::streamData>(this, threadName);
}
void ALStream::pauseStream()
{
SDL_LockMutex(pauseMut);
if (AL::Source::getState(alSrc) != AL_PLAYING)
preemptPause = true;
else
AL::Source::pause(alSrc);
SDL_UnlockMutex(pauseMut);
}
void ALStream::resumeStream()
{
SDL_LockMutex(pauseMut);
if (preemptPause)
preemptPause = false;
else
AL::Source::play(alSrc);
SDL_UnlockMutex(pauseMut);
}
void ALStream::checkStopped()
{
/* This only concerns the scenario where
* state is still 'Playing', but the stream
* has already ended on its own (EOF, Error) */
if (state != Playing)
return;
/* If streaming thread hasn't queued up
* buffers yet there's not point in querying
* the AL source */
if (!streamInited)
return;
/* If alSrc isn't playing, but we haven't
* exhausted the data source yet, we're just
* having a buffer underrun */
if (!sourceExhausted)
return;
if (AL::Source::getState(alSrc) == AL_PLAYING)
return;
stopStream();
state = Stopped;
}
/* thread func */
void ALStream::streamData()
{
/* Fill up queue */
bool firstBuffer = true;
ALDataSource::Status status;
if (threadTermReq)
return;
if (needsRewind)
{
source->seekToOffset(startOffset);
}
for (int i = 0; i < STREAM_BUFS; ++i)
{
if (threadTermReq)
return;
AL::Buffer::ID buf = alBuf[i];
status = source->fillBuffer(buf);
if (status == ALDataSource::Error)
return;
AL::Source::queueBuffer(alSrc, buf);
if (firstBuffer)
{
resumeStream();
firstBuffer = false;
streamInited.set();
}
if (threadTermReq)
return;
if (status == ALDataSource::EndOfStream)
{
sourceExhausted.set();
break;
}
}
/* Wait for buffers to be consumed, then
* refill and queue them up again */
while (true)
{
shState->rtData().syncPoint.passSecondarySync();
ALint procBufs = AL::Source::getProcBufferCount(alSrc);
while (procBufs--)
{
if (threadTermReq)
break;
AL::Buffer::ID buf = AL::Source::unqueueBuffer(alSrc);
/* If something went wrong, try again later */
if (buf == AL::Buffer::ID(0))
break;
if (buf == lastBuf)
{
/* Reset the processed sample count so
* querying the playback offset returns 0.0 again */
procFrames = source->loopStartFrames();
lastBuf = AL::Buffer::ID(0);
}
else
{
/* Add the frame count contained in this
* buffer to the total count */
ALint bits = AL::Buffer::getBits(buf);
ALint size = AL::Buffer::getSize(buf);
ALint chan = AL::Buffer::getChannels(buf);
if (bits != 0 && chan != 0)
procFrames += ((size / (bits / 8)) / chan);
}
if (sourceExhausted)
continue;
status = source->fillBuffer(buf);
if (status == ALDataSource::Error)
{
sourceExhausted.set();
return;
}
AL::Source::queueBuffer(alSrc, buf);
/* In case of buffer underrun,
* start playing again */
if (AL::Source::getState(alSrc) == AL_STOPPED)
AL::Source::play(alSrc);
/* If this was the last buffer before the data
* source loop wrapped around again, mark it as
* such so we can catch it and reset the processed
* sample count once it gets unqueued */
if (status == ALDataSource::WrapAround)
lastBuf = buf;
if (status == ALDataSource::EndOfStream)
sourceExhausted.set();
}
if (threadTermReq)
break;
SDL_Delay(AUDIO_SLEEP);
}
}

122
src/alstream.h Normal file
View File

@ -0,0 +1,122 @@
/*
** alstream.h
**
** This file is part of mkxp.
**
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ALSTREAM_H
#define ALSTREAM_H
#include "al-util.h"
#include "sdl-util.h"
#include <string>
#include <SDL_rwops.h>
struct ALDataSource;
#define STREAM_BUFS 3
/* State-machine like audio playback stream.
* This class is NOT thread safe */
struct ALStream
{
enum State
{
Closed,
Stopped,
Playing,
Paused
};
bool looped;
State state;
ALDataSource *source;
SDL_Thread *thread;
std::string threadName;
SDL_mutex *pauseMut;
bool preemptPause;
/* When this flag isn't set and alSrc is
* in 'STOPPED' state, stream isn't over
* (it just hasn't started yet) */
AtomicFlag streamInited;
AtomicFlag sourceExhausted;
AtomicFlag threadTermReq;
AtomicFlag needsRewind;
float startOffset;
float pitch;
AL::Source::ID alSrc;
AL::Buffer::ID alBuf[STREAM_BUFS];
uint64_t procFrames;
AL::Buffer::ID lastBuf;
SDL_RWops srcOps;
struct
{
ALenum format;
ALsizei freq;
} stream;
enum LoopMode
{
Looped,
NotLooped
};
ALStream(LoopMode loopMode,
const std::string &threadId);
~ALStream();
void close();
void open(const std::string &filename);
void stop();
void play(float offset = 0);
void pause();
void setVolume(float value);
void setPitch(float value);
State queryState();
float queryOffset();
bool queryNativePitch();
private:
void closeSource();
void openSource(const std::string &filename);
void stopStream();
void startStream(float offset);
void pauseStream();
void resumeStream();
void checkStopped();
/* thread func */
void streamData();
};
#endif // ALSTREAM_H

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -33,27 +33,22 @@
* quite make out their meaning yet) */
struct AudioPrivate;
struct RGSSThreadData;
class Audio
{
public:
void bgmPlay(const char *filename,
int volume = 100,
int pitch = 100
#ifdef RGSS3
,float pos = 0
#endif
);
int pitch = 100,
float pos = 0);
void bgmStop();
void bgmFade(int time);
void bgsPlay(const char *filename,
int volume = 100,
int pitch = 100
#ifdef RGSS3
,float pos = 0
#endif
);
int pitch = 100,
float pos = 0);
void bgsStop();
void bgsFade(int time);
@ -68,14 +63,14 @@ public:
int pitch = 100);
void seStop();
#ifdef RGSS3
void setupMidi();
float bgmPos();
float bgsPos();
#endif
void reset();
private:
Audio();
Audio(RGSSThreadData &rtData);
~Audio();
friend struct SharedStatePrivate;

365
src/audiostream.cpp Normal file
View File

@ -0,0 +1,365 @@
/*
** audiostream.cpp
**
** This file is part of mkxp.
**
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#include "audiostream.h"
#include "util.h"
#include "exception.h"
#include <SDL_mutex.h>
#include <SDL_thread.h>
#include <SDL_timer.h>
AudioStream::AudioStream(ALStream::LoopMode loopMode,
const std::string &threadId)
: extPaused(false),
noResumeStop(false),
stream(loopMode, threadId)
{
current.volume = 1.0f;
current.pitch = 1.0f;
for (size_t i = 0; i < VolumeTypeCount; ++i)
volumes[i] = 1.0f;
fade.thread = 0;
fade.threadName = std::string("audio_fadeout (") + threadId + ")";
fadeIn.thread = 0;
fadeIn.threadName = std::string("audio_fadein (") + threadId + ")";
streamMut = SDL_CreateMutex();
}
AudioStream::~AudioStream()
{
if (fade.thread)
{
fade.reqTerm.set();
SDL_WaitThread(fade.thread, 0);
}
if (fadeIn.thread)
{
fadeIn.rqTerm.set();
SDL_WaitThread(fadeIn.thread, 0);
}
lockStream();
stream.stop();
stream.close();
unlockStream();
SDL_DestroyMutex(streamMut);
}
void AudioStream::play(const std::string &filename,
int volume,
int pitch,
float offset)
{
finiFadeOutInt();
lockStream();
float _volume = clamp<int>(volume, 0, 100) / 100.0f;
float _pitch = clamp<int>(pitch, 50, 150) / 100.0f;
ALStream::State sState = stream.queryState();
/* If all parameters match the current ones and we're
* still playing, there's nothing to do */
if (filename == current.filename
&& _volume == current.volume
&& _pitch == current.pitch
&& (sState == ALStream::Playing || sState == ALStream::Paused))
{
unlockStream();
return;
}
/* If all parameters except volume match the current ones,
* we update the volume and continue streaming */
if (filename == current.filename
&& _pitch == current.pitch
&& (sState == ALStream::Playing || sState == ALStream::Paused))
{
setVolume(Base, _volume);
current.volume = _volume;
unlockStream();
return;
}
/* Requested audio file is different from current one */
bool diffFile = (filename != current.filename);
switch (sState)
{
case ALStream::Paused :
case ALStream::Playing :
stream.stop();
case ALStream::Stopped :
if (diffFile)
stream.close();
case ALStream::Closed :
if (diffFile)
{
try
{
/* This will throw on errors while
* opening the data source */
stream.open(filename);
}
catch (const Exception &e)
{
unlockStream();
throw e;
}
}
break;
}
setVolume(Base, _volume);
stream.setPitch(_pitch);
if (offset > 0)
{
setVolume(FadeIn, 0);
startFadeIn();
}
current.filename = filename;
current.volume = _volume;
current.pitch = _pitch;
if (!extPaused)
stream.play(offset);
else
noResumeStop = false;
unlockStream();
}
void AudioStream::stop()
{
finiFadeOutInt();
lockStream();
noResumeStop = true;
stream.stop();
unlockStream();
}
void AudioStream::fadeOut(int duration)
{
lockStream();
ALStream::State sState = stream.queryState();
noResumeStop = true;
if (fade.active)
{
unlockStream();
return;
}
if (sState == ALStream::Paused)
{
stream.stop();
unlockStream();
return;
}
if (sState != ALStream::Playing)
{
unlockStream();
return;
}
if (fade.thread)
{
fade.reqFini.set();
SDL_WaitThread(fade.thread, 0);
fade.thread = 0;
}
fade.active.set();
fade.msStep = 1.0f / duration;
fade.reqFini.clear();
fade.reqTerm.clear();
fade.startTicks = SDL_GetTicks();
fade.thread = createSDLThread
<AudioStream, &AudioStream::fadeOutThread>(this, fade.threadName);
unlockStream();
}
/* Any access to this classes 'stream' member,
* whether state query or modification, must be
* protected by a 'lock'/'unlock' pair */
void AudioStream::lockStream()
{
SDL_LockMutex(streamMut);
}
void AudioStream::unlockStream()
{
SDL_UnlockMutex(streamMut);
}
void AudioStream::setVolume(VolumeType type, float value)
{
volumes[type] = value;
updateVolume();
}
float AudioStream::getVolume(VolumeType type)
{
return volumes[type];
}
float AudioStream::playingOffset()
{
return stream.queryOffset();
}
void AudioStream::updateVolume()
{
float vol = GLOBAL_VOLUME;
for (size_t i = 0; i < VolumeTypeCount; ++i)
vol *= volumes[i];
stream.setVolume(vol);
}
void AudioStream::finiFadeOutInt()
{
if (fade.thread)
{
fade.reqFini.set();
SDL_WaitThread(fade.thread, 0);
fade.thread = 0;
}
if (fadeIn.thread)
{
fadeIn.rqFini.set();
SDL_WaitThread(fadeIn.thread, 0);
fadeIn.thread = 0;
}
}
void AudioStream::startFadeIn()
{
/* Previous fadein should always be terminated in play() */
assert(!fadeIn.thread);
fadeIn.rqFini.clear();
fadeIn.rqTerm.clear();
fadeIn.startTicks = SDL_GetTicks();
fadeIn.thread = createSDLThread
<AudioStream, &AudioStream::fadeInThread>(this, fadeIn.threadName);
}
void AudioStream::fadeOutThread()
{
while (true)
{
/* Just immediately terminate on request */
if (fade.reqTerm)
break;
lockStream();
uint32_t curDur = SDL_GetTicks() - fade.startTicks;
float resVol = 1.0f - (curDur*fade.msStep);
ALStream::State state = stream.queryState();
if (state != ALStream::Playing
|| resVol < 0
|| fade.reqFini)
{
if (state != ALStream::Paused)
stream.stop();
setVolume(FadeOut, 1.0f);
unlockStream();
break;
}
setVolume(FadeOut, resVol);
unlockStream();
SDL_Delay(AUDIO_SLEEP);
}
fade.active.clear();
}
void AudioStream::fadeInThread()
{
while (true)
{
if (fadeIn.rqTerm)
break;
lockStream();
/* Fade in duration is always 1 second */
uint32_t cur = SDL_GetTicks() - fadeIn.startTicks;
float prog = cur / 1000.0f;
ALStream::State state = stream.queryState();
if (state != ALStream::Playing
|| prog >= 1.0f
|| fadeIn.rqFini)
{
setVolume(FadeIn, 1.0f);
unlockStream();
break;
}
/* Quadratic increase (not really the same as
* in RMVXA, but close enough) */
setVolume(FadeIn, prog*prog);
unlockStream();
SDL_Delay(AUDIO_SLEEP);
}
}

154
src/audiostream.h Normal file
View File

@ -0,0 +1,154 @@
/*
** audiostream.h
**
** This file is part of mkxp.
**
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUDIOSTREAM_H
#define AUDIOSTREAM_H
#include "al-util.h"
#include "alstream.h"
#include "sdl-util.h"
#include <string>
struct AudioStream
{
struct
{
std::string filename;
float volume;
float pitch;
} current;
/* Volumes set by external threads,
* such as for fade-in/out.
* Multiplied together for final
* playback volume. Used with setVolume().
* Base is set by play().
* External is used by MeWatch */
enum VolumeType
{
Base = 0,
FadeOut,
FadeIn,
External,
VolumeTypeCount
};
/* Note that 'extPaused' and 'noResumeStop' are
* effectively only used with the AudioStream
* instance representing the BGM.
* They are not AtomicFlags because they're regarded
* as part of the underlying stream state, and
* always accessed with the stream lock held */
/* Flag indicating that the MeWatch paused this
* (BGM) stream because a ME started playing.
* While this flag is set, calls to 'play()'
* might open another file, but will not start
* the playback stream (the MeWatch will start
* it as soon as the ME finished playing). */
bool extPaused;
/* Flag indicating that this stream shouldn't be
* started by the MeWatch when it is in stopped
* state (eg. because the BGM stream was explicitly
* stopped by the user script while the ME was playing.
* When a new BGM is started (via 'play()') while an ME
* is playing, the file will be loaded without starting
* the stream, but we want the MeWatch to start it as
* soon as the ME ends, so we unset this flag. */
bool noResumeStop;
ALStream stream;
SDL_mutex *streamMut;
/* Fade out */
struct
{
/* Fade out is in progress */
AtomicFlag active;
/* Request fade thread to finish and
* cleanup (like it normally would) */
AtomicFlag reqFini;
/* Request fade thread to terminate
* immediately */
AtomicFlag reqTerm;
SDL_Thread *thread;
std::string threadName;
/* Amount of reduced absolute volume
* per ms of fade time */
float msStep;
/* Ticks at start of fade */
uint32_t startTicks;
} fade;
/* Fade in */
struct
{
AtomicFlag rqFini;
AtomicFlag rqTerm;
SDL_Thread *thread;
std::string threadName;
uint32_t startTicks;
} fadeIn;
AudioStream(ALStream::LoopMode loopMode,
const std::string &threadId);
~AudioStream();
void play(const std::string &filename,
int volume,
int pitch,
float offset = 0);
void stop();
void fadeOut(int duration);
/* Any access to this classes 'stream' member,
* whether state query or modification, must be
* protected by a 'lock'/'unlock' pair */
void lockStream();
void unlockStream();
void setVolume(VolumeType type, float value);
float getVolume(VolumeType type);
float playingOffset();
private:
float volumes[VolumeTypeCount];
void updateVolume();
void finiFadeOutInt();
void startFadeIn();
void fadeOutThread();
void fadeInThread();
};
#endif // AUDIOSTREAM_H

View File

@ -4,196 +4,196 @@ extern const StaticRect autotileRects[] =
{
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 64.5, 64.5, 15, 15 },
{ 80.5, 64.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 64.5, 80.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 64.5, 64.5, 15, 15 },
{ 80.5, 64.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 64.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 64.5, 80.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 64.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 32.5, 96.5, 15, 15 },
{ 48.5, 96.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 48.5, 96.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.5, 96.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 80.5, 64.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 32.5, 15, 15 },
{ 80.5, 32.5, 15, 15 },
{ 80.5, 48.5, 15, 15 },
{ 64.5, 48.5, 15, 15 },
{ 80.5, 48.5, 15, 15 },
{ 64.5, 32.5, 15, 15 },
{ 80.5, 32.5, 15, 15 },
{ 80.5, 48.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 48.5, 15, 15 },
{ 64.5, 96.5, 15, 15 },
{ 80.5, 96.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 64.5, 112.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 96.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 64.5, 112.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 0.5, 96.5, 15, 15 },
{ 16.5, 96.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 0.5, 96.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 80.5, 32.5, 15, 15 },
{ 80.5, 48.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 80.5, 48.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 0.5, 96.5, 15, 15 },
{ 80.5, 96.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 64.5, 32.5, 15, 15 },
{ 80.5, 32.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 64.5, 112.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 80.5, 32.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 64.5, 112.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 0.5, 0.5, 15, 15 },
{ 16.5, 0.5, 15, 15 },
{ 16.5, 16.5, 15, 15 },
{ 0.5, 16.5, 15, 15 }
{ 0.5, 16.5, 15, 15 },
{ 16.5, 16.5, 15, 15 }
};
extern const int autotileRectsN = sizeof(autotileRects) / sizeof(autotileRects[0]);

615
src/autotilesvx.cpp Normal file
View File

@ -0,0 +1,615 @@
struct StaticRect { float x, y, w, h; };
extern const StaticRect autotileVXRectsA[] =
{
{ 32.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 0.5, 0.5, 15, 15 },
{ 16.5, 0.5, 15, 15 },
{ 0.5, 16.5, 15, 15 },
{ 16.5, 16.5, 15, 15 }
};
extern const int autotileVXRectsAN = sizeof(autotileVXRectsA) / sizeof(autotileVXRectsA[0]);
extern const StaticRect autotileVXRectsA2[] =
{
{ 32.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 0.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 0.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 48.5, 16.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 16.5, 0, 0 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 16.5, 0, 0 },
{ 16.5, 16.5, 0, 0 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 0.5, 0.5, 15, 15 },
{ 16.5, 0.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 16.5, 15, 15 },
{ 16.5, 16.5, 15, 15 }
};
extern const int autotileVXRectsA2N = sizeof(autotileVXRectsA2) / sizeof(autotileVXRectsA2[0]);
extern const float autotileVXRectsA2Sizes[] =
{
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 0.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 0.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 0.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 0.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 0.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 0.0, 0.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0,
16.0, 16.0, 16.0, 16.0, 16.0, 16.0
};
extern const StaticRect autotileVXRectsB[] =
{
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 16.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 0.5, 16.5, 15, 15 },
{ 16.5, 16.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 0.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 16.5, 16.5, 15, 15 },
{ 0.5, 0.5, 15, 15 },
{ 16.5, 0.5, 15, 15 },
{ 0.5, 16.5, 15, 15 },
{ 16.5, 16.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 0.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 0.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 0.5, 16.5, 15, 15 },
{ 48.5, 16.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 16.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 0.5, 0.5, 15, 15 },
{ 16.5, 0.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 16.5, 48.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 32.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 0.5, 0.5, 15, 15 },
{ 48.5, 0.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 48.5, 48.5, 15, 15 }
};
extern const int autotileVXRectsBN = sizeof(autotileVXRectsB) / sizeof(autotileVXRectsB[0]);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -35,6 +35,10 @@ struct ScriptBinding
* function will perform a longjmp instead of returning,
* so be careful about any variables with local storage */
void (*terminate) (void);
/* Instructs the binding to issue a game reset.
* Same conditions as for terminate apply */
void (*reset) (void);
};
/* VTable defined in the binding source */

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -49,7 +49,7 @@ public:
IntRect rect() const;
void blt(int x, int y,
const Bitmap &source, const IntRect &rect,
const Bitmap &source, IntRect rect,
int opacity = 255);
void stretchBlt(const IntRect &destRect,
@ -61,7 +61,6 @@ public:
const Vec4 &color);
void fillRect(const IntRect &rect, const Vec4 &color);
#ifdef RGSS2
void gradientFillRect(int x, int y,
int width, int height,
const Vec4 &color1, const Vec4 &color2,
@ -75,14 +74,12 @@ public:
void clearRect(const IntRect &rect);
void blur();
void radialBlur(int angle, int divisions);
#endif
void clear();
Vec4 getPixel(int x, int y) const;
void setPixel(int x, int y, const Vec4 &color);
Color getPixel(int x, int y) const;
void setPixel(int x, int y, const Color &color);
void hueChange(int hue);
@ -102,12 +99,13 @@ public:
IntRect textSize(const char *str);
DECL_ATTR(Font, Font*)
DECL_ATTR(Font, Font&)
/* Sets initial reference without copying by value,
* use at construction */
void setInitFont(Font *value);
/* <internal> */
/* Warning: Flushing might change the current
* FBO binding (so don't call it during 'draw()' routines */
void flush() const;
TEXFBO &getGLTypes();
SDL_Surface *megaSurface() const;
void ensureNonMega() const;
@ -116,10 +114,14 @@ public:
* texture size uniform in shader */
void bindTex(ShaderBase &shader);
/* Adds 'rect' to tainted area */
void taintArea(const IntRect &rect);
sigc::signal<void> modified;
private:
void releaseResources();
const char *klassName() const { return "bitmap"; }
BitmapPrivate *p;
};

Some files were not shown because too many files have changed in this diff Show More