From 5a161ce8b752c64fe27d0a91885795f840ebda67 Mon Sep 17 00:00:00 2001 From: DepressedTWM Date: Fri, 5 Jun 2026 12:50:18 -0400 Subject: [PATCH] Fuck RPGMaker games compatibility, more optimizatopn for GCC compiled binaryez --- CMakeLists.txt | 32 +++++++-- CREDITS.md | 23 +++++++ binding-mri/audio-binding.cpp | 5 +- binding-mri/binding-mri.cpp | 9 +-- binding-mri/binding-util.cpp | 2 +- binding-mri/bitmap-binding.cpp | 28 +------- binding-mri/chroma-binding.cpp | 96 --------------------------- binding-mri/disposable-binding.h | 3 +- binding-mri/etc-binding.cpp | 3 - binding-mri/font-binding.cpp | 7 -- binding-mri/input-binding.cpp | 33 +++------ binding-mri/viewport-binding.cpp | 2 +- binding-mri/viewportelement-binding.h | 3 +- scripts/Settings.rb | 2 +- src/config.cpp | 1 - src/config.h | 2 - src/eventthread.cpp | 2 +- src/screen.cpp | 1 - src/sdlsoundsource.cpp | 6 +- src/sharedstate.cpp | 5 +- src/sharedstate.h | 2 - src/vorbissource.cpp | 6 +- 22 files changed, 75 insertions(+), 198 deletions(-) create mode 100644 CREDITS.md delete mode 100644 binding-mri/chroma-binding.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index cecd68b..220653c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ include(FindPackageHandleStandardArgs) option(STEAM "Build for Steam" OFF) option(DEBUG "Debug mode" OFF) option(FORCE32 "Force 32bit compile on 64bit OS" OFF) # from MKXP +option(NATIVE "Use native instructions(for local use only)" ON) # from MKXP option(EXTRA_SECURITY "Extra security" OFF) set(CMAKE_DISABLE_IN_SOURCE_BUILD TRUE) @@ -24,21 +25,45 @@ if(FORCE32) endif() endif() +if(NATIVE) + if (MSVC) + #TODO + add_compile_options() + else() + add_compile_options(-march=native -mtune=native) + endif() +endif() + if(DEBUG) # Debug stuff if (MSVC) add_compile_options(/EHr /fsanitize /validate-charset /DEBUG /RTCu /RTCs /RTCc) - set(WINDOWS_EXPORT_ALL_SYMBOLS ON) else() - add_compile_options(-g3 -O0 -fno-omit-frame-pointer -ggdb -fcheck-new -gbtf -pipe) + add_compile_options(-g3 -O0 -fno-omit-frame-pointer -ggdb -fcheck-new -gbtf) endif() else() # Optimization stuff if (MSVC) add_compile_options(/O2 /fp:fast /GL /GF /GA) else() - add_compile_options(-O3 -ffast-math -flto -pipe -funroll-loops -falign-functions=16 -falign-jumps=8 -falign-loops=8 -fno-common -s) + #bruh.... + add_compile_options(-Ofast -flto -funroll-loops -fipa-pta -ftree-vectorize -fstdarg-opt -fomit-frame-pointer) add_link_options(-Wl,-O2) + set_property(SOURCE src/tilequad.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/tilemap.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/tileatlas.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/texpool.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/table.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/sprite.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/shader.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/security.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/vorbissource.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/sdlsoundsource.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/screen.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/oneshot.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/meow.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/etc.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") + set_property(SOURCE src/filesystem.cpp APPEND PROPERTY COMPILE_OPTIONS "-fgcse-las") endif() endif() @@ -313,7 +338,6 @@ set(BINDING_SOURCE binding-mri/steam-binding.cpp binding-mri/wallpaper-binding.cpp binding-mri/journal-binding.cpp - binding-mri/chroma-binding.cpp binding-mri/niko-binding.cpp binding-mri/time-binding.cpp binding-mri/shader-binging.cpp diff --git a/CREDITS.md b/CREDITS.md new file mode 100644 index 0000000..7f05220 --- /dev/null +++ b/CREDITS.md @@ -0,0 +1,23 @@ +Programmers: + +* Issac332 +* "Визя" +* DepressedTWM + +Artists: + +* Issac332 +* Creature_of_steel1 + +Testers: + +* Rubik +* Prime 223432 + +External artists: +* "Ргинша" + +Donators: + +* Kodu + diff --git a/binding-mri/audio-binding.cpp b/binding-mri/audio-binding.cpp index 0c42f1f..1de027b 100644 --- a/binding-mri/audio-binding.cpp +++ b/binding-mri/audio-binding.cpp @@ -32,10 +32,7 @@ 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); \ + 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; \ } \ diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index c296695..bc81165 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -83,7 +83,6 @@ void nikoBindingInit(); void oneshotBindingInit(); void SunshineBindingInit(); void steamBindingInit(); -void chromaBindingInit(); void shaderBindingInit(); RB_METHOD(mriPrint); @@ -119,7 +118,6 @@ static void mriBindingInit(){ oneshotBindingInit(); SunshineBindingInit(); steamBindingInit(); - chromaBindingInit(); shaderBindingInit(); _rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain); @@ -142,11 +140,6 @@ static void mriBindingInit(){ /* Load global constants */ rb_gv_set("MKXP", Qtrue); - - VALUE debug = rb_bool_new(shState->config().editor.debug); - rb_gv_set("DEBUG", debug); - - rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest)); } static void printP(int argc, VALUE *argv, const char *convMethod, const char *sep){ @@ -335,7 +328,7 @@ struct BacktraceData{ BoostHash scriptNames; }; -#define SCRIPT_SECTION_FMT (rgssVer >= 3 ? "{%04ld}" : "Section%03ld") +#define SCRIPT_SECTION_FMT "Section%03ld" static void runRMXPScripts(BacktraceData &btData){ const Config &conf = shState->rtData().config; diff --git a/binding-mri/binding-util.cpp b/binding-mri/binding-util.cpp index 91426a3..38a7d9e 100644 --- a/binding-mri/binding-util.cpp +++ b/binding-mri/binding-util.cpp @@ -48,7 +48,7 @@ RbData::RbData(){ exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException); exc[RGSS] = rb_define_class("RGSSError", rb_eStandardError); - exc[Reset] = rb_define_class(rgssVer >= 3 ? "RGSSReset" : "Reset", rb_eException); + exc[Reset] = rb_define_class("Reset", rb_eException); exc[ErrnoENOENT] = rb_const_get(rb_const_get(rb_cObject, rb_intern("Errno")), rb_intern("ENOENT")); exc[IOError] = rb_eIOError; diff --git a/binding-mri/bitmap-binding.cpp b/binding-mri/bitmap-binding.cpp index fd4b0c9..329003f 100644 --- a/binding-mri/bitmap-binding.cpp +++ b/binding-mri/bitmap-binding.cpp @@ -238,14 +238,7 @@ RB_METHOD(bitmapDrawText){ VALUE rectObj; Rect *rect; - if (rgssVer >= 2){ - VALUE strObj; - rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END); - - str = objAsStringPtr(strObj); - }else{ - rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END); - } + rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END); rect = getPrivateDataCheck(rectObj, RectType); @@ -253,15 +246,7 @@ RB_METHOD(bitmapDrawText){ }else{ int x, y, width, height; - if (rgssVer >= 2){ - VALUE strObj; - rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END); - - str = objAsStringPtr(strObj); - }else{ - rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END); - } - + rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END); GUARD_EXC( b->drawText(x, y, width, height, str, align); ); } @@ -273,14 +258,7 @@ RB_METHOD(bitmapTextSize){ const char *str; - if (rgssVer >= 2){ - VALUE strObj; - rb_get_args(argc, argv, "o", &strObj RB_ARG_END); - - str = objAsStringPtr(strObj); - }else{ - rb_get_args(argc, argv, "z", &str RB_ARG_END); - } + rb_get_args(argc, argv, "z", &str RB_ARG_END); IntRect value; GUARD_EXC( value = b->textSize(str); ); diff --git a/binding-mri/chroma-binding.cpp b/binding-mri/chroma-binding.cpp deleted file mode 100644 index 3cc4bde..0000000 --- a/binding-mri/chroma-binding.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "binding-util.h" -#include "binding-types.h" -#include "debugwriter.h" - -#include "third_party/chromasdk/ChromaApi.h" - -bool INIT_SUCCESS = false; - -#ifdef _WIN32 - HINSTANCE hLib = NULL; -#else - int* hLib = NULL; -#endif - -//dynamic-loaded proc pointers -PluginPlayAnimation _playAnimation = NULL; -PluginOpenAnimation _openAnimation = NULL; -PluginIsInitialized _pluginIsInitialized = NULL; -PluginInit _pluginInit = NULL; -PluginUninit _pluginUninit = NULL; - -int lastAnimId = -1; - -void _attemptLinkSdk() { - Debug() << "[_attempLinkSdk] Attempting to bind Chroma SDK"; - #ifdef _WIN32 - hLib = LoadLibrary(L"ChromaApi.dll"); - if (hLib != NULL) { - Debug() << "[_attempLinkSdk] Chroma Impl @" << hLib; - INIT_SUCCESS = true; - - _playAnimation = (PluginPlayAnimation) GetProcAddress(hLib, "PluginPlayAnimation"); - INIT_SUCCESS &= _playAnimation != NULL; - Debug() << "[_attempLinkSdk] Plugin method @" << reinterpret_cast(_playAnimation); - - _openAnimation = (PluginOpenAnimation) GetProcAddress(hLib, "PluginOpenAnimation"); - INIT_SUCCESS &= _openAnimation != NULL; - - _pluginInit = (PluginInit) GetProcAddress(hLib, "PluginInit"); - INIT_SUCCESS &= _pluginInit != NULL; - - _pluginIsInitialized = (PluginIsInitialized) GetProcAddress(hLib, "PluginIsInitialized"); - INIT_SUCCESS &= _pluginInit != NULL; - if (INIT_SUCCESS && !_pluginIsInitialized()) { - Debug() << "[_attempLinkSdk] Initializing chroma plugin"; - _pluginInit(); - } - _pluginUninit = (PluginUninit) GetProcAddress(hLib, "PluginUninit"); - INIT_SUCCESS &= _pluginUninit != NULL; - Debug() << "[_attempLinkSdk] Plugin init success:" << INIT_SUCCESS; - } - #else - // Currently the Razor Chroma API is Windows-only. - // So, if we are not building for Windows platform, - // then don't bother with Chroma stuff. - Debug() << "[_attempLinkSdk] Chroma: Unsupported Platform"; - #endif -} - - -RB_METHOD(chromaPlayAnimation) { - RB_UNUSED_PARAM; - - Debug() << "[chromaPlayAnimation] Chroma: Attempting to play animation."; - const char* animfile; - bool loop; - - rb_get_args(argc, argv, "zb", &animfile, &loop RB_ARG_END); - - if (INIT_SUCCESS) { - lastAnimId = _openAnimation(animfile); - Debug() << "[chromaPlayAnimation] Opening animation:" << animfile; - Debug() << "[chromaPlayAnimation] ID:" << lastAnimId; - _playAnimation(lastAnimId); - } - - return Qnil; -} - -void chromaBindingInit() { - _attemptLinkSdk(); - - VALUE module = rb_define_module("Chroma"); - _rb_define_module_function(module, "playAnim", chromaPlayAnimation); -} - -void chromaBindingRelease() { - #ifdef _WIN32 - if (hLib != NULL) { - _pluginUninit(); - FreeLibrary(hLib); - hLib = NULL; - INIT_SUCCESS = false; - } - #endif -} diff --git a/binding-mri/disposable-binding.h b/binding-mri/disposable-binding.h index 023dea3..63fa282 100644 --- a/binding-mri/disposable-binding.h +++ b/binding-mri/disposable-binding.h @@ -65,8 +65,7 @@ RB_METHOD(disposableDispose){ if (d->isDisposed()) return Qnil; - if (rgssVer == 1) - disposableDisposeChildren(self); + disposableDisposeChildren(self); d->dispose(); diff --git a/binding-mri/etc-binding.cpp b/binding-mri/etc-binding.cpp index 96f72db..23e82cc 100644 --- a/binding-mri/etc-binding.cpp +++ b/binding-mri/etc-binding.cpp @@ -69,9 +69,6 @@ ATTR_INT_RW(Rect, Height) VALUE otherObj; \ Klass *other; \ rb_get_args(argc, argv, "o", &otherObj RB_ARG_END); \ - if (rgssVer >= 3) \ - if (!rb_typeddata_is_kind_of(otherObj, &Klass##Type)) \ - return Qfalse; \ other = getPrivateDataCheck(otherObj, Klass##Type); \ return rb_bool_new(*p == *other); \ } diff --git a/binding-mri/font-binding.cpp b/binding-mri/font-binding.cpp index b6b8e00..3c951bc 100644 --- a/binding-mri/font-binding.cpp +++ b/binding-mri/font-binding.cpp @@ -27,7 +27,6 @@ #include - static void collectStrings(VALUE obj, std::vector &out){ if (RB_TYPE_P(obj, RUBY_T_STRING)){ out.push_back(RSTRING_PTR(obj)); @@ -94,9 +93,6 @@ RB_METHOD(fontInitialize){ wrapProperty(self, &f->getColor(), "color", ColorType); - if (rgssVer >= 3) - wrapProperty(self, &f->getOutColor(), "out_color", ColorType); - return self; } @@ -116,9 +112,6 @@ RB_METHOD(fontInitializeCopy){ wrapProperty(self, &f->getColor(), "color", ColorType); - if (rgssVer >= 3) - wrapProperty(self, &f->getOutColor(), "out_color", ColorType); - return self; } diff --git a/binding-mri/input-binding.cpp b/binding-mri/input-binding.cpp index f0f9507..826d600 100644 --- a/binding-mri/input-binding.cpp +++ b/binding-mri/input-binding.cpp @@ -41,10 +41,10 @@ static int getButtonArg(int argc, VALUE *argv){ if (FIXNUM_P(argv[0])){ num = FIX2INT(argv[0]); } - else if (SYMBOL_P(argv[0]) && rgssVer >= 3){ - VALUE symHash = getRbData()->buttoncodeHash; - num = FIX2INT(rb_hash_lookup2(symHash, argv[0], INT2FIX(Input::None))); - } + //else if (SYMBOL_P(argv[0]) && rgssVer >= 3){ + // VALUE symHash = getRbData()->buttoncodeHash; + // num = FIX2INT(rb_hash_lookup2(symHash, argv[0], INT2FIX(Input::None))); + //} else{ // FIXME: RMXP allows only few more types that // don't make sense (symbols in pre 3, floats) @@ -171,27 +171,10 @@ void inputBindingInit(){ _rb_define_module_function(module, "quit?", inputQuit); - if (rgssVer >= 3){ - VALUE symHash = rb_hash_new(); + for (size_t i = 0; i < buttonCodesN; ++i){ + ID sym = rb_intern(buttonCodes[i].str); + VALUE val = INT2FIX(buttonCodes[i].val); - for (size_t i = 0; i < buttonCodesN; ++i){ - ID sym = rb_intern(buttonCodes[i].str); - VALUE val = INT2FIX(buttonCodes[i].val); - - /* In RGSS3 all Input::XYZ constants are equal to :XYZ symbols, - * to be compatible with the previous convention */ - rb_const_set(module, sym, ID2SYM(sym)); - rb_hash_aset(symHash, ID2SYM(sym), val); - } - - rb_iv_set(module, "buttoncodes", symHash); - getRbData()->buttoncodeHash = symHash; - }else{ - for (size_t i = 0; i < buttonCodesN; ++i){ - ID sym = rb_intern(buttonCodes[i].str); - VALUE val = INT2FIX(buttonCodes[i].val); - - rb_const_set(module, sym, val); - } + rb_const_set(module, sym, val); } } diff --git a/binding-mri/viewport-binding.cpp b/binding-mri/viewport-binding.cpp index b9e0d01..b720eff 100644 --- a/binding-mri/viewport-binding.cpp +++ b/binding-mri/viewport-binding.cpp @@ -32,7 +32,7 @@ DEF_TYPE(Viewport); RB_METHOD(viewportInitialize){ Viewport *v; - if (argc == 0 && rgssVer >= 3){ + if (argc == 0){ v = new Viewport(); } else if (argc == 1){ diff --git a/binding-mri/viewportelement-binding.h b/binding-mri/viewportelement-binding.h index ca457e8..25e930b 100644 --- a/binding-mri/viewportelement-binding.h +++ b/binding-mri/viewportelement-binding.h @@ -71,8 +71,7 @@ static C *viewportElementInitialize(int argc, VALUE *argv, VALUE self){ if (!NIL_P(viewportObj)){ viewport = getPrivateDataCheck(viewportObj, ViewportType); - if (rgssVer == 1) - disposableAddChild(viewportObj, self); + disposableAddChild(viewportObj, self); } /* Construct object */ diff --git a/scripts/Settings.rb b/scripts/Settings.rb index da90c4a..794c0c7 100644 --- a/scripts/Settings.rb +++ b/scripts/Settings.rb @@ -112,4 +112,4 @@ module Settings end -end \ No newline at end of file +end diff --git a/src/config.cpp b/src/config.cpp index 9fc5ca0..6ed463b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -167,7 +167,6 @@ void Config::read(int argc, char *argv[]){ commonDataPath = prefPath(".", "Oneshot"); - rgssVersion = 1; if(windowTitle == "") game.title = "OneShot: Sunshine"; game.scripts = "Data/xScripts.rxdata"; diff --git a/src/config.h b/src/config.h index 2f4f510..041ceff 100644 --- a/src/config.h +++ b/src/config.h @@ -27,8 +27,6 @@ #include struct Config{ - unsigned short rgssVersion; - bool debugMode; bool screenMode; bool printFPS; diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 4b35648..4e5f689 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -565,7 +565,7 @@ bool EventThread::eventFilter(void *data, SDL_Event *event){ /* Workaround for Windows pausing on drag */ default: if (event->window.type == SDL_EVENT_WINDOW_MOVED){ - if (shState != NULL && shState->rgssVersion > 0){ + if (shState != NULL){ shState->oneshot().setWindowPos(event->window.data1, event->window.data2); shState->graphics().update(false); } diff --git a/src/screen.cpp b/src/screen.cpp index 896d877..6b2f983 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -24,7 +24,6 @@ static bool readMessage(Pipe &ipc, char *buf, size_t size){ } int screenMain(Config &conf){ - char msg[512]; const SDL_Color colorKey = {0x00, 0xFF, 0x00, 0xFF}; const SDL_Color black = {0x00, 0x00, 0x00, 0xFF}; diff --git a/src/sdlsoundsource.cpp b/src/sdlsoundsource.cpp index f3f0856..09b8dfd 100644 --- a/src/sdlsoundsource.cpp +++ b/src/sdlsoundsource.cpp @@ -30,15 +30,11 @@ struct SDLSoundSource : ALDataSource{ SDL_IOStream &srcOps; uint8_t sampleSize; bool looped; - char msg[512]; ALenum alFormat; ALsizei alFreq; - SDLSoundSource(SDL_IOStream &ops, - const char *extension, - uint32_t maxBufSize, - bool looped) + SDLSoundSource(SDL_IOStream &ops, const char *extension, uint32_t maxBufSize, bool looped) : srcOps(ops), looped(looped) { diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp index c19cc34..fe97e0f 100644 --- a/src/sharedstate.cpp +++ b/src/sharedstate.cpp @@ -48,7 +48,6 @@ #include SharedState *SharedState::instance = 0; -int SharedState::rgssVersion = 0; static GlobalIBO *_globalIBO = 0; struct SharedStatePrivate{ @@ -145,9 +144,7 @@ void SharedState::initInstance(RGSSThreadData *threadData){ /* This section is tricky because of dependencies: * SharedState depends on GlobalIBO existing, * Font depends on SharedState existing */ - - rgssVersion = threadData->config.rgssVersion; - + _globalIBO = new GlobalIBO(); _globalIBO->ensureSize(1); diff --git a/src/sharedstate.h b/src/sharedstate.h index f93b774..1e562d8 100644 --- a/src/sharedstate.h +++ b/src/sharedstate.h @@ -27,7 +27,6 @@ #define shState SharedState::instance #define glState shState->_glState() -#define rgssVer SharedState::rgssVersion struct SharedStatePrivate; struct RGSSThreadData; @@ -119,7 +118,6 @@ struct SharedState{ void checkReset(); static SharedState *instance; - static int rgssVersion; /* This function will throw an Exception instance * on initialization error */ diff --git a/src/vorbissource.cpp b/src/vorbissource.cpp index 1ec7288..1b2b1f9 100644 --- a/src/vorbissource.cpp +++ b/src/vorbissource.cpp @@ -63,9 +63,9 @@ struct VorbisSource : ALDataSource{ } loop; struct{ - unsigned int channels; - unsigned int rate; - unsigned int frameSize; + int channels; + int rate; + int frameSize; ALenum alFormat; } info;