Debuging ruby error + added One shot mode

This commit is contained in:
ZakatTeamI2P 2026-04-12 12:49:07 +04:00
parent cbac6c0c6f
commit 799370de98
21 changed files with 236 additions and 360 deletions

View file

@ -11,8 +11,9 @@ option(DEBUG "Debug mode" OFF)
## Misc setup ## ## Misc setup ##
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(DEBUG_C_FLAGS "-g -O0 -fno-omit-frame-pointer") #i want die
set(DEBUG_CXX_FLAGS "-g -O0 -fno-omit-frame-pointer -std=c++17") set(DEBUG_C_FLAGS "-g -O0 -fno-omit-frame-pointer -ggdb")
set(DEBUG_CXX_FLAGS "-g -O0 -fno-omit-frame-pointer -ggdb")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_C_FLAGS}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_C_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_CXX_FLAGS}")

View file

@ -1,6 +1,6 @@
# mkxp-sunshine # mkxp-sunshine
This is a specialized fork of [mkxp-oneshot](https://github.com/elizagamedev/mkxp-oneshot) designed for OneShot: sunshine. This is a specialized fork of [mkxp-oneshot](https://github.com/elizagamedev/mkxp-oneshot) designed for OneShot: sunshine mod
# xScripts.rxdata # xScripts.rxdata
./rpgscript.rb scripts/ [GameDir] ./rpgscript.rb scripts/ [GameDir]

View file

@ -3,6 +3,7 @@ Type=Application
Name=OneShot Name=OneShot
Exec=oneshot %F Exec=oneshot %F
Comment=A surreal puzzle adventure game with unique mechanics / capabilities. Comment=A surreal puzzle adventure game with unique mechanics / capabilities.
Comment[ru]=Сюрреалистическая головоломка-приключение с уникальными механиками / возможностями.
Icon=oneshot Icon=oneshot
Categories=Game; Categories=Game;
Terminal=false Terminal=false

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; \
rb_get_args(argc, argv, "z|iif", &filename, &volume, &pitch, &pos RB_ARG_END); \ 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); ) \ GUARD_EXC( shState->audio().entity##Play(filename, volume, pitch, pos); ) \
return Qnil; \ return Qnil; \
} \ } \
@ -112,8 +115,7 @@ DEF_PLAY_STOP( se )
DEF_AUD_PROP_I(BGM_Volume) DEF_AUD_PROP_I(BGM_Volume)
DEF_AUD_PROP_I(SFX_Volume) DEF_AUD_PROP_I(SFX_Volume)
RB_METHOD(audioReset) RB_METHOD(audioReset){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
shState->audio().reset(); shState->audio().reset();
@ -143,18 +145,16 @@ RB_METHOD(audioReset)
} }
void void
audioBindingInit() audioBindingInit(){
{
VALUE module = rb_define_module("Audio"); VALUE module = rb_define_module("Audio");
BIND_PLAY_STOP_FADE( bgm ); BIND_PLAY_STOP_FADE( bgm );
BIND_PLAY_STOP_FADE( bgs ); BIND_PLAY_STOP_FADE( bgs );
BIND_PLAY_STOP_FADE( me ); BIND_PLAY_STOP_FADE( me );
if (rgssVer >= 3) if (rgssVer >= 3){
{ BIND_POS( bgm );
BIND_POS( bgm ); BIND_POS( bgs );
BIND_POS( bgs );
} }
BIND_PLAY_STOP( se ) BIND_PLAY_STOP( se )

View file

@ -34,7 +34,6 @@
#include <ruby.h> #include <ruby.h>
#include <ruby/encoding.h> #include <ruby/encoding.h>
#undef inline #undef inline
#include <assert.h> #include <assert.h>
#include <string> #include <string>
#include <zlib.h> #include <zlib.h>
@ -47,8 +46,7 @@ static void mriBindingExecute();
static void mriBindingTerminate(); static void mriBindingTerminate();
static void mriBindingReset(); static void mriBindingReset();
ScriptBinding scriptBindingImpl = ScriptBinding scriptBindingImpl = {
{
mriBindingExecute, mriBindingExecute,
mriBindingTerminate, mriBindingTerminate,
mriBindingReset mriBindingReset
@ -95,8 +93,7 @@ RB_METHOD(mriRgssMain);
RB_METHOD(mriRgssStop); RB_METHOD(mriRgssStop);
RB_METHOD(_kernelCaller); RB_METHOD(_kernelCaller);
static void mriBindingInit() static void mriBindingInit(){
{
tableBindingInit(); tableBindingInit();
etcBindingInit(); etcBindingInit();
fontBindingInit(); fontBindingInit();
@ -120,8 +117,7 @@ static void mriBindingInit()
steamBindingInit(); steamBindingInit();
chromaBindingInit(); chromaBindingInit();
if (rgssVer >= 3) 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, "rgss_stop", mriRgssStop); _rb_define_module_function(rb_mKernel, "rgss_stop", mriRgssStop);
@ -129,9 +125,7 @@ static void mriBindingInit()
_rb_define_module_function(rb_mKernel, "msgbox_p", mriP); _rb_define_module_function(rb_mKernel, "msgbox_p", mriP);
rb_define_global_const("RGSS_VERSION", rb_str_new_cstr("3.0.1")); rb_define_global_const("RGSS_VERSION", rb_str_new_cstr("3.0.1"));
} }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);
@ -159,9 +153,7 @@ static void mriBindingInit()
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest)); rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
} }
static void static void showMsg(const std::string &msg){
showMsg(const std::string &msg)
{
#ifdef NDEBUG #ifdef NDEBUG
shState->eThread().showMessageBox(msg.c_str()); shState->eThread().showMessageBox(msg.c_str());
#else #else
@ -169,14 +161,11 @@ showMsg(const std::string &msg)
#endif #endif
} }
static void printP(int argc, VALUE *argv, static void printP(int argc, VALUE *argv, const char *convMethod, const char *sep){
const char *convMethod, const char *sep)
{
VALUE dispString = rb_str_buf_new(128); VALUE dispString = rb_str_buf_new(128);
ID conv = rb_intern(convMethod); ID conv = rb_intern(convMethod);
for (int i = 0; i < argc; ++i) for (int i = 0; i < argc; ++i){
{
VALUE str = rb_funcall2(argv[i], conv, 0, NULL); VALUE str = rb_funcall2(argv[i], conv, 0, NULL);
rb_str_buf_append(dispString, str); rb_str_buf_append(dispString, str);
@ -187,8 +176,7 @@ static void printP(int argc, VALUE *argv,
showMsg(RSTRING_PTR(dispString)); showMsg(RSTRING_PTR(dispString));
} }
RB_METHOD(mriPrint) RB_METHOD(mriPrint){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
printP(argc, argv, "to_s", ""); printP(argc, argv, "to_s", "");
@ -196,8 +184,7 @@ RB_METHOD(mriPrint)
return Qnil; return Qnil;
} }
RB_METHOD(mriP) RB_METHOD(mriP){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
printP(argc, argv, "inspect", "\n"); printP(argc, argv, "inspect", "\n");
@ -205,8 +192,7 @@ RB_METHOD(mriP)
return Qnil; return Qnil;
} }
RB_METHOD(mkxpDataDirectory) RB_METHOD(mkxpDataDirectory){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const std::string &path = shState->config().customDataPath; const std::string &path = shState->config().customDataPath;
@ -215,8 +201,7 @@ RB_METHOD(mkxpDataDirectory)
return rb_str_new_cstr(s); return rb_str_new_cstr(s);
} }
RB_METHOD(mkxpPuts) RB_METHOD(mkxpPuts){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const char *str; const char *str;
@ -227,8 +212,7 @@ RB_METHOD(mkxpPuts)
return Qnil; return Qnil;
} }
RB_METHOD(mkxpRawKeyStates) RB_METHOD(mkxpRawKeyStates){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
VALUE str = rb_str_new(0, sizeof(EventThread::keyStates)); VALUE str = rb_str_new(0, sizeof(EventThread::keyStates));
@ -237,21 +221,18 @@ RB_METHOD(mkxpRawKeyStates)
return str; return str;
} }
RB_METHOD(mkxpMouseInWindow) RB_METHOD(mkxpMouseInWindow){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_bool_new(EventThread::mouseState.inWindow); return rb_bool_new(EventThread::mouseState.inWindow);
} }
static VALUE rgssMainCb(VALUE block) static VALUE rgssMainCb(VALUE block){
{
rb_funcall2(block, rb_intern("call"), 0, 0); rb_funcall2(block, rb_intern("call"), 0, 0);
return Qnil; return Qnil;
} }
static VALUE rgssMainRescue(VALUE arg, VALUE exc) static VALUE rgssMainRescue(VALUE arg, VALUE exc){
{
VALUE *excRet = (VALUE*) arg; VALUE *excRet = (VALUE*) arg;
*excRet = exc; *excRet = exc;
@ -259,8 +240,7 @@ static VALUE rgssMainRescue(VALUE arg, VALUE exc)
return Qnil; return Qnil;
} }
static void processReset() static void processReset(){
{
shState->graphics().reset(); shState->graphics().reset();
shState->audio().reset(); shState->audio().reset();
@ -269,12 +249,10 @@ static void processReset()
false); false);
} }
RB_METHOD(mriRgssMain) RB_METHOD(mriRgssMain){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
while (true) while (true){
{
VALUE exc = Qnil; VALUE exc = Qnil;
rb_rescue2((VALUE(*)(ANYARGS)) rgssMainCb, rb_block_proc(), rb_rescue2((VALUE(*)(ANYARGS)) rgssMainCb, rb_block_proc(),
@ -293,8 +271,7 @@ RB_METHOD(mriRgssMain)
return Qnil; return Qnil;
} }
RB_METHOD(mriRgssStop) RB_METHOD(mriRgssStop){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
while (true) while (true)
@ -303,8 +280,7 @@ RB_METHOD(mriRgssStop)
return Qnil; return Qnil;
} }
RB_METHOD(_kernelCaller) RB_METHOD(_kernelCaller){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
VALUE trace = rb_funcall2(rb_mKernel, rb_intern("_mkxp_kernel_caller_alias"), 0, 0); VALUE trace = rb_funcall2(rb_mKernel, rb_intern("_mkxp_kernel_caller_alias"), 0, 0);
@ -335,35 +311,29 @@ RB_METHOD(_kernelCaller)
return trace; return trace;
} }
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());
} }
struct evalArg struct evalArg{
{
VALUE string; VALUE string;
VALUE filename; VALUE filename;
}; };
static VALUE evalHelper(evalArg *arg) static VALUE evalHelper(evalArg *arg){
{
VALUE argv[] = { arg->string, Qnil, arg->filename }; VALUE argv[] = { arg->string, Qnil, arg->filename };
return rb_funcall2(Qnil, rb_intern("eval"), ARRAY_SIZE(argv), argv); return rb_funcall2(Qnil, rb_intern("eval"), ARRAY_SIZE(argv), argv);
} }
static VALUE evalString(VALUE string, VALUE filename, int *state) static VALUE evalString(VALUE string, VALUE filename, int *state){
{
evalArg arg = { string, filename }; evalArg arg = { string, filename };
return rb_protect((VALUE (*)(VALUE))evalHelper, (VALUE)&arg, state); return rb_protect((VALUE (*)(VALUE))evalHelper, (VALUE)&arg, state);
} }
static void runCustomScript(const std::string &filename) static void runCustomScript(const std::string &filename){
{
std::string scriptData; std::string scriptData;
if (!readFileSDL(filename.c_str(), scriptData)) if (!readFileSDL(filename.c_str(), scriptData)){
{
showMsg(std::string("Unable to open '") + filename + "'"); showMsg(std::string("Unable to open '") + filename + "'");
return; return;
} }
@ -374,27 +344,23 @@ static void runCustomScript(const std::string &filename)
VALUE kernelLoadDataInt(const char *filename, bool rubyExc); VALUE kernelLoadDataInt(const char *filename, bool rubyExc);
struct BacktraceData struct BacktraceData{
{
/* Maps: Ruby visible filename, To: Actual script name */ /* Maps: Ruby visible filename, To: Actual script name */
BoostHash<std::string, std::string> scriptNames; BoostHash<std::string, std::string> scriptNames;
}; };
#define SCRIPT_SECTION_FMT (rgssVer >= 3 ? "{%04ld}" : "Section%03ld") #define SCRIPT_SECTION_FMT (rgssVer >= 3 ? "{%04ld}" : "Section%03ld")
static void runRMXPScripts(BacktraceData &btData) static void runRMXPScripts(BacktraceData &btData){
{
const Config &conf = shState->rtData().config; const Config &conf = shState->rtData().config;
const std::string &scriptPack = conf.game.scripts; const std::string &scriptPack = conf.game.scripts;
if (scriptPack.empty()) if (scriptPack.empty()){
{
showMsg("No game scripts specified (missing Game.ini?)"); showMsg("No game scripts specified (missing Game.ini?)");
return; return;
} }
if (!shState->fileSystem().exists(scriptPack.c_str())) if (!shState->fileSystem().exists(scriptPack.c_str())){
{
showMsg("Unable to open '" + scriptPack + "'"); showMsg("Unable to open '" + scriptPack + "'");
return; return;
} }
@ -403,18 +369,14 @@ static void runRMXPScripts(BacktraceData &btData)
/* We checked if Scripts.rxdata exists, but something might /* We checked if Scripts.rxdata exists, but something might
* still go wrong */ * still go wrong */
try try{
{
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false); scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
} }catch (const Exception &e){
catch (const Exception &e)
{
showMsg(std::string("Failed to read script data: ") + e.msg); showMsg(std::string("Failed to read script data: ") + e.msg);
return; return;
} }
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)) if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)){
{
showMsg("Failed to read script data"); showMsg("Failed to read script data");
return; return;
} }
@ -429,8 +391,7 @@ static void runRMXPScripts(BacktraceData &btData)
std::string decodeBuffer; std::string decodeBuffer;
decodeBuffer.resize(0x1000); decodeBuffer.resize(0x1000);
for (long i = 0; i < scriptCount; ++i) for (long i = 0; i < scriptCount; ++i){
{
VALUE script = rb_ary_entry(scriptArray, i); VALUE script = rb_ary_entry(scriptArray, i);
if (!RB_TYPE_P(script, RUBY_T_ARRAY)) if (!RB_TYPE_P(script, RUBY_T_ARRAY))
@ -442,8 +403,7 @@ static void runRMXPScripts(BacktraceData &btData)
int result = Z_OK; int result = Z_OK;
unsigned long bufferLen; unsigned long bufferLen;
while (true) while (true){
{
unsigned char *bufferPtr = unsigned char *bufferPtr =
reinterpret_cast<unsigned char*>(const_cast<char*>(decodeBuffer.c_str())); reinterpret_cast<unsigned char*>(const_cast<char*>(decodeBuffer.c_str()));
const unsigned char *sourcePtr = const unsigned char *sourcePtr =
@ -462,8 +422,7 @@ static void runRMXPScripts(BacktraceData &btData)
decodeBuffer.resize(decodeBuffer.size()*2); decodeBuffer.resize(decodeBuffer.size()*2);
} }
if (result != Z_OK) if (result != Z_OK){
{
static char buffer[256]; static char buffer[256];
snprintf(buffer, sizeof(buffer), "Error decoding script %ld: '%s'", snprintf(buffer, sizeof(buffer), "Error decoding script %ld: '%s'",
i, RSTRING_PTR(scriptName)); i, RSTRING_PTR(scriptName));
@ -485,10 +444,8 @@ static void runRMXPScripts(BacktraceData &btData)
if (exc != Qnil) if (exc != Qnil)
return; return;
while (true) while (true){
{ for (long i = 0; i < scriptCount; ++i){
for (long i = 0; i < scriptCount; ++i)
{
VALUE script = rb_ary_entry(scriptArray, i); VALUE script = rb_ary_entry(scriptArray, i);
VALUE scriptDecoded = rb_ary_entry(script, 3); VALUE scriptDecoded = rb_ary_entry(script, 3);
VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded), VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded),
@ -518,8 +475,7 @@ static void runRMXPScripts(BacktraceData &btData)
} }
} }
static void showExc(VALUE exc, const BacktraceData &btData) static void showExc(VALUE exc, const BacktraceData &btData){
{
VALUE bt = rb_funcall2(exc, rb_intern("backtrace"), 0, NULL); VALUE bt = rb_funcall2(exc, rb_intern("backtrace"), 0, NULL);
VALUE msg = rb_funcall2(exc, rb_intern("message"), 0, NULL); VALUE msg = rb_funcall2(exc, rb_intern("message"), 0, NULL);
VALUE bt0 = rb_ary_entry(bt, 0); VALUE bt0 = rb_ary_entry(bt, 0);
@ -577,29 +533,27 @@ static void showExc(VALUE exc, const BacktraceData &btData)
showMsg(ms); showMsg(ms);
} }
static void mriBindingExecute() static void mriBindingExecute(){
{
/* Normally only a ruby executable would do a sysinit, /* Normally only a ruby executable would do a sysinit,
* but not doing it will lead to crashes due to closed * but not doing it will lead to crashes due to closed
* stdio streams on some platforms (eg. Windows) */ * stdio streams on some platforms (eg. Windows) */
//JIT for performance
int argc = 0; int argc = 0;
char **argv = 0; char **argv = 0;
ruby_sysinit(&argc, &argv); char options_argv1[] = "oneshot", options_argv2[] = "-evd", options_argv3[] = "--jit";
ruby_setup();
char options_argv1[] = "oneshot", options_argv2[] = "-e", options_argv3[] = "";
char* options_argv[] = {options_argv1, options_argv2, options_argv3, NULL}; char* options_argv[] = {options_argv1, options_argv2, options_argv3, NULL};
ruby_setup();
ruby_sysinit(&argc, &argv);
//ruby_init();
rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding())); rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));
Config &conf = shState->rtData().config; Config &conf = shState->rtData().config;
if (!conf.rubyLoadpaths.empty()) if (!conf.rubyLoadpaths.empty()){
{
/* Setup custom load paths */ /* Setup custom load paths */
VALUE lpaths = rb_gv_get(":"); VALUE lpaths = rb_gv_get(":");
for (size_t i = 0; i < conf.rubyLoadpaths.size(); ++i) for (size_t i = 0; i < conf.rubyLoadpaths.size(); ++i){
{
std::string &path = conf.rubyLoadpaths[i]; std::string &path = conf.rubyLoadpaths[i];
VALUE pathv = rb_str_new(path.c_str(), path.size()); VALUE pathv = rb_str_new(path.c_str(), path.size());
@ -624,15 +578,13 @@ static void mriBindingExecute()
shState->rtData().rqTermAck.set(); shState->rtData().rqTermAck.set();
} }
static void mriBindingTerminate() static void mriBindingTerminate(){
{
rb_raise(rb_eSystemExit, " "); rb_raise(rb_eSystemExit, " ");
#ifdef __linux__ #ifdef __linux__
wallpaperBindingTerminate(); wallpaperBindingTerminate();
#endif #endif
} }
static void mriBindingReset() static void mriBindingReset(){
{
rb_raise(getRbData()->exc[Reset], " "); rb_raise(getRbData()->exc[Reset], " ");
} }

View file

@ -29,13 +29,11 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
RbData *getRbData() RbData *getRbData(){
{
return static_cast<RbData*>(shState->bindingData()); return static_cast<RbData*>(shState->bindingData());
} }
struct struct{
{
RbException id; RbException id;
const char *name; const char *name;
} static customExc[] = } static customExc[] =
@ -45,8 +43,7 @@ struct
{ SDL, "SDLError" } { SDL, "SDLError" }
}; };
RbData::RbData() RbData::RbData(){
{
for (size_t i = 0; i < ARRAY_SIZE(customExc); ++i) for (size_t i = 0; i < ARRAY_SIZE(customExc); ++i)
exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException); exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException);
@ -59,14 +56,12 @@ RbData::RbData()
exc[ArgumentError] = rb_eArgError; exc[ArgumentError] = rb_eArgError;
} }
RbData::~RbData() RbData::~RbData(){
{
} }
/* Indexed with Exception::Type */ /* Indexed with Exception::Type */
static const RbException excToRbExc[] = static const RbException excToRbExc[] = {
{
RGSS, /* RGSSError */ RGSS, /* RGSSError */
ErrnoENOENT, /* NoFileError */ ErrnoENOENT, /* NoFileError */
IOError, IOError,
@ -85,9 +80,7 @@ void raiseRbExc(const Exception &exc){
rb_raise(excClass, "%s", exc.msg.c_str()); rb_raise(excClass, "%s", exc.msg.c_str());
} }
void void raiseDisposedAccess(VALUE self){
raiseDisposedAccess(VALUE self)
{
const char *klassName = RTYPEDDATA_TYPE(self)->wrap_struct_name; const char *klassName = RTYPEDDATA_TYPE(self)->wrap_struct_name;
char buf[32]; char buf[32];
@ -97,9 +90,7 @@ raiseDisposedAccess(VALUE self)
rb_raise(getRbData()->exc[RGSS], "disposed %s", buf); rb_raise(getRbData()->exc[RGSS], "disposed %s", buf);
} }
int int rb_get_args(int argc, VALUE *argv, const char *format, ...){
rb_get_args(int argc, VALUE *argv, const char *format, ...)
{
char c; char c;
VALUE *arg = argv; VALUE *arg = argv;
va_list ap; va_list ap;
@ -108,8 +99,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
va_start(ap, format); va_start(ap, format);
while ((c = *format++)) while ((c = *format++)){
{
switch (c) switch (c)
{ {
case '|' : case '|' :
@ -117,7 +107,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
default: default:
// FIXME print num of needed args vs provided // FIXME print num of needed args vs provided
if (argc <= argI && !opt) if (argc <= argI && !opt)
rb_raise(rb_eArgError, "wrong number of arguments"); rb_raise(rb_eArgError, "wrong number of arguments ");
break; break;
} }

View file

@ -28,13 +28,10 @@
/* 'Children' are disposables that are disposed together /* 'Children' are disposables that are disposed together
* with their parent. Currently this is only used by Viewport * with their parent. Currently this is only used by Viewport
* in RGSS1. */ * in RGSS1. */
inline void inline void disposableAddChild(VALUE disp, VALUE child){
disposableAddChild(VALUE disp, VALUE child)
{
VALUE children = rb_iv_get(disp, "children"); VALUE children = rb_iv_get(disp, "children");
if (NIL_P(children)) if (NIL_P(children)){
{
children = rb_ary_new(); children = rb_ary_new();
rb_iv_set(disp, "children", children); rb_iv_set(disp, "children", children);
} }
@ -43,9 +40,7 @@ disposableAddChild(VALUE disp, VALUE child)
rb_ary_push(children, child); rb_ary_push(children, child);
} }
inline void inline void disposableDisposeChildren(VALUE disp){
disposableDisposeChildren(VALUE disp)
{
VALUE children = rb_iv_get(disp, "children"); VALUE children = rb_iv_get(disp, "children");
if (NIL_P(children)) if (NIL_P(children))
@ -58,8 +53,7 @@ disposableDisposeChildren(VALUE disp)
} }
template<class C> template<class C>
RB_METHOD(disposableDispose) RB_METHOD(disposableDispose){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
C *d = getPrivateData<C>(self); C *d = getPrivateData<C>(self);
@ -80,8 +74,7 @@ RB_METHOD(disposableDispose)
} }
template<class C> template<class C>
RB_METHOD(disposableIsDisposed) RB_METHOD(disposableIsDisposed){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
C *d = getPrivateData<C>(self); C *d = getPrivateData<C>(self);
@ -93,8 +86,7 @@ RB_METHOD(disposableIsDisposed)
} }
template<class C> template<class C>
static void disposableBindingInit(VALUE klass) static void disposableBindingInit(VALUE klass){
{
_rb_define_method(klass, "dispose", disposableDispose<C>); _rb_define_method(klass, "dispose", disposableDispose<C>);
_rb_define_method(klass, "disposed?", disposableIsDisposed<C>); _rb_define_method(klass, "disposed?", disposableIsDisposed<C>);
@ -105,9 +97,7 @@ static void disposableBindingInit(VALUE klass)
} }
template<class C> template<class C>
inline void inline void checkDisposed(VALUE self){
checkDisposed(VALUE self)
{
if (disposableIsDisposed<C>(0, 0, self) == Qtrue) if (disposableIsDisposed<C>(0, 0, self) == Qtrue)
raiseDisposedAccess(self); raiseDisposedAccess(self);
} }

View file

@ -125,16 +125,14 @@ SET_FUN(Color, double, "fff|f", 255)
SET_FUN(Tone, double, "fff|f", 0) SET_FUN(Tone, double, "fff|f", 0)
SET_FUN(Rect, int, "iiii", 0) SET_FUN(Rect, int, "iiii", 0)
RB_METHOD(rectEmpty) RB_METHOD(rectEmpty){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Rect *r = getPrivateData<Rect>(self); Rect *r = getPrivateData<Rect>(self);
r->empty(); r->empty();
return self; return self;
} }
RB_METHOD(ColorStringify) RB_METHOD(ColorStringify){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Color *c = getPrivateData<Color>(self); Color *c = getPrivateData<Color>(self);
@ -143,8 +141,7 @@ RB_METHOD(ColorStringify)
c->red, c->green, c->blue, c->alpha); c->red, c->green, c->blue, c->alpha);
} }
RB_METHOD(ToneStringify) RB_METHOD(ToneStringify){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Tone *t = getPrivateData<Tone>(self); Tone *t = getPrivateData<Tone>(self);
@ -153,8 +150,7 @@ RB_METHOD(ToneStringify)
t->red, t->green, t->blue, t->gray); t->red, t->green, t->blue, t->gray);
} }
RB_METHOD(RectStringify) RB_METHOD(RectStringify){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Rect *r = getPrivateData<Rect>(self); Rect *r = getPrivateData<Rect>(self);
@ -196,9 +192,7 @@ INITCOPY_FUN(Rect)
#define RB_ATTR_RW(Klass, Attr, attr) \ #define RB_ATTR_RW(Klass, Attr, attr) \
{ RB_ATTR_R(Klass, Attr, attr); RB_ATTR_W(Klass, Attr, attr); } { RB_ATTR_R(Klass, Attr, attr); RB_ATTR_W(Klass, Attr, attr); }
void void etcBindingInit(){
etcBindingInit()
{
VALUE klass; VALUE klass;
INIT_BIND(Color); INIT_BIND(Color);

View file

@ -30,23 +30,17 @@
static void fileIntFreeInstance(void *inst){ static void fileIntFreeInstance(void *inst){
SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst); SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst);
SDL_CloseIO(ops); SDL_CloseIO(ops);
} }
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance); DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
static VALUE static VALUE fileIntForPath(const char *path, bool rubyExc){
fileIntForPath(const char *path, bool rubyExc)
{
SDL_IOStream* ops; SDL_IOStream* ops;
try{
try
{
shState->fileSystem().openReadRaw(ops, path); shState->fileSystem().openReadRaw(ops, path);
} }
catch (const Exception &e) catch (const Exception &e){
{
SDL_CloseIO(ops); SDL_CloseIO(ops);
if (rubyExc) if (rubyExc)
@ -64,16 +58,14 @@ fileIntForPath(const char *path, bool rubyExc)
return obj; return obj;
} }
RB_METHOD(fileIntRead) RB_METHOD(fileIntRead){
{
int length = -1; int length = -1;
rb_get_args(argc, argv, "i", &length RB_ARG_END); rb_get_args(argc, argv, "i", &length RB_ARG_END);
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self); SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
if (length == -1) if (length == -1){
{
Sint64 cur = SDL_TellIO(ops); Sint64 cur = SDL_TellIO(ops);
Sint64 end = SDL_SeekIO(ops, 0, SDL_IO_SEEK_END); Sint64 end = SDL_SeekIO(ops, 0, SDL_IO_SEEK_END);
length = end - cur; length = end - cur;
@ -90,8 +82,7 @@ RB_METHOD(fileIntRead)
return data; return data;
} }
RB_METHOD(fileIntClose) RB_METHOD(fileIntClose){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self); SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
@ -100,28 +91,21 @@ RB_METHOD(fileIntClose)
return Qnil; return Qnil;
} }
RB_METHOD(fileIntGetByte) RB_METHOD(fileIntGetByte){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self); SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
unsigned char byte; unsigned char byte;
size_t result = SDL_ReadIO(ops, &byte, 1); size_t result = SDL_ReadIO(ops, &byte, 1);
return (result == 1) ? rb_fix_new(byte) : Qnil; return (result == 1) ? rb_fix_new(byte) : Qnil;
} }
RB_METHOD(fileIntBinmode) RB_METHOD(fileIntBinmode){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return Qnil; return Qnil;
} }
VALUE VALUE kernelLoadDataInt(const char *filename, bool rubyExc){
kernelLoadDataInt(const char *filename, bool rubyExc)
{
rb_gc_start(); rb_gc_start();
VALUE port = fileIntForPath(filename, rubyExc); VALUE port = fileIntForPath(filename, rubyExc);
@ -136,8 +120,7 @@ kernelLoadDataInt(const char *filename, bool rubyExc)
return result; return result;
} }
RB_METHOD(kernelLoadData) RB_METHOD(kernelLoadData){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const char *filename; const char *filename;
@ -146,8 +129,7 @@ RB_METHOD(kernelLoadData)
return kernelLoadDataInt(filename, true); return kernelLoadDataInt(filename, true);
} }
RB_METHOD(kernelSaveData) RB_METHOD(kernelSaveData){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
VALUE obj; VALUE obj;
@ -167,48 +149,36 @@ RB_METHOD(kernelSaveData)
return Qnil; return Qnil;
} }
static VALUE stringForceUTF8(VALUE arg) static VALUE stringForceUTF8(VALUE arg){
{
if (RB_TYPE_P(arg, RUBY_T_STRING) && ENCODING_IS_ASCII8BIT(arg)) if (RB_TYPE_P(arg, RUBY_T_STRING) && ENCODING_IS_ASCII8BIT(arg))
rb_enc_associate_index(arg, rb_utf8_encindex()); rb_enc_associate_index(arg, rb_utf8_encindex());
return arg; return arg;
} }
static VALUE customProc(VALUE arg, VALUE proc) static VALUE customProc(VALUE arg, VALUE proc){
{
VALUE obj = stringForceUTF8(arg); VALUE obj = stringForceUTF8(arg);
obj = rb_funcall2(proc, rb_intern("call"), 1, &obj); obj = rb_funcall2(proc, rb_intern("call"), 1, &obj);
return obj; return obj;
} }
RB_METHOD(_marshalLoad){ RB_METHOD(_marshalLoad){
printf("test\n");
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
printf("test2\n");
VALUE port, proc = Qnil; VALUE port, proc = Qnil;
printf("test3\n");
rb_scan_args(argc, argv, "01", &port, &proc); rb_scan_args(argc, argv, "01", &port, &proc);
//rb_get_args(argc, argv, "o|o", &port, &proc RB_ARG_END); //rb_get_args(argc, argv, "o|o", &port, &proc RB_ARG_END);
printf("test4\n");
VALUE utf8Proc; VALUE utf8Proc;
if (NIL_P(proc)) if (NIL_P(proc))
utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(stringForceUTF8), Qnil); utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(stringForceUTF8), Qnil);
else else
utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(customProc), proc); utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(customProc), proc);
printf("test5\n");
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal")); VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
//if (!rb_obj_is_kind_of(marsh, rb_cModule)) rb_raise(rb_eRuntimeError, "Marshal not found");
printf("test6\n");
VALUE v[] = { port, utf8Proc }; VALUE v[] = { port, utf8Proc };
printf("test7\n");
return rb_funcall2(marsh, rb_intern("_mkxp_load_alias"), ARRAY_SIZE(v), v); return rb_funcall2(marsh, rb_intern("_mkxp_load_alias"), ARRAY_SIZE(v), v);
} }
void void fileIntBindingInit(){
fileIntBindingInit()
{
VALUE klass = rb_define_class("FileInt", rb_cIO); VALUE klass = rb_define_class("FileInt", rb_cIO);
rb_define_alloc_func(klass, classAllocate<&FileIntType>); rb_define_alloc_func(klass, classAllocate<&FileIntType>);
@ -223,11 +193,11 @@ fileIntBindingInit()
/* We overload the built-in 'Marshal::load()' function to silently /* We overload the built-in 'Marshal::load()' function to silently
* insert our utf8proc that ensures all read strings will be * insert our utf8proc that ensures all read strings will be
* UTF-8 encoded */ * UTF-8 encoded */
printf("test8\n");
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal")); VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
printf("test9\n"); if(marsh = Qnil){
printf("BrUh: cant get Marshal\n");
exit(1);
}
rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load"); rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load");
printf("test10\n");
_rb_define_module_function(marsh, "load", _marshalLoad); _rb_define_module_function(marsh, "load", _marshalLoad);
printf("test11\n");
} }

View file

@ -57,8 +57,7 @@
#endif #endif
#ifdef __linux__ #ifdef __linux__
void desktopEnvironmentInit() void desktopEnvironmentInit(){
{
if (desktop != "uninitialized") { if (desktop != "uninitialized") {
return; return;
} }

View file

@ -26,8 +26,7 @@
DEF_TYPE(Window); DEF_TYPE(Window);
RB_METHOD(windowInitialize) RB_METHOD(windowInitialize){
{
Window *w = viewportElementInitialize<Window>(argc, argv, self); Window *w = viewportElementInitialize<Window>(argc, argv, self);
setPrivateData(self, w); setPrivateData(self, w);
@ -39,8 +38,7 @@ RB_METHOD(windowInitialize)
return self; return self;
} }
RB_METHOD(windowUpdate) RB_METHOD(windowUpdate){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Window *w = getPrivateData<Window>(self); Window *w = getPrivateData<Window>(self);
@ -70,8 +68,7 @@ DEF_PROP_I(Window, ContentsOpacity)
void void
windowBindingInit() windowBindingInit(){
{
VALUE klass = rb_define_class("Window", rb_cObject); VALUE klass = rb_define_class("Window", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&WindowType>); rb_define_alloc_func(klass, classAllocate<&WindowType>);

View file

@ -24,24 +24,15 @@
#include "eventthread.h" #include "eventthread.h"
#include "debugwriter.h" #include "debugwriter.h"
static void nullBindingExecute() static void nullBindingExecute(){
{
Debug() << "The null binding doesn't do anything, so we're done!"; Debug() << "The null binding doesn't do anything, so we're done!";
shState->rtData().rqTermAck.set(); shState->rtData().rqTermAck.set();
} }
static void nullBindingTerminate() static void nullBindingTerminate() {}
{ static void nullBindingReset() {}
} ScriptBinding scriptBindingImpl ={
static void nullBindingReset()
{
}
ScriptBinding scriptBindingImpl =
{
nullBindingExecute, nullBindingExecute,
nullBindingTerminate, nullBindingTerminate,
nullBindingReset nullBindingReset

View file

@ -10,8 +10,7 @@
#include <guiddef.h> #include <guiddef.h>
#endif #endif
namespace ChromaSDK namespace ChromaSDK{
{
// Keyboards // Keyboards
//! Razer Blackwidow Chroma device. //! Razer Blackwidow Chroma device.
// {2EA1BB63-CA28-428D-9F06-196B88330BBB} // {2EA1BB63-CA28-428D-9F06-196B88330BBB}
@ -166,7 +165,6 @@ namespace ChromaSDK
static const GUID CORE_CHROMA = static const GUID CORE_CHROMA =
{ 0x201203b, 0x62f3, 0x4c50, { 0x83, 0xdd, 0x59, 0x8b, 0xab, 0xd2, 0x8, 0xe0 } }; { 0x201203b, 0x62f3, 0x4c50, { 0x83, 0xdd, 0x59, 0x8b, 0xab, 0xd2, 0x8, 0xe0 } };
} }
#endif #endif

View file

@ -15,14 +15,12 @@ typedef void* PRZPARAM; //!< Context sensitive pointer.
typedef DWORD RZID; //!< Generic data type for Identifier. typedef DWORD RZID; //!< Generic data type for Identifier.
typedef DWORD RZCOLOR; //!< Color data. 1st byte = Red; 2nd byte = Green; 3rd byte = Blue; 4th byte = Alpha (if applicable) typedef DWORD RZCOLOR; //!< Color data. 1st byte = Red; 2nd byte = Green; 3rd byte = Blue; 4th byte = Alpha (if applicable)
namespace ChromaSDK namespace ChromaSDK{
{
//! Event notification Window message //! Event notification Window message
const UINT WM_CHROMA_EVENT = WM_APP+0x2000; const UINT WM_CHROMA_EVENT = WM_APP+0x2000;
//! Chroma generic effects. Note: Not all devices supported the listed effects. //! Chroma generic effects. Note: Not all devices supported the listed effects.
typedef enum EFFECT_TYPE typedef enum EFFECT_TYPE{
{
CHROMA_NONE = 0, //!< No effect. CHROMA_NONE = 0, //!< No effect.
CHROMA_WAVE, //!< Wave effect (This effect type has deprecated and should not be used). CHROMA_WAVE, //!< Wave effect (This effect type has deprecated and should not be used).
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (This effect type has deprecated and should not be used). CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (This effect type has deprecated and should not be used).
@ -36,11 +34,9 @@ namespace ChromaSDK
} EFFECT_TYPE; } EFFECT_TYPE;
//! Device info. //! Device info.
typedef struct DEVICE_INFO_TYPE typedef struct DEVICE_INFO_TYPE{
{
//! Device types. //! Device types.
enum DeviceType enum DeviceType{
{
DEVICE_KEYBOARD = 1, //!< Keyboard device. DEVICE_KEYBOARD = 1, //!< Keyboard device.
DEVICE_MOUSE = 2, //!< Mouse device. DEVICE_MOUSE = 2, //!< Mouse device.
DEVICE_HEADSET = 3, //!< Headset device. DEVICE_HEADSET = 3, //!< Headset device.
@ -57,8 +53,7 @@ namespace ChromaSDK
const RZSIZE MAX_COLUMN = 30; //!< Maximum columns for custom effects. const RZSIZE MAX_COLUMN = 30; //!< Maximum columns for custom effects.
//! Blinking effect (This effect type has deprecated and should not be used). //! Blinking effect (This effect type has deprecated and should not be used).
typedef struct BLINKING_EFFECT_TYPE typedef struct BLINKING_EFFECT_TYPE{
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(BLINKING_EFFECT_TYPE) RZSIZE Size; //!< Size of the structure. Size = sizeof(BLINKING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters. DWORD Param; //!< Extra parameters.
@ -66,14 +61,12 @@ namespace ChromaSDK
} BLINKING_EFFECT_TYPE; } BLINKING_EFFECT_TYPE;
//! Breathing effect (This effect type has deprecated and should not be used). //! Breathing effect (This effect type has deprecated and should not be used).
typedef struct BREATHING_EFFECT_TYPE typedef struct BREATHING_EFFECT_TYPE{
{
RZSIZE Size; //!< Size of ths structure. Size = sizeof(BREATHING_EFFECT_TYPE) RZSIZE Size; //!< Size of ths structure. Size = sizeof(BREATHING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters. DWORD Param; //!< Extra parameters.
//! Breathing effect types. //! Breathing effect types.
enum _Type enum _Type{
{
ONE_COLOR = 1, //!< 1 color (Only fill Color1). ONE_COLOR = 1, //!< 1 color (Only fill Color1).
TWO_COLORS, //!< 2 colors. TWO_COLORS, //!< 2 colors.
RANDOM_COLORS //!< Random colors RANDOM_COLORS //!< Random colors
@ -84,8 +77,7 @@ namespace ChromaSDK
} BREATHING_EFFECT_TYPE; } BREATHING_EFFECT_TYPE;
//! Custom effect (This effect type has deprecated and should not be used). //! Custom effect (This effect type has deprecated and should not be used).
typedef struct CUSTOM_EFFECT_TYPE typedef struct CUSTOM_EFFECT_TYPE{
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(CUSTOM_EFFECT_TYPE) RZSIZE Size; //!< Size of the structure. Size = sizeof(CUSTOM_EFFECT_TYPE)
DWORD Param; //!< Extra parameters. DWORD Param; //!< Extra parameters.
@ -93,21 +85,18 @@ namespace ChromaSDK
} CUSTOM_EFFECT_TYPE; } CUSTOM_EFFECT_TYPE;
//! No effect. //! No effect.
typedef struct NO_EFFECT_TYPE typedef struct NO_EFFECT_TYPE{
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(NO_EFFECT_TYPE) RZSIZE Size; //!< Size of the structure. Size = sizeof(NO_EFFECT_TYPE)
DWORD Param; //!< Extra parameters. DWORD Param; //!< Extra parameters.
} NO_EFFECT_TYPE; } NO_EFFECT_TYPE;
//! Reactive effect (This effect type has deprecated and should not be used). //! Reactive effect (This effect type has deprecated and should not be used).
typedef struct REACTIVE_EFFECT_TYPE typedef struct REACTIVE_EFFECT_TYPE{
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(REACTIVE_EFFECT_TYPE) RZSIZE Size; //!< Size of the structure. Size = sizeof(REACTIVE_EFFECT_TYPE)
DWORD Param; //!< Extra parameters. DWORD Param; //!< Extra parameters.
//! Duration of the effect. //! Duration of the effect.
enum _Duration enum _Duration{
{
DURATION_SHORT = 1, //!< Short duration. DURATION_SHORT = 1, //!< Short duration.
DURATION_MEDIUM, //!< Medium duration. DURATION_MEDIUM, //!< Medium duration.
DURATION_LONG //!< Long duration. DURATION_LONG //!< Long duration.
@ -117,21 +106,18 @@ namespace ChromaSDK
} REACTIVE_EFFECT_TYPE; } REACTIVE_EFFECT_TYPE;
//! Spectrum cycling effect (This effect type has deprecated and should not be used). //! Spectrum cycling effect (This effect type has deprecated and should not be used).
typedef struct SPECTRUMCYCLING_EFFECT_TYPE typedef struct SPECTRUMCYCLING_EFFECT_TYPE{
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE) RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters. DWORD Param; //!< Extra parameters.
} SPECTRUMCYCLING_EFFECT_TYPE; } SPECTRUMCYCLING_EFFECT_TYPE;
//! Starlight effect (This effect type has deprecated and should not be used). //! Starlight effect (This effect type has deprecated and should not be used).
typedef struct STARLIGHT_EFFECT_TYPE typedef struct STARLIGHT_EFFECT_TYPE{
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE) RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE)
DWORD Param; //!< Extra parameters. DWORD Param; //!< Extra parameters.
//! Starlight effect types. //! Starlight effect types.
enum _Type enum _Type{
{
TWO_COLORS = 1, //!< 2 colors. TWO_COLORS = 1, //!< 2 colors.
RANDOM_COLORS //!< Random colors RANDOM_COLORS //!< Random colors
} Type; } Type;
@ -140,8 +126,7 @@ namespace ChromaSDK
COLORREF Color2; //!< Second color. COLORREF Color2; //!< Second color.
//! Duration of the effect. //! Duration of the effect.
enum _Duration enum _Duration{
{
DURATION_SHORT = 1, //!< Short duration. DURATION_SHORT = 1, //!< Short duration.
DURATION_MEDIUM, //!< Medium duration. DURATION_MEDIUM, //!< Medium duration.
DURATION_LONG //!< Long duration. DURATION_LONG //!< Long duration.
@ -150,8 +135,7 @@ namespace ChromaSDK
} STARLIGHT_EFFECT_TYPE; } STARLIGHT_EFFECT_TYPE;
//! Static effect (This effect type has deprecated and should not be used). //! Static effect (This effect type has deprecated and should not be used).
typedef struct STATIC_EFFECT_TYPE typedef struct STATIC_EFFECT_TYPE{
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(STATIC_EFFECT_TYPE) RZSIZE Size; //!< Size of the structure. Size = sizeof(STATIC_EFFECT_TYPE)
DWORD Param; //!< Extra parameters. DWORD Param; //!< Extra parameters.
@ -159,8 +143,7 @@ namespace ChromaSDK
} STATIC_EFFECT_TYPE; } STATIC_EFFECT_TYPE;
//! Wave effect (This effect type has deprecated and should not be used). //! Wave effect (This effect type has deprecated and should not be used).
typedef struct WAVE_EFFECT_TYPE typedef struct WAVE_EFFECT_TYPE{
{
RZSIZE Size; //!< Size of the structure. Size = sizeof(WAVE_EFFECT_TYPE) RZSIZE Size; //!< Size of the structure. Size = sizeof(WAVE_EFFECT_TYPE)
DWORD Param; //!< Extra parameters. DWORD Param; //!< Extra parameters.
@ -175,8 +158,7 @@ namespace ChromaSDK
} WAVE_EFFECT_TYPE; } WAVE_EFFECT_TYPE;
//! Keyboards //! Keyboards
namespace Keyboard namespace Keyboard{
{
//! Definitions of keys. //! Definitions of keys.
typedef enum RZKEY typedef enum RZKEY
{ {

View file

@ -123,7 +123,12 @@ class Scene_Map
EdText.info(tr("You cannot perform this action during cutscenes.")) EdText.info(tr("You cannot perform this action during cutscenes."))
return return
else else
$game_temp.common_event_id = 35 if Window_Settings.OneShotMode = true
File.new("badend.lock", "w")
$game_temp.common_event_id = 35
else
$game_temp.common_event_id = 35
end
end end
end end
# Loop # Loop

View file

@ -34,12 +34,12 @@ class Scene_Title
$game_system = Game_System.new $game_system = Game_System.new
# Skip title screen if debug mode (or demo, but not GDC) # Skip title screen if debug mode (or demo, but not GDC)
if $debug || ($demo && !$GDC) || save_exists #if $debug || ($demo && !$GDC) || save_exists
$game_map.update # $game_map.update
$game_map.autoplay # $game_map.autoplay
$scene = Scene_Map.new # $scene = Scene_Map.new
return # return
end #end
load_perma_flags load_perma_flags
Window_Settings.load_settings Window_Settings.load_settings
Oneshot.allow_exit true Oneshot.allow_exit true
@ -53,7 +53,11 @@ class Scene_Title
if File.exists?("Graphics/Titles/#{translation_name}.png") if File.exists?("Graphics/Titles/#{translation_name}.png")
@sprite.bitmap = RPG::Cache.title(translation_name) @sprite.bitmap = RPG::Cache.title(translation_name)
else else
@sprite.bitmap = RPG::Cache.title($data_system.title_name) if File.exist?("badend.lock")
@sprite.bitmap = RPG::Cache.title("badend")
else
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
end
end end
# check for debug file to add debug items # check for debug file to add debug items
@ -72,9 +76,7 @@ class Scene_Title
@menu.bitmap = Bitmap.new(640, 480) @menu.bitmap = Bitmap.new(640, 480)
@menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start")) @menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start"))
@menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings")) @menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings"))
if !$GDC @menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit"))
@menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit"))
end
if $game_switches[160] && $game_switches[152] if $game_switches[160] && $game_switches[152]
@menu.bitmap.draw_text(MENU_X, MENU_Y + 75, 150, 24, tr("...")) @menu.bitmap.draw_text(MENU_X, MENU_Y + 75, 150, 24, tr("..."))
end end
@ -90,7 +92,12 @@ class Scene_Title
# Initialize cursor position # Initialize cursor position
@cursor_pos = 0 @cursor_pos = 0
# Play title BGM # Play title BGM
$game_system.bgm_play($data_system.title_bgm) if File.exist?("badend.lock")
#TODO: fix
Audio.bgm_play("Audio/BGM/MyBurdenIsDead.ogg", 100, 100)
else
$game_system.bgm_play($data_system.title_bgm)
end
# Stop playing ME and BGS # Stop playing ME and BGS
Audio.me_stop Audio.me_stop
Audio.bgs_stop Audio.bgs_stop
@ -130,11 +137,9 @@ class Scene_Title
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
def update def update
@menu.bitmap.clear @menu.bitmap.clear
@menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start")) @menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start"))
@menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings")) @menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings"))
if !$GDC @menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit"))
@menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit"))
end
if $game_switches[160] && $game_switches[152] if $game_switches[160] && $game_switches[152]
@menu.bitmap.draw_text(MENU_X, MENU_Y + 75, 150, 24, tr("...")) @menu.bitmap.draw_text(MENU_X, MENU_Y + 75, 150, 24, tr("..."))
end end
@ -178,17 +183,28 @@ class Scene_Title
if !@window_settings_title.visible if !@window_settings_title.visible
# Handle confirmation # Handle confirmation
if Input.trigger?(Input::ACTION) if Input.trigger?(Input::ACTION)
case @cursor_pos if File.exist?("badend.lock")
when 0 # Continue case @cursor_pos
$game_switches[157] = false when 0 # Continue
command_continue EdText.info(tr("Savior not found"))
when 1 # Settings when 1 # Settings
command_settings command_settings
when 2 # Shutdown when 2 # Shutdown
command_shutdown command_shutdown
when 3 # memory end
$game_switches[157] = true else
command_continue case @cursor_pos
when 0 # Continue
$game_switches[157] = false
command_continue
when 1 # Settings
command_settings
when 2 # Shutdown
command_shutdown
when 3 # memory
$game_switches[157] = true
command_continue
end
end end
end end
end end

View file

@ -8,8 +8,11 @@ class Window_Settings
SETTINGS_FILE_NAME = Oneshot::SAVE_PATH + '/settings.conf' SETTINGS_FILE_NAME = Oneshot::SAVE_PATH + '/settings.conf'
class << self class << self
attr_accessor :DebugIsEnabled attr_accessor :DebugIsEnabled
attr_accessor :OneShotMode
end end
@DebugIsEnabled = false @DebugIsEnabled = false
#You have only ONE shot!
@OneShotMode = false
def save_settings def save_settings
$persistent.save $persistent.save
File.open(SETTINGS_FILE_NAME, 'w') do |file| File.open(SETTINGS_FILE_NAME, 'w') do |file|
@ -22,6 +25,7 @@ class Window_Settings
file.puts('frameskip=' + Graphics.frameskip.to_s) file.puts('frameskip=' + Graphics.frameskip.to_s)
file.puts('in_game_timer=' + $game_temp.igt_timer_visible.to_s) file.puts('in_game_timer=' + $game_temp.igt_timer_visible.to_s)
file.puts('debug=' + Window_Settings.DebugIsEnabled.to_s) file.puts('debug=' + Window_Settings.DebugIsEnabled.to_s)
file.puts('oneshotmode=' + Window_Settings.OneShotMode.to_s)
end end
end end
@ -84,10 +88,16 @@ class Window_Settings
Window_Settings.DebugIsEnabled = true Window_Settings.DebugIsEnabled = true
elsif vals[1] == "false" elsif vals[1] == "false"
Window_Settings.DebugIsEnabled = false Window_Settings.DebugIsEnabled = false
end
when "oneshotmode"
if vals[1] == "true"
Window_Settings.OneShotMode = true
elsif vals[1] == "false"
Window_Settings.OneShotMode = false
end
end end
end end
end end
end
def initialize def initialize
@viewport = Viewport.new(0, 0, 640, 480) @viewport = Viewport.new(0, 0, 640, 480)
@bg = Sprite.new(@viewport) @bg = Sprite.new(@viewport)
@ -145,7 +155,7 @@ class Window_Settings
tr('In-Game Timer'), tr('In-Game Timer'),
tr('Language'), tr('Language'),
tr('Debug mode(DEVS ONLY!)'), tr('Debug mode(DEVS ONLY!)'),
tr('Configure Controls (Press F1)'), tr('One Shot Mode(!)'),
] ]
@index = 0 @index = 0
@ -231,6 +241,13 @@ class Window_Settings
else else
spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, tr("OFF")) spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, tr("OFF"))
end end
when 10
if(Window_Settings.OneShotMode == true)
#EdText.info(tr("WARNING: In this mode, if you close the game NOT through the bed, you will get a bad ending(Like in the Freeware Oneshot version)!"))
spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, tr("ON"))
else
spr.bitmap.draw_text(VALUE_MARGIN, 0, spr.bitmap.width, spr.bitmap.height, tr("OFF"))
end
end end
end end
@ -476,6 +493,11 @@ class Window_Settings
Window_Settings.DebugIsEnabled = !Window_Settings.DebugIsEnabled Window_Settings.DebugIsEnabled = !Window_Settings.DebugIsEnabled
redraw_setting_index(9) redraw_setting_index(9)
end end
when 10
if Input.trigger?(Input::ACTION) || Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
Window_Settings.OneShotMode = !Window_Settings.OneShotMode
redraw_setting_index(10)
end
end end
if Input.trigger?(Input::CANCEL) if Input.trigger?(Input::CANCEL)

View file

@ -48,48 +48,40 @@ struct ID \
} \ } \
}; };
namespace Buffer namespace Buffer{
{
DEF_AL_ID DEF_AL_ID
inline Buffer::ID gen() inline Buffer::ID gen(){
{
Buffer::ID id; Buffer::ID id;
alGenBuffers(1, &id.al); alGenBuffers(1, &id.al);
return id; return id;
} }
inline void del(Buffer::ID id) inline void del(Buffer::ID id){
{
alDeleteBuffers(1, &id.al); alDeleteBuffers(1, &id.al);
} }
inline void uploadData(Buffer::ID id, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq) inline void uploadData(Buffer::ID id, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq){
{
alBufferData(id.al, format, data, size, freq); alBufferData(id.al, format, data, size, freq);
} }
inline ALint getInteger(Buffer::ID id, ALenum prop) inline ALint getInteger(Buffer::ID id, ALenum prop){
{
ALint value; ALint value;
alGetBufferi(id.al, prop, &value); alGetBufferi(id.al, prop, &value);
return value; return value;
} }
inline ALint getSize(Buffer::ID id) inline ALint getSize(Buffer::ID id){
{
return getInteger(id, AL_SIZE); return getInteger(id, AL_SIZE);
} }
inline ALint getBits(Buffer::ID id) inline ALint getBits(Buffer::ID id){
{
return getInteger(id, AL_BITS); return getInteger(id, AL_BITS);
} }
inline ALint getChannels(Buffer::ID id) inline ALint getChannels(Buffer::ID id){
{
return getInteger(id, AL_CHANNELS); return getInteger(id, AL_CHANNELS);
} }
} }
@ -98,103 +90,86 @@ namespace Source
{ {
DEF_AL_ID DEF_AL_ID
inline Source::ID gen() inline Source::ID gen(){
{
Source::ID id; Source::ID id;
alGenSources(1, &id.al); alGenSources(1, &id.al);
return id; return id;
} }
inline void del(Source::ID id) inline void del(Source::ID id){
{
alDeleteSources(1, &id.al); alDeleteSources(1, &id.al);
} }
inline void attachBuffer(Source::ID id, Buffer::ID buffer) inline void attachBuffer(Source::ID id, Buffer::ID buffer){
{
alSourcei(id.al, AL_BUFFER, buffer.al); alSourcei(id.al, AL_BUFFER, buffer.al);
} }
inline void detachBuffer(Source::ID id) inline void detachBuffer(Source::ID id){
{
attachBuffer(id, Buffer::ID(0)); attachBuffer(id, Buffer::ID(0));
} }
inline void queueBuffer(Source::ID id, Buffer::ID buffer) inline void queueBuffer(Source::ID id, Buffer::ID buffer){
{
alSourceQueueBuffers(id.al, 1, &buffer.al); alSourceQueueBuffers(id.al, 1, &buffer.al);
} }
inline Buffer::ID unqueueBuffer(Source::ID id) inline Buffer::ID unqueueBuffer(Source::ID id){
{
Buffer::ID buffer; Buffer::ID buffer;
alSourceUnqueueBuffers(id.al, 1, &buffer.al); alSourceUnqueueBuffers(id.al, 1, &buffer.al);
return buffer; return buffer;
} }
inline void clearQueue(Source::ID id) inline void clearQueue(Source::ID id){
{
attachBuffer(id, Buffer::ID(0)); attachBuffer(id, Buffer::ID(0));
} }
inline ALint getInteger(Source::ID id, ALenum prop) inline ALint getInteger(Source::ID id, ALenum prop){
{
ALint value; ALint value;
alGetSourcei(id.al, prop, &value); alGetSourcei(id.al, prop, &value);
return value; return value;
} }
inline ALint getProcBufferCount(Source::ID id) inline ALint getProcBufferCount(Source::ID id){
{
return getInteger(id, AL_BUFFERS_PROCESSED); return getInteger(id, AL_BUFFERS_PROCESSED);
} }
inline ALenum getState(Source::ID id) inline ALenum getState(Source::ID id){
{
return getInteger(id, AL_SOURCE_STATE); return getInteger(id, AL_SOURCE_STATE);
} }
inline ALfloat getSecOffset(Source::ID id) inline ALfloat getSecOffset(Source::ID id){
{
ALfloat value; ALfloat value;
alGetSourcef(id.al, AL_SEC_OFFSET, &value); alGetSourcef(id.al, AL_SEC_OFFSET, &value);
return value; return value;
} }
inline void setVolume(Source::ID id, float value) inline void setVolume(Source::ID id, float value){
{
alSourcef(id.al, AL_GAIN, value); alSourcef(id.al, AL_GAIN, value);
} }
inline void setPitch(Source::ID id, float value) inline void setPitch(Source::ID id, float value){
{
alSourcef(id.al, AL_PITCH, value); alSourcef(id.al, AL_PITCH, value);
} }
inline void play(Source::ID id) inline void play(Source::ID id){
{
alSourcePlay(id.al); alSourcePlay(id.al);
} }
inline void stop(Source::ID id) inline void stop(Source::ID id){
{
alSourceStop(id.al); alSourceStop(id.al);
} }
inline void pause(Source::ID id) inline void pause(Source::ID id){
{
alSourcePause(id.al); alSourcePause(id.al);
} }
} }
} }
inline uint8_t formatSampleSize(int sdlFormat) inline uint8_t formatSampleSize(int sdlFormat){
{
switch (sdlFormat) switch (sdlFormat)
{ {
case SDL_AUDIO_U8 : case SDL_AUDIO_U8 :
@ -215,20 +190,16 @@ inline uint8_t formatSampleSize(int sdlFormat)
return 0; return 0;
} }
inline ALenum chooseALFormat(int sampleSize, int channelCount) inline ALenum chooseALFormat(int sampleSize, int channelCount){
{ switch (sampleSize){
switch (sampleSize)
{
case 1 : case 1 :
switch (channelCount) switch (channelCount){
{
case 1 : return AL_FORMAT_MONO8; case 1 : return AL_FORMAT_MONO8;
case 2 : return AL_FORMAT_STEREO8; case 2 : return AL_FORMAT_STEREO8;
} }
/* falls through */ /* falls through */
case 2 : case 2 :
switch (channelCount) switch (channelCount){
{
case 1 : return AL_FORMAT_MONO16; case 1 : return AL_FORMAT_MONO16;
case 2 : return AL_FORMAT_STEREO16; case 2 : return AL_FORMAT_STEREO16;
} }

View file

@ -28,8 +28,7 @@
#include <cstring> #include <cstring>
#endif #endif
struct ALDataSource struct ALDataSource{
{
enum Status enum Status
{ {
NoError, NoError,

View file

@ -55,15 +55,13 @@
#include "gamecontrollerdb.txt.xxd" #include "gamecontrollerdb.txt.xxd"
#endif #endif
static void static void rgssThreadError(RGSSThreadData *rtData, const std::string &msg){
rgssThreadError(RGSSThreadData *rtData, const std::string &msg){
rtData->rgssErrorMsg = msg; rtData->rgssErrorMsg = msg;
rtData->ethread->requestTerminate(); rtData->ethread->requestTerminate();
rtData->rqTermAck.set(); rtData->rqTermAck.set();
} }
static inline const char* static inline const char* glGetStringInt(GLenum name){
glGetStringInt(GLenum name){
return (const char*) gl.GetString(name); return (const char*) gl.GetString(name);
} }