Fuck RPGMaker games compatibility, more optimizatopn for GCC compiled binaryez

This commit is contained in:
DepressedTWM 2026-06-05 12:50:18 -04:00
parent 20acf0d327
commit 5a161ce8b7
22 changed files with 75 additions and 198 deletions

View File

@ -6,6 +6,7 @@ include(FindPackageHandleStandardArgs)
option(STEAM "Build for Steam" OFF) option(STEAM "Build for Steam" OFF)
option(DEBUG "Debug mode" OFF) option(DEBUG "Debug mode" OFF)
option(FORCE32 "Force 32bit compile on 64bit OS" OFF) # from MKXP 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) option(EXTRA_SECURITY "Extra security" OFF)
set(CMAKE_DISABLE_IN_SOURCE_BUILD TRUE) set(CMAKE_DISABLE_IN_SOURCE_BUILD TRUE)
@ -24,21 +25,45 @@ if(FORCE32)
endif() endif()
endif() endif()
if(NATIVE)
if (MSVC)
#TODO
add_compile_options()
else()
add_compile_options(-march=native -mtune=native)
endif()
endif()
if(DEBUG) if(DEBUG)
# Debug stuff # Debug stuff
if (MSVC) if (MSVC)
add_compile_options(/EHr /fsanitize /validate-charset /DEBUG /RTCu /RTCs /RTCc) add_compile_options(/EHr /fsanitize /validate-charset /DEBUG /RTCu /RTCs /RTCc)
set(WINDOWS_EXPORT_ALL_SYMBOLS ON)
else() 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() endif()
else() else()
# Optimization stuff # Optimization stuff
if (MSVC) if (MSVC)
add_compile_options(/O2 /fp:fast /GL /GF /GA) add_compile_options(/O2 /fp:fast /GL /GF /GA)
else() 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) 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()
endif() endif()
@ -313,7 +338,6 @@ set(BINDING_SOURCE
binding-mri/steam-binding.cpp binding-mri/steam-binding.cpp
binding-mri/wallpaper-binding.cpp binding-mri/wallpaper-binding.cpp
binding-mri/journal-binding.cpp binding-mri/journal-binding.cpp
binding-mri/chroma-binding.cpp
binding-mri/niko-binding.cpp binding-mri/niko-binding.cpp
binding-mri/time-binding.cpp binding-mri/time-binding.cpp
binding-mri/shader-binging.cpp binding-mri/shader-binging.cpp

23
CREDITS.md Normal file
View File

@ -0,0 +1,23 @@
Programmers:
* Issac332
* "Визя"
* DepressedTWM
Artists:
* Issac332
* Creature_of_steel1
Testers:
* Rubik
* Prime 223432
External artists:
* "Ргинша"
Donators:
* Kodu

View File

@ -32,9 +32,6 @@
int volume = 100; \ int volume = 100; \
int pitch = 100; \ int pitch = 100; \
double pos = 0.0; \ double pos = 0.0; \
if (rgssVer >= 3) \
rb_get_args(argc, argv, "z|iif", &filename, &volume, &pitch, &pos RB_ARG_END); \
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); ) \ GUARD_EXC( shState->audio().entity##Play(filename, volume, pitch, pos); ) \
return Qnil; \ return Qnil; \

View File

@ -83,7 +83,6 @@ void nikoBindingInit();
void oneshotBindingInit(); void oneshotBindingInit();
void SunshineBindingInit(); void SunshineBindingInit();
void steamBindingInit(); void steamBindingInit();
void chromaBindingInit();
void shaderBindingInit(); void shaderBindingInit();
RB_METHOD(mriPrint); RB_METHOD(mriPrint);
@ -119,7 +118,6 @@ static void mriBindingInit(){
oneshotBindingInit(); oneshotBindingInit();
SunshineBindingInit(); SunshineBindingInit();
steamBindingInit(); steamBindingInit();
chromaBindingInit();
shaderBindingInit(); shaderBindingInit();
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain); _rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
@ -142,11 +140,6 @@ static void mriBindingInit(){
/* Load global constants */ /* Load global constants */
rb_gv_set("MKXP", Qtrue); 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){ static void printP(int argc, VALUE *argv, const char *convMethod, const char *sep){
@ -335,7 +328,7 @@ struct BacktraceData{
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 "Section%03ld"
static void runRMXPScripts(BacktraceData &btData){ static void runRMXPScripts(BacktraceData &btData){
const Config &conf = shState->rtData().config; const Config &conf = shState->rtData().config;

View File

@ -48,7 +48,7 @@ RbData::RbData(){
exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException); exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException);
exc[RGSS] = rb_define_class("RGSSError", rb_eStandardError); 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[ErrnoENOENT] = rb_const_get(rb_const_get(rb_cObject, rb_intern("Errno")), rb_intern("ENOENT"));
exc[IOError] = rb_eIOError; exc[IOError] = rb_eIOError;

View File

@ -238,14 +238,7 @@ RB_METHOD(bitmapDrawText){
VALUE rectObj; VALUE rectObj;
Rect *rect; 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<Rect>(rectObj, RectType); rect = getPrivateDataCheck<Rect>(rectObj, RectType);
@ -253,15 +246,7 @@ RB_METHOD(bitmapDrawText){
}else{ }else{
int x, y, width, height; 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); ); GUARD_EXC( b->drawText(x, y, width, height, str, align); );
} }
@ -273,14 +258,7 @@ RB_METHOD(bitmapTextSize){
const char *str; 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; IntRect value;
GUARD_EXC( value = b->textSize(str); ); GUARD_EXC( value = b->textSize(str); );

View File

@ -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<void*>(_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
}

View File

@ -65,7 +65,6 @@ RB_METHOD(disposableDispose){
if (d->isDisposed()) if (d->isDisposed())
return Qnil; return Qnil;
if (rgssVer == 1)
disposableDisposeChildren(self); disposableDisposeChildren(self);
d->dispose(); d->dispose();

View File

@ -69,9 +69,6 @@ ATTR_INT_RW(Rect, Height)
VALUE otherObj; \ VALUE otherObj; \
Klass *other; \ Klass *other; \
rb_get_args(argc, argv, "o", &otherObj RB_ARG_END); \ 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<Klass>(otherObj, Klass##Type); \ other = getPrivateDataCheck<Klass>(otherObj, Klass##Type); \
return rb_bool_new(*p == *other); \ return rb_bool_new(*p == *other); \
} }

View File

@ -27,7 +27,6 @@
#include <string.h> #include <string.h>
static void collectStrings(VALUE obj, std::vector<std::string> &out){ static void collectStrings(VALUE obj, std::vector<std::string> &out){
if (RB_TYPE_P(obj, RUBY_T_STRING)){ if (RB_TYPE_P(obj, RUBY_T_STRING)){
out.push_back(RSTRING_PTR(obj)); out.push_back(RSTRING_PTR(obj));
@ -94,9 +93,6 @@ RB_METHOD(fontInitialize){
wrapProperty(self, &f->getColor(), "color", ColorType); wrapProperty(self, &f->getColor(), "color", ColorType);
if (rgssVer >= 3)
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
return self; return self;
} }
@ -116,9 +112,6 @@ RB_METHOD(fontInitializeCopy){
wrapProperty(self, &f->getColor(), "color", ColorType); wrapProperty(self, &f->getColor(), "color", ColorType);
if (rgssVer >= 3)
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
return self; return self;
} }

View File

@ -41,10 +41,10 @@ static int getButtonArg(int argc, VALUE *argv){
if (FIXNUM_P(argv[0])){ if (FIXNUM_P(argv[0])){
num = FIX2INT(argv[0]); num = FIX2INT(argv[0]);
} }
else if (SYMBOL_P(argv[0]) && rgssVer >= 3){ //else if (SYMBOL_P(argv[0]) && rgssVer >= 3){
VALUE symHash = getRbData()->buttoncodeHash; // VALUE symHash = getRbData()->buttoncodeHash;
num = FIX2INT(rb_hash_lookup2(symHash, argv[0], INT2FIX(Input::None))); // num = FIX2INT(rb_hash_lookup2(symHash, argv[0], INT2FIX(Input::None)));
} //}
else{ else{
// FIXME: RMXP allows only few more types that // FIXME: RMXP allows only few more types that
// don't make sense (symbols in pre 3, floats) // don't make sense (symbols in pre 3, floats)
@ -171,22 +171,6 @@ void inputBindingInit(){
_rb_define_module_function(module, "quit?", inputQuit); _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);
/* 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){ for (size_t i = 0; i < buttonCodesN; ++i){
ID sym = rb_intern(buttonCodes[i].str); ID sym = rb_intern(buttonCodes[i].str);
VALUE val = INT2FIX(buttonCodes[i].val); VALUE val = INT2FIX(buttonCodes[i].val);
@ -194,4 +178,3 @@ void inputBindingInit(){
rb_const_set(module, sym, val); rb_const_set(module, sym, val);
} }
} }
}

View File

@ -32,7 +32,7 @@ DEF_TYPE(Viewport);
RB_METHOD(viewportInitialize){ RB_METHOD(viewportInitialize){
Viewport *v; Viewport *v;
if (argc == 0 && rgssVer >= 3){ if (argc == 0){
v = new Viewport(); v = new Viewport();
} }
else if (argc == 1){ else if (argc == 1){

View File

@ -71,7 +71,6 @@ static C *viewportElementInitialize(int argc, VALUE *argv, VALUE self){
if (!NIL_P(viewportObj)){ if (!NIL_P(viewportObj)){
viewport = getPrivateDataCheck<Viewport>(viewportObj, ViewportType); viewport = getPrivateDataCheck<Viewport>(viewportObj, ViewportType);
if (rgssVer == 1)
disposableAddChild(viewportObj, self); disposableAddChild(viewportObj, self);
} }

View File

@ -167,7 +167,6 @@ void Config::read(int argc, char *argv[]){
commonDataPath = prefPath(".", "Oneshot"); commonDataPath = prefPath(".", "Oneshot");
rgssVersion = 1;
if(windowTitle == "") if(windowTitle == "")
game.title = "OneShot: Sunshine"; game.title = "OneShot: Sunshine";
game.scripts = "Data/xScripts.rxdata"; game.scripts = "Data/xScripts.rxdata";

View File

@ -27,8 +27,6 @@
#include <set> #include <set>
struct Config{ struct Config{
unsigned short rgssVersion;
bool debugMode; bool debugMode;
bool screenMode; bool screenMode;
bool printFPS; bool printFPS;

View File

@ -565,7 +565,7 @@ bool EventThread::eventFilter(void *data, SDL_Event *event){
/* Workaround for Windows pausing on drag */ /* Workaround for Windows pausing on drag */
default: default:
if (event->window.type == SDL_EVENT_WINDOW_MOVED){ 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->oneshot().setWindowPos(event->window.data1, event->window.data2);
shState->graphics().update(false); shState->graphics().update(false);
} }

View File

@ -24,7 +24,6 @@ static bool readMessage(Pipe &ipc, char *buf, size_t size){
} }
int screenMain(Config &conf){ int screenMain(Config &conf){
char msg[512];
const SDL_Color colorKey = {0x00, 0xFF, 0x00, 0xFF}; const SDL_Color colorKey = {0x00, 0xFF, 0x00, 0xFF};
const SDL_Color black = {0x00, 0x00, 0x00, 0xFF}; const SDL_Color black = {0x00, 0x00, 0x00, 0xFF};

View File

@ -30,15 +30,11 @@ struct SDLSoundSource : ALDataSource{
SDL_IOStream &srcOps; SDL_IOStream &srcOps;
uint8_t sampleSize; uint8_t sampleSize;
bool looped; bool looped;
char msg[512];
ALenum alFormat; ALenum alFormat;
ALsizei alFreq; ALsizei alFreq;
SDLSoundSource(SDL_IOStream &ops, SDLSoundSource(SDL_IOStream &ops, const char *extension, uint32_t maxBufSize, bool looped)
const char *extension,
uint32_t maxBufSize,
bool looped)
: srcOps(ops), : srcOps(ops),
looped(looped) looped(looped)
{ {

View File

@ -48,7 +48,6 @@
#include <string> #include <string>
SharedState *SharedState::instance = 0; SharedState *SharedState::instance = 0;
int SharedState::rgssVersion = 0;
static GlobalIBO *_globalIBO = 0; static GlobalIBO *_globalIBO = 0;
struct SharedStatePrivate{ struct SharedStatePrivate{
@ -146,8 +145,6 @@ void SharedState::initInstance(RGSSThreadData *threadData){
* SharedState depends on GlobalIBO existing, * SharedState depends on GlobalIBO existing,
* Font depends on SharedState existing */ * Font depends on SharedState existing */
rgssVersion = threadData->config.rgssVersion;
_globalIBO = new GlobalIBO(); _globalIBO = new GlobalIBO();
_globalIBO->ensureSize(1); _globalIBO->ensureSize(1);

View File

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

View File

@ -63,9 +63,9 @@ struct VorbisSource : ALDataSource{
} loop; } loop;
struct{ struct{
unsigned int channels; int channels;
unsigned int rate; int rate;
unsigned int frameSize; int frameSize;
ALenum alFormat; ALenum alFormat;
} info; } info;