CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/HLE/sceAdler.cpp
Views: 1401
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#ifdef SHARED_ZLIB
19
#include <zlib.h>
20
#else
21
#include "../ext/zlib/zlib.h"
22
#endif
23
24
#include "sceAdler.h"
25
#include "Common/Log.h"
26
#include "Core/HLE/HLE.h"
27
#include "Core/HLE/FunctionWrappers.h"
28
29
static u32 sceAdler32(u32 adler, u32 data, u32 datalen) {
30
if (!Memory::IsValidAddress(data) || !Memory::IsValidAddress(data + datalen - 1)) {
31
ERROR_LOG(Log::sceMisc, "sceAdler32(adler=%08x, data=%08x, datalen=%08x) - bad address(es)", adler, data, datalen);
32
return -1;
33
}
34
INFO_LOG(Log::sceMisc, "sceAdler32(adler=%08x, data=%08x, datalen=%08x)", adler, data, datalen);
35
36
u8 *buf = Memory::GetPointerWriteUnchecked(data);
37
u32 ret = adler32(adler, buf, datalen);
38
39
return ret;
40
}
41
42
const HLEFunction sceAdler[] = {
43
{0X9702EF11, &WrapU_UUU<sceAdler32>, "sceAdler32", 'x', "xxx"},
44
};
45
46
void Register_sceAdler() {
47
RegisterModule("sceAdler", ARRAY_SIZE(sceAdler), sceAdler);
48
}
49
50