Update stb_image, clean up some warnings.
This commit is contained in:
parent
d42477ecac
commit
991582f4a8
2
Makefile
2
Makefile
@ -23,7 +23,7 @@ EXTRA_OUTPUT_FILES :=
|
|||||||
LIBRARY_DIRS :=
|
LIBRARY_DIRS :=
|
||||||
LIBRARIES :=
|
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_CC :=
|
||||||
BUILD_FLAGS_CXX :=
|
BUILD_FLAGS_CXX :=
|
||||||
RUN_FLAGS :=
|
RUN_FLAGS :=
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
// Ported from: https://github.com/svn2github/3DS-Explorer/blob/master/3DSExplorer/DSDecmp/Formats/Nitro/LZ11.cs
|
// 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) {
|
if(disp != NULL) {
|
||||||
*disp = 0;
|
*disp = 0;
|
||||||
}
|
}
|
||||||
@ -18,11 +18,11 @@ int lz11_get_occurence_length(u8* newPtr, int newLength, u8* oldPtr, int oldLeng
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxLength = 0;
|
u32 maxLength = 0;
|
||||||
for(int i = 0; i < oldLength - 1; i++) {
|
for(u32 i = 0; i < oldLength - 1; i++) {
|
||||||
u8* currentOldStart = oldPtr + i;
|
u8* currentOldStart = oldPtr + i;
|
||||||
int currentLength = 0;
|
u32 currentLength = 0;
|
||||||
for(int j = 0; j < newLength; j++) {
|
for(u32 j = 0; j < newLength; j++) {
|
||||||
if(*(currentOldStart + j) != *(newPtr + j)) {
|
if(*(currentOldStart + j) != *(newPtr + j)) {
|
||||||
break;
|
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) };
|
u8 header[4] = { 0x11, (u8) (inputSize & 0xFF), (u8) ((inputSize >> 8) & 0xFF), (u8) ((inputSize >> 16) & 0xFF) };
|
||||||
ss.write((char*) header, 4);
|
ss.write((char*) header, 4);
|
||||||
|
|
||||||
int compressedLength = 4;
|
u32 compressedLength = 4;
|
||||||
u8 outbuffer[8 * 4 + 1];
|
u8 outbuffer[8 * 4 + 1];
|
||||||
outbuffer[0] = 0;
|
outbuffer[0] = 0;
|
||||||
int bufferlength = 1;
|
u32 bufferlength = 1;
|
||||||
int bufferedBlocks = 0;
|
u32 bufferedBlocks = 0;
|
||||||
int readBytes = 0;
|
u32 readBytes = 0;
|
||||||
while(readBytes < inputSize) {
|
while(readBytes < inputSize) {
|
||||||
if(bufferedBlocks == 8) {
|
if(bufferedBlocks == 8) {
|
||||||
ss.write((char*) outbuffer, bufferlength);
|
ss.write((char*) outbuffer, bufferlength);
|
||||||
@ -71,9 +71,9 @@ void* lz11_compress(u32* size, void* input, u32 inputSize) {
|
|||||||
bufferedBlocks = 0;
|
bufferedBlocks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int disp = 0;
|
u32 disp = 0;
|
||||||
int oldLength = MIN(readBytes, 0x1000);
|
u32 oldLength = MIN(readBytes, 0x1000);
|
||||||
int length = lz11_get_occurence_length((u8*) input + readBytes, MIN(inputSize - readBytes, 0x10110), (u8*) input + readBytes - oldLength, oldLength, &disp);
|
u32 length = lz11_get_occurence_length((u8*) input + readBytes, MIN(inputSize - readBytes, 0x10110), (u8*) input + readBytes - oldLength, oldLength, &disp);
|
||||||
if(length < 3) {
|
if(length < 3) {
|
||||||
outbuffer[bufferlength++] = *((u8*) input + (readBytes++));
|
outbuffer[bufferlength++] = *((u8*) input + (readBytes++));
|
||||||
} else {
|
} else {
|
||||||
@ -110,7 +110,7 @@ void* lz11_compress(u32* size, void* input, u32 inputSize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(compressedLength % 4 != 0) {
|
if(compressedLength % 4 != 0) {
|
||||||
int padLength = 4 - (compressedLength % 4);
|
u32 padLength = 4 - (compressedLength % 4);
|
||||||
u8 pad[padLength];
|
u8 pad[padLength];
|
||||||
memset(pad, 0, (size_t) padLength);
|
memset(pad, 0, (size_t) padLength);
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ static void* read_file(u32* size, const std::string& file) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 bufferSize = (u32) tell;
|
size_t bufferSize = (size_t) tell;
|
||||||
void* buffer = malloc(bufferSize);
|
void* buffer = malloc(bufferSize);
|
||||||
if(buffer == NULL) {
|
if(buffer == NULL) {
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
@ -59,7 +59,7 @@ static void* read_file(u32* size, const std::string& file) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
long readRet = fread(buffer, 1, bufferSize, fd);
|
size_t readRet = fread(buffer, 1, bufferSize, fd);
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ static bool write_file(void* contents, u32 size, const std::string& file) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
long writeRet = fwrite(contents, 1, size, fd);
|
size_t writeRet = fwrite(contents, 1, size, fd);
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ static void* load_image(const std::string& file, u32 width, u32 height) {
|
|||||||
height = (u32) imgHeight;
|
height = (u32) imgHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(imgWidth != width || imgHeight != height) {
|
if((u32) imgWidth != width || (u32) imgHeight != height) {
|
||||||
stbi_image_free(img);
|
stbi_image_free(img);
|
||||||
|
|
||||||
printf("ERROR: Image must be exactly %d x %d in size.\n", width, height);
|
printf("ERROR: Image must be exactly %d x %d in size.\n", width, height);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user