sotn-decomp/CMakeLists.txt

372 lines
9.2 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.10)
project(Sound)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (WIN32)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-function-declaration")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-incompatible-pointer-types")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-int-conversion")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-return-mismatch")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-function-declaration")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-return-type")
endif()
find_package(SDL2 REQUIRED)
set(SOURCE_FILES_PC
src/pc/log.c
src/pc/stubs.c
src/pc/sotn.c
src/pc/pc.c
src/pc/str.c
Texture render support (#934) Technically unimpressive, but I had to go through quite a good amount of changes. Here is the full changelog to make everything work: * Ensure `ResetPlatform` is always called to avoid memory leaks * Add `g_RawVram` to emulate the PS1 VRAM * ~~The engine will load the optional file `disks/vram.bin`, a RAM dump from an emulator~~ * SDL2 will create 256x256 textures on-the-fly whenever a specific tpage is requested via `GetVramTexture` * The function `GetVramTexture` caches the last called tpage to avoid tanking the performance * `GetVramTexture` for only renders 4bpp and 8bpp textures with their specified palette * Remove `SDL2_image` as the font is now loaded straight from the VRAM * Calling `VSync` will call the set callback, which the game uses for DMA operations * `MyLoadImage` is not yet implemented, but it is a placeholder to then interact with `g_RawVram` * The menu font now uses the texture found in the VRAM * Plugged a custom version of `LoadFileSim` * The file `sim_pc.c` is similar to the original game's code but it is used here to load files from custom paths * Using F5, F6 or F7 can dump the VRAM content on-screen, respectively in 16bpp, 8bpp and 4bpp There are new graphical glitches on the font. In some occasions it appears black. It seems to be related to a flag in `P_TAG.code`. I plan to dig into it when I can render entities on screen to avoid potential mistakes. The same problem is present for the first half of Alucard's portrait. It seems to be related when a texture is transparent? 🤷 I am not sure why the font is completely corrupted when entering in the Equip menu. It is hard to understand if I introduced any regression. Maybe the glitch was always there but it was hidden since I was always forcing the font texture to be rendered. EDIT: Implemented `LoadImage`, `SaveImage` and `ClearImage`
2024-01-01 23:31:56 +00:00
src/pc/sim_pc.c
2024-06-06 22:11:18 +00:00
src/pc/pl_arc.c
src/pc/pl_ric.c
src/pc/stages/stage_loader.c
src/pc/stages/stage_dummy.c
src/pc/weapon_pc.c
)
if(WIN32)
list(APPEND SOURCE_FILES_PC src/pc/plat_win.c)
else()
list(APPEND SOURCE_FILES_PC src/pc/plat_unix.c)
endif()
set(SOURCE_FILES_PSX_SDK
src/main/psxsdk/libgpu/ext.c
src/main/psxsdk/libgpu/prim.c
)
set(WANT_LIBSND_LLE FALSE CACHE BOOL "Whether to append use LLE for libsnd")
if(WANT_LIBSND_LLE)
set(SOURCE_FILES_LIBSND_LLE
# libsnd
src/main/psxsdk/libsnd/adsr.c
src/main/psxsdk/libsnd/cres.c
src/main/psxsdk/libsnd/decre.c
src/main/psxsdk/libsnd/libsnd_i.h
src/main/psxsdk/libsnd/next.c
src/main/psxsdk/libsnd/pause.c
src/main/psxsdk/libsnd/play.c
src/main/psxsdk/libsnd/replay.c
src/main/psxsdk/libsnd/scsmvol.c
src/main/psxsdk/libsnd/scssattr.c
src/main/psxsdk/libsnd/scssvol.c
src/main/psxsdk/libsnd/seqinit.c
src/main/psxsdk/libsnd/seqread.c
src/main/psxsdk/libsnd/seskoff.c
src/main/psxsdk/libsnd/seskon.c
src/main/psxsdk/libsnd/sscall.c
src/main/psxsdk/libsnd/ssclose.c
src/main/psxsdk/libsnd/ssend.c
src/main/psxsdk/libsnd/ssinit.c
src/main/psxsdk/libsnd/ssinit_h.c
src/main/psxsdk/libsnd/ssplay.c
src/main/psxsdk/libsnd/ssquit.c
src/main/psxsdk/libsnd/ssstart.c
src/main/psxsdk/libsnd/sstable.c
src/main/psxsdk/libsnd/sstick.c
src/main/psxsdk/libsnd/ssvol.c
src/main/psxsdk/libsnd/stop.c
src/main/psxsdk/libsnd/tempo.c
src/main/psxsdk/libsnd/ut_gpa.c
src/main/psxsdk/libsnd/ut_gva.c
src/main/psxsdk/libsnd/ut_rdel.c
src/main/psxsdk/libsnd/ut_rdep.c
src/main/psxsdk/libsnd/ut_rev.c
src/main/psxsdk/libsnd/ut_rfb.c
src/main/psxsdk/libsnd/ut_roff.c
src/main/psxsdk/libsnd/ut_ron.c
src/main/psxsdk/libsnd/ut_sva.c
src/main/psxsdk/libsnd/vm_doff.c
src/main/psxsdk/libsnd/vm_don.c
src/main/psxsdk/libsnd/vm_vsu.c
src/main/psxsdk/libsnd/vmanager.c
src/main/psxsdk/libsnd/vs_mono.c
src/main/psxsdk/libsnd/vs_srv.c
src/main/psxsdk/libsnd/vs_vab.c
src/main/psxsdk/libsnd/vs_vfb.c
src/main/psxsdk/libsnd/vs_vh.c
src/main/psxsdk/libsnd/vs_vtb.c
src/main/psxsdk/libsnd/vs_vtbp.c
src/main/psxsdk/libsnd/vs_vtc.c
# libspu
src/main/psxsdk/libspu/s_cb.c
src/main/psxsdk/libspu/s_crwa.c
src/main/psxsdk/libspu/s_dcb.c
src/main/psxsdk/libspu/s_gva.c
src/main/psxsdk/libspu/s_i.c
src/main/psxsdk/libspu/s_ini.c
src/main/psxsdk/libspu/s_it.c
src/main/psxsdk/libspu/s_itc.c
src/main/psxsdk/libspu/s_m_f.c
src/main/psxsdk/libspu/s_m_init.c
src/main/psxsdk/libspu/s_m_m.c
src/main/psxsdk/libspu/s_m_util.c
src/main/psxsdk/libspu/s_m_wsa.c
src/main/psxsdk/libspu/s_n2p.c
src/main/psxsdk/libspu/s_q.c
src/main/psxsdk/libspu/s_r.c
src/main/psxsdk/libspu/s_sav.c
src/main/psxsdk/libspu/s_sca.c
src/main/psxsdk/libspu/s_si.c
src/main/psxsdk/libspu/s_sic.c
src/main/psxsdk/libspu/s_sk.c
src/main/psxsdk/libspu/s_snv.c
src/main/psxsdk/libspu/s_sr.c
src/main/psxsdk/libspu/s_srmp.c
src/main/psxsdk/libspu/s_stm.c
src/main/psxsdk/libspu/s_stsa.c
src/main/psxsdk/libspu/s_sva.c
src/main/psxsdk/libspu/s_w.c
src/main/psxsdk/libspu/s_wp.c
src/main/psxsdk/libspu/spu.c
src/main/psxsdk/libspu/sr_gaks.c
src/pc/psxsdk/emu.cpp
src/pc/psxsdk/mednafen/spu.cpp
)
list(APPEND SOURCE_FILES_PSX_SDK ${SOURCE_FILES_LIBSND_LLE})
endif()
set(SOURCE_FILES_MOCK_SDK
src/pc/psxsdk/libapi.c
src/pc/psxsdk/libetc.c
src/pc/psxsdk/libgpu.c
src/pc/psxsdk/libgte.c
src/pc/psxsdk/libgs.c
src/pc/psxsdk/libcd.c
src/pc/psxsdk/libcard.c
src/pc/psxsdk/libspu.c
src/pc/psxsdk/libsnd.c
src/pc/psxsdk/cdc.c
)
set(SOURCE_FILES_3RD
src/pc/3rd/cJSON/cJSON.c
)
set(SOURCE_FILES_DRA
src/dra/42398.c
src/dra/play.c
src/dra/loading.c
src/dra/pads.c
src/dra/save_mgr_pre.c
src/dra/save_mgr.c
src/dra/4A538.c
src/dra/collider.c
src/dra/demo.c
src/dra/5087C.c
src/dra/lba_stage.c
src/dra/config_us.c
src/dra/menu.c
src/dra/5D5BC.c
src/dra/d_C910.c
src/dra/627C4.c
src/dra/63ED4.c
src/dra/d_CD80.c
src/dra/692E8.c
src/dra/6D59C.c
src/dra/704D0.c
src/dra/71830.c
src/dra/72BB0.c
2024-06-03 20:47:30 +00:00
src/dra/75F54.c
src/dra/78D0C.c
src/dra/d_CF74.c
2024-06-03 20:47:30 +00:00
src/dra/7A4D0.c
src/dra/7E4BC.c
src/dra/d_DBD4.c
src/dra/d_E294.c
src/dra/d_10798.c
src/dra/843B0.c
src/dra/8A0A4.c
2024-06-03 20:47:30 +00:00
src/dra/8D3E8.c
src/dra/91EBC.c
src/dra/92F60.c
src/dra/93290.c
src/dra/93BDC.c
src/dra/94F50.c
src/dra/953A0.c
src/dra/d_24CEC.c
src/dra/d_2F324.c
src/dra/d_3B0D4.c
)
set(SOURCE_FILES_STAGE_SEL
src/pc/stages/stage_sel.c
src/st/sel/banks.c
src/st/sel/CD54.c
src/st/sel/2C048.c
src/st/sel/33164.c
src/st/sel/3410C.c
src/st/sel/3585C.c
src/st/sel/3642C.c
)
set(SOURCE_FILES_STAGE_WRP
src/pc/stages/stage_wrp.c
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
src/st/wrp/d_1b8.c
src/st/wrp/e_laydef.c
src/st/wrp/d_3e4.c
src/st/wrp/st_debug.c
src/st/wrp/e_breakable.c
src/st/wrp/d_608.c
New asset manager (#1343) This aims to deprecate all the Splat tools in `tools/splat_ext` in favour of a more centralised asset manager. This brings the following advantages: * Much faster extraction * Faster build * Automatically define `static` symbols or unique names whenever `static` is not possible * Allow to embed assets into the output binary * Drastically simplify `Makefile` by removing all the asset build rules * Avoid situations where it is not possible to extract and build assets that is not 4-byte aligned This is achieved by having the splat YAML targeting a normal C file as data and have an external tool to take care of the following: 1. Extract asset files straight from the overlay binary file into human readable file in `assets/st/STAGE_NAME` 2. Build assets as header files that go into `src/st/STAGE_NAME` to just include them from any C file This requires each stage header to have the following new format: please see `src/st/nz0/header.c` Built assets in `src/st` are ignored by Git. As for now, for simplicity sake, the steps `make extract_assets` and `make build_assets` are just executed within `make extract` exclusively for the US version. I plan to auto-generate files such as `src/st/nz0/tile_data.c`. For a first iteration I am aiming to handle the following: * [X] Extract rooms: `assets/st/*/rooms.json` * [X] Extract room layers: `assets/st/*/entity_layouts.json` * [X] Extract tilemap data: `assets/st/*/tilemap_*.bin` * [X] Extract tilemap definitions: `assets/st/*/tiledef_*.json` * [X] Extract sprites: `assets/st/*/sprites.json` * [x] Extract entity layouts * [X] Build rooms: `src/st/*/rooms.h` * [X] Build room layers: `src/st/*/layers.h` * [X] Build tilemap data: `src/st/*/tilemap_*.h` * [X] Build tilemap definitions: `src/st/*/tiledef_*.h` * [x] Build sprites (aka `g_SpriteBanks`) * [x] Build entity layouts * [x] Allow the tool to suggest how to adjust the Splat config for each overlay I want the tool to cover the following stages: * [x] CEN * [x] DRE * ~MAD~ I do not think this can be done, it is way too different from the other overlays * [x] NO3 * [x] NP3 * [X] NZ0 * [x] ST0 * [X] WRP * [x] RWRP * ~WRP (PSP)~ Maybe in a follow-up PR For a later iteration I plan on extracting and build: * Entity GFX thingie * The CLUT thingie in the header * Uncompressed GFX data * Cutscene data * Blueprints * The `src/config_us.h` thingie --------- Co-authored-by: Josh Lory <josh.lory@outlook.com>
2024-07-02 20:38:36 +00:00
src/st/wrp/rooms.c
src/st/wrp/e_layout.c
src/st/wrp/tile_data.c
src/st/wrp/sprites.c
src/st/wrp/warp.c
src/st/wrp/st_update.c
src/st/wrp/collision.c
src/st/wrp/create_entity.c
src/st/wrp/e_red_door.c
src/st/wrp/st_common.c
src/st/wrp/e_collect.c
src/st/wrp/blit_char.c
src/st/wrp/e_misc.c
src/st/wrp/e_stage_name.c
src/st/wrp/e_particles.c
src/st/wrp/e_room_fg.c
src/st/wrp/popup.c
src/st/wrp/prim_helpers.c
src/st/wrp/bss.c
)
set(SOURCE_FILES_WEAPON
src/weapon/w_000.c
)
# WEAPON_ID needs to be a string and not just a number
set_source_files_properties(src/weapon/w_000.c PROPERTIES COMPILE_DEFINITIONS WEAPON_ID=w_000)
# organization is:
# two executables, sdl2 and null, plus a shared library "core"
# any executable links core (which is pc shared code + sotn psx code)
# the null backend is present to try and help with developing a backend-agnostic interface
# and for a basic "does it segfault" check in CI
# core library
set(SOURCE_FILES_CORE
${SOURCE_FILES_DRA}
${SOURCE_FILES_PC}
${SOURCE_FILES_PSX_SDK}
${SOURCE_FILES_MOCK_SDK}
${SOURCE_FILES_3RD}
${SOURCE_FILES_DRA}
${SOURCE_FILES_STAGE_SEL}
${SOURCE_FILES_STAGE_WRP}
${SOURCE_FILES_WEAPON}
)
add_library(core ${SOURCE_FILES_CORE})
target_include_directories(core PRIVATE
include
src/dra
src/pc/3rd
)
target_compile_definitions(core PRIVATE
_USE_MATH_DEFINES # needed for msvc
VERSION_PC
PERMUTER
NON_MATCHING
HARD_LINK
DEMO_KEY_PTR=0
_internal_version_us
)
# sdl2 target
add_executable(${PROJECT_NAME}
src/pc/sdl2.c
src/pc/render_soft.c
src/pc/render_shared.c
src/pc/render_gl.c
src/pc/psxsdk/mednafen/gpu.cpp
src/pc/psxsdk/mednafen/gpu_line.cpp
src/pc/psxsdk/mednafen/gpu_polygon.cpp
src/pc/psxsdk/mednafen/gpu_sprite.cpp
src/pc/sdl2_macros.c
)
target_include_directories(${PROJECT_NAME} PRIVATE
${SDL2_INCLUDE_DIRS}
include
src/dra
src/pc/3rd
)
if (WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE
${SDL2_LIBRARIES} core)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE
${SDL2_LIBRARIES} core m)
endif()
target_compile_definitions(${PROJECT_NAME} PRIVATE
_USE_MATH_DEFINES # needed for msvc
VERSION_PC
PERMUTER
NON_MATCHING
HARD_LINK
DEMO_KEY_PTR=0
_internal_version_us
)
if(WANT_LIBSND_LLE)
target_compile_definitions(core PRIVATE WANT_LIBSND_LLE=1)
target_compile_definitions(${PROJECT_NAME} PRIVATE WANT_LIBSND_LLE=1)
endif()
# null target
add_executable(${PROJECT_NAME}_null
src/pc/null.c
)
target_include_directories(${PROJECT_NAME}_null PRIVATE
include
src/dra
src/pc/3rd
)
if (WIN32)
target_link_libraries(${PROJECT_NAME}_null PRIVATE
core)
else()
target_link_libraries(${PROJECT_NAME}_null PRIVATE
core m)
endif()
target_compile_definitions(${PROJECT_NAME}_null PRIVATE
_USE_MATH_DEFINES # needed for msvc
VERSION_PC
PERMUTER
NON_MATCHING
HARD_LINK
DEMO_KEY_PTR=0
_internal_version_us
)