-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
188 lines (150 loc) · 4.91 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
cmake_minimum_required(VERSION 3.13)
include(pico_sdk_import.cmake)
project(wonderswan C CXX ASM)
SET(BUILD_NAME "${PROJECT_NAME}")
option(I2S "Enable I2S sound" OFF)
option(I2S_CS4334 "Enable I2S CS4334 sound" OFF)
option(VGA "Enable VGA" OFF)
option(TFT "Enable TFT display" OFF)
option(ILI9341 "Enable TFT ILI9341 display" OFF)
option(HDMI "Enable HDMI display" OFF)
option(TV "Enable TV composite output" OFF)
option(SOFTTV "Enable TV soft composite output" OFF)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
#add_compile_options(-flto)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funroll-loops -ffast-math -feliminate-unused-debug-types -ffunction-sections -fdata-sections -Ofast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops -fno-rtti -ffast-math -feliminate-unused-debug-types -ffunction-sections -fdata-sections -Ofast")
set(OUTPUT_DIR "${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
pico_sdk_init()
add_subdirectory(drivers/audio)
add_subdirectory(drivers/ps2kbd)
add_subdirectory(drivers/nespad)
add_subdirectory(drivers/fatfs)
add_subdirectory(drivers/sdcard)
add_subdirectory(drivers/psram)
add_subdirectory(drivers/vga-nextgen)
add_subdirectory(drivers/st7789)
add_subdirectory(drivers/hdmi)
add_subdirectory(drivers/tv)
add_subdirectory(drivers/tv-software)
add_subdirectory(drivers/graphics)
# INCLUDE FILES THAT SHOULD BE COMPILED:
file(GLOB_RECURSE SRC "src/*.cpp" "src/*.c")
message(STATUS "Add source files:")
foreach (SRC_FILE IN LISTS SRC)
message(STATUS "${SRC_FILE}")
endforeach ()
message(STATUS "")
add_executable(${PROJECT_NAME} ${SRC})
pico_define_boot_stage2(slower_boot2 ${PICO_DEFAULT_BOOT_STAGE2_FILE})
target_compile_definitions(slower_boot2 PRIVATE PICO_FLASH_SPI_CLKDIV=4)
pico_set_boot_stage2(${PROJECT_NAME} slower_boot2)
set(FAMILY rp2040)
set(BOARD pico_sdk)
pico_set_program_name(wonderswan "Wonderswan emulator by xrip for MURMULATOR devboard")
pico_set_program_version(wonderswan "develop")
#include_directories()
include_directories(${PROJECT_NAME} PRIVATE src src/oswan)
IF(TFT)
target_link_libraries(${PROJECT_NAME} PRIVATE st7789)
target_compile_definitions(${PROJECT_NAME} PRIVATE TFT)
SET(BUILD_NAME "${BUILD_NAME}-TFT")
IF(ILI9341)
SET(BUILD_NAME "${BUILD_NAME}-ILI9341")
target_compile_definitions(${PROJECT_NAME} PRIVATE ILI9341)
ELSE()
SET(BUILD_NAME "${BUILD_NAME}-ST7789")
ENDIF()
ELSEIF(HDMI)
target_link_libraries(${PROJECT_NAME} PRIVATE hdmi)
target_compile_definitions(${PROJECT_NAME} PRIVATE HDMI)
SET(BUILD_NAME "${BUILD_NAME}-HDMI")
ELSEIF(TV)
target_compile_definitions(${PROJECT_NAME} PRIVATE TV)
target_link_libraries(${PROJECT_NAME} PRIVATE tv)
SET(BUILD_NAME "${BUILD_NAME}-TV")
ELSEIF(SOFTTV)
target_compile_definitions(${PROJECT_NAME} PRIVATE SOFTTV)
target_link_libraries(${PROJECT_NAME} PRIVATE tv-software)
SET(BUILD_NAME "${BUILD_NAME}-TV-SOFT")
ELSE()
target_compile_definitions(${PROJECT_NAME} PRIVATE VGA)
target_link_libraries(${PROJECT_NAME} PRIVATE vga-nextgen)
SET(BUILD_NAME "${BUILD_NAME}-VGA")
ENDIF()
IF(NOT I2S)
target_compile_definitions(${PROJECT_NAME} PRIVATE AUDIO_PWM_PIN=26)
ELSEIF(I2S_CS4334)
target_compile_definitions(${PROJECT_NAME} PRIVATE I2S_CS4334)
SET(BUILD_NAME "${BUILD_NAME}-I2S-CS4334")
ELSE()
SET(BUILD_NAME "${BUILD_NAME}-I2S-TDA1387")
ENDIF()
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${BUILD_NAME}")
target_link_libraries(${PROJECT_NAME} PRIVATE
graphics
audio
nespad
sdcard
ps2kbd
fatfs
psram
pico_runtime
pico_stdlib
pico_multicore
hardware_dma
hardware_pio
hardware_i2c
hardware_interp
hardware_timer
hardware_clocks
hardware_pwm
hardware_flash
# tinyusb_board
tinyusb_device
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
PICO_FLASH_SIZE_BYTES=16777216
# SDCARD
SDCARD_PIN_SPI0_CS=5
SDCARD_PIN_SPI0_SCK=2
SDCARD_PIN_SPI0_MOSI=3
SDCARD_PIN_SPI0_MISO=4
# PS2KBD
USE_PS2_KBD
PS2KBD_GPIO_FIRST=0
# NES Gamepad
USE_NESPAD
NES_GPIO_CLK=14
NES_GPIO_DATA=16
NES_GPIO_LAT=15
# VGA 8 pins starts from pin:
VGA_BASE_PIN=6
# HDMI 8 pins starts from pin:
HDMI_BASE_PIN=6
# TFT
TFT_CS_PIN=6
TFT_RST_PIN=8
TFT_LED_PIN=9
TFT_DC_PIN=10
TFT_DATA_PIN=12
TFT_CLK_PIN=13
PSRAM
# PSRAM_MUTEX=1
PSRAM_SPINLOCK=1
PSRAM_ASYNC=1
PSRAM_PIN_CS=18
PSRAM_PIN_SCK=19
PSRAM_PIN_MOSI=20
PSRAM_PIN_MISO=21
)
target_link_options(${PROJECT_NAME} PRIVATE -Xlinker --print-memory-usage --data-sections --function-sections)
#add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
# COMMAND arm-none-eabi-size --format=berkeley "../bin/Debug/${BUILD_NAME}.elf")
pico_enable_stdio_uart(${PROJECT_NAME} 0)
pico_enable_stdio_usb(${PROJECT_NAME} 1)
pico_add_extra_outputs(${PROJECT_NAME})