Skip to content

Commit e95e147

Browse files
committed
fix 3ds run, it's dirty atm
1 parent 98cf7ab commit e95e147

File tree

8 files changed

+58
-28
lines changed

8 files changed

+58
-28
lines changed
45.7 KB
Binary file not shown.

platforms/build-3ds.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ export ENDIANESS="little"
4545

4646
export COMMON_FLAGS="'-march=armv6k','-mtune=mpcore','-mfloat-abi=hard','-mtp=soft','-mword-relocations','-ffunction-sections','-fdata-sections'"
4747

48-
# compat flags for some POSIX functions
49-
export EXTRA_COMPILE_FLAGS="'-DNOSTYLUS','-D_XOPEN_SOURCE'"
50-
5148
export COMPILE_FLAGS="'-D_3DS','-D__3DS__','-D__CONSOLE__','-D__NINTENDO_CONSOLE__','-isystem','$LIBCTRU/include','-I$PORTLIBS_PATH_3DS/include'"
5249

5350
export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBCTRU_LIB','-fPIE','-specs=$ARCH_DEVKIT_FOLDER/$TOOL_PREFIX/lib/3dsx.specs'"
@@ -87,10 +84,10 @@ libpng-config='$BIN_DIR/libpng-config'
8784
sdl2-config='$BIN_DIR/bin/sdl2-config'
8885
8986
[built-in options]
90-
c_std = 'c11'
87+
c_std = 'gnu11'
9188
cpp_std = 'c++23'
92-
c_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS]
93-
cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS]
89+
c_args = [$COMMON_FLAGS, $COMPILE_FLAGS]
90+
cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS]
9491
c_link_args = [$COMMON_FLAGS, $LINK_FLAGS]
9592
cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS]
9693
@@ -241,9 +238,9 @@ fi
241238

242239
if [ ! -d "$ROMFS" ]; then
243240

244-
mkdir -p $ROMFS
241+
mkdir -p "$ROMFS"
245242

246-
cp -r assets $ROMFS
243+
cp -r assets "$ROMFS"
247244

248245
fi
249246

platforms/build-android.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ pkg-config = 'false'
296296
llvm-config = 'llvm-config'
297297
298298
[built-in options]
299-
c_std = 'c11'
299+
c_std = 'gnu11'
300300
cpp_std = 'c++23'
301301
c_args = ['--sysroot=${SYS_ROOT:?}','-fPIE','-fPIC','--target=$ARM_COMPILER_TRIPLE','-DHAVE_USR_INCLUDE_MALLOC_H','-D_MALLOC_H','-D__BITNESS=$BITNESS']
302302
cpp_args = ['--sysroot=${SYS_ROOT:?}','-fPIE','-fPIC','--target=$ARM_COMPILER_TRIPLE','-D__BITNESS=$BITNESS']

platforms/build-switch.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ export ENDIANESS="little"
4343

4444
export COMMON_FLAGS="'-ftls-model=local-exec','-march=armv8-a+crc+crypto','-mtune=cortex-a57','-mtp=soft','-ftls-model=local-exec','-fPIC','-ffunction-sections','-fdata-sections'"
4545

46-
# compat flags for some POSIX functions
47-
export EXTRA_COMPILE_FLAGS="'-DNOSTYLUS','-D_XOPEN_SOURCE'"
48-
4946
export COMPILE_FLAGS="'-D__SWITCH__','-D__CONSOLE__','-D__NINTENDO_CONSOLE__','-isystem','$LIBNX/include','-I$PORTLIBS_PATH_SWITCH/include'"
5047

5148
export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBNX_LIB','-fPIE','-specs=$DEVKITPRO/libnx/switch.specs'"
@@ -85,10 +82,10 @@ libpng-config='$BIN_DIR/libpng-config'
8582
sdl2-config='$BIN_DIR/sdl2-config'
8683
8784
[built-in options]
88-
c_std = 'c11'
85+
c_std = 'gnu11'
8986
cpp_std = 'c++23'
90-
c_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS]
91-
cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS]
87+
c_args = [$COMMON_FLAGS, $COMPILE_FLAGS]
88+
cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS]
9289
c_link_args = [$COMMON_FLAGS, $LINK_FLAGS]
9390
cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS]
9491
@@ -138,9 +135,9 @@ fi
138135

139136
if [ ! -d "$ROMFS" ]; then
140137

141-
mkdir -p $ROMFS
138+
mkdir -p "$ROMFS"
142139

143-
cp -r assets $ROMFS
140+
cp -r assets "$ROMFS"
144141

145142
fi
146143

src/application.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,16 @@ void Application::try_load_settings() {
285285

286286
void Application::load_resources() {
287287
constexpr auto fonts_size = 128;
288-
const std::vector<std::tuple<FontId, std::string>> fonts{
289-
{ FontId::Default, "PressStart2P.ttf"},
290-
{ FontId::Arial, "arial.ttf"},
291-
{FontId::NotoColorEmoji, "NotoColorEmoji.ttf"},
292-
{ FontId::Symbola, "Symbola.ttf"}
288+
const std::vector<std::tuple<FontId, std::string>> fonts {
289+
#if defined(__3DS__)
290+
//TODO: debug why the other font crashed, not on loading, but on trying to render text!
291+
{ FontId::Default, "LeroyLetteringLightBeta01.ttf" },
292+
#else
293+
{ FontId::Default, "PressStart2P.ttf" },
294+
#endif
295+
{ FontId::Arial, "arial.ttf" }, { FontId::NotoColorEmoji, "NotoColorEmoji.ttf" }, {
296+
FontId::Symbola, "Symbola.ttf"
297+
}
293298
};
294299
for (const auto& [font_id, path] : fonts) {
295300
const auto font_path = utils::get_assets_folder() / "fonts" / path;

src/graphics/renderer.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33

44
//TODO: assert return values of all sdl functions
55

6-
Renderer::Renderer(const Window& window, const VSync v_sync)
7-
: m_renderer{ SDL_CreateRenderer(
8-
window.get_sdl_window(),
9-
-1,
6+
Renderer::Renderer(const Window& window, const VSync v_sync) : m_renderer {
7+
SDL_CreateRenderer(
8+
window.get_sdl_window(), -1,
109
(v_sync == VSync::Enabled ? SDL_RENDERER_PRESENTVSYNC : 0) | SDL_RENDERER_TARGETTEXTURE
10+
#if defined(__3DS__)
11+
| SDL_RENDERER_SOFTWARE
12+
#else
1113
| SDL_RENDERER_ACCELERATED
12-
) } {
14+
#endif
15+
)
16+
}
17+
{
18+
1319
if (m_renderer == nullptr) {
1420
throw helper::InitializationError{ fmt::format("Failed creating a SDL Renderer: {}", SDL_GetError()) };
1521
}

src/helper/console_helpers.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,16 @@ namespace console {
3838
void sink_it_(const spdlog::details::log_msg& msg) override {
3939
spdlog::memory_buf_t formatted;
4040
spdlog::sinks::base_sink<Mutex>::formatter_->format(msg, formatted);
41-
debug_write(formatted.data(), static_cast<std::streamsize>(formatted.size()));
41+
42+
auto size = formatted.size();
43+
44+
// debug_write already writes an newline at the end!
45+
if (size > 0 and formatted.data()[size - 1] == '\n') {
46+
formatted.data()[size - 1] = '\0';
47+
--size;
48+
}
49+
50+
debug_write(formatted.data(), size);
4251
}
4352

4453
void flush_() override {

tools/dependencies/meson.build

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ if meson.is_cross_build()
99
}
1010

1111
only_allow_native_libs = true
12+
13+
# TODO: debug, if exceptions or rtti work on the 3ds
14+
15+
# if host_machine.system() == '3ds'
16+
# add_global_link_arguments(
17+
# '-fno-rtti',
18+
# '-fno-exceptions',
19+
# language: ['cpp'],
20+
# )
21+
# add_global_arguments(
22+
# '-fno-rtti',
23+
# '-fno-exceptions',
24+
# language: ['cpp'],
25+
# )
26+
# endif
27+
1228
endif
1329
endif
1430

0 commit comments

Comments
 (0)