summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPheenoh <pheenoh@gmail.com>2020-09-30 18:24:58 -0400
committerGitHub <noreply@github.com>2020-09-30 18:24:58 -0400
commitc2e6e90283cc1a9ab2b30b1295f6d68c73e104bd (patch)
treea1264df8894aa4727a4dc8554a60667c21bb9391
parent5549775c466a3ffb62a14ea94d7358a45f9245e4 (diff)
parent3f8186331fd1dc4e6bb1f5cde67f8c3311a08bd7 (diff)
Merge pull request #1 from kipcode66/master
Added DVD functions
-rw-r--r--include/dvd.h134
1 files changed, 101 insertions, 33 deletions
diff --git a/include/dvd.h b/include/dvd.h
index e2f8a7e..e09c65f 100644
--- a/include/dvd.h
+++ b/include/dvd.h
@@ -1,40 +1,108 @@
-#pragma once
+#ifndef __DVD_H__
+#define __DVD_H__
+
#include <stdint.h>
-struct DVDDiskID {
- char game_name[4];
- char company[2];
- uint8_t disk_number;
- uint8_t game_version;
- uint8_t is_streaming;
- uint8_t streaming_buffer_size;
- uint8_t padding[22];
-};
+/*
+ * DVD state codes
+ */
+#define DVD_STATE_FATAL_ERROR -1
+#define DVD_STATE_END 0
+#define DVD_STATE_BUSY 1
+#define DVD_STATE_WAITING 2
+#define DVD_STATE_COVER_CLOSED 3
+#define DVD_STATE_NO_DISK 4
+#define DVD_STATE_COVER_OPEN 5
+#define DVD_STATE_WRONG_DISK 6
+#define DVD_STATE_MOTOR_STOPPED 7
+#define DVD_STATE_IGNORED 8
+#define DVD_STATE_CANCELED 10
+#define DVD_STATE_RETRY 11
-struct DVDCommandBlock {
- DVDCommandBlock* next;
- DVDCommandBlock* previous;
- uint32_t command;
- signed int state;
- uint32_t offset;
- uint32_t length;
- void* buffer;
- uint32_t current_transfer_size;
- uint32_t transferred_size;
- DVDDiskID* disk_id;
- void (*DVDCBCallback)(signed int result, DVDCommandBlock* block);
- void* user_data;
-};
+/*
+ * DVD error codes
+ */
+#define DVD_ERROR_OK 0
+#define DVD_ERROR_FATAL -1
+#define DVD_ERROR_IGNORED -2
+#define DVD_ERROR_CANCELED -3
+#define DVD_ERROR_COVER_CLOSED -4
+
+#ifdef __cplusplus
+extern "C" {
+#endif
-struct DVDFileInfo {
- DVDCommandBlock block;
- uint32_t start_address;
- uint32_t length;
- void (*DVDCallback)(signed int result, DVDFileInfo* fileInfo);
+/**
+ * @brief Forward typedef for struct _DVDCommandBlock
+ */
+typedef struct _DVDCommandBlock DVDCommandBlock;
+
+/*!
+ * \typedef struct _dvdcmdblk dvdcmdblk
+ *
+ * This structure is used internally to control the requested operation.
+ */
+struct _DVDCommandBlock {
+ uint8_t unk1[12];
+ int32_t state;
+ uint8_t unk2[36];
};
-extern "C" {
-bool DVDOpen(const char* fileName, DVDFileInfo* fileInfo);
-signed long DVDReadPrio(DVDFileInfo* fileInfo, void* buffer, signed long length, signed long offset, signed long prio);
+typedef struct _DVDFileInfo DVDFileInfo;
+
+/**
+ * @brief function pointer typedef for the user's DVD operation callback
+ *
+ * @param[in] result error code of last operation
+ * @param[in] info pointer to user's file info strucutre
+ */
+typedef void (*DVDCallback)(uint32_t result, DVDFileInfo *info);
+
+struct _DVDFileInfo {
+ DVDCommandBlock blk;
+ uint32_t addr;
+ uint32_t len;
+ DVDCallback cb;
+} __attribute__((packed));
+
+bool DVDOpen(const char* param_1, DVDFileInfo* param_2);
bool DVDClose(DVDFileInfo* fileInfo);
-} \ No newline at end of file
+int32_t DVDReadPrio(DVDFileInfo* fileInfo, void* buffer, int length, int offset, int prio);
+
+
+bool DVDGetCurrentDir(char* outBuf, uint32_t bufSize);
+bool DVDChangeDir(const char* path);
+
+
+typedef struct _DVDDirCursor DVDDirCursor;
+
+struct _DVDDirCursor {
+ int32_t dir_idx;
+ int32_t file_cursor;
+ uint32_t num_entries; // could be an offset, could be a length
+} __attribute__((packed));
+
+typedef struct _DVDDirEntryInfo DVDDirEntryInfo;
+
+struct _DVDDirEntryInfo {
+ int32_t curr_entrynum;
+ int32_t is_dir;
+ char* name;
+} __attribute__((packed));
+
+bool DVDOpenDir(const char* path, DVDDirCursor* dirinfo);
+/**
+ * @brief Fetch the current entry and forward the cursor to the next entry.
+ *
+ * @param[in|out] cursor The cursor to an opened directory.
+ * @param[out] entryInfo The data on the current entry.
+ * @returns True if the cursor successfully fetched an entry. False otherwise.
+ */
+bool DVDReadDir(DVDDirCursor* cursor, _DVDDirEntryInfo* entryInfo);
+bool DVDCloseDir(DVDDirCursor*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __DVD_H__ \ No newline at end of file