Update stb_image, clean up some warnings.

This commit is contained in:
Steveice10 2018-04-10 17:07:31 -07:00
parent d42477ecac
commit 991582f4a8
5 changed files with 1568 additions and 707 deletions

View File

@ -23,7 +23,7 @@ EXTRA_OUTPUT_FILES :=
LIBRARY_DIRS :=
LIBRARIES :=
BUILD_FLAGS := -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation -Wno-unused-function
BUILD_FLAGS := -Wno-unused-function
BUILD_FLAGS_CC :=
BUILD_FLAGS_CXX :=
RUN_FLAGS :=

View File

@ -9,7 +9,7 @@
// Ported from: https://github.com/svn2github/3DS-Explorer/blob/master/3DSExplorer/DSDecmp/Formats/Nitro/LZ11.cs
int lz11_get_occurence_length(u8* newPtr, int newLength, u8* oldPtr, int oldLength, int* disp) {
u32 lz11_get_occurence_length(u8* newPtr, u32 newLength, u8* oldPtr, u32 oldLength, u32* disp) {
if(disp != NULL) {
*disp = 0;
}
@ -18,11 +18,11 @@ int lz11_get_occurence_length(u8* newPtr, int newLength, u8* oldPtr, int oldLeng
return 0;
}
int maxLength = 0;
for(int i = 0; i < oldLength - 1; i++) {
u32 maxLength = 0;
for(u32 i = 0; i < oldLength - 1; i++) {
u8* currentOldStart = oldPtr + i;
int currentLength = 0;
for(int j = 0; j < newLength; j++) {
u32 currentLength = 0;
for(u32 j = 0; j < newLength; j++) {
if(*(currentOldStart + j) != *(newPtr + j)) {
break;
}
@ -56,12 +56,12 @@ void* lz11_compress(u32* size, void* input, u32 inputSize) {
u8 header[4] = { 0x11, (u8) (inputSize & 0xFF), (u8) ((inputSize >> 8) & 0xFF), (u8) ((inputSize >> 16) & 0xFF) };
ss.write((char*) header, 4);
int compressedLength = 4;
u32 compressedLength = 4;
u8 outbuffer[8 * 4 + 1];
outbuffer[0] = 0;
int bufferlength = 1;
int bufferedBlocks = 0;
int readBytes = 0;
u32 bufferlength = 1;
u32 bufferedBlocks = 0;
u32 readBytes = 0;
while(readBytes < inputSize) {
if(bufferedBlocks == 8) {
ss.write((char*) outbuffer, bufferlength);
@ -71,9 +71,9 @@ void* lz11_compress(u32* size, void* input, u32 inputSize) {
bufferedBlocks = 0;
}
int disp = 0;
int oldLength = MIN(readBytes, 0x1000);
int length = lz11_get_occurence_length((u8*) input + readBytes, MIN(inputSize - readBytes, 0x10110), (u8*) input + readBytes - oldLength, oldLength, &disp);
u32 disp = 0;
u32 oldLength = MIN(readBytes, 0x1000);
u32 length = lz11_get_occurence_length((u8*) input + readBytes, MIN(inputSize - readBytes, 0x10110), (u8*) input + readBytes - oldLength, oldLength, &disp);
if(length < 3) {
outbuffer[bufferlength++] = *((u8*) input + (readBytes++));
} else {
@ -110,7 +110,7 @@ void* lz11_compress(u32* size, void* input, u32 inputSize) {
}
if(compressedLength % 4 != 0) {
int padLength = 4 - (compressedLength % 4);
u32 padLength = 4 - (compressedLength % 4);
u8 pad[padLength];
memset(pad, 0, (size_t) padLength);

View File

@ -50,7 +50,7 @@ static void* read_file(u32* size, const std::string& file) {
return NULL;
}
u32 bufferSize = (u32) tell;
size_t bufferSize = (size_t) tell;
void* buffer = malloc(bufferSize);
if(buffer == NULL) {
fclose(fd);
@ -59,7 +59,7 @@ static void* read_file(u32* size, const std::string& file) {
return NULL;
}
long readRet = fread(buffer, 1, bufferSize, fd);
size_t readRet = fread(buffer, 1, bufferSize, fd);
fclose(fd);
@ -84,7 +84,7 @@ static bool write_file(void* contents, u32 size, const std::string& file) {
return false;
}
long writeRet = fwrite(contents, 1, size, fd);
size_t writeRet = fwrite(contents, 1, size, fd);
fclose(fd);
@ -114,7 +114,7 @@ static void* load_image(const std::string& file, u32 width, u32 height) {
height = (u32) imgHeight;
}
if(imgWidth != width || imgHeight != height) {
if((u32) imgWidth != width || (u32) imgHeight != height) {
stbi_image_free(img);
printf("ERROR: Image must be exactly %d x %d in size.\n", width, height);

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
#include <sstream>
#include <errno.h>
#include <stdlib.h>
#include <string.h>