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:
parent
b1981055e1
commit
55f1542c76
41 changed files with 460 additions and 465 deletions
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -41,17 +41,20 @@ static mrb_int getButtonArg(mrb_state *mrb)
|
|||
{
|
||||
mrb_int num;
|
||||
|
||||
#ifdef RGSS3
|
||||
mrb_sym sym;
|
||||
mrb_get_args(mrb, "n", &sym);
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
mrb_sym sym;
|
||||
mrb_get_args(mrb, "n", &sym);
|
||||
|
||||
mrb_value symHash = getMrbData(mrb)->buttoncodeHash;
|
||||
mrb_value numVal = mrb_hash_fetch(mrb, symHash, mrb_symbol_value(sym),
|
||||
mrb_fixnum_value(Input::None));
|
||||
num = mrb_fixnum(numVal);
|
||||
#else
|
||||
mrb_get_args(mrb, "i", &num);
|
||||
#endif
|
||||
mrb_value symHash = getMrbData(mrb)->buttoncodeHash;
|
||||
mrb_value numVal = mrb_hash_fetch(mrb, symHash, mrb_symbol_value(sym),
|
||||
mrb_fixnum_value(Input::None));
|
||||
num = mrb_fixnum(numVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
mrb_get_args(mrb, "i", &num);
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
@ -167,32 +170,35 @@ 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_value symHash = mrb_hash_new_capa(mrb, buttonCodesN);
|
||||
|
||||
mrb_const_set(mrb, modVal, sym, val);
|
||||
for (size_t i = 0; i < buttonCodesN; ++i)
|
||||
{
|
||||
const char *str = buttonCodes[i].str;
|
||||
mrb_sym sym = mrb_intern_static(mrb, str, strlen(str));
|
||||
mrb_value symVal = mrb_symbol_value(sym);
|
||||
mrb_value val = mrb_fixnum_value(buttonCodes[i].val);
|
||||
|
||||
/* In RGSS3 all Input::XYZ constants are equal to :XYZ symbols,
|
||||
* to be compatible with the previous convention */
|
||||
mrb_const_set(mrb, modVal, sym, symVal);
|
||||
mrb_hash_set(mrb, symHash, symVal, val);
|
||||
}
|
||||
|
||||
mrb_iv_set(mrb, modVal, mrb_intern_lit(mrb, "buttoncodes"), symHash);
|
||||
getMrbData(mrb)->buttoncodeHash = symHash;
|
||||
}
|
||||
#else
|
||||
mrb_value symHash = mrb_hash_new_capa(mrb, buttonCodesN);
|
||||
|
||||
for (size_t i = 0; i < buttonCodesN; ++i)
|
||||
else
|
||||
{
|
||||
const char *str = buttonCodes[i].str;
|
||||
mrb_sym sym = mrb_intern_static(mrb, str, strlen(str));
|
||||
mrb_value symVal = mrb_symbol_value(sym);
|
||||
mrb_value val = mrb_fixnum_value(buttonCodes[i].val);
|
||||
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);
|
||||
|
||||
/* In RGSS3 all Input::XYZ constants are equal to :XYZ symbols,
|
||||
* to be compatible with the previous convention */
|
||||
mrb_const_set(mrb, modVal, sym, symVal);
|
||||
mrb_hash_set(mrb, symHash, symVal, val);
|
||||
mrb_const_set(mrb, modVal, sym, val);
|
||||
}
|
||||
}
|
||||
|
||||
mrb_iv_set(mrb, modVal, mrb_intern_lit(mrb, "buttoncodes"), symHash);
|
||||
getMrbData(mrb)->buttoncodeHash = symHash;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue