Merge branch 'misc-fixes' into libretro-compat

This commit is contained in:
刘皓 2025-02-27 22:56:24 -05:00
commit ecc5cb5de3
No known key found for this signature in database
GPG key ID: 7901753DB465B711
9 changed files with 81 additions and 22 deletions

View file

@ -29,7 +29,6 @@ jobs:
base-devel
git
ruby
vim
mingw-w64-x86_64-cmake
mingw-w64-x86_64-meson
mingw-w64-x86_64-autotools

View file

@ -17,10 +17,11 @@ foreach file : embedded_assets_f
input: file,
output: '@0@.xxd'.format(embedded_assets[count]),
command: [
xxd, '-i', '@INPUT@'
embedtool,
'@INPUT@',
'@OUTPUT@',
'mkxp_assets_@0@'.format(embedded_assets[count].replace('.', '_')),
],
capture: true,
depend_files: embedded_assets_f[count]
)
count += 1
endforeach

59
embedtool.cpp Normal file
View file

@ -0,0 +1,59 @@
/*
** embedtool.cpp
**
** This file is part of mkxp.
**
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdint>
#include <fstream>
int main(int argc, char **argv) {
if (argc < 4) {
return 1;
}
const char *input = argv[1];
const char *output = argv[2];
const char *arrayname = argv[3];
std::ifstream inputf(input);
if (!inputf.is_open()) {
return 2;
}
std::ofstream outputf(output);
if (!outputf.is_open()) {
return 3;
}
outputf << "#include <stddef.h>\n#include <stdint.h>\nconst uint8_t " << arrayname << "[] = {";
uint64_t len = 0;
for (;;) {
unsigned char c = inputf.get();
if (inputf.eof()) {
break;
}
outputf << (unsigned int)c << ',';
++len;
}
outputf << "};\nconst size_t " << arrayname << "_len = " << len << "ULL;";
return 0;
}

View file

@ -12,6 +12,8 @@ if not is_libretro and host_system == 'darwin'
error('This Meson project no longer supports macOS. Please use the Xcode project instead.')
endif
git_hash = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
compilers = {'c': meson.get_compiler('c'), 'cpp': meson.get_compiler('cpp')}
global_sources = []
@ -33,6 +35,8 @@ global_args += '-DHAVE_NANOSLEEP'
# ====================
if is_libretro
embedtool = executable('embedtool', sources: 'embedtool.cpp', native: true, override_options: [])
libretro_stage1_path = get_option('libretro_stage1_path')
libretro_link_args = []
@ -587,8 +591,6 @@ if is_emscripten or not compilers['cpp'].compiles('struct E {}; int main() { thr
libretro_defines += '-DBOOST_NO_EXCEPTIONS'
endif
xxd = find_program('xxd', native: true)
# STEAMWORKS
steamworks = false
@ -674,6 +676,9 @@ endif
global_args += '-DMKXPZ_INIT_GL_LATER'
subdir('src')
embedtool = executable('embedtool', sources: 'embedtool.cpp', native: true, override_options: [])
subdir('binding')
subdir('shader')
subdir('assets')

View file

@ -42,10 +42,11 @@ foreach file : embedded_shaders_f
input: file,
output: '@0@.xxd'.format(embedded_shaders[count]),
command: [
xxd, '-i', '@INPUT@'
embedtool,
'@INPUT@',
'@OUTPUT@',
'mkxp_shader_@0@'.format(embedded_shaders[count].replace('.', '_')),
],
capture: true,
depend_files: embedded_shaders_f[count]
)
count += 1
endforeach

View file

@ -55,14 +55,8 @@
#define BUNDLED_FONT wqymicrohei
#endif
#define BUNDLED_FONT_DECL(FONT) \
extern unsigned char ___assets_##FONT##_ttf[]; \
extern unsigned int ___assets_##FONT##_ttf_len;
BUNDLED_FONT_DECL(liberation)
#define BUNDLED_FONT_D(f) ___assets_## f ##_ttf
#define BUNDLED_FONT_L(f) ___assets_## f ##_ttf_len
#define BUNDLED_FONT_D(f) mkxp_assets_## f ##_ttf
#define BUNDLED_FONT_L(f) sizeof mkxp_assets_## f ##_ttf
// Go fuck yourself CPP
#define BNDL_F_D(f) BUNDLED_FONT_D(f)

View file

@ -74,7 +74,7 @@
#else
#define INIT_SHADER(vert, frag, name) \
{ \
Shader::init(___shader_##vert##_vert, ___shader_##vert##_vert_len, ___shader_##frag##_frag, ___shader_##frag##_frag_len, \
Shader::init(mkxp_shader_##vert##_vert, sizeof mkxp_shader_##vert##_vert, mkxp_shader_##frag##_frag, sizeof mkxp_shader_##frag##_frag, \
#vert, #frag, #name); \
}
#endif
@ -168,8 +168,8 @@ static void setupShaderSource(GLuint shader, GLenum type,
}
#ifndef MKXPZ_BUILD_XCODE
shaderSrc[i] = (const GLchar*) ___shader_common_h;
shaderSrcSize[i] = ___shader_common_h_len;
shaderSrc[i] = (const GLchar*) mkxp_shader_common_h;
shaderSrcSize[i] = sizeof mkxp_shader_common_h;
#else
shaderSrc[i] = (const GLchar*) Shader::commonHeader().c_str();
shaderSrcSize[i] = Shader::commonHeader().length();

View file

@ -184,7 +184,7 @@ void EventThread::process(RGSSThreadData &rtData)
SDL_GameControllerAddMappingsFromFile(mkxp_fs::getPathForAsset("gamecontrollerdb", "txt").c_str());
#else
SDL_GameControllerAddMappingsFromRW(
SDL_RWFromConstMem(___assets_gamecontrollerdb_txt, ___assets_gamecontrollerdb_txt_len),
SDL_RWFromConstMem(mkxp_assets_gamecontrollerdb_txt, sizeof mkxp_assets_gamecontrollerdb_txt),
1);
#endif

View file

@ -186,7 +186,7 @@ static void setupWindowIcon(const Config &conf, SDL_Window *win) {
if (conf.iconPath.empty())
#ifndef MKXPZ_BUILD_XCODE
iconSrc = SDL_RWFromConstMem(___assets_icon_png, ___assets_icon_png_len);
iconSrc = SDL_RWFromConstMem(mkxp_assets_icon_png, sizeof mkxp_assets_icon_png);
#else
iconSrc = SDL_RWFromFile(mkxp_fs::getPathForAsset("icon", "png").c_str(), "rb");
#endif