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(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

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,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; \
} \

View file

@ -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<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){
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[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;

View file

@ -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<Rect>(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); );

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,8 +65,7 @@ RB_METHOD(disposableDispose){
if (d->isDisposed())
return Qnil;
if (rgssVer == 1)
disposableDisposeChildren(self);
disposableDisposeChildren(self);
d->dispose();

View file

@ -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<Klass>(otherObj, Klass##Type); \
return rb_bool_new(*p == *other); \
}

View file

@ -27,7 +27,6 @@
#include <string.h>
static void collectStrings(VALUE obj, std::vector<std::string> &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;
}

View file

@ -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);
}
}

View file

@ -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){

View file

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

View file

@ -112,4 +112,4 @@ module Settings
end
end
end

View file

@ -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";

View file

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

View file

@ -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);
}

View file

@ -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};

View file

@ -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)
{

View file

@ -48,7 +48,6 @@
#include <string>
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);

View file

@ -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 */

View file

@ -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;