Skip to content

Commit

Permalink
Implement large chunks of sceMpeg and scePsmf with JPSCP as a guide.
Browse files Browse the repository at this point in the history
Not yet hooked up to FFMPEG and doesn't quite work yet.
  • Loading branch information
hrydgard committed Nov 13, 2012
1 parent b4a960a commit 8053c24
Show file tree
Hide file tree
Showing 13 changed files with 1,008 additions and 268 deletions.
11 changes: 11 additions & 0 deletions Common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ class NonCopyable
# define _M_SSE 0x402
#endif


#ifdef _MSC_VER
inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); }
inline unsigned int bswap16(unsigned int x) { return _byteswap_ushort(x); }
#else
// TODO: speedup
inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);}
inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); }
#endif


// Host communication.
enum HOST_COMM
{
Expand Down
1 change: 1 addition & 0 deletions Core/CoreParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ struct CoreParameter
bool enableDebugging; // enables breakpoints and other time-consuming debugger features
bool printfEmuLog; // writes "emulator:" logging to stdout
bool headLess; // Try to avoid messageboxes etc
bool useMediaEngine;
};
5 changes: 5 additions & 0 deletions Core/HLE/FunctionWrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ template<u32 func(u32, u32)> void WrapU_UU() {
RETURN(retval);
}

template<u32 func(u32, int)> void WrapU_UI() {
u32 retval = func(PARAM(0), PARAM(1));
RETURN(retval);
}

template<u32 func(int, u32)> void WrapU_IU() {
int retval = func(PARAM(0), PARAM(1));
RETURN(retval);
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/sceAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void sceAudioOutputPannedBlocking(u32 chan, u32 volume1, u32 volume2, u32 sample
}
else if (chan < 0 || chan >= MAX_CHANNEL)
{
ERROR_LOG(HLE,"sceAudioOutputPannedBlocking() - BAD CHANNEL");
ERROR_LOG(HLE,"sceAudioOutputPannedBlocking() - BAD CHANNEL: %08x", chan);
RETURN(SCE_ERROR_AUDIO_INVALID_CHANNEL);
}
else if (!chans[chan].reserved)
Expand Down
3 changes: 3 additions & 0 deletions Core/HLE/sceKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "sceKernelEventFlag.h"
#include "sceKernelVTimer.h"
#include "sceKernelTime.h"
#include "sceMpeg.h"
#include "scePower.h"
#include "sceUtility.h"
#include "sceUmd.h"
Expand Down Expand Up @@ -78,6 +79,7 @@ void __KernelInit()
__PowerInit();
__UtilityInit();
__UmdInit();
__MpegInit(PSP_CoreParameter().useMediaEngine);

kernelRunning = true;
INFO_LOG(HLE, "Kernel initialized.");
Expand All @@ -94,6 +96,7 @@ void __KernelShutdown()
INFO_LOG(HLE, "Shutting down kernel - %i kernel objects alive", kernelObjects.GetCount());
kernelObjects.Clear();

__MpegShutdown();
__GeShutdown();
__AudioShutdown();
__IoShutdown();
Expand Down
15 changes: 13 additions & 2 deletions Core/HLE/sceKernelThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,17 @@ void __KernelCallAddress(Thread *thread, u32 entryPoint, Action *afterAction, bo
thread->pendingMipsCalls.push_back(callId);
}
}


void __KernelDirectMipsCall(u32 entryPoint, Action *afterAction, bool returnVoid, u32 args[], int numargs)
{
// TODO: get rid of the vector
std::vector<int> argsv;
for (int i = 0; i < numargs; i++)
argsv.push_back(args[i]);

__KernelCallAddress(currentThread, entryPoint, afterAction, returnVoid, argsv);
}

void __KernelExecuteMipsCallOnCurrentThread(int callId)
{
if (g_inCbCount > 0) {
Expand Down Expand Up @@ -1598,7 +1608,8 @@ void __KernelReturnFromMipsCall()
if (!__KernelExecutePendingMipsCalls())
{
// We should definitely reschedule as we might still be asleep. - except if we came from checkcallbacks?
__KernelReSchedule("return from callback");
// TODO: Should not do this for a plain Direct mipscall
__KernelReSchedule("return from mipscall");
}
}

Expand Down
7 changes: 6 additions & 1 deletion Core/HLE/sceKernelThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ void sceKernelGetCallbackCount();
void sceKernelCheckCallback();
void sceKernelGetCallbackCount();
void sceKernelReferCallbackStatus();

class Action;

// Not an official Callback object, just calls a mips function on the current thread.
void __KernelDirectMipsCall(u32 entryPoint, Action *afterAction, bool returnVoid, u32 args[], int numargs);

void __KernelReturnFromMipsCall(); // Called as HLE function
bool __KernelInCallback();

Expand All @@ -165,7 +171,6 @@ void __KernelNotifyCallback(RegisteredCallbackType type, SceUID threadId, SceUID

// A call into game code. These can be pending on a thread.
// Similar to Callback-s (NOT CallbackInfos) in JPCSP.
class Action;
struct MipsCall {
u32 entryPoint;
u32 cbId;
Expand Down
Loading

0 comments on commit 8053c24

Please sign in to comment.