Skip to content

Commit

Permalink
Merge branch 'main' into opt-flags
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox authored Nov 11, 2024
2 parents 80c5858 + ce24e76 commit 44ffacb
Show file tree
Hide file tree
Showing 26 changed files with 87 additions and 81 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ jobs:
# === Raspberry PI 1-4 Bare Metal ===
rpi-baremetal:
runs-on: ubuntu-latest
container: nesbox/baremetalpi-tic80:latest
container: miguelhrvs/baremetalapi-tic80:latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
Expand All @@ -255,7 +255,7 @@ jobs:
cd vendor
git clone --recursive https://github.com/smuehlst/circle-stdlib
cd circle-stdlib
git checkout fdb3c4a948421d47fddab8042a92f980cba43915
git checkout db053a32c165c1b22423a47ed6cb5bddc72b51f2
git submodule update --recursive
./configure -r 3
make -j$(nproc)
Expand Down Expand Up @@ -283,24 +283,25 @@ jobs:
cp build/baremetalpi/boot/config.txt vendor/circle-stdlib/libs/circle/boot/config.txt
- name: Deploy
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "tic80-rpi-baremetal"
path: |
vendor/circle-stdlib/libs/circle/boot/bcm2710-rpi-zero-2-w.dtb
vendor/circle-stdlib/libs/circle/boot/config.txt
vendor/circle-stdlib/libs/circle/boot/kernel.img
vendor/circle-stdlib/libs/circle/boot/bootcode.bin
vendor/circle-stdlib/libs/circle/boot/start.elf
vendor/circle-stdlib/libs/circle/boot/fixup.dat
vendor/circle-stdlib/libs/circle/boot/LICENCE.broadcom
# === Raspberry PI 4 Bare Metal ===
# === Raspberry PI 4-5 Bare Metal ===
rpi4-baremetal:
runs-on: ubuntu-latest
container: nesbox/baremetalpi-tic80:latest
container: miguelhrvs/baremetalapi-tic80:latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
Expand All @@ -315,7 +316,7 @@ jobs:
cd vendor
git clone --recursive https://github.com/smuehlst/circle-stdlib
cd circle-stdlib
git checkout fdb3c4a948421d47fddab8042a92f980cba43915
git checkout db053a32c165c1b22423a47ed6cb5bddc72b51f2
git submodule update --recursive
./configure -r 4
make -j$(nproc)
Expand Down Expand Up @@ -343,12 +344,14 @@ jobs:
cp build/baremetalpi/boot/config.txt vendor/circle-stdlib/libs/circle/boot/config.txt
- name: Deploy
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "tic80-rpi4-baremetal"
path: |
vendor/circle-stdlib/libs/circle/boot/bcm2711-rpi-4-b.dtb
vendor/circle-stdlib/libs/circle/boot/bcm2711-rpi-cm4.dtb
vendor/circle-stdlib/libs/circle/boot/bcm2711-rpi-400.dtb
vendor/circle-stdlib/libs/circle/boot/bcm2711-rpi-5-b.dtb
vendor/circle-stdlib/libs/circle/boot/bootcode.bin
vendor/circle-stdlib/libs/circle/boot/config.txt
vendor/circle-stdlib/libs/circle/boot/COPYING.linux
Expand All @@ -360,10 +363,10 @@ jobs:
# === Nintendo 3DS build ===
nintendo-3ds:
runs-on: ubuntu-latest
container: nesbox/devkitpro-tic80:latest
container: devkitpro/devkitarm:latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
Expand All @@ -375,12 +378,11 @@ jobs:
- name: Build
run: |
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/3ds.cmake -DN3DS=TRUE -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_ALL=ON ..
make -j$(nproc)
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 ..
cmake --build build --parallel
- name: Deploy
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "tic80-nintendo-3ds"
path: build/bin/tic80.3dsx
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ message("VERSION_HASH: ${VERSION_HASH}")

configure_file("${PROJECT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h")

if(ANDROID OR EMSCRIPTEN OR N3DS OR BAREMETALPI)
if(ANDROID OR EMSCRIPTEN OR NINTENDO_3DS OR BAREMETALPI)
set(BUILD_STATIC_DEFAULT ON)
else()
set(BUILD_STATIC_DEFAULT OFF)
Expand Down Expand Up @@ -74,15 +74,15 @@ message("BUILD_SDLGPU: ${BUILD_SDLGPU}")
message("BUILD_TOUCH_INPUT: ${BUILD_TOUCH_INPUT}")
message("BUILD_WITH_ALL: ${BUILD_WITH_ALL}")

if (N3DS)
if (NINTENDO_3DS)
set(BUILD_SDL OFF)
endif()

if (BAREMETALPI)
set(BUILD_SDL OFF)
endif()

if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID AND NOT N3DS)
if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID AND NOT NINTENDO_3DS)
set(LINUX TRUE)

if(CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD")
Expand Down
12 changes: 6 additions & 6 deletions build/baremetalpi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM ubuntu:18.04
FROM ubuntu:24.04
RUN apt-get update
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:git-core/ppa -y
RUN apt-get install wget git build-essential -y
RUN wget -q https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.sh
RUN sh cmake-3.13.0-Linux-x86_64.sh --skip-license --prefix=/usr
RUN cd /opt && wget -q https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
RUN cd /opt && tar xjf gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
ENV PATH=/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/:$PATH
RUN wget -q https://cmake.org/files/v3.30/cmake-3.30.3-linux-x86_64.sh
RUN sh cmake-3.30.3-linux-x86_64.sh --skip-license --prefix=/usr
RUN cd /opt && wget -q https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz
RUN cd /opt && tar -xf arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz
ENV PATH=/opt/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi/bin/:$PATH
RUN mkdir /src
WORKDIR /src
1 change: 1 addition & 0 deletions build/baremetalpi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ LIBS := \
$(CIRCLEHOME)/addon/linux/liblinuxemu.a \
$(CIRCLEHOME)/addon/SDCard/libsdcard.a \
$(CIRCLEHOME)/addon/fatfs/libfatfs.a \
$(CIRCLEHOME)/lib/sound/libsound.a \
$(CIRCLEHOME)/lib/usb/libusb.a \
$(CIRCLEHOME)/lib/input/libinput.a \
$(CIRCLEHOME)/lib/fs/fat/libfatfs.a \
Expand Down
9 changes: 3 additions & 6 deletions build/n3ds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

## Requirements

* devkitARM (tested on release 54, please use latest) + the 3ds-dev meta package
* devkitARM (tested on release 65, please use latest) + the 3ds-dev meta package
* the following additional packages:
* devkitpro-pkgbuild-helpers
* 3ds-libpng
* 3ds-pkg-config
* 3ds-zlib

## Building instructions

```
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/3ds.cmake -DN3DS=TRUE
make
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/3DS.cmake
cmake --build build
```

You should now be able to find `tic80.3dsx` in build/bin.
5 changes: 0 additions & 5 deletions build/n3ds/elf_to_3dsx.sh

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/lua.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if(BUILD_WITH_LUA)
${CMAKE_SOURCE_DIR}/src
)

if(N3DS)
if(NINTENDO_3DS)
target_compile_definitions(luaapi PUBLIC LUA_32BITS)
endif()

Expand Down
26 changes: 17 additions & 9 deletions cmake/n3ds.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,34 @@
# TIC-80 app (N3DS)
################################

if(N3DS)
if(NINTENDO_3DS)
set(TIC80_SRC ${TIC80_SRC}
${CMAKE_SOURCE_DIR}/src/system/n3ds/utils.c
${CMAKE_SOURCE_DIR}/src/system/n3ds/keyboard.c
${CMAKE_SOURCE_DIR}/src/system/n3ds/main.c
)

add_executable(tic80_n3ds ${TIC80_SRC})
add_executable(tic80 ${TIC80_SRC})

target_include_directories(tic80_n3ds PRIVATE
target_include_directories(tic80 PRIVATE
${DEVKITPRO}/portlibs/3ds/include
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src)

target_link_directories(tic80_n3ds PRIVATE ${DEVKITPRO}/libctru/lib ${DEVKITPRO}/portlibs/3ds/lib)
target_link_libraries(tic80_n3ds tic80studio png citro3d)
target_link_directories(tic80 PRIVATE ${DEVKITPRO}/libctru/lib ${DEVKITPRO}/portlibs/3ds/lib)
target_link_libraries(tic80 tic80studio png citro3d)

add_custom_command(TARGET tic80_n3ds
POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/build/n3ds/elf_to_3dsx.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/build
ctr_generate_smdh(tic80.smdh
NAME "TIC-80 tiny computer"
DESCRIPTION "Fantasy computer for making, playing and sharing tiny games"
AUTHOR "Nesbox"
ICON ${CMAKE_SOURCE_DIR}/build/n3ds/icon.png
)

ctr_create_3dsx(tic80
SMDH tic80.smdh
ROMFS ${CMAKE_SOURCE_DIR}/build/n3ds/romfs
OUTPUT ${CMAKE_SOURCE_DIR}/build/bin/tic80.3dsx
)

endif()
2 changes: 1 addition & 1 deletion cmake/naett.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# naett
################################

if(NOT RPI AND NOT N3DS AND NOT EMSCRIPTEN AND NOT BAREMETALPI)
if(NOT RPI AND NOT NINTENDO_3DS AND NOT EMSCRIPTEN AND NOT BAREMETALPI)
set(USE_NAETT TRUE)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/quickjs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if(BUILD_WITH_JS)
target_compile_definitions(quickjs PRIVATE DUMP_LEAKS)
endif()

if(BAREMETALPI OR N3DS)
if(BAREMETALPI OR NINTENDO_3DS)
target_compile_definitions(quickjs PRIVATE POOR_CLIB)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/scheme.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if(BUILD_WITH_SCHEME)
${CMAKE_SOURCE_DIR}/src
)

if (N3DS)
if (NINTENDO_3DS)
target_compile_definitions(scheme PRIVATE S7_N3DS)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/zlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ZLIB
################################

if (NOT N3DS)
if (NOT NINTENDO_3DS)

set(ZLIB_DIR ${THIRDPARTY_DIR}/zlib)
set(ZLIB_SRC
Expand Down
3 changes: 2 additions & 1 deletion src/api/fennel.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ static const char* execute_fennel_src = FENNEL_CODE(
io = { read = true }
local fennel = require("fennel")
debug.traceback = fennel.traceback
local opts = {allowedGlobals = false, ["error-pinpoint"]={">>", "<<"}}
local opts = {allowedGlobals = false, ["error-pinpoint"]={">>", "<<"},
filename="game.fnl"}
local src = ...
if(src:find("\n;; +strict: *true")) then opts.allowedGlobals = nil end
local ok, msg = pcall(fennel.eval, src, opts)
Expand Down
18 changes: 12 additions & 6 deletions src/api/luaapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,14 +1595,14 @@ static s32 lua_ffts(lua_State* lua)
return 0;
}

static s32 lua_dofile(lua_State *lua)
static int lua_dofile(lua_State *lua)
{
luaL_error(lua, "unknown method: \"dofile\"\n");

return 0;
}

static s32 lua_loadfile(lua_State *lua)
static int lua_loadfile(lua_State *lua)
{
luaL_error(lua, "unknown method: \"loadfile\"\n");

Expand Down Expand Up @@ -1634,12 +1634,12 @@ void luaapi_init(tic_core* core)
{
static const struct{lua_CFunction func; const char* name;} ApiItems[] =
{
#define API_FUNC_DEF(name, ...) {lua_ ## name, #name},
#define API_FUNC_DEF(name, ...) {(lua_CFunction)(lua_ ## name), #name},
TIC_API_LIST(API_FUNC_DEF)
#undef API_FUNC_DEF

#if defined(BUILD_DEPRECATED)
{lua_textri, "textri"},
{(lua_CFunction)lua_textri, "textri"},
#endif
};

Expand All @@ -1665,7 +1665,7 @@ void luaapi_close(tic_mem* tic)
** Message handler which appends stract trace to exceptions.
** This function was extractred from lua.c.
*/
static s32 msghandler (lua_State *lua)
static int msghandler (lua_State *lua)
{
const char *msg = lua_tostring(lua, 1);
if (msg == NULL) /* is error object not a string? */
Expand All @@ -1676,7 +1676,13 @@ static s32 msghandler (lua_State *lua)
else
msg = lua_pushfstring(lua, "(error object is a %s value)", luaL_typename(lua, 1));
}
luaL_traceback(lua, lua, msg, 1); /* append a standard traceback */
/* call the debug.traceback function instead of luaL_traceback so */
/* customized sourcemap-aware debug.traceback can give better line numbers */
lua_getglobal(lua, "debug");
lua_pushstring(lua, "traceback");
lua_gettable(lua, -2);
lua_pushstring(lua, msg);
lua_call(lua, 1, 1);
return 1; /* return the traceback */
}

Expand Down
5 changes: 3 additions & 2 deletions src/api/mruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,12 +1012,13 @@ static mrb_value mrb_mouse(mrb_state *mrb, mrb_value self)

tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core;

tic_point pos = core->api.mouse(tic);
const tic80_mouse* mouse = &tic->ram->input.mouse;

mrb_value hash = mrb_hash_new(mrb);

mrb_hash_set(mrb, hash, sym_x, mrb_fixnum_value(mouse->x));
mrb_hash_set(mrb, hash, sym_y, mrb_fixnum_value(mouse->y));
mrb_hash_set(mrb, hash, sym_x, mrb_fixnum_value(pos.x));
mrb_hash_set(mrb, hash, sym_y, mrb_fixnum_value(pos.y));
mrb_hash_set(mrb, hash, sym_left, mrb_bool_value(mouse->left));
mrb_hash_set(mrb, hash, sym_middle, mrb_bool_value(mouse->middle));
mrb_hash_set(mrb, hash, sym_right, mrb_bool_value(mouse->right));
Expand Down
2 changes: 1 addition & 1 deletion src/api/wren.c
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ static void initAPI(tic_core* core)
}
}

static void reportError(WrenVM* vm, WrenErrorType type, const char* module, s32 line, const char* message)
static void reportError(WrenVM* vm, WrenErrorType type, const char* module, int line, const char* message)
{
tic_core* core = getWrenCore(vm);

Expand Down
Loading

0 comments on commit 44ffacb

Please sign in to comment.