From 9fa0a7f1da1b70bee995f53c6c96c43189018772 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Wed, 1 Feb 2023 18:45:02 -0400 Subject: global: Import Dolphin SDK This version comes from the Metroid Prime decompilation project. https://github.com/PrimeDecomp/prime --- src/Dolphin/dvd/dvderror.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/Dolphin/dvd/dvderror.c (limited to 'src/Dolphin/dvd/dvderror.c') diff --git a/src/Dolphin/dvd/dvderror.c b/src/Dolphin/dvd/dvderror.c new file mode 100644 index 0000000..c984a8b --- /dev/null +++ b/src/Dolphin/dvd/dvderror.c @@ -0,0 +1,56 @@ +#include "dolphin/DVDPriv.h" +#include "dolphin/OSRtcPriv.h" + +static u32 ErrorTable[] = { + 0, 0x00023A00, 0x00062800, 0x00030200, 0x00031100, 0x00052000, + 0x00052001, 0x00052100, 0x00052400, 0x00052401, 0x00052402, 0x000B5A01, + 0x00056300, 0x00020401, 0x00020400, 0x00040800, 0x00100007, 0, +}; + +static u8 ErrorCode2Num(u32 errorCode) { + u32 i; + + for (i = 0; i < sizeof(ErrorTable) / sizeof(ErrorTable[0]); i++) { + if (ErrorTable[i] == errorCode) { + return (u8)i; + } + } + + if ((errorCode >= 0x00100000) && (errorCode <= 0x00100008)) { + return 17; + } + + return 29; +} + +static u8 Convert(u32 error) { + u32 statusCode; + u32 errorCode; + u8 errorNum; + + if (error == 0x01234567) + return 255; + + if (error == 0x01234568) + return 254; + + statusCode = (error & 0xff000000) >> 24; + errorCode = error & 0x00ffffff; + + errorNum = ErrorCode2Num(errorCode); + if (statusCode >= 6) + statusCode = 6; + + return (u8)(statusCode * 30 + errorNum); +} + +void __DVDStoreErrorCode(u32 error) { + OSSramEx* sram; + u8 num; + + num = Convert(error); + + sram = __OSLockSramEx(); + sram->dvdErrorCode = num; + __OSUnlockSramEx(TRUE); +} -- cgit v1.2.3-13-gbd6f