From d5fd68e4a4bd081c09d42bdba232e6b5f01e9c45 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 24 Feb 2014 14:43:43 -0500 Subject: [PATCH 1/2] Eliminate the magic constants in the switch statement in WII_IPC_HLE_Device_FileIO.cpp's Seek function. --- Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp | 9 ++++++--- Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp index 3a6d3283df..b0ae7a33d8 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp @@ -162,7 +162,7 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress) switch (Mode) { - case 0: + case WII_SEEK_SET: { if ((SeekPosition >=0) && (SeekPosition <= fileSize)) { @@ -171,7 +171,8 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress) } break; } - case 1: + + case WII_SEEK_CUR: { s32 wantedPos = SeekPosition+m_SeekPos; if (wantedPos >=0 && wantedPos <= fileSize) @@ -181,7 +182,8 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress) } break; } - case 2: + + case WII_SEEK_END: { s32 wantedPos = fileSize+m_SeekPos; if (wantedPos >=0 && wantedPos <= fileSize) @@ -191,6 +193,7 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress) } break; } + default: { PanicAlert("CWII_IPC_HLE_Device_FileIO Unsupported seek mode %i", Mode); diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h index 93bfe97604..d88c617e55 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h @@ -35,6 +35,13 @@ private: ISFS_OPEN_RW = (ISFS_OPEN_READ | ISFS_OPEN_WRITE) }; + enum + { + WII_SEEK_SET = 0, + WII_SEEK_CUR = 1, + WII_SEEK_END = 2, + }; + enum { ISFS_FUNCNULL = 0, From 3bc082be52808d0d22688e51f32b3d7da0ec99bb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 28 Feb 2014 19:56:42 -0500 Subject: [PATCH 2/2] Fix WII_SEEK_END seeking. --- Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp index b0ae7a33d8..fc1e97bb40 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp @@ -185,7 +185,7 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress) case WII_SEEK_END: { - s32 wantedPos = fileSize+m_SeekPos; + s32 wantedPos = SeekPosition+fileSize; if (wantedPos >=0 && wantedPos <= fileSize) { m_SeekPos = wantedPos;