Skip to content

Commit

Permalink
Merge pull request #2 from hrydgard/master
Browse files Browse the repository at this point in the history
Sync
  • Loading branch information
CrazyMax committed Mar 31, 2013
2 parents 716664c + 086fd24 commit d82b09b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
9 changes: 7 additions & 2 deletions Core/HLE/sceKernelThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ class MipsCallManager {
return id;
}
MipsCall *get(u32 id) {
return calls_[id];
auto iter = calls_.find(id);
if (iter == calls_.end())
return NULL;
return iter->second;
}
MipsCall *pop(u32 id) {
MipsCall *temp = calls_[id];
Expand Down Expand Up @@ -1614,7 +1617,9 @@ int sceKernelStartThread(SceUID threadToStartID, u32 argSize, u32 argBlockPtr)
// TODO: Maybe this happens even for worse-priority started threads?
dispatchEnabled = true;

__KernelChangeReadyState(currentThread, true);
if (cur && cur->isRunning())
cur->nt.status &= ~THREADSTATUS_RUNNING;
__KernelChangeReadyState(cur, currentThread, true);
hleReSchedule("thread started");
}
else if (!dispatchEnabled)
Expand Down
51 changes: 42 additions & 9 deletions Core/HLE/sceMpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,11 @@ u32 sceMpegQueryStreamSize(u32 bufferAddr, u32 sizeAddr)
AnalyzeMpeg(bufferAddr, &ctx);

if (ctx.mpegMagic != PSMF_MAGIC) {
ERROR_LOG(HLE, "sceMpegQueryStreamOffset: Bad PSMF magic");
ERROR_LOG(HLE, "sceMpegQueryStreamSize: Bad PSMF magic");
Memory::Write_U32(0, sizeAddr);
return ERROR_MPEG_INVALID_VALUE;
} else if ((ctx.mpegOffset & 2047) != 0 ) {
ERROR_LOG(HLE, "sceMpegQueryStreamOffset: Bad offset");
ERROR_LOG(HLE, "sceMpegQueryStreamSize: Bad offset");
Memory::Write_U32(0, sizeAddr);
return ERROR_MPEG_INVALID_VALUE;
}
Expand Down Expand Up @@ -1081,16 +1081,16 @@ int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
WARN_LOG(HLE, "sceMpegGetAvcAu(%08x, %08x, %08x, %08x): bad mpeg handle", mpeg, streamId, auAddr, attrAddr);
return -1;
}
DEBUG_LOG(HLE, "sceMpegGetAvcAu(%08x, %08x, %08x, %08x)", mpeg, streamId, auAddr, attrAddr);

SceMpegRingBuffer mpegRingbuffer;
Memory::ReadStruct(ctx->mpegRingbufferAddr, &mpegRingbuffer);

SceMpegAu sceAu;
sceAu.read(auAddr);

if (mpegRingbuffer.packetsRead == 0) {
if (mpegRingbuffer.packetsRead == 0 || mpegRingbuffer.packetsFree == mpegRingbuffer.packets) {
// delayThread(mpegErrorDecodeDelay)
DEBUG_LOG(HLE, "PSP_ERROR_MPEG_NO_DATA=sceMpegGetAvcAu(%08x, %08x, %08x, %08x)", mpeg, streamId, auAddr, attrAddr);
return PSP_ERROR_MPEG_NO_DATA;
}

Expand Down Expand Up @@ -1135,6 +1135,7 @@ int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
Memory::Write_U32(1, attrAddr);
}

DEBUG_LOG(HLE, "%x=sceMpegGetAvcAu(%08x, %08x, %08x, %08x)", result, mpeg, streamId, auAddr, attrAddr);
return result;
}

Expand All @@ -1158,7 +1159,6 @@ int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
WARN_LOG(HLE, "sceMpegGetAtracAu(%08x, %08x, %08x, %08x): bad mpeg handle", mpeg, streamId, auAddr, attrAddr);
return -1;
}
DEBUG_LOG(HLE, "sceMpegGetAtracAu(%08x, %08x, %08x, %08x)", mpeg, streamId, auAddr, attrAddr);

SceMpegRingBuffer mpegRingbuffer;
Memory::ReadStruct(ctx->mpegRingbufferAddr, &mpegRingbuffer);
Expand All @@ -1168,6 +1168,11 @@ int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)

int result = 0;

if (mpegRingbuffer.packetsFree == mpegRingbuffer.packets) {
DEBUG_LOG(HLE, "PSP_ERROR_MPEG_NO_DATA=sceMpegGetAtracAu(%08x, %08x, %08x, %08x)", mpeg, streamId, auAddr, attrAddr);
return PSP_ERROR_MPEG_NO_DATA;
}

//...
// TODO: Just faking it.
sceAu.pts += videoTimestampStep;
Expand All @@ -1186,6 +1191,7 @@ int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
Memory::Write_U32(0, attrAddr);
}

DEBUG_LOG(HLE, "%x=sceMpegGetAtracAu(%08x, %08x, %08x, %08x)", result, mpeg, streamId, auAddr, attrAddr);
return result;
}

Expand Down Expand Up @@ -1270,10 +1276,29 @@ u32 sceMpegRingbufferQueryPackNum(int memorySize)
u32 sceMpegFlushAllStream(u32 mpeg)
{
MpegContext *ctx = getMpegCtx(mpeg);
ERROR_LOG(HLE, "UNIMPL sceMpegFlushAllStream(%08x)", mpeg);
if ( ctx->videoFrameCount > 0 || ctx->audioFrameCount > 0) {
//__MpegFinish();
if (!ctx) {
WARN_LOG(HLE, "sceMpegFlushAllStream(%08x): bad mpeg handle", mpeg);
return -1;
}
WARN_LOG(HLE, "UNIMPL sceMpegFlushAllStream(%08x)", mpeg);

ctx->avcRegistered = false;
ctx->atracRegistered = false;
ctx->pcmRegistered = false;
ctx->dataRegistered = false;

ctx->streamMap.clear();
ctx->isAnalyzed = false;

if (Memory::IsValidAddress(ctx->mpegRingbufferAddr))
{
auto ringbuffer = Memory::GetStruct<SceMpegRingBuffer>(ctx->mpegRingbufferAddr);

ringbuffer->packetsFree = ringbuffer->packets;
ringbuffer->packetsRead = 0;
ringbuffer->packetsWritten = 0;
}

return 0;
}

Expand Down Expand Up @@ -1308,7 +1333,15 @@ u32 sceMpegAvcCsc(u32 mpeg, u32 sourceAddr, u32 rangeAddr, int frameWidth, u32 d
u32 sceMpegRingbufferDestruct(u32 ringbufferAddr)
{
DEBUG_LOG(HLE, "sceMpegRingbufferDestruct(%08x)", ringbufferAddr);
// Don't need to do anything here

if (Memory::IsValidAddress(ringbufferAddr))
{
auto ringbuffer = Memory::GetStruct<SceMpegRingBuffer>(ringbufferAddr);

ringbuffer->packetsFree = ringbuffer->packets;
ringbuffer->packetsRead = 0;
ringbuffer->packetsWritten = 0;
}
return 0;
}

Expand Down
5 changes: 4 additions & 1 deletion Windows/KeyboardDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ int KeyboardDevice::UpdateState(InputState &input_state) {
bool doAlternate = alternate && (alternator++ % 10) < 5;

for (int i = 0; i < sizeof(key_pad_map)/sizeof(key_pad_map[0]); i += 2) {
if (GetAsyncKeyState(key_pad_map[i]) && !doAlternate) {
if (!GetAsyncKeyState(key_pad_map[i])) {
continue;
}
if (!doAlternate || key_pad_map[i + 1] > PAD_BUTTON_SELECT) {
input_state.pad_buttons |= key_pad_map[i+1];
}
}
Expand Down

0 comments on commit d82b09b

Please sign in to comment.