Skip to content
Merged
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
5 changes: 2 additions & 3 deletions cmake/aurora_dvd.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/AuroraNodProvider.cmake)

add_library(aurora_dvd STATIC lib/dolphin/dvd/dvd.cpp)
add_library(aurora_dvd STATIC lib/dolphin/dvd/dvd.cpp lib/dolphin/dvd/dvd.hpp lib/dolphin/dvd/fst.cpp)
add_library(aurora::dvd ALIAS aurora_dvd)
set_target_properties(aurora_dvd PROPERTIES FOLDER "aurora")

target_compile_definitions(aurora_dvd PUBLIC AURORA TARGET_PC)
target_include_directories(aurora_dvd PUBLIC include)
target_link_libraries(aurora_dvd PUBLIC nod::nod ${AURORA_SDL3_TARGET})
target_link_libraries(aurora_dvd PRIVATE fmt::fmt)
target_link_libraries(aurora_dvd PUBLIC nod::nod fmt::fmt ${AURORA_SDL3_TARGET})

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Why make this dependency public?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It fixes an import issue with system fmt headers

99 changes: 99 additions & 0 deletions include/aurora/dvd.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,105 @@ bool aurora_dvd_open(const char* disc_path);
*/
void aurora_dvd_close(void);

/**
* OVERLAY FILES!
*
* Overlay files allow you to replace and add ("overlay") files that are present in the loaded DVD.
* The way this works is pretty simple: you provide some callbacks and a list of files.
* When an overlaid file gets read, your callbacks get called instead of pulling from the underlying DVD.
*
* Original disc EntryNums are not touched by the overlay system. New files and directories
* are assigned stable EntryNums by Aurora.
*/

/**
* \brief A single file to be overlaid over the DVD files.
*
* You do not need to concern yourself with providing entries for directories. They are automatically merged
* and created where necessary.
*/
typedef struct AuroraOverlayFile {
/**
* \brief Absolute file path of this file.
*
* Must be in the form "/foo/bar/baz.txt", note the leading slash.
*/
const char* fileName;

/**
* \brief Userdata pointer that will be passed to the callback when this file is opened.
*/
void* userData;

/**
* \brief Size of this file, in bytes.
*
* While this is of type size_t, file sizes larger than u32 are not currently supported.
*/
size_t size;

} AuroraOverlayFile;

/**
* \brief Callbacks to implement overlay files.
*
* Callbacks may be ran from any thread at any time. Make sure they're thread safe!
*/
typedef struct AuroraOverlayCallbacks {
/**
* Called when a new file has been opened.
*
* Returns an opaque handle that will be passed to the remaining callbacks. Receives the userdata specified in
* the AuroraOverlayFile.
*/
void* (*open)(void* userdata);

/**
* Close a file handle previously returned from the open callback.
*/
void (*close)(void* handle);

/**
* Read data from a file handle.
*
* Returns the amount of data read, or -1 on error.
*/
int64_t (*read)(void* handle, uint8_t* buf, size_t len);

/**
* Seek to a position in a file handle.
*
* Returns the resulting position, or -1 on error.
*/
int64_t (*seek)(void* handle, int64_t offset, int32_t whence);
} AuroraOverlayCallbacks;

/**
* \brief Specify callbacks for overlaid files.
*/
void aurora_dvd_overlay_callbacks(const AuroraOverlayCallbacks* callbacks);

/**
* \brief Specify a set of overlay files to be used by the DVD layer.
*
* Calling this function immediately applies the new files and rebuilds the FST. This is not thread safe.
* It is best you only call this once on startup, before the game's code has started.
*
* This function must be called *after* aurora_dvd_overlay_callbacks.
*
* @param files Array of AuroraOverlayFiles, one for every file being overlaid.
* @param nFiles Amount of files in the array.
* @param outEntryNums Optional output array receiving one EntryNum per input file. Unaccepted files receive -1.
*/
void aurora_dvd_overlay_files(const AuroraOverlayFile* files, size_t nFiles, s32* outEntryNums);

/**
* \brief Gets the amount of FST entries present on the loaded game disc.
*
* This does not take overlay files into account.
*/
s32 aurora_dvd_base_entry_count();

#ifdef __cplusplus
}
#endif
Expand Down
Loading
Loading