CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/HLE/AtracCtx2.cpp
Views: 1401
#include "Common/Log.h"1#include "Core/MemMapHelpers.h"2#include "Core/HLE/HLE.h"3#include "Core/HLE/FunctionWrappers.h"4#include "Core/HLE/AtracCtx2.h"5#include "Core/HW/Atrac3Standalone.h"67// Convenient command line:8// Windows\x64\debug\PPSSPPHeadless.exe --root pspautotests/tests/../ --compare --timeout=5 --new-atrac --graphics=software pspautotests/tests/audio/atrac/decode.prx910// See the big comment in sceAtrac.cpp for an overview of the different modes of operation.11//12// Test cases13//14// Halfway buffer15//16// * None found yet17//18// All-data-loaded19//20// * MotoGP (menu music with specified loop). Simple repeated calls to sceAtracDecodeData21// * Archer MacLean's Mercury (in-game, not menu)22// * Crisis Core23//24// Streaming25//26// - Good ones (early)27// * Everybody's Golf 2 (0x2000 buffer size, loop from end)28// * Burnout Legends (no loop, 0x1800 buffer size)29// * Suicide Barbie30// - Others31// * Bleach32// * God of War: Chains of Olympus33// * Ape Academy 2 (bufsize 8192)34// * Half Minute Hero (bufsize 65536)35// * Flatout (tricky! needs investigation)3637void Atrac2::DoState(PointerWrap &p) {38_assert_msg_(false, "Savestates not yet support with new Atrac implementation.\n\nTurn it off in Developer settings.\n\n");39}4041void Atrac2::WriteContextToPSPMem() {42if (!context_.IsValid()) {43return;44}45// context points into PSP memory.46SceAtracContext *context = context_;47context->info.buffer = 0; // bufferAddr_; // first_.addr;48context->info.bufferByte = 0; // bufferMaxSize_;49context->info.secondBuffer = 0; // TODO50context->info.secondBufferByte = 0; // TODO51context->info.codec = track_.codecType;52context->info.loopNum = loopNum_;53context->info.loopStart = track_.loopStartSample > 0 ? track_.loopStartSample : 0;54context->info.loopEnd = track_.loopEndSample > 0 ? track_.loopEndSample : 0;5556// Note that we read in the state when loading the atrac object, so it's safe57// to update it back here all the time. Some games, like Sol Trigger, change it.58// TODO: Should we just keep this in PSP ram then, or something?59context->info.state = bufferState_;60if (track_.firstSampleOffset != 0) {61context->info.samplesPerChan = track_.FirstSampleOffsetFull();62} else {63context->info.samplesPerChan = (track_.codecType == PSP_MODE_AT_3_PLUS ? ATRAC3PLUS_MAX_SAMPLES : ATRAC3_MAX_SAMPLES);64}65context->info.sampleSize = track_.bytesPerFrame;66context->info.numChan = track_.channels;67context->info.dataOff = track_.dataByteOffset;68context->info.endSample = track_.endSample + track_.FirstSampleOffsetFull();69context->info.dataEnd = track_.fileSize;70context->info.curOff = 0; // first_.fileoffset;71context->info.decodePos = track_.DecodePosBySample(currentSample_);72context->info.streamDataByte = 0; // first_.size - track_.dataOff;7374u8 *buf = (u8 *)context;75*(u32_le *)(buf + 0xfc) = atracID_;7677NotifyMemInfo(MemBlockFlags::WRITE, context_.ptr, sizeof(SceAtracContext), "AtracContext");78}7980int Atrac2::Analyze(u32 addr, u32 size) {81int retval = AnalyzeAtracTrack(addr, size, &track_);82if (retval < 0) {83return retval;84}85return 0;86}87int Atrac2::AnalyzeAA3(u32 addr, u32 size, u32 filesize) {88int retval = AnalyzeAA3Track(addr, size, filesize, &track_);89if (retval < 0) {90return retval;91}9293return 0;94}9596int Atrac2::RemainingFrames() const {97return 0;98}99100u32 Atrac2::SecondBufferSize() const {101return 0;102}103104void Atrac2::GetStreamDataInfo(u32 *writePtr, u32 *writableBytes, u32 *readOffset) {105106}107108int Atrac2::AddStreamData(u32 bytesToAdd) {109return 0;110}111112u32 Atrac2::AddStreamDataSas(u32 bufPtr, u32 bytesToAdd) {113return 0;114}115116u32 Atrac2::ResetPlayPosition(int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf) {117return 0;118}119120void Atrac2::GetResetBufferInfo(AtracResetBufferInfo *bufferInfo, int sample) {121122}123124int Atrac2::SetData(u32 buffer, u32 readSize, u32 bufferSize, int outputChannels, int successCode) {125if (readSize == bufferSize) {126bufferState_ = ATRAC_STATUS_ALL_DATA_LOADED;127} else {128bufferState_ = ATRAC_STATUS_HALFWAY_BUFFER;129}130return hleLogSuccessI(Log::ME, successCode);131}132133u32 Atrac2::SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) {134return 0;135}136137u32 Atrac2::DecodeData(u8 *outbuf, u32 outbufPtr, u32 *SamplesNum, u32 *finish, int *remains) {138139return 0;140}141142u32 Atrac2::GetNextSamples() {143return 0;144}145146void Atrac2::InitLowLevel(u32 paramsAddr, bool jointStereo) {147track_.AnalyzeReset();148track_.channels = Memory::Read_U32(paramsAddr);149outputChannels_ = Memory::Read_U32(paramsAddr + 4);150track_.bytesPerFrame = Memory::Read_U32(paramsAddr + 8);151if (track_.codecType == PSP_MODE_AT_3) {152track_.bitrate = (track_.bytesPerFrame * 352800) / 1000;153track_.bitrate = (track_.bitrate + 511) >> 10;154track_.jointStereo = false;155} else if (track_.codecType == PSP_MODE_AT_3_PLUS) {156track_.bitrate = (track_.bytesPerFrame * 352800) / 1000;157track_.bitrate = ((track_.bitrate >> 11) + 8) & 0xFFFFFFF0;158track_.jointStereo = false;159}160track_.dataByteOffset = 0;161bufferState_ = ATRAC_STATUS_LOW_LEVEL;162currentSample_ = 0;163CreateDecoder();164WriteContextToPSPMem();165}166167168