Compare commits

..

1 Commits

Author SHA1 Message Date
Jonas Kulla dcf77bde78 Bitmap: Add option to always use render pipeline to blit text
A hack that might solve issues some users are having on
AMD SI cards with fglrx.
2014-01-26 08:39:02 +01:00
195 changed files with 8781 additions and 23677 deletions

View File

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

5
.gitignore vendored
View File

@ -11,8 +11,3 @@ mkxp
xxd+
/build
# Codeblocks
mkxp.layout
mkxp.cbp

View File

@ -3,8 +3,7 @@ Project(mkxp)
## Setup options ##
option(SHARED_FLUID "Dynamically link fluidsynth at build time" OFF)
option(WORKDIR_CURRENT "Keep current directory on startup" OFF)
option(RGSS2 "Enable RGSS2" ON)
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")
@ -19,12 +18,6 @@ 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")
@ -86,14 +79,15 @@ 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 ##
@ -110,7 +104,6 @@ set(MAIN_HEADERS
src/flashable.h
src/font.h
src/input.h
src/iniconfig.h
src/plane.h
src/scene.h
src/sprite.h
@ -125,9 +118,8 @@ set(MAIN_HEADERS
src/glstate.h
src/quad.h
src/tilemap.h
src/tilemap-common.h
src/graphics.h
src/gl-debug.h
src/debuglogger.h
src/global-ibo.h
src/exception.h
src/filesystem.h
@ -137,27 +129,12 @@ 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
@ -168,7 +145,6 @@ set(MAIN_SOURCE
src/filesystem.cpp
src/font.cpp
src/input.cpp
src/iniconfig.cpp
src/plane.cpp
src/scene.cpp
src/sprite.cpp
@ -182,79 +158,41 @@ set(MAIN_SOURCE
src/tilemap.cpp
src/autotiles.cpp
src/graphics.cpp
src/gl-debug.cpp
src/debuglogger.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
assets/liberation.ttf
)
if (RGSS2)
list(APPEND EMBEDDED_INPUT
shader/blur.frag
shader/blurH.vert
shader/blurV.vert
shader/simpleMatrix.vert
assets/liberation.ttf
assets/icon.png
)
if (RGSS2)
list(APPEND DEFINES
RGSS2
)
endif()
if (SHARED_FLUID)
pkg_check_modules(FLUID REQUIRED fluidsynth)
list(APPEND DEFINES
SHARED_FLUID
)
endif()
@ -294,7 +232,7 @@ source_group("Embedded Source" FILES ${EMBEDDED_INPUT} ${EMBEDDED_SOURCE})
## Setup binding source ##
if (BINDING STREQUAL "MRI")
set(MRIVERSION "2.1" CACHE STRING "Version of MRI to link with")
set(MRIVERSION "2.0" CACHE STRING "Version of MRI to link with")
pkg_check_modules(MRI REQUIRED ruby-${MRIVERSION})
list(APPEND DEFINES
BINDING_MRI
@ -325,8 +263,6 @@ 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")
@ -386,7 +322,6 @@ if(APPLE)
list(APPEND PLATFORM_LIBRARIES
${CARBON_LIBRARY}
${IOKIT_LIBRARY}
"-liconv"
)
endif()
@ -412,16 +347,13 @@ 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}
)
@ -435,9 +367,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,20 +1,9 @@
# mkxp
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.
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.
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:
@ -26,8 +15,6 @@ 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
@ -37,8 +24,6 @@ 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
@ -50,33 +35,22 @@ 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
* [my SDL_sound fork](https://github.com/Ancurio/SDL_sound)
* vorbisfile
* SDL_sound (apply provided patches!)
* 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)
(* 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).
mkxp employs Qt's qmake build system, so you'll need to install that beforehand.
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. You can specify a library suffix (eg. "-mt") via `BOOST_LIB_SUFFIX` if needed.
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.
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).
**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).
**MRuby-Binding**: place the "mruby" folder into the project folder and build it first. Add `BINDING=MRUBY` to qmake's arguments.
@ -85,27 +59,15 @@ To auto detect the encoding of the game title in `Game.ini` and auto convert it
### 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 (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.
To run mkxp, you should have a graphics card capable of at least **OpenGL 2.0** with an up-to-date driver installed.
## Configuration
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.
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. See 'mkxp.conf.sample' for a list of accepted entries.
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>`
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)
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".
## Fonts
@ -115,9 +77,9 @@ If a requested font is not found, no error is generated. Instead, a built-in fon
## What doesn't work (yet)
* Movie playback
* wma audio files
* midi and 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.
@ -127,5 +89,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 screen.
* The `Input` module has two additional functions, `#mouse_x` and `#mouse_y` to query the mouse pointer position relative to the game window.
* 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`.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,50 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,33 +24,6 @@
#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) \
{ \
@ -79,42 +52,16 @@ RB_METHOD(audio_##entity##Fade) \
return Qnil; \
}
#define DEF_POS(entity) \
RB_METHOD(audio_##entity##Pos) \
{ \
RB_UNUSED_PARAM; \
return rb_float_new(shState->audio().entity##Pos()); \
}
#define DEF_PLAY_STOP_FADE(entity) \
DEF_PLAY_STOP(entity) \
DEF_FADE(entity)
DEF_PLAY_STOP_POS( bgm )
DEF_PLAY_STOP_POS( bgs )
DEF_PLAY_STOP( me )
DEF_FADE( bgm )
DEF_FADE( bgs )
DEF_FADE( me )
DEF_PLAY_STOP_FADE( bgm )
DEF_PLAY_STOP_FADE( bgs )
DEF_PLAY_STOP_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) \
_rb_define_module_function(module, #entity "_play", audio_##entity##Play); \
@ -127,28 +74,15 @@ RB_METHOD(audioReset)
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 );
if (rgssVer >= 3)
{
BIND_POS( bgm );
BIND_POS( bgs );
_rb_define_module_function(module, "setup_midi", audioSetupMidi);
}
BIND_PLAY_STOP_FADE( bgm )
BIND_PLAY_STOP_FADE( bgs )
BIND_PLAY_STOP_FADE( me )
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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,34 +25,26 @@
#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_rpg1[];
extern const char module_rpg2[];
extern const char module_rpg3[];
extern const char module_rpg[];
static void mriBindingExecute();
static void mriBindingTerminate();
static void mriBindingReset();
ScriptBinding scriptBindingImpl =
{
mriBindingExecute,
mriBindingTerminate,
mriBindingReset
mriBindingTerminate
};
ScriptBinding *scriptBinding = &scriptBindingImpl;
@ -66,8 +58,6 @@ void viewportBindingInit();
void planeBindingInit();
void windowBindingInit();
void tilemapBindingInit();
void windowVXBindingInit();
void tilemapVXBindingInit();
void inputBindingInit();
void audioBindingInit();
@ -77,14 +67,8 @@ void fileIntBindingInit();
RB_METHOD(mriPrint);
RB_METHOD(mriP);
RB_METHOD(mkxpDataDirectory);
RB_METHOD(mriDataDirectory);
RB_METHOD(mkxpPuts);
RB_METHOD(mkxpRawKeyStates);
RB_METHOD(mkxpMouseInWindow);
RB_METHOD(mriRgssMain);
RB_METHOD(mriRgssStop);
RB_METHOD(_kernelCaller);
static void mriBindingInit()
{
@ -95,17 +79,8 @@ static void mriBindingInit()
spriteBindingInit();
viewportBindingInit();
planeBindingInit();
if (rgssVer == 1)
{
windowBindingInit();
tilemapBindingInit();
}
else
{
windowVXBindingInit();
tilemapVXBindingInit();
}
inputBindingInit();
audioBindingInit();
@ -113,50 +88,16 @@ static void mriBindingInit()
fileIntBindingInit();
if (rgssVer >= 3)
{
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
_rb_define_module_function(rb_mKernel, "rgss_stop", mriRgssStop);
_rb_define_module_function(rb_mKernel, "msgbox", mriPrint);
_rb_define_module_function(rb_mKernel, "msgbox_p", mriP);
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);
}
rb_eval_string(module_rpg);
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);
VALUE mod = rb_define_module("System");
_rb_define_module_function(mod, "data_directory", mriDataDirectory);
_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);
/* 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));
rb_define_global_const("MKXP", Qtrue);
}
static void
@ -165,6 +106,18 @@ 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)
{
@ -201,187 +154,41 @@ RB_METHOD(mriP)
return Qnil;
}
RB_METHOD(mkxpDataDirectory)
RB_METHOD(mriDataDirectory)
{
RB_UNUSED_PARAM;
const std::string &path = shState->config().customDataPath;
const char *s = path.empty() ? "." : path.c_str();
const char *org, *app;
return rb_str_new_cstr(s);
rb_get_args(argc, argv, "zz", &org, &app RB_ARG_END);
char *path = SDL_GetPrefPath(org, app);
VALUE pathStr = rb_str_new_cstr(path);
SDL_free(path);
return pathStr;
}
RB_METHOD(mkxpPuts)
static void runCustomScript(const char *filename)
{
RB_UNUSED_PARAM;
std::string scriptData("#encoding:utf-8\n");
const char *str;
rb_get_args(argc, argv, "z", &str RB_ARG_END);
Debug() << str;
return Qnil;
}
RB_METHOD(mkxpRawKeyStates)
{
RB_UNUSED_PARAM;
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))
if (!readFile(filename, scriptData))
{
showMsg(std::string("Unable to open '") + filename + "'");
return;
}
evalString(newStringUTF8(scriptData.c_str(), scriptData.size()),
newStringUTF8(filename.c_str(), filename.size()), NULL);
rb_eval_string_protect(scriptData.c_str(), 0);
}
VALUE kernelLoadDataInt(const char *filename, bool rubyExc);
VALUE kernelLoadDataInt(const char *filename);
struct BacktraceData
static void runRMXPScripts()
{
/* 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;
const std::string &scriptPack = shState->rtData().config.game.scripts;
if (scriptPack.empty())
{
@ -395,28 +202,14 @@ static void runRMXPScripts(BacktraceData &btData)
return;
}
VALUE scriptArray;
VALUE scriptArray = kernelLoadDataInt(scriptPack.c_str());
/* 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))
if (rb_type(scriptArray) != RUBY_T_ARRAY)
{
showMsg("Failed to read script data");
return;
}
rb_gv_set("$RGSS_SCRIPTS", scriptArray);
long scriptCount = RARRAY_LEN(scriptArray);
std::string decodeBuffer;
@ -426,7 +219,7 @@ static void runRMXPScripts(BacktraceData &btData)
{
VALUE script = rb_ary_entry(scriptArray, i);
if (!RB_TYPE_P(script, RUBY_T_ARRAY))
if (rb_type(script) != RUBY_T_ARRAY)
continue;
VALUE scriptName = rb_ary_entry(script, 1);
@ -466,168 +259,61 @@ static void runRMXPScripts(BacktraceData &btData)
break;
}
rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str()));
}
/* 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);
/* Execute preloaded scripts */
for (std::set<std::string>::iterator i = conf.preloadScripts.begin();
i != conf.preloadScripts.end(); ++i)
runCustomScript(*i);
ruby_script(RSTRING_PTR(scriptName));
VALUE exc = rb_gv_get("$!");
if (exc != Qnil)
return;
rb_gc_start();
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));
/* Execute code */
rb_eval_string_protect(decData.c_str(), 0);
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)
VALUE exc = rb_errinfo();
if (!NIL_P(exc))
break;
}
VALUE exc = rb_gv_get("$!");
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 = conf.customScript;
std::string &customScript = shState->rtData().config.customScript;
if (!customScript.empty())
runCustomScript(customScript);
runCustomScript(customScript.c_str());
else
runRMXPScripts(btData);
runRMXPScripts();
VALUE exc = rb_errinfo();
if (!NIL_P(exc) && !rb_obj_is_kind_of(exc, rb_eSystemExit))
showExc(exc, btData);
{
Debug() << "Had exception:" << rb_class2name(rb_obj_class(exc));
VALUE bt = rb_funcall2(exc, rb_intern("backtrace"), 0, NULL);
rb_p(bt);
VALUE msg = rb_funcall2(exc, rb_intern("message"), 0, NULL);
if (RSTRING_LEN(msg) < 256)
showMsg(RSTRING_PTR(msg));
else
Debug() << (RSTRING_PTR(msg));
}
ruby_cleanup(0);
shState->rtData().rqTermAck.set();
shState->rtData().rqTermAck = true;
}
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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,9 +26,21 @@
#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());
@ -41,6 +53,7 @@ struct
} static customExc[] =
{
{ MKXP, "MKXPError" },
{ RGSS, "RGSSError" },
{ PHYSFS, "PHYSFSError" },
{ SDL, "SDLError" }
};
@ -50,9 +63,6 @@ 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;
@ -87,18 +97,6 @@ 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, ...)
{
@ -150,7 +148,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
VALUE *str = va_arg(ap, VALUE*);
VALUE tmp = *arg;
if (!RB_TYPE_P(tmp, RUBY_T_STRING))
if (!(rb_type(tmp) == RUBY_T_STRING))
rb_raise(rb_eTypeError, "Argument %d: Expected string", argI);
*str = tmp;
@ -169,7 +167,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
VALUE tmp = *arg;
if (!RB_TYPE_P(tmp, RUBY_T_STRING))
if (!(rb_type(tmp) == RUBY_T_STRING))
rb_raise(rb_eTypeError, "Argument %d: Expected string", argI);
*s = RSTRING_PTR(tmp);
@ -188,7 +186,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
VALUE tmp = *arg++;
if (!RB_TYPE_P(tmp, RUBY_T_STRING))
if (!(rb_type(tmp) == RUBY_T_STRING))
rb_raise(rb_eTypeError, "Argument %d: Expected string", argI);
*s = RSTRING_PTR(tmp);
@ -239,24 +237,6 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,7 +29,6 @@
enum RbException
{
RGSS = 0,
Reset,
PHYSFS,
SDL,
MKXP,
@ -48,9 +47,6 @@ struct RbData
{
VALUE exc[RbExceptionsMax];
/* Input module (RGSS3) */
VALUE buttoncodeHash;
RbData();
~RbData();
};
@ -63,39 +59,19 @@ void
raiseRbExc(const Exception &exc);
#define DECL_TYPE(Klass) \
extern rb_data_type_t Klass##Type
extern 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
#define DEF_TYPE(Klass) \
rb_data_type_struct Klass##Type
#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)
void initType(rb_data_type_struct &type,
const char *name,
void (*freeInst)(void*));
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>
@ -104,21 +80,18 @@ static void freeInstance(void *inst)
delete static_cast<C*>(inst);
}
void
raiseDisposedAccess(VALUE self);
#define INIT_TYPE(Klass) initType(Klass##Type, #Klass, freeInstance<Klass>)
template<class C>
inline C *
static inline C *
getPrivateData(VALUE self)
{
C *c = static_cast<C*>(RTYPEDDATA_DATA(self));
return c;
return static_cast<C*>(RTYPEDDATA_DATA(self));
}
template<class C>
static inline C *
getPrivateDataCheck(VALUE self, const rb_data_type_t &type)
getPrivateDataCheck(VALUE self, const rb_data_type_struct &type)
{
void *obj = Check_TypedStruct(self, &type);
return static_cast<C*>(obj);
@ -131,10 +104,9 @@ setPrivateData(VALUE self, void *p)
}
inline VALUE
wrapObject(void *p, const rb_data_type_t &type,
VALUE underKlass = rb_cObject)
wrapObject(void *p, const rb_data_type_struct &type)
{
VALUE klass = rb_const_get(underKlass, rb_intern(type.wrap_struct_name));
VALUE klass = rb_const_get(rb_cObject, rb_intern(type.wrap_struct_name));
VALUE obj = rb_obj_alloc(klass);
setPrivateData(obj, p);
@ -144,17 +116,22 @@ wrapObject(void *p, const rb_data_type_t &type,
inline VALUE
wrapProperty(VALUE self, void *prop, const char *iv,
const rb_data_type_t &type,
VALUE underKlass = rb_cObject)
const rb_data_type_struct &type)
{
VALUE propObj = wrapObject(prop, type, underKlass);
VALUE propObj = wrapObject(prop, type);
rb_iv_set(self, iv, propObj);
return propObj;
}
/* Implemented: oSszfibn| */
inline void
wrapNilProperty(VALUE self, const char *iv)
{
rb_iv_set(self, iv, Qnil);
}
/* Implemented: oSszfib| */
int
rb_get_args(int argc, VALUE *argv, const char *format, ...);
@ -304,14 +281,38 @@ rb_check_argc(int actual, int expected)
return self; \
}
/* 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) \
/* 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) \
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_check_argc(argc, 1); \
Klass *k = getPrivateData<Klass>(self); \
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) \
@ -330,33 +331,13 @@ rb_check_argc(int actual, int expected)
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) \
{ \
rb_check_argc(argc, 1); \
Klass *k = getPrivateData<Klass>(self); \
VALUE propObj = *argv; \
PropKlass *prop; \
prop = getPrivateDataCheck<PropKlass>(propObj, PropKlass##Type); \
GUARD_EXC( k->set##PropName(*prop); ) \
return propObj; \
}
#define DEF_PROP(Klass, type, PropName, arg_fun, value_fun) \
RB_METHOD(Klass##Get##PropName) \
{ \
RB_UNUSED_PARAM; \
Klass *k = getPrivateData<Klass>(self); \
type value = 0; \
GUARD_EXC( value = k->get##PropName(); ) \
return value_fun(value); \
DEF_PROP_CHK_DISP \
return value_fun(k->get##PropName()); \
} \
RB_METHOD(Klass##Set##PropName) \
{ \

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,32 +22,14 @@
#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;
@ -68,7 +50,14 @@ RB_METHOD(bitmapInitialize)
}
setPrivateData(self, b);
bitmapInitProps(b, self);
/* 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);
return self;
}
@ -208,7 +197,12 @@ RB_METHOD(bitmapGetPixel)
rb_get_args(argc, argv, "ii", &x, &y RB_ARG_END);
Color value;
GUARD_EXC(
if (x < 0 || y < 0 || x >= b->width() || y >= b->height())
return Qnil;
)
Vec4 value;
GUARD_EXC( value = b->getPixel(x, y); );
Color *color = new Color(value);
@ -229,7 +223,7 @@ RB_METHOD(bitmapSetPixel)
color = getPrivateDataCheck<Color>(colorObj, ColorType);
GUARD_EXC( b->setPixel(x, y, *color); );
GUARD_EXC( b->setPixel(x, y, color->norm); );
return self;
}
@ -259,17 +253,7 @@ RB_METHOD(bitmapDrawText)
VALUE rectObj;
Rect *rect;
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);
@ -279,17 +263,7 @@ RB_METHOD(bitmapDrawText)
{
int x, y, width, height;
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); );
}
@ -303,17 +277,7 @@ RB_METHOD(bitmapTextSize)
const char *str;
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); );
@ -323,127 +287,28 @@ RB_METHOD(bitmapTextSize)
return wrapObject(rect, RectType);
}
DEF_PROP_OBJ_VAL(Bitmap, Font, Font, "font")
DEF_PROP_OBJ(Bitmap, Font, Font, "font")
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;
}
// 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)
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);
@ -458,13 +323,5 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,54 +25,12 @@
#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;
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);
Disposable *d = getPrivateData<C>(self);
d->dispose();
@ -84,10 +42,7 @@ RB_METHOD(disposableIsDisposed)
{
RB_UNUSED_PARAM;
C *d = getPrivateData<C>(self);
if (!d)
return Qtrue;
Disposable *d = getPrivateData<C>(self);
return rb_bool_new(d->isDisposed());
}
@ -97,19 +52,14 @@ 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");
}
template<class C>
inline void
checkDisposed(VALUE self)
inline void checkDisposed(Disposable *d, const char *klassName)
{
if (disposableIsDisposed<C>(0, 0, self) == Qtrue)
raiseDisposedAccess(self);
RbData *data = getRbData(); (void) data;
if (d->isDisposed())
rb_raise(getRbData()->exc[RGSS], "disposed %s", klassName);
}
#endif // DISPOSABLEBINDING_H

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,7 +22,6 @@
#include "etc.h"
#include "binding-util.h"
#include "serializable-binding.h"
#include "sharedstate.h"
DEF_TYPE(Color);
DEF_TYPE(Tone);
@ -69,9 +68,6 @@ 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); \
}
@ -82,18 +78,10 @@ EQUAL_FUN(Rect)
#define INIT_FUN(Klass, param_type, param_t_s, last_param_def) \
RB_METHOD(Klass##Initialize) \
{ \
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); \
} \
Klass *k = new Klass(p1, p2, p3, p4); \
setPrivateData(self, k); \
return self; \
}
@ -104,20 +92,11 @@ INIT_FUN(Rect, int, "iiii", 0)
#define SET_FUN(Klass, param_type, param_t_s, last_param_def) \
RB_METHOD(Klass##Set) \
{ \
Klass *k = getPrivateData<Klass>(self); \
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); \
Klass *k = getPrivateData<Klass>(self); \
k->set(p1, p2, p3, p4); \
} \
return self; \
}
@ -173,6 +152,7 @@ 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); \
@ -181,8 +161,6 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,35 +28,13 @@
#include "ruby/encoding.h"
#include "ruby/intern.h"
static void
fileIntFreeInstance(void *inst)
{
SDL_RWops *ops = static_cast<SDL_RWops*>(inst);
SDL_RWclose(ops);
SDL_FreeRW(ops);
}
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
DEF_TYPE(FileInt);
static VALUE
fileIntForPath(const char *path, bool rubyExc)
fileIntForPath(const char *path)
{
SDL_RWops *ops = SDL_AllocRW();
try
{
shState->fileSystem().openReadRaw(*ops, path);
}
catch (const Exception &e)
{
SDL_FreeRW(ops);
if (rubyExc)
raiseRbExc(e);
else
throw e;
}
shState->fileSystem().openRead(*ops, path);
VALUE klass = rb_const_get(rb_cObject, rb_intern("FileInt"));
@ -122,12 +100,21 @@ 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, bool rubyExc)
kernelLoadDataInt(const char *filename)
{
rb_gc_start();
VALUE port = fileIntForPath(filename, rubyExc);
VALUE port = fileIntForPath(filename);
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
@ -146,7 +133,7 @@ RB_METHOD(kernelLoadData)
const char *filename;
rb_get_args(argc, argv, "z", &filename RB_ARG_END);
return kernelLoadDataInt(filename, true);
return kernelLoadDataInt(filename);
}
RB_METHOD(kernelSaveData)
@ -172,7 +159,7 @@ RB_METHOD(kernelSaveData)
static VALUE stringForceUTF8(VALUE arg)
{
if (RB_TYPE_P(arg, RUBY_T_STRING) && ENCODING_IS_ASCII8BIT(arg))
if (rb_type(arg) == RUBY_T_STRING && ENCODING_IS_ASCII8BIT(arg))
rb_enc_associate_index(arg, rb_utf8_encindex());
return arg;
@ -209,6 +196,8 @@ RB_METHOD(_marshalLoad)
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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 (NIL_P(colorObj))
if (NIL_P(rb_type(colorObj)))
{
f->flash(0, duration);
return Qnil;

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,32 +23,6 @@
#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);
@ -56,55 +30,26 @@ RB_METHOD(fontDoesExist)
{
RB_UNUSED_PARAM;
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);
const char *name;
rb_get_args(argc, argv, "z", &name RB_ARG_END);
return rb_bool_new(Font::doesExist(name));
}
RB_METHOD(FontSetName);
RB_METHOD(fontInitialize)
{
VALUE namesObj = Qnil;
const char *name = 0;
int size = 0;
rb_get_args(argc, argv, "|oi", &namesObj, &size RB_ARG_END);
rb_get_args(argc, argv, "|zi", &name, &size RB_ARG_END);
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);
Font *f = new Font(name, size);
setPrivateData(self, f);
/* Wrap property objects */
f->initDynAttribs();
wrapProperty(self, &f->getColor(), "color", ColorType);
if (rgssVer >= 3)
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
f->setColor(new Color(*f->getColor()));
wrapProperty(self, f->getColor(), "color", ColorType);
return self;
}
@ -122,12 +67,8 @@ RB_METHOD(fontInitializeCopy)
setPrivateData(self, f);
/* Wrap property objects */
f->initDynAttribs();
wrapProperty(self, &f->getColor(), "color", ColorType);
if (rgssVer >= 3)
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
f->setColor(new Color(*f->getColor()));
wrapProperty(self, f->getColor(), "color", ColorType);
return self;
}
@ -136,36 +77,30 @@ RB_METHOD(FontGetName)
{
RB_UNUSED_PARAM;
return rb_iv_get(self, "name");
Font *f = getPrivateData<Font>(self);
return rb_str_new_cstr(f->getName());
}
RB_METHOD(FontSetName)
{
Font *f = getPrivateData<Font>(self);
rb_check_argc(argc, 1);
VALUE name;
rb_get_args(argc, argv, "S", &name RB_ARG_END);
std::vector<std::string> namesObj;
collectStrings(argv[0], namesObj);
f->setName(RSTRING_PTR(name));
f->setName(namesObj);
rb_iv_set(self, "name", argv[0]);
return argv[0];
return name;
}
template<class C>
static void checkDisposed(VALUE) {}
DEF_PROP_OBJ_VAL(Font, Color, Color, "color")
DEF_PROP_OBJ_VAL(Font, Color, OutColor, "out_color")
#undef DEF_PROP_CHK_DISP
#define DEF_PROP_CHK_DISP
DEF_PROP_I(Font, Size)
DEF_PROP_B(Font, Bold)
DEF_PROP_B(Font, Italic)
DEF_PROP_B(Font, Shadow)
DEF_PROP_B(Font, Outline)
DEF_PROP_OBJ(Font, Color, Color, "color")
#define DEF_KLASS_PROP(Klass, type, PropName, param_t_s, value_fun) \
RB_METHOD(Klass##Get##PropName) \
@ -185,49 +120,22 @@ DEF_PROP_B(Font, Outline)
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_iv_get(self, "default_name");
return rb_str_new_cstr(Font::getDefaultName());
}
RB_METHOD(FontSetDefaultName)
{
RB_UNUSED_PARAM;
VALUE nameObj;
rb_get_args(argc, argv, "S", &nameObj RB_ARG_END);
rb_check_argc(argc, 1);
Font::setDefaultName(RSTRING_PTR(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];
return nameObj;
}
RB_METHOD(FontGetDefaultColor)
@ -239,14 +147,13 @@ 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);
Font::setDefaultColor(c);
rb_iv_set(self, "default_color", colorObj);
return colorObj;
}
@ -260,32 +167,13 @@ RB_METHOD(FontSetDefaultColor)
void
fontBindingInit()
{
INIT_TYPE(Font);
VALUE klass = rb_define_class("Font", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&FontType>);
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);
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
wrapProperty(klass, Font::getDefaultColor(), "default_color", ColorType);
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
@ -293,17 +181,6 @@ 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);
@ -314,15 +191,4 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,7 +22,6 @@
#include "graphics.h"
#include "sharedstate.h"
#include "binding-util.h"
#include "binding-types.h"
#include "exception.h"
RB_METHOD(graphicsUpdate)
@ -48,7 +47,7 @@ RB_METHOD(graphicsTransition)
RB_UNUSED_PARAM;
int duration = 8;
const char *filename = "";
const char *filename = 0;
int vague = 40;
rb_get_args(argc, argv, "|izi", &duration, &filename, &vague RB_ARG_END);
@ -97,107 +96,8 @@ 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)
@ -217,29 +117,9 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,6 @@
#include "sharedstate.h"
#include "exception.h"
#include "binding-util.h"
#include "util.h"
RB_METHOD(inputUpdate)
{
@ -34,56 +33,40 @@ 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 = getButtonArg(argc, argv);
int num;
rb_get_args(argc, argv, "i", &num RB_ARG_END);
return rb_bool_new(shState->input().isPressed(num));
Input::ButtonCode bc = (Input::ButtonCode) num;
return rb_bool_new(shState->input().isPressed(bc));
}
RB_METHOD(inputTrigger)
{
RB_UNUSED_PARAM;
int num = getButtonArg(argc, argv);
int num;
rb_get_args(argc, argv, "i", &num RB_ARG_END);
return rb_bool_new(shState->input().isTriggered(num));
Input::ButtonCode bc = (Input::ButtonCode) num;
return rb_bool_new(shState->input().isTriggered(bc));
}
RB_METHOD(inputRepeat)
{
RB_UNUSED_PARAM;
int num = getButtonArg(argc, argv);
int num;
rb_get_args(argc, argv, "i", &num RB_ARG_END);
return rb_bool_new(shState->input().isRepeated(num));
Input::ButtonCode bc = (Input::ButtonCode) num;
return rb_bool_new(shState->input().isRepeated(bc));
}
RB_METHOD(inputDir4)
@ -115,44 +98,8 @@ RB_METHOD(inputMouseY)
return rb_fix_new(shState->input().mouseY());
}
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);
#define DEF_CONST_I(name, value) \
rb_const_set(module, rb_intern(name), rb_fix_new(value))
void
inputBindingInit()
@ -166,35 +113,34 @@ 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);
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);
}
}
DEF_CONST_I("MOUSELEFT", Input::MouseLeft );
DEF_CONST_I("MOUSEMIDDLE", Input::MouseMiddle);
DEF_CONST_I("MOUSERIGHT", Input::MouseRight );
}

View File

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

View File

@ -1,4 +1,4 @@
extern const char module_rpg1[] = {
extern const char module_rpg[] = {
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_rpg1[] = {
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_rpg1_len = 38461;
extern const unsigned int module_rpg_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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,17 +33,21 @@ RB_METHOD(planeInitialize)
setPrivateData(self, p);
p->initDynAttribs();
p->setColor(new Color);
p->setTone(new Tone);
wrapProperty(self, &p->getColor(), "color", ColorType);
wrapProperty(self, &p->getTone(), "tone", ToneType);
wrapNilProperty(self, "bitmap");
wrapProperty(self, p->getColor(), "color", ColorType);
wrapProperty(self, p->getTone(), "tone", ToneType);
return self;
}
DEF_PROP_OBJ_REF(Plane, Bitmap, Bitmap, "bitmap")
DEF_PROP_OBJ_VAL(Plane, Color, Color, "color")
DEF_PROP_OBJ_VAL(Plane, Tone, Tone, "tone")
#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_I(Plane, OX)
DEF_PROP_I(Plane, OY)
@ -57,6 +61,8 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,7 +20,6 @@
*/
#include "sprite.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "flashable-binding.h"
#include "sceneelement-binding.h"
@ -37,66 +36,44 @@ RB_METHOD(spriteInitialize)
setPrivateData(self, s);
/* Wrap property objects */
s->initDynAttribs();
s->setSrcRect(new Rect);
s->setColor(new Color);
s->setTone(new Tone);
wrapProperty(self, &s->getSrcRect(), "src_rect", RectType);
wrapProperty(self, &s->getColor(), "color", ColorType);
wrapProperty(self, &s->getTone(), "tone", ToneType);
wrapNilProperty(self, "bitmap");
wrapProperty(self, s->getSrcRect(), "src_rect", RectType);
wrapProperty(self, s->getColor(), "color", ColorType);
wrapProperty(self, s->getTone(), "tone", ToneType);
return self;
}
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")
#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_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>);
@ -121,17 +98,4 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,44 +19,18 @@
** 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;
parseArgsTableSizes(argc, argv, &x, &y, &z);
rb_get_args(argc, argv, "i|ii", &x, &y, &z RB_ARG_END);
Table *t = new Table(x, y, z);
@ -69,12 +43,24 @@ RB_METHOD(tableResize)
{
Table *t = getPrivateData<Table>(self);
int x, y, z;
parseArgsTableSizes(argc, argv, &x, &y, &z);
t->resize(x, y, z);
switch (argc)
{
default:
case 1:
t->resize(FIX2INT(argv[0]));
return Qnil;
case 2:
t->resize(FIX2INT(argv[0]),
FIX2INT(argv[1]));
return Qnil;
case 3:
t->resize(FIX2INT(argv[0]),
FIX2INT(argv[1]),
FIX2INT(argv[2]));
return Qnil;
}
}
#define TABLE_SIZE(d, D) \
@ -82,7 +68,7 @@ RB_METHOD(tableResize)
{ \
RB_UNUSED_PARAM \
Table *t = getPrivateData<Table>(self); \
return INT2NUM(t->d##Size()); \
return rb_int2inum(t->d##Size()); \
}
TABLE_SIZE(x, X)
@ -112,9 +98,9 @@ RB_METHOD(tableGetAt)
return Qnil;
}
short result = t->get(x, y, z);
int result = t->get(x, y, z);
return INT2FIX(result); /* short always fits in a Fixnum */
return rb_int2inum(result);
}
RB_METHOD(tableSetAt)
@ -131,36 +117,37 @@ RB_METHOD(tableSetAt)
{
default:
case 2 :
x = NUM2INT(argv[0]);
value = NUM2INT(argv[1]);
x = FIX2INT(argv[0]);
value = FIX2INT(argv[1]);
break;
case 3 :
x = NUM2INT(argv[0]);
y = NUM2INT(argv[1]);
value = NUM2INT(argv[2]);
x = FIX2INT(argv[0]);
y = FIX2INT(argv[1]);
value = FIX2INT(argv[2]);
break;
case 4 :
x = NUM2INT(argv[0]);
y = NUM2INT(argv[1]);
z = NUM2INT(argv[2]);
value = NUM2INT(argv[3]);
x = FIX2INT(argv[0]);
y = FIX2INT(argv[1]);
z = FIX2INT(argv[2]);
value = FIX2INT(argv[3]);
break;
}
t->set(value, x, y, z);
return argv[argc - 1];
return rb_int2inum(value);
}
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>);
@ -169,7 +156,6 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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"
DEF_TYPE_CUSTOMFREE(TilemapAutotiles, RUBY_TYPED_NEVER_FREE);
rb_data_type_struct TilemapAutotilesType;
RB_METHOD(tilemapAutotilesSet)
{
@ -94,10 +94,6 @@ 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;
}
@ -105,8 +101,6 @@ RB_METHOD(tilemapGetAutotiles)
{
RB_UNUSED_PARAM;
checkDisposed<Tilemap>(self);
return rb_iv_get(self, "autotiles");
}
@ -121,19 +115,23 @@ RB_METHOD(tilemapUpdate)
return Qnil;
}
#define DISP_CLASS_NAME "tilemap"
RB_METHOD(tilemapGetViewport)
{
RB_UNUSED_PARAM;
checkDisposed<Tilemap>(self);
Tilemap *t = getPrivateData<Tilemap>(self);
checkDisposed(t, DISP_CLASS_NAME);
return rb_iv_get(self, "viewport");
}
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_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_B(Tilemap, Visible)
@ -143,12 +141,16 @@ 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>);
@ -168,3 +170,4 @@ tilemapBindingInit()
INIT_PROP_BIND( Tilemap, OX, "ox" );
INIT_PROP_BIND( Tilemap, OY, "oy" );
}

View File

@ -1,169 +0,0 @@
/*
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,7 +20,6 @@
*/
#include "viewport.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "flashable-binding.h"
#include "sceneelement-binding.h"
@ -33,11 +32,7 @@ RB_METHOD(viewportInitialize)
{
Viewport *v;
if (argc == 0 && rgssVer >= 3)
{
v = new Viewport();
}
else if (argc == 1)
if (argc == 1)
{
/* The rect arg is only used to init the viewport,
* and does NOT replace its 'rect' property */
@ -62,23 +57,22 @@ RB_METHOD(viewportInitialize)
setPrivateData(self, v);
/* Wrap property objects */
v->initDynAttribs();
v->setRect(new Rect(*v->getRect()));
v->setColor(new Color);
v->setTone(new Tone);
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());
wrapProperty(self, v->getRect(), "rect", RectType);
wrapProperty(self, v->getColor(), "color", ColorType);
wrapProperty(self, v->getTone(), "tone", ToneType);
return self;
}
DEF_PROP_OBJ_VAL(Viewport, Rect, Rect, "rect")
DEF_PROP_OBJ_VAL(Viewport, Color, Color, "color")
DEF_PROP_OBJ_VAL(Viewport, Tone, Tone, "tone")
#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_I(Viewport, OX)
DEF_PROP_I(Viewport, OY)
@ -87,6 +81,8 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,23 +23,25 @@
#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;
checkDisposed<C>(self);
ViewportElement *ve = getPrivateData<C>(self);
GUARD_EXC( ve->aboutToAccess(); );
return rb_iv_get(self, "viewport");
}
#ifdef RGSS2
template<class C>
RB_METHOD(viewportElementSetViewport)
{
@ -62,6 +64,8 @@ RB_METHOD(viewportElementSetViewport)
return viewportObj;
}
#endif
template<class C>
static C *
viewportElementInitialize(int argc, VALUE *argv, VALUE self)
@ -73,13 +77,8 @@ viewportElementInitialize(int argc, VALUE *argv, VALUE self)
rb_get_args(argc, argv, "|o", &viewportObj RB_ARG_END);
if (!NIL_P(viewportObj))
{
viewport = getPrivateDataCheck<Viewport>(viewportObj, ViewportType);
if (rgssVer == 1)
disposableAddChild(viewportObj, self);
}
/* Construct object */
C *ve = new C(viewport);
@ -97,10 +96,9 @@ viewportElementBindingInit(VALUE klass)
_rb_define_method(klass, "viewport", viewportElementGetViewport<C>);
if (rgssVer >= 2)
{
#ifdef RGSS2
_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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,9 +32,10 @@ RB_METHOD(windowInitialize)
setPrivateData(self, w);
w->initDynAttribs();
wrapProperty(self, &w->getCursorRect(), "cursor_rect", RectType);
w->setCursorRect(new Rect);
wrapNilProperty(self, "windowskin");
wrapNilProperty(self, "contents");
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
return self;
}
@ -50,9 +51,11 @@ RB_METHOD(windowUpdate)
return Qnil;
}
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")
#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_B(Window, Stretch)
DEF_PROP_B(Window, Active)
@ -72,6 +75,8 @@ 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

@ -1,172 +0,0 @@
/*
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,13 +51,11 @@
static void mrbBindingExecute();
static void mrbBindingTerminate();
static void mrbBindingReset();
ScriptBinding scriptBindingImpl =
{
mrbBindingExecute,
mrbBindingTerminate,
mrbBindingReset
mrbBindingTerminate
};
ScriptBinding *scriptBinding = &scriptBindingImpl;
@ -114,17 +112,8 @@ 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);
}
@ -151,7 +140,7 @@ mkxpTimeOp(mrb_state *mrb, mrb_value)
printf("<%s> [%f ms]\n", opName, ms);
fflush(stdout);
return mrb_float_value(mrb, ms);
return mrb__float_value(ms);
}
static const char *
@ -170,7 +159,7 @@ showExcMessageBox(mrb_state *mrb, mrb_value exc)
const char *excClass = mrb_class_name(mrb, mrb_class(mrb, exc));
char msgBoxText[512];
snprintf(msgBoxText, sizeof(msgBoxText), "Script '%s' line %d: %s occured.\n\n%s",
snprintf(msgBoxText, 512, "Script '%s' line %d: %s occured.\n\n%s",
mrbValueString(file), mrb_fixnum(line), excClass, mrbValueString(mesg));
shState->eThread().showMessageBox(msgBoxText, SDL_MESSAGEBOX_ERROR);
@ -201,7 +190,7 @@ static void
runCustomScript(mrb_state *mrb, mrbc_context *ctx, const char *filename)
{
/* Execute custom script */
FILE *f = fopen(filename, "rb");
FILE *f = fopen(filename, "r");
if (!f)
{
@ -226,7 +215,7 @@ static void
runMrbFile(mrb_state *mrb, const char *filename)
{
/* Execute compiled script */
FILE *f = fopen(filename, "rb");
FILE *f = fopen(filename, "r");
if (!f)
{
@ -275,7 +264,7 @@ runRMXPScripts(mrb_state *mrb, mrbc_context *ctx)
mrb_state *scriptMrb = mrb_open();
SDL_RWops ops;
shState->fileSystem().openReadRaw(ops, scriptPack.c_str());
shState->fileSystem().openRead(ops, scriptPack.c_str());
mrb_value scriptArray = mrb_nil_value();
std::string readError;
@ -395,7 +384,7 @@ static void mrbBindingExecute()
checkException(mrb);
shState->rtData().rqTermAck.set();
shState->rtData().rqTermAck = true;
shState->texPool().disable();
mrbc_context_free(mrb, ctx);
@ -409,8 +398,3 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,8 +23,6 @@
#include "util.h"
#include "exception.h"
#include <string.h>
#define SYMD(symbol) { CS##symbol, #symbol }
struct
@ -33,15 +31,14 @@ 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),
@ -52,10 +49,7 @@ struct
SYMD(cursor_rect),
SYMD(path),
SYMD(array),
SYMD(default_color),
SYMD(default_out_color),
SYMD(children),
SYMD(_mkxp_dispose_alias)
SYMD(default_color)
};
static elementsN(symData);
@ -69,6 +63,7 @@ struct MrbExcData
static const MrbExcData excData[] =
{
{ Shutdown, "SystemExit" },
{ RGSS, "RGSSError" },
{ PHYSFS, "PHYSFSError" },
{ SDL, "SDLError" },
{ MKXP, "MKXPError" },
@ -105,21 +100,19 @@ MrbData::MrbData(mrb_state *mrb)
{
int arena = mrb_gc_arena_save(mrb);
for (size_t i = 0; i < excDataN; ++i)
for (int 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 (size_t i = 0; i < enoExcDataN; ++i)
for (int 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 (size_t i = 0; i < symDataN; ++i)
for (int i = 0; i < symDataN; ++i)
symbols[symData[i].ind] = mrb_intern_cstr(mrb, symData[i].str);
mrb_gc_arena_restore(mrb, arena);
@ -148,23 +141,12 @@ 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(self)->struct_name, DATA_PTR(self));
snprintf(buffer, sizeof(buffer), "#<%s:%p>", DATA_TYPE(priv)->struct_name, DATA_PTR(priv));
return mrb_str_new_cstr(mrb, buffer);
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,8 +22,6 @@
#ifndef BINDINGUTIL_H
#define BINDINGUTIL_H
#include "exception.h"
#include <mruby.h>
#include <mruby/data.h>
#include <mruby/variable.h>
@ -34,15 +32,17 @@
enum CommonSymbol
{
CSfont = 0,
CSpriv_iv = 0, /* private data */
/* From here on out all symbols
* have implicit '@' prefix */
CSfont,
CSviewport,
CSbitmap,
CScolor,
CSout_color,
CStone,
CSrect,
CSsrc_rect,
CStilemap,
CStileset,
CSautotiles,
CSmap_data,
@ -54,9 +54,6 @@ enum CommonSymbol
CSpath,
CSarray,
CSdefault_color,
CSdefault_out_color,
CSchildren,
CS_mkxp_dispose_alias,
CommonSymbolsMax
};
@ -101,8 +98,6 @@ 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);
};
@ -117,15 +112,6 @@ 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); } }
@ -152,11 +138,16 @@ defineClass(mrb_state *mrb, const char *name)
#define MRB_FUN_UNUSED_PARAM { (void) mrb; }
/* Object property which is copied by value, not reference */
#define DEF_PROP_OBJ_VAL(Klass, PropKlass, PropName, prop_iv) \
/* 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) \
MRB_METHOD(Klass##Get##PropName) \
{ \
checkDisposed<Klass>(mrb, self); \
Klass *k = getPrivateData<Klass>(mrb, self); (void) k; \
DEF_PROP_CHK_DISP \
return getProperty(mrb, self, prop_iv); \
} \
MRB_METHOD(Klass##Set##PropName) \
@ -166,14 +157,17 @@ defineClass(mrb_state *mrb, const char *name)
PropKlass *prop; \
mrb_get_args(mrb, "o", &propObj); \
prop = getPrivateDataCheck<PropKlass>(mrb, propObj, PropKlass##Type); \
GUARD_EXC( k->set##PropName(*prop); ) \
GUARD_EXC( k->set##PropName(prop); ) \
setProperty(mrb, self, prop_iv, propObj); \
return propObj; \
}
/* Object property which is copied by reference, with allowed NIL */
#define DEF_PROP_OBJ_REF(Klass, PropKlass, PropName, prop_iv) \
/* Object property with allowed NIL */
#define DEF_PROP_OBJ_NIL(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) \
@ -195,9 +189,8 @@ defineClass(mrb_state *mrb, const char *name)
MRB_METHOD(Klass##Get##PropName) \
{ \
Klass *k = getPrivateData<Klass>(mrb, self); \
mrb_type value = 0; \
GUARD_EXC( value = k->get##PropName(); ) \
return mrb_##conv_t##_value(value); \
DEF_PROP_CHK_DISP \
return mrb_##conv_t##_value(k->get##PropName()); \
} \
MRB_METHOD(Klass##Set##PropName) \
{ \
@ -217,16 +210,14 @@ defineClass(mrb_state *mrb, const char *name)
#define DEF_PROP_B(Klass, PropName) \
DEF_PROP(Klass, mrb_bool, PropName, "b", bool)
#define INITCOPY_FUN(Klass) \
MRB_METHOD(Klass##InitializeCopy) \
#define CLONE_FUN(Klass) \
MRB_METHOD(Klass##Clone) \
{ \
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; \
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; \
}
#define MARSH_LOAD_FUN(Klass) \
@ -246,7 +237,7 @@ mrb__float_value(mrb_float f)
{
mrb_value v;
SET_FLOAT_VALUE(0, v, f);
MRB_SET_VALUE(v, MRB_TT_FLOAT, value.f, f);
return v;
}
@ -256,47 +247,71 @@ getSym(mrb_state *mrb, CommonSymbol sym)
return getMrbData(mrb)->symbols[sym];
}
void
raiseDisposedAccess(mrb_state *mrb, mrb_value self);
template<class C>
inline C *
getPrivateData(mrb_state *, mrb_value self)
template<typename T>
inline T *
getPrivateData(mrb_state *mrb, mrb_value self)
{
C *c = static_cast<C*>(DATA_PTR(self));
mrb_value priv = mrb_obj_iv_get(mrb,
mrb_obj_ptr(self),
getSym(mrb, CSpriv_iv));
return c;
return static_cast<T*>(DATA_PTR(priv));
}
template<typename T>
inline T *
getPrivateDataCheck(mrb_state *mrb, mrb_value obj, const mrb_data_type &type)
{
void *ptr = mrb_check_datatype(mrb, obj, &type);
return static_cast<T*>(ptr);
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);
}
inline void
setPrivateData(mrb_value self, void *p, const mrb_data_type &type)
setPrivateData(mrb_state *mrb, mrb_value self, void *p, const mrb_data_type &type)
{
DATA_PTR(self) = p;
DATA_TYPE(self) = &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));
}
inline mrb_value
wrapObject(mrb_state *mrb, void *p, const mrb_data_type &type)
{
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);
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);
setPrivateData(obj, p, type);
setPrivateData(mrb, obj, p, type);
return obj;
}
inline mrb_value
inline void
wrapProperty(mrb_state *mrb, mrb_value self,
void *prop, CommonSymbol iv, const mrb_data_type &type)
{
@ -306,8 +321,15 @@ wrapProperty(mrb_state *mrb, mrb_value self,
mrb_obj_ptr(self),
getSym(mrb, iv),
propObj);
}
return 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());
}
inline mrb_value
@ -356,10 +378,12 @@ 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);
RData *obj = mrb_data_object_alloc(mrb, klass, c, &type);
mrb_value obj_value = mrb_obj_value(obj);
setPrivateData(mrb, obj_value, c, type);
return obj_value;
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,11 +22,12 @@
#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)
@ -48,19 +49,15 @@ MRB_METHOD(bitmapInitialize)
GUARD_EXC( b = new Bitmap(width, height); )
}
setPrivateData(self, b, BitmapType);
setPrivateData(mrb, self, b, BitmapType);
/* Wrap properties */
Font *font = new Font();
b->setInitFont(font);
font->initDynAttribs();
b->setFont(font);
font->setColor(new Color(*font->getColor()));
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);
wrapProperty(mrb, self, font, CSfont, FontType);
wrapProperty(mrb, getProperty(mrb, self, CSfont), font->getColor(), CScolor, ColorType);
return self;
}
@ -192,7 +189,12 @@ MRB_METHOD(bitmapGetPixel)
mrb_get_args(mrb, "ii", &x, &y);
Color value;
GUARD_EXC(
if (x < 0 || y < 0 || x >= b->width() || y >= b->height())
return mrb_nil_value();
)
Vec4 value;
GUARD_EXC( value = b->getPixel(x, y); )
Color *color = new Color(value);
@ -213,7 +215,7 @@ MRB_METHOD(bitmapSetPixel)
color = getPrivateDataCheck<Color>(mrb, colorObj, ColorType);
GUARD_EXC( b->setPixel(x, y, *color); )
GUARD_EXC( b->setPixel(x, y, color->norm); )
return mrb_nil_value();
}
@ -280,7 +282,8 @@ MRB_METHOD(bitmapTextSize)
MRB_METHOD(bitmapGetFont)
{
checkDisposed<Bitmap>(mrb, self);
Bitmap *b = getPrivateData<Bitmap>(mrb, self);
checkDisposed(mrb, b, "bitmap");
return getProperty(mrb, self, CSfont);
}
@ -296,23 +299,23 @@ MRB_METHOD(bitmapSetFont)
font = getPrivateDataCheck<Font>(mrb, fontObj, FontType);
GUARD_EXC( b->setFont(*font); )
GUARD_EXC( b->setFont(font); )
setProperty(mrb, self, CSfont, fontObj);
return mrb_nil_value();
}
INITCOPY_FUN(Bitmap)
CLONE_FUN(Bitmap)
void
bitmapBindingInit(mrb_state *mrb)
{
RClass *klass = defineClass(mrb, "Bitmap");
RClass *klass = mrb_define_class(mrb, "Bitmap", 0);
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_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());
@ -331,4 +334,5 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,57 +25,12 @@
#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)
{
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);
Disposable *d = getPrivateData<C>(mrb, self);
d->dispose();
@ -83,14 +38,9 @@ MRB_METHOD(disposableDispose)
}
template<class C>
MRB_METHOD(disposableIsDisposed)
MRB_METHOD(disposableDisposed)
{
MRB_UNUSED_PARAM;
C *d = static_cast<C*>(DATA_PTR(self));
if (!d)
return mrb_true_value();
Disposable *d = getPrivateData<C>(mrb, self);
return mrb_bool_value(d->isDisposed());
}
@ -99,19 +49,16 @@ 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?", 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"));
mrb_define_method(mrb, klass, "disposed?", disposableDisposed<C>, MRB_ARGS_NONE());
}
template<class C>
inline void
checkDisposed(mrb_state *mrb, mrb_value self)
inline void checkDisposed(mrb_state *mrb, Disposable *d, const char *klassName)
{
if (mrb_test(disposableIsDisposed<C>(0, self)))
raiseDisposedAccess(mrb, self);
MrbData *data = getMrbData(mrb);
if (d->isDisposed())
mrb_raisef(mrb, data->exc[RGSS], "disposed %S",
mrb_str_new_static(mrb, klassName, strlen(klassName)));
}
#endif // DISPOSABLEBINDING_H

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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->get##Attr()); \
return mrb_##mrb_val##_value(p->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->set##Attr(arg); \
p->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(self, k, Klass##Type); \
setPrivateData(mrb, self, k, Klass##Type); \
return self; \
}
@ -159,22 +159,28 @@ MARSH_LOAD_FUN(Color)
MARSH_LOAD_FUN(Tone)
MARSH_LOAD_FUN(Rect)
INITCOPY_FUN(Tone)
INITCOPY_FUN(Color)
INITCOPY_FUN(Rect)
CLONE_FUN(Tone)
CLONE_FUN(Color)
CLONE_FUN(Rect)
#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 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 INIT_BIND(Klass) \
{ \
klass = defineClass(mrb, #Klass); \
klass = mrb_define_class(mrb, #Klass, 0); \
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()); \
@ -185,21 +191,21 @@ void etcBindingInit(mrb_state *mrb)
RClass *klass;
INIT_BIND(Color);
MRB_ATTR_RW(Color, Red, "red" );
MRB_ATTR_RW(Color, Green, "green");
MRB_ATTR_RW(Color, Blue, "blue" );
MRB_ATTR_RW(Color, Alpha, "alpha");
MRB_ATTR_RW(Color, red);
MRB_ATTR_RW(Color, green);
MRB_ATTR_RW(Color, blue);
MRB_ATTR_RW(Color, alpha);
INIT_BIND(Tone);
MRB_ATTR_RW(Tone, Red, "red" );
MRB_ATTR_RW(Tone, Green, "green");
MRB_ATTR_RW(Tone, Blue, "blue" );
MRB_ATTR_RW(Tone, Gray, "gray" );
MRB_ATTR_RW(Tone, red);
MRB_ATTR_RW(Tone, green);
MRB_ATTR_RW(Tone, blue);
MRB_ATTR_RW(Tone, gray);
INIT_BIND(Rect);
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_ATTR_RW(Rect, x);
MRB_ATTR_RW(Rect, y);
MRB_ATTR_RW(Rect, width);
MRB_ATTR_RW(Rect, 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,7 +20,6 @@
*/
#include "font.h"
#include "sharedstate.h"
#include "binding-util.h"
#include "binding-types.h"
#include "exception.h"
@ -31,13 +30,8 @@ DEF_TYPE(Font);
MRB_FUNCTION(fontDoesExist)
{
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);
const char *name;
mrb_get_args(mrb, "z", &name);
return mrb_bool_value(Font::doesExist(name));
}
@ -51,35 +45,11 @@ MRB_METHOD(fontInitialize)
Font *f = new Font(name, size);
setPrivateData(self, f, FontType);
setPrivateData(mrb, 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;
}
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);
f->setColor(new Color(*f->getColor()));
wrapProperty(mrb, self, f->getColor(), CScolor, ColorType);
return self;
}
@ -103,16 +73,13 @@ MRB_METHOD(FontSetName)
return name;
}
template<class C>
static void checkDisposed(mrb_state *, mrb_value) {}
#undef DEF_PROP_CHK_DISP
#define DEF_PROP_CHK_DISP
DEF_PROP_I(Font, Size)
DEF_PROP_B(Font, Bold)
DEF_PROP_B(Font, Italic)
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)
DEF_PROP_OBJ(Font, Color, Color, CScolor)
#define DEF_KLASS_PROP(Klass, mrb_type, PropName, arg_type, conv_t) \
static mrb_value \
@ -132,8 +99,6 @@ DEF_PROP_OBJ_VAL(Font, Color, OutColor, CSout_color)
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)
{
@ -157,33 +122,13 @@ 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);
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);
Font::setDefaultColor(c);
setProperty(mrb, self, CSdefault_color, colorObj);
return colorObj;
}
@ -197,10 +142,10 @@ MRB_METHOD(FontSetDefaultOutColor)
void
fontBindingInit(mrb_state *mrb)
{
RClass *klass = defineClass(mrb, "Font");
RClass *klass = mrb_define_class(mrb, "Font", 0);
Font::initDefaultDynAttribs();
wrapProperty(mrb, mrb_obj_value(klass), &Font::getDefaultColor(), CSdefault_color, ColorType);
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
wrapProperty(mrb, mrb_obj_value(klass), Font::getDefaultColor(), CSdefault_color, ColorType);
mrb_define_class_method(mrb, klass, "exist?", fontDoesExist, MRB_ARGS_REQ(1));
@ -210,20 +155,7 @@ fontBindingInit(mrb_state *mrb)
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");
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");
@ -231,16 +163,5 @@ fontBindingInit(mrb_state *mrb)
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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 = "";
const char *filename = 0;
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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,10 +23,6 @@
#include "sharedstate.h"
#include "exception.h"
#include "binding-util.h"
#include "util.h"
#include <mruby/hash.h>
#include <string.h>
MRB_FUNCTION(inputUpdate)
{
@ -37,59 +33,34 @@ MRB_FUNCTION(inputUpdate)
return mrb_nil_value();
}
static mrb_int getButtonArg(mrb_state *mrb)
MRB_FUNCTION(inputPress)
{
mrb_int num;
mrb_value arg;
mrb_get_args(mrb, "i", &num);
mrb_get_args(mrb, "o", &arg);
Input::ButtonCode bc = (Input::ButtonCode) num;
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;
return mrb_bool_value(shState->input().isPressed(bc));
}
MRB_METHOD(inputPress)
MRB_FUNCTION(inputTrigger)
{
MRB_UNUSED_PARAM;
mrb_int num;
mrb_get_args(mrb, "i", &num);
mrb_int num = getButtonArg(mrb);
Input::ButtonCode bc = (Input::ButtonCode) num;
return mrb_bool_value(shState->input().isPressed(num));
return mrb_bool_value(shState->input().isTriggered(bc));
}
MRB_METHOD(inputTrigger)
MRB_FUNCTION(inputRepeat)
{
MRB_UNUSED_PARAM;
mrb_int num;
mrb_get_args(mrb, "i", &num);
mrb_int num = getButtonArg(mrb);
Input::ButtonCode bc = (Input::ButtonCode) num;
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));
return mrb_bool_value(shState->input().isRepeated(bc));
}
MRB_FUNCTION(inputDir4)
@ -121,43 +92,8 @@ MRB_FUNCTION(inputMouseY)
return mrb_fixnum_value(shState->input().mouseY());
}
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);
#define DEF_CONST_I(name, value) \
mrb_const_set(mrb, mrb_obj_value(module), mrb_intern_lit(mrb, name), mrb_fixnum_value(value))
void
inputBindingInit(mrb_state *mrb)
@ -171,40 +107,34 @@ 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());
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);
}
}
DEF_CONST_I("MOUSELEFT", Input::MouseLeft );
DEF_CONST_I("MOUSEMIDDLE", Input::MouseMiddle);
DEF_CONST_I("MOUSERIGHT", Input::MouseRight );
}

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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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[PATH_MAX];
char buffer[512];
char *unused = realpath(path, buffer);
(void) unused;
@ -321,7 +321,7 @@ readLine(FILE *f, std::vector<char> &buffer)
if (feof(f))
break;
int c = fgetc(f);
char 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 = defineClass(mrb, "IO");
RClass *klass = mrb_define_class(mrb, "IO", 0);
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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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(size_t idx)
bool containsIdx(int idx)
{
if (vec.empty())
return false;
@ -132,7 +132,7 @@ struct LinkBuffer
return idx;
}
T lookup(size_t idx)
T lookup(int idx)
{
return vec[idx];
}
@ -153,9 +153,9 @@ struct MarshalContext
LinkBuffer<mrb_sym> symbols;
LinkBuffer<mrb_value> objects;
int8_t readByte()
char readByte()
{
int8_t byte;
char 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(int8_t byte)
void writeByte(char byte)
{
int result = SDL_RWwrite(ops, &byte, 1, 1);
@ -193,7 +193,7 @@ struct MarshalContext
static int
read_fixnum(MarshalContext *ctx)
{
int8_t head = ctx->readByte();
char head = ctx->readByte();
if (head == 0)
return 0;
@ -202,10 +202,10 @@ read_fixnum(MarshalContext *ctx)
else if (head < -4)
return head + 5;
int8_t pos = (head > 0);
int8_t len = pos ? head : head * -1;
int pos = (head > 0);
int len = pos ? head : head * -1;
int8_t n1, n2, n3, n4;
char n1, n2, n3, n4;
if (pos)
n2 = n3 = n4 = 0;
@ -259,13 +259,21 @@ read_string_value(MarshalContext *ctx)
mrb_state *mrb = ctx->mrb;
int len = read_fixnum(ctx);
mrb_value str = mrb_str_new(mrb, 0, len);
char *ptr = RSTR_PTR(RSTRING(str));
struct RString *str =
(struct RString*) mrb_obj_alloc
(mrb, MRB_TT_STRING, mrb->string_class);
ctx->readData(ptr, len);
ptr[len] = '\0';
str->c = mrb->string_class;
str->len = len;
str->aux.capa = len;
str->ptr = (char*) mrb_malloc(mrb, len+1);
return str;
ctx->readData(str->ptr, len);
str->ptr[len] = '\0';
mrb_value str_obj = mrb_obj_value(str);
return str_obj;
}
static mrb_value read_value(MarshalContext *ctx);
@ -471,7 +479,7 @@ static mrb_value
read_value(MarshalContext *ctx)
{
mrb_state *mrb = ctx->mrb;
int8_t type = ctx->readByte();
char type = ctx->readByte();
mrb_value value;
if (mrb->arena_idx > maxArena)
maxArena = mrb->arena_idx;
@ -559,16 +567,16 @@ write_fixnum(MarshalContext *ctx, int value)
}
else if (value > 0 && value < 123)
{
ctx->writeByte((int8_t) value + 5);
ctx->writeByte((char) value + 5);
return;
}
else if (value < 0 && value > -124)
{
ctx->writeByte((int8_t) value - 5);
ctx->writeByte((char) value - 5);
return;
}
int8_t len;
char len;
if (value > 0)
{
@ -716,7 +724,7 @@ write_symbol(MarshalContext *ctx, mrb_value symbol)
{
mrb_state *mrb = ctx->mrb;
mrb_sym sym = mrb_symbol(symbol);
mrb_int len;
size_t len;
const char *p = mrb_sym2name_len(mrb, sym, &len);
write_string(ctx, p);
@ -875,8 +883,8 @@ writeMarshalHeader(MarshalContext *ctx)
static void
verifyMarshalHeader(MarshalContext *ctx)
{
int8_t maj = ctx->readByte();
int8_t min = ctx->readByte();
char maj = ctx->readByte();
char 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,7 +20,6 @@
*/
#include "rwmem.h"
#include "util.h"
#include <SDL_rwops.h>
@ -102,7 +101,7 @@ int RWMemGetData(SDL_RWops *ops, void *buffer)
ByteVec *v = getRWPrivate(ops);
if (buffer)
memcpy(buffer, dataPtr(*v), v->size());
memcpy(buffer, &(*v)[0], v->size());
return v->size();
}

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 = defineClass(mrb, "Time");
mrb_include_module(mrb, klass, mrb_module_get(mrb, "Comparable"));
RClass *klass = mrb_define_class(mrb, "Time", 0);
mrb_include_module(mrb, klass, mrb_class_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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,19 +31,23 @@ MRB_METHOD(planeInitialize)
{
Plane *p = viewportElementInitialize<Plane>(mrb, self);
setPrivateData(self, p, PlaneType);
setPrivateData(mrb, self, p, PlaneType);
p->initDynAttribs();
p->setColor(new Color);
p->setTone(new Tone);
wrapProperty(mrb, self, &p->getColor(), CScolor, ColorType);
wrapProperty(mrb, self, &p->getTone(), CStone, ToneType);
wrapNilProperty(mrb, self, CSbitmap);
wrapProperty(mrb, self, p->getColor(), CScolor, ColorType);
wrapProperty(mrb, self, p->getTone(), CStone, ToneType);
return self;
}
DEF_PROP_OBJ_REF(Plane, Bitmap, Bitmap, CSbitmap)
DEF_PROP_OBJ_VAL(Plane, Color, Color, CScolor)
DEF_PROP_OBJ_VAL(Plane, Tone, Tone, CStone)
#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_I(Plane, OX)
DEF_PROP_I(Plane, OY)
@ -57,7 +61,7 @@ DEF_PROP_F(Plane, ZoomY)
void
planeBindingInit(mrb_state *mrb)
{
RClass *klass = defineClass(mrb, "Plane");
RClass *klass = mrb_define_class(mrb, "Plane", 0);
disposableBindingInit<Plane> (mrb, klass);
viewportElementBindingInit<Plane>(mrb, klass);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,7 +20,6 @@
*/
#include "sprite.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "flashable-binding.h"
#include "sceneelement-binding.h"
@ -33,22 +32,27 @@ MRB_METHOD(spriteInitialize)
{
Sprite *s = viewportElementInitialize<Sprite>(mrb, self);
setPrivateData(self, s, SpriteType);
setPrivateData(mrb, self, s, SpriteType);
/* Wrap property objects */
s->initDynAttribs();
s->setSrcRect(new Rect);
s->setColor(new Color);
s->setTone(new Tone);
wrapProperty(mrb, self, &s->getSrcRect(), CSsrc_rect, RectType);
wrapProperty(mrb, self, &s->getColor(), CScolor, ColorType);
wrapProperty(mrb, self, &s->getTone(), CStone, ToneType);
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);
return self;
}
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)
#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_I(Sprite, X)
DEF_PROP_I(Sprite, Y)
@ -57,41 +61,17 @@ 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 = defineClass(mrb, "Sprite");
RClass *klass = mrb_define_class(mrb, "Sprite", 0);
disposableBindingInit <Sprite>(mrb, klass);
flashableBindingInit <Sprite>(mrb, klass);
@ -115,16 +95,5 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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(self, t, TableType);
setPrivateData(mrb, self, t, TableType);
return self;
}
@ -141,19 +141,16 @@ MRB_METHOD(tableSetAt)
}
MARSH_LOAD_FUN(Table)
INITCOPY_FUN(Table)
void
tableBindingInit(mrb_state *mrb)
{
RClass *klass = defineClass(mrb, "Table");
RClass *klass = mrb_define_class(mrb, "Table", 0);
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_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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,32 +87,25 @@ MRB_METHOD(tilemapInitialize)
/* Construct object */
t = new Tilemap(viewport);
setPrivateData(self, t, TilemapType);
setPrivateData(mrb, self, t, TilemapType);
setProperty(mrb, self, CSviewport, viewportObj);
wrapProperty(mrb, self, &t->getAutotiles(), CSautotiles, TilemapAutotilesType);
MrbData &mrbData = *getMrbData(mrb);
mrb_value autotilesObj = mrb_iv_get(mrb, self, mrbData.symbols[CSautotiles]);
mrb_value autotilesObj = mrb_iv_get(mrb, self, getMrbData(mrb)->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, 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);
mrb_iv_set(mrb, autotilesObj, getMrbData(mrb)->symbols[CSarray], ary);
return self;
}
MRB_METHOD(tilemapGetAutotiles)
{
checkDisposed<Tilemap>(mrb, self);
return getProperty(mrb, self, CSautotiles);
}
@ -125,17 +118,21 @@ MRB_METHOD(tilemapUpdate)
return mrb_nil_value();
}
#define DISP_CLASS_NAME "tilemap"
MRB_METHOD(tilemapGetViewport)
{
checkDisposed<Tilemap>(mrb, self);
Tilemap *t = getPrivateData<Tilemap>(mrb, self);
checkDisposed(mrb, t, DISP_CLASS_NAME);
return getProperty(mrb, self, CSviewport);
}
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_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_B(Tilemap, Visible)
@ -145,13 +142,13 @@ DEF_PROP_I(Tilemap, OY)
void
tilemapBindingInit(mrb_state *mrb)
{
RClass *klass = defineClass(mrb, "TilemapAutotiles");
RClass *klass = mrb_define_class(mrb, "TilemapAutotiles", 0);
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 = defineClass(mrb, "Tilemap");
klass = mrb_define_class(mrb, "Tilemap", 0);
disposableBindingInit<Tilemap>(mrb, klass);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,21 +54,25 @@ MRB_METHOD(viewportInitialize)
v = new Viewport(x, y, width, height);
}
setPrivateData(self, v, ViewportType);
setPrivateData(mrb, self, v, ViewportType);
/* Wrap property objects */
v->initDynAttribs();
v->setRect(new Rect(*v->getRect()));
v->setColor(new Color);
v->setTone(new Tone);
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;
}
DEF_PROP_OBJ_VAL(Viewport, Rect, Rect, CSrect)
DEF_PROP_OBJ_VAL(Viewport, Color, Color, CScolor)
DEF_PROP_OBJ_VAL(Viewport, Tone, Tone, CStone)
#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_I(Viewport, OX)
DEF_PROP_I(Viewport, OY)
@ -77,7 +81,7 @@ DEF_PROP_I(Viewport, OY)
void
viewportBindingInit(mrb_state *mrb)
{
RClass *klass = defineClass(mrb, "Viewport");
RClass *klass = mrb_define_class(mrb, "Viewport", 0);
disposableBindingInit <Viewport>(mrb, klass);
flashableBindingInit <Viewport>(mrb, klass);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,12 +27,13 @@
#include "binding-types.h"
#include "sceneelement-binding.h"
#include "disposable-binding.h"
template<class C>
MRB_METHOD(viewportElementGetViewport)
{
checkDisposed<C>(mrb, self);
ViewportElement *ve = getPrivateData<C>(mrb, self);
GUARD_EXC( ve->aboutToAccess(); )
return getProperty(mrb, self, CSviewport);
}
@ -48,13 +49,8 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,10 +30,12 @@ MRB_METHOD(windowInitialize)
{
Window *w = viewportElementInitialize<Window>(mrb, self);
setPrivateData(self, w, WindowType);
setPrivateData(mrb, self, w, WindowType);
w->initDynAttribs();
wrapProperty(mrb, self, &w->getCursorRect(), CScursor_rect, RectType);
w->setCursorRect(new Rect);
wrapNilProperty(mrb, self, CSwindowskin);
wrapNilProperty(mrb, self, CScontents);
wrapProperty(mrb, self, w->getCursorRect(), CScursor_rect, RectType);
return self;
}
@ -47,9 +49,11 @@ MRB_METHOD(windowUpdate)
return mrb_nil_value();
}
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)
#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_B(Window, Stretch)
DEF_PROP_B(Window, Active)
@ -69,7 +73,7 @@ DEF_PROP_I(Window, ContentsOpacity)
void
windowBindingInit(mrb_state *mrb)
{
RClass *klass = defineClass(mrb, "Window");
RClass *klass = mrb_define_class(mrb, "Window", 0);
disposableBindingInit <Window>(mrb, klass);
viewportElementBindingInit<Window>(mrb, klass);

View File

@ -3,7 +3,7 @@
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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.set();
shState->rtData().rqTermAck = true;
}
static void nullBindingTerminate()
@ -35,16 +35,10 @@ static void nullBindingTerminate()
}
static void nullBindingReset()
{
}
ScriptBinding scriptBindingImpl =
{
nullBindingExecute,
nullBindingTerminate,
nullBindingReset
nullBindingTerminate
};
ScriptBinding *scriptBinding = &scriptBindingImpl;

View File

@ -1,24 +1,4 @@
# 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
# Lines starting with '#' are comments
# Create a debug context and log
# OpenGL debug information to the console
@ -27,14 +7,6 @@
# 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)
#
@ -57,9 +29,9 @@
# Apply linear interpolation when game screen
# is upscaled
# (default: enabled)
# (default: disabled)
#
# smoothScaling=true
# smoothScaling=false
# Sync screen redraws to the monitor refresh rate
@ -68,30 +40,16 @@
# 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)
# Create the window with 640 in width at startup
#
# 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)
# Create the window with 480 in height at startup
#
# defScreenH=480
# Override the game window title
# (default: none)
#
# windowTitle=Custom Title
# Enforce a static frame rate
# (0 = disabled)
#
@ -104,52 +62,12 @@
# 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)
#
@ -163,31 +81,12 @@
# 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)
#
@ -201,21 +100,12 @@
# 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)
@ -223,82 +113,3 @@
# 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,13 +5,10 @@ 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
}
@ -43,17 +40,17 @@ contains(BINDING, NULL) {
CONFIG += BINDING_NULL
}
RGSS2 {
DEFINES += RGSS2
}
unix {
CONFIG += link_pkgconfig
PKGCONFIG += sigc++-2.0 pixman-1 zlib physfs vorbisfile \
PKGCONFIG += sigc++-2.0 glew pixman-1 zlib physfs \
sdl2 SDL2_image SDL2_ttf SDL_sound openal
SHARED_FLUID {
PKGCONFIG += fluidsynth
}
INI_ENCODING {
PKGCONFIG += libguess
RGSS2 {
PKGCONFIG += vorbisfile
}
# Deal with boost paths...
@ -73,11 +70,7 @@ unix {
LIBS += -L$$BOOST_L
}
isEmpty(BOOST_LIB_SUFFIX) {
BOOST_LIB_SUFFIX = $$(BOOST_LIB_SUFFIX)
}
LIBS += -lboost_program_options$$BOOST_LIB_SUFFIX
LIBS += -lboost_program_options
}
# Input
@ -93,7 +86,6 @@ HEADERS += \
src/flashable.h \
src/font.h \
src/input.h \
src/iniconfig.h \
src/plane.h \
src/scene.h \
src/sprite.h \
@ -108,9 +100,8 @@ HEADERS += \
src/glstate.h \
src/quad.h \
src/tilemap.h \
src/tilemap-common.h \
src/graphics.h \
src/gl-debug.h \
src/debuglogger.h \
src/global-ibo.h \
src/exception.h \
src/filesystem.h \
@ -120,27 +111,12 @@ 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
src/debugwriter.h
SOURCES += \
src/main.cpp \
@ -150,7 +126,6 @@ SOURCES += \
src/filesystem.cpp \
src/font.cpp \
src/input.cpp \
src/iniconfig.cpp \
src/plane.cpp \
src/scene.cpp \
src/sprite.cpp \
@ -164,64 +139,35 @@ SOURCES += \
src/tilemap.cpp \
src/autotiles.cpp \
src/graphics.cpp \
src/gl-debug.cpp \
src/debuglogger.cpp \
src/etc.cpp \
src/config.cpp \
src/settingsmenu.cpp \
src/keybindings.cpp \
src/tileatlas.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
src/perftimer.cpp \
src/sharedstate.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 \
shader/tilemap.vert \
assets/liberation.ttf
RGSS2 {
EMBED += \
shader/blur.frag \
shader/blurH.vert \
shader/blurV.vert \
shader/simpleMatrix.vert \
shader/tilemapvx.vert \
assets/liberation.ttf \
assets/icon.png
SHARED_FLUID {
DEFINES += SHARED_FLUID
}
INI_ENCODING {
DEFINES += INI_ENCODING
shader/simpleMatrix.vert
}
defineReplace(xxdOutput) {
@ -284,11 +230,7 @@ BINDING_MRUBY {
}
BINDING_MRI {
isEmpty(MRIVERSION) {
MRIVERSION = 2.1
}
PKGCONFIG += ruby-$$MRIVERSION
PKGCONFIG += ruby-2.1
DEFINES += BINDING_MRI
# EMBED2 = binding-mri/module_rpg.rb
@ -324,9 +266,5 @@ BINDING_MRI {
binding-mri/tilemap-binding.cpp \
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
binding-mri/filesystem-binding.cpp
}
OTHER_FILES += $$EMBED

View File

@ -0,0 +1,54 @@
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

@ -1,43 +0,0 @@
--- 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 lowp float opacity;
uniform float opacity;
varying vec2 v_texCoord;
@ -20,14 +20,18 @@ void main()
vec4 resFrag;
float co1 = srcFrag.a * opacity;
float co2 = dstFrag.a * (1.0 - co1);
resFrag.a = co1 + co2;
float ab = opacity;
float as = srcFrag.a;
float ad = dstFrag.a;
if (resFrag.a == 0.0)
float at = ab*as;
resFrag.a = at + ad - ad*at;
// Sigh...
if (ad == 0.0)
resFrag.rgb = srcFrag.rgb;
else
resFrag.rgb = (co1*srcFrag.rgb + co2*dstFrag.rgb) / resFrag.a;
resFrag.rgb = as*srcFrag.rgb + (1.0-at) * ad * dstFrag.rgb;
gl_FragColor = resFrag;
}

View File

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

View File

@ -1,15 +0,0 @@
#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 lowp float alpha;
uniform float alpha;
varying lowp vec4 v_color;
varying vec4 v_color;
void main()
{

View File

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

View File

@ -1,19 +0,0 @@
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,40 +1,44 @@
uniform sampler2D texture;
uniform mediump float hueAdjust;
uniform sampler2D inputTexture;
uniform 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 ()
{
vec4 color = texture2D (texture, v_texCoord.xy);
vec3 hsv = rgb2hsv(color.rgb);
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);
hsv.x += hueAdjust;
color.rgb = hsv2rgb(hsv);
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);
/* 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;
}

View File

@ -1,8 +0,0 @@
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 lowp vec4 tone;
uniform vec4 tone;
uniform lowp float opacity;
uniform lowp vec4 color;
uniform lowp vec4 flash;
uniform float opacity;
uniform vec4 color;
uniform vec4 flash;
varying vec2 v_texCoord;

View File

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

View File

@ -1,11 +0,0 @@
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 lowp vec4 v_color;
varying vec4 v_color;
void main()
{

View File

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

View File

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

View File

@ -1,13 +1,13 @@
uniform sampler2D texture;
uniform lowp vec4 tone;
uniform vec4 tone;
uniform lowp float opacity;
uniform lowp vec4 color;
uniform float opacity;
uniform vec4 color;
uniform float bushDepth;
uniform lowp float bushOpacity;
uniform 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 */
lowp float underBush = float(v_texCoord.y < bushDepth);
float underBush = float(v_texCoord.y < bushDepth);
frag.a *= clamp(bushOpacity + underBush, 0.0, 1.0);
gl_FragColor = frag;

View File

@ -1,28 +0,0 @@
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;
}

View File

@ -1,34 +0,0 @@
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);
lowp float alpha = (cTransV - prog) / vague;
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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,8 +23,7 @@
#define ALUTIL_H
#include <al.h>
#include <SDL_audio.h>
#include <assert.h>
#include <alext.h>
namespace AL
{
@ -133,11 +132,6 @@ 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;
@ -192,52 +186,4 @@ 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

View File

@ -1,67 +0,0 @@
/*
** 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

View File

@ -1,479 +0,0 @@
/*
** 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);
}
}

View File

@ -1,122 +0,0 @@
/*
** 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,22 +33,27 @@
* quite make out their meaning yet) */
struct AudioPrivate;
struct RGSSThreadData;
class Audio
{
public:
void bgmPlay(const char *filename,
int volume = 100,
int pitch = 100,
float pos = 0);
int pitch = 100
#ifdef RGSS3
,float pos = 0
#endif
);
void bgmStop();
void bgmFade(int time);
void bgsPlay(const char *filename,
int volume = 100,
int pitch = 100,
float pos = 0);
int pitch = 100
#ifdef RGSS3
,float pos = 0
#endif
);
void bgsStop();
void bgsFade(int time);
@ -63,14 +68,14 @@ public:
int pitch = 100);
void seStop();
#ifdef RGSS3
void setupMidi();
float bgmPos();
float bgsPos();
void reset();
#endif
private:
Audio(RGSSThreadData &rtData);
Audio();
~Audio();
friend struct SharedStatePrivate;

View File

@ -1,365 +0,0 @@
/*
** 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);
}
}

View File

@ -1,154 +0,0 @@
/*
** 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 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 32.5, 80.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 32.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 },
{ 64.5, 16.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 48.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 48.5, 64.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 32.5, 64.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 64.5, 16.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, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 16.5, 80.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 16.5, 64.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 0.5, 80.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 },
{ 80.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, 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 },
{ 80.5, 16.5, 15, 15 },
{ 32.5, 48.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 48.5, 48.5, 15, 15 },
{ 64.5, 16.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 },
{ 64.5, 80.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 64.5, 80.5, 15, 15 },
{ 64.5, 64.5, 15, 15 },
{ 80.5, 64.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 64.5, 16.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 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 32.5, 96.5, 15, 15 },
{ 48.5, 96.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 48.5, 96.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 32.5, 96.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 0.5, 64.5, 15, 15 },
{ 80.5, 64.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 80.5, 80.5, 15, 15 },
{ 0.5, 80.5, 15, 15 },
{ 32.5, 32.5, 15, 15 },
{ 48.5, 32.5, 15, 15 },
{ 32.5, 112.5, 15, 15 },
{ 48.5, 112.5, 15, 15 },
{ 32.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 },
{ 0.5, 48.5, 15, 15 },
{ 80.5, 16.5, 15, 15 },
{ 0.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, 48.5, 15, 15 },
{ 80.5, 48.5, 15, 15 },
{ 64.5, 32.5, 15, 15 },
{ 80.5, 32.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 80.5, 48.5, 15, 15 },
{ 64.5, 16.5, 15, 15 },
{ 64.5, 96.5, 15, 15 },
{ 80.5, 96.5, 15, 15 },
{ 64.5, 112.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 64.5, 112.5, 15, 15 },
{ 64.5, 0.5, 15, 15 },
{ 80.5, 96.5, 15, 15 },
{ 64.5, 112.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 64.5, 112.5, 15, 15 },
{ 0.5, 96.5, 15, 15 },
{ 16.5, 96.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 0.5, 96.5, 15, 15 },
{ 80.5, 0.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 80.5, 32.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 80.5, 48.5, 15, 15 },
{ 0.5, 48.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 16.5, 32.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 0.5, 96.5, 15, 15 },
{ 80.5, 96.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 64.5, 32.5, 15, 15 },
{ 80.5, 32.5, 15, 15 },
{ 64.5, 112.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 64.5, 112.5, 15, 15 },
{ 0.5, 32.5, 15, 15 },
{ 80.5, 32.5, 15, 15 },
{ 0.5, 112.5, 15, 15 },
{ 80.5, 112.5, 15, 15 },
{ 16.5, 112.5, 15, 15 },
{ 64.5, 112.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 }
{ 16.5, 16.5, 15, 15 },
{ 0.5, 16.5, 15, 15 }
};
extern const int autotileRectsN = sizeof(autotileRects) / sizeof(autotileRects[0]);

View File

@ -1,615 +0,0 @@
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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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,10 +35,6 @@ 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 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** 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, IntRect rect,
const Bitmap &source, const IntRect &rect,
int opacity = 255);
void stretchBlt(const IntRect &destRect,
@ -61,6 +61,7 @@ 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,
@ -74,12 +75,14 @@ public:
void clearRect(const IntRect &rect);
void blur();
void radialBlur(int angle, int divisions);
#endif
void clear();
Color getPixel(int x, int y) const;
void setPixel(int x, int y, const Color &color);
Vec4 getPixel(int x, int y) const;
void setPixel(int x, int y, const Vec4 &color);
void hueChange(int hue);
@ -99,13 +102,12 @@ public:
IntRect textSize(const char *str);
DECL_ATTR(Font, Font&)
/* Sets initial reference without copying by value,
* use at construction */
void setInitFont(Font *value);
DECL_ATTR(Font, Font*)
/* <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;
@ -114,14 +116,10 @@ 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