Skip to content

Commit eebd762

Browse files
[NDSi] Port Vanilla-Conquer to Nintendo DSi.
This commit introduces a new target platform to Vanilla-Conquer: The mighty Nintendo DSi. It includes: - A CMake toolchain file for devKitPro - A video interface to the game graphical engine relying purely on libnds. - A dedicated asynchronous sound engine running on the secondary ARM7. - Fixing many unaligned accesses problems in the engine. - Introduce ways of measuring how much RAM to allocate to BigShapeBuff. - Optimized functions for the platform and a macro that can be used by other developers to also change some functions optimizations according to their needs. [NDSi] Fix tickling effect in music
1 parent 11efe9b commit eebd762

80 files changed

Lines changed: 5573 additions & 198 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
77
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo" FORCE)
88
endif()
99

10-
project(VanillaConquer CXX)
10+
project(VanillaConquer CXX ASM)
1111

1212
option(BUILD_REMASTERTD "Build Tiberian Dawn remaster dll." OFF)
1313
option(BUILD_REMASTERRA "Build Red Alert remaster dll." OFF)
@@ -34,13 +34,19 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
3434
add_feature_info(DirectDraw DDRAW "DirectDraw video backend (deprecated)")
3535
add_feature_info(SDL2 SDL2 "SDL2 video backend")
3636
add_feature_info(OpenAL OPENAL "OpenAL audio backend")
37+
elseif(NDS)
38+
set(SDL2 FALSE)
39+
set(OPENAL FALSE)
40+
set(DSOUND FALSE)
41+
set(DDRAW FALSE)
42+
set(NETWORKING FALSE)
3743
else()
3844
set(SDL2 TRUE)
3945
set(OPENAL TRUE)
4046
endif()
4147

4248
if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
43-
option(MAKE_BUNDLE "Create a standard app bundle rather than command line program." ON)
49+
option(MAKE_BUNDLE "Create a standard app bundle rather than command line program." ON)
4450
add_feature_info(MakeBundle MAKE_BUNDLE "App bundles will be generated")
4551
if(MAKE_BUNDLE)
4652
set(MAKE_BUNDLE_OPTION MACOSX_BUNDLE)
@@ -74,6 +80,10 @@ if(NOT MSVC)
7480
set(CMAKE_CXX_FLAGS_DEBUG "-gstabs3")
7581
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
7682
set(STATIC_LIBS "-static-libstdc++ -static-libgcc")
83+
elseif(NDS)
84+
# We need to enable optimizations, else the code doesn't fit in
85+
# correct address region.
86+
set(CMAKE_CXX_FLAGS_DEBUG "-O2 -g3")
7787
else()
7888
set(CMAKE_CXX_FLAGS_DEBUG "-g3")
7989
set(CMAKE_FIND_FRAMEWORK "LAST")
@@ -134,6 +144,25 @@ if(OPENAL)
134144
set(DSOUND OFF)
135145
endif()
136146

147+
if(NDS)
148+
# This directory contains code that will run on the ARM7 chip. So we don't
149+
# define the arch variables until this directory has already been compiled.
150+
add_subdirectory(arm7)
151+
152+
# The code below will run on ARM9 chip.
153+
add_definitions(-DARM9)
154+
155+
set(ARCH "-mthumb -mthumb-interwork -mcpu=arm946e-s -mtune=arm946e-s")
156+
set(CMAKE_C_FLAGS "${ARCH} ${CMAKE_C_CFLAGS} -fomit-frame-pointer -fno-rtti -fno-exceptions -ffast-math -fno-unwind-tables")
157+
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
158+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -specs=ds_arm9.specs -mthumb -mthumb-interwork -Wl,-Map,vanilla.map")
159+
160+
# Link with those libraries.
161+
link_libraries("-lc") # C library
162+
link_libraries("-lfat")
163+
link_libraries("-lnds9")
164+
endif()
165+
137166
if(BUILD_TESTS)
138167
# Tests need to respect some options so need to occur after the options are set.
139168
enable_testing()

arm7/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
add_definitions(-DARM7 -D_NDS)
2+
3+
set(ARCH "-mthumb -mthumb-interwork -mcpu=arm7tdmi -mtune=arm7tdmi")
4+
set(CMAKE_C_FLAGS "${ARCH} -g -fomit-frame-pointer -fno-rtti -fno-exceptions -ffast-math -fstack-protector-all")
5+
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
6+
SET(CMAKE_CXX_FLAGS_DEBUG "-Os -g")
7+
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
8+
set(CMAKE_EXE_LINKER_FLAGS "-specs=ds_arm7.specs -mthumb -mthumb-interwork -Wl,-Map,vanilla.map")
9+
10+
set(ARM7_SRC
11+
main.cpp
12+
audio.cpp
13+
printf.cpp
14+
)
15+
16+
# Link with those libraries
17+
link_libraries("-lc") # C library
18+
link_libraries("-lnds7d")
19+
20+
add_executable(arm7.elf ${ARM7_SRC})

0 commit comments

Comments
 (0)