Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NDSi] Port Vanilla-Conquer to the Nintendo DSi #821

Open
wants to merge 2 commits into
base: vanilla
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo" FORCE)
endif()

project(VanillaConquer CXX)
project(VanillaConquer CXX ASM)

option(BUILD_REMASTERTD "Build Tiberian Dawn remaster dll." OFF)
option(BUILD_REMASTERRA "Build Red Alert remaster dll." OFF)
Expand All @@ -34,13 +34,19 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_feature_info(DirectDraw DDRAW "DirectDraw video backend (deprecated)")
add_feature_info(SDL2 SDL2 "SDL2 video backend")
add_feature_info(OpenAL OPENAL "OpenAL audio backend")
elseif(NDS)
set(SDL2 FALSE)
set(OPENAL FALSE)
set(DSOUND FALSE)
set(DDRAW FALSE)
set(NETWORKING FALSE)
else()
set(SDL2 TRUE)
set(OPENAL TRUE)
endif()

if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
option(MAKE_BUNDLE "Create a standard app bundle rather than command line program." ON)
option(MAKE_BUNDLE "Create a standard app bundle rather than command line program." ON)
add_feature_info(MakeBundle MAKE_BUNDLE "App bundles will be generated")
if(MAKE_BUNDLE)
set(MAKE_BUNDLE_OPTION MACOSX_BUNDLE)
Expand Down Expand Up @@ -74,6 +80,10 @@ if(NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "-gstabs3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
set(STATIC_LIBS "-static-libstdc++ -static-libgcc")
elseif(NDS)
# We need to enable optimizations, else the code doesn't fit in
# correct address region.
set(CMAKE_CXX_FLAGS_DEBUG "-O2 -g3")
else()
set(CMAKE_CXX_FLAGS_DEBUG "-g3")
set(CMAKE_FIND_FRAMEWORK "LAST")
Expand Down Expand Up @@ -134,6 +144,25 @@ if(OPENAL)
set(DSOUND OFF)
endif()

if(NDS)
# This directory contains code that will run on the ARM7 chip. So we don't
# define the arch variables until this directory has already been compiled.
add_subdirectory(arm7)

# The code below will run on ARM9 chip.
add_definitions(-DARM9)

set(ARCH "-mthumb -mthumb-interwork -mcpu=arm946e-s -mtune=arm946e-s")
set(CMAKE_C_FLAGS "${ARCH} ${CMAKE_C_CFLAGS} -fomit-frame-pointer -fno-rtti -fno-exceptions -ffast-math -fno-unwind-tables")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -specs=ds_arm9.specs -mthumb -mthumb-interwork -Wl,-Map,vanilla.map")

# Link with those libraries.
link_libraries("-lc") # C library
link_libraries("-lfat")
link_libraries("-lnds9")
endif()

if(BUILD_TESTS)
# Tests need to respect some options so need to occur after the options are set.
enable_testing()
Expand Down
20 changes: 20 additions & 0 deletions arm7/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
add_definitions(-DARM7 -D_NDS)

set(ARCH "-mthumb -mthumb-interwork -mcpu=arm7tdmi -mtune=arm7tdmi")
set(CMAKE_C_FLAGS "${ARCH} -g -fomit-frame-pointer -fno-rtti -fno-exceptions -ffast-math -fstack-protector-all")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid a lot of this redefintion of compiler flags by using target_compile_options instead to set different options on different targets.

set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "-Os -g")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
set(CMAKE_EXE_LINKER_FLAGS "-specs=ds_arm7.specs -mthumb -mthumb-interwork -Wl,-Map,vanilla.map")

set(ARM7_SRC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same goes for libraries by using target_link_libraries.

main.cpp
audio.cpp
printf.cpp
)

# Link with those libraries
link_libraries("-lc") # C library
link_libraries("-lnds7d")

add_executable(arm7.elf ${ARM7_SRC})
Loading