1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Include clearing

This commit is contained in:
Nekotekina 2014-08-24 00:40:04 +04:00
parent b005ee3cda
commit 4ffd03fe3e
80 changed files with 1785 additions and 1745 deletions

View File

@ -1,6 +1,4 @@
#include <stdafx.h>
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/CPU/CPUThread.h"

View File

@ -5,7 +5,7 @@
#include <mutex>
#include <atomic>
#include <condition_variable>
#include <Utilities/SSemaphore.h>
//#include <Utilities/SSemaphore.h>
static std::thread::id main_thread;

View File

@ -6,6 +6,7 @@
#include "Emu/System.h"
#include "Emu/DbgCommand.h"
#include "CPUDecoder.h"
#include "CPUThread.h"
CPUThread* GetCurrentCPUThread()

View File

@ -1,5 +1,4 @@
#pragma once
#include "Emu/CPU/CPUDecoder.h"
enum CPUThreadType :unsigned char
{
@ -20,6 +19,8 @@ enum CPUThreadStatus
CPUThread_Step,
};
class CPUDecoder;
class CPUThread : public ThreadBase
{
protected:

View File

@ -1,5 +1,4 @@
#pragma once
#include "Emu/CPU/CPUThread.h"
class PPCThread : public CPUThread

View File

@ -1,7 +1,51 @@
#include "stdafx.h"
#include "SPURSManager.h"
#include "Emu/Memory/Memory.h"
#include "SPURSManager.h"
SPURSManagerAttribute::SPURSManagerAttribute(int nSpus, int spuPriority, int ppuPriority, bool exitIfNoWork)
{
this->nSpus = nSpus;
this->spuThreadGroupPriority = spuPriority;
this->ppuThreadPriority = ppuPriority;
this->exitIfNoWork = exitIfNoWork;
memset(this->namePrefix, 0, CELL_SPURS_NAME_MAX_LENGTH + 1);
this->threadGroupType = 0;
this->container = 0;
}
int SPURSManagerAttribute::_setNamePrefix(const char *name, u32 size)
{
strncpy(this->namePrefix, name, size);
this->namePrefix[0] = 0;
return 0;
}
int SPURSManagerAttribute::_setSpuThreadGroupType(int type)
{
this->threadGroupType = type;
return 0;
}
int SPURSManagerAttribute::_setMemoryContainerForSpuThread(u32 container)
{
this->container = container;
return 0;
}
SPURSManagerEventFlag::SPURSManagerEventFlag(u32 flagClearMode, u32 flagDirection)
{
this->flagClearMode = flagClearMode;
this->flagDirection = flagDirection;
}
SPURSManagerTasksetAttribute::SPURSManagerTasksetAttribute(u64 args, mem8_t priority, u32 maxContention)
{
this->args = args;
this->maxContention = maxContention;
}
SPURSManager::SPURSManager(SPURSManagerAttribute *attr)
{
this->attr = attr;
@ -26,4 +70,4 @@ SPURSManagerTaskset::SPURSManagerTaskset(u32 address, SPURSManagerTasksetAttribu
{
this->tattr = tattr;
this->address = address;
}
}

View File

@ -1,85 +1,18 @@
#pragma once
#include "Emu/Memory/Memory.h"
// SPURS defines.
enum SPURSKernelInterfaces
{
CELL_SPURS_MAX_SPU = 8,
CELL_SPURS_MAX_WORKLOAD = 16,
CELL_SPURS_MAX_WORKLOAD2 = 32,
CELL_SPURS_MAX_PRIORITY = 16,
CELL_SPURS_NAME_MAX_LENGTH = 15,
CELL_SPURS_SIZE = 4096,
CELL_SPURS_SIZE2 = 8192,
CELL_SPURS_ALIGN = 128,
CELL_SPURS_ATTRIBUTE_SIZE = 512,
CELL_SPURS_ATTRIBUTE_ALIGN = 8,
CELL_SPURS_INTERRUPT_VECTOR = 0x0,
CELL_SPURS_LOCK_LINE = 0x80,
CELL_SPURS_KERNEL_DMA_TAG_ID = 31,
};
enum RangeofEventQueuePortNumbers
{
CELL_SPURS_STATIC_PORT_RANGE_BOTTOM = 15,
CELL_SPURS_DYNAMIC_PORT_RANGE_TOP = 16,
CELL_SPURS_DYNAMIC_PORT_RANGE_BOTTOM = 63,
};
enum SPURSTraceTypes
{
CELL_SPURS_TRACE_TAG_LOAD = 0x2a,
CELL_SPURS_TRACE_TAG_MAP = 0x2b,
CELL_SPURS_TRACE_TAG_START = 0x2c,
CELL_SPURS_TRACE_TAG_STOP = 0x2d,
CELL_SPURS_TRACE_TAG_USER = 0x2e,
CELL_SPURS_TRACE_TAG_GUID = 0x2f,
};
// SPURS task defines.
enum TaskConstants
{
CELL_SPURS_MAX_TASK = 128,
CELL_SPURS_TASK_TOP = 0x3000,
CELL_SPURS_TASK_BOTTOM = 0x40000,
CELL_SPURS_MAX_TASK_NAME_LENGTH = 32,
};
#include "Emu/SysCalls/Modules/cellSpurs.h"
// Internal class to shape a SPURS attribute.
class SPURSManagerAttribute
{
public:
SPURSManagerAttribute(int nSpus, int spuPriority, int ppuPriority, bool exitIfNoWork)
{
this->nSpus = nSpus;
this->spuThreadGroupPriority = spuPriority;
this->ppuThreadPriority = ppuPriority;
this->exitIfNoWork = exitIfNoWork;
SPURSManagerAttribute(int nSpus, int spuPriority, int ppuPriority, bool exitIfNoWork);
memset(this->namePrefix, 0, CELL_SPURS_NAME_MAX_LENGTH + 1);
this->threadGroupType = 0;
this->container = 0;
}
int _setNamePrefix(const char *name, u32 size);
int _setNamePrefix(const char *name, u32 size)
{
strncpy(this->namePrefix, name, size);
this->namePrefix[0] = 0;
return 0;
}
int _setSpuThreadGroupType(int type);
int _setSpuThreadGroupType(int type)
{
this->threadGroupType = type;
return 0;
}
int _setMemoryContainerForSpuThread(u32 container)
{
this->container = container;
return 0;
}
int _setMemoryContainerForSpuThread(u32 container);
protected:
be_t<int> nSpus;
@ -94,11 +27,7 @@ protected:
class SPURSManagerEventFlag
{
public:
SPURSManagerEventFlag(u32 flagClearMode, u32 flagDirection)
{
this->flagClearMode = flagClearMode;
this->flagDirection = flagDirection;
}
SPURSManagerEventFlag(u32 flagClearMode, u32 flagDirection);
u32 _getDirection()
{
@ -118,11 +47,7 @@ protected:
class SPURSManagerTasksetAttribute
{
public:
SPURSManagerTasksetAttribute(u64 args, mem8_t priority, u32 maxContention)
{
this->args = args;
this->maxContention = maxContention;
}
SPURSManagerTasksetAttribute(u64 args, mem8_t priority, u32 maxContention);
protected:
be_t<u64> args;

View File

@ -1,7 +1,6 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
//#include "Emu/System.h"
#include "Event.h"
void EventManager::Init()

View File

@ -2,10 +2,9 @@
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Callback.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/Cell/PPCThread.h"
#include "Callback.h"
Callback::Callback(u32 slot, u64 addr)
: m_addr(addr)

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/Static.h"
@ -175,6 +174,11 @@ bool Module::CheckID(u32 id, ID*& _id) const
return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->m_name == GetName();
}
bool Module::RemoveId(u32 id)
{
return Emu.GetIdManager().RemoveID(id);
}
IdManager& Module::GetIdManager() const
{
return Emu.GetIdManager();

View File

@ -114,6 +114,8 @@ public:
return GetIdManager().GetNewID<T>(GetName(), data, type);
}
bool RemoveId(u32 id);
template<typename T> __forceinline void AddFunc(u32 id, T func);
template<typename T> __forceinline void AddFunc(const char* name, T func);
template<typename T> __forceinline void AddFuncSub(const char group[8], const u64 ops[], const char* name, T func);

View File

@ -1,8 +1,8 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/Io/Keyboard.h"
extern Module *sys_io;

View File

@ -1,8 +1,8 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/Io/Mouse.h"
extern Module *sys_io;

View File

@ -1,8 +1,8 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/Io/Pad.h"
extern Module *sys_io;

View File

@ -1,9 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellPamf.h"
extern std::mutex g_mutex_avcodec_open2;
@ -14,12 +12,77 @@ extern "C"
#include "libswresample/swresample.h"
}
#include "cellPamf.h"
#include "cellAdec.h"
//void cellAdec_init();
//Module cellAdec(0x0006, cellAdec_init);
Module *cellAdec = nullptr;
AudioDecoder::AudioDecoder(AudioCodecType type, u32 addr, u32 size, u32 func, u32 arg)
: type(type)
, memAddr(addr)
, memSize(size)
, memBias(0)
, cbFunc(func)
, cbArg(arg)
, adecCb(nullptr)
, is_running(false)
, is_finished(false)
, just_started(false)
, just_finished(false)
, ctx(nullptr)
, fmt(nullptr)
{
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_ATRAC3P);
if (!codec)
{
cellAdec->Error("AudioDecoder(): avcodec_find_decoder(ATRAC3P) failed");
Emu.Pause();
return;
}
fmt = avformat_alloc_context();
if (!fmt)
{
cellAdec->Error("AudioDecoder(): avformat_alloc_context failed");
Emu.Pause();
return;
}
io_buf = (u8*)av_malloc(4096);
fmt->pb = avio_alloc_context(io_buf, 4096, 0, this, adecRead, NULL, NULL);
if (!fmt->pb)
{
cellAdec->Error("AudioDecoder(): avio_alloc_context failed");
Emu.Pause();
return;
}
}
AudioDecoder::~AudioDecoder()
{
// TODO: check finalization
if (ctx)
{
for (u32 i = frames.GetCount() - 1; ~i; i--)
{
AdecFrame& af = frames.Peek(i);
av_frame_unref(af.data);
av_frame_free(&af.data);
}
avcodec_close(ctx);
avformat_close_input(&fmt);
}
if (fmt)
{
if (io_buf)
{
av_free(io_buf);
}
if (fmt->pb) av_free(fmt->pb);
avformat_free_context(fmt);
}
}
int adecRawRead(void* opaque, u8* buf, int buf_size)
{
AudioDecoder& adec = *(AudioDecoder*)opaque;
@ -33,7 +96,7 @@ next:
{
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "adecRawRead(): aborted");
cellAdec->Warning("adecRawRead(): aborted");
return 0;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
@ -65,7 +128,7 @@ next:
}
break;
default:
LOG_ERROR(HLE, "adecRawRead(): sequence error (task %d)", adec.job.Peek().type);
cellAdec->Error("adecRawRead(): sequence error (task %d)", adec.job.Peek().type);
return -1;
}
@ -100,7 +163,7 @@ int adecRead(void* opaque, u8* buf, int buf_size)
{
if (buf_size < (int)adec.reader.rem_size)
{
LOG_ERROR(HLE, "adecRead(): too small buf_size (rem_size = %d, buf_size = %d)", adec.reader.rem_size, buf_size);
cellAdec->Error("adecRead(): too small buf_size (rem_size = %d, buf_size = %d)", adec.reader.rem_size, buf_size);
Emu.Pause();
return 0;
}
@ -120,7 +183,7 @@ int adecRead(void* opaque, u8* buf, int buf_size)
if (adecRawRead(opaque, header, 8) < 8) break;
if (header[0] != 0x0f || header[1] != 0xd0)
{
LOG_ERROR(HLE, "adecRead(): 0x0FD0 header not found");
cellAdec->Error("adecRead(): 0x0FD0 header not found");
Emu.Pause();
return -1;
}
@ -130,7 +193,7 @@ int adecRead(void* opaque, u8* buf, int buf_size)
OMAHeader oma(1 /* atrac3p id */, header[2], header[3]);
if (buf_size < sizeof(oma) + 8)
{
LOG_ERROR(HLE, "adecRead(): OMAHeader writing failed");
cellAdec->Error("adecRead(): OMAHeader writing failed");
Emu.Pause();
return 0;
}
@ -187,7 +250,7 @@ u32 adecOpen(AudioDecoder* data)
thread t("Audio Decoder[" + std::to_string(adec_id) + "] Thread", [&]()
{
LOG_NOTICE(HLE, "Audio Decoder thread started");
cellAdec->Notice("Audio Decoder thread started");
AdecTask& task = adec.task;
@ -218,288 +281,288 @@ u32 adecOpen(AudioDecoder* data)
switch (task.type)
{
case adecStartSeq:
{
// TODO: reset data
LOG_WARNING(HLE, "adecStartSeq:");
{
// TODO: reset data
cellAdec->Warning("adecStartSeq:");
adec.reader.addr = 0;
adec.reader.size = 0;
adec.reader.init = false;
if (adec.reader.rem) free(adec.reader.rem);
adec.reader.rem = nullptr;
adec.reader.rem_size = 0;
adec.is_running = true;
adec.just_started = true;
}
break;
adec.reader.addr = 0;
adec.reader.size = 0;
adec.reader.init = false;
if (adec.reader.rem) free(adec.reader.rem);
adec.reader.rem = nullptr;
adec.reader.rem_size = 0;
adec.is_running = true;
adec.just_started = true;
}
break;
case adecEndSeq:
{
// TODO: finalize
LOG_WARNING(HLE, "adecEndSeq:");
{
// TODO: finalize
cellAdec->Warning("adecEndSeq:");
/*Callback cb;
cb.SetAddr(adec.cbFunc);
cb.Handle(adec.id, CELL_ADEC_MSG_TYPE_SEQDONE, CELL_OK, adec.cbArg);
cb.Branch(true); // ???*/
adec.adecCb->ExecAsCallback(adec.cbFunc, true, adec.id, CELL_ADEC_MSG_TYPE_SEQDONE, CELL_OK, adec.cbArg);
/*Callback cb;
cb.SetAddr(adec.cbFunc);
cb.Handle(adec.id, CELL_ADEC_MSG_TYPE_SEQDONE, CELL_OK, adec.cbArg);
cb.Branch(true); // ???*/
adec.adecCb->ExecAsCallback(adec.cbFunc, true, adec.id, CELL_ADEC_MSG_TYPE_SEQDONE, CELL_OK, adec.cbArg);
adec.is_running = false;
adec.just_finished = true;
}
break;
adec.is_running = false;
adec.just_finished = true;
}
break;
case adecDecodeAu:
{
int err = 0;
adec.reader.addr = task.au.addr;
adec.reader.size = task.au.size;
//LOG_NOTICE(HLE, "Audio AU: size = 0x%x, pts = 0x%llx", task.au.size, task.au.pts);
if (adec.just_started)
{
int err = 0;
adec.first_pts = task.au.pts;
adec.last_pts = task.au.pts - 0x10000; // hack
}
adec.reader.addr = task.au.addr;
adec.reader.size = task.au.size;
//LOG_NOTICE(HLE, "Audio AU: size = 0x%x, pts = 0x%llx", task.au.size, task.au.pts);
if (adec.just_started)
struct AVPacketHolder : AVPacket
{
AVPacketHolder(u32 size)
{
adec.first_pts = task.au.pts;
adec.last_pts = task.au.pts - 0x10000; // hack
av_init_packet(this);
if (size)
{
data = (u8*)av_calloc(1, size + FF_INPUT_BUFFER_PADDING_SIZE);
this->size = size + FF_INPUT_BUFFER_PADDING_SIZE;
}
else
{
data = NULL;
size = 0;
}
}
struct AVPacketHolder : AVPacket
~AVPacketHolder()
{
AVPacketHolder(u32 size)
{
av_init_packet(this);
av_free(data);
//av_free_packet(this);
}
if (size)
{
data = (u8*)av_calloc(1, size + FF_INPUT_BUFFER_PADDING_SIZE);
this->size = size + FF_INPUT_BUFFER_PADDING_SIZE;
}
else
{
data = NULL;
size = 0;
}
}
} au(0);
~AVPacketHolder()
{
av_free(data);
//av_free_packet(this);
}
/*{
wxFile dump;
dump.Open(wxString::Format("audio pts-0x%llx.dump", task.au.pts), wxFile::write);
u8* buf = (u8*)malloc(task.au.size);
if (Memory.CopyToReal(buf, task.au.addr, task.au.size)) dump.Write(buf, task.au.size);
free(buf);
dump.Close();
}*/
} au(0);
if (adec.just_started && adec.just_finished)
{
avcodec_flush_buffers(adec.ctx);
adec.reader.init = true;
adec.just_finished = false;
adec.just_started = false;
}
else if (adec.just_started) // deferred initialization
{
err = avformat_open_input(&adec.fmt, NULL, av_find_input_format("oma"), NULL);
if (err)
{
cellAdec->Error("adecDecodeAu: avformat_open_input() failed");
Emu.Pause();
break;
}
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_ATRAC3P); // ???
if (!codec)
{
cellAdec->Error("adecDecodeAu: avcodec_find_decoder() failed");
Emu.Pause();
break;
}
//err = avformat_find_stream_info(adec.fmt, NULL);
//if (err)
//{
// cellAdec->Error("adecDecodeAu: avformat_find_stream_info() failed");
// Emu.Pause();
// break;
//}
//if (!adec.fmt->nb_streams)
//{
// cellAdec->Error("adecDecodeAu: no stream found");
// Emu.Pause();
// break;
//}
if (!avformat_new_stream(adec.fmt, codec))
{
cellAdec->Error("adecDecodeAu: avformat_new_stream() failed");
Emu.Pause();
break;
}
adec.ctx = adec.fmt->streams[0]->codec; // TODO: check data
/*{
wxFile dump;
dump.Open(wxString::Format("audio pts-0x%llx.dump", task.au.pts), wxFile::write);
u8* buf = (u8*)malloc(task.au.size);
if (Memory.CopyToReal(buf, task.au.addr, task.au.size)) dump.Write(buf, task.au.size);
free(buf);
dump.Close();
AVDictionary* opts = nullptr;
av_dict_set(&opts, "refcounted_frames", "1", 0);
{
std::lock_guard<std::mutex> lock(g_mutex_avcodec_open2);
// not multithread-safe (???)
err = avcodec_open2(adec.ctx, codec, &opts);
}
if (err)
{
cellAdec->Error("adecDecodeAu: avcodec_open2() failed");
Emu.Pause();
break;
}
adec.just_started = false;
}
bool last_frame = false;
while (true)
{
if (Emu.IsStopped())
{
cellAdec->Warning("adecDecodeAu: aborted");
return;
}
/*if (!adec.ctx) // fake
{
AdecFrame frame;
frame.pts = task.au.pts;
frame.auAddr = task.au.addr;
frame.auSize = task.au.size;
frame.userdata = task.au.userdata;
frame.size = 4096;
frame.data = nullptr;
adec.frames.Push(frame);
adec.adecCb->ExecAsCallback(adec.cbFunc, false, adec.id, CELL_ADEC_MSG_TYPE_PCMOUT, CELL_OK, adec.cbArg);
break;
}*/
if (adec.just_started && adec.just_finished)
last_frame = av_read_frame(adec.fmt, &au) < 0;
if (last_frame)
{
avcodec_flush_buffers(adec.ctx);
adec.reader.init = true;
adec.just_finished = false;
adec.just_started = false;
}
else if (adec.just_started) // deferred initialization
{
err = avformat_open_input(&adec.fmt, NULL, av_find_input_format("oma"), NULL);
if (err)
{
LOG_ERROR(HLE, "adecDecodeAu: avformat_open_input() failed");
Emu.Pause();
break;
}
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_ATRAC3P); // ???
if (!codec)
{
LOG_ERROR(HLE, "adecDecodeAu: avcodec_find_decoder() failed");
Emu.Pause();
break;
}
/*err = avformat_find_stream_info(adec.fmt, NULL);
if (err)
{
LOG_ERROR(HLE, "adecDecodeAu: avformat_find_stream_info() failed");
Emu.Pause();
break;
}
if (!adec.fmt->nb_streams)
{
LOG_ERROR(HLE, "adecDecodeAu: no stream found");
Emu.Pause();
break;
}*/
if (!avformat_new_stream(adec.fmt, codec))
{
LOG_ERROR(HLE, "adecDecodeAu: avformat_new_stream() failed");
Emu.Pause();
break;
}
adec.ctx = adec.fmt->streams[0]->codec; // TODO: check data
AVDictionary* opts = nullptr;
av_dict_set(&opts, "refcounted_frames", "1", 0);
{
std::lock_guard<std::mutex> lock(g_mutex_avcodec_open2);
// not multithread-safe (???)
err = avcodec_open2(adec.ctx, codec, &opts);
}
if (err)
{
LOG_ERROR(HLE, "adecDecodeAu: avcodec_open2() failed");
Emu.Pause();
break;
}
adec.just_started = false;
//break;
av_free(au.data);
au.data = NULL;
au.size = 0;
}
bool last_frame = false;
while (true)
struct AdecFrameHolder : AdecFrame
{
if (Emu.IsStopped())
AdecFrameHolder()
{
LOG_WARNING(HLE, "adecDecodeAu: aborted");
return;
data = av_frame_alloc();
}
/*if (!adec.ctx) // fake
~AdecFrameHolder()
{
AdecFrame frame;
frame.pts = task.au.pts;
frame.auAddr = task.au.addr;
frame.auSize = task.au.size;
frame.userdata = task.au.userdata;
frame.size = 4096;
frame.data = nullptr;
adec.frames.Push(frame);
if (data)
{
av_frame_unref(data);
av_frame_free(&data);
}
}
adec.adecCb->ExecAsCallback(adec.cbFunc, false, adec.id, CELL_ADEC_MSG_TYPE_PCMOUT, CELL_OK, adec.cbArg);
} frame;
if (!frame.data)
{
cellAdec->Error("adecDecodeAu: av_frame_alloc() failed");
Emu.Pause();
break;
}
int got_frame = 0;
int decode = avcodec_decode_audio4(adec.ctx, frame.data, &got_frame, &au);
if (decode <= 0)
{
if (!last_frame && decode < 0)
{
cellAdec->Error("adecDecodeAu: AU decoding error(0x%x)", decode);
}
if (!got_frame && adec.reader.size == 0) break;
}
if (got_frame)
{
u64 ts = av_frame_get_best_effort_timestamp(frame.data);
if (ts != AV_NOPTS_VALUE)
{
frame.pts = ts/* - adec.first_pts*/;
adec.last_pts = frame.pts;
}
else
{
adec.last_pts += ((u64)frame.data->nb_samples) * 90000 / 48000;
frame.pts = adec.last_pts;
}
//frame.pts = adec.last_pts;
//adec.last_pts += ((u64)frame.data->nb_samples) * 90000 / 48000; // ???
frame.auAddr = task.au.addr;
frame.auSize = task.au.size;
frame.userdata = task.au.userdata;
frame.size = frame.data->nb_samples * frame.data->channels * sizeof(float);
if (frame.data->format != AV_SAMPLE_FMT_FLTP)
{
cellAdec->Error("adecDecodeaAu: unsupported frame format(%d)", frame.data->format);
Emu.Pause();
break;
}*/
last_frame = av_read_frame(adec.fmt, &au) < 0;
if (last_frame)
{
//break;
av_free(au.data);
au.data = NULL;
au.size = 0;
}
struct AdecFrameHolder : AdecFrame
if (frame.data->channels != 2)
{
AdecFrameHolder()
{
data = av_frame_alloc();
}
~AdecFrameHolder()
{
if (data)
{
av_frame_unref(data);
av_frame_free(&data);
}
}
} frame;
if (!frame.data)
{
LOG_ERROR(HLE, "adecDecodeAu: av_frame_alloc() failed");
cellAdec->Error("adecDecodeAu: unsupported channel count (%d)", frame.data->channels);
Emu.Pause();
break;
}
int got_frame = 0;
//LOG_NOTICE(HLE, "got audio frame (pts=0x%llx, nb_samples=%d, ch=%d, sample_rate=%d, nbps=%d)",
//frame.pts, frame.data->nb_samples, frame.data->channels, frame.data->sample_rate,
//av_get_bytes_per_sample((AVSampleFormat)frame.data->format));
int decode = avcodec_decode_audio4(adec.ctx, frame.data, &got_frame, &au);
adec.frames.Push(frame);
frame.data = nullptr; // to prevent destruction
if (decode <= 0)
{
if (!last_frame && decode < 0)
{
LOG_ERROR(HLE, "adecDecodeAu: AU decoding error(0x%x)", decode);
}
if (!got_frame && adec.reader.size == 0) break;
}
if (got_frame)
{
u64 ts = av_frame_get_best_effort_timestamp(frame.data);
if (ts != AV_NOPTS_VALUE)
{
frame.pts = ts/* - adec.first_pts*/;
adec.last_pts = frame.pts;
}
else
{
adec.last_pts += ((u64)frame.data->nb_samples) * 90000 / 48000;
frame.pts = adec.last_pts;
}
//frame.pts = adec.last_pts;
//adec.last_pts += ((u64)frame.data->nb_samples) * 90000 / 48000; // ???
frame.auAddr = task.au.addr;
frame.auSize = task.au.size;
frame.userdata = task.au.userdata;
frame.size = frame.data->nb_samples * frame.data->channels * sizeof(float);
if (frame.data->format != AV_SAMPLE_FMT_FLTP)
{
LOG_ERROR(HLE, "adecDecodeaAu: unsupported frame format(%d)", frame.data->format);
Emu.Pause();
break;
}
if (frame.data->channels != 2)
{
LOG_ERROR(HLE, "adecDecodeAu: unsupported channel count (%d)", frame.data->channels);
Emu.Pause();
break;
}
//LOG_NOTICE(HLE, "got audio frame (pts=0x%llx, nb_samples=%d, ch=%d, sample_rate=%d, nbps=%d)",
//frame.pts, frame.data->nb_samples, frame.data->channels, frame.data->sample_rate,
//av_get_bytes_per_sample((AVSampleFormat)frame.data->format));
adec.frames.Push(frame);
frame.data = nullptr; // to prevent destruction
/*Callback cb;
cb.SetAddr(adec.cbFunc);
cb.Handle(adec.id, CELL_ADEC_MSG_TYPE_PCMOUT, CELL_OK, adec.cbArg);
cb.Branch(false);*/
adec.adecCb->ExecAsCallback(adec.cbFunc, false, adec.id, CELL_ADEC_MSG_TYPE_PCMOUT, CELL_OK, adec.cbArg);
}
/*Callback cb;
cb.SetAddr(adec.cbFunc);
cb.Handle(adec.id, CELL_ADEC_MSG_TYPE_PCMOUT, CELL_OK, adec.cbArg);
cb.Branch(false);*/
adec.adecCb->ExecAsCallback(adec.cbFunc, false, adec.id, CELL_ADEC_MSG_TYPE_PCMOUT, CELL_OK, adec.cbArg);
}
/*Callback cb;
cb.SetAddr(adec.cbFunc);
cb.Handle(adec.id, CELL_ADEC_MSG_TYPE_AUDONE, task.au.auInfo_addr, adec.cbArg);
cb.Branch(false);*/
adec.adecCb->ExecAsCallback(adec.cbFunc, false, adec.id, CELL_ADEC_MSG_TYPE_AUDONE, task.au.auInfo_addr, adec.cbArg);
}
break;
/*Callback cb;
cb.SetAddr(adec.cbFunc);
cb.Handle(adec.id, CELL_ADEC_MSG_TYPE_AUDONE, task.au.auInfo_addr, adec.cbArg);
cb.Branch(false);*/
adec.adecCb->ExecAsCallback(adec.cbFunc, false, adec.id, CELL_ADEC_MSG_TYPE_AUDONE, task.au.auInfo_addr, adec.cbArg);
}
break;
case adecClose:
{
adec.is_finished = true;
LOG_NOTICE(HLE, "Audio Decoder thread ended");
return;
}
{
adec.is_finished = true;
cellAdec->Notice("Audio Decoder thread ended");
return;
}
default:
LOG_ERROR(HLE, "Audio Decoder thread error: unknown task(%d)", task.type);
cellAdec->Error("Audio Decoder thread error: unknown task(%d)", task.type);
}
}
adec.is_finished = true;
LOG_WARNING(HLE, "Audio Decoder thread aborted");
cellAdec->Warning("Audio Decoder thread aborted");
});
t.detach();
@ -511,8 +574,8 @@ bool adecCheckType(AudioCodecType type)
{
switch (type)
{
case CELL_ADEC_TYPE_ATRACX: LOG_NOTICE(HLE, "adecCheckType: ATRAC3plus"); break;
case CELL_ADEC_TYPE_ATRACX_2CH: LOG_NOTICE(HLE, "adecCheckType: ATRAC3plus 2ch"); break;
case CELL_ADEC_TYPE_ATRACX: cellAdec->Notice("adecCheckType: ATRAC3plus"); break;
case CELL_ADEC_TYPE_ATRACX_2CH: cellAdec->Notice("adecCheckType: ATRAC3plus 2ch"); break;
case CELL_ADEC_TYPE_ATRACX_6CH:
case CELL_ADEC_TYPE_ATRACX_8CH:
@ -587,7 +650,7 @@ int cellAdecClose(u32 handle)
{
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellAdecClose(%d) aborted", handle);
cellAdec->Warning("cellAdecClose(%d) aborted", handle);
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
@ -751,15 +814,15 @@ int cellAdecGetPcmItem(u32 handle, mem32_t pcmItem_ptr)
void cellAdec_init()
{
cellAdec->AddFunc(0x7e4a4a49, cellAdecQueryAttr);
cellAdec->AddFunc(0xd00a6988, cellAdecOpen);
cellAdec->AddFunc(0x8b5551a4, cellAdecOpenEx);
cellAdec->AddFunc(0x847d2380, cellAdecClose);
cellAdec->AddFunc(0x487b613e, cellAdecStartSeq);
cellAdec->AddFunc(0xe2ea549b, cellAdecEndSeq);
cellAdec->AddFunc(0x1529e506, cellAdecDecodeAu);
cellAdec->AddFunc(0x97ff2af1, cellAdecGetPcm);
cellAdec->AddFunc(0xbd75f78b, cellAdecGetPcmItem);
REG_FUNC(cellAdec, cellAdecQueryAttr);
REG_FUNC(cellAdec, cellAdecOpen);
REG_FUNC(cellAdec, cellAdecOpenEx);
REG_FUNC(cellAdec, cellAdecClose);
REG_FUNC(cellAdec, cellAdecStartSeq);
REG_FUNC(cellAdec, cellAdecEndSeq);
REG_FUNC(cellAdec, cellAdecDecodeAu);
REG_FUNC(cellAdec, cellAdecGetPcm);
REG_FUNC(cellAdec, cellAdecGetPcmItem);
av_register_all();
avcodec_register_all();

View File

@ -1117,67 +1117,7 @@ public:
CPUThread* adecCb;
AudioDecoder(AudioCodecType type, u32 addr, u32 size, u32 func, u32 arg)
: type(type)
, memAddr(addr)
, memSize(size)
, memBias(0)
, cbFunc(func)
, cbArg(arg)
, adecCb(nullptr)
, is_running(false)
, is_finished(false)
, just_started(false)
, just_finished(false)
, ctx(nullptr)
, fmt(nullptr)
{
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_ATRAC3P);
if (!codec)
{
LOG_ERROR(HLE, "AudioDecoder(): avcodec_find_decoder(ATRAC3P) failed");
Emu.Pause();
return;
}
fmt = avformat_alloc_context();
if (!fmt)
{
LOG_ERROR(HLE, "AudioDecoder(): avformat_alloc_context failed");
Emu.Pause();
return;
}
io_buf = (u8*)av_malloc(4096);
fmt->pb = avio_alloc_context(io_buf, 4096, 0, this, adecRead, NULL, NULL);
if (!fmt->pb)
{
LOG_ERROR(HLE, "AudioDecoder(): avio_alloc_context failed");
Emu.Pause();
return;
}
}
AudioDecoder(AudioCodecType type, u32 addr, u32 size, u32 func, u32 arg);
~AudioDecoder()
{
// TODO: check finalization
if (ctx)
{
for (u32 i = frames.GetCount() - 1; ~i; i--)
{
AdecFrame& af = frames.Peek(i);
av_frame_unref(af.data);
av_frame_free(&af.data);
}
avcodec_close(ctx);
avformat_close_input(&fmt);
}
if (fmt)
{
if (io_buf)
{
av_free(io_buf);
}
if (fmt->pb) av_free(fmt->pb);
avformat_free_context(fmt);
}
}
~AudioDecoder();
};

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/SysCalls/Modules.h"

View File

@ -1,15 +1,15 @@
#include "stdafx.h"
#include "rpcs3/Ini.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "rpcs3/Ini.h"
#include "Utilities/SQueue.h"
#include "Emu/Event.h"
#include "Emu/SysCalls/lv2/sys_time.h"
#include "Emu/Audio/cellAudio.h"
#include "Emu/Audio/AudioManager.h"
//#include "Emu/Audio/AudioManager.h"
#include "Emu/Audio/AudioDumper.h"
#include "Emu/Audio/cellAudio.h"
//void cellAudio_init();
//Module cellAudio(0x0011, cellAudio_init);
@ -52,11 +52,11 @@ int cellAudioInit()
if (do_dump && !m_dump.Init())
{
LOG_ERROR(HLE, "cellAudioInit(): AudioDumper::Init() failed");
cellAudio->Error("cellAudioInit(): AudioDumper::Init() failed");
return;
}
LOG_NOTICE(HLE, "Audio thread started");
cellAudio->Notice("Audio thread started");
if (Ini.AudioDumpToFile.GetValue())
m_dump.WriteHeader();
@ -137,7 +137,7 @@ int cellAudioInit()
{
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "Audio thread aborted");
cellAudio->Warning("Audio thread aborted");
goto abort;
}
@ -417,7 +417,7 @@ int cellAudioInit()
{
if (m_dump.WriteData(&buf8ch, sizeof(buf8ch)) != sizeof(buf8ch)) // write file data
{
LOG_ERROR(HLE, "cellAudioInit(): AudioDumper::WriteData() failed");
cellAudio->Error("cellAudioInit(): AudioDumper::WriteData() failed");
goto abort;
}
}
@ -425,13 +425,13 @@ int cellAudioInit()
{
if (m_dump.WriteData(&buf2ch, sizeof(buf2ch)) != sizeof(buf2ch)) // write file data
{
LOG_ERROR(HLE, "cellAudioInit(): AudioDumper::WriteData() failed");
cellAudio->Error("cellAudioInit(): AudioDumper::WriteData() failed");
goto abort;
}
}
else
{
LOG_ERROR(HLE, "cellAudioInit(): unknown AudioDumper::GetCh() value (%d)", m_dump.GetCh());
cellAudio->Error("cellAudioInit(): unknown AudioDumper::GetCh() value (%d)", m_dump.GetCh());
goto abort;
}
}
@ -439,7 +439,7 @@ int cellAudioInit()
//LOG_NOTICE(HLE, "Audio perf: start=%d (access=%d, AddData=%d, events=%d, dump=%d)",
//stamp0 - m_config.start_time, stamp1 - stamp0, stamp2 - stamp1, stamp3 - stamp2, get_system_time() - stamp3);
}
LOG_NOTICE(HLE, "Audio thread ended");
cellAudio->Notice("Audio thread ended");
abort:
queue.Push(nullptr);
queue_float.Push(nullptr);
@ -471,7 +471,7 @@ abort:
{
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellAudioInit() aborted");
cellAudio->Warning("cellAudioInit() aborted");
return CELL_OK;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
@ -496,7 +496,7 @@ int cellAudioQuit()
std::this_thread::sleep_for(std::chrono::milliseconds(1));
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellAudioQuit(): aborted");
cellAudio->Warning("cellAudioQuit(): aborted");
return CELL_OK;
}
}

View File

@ -1,9 +1,8 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
#include "cellPamf.h"
#include "cellDmux.h"
@ -11,6 +10,300 @@
//Module cellDmux(0x0007, cellDmux_init);
Module *cellDmux = nullptr;
PesHeader::PesHeader(DemuxerStream& stream)
: pts(0xffffffffffffffffull)
, dts(0xffffffffffffffffull)
, size(0)
, new_au(false)
{
u16 header;
stream.get(header);
stream.get(size);
if (size)
{
u8 empty = 0;
u8 v;
while (true)
{
stream.get(v);
if (v != 0xFF) break; // skip padding bytes
empty++;
if (empty == size) return;
};
if ((v & 0xF0) == 0x20 && (size - empty) >= 5) // pts only
{
new_au = true;
pts = stream.get_ts(v);
stream.skip(size - empty - 5);
}
else
{
new_au = true;
if ((v & 0xF0) != 0x30 || (size - empty) < 10)
{
cellDmux->Error("PesHeader(): pts not found");
Emu.Pause();
}
pts = stream.get_ts(v);
stream.get(v);
if ((v & 0xF0) != 0x10)
{
cellDmux->Error("PesHeader(): dts not found");
Emu.Pause();
}
dts = stream.get_ts(v);
stream.skip(size - empty - 10);
}
}
}
bool ElementaryStream::is_full()
{
if (released < put_count)
{
u32 first = entries.Peek();
if (first >= put)
{
return (first - put) < GetMaxAU();
}
else
{
// probably, always false
return (put + GetMaxAU()) > (memAddr + memSize);
}
}
else
{
return false;
}
}
const u32 ElementaryStream::GetMaxAU() const
{
return (fidMajor == 0xbd) ? 4096 : 640 * 1024 + 128; // TODO
}
u32 ElementaryStream::freespace()
{
if (size > GetMaxAU())
{
cellDmux->Error("es::freespace(): last_size too big (size=0x%x, max_au=0x%x)", size, GetMaxAU());
Emu.Pause();
return 0;
}
return GetMaxAU() - size;
}
bool ElementaryStream::hasunseen()
{
std::lock_guard<std::mutex> lock(m_mutex);
return peek_count < put_count;
}
bool ElementaryStream::hasdata()
{
std::lock_guard<std::mutex> lock(m_mutex);
return size != 0;
}
bool ElementaryStream::isfull()
{
std::lock_guard<std::mutex> lock(m_mutex);
return is_full();
}
void ElementaryStream::finish(DemuxerStream& stream) // not multithread-safe
{
u32 addr;
{
std::lock_guard<std::mutex> lock(m_mutex);
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, ">>> es::finish(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
addr = put;
/*if (!first)
{
first = put;
}
if (!peek)
{
peek = put;
}*/
mem_ptr_t<CellDmuxAuInfo> info(put);
//if (fidMajor != 0xbd) LOG_WARNING(HLE, "es::finish(): (%s) size = 0x%x, info_addr=0x%x, pts = 0x%x",
//wxString(fidMajor == 0xbd ? "ATRAC3P Audio" : "Video AVC").wx_str(),
//(u32)info->auSize, put, (u32)info->ptsLower);
u32 new_addr = a128(put + 128 + size);
put = ((new_addr + GetMaxAU()) > (memAddr + memSize))
? memAddr : new_addr;
size = 0;
put_count++;
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, "<<< es::finish(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
}
if (!entries.Push(addr))
{
cellDmux->Error("es::finish() aborted (no space)");
}
}
void ElementaryStream::push(DemuxerStream& stream, u32 sz, PesHeader& pes)
{
std::lock_guard<std::mutex> lock(m_mutex);
if (is_full())
{
cellDmux->Error("es::push(): buffer is full");
Emu.Pause();
return;
}
u32 data_addr = put + 128 + size;
size += sz;
memcpy(Memory + data_addr, Memory + stream.addr, sz);
stream.skip(sz);
mem_ptr_t<CellDmuxAuInfoEx> info(put);
info->auAddr = put + 128;
info->auSize = size;
if (pes.new_au)
{
info->dts.lower = (u32)pes.dts;
info->dts.upper = (u32)(pes.dts >> 32);
info->pts.lower = (u32)pes.pts;
info->pts.upper = (u32)(pes.pts >> 32);
info->isRap = false; // TODO: set valid value
info->reserved = 0;
info->userData = stream.userdata;
}
mem_ptr_t<CellDmuxPamfAuSpecificInfoAvc> tail(put + sizeof(CellDmuxAuInfoEx));
tail->reserved1 = 0;
mem_ptr_t<CellDmuxAuInfo> inf(put + 64);
inf->auAddr = put + 128;
inf->auSize = size;
if (pes.new_au)
{
inf->dtsLower = (u32)pes.dts;
inf->dtsUpper = (u32)(pes.dts >> 32);
inf->ptsLower = (u32)pes.pts;
inf->ptsUpper = (u32)(pes.pts >> 32);
inf->auMaxSize = 0; // ?????
inf->userData = stream.userdata;
}
}
bool ElementaryStream::release()
{
std::lock_guard<std::mutex> lock(m_mutex);
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, ">>> es::release(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
if (released >= put_count)
{
cellDmux->Error("es::release(): buffer is empty");
return false;
}
u32 addr = entries.Peek();
mem_ptr_t<CellDmuxAuInfo> info(addr);
//if (fidMajor != 0xbd) LOG_WARNING(HLE, "es::release(): (%s) size = 0x%x, info = 0x%x, pts = 0x%x",
//wxString(fidMajor == 0xbd ? "ATRAC3P Audio" : "Video AVC").wx_str(), (u32)info->auSize, first, (u32)info->ptsLower);
if (released >= peek_count)
{
cellDmux->Error("es::release(): buffer has not been seen yet");
return false;
}
/*u32 new_addr = a128(info.GetAddr() + 128 + info->auSize);
if (new_addr == put)
{
first = 0;
}
else if ((new_addr + GetMaxAU()) > (memAddr + memSize))
{
first = memAddr;
}
else
{
first = new_addr;
}*/
released++;
if (!entries.Pop(addr))
{
cellDmux->Error("es::release(): entries.Pop() aborted (no entries found)");
return false;
}
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, "<<< es::release(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
return true;
}
bool ElementaryStream::peek(u32& out_data, bool no_ex, u32& out_spec, bool update_index)
{
std::lock_guard<std::mutex> lock(m_mutex);
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, ">>> es::peek(%sAu%s): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", wxString(update_index ? "Get" : "Peek").wx_str(),
//wxString(no_ex ? "" : "Ex").wx_str(), peek, first, put, size);
if (peek_count >= put_count) return false;
if (peek_count < released)
{
cellDmux->Error("es::peek(): sequence error: peek_count < released (peek_count=%d, released=%d)", peek_count, released);
Emu.Pause();
return false;
}
u32 addr = entries.Peek(peek_count - released);
mem_ptr_t<CellDmuxAuInfo> info(addr);
//if (fidMajor != 0xbd) LOG_WARNING(HLE, "es::peek(%sAu(Ex)): (%s) size = 0x%x, info = 0x%x, pts = 0x%x",
//wxString(update_index ? "Get" : "Peek").wx_str(),
//wxString(fidMajor == 0xbd ? "ATRAC3P Audio" : "Video AVC").wx_str(), (u32)info->auSize, peek, (u32)info->ptsLower);
out_data = addr;
out_spec = out_data + sizeof(CellDmuxAuInfoEx);
if (no_ex) out_data += 64;
if (update_index)
{
/*u32 new_addr = a128(peek + 128 + info->auSize);
if (new_addr == put)
{
peek = 0;
}
else if ((new_addr + GetMaxAU()) > (memAddr + memSize))
{
peek = memAddr;
}
else
{
peek = new_addr;
}*/
peek_count++;
}
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, "<<< es::peek(%sAu%s): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", wxString(update_index ? "Get" : "Peek").wx_str(),
//wxString(no_ex ? "" : "Ex").wx_str(), peek, first, put, size);
return true;
}
void ElementaryStream::reset()
{
std::lock_guard<std::mutex> lock(m_mutex);
//first = 0;
//peek = 0;
put = memAddr;
size = 0;
entries.Clear();
put_count = 0;
released = 0;
peek_count = 0;
}
void dmuxQueryAttr(u32 info_addr /* may be 0 */, mem_ptr_t<CellDmuxAttr> attr)
{
attr->demuxerVerLower = 0x280000; // TODO: check values
@ -44,7 +337,7 @@ u32 dmuxOpen(Demuxer* data)
thread t("Demuxer[" + std::to_string(dmux_id) + "] Thread", [&]()
{
LOG_NOTICE(HLE, "Demuxer thread started (mem=0x%x, size=0x%x, cb=0x%x, arg=0x%x)", dmux.memAddr, dmux.memSize, dmux.cbFunc, dmux.cbArg);
cellDmux->Notice("Demuxer thread started (mem=0x%x, size=0x%x, cb=0x%x, arg=0x%x)", dmux.memAddr, dmux.memSize, dmux.cbFunc, dmux.cbArg);
DemuxerTask task;
DemuxerStream stream;
@ -131,7 +424,7 @@ u32 dmuxOpen(Demuxer* data)
if (!pes.new_au) // temporarily
{
LOG_ERROR(HLE, "No pts info found");
cellDmux->Error("No pts info found");
}
// read additional header:
@ -261,7 +554,7 @@ u32 dmuxOpen(Demuxer* data)
case 0x1dc: case 0x1dd: case 0x1de: case 0x1df:
{
// unknown
LOG_WARNING(HLE, "Unknown MPEG stream found");
cellDmux->Warning("Unknown MPEG stream found");
stream.skip(4);
stream.get(len);
stream.skip(len);
@ -270,7 +563,7 @@ u32 dmuxOpen(Demuxer* data)
case USER_DATA_START_CODE:
{
LOG_ERROR(HLE, "USER_DATA_START_CODE found");
cellDmux->Error("USER_DATA_START_CODE found");
return;
}
@ -297,7 +590,7 @@ u32 dmuxOpen(Demuxer* data)
{
if (task.stream.discontinuity)
{
LOG_WARNING(HLE, "dmuxSetStream (beginning)");
cellDmux->Warning("dmuxSetStream (beginning)");
for (u32 i = 0; i < 192; i++)
{
if (esALL[i])
@ -311,7 +604,7 @@ u32 dmuxOpen(Demuxer* data)
if (updates_count != updates_signaled)
{
LOG_ERROR(HLE, "dmuxSetStream: stream update inconsistency (input=%d, signaled=%d)", updates_count, updates_signaled);
cellDmux->Error("dmuxSetStream: stream update inconsistency (input=%d, signaled=%d)", updates_count, updates_signaled);
return;
}
@ -350,7 +643,7 @@ u32 dmuxOpen(Demuxer* data)
case dmuxClose:
{
dmux.is_finished = true;
LOG_NOTICE(HLE, "Demuxer thread ended");
cellDmux->Notice("Demuxer thread ended");
return;
}
@ -374,7 +667,7 @@ u32 dmuxOpen(Demuxer* data)
}
else
{
LOG_WARNING(HLE, "dmuxEnableEs: (TODO) unsupported filter (0x%x, 0x%x, 0x%x, 0x%x)", es.fidMajor, es.fidMinor, es.sup1, es.sup2);
cellDmux->Warning("dmuxEnableEs: (TODO) unsupported filter (0x%x, 0x%x, 0x%x, 0x%x)", es.fidMajor, es.fidMinor, es.sup1, es.sup2);
}
es.dmux = &dmux;
}
@ -385,7 +678,7 @@ u32 dmuxOpen(Demuxer* data)
ElementaryStream& es = *task.es.es_ptr;
if (es.dmux != &dmux)
{
LOG_WARNING(HLE, "dmuxDisableEs: invalid elementary stream");
cellDmux->Warning("dmuxDisableEs: invalid elementary stream");
break;
}
for (u32 i = 0; i < 192; i++)
@ -443,11 +736,11 @@ u32 dmuxOpen(Demuxer* data)
break;
default:
LOG_ERROR(HLE, "Demuxer thread error: unknown task(%d)", task.type);
cellDmux->Error("Demuxer thread error: unknown task(%d)", task.type);
return;
}
}
LOG_WARNING(HLE, "Demuxer thread aborted");
cellDmux->Warning("Demuxer thread aborted");
});
t.detach();
@ -551,7 +844,7 @@ int cellDmuxClose(u32 demuxerHandle)
{
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellDmuxClose(%d) aborted", demuxerHandle);
cellDmux->Warning("cellDmuxClose(%d) aborted", demuxerHandle);
return CELL_OK;
}
@ -578,7 +871,7 @@ int cellDmuxSetStream(u32 demuxerHandle, const u32 streamAddress, u32 streamSize
{
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellDmuxSetStream(%d) aborted (waiting)", demuxerHandle);
cellDmux->Warning("cellDmuxSetStream(%d) aborted (waiting)", demuxerHandle);
return CELL_OK;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
@ -597,12 +890,12 @@ int cellDmuxSetStream(u32 demuxerHandle, const u32 streamAddress, u32 streamSize
u32 addr;
if (!dmux->fbSetStream.Pop(addr))
{
LOG_WARNING(HLE, "cellDmuxSetStream(%d) aborted (fbSetStream.Pop())", demuxerHandle);
cellDmux->Warning("cellDmuxSetStream(%d) aborted (fbSetStream.Pop())", demuxerHandle);
return CELL_OK;
}
if (addr != info.addr)
{
LOG_ERROR(HLE, "cellDmuxSetStream(%d): wrong stream queued (right=0x%x, queued=0x%x)", demuxerHandle, info.addr, addr);
cellDmux->Error("cellDmuxSetStream(%d): wrong stream queued (right=0x%x, queued=0x%x)", demuxerHandle, info.addr, addr);
Emu.Pause();
}
return CELL_OK;
@ -638,12 +931,12 @@ int cellDmuxResetStreamAndWaitDone(u32 demuxerHandle)
u32 addr;
if (!dmux->fbSetStream.Pop(addr))
{
LOG_WARNING(HLE, "cellDmuxResetStreamAndWaitDone(%d) aborted (fbSetStream.Pop())", demuxerHandle);
cellDmux->Warning("cellDmuxResetStreamAndWaitDone(%d) aborted (fbSetStream.Pop())", demuxerHandle);
return CELL_OK;
}
if (addr != 0)
{
LOG_ERROR(HLE, "cellDmuxResetStreamAndWaitDone(%d): wrong stream queued (0x%x)", demuxerHandle, addr);
cellDmux->Error("cellDmuxResetStreamAndWaitDone(%d): wrong stream queued (0x%x)", demuxerHandle, addr);
Emu.Pause();
}
return CELL_OK;

View File

@ -362,53 +362,7 @@ struct PesHeader
u8 size;
bool new_au;
PesHeader(DemuxerStream& stream)
: pts(0xffffffffffffffff)
, dts(0xffffffffffffffff)
, size(0)
, new_au(false)
{
u16 header;
stream.get(header);
stream.get(size);
if (size)
{
u8 empty = 0;
u8 v;
while (true)
{
stream.get(v);
if (v != 0xFF) break; // skip padding bytes
empty++;
if (empty == size) return;
};
if ((v & 0xF0) == 0x20 && (size - empty) >= 5) // pts only
{
new_au = true;
pts = stream.get_ts(v);
stream.skip(size - empty - 5);
}
else
{
new_au = true;
if ((v & 0xF0) != 0x30 || (size - empty) < 10)
{
LOG_ERROR(HLE, "PesHeader(): pts not found");
Emu.Pause();
}
pts = stream.get_ts(v);
stream.get(v);
if ((v & 0xF0) != 0x10)
{
LOG_ERROR(HLE, "PesHeader(): dts not found");
Emu.Pause();
}
dts = stream.get_ts(v);
stream.skip(size - empty - 10);
}
}
}
PesHeader(DemuxerStream& stream);
};
class ElementaryStream;
@ -493,26 +447,7 @@ class ElementaryStream
//u32 first; // AU that will be released
//u32 peek; // AU that will be obtained by GetAu(Ex)/PeekAu(Ex)
bool is_full()
{
if (released < put_count)
{
u32 first = entries.Peek();
if (first >= put)
{
return (first - put) < GetMaxAU();
}
else
{
// probably, always false
return (put + GetMaxAU()) > (memAddr + memSize);
}
}
else
{
return false;
}
}
bool is_full();
public:
Demuxer* dmux;
@ -548,228 +483,23 @@ public:
{
}
const u32 GetMaxAU() const
{
return (fidMajor == 0xbd) ? 4096 : 640 * 1024 + 128; // TODO
}
const u32 GetMaxAU() const;
u32 freespace()
{
if (size > GetMaxAU())
{
LOG_ERROR(HLE, "es::freespace(): last_size too big (size=0x%x, max_au=0x%x)", size, GetMaxAU());
Emu.Pause();
return 0;
}
return GetMaxAU() - size;
}
u32 freespace();
bool hasunseen()
{
std::lock_guard<std::mutex> lock(m_mutex);
return peek_count < put_count;
}
bool hasunseen();
bool hasdata()
{
std::lock_guard<std::mutex> lock(m_mutex);
return size;
}
bool hasdata();
bool isfull()
{
std::lock_guard<std::mutex> lock(m_mutex);
return is_full();
}
bool isfull();
void finish(DemuxerStream& stream) // not multithread-safe
{
u32 addr;
{
std::lock_guard<std::mutex> lock(m_mutex);
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, ">>> es::finish(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
void finish(DemuxerStream& stream);
addr = put;
/*if (!first)
{
first = put;
}
if (!peek)
{
peek = put;
}*/
void push(DemuxerStream& stream, u32 sz, PesHeader& pes);
mem_ptr_t<CellDmuxAuInfo> info(put);
//if (fidMajor != 0xbd) LOG_WARNING(HLE, "es::finish(): (%s) size = 0x%x, info_addr=0x%x, pts = 0x%x",
//wxString(fidMajor == 0xbd ? "ATRAC3P Audio" : "Video AVC").wx_str(),
//(u32)info->auSize, put, (u32)info->ptsLower);
bool release();
u32 new_addr = a128(put + 128 + size);
put = ((new_addr + GetMaxAU()) > (memAddr + memSize))
? memAddr : new_addr;
bool peek(u32& out_data, bool no_ex, u32& out_spec, bool update_index);
size = 0;
put_count++;
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, "<<< es::finish(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
}
if (!entries.Push(addr))
{
LOG_ERROR(HLE, "es::finish() aborted (no space)");
}
}
void push(DemuxerStream& stream, u32 sz, PesHeader& pes)
{
std::lock_guard<std::mutex> lock(m_mutex);
if (is_full())
{
LOG_ERROR(HLE, "es::push(): buffer is full");
Emu.Pause();
return;
}
u32 data_addr = put + 128 + size;
size += sz;
memcpy(Memory + data_addr, Memory + stream.addr, sz);
stream.skip(sz);
mem_ptr_t<CellDmuxAuInfoEx> info(put);
info->auAddr = put + 128;
info->auSize = size;
if (pes.new_au)
{
info->dts.lower = (u32)pes.dts;
info->dts.upper = (u32)(pes.dts >> 32);
info->pts.lower = (u32)pes.pts;
info->pts.upper = (u32)(pes.pts >> 32);
info->isRap = false; // TODO: set valid value
info->reserved = 0;
info->userData = stream.userdata;
}
mem_ptr_t<CellDmuxPamfAuSpecificInfoAvc> tail(put + sizeof(CellDmuxAuInfoEx));
tail->reserved1 = 0;
mem_ptr_t<CellDmuxAuInfo> inf(put + 64);
inf->auAddr = put + 128;
inf->auSize = size;
if (pes.new_au)
{
inf->dtsLower = (u32)pes.dts;
inf->dtsUpper = (u32)(pes.dts >> 32);
inf->ptsLower = (u32)pes.pts;
inf->ptsUpper = (u32)(pes.pts >> 32);
inf->auMaxSize = 0; // ?????
inf->userData = stream.userdata;
}
}
bool release()
{
std::lock_guard<std::mutex> lock(m_mutex);
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, ">>> es::release(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
if (released >= put_count)
{
LOG_ERROR(HLE, "es::release(): buffer is empty");
return false;
}
u32 addr = entries.Peek();
mem_ptr_t<CellDmuxAuInfo> info(addr);
//if (fidMajor != 0xbd) LOG_WARNING(HLE, "es::release(): (%s) size = 0x%x, info = 0x%x, pts = 0x%x",
//wxString(fidMajor == 0xbd ? "ATRAC3P Audio" : "Video AVC").wx_str(), (u32)info->auSize, first, (u32)info->ptsLower);
if (released >= peek_count)
{
LOG_ERROR(HLE, "es::release(): buffer has not been seen yet");
return false;
}
/*u32 new_addr = a128(info.GetAddr() + 128 + info->auSize);
if (new_addr == put)
{
first = 0;
}
else if ((new_addr + GetMaxAU()) > (memAddr + memSize))
{
first = memAddr;
}
else
{
first = new_addr;
}*/
released++;
if (!entries.Pop(addr))
{
LOG_ERROR(HLE, "es::release(): entries.Pop() aborted (no entries found)");
return false;
}
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, "<<< es::release(): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", peek, first, put, size);
return true;
}
bool peek(u32& out_data, bool no_ex, u32& out_spec, bool update_index)
{
std::lock_guard<std::mutex> lock(m_mutex);
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, ">>> es::peek(%sAu%s): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", wxString(update_index ? "Get" : "Peek").wx_str(),
//wxString(no_ex ? "" : "Ex").wx_str(), peek, first, put, size);
if (peek_count >= put_count) return false;
if (peek_count < released)
{
LOG_ERROR(HLE, "es::peek(): sequence error: peek_count < released (peek_count=%d, released=%d)", peek_count, released);
Emu.Pause();
return false;
}
u32 addr = entries.Peek(peek_count - released);
mem_ptr_t<CellDmuxAuInfo> info(addr);
//if (fidMajor != 0xbd) LOG_WARNING(HLE, "es::peek(%sAu(Ex)): (%s) size = 0x%x, info = 0x%x, pts = 0x%x",
//wxString(update_index ? "Get" : "Peek").wx_str(),
//wxString(fidMajor == 0xbd ? "ATRAC3P Audio" : "Video AVC").wx_str(), (u32)info->auSize, peek, (u32)info->ptsLower);
out_data = addr;
out_spec = out_data + sizeof(CellDmuxAuInfoEx);
if (no_ex) out_data += 64;
if (update_index)
{
/*u32 new_addr = a128(peek + 128 + info->auSize);
if (new_addr == put)
{
peek = 0;
}
else if ((new_addr + GetMaxAU()) > (memAddr + memSize))
{
peek = memAddr;
}
else
{
peek = new_addr;
}*/
peek_count++;
}
//if (fidMajor != 0xbd) LOG_NOTICE(HLE, "<<< es::peek(%sAu%s): peek=0x%x, first=0x%x, put=0x%x, size=0x%x", wxString(update_index ? "Get" : "Peek").wx_str(),
//wxString(no_ex ? "" : "Ex").wx_str(), peek, first, put, size);
return true;
}
void reset()
{
std::lock_guard<std::mutex> lock(m_mutex);
//first = 0;
//peek = 0;
put = memAddr;
size = 0;
entries.Clear();
put_count = 0;
released = 0;
peek_count = 0;
}
void reset();
};

View File

@ -1,12 +1,10 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
#include "stblib/stb_truetype.h"
#include "Emu/FS/vfsFile.h"
#include "cellFont.h"
#include "stblib/stb_truetype.h"
//void cellFont_init();
//void cellFont_load();
@ -14,224 +12,6 @@
//Module cellFont(0x0019, cellFont_init, cellFont_load, cellFont_unload);
Module *cellFont = nullptr;
// Font Set Types
enum
{
CELL_FONT_TYPE_RODIN_SANS_SERIF_LATIN = 0x00000000,
CELL_FONT_TYPE_RODIN_SANS_SERIF_LIGHT_LATIN = 0x00000001,
CELL_FONT_TYPE_RODIN_SANS_SERIF_BOLD_LATIN = 0x00000002,
CELL_FONT_TYPE_RODIN_SANS_SERIF_LATIN2 = 0x00000018,
CELL_FONT_TYPE_RODIN_SANS_SERIF_LIGHT_LATIN2 = 0x00000019,
CELL_FONT_TYPE_RODIN_SANS_SERIF_BOLD_LATIN2 = 0x0000001a,
CELL_FONT_TYPE_MATISSE_SERIF_LATIN = 0x00000020,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_JAPANESE = 0x00000008,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_LIGHT_JAPANESE = 0x00000009,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_BOLD_JAPANESE = 0x0000000a,
CELL_FONT_TYPE_YD_GOTHIC_KOREAN = 0x0000000c,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_LATIN = 0x00000040,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_LATIN2 = 0x00000041,
CELL_FONT_TYPE_VAGR_SANS_SERIF_ROUND = 0x00000043,
CELL_FONT_TYPE_VAGR_SANS_SERIF_ROUND_LATIN2 = 0x00000044,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_JAPANESE = 0x00000048,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_JP_SET = 0x00000100,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_LATIN_SET = 0x00000101,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN_SET = 0x00000104,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN2_SET = 0x00000204,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN2_SET = 0x00000201,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_DFHEI5_SET = 0x00000108,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_DFHEI5_RODIN_SET = 0x00000109,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_DFHEI5_RODIN2_SET = 0x00000209,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_TCH_SET = 0x0000010a,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN_TCH_SET = 0x0000010b,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN2_TCH_SET = 0x0000020b,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_SCH_SET = 0x0000010c,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN_SCH_SET = 0x0000010d,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN2_SCH_SET = 0x0000020d,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_RSANS_SET = 0x00300104,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_RSANS_SET = 0x00300105,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_JP_SET = 0x00300107,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_YG_DFHEI5_RSANS_SET = 0x00300109,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_RSANS_SET = 0x0030010F,
CELL_FONT_TYPE_VAGR_SEURAT_CAPIE_MARU_GOTHIC_RSANS_SET = 0x00300124,
CELL_FONT_TYPE_VAGR_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_RSANS_SET = 0x00300129,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_LIGHT_SET = 0x00040100,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN_LIGHT_SET = 0x00040101,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN2_LIGHT_SET = 0x00040201,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN_LIGHT_SET = 0x00040104,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN2_LIGHT_SET = 0x00040204,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_BOLD_SET = 0x00070100,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN_BOLD_SET = 0x00070101,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN2_BOLD_SET = 0x00070201,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN_BOLD_SET = 0x00070104,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN2_BOLD_SET = 0x00070204,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_RSANS2_SET = 0x00300204,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_RSANS2_SET = 0x00300205,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_YG_DFHEI5_RSANS2_SET = 0x00300209,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_RSANS2_SET = 0x0030020F,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_VAGR2_SET = 0x00300229,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_VAGR2_SET = 0x00300224,
};
enum
{
CELL_FONT_MAP_FONT = 0,
CELL_FONT_MAP_UNICODE = 1,
};
struct CellFontConfig
{
struct {
be_t<u32> buffer_addr;
be_t<u32> size;
} FileCache;
be_t<u32> userFontEntryMax;
be_t<u32> userFontEntrys_addr;
be_t<u32> flags;
};
struct CellFontRenderer
{
void *systemReserved[64];
};
//Custom enum to determine the origin of a CellFont object
enum
{
CELL_FONT_OPEN_FONTSET,
CELL_FONT_OPEN_FONT_FILE,
CELL_FONT_OPEN_FONT_INSTANCE,
CELL_FONT_OPEN_MEMORY,
};
struct CellFont
{
//void* SystemReserved[64];
be_t<float> scale_x;
be_t<float> scale_y;
be_t<float> slant;
be_t<u32> renderer_addr;
stbtt_fontinfo stbfont;
be_t<u32> fontdata_addr;
be_t<u32> origin;
};
struct CellFontType
{
be_t<u32> type;
be_t<u32> map;
};
struct CellFontInitGraphicsConfigGcm
{
be_t<u32> configType;
struct {
be_t<u32> address;
be_t<u32> size;
} GraphicsMemory;
struct {
be_t<u32> address;
be_t<u32> size;
} MappedMainMemory;
struct {
be_t<s16> slotNumber;
be_t<s16> slotCount;
} VertexShader;
};
struct CellFontGraphics
{
u32 graphicsType;
u32 SystemClosed_addr;
};
struct CellFontHorizontalLayout
{
be_t<float> baseLineY;
be_t<float> lineHeight;
be_t<float> effectHeight;
};
struct CellFontVerticalLayout
{
be_t<float> baseLineX;
be_t<float> lineWidth;
be_t<float> effectWidth;
};
struct CellFontGlyphMetrics
{
be_t<float> width;
be_t<float> height;
struct {
be_t<float> bearingX;
be_t<float> bearingY;
be_t<float> advance;
} Horizontal;
struct {
be_t<float> bearingX;
be_t<float> bearingY;
be_t<float> advance;
} Vertical;
};
struct CellFontImageTransInfo
{
be_t<u32> Image_addr;
be_t<u32> imageWidthByte;
be_t<u32> imageWidth;
be_t<u32> imageHeight;
be_t<u32> Surface_addr;
be_t<u32> surfWidthByte;
};
struct CellFontRendererConfig
{
struct BufferingPolicy
{
be_t<u32> buffer;
be_t<u32> initSize;
be_t<u32> maxSize;
be_t<u32> expandSize;
be_t<u32> resetSize;
};
};
struct CellFontRenderSurface
{
be_t<u32> buffer_addr;
be_t<u32> widthByte;
be_t<u32> pixelSizeByte;
be_t<u32> width, height;
struct {
be_t<u32> x0, y0;
be_t<u32> x1, y1;
} Scissor;
};
// Internal Datatypes
struct CCellFontInternal //Module cellFont
{
u32 m_buffer_addr, m_buffer_size;
u32 m_userFontEntrys_addr, m_userFontEntryMax;
bool m_bInitialized;
bool m_bFontGcmInitialized;
CCellFontInternal()
: m_buffer_addr(0)
, m_buffer_size(0)
, m_bInitialized(false)
, m_bFontGcmInitialized(false)
{
}
};
CCellFontInternal* s_fontInternalInstance = nullptr;
// Functions
@ -295,7 +75,9 @@ int cellFontOpenFontMemory(mem_ptr_t<CellFontLibrary> library, u32 fontAddr, u32
if (!s_fontInternalInstance->m_bInitialized)
return CELL_FONT_ERROR_UNINITIALIZED;
if (!stbtt_InitFont(&(font->stbfont), (unsigned char*)Memory.VirtualToRealAddr(fontAddr), 0))
font->stbfont = (stbtt_fontinfo*)((u8*)&(font->stbfont) + sizeof(void*)); // hack: use next bytes of the struct
if (!stbtt_InitFont(font->stbfont, (unsigned char*)Memory.VirtualToRealAddr(fontAddr), 0))
return CELL_FONT_ERROR_FONT_OPEN_FAILED;
font->renderer_addr = 0;
@ -483,8 +265,8 @@ int cellFontGetHorizontalLayout(mem_ptr_t<CellFont> font, mem_ptr_t<CellFontHori
font.GetAddr(), layout.GetAddr());
int ascent, descent, lineGap;
float scale = stbtt_ScaleForPixelHeight(&(font->stbfont), font->scale_y);
stbtt_GetFontVMetrics(&(font->stbfont), &ascent, &descent, &lineGap);
float scale = stbtt_ScaleForPixelHeight(font->stbfont, font->scale_y);
stbtt_GetFontVMetrics(font->stbfont, &ascent, &descent, &lineGap);
layout->baseLineY = ascent * scale;
layout->lineHeight = (ascent-descent+lineGap) * scale;
@ -558,14 +340,14 @@ int cellFontRenderCharGlyphImage(mem_ptr_t<CellFont> font, u32 code, mem_ptr_t<C
// Render the character
int width, height, xoff, yoff;
float scale = stbtt_ScaleForPixelHeight(&(font->stbfont), font->scale_y);
unsigned char* box = stbtt_GetCodepointBitmap(&(font->stbfont), scale, scale, code, &width, &height, &xoff, &yoff);
float scale = stbtt_ScaleForPixelHeight(font->stbfont, font->scale_y);
unsigned char* box = stbtt_GetCodepointBitmap(font->stbfont, scale, scale, code, &width, &height, &xoff, &yoff);
if (!box) return CELL_OK;
// Get the baseLineY value
int baseLineY;
int ascent, descent, lineGap;
stbtt_GetFontVMetrics(&(font->stbfont), &ascent, &descent, &lineGap);
stbtt_GetFontVMetrics(font->stbfont, &ascent, &descent, &lineGap);
baseLineY = ascent * scale;
// Move the rendered character to the surface
@ -640,9 +422,9 @@ int cellFontGetCharGlyphMetrics(mem_ptr_t<CellFont> font, u32 code, mem_ptr_t<Ce
int x0, y0, x1, y1;
int advanceWidth, leftSideBearing;
float scale = stbtt_ScaleForPixelHeight(&(font->stbfont), font->scale_y);
stbtt_GetCodepointBox(&(font->stbfont), code, &x0, &y0, &x1, &y1);
stbtt_GetCodepointHMetrics(&(font->stbfont), code, &advanceWidth, &leftSideBearing);
float scale = stbtt_ScaleForPixelHeight(font->stbfont, font->scale_y);
stbtt_GetCodepointBox(font->stbfont, code, &x0, &y0, &x1, &y1);
stbtt_GetCodepointHMetrics(font->stbfont, code, &advanceWidth, &leftSideBearing);
// TODO: Add the rest of the information
metrics->width = (x1-x0) * scale;

View File

@ -44,4 +44,225 @@ struct CellFontMemoryInterface
//CellFontFreeCallback Free;
//CellFontReallocCallback Realloc;
//CellFontCallocCallback Calloc;
};
// Font Set Types
enum
{
CELL_FONT_TYPE_RODIN_SANS_SERIF_LATIN = 0x00000000,
CELL_FONT_TYPE_RODIN_SANS_SERIF_LIGHT_LATIN = 0x00000001,
CELL_FONT_TYPE_RODIN_SANS_SERIF_BOLD_LATIN = 0x00000002,
CELL_FONT_TYPE_RODIN_SANS_SERIF_LATIN2 = 0x00000018,
CELL_FONT_TYPE_RODIN_SANS_SERIF_LIGHT_LATIN2 = 0x00000019,
CELL_FONT_TYPE_RODIN_SANS_SERIF_BOLD_LATIN2 = 0x0000001a,
CELL_FONT_TYPE_MATISSE_SERIF_LATIN = 0x00000020,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_JAPANESE = 0x00000008,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_LIGHT_JAPANESE = 0x00000009,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_BOLD_JAPANESE = 0x0000000a,
CELL_FONT_TYPE_YD_GOTHIC_KOREAN = 0x0000000c,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_LATIN = 0x00000040,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_LATIN2 = 0x00000041,
CELL_FONT_TYPE_VAGR_SANS_SERIF_ROUND = 0x00000043,
CELL_FONT_TYPE_VAGR_SANS_SERIF_ROUND_LATIN2 = 0x00000044,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_JAPANESE = 0x00000048,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_JP_SET = 0x00000100,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_LATIN_SET = 0x00000101,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN_SET = 0x00000104,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN2_SET = 0x00000204,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN2_SET = 0x00000201,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_DFHEI5_SET = 0x00000108,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_DFHEI5_RODIN_SET = 0x00000109,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_DFHEI5_RODIN2_SET = 0x00000209,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_TCH_SET = 0x0000010a,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN_TCH_SET = 0x0000010b,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN2_TCH_SET = 0x0000020b,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_SCH_SET = 0x0000010c,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN_SCH_SET = 0x0000010d,
CELL_FONT_TYPE_DFHEI5_GOTHIC_YG_NEWRODIN_RODIN2_SCH_SET = 0x0000020d,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_RSANS_SET = 0x00300104,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_RSANS_SET = 0x00300105,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_JP_SET = 0x00300107,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_YG_DFHEI5_RSANS_SET = 0x00300109,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_RSANS_SET = 0x0030010F,
CELL_FONT_TYPE_VAGR_SEURAT_CAPIE_MARU_GOTHIC_RSANS_SET = 0x00300124,
CELL_FONT_TYPE_VAGR_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_RSANS_SET = 0x00300129,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_LIGHT_SET = 0x00040100,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN_LIGHT_SET = 0x00040101,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN2_LIGHT_SET = 0x00040201,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN_LIGHT_SET = 0x00040104,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN2_LIGHT_SET = 0x00040204,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_BOLD_SET = 0x00070100,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN_BOLD_SET = 0x00070101,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_YG_RODIN2_BOLD_SET = 0x00070201,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN_BOLD_SET = 0x00070104,
CELL_FONT_TYPE_NEWRODIN_GOTHIC_RODIN2_BOLD_SET = 0x00070204,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_RSANS2_SET = 0x00300204,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_RSANS2_SET = 0x00300205,
CELL_FONT_TYPE_SEURAT_MARU_GOTHIC_YG_DFHEI5_RSANS2_SET = 0x00300209,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_RSANS2_SET = 0x0030020F,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_YG_DFHEI5_VAGR2_SET = 0x00300229,
CELL_FONT_TYPE_SEURAT_CAPIE_MARU_GOTHIC_VAGR2_SET = 0x00300224,
};
enum
{
CELL_FONT_MAP_FONT = 0,
CELL_FONT_MAP_UNICODE = 1,
};
struct CellFontConfig
{
struct {
be_t<u32> buffer_addr;
be_t<u32> size;
} FileCache;
be_t<u32> userFontEntryMax;
be_t<u32> userFontEntrys_addr;
be_t<u32> flags;
};
struct CellFontRenderer
{
void *systemReserved[64];
};
//Custom enum to determine the origin of a CellFont object
enum
{
CELL_FONT_OPEN_FONTSET,
CELL_FONT_OPEN_FONT_FILE,
CELL_FONT_OPEN_FONT_INSTANCE,
CELL_FONT_OPEN_MEMORY,
};
struct stbtt_fontinfo;
struct CellFont
{
//void* SystemReserved[64];
be_t<float> scale_x;
be_t<float> scale_y;
be_t<float> slant;
be_t<u32> renderer_addr;
be_t<u32> fontdata_addr;
be_t<u32> origin;
stbtt_fontinfo* stbfont;
// hack: don't place anything after pointer
};
struct CellFontType
{
be_t<u32> type;
be_t<u32> map;
};
struct CellFontInitGraphicsConfigGcm
{
be_t<u32> configType;
struct {
be_t<u32> address;
be_t<u32> size;
} GraphicsMemory;
struct {
be_t<u32> address;
be_t<u32> size;
} MappedMainMemory;
struct {
be_t<s16> slotNumber;
be_t<s16> slotCount;
} VertexShader;
};
struct CellFontGraphics
{
u32 graphicsType;
u32 SystemClosed_addr;
};
struct CellFontHorizontalLayout
{
be_t<float> baseLineY;
be_t<float> lineHeight;
be_t<float> effectHeight;
};
struct CellFontVerticalLayout
{
be_t<float> baseLineX;
be_t<float> lineWidth;
be_t<float> effectWidth;
};
struct CellFontGlyphMetrics
{
be_t<float> width;
be_t<float> height;
struct {
be_t<float> bearingX;
be_t<float> bearingY;
be_t<float> advance;
} Horizontal;
struct {
be_t<float> bearingX;
be_t<float> bearingY;
be_t<float> advance;
} Vertical;
};
struct CellFontImageTransInfo
{
be_t<u32> Image_addr;
be_t<u32> imageWidthByte;
be_t<u32> imageWidth;
be_t<u32> imageHeight;
be_t<u32> Surface_addr;
be_t<u32> surfWidthByte;
};
struct CellFontRendererConfig
{
struct BufferingPolicy
{
be_t<u32> buffer;
be_t<u32> initSize;
be_t<u32> maxSize;
be_t<u32> expandSize;
be_t<u32> resetSize;
};
};
struct CellFontRenderSurface
{
be_t<u32> buffer_addr;
be_t<u32> widthByte;
be_t<u32> pixelSizeByte;
be_t<u32> width, height;
struct {
be_t<u32> x0, y0;
be_t<u32> x1, y1;
} Scissor;
};
// Internal Datatypes
struct CCellFontInternal //Module cellFont
{
u32 m_buffer_addr, m_buffer_size;
u32 m_userFontEntrys_addr, m_userFontEntryMax;
bool m_bInitialized;
bool m_bFontGcmInitialized;
CCellFontInternal()
: m_buffer_addr(0)
, m_buffer_size(0)
, m_bInitialized(false)
, m_bFontGcmInitialized(false)
{
}
};

View File

@ -1,9 +1,9 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellFont.h"
#include "cellFontFT.h"
//void cellFontFT_init();
//void cellFontFT_load();
@ -11,33 +11,6 @@
//Module cellFontFT(0x001a, cellFontFT_init, cellFontFT_load, cellFontFT_unload);
Module *cellFontFT = nullptr;
struct CellFontLibraryConfigFT
{
u32 library_addr; //void*
CellFontMemoryInterface MemoryIF;
};
struct CellFontRendererConfigFT
{
struct {
u32 buffer_addr; //void*
u32 initSize;
u32 maxSize;
u32 expandSize;
u32 resetSize;
} BufferingPolicy;
};
struct CCellFontFTInternal
{
bool m_bInitialized;
CCellFontFTInternal()
: m_bInitialized(false)
{
}
};
CCellFontFTInternal* s_fontFtInternalInstance = nullptr;
int cellFontInitLibraryFreeTypeWithRevision(u64 revisionFlags, mem_ptr_t<CellFontLibraryConfigFT> config, u32 lib_addr_addr)

View File

@ -0,0 +1,28 @@
#pragma once
struct CellFontLibraryConfigFT
{
u32 library_addr; //void*
CellFontMemoryInterface MemoryIF;
};
struct CellFontRendererConfigFT
{
struct {
u32 buffer_addr; //void*
u32 initSize;
u32 maxSize;
u32 expandSize;
u32 resetSize;
} BufferingPolicy;
};
struct CCellFontFTInternal
{
bool m_bInitialized;
CCellFontFTInternal()
: m_bInitialized(false)
{
}
};

View File

@ -1,13 +1,11 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rMsgBox.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Utilities/rMsgBox.h"
#include "Emu/FS/vfsFile.h"
#include "Loader/PSF.h"
#include "cellGame.h"
//void cellGame_init();

View File

@ -1,11 +1,10 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/RSX/GCM.h"
#include "Emu/SysCalls/lv2/sys_process.h"
#include "sysPrxForUser.h"
//#include "Emu/RSX/GCM.h"
//#include "Emu/SysCalls/lv2/sys_process.h"
#include "cellGcmSys.h"
//void cellGcmSys_init();
@ -487,7 +486,7 @@ s32 cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id)
if(current + 8 >= end)
{
LOG_WARNING(HLE, "bad flip!");
cellGcmSys->Error("bad flip!");
//cellGcmCallback(ctxt.GetAddr(), current + 8 - end);
//copied:

View File

@ -1,6 +1,6 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/SysCalls/Modules.h"
#include "cellGem.h"
void cellGem_init();

View File

@ -1,13 +1,11 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellGifDec.h"
#include "Emu/SysCalls/lv2/lv2Fs.h"
#include "stblib/stb_image.h"
#include "stblib/stb_image.c" // (TODO: Should we put this elsewhere?)
#include "Emu/SysCalls/lv2/lv2Fs.h"
#include "cellGifDec.h"
//void cellGifDec_init();
//Module cellGifDec(0xf010, cellGifDec_init);
@ -269,7 +267,7 @@ int cellGifDecClose(u32 mainHandle, u32 subHandle)
return CELL_GIFDEC_ERROR_FATAL;
cellFsClose(subHandle_data->fd);
Emu.GetIdManager().RemoveID(subHandle);
cellGifDec->RemoveId(subHandle);
return CELL_OK;
}

View File

@ -1,6 +1,5 @@
#pragma once
//Return Codes
enum
{

View File

@ -1,11 +1,10 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellJpgDec.h"
#include "stblib/stb_image.h"
#include "Emu/SysCalls/lv2/lv2Fs.h"
#include "cellJpgDec.h"
//void cellJpgDec_init();
//Module cellJpgDec(0x000f, cellJpgDec_init);
@ -76,7 +75,7 @@ int cellJpgDecClose(u32 mainHandle, u32 subHandle)
return CELL_JPGDEC_ERROR_FATAL;
cellFsClose(subHandle_data->fd);
Emu.GetIdManager().RemoveID(subHandle);
cellJpgDec->RemoveId(subHandle);
return CELL_OK;
}

View File

@ -1,8 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellL10n.h"
#include <stdio.h>
#include <stdlib.h>
@ -286,9 +285,9 @@ int _L10nConvertStr(int src_code, const void* src, size_t * src_len, int dst_cod
//TODO: Check the code in emulation. If support for UTF8/UTF16/UTF32/UCS2/UCS4 should use wider chars.. awful.
int L10nConvertStr(int src_code, mem8_ptr_t src, mem64_t src_len, int dst_code, mem8_ptr_t dst, mem64_t dst_len)
{
LOG_ERROR(HLE, "L10nConvertStr(src_code=%d,src=0x%x,src_len=%ld,dst_code=%d,dst=0x%x,dst_len=%ld)",
cellL10n->Todo("L10nConvertStr(src_code=%d,src=0x%x,src_len=%ld,dst_code=%d,dst=0x%x,dst_len=%ld)",
src_code, src.GetAddr(), src_len.GetValue(), dst_code, dst.GetAddr(), dst_len.GetValue());
LOG_ERROR(HLE, "L10nConvertStr: 1st char at dst: %x(Hex)", *((char*)Memory.VirtualToRealAddr(src.GetAddr())));
cellL10n->Todo("L10nConvertStr: 1st char at dst: %x(Hex)", *((char*)Memory.VirtualToRealAddr(src.GetAddr())));
#ifdef _MSC_VER
unsigned int srcCode = 0, dstCode = 0; //OEM code pages
bool src_page_converted = _L10nCodeParse(src_code, srcCode); //Check if code is in list.

View File

@ -1,12 +1,11 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rMsgBox.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/lv2/sys_time.h"
#include "rpcs3.h"
#include "rpcs3.h"
#include "Utilities/rMsgBox.h"
#include "Emu/SysCalls/lv2/sys_time.h"
#include "cellSysutil.h"
#include "cellMsgDialog.h"
@ -46,8 +45,8 @@ int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<Ce
{
switch (type & CELL_MSGDIALOG_TYPE_SE_TYPE)
{
case CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL: LOG_WARNING(Log::HLE, "%s", msgString.GetString()); break;
case CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR: LOG_ERROR(Log::HLE, "%s", msgString.GetString()); break;
case CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL: cellSysutil->Warning("Message: \n%s", msgString.GetString()); break;
case CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR: cellSysutil->Error("Message: \n%s", msgString.GetString()); break;
}
switch (type & CELL_MSGDIALOG_TYPE_SE_MUTE) // TODO
@ -361,7 +360,7 @@ int cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, mem_list_ptr_t<u8> msgS
return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
}
if (progressBarIndex >= (u32)(bool)m_gauge1 + (u32)(bool)m_gauge2)
if (progressBarIndex >= (m_gauge1 ? 1u : 0u) + (m_gauge2 ? 1u : 0u))
{
return CELL_MSGDIALOG_ERROR_PARAM;
}
@ -390,7 +389,7 @@ int cellMsgDialogProgressBarReset(u32 progressBarIndex)
return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
}
if (progressBarIndex >= (u32)(bool)m_gauge1 + (u32)(bool)m_gauge2)
if (progressBarIndex >= (m_gauge1 ? 1u : 0u) + (m_gauge2 ? 1u : 0u))
{
return CELL_MSGDIALOG_ERROR_PARAM;
}
@ -415,7 +414,7 @@ int cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta)
return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
}
if (progressBarIndex >= (u32)(bool)m_gauge1 + (u32)(bool)m_gauge2)
if (progressBarIndex >= (m_gauge1 ? 1u : 0u) + (m_gauge2 ? 1u : 0u))
{
return CELL_MSGDIALOG_ERROR_PARAM;
}

View File

@ -1,7 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellNetCtl.h"

View File

@ -1,8 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellPamf.h"
Module *cellPamf = nullptr;

View File

@ -1,11 +1,10 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellPngDec.h"
#include "stblib/stb_image.h"
#include "Emu/SysCalls/lv2/lv2Fs.h"
#include "cellPngDec.h"
#include <map>
//void cellPngDec_init();
@ -114,7 +113,7 @@ int cellPngDecClose(u32 mainHandle, u32 subHandle)
return CELL_PNGDEC_ERROR_FATAL;
cellFsClose(subHandle_data->fd);
Emu.GetIdManager().RemoveID(subHandle);
cellPngDec->RemoveId(subHandle);
return CELL_OK;
}

View File

@ -1,8 +1,8 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellSysutil.h"
#include "Emu/RSX/sysutil_video.h"
#include "cellResc.h"

View File

@ -1,9 +1,8 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rTime.h"
#include "Emu/Memory/Memory.h"
#include "Emu/SysCalls/Modules.h"
#include "Utilities/rTime.h"
#include "cellRtc.h"
//void cellRtc_init();

View File

@ -1,7 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellSail.h"

View File

@ -1,9 +1,8 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/Cell/SPURSManager.h"
#include "cellSpurs.h"
//void cellSpurs_init();
@ -258,10 +257,10 @@ s32 cellSpursEnableExceptionEventHandler(mem_ptr_t<CellSpurs> spurs, bool flag)
#endif
}
s32 cellSpursSetGlobalExceptionEventHandler(mem_ptr_t<CellSpurs> spurs, mem_func_ptr_t<CellSpursGlobalExceptionEventHandler> eaHandler, u32 arg_addr)
s32 cellSpursSetGlobalExceptionEventHandler(mem_ptr_t<CellSpurs> spurs, u32 eaHandler_addr, u32 arg_addr)
{
cellSpurs->Warning("cellSpursSetGlobalExceptionEventHandler(spurs_addr=0x%x, eaHandler_addr=0x%x, arg_addr=0x%x,)",
spurs.GetAddr(), eaHandler.GetAddr(), arg_addr);
cellSpurs->Warning("cellSpursSetGlobalExceptionEventHandler(spurs_addr=0x%x, eaHandler_addr=0x%x, arg_addr=0x%x)",
spurs.GetAddr(), eaHandler_addr, arg_addr);
#ifdef PRX_DEBUG
return GetCurrentPPUThread().FastCall2(libsre + 0xD6D0, libsre_rtoc);

View File

@ -1,5 +1,4 @@
#pragma once
#include "Emu/Cell/SPURSManager.h"
// Core return codes.
enum
@ -33,6 +32,55 @@ enum
CELL_SPURS_TASK_ERROR_SHUTDOWN = 0x80410920,
};
// SPURS defines.
enum SPURSKernelInterfaces
{
CELL_SPURS_MAX_SPU = 8,
CELL_SPURS_MAX_WORKLOAD = 16,
CELL_SPURS_MAX_WORKLOAD2 = 32,
CELL_SPURS_MAX_PRIORITY = 16,
CELL_SPURS_NAME_MAX_LENGTH = 15,
CELL_SPURS_SIZE = 4096,
CELL_SPURS_SIZE2 = 8192,
CELL_SPURS_ALIGN = 128,
CELL_SPURS_ATTRIBUTE_SIZE = 512,
CELL_SPURS_ATTRIBUTE_ALIGN = 8,
CELL_SPURS_INTERRUPT_VECTOR = 0x0,
CELL_SPURS_LOCK_LINE = 0x80,
CELL_SPURS_KERNEL_DMA_TAG_ID = 31,
};
enum RangeofEventQueuePortNumbers
{
CELL_SPURS_STATIC_PORT_RANGE_BOTTOM = 15,
CELL_SPURS_DYNAMIC_PORT_RANGE_TOP = 16,
CELL_SPURS_DYNAMIC_PORT_RANGE_BOTTOM = 63,
};
enum SPURSTraceTypes
{
CELL_SPURS_TRACE_TAG_LOAD = 0x2a,
CELL_SPURS_TRACE_TAG_MAP = 0x2b,
CELL_SPURS_TRACE_TAG_START = 0x2c,
CELL_SPURS_TRACE_TAG_STOP = 0x2d,
CELL_SPURS_TRACE_TAG_USER = 0x2e,
CELL_SPURS_TRACE_TAG_GUID = 0x2f,
};
// SPURS task defines.
enum TaskConstants
{
CELL_SPURS_MAX_TASK = 128,
CELL_SPURS_TASK_TOP = 0x3000,
CELL_SPURS_TASK_BOTTOM = 0x40000,
CELL_SPURS_MAX_TASK_NAME_LENGTH = 32,
};
class SPURSManager;
class SPURSManagerAttribute;
class SPURSManagerEventFlag;
class SPURSManagerTaskset;
// Core CellSpurs structures.
struct CellSpurs
{
@ -146,11 +194,11 @@ struct CellSpursTracePacket
};
// Exception handlers.
typedef void (*CellSpursGlobalExceptionEventHandler)(mem_ptr_t<CellSpurs> spurs, const mem_ptr_t<CellSpursExceptionInfo> info,
u32 id, mem_ptr_t<void> arg);
typedef void (*CellSpursTasksetExceptionEventHandler)(mem_ptr_t<CellSpurs> spurs, mem_ptr_t<CellSpursTaskset> taskset,
u32 idTask, const mem_ptr_t<CellSpursExceptionInfo> info, mem_ptr_t<void> arg);
//typedef void (*CellSpursGlobalExceptionEventHandler)(mem_ptr_t<CellSpurs> spurs, const mem_ptr_t<CellSpursExceptionInfo> info,
// u32 id, mem_ptr_t<void> arg);
//
//typedef void (*CellSpursTasksetExceptionEventHandler)(mem_ptr_t<CellSpurs> spurs, mem_ptr_t<CellSpursTaskset> taskset,
// u32 idTask, const mem_ptr_t<CellSpursExceptionInfo> info, mem_ptr_t<void> arg);
struct CellSpursTasksetInfo
{
@ -159,7 +207,7 @@ struct CellSpursTasksetInfo
be_t<u32> idWorkload;
be_t<u32> idLastScheduledTask; //typedef unsigned CellSpursTaskId
be_t<u32> name_addr;
CellSpursTasksetExceptionEventHandler exceptionEventHandler;
be_t<u32> exceptionEventHandler_addr;
be_t<u32> exceptionEventHandlerArgument_addr; //void *exceptionEventHandlerArgument
be_t<u64> sizeTaskset;
//be_t<u8> reserved[];

View File

@ -1,11 +1,10 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/lv2/sys_process.h"
#include "Emu/Event.h"
#include "cellSync.h"
//void cellSync_init();
@ -90,7 +89,7 @@ s32 cellSyncMutexLock(mem_ptr_t<CellSyncMutex> mutex)
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellSyncMutexLock(mutex_addr=0x%x) aborted", mutex.GetAddr());
cellSync->Warning("cellSyncMutexLock(mutex_addr=0x%x) aborted", mutex.GetAddr());
break;
}
}
@ -219,7 +218,7 @@ s32 cellSyncBarrierNotify(mem_ptr_t<CellSyncBarrier> barrier)
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellSyncBarrierNotify(barrier_addr=0x%x) aborted", barrier.GetAddr());
cellSync->Warning("cellSyncBarrierNotify(barrier_addr=0x%x) aborted", barrier.GetAddr());
return CELL_OK;
}
continue;
@ -306,7 +305,7 @@ s32 cellSyncBarrierWait(mem_ptr_t<CellSyncBarrier> barrier)
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellSyncBarrierWait(barrier_addr=0x%x) aborted", barrier.GetAddr());
cellSync->Warning("cellSyncBarrierWait(barrier_addr=0x%x) aborted", barrier.GetAddr());
return CELL_OK;
}
continue;
@ -1039,10 +1038,10 @@ s32 cellSyncQueueClear(mem_ptr_t<CellSyncQueue> queue)
void syncLFQueueDump(mem_ptr_t<CellSyncLFQueue> queue)
{
LOG_NOTICE(HLE, "CellSyncLFQueue dump: addr = 0x%x", queue.GetAddr());
cellSync->Notice("CellSyncLFQueue dump: addr = 0x%x", queue.GetAddr());
for (u32 i = 0; i < sizeof(CellSyncLFQueue) / 16; i++)
{
LOG_NOTICE(HLE, "*** 0x%.16llx 0x%.16llx", Memory.Read64(queue.GetAddr() + i * 16), Memory.Read64(queue.GetAddr() + i * 16 + 8));
cellSync->Notice("*** 0x%.16llx 0x%.16llx", Memory.Read64(queue.GetAddr() + i * 16), Memory.Read64(queue.GetAddr() + i * 16 + 8));
}
}
@ -2309,7 +2308,7 @@ void cellSync_init()
}
else
{
LOG_NOTICE(HLE, "libsre: 0x%x : 0x%llx", i - libsre, flag);
cellSync->Notice("libsre: 0x%x : 0x%llx", i - libsre, flag);
}
}
});

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/ModuleManager.h"

View File

@ -1,20 +1,18 @@
#include "stdafx.h"
#include "rpcs3/Ini.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/DbgCommand.h"
#include "Emu/FS/vfsFile.h"
#include "Emu/Audio/sysutil_audio.h"
#include "cellSysutil.h"
#include "cellSysutil_SaveData.h"
#include "rpcs3/Ini.h"
#include "Emu/FS/vfsFile.h"
#include "Loader/PSF.h"
#include "Emu/Audio/sysutil_audio.h"
#include "Emu/RSX/sysutil_video.h"
#include "cellMsgDialog.h"
#include "cellGame.h"
#include "Loader/PSF.h"
#include "cellSysutil.h"
#include "cellSysutil_SaveData.h"
typedef void (*CellHddGameStatCallback)(mem_ptr_t<CellHddGameCBResult> cbResult, mem_ptr_t<CellHddGameStatGet> get, mem_ptr_t<CellHddGameStatSet> set);
@ -329,7 +327,7 @@ int cellSysutilCheckCallback()
std::this_thread::sleep_for(std::chrono::milliseconds(1));
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellSysutilCheckCallback() aborted");
cellSysutil->Warning("cellSysutilCheckCallback() aborted");
break;
}
}

View File

@ -1,7 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
//void cellSysutilAp_init();

View File

@ -1,14 +1,13 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/vfsFile.h"
#include "Emu/FS/vfsDir.h"
#include <algorithm>
#include "cellSysutil_SaveData.h"
#include "Loader/PSF.h"
#include "cellSysutil_SaveData.h"
#include <algorithm>
extern Module *cellSysutil;
@ -228,7 +227,7 @@ s32 modifySaveDataFiles(mem_func_ptr_t<CellSaveDataFileCallback>& funcFile, mem_
{
funcFile(result.GetAddr(), fileGet.GetAddr(), fileSet.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "modifySaveDataFiles: CellSaveDataFileCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("modifySaveDataFiles: CellSaveDataFileCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
if (result->result == CELL_SAVEDATA_CBRESULT_OK_LAST) {
@ -249,7 +248,7 @@ s32 modifySaveDataFiles(mem_func_ptr_t<CellSaveDataFileCallback>& funcFile, mem_
case CELL_SAVEDATA_FILETYPE_CONTENT_SND0: filepath += "SND0.AT3"; break;
default:
LOG_ERROR(HLE, "modifySaveDataFiles: Unknown fileType! Aborting...");
cellSysutil->Error("modifySaveDataFiles: Unknown fileType! Aborting...");
return CELL_SAVEDATA_ERROR_PARAM;
}
@ -272,11 +271,11 @@ s32 modifySaveDataFiles(mem_func_ptr_t<CellSaveDataFileCallback>& funcFile, mem_
break;
case CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC:
LOG_WARNING(HLE, "modifySaveDataFiles: File operation CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC not yet implemented");
cellSysutil->Warning("modifySaveDataFiles: File operation CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC not yet implemented");
break;
default:
LOG_ERROR(HLE, "modifySaveDataFiles: Unknown fileOperation! Aborting...");
cellSysutil->Error("modifySaveDataFiles: Unknown fileOperation! Aborting...");
return CELL_SAVEDATA_ERROR_PARAM;
}
@ -334,7 +333,7 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, m
funcList(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataListSave2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("cellSaveDataListSave2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
@ -342,7 +341,7 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, m
if (listSet->newData.GetAddr())
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr());
if (saveEntries.size() == 0) {
LOG_WARNING(HLE, "cellSaveDataListSave2: No save entries found!"); // TODO: Find a better way to handle this error
cellSysutil->Warning("cellSaveDataListSave2: No save entries found!"); // TODO: Find a better way to handle this error
return CELL_SAVEDATA_RET_OK;
}
@ -355,7 +354,7 @@ int cellSaveDataListSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, m
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
Memory.Free(statGet->fileList.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
@ -414,7 +413,7 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, m
funcList(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataListLoad2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
@ -422,7 +421,7 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, m
if (listSet->newData.GetAddr())
addNewSaveDataEntry(saveEntries, (u32)listSet->newData.GetAddr());
if (saveEntries.size() == 0) {
LOG_WARNING(HLE, "cellSaveDataListLoad2: No save entries found!"); // TODO: Find a better way to handle this error
cellSysutil->Warning("cellSaveDataListLoad2: No save entries found!"); // TODO: Find a better way to handle this error
return CELL_SAVEDATA_RET_OK;
}
@ -435,7 +434,7 @@ int cellSaveDataListLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, m
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
Memory.Free(statGet->fileList.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("cellSaveDataListLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
@ -493,7 +492,7 @@ int cellSaveDataFixedSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList,
}
funcFixed(result.GetAddr(), listGet.GetAddr(), fixedSet.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataFixedSave2: CellSaveDataFixedCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("cellSaveDataFixedSave2: CellSaveDataFixedCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
setSaveDataFixed(saveEntries, fixedSet.GetAddr());
@ -504,7 +503,7 @@ int cellSaveDataFixedSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList,
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
Memory.Free(statGet->fileList.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataFixedSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("cellSaveDataFixedSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
@ -562,7 +561,7 @@ int cellSaveDataFixedLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList,
}
funcFixed(result.GetAddr(), listGet.GetAddr(), fixedSet.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataFixedLoad2: CellSaveDataFixedCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("cellSaveDataFixedLoad2: CellSaveDataFixedCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
setSaveDataFixed(saveEntries, fixedSet.GetAddr());
@ -573,7 +572,7 @@ int cellSaveDataFixedLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList,
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
Memory.Free(statGet->fileList.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataFixedLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("cellSaveDataFixedLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
@ -626,7 +625,7 @@ int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_
Memory.Free(statGet->fileList.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataAutoSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("cellSaveDataAutoSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())
@ -666,7 +665,7 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_
// The target entry does not exist
if (saveEntries.size() == 0) {
LOG_WARNING(HLE, "cellSaveDataAutoLoad2: Couldn't find save entry (%s)", dirName.c_str());
cellSysutil->Warning("cellSaveDataAutoLoad2: Couldn't find save entry (%s)", dirName.c_str());
return CELL_OK; // TODO: Can anyone check the actual behaviour of a PS3 when saves are not found?
}
@ -676,7 +675,7 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_
Memory.Free(statGet->fileList.GetAddr());
if (result->result < 0) {
LOG_ERROR(HLE, "cellSaveDataAutoLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
cellSysutil->Error("cellSaveDataAutoLoad2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message.
return CELL_SAVEDATA_ERROR_CBRESULT;
}
/*if (statSet->setParam.GetAddr())

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"

View File

@ -1,9 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "cellPamf.h"
std::mutex g_mutex_avcodec_open2;
@ -14,12 +12,77 @@ extern "C"
#include "libavutil/imgutils.h"
}
#include "cellPamf.h"
#include "cellVdec.h"
//void cellVdec_init();
//Module cellVdec(0x0005, cellVdec_init);
Module *cellVdec = nullptr;
VideoDecoder::VideoDecoder(CellVdecCodecType type, u32 profile, u32 addr, u32 size, u32 func, u32 arg)
: type(type)
, profile(profile)
, memAddr(addr)
, memSize(size)
, memBias(0)
, cbFunc(func)
, cbArg(arg)
, is_finished(false)
, is_running(false)
, just_started(false)
, just_finished(false)
, ctx(nullptr)
, vdecCb(nullptr)
{
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_H264);
if (!codec)
{
cellVdec->Error("VideoDecoder(): avcodec_find_decoder(H264) failed");
Emu.Pause();
return;
}
fmt = avformat_alloc_context();
if (!fmt)
{
cellVdec->Error("VideoDecoder(): avformat_alloc_context failed");
Emu.Pause();
return;
}
io_buf = (u8*)av_malloc(4096);
fmt->pb = avio_alloc_context(io_buf, 4096, 0, this, vdecRead, NULL, NULL);
if (!fmt->pb)
{
cellVdec->Error("VideoDecoder(): avio_alloc_context failed");
Emu.Pause();
return;
}
}
VideoDecoder::~VideoDecoder()
{
// TODO: check finalization
if (ctx)
{
for (u32 i = frames.GetCount() - 1; ~i; i--)
{
VdecFrame& vf = frames.Peek(i);
av_frame_unref(vf.data);
av_frame_free(&vf.data);
}
avcodec_close(ctx);
avformat_close_input(&fmt);
}
if (fmt)
{
if (io_buf)
{
av_free(io_buf);
}
if (fmt->pb) av_free(fmt->pb);
avformat_free_context(fmt);
}
}
int vdecRead(void* opaque, u8* buf, int buf_size)
{
VideoDecoder& vdec = *(VideoDecoder*)opaque;
@ -33,7 +96,7 @@ next:
{
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "vdecRead(): aborted");
cellVdec->Warning("vdecRead(): aborted");
return 0;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
@ -69,7 +132,7 @@ next:
}
break;
default:
LOG_ERROR(HLE, "vdecRead(): sequence error (task %d)", vdec.job.Peek().type);
cellVdec->Error("vdecRead(): sequence error (task %d)", vdec.job.Peek().type);
return 0;
}
@ -126,7 +189,7 @@ u32 vdecOpen(VideoDecoder* data)
thread t("Video Decoder[" + std::to_string(vdec_id) + "] Thread", [&]()
{
LOG_NOTICE(HLE, "Video Decoder thread started");
cellVdec->Notice("Video Decoder thread started");
VdecTask& task = vdec.task;
@ -157,257 +220,257 @@ u32 vdecOpen(VideoDecoder* data)
switch (task.type)
{
case vdecStartSeq:
{
// TODO: reset data
LOG_WARNING(HLE, "vdecStartSeq:");
{
// TODO: reset data
cellVdec->Warning("vdecStartSeq:");
vdec.reader.addr = 0;
vdec.reader.size = 0;
vdec.is_running = true;
vdec.just_started = true;
}
break;
vdec.reader.addr = 0;
vdec.reader.size = 0;
vdec.is_running = true;
vdec.just_started = true;
}
break;
case vdecEndSeq:
{
// TODO: finalize
LOG_WARNING(HLE, "vdecEndSeq:");
{
// TODO: finalize
cellVdec->Warning("vdecEndSeq:");
vdec.vdecCb->ExecAsCallback(vdec.cbFunc, false, vdec.id, CELL_VDEC_MSG_TYPE_SEQDONE, CELL_OK, vdec.cbArg);
/*Callback cb;
cb.SetAddr(vdec.cbFunc);
cb.Handle(vdec.id, CELL_VDEC_MSG_TYPE_SEQDONE, CELL_OK, vdec.cbArg);
cb.Branch(true); // ???*/
vdec.vdecCb->ExecAsCallback(vdec.cbFunc, false, vdec.id, CELL_VDEC_MSG_TYPE_SEQDONE, CELL_OK, vdec.cbArg);
/*Callback cb;
cb.SetAddr(vdec.cbFunc);
cb.Handle(vdec.id, CELL_VDEC_MSG_TYPE_SEQDONE, CELL_OK, vdec.cbArg);
cb.Branch(true); // ???*/
vdec.is_running = false;
vdec.just_finished = true;
}
break;
vdec.is_running = false;
vdec.just_finished = true;
}
break;
case vdecDecodeAu:
{
int err;
{
int err;
if (task.mode != CELL_VDEC_DEC_MODE_NORMAL)
if (task.mode != CELL_VDEC_DEC_MODE_NORMAL)
{
cellVdec->Error("vdecDecodeAu: unsupported decoding mode(%d)", task.mode);
break;
}
vdec.reader.addr = task.addr;
vdec.reader.size = task.size;
//LOG_NOTICE(HLE, "Video AU: size = 0x%x, pts = 0x%llx, dts = 0x%llx", task.size, task.pts, task.dts);
if (vdec.just_started)
{
vdec.first_pts = task.pts;
vdec.last_pts = task.pts;
vdec.first_dts = task.dts;
}
struct AVPacketHolder : AVPacket
{
AVPacketHolder(u32 size)
{
LOG_ERROR(HLE, "vdecDecodeAu: unsupported decoding mode(%d)", task.mode);
av_init_packet(this);
if (size)
{
data = (u8*)av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
this->size = size + FF_INPUT_BUFFER_PADDING_SIZE;
}
else
{
data = NULL;
size = 0;
}
}
~AVPacketHolder()
{
av_free(data);
//av_free_packet(this);
}
} au(0);
if (vdec.just_started && vdec.just_finished)
{
avcodec_flush_buffers(vdec.ctx);
vdec.just_started = false;
vdec.just_finished = false;
}
else if (vdec.just_started) // deferred initialization
{
err = avformat_open_input(&vdec.fmt, NULL, av_find_input_format("mpeg"), NULL);
if (err)
{
cellVdec->Error("vdecDecodeAu: avformat_open_input() failed");
Emu.Pause();
break;
}
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_H264); // ???
if (!codec)
{
cellVdec->Error("vdecDecodeAu: avcodec_find_decoder() failed");
Emu.Pause();
break;
}
/*err = avformat_find_stream_info(vdec.fmt, NULL);
if (err)
{
LOG_ERROR(HLE, "vdecDecodeAu: avformat_find_stream_info() failed");
Emu.Pause();
break;
}
if (!vdec.fmt->nb_streams)
{
LOG_ERROR(HLE, "vdecDecodeAu: no stream found");
Emu.Pause();
break;
}*/
if (!avformat_new_stream(vdec.fmt, codec))
{
cellVdec->Error("vdecDecodeAu: avformat_new_stream() failed");
Emu.Pause();
break;
}
vdec.ctx = vdec.fmt->streams[0]->codec; // TODO: check data
AVDictionary* opts = nullptr;
av_dict_set(&opts, "refcounted_frames", "1", 0);
{
std::lock_guard<std::mutex> lock(g_mutex_avcodec_open2);
// not multithread-safe (???)
err = avcodec_open2(vdec.ctx, codec, &opts);
}
if (err)
{
cellVdec->Error("vdecDecodeAu: avcodec_open2() failed");
Emu.Pause();
break;
}
vdec.just_started = false;
}
bool last_frame = false;
while (true)
{
if (Emu.IsStopped() || vdec.job.PeekIfExist().type == vdecClose)
{
vdec.is_finished = true;
cellVdec->Warning("vdecDecodeAu: aborted");
return;
}
last_frame = av_read_frame(vdec.fmt, &au) < 0;
if (last_frame)
{
//break;
av_free(au.data);
au.data = NULL;
au.size = 0;
}
struct VdecFrameHolder : VdecFrame
{
VdecFrameHolder()
{
data = av_frame_alloc();
}
~VdecFrameHolder()
{
if (data)
{
av_frame_unref(data);
av_frame_free(&data);
}
}
} frame;
if (!frame.data)
{
cellVdec->Error("vdecDecodeAu: av_frame_alloc() failed");
Emu.Pause();
break;
}
vdec.reader.addr = task.addr;
vdec.reader.size = task.size;
//LOG_NOTICE(HLE, "Video AU: size = 0x%x, pts = 0x%llx, dts = 0x%llx", task.size, task.pts, task.dts);
int got_picture = 0;
if (vdec.just_started)
int decode = avcodec_decode_video2(vdec.ctx, frame.data, &got_picture, &au);
if (decode <= 0)
{
vdec.first_pts = task.pts;
vdec.last_pts = task.pts;
vdec.first_dts = task.dts;
if (!last_frame && decode < 0)
{
cellVdec->Error("vdecDecodeAu: AU decoding error(0x%x)", decode);
}
if (!got_picture && vdec.reader.size == 0) break; // video end?
}
struct AVPacketHolder : AVPacket
if (got_picture)
{
AVPacketHolder(u32 size)
u64 ts = av_frame_get_best_effort_timestamp(frame.data);
if (ts != AV_NOPTS_VALUE)
{
av_init_packet(this);
if (size)
{
data = (u8*)av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
this->size = size + FF_INPUT_BUFFER_PADDING_SIZE;
}
else
{
data = NULL;
size = 0;
}
frame.pts = ts/* - vdec.first_pts*/; // ???
vdec.last_pts = frame.pts;
}
~AVPacketHolder()
else
{
av_free(data);
//av_free_packet(this);
vdec.last_pts += vdec.ctx->time_base.num * 90000 / (vdec.ctx->time_base.den / vdec.ctx->ticks_per_frame);
frame.pts = vdec.last_pts;
}
//frame.pts = vdec.last_pts;
//vdec.last_pts += 3754;
frame.dts = (frame.pts - vdec.first_pts) + vdec.first_dts;
frame.userdata = task.userData;
} au(0);
//LOG_NOTICE(HLE, "got picture (pts=0x%llx, dts=0x%llx)", frame.pts, frame.dts);
if (vdec.just_started && vdec.just_finished)
{
avcodec_flush_buffers(vdec.ctx);
vdec.just_started = false;
vdec.just_finished = false;
vdec.frames.Push(frame); // !!!!!!!!
frame.data = nullptr; // to prevent destruction
vdec.vdecCb->ExecAsCallback(vdec.cbFunc, false, vdec.id, CELL_VDEC_MSG_TYPE_PICOUT, CELL_OK, vdec.cbArg);
/*Callback cb;
cb.SetAddr(vdec.cbFunc);
cb.Handle(vdec.id, CELL_VDEC_MSG_TYPE_PICOUT, CELL_OK, vdec.cbArg);
cb.Branch(false);*/
}
else if (vdec.just_started) // deferred initialization
{
err = avformat_open_input(&vdec.fmt, NULL, av_find_input_format("mpeg"), NULL);
if (err)
{
LOG_ERROR(HLE, "vdecDecodeAu: avformat_open_input() failed");
Emu.Pause();
break;
}
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_H264); // ???
if (!codec)
{
LOG_ERROR(HLE, "vdecDecodeAu: avcodec_find_decoder() failed");
Emu.Pause();
break;
}
/*err = avformat_find_stream_info(vdec.fmt, NULL);
if (err)
{
LOG_ERROR(HLE, "vdecDecodeAu: avformat_find_stream_info() failed");
Emu.Pause();
break;
}
if (!vdec.fmt->nb_streams)
{
LOG_ERROR(HLE, "vdecDecodeAu: no stream found");
Emu.Pause();
break;
}*/
if (!avformat_new_stream(vdec.fmt, codec))
{
LOG_ERROR(HLE, "vdecDecodeAu: avformat_new_stream() failed");
Emu.Pause();
break;
}
vdec.ctx = vdec.fmt->streams[0]->codec; // TODO: check data
AVDictionary* opts = nullptr;
av_dict_set(&opts, "refcounted_frames", "1", 0);
{
std::lock_guard<std::mutex> lock(g_mutex_avcodec_open2);
// not multithread-safe (???)
err = avcodec_open2(vdec.ctx, codec, &opts);
}
if (err)
{
LOG_ERROR(HLE, "vdecDecodeAu: avcodec_open2() failed");
Emu.Pause();
break;
}
vdec.just_started = false;
}
bool last_frame = false;
while (true)
{
if (Emu.IsStopped() || vdec.job.PeekIfExist().type == vdecClose)
{
vdec.is_finished = true;
LOG_WARNING(HLE, "vdecDecodeAu: aborted");
return;
}
last_frame = av_read_frame(vdec.fmt, &au) < 0;
if (last_frame)
{
//break;
av_free(au.data);
au.data = NULL;
au.size = 0;
}
struct VdecFrameHolder : VdecFrame
{
VdecFrameHolder()
{
data = av_frame_alloc();
}
~VdecFrameHolder()
{
if (data)
{
av_frame_unref(data);
av_frame_free(&data);
}
}
} frame;
if (!frame.data)
{
LOG_ERROR(HLE, "vdecDecodeAu: av_frame_alloc() failed");
Emu.Pause();
break;
}
int got_picture = 0;
int decode = avcodec_decode_video2(vdec.ctx, frame.data, &got_picture, &au);
if (decode <= 0)
{
if (!last_frame && decode < 0)
{
LOG_ERROR(HLE, "vdecDecodeAu: AU decoding error(0x%x)", decode);
}
if (!got_picture && vdec.reader.size == 0) break; // video end?
}
if (got_picture)
{
u64 ts = av_frame_get_best_effort_timestamp(frame.data);
if (ts != AV_NOPTS_VALUE)
{
frame.pts = ts/* - vdec.first_pts*/; // ???
vdec.last_pts = frame.pts;
}
else
{
vdec.last_pts += vdec.ctx->time_base.num * 90000 / (vdec.ctx->time_base.den / vdec.ctx->ticks_per_frame);
frame.pts = vdec.last_pts;
}
//frame.pts = vdec.last_pts;
//vdec.last_pts += 3754;
frame.dts = (frame.pts - vdec.first_pts) + vdec.first_dts;
frame.userdata = task.userData;
//LOG_NOTICE(HLE, "got picture (pts=0x%llx, dts=0x%llx)", frame.pts, frame.dts);
vdec.frames.Push(frame); // !!!!!!!!
frame.data = nullptr; // to prevent destruction
vdec.vdecCb->ExecAsCallback(vdec.cbFunc, false, vdec.id, CELL_VDEC_MSG_TYPE_PICOUT, CELL_OK, vdec.cbArg);
/*Callback cb;
cb.SetAddr(vdec.cbFunc);
cb.Handle(vdec.id, CELL_VDEC_MSG_TYPE_PICOUT, CELL_OK, vdec.cbArg);
cb.Branch(false);*/
}
}
vdec.vdecCb->ExecAsCallback(vdec.cbFunc, false, vdec.id, CELL_VDEC_MSG_TYPE_AUDONE, CELL_OK, vdec.cbArg);
/*Callback cb;
cb.SetAddr(vdec.cbFunc);
cb.Handle(vdec.id, CELL_VDEC_MSG_TYPE_AUDONE, CELL_OK, vdec.cbArg);
cb.Branch(false);*/
}
break;
vdec.vdecCb->ExecAsCallback(vdec.cbFunc, false, vdec.id, CELL_VDEC_MSG_TYPE_AUDONE, CELL_OK, vdec.cbArg);
/*Callback cb;
cb.SetAddr(vdec.cbFunc);
cb.Handle(vdec.id, CELL_VDEC_MSG_TYPE_AUDONE, CELL_OK, vdec.cbArg);
cb.Branch(false);*/
}
break;
case vdecClose:
{
vdec.is_finished = true;
LOG_NOTICE(HLE, "Video Decoder thread ended");
return;
}
{
vdec.is_finished = true;
cellVdec->Notice("Video Decoder thread ended");
return;
}
case vdecSetFrameRate:
{
LOG_ERROR(HLE, "TODO: vdecSetFrameRate(%d)", task.frc);
}
break;
{
cellVdec->Error("TODO: vdecSetFrameRate(%d)", task.frc);
}
break;
default:
LOG_ERROR(HLE, "Video Decoder thread error: unknown task(%d)", task.type);
cellVdec->Error("Video Decoder thread error: unknown task(%d)", task.type);
}
}
vdec.is_finished = true;
LOG_WARNING(HLE, "Video Decoder thread aborted");
cellVdec->Warning("Video Decoder thread aborted");
});
t.detach();
@ -465,7 +528,7 @@ int cellVdecClose(u32 handle)
{
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellVdecClose(%d) aborted", handle);
cellVdec->Warning("cellVdecClose(%d) aborted", handle);
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
@ -516,7 +579,7 @@ int cellVdecEndSeq(u32 handle)
{
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "cellVdecEndSeq(%d) aborted", handle);
cellVdec->Warning("cellVdecEndSeq(%d) aborted", handle);
return CELL_OK;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
@ -690,13 +753,13 @@ int cellVdecGetPicItem(u32 handle, mem32_t picItem_ptr)
}
else
{
LOG_ERROR(HLE, "cellVdecGetPicItem: unsupported time_base.den (%d)", vdec->ctx->time_base.den);
cellVdec->Error("cellVdecGetPicItem: unsupported time_base.den (%d)", vdec->ctx->time_base.den);
Emu.Pause();
}
}
else
{
LOG_ERROR(HLE, "cellVdecGetPicItem: unsupported time_base.num (%d)", vdec->ctx->time_base.num);
cellVdec->Error("cellVdecGetPicItem: unsupported time_base.num (%d)", vdec->ctx->time_base.num);
Emu.Pause();
}
avc->fixed_frame_rate_flag = true;

View File

@ -727,67 +727,7 @@ public:
CPUThread* vdecCb;
VideoDecoder(CellVdecCodecType type, u32 profile, u32 addr, u32 size, u32 func, u32 arg)
: type(type)
, profile(profile)
, memAddr(addr)
, memSize(size)
, memBias(0)
, cbFunc(func)
, cbArg(arg)
, is_finished(false)
, is_running(false)
, just_started(false)
, just_finished(false)
, ctx(nullptr)
, vdecCb(nullptr)
{
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_H264);
if (!codec)
{
LOG_ERROR(HLE, "VideoDecoder(): avcodec_find_decoder(H264) failed");
Emu.Pause();
return;
}
fmt = avformat_alloc_context();
if (!fmt)
{
LOG_ERROR(HLE, "VideoDecoder(): avformat_alloc_context failed");
Emu.Pause();
return;
}
io_buf = (u8*)av_malloc(4096);
fmt->pb = avio_alloc_context(io_buf, 4096, 0, this, vdecRead, NULL, NULL);
if (!fmt->pb)
{
LOG_ERROR(HLE, "VideoDecoder(): avio_alloc_context failed");
Emu.Pause();
return;
}
}
VideoDecoder(CellVdecCodecType type, u32 profile, u32 addr, u32 size, u32 func, u32 arg);
~VideoDecoder()
{
// TODO: check finalization
if (ctx)
{
for (u32 i = frames.GetCount() - 1; ~i; i--)
{
VdecFrame& vf = frames.Peek(i);
av_frame_unref(vf.data);
av_frame_free(&vf.data);
}
avcodec_close(ctx);
avformat_close_input(&fmt);
}
if (fmt)
{
if (io_buf)
{
av_free(io_buf);
}
if (fmt->pb) av_free(fmt->pb);
avformat_free_context(fmt);
}
}
~VideoDecoder();
};

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
@ -33,7 +32,7 @@ u32 vpostOpen(VpostInstance* data)
{
u32 id = cellVpost->GetNewId(data);
LOG_NOTICE(HLE, "*** Vpost instance created (to_rgba=%d): id = %d", data->to_rgba, id);
cellVpost->Notice("*** Vpost instance created (to_rgba=%d): id = %d", data->to_rgba, id);
return id;
}
@ -90,15 +89,15 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpos
u32 oh = ctrlParam->outHeight;
ctrlParam->inWindow; // ignored
if (ctrlParam->inWindow.x) LOG_WARNING(HLE, "*** inWindow.x = %d", (u32)ctrlParam->inWindow.x);
if (ctrlParam->inWindow.y) LOG_WARNING(HLE, "*** inWindow.y = %d", (u32)ctrlParam->inWindow.y);
if (ctrlParam->inWindow.width != w) LOG_WARNING(HLE, "*** inWindow.width = %d", (u32)ctrlParam->inWindow.width);
if (ctrlParam->inWindow.height != h) LOG_WARNING(HLE, "*** inWindow.height = %d", (u32)ctrlParam->inWindow.height);
if (ctrlParam->inWindow.x) cellVpost->Notice("*** inWindow.x = %d", (u32)ctrlParam->inWindow.x);
if (ctrlParam->inWindow.y) cellVpost->Notice("*** inWindow.y = %d", (u32)ctrlParam->inWindow.y);
if (ctrlParam->inWindow.width != w) cellVpost->Notice("*** inWindow.width = %d", (u32)ctrlParam->inWindow.width);
if (ctrlParam->inWindow.height != h) cellVpost->Notice("*** inWindow.height = %d", (u32)ctrlParam->inWindow.height);
ctrlParam->outWindow; // ignored
if (ctrlParam->outWindow.x) LOG_WARNING(HLE, "*** outWindow.x = %d", (u32)ctrlParam->outWindow.x);
if (ctrlParam->outWindow.y) LOG_WARNING(HLE, "*** outWindow.y = %d", (u32)ctrlParam->outWindow.y);
if (ctrlParam->outWindow.width != ow) LOG_WARNING(HLE, "*** outWindow.width = %d", (u32)ctrlParam->outWindow.width);
if (ctrlParam->outWindow.height != oh) LOG_WARNING(HLE, "*** outWindow.height = %d", (u32)ctrlParam->outWindow.height);
if (ctrlParam->outWindow.x) cellVpost->Notice("*** outWindow.x = %d", (u32)ctrlParam->outWindow.x);
if (ctrlParam->outWindow.y) cellVpost->Notice("*** outWindow.y = %d", (u32)ctrlParam->outWindow.y);
if (ctrlParam->outWindow.width != ow) cellVpost->Notice("*** outWindow.width = %d", (u32)ctrlParam->outWindow.width);
if (ctrlParam->outWindow.height != oh) cellVpost->Notice("*** outWindow.height = %d", (u32)ctrlParam->outWindow.height);
ctrlParam->execType; // ignored
ctrlParam->scalerType; // ignored
ctrlParam->ipcType; // ignored

View File

@ -1,9 +1,8 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/Audio/cellAudio.h"
#include "libmixer.h"
@ -337,7 +336,7 @@ int cellSurMixerCreate(const mem_ptr_t<CellSurMixerConfig> config)
{
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "Surmixer aborted");
libmixer->Warning("Surmixer aborted");
break;
}

View File

@ -1,9 +1,8 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/vfsDir.h"
#include "Crypto/unedat.h"
#include "sceNp.h"

View File

@ -1,5 +1,4 @@
#pragma once
#include "cellRtc.h"
// Error Codes

View File

@ -1,9 +1,8 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/System.h"
#include "cellRtc.h"
#include "Emu/SysCalls/Modules.h"
#include "sceNp.h"
#include "sceNpClans.h"

View File

@ -1,8 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/SysCalls/Modules.h"
#include "cellRtc.h"
#include "sceNpCommerce2.h"
//void sceNpCommerce2_unload();

View File

@ -1,4 +1,5 @@
#pragma once
#include "cellRtc.h"
// Return codes
enum

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/SysCalls/Modules.h"
#include "sceNpSns.h"

View File

@ -1,21 +1,16 @@
#include "stdafx.h"
#include "rpcs3/Ini.h"
#include "Utilities/Log.h"
#include "Utilities/rXml.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/vfsDir.h"
#include "cellRtc.h"
#include "sceNp.h"
#include "sceNpTrophy.h"
#include "rpcs3/Ini.h"
#include "Utilities/rXml.h"
#include "Loader/TRP.h"
#include "Loader/TROPUSR.h"
#include "Emu/FS/vfsDir.h"
#include "Emu/SysCalls/lv2/sys_time.h"
#include "sceNp.h"
#include "sceNpTrophy.h"
#include <algorithm>
#include <memory>
@ -350,7 +345,7 @@ int sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, mem_ptr_t<SceNpTrop
sceNpTrophyInternalContext& ctxt = s_npTrophyInstance.contexts[context];
count = ctxt.tropusr->GetTrophiesCount();
if (count.GetValue() > 128)
LOG_WARNING(HLE, "sceNpTrophyGetTrophyUnlockState: More than 128 trophies detected!");
sceNpTrophy->Warning("sceNpTrophyGetTrophyUnlockState: More than 128 trophies detected!");
// Pack up to 128 bools in u32 flag_bits[4]
for (u32 id=0; id<count.GetValue(); id++)

View File

@ -1,8 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/SysCalls/Modules.h"
#include "cellRtc.h"
#include "sceNp.h"
#include "sceNpTus.h"

View File

@ -1,4 +1,5 @@
#pragma once
#include "cellRtc.h"
// Constants for TUS functions and structures
enum

View File

@ -1,9 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/vfsFile.h"
#include "Emu/FS/vfsStreamMemory.h"
#include "Emu/SysCalls/lv2/sys_spu.h"
@ -306,8 +304,7 @@ s32 _sys_printf(u32 arg1)
sysPrxForUser->Todo("_sys_printf(arg1=0x%x)", arg1);
// probably, assertion failed
LOG_WARNING(TTY, "%s", (char*)(Memory + arg1));
Emu.Pause();
sysPrxForUser->Warning("_sys_printf: \n%s", (char*)(Memory + arg1));
return CELL_OK;
}

View File

@ -1,9 +1,6 @@
#include "stdafx.h"
#include "rpcs3/Ini.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/lv2/lv2Fs.h"
@ -157,7 +154,7 @@ void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, int xid, mem_func_ptr_t<void (*
std::this_thread::sleep_for(std::chrono::milliseconds(1));
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "fsAioRead() aborted");
sys_fs->Warning("fsAioRead() aborted");
return;
}
}
@ -188,9 +185,8 @@ void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, int xid, mem_func_ptr_t<void (*
file.Seek(old_pos);
if (Ini.HLELogging.GetValue())
LOG_NOTICE(HLE, "*** fsAioRead(fd=%d, offset=0x%llx, buf_addr=0x%x, size=0x%x, error=0x%x, res=0x%x, xid=0x%x [%s])",
fd, (u64)aio->offset, buf_addr, (u64)aio->size, error, res, xid, orig_file->GetPath().c_str());
sys_fs->Log("*** fsAioRead(fd=%d, offset=0x%llx, buf_addr=0x%x, size=0x%x, error=0x%x, res=0x%x, xid=0x%x [%s])",
fd, (u64)aio->offset, buf_addr, (u64)aio->size, error, res, xid, orig_file->GetPath().c_str());
if (func) // start callback thread
{

View File

@ -1,8 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
//void sys_io_init();

View File

@ -1,12 +1,7 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
#include "sys_net.h"
#ifdef _WIN32
#include <winsock.h>
#else
@ -19,6 +14,8 @@ extern "C"
}
#endif
#include "sys_net.h"
//void sys_net_init();
//Module sys_net((u16)0x0000, sys_net_init);
Module *sys_net = nullptr;

View File

@ -1,5 +1,4 @@
#pragma once
#include "Emu/Cell/PPUThread.h"
#define RESULT(x) CPU.GPR[3] = (x)

View File

@ -1,9 +1,6 @@
#include "stdafx.h"
#include "rpcs3/Ini.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/Modules.h"
#include "Static.h"

View File

@ -4,8 +4,6 @@
#include "Utilities/AutoPause.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/SC_FUNC.h"
#include "ModuleManager.h"
#include "lv2/lv2Fs.h"
@ -971,4 +969,9 @@ void SysCalls::DoSyscall(u32 code)
IdManager& SysCallBase::GetIdManager() const
{
return Emu.GetIdManager();
}
bool SysCallBase::RemoveId(u32 id)
{
return Emu.GetIdManager().RemoveID(id);
}

View File

@ -52,6 +52,8 @@ public:
{
return GetIdManager().GetNewID<T>(GetName(), data, type);
}
bool RemoveId(u32 id);
};
extern bool dump_enable;

View File

@ -1,6 +1,5 @@
#include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "sys_memory.h"
@ -140,7 +139,7 @@ s32 sys_memory_container_destroy(u32 cid)
// Release the allocated memory and remove the ID.
Memory.Free(ct->addr);
Emu.GetIdManager().RemoveID(cid);
sys_memory.RemoveId(cid);
return CELL_OK;
}

View File

@ -1,6 +1,5 @@
#include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/SysCalls.h"
#include "sys_memory.h"
@ -155,7 +154,7 @@ s32 sys_mmapper_free_memory(u32 mem_id)
// Release the allocated memory and remove the ID.
Memory.Free(info->addr);
Emu.GetIdManager().RemoveID(mem_id);
sys_mmapper.RemoveId(mem_id);
return CELL_OK;
}

View File

@ -2,7 +2,6 @@
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
//#include "Ini.h"
#include "Emu/GameInfo.h"
#include "Emu/SysCalls/Static.h"

View File

@ -1,7 +1,16 @@
#include "stdafx.h"
#include "Loader.h"
#include "ELF.h"
void Elf_Ehdr::Show()
{
}
void Elf_Ehdr::Load(vfsStream& f)
{
e_magic = Read32(f);
e_class = Read8(f);
}
ELFLoader::ELFLoader(vfsStream& f)
: elf_f(f)
, LoaderBase()

View File

@ -1,7 +1,6 @@
#pragma once
#include "ELF64.h"
#include "ELF32.h"
#include "Emu/FS/vfsStream.h"
enum ElfClass
{
@ -15,15 +14,9 @@ struct Elf_Ehdr
u32 e_magic;
u8 e_class;
virtual void Show()
{
}
virtual void Show();
virtual void Load(vfsStream& f)
{
e_magic = Read32(f);
e_class = Read8(f);
}
virtual void Load(vfsStream& f);
bool CheckMagic() const { return e_magic == 0x7F454C46; }

View File

@ -3,6 +3,207 @@
#include "Emu/Memory/Memory.h"
#include "ELF32.h"
void Elf32_Ehdr::Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Magic: %08x", e_magic);
LOG_NOTICE(LOADER, "Class: %s", "ELF32");
LOG_NOTICE(LOADER, "Data: %s", Ehdr_DataToString(e_data).c_str());
LOG_NOTICE(LOADER, "Current Version: %d", e_curver);
LOG_NOTICE(LOADER, "OS/ABI: %s", Ehdr_OS_ABIToString(e_os_abi).c_str());
LOG_NOTICE(LOADER, "ABI version: %lld", e_abi_ver);
LOG_NOTICE(LOADER, "Type: %s", Ehdr_TypeToString(e_type).c_str());
LOG_NOTICE(LOADER, "Machine: %s", Ehdr_MachineToString(e_machine).c_str());
LOG_NOTICE(LOADER, "Version: %d", e_version);
LOG_NOTICE(LOADER, "Entry point address: 0x%x", e_entry);
LOG_NOTICE(LOADER, "Program headers offset: 0x%08x", e_phoff);
LOG_NOTICE(LOADER, "Section headers offset: 0x%08x", e_shoff);
LOG_NOTICE(LOADER, "Flags: 0x%x", e_flags);
LOG_NOTICE(LOADER, "Size of this header: %d", e_ehsize);
LOG_NOTICE(LOADER, "Size of program headers: %d", e_phentsize);
LOG_NOTICE(LOADER, "Number of program headers: %d", e_phnum);
LOG_NOTICE(LOADER, "Size of section headers: %d", e_shentsize);
LOG_NOTICE(LOADER, "Number of section headers: %d", e_shnum);
LOG_NOTICE(LOADER, "Section header string table index: %d", e_shstrndx);
#endif
}
void Elf32_Ehdr::Load(vfsStream& f)
{
e_magic = Read32(f);
e_class = Read8(f);
e_data = Read8(f);
e_curver = Read8(f);
e_os_abi = Read8(f);
if(IsLittleEndian())
{
e_abi_ver = Read64LE(f);
e_type = Read16LE(f);
e_machine = Read16LE(f);
e_version = Read32LE(f);
e_entry = Read32LE(f);
e_phoff = Read32LE(f);
e_shoff = Read32LE(f);
e_flags = Read32LE(f);
e_ehsize = Read16LE(f);
e_phentsize = Read16LE(f);
e_phnum = Read16LE(f);
e_shentsize = Read16LE(f);
e_shnum = Read16LE(f);
e_shstrndx = Read16LE(f);
}
else
{
e_abi_ver = Read64(f);
e_type = Read16(f);
e_machine = Read16(f);
e_version = Read32(f);
e_entry = Read32(f);
e_phoff = Read32(f);
e_shoff = Read32(f);
e_flags = Read32(f);
e_ehsize = Read16(f);
e_phentsize = Read16(f);
e_phnum = Read16(f);
e_shentsize = Read16(f);
e_shnum = Read16(f);
e_shstrndx = Read16(f);
}
}
void Elf32_Desc::Load(vfsStream& f)
{
revision = Read32(f);
ls_size = Read32(f);
stack_size = Read32(f);
flags = Read32(f);
}
void Elf32_Desc::LoadLE(vfsStream& f)
{
revision = Read32LE(f);
ls_size = Read32LE(f);
stack_size = Read32LE(f);
flags = Read32LE(f);
}
void Elf32_Note::Load(vfsStream& f)
{
namesz = Read32(f);
descsz = Read32(f);
type = Read32(f);
f.Read(name, 8);
if (descsz == 32)
{
f.Read(desc_text, descsz);
}
else
{
desc.Load(f);
}
}
void Elf32_Note::LoadLE(vfsStream& f)
{
namesz = Read32LE(f);
descsz = Read32LE(f);
type = Read32LE(f);
f.Read(name, 8);
if (descsz == 32)
{
f.Read(desc_text, descsz);
}
else
{
desc.Load(f);
}
}
void Elf32_Shdr::Load(vfsStream& f)
{
sh_name = Read32(f);
sh_type = Read32(f);
sh_flags = Read32(f);
sh_addr = Read32(f);
sh_offset = Read32(f);
sh_size = Read32(f);
sh_link = Read32(f);
sh_info = Read32(f);
sh_addralign = Read32(f);
sh_entsize = Read32(f);
}
void Elf32_Shdr::LoadLE(vfsStream& f)
{
sh_name = Read32LE(f);
sh_type = Read32LE(f);
sh_flags = Read32LE(f);
sh_addr = Read32LE(f);
sh_offset = Read32LE(f);
sh_size = Read32LE(f);
sh_link = Read32LE(f);
sh_info = Read32LE(f);
sh_addralign = Read32LE(f);
sh_entsize = Read32LE(f);
}
void Elf32_Shdr::Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Name offset: %x", sh_name);
LOG_NOTICE(LOADER, "Type: %d", sh_type);
LOG_NOTICE(LOADER, "Addr: %x", sh_addr);
LOG_NOTICE(LOADER, "Offset: %x", sh_offset);
LOG_NOTICE(LOADER, "Size: %x", sh_size);
LOG_NOTICE(LOADER, "EntSize: %d", sh_entsize);
LOG_NOTICE(LOADER, "Flags: %x", sh_flags);
LOG_NOTICE(LOADER, "Link: %x", sh_link);
LOG_NOTICE(LOADER, "Info: %d", sh_info);
LOG_NOTICE(LOADER, "Address align: %x", sh_addralign);
#endif
}
void Elf32_Phdr::Load(vfsStream& f)
{
p_type = Read32(f);
p_offset = Read32(f);
p_vaddr = Read32(f);
p_paddr = Read32(f);
p_filesz = Read32(f);
p_memsz = Read32(f);
p_flags = Read32(f);
p_align = Read32(f);
}
void Elf32_Phdr::LoadLE(vfsStream& f)
{
p_type = Read32LE(f);
p_offset = Read32LE(f);
p_vaddr = Read32LE(f);
p_paddr = Read32LE(f);
p_filesz = Read32LE(f);
p_memsz = Read32LE(f);
p_flags = Read32LE(f);
p_align = Read32LE(f);
}
void Elf32_Phdr::Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Type: %s", Phdr_TypeToString(p_type).c_str());
LOG_NOTICE(LOADER, "Offset: 0x%08x", p_offset);
LOG_NOTICE(LOADER, "Virtual address: 0x%08x", p_vaddr);
LOG_NOTICE(LOADER, "Physical address: 0x%08x", p_paddr);
LOG_NOTICE(LOADER, "File size: 0x%08x", p_filesz);
LOG_NOTICE(LOADER, "Memory size: 0x%08x", p_memsz);
LOG_NOTICE(LOADER, "Flags: %s", Phdr_FlagsToString(p_flags).c_str());
LOG_NOTICE(LOADER, "Align: 0x%x", p_align);
#endif
}
void WriteEhdr(rFile& f, Elf32_Ehdr& ehdr)
{
Write32(f, ehdr.e_magic);

View File

@ -23,79 +23,14 @@ struct Elf32_Ehdr
u16 e_shnum;
u16 e_shstrndx;
void Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Magic: %08x", e_magic);
LOG_NOTICE(LOADER, "Class: %s", "ELF32");
LOG_NOTICE(LOADER, "Data: %s", Ehdr_DataToString(e_data).c_str());
LOG_NOTICE(LOADER, "Current Version: %d", e_curver);
LOG_NOTICE(LOADER, "OS/ABI: %s", Ehdr_OS_ABIToString(e_os_abi).c_str());
LOG_NOTICE(LOADER, "ABI version: %lld", e_abi_ver);
LOG_NOTICE(LOADER, "Type: %s", Ehdr_TypeToString(e_type).c_str());
LOG_NOTICE(LOADER, "Machine: %s", Ehdr_MachineToString(e_machine).c_str());
LOG_NOTICE(LOADER, "Version: %d", e_version);
LOG_NOTICE(LOADER, "Entry point address: 0x%x", e_entry);
LOG_NOTICE(LOADER, "Program headers offset: 0x%08x", e_phoff);
LOG_NOTICE(LOADER, "Section headers offset: 0x%08x", e_shoff);
LOG_NOTICE(LOADER, "Flags: 0x%x", e_flags);
LOG_NOTICE(LOADER, "Size of this header: %d", e_ehsize);
LOG_NOTICE(LOADER, "Size of program headers: %d", e_phentsize);
LOG_NOTICE(LOADER, "Number of program headers: %d", e_phnum);
LOG_NOTICE(LOADER, "Size of section headers: %d", e_shentsize);
LOG_NOTICE(LOADER, "Number of section headers: %d", e_shnum);
LOG_NOTICE(LOADER, "Section header string table index: %d", e_shstrndx);
#endif
}
void Show();
bool IsLittleEndian() const
{
return e_data == 1;
}
void Load(vfsStream& f)
{
e_magic = Read32(f);
e_class = Read8(f);
e_data = Read8(f);
e_curver = Read8(f);
e_os_abi = Read8(f);
if(IsLittleEndian())
{
e_abi_ver = Read64LE(f);
e_type = Read16LE(f);
e_machine = Read16LE(f);
e_version = Read32LE(f);
e_entry = Read32LE(f);
e_phoff = Read32LE(f);
e_shoff = Read32LE(f);
e_flags = Read32LE(f);
e_ehsize = Read16LE(f);
e_phentsize = Read16LE(f);
e_phnum = Read16LE(f);
e_shentsize = Read16LE(f);
e_shnum = Read16LE(f);
e_shstrndx = Read16LE(f);
}
else
{
e_abi_ver = Read64(f);
e_type = Read16(f);
e_machine = Read16(f);
e_version = Read32(f);
e_entry = Read32(f);
e_phoff = Read32(f);
e_shoff = Read32(f);
e_flags = Read32(f);
e_ehsize = Read16(f);
e_phentsize = Read16(f);
e_phnum = Read16(f);
e_shentsize = Read16(f);
e_shnum = Read16(f);
e_shstrndx = Read16(f);
}
}
void Load(vfsStream& f);
bool CheckMagic() const { return e_magic == 0x7F454C46; }
u32 GetEntry() const { return e_entry; }
@ -108,21 +43,9 @@ struct Elf32_Desc
u32 stack_size;
u32 flags;
void Load(vfsStream& f)
{
revision = Read32(f);
ls_size = Read32(f);
stack_size = Read32(f);
flags = Read32(f);
}
void Load(vfsStream& f);
void LoadLE(vfsStream& f)
{
revision = Read32LE(f);
ls_size = Read32LE(f);
stack_size = Read32LE(f);
flags = Read32LE(f);
}
void LoadLE(vfsStream& f);
};
struct Elf32_Note
@ -137,39 +60,9 @@ struct Elf32_Note
char desc_text[32];
};
void Load(vfsStream& f)
{
namesz = Read32(f);
descsz = Read32(f);
type = Read32(f);
f.Read(name, 8);
void Load(vfsStream& f);
if(descsz == 32)
{
f.Read(desc_text, descsz);
}
else
{
desc.Load(f);
}
}
void LoadLE(vfsStream& f)
{
namesz = Read32LE(f);
descsz = Read32LE(f);
type = Read32LE(f);
f.Read(name, 8);
if(descsz == 32)
{
f.Read(desc_text, descsz);
}
else
{
desc.Load(f);
}
}
void LoadLE(vfsStream& f);
};
struct Elf32_Shdr
@ -185,49 +78,11 @@ struct Elf32_Shdr
u32 sh_addralign;
u32 sh_entsize;
void Load(vfsStream& f)
{
sh_name = Read32(f);
sh_type = Read32(f);
sh_flags = Read32(f);
sh_addr = Read32(f);
sh_offset = Read32(f);
sh_size = Read32(f);
sh_link = Read32(f);
sh_info = Read32(f);
sh_addralign = Read32(f);
sh_entsize = Read32(f);
}
void Load(vfsStream& f);
void LoadLE(vfsStream& f)
{
sh_name = Read32LE(f);
sh_type = Read32LE(f);
sh_flags = Read32LE(f);
sh_addr = Read32LE(f);
sh_offset = Read32LE(f);
sh_size = Read32LE(f);
sh_link = Read32LE(f);
sh_info = Read32LE(f);
sh_addralign = Read32LE(f);
sh_entsize = Read32LE(f);
}
void LoadLE(vfsStream& f);
void Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Name offset: %x", sh_name);
LOG_NOTICE(LOADER, "Type: %d", sh_type);
LOG_NOTICE(LOADER, "Addr: %x", sh_addr);
LOG_NOTICE(LOADER, "Offset: %x", sh_offset);
LOG_NOTICE(LOADER, "Size: %x", sh_size);
LOG_NOTICE(LOADER, "EntSize: %d", sh_entsize);
LOG_NOTICE(LOADER, "Flags: %x", sh_flags);
LOG_NOTICE(LOADER, "Link: %x", sh_link);
LOG_NOTICE(LOADER, "Info: %d", sh_info);
LOG_NOTICE(LOADER, "Address align: %x", sh_addralign);
#endif
}
void Show();
};
struct Elf32_Phdr
@ -241,43 +96,11 @@ struct Elf32_Phdr
u32 p_flags;
u32 p_align;
void Load(vfsStream& f)
{
p_type = Read32(f);
p_offset = Read32(f);
p_vaddr = Read32(f);
p_paddr = Read32(f);
p_filesz = Read32(f);
p_memsz = Read32(f);
p_flags = Read32(f);
p_align = Read32(f);
}
void Load(vfsStream& f);
void LoadLE(vfsStream& f)
{
p_type = Read32LE(f);
p_offset = Read32LE(f);
p_vaddr = Read32LE(f);
p_paddr = Read32LE(f);
p_filesz = Read32LE(f);
p_memsz = Read32LE(f);
p_flags = Read32LE(f);
p_align = Read32LE(f);
}
void LoadLE(vfsStream& f);
void Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Type: %s", Phdr_TypeToString(p_type).c_str());
LOG_NOTICE(LOADER, "Offset: 0x%08x", p_offset);
LOG_NOTICE(LOADER, "Virtual address: 0x%08x", p_vaddr);
LOG_NOTICE(LOADER, "Physical address: 0x%08x", p_paddr);
LOG_NOTICE(LOADER, "File size: 0x%08x", p_filesz);
LOG_NOTICE(LOADER, "Memory size: 0x%08x", p_memsz);
LOG_NOTICE(LOADER, "Flags: %s", Phdr_FlagsToString(p_flags).c_str());
LOG_NOTICE(LOADER, "Align: 0x%x", p_align);
#endif
}
void Show();
};
class ELF32Loader : public LoaderBase

View File

@ -2,9 +2,7 @@
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/Static.h"
#include "Emu/Cell/PPUInstrTable.h"
#include "Emu/SysCalls/ModuleManager.h"
@ -12,6 +10,110 @@
using namespace PPU_instr;
void Elf64_Ehdr::Load(vfsStream& f)
{
e_magic = Read32(f);
e_class = Read8(f);
e_data = Read8(f);
e_curver = Read8(f);
e_os_abi = Read8(f);
e_abi_ver = Read64(f);
e_type = Read16(f);
e_machine = Read16(f);
e_version = Read32(f);
e_entry = Read64(f);
e_phoff = Read64(f);
e_shoff = Read64(f);
e_flags = Read32(f);
e_ehsize = Read16(f);
e_phentsize = Read16(f);
e_phnum = Read16(f);
e_shentsize = Read16(f);
e_shnum = Read16(f);
e_shstrndx = Read16(f);
}
void Elf64_Ehdr::Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Magic: %08x", e_magic);
LOG_NOTICE(LOADER, "Class: %s", "ELF64");
LOG_NOTICE(LOADER, "Data: %s", Ehdr_DataToString(e_data).c_str());
LOG_NOTICE(LOADER, "Current Version: %d", e_curver);
LOG_NOTICE(LOADER, "OS/ABI: %s", Ehdr_OS_ABIToString(e_os_abi).c_str());
LOG_NOTICE(LOADER, "ABI version: %lld", e_abi_ver);
LOG_NOTICE(LOADER, "Type: %s", Ehdr_TypeToString(e_type).c_str());
LOG_NOTICE(LOADER, "Machine: %s", Ehdr_MachineToString(e_machine).c_str());
LOG_NOTICE(LOADER, "Version: %d", e_version);
LOG_NOTICE(LOADER, "Entry point address: 0x%08llx", e_entry);
LOG_NOTICE(LOADER, "Program headers offset: 0x%08llx", e_phoff);
LOG_NOTICE(LOADER, "Section headers offset: 0x%08llx", e_shoff);
LOG_NOTICE(LOADER, "Flags: 0x%x", e_flags);
LOG_NOTICE(LOADER, "Size of this header: %d", e_ehsize);
LOG_NOTICE(LOADER, "Size of program headers: %d", e_phentsize);
LOG_NOTICE(LOADER, "Number of program headers: %d", e_phnum);
LOG_NOTICE(LOADER, "Size of section headers: %d", e_shentsize);
LOG_NOTICE(LOADER, "Number of section headers: %d", e_shnum);
LOG_NOTICE(LOADER, "Section header string table index: %d", e_shstrndx);
#endif
}
void Elf64_Shdr::Load(vfsStream& f)
{
sh_name = Read32(f);
sh_type = Read32(f);
sh_flags = Read64(f);
sh_addr = Read64(f);
sh_offset = Read64(f);
sh_size = Read64(f);
sh_link = Read32(f);
sh_info = Read32(f);
sh_addralign = Read64(f);
sh_entsize = Read64(f);
}
void Elf64_Shdr::Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Name offset: %x", sh_name);
LOG_NOTICE(LOADER, "Type: %d", sh_type);
LOG_NOTICE(LOADER, "Addr: %llx", sh_addr);
LOG_NOTICE(LOADER, "Offset: %llx", sh_offset);
LOG_NOTICE(LOADER, "Size: %llx", sh_size);
LOG_NOTICE(LOADER, "EntSize: %lld", sh_entsize);
LOG_NOTICE(LOADER, "Flags: %llx", sh_flags);
LOG_NOTICE(LOADER, "Link: %x", sh_link);
LOG_NOTICE(LOADER, "Info: %x", sh_info);
LOG_NOTICE(LOADER, "Address align: %llx", sh_addralign);
#endif
}
void Elf64_Phdr::Load(vfsStream& f)
{
p_type = Read32(f);
p_flags = Read32(f);
p_offset = Read64(f);
p_vaddr = Read64(f);
p_paddr = Read64(f);
p_filesz = Read64(f);
p_memsz = Read64(f);
p_align = Read64(f);
}
void Elf64_Phdr::Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Type: %s", Phdr_TypeToString(p_type).c_str());
LOG_NOTICE(LOADER, "Offset: 0x%08llx", p_offset);
LOG_NOTICE(LOADER, "Virtual address: 0x%08llx", p_vaddr);
LOG_NOTICE(LOADER, "Physical address: 0x%08llx", p_paddr);
LOG_NOTICE(LOADER, "File size: 0x%08llx", p_filesz);
LOG_NOTICE(LOADER, "Memory size: 0x%08llx", p_memsz);
LOG_NOTICE(LOADER, "Flags: %s", Phdr_FlagsToString(p_flags).c_str());
LOG_NOTICE(LOADER, "Align: 0x%llx", p_align);
#endif
}
void WriteEhdr(rFile& f, Elf64_Ehdr& ehdr)
{
Write32(f, ehdr.e_magic);

View File

@ -23,53 +23,9 @@ struct Elf64_Ehdr
u16 e_shnum;
u16 e_shstrndx;
void Load(vfsStream& f)
{
e_magic = Read32(f);
e_class = Read8(f);
e_data = Read8(f);
e_curver = Read8(f);
e_os_abi = Read8(f);
e_abi_ver = Read64(f);
e_type = Read16(f);
e_machine = Read16(f);
e_version = Read32(f);
e_entry = Read64(f);
e_phoff = Read64(f);
e_shoff = Read64(f);
e_flags = Read32(f);
e_ehsize = Read16(f);
e_phentsize = Read16(f);
e_phnum = Read16(f);
e_shentsize = Read16(f);
e_shnum = Read16(f);
e_shstrndx = Read16(f);
}
void Load(vfsStream& f);
void Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Magic: %08x", e_magic);
LOG_NOTICE(LOADER, "Class: %s", "ELF64");
LOG_NOTICE(LOADER, "Data: %s", Ehdr_DataToString(e_data).c_str());
LOG_NOTICE(LOADER, "Current Version: %d", e_curver);
LOG_NOTICE(LOADER, "OS/ABI: %s", Ehdr_OS_ABIToString(e_os_abi).c_str());
LOG_NOTICE(LOADER, "ABI version: %lld", e_abi_ver);
LOG_NOTICE(LOADER, "Type: %s", Ehdr_TypeToString(e_type).c_str());
LOG_NOTICE(LOADER, "Machine: %s", Ehdr_MachineToString(e_machine).c_str());
LOG_NOTICE(LOADER, "Version: %d", e_version);
LOG_NOTICE(LOADER, "Entry point address: 0x%08llx", e_entry);
LOG_NOTICE(LOADER, "Program headers offset: 0x%08llx", e_phoff);
LOG_NOTICE(LOADER, "Section headers offset: 0x%08llx", e_shoff);
LOG_NOTICE(LOADER, "Flags: 0x%x", e_flags);
LOG_NOTICE(LOADER, "Size of this header: %d", e_ehsize);
LOG_NOTICE(LOADER, "Size of program headers: %d", e_phentsize);
LOG_NOTICE(LOADER, "Number of program headers: %d", e_phnum);
LOG_NOTICE(LOADER, "Size of section headers: %d", e_shentsize);
LOG_NOTICE(LOADER, "Number of section headers: %d", e_shnum);
LOG_NOTICE(LOADER, "Section header string table index: %d", e_shstrndx);
#endif
}
void Show();
bool CheckMagic() const { return e_magic == 0x7F454C46; }
u32 GetEntry() const { return e_entry; }
@ -88,35 +44,9 @@ struct Elf64_Shdr
u64 sh_addralign;
u64 sh_entsize;
void Load(vfsStream& f)
{
sh_name = Read32(f);
sh_type = Read32(f);
sh_flags = Read64(f);
sh_addr = Read64(f);
sh_offset = Read64(f);
sh_size = Read64(f);
sh_link = Read32(f);
sh_info = Read32(f);
sh_addralign = Read64(f);
sh_entsize = Read64(f);
}
void Load(vfsStream& f);
void Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Name offset: %x", sh_name);
LOG_NOTICE(LOADER, "Type: %d", sh_type);
LOG_NOTICE(LOADER, "Addr: %llx", sh_addr);
LOG_NOTICE(LOADER, "Offset: %llx", sh_offset);
LOG_NOTICE(LOADER, "Size: %llx", sh_size);
LOG_NOTICE(LOADER, "EntSize: %lld", sh_entsize);
LOG_NOTICE(LOADER, "Flags: %llx", sh_flags);
LOG_NOTICE(LOADER, "Link: %x", sh_link);
LOG_NOTICE(LOADER, "Info: %x", sh_info);
LOG_NOTICE(LOADER, "Address align: %llx", sh_addralign);
#endif
}
void Show();
};
struct Elf64_Phdr
@ -130,31 +60,9 @@ struct Elf64_Phdr
u64 p_memsz;
u64 p_align;
void Load(vfsStream& f)
{
p_type = Read32(f);
p_flags = Read32(f);
p_offset = Read64(f);
p_vaddr = Read64(f);
p_paddr = Read64(f);
p_filesz = Read64(f);
p_memsz = Read64(f);
p_align = Read64(f);
}
void Load(vfsStream& f);
void Show()
{
#ifdef LOADER_DEBUG
LOG_NOTICE(LOADER, "Type: %s", Phdr_TypeToString(p_type).c_str());
LOG_NOTICE(LOADER, "Offset: 0x%08llx", p_offset);
LOG_NOTICE(LOADER, "Virtual address: 0x%08llx", p_vaddr);
LOG_NOTICE(LOADER, "Physical address: 0x%08llx", p_paddr);
LOG_NOTICE(LOADER, "File size: 0x%08llx", p_filesz);
LOG_NOTICE(LOADER, "Memory size: 0x%08llx", p_memsz);
LOG_NOTICE(LOADER, "Flags: %s", Phdr_FlagsToString(p_flags).c_str());
LOG_NOTICE(LOADER, "Align: 0x%llx", p_align);
#endif
}
void Show();
};
class ELF64Loader : public LoaderBase

View File

@ -1,7 +1,6 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Utilities/rXml.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "TROPUSR.h"
@ -212,7 +211,8 @@ bool TROPUSRLoader::Close()
{
if (m_file && m_file->Close())
{
safe_delete(m_file);
delete m_file;
m_file = nullptr;
return true;
}
return false;

View File

@ -1,6 +1,5 @@
#include "stdafx.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/FS/vfsFile.h"
#include "TRP.h"

View File

@ -355,6 +355,7 @@
<ClInclude Include="Emu\SysCalls\Modules\cellAtrac.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellDmux.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellFont.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellFontFT.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellGame.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellGcmSys.h" />
<ClInclude Include="Emu\SysCalls\Modules\cellGem.h" />

View File

@ -1162,5 +1162,8 @@
<ClInclude Include="Emu\IdManager.h">
<Filter>Emu</Filter>
</ClInclude>
<ClInclude Include="Emu\SysCalls\Modules\cellFontFT.h">
<Filter>Emu\SysCalls\Modules</Filter>
</ClInclude>
</ItemGroup>
</Project>