sotn-decomp/CMakeLists.txt

195 lines
4.0 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")
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
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
src/pc/stage_dummy.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
)
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
Refactor DRA func_800FD5BC (#980) Came across this function today and found several improvements for it. - Unkstruct_800FD5BC is a duplicate of DamageParam. Therefore, I have changed all instances of Unkstruct_800FD5BC to DamageParam. The fields make sense in context and everything. - Because func_800FD5BC is in GameApi, which is defined in `game.h`, its argument (now a DamageParam) needs to be accessible in `game.h`. Therefore, DamageParam moves from dra.h to game.h. - We had a fake division being done with using a `temp` and checking a comparison to zero; this has been changed to be a normal division. This is a common pattern I see in initial m2c output and I'm sure it exists in other places in the repo, would be nice if we could find an automated way to search for this type of structure to simplify the code. - Changed a 0x14 to 20 since it makes way more sense that way - Changed an `if(){dostuff; return} else{morestuff}` to just `if(){dostuff; return} morestuff`, eliminating the `else` I think this function should not be in `menu.c` since it has no close connection to any kind of menu. It would also be nice if we could figure out what damageKind actually is, and maybe make an enum for it. Overall, no new decompiling here, but lots of improvement to the readability of the code. This might actually be a good PR to keep in mind as an example for people who are interested in the project but aren't comfortable with assembly, since this is a lot of improvement and change, without touching assembly at all.
2024-01-14 16:37:35 +00:00
src/dra/5D5BC.c
src/dra/627C4.c
src/dra/63ED4.c
src/dra/692E8.c
src/dra/6D59C.c
src/dra/704D0.c
src/dra/71830.c
src/dra/72BB0.c
#src/dra/75F54.c # unable to link it, the file needs to be splitted
#src/dra/7A4D0.c # loads of unimplemented calls and symbols
src/dra/7E4BC.c
src/dra/843B0.c
src/dra/86ECC.c
#src/dra/8D3E8.c # countless unimplemented symbols
src/dra/91EBC.c
src/dra/92F60.c
src/dra/93290.c
src/dra/93BDC.c
src/dra/94F50.c
src/dra/953A0.c
)
set(SOURCE_FILES_STAGE_SEL
src/pc/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
)
# 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}
)
add_library(core ${SOURCE_FILES_CORE})
target_include_directories(core PRIVATE
include
src/dra
src/pc/3rd
)
target_compile_definitions(core PRIVATE
VERSION_PC
PERMUTER
NON_MATCHING
HARD_LINK
DEMO_KEY_PTR=0
_internal_version_us
)
# sdl2 target
add_executable(${PROJECT_NAME}
src/pc/sdl2.c
)
target_include_directories(${PROJECT_NAME} PRIVATE
${SDL2_INCLUDE_DIRS}
include
src/dra
src/pc/3rd
)
target_link_libraries(${PROJECT_NAME} PRIVATE
${SDL2_LIBRARIES}
core
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
VERSION_PC
PERMUTER
NON_MATCHING
HARD_LINK
DEMO_KEY_PTR=0
_internal_version_us
)
# null target
add_executable(${PROJECT_NAME}_null
src/pc/null.c
)
target_include_directories(${PROJECT_NAME}_null PRIVATE
include
src/dra
src/pc/3rd
)
target_link_libraries(${PROJECT_NAME}_null PRIVATE
core
)
target_compile_definitions(${PROJECT_NAME}_null PRIVATE
VERSION_PC
PERMUTER
NON_MATCHING
HARD_LINK
DEMO_KEY_PTR=0
_internal_version_us
)