Merge separate RGSS version build configs into one

Setup active RGSS version at runtime. Desired version can be
specified via config, or as default, auto detected from the game
files. This removes the need to build specifically for each
version, which should help packaging a lot.

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

This can be optimized more, eg. not compiling shaders that aren't
needed in the active version.
This commit is contained in:
Jonas Kulla 2014-08-28 23:11:10 +02:00
parent b1981055e1
commit 55f1542c76
41 changed files with 460 additions and 465 deletions

View File

@ -3,7 +3,6 @@ Project(mkxp)
## Setup options ## ## Setup options ##
option(RGSS2 "Enable RGSS2" OFF)
option(MIDI "Enable midi support" ON) option(MIDI "Enable midi support" ON)
option(WORKDIR_CURRENT "Keep current directory on startup" OFF) option(WORKDIR_CURRENT "Keep current directory on startup" OFF)
option(FORCE32 "Force 32bit compile on 64bit OS" OFF) option(FORCE32 "Force 32bit compile on 64bit OS" OFF)
@ -87,6 +86,7 @@ endif()
pkg_check_modules(SIGCXX REQUIRED sigc++-2.0) pkg_check_modules(SIGCXX REQUIRED sigc++-2.0)
pkg_check_modules(PIXMAN REQUIRED pixman-1) pkg_check_modules(PIXMAN REQUIRED pixman-1)
pkg_check_modules(PHYSFS REQUIRED physfs>=2.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 REQUIRED sdl2)
pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf) pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf)
pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image) pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image)
@ -148,6 +148,9 @@ set(MAIN_HEADERS
src/alstream.h src/alstream.h
src/audiostream.h src/audiostream.h
src/rgssad.h src/rgssad.h
src/windowvx.h
src/tilemapvx.h
src/tileatlasvx.h
) )
set(MAIN_SOURCE set(MAIN_SOURCE
@ -185,6 +188,11 @@ set(MAIN_SOURCE
src/audiostream.cpp src/audiostream.cpp
src/rgssad.cpp src/rgssad.cpp
src/bundledfont.cpp src/bundledfont.cpp
src/vorbissource.cpp
src/windowvx.cpp
src/tilemapvx.cpp
src/tileatlasvx.cpp
src/autotilesvx.cpp
) )
source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS}) source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS})
@ -206,22 +214,16 @@ set(EMBEDDED_INPUT
shader/simpleColor.vert shader/simpleColor.vert
shader/sprite.vert shader/sprite.vert
shader/tilemap.vert shader/tilemap.vert
assets/liberation.ttf
)
if (RGSS2)
pkg_check_modules(RGSS2 REQUIRED vorbisfile)
list(APPEND DEFINES
RGSS2
)
list(APPEND MAIN_SOURCE
src/vorbissource.cpp
)
list(APPEND EMBEDDED_INPUT
shader/blur.frag shader/blur.frag
shader/blurH.vert shader/blurH.vert
shader/blurV.vert shader/blurV.vert
shader/simpleMatrix.vert shader/simpleMatrix.vert
assets/liberation.ttf
)
if (RGSS2)
list(APPEND DEFINES
RGSS2
) )
endif() endif()
@ -305,6 +307,8 @@ if (BINDING STREQUAL "MRI")
binding-mri/audio-binding.cpp binding-mri/audio-binding.cpp
binding-mri/module_rpg.cpp binding-mri/module_rpg.cpp
binding-mri/filesystem-binding.cpp binding-mri/filesystem-binding.cpp
binding-mri/windowvx-binding.cpp
binding-mri/tilemapvx-binding.cpp
) )
elseif(BINDING STREQUAL "MRUBY") elseif(BINDING STREQUAL "MRUBY")
message(FATAL_ERROR "Mruby support in CMake needs to be finished") message(FATAL_ERROR "Mruby support in CMake needs to be finished")
@ -395,7 +399,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE
${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory ${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory
${Boost_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
${MRI_INCLUDE_DIRS} ${MRI_INCLUDE_DIRS}
${RGSS2_INCLUDE_DIRS} ${VORBISFILE_INCLUDE_DIRS}
${MIDI_INCLUDE_DIRS} ${MIDI_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR}
) )
@ -410,7 +414,7 @@ target_link_libraries(${PROJECT_NAME}
${PIXMAN_LIBRARIES} ${PIXMAN_LIBRARIES}
${Boost_LIBRARIES} ${Boost_LIBRARIES}
${MRI_LIBRARIES} ${MRI_LIBRARIES}
${RGSS2_LIBRARIES} ${VORBISFILE_LIBRARIES}
${MIDI_LIBRARIES} ${MIDI_LIBRARIES}
${OPENAL_LIBRARY} ${OPENAL_LIBRARY}
${ZLIB_LIBRARY} ${ZLIB_LIBRARY}

View File

@ -58,6 +58,7 @@ This binding only exists for testing purposes and does nothing (the engine quits
* SDL2_image * SDL2_image
* SDL2_ttf * SDL2_ttf
* SDL_sound (latest hg, apply provided patches!) * SDL_sound (latest hg, apply provided patches!)
* vorbisfile
* pixman * pixman
* fluidsynth (if midi enabled) * fluidsynth (if midi enabled)
* zlib (only ruby bindings) * zlib (only ruby bindings)
@ -77,8 +78,6 @@ By default, mkxp switches into the directory where its binary is contained and t
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. 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.
**RGSS Version**: Add `RGSS_VER=<version>`, with `<version>` being either 1, 2 or 3, to the parameter list to select the desired version. The default is 1.
**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). **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. **MRuby-Binding**: place the "mruby" folder into the project folder and build it first. Add `BINDING=MRUBY` to qmake's arguments.

View File

@ -32,7 +32,10 @@
int volume = 100; \ int volume = 100; \
int pitch = 100; \ int pitch = 100; \
double pos = 0.0; \ double pos = 0.0; \
if (rgssVer >= 3) \
rb_get_args(argc, argv, "z|iif", &filename, &volume, &pitch, &pos RB_ARG_END); \ 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); ) \ GUARD_EXC( shState->audio().entity##Play(filename, volume, pitch, pos); ) \
return Qnil; \ return Qnil; \
} \ } \
@ -83,13 +86,8 @@ RB_METHOD(audio_##entity##Fade) \
return rb_float_new(shState->audio().entity##Pos()); \ return rb_float_new(shState->audio().entity##Pos()); \
} }
#ifdef RGSS3
DEF_PLAY_STOP_POS( bgm ) DEF_PLAY_STOP_POS( bgm )
DEF_PLAY_STOP_POS( bgs ) DEF_PLAY_STOP_POS( bgs )
#else
DEF_PLAY_STOP( bgm )
DEF_PLAY_STOP( bgs )
#endif
DEF_PLAY_STOP( me ) DEF_PLAY_STOP( me )
@ -124,10 +122,11 @@ audioBindingInit()
BIND_PLAY_STOP_FADE( bgs ); BIND_PLAY_STOP_FADE( bgs );
BIND_PLAY_STOP_FADE( me ); BIND_PLAY_STOP_FADE( me );
#ifdef RGSS3 if (rgssVer >= 3)
{
BIND_POS( bgm ); BIND_POS( bgm );
BIND_POS( bgs ); BIND_POS( bgs );
#endif }
BIND_PLAY_STOP( se ) BIND_PLAY_STOP( se )
} }

View File

@ -30,13 +30,15 @@
#include <ruby.h> #include <ruby.h>
#include <ruby/encoding.h> #include <ruby/encoding.h>
#include <assert.h>
#include <string> #include <string>
#include <zlib.h> #include <zlib.h>
#include <SDL_filesystem.h> #include <SDL_filesystem.h>
extern const char module_rpg[]; extern const char module_rpg1[];
extern const char module_rpg2[];
extern const char module_rpg3[];
static void mriBindingExecute(); static void mriBindingExecute();
static void mriBindingTerminate(); static void mriBindingTerminate();
@ -58,11 +60,8 @@ void viewportBindingInit();
void planeBindingInit(); void planeBindingInit();
void windowBindingInit(); void windowBindingInit();
void tilemapBindingInit(); void tilemapBindingInit();
#ifdef RGSS2
void windowVXBindingInit(); void windowVXBindingInit();
void tilemapVXBindingInit(); void tilemapVXBindingInit();
#endif
void inputBindingInit(); void inputBindingInit();
void audioBindingInit(); void audioBindingInit();
@ -75,11 +74,8 @@ RB_METHOD(mriP);
RB_METHOD(mriDataDirectory); RB_METHOD(mriDataDirectory);
RB_METHOD(mkxpPuts); RB_METHOD(mkxpPuts);
#ifdef RGSS3
RB_METHOD(mriRgssMain); RB_METHOD(mriRgssMain);
#else
RB_METHOD(_kernelCaller); RB_METHOD(_kernelCaller);
#endif
static void mriBindingInit() static void mriBindingInit()
{ {
@ -91,13 +87,16 @@ static void mriBindingInit()
viewportBindingInit(); viewportBindingInit();
planeBindingInit(); planeBindingInit();
#ifdef RGSS2 if (rgssVer == 1)
windowVXBindingInit(); {
tilemapVXBindingInit();
#else
windowBindingInit(); windowBindingInit();
tilemapBindingInit(); tilemapBindingInit();
#endif }
else
{
windowVXBindingInit();
tilemapVXBindingInit();
}
inputBindingInit(); inputBindingInit();
audioBindingInit(); audioBindingInit();
@ -105,27 +104,35 @@ static void mriBindingInit()
fileIntBindingInit(); fileIntBindingInit();
#ifdef RGSS3 if (rgssVer >= 3)
{
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain); _rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
_rb_define_module_function(rb_mKernel, "msgbox", mriPrint); _rb_define_module_function(rb_mKernel, "msgbox", mriPrint);
_rb_define_module_function(rb_mKernel, "msgbox_p", mriP); _rb_define_module_function(rb_mKernel, "msgbox_p", mriP);
#else }
else
{
_rb_define_module_function(rb_mKernel, "print", mriPrint); _rb_define_module_function(rb_mKernel, "print", mriPrint);
_rb_define_module_function(rb_mKernel, "p", mriP); _rb_define_module_function(rb_mKernel, "p", mriP);
#endif
rb_eval_string(module_rpg); rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller");
_rb_define_module_function(rb_mKernel, "caller", _kernelCaller);
}
if (rgssVer == 1)
rb_eval_string(module_rpg1);
else if (rgssVer == 2)
rb_eval_string(module_rpg2);
else if (rgssVer == 3)
rb_eval_string(module_rpg3);
else
assert(!"unreachable");
VALUE mod = rb_define_module("System"); VALUE mod = rb_define_module("System");
_rb_define_module_function(mod, "data_directory", mriDataDirectory); _rb_define_module_function(mod, "data_directory", mriDataDirectory);
_rb_define_module_function(mod, "puts", mkxpPuts); _rb_define_module_function(mod, "puts", mkxpPuts);
#ifndef RGSS3
rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller");
_rb_define_module_function(rb_mKernel, "caller", _kernelCaller);
#endif
rb_gv_set("MKXP", Qtrue); rb_gv_set("MKXP", Qtrue);
} }
@ -200,8 +207,6 @@ RB_METHOD(mriDataDirectory)
return pathStr; return pathStr;
} }
#ifdef RGSS3
RB_METHOD(mriRgssMain) RB_METHOD(mriRgssMain)
{ {
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
@ -212,8 +217,6 @@ RB_METHOD(mriRgssMain)
return Qnil; return Qnil;
} }
#else
RB_METHOD(_kernelCaller) RB_METHOD(_kernelCaller)
{ {
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
@ -246,8 +249,6 @@ RB_METHOD(_kernelCaller)
return trace; return trace;
} }
#endif
static VALUE newStringUTF8(const char *string, long length) static VALUE newStringUTF8(const char *string, long length)
{ {
return rb_enc_str_new(string, length, rb_utf8_encoding()); return rb_enc_str_new(string, length, rb_utf8_encoding());
@ -287,12 +288,6 @@ static void runCustomScript(const std::string &filename)
VALUE kernelLoadDataInt(const char *filename); VALUE kernelLoadDataInt(const char *filename);
#ifdef RGSS3
#define RGSS_SECTION_STR "{%04ld}"
#else
#define RGSS_SECTION_STR "Section%03ld"
#endif
static void runRMXPScripts() static void runRMXPScripts()
{ {
const Config &conf = shState->rtData().config; const Config &conf = shState->rtData().config;
@ -391,7 +386,8 @@ static void runRMXPScripts()
else else
{ {
char buf[32]; char buf[32];
int len = snprintf(buf, sizeof(buf), RGSS_SECTION_STR, i); const char *format = rgssVer >= 3 ? "{%04ld}" : "Section%03ld";
int len = snprintf(buf, sizeof(buf), format, i);
fname = newStringUTF8(buf, len); fname = newStringUTF8(buf, len);
} }

View File

@ -47,10 +47,8 @@ struct RbData
{ {
VALUE exc[RbExceptionsMax]; VALUE exc[RbExceptionsMax];
#ifdef RGSS3 /* Input module (RGSS3) */
/* Input module */
VALUE buttoncodeHash; VALUE buttoncodeHash;
#endif
RbData(); RbData();
~RbData(); ~RbData();

View File

@ -22,6 +22,7 @@
#include "bitmap.h" #include "bitmap.h"
#include "font.h" #include "font.h"
#include "exception.h" #include "exception.h"
#include "sharedstate.h"
#include "disposable-binding.h" #include "disposable-binding.h"
#include "binding-util.h" #include "binding-util.h"
#include "binding-types.h" #include "binding-types.h"
@ -252,7 +253,8 @@ RB_METHOD(bitmapDrawText)
VALUE rectObj; VALUE rectObj;
Rect *rect; Rect *rect;
#ifdef RGSS2 if (rgssVer >= 2)
{
VALUE strObj; VALUE strObj;
rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END); rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END);
@ -260,9 +262,11 @@ RB_METHOD(bitmapDrawText)
strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0); strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
str = RSTRING_PTR(strObj); str = RSTRING_PTR(strObj);
#else }
else
{
rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END); rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END);
#endif }
rect = getPrivateDataCheck<Rect>(rectObj, RectType); rect = getPrivateDataCheck<Rect>(rectObj, RectType);
@ -272,7 +276,8 @@ RB_METHOD(bitmapDrawText)
{ {
int x, y, width, height; int x, y, width, height;
#ifdef RGSS2 if (rgssVer >= 2)
{
VALUE strObj; VALUE strObj;
rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END); rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END);
@ -280,9 +285,11 @@ RB_METHOD(bitmapDrawText)
strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0); strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
str = RSTRING_PTR(strObj); str = RSTRING_PTR(strObj);
#else }
else
{
rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END); rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END);
#endif }
GUARD_EXC( b->drawText(x, y, width, height, str, align); ); GUARD_EXC( b->drawText(x, y, width, height, str, align); );
} }
@ -296,7 +303,8 @@ RB_METHOD(bitmapTextSize)
const char *str; const char *str;
#ifdef RGSS2 if (rgssVer >= 2)
{
VALUE strObj; VALUE strObj;
rb_get_args(argc, argv, "o", &strObj RB_ARG_END); rb_get_args(argc, argv, "o", &strObj RB_ARG_END);
@ -304,9 +312,11 @@ RB_METHOD(bitmapTextSize)
strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0); strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
str = RSTRING_PTR(strObj); str = RSTRING_PTR(strObj);
#else }
else
{
rb_get_args(argc, argv, "z", &str RB_ARG_END); rb_get_args(argc, argv, "z", &str RB_ARG_END);
#endif }
IntRect value; IntRect value;
GUARD_EXC( value = b->textSize(str); ); GUARD_EXC( value = b->textSize(str); );
@ -318,8 +328,6 @@ RB_METHOD(bitmapTextSize)
DEF_PROP_OBJ(Bitmap, Font, Font, "font") DEF_PROP_OBJ(Bitmap, Font, Font, "font")
#ifdef RGSS2
RB_METHOD(bitmapGradientFillRect) RB_METHOD(bitmapGradientFillRect)
{ {
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
@ -408,8 +416,6 @@ RB_METHOD(bitmapRadialBlur)
return Qnil; return Qnil;
} }
#endif
// FIXME: This isn't entire correct as the cloned bitmap // FIXME: This isn't entire correct as the cloned bitmap
// does not get a cloned version of the original bitmap's 'font' // does not get a cloned version of the original bitmap's 'font'
// attribute (the internal font attrb is the default one, whereas // attribute (the internal font attrb is the default one, whereas
@ -444,12 +450,13 @@ bitmapBindingInit()
_rb_define_method(klass, "draw_text", bitmapDrawText); _rb_define_method(klass, "draw_text", bitmapDrawText);
_rb_define_method(klass, "text_size", bitmapTextSize); _rb_define_method(klass, "text_size", bitmapTextSize);
#ifdef RGSS2 if (rgssVer >= 2)
{
_rb_define_method(klass, "gradient_fill_rect", bitmapGradientFillRect); _rb_define_method(klass, "gradient_fill_rect", bitmapGradientFillRect);
_rb_define_method(klass, "clear_rect", bitmapClearRect); _rb_define_method(klass, "clear_rect", bitmapClearRect);
_rb_define_method(klass, "blur", bitmapBlur); _rb_define_method(klass, "blur", bitmapBlur);
_rb_define_method(klass, "radial_blur", bitmapRadialBlur); _rb_define_method(klass, "radial_blur", bitmapRadialBlur);
#endif }
INIT_PROP_BIND(Bitmap, Font, "font"); INIT_PROP_BIND(Bitmap, Font, "font");
} }

View File

@ -61,10 +61,11 @@ RB_METHOD(fontInitialize)
f->setColor(new Color(*f->getColor())); f->setColor(new Color(*f->getColor()));
wrapProperty(self, f->getColor(), "color", ColorType); wrapProperty(self, f->getColor(), "color", ColorType);
#ifdef RGSS3 if (rgssVer >= 3)
{
f->setOutColor(new Color(*f->getOutColor())); f->setOutColor(new Color(*f->getOutColor()));
wrapProperty(self, f->getOutColor(), "out_color", ColorType); wrapProperty(self, f->getOutColor(), "out_color", ColorType);
#endif }
if (NIL_P(name)) if (NIL_P(name))
name = rb_iv_get(rb_obj_class(self), "default_name"); name = rb_iv_get(rb_obj_class(self), "default_name");
@ -92,10 +93,11 @@ RB_METHOD(fontInitializeCopy)
f->setColor(new Color(*f->getColor())); f->setColor(new Color(*f->getColor()));
wrapProperty(self, f->getColor(), "color", ColorType); wrapProperty(self, f->getColor(), "color", ColorType);
#ifdef RGSS3 if (rgssVer >= 3)
{
f->setOutColor(new Color(*f->getOutColor())); f->setOutColor(new Color(*f->getOutColor()));
wrapProperty(self, f->getOutColor(), "out_color", ColorType); wrapProperty(self, f->getOutColor(), "out_color", ColorType);
#endif }
return self; return self;
} }
@ -166,16 +168,10 @@ RB_METHOD(FontSetName)
DEF_PROP_I(Font, Size) DEF_PROP_I(Font, Size)
DEF_PROP_B(Font, Bold) DEF_PROP_B(Font, Bold)
DEF_PROP_B(Font, Italic) DEF_PROP_B(Font, Italic)
DEF_PROP_OBJ(Font, Color, Color, "color")
#ifdef RGSS2
DEF_PROP_B(Font, Shadow) DEF_PROP_B(Font, Shadow)
#endif
#ifdef RGSS3
DEF_PROP_B(Font, Outline) DEF_PROP_B(Font, Outline)
DEF_PROP_OBJ(Font, Color, Color, "color")
DEF_PROP_OBJ(Font, Color, OutColor, "out_color") DEF_PROP_OBJ(Font, Color, OutColor, "out_color")
#endif
#define DEF_KLASS_PROP(Klass, type, PropName, param_t_s, value_fun) \ #define DEF_KLASS_PROP(Klass, type, PropName, param_t_s, value_fun) \
RB_METHOD(Klass##Get##PropName) \ RB_METHOD(Klass##Get##PropName) \
@ -195,12 +191,7 @@ DEF_PROP_OBJ(Font, Color, OutColor, "out_color")
DEF_KLASS_PROP(Font, int, DefaultSize, "i", rb_fix_new) DEF_KLASS_PROP(Font, int, DefaultSize, "i", rb_fix_new)
DEF_KLASS_PROP(Font, bool, DefaultBold, "b", rb_bool_new) DEF_KLASS_PROP(Font, bool, DefaultBold, "b", rb_bool_new)
DEF_KLASS_PROP(Font, bool, DefaultItalic, "b", rb_bool_new) DEF_KLASS_PROP(Font, bool, DefaultItalic, "b", rb_bool_new)
#ifdef RGSS2
DEF_KLASS_PROP(Font, bool, DefaultShadow, "b", rb_bool_new) DEF_KLASS_PROP(Font, bool, DefaultShadow, "b", rb_bool_new)
#endif
#ifdef RGSS3
DEF_KLASS_PROP(Font, bool, DefaultOutline, "b", rb_bool_new) DEF_KLASS_PROP(Font, bool, DefaultOutline, "b", rb_bool_new)
RB_METHOD(FontGetDefaultOutColor) RB_METHOD(FontGetDefaultOutColor)
@ -221,7 +212,6 @@ RB_METHOD(FontSetDefaultOutColor)
return colorObj; return colorObj;
} }
#endif
RB_METHOD(FontGetDefaultName) RB_METHOD(FontGetDefaultName)
{ {
@ -285,14 +275,16 @@ fontBindingInit()
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic"); INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color"); INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
#ifdef RGSS2 if (rgssVer >= 2)
{
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow"); INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
#endif }
#ifdef RGSS3 if (rgssVer >= 3)
{
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline"); INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color"); INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
#endif }
rb_define_class_method(klass, "exist?", fontDoesExist); rb_define_class_method(klass, "exist?", fontDoesExist);
@ -305,12 +297,14 @@ fontBindingInit()
INIT_PROP_BIND(Font, Italic, "italic"); INIT_PROP_BIND(Font, Italic, "italic");
INIT_PROP_BIND(Font, Color, "color"); INIT_PROP_BIND(Font, Color, "color");
#ifdef RGSS2 if (rgssVer >= 2)
{
INIT_PROP_BIND(Font, Shadow, "shadow"); INIT_PROP_BIND(Font, Shadow, "shadow");
#endif }
#ifdef RGSS3 if (rgssVer >= 3)
{
INIT_PROP_BIND(Font, Outline, "outline"); INIT_PROP_BIND(Font, Outline, "outline");
INIT_PROP_BIND(Font, OutColor, "out_color"); INIT_PROP_BIND(Font, OutColor, "out_color");
#endif }
} }

View File

@ -97,11 +97,6 @@ RB_METHOD(graphicsFrameReset)
return rb_bool_new(value); \ return rb_bool_new(value); \
} }
DEF_GRA_PROP_I(FrameRate)
DEF_GRA_PROP_I(FrameCount)
#ifdef RGSS2
RB_METHOD(graphicsWidth) RB_METHOD(graphicsWidth)
{ {
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
@ -179,10 +174,10 @@ RB_METHOD(graphicsResizeScreen)
return Qnil; return Qnil;
} }
DEF_GRA_PROP_I(FrameRate)
DEF_GRA_PROP_I(FrameCount)
DEF_GRA_PROP_I(Brightness) DEF_GRA_PROP_I(Brightness)
#endif
DEF_GRA_PROP_B(Fullscreen) DEF_GRA_PROP_B(Fullscreen)
DEF_GRA_PROP_B(ShowCursor) DEF_GRA_PROP_B(ShowCursor)
@ -204,7 +199,8 @@ void graphicsBindingInit()
INIT_GRA_PROP_BIND( FrameRate, "frame_rate" ); INIT_GRA_PROP_BIND( FrameRate, "frame_rate" );
INIT_GRA_PROP_BIND( FrameCount, "frame_count" ); INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
#ifdef RGSS2 if (rgssVer >= 2)
{
_rb_define_module_function(module, "width", graphicsWidth); _rb_define_module_function(module, "width", graphicsWidth);
_rb_define_module_function(module, "height", graphicsHeight); _rb_define_module_function(module, "height", graphicsHeight);
_rb_define_module_function(module, "wait", graphicsWait); _rb_define_module_function(module, "wait", graphicsWait);
@ -214,7 +210,7 @@ void graphicsBindingInit()
_rb_define_module_function(module, "resize_screen", graphicsResizeScreen); _rb_define_module_function(module, "resize_screen", graphicsResizeScreen);
INIT_GRA_PROP_BIND( Brightness, "brightness" ); INIT_GRA_PROP_BIND( Brightness, "brightness" );
#endif }
INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" ); INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" );
INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" ); INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );

View File

@ -38,15 +38,18 @@ static int getButtonArg(int argc, VALUE *argv)
{ {
int num; int num;
#ifdef RGSS3 if (rgssVer >= 3)
{
ID sym; ID sym;
rb_get_args(argc, argv, "n", &sym RB_ARG_END); rb_get_args(argc, argv, "n", &sym RB_ARG_END);
VALUE symHash = getRbData()->buttoncodeHash; VALUE symHash = getRbData()->buttoncodeHash;
num = FIX2INT(rb_hash_lookup2(symHash, ID2SYM(sym), INT2FIX(Input::None))); num = FIX2INT(rb_hash_lookup2(symHash, ID2SYM(sym), INT2FIX(Input::None)));
#else }
else
{
rb_get_args(argc, argv, "i", &num RB_ARG_END); rb_get_args(argc, argv, "i", &num RB_ARG_END);
#endif }
return num; return num;
} }
@ -161,15 +164,8 @@ inputBindingInit()
_rb_define_module_function(module, "mouse_x", inputMouseX); _rb_define_module_function(module, "mouse_x", inputMouseX);
_rb_define_module_function(module, "mouse_y", inputMouseY); _rb_define_module_function(module, "mouse_y", inputMouseY);
#ifndef RGSS3 if (rgssVer >= 3)
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);
}
#else
VALUE symHash = rb_hash_new(); VALUE symHash = rb_hash_new();
for (size_t i = 0; i < buttonCodesN; ++i) for (size_t i = 0; i < buttonCodesN; ++i)
@ -185,5 +181,15 @@ inputBindingInit()
rb_iv_set(module, "buttoncodes", symHash); rb_iv_set(module, "buttoncodes", symHash);
getRbData()->buttoncodeHash = symHash; getRbData()->buttoncodeHash = symHash;
#endif }
else
{
for (size_t i = 0; i < buttonCodesN; ++i)
{
ID sym = rb_intern(buttonCodes[i].str);
VALUE val = INT2FIX(buttonCodes[i].val);
rb_const_set(module, sym, val);
}
}
} }

View File

@ -1,8 +1,4 @@
#ifdef RGSS3 # include "module_rpg1.rb.xxd"
# include "module_rpg3.rb.xxd"
#elif RGSS2
# include "module_rpg2.rb.xxd" # include "module_rpg2.rb.xxd"
#else # include "module_rpg3.rb.xxd"
# include "module_rpg.rb.xxd"
#endif

View File

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

View File

@ -1,4 +1,4 @@
extern const char module_rpg[] = { extern const char module_rpg2[] = {
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x52, 0x50, 0x47, 0x0a, 0x20, 0x20, 0x63, 0x6c, 0x61, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x52, 0x50, 0x47, 0x0a, 0x20, 0x20, 0x63, 0x6c, 0x61,
0x73, 0x73, 0x20, 0x4d, 0x61, 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x66, 0x20, 0x69, 0x73, 0x73, 0x20, 0x4d, 0x61, 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x66, 0x20, 0x69,
0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x28, 0x77, 0x69, 0x64, 0x74, 0x68, 0x2c, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x28, 0x77, 0x69, 0x64, 0x74, 0x68, 0x2c,
@ -1441,4 +1441,4 @@ extern const char module_rpg[] = {
0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65,
0x6e, 0x64, 0x0a, 0x00 0x6e, 0x64, 0x0a, 0x00
}; };
extern const unsigned int module_rpg_len = 23043; extern const unsigned int module_rpg2_len = 23043;

View File

@ -1,4 +1,4 @@
extern const char module_rpg[] = { extern const char module_rpg3[] = {
0x0a, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x52, 0x50, 0x47, 0x0a, 0x20, 0x20, 0x63, 0x6c, 0x0a, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x52, 0x50, 0x47, 0x0a, 0x20, 0x20, 0x63, 0x6c,
0x61, 0x73, 0x73, 0x20, 0x4d, 0x61, 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x61, 0x73, 0x73, 0x20, 0x4d, 0x61, 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6c, 0x61, 0x73,
0x73, 0x20, 0x45, 0x6e, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x73, 0x20, 0x45, 0x6e, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x0a, 0x20, 0x20, 0x20, 0x20,
@ -1401,4 +1401,4 @@ extern const char module_rpg[] = {
0x65, 0x5f, 0x73, 0x74, 0x6f, 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x65, 0x5f, 0x73, 0x74, 0x6f, 0x70, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20,
0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x00 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x00
}; };
extern const unsigned int module_rpg_len = 22410; extern const unsigned int module_rpg3_len = 22410;

View File

@ -20,6 +20,7 @@
*/ */
#include "sprite.h" #include "sprite.h"
#include "sharedstate.h"
#include "disposable-binding.h" #include "disposable-binding.h"
#include "flashable-binding.h" #include "flashable-binding.h"
#include "sceneelement-binding.h" #include "sceneelement-binding.h"
@ -60,15 +61,17 @@ DEF_PROP_I(Sprite, OY)
DEF_PROP_I(Sprite, BushDepth) DEF_PROP_I(Sprite, BushDepth)
DEF_PROP_I(Sprite, Opacity) DEF_PROP_I(Sprite, Opacity)
DEF_PROP_I(Sprite, BlendType) 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, ZoomX)
DEF_PROP_F(Sprite, ZoomY) DEF_PROP_F(Sprite, ZoomY)
DEF_PROP_F(Sprite, Angle) DEF_PROP_F(Sprite, Angle)
DEF_PROP_F(Sprite, WavePhase)
DEF_PROP_B(Sprite, Mirror) DEF_PROP_B(Sprite, Mirror)
#ifdef RGSS2
RB_METHOD(spriteWidth) RB_METHOD(spriteWidth)
{ {
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
@ -93,13 +96,6 @@ RB_METHOD(spriteHeight)
return rb_fix_new(value); return rb_fix_new(value);
} }
DEF_PROP_I(Sprite, WaveAmp)
DEF_PROP_I(Sprite, WaveLength)
DEF_PROP_I(Sprite, WaveSpeed)
DEF_PROP_F(Sprite, WavePhase)
#endif
void void
spriteBindingInit() spriteBindingInit()
{ {
@ -130,7 +126,8 @@ spriteBindingInit()
INIT_PROP_BIND( Sprite, Color, "color" ); INIT_PROP_BIND( Sprite, Color, "color" );
INIT_PROP_BIND( Sprite, Tone, "tone" ); INIT_PROP_BIND( Sprite, Tone, "tone" );
#ifdef RGSS2 if (rgssVer >= 2)
{
_rb_define_method(klass, "width", spriteWidth); _rb_define_method(klass, "width", spriteWidth);
_rb_define_method(klass, "height", spriteHeight); _rb_define_method(klass, "height", spriteHeight);
@ -138,5 +135,5 @@ spriteBindingInit()
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" ); INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" ); INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" ); INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
#endif }
} }

View File

@ -23,17 +23,12 @@
#include "viewport.h" #include "viewport.h"
#include "bitmap.h" #include "bitmap.h"
#include "table.h" #include "table.h"
#include "sharedstate.h"
#include "disposable-binding.h" #include "disposable-binding.h"
#include "binding-util.h" #include "binding-util.h"
#include "binding-types.h" #include "binding-types.h"
#ifdef RGSS3
# define FLAGS_PROP "flags"
#else
# define FLAGS_PROP "passages"
#endif
DEF_TYPE(TilemapVX); DEF_TYPE(TilemapVX);
rb_data_type_struct BitmapArrayType; rb_data_type_struct BitmapArrayType;
@ -93,7 +88,7 @@ DEF_PROP_OBJ_NIL(TilemapVX, Viewport, Viewport, "viewport")
DEF_PROP_OBJ(TilemapVX, Table, MapData, "map_data") DEF_PROP_OBJ(TilemapVX, Table, MapData, "map_data")
DEF_PROP_OBJ(TilemapVX, Table, FlashData, "flash_data") DEF_PROP_OBJ(TilemapVX, Table, FlashData, "flash_data")
DEF_PROP_OBJ(TilemapVX, Table, Flags, FLAGS_PROP) DEF_PROP_OBJ(TilemapVX, Table, Flags, "flags")
DEF_PROP_B(TilemapVX, Visible) DEF_PROP_B(TilemapVX, Visible)
@ -149,11 +144,19 @@ tilemapVXBindingInit()
INIT_PROP_BIND( TilemapVX, Viewport, "viewport" ); INIT_PROP_BIND( TilemapVX, Viewport, "viewport" );
INIT_PROP_BIND( TilemapVX, MapData, "map_data" ); INIT_PROP_BIND( TilemapVX, MapData, "map_data" );
INIT_PROP_BIND( TilemapVX, FlashData, "flash_data" ); INIT_PROP_BIND( TilemapVX, FlashData, "flash_data" );
INIT_PROP_BIND( TilemapVX, Flags, FLAGS_PROP );
INIT_PROP_BIND( TilemapVX, Visible, "visible" ); INIT_PROP_BIND( TilemapVX, Visible, "visible" );
INIT_PROP_BIND( TilemapVX, OX, "ox" ); INIT_PROP_BIND( TilemapVX, OX, "ox" );
INIT_PROP_BIND( TilemapVX, OY, "oy" ); INIT_PROP_BIND( TilemapVX, OY, "oy" );
if (rgssVer == 3)
{
INIT_PROP_BIND( TilemapVX, Flags, "flags" );
}
else
{
INIT_PROP_BIND( TilemapVX, Flags, "passages" );
}
initType(BitmapArrayType, "BitmapArray", 0); initType(BitmapArrayType, "BitmapArray", 0);
klass = rb_define_class_under(klass, "BitmapArray", rb_cObject); klass = rb_define_class_under(klass, "BitmapArray", rb_cObject);

View File

@ -20,6 +20,7 @@
*/ */
#include "viewport.h" #include "viewport.h"
#include "sharedstate.h"
#include "disposable-binding.h" #include "disposable-binding.h"
#include "flashable-binding.h" #include "flashable-binding.h"
#include "sceneelement-binding.h" #include "sceneelement-binding.h"
@ -32,14 +33,11 @@ RB_METHOD(viewportInitialize)
{ {
Viewport *v; Viewport *v;
#ifdef RGSS3 if (argc == 0 && rgssVer >= 3)
if (argc == 0)
{ {
v = new Viewport(); v = new Viewport();
} }
else else if (argc == 1)
#endif
if (argc == 1)
{ {
/* The rect arg is only used to init the viewport, /* The rect arg is only used to init the viewport,
* and does NOT replace its 'rect' property */ * and does NOT replace its 'rect' property */

View File

@ -23,6 +23,7 @@
#define VIEWPORTELEMENTBINDING_H #define VIEWPORTELEMENTBINDING_H
#include "viewport.h" #include "viewport.h"
#include "sharedstate.h"
#include "binding-util.h" #include "binding-util.h"
#include "binding-types.h" #include "binding-types.h"
@ -39,8 +40,6 @@ RB_METHOD(viewportElementGetViewport)
return rb_iv_get(self, "viewport"); return rb_iv_get(self, "viewport");
} }
#ifdef RGSS2
template<class C> template<class C>
RB_METHOD(viewportElementSetViewport) RB_METHOD(viewportElementSetViewport)
{ {
@ -63,8 +62,6 @@ RB_METHOD(viewportElementSetViewport)
return viewportObj; return viewportObj;
} }
#endif
template<class C> template<class C>
static C * static C *
viewportElementInitialize(int argc, VALUE *argv, VALUE self) viewportElementInitialize(int argc, VALUE *argv, VALUE self)
@ -98,9 +95,10 @@ viewportElementBindingInit(VALUE klass)
_rb_define_method(klass, "viewport", viewportElementGetViewport<C>); _rb_define_method(klass, "viewport", viewportElementGetViewport<C>);
#ifdef RGSS2 if (rgssVer >= 2)
{
_rb_define_method(klass, "viewport=", viewportElementSetViewport<C>); _rb_define_method(klass, "viewport=", viewportElementSetViewport<C>);
#endif }
} }
#endif // VIEWPORTELEMENTBINDING_H #endif // VIEWPORTELEMENTBINDING_H

View File

@ -34,7 +34,8 @@ RB_METHOD(windowVXInitialize)
{ {
WindowVX *w; WindowVX *w;
#if RGSS_VER == 3 if (rgssVer >= 3)
{
int x, y, width, height; int x, y, width, height;
x = y = width = height = 0; x = y = width = height = 0;
@ -42,9 +43,11 @@ RB_METHOD(windowVXInitialize)
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END); rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
w = new WindowVX(x, y, width, height); w = new WindowVX(x, y, width, height);
#else }
else
{
w = viewportElementInitialize<WindowVX>(argc, argv, self); w = viewportElementInitialize<WindowVX>(argc, argv, self);
#endif }
setPrivateData(self, w); setPrivateData(self, w);
@ -54,12 +57,13 @@ RB_METHOD(windowVXInitialize)
wrapProperty(self, w->getTone(), "tone", ToneType); wrapProperty(self, w->getTone(), "tone", ToneType);
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType); wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
#ifdef RGSS2 if (rgssVer >= 2)
{
Bitmap *contents = new Bitmap(1, 1); Bitmap *contents = new Bitmap(1, 1);
VALUE contentsObj = wrapObject(contents, BitmapType); VALUE contentsObj = wrapObject(contents, BitmapType);
bitmapInitProps(contents, contentsObj); bitmapInitProps(contents, contentsObj);
rb_iv_set(self, "contents", contentsObj); rb_iv_set(self, "contents", contentsObj);
#endif }
return self; return self;
} }

View File

@ -98,9 +98,7 @@ struct MrbData
* so I can measure how much of a speed difference they make */ * so I can measure how much of a speed difference they make */
mrb_sym symbols[CommonSymbolsMax]; mrb_sym symbols[CommonSymbolsMax];
#ifdef RGSS3
mrb_value buttoncodeHash; mrb_value buttoncodeHash;
#endif
MrbData(mrb_state *mrb); MrbData(mrb_state *mrb);
}; };

View File

@ -41,7 +41,8 @@ static mrb_int getButtonArg(mrb_state *mrb)
{ {
mrb_int num; mrb_int num;
#ifdef RGSS3 if (rgssVer >= 3)
{
mrb_sym sym; mrb_sym sym;
mrb_get_args(mrb, "n", &sym); mrb_get_args(mrb, "n", &sym);
@ -49,9 +50,11 @@ static mrb_int getButtonArg(mrb_state *mrb)
mrb_value numVal = mrb_hash_fetch(mrb, symHash, mrb_symbol_value(sym), mrb_value numVal = mrb_hash_fetch(mrb, symHash, mrb_symbol_value(sym),
mrb_fixnum_value(Input::None)); mrb_fixnum_value(Input::None));
num = mrb_fixnum(numVal); num = mrb_fixnum(numVal);
#else }
else
{
mrb_get_args(mrb, "i", &num); mrb_get_args(mrb, "i", &num);
#endif }
return num; return num;
} }
@ -167,16 +170,8 @@ inputBindingInit(mrb_state *mrb)
mrb_value modVal = mrb_obj_value(module); mrb_value modVal = mrb_obj_value(module);
#ifndef RGSS3 if (rgssVer >= 3)
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);
}
#else
mrb_value symHash = mrb_hash_new_capa(mrb, buttonCodesN); mrb_value symHash = mrb_hash_new_capa(mrb, buttonCodesN);
for (size_t i = 0; i < buttonCodesN; ++i) for (size_t i = 0; i < buttonCodesN; ++i)
@ -194,5 +189,16 @@ inputBindingInit(mrb_state *mrb)
mrb_iv_set(mrb, modVal, mrb_intern_lit(mrb, "buttoncodes"), symHash); mrb_iv_set(mrb, modVal, mrb_intern_lit(mrb, "buttoncodes"), symHash);
getMrbData(mrb)->buttoncodeHash = symHash; getMrbData(mrb)->buttoncodeHash = symHash;
#endif }
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);
}
}
} }

View File

@ -59,15 +59,17 @@ DEF_PROP_I(Sprite, OY)
DEF_PROP_I(Sprite, BushDepth) DEF_PROP_I(Sprite, BushDepth)
DEF_PROP_I(Sprite, Opacity) DEF_PROP_I(Sprite, Opacity)
DEF_PROP_I(Sprite, BlendType) 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, ZoomX)
DEF_PROP_F(Sprite, ZoomY) DEF_PROP_F(Sprite, ZoomY)
DEF_PROP_F(Sprite, Angle) DEF_PROP_F(Sprite, Angle)
DEF_PROP_F(Sprite, WavePhase)
DEF_PROP_B(Sprite, Mirror) DEF_PROP_B(Sprite, Mirror)
#ifdef RGSS2
MRB_METHOD(spriteWidth) MRB_METHOD(spriteWidth)
{ {
Sprite *s = getPrivateData<Sprite>(mrb, self); Sprite *s = getPrivateData<Sprite>(mrb, self);
@ -88,13 +90,6 @@ MRB_METHOD(spriteHeight)
return mrb_fixnum_value(value); return mrb_fixnum_value(value);
} }
DEF_PROP_I(Sprite, WaveAmp)
DEF_PROP_I(Sprite, WaveLength)
DEF_PROP_I(Sprite, WaveSpeed)
DEF_PROP_F(Sprite, WavePhase)
#endif
void void
spriteBindingInit(mrb_state *mrb) spriteBindingInit(mrb_state *mrb)
{ {
@ -122,7 +117,8 @@ spriteBindingInit(mrb_state *mrb)
INIT_PROP_BIND( Sprite, Color, "color" ); INIT_PROP_BIND( Sprite, Color, "color" );
INIT_PROP_BIND( Sprite, Tone, "tone" ); INIT_PROP_BIND( Sprite, Tone, "tone" );
#ifdef RGSS2 if (rgssVer >= 2)
{
mrb_define_method(mrb, klass, "width", spriteWidth, MRB_ARGS_NONE()); mrb_define_method(mrb, klass, "width", spriteWidth, MRB_ARGS_NONE());
mrb_define_method(mrb, klass, "height", spriteHeight, MRB_ARGS_NONE()); mrb_define_method(mrb, klass, "height", spriteHeight, MRB_ARGS_NONE());
@ -130,7 +126,7 @@ spriteBindingInit(mrb_state *mrb)
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" ); INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" ); INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" ); INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
#endif }
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE()); mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
} }

View File

@ -1,5 +1,15 @@
# Lines starting with '#' are comments # Lines starting with '#' are comments
# Specify the RGSS version to run under.
# Possible values are 0, 1, 2, 3. If set to 0,
# mkxp will try to guess the required version
# based on the game files found in gameFolder.
# If this fails, the version defaults to 1.
# (default: 0)
#
# rgssVersion=1
# Create a debug context and log # Create a debug context and log
# OpenGL debug information to the console # OpenGL debug information to the console
# (default: disabled) # (default: disabled)
@ -40,12 +50,20 @@
# vsync=false # vsync=false
# Create the window with 640 in width at startup # Specify the window width on startup. If set to 0,
# it will default to the default resolution width
# specific to the RGSS version (640 in RGSS1, 544
# in RGSS2 or higher).
# (default: 0)
# #
# defScreenW=640 # defScreenW=640
# Create the window with 480 in height at startup # Specify the window height on startup. If set to 0,
# it will default to the default resolution height
# specific to the RGSS version (480 in RGSS1, 416
# in RGSS2 or higher).
# (default: 0)
# #
# defScreenH=480 # defScreenH=480

View File

@ -45,45 +45,11 @@ contains(BINDING, NULL) {
CONFIG += BINDING_NULL CONFIG += BINDING_NULL
} }
# TODO: Use RGSS_VER macro instead of RGSSN in C++ sources
isEmpty(RGSS_VER) {
RGSS_VER = 1
}
contains(RGSS_VER, 1) {
_HAVE_RGSS_VER = YES
DEFINES += "RGSS_VER=1"
}
contains(RGSS_VER, 2) {
contains(_HAVE_RGSS_VER, YES) {
error("Only one RGSS version may be selected")
}
_HAVE_RGSS_VER = YES
CONFIG += RGSS2
DEFINES += RGSS2 "RGSS_VER=2"
}
contains(RGSS_VER, 3) {
contains(_HAVE_RGSS_VER, YES) {
error("Only one RGSS version may be selected")
}
_HAVE_RGSS_VER = YES
CONFIG += RGSS2 RGSS3
DEFINES += RGSS2 RGSS3 "RGSS_VER=3"
}
unix { unix {
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
PKGCONFIG += sigc++-2.0 pixman-1 zlib physfs \ PKGCONFIG += sigc++-2.0 pixman-1 zlib physfs vorbisfile \
sdl2 SDL2_image SDL2_ttf SDL_sound openal sdl2 SDL2_image SDL2_ttf SDL_sound openal
RGSS2 {
PKGCONFIG += vorbisfile
}
MIDI { MIDI {
PKGCONFIG += fluidsynth PKGCONFIG += fluidsynth
} }
@ -166,7 +132,10 @@ HEADERS += \
src/aldatasource.h \ src/aldatasource.h \
src/alstream.h \ src/alstream.h \
src/audiostream.h \ src/audiostream.h \
src/rgssad.h src/rgssad.h \
src/windowvx.h \
src/tilemapvx.h \
src/tileatlasvx.h
SOURCES += \ SOURCES += \
src/main.cpp \ src/main.cpp \
@ -202,7 +171,12 @@ SOURCES += \
src/alstream.cpp \ src/alstream.cpp \
src/audiostream.cpp \ src/audiostream.cpp \
src/rgssad.cpp \ src/rgssad.cpp \
src/bundledfont.cpp src/bundledfont.cpp \
src/vorbissource.cpp \
src/windowvx.cpp \
src/tilemapvx.cpp \
src/tileatlasvx.cpp \
src/autotilesvx.cpp
EMBED = \ EMBED = \
shader/transSimple.frag \ shader/transSimple.frag \
@ -219,28 +193,12 @@ EMBED = \
shader/simpleColor.vert \ shader/simpleColor.vert \
shader/sprite.vert \ shader/sprite.vert \
shader/tilemap.vert \ shader/tilemap.vert \
assets/liberation.ttf
RGSS2 {
HEADERS += \
src/windowvx.h \
src/tilemapvx.h \
src/tileatlasvx.h
SOURCES += \
src/vorbissource.cpp \
src/windowvx.cpp \
src/tilemapvx.cpp \
src/tileatlasvx.cpp \
src/autotilesvx.cpp
EMBED += \
shader/blur.frag \ shader/blur.frag \
shader/blurH.vert \ shader/blurH.vert \
shader/blurV.vert \ shader/blurV.vert \
shader/simpleMatrix.vert \ shader/simpleMatrix.vert \
shader/tilemapvx.vert shader/tilemapvx.vert \
} assets/liberation.ttf
MIDI { MIDI {
HEADERS += \ HEADERS += \
@ -352,13 +310,9 @@ BINDING_MRI {
binding-mri/tilemap-binding.cpp \ binding-mri/tilemap-binding.cpp \
binding-mri/audio-binding.cpp \ binding-mri/audio-binding.cpp \
binding-mri/module_rpg.cpp \ binding-mri/module_rpg.cpp \
binding-mri/filesystem-binding.cpp binding-mri/filesystem-binding.cpp \
RGSS2 {
SOURCES += \
binding-mri/windowvx-binding.cpp \ binding-mri/windowvx-binding.cpp \
binding-mri/tilemapvx-binding.cpp binding-mri/tilemapvx-binding.cpp
} }
}
OTHER_FILES += $$EMBED OTHER_FILES += $$EMBED

View File

@ -58,10 +58,8 @@ ALDataSource *createSDLSource(SDL_RWops &ops,
uint32_t maxBufSize, uint32_t maxBufSize,
bool looped); bool looped);
#ifdef RGSS2
ALDataSource *createVorbisSource(SDL_RWops &ops, ALDataSource *createVorbisSource(SDL_RWops &ops,
bool looped); bool looped);
#endif
#ifdef MIDI #ifdef MIDI
ALDataSource *createMidiSource(SDL_RWops &ops, ALDataSource *createMidiSource(SDL_RWops &ops,

View File

@ -198,19 +198,25 @@ void ALStream::openSource(const std::string &filename)
shState->fileSystem().openRead(srcOps, filename.c_str(), FileSystem::Audio, false, &ext); shState->fileSystem().openRead(srcOps, filename.c_str(), FileSystem::Audio, false, &ext);
needsRewind = false; needsRewind = false;
#if RGSS2 || MIDI bool readSig = rgssVer >= 2;
#ifdef MIDI
readSig = true;
#endif
if (readSig)
{
/* Try to read ogg file signature */ /* Try to read ogg file signature */
char sig[5] = { 0 }; char sig[5] = { 0 };
SDL_RWread(&srcOps, sig, 1, 4); SDL_RWread(&srcOps, sig, 1, 4);
SDL_RWseek(&srcOps, 0, RW_SEEK_SET); SDL_RWseek(&srcOps, 0, RW_SEEK_SET);
#ifdef RGSS2
if (!strcmp(sig, "OggS")) if (!strcmp(sig, "OggS"))
{ {
source = createVorbisSource(srcOps, looped); source = createVorbisSource(srcOps, looped);
return; return;
} }
#endif
#ifdef MIDI #ifdef MIDI
if (!strcmp(sig, "MThd")) if (!strcmp(sig, "MThd"))
{ {
@ -218,7 +224,7 @@ void ALStream::openSource(const std::string &filename)
return; return;
} }
#endif #endif
#endif }
source = createSDLSource(srcOps, ext, STREAM_BUF_SIZE, looped); source = createSDLSource(srcOps, ext, STREAM_BUF_SIZE, looped);
} }

View File

@ -551,8 +551,6 @@ void Bitmap::clearRect(const IntRect &rect)
p->onModified(); p->onModified();
} }
#ifdef RGSS2
void Bitmap::blur() void Bitmap::blur()
{ {
GUARD_MEGA; GUARD_MEGA;
@ -689,8 +687,6 @@ void Bitmap::radialBlur(int angle, int divisions)
p->onModified(); p->onModified();
} }
#endif
void Bitmap::clear() void Bitmap::clear()
{ {
GUARD_MEGA; GUARD_MEGA;

View File

@ -73,10 +73,8 @@ public:
int width, int height); int width, int height);
void clearRect(const IntRect &rect); void clearRect(const IntRect &rect);
#ifdef RGSS2
void blur(); void blur();
void radialBlur(int angle, int divisions); void radialBlur(int angle, int divisions);
#endif
void clear(); void clear();

View File

@ -122,14 +122,15 @@ typedef std::vector<std::string> StringVec;
namespace po = boost::program_options; namespace po = boost::program_options;
Config::Config() Config::Config()
: debugMode(false), : rgssVersion(0),
debugMode(false),
winResizable(false), winResizable(false),
fullscreen(false), fullscreen(false),
fixedAspectRatio(true), fixedAspectRatio(true),
smoothScaling(false), smoothScaling(false),
vsync(false), vsync(false),
defScreenW(DEF_SCREEN_W), defScreenW(0),
defScreenH(DEF_SCREEN_H), defScreenH(0),
fixedFramerate(0), fixedFramerate(0),
frameSkip(true), frameSkip(true),
solidFonts(false), solidFonts(false),
@ -147,6 +148,7 @@ Config::Config()
void Config::read(int argc, char *argv[]) void Config::read(int argc, char *argv[])
{ {
#define PO_DESC_ALL \ #define PO_DESC_ALL \
PO_DESC(rgssVersion, int) \
PO_DESC(debugMode, bool) \ PO_DESC(debugMode, bool) \
PO_DESC(winResizable, bool) \ PO_DESC(winResizable, bool) \
PO_DESC(fullscreen, bool) \ PO_DESC(fullscreen, bool) \
@ -219,7 +221,7 @@ void Config::read(int argc, char *argv[])
GUARD_ALL( fontSubs = vm["fontSub"].as<StringVec>(); ); GUARD_ALL( fontSubs = vm["fontSub"].as<StringVec>(); );
GUARD_ALL( rubyLoadpaths = vm["rubyLoadpath"].as<StringVec>(); ) GUARD_ALL( rubyLoadpaths = vm["rubyLoadpath"].as<StringVec>(); );
#undef PO_DESC #undef PO_DESC
#undef PO_DESC_ALL #undef PO_DESC_ALL
@ -329,4 +331,31 @@ void Config::readGameINI()
if (game.title.empty()) if (game.title.empty())
game.title = baseName(gameFolder); game.title = baseName(gameFolder);
if (rgssVersion == 0)
{
/* Try to guess RGSS version based on Data/Scripts extension */
rgssVersion = 1;
if (!game.scripts.empty())
{
const char *p = &game.scripts[game.scripts.size()];
const char *head = &game.scripts[0];
while (--p != head)
if (*p == '.')
break;
if (!strcmp(p, ".rvdata"))
rgssVersion = 2;
else if (!strcmp(p, ".rvdata2"))
rgssVersion = 3;
}
}
if (defScreenW <= 0)
defScreenW = (rgssVersion == 1 ? 640 : 544);
if (defScreenH <= 0)
defScreenH = (rgssVersion == 1 ? 480 : 416);
} }

View File

@ -25,16 +25,10 @@
#include <string> #include <string>
#include <vector> #include <vector>
#ifndef RGSS2
# define DEF_SCREEN_W 640
# define DEF_SCREEN_H 480
#else
# define DEF_SCREEN_W 544
# define DEF_SCREEN_H 416
#endif
struct Config struct Config
{ {
int rgssVersion;
bool debugMode; bool debugMode;
bool winResizable; bool winResizable;

View File

@ -48,14 +48,6 @@ BUNDLED_FONT_DECL(liberation)
#define BNDL_F_D(f) BUNDLED_FONT_D(f) #define BNDL_F_D(f) BUNDLED_FONT_D(f)
#define BNDL_F_L(f) BUNDLED_FONT_L(f) #define BNDL_F_L(f) BUNDLED_FONT_L(f)
#ifdef RGSS3
# define DEF_SHADOW false
# define DEF_OUTLINE true
#else
# define DEF_SHADOW true
# define DEF_OUTLINE false
#endif
typedef std::pair<std::string, int> FontKey; typedef std::pair<std::string, int> FontKey;
static SDL_RWops *openBundledFont() static SDL_RWops *openBundledFont()
@ -269,14 +261,20 @@ std::string FontPrivate::defaultName = "Arial";
int FontPrivate::defaultSize = 22; int FontPrivate::defaultSize = 22;
bool FontPrivate::defaultBold = false; bool FontPrivate::defaultBold = false;
bool FontPrivate::defaultItalic = false; bool FontPrivate::defaultItalic = false;
bool FontPrivate::defaultOutline = DEF_OUTLINE; bool FontPrivate::defaultOutline = false; /* Inited at runtime */
bool FontPrivate::defaultShadow = DEF_SHADOW; bool FontPrivate::defaultShadow = false; /* Inited at runtime */
Color *FontPrivate::defaultColor = &FontPrivate::defaultColorTmp; Color *FontPrivate::defaultColor = &FontPrivate::defaultColorTmp;
Color *FontPrivate::defaultOutColor = &FontPrivate::defaultOutColorTmp; Color *FontPrivate::defaultOutColor = &FontPrivate::defaultOutColorTmp;
Color FontPrivate::defaultColorTmp(255, 255, 255, 255); Color FontPrivate::defaultColorTmp(255, 255, 255, 255);
Color FontPrivate::defaultOutColorTmp(0, 0, 0, 128); Color FontPrivate::defaultOutColorTmp(0, 0, 0, 128);
void Font::initDefaults()
{
FontPrivate::defaultOutline = (rgssVer >= 3 ? true : false);
FontPrivate::defaultShadow = (rgssVer >= 3 ? false : true );
}
bool Font::doesExist(const char *name) bool Font::doesExist(const char *name)
{ {
if (!name) if (!name)

View File

@ -102,6 +102,8 @@ public:
DECL_ATTR_STATIC( DefaultOutline, bool ) DECL_ATTR_STATIC( DefaultOutline, bool )
DECL_ATTR_STATIC( DefaultOutColor, Color* ) DECL_ATTR_STATIC( DefaultOutColor, Color* )
static void initDefaults();
/* internal */ /* internal */
_TTF_Font *getSdlFont(); _TTF_Font *getSdlFont();

View File

@ -45,11 +45,9 @@
#include <errno.h> #include <errno.h>
#include <algorithm> #include <algorithm>
#ifdef RGSS2 #define DEF_SCREEN_W (rgssVer == 1 ? 640 : 544)
# define DEF_FRAMERATE 60 #define DEF_SCREEN_H (rgssVer == 1 ? 480 : 416)
#else #define DEF_FRAMERATE (rgssVer == 1 ? 40 : 60)
# define DEF_FRAMERATE 40
#endif
struct PingPong struct PingPong
{ {

View File

@ -205,23 +205,32 @@ static const KbBindingData defaultKbBindings[] =
{ SDL_SCANCODE_B, Input::None }, { SDL_SCANCODE_B, Input::None },
{ SDL_SCANCODE_D, Input::Z }, { SDL_SCANCODE_D, Input::Z },
{ SDL_SCANCODE_Q, Input::L }, { SDL_SCANCODE_Q, Input::L },
{ SDL_SCANCODE_W, Input::R }, { SDL_SCANCODE_W, Input::R }
#if RGSS_VER == 1 };
/* RGSS1 */
static const KbBindingData defaultKbBindings1[] =
{
{ SDL_SCANCODE_Z, Input::A }, { SDL_SCANCODE_Z, Input::A },
{ SDL_SCANCODE_C, Input::C }, { SDL_SCANCODE_C, Input::C },
{ SDL_SCANCODE_V, Input::Z }, { SDL_SCANCODE_V, Input::Z },
{ SDL_SCANCODE_A, Input::Y }, { SDL_SCANCODE_A, Input::Y },
{ SDL_SCANCODE_S, Input::X } { SDL_SCANCODE_S, Input::X }
#else };
/* RGSS2 and higher */
static const KbBindingData defaultKbBindings2[] =
{
{ SDL_SCANCODE_Z, Input::C }, { SDL_SCANCODE_Z, Input::C },
{ SDL_SCANCODE_C, Input::None }, { SDL_SCANCODE_C, Input::None },
{ SDL_SCANCODE_V, Input::None }, { SDL_SCANCODE_V, Input::None },
{ SDL_SCANCODE_A, Input::X }, { SDL_SCANCODE_A, Input::X },
{ SDL_SCANCODE_S, Input::Y } { SDL_SCANCODE_S, Input::Y }
#endif
}; };
static elementsN(defaultKbBindings); static elementsN(defaultKbBindings);
static elementsN(defaultKbBindings1);
static elementsN(defaultKbBindings2);
/* Rebindable */ /* Rebindable */
static const JsBindingData defaultJsBindings[] = static const JsBindingData defaultJsBindings[] =
@ -374,15 +383,20 @@ struct InputPrivate
void initKbBindings() void initKbBindings()
{ {
kbBindings.resize(staticKbBindingsN+defaultKbBindingsN); kbBindings.clear();
size_t n = 0;
for (size_t i = 0; i < staticKbBindingsN; ++i) for (size_t i = 0; i < staticKbBindingsN; ++i)
kbBindings[n++] = KbBinding(staticKbBindings[i]); kbBindings.push_back(KbBinding(staticKbBindings[i]));
for (size_t i = 0; i < defaultKbBindingsN; ++i) for (size_t i = 0; i < defaultKbBindingsN; ++i)
kbBindings[n++] = KbBinding(defaultKbBindings[i]); kbBindings.push_back(KbBinding(defaultKbBindings[i]));
if (rgssVer == 1)
for (size_t i = 0; i < defaultKbBindings1N; ++i)
kbBindings.push_back(KbBinding(defaultKbBindings1[i]));
else
for (size_t i = 0; i < defaultKbBindings2N; ++i)
kbBindings.push_back(KbBinding(defaultKbBindings2[i]));
/* Add to binging array */ /* Add to binging array */
for (size_t i = 0; i < kbBindings.size(); ++i) for (size_t i = 0; i < kbBindings.size(); ++i)

View File

@ -179,13 +179,15 @@ bool SceneElement::operator<(const SceneElement &o) const
{ {
if (z == o.z) if (z == o.z)
{ {
#ifdef RGSS2 if (rgssVer >= 2)
{
/* RGSS2: If two sprites' Z values collide, /* RGSS2: If two sprites' Z values collide,
* their Y coordinates decide draw order. Only * their Y coordinates decide draw order. Only
* on equal Y does the creation time take effect */ * on equal Y does the creation time take effect */
if (isSprite && o.isSprite && spriteY != o.spriteY) if (isSprite && o.isSprite && spriteY != o.spriteY)
return (spriteY < o.spriteY); return (spriteY < o.spriteY);
#endif }
return (creationStamp <= o.creationStamp); return (creationStamp <= o.creationStamp);
} }

View File

@ -42,14 +42,11 @@
#include "../simpleColor.vert.xxd" #include "../simpleColor.vert.xxd"
#include "../sprite.vert.xxd" #include "../sprite.vert.xxd"
#include "../tilemap.vert.xxd" #include "../tilemap.vert.xxd"
#ifdef RGSS2
#include "../blur.frag.xxd" #include "../blur.frag.xxd"
#include "../simpleMatrix.vert.xxd" #include "../simpleMatrix.vert.xxd"
#include "../blurH.vert.xxd" #include "../blurH.vert.xxd"
#include "../blurV.vert.xxd" #include "../blurV.vert.xxd"
#include "../tilemapvx.vert.xxd" #include "../tilemapvx.vert.xxd"
#endif
#define INIT_SHADER(vert, frag, name) \ #define INIT_SHADER(vert, frag, name) \
@ -505,8 +502,6 @@ void HueShader::setInputTexture(TEX::ID tex)
} }
#ifdef RGSS2
SimpleMatrixShader::SimpleMatrixShader() SimpleMatrixShader::SimpleMatrixShader()
{ {
INIT_SHADER(simpleMatrix, simpleAlpha, SimpleMatrixShader); INIT_SHADER(simpleMatrix, simpleAlpha, SimpleMatrixShader);
@ -551,8 +546,6 @@ void TilemapVXShader::setAniOffset(const Vec2 &value)
gl.Uniform2f(u_aniOffset, value.x, value.y); gl.Uniform2f(u_aniOffset, value.x, value.y);
} }
#endif
BltShader::BltShader() BltShader::BltShader()
{ {

View File

@ -213,7 +213,6 @@ private:
GLint u_hueAdjust, u_inputTexture; GLint u_hueAdjust, u_inputTexture;
}; };
#ifdef RGSS2
class SimpleMatrixShader : public ShaderBase class SimpleMatrixShader : public ShaderBase
{ {
public: public:
@ -255,8 +254,6 @@ private:
GLint u_aniOffset; GLint u_aniOffset;
}; };
#endif
/* Bitmap blit */ /* Bitmap blit */
class BltShader : public ShaderBase class BltShader : public ShaderBase
{ {
@ -288,12 +285,9 @@ struct ShaderSet
SimpleTransShader simpleTrans; SimpleTransShader simpleTrans;
HueShader hue; HueShader hue;
BltShader blt; BltShader blt;
#ifdef RGSS2
SimpleMatrixShader simpleMatrix; SimpleMatrixShader simpleMatrix;
BlurShader blur; BlurShader blur;
TilemapVXShader tilemapVX; TilemapVXShader tilemapVX;
#endif
}; };
#endif // SHADER_H #endif // SHADER_H

View File

@ -46,15 +46,21 @@
#include <string> #include <string>
SharedState *SharedState::instance = 0; SharedState *SharedState::instance = 0;
int SharedState::rgssVersion = 0;
static GlobalIBO *_globalIBO = 0; static GlobalIBO *_globalIBO = 0;
#ifdef RGSS3 static const char *defGameArchive()
#define GAME_ARCHIVE "Game.rgss3a" {
#elif RGSS2 if (rgssVer == 1)
#define GAME_ARCHIVE "Game.rgss2a" return "Game.rgssad";
#else else if (rgssVer == 2)
#define GAME_ARCHIVE "Game.rgssad" return "Game.rgss2a";
#endif else if (rgssVer == 3)
return "Game.rgss3a";
assert(!"unreachable");
return 0;
}
struct SharedStatePrivate struct SharedStatePrivate
{ {
@ -122,7 +128,7 @@ struct SharedStatePrivate
} }
// FIXME find out correct archive filename // FIXME find out correct archive filename
std::string archPath = GAME_ARCHIVE; std::string archPath = defGameArchive();
/* Check if a game archive exists */ /* Check if a game archive exists */
FILE *tmp = fopen(archPath.c_str(), "r"); FILE *tmp = fopen(archPath.c_str(), "r");
@ -158,7 +164,8 @@ struct SharedStatePrivate
/* RGSS3 games will call setup_midi, so there's /* RGSS3 games will call setup_midi, so there's
* no need to do it on startup */ * no need to do it on startup */
#if MIDI && !RGSS3 #if MIDI
if (rgssVer <= 2)
midiState.initDefaultSynths(); midiState.initDefaultSynths();
#endif #endif
} }
@ -177,6 +184,9 @@ void SharedState::initInstance(RGSSThreadData *threadData)
* SharedState depends on GlobalIBO existing, * SharedState depends on GlobalIBO existing,
* Font depends on SharedState existing */ * Font depends on SharedState existing */
rgssVersion = threadData->config.rgssVersion;
Font::initDefaults();
_globalIBO = new GlobalIBO(); _globalIBO = new GlobalIBO();
_globalIBO->ensureSize(1); _globalIBO->ensureSize(1);

View File

@ -26,6 +26,7 @@
#define shState SharedState::instance #define shState SharedState::instance
#define glState shState->_glState() #define glState shState->_glState()
#define rgssVer SharedState::rgssVersion
struct SharedStatePrivate; struct SharedStatePrivate;
struct RGSSThreadData; struct RGSSThreadData;
@ -114,6 +115,7 @@ struct SharedState
void checkShutdown(); void checkShutdown();
static SharedState *instance; static SharedState *instance;
static int rgssVersion;
/* This function will throw an Exception instance /* This function will throw an Exception instance
* on initialization error */ * on initialization error */

View File

@ -374,11 +374,11 @@ void Sprite::setY(int value)
p->trans.setPosition(Vec2(getX(), value)); p->trans.setPosition(Vec2(getX(), value));
#ifdef RGSS2 if (rgssVer >= 2)
{
p->wave.dirty = true; p->wave.dirty = true;
setSpriteY(value); setSpriteY(value);
#endif }
} }
void Sprite::setOX(int value) void Sprite::setOX(int value)
@ -413,9 +413,8 @@ void Sprite::setZoomY(float value)
p->trans.setScale(Vec2(getZoomX(), value)); p->trans.setScale(Vec2(getZoomX(), value));
p->recomputeBushDepth(); p->recomputeBushDepth();
#ifdef RGSS2 if (rgssVer >= 2)
p->wave.dirty = true; p->wave.dirty = true;
#endif
} }
void Sprite::setAngle(float value) void Sprite::setAngle(float value)

View File

@ -280,13 +280,14 @@ void build(TEXFBO &tf, Bitmap *bitmaps[BM_COUNT])
FBO::clear(); FBO::clear();
glState.clearColor.pop(); glState.clearColor.pop();
#ifdef RGSS3 if (rgssVer >= 3)
{
SDL_Surface *shadow = createShadowSet(); SDL_Surface *shadow = createShadowSet();
TEX::bind(tf.tex); TEX::bind(tf.tex);
TEX::uploadSubImage(shadowArea.x*32, shadowArea.y*32, TEX::uploadSubImage(shadowArea.x*32, shadowArea.y*32,
shadow->w, shadow->h, shadow->pixels, GL_RGBA); shadow->w, shadow->h, shadow->pixels, GL_RGBA);
SDL_FreeSurface(shadow); SDL_FreeSurface(shadow);
#endif }
Bitmap *bm; Bitmap *bm;
#define EXEC_BLITS(part) \ #define EXEC_BLITS(part) \
@ -585,12 +586,12 @@ onTile(Reader &reader, int16_t tileID,
{ {
int16_t flag = tableGetSafe(flags, tileID); int16_t flag = tableGetSafe(flags, tileID);
bool overPlayer = flag & OVER_PLAYER_FLAG; bool overPlayer = flag & OVER_PLAYER_FLAG;
bool isTable;
#if RGSS_VER == 3 if (rgssVer >= 3)
bool isTable = flag & TABLE_FLAG; isTable = flag & TABLE_FLAG;
#elif RGSS_VER == 2 else
bool isTable = (tileID - 0x0B00) % (8 * 0x30) >= (7 * 0x30); isTable = (tileID - 0x0B00) % (8 * 0x30) >= (7 * 0x30);
#endif
/* B ~ E */ /* B ~ E */
if (tileID < 0x0400) if (tileID < 0x0400)
@ -683,11 +684,8 @@ void readTiles(Reader &reader, const Table &data,
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
readLayer(reader, data, flags, ox, oy, w, h, i); readLayer(reader, data, flags, ox, oy, w, h, i);
#ifdef RGSS3 if (rgssVer >= 3)
readShadowLayer(reader, data, ox, oy, w, h); readShadowLayer(reader, data, ox, oy, w, h);
#else
(void) createShadowSet; (void) readShadowLayer;
#endif
readLayer(reader, data, flags, ox, oy, w, h, 2); readLayer(reader, data, flags, ox, oy, w, h, 2);
} }

View File

@ -35,15 +35,9 @@
#include <algorithm> #include <algorithm>
#include <sigc++/connection.h> #include <sigc++/connection.h>
#ifdef RGSS3 #define DEF_Z (rgssVer >= 3 ? 100 : 0)
# define DEF_Z 100 #define DEF_PADDING (rgssVer >= 3 ? 12 : 16)
# define DEF_PADDING 12 #define DEF_BACK_OPAC (rgssVer >= 3 ? 192 : 255)
# define DEF_BACK_OPAC 192
#else
# define DEF_Z 0
# define DEF_PADDING 16
# define DEF_BACK_OPAC 255
#endif
template<typename T> template<typename T>
struct Sides struct Sides
@ -765,11 +759,11 @@ struct WindowVXPrivate
glState.scissorBox.push(); glState.scissorBox.push();
glState.scissorTest.pushSet(true); glState.scissorTest.pushSet(true);
#ifdef RGSS3 if (rgssVer >= 3)
glState.scissorBox.setIntersect(clip); glState.scissorBox.setIntersect(clip);
#else else
glState.scissorBox.setIntersect(IntRect(trans.x, trans.y, geo.w, geo.h)); glState.scissorBox.setIntersect(IntRect(trans.x, trans.y, geo.w, geo.h));
#endif
IntRect pad = padRect; IntRect pad = padRect;
pad.x += trans.x; pad.x += trans.x;
pad.y += trans.y; pad.y += trans.y;
@ -779,10 +773,13 @@ struct WindowVXPrivate
Vec2i contTrans = pad.pos(); Vec2i contTrans = pad.pos();
contTrans.x += cursorRect->x; contTrans.x += cursorRect->x;
contTrans.y += cursorRect->y; contTrans.y += cursorRect->y;
#ifdef RGSS3
if (rgssVer >= 3)
{
contTrans.x -= contentsOff.x; contTrans.x -= contentsOff.x;
contTrans.y -= contentsOff.y; contTrans.y -= contentsOff.y;
#endif }
shader.setTranslation(contTrans); shader.setTranslation(contTrans);
TEX::setSmooth(true); TEX::setSmooth(true);
@ -792,9 +789,9 @@ struct WindowVXPrivate
if (contents) if (contents)
{ {
#ifndef RGSS3 if (rgssVer <= 2)
glState.scissorBox.setIntersect(clip); glState.scissorBox.setIntersect(clip);
#endif
Vec2i contTrans = pad.pos(); Vec2i contTrans = pad.pos();
contTrans.x -= contentsOff.x; contTrans.x -= contentsOff.x;
contTrans.y -= contentsOff.y; contTrans.y -= contentsOff.y;