Skip to content

Commit e9d10fe

Browse files
authored
Revamp the 3DS port (#2864)
- fix use of deprecated macro - move network stuff to platform directory - ensure all lua is built for 32 bit integers - clean up build configurations - use newer docker image
1 parent 7e70ea3 commit e9d10fe

File tree

15 files changed

+346
-285
lines changed

15 files changed

+346
-285
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ jobs:
330330
# === Nintendo 3DS build ===
331331
nintendo-3ds:
332332
runs-on: ubuntu-latest
333-
container: devkitpro/devkitarm:20250102
333+
container: devkitpro/devkitarm:20250728
334334

335335
steps:
336336
- uses: actions/checkout@v4
@@ -345,7 +345,9 @@ jobs:
345345
346346
- name: Build
347347
run: |
348-
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/3DS.cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON -DBUILD_WITH_SCHEME=OFF -DBUILD_WITH_JS=OFF -DBUILD_WITH_PYTHON=OFF ..
348+
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/3DS.cmake \
349+
-DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON \
350+
-DBUILD_WITH_SCHEME=OFF -DBUILD_WITH_JS=OFF -DBUILD_WITH_PYTHON=OFF
349351
cmake --build build --parallel
350352
351353
- name: Deploy

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,6 @@ build/mruby_vendor-prefix/
186186
# byte battle / test files
187187
/*.lua
188188
/*.tic
189+
# 3ds files
190+
*.3dsx
191+
*.smdh

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ message("BUILD_WITH_ALL: ${BUILD_WITH_ALL}")
7979

8080
if (NINTENDO_3DS)
8181
set(BUILD_SDL OFF)
82+
set(PREFER_SYSTEM_LIBRARIES ON)
8283
endif()
8384

8485
if (BAREMETALPI)
8586
set(BUILD_SDL OFF)
8687
endif()
8788

88-
if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID AND NOT NINTENDO_3DS)
89+
if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID)
8990
set(LINUX TRUE)
9091

9192
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD")

build/n3ds/Dockerfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

build/n3ds/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Requirements
44

5-
* devkitARM (tested on release 65, please use latest) + the 3ds-dev meta package
5+
* devkitARM + the 3ds-dev meta package
66
* the following additional packages:
77
* 3ds-libpng
88
* 3ds-zlib

cmake/moon.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ if(BUILD_WITH_MOON)
2020
add_library(lpeg STATIC ${LPEG_SRC})
2121
target_include_directories(lpeg PRIVATE ${LUA_DIR})
2222

23+
if(NINTENDO_3DS)
24+
target_compile_definitions(lpeg PUBLIC LUA_32BITS)
25+
endif()
26+
2327
add_library(moon ${TIC_RUNTIME} ${CMAKE_SOURCE_DIR}/src/api/moonscript.c)
2428

2529
if(NOT BUILD_STATIC)

cmake/n3ds.cmake

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,28 @@
33
################################
44

55
if(NINTENDO_3DS)
6-
set(TIC80_SRC ${TIC80_SRC}
6+
if(BUILD_EDITORS)
7+
target_sources(tic80studio PRIVATE
8+
src/system/n3ds/net.c)
9+
target_include_directories(tic80studio
10+
PRIVATE ${TIC80LIB_DIR}/studio)
11+
endif()
12+
13+
add_executable(${TIC80_TARGET} ${TIC80_SRC}
714
${CMAKE_SOURCE_DIR}/src/system/n3ds/utils.c
815
${CMAKE_SOURCE_DIR}/src/system/n3ds/keyboard.c
9-
${CMAKE_SOURCE_DIR}/src/system/n3ds/main.c
10-
)
11-
12-
add_executable(tic80 ${TIC80_SRC})
16+
${CMAKE_SOURCE_DIR}/src/system/n3ds/main.c)
1317

14-
target_include_directories(tic80 PRIVATE
15-
${DEVKITPRO}/portlibs/3ds/include
16-
${CMAKE_SOURCE_DIR}/include
17-
${CMAKE_SOURCE_DIR}/src)
18-
19-
target_link_directories(tic80 PRIVATE ${DEVKITPRO}/libctru/lib ${DEVKITPRO}/portlibs/3ds/lib)
20-
target_link_libraries(tic80 tic80studio png citro3d)
18+
target_link_libraries(${TIC80_TARGET} tic80studio png citro3d)
2119

2220
ctr_generate_smdh(tic80.smdh
2321
NAME "TIC-80 tiny computer"
2422
DESCRIPTION "Fantasy computer for making, playing and sharing tiny games"
25-
AUTHOR "Nesbox"
26-
ICON ${CMAKE_SOURCE_DIR}/build/n3ds/icon.png
27-
)
23+
AUTHOR "Nesbox, asie"
24+
ICON ${CMAKE_SOURCE_DIR}/build/n3ds/icon.png)
2825

29-
ctr_create_3dsx(tic80
26+
ctr_create_3dsx(${TIC80_TARGET}
3027
SMDH tic80.smdh
3128
ROMFS ${CMAKE_SOURCE_DIR}/build/n3ds/romfs
32-
OUTPUT ${CMAKE_SOURCE_DIR}/build/bin/tic80.3dsx
33-
)
34-
35-
endif()
29+
OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tic80.3dsx)
30+
endif()

cmake/wasm.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ if(BUILD_WITH_WASM)
4848

4949
add_library(wasm ${TIC_RUNTIME} ${WASM_SRC})
5050

51+
if(NINTENDO_3DS)
52+
# TODO: seems to be broken with gcc 15.1
53+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DM3_HAS_TAIL_CALL=0")
54+
endif()
55+
5156
if(NOT BUILD_STATIC)
5257
set_target_properties(wasm PROPERTIES PREFIX "")
5358
else()

cmake/yue.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ if(BUILD_WITH_YUE)
5454
)
5555

5656
if(NINTENDO_3DS)
57+
# TODO: check if this really works
5758
target_compile_options(yuescript PRIVATE -ftls-model=initial-exec)
5859
endif()
5960

cmake/zlib.cmake

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ if(PREFER_SYSTEM_LIBRARIES)
1414
endif()
1515
endif()
1616

17-
if (NOT NINTENDO_3DS)
18-
1917
set(ZLIB_DIR ${THIRDPARTY_DIR}/zlib)
2018
set(ZLIB_SRC
2119
${ZLIB_DIR}/adler32.c
@@ -33,11 +31,3 @@ set(ZLIB_SRC
3331

3432
add_library(zlib STATIC ${ZLIB_SRC})
3533
target_include_directories(zlib INTERFACE ${THIRDPARTY_DIR}/zlib)
36-
37-
else ()
38-
39-
add_library(zlib STATIC IMPORTED)
40-
set_target_properties( zlib PROPERTIES IMPORTED_LOCATION ${DEVKITPRO}/portlibs/3ds/lib/libz.a )
41-
target_include_directories(zlib INTERFACE ${DEVKITPRO}/portlibs/3ds/include)
42-
43-
endif ()

0 commit comments

Comments
 (0)