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 ##
option(RGSS2 "Enable RGSS2" OFF)
option(MIDI "Enable midi support" ON)
option(WORKDIR_CURRENT "Keep current directory on startup" 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(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)
@ -148,6 +148,9 @@ set(MAIN_HEADERS
src/alstream.h
src/audiostream.h
src/rgssad.h
src/windowvx.h
src/tilemapvx.h
src/tileatlasvx.h
)
set(MAIN_SOURCE
@ -185,6 +188,11 @@ set(MAIN_SOURCE
src/audiostream.cpp
src/rgssad.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})
@ -206,22 +214,16 @@ set(EMBEDDED_INPUT
shader/simpleColor.vert
shader/sprite.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/blurH.vert
shader/blurV.vert
shader/simpleMatrix.vert
assets/liberation.ttf
)
if (RGSS2)
list(APPEND DEFINES
RGSS2
)
endif()
@ -305,6 +307,8 @@ if (BINDING STREQUAL "MRI")
binding-mri/audio-binding.cpp
binding-mri/module_rpg.cpp
binding-mri/filesystem-binding.cpp
binding-mri/windowvx-binding.cpp
binding-mri/tilemapvx-binding.cpp
)
elseif(BINDING STREQUAL "MRUBY")
message(FATAL_ERROR "Mruby support in CMake needs to be finished")
@ -395,7 +399,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE
${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory
${Boost_INCLUDE_DIR}
${MRI_INCLUDE_DIRS}
${RGSS2_INCLUDE_DIRS}
${VORBISFILE_INCLUDE_DIRS}
${MIDI_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR}
)
@ -410,7 +414,7 @@ target_link_libraries(${PROJECT_NAME}
${PIXMAN_LIBRARIES}
${Boost_LIBRARIES}
${MRI_LIBRARIES}
${RGSS2_LIBRARIES}
${VORBISFILE_LIBRARIES}
${MIDI_LIBRARIES}
${OPENAL_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_ttf
* SDL_sound (latest hg, apply provided patches!)
* vorbisfile
* pixman
* fluidsynth (if midi enabled)
* 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.
**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).
**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 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; \
} \
@ -83,13 +86,8 @@ RB_METHOD(audio_##entity##Fade) \
return rb_float_new(shState->audio().entity##Pos()); \
}
#ifdef RGSS3
DEF_PLAY_STOP_POS( bgm )
DEF_PLAY_STOP_POS( bgs )
#else
DEF_PLAY_STOP( bgm )
DEF_PLAY_STOP( bgs )
#endif
DEF_PLAY_STOP( me )
@ -124,10 +122,11 @@ audioBindingInit()
BIND_PLAY_STOP_FADE( bgs );
BIND_PLAY_STOP_FADE( me );
#ifdef RGSS3
if (rgssVer >= 3)
{
BIND_POS( bgm );
BIND_POS( bgs );
#endif
}
BIND_PLAY_STOP( se )
}

View File

@ -30,13 +30,15 @@
#include <ruby.h>
#include <ruby/encoding.h>
#include <assert.h>
#include <string>
#include <zlib.h>
#include <SDL_filesystem.h>
extern const char module_rpg[];
extern const char module_rpg1[];
extern const char module_rpg2[];
extern const char module_rpg3[];
static void mriBindingExecute();
static void mriBindingTerminate();
@ -58,11 +60,8 @@ void viewportBindingInit();
void planeBindingInit();
void windowBindingInit();
void tilemapBindingInit();
#ifdef RGSS2
void windowVXBindingInit();
void tilemapVXBindingInit();
#endif
void inputBindingInit();
void audioBindingInit();
@ -75,11 +74,8 @@ RB_METHOD(mriP);
RB_METHOD(mriDataDirectory);
RB_METHOD(mkxpPuts);
#ifdef RGSS3
RB_METHOD(mriRgssMain);
#else
RB_METHOD(_kernelCaller);
#endif
static void mriBindingInit()
{
@ -91,13 +87,16 @@ static void mriBindingInit()
viewportBindingInit();
planeBindingInit();
#ifdef RGSS2
windowVXBindingInit();
tilemapVXBindingInit();
#else
if (rgssVer == 1)
{
windowBindingInit();
tilemapBindingInit();
#endif
}
else
{
windowVXBindingInit();
tilemapVXBindingInit();
}
inputBindingInit();
audioBindingInit();
@ -105,27 +104,35 @@ static void mriBindingInit()
fileIntBindingInit();
#ifdef RGSS3
if (rgssVer >= 3)
{
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
_rb_define_module_function(rb_mKernel, "msgbox", mriPrint);
_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, "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");
_rb_define_module_function(mod, "data_directory", mriDataDirectory);
_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);
}
@ -200,8 +207,6 @@ RB_METHOD(mriDataDirectory)
return pathStr;
}
#ifdef RGSS3
RB_METHOD(mriRgssMain)
{
RB_UNUSED_PARAM;
@ -212,8 +217,6 @@ RB_METHOD(mriRgssMain)
return Qnil;
}
#else
RB_METHOD(_kernelCaller)
{
RB_UNUSED_PARAM;
@ -246,8 +249,6 @@ RB_METHOD(_kernelCaller)
return trace;
}
#endif
static VALUE newStringUTF8(const char *string, long length)
{
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);
#ifdef RGSS3
#define RGSS_SECTION_STR "{%04ld}"
#else
#define RGSS_SECTION_STR "Section%03ld"
#endif
static void runRMXPScripts()
{
const Config &conf = shState->rtData().config;
@ -391,7 +386,8 @@ static void runRMXPScripts()
else
{
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);
}

View File

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

View File

@ -22,6 +22,7 @@
#include "bitmap.h"
#include "font.h"
#include "exception.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "binding-util.h"
#include "binding-types.h"
@ -252,7 +253,8 @@ RB_METHOD(bitmapDrawText)
VALUE rectObj;
Rect *rect;
#ifdef RGSS2
if (rgssVer >= 2)
{
VALUE strObj;
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);
str = RSTRING_PTR(strObj);
#else
}
else
{
rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END);
#endif
}
rect = getPrivateDataCheck<Rect>(rectObj, RectType);
@ -272,7 +276,8 @@ RB_METHOD(bitmapDrawText)
{
int x, y, width, height;
#ifdef RGSS2
if (rgssVer >= 2)
{
VALUE strObj;
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);
str = RSTRING_PTR(strObj);
#else
}
else
{
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); );
}
@ -296,7 +303,8 @@ RB_METHOD(bitmapTextSize)
const char *str;
#ifdef RGSS2
if (rgssVer >= 2)
{
VALUE strObj;
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);
str = RSTRING_PTR(strObj);
#else
}
else
{
rb_get_args(argc, argv, "z", &str RB_ARG_END);
#endif
}
IntRect value;
GUARD_EXC( value = b->textSize(str); );
@ -318,8 +328,6 @@ RB_METHOD(bitmapTextSize)
DEF_PROP_OBJ(Bitmap, Font, Font, "font")
#ifdef RGSS2
RB_METHOD(bitmapGradientFillRect)
{
Bitmap *b = getPrivateData<Bitmap>(self);
@ -408,8 +416,6 @@ RB_METHOD(bitmapRadialBlur)
return Qnil;
}
#endif
// 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
@ -444,12 +450,13 @@ bitmapBindingInit()
_rb_define_method(klass, "draw_text", bitmapDrawText);
_rb_define_method(klass, "text_size", bitmapTextSize);
#ifdef RGSS2
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);
#endif
}
INIT_PROP_BIND(Bitmap, Font, "font");
}

View File

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

View File

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

View File

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

View File

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

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,
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,
@ -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,
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,
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,
@ -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,
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 "sharedstate.h"
#include "disposable-binding.h"
#include "flashable-binding.h"
#include "sceneelement-binding.h"
@ -60,15 +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)
#ifdef RGSS2
RB_METHOD(spriteWidth)
{
RB_UNUSED_PARAM;
@ -93,13 +96,6 @@ RB_METHOD(spriteHeight)
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
spriteBindingInit()
{
@ -130,7 +126,8 @@ spriteBindingInit()
INIT_PROP_BIND( Sprite, Color, "color" );
INIT_PROP_BIND( Sprite, Tone, "tone" );
#ifdef RGSS2
if (rgssVer >= 2)
{
_rb_define_method(klass, "width", spriteWidth);
_rb_define_method(klass, "height", spriteHeight);
@ -138,5 +135,5 @@ spriteBindingInit()
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
#endif
}
}

View File

@ -23,17 +23,12 @@
#include "viewport.h"
#include "bitmap.h"
#include "table.h"
#include "sharedstate.h"
#include "disposable-binding.h"
#include "binding-util.h"
#include "binding-types.h"
#ifdef RGSS3
# define FLAGS_PROP "flags"
#else
# define FLAGS_PROP "passages"
#endif
DEF_TYPE(TilemapVX);
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, FlashData, "flash_data")
DEF_PROP_OBJ(TilemapVX, Table, Flags, FLAGS_PROP)
DEF_PROP_OBJ(TilemapVX, Table, Flags, "flags")
DEF_PROP_B(TilemapVX, Visible)
@ -149,11 +144,19 @@ tilemapVXBindingInit()
INIT_PROP_BIND( TilemapVX, Viewport, "viewport" );
INIT_PROP_BIND( TilemapVX, MapData, "map_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, OX, "ox" );
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);
klass = rb_define_class_under(klass, "BitmapArray", rb_cObject);

View File

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

View File

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

View File

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

View File

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

View File

@ -41,7 +41,8 @@ static mrb_int getButtonArg(mrb_state *mrb)
{
mrb_int num;
#ifdef RGSS3
if (rgssVer >= 3)
{
mrb_sym 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_fixnum_value(Input::None));
num = mrb_fixnum(numVal);
#else
}
else
{
mrb_get_args(mrb, "i", &num);
#endif
}
return num;
}
@ -167,16 +170,8 @@ inputBindingInit(mrb_state *mrb)
mrb_value modVal = mrb_obj_value(module);
#ifndef RGSS3
for (size_t i = 0; i < buttonCodesN; ++i)
if (rgssVer >= 3)
{
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);
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);
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, 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)
#ifdef RGSS2
MRB_METHOD(spriteWidth)
{
Sprite *s = getPrivateData<Sprite>(mrb, self);
@ -88,13 +90,6 @@ MRB_METHOD(spriteHeight)
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
spriteBindingInit(mrb_state *mrb)
{
@ -122,7 +117,8 @@ spriteBindingInit(mrb_state *mrb)
INIT_PROP_BIND( Sprite, Color, "color" );
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, "height", spriteHeight, MRB_ARGS_NONE());
@ -130,7 +126,7 @@ spriteBindingInit(mrb_state *mrb)
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
#endif
}
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
}

View File

@ -1,5 +1,15 @@
# 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
# OpenGL debug information to the console
# (default: disabled)
@ -40,12 +50,20 @@
# 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
# 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

View File

@ -45,45 +45,11 @@ contains(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 {
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
RGSS2 {
PKGCONFIG += vorbisfile
}
MIDI {
PKGCONFIG += fluidsynth
}
@ -166,7 +132,10 @@ HEADERS += \
src/aldatasource.h \
src/alstream.h \
src/audiostream.h \
src/rgssad.h
src/rgssad.h \
src/windowvx.h \
src/tilemapvx.h \
src/tileatlasvx.h
SOURCES += \
src/main.cpp \
@ -202,7 +171,12 @@ SOURCES += \
src/alstream.cpp \
src/audiostream.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 = \
shader/transSimple.frag \
@ -219,28 +193,12 @@ EMBED = \
shader/simpleColor.vert \
shader/sprite.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/blurH.vert \
shader/blurV.vert \
shader/simpleMatrix.vert \
shader/tilemapvx.vert
}
shader/tilemapvx.vert \
assets/liberation.ttf
MIDI {
HEADERS += \
@ -352,13 +310,9 @@ BINDING_MRI {
binding-mri/tilemap-binding.cpp \
binding-mri/audio-binding.cpp \
binding-mri/module_rpg.cpp \
binding-mri/filesystem-binding.cpp
RGSS2 {
SOURCES += \
binding-mri/filesystem-binding.cpp \
binding-mri/windowvx-binding.cpp \
binding-mri/tilemapvx-binding.cpp
}
}
OTHER_FILES += $$EMBED

View File

@ -58,10 +58,8 @@ ALDataSource *createSDLSource(SDL_RWops &ops,
uint32_t maxBufSize,
bool looped);
#ifdef RGSS2
ALDataSource *createVorbisSource(SDL_RWops &ops,
bool looped);
#endif
#ifdef MIDI
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);
needsRewind = false;
#if RGSS2 || MIDI
bool readSig = rgssVer >= 2;
#ifdef MIDI
readSig = true;
#endif
if (readSig)
{
/* Try to read ogg file signature */
char sig[5] = { 0 };
SDL_RWread(&srcOps, sig, 1, 4);
SDL_RWseek(&srcOps, 0, RW_SEEK_SET);
#ifdef RGSS2
if (!strcmp(sig, "OggS"))
{
source = createVorbisSource(srcOps, looped);
return;
}
#endif
#ifdef MIDI
if (!strcmp(sig, "MThd"))
{
@ -218,7 +224,7 @@ void ALStream::openSource(const std::string &filename)
return;
}
#endif
#endif
}
source = createSDLSource(srcOps, ext, STREAM_BUF_SIZE, looped);
}

View File

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

View File

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

View File

@ -122,14 +122,15 @@ typedef std::vector<std::string> StringVec;
namespace po = boost::program_options;
Config::Config()
: debugMode(false),
: rgssVersion(0),
debugMode(false),
winResizable(false),
fullscreen(false),
fixedAspectRatio(true),
smoothScaling(false),
vsync(false),
defScreenW(DEF_SCREEN_W),
defScreenH(DEF_SCREEN_H),
defScreenW(0),
defScreenH(0),
fixedFramerate(0),
frameSkip(true),
solidFonts(false),
@ -147,6 +148,7 @@ Config::Config()
void Config::read(int argc, char *argv[])
{
#define PO_DESC_ALL \
PO_DESC(rgssVersion, int) \
PO_DESC(debugMode, bool) \
PO_DESC(winResizable, 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( rubyLoadpaths = vm["rubyLoadpath"].as<StringVec>(); )
GUARD_ALL( rubyLoadpaths = vm["rubyLoadpath"].as<StringVec>(); );
#undef PO_DESC
#undef PO_DESC_ALL
@ -329,4 +331,31 @@ void Config::readGameINI()
if (game.title.empty())
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 <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
{
int rgssVersion;
bool debugMode;
bool winResizable;

View File

@ -48,14 +48,6 @@ BUNDLED_FONT_DECL(liberation)
#define BNDL_F_D(f) BUNDLED_FONT_D(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;
static SDL_RWops *openBundledFont()
@ -269,14 +261,20 @@ std::string FontPrivate::defaultName = "Arial";
int FontPrivate::defaultSize = 22;
bool FontPrivate::defaultBold = false;
bool FontPrivate::defaultItalic = false;
bool FontPrivate::defaultOutline = DEF_OUTLINE;
bool FontPrivate::defaultShadow = DEF_SHADOW;
bool FontPrivate::defaultOutline = false; /* Inited at runtime */
bool FontPrivate::defaultShadow = false; /* Inited at runtime */
Color *FontPrivate::defaultColor = &FontPrivate::defaultColorTmp;
Color *FontPrivate::defaultOutColor = &FontPrivate::defaultOutColorTmp;
Color FontPrivate::defaultColorTmp(255, 255, 255, 255);
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)
{
if (!name)

View File

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

View File

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

View File

@ -205,23 +205,32 @@ static const KbBindingData defaultKbBindings[] =
{ SDL_SCANCODE_B, Input::None },
{ SDL_SCANCODE_D, Input::Z },
{ SDL_SCANCODE_Q, Input::L },
{ SDL_SCANCODE_W, Input::R },
#if RGSS_VER == 1
{ SDL_SCANCODE_W, Input::R }
};
/* RGSS1 */
static const KbBindingData defaultKbBindings1[] =
{
{ SDL_SCANCODE_Z, Input::A },
{ SDL_SCANCODE_C, Input::C },
{ SDL_SCANCODE_V, Input::Z },
{ SDL_SCANCODE_A, Input::Y },
{ SDL_SCANCODE_S, Input::X }
#else
};
/* RGSS2 and higher */
static const KbBindingData defaultKbBindings2[] =
{
{ SDL_SCANCODE_Z, Input::C },
{ SDL_SCANCODE_C, Input::None },
{ SDL_SCANCODE_V, Input::None },
{ SDL_SCANCODE_A, Input::X },
{ SDL_SCANCODE_S, Input::Y }
#endif
};
static elementsN(defaultKbBindings);
static elementsN(defaultKbBindings1);
static elementsN(defaultKbBindings2);
/* Rebindable */
static const JsBindingData defaultJsBindings[] =
@ -374,15 +383,20 @@ struct InputPrivate
void initKbBindings()
{
kbBindings.resize(staticKbBindingsN+defaultKbBindingsN);
size_t n = 0;
kbBindings.clear();
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)
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 */
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)
{
#ifdef RGSS2
if (rgssVer >= 2)
{
/* RGSS2: If two sprites' Z values collide,
* their Y coordinates decide draw order. Only
* on equal Y does the creation time take effect */
if (isSprite && o.isSprite && spriteY != o.spriteY)
return (spriteY < o.spriteY);
#endif
}
return (creationStamp <= o.creationStamp);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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