From d4c6605a12d31e84d1cba2f5ef7329bcb99c8aaf Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Sun, 12 Sep 2021 19:39:06 +0200 Subject: Migrated libpsn00b to CMake --- libpsn00b/include/lzp/lzp.h | 223 ++++++++++++++++++++++++++++++++++++++++++ libpsn00b/include/lzp/lzqlp.h | 26 +++++ 2 files changed, 249 insertions(+) create mode 100644 libpsn00b/include/lzp/lzp.h create mode 100644 libpsn00b/include/lzp/lzqlp.h (limited to 'libpsn00b/include') diff --git a/libpsn00b/include/lzp/lzp.h b/libpsn00b/include/lzp/lzp.h new file mode 100644 index 0000000..ffd7933 --- /dev/null +++ b/libpsn00b/include/lzp/lzp.h @@ -0,0 +1,223 @@ +/*! \file lzp.h + * \brief Main library header + */ + +/*! \mainpage + * \version 0.20b + * \author John Wilbert 'Lameguy64' Villamor + * + * \section creditsSection Credits + * - LZ77 data compression/decompression routines based from Ilya Muravyov's + * crush.cpp released under public domain. Refined and ported to C by Lameguy64. + * - CRC calculation routines based from Lammert Bies' lib_crc routines. + * + */ + +#ifndef _LZPACK_H +#define _LZPACK_H + +#include +#ifdef _WIN32 +#include +#endif + +/*! \addtogroup crcBaseRemainders CRC Base Remainder Values + * @{ + */ +//! Initial remainder value for lzCRC16() +#define LZP_CRC16_REMAINDER 0x0000 +//! Initial remainder value for lzCRC32() +#define LZP_CRC32_REMAINDER 0xFFFFFFFF +/*! @} */ + + +/*! \addtogroup compLevels Compression Levels + * \brief Compression levels for the lzCompress() function. + * @{ + */ +//! Minimal (but fast) compression +#define LZP_COMPRESS_FAST 0 +//! Normal compression level +#define LZP_COMPRESS_NORMAL 1 +//! Maximum compression level +#define LZP_COMPRESS_MAX 2 +/*! @} */ + + +/*! \addtogroup libraryErrorCodes Library Error Codes + * @{ + */ +//! No error +#define LZP_ERR_NONE 0 +//! Decompression error +#define LZP_ERR_DECOMPRESS -1 +//! Not a valid LZP/QLP/PCK archive +#define LZP_ERR_INVALID_PACK -2 +//! File not found +#define LZP_ERR_NOTFOUND -3 +//! CRC check mismatch (data corruption) +#define LZP_ERR_CRC_MISMATCH -4 +/*! @} */ + + +//! Header structure of an LZP format archive file +typedef struct { + + //! File ID (must always be 'LZP') + char id[3]; + //! File count + u_char numFiles; + +} LZP_HEAD; + +//! File entry structure for an LZP format archive file +typedef struct { + + //! File name + char fileName[16]; + //! CRC32 checksum of file + u_int crc; + //! Original size of file in bytes + u_int fileSize; + //! Compressed size of file + u_int packedSize; + //! File data offset + u_int offset; + +} LZP_FILE; + + +// Function prototypes +#ifdef __cplusplus +extern "C" { +#endif + + +/*! \addtogroup compressFuncs Data Compression and Decompression Functions + * \brief Functions to compress and decompress data. + * @{ + */ + +/*! Compress a block of data. + * + * \details This function compresses a specified block of data in LZ77 encoding. + * Depending on the size of the input data and speed of the computer, compression + * may take a while to complete. + * + * \param[out] *outBuff Pointer to buffer to store compressed data. + * \param[in] *inBuff Pointer to data to compress. + * \param[in] inSize Size of data to compress in bytes. + * \param[in] level Compression level (see \ref compLevels). + * + * \returns The size of the compressed data in bytes. + */ +int lzCompress(void* outBuff, void* inBuff, int inSize, int level); + +/*! Decompress a compressed block of data. + * + * \details Decompressed a compressed block of data produced by lzCompress(). It cannot + * return the decompressed size of the data ahead of time so you must preserve the decompressed + * size of the data yourself. + * + * \note The decompression algorithm used in this function is completely independent + * of the compression settings set by lzSetHashSizes() before compressing the data with + * lzCompress(). + * + * \param[out] *outBuff Pointer to buffer to store decompressed data. + * \param[in] *inBuff Pointer to compressed data to decompress. + * \param[in] inSize Compressed data size in bytes. + * + * \returns Size of decompressed data in bytes or LZP_ERR_DECOMPRESS if a + * decompression error occurred. + */ +int lzDecompress(void* outBuff, void* inBuff, int inSize); + +int lzDecompressLen(void* outBuff, int outSize, void* inBuff, int inSize); + +/*! Sets the sizes of hash tables for data compression. + * + * \param[in] window Sliding window size. + * \param[in] hash1 Hash table 1 size. + * \param[in] hash2 Hash table 2 size. + */ +void lzSetHashSizes(int window, int hash1, int hash2); + +/*! Reset the sizes of hash tables to their defaults. + */ +void lzResetHashSizes(); + +/*! @} */ + + +/*! \addtogroup crcFuncs CRC Hashing Functions + * \brief Functions to calculate CRC hashes of data. + * @{ + */ + +/*! Calculates a CRC16 hash of the specified buffer. + * + * \param[in] *buff Pointer to buffer to calculate a hash of. + * \param[in] bytes Size of buffer in bytes. + * \param[in] crc CRC remainder (use LZP_CRC16_REMAINDER). + * + * \returns CRC16 hash of specified buffer. + */ +unsigned short lzCRC16(void* buff, int bytes, unsigned short crc); + +/*! Calculates a CRC32 hash of the specified buffer. + * + * \param[in] *buff Pointer to buffer to calculate a hash of. + * \param[in] bytes Size of buffer in bytes. + * \param[in] crc CRC remainder (use LZP_CRC16_REMAINDER). + * + * \returns CRC32 hash of specified buffer. + */ +unsigned int lzCRC32(void* buff, int bytes, unsigned int crc); + +/*! @} */ + + +/*! \addtogroup lzpFunctions LZP Archive Handling Routines + * \brief Functions to index and unpack files from LZP archives. + * @{ + */ + +/*! Searches for a file by name in an LZP archive and returns a file entry number. + * + * \param[in] *fileName String of file to search (must be less than 13 characters). + * \param[in] *lzpack Pointer to LZP archive file. + * + * \returns File index of found file or one of \ref libraryErrorCodes if an error occurred. + */ +int lzpSearchFile(const char* fileName, void* lzpack); + +int lzpFileSize(void* lzpack, int fileNum); + +/*! Get a pointer to a file entry inside of an LZP archive. + * + * \param[in] *lzpack Pointer to LZP archive file. + * \param[in] fileNum File number to get an entry of (you may use lzpSearchFile()). + * + * \returns A pointer to an LZP_FILE struct or NULL if an error occurred. + */ +LZP_FILE* lzpFileEntry(void* lzpack, int fileNum); + +/*! Unpacks a file from an LZP archive to the specified memory buffer. + * + * \param[in] *buff Pointer to buffer to store unpacked file. + * \param[in] *lzpack Pointer to LZP archive file. + * \param[in] fileNum File entry number of file to extract (you may use lzpSearchFile()). + * + * \returns Size of decompressed file in bytes or one of \ref libraryErrorCodes if an error occurred. + */ +int lzpUnpackFile(void* buff, void* lzpack, int fileNum); + +/*! @} */ + + +#ifdef __cplusplus +} +#endif + + +#endif // _LZPACK_H diff --git a/libpsn00b/include/lzp/lzqlp.h b/libpsn00b/include/lzp/lzqlp.h new file mode 100644 index 0000000..fae6438 --- /dev/null +++ b/libpsn00b/include/lzp/lzqlp.h @@ -0,0 +1,26 @@ +#ifndef _QLP_H +#define _QLP_H + +#define PACK_ERR_NONE 0 +#define PACK_ERR_INVALID -1 +#define PACK_ERR_NOTFOUND -2 +#define PACK_ERR_INCOMPLETE -3 +#define PACK_ERR_READ_FAULT -4 + +typedef struct { + char id[3]; + unsigned char numfiles; +} QLP_HEAD; + +typedef struct { + char name[16]; + unsigned int size; + unsigned int offs; +} QLP_FILE; + +int qlpFileCount(void* qlpfile); +QLP_FILE* qlpFileEntry(int index, void* qlpfile); +void* qlpFileAddr(int index, void* qlpfile); +int qlpFindFile(char* fileName, void* qlpfile); + +#endif // _QLP_H \ No newline at end of file -- cgit v1.2.3 From 5bc36dfcfc64e48401a9c6472062020681b3511f Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Mon, 13 Sep 2021 18:09:53 +0200 Subject: Misc. CMake bug and typo fixes, updated changelog --- .gitignore | 10 +++++++++- CMakeLists.txt | 8 ++++++-- changelog.txt | 25 +++++++++++++++++++++++++ libpsn00b/include/dlfcn.h | 2 +- 4 files changed, 41 insertions(+), 4 deletions(-) (limited to 'libpsn00b/include') diff --git a/.gitignore b/.gitignore index bf1de1f..71a3cea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,21 @@ .svn +.vscode +.DS_Store build bin old scrap *.a *.o +*.obj *.elf +*.so *.exe +*.map +*.dll *.lzp *.qlp *.iso -*.rom \ No newline at end of file +*.rom +*.code-workspace +CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cca098..71f9acf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ set( ) set( SKIP_EXAMPLES OFF - CACHE BOOL "Skip building SDK examples (which are never installed)" + CACHE BOOL "Skip building SDK examples (not required for installation)" ) # Forward some important variables to mkpsxiso and to the subprojects (they are @@ -54,6 +54,7 @@ set( -DPSN00BSDK_TARGET:STRING=${PSN00BSDK_TARGET} -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX:PATH=${PROJECT_BINARY_DIR}/install_tree + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} ) set( EXAMPLES_ARGS @@ -61,6 +62,7 @@ set( -DPSN00BSDK_TARGET:STRING=${PSN00BSDK_TARGET} -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${PROJECT_BINARY_DIR}/install_tree/${CMAKE_INSTALL_LIBDIR}/libpsn00b/cmake/sdk.cmake -DCMAKE_INSTALL_PREFIX:PATH=${PROJECT_BINARY_DIR}/examples + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} ) ## External dependencies @@ -130,9 +132,11 @@ install( ## CPack configuration -# TODO: add a macOS installer and related options if(WIN32) set(CPACK_GENERATOR ZIP NSIS) +elseif(APPLE) + # TODO: add a macOS installer and related options + set(CPACK_GENERATOR ZIP) elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(CPACK_GENERATOR ZIP DEB RPM) else() diff --git a/changelog.txt b/changelog.txt index 15bbb85..03d2d10 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,31 @@ PSn00bSDK changelog Items that are lower in the log are more recently implemented. +09-13-2021 by spicyjpeg: + +* Migrated libpsn00b, tools, examples and template to CMake, added a top-level + CMakeLists.txt and the libpsn00b/cmake directory for CMake setup scripts, got + rid of the old makefiles and installation method. + +* Updated docs to match the new build system, moved installation instructions + to INSTALL.md and added doc/cmake_reference.md describing the SDK's CMake + API and variables. + +* mkpsxiso: Added rules to automatically download, build and install mkpsxiso + (as well as its dependencies) as part of the SDK. + +* cpack: Added initial CPack support and created the cpack directory containing + branding assets for installers built through CPack. A shell script is + provided to regenerate the assets from their source SVGs. + +* liblzp: Copied library headers to libpsn00b/include/lzp. + +* psxetc: Fixed a random typo in a javadoc comment (those should be eventually + rewritten into proper documentation anyway). + +* Added CMake, VS Code and DLL related entries to .gitignore. + + 08-16-2021 by spicyjpeg: * psxetc: Added dynamic linking APIs (dl*, DL_*), implemented in dl.c and diff --git a/libpsn00b/include/dlfcn.h b/libpsn00b/include/dlfcn.h index 5fdd343..0c51821 100644 --- a/libpsn00b/include/dlfcn.h +++ b/libpsn00b/include/dlfcn.h @@ -119,7 +119,7 @@ void DL_SetResolveCallback(void *(*callback)(DLL *, const char *)); * * The third argument specifies when symbols in the DLL should be resolved. * Setting it to RTLD_LAZY defers resolution of undefined functions to when - * they are first called, while RTLD_DEFAULT forces all symbols to be resolved + * they are first called, while RTLD_NOW forces all symbols to be resolved * immediately. If a custom resolver has been set via DL_SetResolveCallback(), * it will be called for each symbol to resolve. * -- cgit v1.2.3 From 49ea4e7561980d79ec3bed869982852b45b597e8 Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Mon, 27 Sep 2021 22:27:17 +0200 Subject: Updated changelog and files missing from last commit --- changelog.txt | 16 ++++++++++++++++ doc/cmake_reference.md | 6 +++++- examples/demos/n00bdemo/data.h | 4 +++- examples/demos/n00bdemo/data.s.template | 6 +++--- examples/demos/n00bdemo/main.c | 6 ++++-- libpsn00b/cmake/internal_setup.cmake | 3 +++ libpsn00b/include/lzp/lzp.h | 18 +++++++++--------- libpsn00b/include/lzp/lzqlp.h | 23 ++++++++++++++--------- libpsn00b/lzp/bit.c | 2 +- libpsn00b/lzp/bit.h | 2 +- libpsn00b/lzp/crc.c | 6 +++--- tools/lzpack/main.cpp | 18 +++++++++--------- 12 files changed, 71 insertions(+), 39 deletions(-) (limited to 'libpsn00b/include') diff --git a/changelog.txt b/changelog.txt index 03d2d10..046f4fe 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,22 @@ PSn00bSDK changelog Items that are lower in the log are more recently implemented. +09-27-2021 by spicyjpeg: + +* liblzp, tools: Fixed tools not building on MSVC and cleaned up LZP API + declarations (replaced meaningless void* pointers with proper types). + +* libpsn00b: Added missing PSN00BSDK_VERSION CMake variable. + +* examples: Fixed childexec (parent.exe) example crashing due to the child + executable not being relocated in the new build script. Patched n00bdemo to + suppress liblzp pointer type warnings. + +* Fixed another MSVC linker error when building tinyxml2 automatically, as well + as various toolchain/compiler test errors sometimes thrown by CMake. Updated + INSTALL.md with more details. + + 09-13-2021 by spicyjpeg: * Migrated libpsn00b, tools, examples and template to CMake, added a top-level diff --git a/doc/cmake_reference.md b/doc/cmake_reference.md index 8810ad4..3b586ab 100644 --- a/doc/cmake_reference.md +++ b/doc/cmake_reference.md @@ -182,6 +182,10 @@ the build script. ## Read-only variables +- `PSN00BSDK_VERSION` + + The SDK's version number (`major.minor.patch`). + - `PSN00BSDK_TOOLS`, `PSN00BSDK_INCLUDE`, `PSN00BSDK_LDSCRIPTS` Lists of paths used internally. Should not be set, manipulated or overridden @@ -200,4 +204,4 @@ the build script. LZP archives as part of the build pipeline. ----------------------------------------- -_Last updated on 2021-09-12 by spicyjpeg_ +_Last updated on 2021-09-27 by spicyjpeg_ diff --git a/examples/demos/n00bdemo/data.h b/examples/demos/n00bdemo/data.h index 3be0e3d..9e64ea1 100644 --- a/examples/demos/n00bdemo/data.h +++ b/examples/demos/n00bdemo/data.h @@ -1,7 +1,9 @@ #ifndef _DATA_H #define _DATA_H -extern unsigned char lz_resources[]; +extern unsigned char _lz_resources[]; + +#define lz_resources ((const LZP_HEAD*) _lz_resources) /*extern unsigned char smd_mtekdisk[]; extern unsigned char smd_mtektext[]; diff --git a/examples/demos/n00bdemo/data.s.template b/examples/demos/n00bdemo/data.s.template index a7237cd..9fbef2e 100644 --- a/examples/demos/n00bdemo/data.s.template +++ b/examples/demos/n00bdemo/data.s.template @@ -1,8 +1,8 @@ .section .data -.global lz_resources -.type lz_resources, @object -lz_resources: +.global _lz_resources +.type _lz_resources, @object +_lz_resources: .incbin "${PROJECT_BINARY_DIR}/data.lzp" #.global smd_mtekdisk diff --git a/examples/demos/n00bdemo/main.c b/examples/demos/n00bdemo/main.c index fcd38b8..ba21d88 100644 --- a/examples/demos/n00bdemo/main.c +++ b/examples/demos/n00bdemo/main.c @@ -85,11 +85,12 @@ void loadTextures() { Unpack textures from an embedded LZP archive and upload them to VRAM. */ int i; - int *tex_buff,*ttim,j; + int *ttim,j; + QLP_HEAD *tex_buff; TIM_IMAGE tim; i = lzpSearchFile( "textures", lz_resources ); - tex_buff = (int*)malloc( lzpFileSize( lz_resources, i ) ); + tex_buff = (QLP_HEAD*)malloc( lzpFileSize( lz_resources, i ) ); lzpUnpackFile( tex_buff, lz_resources, i ); @@ -148,6 +149,7 @@ void loadTextures() { font_tpage = getTPage( 0, 1, tim.prect->x, tim.prect->y )|0x200; font_clut = getClut( tim.crect->x, tim.crect->y ); + free( tex_buff ); } void unpackModels() { diff --git a/libpsn00b/cmake/internal_setup.cmake b/libpsn00b/cmake/internal_setup.cmake index e9423a4..e3d4be7 100644 --- a/libpsn00b/cmake/internal_setup.cmake +++ b/libpsn00b/cmake/internal_setup.cmake @@ -7,6 +7,9 @@ cmake_minimum_required(VERSION 3.21) include(GNUInstallDirs) +# IMPORTANT TODO: set a version number +set(PSN00BSDK_VERSION 0.1.0) + ## Settings (can be overridden by projects) set(PSN00BSDK_EXECUTABLE_SUFFIX ".exe") diff --git a/libpsn00b/include/lzp/lzp.h b/libpsn00b/include/lzp/lzp.h index ffd7933..cfeeb72 100644 --- a/libpsn00b/include/lzp/lzp.h +++ b/libpsn00b/include/lzp/lzp.h @@ -111,7 +111,7 @@ extern "C" { * * \returns The size of the compressed data in bytes. */ -int lzCompress(void* outBuff, void* inBuff, int inSize, int level); +int lzCompress(void* outBuff, const void* inBuff, int inSize, int level); /*! Decompress a compressed block of data. * @@ -130,9 +130,9 @@ int lzCompress(void* outBuff, void* inBuff, int inSize, int level); * \returns Size of decompressed data in bytes or LZP_ERR_DECOMPRESS if a * decompression error occurred. */ -int lzDecompress(void* outBuff, void* inBuff, int inSize); +int lzDecompress(void* outBuff, const void* inBuff, int inSize); -int lzDecompressLen(void* outBuff, int outSize, void* inBuff, int inSize); +int lzDecompressLen(void* outBuff, int outSize, const void* inBuff, int inSize); /*! Sets the sizes of hash tables for data compression. * @@ -162,7 +162,7 @@ void lzResetHashSizes(); * * \returns CRC16 hash of specified buffer. */ -unsigned short lzCRC16(void* buff, int bytes, unsigned short crc); +unsigned short lzCRC16(const void* buff, int bytes, unsigned short crc); /*! Calculates a CRC32 hash of the specified buffer. * @@ -172,7 +172,7 @@ unsigned short lzCRC16(void* buff, int bytes, unsigned short crc); * * \returns CRC32 hash of specified buffer. */ -unsigned int lzCRC32(void* buff, int bytes, unsigned int crc); +unsigned int lzCRC32(const void* buff, int bytes, unsigned int crc); /*! @} */ @@ -189,9 +189,9 @@ unsigned int lzCRC32(void* buff, int bytes, unsigned int crc); * * \returns File index of found file or one of \ref libraryErrorCodes if an error occurred. */ -int lzpSearchFile(const char* fileName, void* lzpack); +int lzpSearchFile(const char* fileName, const LZP_HEAD* lzpack); -int lzpFileSize(void* lzpack, int fileNum); +int lzpFileSize(const LZP_HEAD* lzpack, int fileNum); /*! Get a pointer to a file entry inside of an LZP archive. * @@ -200,7 +200,7 @@ int lzpFileSize(void* lzpack, int fileNum); * * \returns A pointer to an LZP_FILE struct or NULL if an error occurred. */ -LZP_FILE* lzpFileEntry(void* lzpack, int fileNum); +const LZP_FILE* lzpFileEntry(const LZP_HEAD* lzpack, int fileNum); /*! Unpacks a file from an LZP archive to the specified memory buffer. * @@ -210,7 +210,7 @@ LZP_FILE* lzpFileEntry(void* lzpack, int fileNum); * * \returns Size of decompressed file in bytes or one of \ref libraryErrorCodes if an error occurred. */ -int lzpUnpackFile(void* buff, void* lzpack, int fileNum); +int lzpUnpackFile(void* buff, const LZP_HEAD* lzpack, int fileNum); /*! @} */ diff --git a/libpsn00b/include/lzp/lzqlp.h b/libpsn00b/include/lzp/lzqlp.h index fae6438..5b70b40 100644 --- a/libpsn00b/include/lzp/lzqlp.h +++ b/libpsn00b/include/lzp/lzqlp.h @@ -1,6 +1,11 @@ #ifndef _QLP_H #define _QLP_H +#include +#ifdef _WIN32 +#include +#endif + #define PACK_ERR_NONE 0 #define PACK_ERR_INVALID -1 #define PACK_ERR_NOTFOUND -2 @@ -8,19 +13,19 @@ #define PACK_ERR_READ_FAULT -4 typedef struct { - char id[3]; - unsigned char numfiles; + char id[3]; + u_char numfiles; } QLP_HEAD; typedef struct { - char name[16]; - unsigned int size; - unsigned int offs; + char name[16]; + u_int size; + u_int offs; } QLP_FILE; -int qlpFileCount(void* qlpfile); -QLP_FILE* qlpFileEntry(int index, void* qlpfile); -void* qlpFileAddr(int index, void* qlpfile); -int qlpFindFile(char* fileName, void* qlpfile); +int qlpFileCount(const QLP_HEAD* qlpfile); +const QLP_FILE* qlpFileEntry(int index, const QLP_HEAD* qlpfile); +const void* qlpFileAddr(int index, const QLP_HEAD* qlpfile); +int qlpFindFile(char* fileName, const QLP_HEAD* qlpfile); #endif // _QLP_H \ No newline at end of file diff --git a/libpsn00b/lzp/bit.c b/libpsn00b/lzp/bit.c index aefa45d..9678357 100644 --- a/libpsn00b/lzp/bit.c +++ b/libpsn00b/lzp/bit.c @@ -3,7 +3,7 @@ // Bit I/O // -unsigned char* inPtr = 0; +const unsigned char* inPtr = 0; int inBytes = 0; unsigned char* outPtr = 0; int outBytes = 0; diff --git a/libpsn00b/lzp/bit.h b/libpsn00b/lzp/bit.h index ff71025..321160a 100644 --- a/libpsn00b/lzp/bit.h +++ b/libpsn00b/lzp/bit.h @@ -1,7 +1,7 @@ #ifndef _LZP_BIT_H #define _LZP_BIT_H -extern unsigned char* inPtr; +extern const unsigned char* inPtr; extern int inBytes; extern unsigned char* outPtr; extern int outBytes; diff --git a/libpsn00b/lzp/crc.c b/libpsn00b/lzp/crc.c index 7cc7bf3..3c1ae57 100644 --- a/libpsn00b/lzp/crc.c +++ b/libpsn00b/lzp/crc.c @@ -73,9 +73,9 @@ unsigned short lzCRC16(const void* buff, int bytes, unsigned short crc) { unsigned int lzCRC32(const void* buff, int bytes, unsigned int crc) { int i; - unsigned char* byteBuff = (const unsigned char*)buff; - unsigned int byte; - unsigned int crcTable[256]; + const unsigned char* byteBuff = (const unsigned char*)buff; + unsigned int byte; + unsigned int crcTable[256]; initTable32(crcTable); diff --git a/tools/lzpack/main.cpp b/tools/lzpack/main.cpp index f684d18..506b76c 100644 --- a/tools/lzpack/main.cpp +++ b/tools/lzpack/main.cpp @@ -178,7 +178,7 @@ int CreateLZPfile(const char* packFile, FileListClass* fileList) { printf("ERROR: Entry '%s' has more than 15 characters.\n", name); fclose(packp); unlink(packFile); - delete entry; + delete[] entry; return(0); @@ -216,8 +216,8 @@ int CreateLZPfile(const char* packFile, FileListClass* fileList) { fwrite(compBuff, compSize, 1, packp); - delete compBuff; - delete fileBuff; + delete[] compBuff; + delete[] fileBuff; printf("Ok. (%.02f%%)\n", 100.f*((float)compSize/fileSize)); @@ -238,7 +238,7 @@ int CreateLZPfile(const char* packFile, FileListClass* fileList) { fwrite(entry, sizeof(LZP_FILE), fileList->EntryCount(), packp); fclose(packp); - delete entry; + delete[] entry; printf("Packed %d file(s) totaling %d bytes (%.02f%% compression ratio).\n", fileList->EntryCount(), @@ -285,7 +285,7 @@ int CreateQLPfile(const char* packFile, FileListClass* fileList) { printf("ERROR: Entry '%s' has more than 15 characters.\n", name); fclose(packp); unlink(packFile); - delete fileEntry; + delete[] fileEntry; return(0); @@ -328,7 +328,7 @@ int CreateQLPfile(const char* packFile, FileListClass* fileList) { } - delete copyBuff; + delete[] copyBuff; fclose(fp); fileEntry[i].fileSize = bytesCopied; @@ -345,7 +345,7 @@ int CreateQLPfile(const char* packFile, FileListClass* fileList) { fwrite(fileEntry, sizeof(QLP_FILE), head.numFiles, packp); fclose(packp); - delete fileEntry; + delete[] fileEntry; return(true); @@ -417,7 +417,7 @@ int CreatePCKfile(const char* packFile, FileListClass* fileList) { } fclose(fp); - delete buff; + delete[] buff; toc.file[i].size = bytesTotal; @@ -428,7 +428,7 @@ int CreatePCKfile(const char* packFile, FileListClass* fileList) { memset(padding, 0x00, pad); fwrite(padding, pad, 1, packp); - delete padding; + delete[] padding; } printf("Done.\n"); -- cgit v1.2.3