Example #1
0
s32 sceNpMatching2Init2(u32 poolsize, s32 priority, vm::ptr<SceNpMatching2UtilityInitParam> param)
{
	sceNp2.Todo("sceNpMatching2Init2(poolsize=%d, priority=%d, param_addr=0x%x)", poolsize, priority, param.addr());

	if (!sceNp2Instance.m_bSceNp2Initialized)
	{
		sceNp2.Error("sceNpMatching2Init2(): sceNp2 has not been intialized.");
		return SCE_NP_ERROR_NOT_INITIALIZED;
	}

	if (sceNp2Instance.m_bSceNp2Matching2Initialized2)
	{
		sceNp2.Error("sceNpMatching2Init2(): new sceNpMatching2 has already been intialized.");
		return SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED;
	}

	sceNp2Instance.m_bSceNp2Matching2Initialized2 = true;

	// TODO:
	// 1. Create an internal thread
	// 2. Create heap area to be used by the NP matching 2 utility
	// 3. Set maximum lengths for the event data queues in the system

	return CELL_OK;
}
Example #2
0
s32 sceNp2Init(u32 poolsize, vm::ptr<u32> poolptr)
{
	sceNp2.Warning("sceNp2Init(poolsize=%d, poolptr=0x%x)", poolsize, poolptr);

	if (sceNp2Instance.m_bSceNp2Initialized)
	{
		sceNp2.Error("sceNp2Init(): sceNp2 has been already initialized.");
		return SCE_NP_ERROR_ALREADY_INITIALIZED;
	}

	if (poolsize == 0)
	{
		sceNp2.Error("sceNp2Init(): poolsize given is 0.");
		return SCE_NP_ERROR_INVALID_ARGUMENT;
	}
	else if (poolsize < 128 * 1024)
	{
		sceNp2.Error("sceNp2Init(): poolsize given is under 131072 bytes.");
		return SCE_NP_ERROR_INSUFFICIENT_BUFFER;
	}

	if (!poolptr)
	{
		sceNp2.Error("sceNp2Init(): poolptr is invalid.");
		return SCE_NP_ERROR_INVALID_ARGUMENT;
	}

	sceNpInstance.m_bSceNpInitialized = true;
	sceNp2Instance.m_bSceNp2Initialized = true;

	return CELL_OK;
}
Example #3
0
bool ElementaryStream::peek(u32& out_data, bool no_ex, u32& out_spec, bool update_index)
{
	std::lock_guard<std::mutex> lock(m_mutex);
	if (got_count < released)
	{
		cellDmux.Error("es::peek() error: got_count(%d) < released(%d) (put_count=%d)", got_count, released, put_count);
		Emu.Pause();
		return false;
	}
	if (got_count >= put_count)
	{
		return false;
	}

	u32 addr = 0;
	if (!entries.peek(addr, got_count - released, &dmux->is_closed) || !addr)
	{
		cellDmux.Error("es::peek() error: entries.Peek() failed");
		Emu.Pause();
		return false;
	}

	out_data = no_ex ? addr + 64 : addr;
	out_spec = addr + sizeof(CellDmuxAuInfoEx);

	if (update_index)
	{
		got_count++;
	}
	return true;
}
Example #4
0
s32 cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr<CellGameContentSize> size, vm::ptr<char[CELL_GAME_DIRNAME_SIZE]> dirName)
{
	cellGame.Warning("cellGameBootCheck(type=*0x%x, attributes=*0x%x, size=*0x%x, dirName=*0x%x)", type, attributes, size, dirName);

	if (size)
	{
		// TODO: Use the free space of the computer's HDD where RPCS3 is being run.
		size->hddFreeSizeKB = 40000000; // 40 GB

		// TODO: Calculate data size for HG and DG games, if necessary.
		size->sizeKB = CELL_GAME_SIZEKB_NOTCALC;
		size->sysSizeKB = 0;
	}

	vfsFile f("/app_home/../PARAM.SFO");
	const PSFLoader psf(f);

	if (!psf)
	{
		// According to testing (in debug mode) cellGameBootCheck doesn't return an error code, when PARAM.SFO doesn't exist.
		cellGame.Error("cellGameBootCheck(): Cannot read PARAM.SFO.");
	}

	std::string category = psf.GetString("CATEGORY");
	if (category.substr(0, 2) == "DG")
	{
		*type = CELL_GAME_GAMETYPE_DISC;
		*attributes = 0; // TODO
		if (dirName) strcpy_trunc(*dirName, ""); // ???
		contentInfo = "/dev_bdvd/PS3_GAME";
		usrdir = "/dev_bdvd/PS3_GAME/USRDIR";
		path_set = true;
	}
	else if (category.substr(0, 2) == "HG")
	{
		std::string titleId = psf.GetString("TITLE_ID");
		*type = CELL_GAME_GAMETYPE_HDD;
		*attributes = 0; // TODO
		if (dirName) strcpy_trunc(*dirName, titleId);
		contentInfo = "/dev_hdd0/game/" + titleId;
		usrdir = "/dev_hdd0/game/" + titleId + "/USRDIR";
		path_set = true;
	}
	else if (category.substr(0, 2) == "GD")
	{
		std::string titleId = psf.GetString("TITLE_ID");
		*type = CELL_GAME_GAMETYPE_DISC;
		*attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO
		if (dirName) strcpy_trunc(*dirName, titleId); // ???
		contentInfo = "/dev_bdvd/PS3_GAME";
		usrdir = "/dev_bdvd/PS3_GAME/USRDIR";
		path_set = true;
	}
	else if (psf)
	{
		cellGame.Error("cellGameBootCheck(): Unknown CATEGORY.");
	}

	return CELL_GAME_RET_OK;
}
Example #5
0
s32 sceNpTrophyGetTrophyUnlockState(u32 context, u32 handle, vm::ptr<SceNpTrophyFlagArray> flags, vm::ptr<u32> count)
{
	sceNpTrophy.Error("sceNpTrophyGetTrophyUnlockState(context=0x%x, handle=0x%x, flags=*0x%x, count=*0x%x)", context, handle, flags, count);

	const auto ctxt = idm::get<trophy_context_t>(context);

	if (!ctxt)
	{
		return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT;
	}

	const auto hndl = idm::get<trophy_handle_t>(handle);

	if (!hndl)
	{
		return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
	}

	u32 count_ = ctxt->tropusr->GetTrophiesCount();
	*count = count_;
	if (count_ > 128)
		sceNpTrophy.Error("sceNpTrophyGetTrophyUnlockState: More than 128 trophies detected!");

	// Pack up to 128 bools in u32 flag_bits[4]
	for (u32 id = 0; id < count_; id++)
	{
		if (ctxt->tropusr->GetTrophyUnlockState(id))
			flags->flag_bits[id/32] |= 1<<(id%32);
		else
			flags->flag_bits[id/32] &= ~(1<<(id%32));
	}

	return CELL_OK;
}
Example #6
0
bool ElementaryStream::release()
{
	std::lock_guard<std::mutex> lock(m_mutex);
	if (released >= put_count)
	{
		cellDmux.Error("es::release() error: buffer is empty");
		Emu.Pause();
		return false;
	}
	if (released >= got_count)
	{
		cellDmux.Error("es::release() error: buffer has not been seen yet");
		Emu.Pause();
		return false;
	}

	u32 addr = 0;
	if (!entries.pop(addr, &dmux->is_closed) || !addr)
	{
		cellDmux.Error("es::release() error: entries.Pop() failed");
		Emu.Pause();
		return false;
	}

	released++;
	return true;
}
Example #7
0
s32 cellGameCreateGameData(vm::ptr<CellGameSetInitParams> init, vm::ptr<char[CELL_GAME_PATH_MAX]> tmp_contentInfoPath, vm::ptr<char[CELL_GAME_PATH_MAX]> tmp_usrdirPath)
{
	cellGame.Error("cellGameCreateGameData(init=*0x%x, tmp_contentInfoPath=*0x%x, tmp_usrdirPath=*0x%x)", init, tmp_contentInfoPath, tmp_usrdirPath);

	std::string dir = init->titleId;
	std::string tmp_contentInfo = "/dev_hdd0/game/TMP_" + dir;
	std::string tmp_usrdir = "/dev_hdd0/game/TMP_" + dir + "/USRDIR";

	if (!Emu.GetVFS().CreateDir(tmp_contentInfo))
	{
		cellGame.Error("cellGameCreateGameData(): failed to create content directory ('%s')", tmp_contentInfo);
		return CELL_GAME_ERROR_ACCESS_ERROR; // ???
	}

	if (!Emu.GetVFS().CreateDir(tmp_usrdir))
	{
		cellGame.Error("cellGameCreateGameData(): failed to create USRDIR directory ('%s')", tmp_usrdir);
		return CELL_GAME_ERROR_ACCESS_ERROR; // ???
	}

	// cellGameContentPermit should then move files in non-temporary location and return their non-temporary displacement
	strcpy_trunc(*tmp_contentInfoPath, tmp_contentInfo);
	strcpy_trunc(*tmp_usrdirPath, tmp_usrdir);

	contentInfo = dir;
	usrdir.clear();
	path_set = true;

	cellGame.Success("cellGameCreateGameData(): temporary gamedata directory created ('%s')", tmp_contentInfo);

	// TODO: set initial PARAM.SFO parameters
	
	return CELL_OK;
}
s32 sys_lwmutex_create(vm::ptr<sys_lwmutex_t> lwmutex, vm::ptr<sys_lwmutex_attribute_t> attr)
{
	sysPrxForUser.Warning("sys_lwmutex_create(lwmutex=*0x%x, attr=*0x%x)", lwmutex, attr);

	const bool recursive = attr->recursive.data() == se32(SYS_SYNC_RECURSIVE);

	if (!recursive && attr->recursive.data() != se32(SYS_SYNC_NOT_RECURSIVE))
	{
		sysPrxForUser.Error("sys_lwmutex_create(): invalid recursive attribute (0x%x)", attr->recursive);
		return CELL_EINVAL;
	}

	const u32 protocol = attr->protocol;

	switch (protocol)
	{
	case SYS_SYNC_FIFO: break;
	case SYS_SYNC_RETRY: break;
	case SYS_SYNC_PRIORITY: break;
	default: sysPrxForUser.Error("sys_lwmutex_create(): invalid protocol (0x%x)", protocol); return CELL_EINVAL;
	}

	lwmutex->lock_var = { { lwmutex::free, lwmutex::zero } };
	lwmutex->attribute = attr->recursive | attr->protocol;
	lwmutex->recursive_count = 0;
	lwmutex->sleep_queue = Emu.GetIdManager().make<lv2_lwmutex_t>(protocol, attr->name_u64);

	return CELL_OK;
}
s32 sys_raw_spu_load(s32 id, vm::ptr<const char> path, vm::ptr<u32> entry)
{
	sysPrxForUser.Warning("sys_raw_spu_load(id=%d, path=*0x%x, entry=*0x%x)", id, path, entry);
	sysPrxForUser.Warning("*** path = '%s'", path.get_ptr());

	vfsFile f(path.get_ptr());
	if(!f.IsOpened())
	{
		sysPrxForUser.Error("sys_raw_spu_load error: '%s' not found!", path.get_ptr());
		return CELL_ENOENT;
	}

	SceHeader hdr;
	hdr.Load(f);

	if (hdr.CheckMagic())
	{
		sysPrxForUser.Error("sys_raw_spu_load error: '%s' is encrypted! Decrypt SELF and try again.", path.get_ptr());
		Emu.Pause();
		return CELL_ENOENT;
	}

	f.Seek(0);

	u32 _entry;
	LoadSpuImage(f, _entry, RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id);

	*entry = _entry | 1;

	return CELL_OK;
}
Example #10
0
bool adecCheckType(AudioCodecType type)
{
	switch (type)
	{
	case CELL_ADEC_TYPE_ATRACX: ConLog.Write("*** (???) type: ATRAC3plus"); break;
	case CELL_ADEC_TYPE_ATRACX_2CH: ConLog.Write("*** type: ATRAC3plus 2ch"); break;

	case CELL_ADEC_TYPE_ATRACX_6CH:
	case CELL_ADEC_TYPE_ATRACX_8CH:
	case CELL_ADEC_TYPE_LPCM_PAMF:
	case CELL_ADEC_TYPE_AC3:
	case CELL_ADEC_TYPE_MP3:
	case CELL_ADEC_TYPE_ATRAC3:
	case CELL_ADEC_TYPE_MPEG_L2:
	case CELL_ADEC_TYPE_CELP:
	case CELL_ADEC_TYPE_M4AAC:
	case CELL_ADEC_TYPE_CELP8:
		cellAdec.Error("Unimplemented audio codec type (%d)", type);
		break;
	default:
		return false;
	}

	return true;
}
Example #11
0
	virtual wxDirTraverseResult OnFile(const wxString& filename)
	{
		if (!wxRemoveFile(filename)){
			cellSysutil.Error("Couldn't delete File: %s", filename.wx_str());
		}
		return wxDIR_CONTINUE;
	}
Example #12
0
s32 sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptr<SceNpTrophyGameDetails> details, vm::ptr<SceNpTrophyGameData> data)
{
	sceNpTrophy.Error("sceNpTrophyGetGameInfo(context=0x%x, handle=0x%x, details=*0x%x, data=*0x%x)", context, handle, details, data);

	const auto ctxt = idm::get<trophy_context_t>(context);

	if (!ctxt)
	{
		return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT;
	}

	const auto hndl = idm::get<trophy_handle_t>(handle);

	if (!hndl)
	{
		return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
	}

	std::string path;
	rXmlDocument doc;
	Emu.GetVFS().GetDevice("/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name + "/TROPCONF.SFM", path);  // TODO: Get the path of the current user
	doc.Load(path);

	std::string titleName;
	std::string titleDetail;
	for (std::shared_ptr<rXmlNode> n = doc.GetRoot()->GetChildren(); n; n = n->GetNext())
	{
		if (n->GetName() == "title-name")
			titleName = n->GetNodeContent();
		if (n->GetName() == "title-detail")
			titleDetail = n->GetNodeContent();
		if (n->GetName() == "trophy")
		{
			u32 trophy_id = atoi(n->GetAttribute("id").c_str());
			
			details->numTrophies++;
			switch (n->GetAttribute("ttype")[0]) {
			case 'B': details->numBronze++;   break;
			case 'S': details->numSilver++;   break;
			case 'G': details->numGold++;     break;
			case 'P': details->numPlatinum++; break;
			}
			
			if (ctxt->tropusr->GetTrophyUnlockState(trophy_id))
			{
				data->unlockedTrophies++;
				switch (n->GetAttribute("ttype")[0]) {
				case 'B': data->unlockedBronze++;   break;
				case 'S': data->unlockedSilver++;   break;
				case 'G': data->unlockedGold++;     break;
				case 'P': data->unlockedPlatinum++; break;
				}
			}
		}
	}

	strcpy_trunc(details->title, titleName);
	strcpy_trunc(details->description, titleDetail);
	return CELL_OK;
}
Example #13
0
int cellPamfReaderSetStreamWithTypeAndChannel(mem_ptr_t<CellPamfReader> pSelf, u8 streamType, u8 ch)
{
	cellPamf.Warning("cellPamfReaderSetStreamWithTypeAndChannel(pSelf=0x%x, streamType=%d, ch=%d)",
		pSelf.GetAddr(), streamType, ch);
	
	if (!pSelf.IsGood() || !Memory.IsGoodAddr(pSelf->pAddr))
		return CELL_PAMF_ERROR_INVALID_ARG;

	const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);

	if (streamType > 5)
	{
		cellPamf.Error("cellPamfReaderSetStreamWithTypeAndChannel: invalid stream type(%d)", streamType);
		//it probably doesn't support "any audio" or "any video" argument
		return CELL_PAMF_ERROR_INVALID_ARG;
	}

	for (u8 i = 0; i < pAddr->stream_count; i++)
	{
		if (pamfGetStreamType(pSelf, i) == streamType) 
		{
			if (pamfGetStreamChannel(pSelf, i) == ch)
			{
				pSelf->stream = i;
				return i;
			}
		}
	}

	return CELL_PAMF_ERROR_STREAM_NOT_FOUND;
}
Example #14
0
s32 sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::ptr<u32> platinumId)
{
	sceNpTrophy.Error("sceNpTrophyUnlockTrophy(context=0x%x, handle=0x%x, trophyId=%d, platinumId=*0x%x)", context, handle, trophyId, platinumId);

	const auto ctxt = idm::get<trophy_context_t>(context);

	if (!ctxt)
	{
		return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT;
	}

	const auto hndl = idm::get<trophy_handle_t>(handle);

	if (!hndl)
	{
		return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
	}

	if (trophyId >= (s32)ctxt->tropusr->GetTrophiesCount())
		return SCE_NP_TROPHY_ERROR_INVALID_TROPHY_ID;
	if (ctxt->tropusr->GetTrophyUnlockState(trophyId))
		return SCE_NP_TROPHY_ERROR_ALREADY_UNLOCKED;

	ctxt->tropusr->UnlockTrophy(trophyId, 0, 0); // TODO
	std::string trophyPath = "/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name + "/TROPUSR.DAT";
	ctxt->tropusr->Save(trophyPath);

	*platinumId = SCE_NP_TROPHY_INVALID_TROPHY_ID; // TODO
	return CELL_OK;
}
Example #15
0
s32 cellSaveDataUserListAutoLoad(PPUThread& ppu, u32 version, u32 userId, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{
	cellSysutil.Error("cellSaveDataUserListAutoLoad(version=%d, userId=%d, errDialog=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
		version, userId, errDialog, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata);

	return savedata_op(ppu, SAVEDATA_OP_LIST_AUTO_LOAD, version, vm::null, errDialog, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 6, userdata, userId, vm::null);
}
Example #16
0
s32 cellSaveDataUserFixedSave(PPUThread& ppu, u32 version, u32 userId, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{
	cellSysutil.Error("cellSaveDataUserFixedSave(version=%d, userId=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
		version, userId, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata);

	return savedata_op(ppu, SAVEDATA_OP_FIXED_SAVE, version, vm::null, 0, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 6, userdata, userId, vm::null);
}
Example #17
0
// Functions
s32 cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr<CellFontConfig> config)
{
	cellFont.Warning("cellFontInitializeWithRevision(revisionFlags=0x%llx, config=*0x%x)", revisionFlags, config);
	
	if (g_font->m_bInitialized)
	{
		return CELL_FONT_ERROR_ALREADY_INITIALIZED;
	}

	if (config->FileCache.size < 24)
	{
		return CELL_FONT_ERROR_INVALID_PARAMETER;
	}

	if (config->flags != 0)
	{
		cellFont.Error("cellFontInitializeWithRevision: Unknown flags (0x%x)", config->flags);
	}

	g_font->m_buffer_addr = config->FileCache.buffer_addr;
	g_font->m_buffer_size = config->FileCache.size;
	g_font->m_userFontEntrys_addr = config->userFontEntrys_addr;
	g_font->m_userFontEntryMax    = config->userFontEntryMax;
	g_font->m_bInitialized = true;
	return CELL_OK;
}
Example #18
0
int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpostCtrlParam> ctrlParam,
				  u32 outPicBuff_addr, mem_ptr_t<CellVpostPictureInfo> picInfo)
{
	cellVpost.Error("cellVpostExec(handle=0x%x, inPicBuff_addr=0x%x, ctrlParam_addr=0x%x, outPicBuff_addr=0x%x, picInfo_addr=0x%x)",
		handle, inPicBuff_addr, ctrlParam.GetAddr(), outPicBuff_addr, picInfo.GetAddr());
	return CELL_OK;
}
Example #19
0
s32 cellSaveDataUserAutoSave(PPUThread& ppu, u32 version, u32 userId, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{
	cellSysutil.Error("cellSaveDataUserAutoSave(version=%d, userId=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
		version, userId, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata);

	return savedata_op(ppu, SAVEDATA_OP_AUTO_SAVE, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null);
}
Example #20
0
s32 cellGameGetParamInt(u32 id, vm::ptr<u32> value)
{
	cellGame.Warning("cellGameGetParamInt(id=%d, value=*0x%x)", id, value);

	// TODO: Access through cellGame***Check functions
	vfsFile f("/app_home/../PARAM.SFO");
	const PSFLoader psf(f);

	if (!psf)
	{
		return CELL_GAME_ERROR_FAILURE;
	}

	switch(id)
	{
	case CELL_GAME_PARAMID_PARENTAL_LEVEL: *value = psf.GetInteger("PARENTAL_LEVEL"); break;
	case CELL_GAME_PARAMID_RESOLUTION:     *value = psf.GetInteger("RESOLUTION");     break;
	case CELL_GAME_PARAMID_SOUND_FORMAT:   *value = psf.GetInteger("SOUND_FORMAT");   break;

	default:
		cellGame.Error("cellGameGetParamInt(): Unimplemented parameter (%d)", id);
		return CELL_GAME_ERROR_INVALID_ID;
	}

	return CELL_OK;
}
Example #21
0
int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_struct_ptr_t<CellPngDecDataCtrlParam> dataCtrlParam, mem_struct_ptr_t<CellPngDecDataOutInfo> dataOutInfo)
{
	dataOutInfo->status = CELL_PNGDEC_DEC_STATUS_STOP;
	ID sub_handle_id_data;
	if(!cellPngDec.CheckId(subHandle, sub_handle_id_data))
		return CELL_PNGDEC_ERROR_FATAL;

	auto subHandle_data = (CellPngDecSubHandle*)sub_handle_id_data.m_data;

	const u32& fd = subHandle_data->fd;
	const u64& fileSize = subHandle_data->fileSize;
	const CellPngDecOutParam& current_outParam = subHandle_data->outParam;

	//Copy the PNG file to a buffer
	MemoryAllocator<unsigned char> png(fileSize);
	MemoryAllocator<u64> pos, nread;
	cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
	cellFsRead(fd, png.GetAddr(), png.GetSize(), nread);

	//Decode PNG file. (TODO: Is there any faster alternative? Can we do it without external libraries?)
	int width, height, actual_components;
	std::shared_ptr<unsigned char> image(stbi_load_from_memory(png, fileSize, &width, &height, &actual_components, 4));
	if (!image)	return CELL_PNGDEC_ERROR_STREAM_FORMAT;

	uint image_size = width * height;
	switch(current_outParam.outputColorSpace)
	{
	case CELL_PNGDEC_RGB:
	case CELL_PNGDEC_RGBA:
		image_size *= current_outParam.outputColorSpace == CELL_PNGDEC_RGBA ? 4 : 3;
		memcpy(data, image.get(), image_size);
	break;

	case CELL_PNGDEC_ARGB:
		image_size *= 4;

		for(uint i = 0; i < image_size; i+=4)
		{
			data += image.get()[i+3];
			data += image.get()[i+0];
			data += image.get()[i+1];
			data += image.get()[i+2];
		}
	break;

	case CELL_PNGDEC_GRAYSCALE:
	case CELL_PNGDEC_PALETTE:
	case CELL_PNGDEC_GRAYSCALE_ALPHA:
		cellPngDec.Error("cellPngDecDecodeData: Unsupported color space (%d)", current_outParam.outputColorSpace.ToLE());
	break;

	default:
		return CELL_PNGDEC_ERROR_ARG;
	}

	dataOutInfo->status = CELL_PNGDEC_DEC_STATUS_FINISH;

	return CELL_OK;
}
Example #22
0
s32 cellSysutilAvc2InitParam(u16 version, vm::ptr<CellSysutilAvc2InitParam> option)
{
	cellSysutilAvc2.Warning("cellSysutilAvc2InitParam(version=%d, option=*0x%x)", version, option);

	if (version >= 110)
	{
		// Notify the user that, a version different from the one, that we know the constants for, is used.
		// Other versions shouldn't differ by too much, if at all - they most likely differ in other functions.
		if (version != 140)
		{
			cellSysutilAvc2.Todo("cellSysutilAvc2InitParam(): Older/newer version %d used, might cause problems.", version);
		}

		option->avc_init_param_version = version;

		if (option->media_type == CELL_SYSUTIL_AVC2_VOICE_CHAT)
		{
			option->max_players = 16;
		}
		else if (option->media_type == CELL_SYSUTIL_AVC2_VIDEO_CHAT)
		{
			if (option->video_param.frame_mode == CELL_SYSUTIL_AVC2_FRAME_MODE_NORMAL)
			{
				option->max_players = 6;
			}
			else if (option->video_param.frame_mode == CELL_SYSUTIL_AVC2_FRAME_MODE_INTRA_ONLY)
			{
				option->max_players = 16;
			}
			else
			{
				cellSysutilAvc2.Error("Unknown frame mode 0x%x", option->video_param.frame_mode);
			}
		}
		else
		{
			cellSysutilAvc2.Error("Unknown media type 0x%x", option->media_type);
		}
	}
	else
	{
		cellSysutilAvc2.Error("cellSysutilAvc2InitParam(): Unknown version %d used, please report this to a developer.", version);
	}

	return CELL_OK;
}
Example #23
0
int cellFsOpendir(u32 path_addr, mem32_t fd)
{
	const wxString& path = Memory.ReadString(path_addr);
	sys_fs.Error("cellFsOpendir(path_addr: 0x%x(%s), fd_addr: 0x%x)", path_addr, path.mb_str(), fd.GetAddr());
	if(!Memory.IsGoodAddr(path_addr) || !fd.IsGood()) return CELL_EFAULT;

	return CELL_OK;
}
Example #24
0
u32 vdecQueryAttr(CellVdecCodecType type, u32 profile, u32 spec_addr /* may be 0 */, mem_ptr_t<CellVdecAttr> attr)
{
	switch (type) // TODO: check profile levels
	{
	case CELL_VDEC_CODEC_TYPE_AVC: cellVdec.Warning("cellVdecQueryAttr: AVC (profile=%d)", profile); break;
	case CELL_VDEC_CODEC_TYPE_MPEG2: cellVdec.Error("TODO: MPEG2 not supported"); break;
	case CELL_VDEC_CODEC_TYPE_DIVX: cellVdec.Error("TODO: DIVX not supported"); break;
	default: return CELL_VDEC_ERROR_ARG;
	}

	// TODO: check values
	attr->decoderVerLower = 0x280000; // from dmux
	attr->decoderVerUpper = 0x260000;
	attr->memSize = 4 * 1024 * 1024;
	attr->cmdDepth = 16;
	return CELL_OK;
}
Example #25
0
int cellFsUnlink(u32 path_addr)
{
	const wxString& ps3_path = Memory.ReadString(path_addr);
	wxString path;
	Emu.GetVFS().GetDevice(ps3_path, path);
	sys_fs.Error("cellFsUnlink(path: %s)", path.mb_str());
	return CELL_OK;
}
Example #26
0
s32 cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameContentSize> size)
{
	cellGame.Warning("cellGameDataCheck(type=%d, dirName=*0x%x, size=*0x%x)", type, dirName, size);

	if ((type - 1) >= 3)
	{
		cellGame.Error("cellGameDataCheck(): CELL_GAME_ERROR_PARAM");
		return CELL_GAME_ERROR_PARAM;
	}

	if (size)
	{
		// TODO: Use the free space of the computer's HDD where RPCS3 is being run.
		size->hddFreeSizeKB = 40000000; //40 GB

		// TODO: Calculate data size for game data, if necessary.
		size->sizeKB = CELL_GAME_SIZEKB_NOTCALC;
		size->sysSizeKB = 0;
	}

	if (type == CELL_GAME_GAMETYPE_DISC)
	{
		// TODO: not sure what should be checked there

		if (!Emu.GetVFS().ExistsDir("/dev_bdvd/PS3_GAME"))
		{
			cellGame.Warning("cellGameDataCheck(): /dev_bdvd/PS3_GAME not found");
			contentInfo = "";
			usrdir = "";
			path_set = true;
			return CELL_GAME_RET_NONE;
		}

		contentInfo = "/dev_bdvd/PS3_GAME";
		usrdir = "/dev_bdvd/PS3_GAME/USRDIR";
		path_set = true;
	}
	else
	{
		const std::string dir = std::string("/dev_hdd0/game/") + dirName.get_ptr();

		if (!Emu.GetVFS().ExistsDir(dir))
		{
			cellGame.Warning("cellGameDataCheck(): '%s' directory not found", dir.c_str());
			contentInfo = "";
			usrdir = "";
			path_set = true;
			return CELL_GAME_RET_NONE;
		}

		contentInfo = dir;
		usrdir = dir + "/USRDIR";
		path_set = true;
	}

	return CELL_GAME_RET_OK;
}
Example #27
0
int _cellSpursSendSignal(mem_ptr_t<CellSpursTaskset> taskset, u32 taskID)
{
	cellSpurs.Error("_cellSpursSendSignal(taskset_addr=0x%x, taskID=%u)", taskset.GetAddr(), taskID);
	
	if(!taskset.IsGood())
		return CELL_SPURS_CORE_ERROR_NULL_POINTER;

	return CELL_OK;
}
Example #28
0
int cellSpursGetTasksetId(mem_ptr_t<CellSpursTaskset> taskset, mem32_t workloadId)
{
	cellSpurs.Error("cellSpursGetTasksetId(taskset_addr=0x%x, workloadId_addr=0x%x)", taskset.GetAddr(), workloadId.GetAddr());
	
	if(!taskset.IsGood() || !workloadId.IsGood())
		return CELL_SPURS_TASK_ERROR_NULL_POINTER;

	return CELL_OK;
}
Example #29
0
int cellSpursShutdownTaskset(mem_ptr_t<CellSpursTaskset> taskset)
{
	cellSpurs.Error("cellSpursShutdownTaskset(taskset_addr=0x%x)", taskset.GetAddr());
	
	if(!taskset.IsGood())
		return CELL_SPURS_TASK_ERROR_NULL_POINTER;

	return CELL_OK;
}
Example #30
0
int cellPamfReaderGetEpIteratorWithTimeStamp(mem_ptr_t<CellPamfReader> pSelf, mem_ptr_t<CellCodecTimeStamp> pTimeStamp, mem_ptr_t<CellPamfEpIterator> pIt)
{
	cellPamf.Error("cellPamfReaderGetEpIteratorWithTimeStamp(pSelf=0x%x, pTimeStamp_addr=0x%x, pIt_addr=0x%x)",
		pSelf.GetAddr(), pTimeStamp.GetAddr(), pIt.GetAddr());

	const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);
	//TODO:
	return CELL_OK;
}