mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 07:20:49 +00:00
Ensure safe zim access regardless of file contents.
This commit is contained in:
parent
a191b9ac7f
commit
d497bc7c8c
@ -164,19 +164,19 @@ void __PPGeInit()
|
||||
NOTICE_LOG(SCEGE, "Not initializing PPGe - GPU is NullGpu");
|
||||
return;
|
||||
}
|
||||
u8 *imageData;
|
||||
int width;
|
||||
int height;
|
||||
u8 *imageData[12];
|
||||
int width[12];
|
||||
int height[12];
|
||||
int flags;
|
||||
if (!LoadZIM("ppge_atlas.zim", &width, &height, &flags, &imageData)) {
|
||||
if (!LoadZIM("ppge_atlas.zim", width, height, &flags, imageData)) {
|
||||
PanicAlert("Failed to load ppge_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory.");
|
||||
ERROR_LOG(SCEGE, "PPGe init failed - no atlas texture. PPGe stuff will not be drawn.");
|
||||
return;
|
||||
}
|
||||
|
||||
u32 atlasSize = height * width / 2; // it's a 4-bit paletted texture in ram
|
||||
atlasWidth = width;
|
||||
atlasHeight = height;
|
||||
u32 atlasSize = height[0] * width[0] / 2; // it's a 4-bit paletted texture in ram
|
||||
atlasWidth = width[0];
|
||||
atlasHeight = height[0];
|
||||
dlPtr = __PPGeDoAlloc(dlSize, false, "PPGe Display List");
|
||||
dataPtr = __PPGeDoAlloc(dataSize, false, "PPGe Vertex Data");
|
||||
__PPGeSetupListArgs();
|
||||
@ -189,11 +189,11 @@ void __PPGeInit()
|
||||
palette[i] = (val << 12) | 0xFFF;
|
||||
}
|
||||
|
||||
const u32_le *imagePtr = (u32_le *)imageData;
|
||||
const u32_le *imagePtr = (u32_le *)imageData[0];
|
||||
u8 *ramPtr = (u8 *)Memory::GetPointer(atlasPtr);
|
||||
|
||||
// Palettize to 4-bit, the easy way.
|
||||
for (int i = 0; i < width * height / 2; i++) {
|
||||
for (int i = 0; i < width[0] * height[0] / 2; i++) {
|
||||
// Each pixel is 16 bits, so this loads two pixels.
|
||||
u32 c = imagePtr[i];
|
||||
// It's white anyway, so we only look at one channel of each pixel.
|
||||
@ -203,7 +203,7 @@ void __PPGeInit()
|
||||
ramPtr[i] = cval;
|
||||
}
|
||||
|
||||
free(imageData);
|
||||
free(imageData[0]);
|
||||
|
||||
DEBUG_LOG(SCEGE, "PPGe drawing library initialized. DL: %08x Data: %08x Atlas: %08x (%i) Args: %08x",
|
||||
dlPtr, dataPtr, atlasPtr, atlasSize, listArgs.ptr);
|
||||
|
Loading…
Reference in New Issue
Block a user