From 066a2e218273cbac0e745158adb4dca10ba0c7de Mon Sep 17 00:00:00 2001 From: oioitff Date: Sun, 12 May 2013 21:14:41 +0800 Subject: [PATCH] Add some comments for sceAtrac --- Core/HLE/sceAtrac.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index e8cddf1f79..1266c2e565 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -427,6 +427,12 @@ u32 sceAtracGetAtracID(int codecType) return atracID; } +// PSP allow games to add stream data to a temp buf, the buf size is given by "atracBufSize "here. +// "first.offset" means how many bytes the temp buf has been written, +// and "first.writableBytes" means how many bytes the temp buf is allowed to write +// (We always have "first.offset + first.writableBytes = atracBufSize"). +// We only reset the temp buf when games call sceAtracGetStreamDataInfo, +// because that function would tell games how to add the left stream data. u32 sceAtracAddStreamData(int atracID, u32 bytesToAdd) { INFO_LOG(HLE, "sceAtracAddStreamData(%i, %08x)", atracID, bytesToAdd); @@ -738,6 +744,9 @@ u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoopStartSa return 0; } +// Games call this function to get some info for add more stream data, +// such as where the data read from, where the data add to, +// and how many bytes are allowed to add. u32 sceAtracGetStreamDataInfo(int atracID, u32 writeAddr, u32 writableBytesAddr, u32 readOffsetAddr) { DEBUG_LOG(HLE, "sceAtracGetStreamDataInfo(%i, %08x, %08x, %08x)", atracID, writeAddr, writableBytesAddr, readOffsetAddr); @@ -745,8 +754,10 @@ u32 sceAtracGetStreamDataInfo(int atracID, u32 writeAddr, u32 writableBytesAddr, if (!atrac) { //return -1; } else { + // reset the temp buf for adding more stream data atrac->first.writableBytes = std::min(atrac->first.filesize - atrac->first.size, atrac->atracBufSize); atrac->first.offset = 0; + if (Memory::IsValidAddress(writeAddr)) Memory::Write_U32(atrac->first.addr, writeAddr); if (Memory::IsValidAddress(writableBytesAddr)) @@ -887,10 +898,12 @@ int __AtracSetContext(Atrac *atrac, u32 buffer, u32 bufferSize) int _AtracSetData(Atrac *atrac, u32 buffer, u32 bufferSize) { - atrac->atracBufSize = bufferSize; if (atrac->first.size > atrac->first.filesize) atrac->first.size = atrac->first.filesize; atrac->first.fileoffset = atrac->first.size; + + // got the size of temp buf, and calculate writableBytes and offset + atrac->atracBufSize = bufferSize; atrac->first.writableBytes = (u32)std::max((int)bufferSize - (int)atrac->first.size, 0); atrac->first.offset = atrac->first.size;