diff --git a/.travis.yml b/.travis.yml index b591172..f0541cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,13 +31,13 @@ before_install: - export DEVKITPPC=${DEVKITPRO}/devkitPPC - mkdir -p $DEVKITPRO - cd $DEVKITPRO -- wget -N https://raw.githubusercontent.com/Maschell/hid_to_vpad/master/other/devkitPPCupdatePPCr27.pl +- wget -N https://raw.githubusercontent.com/Maschell/hid_to_vpad/master/other/devkitPPCupdatePPCr29.pl - wget -N https://raw.githubusercontent.com/Maschell/hid_to_vpad/master/other/libogc.7z - wget -N https://raw.githubusercontent.com/Maschell/hid_to_vpad/master/other/portlibs.7z install: - cd $DEVKITPRO -- perl devkitPPCupdatePPCr27.pl +- perl devkitPPCupdatePPCr29.pl - 7z x -y libogc.7z - 7z x -y portlibs.7z - cp -R portlibs/ppc/* devkitPPC/ diff --git a/Makefile b/Makefile index e406a88..f206a0e 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ INCLUDES := src #--------------------------------------------------------------------------------- CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE) -CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ +CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math -D_GNU_SOURCE \ -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE) ASFLAGS := -mregnames LDFLAGS := -nostartfiles -Wl,-Map,$(notdir $@).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,--gc-sections diff --git a/other/devkitPPCupdatePPCr27.pl b/other/devkitPPCupdatePPCr29.pl similarity index 95% rename from other/devkitPPCupdatePPCr27.pl rename to other/devkitPPCupdatePPCr29.pl index 3c92231..2d42bd9 100644 --- a/other/devkitPPCupdatePPCr27.pl +++ b/other/devkitPPCupdatePPCr29.pl @@ -97,12 +97,12 @@ } # Grab update file - if(-e "devkitProUpdatePPCr27.ini") + if(-e "devkitProUpdatePPCr29.ini") { - unlink("devkitProUpdatePPCr27.ini") or die $!; + unlink("devkitProUpdatePPCr29.ini") or die $!; } printf("Downloading update file..."); - system($downloader . " https://raw.githubusercontent.com/MaschellTest/hid_to_vpad/master/other/devkitProUpdatePPCr27.ini") and die "Failed to download!"; + system($downloader . " https://raw.githubusercontent.com/Maschell/hid_to_vpad/master/other/devkitProUpdatePPCr29.ini") and die "Failed to download!"; printf("OK!\n"); # Initialize versions & newVersions @@ -143,7 +143,7 @@ my %newFiles = (); - open(MYFILE, ") { chomp; @@ -161,7 +161,7 @@ } } close(MYFILE); - unlink("devkitProUpdatePPCr27.ini") or die $!; + unlink("devkitProUpdatePPCr29.ini") or die $!; # see what to update my %updates = (); diff --git a/other/devkitProUpdatePPCr27.ini b/other/devkitProUpdatePPCr29.ini similarity index 52% rename from other/devkitProUpdatePPCr27.ini rename to other/devkitProUpdatePPCr29.ini index 1f04860..da88c98 100644 --- a/other/devkitProUpdatePPCr27.ini +++ b/other/devkitProUpdatePPCr29.ini @@ -4,18 +4,18 @@ URL=http://downloads.sourceforge.net/devkitpro Filename=devkitProUpdater-1.6.0.exe [msys] -Version=1.0.17 -File=msys-1.0.17.exe +Version=1.0.17-1 +File=msys-1.0.17-1.exe Size=118660 [devkitARM] -Version=45 -File=devkitARM_r45-win32.exe +Version=46 +File=devkitARM_r46-win32.exe Size=70461 [devkitPPC] -Version=27 -File=devkitPPC_r27-win32.exe +Version=29-1 +File=devkitPPC_r29-1-win32.exe Size=65356 [devkitPSP] @@ -29,48 +29,48 @@ File=pspsdk-doc-20051113.tar.bz2 Size=9344 [libgba] -Version=20090222 -File=libgba-20090222.tar.bz2 +Version=0.5.0 +File=libgba-0.5.0.tar.bz2 Size=268 [libgbafat] -Version=1.0.14 -File=libfat-gba-1.0.14.tar.bz2 +Version=1.1.0 +File=libfat-gba-1.1.0.tar.bz2 Size=241 [maxmodgba] -Version=1.0.9 -File=maxmod-gba-1.0.9.tar.bz2 +Version=1.0.10 +File=maxmod-gba-1.0.10.tar.bz2 Size= [libnds] -Version=1.5.12 -File=libnds-1.5.12.tar.bz2 +Version=1.6.2 +File=libnds-1.6.2.tar.bz2 Size=470 [libndsfat] -Version=1.0.14 -File=libfat-nds-1.0.14.tar.bz2 +Version=1.1.0 +File=libfat-nds-1.1.0.tar.bz2 Size=272 [maxmodds] -Version=1.0.9 -File=maxmod-nds-1.0.9.tar.bz2 +Version=1.0.10 +File=maxmod-nds-1.0.10.tar.bz2 Size= [dswifi] -Version=0.3.17 -File=dswifi-0.3.17.tar.bz2 +Version=0.4.0 +File=dswifi-0.4.0.tar.bz2 Size=496 [libctru] -Version=1.0.0 -File=libctru-1.0.0.tar.bz2 +Version=1.2.1 +File=libctru-1.2.1.tar.bz2 Size=371 [citro3d] -Version=1.0.0 -File=citro3d-1.0.0.tar.bz2 +Version=1.2.0 +File=citro3d-1.2.0.tar.bz2 Size=371 [libmirko] @@ -79,13 +79,13 @@ File=libmirko-0.9.7.tar.bz2 Size=1056 [libogc] -Version=1.8.12 -File=libogc-1.8.12.tar.bz2 +Version=1.8.16 +File=libogc-1.8.16.tar.bz2 Size=2748 [libogcfat] -Version=1.0.14 -File=libfat-ogc-1.0.14.tar.bz2 +Version=1.1.0 +File=libfat-ogc-1.1.0.tar.bz2 Size=481 [pnotepad] @@ -99,23 +99,23 @@ File=insight-7.3.50.20110803-cvs.exe Size=32932 [ndsexamples] -Version=20140401 -File=nds-examples-20140401.tar.bz2 +Version=20170124 +File=nds-examples-20170124.tar.bz2 Size=1191 [defaultarm7] -Version=0.6.0 -File=default_arm7-0.6.0.tar.bz2 +Version=0.7.1 +File=default_arm7-0.7.1.tar.bz2 Size=9 [filesystem] -Version=0.9.12 -File=libfilesystem-0.9.12.tar.bz2 +Version=0.9.13-1 +File=libfilesystem-0.9.13-1.tar.bz2 Size=9 [gbaexamples] -Version=20090222 -File=gba-examples-20090222.tar.bz2 +Version=20170228 +File=gba-examples-20170228.tar.bz2 Size=1019 [gp32examples] @@ -124,18 +124,18 @@ File=gp32-examples-20051021.tar.bz2 Size=732 [cubeexamples] -Version=20110620 -File=gamecube-examples-20110620.tar.bz2 +Version=20170228 +File=gamecube-examples-20170228.tar.bz2 Size=198 [wiiexamples] -Version=20110620 -File=wii-examples-20110620.tar.bz2 +Version=20170228 +File=wii-examples-20170228.tar.bz2 Size=93 [3dsexamples] -Version=20151219 -File=3ds-examples-20151219.tar.bz2 +Version=20170226 +File=3ds-examples-20170226.tar.bz2 Size=93 [gcube] diff --git a/other/portlibs.7z b/other/portlibs.7z index 3b22468..272bb4c 100644 Binary files a/other/portlibs.7z and b/other/portlibs.7z differ diff --git a/src/Application.cpp b/src/Application.cpp index e0d6cb5..7a1faea 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -48,19 +48,19 @@ Application::Application() } Application::~Application(){ - log_printf("Destroy music\n"); + log_printf("Application::~Application: Destroy music\n"); delete bgMusic; - log_printf("Destroy controller\n"); + log_printf("Application::~Application: Destroy controller\n"); - for(int i = 0; i < 5; i++) + for(s32 i = 0; i < 5; i++) delete controller[i]; //We may have to handle Asyncdelete in the Destructors. - log_printf("Destroy async deleter\n"); + log_printf("Application::~Application: Destroy async deleter\n"); do{ - log_printf("Triggering AsyncDeleter\n"); + log_printf("Application::~Application: Triggering AsyncDeleter\n"); AsyncDeleter::triggerDeleteProcess(); while(!AsyncDeleter::realListEmpty()){ usleep(1000); @@ -68,14 +68,14 @@ Application::~Application(){ }while(!AsyncDeleter::deleteListEmpty()); AsyncDeleter::destroyInstance(); - log_printf("Clear resources\n"); + log_printf("Application::~Application: Clear resources\n"); Resources::Clear(); - log_printf("Stop sound handler\n"); + log_printf("Application::~Application: Stop sound handler\n"); SoundHandler::DestroyInstance(); } -int Application::exec(){ +s32 Application::exec(){ //! start main GX2 thread resumeThread(); //! now wait for thread to finish @@ -87,7 +87,7 @@ int Application::exec(){ void Application::fadeOut(){ GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color){ 0, 0, 0, 255 }); - for(int i = 0; i < 255; i += 10) + for(s32 i = 0; i < 255; i += 10) { if(i > 255) i = 255; @@ -132,17 +132,17 @@ void Application::fadeOut(){ } void Application::executeThread(void){ - log_printf("Initialize video\n"); + log_printf("Application::executeThread: Initialize video\n"); video = new CVideo(GX2_TV_SCAN_MODE_720P, GX2_DRC_SINGLE); - log_printf("Video size %i x %i\n", video->getTvWidth(), video->getTvHeight()); + log_printf("Application::executeThread: Video size %i x %i\n", video->getTvWidth(), video->getTvHeight()); //! setup default Font - log_printf("Initialize main font system\n"); + log_printf("Application::executeThread: Initialize main font system\n"); FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true); GuiText::setPresetFont(fontSystem); - log_printf("Initialize main window\n"); + log_printf("Application::executeThread: Initialize main window\n"); mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight()); @@ -150,13 +150,13 @@ void Application::executeThread(void){ bgMusic->Play(); bgMusic->SetVolume(50); - log_printf("Entering main loop\n"); + log_printf("Application::executeThread: Entering main loop\n"); //! main GX2 loop (60 Hz cycle with max priority on core 1) while(!exitApplication) { //! Read out inputs - for(int i = 0; i < 5; i++) + for(s32 i = 0; i < 5; i++) { if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false) continue; diff --git a/src/Application.h b/src/Application.h index 5431a76..a93483f 100644 --- a/src/Application.h +++ b/src/Application.h @@ -51,10 +51,10 @@ public: return bgMusic; } - int exec(void); + s32 exec(void); void fadeOut(void); - void quit(int code) { + void quit(s32 code) { exitCode = code; exitApplication = true; } @@ -71,7 +71,7 @@ private: CVideo *video; MainWindow *mainWindow; GuiController *controller[5]; - int exitCode; + s32 exitCode; }; #endif //_APPLICATION_H diff --git a/src/common/common.h b/src/common/common.h index 7d224c8..39987bc 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -38,10 +38,10 @@ extern "C" { #define MEM_BASE (0x00800000) #endif -#define ELF_DATA_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x00)) -#define ELF_DATA_SIZE (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x04)) -#define MAIN_ENTRY_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x00)) -#define OS_FIRMWARE (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x04)) +#define ELF_DATA_ADDR (*(volatile u32*)(MEM_BASE + 0x1300 + 0x00)) +#define ELF_DATA_SIZE (*(volatile u32*)(MEM_BASE + 0x1300 + 0x04)) +#define MAIN_ENTRY_ADDR (*(volatile u32*)(MEM_BASE + 0x1400 + 0x00)) +#define OS_FIRMWARE (*(volatile u32*)(MEM_BASE + 0x1400 + 0x04)) #define OS_SPECIFICS ((OsSpecifics*)(MEM_BASE + 0x1500)) diff --git a/src/controller_patcher b/src/controller_patcher index 5a3aa0d..73bf9bf 160000 --- a/src/controller_patcher +++ b/src/controller_patcher @@ -1 +1 @@ -Subproject commit 5a3aa0d0aab1d1729f46f01c5b53f72a4a2dbd92 +Subproject commit 73bf9bfb74b74967fe017dedde2041e31397d75a diff --git a/src/dynamic_libs b/src/dynamic_libs index 5e01fb7..a136b12 160000 --- a/src/dynamic_libs +++ b/src/dynamic_libs @@ -1 +1 @@ -Subproject commit 5e01fb7d3f458fafa4f7e321f963eecd05e89874 +Subproject commit a136b12c5225d932a73c299cb0edb638930f2d67 diff --git a/src/entry.c b/src/entry.c index 759cee0..13dcad6 100644 --- a/src/entry.c +++ b/src/entry.c @@ -5,7 +5,7 @@ #include "utils/utils.h" #include "main.h" -int __entry_menu(int argc, char **argv) +int __entry_menu(s32 argc, char **argv) { //! ******************************************************************* //! * Jump to our application * diff --git a/src/fs/CFile.cpp b/src/fs/CFile.cpp index b86eed9..ac7bbd2 100644 --- a/src/fs/CFile.cpp +++ b/src/fs/CFile.cpp @@ -16,7 +16,7 @@ CFile::CFile(const std::string & filepath, eOpenTypes mode) this->open(filepath, mode); } -CFile::CFile(const u8 * mem, int size) +CFile::CFile(const u8 * mem, s32 size) { iFd = -1; this->open(mem, size); @@ -27,7 +27,7 @@ CFile::~CFile() this->close(); } -int CFile::open(const std::string & filepath, eOpenTypes mode) +s32 CFile::open(const std::string & filepath, eOpenTypes mode) { this->close(); @@ -65,7 +65,7 @@ int CFile::open(const std::string & filepath, eOpenTypes mode) return 0; } -int CFile::open(const u8 * mem, int size) +s32 CFile::open(const u8 * mem, s32 size) { this->close(); @@ -86,17 +86,17 @@ void CFile::close() pos = 0; } -int CFile::read(u8 * ptr, size_t size) +s32 CFile::read(u8 * ptr, size_t size) { if(iFd >= 0) { - int ret = ::read(iFd, ptr,size); + s32 ret = ::read(iFd, ptr,size); if(ret > 0) pos += ret; return ret; } - int readsize = size; + s32 readsize = size; if(readsize > (s64) (filesize-pos)) readsize = filesize-pos; @@ -114,14 +114,14 @@ int CFile::read(u8 * ptr, size_t size) return -1; } -int CFile::write(const u8 * ptr, size_t size) +s32 CFile::write(const u8 * ptr, size_t size) { if(iFd >= 0) { size_t done = 0; while(done < size) { - int ret = ::write(iFd, ptr, size - done); + s32 ret = ::write(iFd, ptr, size - done); if(ret <= 0) return ret; @@ -135,9 +135,9 @@ int CFile::write(const u8 * ptr, size_t size) return -1; } -int CFile::seek(long int offset, int origin) +s32 CFile::seek(long int offset, s32 origin) { - int ret = 0; + s32 ret = 0; s64 newPos = pos; if(origin == SEEK_SET) @@ -175,9 +175,9 @@ int CFile::seek(long int offset, int origin) return ret; } -int CFile::fwrite(const char *format, ...) +s32 CFile::fwrite(const char *format, ...) { - int result = -1; + s32 result = -1; char * tmp = NULL; va_list va; diff --git a/src/fs/CFile.hpp b/src/fs/CFile.hpp index a95d3cd..0a46a32 100644 --- a/src/fs/CFile.hpp +++ b/src/fs/CFile.hpp @@ -21,11 +21,11 @@ class CFile CFile(); CFile(const std::string & filepath, eOpenTypes mode); - CFile(const u8 * memory, int memsize); + CFile(const u8 * memory, s32 memsize); virtual ~CFile(); - int open(const std::string & filepath, eOpenTypes mode); - int open(const u8 * memory, int memsize); + s32 open(const std::string & filepath, eOpenTypes mode); + s32 open(const u8 * memory, s32 memsize); bool isOpen() const { if(iFd >= 0) @@ -39,16 +39,16 @@ class CFile void close(); - int read(u8 * ptr, size_t size); - int write(const u8 * ptr, size_t size); - int fwrite(const char *format, ...); - int seek(long int offset, int origin); + s32 read(u8 * ptr, size_t size); + s32 write(const u8 * ptr, size_t size); + s32 fwrite(const char *format, ...); + s32 seek(long int offset, s32 origin); u64 tell() { return pos; }; u64 size() { return filesize; }; void rewind() { this->seek(0, SEEK_SET); }; protected: - int iFd; + s32 iFd; const u8 * mem_file; u64 filesize; u64 pos; diff --git a/src/fs/DirList.cpp b/src/fs/DirList.cpp index f8d283f..6a6d61d 100644 --- a/src/fs/DirList.cpp +++ b/src/fs/DirList.cpp @@ -96,7 +96,7 @@ bool DirList::InternalLoadPath(std::string &folderpath) if(Flags & CheckSubfolders) { - int length = folderpath.size(); + s32 length = folderpath.size(); if(length > 2 && folderpath[length-1] != '/') folderpath += '/'; folderpath += filename; @@ -136,7 +136,7 @@ void DirList::AddEntrie(const std::string &filepath, const char * filename, bool if(!filename) return; - int pos = FileInfo.size(); + s32 pos = FileInfo.size(); FileInfo.resize(pos+1); @@ -165,7 +165,7 @@ void DirList::ClearList() std::vector().swap(FileInfo); } -const char * DirList::GetFilename(int ind) const +const char * DirList::GetFilename(s32 ind) const { if (!valid(ind)) return ""; @@ -199,7 +199,7 @@ void DirList::SortList(bool (*SortFunc)(const DirEntry &a, const DirEntry &b)) std::sort(FileInfo.begin(), FileInfo.end(), SortFunc); } -u64 DirList::GetFilesize(int index) const +u64 DirList::GetFilesize(s32 index) const { struct stat st; const char *path = GetFilepath(index); @@ -210,7 +210,7 @@ u64 DirList::GetFilesize(int index) const return st.st_size; } -int DirList::GetFileIndex(const char *filename) const +s32 DirList::GetFileIndex(const char *filename) const { if(!filename) return -1; diff --git a/src/fs/DirList.h b/src/fs/DirList.h index 2a34208..3beb6bf 100644 --- a/src/fs/DirList.h +++ b/src/fs/DirList.h @@ -52,24 +52,24 @@ public: bool LoadPath(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs); //! Get a filename of the list //!\param list index - const char * GetFilename(int index) const; + const char * GetFilename(s32 index) const; //! Get the a filepath of the list //!\param list index - const char *GetFilepath(int index) const { if (!valid(index)) return ""; else return FileInfo[index].FilePath; } + const char *GetFilepath(s32 index) const { if (!valid(index)) return ""; else return FileInfo[index].FilePath; } //! Get the a filesize of the list //!\param list index - u64 GetFilesize(int index) const; + u64 GetFilesize(s32 index) const; //! Is index a dir or a file //!\param list index - bool IsDir(int index) const { if(!valid(index)) return false; return FileInfo[index].isDir; }; + bool IsDir(s32 index) const { if(!valid(index)) return false; return FileInfo[index].isDir; }; //! Get the filecount of the whole list - int GetFilecount() const { return FileInfo.size(); }; + s32 GetFilecount() const { return FileInfo.size(); }; //! Sort list by filepath void SortList(); //! Custom sort command for custom sort functions definitions void SortList(bool (*SortFunc)(const DirEntry &a, const DirEntry &b)); //! Get the index of the specified filename - int GetFileIndex(const char *filename) const; + s32 GetFileIndex(const char *filename) const; //! Enum for search/filter flags enum { diff --git a/src/fs/fs_utils.c b/src/fs/fs_utils.c index cdf071e..250e72a 100644 --- a/src/fs/fs_utils.c +++ b/src/fs/fs_utils.c @@ -6,9 +6,9 @@ #include "dynamic_libs/fs_defs.h" #include "dynamic_libs/fs_functions.h" -int MountFS(void *pClient, void *pCmd, char **mount_path) +s32 MountFS(void *pClient, void *pCmd, char **mount_path) { - int result = -1; + s32 result = -1; void *mountSrc = malloc(FS_MOUNT_SOURCE_SIZE); if(!mountSrc) @@ -44,22 +44,22 @@ int MountFS(void *pClient, void *pCmd, char **mount_path) return result; } -int UmountFS(void *pClient, void *pCmd, const char *mountPath) +s32 UmountFS(void *pClient, void *pCmd, const char *mountPath) { - int result = -1; + s32 result = -1; result = FSUnmount(pClient, pCmd, mountPath, -1); return result; } -int LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size) +s32 LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size) { //! always initialze input *inbuffer = NULL; if(size) *size = 0; - int iFd = open(filepath, O_RDONLY); + s32 iFd = open(filepath, O_RDONLY); if (iFd < 0) return -1; @@ -75,7 +75,7 @@ int LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size) u32 blocksize = 0x4000; u32 done = 0; - int readBytes = 0; + s32 readBytes = 0; while(done < filesize) { @@ -100,13 +100,14 @@ int LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size) *inbuffer = buffer; //! sign is optional input - if(size) + if(size){ *size = filesize; + } return filesize; } -int CheckFile(const char * filepath) +s32 CheckFile(const char * filepath) { if(!filepath) return 0; @@ -131,17 +132,17 @@ int CheckFile(const char * filepath) return 0; } -int CreateSubfolder(const char * fullpath) +s32 CreateSubfolder(const char * fullpath) { if(!fullpath) return 0; - int result = 0; + s32 result = 0; char dirnoslash[strlen(fullpath)+1]; strcpy(dirnoslash, fullpath); - int pos = strlen(dirnoslash)-1; + s32 pos = strlen(dirnoslash)-1; while(dirnoslash[pos] == '/') { dirnoslash[pos] = '\0'; diff --git a/src/fs/fs_utils.h b/src/fs/fs_utils.h index 7022695..cedfca4 100644 --- a/src/fs/fs_utils.h +++ b/src/fs/fs_utils.h @@ -7,14 +7,14 @@ extern "C" { #include -int MountFS(void *pClient, void *pCmd, char **mount_path); -int UmountFS(void *pClient, void *pCmd, const char *mountPath); +s32 MountFS(void *pClient, void *pCmd, char **mount_path); +s32 UmountFS(void *pClient, void *pCmd, const char *mountPath); -int LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size); +s32 LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size); //! todo: C++ class -int CreateSubfolder(const char * fullpath); -int CheckFile(const char * filepath); +s32 CreateSubfolder(const char * fullpath); +s32 CheckFile(const char * filepath); #ifdef __cplusplus } diff --git a/src/fs/sd_fat_devoptab.c b/src/fs/sd_fat_devoptab.c index 7e8fbc1..e4feee5 100644 --- a/src/fs/sd_fat_devoptab.c +++ b/src/fs/sd_fat_devoptab.c @@ -45,8 +45,8 @@ typedef struct _sd_fat_private_t { typedef struct _sd_fat_file_state_t { sd_fat_private_t *dev; - int fd; /* File descriptor */ - int flags; /* Opening flags */ + s32 fd; /* File descriptor */ + s32 flags; /* Opening flags */ bool read; /* True if allowed to read from file */ bool write; /* True if allowed to write to file */ bool append; /* True if allowed to append to file */ @@ -58,14 +58,14 @@ typedef struct _sd_fat_file_state_t { typedef struct _sd_fat_dir_entry_t { sd_fat_private_t *dev; - int dirHandle; + s32 dirHandle; } sd_fat_dir_entry_t; static sd_fat_private_t *sd_fat_get_device_data(const char *path) { const devoptab_t *devoptab = NULL; char name[128] = {0}; - int i; + s32 i; // Get the device name from the path strncpy(name, path, 127); @@ -98,7 +98,7 @@ static char *sd_fat_real_path (const char *path, sd_fat_private_t *dev) path = strchr(path, ':') + 1; } - int mount_len = strlen(dev->mount_path); + s32 mount_len = strlen(dev->mount_path); char *new_name = (char*)malloc(mount_len + strlen(path) + 1); if(new_name) { @@ -109,7 +109,7 @@ static char *sd_fat_real_path (const char *path, sd_fat_private_t *dev) return new_name; } -static int sd_fat_open_r (struct _reent *r, void *fileStruct, const char *path, int flags, int mode) +static s32 sd_fat_open_r (struct _reent *r, void *fileStruct, const char *path, s32 flags, s32 mode) { sd_fat_private_t *dev = sd_fat_get_device_data(path); if(!dev) { @@ -145,7 +145,7 @@ static int sd_fat_open_r (struct _reent *r, void *fileStruct, const char *path, return -1; } - int fd = -1; + s32 fd = -1; OSLockMutex(dev->pMutex); @@ -156,7 +156,7 @@ static int sd_fat_open_r (struct _reent *r, void *fileStruct, const char *path, return -1; } - int result = FSOpenFile(dev->pClient, dev->pCmd, real_path, mode_str, &fd, -1); + s32 result = FSOpenFile(dev->pClient, dev->pCmd, real_path, mode_str, &fd, (s32)-1); free(real_path); @@ -174,7 +174,7 @@ static int sd_fat_open_r (struct _reent *r, void *fileStruct, const char *path, file->pos = 0; file->len = stats.size; OSUnlockMutex(dev->pMutex); - return (int)file; + return (s32)file; } r->_errno = result; @@ -183,7 +183,7 @@ static int sd_fat_open_r (struct _reent *r, void *fileStruct, const char *path, } -static int sd_fat_close_r (struct _reent *r, int fd) +static s32 sd_fat_close_r (struct _reent *r, s32 fd) { sd_fat_file_state_t *file = (sd_fat_file_state_t *)fd; if(!file->dev) { @@ -193,7 +193,7 @@ static int sd_fat_close_r (struct _reent *r, int fd) OSLockMutex(file->dev->pMutex); - int result = FSCloseFile(file->dev->pClient, file->dev->pCmd, file->fd, -1); + s32 result = FSCloseFile(file->dev->pClient, file->dev->pCmd, file->fd, -1); OSUnlockMutex(file->dev->pMutex); @@ -205,7 +205,7 @@ static int sd_fat_close_r (struct _reent *r, int fd) return 0; } -static off_t sd_fat_seek_r (struct _reent *r, int fd, off_t pos, int dir) +static off_t sd_fat_seek_r (struct _reent *r, s32 fd, off_t pos, s32 dir) { sd_fat_file_state_t *file = (sd_fat_file_state_t *)fd; if(!file->dev) { @@ -231,7 +231,7 @@ static off_t sd_fat_seek_r (struct _reent *r, int fd, off_t pos, int dir) return -1; } - int result = FSSetPosFile(file->dev->pClient, file->dev->pCmd, file->fd, file->pos, -1); + s32 result = FSSetPosFile(file->dev->pClient, file->dev->pCmd, file->fd, file->pos, -1); OSUnlockMutex(file->dev->pMutex); @@ -243,7 +243,7 @@ static off_t sd_fat_seek_r (struct _reent *r, int fd, off_t pos, int dir) return result; } -static ssize_t sd_fat_write_r (struct _reent *r, int fd, const char *ptr, size_t len) +static ssize_t sd_fat_write_r (struct _reent *r, s32 fd, const char *ptr, size_t len) { sd_fat_file_state_t *file = (sd_fat_file_state_t *)fd; if(!file->dev) { @@ -277,7 +277,7 @@ static ssize_t sd_fat_write_r (struct _reent *r, int fd, const char *ptr, size_t size_t write_size = (len_aligned < (len - done)) ? len_aligned : (len - done); memcpy(tmpBuf, ptr + done, write_size); - int result = FSWriteFile(file->dev->pClient, file->dev->pCmd, tmpBuf, 0x01, write_size, file->fd, 0, -1); + s32 result = FSWriteFile(file->dev->pClient, file->dev->pCmd, tmpBuf, 0x01, write_size, file->fd, 0, -1); if(result < 0) { r->_errno = result; @@ -302,7 +302,7 @@ static ssize_t sd_fat_write_r (struct _reent *r, int fd, const char *ptr, size_t return done; } -static ssize_t sd_fat_read_r (struct _reent *r, int fd, char *ptr, size_t len) +static ssize_t sd_fat_read_r (struct _reent *r, s32 fd, char *ptr, size_t len) { sd_fat_file_state_t *file = (sd_fat_file_state_t *)fd; if(!file->dev) { @@ -335,7 +335,7 @@ static ssize_t sd_fat_read_r (struct _reent *r, int fd, char *ptr, size_t len) { size_t read_size = (len_aligned < (len - done)) ? len_aligned : (len - done); - int result = FSReadFile(file->dev->pClient, file->dev->pCmd, tmpBuf, 0x01, read_size, file->fd, 0, -1); + s32 result = FSReadFile(file->dev->pClient, file->dev->pCmd, tmpBuf, 0x01, read_size, file->fd, 0, -1); if(result < 0) { r->_errno = result; @@ -362,7 +362,7 @@ static ssize_t sd_fat_read_r (struct _reent *r, int fd, char *ptr, size_t len) } -static int sd_fat_fstat_r (struct _reent *r, int fd, struct stat *st) +static s32 sd_fat_fstat_r (struct _reent *r, s32 fd, struct stat *st) { sd_fat_file_state_t *file = (sd_fat_file_state_t *)fd; if(!file->dev) { @@ -376,7 +376,7 @@ static int sd_fat_fstat_r (struct _reent *r, int fd, struct stat *st) memset(st, 0, sizeof(struct stat)); FSStat stats; - int result = FSGetStatFile(file->dev->pClient, file->dev->pCmd, file->fd, &stats, -1); + s32 result = FSGetStatFile(file->dev->pClient, file->dev->pCmd, file->fd, &stats, -1); if(result != 0) { r->_errno = result; OSUnlockMutex(file->dev->pMutex); @@ -400,7 +400,7 @@ static int sd_fat_fstat_r (struct _reent *r, int fd, struct stat *st) return 0; } -static int sd_fat_ftruncate_r (struct _reent *r, int fd, off_t len) +static s32 sd_fat_ftruncate_r (struct _reent *r, s32 fd, off_t len) { sd_fat_file_state_t *file = (sd_fat_file_state_t *)fd; if(!file->dev) { @@ -410,7 +410,7 @@ static int sd_fat_ftruncate_r (struct _reent *r, int fd, off_t len) OSLockMutex(file->dev->pMutex); - int result = FSTruncateFile(file->dev->pClient, file->dev->pCmd, file->fd, -1); + s32 result = FSTruncateFile(file->dev->pClient, file->dev->pCmd, file->fd, -1); OSUnlockMutex(file->dev->pMutex); @@ -422,7 +422,7 @@ static int sd_fat_ftruncate_r (struct _reent *r, int fd, off_t len) return 0; } -static int sd_fat_fsync_r (struct _reent *r, int fd) +static s32 sd_fat_fsync_r (struct _reent *r, s32 fd) { sd_fat_file_state_t *file = (sd_fat_file_state_t *)fd; if(!file->dev) { @@ -432,7 +432,7 @@ static int sd_fat_fsync_r (struct _reent *r, int fd) OSLockMutex(file->dev->pMutex); - int result = FSFlushFile(file->dev->pClient, file->dev->pCmd, file->fd, -1); + s32 result = FSFlushFile(file->dev->pClient, file->dev->pCmd, file->fd, -1); OSUnlockMutex(file->dev->pMutex); @@ -444,7 +444,7 @@ static int sd_fat_fsync_r (struct _reent *r, int fd) return 0; } -static int sd_fat_stat_r (struct _reent *r, const char *path, struct stat *st) +static s32 sd_fat_stat_r (struct _reent *r, const char *path, struct stat *st) { sd_fat_private_t *dev = sd_fat_get_device_data(path); if(!dev) { @@ -466,7 +466,7 @@ static int sd_fat_stat_r (struct _reent *r, const char *path, struct stat *st) FSStat stats; - int result = FSGetStat(dev->pClient, dev->pCmd, real_path, &stats, -1); + s32 result = FSGetStat(dev->pClient, dev->pCmd, real_path, &stats, -1); free(real_path); real_path = NULL; @@ -496,13 +496,13 @@ static int sd_fat_stat_r (struct _reent *r, const char *path, struct stat *st) return 0; } -static int sd_fat_link_r (struct _reent *r, const char *existing, const char *newLink) +static s32 sd_fat_link_r (struct _reent *r, const char *existing, const char *newLink) { r->_errno = ENOTSUP; return -1; } -static int sd_fat_unlink_r (struct _reent *r, const char *name) +static s32 sd_fat_unlink_r (struct _reent *r, const char *name) { sd_fat_private_t *dev = sd_fat_get_device_data(name); if(!dev) { @@ -520,7 +520,7 @@ static int sd_fat_unlink_r (struct _reent *r, const char *name) } - int result = FSRemove(dev->pClient, dev->pCmd, real_path, -1); + s32 result = FSRemove(dev->pClient, dev->pCmd, real_path, -1); free(real_path); real_path = NULL; @@ -535,7 +535,7 @@ static int sd_fat_unlink_r (struct _reent *r, const char *name) return 0; } -static int sd_fat_chdir_r (struct _reent *r, const char *name) +static s32 sd_fat_chdir_r (struct _reent *r, const char *name) { sd_fat_private_t *dev = sd_fat_get_device_data(name); if(!dev) { @@ -552,7 +552,7 @@ static int sd_fat_chdir_r (struct _reent *r, const char *name) return -1; } - int result = FSChangeDir(dev->pClient, dev->pCmd, real_path, -1); + s32 result = FSChangeDir(dev->pClient, dev->pCmd, real_path, -1); free(real_path); real_path = NULL; @@ -567,7 +567,7 @@ static int sd_fat_chdir_r (struct _reent *r, const char *name) return 0; } -static int sd_fat_rename_r (struct _reent *r, const char *oldName, const char *newName) +static s32 sd_fat_rename_r (struct _reent *r, const char *oldName, const char *newName) { sd_fat_private_t *dev = sd_fat_get_device_data(oldName); if(!dev) { @@ -591,7 +591,7 @@ static int sd_fat_rename_r (struct _reent *r, const char *oldName, const char *n return -1; } - int result = FSRename(dev->pClient, dev->pCmd, real_oldpath, real_newpath, -1); + s32 result = FSRename(dev->pClient, dev->pCmd, real_oldpath, real_newpath, -1); free(real_oldpath); free(real_newpath); @@ -607,7 +607,7 @@ static int sd_fat_rename_r (struct _reent *r, const char *oldName, const char *n } -static int sd_fat_mkdir_r (struct _reent *r, const char *path, int mode) +static s32 sd_fat_mkdir_r (struct _reent *r, const char *path, s32 mode) { sd_fat_private_t *dev = sd_fat_get_device_data(path); if(!dev) { @@ -624,7 +624,7 @@ static int sd_fat_mkdir_r (struct _reent *r, const char *path, int mode) return -1; } - int result = FSMakeDir(dev->pClient, dev->pCmd, real_path, -1); + s32 result = FSMakeDir(dev->pClient, dev->pCmd, real_path, -1); free(real_path); @@ -638,7 +638,7 @@ static int sd_fat_mkdir_r (struct _reent *r, const char *path, int mode) return 0; } -static int sd_fat_statvfs_r (struct _reent *r, const char *path, struct statvfs *buf) +static s32 sd_fat_statvfs_r (struct _reent *r, const char *path, struct statvfs *buf) { sd_fat_private_t *dev = sd_fat_get_device_data(path); if(!dev) { @@ -660,7 +660,7 @@ static int sd_fat_statvfs_r (struct _reent *r, const char *path, struct statvfs u64 size; - int result = FSGetFreeSpaceSize(dev->pClient, dev->pCmd, real_path, &size, -1); + s32 result = FSGetFreeSpaceSize(dev->pClient, dev->pCmd, real_path, &size, -1); free(real_path); @@ -682,7 +682,7 @@ static int sd_fat_statvfs_r (struct _reent *r, const char *path, struct statvfs // Free blocks available for all and for non-privileged processes buf->f_bfree = buf->f_bavail = size >> 9; - // Number of inodes at this point in time + // Number of inodes at this pos32 in time buf->f_files = 0xffffffff; // Free inodes available for all and for non-privileged processes @@ -721,9 +721,9 @@ static DIR_ITER *sd_fat_diropen_r (struct _reent *r, DIR_ITER *dirState, const c return NULL; } - int dirHandle; + s32 dirHandle; - int result = FSOpenDir(dev->pClient, dev->pCmd, real_path, &dirHandle, -1); + s32 result = FSOpenDir(dev->pClient, dev->pCmd, real_path, &dirHandle, (s32)-1); free(real_path); @@ -741,7 +741,7 @@ static DIR_ITER *sd_fat_diropen_r (struct _reent *r, DIR_ITER *dirState, const c return dirState; } -static int sd_fat_dirclose_r (struct _reent *r, DIR_ITER *dirState) +static s32 sd_fat_dirclose_r (struct _reent *r, DIR_ITER *dirState) { sd_fat_dir_entry_t *dirIter = (sd_fat_dir_entry_t *)dirState->dirStruct; if(!dirIter->dev) { @@ -751,7 +751,7 @@ static int sd_fat_dirclose_r (struct _reent *r, DIR_ITER *dirState) OSLockMutex(dirIter->dev->pMutex); - int result = FSCloseDir(dirIter->dev->pClient, dirIter->dev->pCmd, dirIter->dirHandle, -1); + s32 result = FSCloseDir(dirIter->dev->pClient, dirIter->dev->pCmd, dirIter->dirHandle, -1); OSUnlockMutex(dirIter->dev->pMutex); @@ -763,7 +763,7 @@ static int sd_fat_dirclose_r (struct _reent *r, DIR_ITER *dirState) return 0; } -static int sd_fat_dirreset_r (struct _reent *r, DIR_ITER *dirState) +static s32 sd_fat_dirreset_r (struct _reent *r, DIR_ITER *dirState) { sd_fat_dir_entry_t *dirIter = (sd_fat_dir_entry_t *)dirState->dirStruct; if(!dirIter->dev) { @@ -773,7 +773,7 @@ static int sd_fat_dirreset_r (struct _reent *r, DIR_ITER *dirState) OSLockMutex(dirIter->dev->pMutex); - int result = FSRewindDir(dirIter->dev->pClient, dirIter->dev->pCmd, dirIter->dirHandle, -1); + s32 result = FSRewindDir(dirIter->dev->pClient, dirIter->dev->pCmd, dirIter->dirHandle, -1); OSUnlockMutex(dirIter->dev->pMutex); @@ -785,7 +785,7 @@ static int sd_fat_dirreset_r (struct _reent *r, DIR_ITER *dirState) return 0; } -static int sd_fat_dirnext_r (struct _reent *r, DIR_ITER *dirState, char *filename, struct stat *st) +static s32 sd_fat_dirnext_r (struct _reent *r, DIR_ITER *dirState, char *filename, struct stat *st) { sd_fat_dir_entry_t *dirIter = (sd_fat_dir_entry_t *)dirState->dirStruct; if(!dirIter->dev) { @@ -797,7 +797,7 @@ static int sd_fat_dirnext_r (struct _reent *r, DIR_ITER *dirState, char *filenam FSDirEntry * dir_entry = malloc(sizeof(FSDirEntry)); - int result = FSReadDir(dirIter->dev->pClient, dirIter->dev->pCmd, dirIter->dirHandle, dir_entry, -1); + s32 result = FSReadDir(dirIter->dev->pClient, dirIter->dev->pCmd, dirIter->dirHandle, dir_entry, -1); if(result < 0) { free(dir_entry); @@ -859,12 +859,12 @@ static const devoptab_t devops_sd_fat = { NULL /* Device data */ }; -static int sd_fat_add_device (const char *name, const char *mount_path, void *pClient, void *pCmd) +static s32 sd_fat_add_device (const char *name, const char *mount_path, void *pClient, void *pCmd) { devoptab_t *dev = NULL; char *devname = NULL; char *devpath = NULL; - int i; + s32 i; // Sanity check if (!name) { @@ -933,11 +933,11 @@ static int sd_fat_add_device (const char *name, const char *mount_path, void *pC return -1; } -static int sd_fat_remove_device (const char *path, void **pClient, void **pCmd, char **mountPath) +static s32 sd_fat_remove_device (const char *path, void **pClient, void **pCmd, char **mountPath) { const devoptab_t *devoptab = NULL; char name[128] = {0}; - int i; + s32 i; // Get the device name from the path strncpy(name, path, 127); @@ -975,9 +975,9 @@ static int sd_fat_remove_device (const char *path, void **pClient, void **pCmd, return -1; } -int mount_sd_fat(const char *path) +s32 mount_sd_fat(const char *path) { - int result = -1; + s32 result = -1; // get command and client void* pClient = malloc(FS_CLIENT_SIZE); @@ -1006,13 +1006,13 @@ int mount_sd_fat(const char *path) return result; } -int unmount_sd_fat(const char *path) +s32 unmount_sd_fat(const char *path) { void *pClient = 0; void *pCmd = 0; char *mountPath = 0; - int result = sd_fat_remove_device(path, &pClient, &pCmd, &mountPath); + s32 result = sd_fat_remove_device(path, &pClient, &pCmd, &mountPath); if(result == 0) { UmountFS(pClient, pCmd, mountPath); diff --git a/src/fs/sd_fat_devoptab.h b/src/fs/sd_fat_devoptab.h index 8df487a..ae406a2 100644 --- a/src/fs/sd_fat_devoptab.h +++ b/src/fs/sd_fat_devoptab.h @@ -28,8 +28,8 @@ extern "C" { #endif -int mount_sd_fat(const char *path); -int unmount_sd_fat(const char *path); +s32 mount_sd_fat(const char *path); +s32 unmount_sd_fat(const char *path); #ifdef __cplusplus } diff --git a/src/gui/FreeTypeGX.cpp b/src/gui/FreeTypeGX.cpp index 6111153..4784e04 100644 --- a/src/gui/FreeTypeGX.cpp +++ b/src/gui/FreeTypeGX.cpp @@ -1,6 +1,6 @@ /* * FreeTypeGX is a wrapper class for libFreeType which renders a compiled - * FreeType parsable font into a GX texture for Wii homebrew development. + * FreeType parsable font so a GX texture for Wii homebrew development. * Copyright (C) 2008 Armin Tamzarian * Modified by Dimok, 2015 for WiiU GX2 * @@ -34,7 +34,7 @@ using namespace std; */ FreeTypeGX::FreeTypeGX(const uint8_t* fontBuffer, FT_Long bufferSize, bool lastFace) { - int faceIndex = 0; + int32_t faceIndex = 0; ftPointSize = 0; GX2InitSampler(&ftSampler, GX2_TEX_CLAMP_CLAMP_BORDER, GX2_TEX_XY_FILTER_BILINEAR); @@ -78,7 +78,7 @@ wchar_t* FreeTypeGX::charToWideChar(const char* strChar) wchar_t *strWChar = new (std::nothrow) wchar_t[strlen(strChar) + 1]; if (!strWChar) return NULL; - int bt = mbstowcs(strWChar, strChar, strlen(strChar)); + int32_t bt = mbstowcs(strWChar, strChar, strlen(strChar)); if (bt > 0) { strWChar[bt] = 0; @@ -389,7 +389,7 @@ uint16_t FreeTypeGX::drawText(CVideo *video, int16_t x, int16_t y, int16_t z, co y_offset = getStyleOffsetHeight(textStyle, pixelSize); } - int i = 0; + int32_t i = 0; while (text[i]) { ftgxCharData* glyphData = cacheGlyphData(text[i], pixelSize); @@ -429,8 +429,8 @@ uint16_t FreeTypeGX::getWidth(const wchar_t *text, int16_t pixelSize) uint16_t strWidth = 0; FT_Vector pairDelta; + int32_t i = 0; - int i = 0; while (text[i]) { ftgxCharData* glyphData = cacheGlyphData(text[i], pixelSize); @@ -505,7 +505,7 @@ void FreeTypeGX::getOffset(const wchar_t *text, int16_t pixelSize, uint16_t widt int16_t strMax = 0, strMin = 9999; uint16_t currWidth = 0; - int i = 0; + int32_t i = 0; while (text[i]) { diff --git a/src/gui/GameIcon.cpp b/src/gui/GameIcon.cpp index 2e1aa73..dba86b8 100644 --- a/src/gui/GameIcon.cpp +++ b/src/gui/GameIcon.cpp @@ -183,7 +183,7 @@ void GameIcon::draw(CVideo *pVideo, const glm::mat4 & projectionMtx, const glm:: f32 strokeScaleX = pVideo->getWidthScaleFactor() * strokeWidth * 0.25f + cfIconMirrorScale; f32 strokeScaleY = pVideo->getHeightScaleFactor() * strokeWidth * 0.25f + cfIconMirrorScale; - for(int iDraw = 0; iDraw < 2; iDraw++) + for(s32 iDraw = 0; iDraw < 2; iDraw++) { glm::vec4 * alphaFadeOut; glm::mat4 m_iconView; diff --git a/src/gui/GameIcon.h b/src/gui/GameIcon.h index 238060c..9f2923d 100644 --- a/src/gui/GameIcon.h +++ b/src/gui/GameIcon.h @@ -72,7 +72,7 @@ private: f32 *strokePosVtxs; f32 *strokeTexCoords; u8 *strokeColorVtxs; - int strokeFractalEnable; + s32 strokeFractalEnable; f32 strokeBlurBorder; glm::vec4 selectionBlurOuterColorIntensity; f32 selectionBlurOuterSize; diff --git a/src/gui/GameIconModel.h b/src/gui/GameIconModel.h index 97621ea..6149557 100644 --- a/src/gui/GameIconModel.h +++ b/src/gui/GameIconModel.h @@ -755,6 +755,6 @@ const float cfGameIconStrokeVtxs[] = -0.376756459475,1.046143651009,0.0f }; -const unsigned int cuGameIconStrokeVtxCount = sizeof(cfGameIconStrokeVtxs) / (sizeof(float) * 3); +const u32 cuGameIconStrokeVtxCount = sizeof(cfGameIconStrokeVtxs) / (sizeof(float) * 3); #endif diff --git a/src/gui/GridBackground.cpp b/src/gui/GridBackground.cpp index d027ab8..026c7c9 100644 --- a/src/gui/GridBackground.cpp +++ b/src/gui/GridBackground.cpp @@ -20,7 +20,7 @@ GridBackground::GridBackground(GuiImageData *img) if(m_posVtxs) { - int i = 0; + s32 i = 0; m_posVtxs[i++] = -1.0f; m_posVtxs[i++] = 0.0f; m_posVtxs[i++] = 1.0f; m_posVtxs[i++] = 1.0f; m_posVtxs[i++] = 0.0f; m_posVtxs[i++] = 1.0f; m_posVtxs[i++] = 1.0f; m_posVtxs[i++] = 0.0f; m_posVtxs[i++] = -1.0f; @@ -44,7 +44,7 @@ GridBackground::GridBackground(GuiImageData *img) sinRot, cosRot }); - for(int i = 0; i < 4; i++) { + for(s32 i = 0; i < 4; i++) { texCoordVec[i] = texRotateMtx * texCoordVec[i]; m_texCoords[i*2 + 0] = texCoordVec[i][0]; m_texCoords[i*2 + 1] = texCoordVec[i][1]; diff --git a/src/gui/GuiButton.cpp b/src/gui/GuiButton.cpp index ae05a8d..82820c9 100644 --- a/src/gui/GuiButton.cpp +++ b/src/gui/GuiButton.cpp @@ -33,14 +33,14 @@ GuiButton::GuiButton(f32 w, f32 h) icon = NULL; iconOver = NULL; - for(int i = 0; i < 4; i++) + for(s32 i = 0; i < 4; i++) { label[i] = NULL; labelOver[i] = NULL; labelHold[i] = NULL; labelClick[i] = NULL; } - for(int i = 0; i < iMaxGuiTriggers; i++) + for(s32 i = 0; i < iMaxGuiTriggers; i++) { trigger[i] = NULL; } @@ -93,22 +93,22 @@ void GuiButton::setIconOver(GuiImage* img) if(img) img->setParent(this); } -void GuiButton::setLabel(GuiText* txt, int n) +void GuiButton::setLabel(GuiText* txt, s32 n) { label[n] = txt; if(txt) txt->setParent(this); } -void GuiButton::setLabelOver(GuiText* txt, int n) +void GuiButton::setLabelOver(GuiText* txt, s32 n) { labelOver[n] = txt; if(txt) txt->setParent(this); } -void GuiButton::setLabelHold(GuiText* txt, int n) +void GuiButton::setLabelHold(GuiText* txt, s32 n) { labelHold[n] = txt; if(txt) txt->setParent(this); } -void GuiButton::setLabelClick(GuiText* txt, int n) +void GuiButton::setLabelClick(GuiText* txt, s32 n) { labelClick[n] = txt; if(txt) txt->setParent(this); @@ -127,7 +127,7 @@ void GuiButton::setSoundClick(GuiSound * snd) soundClick = snd; } -void GuiButton::setTrigger(GuiTrigger * t, int idx) +void GuiButton::setTrigger(GuiTrigger * t, s32 idx) { if(idx >= 0 && idx < iMaxGuiTriggers) { @@ -135,7 +135,7 @@ void GuiButton::setTrigger(GuiTrigger * t, int idx) } else { - for(int i = 0; i < iMaxGuiTriggers; i++) + for(s32 i = 0; i < iMaxGuiTriggers; i++) { if(!trigger[i]) { @@ -175,7 +175,7 @@ void GuiButton::draw(CVideo *v) icon->draw(v); // draw text - for(int i = 0; i < 4; i++) + for(s32 i = 0; i < 4; i++) { if(isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && labelOver[i]) labelOver[i]->draw(v); @@ -231,7 +231,7 @@ void GuiButton::update(GuiController * c) } } - for(int i = 0; i < iMaxGuiTriggers; i++) + for(s32 i = 0; i < iMaxGuiTriggers; i++) { if(!trigger[i]) continue; @@ -240,7 +240,7 @@ void GuiButton::update(GuiController * c) if(clickable) { - int isClicked = trigger[i]->clicked(c); + s32 isClicked = trigger[i]->clicked(c); if( !clickedTrigger && (isClicked != GuiTrigger::CLICKED_NONE) && (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chan) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) diff --git a/src/gui/GuiButton.h b/src/gui/GuiButton.h index 0e08d42..0336df1 100644 --- a/src/gui/GuiButton.h +++ b/src/gui/GuiButton.h @@ -52,19 +52,19 @@ class GuiButton : public GuiElement //!Sets the button's label //!\param t Pointer to GuiText object //!\param n Index of label to set (optional, default is 0) - void setLabel(GuiText* t, int n = 0); + void setLabel(GuiText* t, s32 n = 0); //!Sets the button's label on over (eg: different colored text) //!\param t Pointer to GuiText object //!\param n Index of label to set (optional, default is 0) - void setLabelOver(GuiText* t, int n = 0); + void setLabelOver(GuiText* t, s32 n = 0); //!Sets the button's label on hold //!\param t Pointer to GuiText object //!\param n Index of label to set (optional, default is 0) - void setLabelHold(GuiText* t, int n = 0); + void setLabelHold(GuiText* t, s32 n = 0); //!Sets the button's label on click //!\param t Pointer to GuiText object //!\param n Index of label to set (optional, default is 0) - void setLabelClick(GuiText* t, int n = 0); + void setLabelClick(GuiText* t, s32 n = 0); //!Sets the sound to play on over //!\param s Pointer to GuiSound object void setSoundOver(GuiSound * s); @@ -77,7 +77,7 @@ class GuiButton : public GuiElement //!Set a new GuiTrigger for the element //!\param i Index of trigger array to set //!\param t Pointer to GuiTrigger - void setTrigger(GuiTrigger * t, int idx = -1); + void setTrigger(GuiTrigger * t, s32 idx = -1); //! void resetState(void); //!Constantly called to draw the GuiButton @@ -85,7 +85,7 @@ class GuiButton : public GuiElement //!Constantly called to allow the GuiButton to respond to updated input data //!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD void update(GuiController * c); - + sigslot::signal2 selected; sigslot::signal2 deSelected; sigslot::signal2 pointedOn; @@ -94,7 +94,7 @@ class GuiButton : public GuiElement sigslot::signal3 held; sigslot::signal3 released; protected: - static const int iMaxGuiTriggers = 10; + static const s32 iMaxGuiTriggers = 10; GuiImage * image; //!< Button image (default) GuiImage * imageOver; //!< Button image for STATE_SELECTED diff --git a/src/gui/GuiConfigurationScreen.h b/src/gui/GuiConfigurationScreen.h index 4e1abcd..78a81eb 100644 --- a/src/gui/GuiConfigurationScreen.h +++ b/src/gui/GuiConfigurationScreen.h @@ -23,11 +23,11 @@ class GuiConfigurationScreen : public GuiFrame { public: - GuiConfigurationScreen(int w, int h) : GuiFrame(w, h) {} + GuiConfigurationScreen(s32 w, s32 h) : GuiFrame(w, h) {} virtual ~GuiConfigurationScreen() {} - sigslot::signal2 gameLaunchClicked; - sigslot::signal2 gameSelectionChanged; + sigslot::signal2 gameLaunchClicked; + sigslot::signal2 gameSelectionChanged; }; #endif /* GUICONFIGURATIONSCREEN_H_ */ diff --git a/src/gui/GuiController.h b/src/gui/GuiController.h index c9cc443..76aa13a 100644 --- a/src/gui/GuiController.h +++ b/src/gui/GuiController.h @@ -24,7 +24,7 @@ class GuiController { public: //!Constructor - GuiController(int channel) + GuiController(s32 channel) : chan(channel) { memset(&lastData, 0, sizeof(lastData)); @@ -54,22 +54,22 @@ public: //!Destructor virtual ~GuiController() {} - virtual bool update(int width, int height) = 0; + virtual bool update(s32 width, s32 height) = 0; typedef struct { - unsigned int buttons_h; - unsigned int buttons_d; - unsigned int buttons_r; + u32 buttons_h; + u32 buttons_d; + u32 buttons_r; bool validPointer; bool touched; float pointerAngle; - int x; - int y; + s32 x; + s32 y; } PadData; - int chan; - int chanIdx; + s32 chan; + s32 chanIdx; PadData data; PadData lastData; diff --git a/src/gui/GuiControllerInputDisplay.cpp b/src/gui/GuiControllerInputDisplay.cpp index 1eb4061..32b5c64 100644 --- a/src/gui/GuiControllerInputDisplay.cpp +++ b/src/gui/GuiControllerInputDisplay.cpp @@ -19,8 +19,6 @@ #include "utils/StringTools.h" #include "utils/logger.h" - - GuiControllerInputDisplay::GuiControllerInputDisplay(UController_Type _controller_type): GuiFrame(441,324) , controller_type(_controller_type) , proImageData(Resources::GetImageData("buttons_pro_controller.png")) @@ -45,29 +43,21 @@ GuiControllerInputDisplay::GuiControllerInputDisplay(UController_Type _controlle } typedef std::map::iterator it_type; for(it_type iterator = btn_list->begin(); iterator != btn_list->end(); iterator++) { - //log_printf("Adding button! \"%s\"\n",iterator->first.c_str()); - //log_printf("Creating ButtonConfig* \n"); ButtonConfig * btn_cfg = new ButtonConfig; if(btn_cfg == NULL){ log_printf("Error on alloc ButtonConfig\n"); continue; } memset(btn_cfg,0,sizeof(ButtonConfig)); - //log_printf("Creating suffix \n"); std::string * suffix = new std::string(iterator->first); - //log_printf("Setting suffix \n"); btn_cfg->img.suffix = suffix; - //log_printf("creating new filename\n"); std::string filename = strfmt("%s%s.png",prefix.c_str(),btn_cfg->img.suffix->c_str()); - //log_printf("loading file..%s \n",filename.c_str()); btn_cfg->img.imagedata = Resources::GetImageData(filename.c_str()); if(btn_cfg->img.imagedata == NULL){ log_printf("Error, was null!\n"); delete btn_cfg; continue; } - //log_printf("Done!\n"); - //log_printf("loading image..\n"); btn_cfg->img.image = new GuiImage(btn_cfg->img.imagedata); if(btn_cfg->img.image == NULL){ log_printf("Error, was null! Removing ImageData\n"); @@ -75,11 +65,9 @@ GuiControllerInputDisplay::GuiControllerInputDisplay(UController_Type _controlle delete btn_cfg; continue; } - //log_printf("setting value to %08X.\n",iterator->second); btn_cfg->value = iterator->second; controllerConfig.buttons.push_back(btn_cfg); btn_cfg->img.image->setState(STATE_HIDDEN); - //log_printf("Appending\n"); append(btn_cfg->img.image); } } @@ -109,18 +97,17 @@ void GuiControllerInputDisplay::process(){ buttons_hold = gamepadData.btns_h; }else{ - int chan = 0; + s32 chan = 0; if(controller_type == UController_Type_Pro1){ chan = 0;} if(controller_type == UController_Type_Pro2){ chan = 1;} if(controller_type == UController_Type_Pro3){ chan = 2;} if(controller_type == UController_Type_Pro4){ chan = 3;} - int res = 0; + s32 res = 0; if((res = ControllerPatcher::setProControllerDataFromHID((void *) &proData,chan,PRO_CONTROLLER_MODE_KPADDATA)) >= 0){ buttons_hold = proData.pro.btns_h; } } - for(std::vector::iterator it = controllerConfig.buttons.begin(); it != controllerConfig.buttons.end(); ++it) { ButtonConfig * btn_cfg = *it; if(btn_cfg != NULL){ diff --git a/src/gui/GuiDragListener.cpp b/src/gui/GuiDragListener.cpp index 858f8bc..8cfc32e 100644 --- a/src/gui/GuiDragListener.cpp +++ b/src/gui/GuiDragListener.cpp @@ -26,7 +26,7 @@ GuiDragListener::GuiDragListener(f32 w,f32 h){ width = w; height = h; - for(int i = 0; i < iMaxGuiTriggers; i++) + for(s32 i = 0; i < iMaxGuiTriggers; i++) { trigger[i] = NULL; } @@ -38,18 +38,18 @@ GuiDragListener::GuiDragListener(f32 w,f32 h){ GuiDragListener::~GuiDragListener(){ } -void GuiDragListener::setState(int i, int c){ +void GuiDragListener::setState(s32 i, s32 c){ GuiElement::setState(i,c); } -void GuiDragListener::setTrigger(GuiTrigger * t, int idx){ +void GuiDragListener::setTrigger(GuiTrigger * t, s32 idx){ if(idx >= 0 && idx < iMaxGuiTriggers) { trigger[idx] = t; } else { - for(int i = 0; i < iMaxGuiTriggers; i++) + for(s32 i = 0; i < iMaxGuiTriggers; i++) { if(!trigger[i]) { @@ -66,7 +66,7 @@ void GuiDragListener::update(GuiController * c){ else if(parentElement && (parentElement->isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chan))) return; - for(int i = 0; i < iMaxGuiTriggers; i++){ + for(s32 i = 0; i < iMaxGuiTriggers; i++){ if(!trigger[i]){ continue; } @@ -75,8 +75,8 @@ void GuiDragListener::update(GuiController * c){ if(isHeld && this->isInside(c->data.x, c->data.y)){ - int dx = c->data.x - c->lastData.x; - int dy = c->data.y - c->lastData.y; + s32 dx = c->data.x - c->lastData.x; + s32 dy = c->data.y - c->lastData.y; if(dx == 0 && dy == 0) continue; diff --git a/src/gui/GuiDragListener.h b/src/gui/GuiDragListener.h index 4c67743..fe40eed 100644 --- a/src/gui/GuiDragListener.h +++ b/src/gui/GuiDragListener.h @@ -32,20 +32,20 @@ class GuiDragListener : public GuiElement //!Destructor virtual ~GuiDragListener(); - void setState(int i, int c); + void setState(s32 i, s32 c); //!Set a new GuiTrigger for the element //!\param i Index of trigger array to set //!\param t Pointer to GuiTrigger - void setTrigger(GuiTrigger * t, int idx = -1); + void setTrigger(GuiTrigger * t, s32 idx = -1); //!Constantly called to allow the GuiDragListener to respond to updated input data //!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD void update(GuiController * c); - sigslot::signal5 dragged; + sigslot::signal5 dragged; protected: - static const int iMaxGuiTriggers = 10; + static const s32 iMaxGuiTriggers = 10; GuiTrigger * trigger[iMaxGuiTriggers]; //!< GuiTriggers (input actions) that this element responds to }; diff --git a/src/gui/GuiElement.cpp b/src/gui/GuiElement.cpp index e79253b..ac26d0a 100644 --- a/src/gui/GuiElement.cpp +++ b/src/gui/GuiElement.cpp @@ -17,8 +17,8 @@ #include "GuiElement.h" //! TODO remove this! -static int screenwidth = 1280; -static int screenheight = 720; +static s32 screenwidth = 1280; +static s32 screenheight = 720; /** * Constructor for the Object class. @@ -34,7 +34,7 @@ GuiElement::GuiElement() scaleX = 1.0f; scaleY = 1.0f; scaleZ = 1.0f; - for(int i = 0; i < 4; i++) + for(s32 i = 0; i < 4; i++) state[i] = STATE_DEFAULT; stateChan = -1; parentElement = NULL; @@ -130,7 +130,7 @@ f32 GuiElement::getTop() return y + yoffset; } -void GuiElement::setEffect(int eff, int amount, int target) +void GuiElement::setEffect(s32 eff, s32 amount, s32 target) { if(eff & EFFECT_SLIDE_IN) { @@ -138,28 +138,28 @@ void GuiElement::setEffect(int eff, int amount, int target) if(eff & EFFECT_SLIDE_TOP) { if(eff & EFFECT_SLIDE_FROM) - yoffsetDyn = (int) -getHeight()*scaleY; + yoffsetDyn = (s32) -getHeight()*scaleY; else yoffsetDyn = -screenheight; } else if(eff & EFFECT_SLIDE_LEFT) { if(eff & EFFECT_SLIDE_FROM) - xoffsetDyn = (int) -getWidth()*scaleX; + xoffsetDyn = (s32) -getWidth()*scaleX; else xoffsetDyn = -screenwidth; } else if(eff & EFFECT_SLIDE_BOTTOM) { if(eff & EFFECT_SLIDE_FROM) - yoffsetDyn = (int) getHeight()*scaleY; + yoffsetDyn = (s32) getHeight()*scaleY; else yoffsetDyn = screenheight; } else if(eff & EFFECT_SLIDE_RIGHT) { if(eff & EFFECT_SLIDE_FROM) - xoffsetDyn = (int) getWidth()*scaleX; + xoffsetDyn = (s32) getWidth()*scaleX; else xoffsetDyn = screenwidth; } @@ -181,7 +181,7 @@ void GuiElement::setEffect(int eff, int amount, int target) //!\param e Effect to enable //!\param a Amount of the effect (usage varies on effect) //!\param t Target amount of the effect (usage varies on effect) -void GuiElement::setEffectOnOver(int e, int a, int t) +void GuiElement::setEffectOnOver(s32 e, s32 a, s32 t) { effectsOver |= e; effectAmountOver = a; diff --git a/src/gui/GuiElement.h b/src/gui/GuiElement.h index 720a721..7b313a9 100644 --- a/src/gui/GuiElement.h +++ b/src/gui/GuiElement.h @@ -239,7 +239,7 @@ class GuiElement : public AsyncDeleter::Element //!Sets the element's state //!\param s State (STATE_DEFAULT, STATE_SELECTED, STATE_CLICKED, STATE_DISABLED) //!\param c Controller channel (0-3, -1 = none) - virtual void setState(int s, int c = -1) + virtual void setState(s32 s, s32 c = -1) { if(c >= 0 && c < 4) { @@ -247,13 +247,13 @@ class GuiElement : public AsyncDeleter::Element } else { - for(int i = 0; i < 4; i++) + for(s32 i = 0; i < 4; i++) state[i] |= s; } stateChan = c; stateChanged(this, s, c); } - virtual void clearState(int s, int c = -1) + virtual void clearState(s32 s, s32 c = -1) { if(c >= 0 && c < 4) { @@ -261,13 +261,13 @@ class GuiElement : public AsyncDeleter::Element } else { - for(int i = 0; i < 4; i++) + for(s32 i = 0; i < 4; i++) state[i] &= ~s; } stateChan = c; stateChanged(this, s, c); } - virtual bool isStateSet(int s, int c = -1) const + virtual bool isStateSet(s32 s, s32 c = -1) const { if(c >= 0 && c < 4) { @@ -275,7 +275,7 @@ class GuiElement : public AsyncDeleter::Element } else { - for(int i = 0; i < 4; i++) + for(s32 i = 0; i < 4; i++) if((state[i] & s) != 0) return true; @@ -284,14 +284,14 @@ class GuiElement : public AsyncDeleter::Element } //!Gets the element's current state //!\return state - virtual int getState(int c = 0) { return state[c]; }; + virtual s32 getState(s32 c = 0) { return state[c]; }; //!Gets the controller channel that last changed the element's state //!\return Channel number (0-3, -1 = no channel) - virtual int getStateChan() { return stateChan; }; + virtual s32 getStateChan() { return stateChan; }; //!Resets the element's state to STATE_DEFAULT virtual void resetState() { - for(int i = 0; i < 4; i++) + for(s32 i = 0; i < 4; i++) state[i] = STATE_DEFAULT; stateChan = -1; } @@ -386,19 +386,19 @@ class GuiElement : public AsyncDeleter::Element //!\param e Effect to enable //!\param a Amount of the effect (usage varies on effect) //!\param t Target amount of the effect (usage varies on effect) - virtual void setEffect(int e, int a, int t=0); + virtual void setEffect(s32 e, s32 a, s32 t=0); //!Sets an effect to be enabled on wiimote cursor over //!\param e Effect to enable //!\param a Amount of the effect (usage varies on effect) //!\param t Target amount of the effect (usage varies on effect) - virtual void setEffectOnOver(int e, int a, int t=0); + virtual void setEffectOnOver(s32 e, s32 a, s32 t=0); //!Shortcut to SetEffectOnOver(EFFECT_SCALE, 4, 110) virtual void setEffectGrow() { setEffectOnOver(EFFECT_SCALE, 4, 110); } //!Reset all applied effects virtual void resetEffects(); //!Gets the current element effects //!\return element effects - virtual int getEffect() const { return effects; } + virtual s32 getEffect() const { return effects; } //!\return true if element animation is on going virtual bool isAnimated() const { return (parentElement != 0) && (getEffect() > 0); } //!Checks whether the specified coordinates are within the element's boundaries @@ -432,13 +432,13 @@ class GuiElement : public AsyncDeleter::Element } //!Gets whether or not the element is in STATE_SELECTED //!\return true if selected, false otherwise - virtual int getSelected() { return -1; } + virtual s32 getSelected() { return -1; } //!Sets the element's alignment respective to its parent element //!Bitwise ALIGN_LEFT | ALIGN_RIGHT | ALIGN_CENTRE, ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE) //!\param align Alignment - virtual void setAlignment(int a) { alignment = a; } + virtual void setAlignment(s32 a) { alignment = a; } //!Gets the element's alignment - virtual int getAlignment() const { return alignment; } + virtual s32 getAlignment() const { return alignment; } //!Angle of the object virtual void setAngle(f32 a) { angle = a; } //!Angle of the object @@ -489,7 +489,7 @@ class GuiElement : public AsyncDeleter::Element } //! Signals sigslot::signal2 visibleChanged; - sigslot::signal3 stateChanged; + sigslot::signal3 stateChanged; sigslot::signal1 effectFinished; protected: bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event @@ -508,22 +508,22 @@ class GuiElement : public AsyncDeleter::Element f32 scaleX; //!< Element scale (1 = 100%) f32 scaleY; //!< Element scale (1 = 100%) f32 scaleZ; //!< Element scale (1 = 100%) - int alignment; //!< Horizontal element alignment, respective to parent element - int state[4]; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED) - int stateChan; //!< Which controller channel is responsible for the last change in state + s32 alignment; //!< Horizontal element alignment, respective to parent element + s32 state[4]; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED) + s32 stateChan; //!< Which controller channel is responsible for the last change in state GuiElement * parentElement; //!< Parent element //! TODO: Move me to some Animator class - int xoffsetDyn; //!< Element X offset, dynamic (added to xoffset value for animation effects) - int yoffsetDyn; //!< Element Y offset, dynamic (added to yoffset value for animation effects) + s32 xoffsetDyn; //!< Element X offset, dynamic (added to xoffset value for animation effects) + s32 yoffsetDyn; //!< Element Y offset, dynamic (added to yoffset value for animation effects) f32 alphaDyn; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects) f32 scaleDyn; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects) - int effects; //!< Currently enabled effect(s). 0 when no effects are enabled - int effectAmount; //!< Effect amount. Used by different effects for different purposes - int effectTarget; //!< Effect target amount. Used by different effects for different purposes - int effectsOver; //!< Effects to enable when wiimote cursor is over this element. Copied to effects variable on over event - int effectAmountOver; //!< EffectAmount to set when wiimote cursor is over this element - int effectTargetOver; //!< EffectTarget to set when wiimote cursor is over this element + s32 effects; //!< Currently enabled effect(s). 0 when no effects are enabled + s32 effectAmount; //!< Effect amount. Used by different effects for different purposes + s32 effectTarget; //!< Effect target amount. Used by different effects for different purposes + s32 effectsOver; //!< Effects to enable when wiimote cursor is over this element. Copied to effects variable on over event + s32 effectAmountOver; //!< EffectAmount to set when wiimote cursor is over this element + s32 effectTargetOver; //!< EffectTarget to set when wiimote cursor is over this element }; #endif diff --git a/src/gui/GuiFrame.cpp b/src/gui/GuiFrame.cpp index 88b19fc..a25e8ce 100644 --- a/src/gui/GuiFrame.cpp +++ b/src/gui/GuiFrame.cpp @@ -118,7 +118,7 @@ void GuiFrame::resetState() } } -void GuiFrame::setState(int s, int c) +void GuiFrame::setState(s32 s, s32 c) { GuiElement::setState(s, c); @@ -128,7 +128,7 @@ void GuiFrame::setState(int s, int c) } } -void GuiFrame::clearState(int s, int c) +void GuiFrame::clearState(s32 s, s32 c) { GuiElement::clearState(s, c); @@ -148,10 +148,10 @@ void GuiFrame::setVisible(bool v) } } -int GuiFrame::getSelected() +s32 GuiFrame::getSelected() { // find selected element - int found = -1; + s32 found = -1; for (u32 i = 0; i < elements.size(); ++i) { if(elements[i]->isStateSet(STATE_SELECTED | STATE_OVER)) diff --git a/src/gui/GuiFrame.h b/src/gui/GuiFrame.h index 14f7616..1d127c8 100644 --- a/src/gui/GuiFrame.h +++ b/src/gui/GuiFrame.h @@ -61,11 +61,11 @@ class GuiFrame : public GuiElement void resetState(); //!Sets the window's state //!\param s State - void setState(int s, int c = -1); - void clearState(int s, int c = -1); + void setState(s32 s, s32 c = -1); + void clearState(s32 s, s32 c = -1); //!Gets the index of the GuiElement inside the window that is currently selected //!\return index of selected GuiElement - int getSelected(); + s32 getSelected(); //!Dim the Window's background void dimBackground(bool d); //!Draws all the elements in this GuiFrame diff --git a/src/gui/GuiImage.cpp b/src/gui/GuiImage.cpp index 344b770..34aefb8 100644 --- a/src/gui/GuiImage.cpp +++ b/src/gui/GuiImage.cpp @@ -33,7 +33,7 @@ GuiImage::GuiImage(GuiImageData * img) imageData = img; } -GuiImage::GuiImage(int w, int h, const GX2Color & c, int type) +GuiImage::GuiImage(s32 w, s32 h, const GX2Color & c, s32 type) { internalInit(w, h); imgType = type; @@ -47,7 +47,7 @@ GuiImage::GuiImage(int w, int h, const GX2Color & c, int type) } } -GuiImage::GuiImage(int w, int h, const GX2Color *c, u32 color_count, int type) +GuiImage::GuiImage(s32 w, s32 h, const GX2Color *c, u32 color_count, s32 type) { internalInit(w, h); imgType = type; @@ -61,7 +61,7 @@ GuiImage::GuiImage(int w, int h, const GX2Color *c, u32 color_count, int type) for(u32 i = 0; i < colorCount; i++) { // take the last as reference if not enough colors defined - int idx = (i < color_count) ? i : (color_count - 1); + s32 idx = (i < color_count) ? i : (color_count - 1); setImageColor(c[idx], i); } } @@ -78,7 +78,7 @@ GuiImage::~GuiImage() } } -void GuiImage::internalInit(int w, int h) +void GuiImage::internalInit(s32 w, s32 h) { imageData = NULL; width = w; @@ -114,7 +114,7 @@ void GuiImage::setImageData(GuiImageData * img) imgType = IMAGE_TEXTURE; } -GX2Color GuiImage::getPixel(int x, int y) +GX2Color GuiImage::getPixel(s32 x, s32 y) { if(!imageData || this->getWidth() <= 0 || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight()) return (GX2Color){0, 0, 0, 0}; @@ -131,7 +131,7 @@ GX2Color GuiImage::getPixel(int x, int y) return color; } -void GuiImage::setPixel(int x, int y, const GX2Color & color) +void GuiImage::setPixel(s32 x, s32 y, const GX2Color & color) { if(!imageData || this->getWidth() <= 0 || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight()) return; @@ -142,13 +142,13 @@ void GuiImage::setPixel(int x, int y, const GX2Color & color) imagePtr[y * pitch + x] = (color.r << 24) | (color.g << 16) | (color.b << 8) | (color.a << 0); } -void GuiImage::setImageColor(const GX2Color & c, int idx) +void GuiImage::setImageColor(const GX2Color & c, s32 idx) { if(!colorVtxs) { return; } - if(idx >= 0 && idx < (int)colorCount) + if(idx >= 0 && idx < (s32)colorCount) { colorVtxs[(idx << 2) + 0] = c.r; colorVtxs[(idx << 2) + 1] = c.g; @@ -169,7 +169,7 @@ void GuiImage::setImageColor(const GX2Color & c, int idx) } } -void GuiImage::setSize(int w, int h) +void GuiImage::setSize(s32 w, s32 h) { width = w; height = h; @@ -188,8 +188,8 @@ void GuiImage::setPrimitiveVertex(s32 prim, const f32 *posVtx, const f32 *texCoo for(u32 i = 0; i < vtxCount; i++) { - int newColorIdx = (i << 2); - int colorIdx = (i < colorCount) ? (newColorIdx) : ((colorCount - 1) << 2); + s32 newColorIdx = (i << 2); + s32 colorIdx = (i < colorCount) ? (newColorIdx) : ((colorCount - 1) << 2); newColorVtxs[newColorIdx + 0] = colorVtxs[colorIdx + 0]; newColorVtxs[newColorIdx + 1] = colorVtxs[colorIdx + 1]; @@ -228,8 +228,8 @@ void GuiImage::draw(CVideo *pVideo) // if(image && tileHorizontal > 0 && tileVertical > 0) // { -// for(int n=0; n 0) // { -// for(int i=0; i 0) // { -// for(int i=0; ifilename.c_str(), &buffer, &bufferSize); + s32 iResult = LoadFileToMem(pInUse->filename.c_str(), &buffer, &bufferSize); if(iResult > 0) { pInUse->imgData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MIRROR); @@ -159,8 +159,9 @@ void GuiImageAsync::threadInit() void GuiImageAsync::threadExit() { - if(threadRefCounter) + if(threadRefCounter){ --threadRefCounter; + } if(/*(threadRefCounter == 0) &&*/ (pThread != NULL)) { diff --git a/src/gui/GuiImageData.cpp b/src/gui/GuiImageData.cpp index 7e9a790..6532bee 100644 --- a/src/gui/GuiImageData.cpp +++ b/src/gui/GuiImageData.cpp @@ -31,7 +31,7 @@ GuiImageData::GuiImageData() /** * Constructor for the GuiImageData class. */ -GuiImageData::GuiImageData(const u8 * img, int imgSize, int textureClamp, int textureFormat) +GuiImageData::GuiImageData(const u8 * img, s32 imgSize, s32 textureClamp, s32 textureFormat) { texture = NULL; sampler = NULL; @@ -74,7 +74,7 @@ void GuiImageData::releaseData(void) } } -void GuiImageData::loadImage(const u8 *img, int imgSize, int textureClamp, int textureFormat) +void GuiImageData::loadImage(const u8 *img, s32 imgSize, s32 textureClamp, s32 textureFormat) { if(!img || (imgSize < 8)) return; diff --git a/src/gui/GuiImageData.h b/src/gui/GuiImageData.h index 03bc1df..a03fbe2 100644 --- a/src/gui/GuiImageData.h +++ b/src/gui/GuiImageData.h @@ -29,22 +29,22 @@ public: GuiImageData(); //!\param img Image data //!\param imgSize The image size - GuiImageData(const u8 * img, int imgSize, int textureClamp = GX2_TEX_CLAMP_CLAMP, int textureFormat = GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM); + GuiImageData(const u8 * img, s32 imgSize, s32 textureClamp = GX2_TEX_CLAMP_CLAMP, s32 textureFormat = GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM); //!Destructor virtual ~GuiImageData(); //!Load image from buffer //!\param img Image data //!\param imgSize The image size - void loadImage(const u8 * img, int imgSize, int textureClamp = GX2_TEX_CLAMP_CLAMP, int textureFormat = GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM); + void loadImage(const u8 * img, s32 imgSize, s32 textureClamp = GX2_TEX_CLAMP_CLAMP, s32 textureFormat = GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM); //! getter functions const GX2Texture * getTexture() const { return texture; }; const GX2Sampler * getSampler() const { return sampler; }; //!Gets the image width //!\return image width - int getWidth() const { if(texture) return texture->surface.width; else return 0; }; + s32 getWidth() const { if(texture) return texture->surface.width; else return 0; }; //!Gets the image height //!\return image height - int getHeight() const { if(texture) return texture->surface.height; else return 0; }; + s32 getHeight() const { if(texture) return texture->surface.height; else return 0; }; //! release memory of the image data void releaseData(void); private: diff --git a/src/gui/GuiParticleImage.cpp b/src/gui/GuiParticleImage.cpp index e39930f..b9630cc 100644 --- a/src/gui/GuiParticleImage.cpp +++ b/src/gui/GuiParticleImage.cpp @@ -30,7 +30,7 @@ static inline f32 getRandMinusOneToOneF32() return getRandZeroToOneF32() * 2.0f - 1.0f; } -GuiParticleImage::GuiParticleImage(int w, int h, u32 particleCount) +GuiParticleImage::GuiParticleImage(s32 w, s32 h, u32 particleCount) : GuiImage(NULL) { width = w; diff --git a/src/gui/GuiParticleImage.h b/src/gui/GuiParticleImage.h index eb7565b..b62eb0c 100644 --- a/src/gui/GuiParticleImage.h +++ b/src/gui/GuiParticleImage.h @@ -22,7 +22,7 @@ class GuiParticleImage : public GuiImage, public sigslot::has_slots<> { public: - GuiParticleImage(int w, int h, u32 particleCount); + GuiParticleImage(s32 w, s32 h, u32 particleCount); virtual ~GuiParticleImage(); void draw(CVideo *pVideo); diff --git a/src/gui/GuiSelectBox.cpp b/src/gui/GuiSelectBox.cpp index 827dc61..7353777 100644 --- a/src/gui/GuiSelectBox.cpp +++ b/src/gui/GuiSelectBox.cpp @@ -151,7 +151,7 @@ void GuiSelectBox::OnDPADClick(GuiButton *button, const GuiController *controlle } } -void GuiSelectBox::Init(std::map values, int valueID) +void GuiSelectBox::Init(std::map values, s32 valueID) { if((u32)valueID >= values.size()){ valueID = 0; @@ -164,7 +164,7 @@ void GuiSelectBox::Init(std::map values, int valueID) valueButtons.resize(values.size()); - int i = 0; + s32 i = 0; f32 imgScale = 1.0f; std::map::iterator itr; for(itr = values.begin(); itr != values.end(); itr++) { @@ -240,7 +240,7 @@ GuiSelectBox::~GuiSelectBox() } -void GuiSelectBox::setState(int s, int c) +void GuiSelectBox::setState(s32 s, s32 c) { GuiElement::setState(s, c); } diff --git a/src/gui/GuiSelectBox.h b/src/gui/GuiSelectBox.h index 1e8557e..deb12bd 100644 --- a/src/gui/GuiSelectBox.h +++ b/src/gui/GuiSelectBox.h @@ -35,9 +35,9 @@ class GuiSelectBox : public GuiFrame, public sigslot::has_slots<> sigslot::signal2 valueChanged; sigslot::signal2 showhide; void OnTopValueClicked(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); - void Init(std::map values, int valueID); + void Init(std::map values, s32 valueID); - void setState(int s, int c = -1); + void setState(s32 s, s32 c = -1); virtual f32 getTopValueHeight(); virtual f32 getTopValueWidth(); diff --git a/src/gui/GuiSound.cpp b/src/gui/GuiSound.cpp index 502a8a2..e4214b8 100644 --- a/src/gui/GuiSound.cpp +++ b/src/gui/GuiSound.cpp @@ -48,7 +48,7 @@ bool GuiSound::Load(const char * filepath) } //! find next free decoder - for(int i = 0; i < MAX_DECODERS; i++) + for(s32 i = 0; i < MAX_DECODERS; i++) { SoundDecoder * decoder = SoundHandler::instance()->getDecoder(i); if(decoder == NULL) @@ -64,8 +64,9 @@ bool GuiSound::Load(const char * filepath) } } - if(voice < 0) + if(voice < 0){ return false; + } return true; } @@ -82,7 +83,7 @@ bool GuiSound::Load(const u8 * snd, s32 len) return false; //! find next free decoder - for(int i = 0; i < MAX_DECODERS; i++) + for(s32 i = 0; i < MAX_DECODERS; i++) { SoundDecoder * decoder = SoundHandler::instance()->getDecoder(i); if(decoder == NULL) @@ -98,8 +99,9 @@ bool GuiSound::Load(const u8 * snd, s32 len) } } - if(voice < 0) + if(voice < 0){ return false; + } return true; } @@ -161,11 +163,10 @@ void GuiSound::Resume() bool GuiSound::IsPlaying() { Voice * v = SoundHandler::instance()->getVoice(voice); - if(v) + if(v){ return v->getState() == Voice::STATE_PLAYING; - + } return false; - } void GuiSound::SetVolume(u32 vol) diff --git a/src/gui/GuiSound.h b/src/gui/GuiSound.h index bb72a3b..3d0a1f2 100644 --- a/src/gui/GuiSound.h +++ b/src/gui/GuiSound.h @@ -28,7 +28,7 @@ class GuiSound : public AsyncDeleter::Element //!\param sound Pointer to the sound data //!\param filesize Length of sound data GuiSound(const char * filepath); - GuiSound(const u8 * sound, int length); + GuiSound(const u8 * sound, s32 length); //!Destructor virtual ~GuiSound(); //!Load a file and replace the old one diff --git a/src/gui/GuiText.cpp b/src/gui/GuiText.cpp index ab54e42..e9a9673 100644 --- a/src/gui/GuiText.cpp +++ b/src/gui/GuiText.cpp @@ -19,10 +19,10 @@ #include "video/CVideo.h" FreeTypeGX * GuiText::presentFont = NULL; -int GuiText::presetSize = 28; -int GuiText::presetInternalRenderingScale = 2.0f; //Lets render the font at the doubled size. This make it even smoother! -int GuiText::presetMaxWidth = 0xFFFF; -int GuiText::presetAlignment = ALIGN_CENTER | ALIGN_MIDDLE; +s32 GuiText::presetSize = 28; +float GuiText::presetInternalRenderingScale = 2.0f; //Lets render the font at the doubled size. This make it even smoother! +s32 GuiText::presetMaxWidth = 0xFFFF; +s32 GuiText::presetAlignment = ALIGN_CENTER | ALIGN_MIDDLE; GX2ColorF32 GuiText::presetColor = (GX2ColorF32){ 1.0f, 1.0f, 1.0f, 1.0f }; #define TEXT_SCROLL_DELAY 6 @@ -56,7 +56,7 @@ GuiText::GuiText() internalRenderingScale = presetInternalRenderingScale; } -GuiText::GuiText(const char * t, int s, const glm::vec4 & c) +GuiText::GuiText(const char * t, s32 s, const glm::vec4 & c) { text = NULL; size = s; @@ -88,7 +88,7 @@ GuiText::GuiText(const char * t, int s, const glm::vec4 & c) } } -GuiText::GuiText(const wchar_t * t, int s, const glm::vec4 & c) +GuiText::GuiText(const wchar_t * t, s32 s, const glm::vec4 & c) { text = NULL; size = s; @@ -199,7 +199,7 @@ void GuiText::setTextf(const char *format, ...) return; } - int max_len = strlen(format) + 8192; + s32 max_len = strlen(format) + 8192; char *tmp = new char[max_len]; va_list va; va_start(va, format); @@ -248,7 +248,7 @@ void GuiText::clearDynamicText() textDynWidth.clear(); } -void GuiText::setPresets(int sz, const glm::vec4 & c, int w, int a) +void GuiText::setPresets(s32 sz, const glm::vec4 & c, s32 w, s32 a) { presetSize = sz; presetColor = (GX2ColorF32) { (f32)c.r / 255.0f, (f32)c.g / 255.0f, (f32)c.b / 255.0f, (f32)c.a / 255.0f }; @@ -261,12 +261,12 @@ void GuiText::setPresetFont(FreeTypeGX *f) presentFont = f; } -void GuiText::setFontSize(int s) +void GuiText::setFontSize(s32 s) { size = s; } -void GuiText::setMaxWidth(int width, int w) +void GuiText::setMaxWidth(s32 width, s32 w) { maxWidth = width; wrapMode = w; @@ -294,17 +294,17 @@ void GuiText::setBlurGlowColor(float blur, const glm::vec4 & c) blurAlpha = c[3]; } -int GuiText::getTextWidth(int ind) +s32 GuiText::getTextWidth(s32 ind) { - if(ind < 0 || ind >= (int) textDyn.size()) + if(ind < 0 || ind >= (s32) textDyn.size()) return this->getTextWidth(); return font->getWidth(textDyn[ind], currentSize); } -const wchar_t * GuiText::getDynText(int ind) +const wchar_t * GuiText::getDynText(s32 ind) { - if(ind < 0 || ind >= (int) textDyn.size()) + if(ind < 0 || ind >= (s32) textDyn.size()) return text; return textDyn[ind]; @@ -341,10 +341,10 @@ std::string GuiText::toUTF8(void) const void GuiText::makeDottedText() { - int pos = textDyn.size(); + s32 pos = textDyn.size(); textDyn.resize(pos + 1); - int i = 0, currentWidth = 0; + s32 i = 0, currentWidth = 0; textDyn[pos] = new (std::nothrow) wchar_t[maxWidth]; if(!textDyn[pos]) { textDyn.resize(pos); @@ -374,8 +374,8 @@ void GuiText::scrollText(u32 frameCount) { if (textDyn.size() == 0) { - int pos = textDyn.size(); - int i = 0, currentWidth = 0; + s32 pos = textDyn.size(); + s32 i = 0, currentWidth = 0; textDyn.resize(pos + 1); textDyn[pos] = new (std::nothrow) wchar_t[maxWidth]; @@ -408,7 +408,7 @@ void GuiText::scrollText(u32 frameCount) return; } - int stringlen = wcslen(text); + s32 stringlen = wcslen(text); ++textScrollPos; if (textScrollPos > stringlen) @@ -417,8 +417,8 @@ void GuiText::scrollText(u32 frameCount) textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY; } - int ch = textScrollPos; - int pos = textDyn.size() - 1; + s32 ch = textScrollPos; + s32 pos = textDyn.size() - 1; if (!textDyn[pos]) textDyn[pos] = new (std::nothrow) wchar_t[maxWidth]; @@ -428,7 +428,7 @@ void GuiText::scrollText(u32 frameCount) return; } - int i = 0, currentWidth = 0; + s32 i = 0, currentWidth = 0; while (currentWidth < maxWidth) { @@ -458,16 +458,16 @@ void GuiText::wrapText() { if (textDyn.size() > 0) return; - int i = 0; - int ch = 0; - int linenum = 0; - int lastSpace = -1; - int lastSpaceIndex = -1; - int currentWidth = 0; + s32 i = 0; + s32 ch = 0; + s32 linenum = 0; + s32 lastSpace = -1; + s32 lastSpaceIndex = -1; + s32 currentWidth = 0; while (text[ch] && linenum < linestodraw) { - if (linenum >= (int) textDyn.size()) + if (linenum >= (s32) textDyn.size()) { textDyn.resize(linenum + 1); textDyn[linenum] = new (std::nothrow) wchar_t[maxWidth]; @@ -538,8 +538,8 @@ void GuiText::draw(CVideo *pVideo) float finalRenderingScale = 2.0f * internalRenderingScale; - int newSize = size * getScale() * finalRenderingScale; - int normal_size = size * getScale(); + s32 newSize = size * getScale() * finalRenderingScale; + s32 normal_size = size * getScale(); if(newSize != currentSize) { @@ -582,9 +582,9 @@ void GuiText::draw(CVideo *pVideo) } else if(wrapMode == WRAP) { - int lineheight = newSize + 6; - int yoffset = 0; - int voffset = 0; + s32 lineheight = newSize + 6; + s32 yoffset = 0; + s32 voffset = 0; if(textDyn.size() == 0) wrapText(); diff --git a/src/gui/GuiText.h b/src/gui/GuiText.h index 5fb8acd..aaf4704 100644 --- a/src/gui/GuiText.h +++ b/src/gui/GuiText.h @@ -30,12 +30,12 @@ public: //!\param t Text //!\param s Font size //!\param c Font color - GuiText(const char * t, int s, const glm::vec4 & c); + GuiText(const char * t, s32 s, const glm::vec4 & c); //!\overload //!\param t Text //!\param s Font size //!\param c Font color - GuiText(const wchar_t * t, int s, const glm::vec4 & c); + GuiText(const wchar_t * t, s32 s, const glm::vec4 & c); //!\overload //!\Assumes SetPresets() has been called to setup preferred text attributes //!\param t Text @@ -54,16 +54,16 @@ public: //!\param w Maximum width of texture image (for text wrapping) //!\param wrap Wrapmode when w>0 //!\param a Text alignment - static void setPresets(int sz, const glm::vec4 & c, int w, int a); + static void setPresets(s32 sz, const glm::vec4 & c, s32 w, s32 a); static void setPresetFont(FreeTypeGX *font); //!Sets the font size //!\param s Font size - void setFontSize(int s); + void setFontSize(s32 s); //!Sets the maximum width of the drawn texture image //!If the text exceeds this, it is wrapped to the next line //!\param w Maximum width //!\param m WrapMode - void setMaxWidth(int w = 0, int m = WRAP); + void setMaxWidth(s32 w = 0, s32 m = WRAP); //!Sets the font color //!\param c Font color void setColor(const glm::vec4 & c); @@ -75,21 +75,21 @@ public: virtual const wchar_t * getText() const { return text; } virtual std::string toUTF8(void) const; //!Get the Horizontal Size of Text - int getTextWidth() { return textWidth; } - int getTextWidth(int ind); + s32 getTextWidth() { return textWidth; } + s32 getTextWidth(s32 ind); //!Get the max textwidth - int getTextMaxWidth() { return maxWidth; } + s32 getTextMaxWidth() { return maxWidth; } //!Get fontsize - int getFontSize() { return size; }; + s32 getFontSize() { return size; }; //!Set max lines to draw - void setLinesToDraw(int l) { linestodraw = l; } + void setLinesToDraw(s32 l) { linestodraw = l; } //!Get current Textline (for position calculation) - const wchar_t * getDynText(int ind = 0); - virtual const wchar_t * getTextLine(int ind) { return getDynText(ind); }; + const wchar_t * getDynText(s32 ind = 0); + virtual const wchar_t * getTextLine(s32 ind) { return getDynText(ind); }; //!Change the font bool setFont(FreeTypeGX *font); //! virtual function used in child classes - virtual int getStartWidth() { return 0; }; + virtual s32 getStartWidth() { return 0; }; //!Constantly called to draw the text void draw(CVideo *pVideo); //! text enums @@ -102,10 +102,10 @@ public: }; protected: static FreeTypeGX * presentFont; - static int presetSize; - static int presetMaxWidth; - static int presetInternalRenderingScale; - static int presetAlignment; + static s32 presetSize; + static s32 presetMaxWidth; + static float presetInternalRenderingScale; + static s32 presetAlignment; static GX2ColorF32 presetColor; //!Clear the dynamic text @@ -120,16 +120,16 @@ protected: wchar_t * text; std::vector textDyn; std::vector textDynWidth; - int wrapMode; //!< Wrapping toggle - int textScrollPos; //!< Current starting index of text string for scrolling - int textScrollInitialDelay; //!< Delay to wait before starting to scroll - int textScrollDelay; //!< Scrolling speed - int size; //!< Font size - int maxWidth; //!< Maximum width of the generated text object (for text wrapping) + s32 wrapMode; //!< Wrapping toggle + s32 textScrollPos; //!< Current starting index of text string for scrolling + s32 textScrollInitialDelay; //!< Delay to wait before starting to scroll + s32 textScrollDelay; //!< Scrolling speed + s32 size; //!< Font size + s32 maxWidth; //!< Maximum width of the generated text object (for text wrapping) FreeTypeGX *font; - int textWidth; - int currentSize; - int linestodraw; + s32 textWidth; + s32 currentSize; + s32 linestodraw; glm::vec4 color; float defaultBlur; float blurGlowIntensity; diff --git a/src/gui/GuiToggle.cpp b/src/gui/GuiToggle.cpp index 03d5b37..b0ad278 100644 --- a/src/gui/GuiToggle.cpp +++ b/src/gui/GuiToggle.cpp @@ -38,12 +38,9 @@ GuiToggle::~GuiToggle() void GuiToggle::OnToggleClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger){ if(!isStateSet(STATE_DISABLED | STATE_HIDDEN | STATE_DISABLE_INPUT)){ - log_print("Clicked on Toggle: "); if(selected){ - log_print("Uncheck\n"); setUnchecked(); }else{ - log_print("Check\n"); setChecked(); } } diff --git a/src/gui/GuiTrigger.cpp b/src/gui/GuiTrigger.cpp index 74e9d05..1d1c5f6 100644 --- a/src/gui/GuiTrigger.cpp +++ b/src/gui/GuiTrigger.cpp @@ -107,13 +107,13 @@ bool GuiTrigger::down(const GuiController *controller) const return false; } -int GuiTrigger::clicked(const GuiController *controller) const +s32 GuiTrigger::clicked(const GuiController *controller) const { if((controller->chan & chan) == 0) { return CLICKED_NONE; } - int bResult = CLICKED_NONE; + s32 bResult = CLICKED_NONE; if(controller->data.touched && controller->data.validPointer && (btns & VPAD_TOUCH) && !controller->lastData.touched) { diff --git a/src/gui/GuiTrigger.h b/src/gui/GuiTrigger.h index ea84b67..c994354 100644 --- a/src/gui/GuiTrigger.h +++ b/src/gui/GuiTrigger.h @@ -91,7 +91,7 @@ public: bool right(const GuiController *controller) const; bool up(const GuiController *controller) const; bool down(const GuiController *controller) const; - int clicked(const GuiController *controller) const; + s32 clicked(const GuiController *controller) const; bool held(const GuiController *controller) const; bool released(const GuiController *controller) const; private: diff --git a/src/gui/Scrollbar.cpp b/src/gui/Scrollbar.cpp index 84979b2..c7dcca6 100644 --- a/src/gui/Scrollbar.cpp +++ b/src/gui/Scrollbar.cpp @@ -24,7 +24,7 @@ #include "Scrollbar.h" #include "resources/Resources.h" -Scrollbar::Scrollbar(int h) +Scrollbar::Scrollbar(s32 h) : touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH) , wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A) { @@ -164,19 +164,21 @@ void Scrollbar::OnDownButtonClick(GuiButton *button, const GuiController *contro void Scrollbar::OnBoxButtonHold(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { - if(EntrieCount == 0) + if(EntrieCount == 0){ return; + } - if(!controller->data.validPointer) + if(!controller->data.validPointer){ return; + } - int y = controller->data.y - this->getCenterY(); + s32 y = controller->data.y - this->getCenterY(); - int positionWiimote = LIMIT(y - MinHeight, 0, MaxHeight - MinHeight); + s32 positionWiimote = LIMIT(y - MinHeight, 0, MaxHeight - MinHeight); - int newSelected = (EntrieCount - 1) - (int) ((float) positionWiimote / (float) (MaxHeight-MinHeight) * (float) (EntrieCount-1)); + s32 newSelected = (EntrieCount - 1) - (s32) ((float) positionWiimote / (float) (MaxHeight-MinHeight) * (float) (EntrieCount-1)); - int diff = newSelected-SelInd-SelItem; + s32 diff = newSelected-SelInd-SelItem; if(newSelected <= 0) { @@ -190,7 +192,7 @@ void Scrollbar::OnBoxButtonHold(GuiButton *button, const GuiController *controll } else if(newSelected < PageSize && SelInd == 0 && diff < 0) { - SelItem = std::max(SelItem+diff, 0); + SelItem = std::max(SelItem+diff, (s32)0); } else if(EntrieCount-newSelected < PageSize && SelInd == EntrieCount-PageSize && diff > 0) { @@ -205,7 +207,7 @@ void Scrollbar::OnBoxButtonHold(GuiButton *button, const GuiController *controll listChanged(SelItem, SelInd); } -void Scrollbar::SetPageSize(int size) +void Scrollbar::SetPageSize(s32 size) { if(PageSize == size) return; @@ -214,7 +216,7 @@ void Scrollbar::SetPageSize(int size) listChanged(SelItem, SelInd); } -void Scrollbar::SetSelectedItem(int pos) +void Scrollbar::SetSelectedItem(s32 pos) { if(SelItem == pos) return; @@ -223,7 +225,7 @@ void Scrollbar::SetSelectedItem(int pos) listChanged(SelItem, SelInd); } -void Scrollbar::SetSelectedIndex(int pos) +void Scrollbar::SetSelectedIndex(s32 pos) { if(SelInd == pos) return; @@ -232,7 +234,7 @@ void Scrollbar::SetSelectedIndex(int pos) listChanged(SelItem, SelInd); } -void Scrollbar::SetEntrieCount(int cnt) +void Scrollbar::SetEntrieCount(s32 cnt) { if(EntrieCount == cnt) return; @@ -241,9 +243,9 @@ void Scrollbar::SetEntrieCount(int cnt) listChanged(SelItem, SelInd); } -void Scrollbar::setScrollboxPosition(int SelItem, int SelInd) +void Scrollbar::setScrollboxPosition(s32 SelItem, s32 SelInd) { - int position = MaxHeight-(MaxHeight-MinHeight)*(SelInd+SelItem)/(EntrieCount-1); + s32 position = MaxHeight-(MaxHeight-MinHeight)*(SelInd+SelItem)/(EntrieCount-1); if(position < MinHeight || (SelInd+SelItem >= EntrieCount-1)) position = MinHeight; diff --git a/src/gui/Scrollbar.h b/src/gui/Scrollbar.h index cd7fc94..1900a03 100644 --- a/src/gui/Scrollbar.h +++ b/src/gui/Scrollbar.h @@ -30,25 +30,25 @@ class Scrollbar : public GuiElement, public sigslot::has_slots<> { public: - Scrollbar(int height); + Scrollbar(s32 height); virtual ~Scrollbar(); void ScrollOneUp(); void ScrollOneDown(); - int GetSelectedItem() { return SelItem; } - int GetSelectedIndex() { return SelInd; } + s32 GetSelectedItem() { return SelItem; } + s32 GetSelectedIndex() { return SelInd; } void draw(CVideo * video); void update(GuiController * t); //! Signals - sigslot::signal2 listChanged; + sigslot::signal2 listChanged; //! Slots - void SetPageSize(int size); - void SetRowSize(int size); - void SetSelectedItem(int pos); - void SetSelectedIndex(int pos); - void SetEntrieCount(int cnt); + void SetPageSize(s32 size); + void SetRowSize(s32 size); + void SetSelectedItem(s32 pos); + void SetSelectedIndex(s32 pos); + void SetEntrieCount(s32 cnt); protected: - void setScrollboxPosition(int SelItem, int SelInd); + void setScrollboxPosition(s32 SelItem, s32 SelInd); void OnUpButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); void OnDownButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); void OnBoxButtonHold(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); @@ -56,13 +56,13 @@ class Scrollbar : public GuiElement, public sigslot::has_slots<> u32 ScrollState; u16 ScrollSpeed; - int MinHeight; - int MaxHeight; - int SelItem; - int SelInd; - int PageSize; - int EntrieCount; - int pressedChan; + s32 MinHeight; + s32 MaxHeight; + s32 SelItem; + s32 SelInd; + s32 PageSize; + s32 EntrieCount; + s32 pressedChan; GuiButton * arrowUpBtn; GuiButton * arrowDownBtn; diff --git a/src/gui/VPadController.h b/src/gui/VPadController.h index 5223774..b9b4506 100644 --- a/src/gui/VPadController.h +++ b/src/gui/VPadController.h @@ -24,7 +24,7 @@ class VPadController : public GuiController { public: //!Constructor - VPadController(int channel) + VPadController(s32 channel) : GuiController(channel) { memset(&vpad, 0, sizeof(vpad)); @@ -33,11 +33,11 @@ public: //!Destructor virtual ~VPadController() {} - bool update(int width, int height) + bool update(s32 width, s32 height) { lastData = data; - int vpadError = -1; + s32 vpadError = -1; VPADRead(0, &vpad, 1, &vpadError); if(vpadError == 0) @@ -48,9 +48,9 @@ public: data.validPointer = !vpad.tpdata.invalid; data.touched = vpad.tpdata.touched; //! calculate the screen offsets - data.x = -(width >> 1) + ((int)(vpad.tpdata1.x * ((width)/1211.0f)*width) >> 12)-30; - data.y = -(height >> 1) + ((int)(vpad.tpdata1.y * ((height)/653.0f)*height) >> 12)-35; - + data.x = -(width >> 1) + ((s32)(vpad.tpdata1.x * ((width)/1211.0f)*width) >> 12)-30; + data.y = -(height >> 1) + ((s32)(vpad.tpdata1.y * ((height)/653.0f)*height) >> 12)-35; + return true; } return false; diff --git a/src/gui/WPadController.h b/src/gui/WPadController.h index 26d1d98..ca0692d 100644 --- a/src/gui/WPadController.h +++ b/src/gui/WPadController.h @@ -24,7 +24,7 @@ class WPadController : public GuiController { public: //!Constructor - WPadController(int channel) + WPadController(s32 channel) : GuiController(channel) { memset(&kpadData, 0, sizeof(kpadData)); @@ -130,7 +130,7 @@ public: return conv_buttons; } - bool update(int width, int height) + bool update(s32 width, s32 height) { lastData = data; diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 6614b63..5da67c2 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -7,22 +7,22 @@ extern void my_PrepareTitle_hook(void); -static void KernelCopyData(unsigned int addr, unsigned int src, unsigned int len) +static void KernelCopyData(u32 addr, u32 src, u32 len) { /* * Setup a DBAT access with cache inhibited to write through and read directly from memory */ - unsigned int dbatu0, dbatl0, dbatu1, dbatl1; + u32 dbatu0, dbatl0, dbatu1, dbatl1; // save the original DBAT value asm volatile("mfdbatu %0, 0" : "=r" (dbatu0)); asm volatile("mfdbatl %0, 0" : "=r" (dbatl0)); asm volatile("mfdbatu %0, 1" : "=r" (dbatu1)); asm volatile("mfdbatl %0, 1" : "=r" (dbatl1)); - unsigned int target_dbatu0 = 0; - unsigned int target_dbatl0 = 0; - unsigned int target_dbatu1 = 0; - unsigned int target_dbatl1 = 0; + u32 target_dbatu0 = 0; + u32 target_dbatl0 = 0; + u32 target_dbatu1 = 0; + u32 target_dbatl1 = 0; unsigned char *dst_p = (unsigned char*)addr; unsigned char *src_p = (unsigned char*)src; @@ -50,11 +50,11 @@ static void KernelCopyData(unsigned int addr, unsigned int src, unsigned int len asm volatile("eieio; isync"); - unsigned int i; + u32 i; for(i = 0; i < len; i++) { // if we are on the edge to next chunk - if((target_dbatu0 != 0) && (((unsigned int)dst_p & 0x00F00000) != (target_dbatu0 & 0x00F00000))) + if((target_dbatu0 != 0) && (((u32)dst_p & 0x00F00000) != (target_dbatu0 & 0x00F00000))) { target_dbatu0 = ((addr + i) & 0x00F00000) | 0xC0000000 | 0x1F; target_dbatl0 = ((addr + i) & 0xFFF00000) | 0x32; @@ -65,7 +65,7 @@ static void KernelCopyData(unsigned int addr, unsigned int src, unsigned int len asm volatile("mtdbatl 0, %0" : : "r" (target_dbatl0)); asm volatile("eieio; isync"); } - if((target_dbatu1 != 0) && (((unsigned int)src_p & 0x00F00000) != (target_dbatu1 & 0x00F00000))) + if((target_dbatu1 != 0) && (((u32)src_p & 0x00F00000) != (target_dbatu1 & 0x00F00000))) { target_dbatu1 = ((src + i) & 0x00F00000) | 0xB0000000 | 0x1F; target_dbatl1 = ((src + i) & 0xFFF00000) | 0x32; @@ -219,21 +219,21 @@ void KernelSetupSyscalls(void) ucSyscallsSetupRequired = 0; - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x36 * 4)), (unsigned int)KernelReadDBATs); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x36 * 4)), (unsigned int)KernelReadDBATs); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x36 * 4)), (unsigned int)KernelReadDBATs); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x36 * 4)), (unsigned int)KernelReadDBATs); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x36 * 4)), (unsigned int)KernelReadDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x36 * 4)), (u32)KernelReadDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x36 * 4)), (u32)KernelReadDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x36 * 4)), (u32)KernelReadDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x36 * 4)), (u32)KernelReadDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x36 * 4)), (u32)KernelReadDBATs); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x37 * 4)), (unsigned int)KernelWriteDBATs); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x37 * 4)), (unsigned int)KernelWriteDBATs); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x37 * 4)), (unsigned int)KernelWriteDBATs); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x37 * 4)), (unsigned int)KernelWriteDBATs); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x37 * 4)), (unsigned int)KernelWriteDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x37 * 4)), (u32)KernelWriteDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x37 * 4)), (u32)KernelWriteDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x37 * 4)), (u32)KernelWriteDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x37 * 4)), (u32)KernelWriteDBATs); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x37 * 4)), (u32)KernelWriteDBATs); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x25 * 4)), (unsigned int)KernelCopyData); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x25 * 4)), (unsigned int)KernelCopyData); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x25 * 4)), (unsigned int)KernelCopyData); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x25 * 4)), (unsigned int)KernelCopyData); - kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x25 * 4)), (unsigned int)KernelCopyData); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x25 * 4)), (u32)KernelCopyData); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x25 * 4)), (u32)KernelCopyData); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x25 * 4)), (u32)KernelCopyData); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x25 * 4)), (u32)KernelCopyData); + kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x25 * 4)), (u32)KernelCopyData); } diff --git a/src/kernel/syscalls.h b/src/kernel/syscalls.h index 8b1eff8..e5281c4 100644 --- a/src/kernel/syscalls.h +++ b/src/kernel/syscalls.h @@ -11,7 +11,7 @@ extern "C" { void KernelSetupSyscalls(void); -void SC0x25_KernelCopyData(unsigned int addr, unsigned int src, unsigned int len); +void SC0x25_KernelCopyData(u32 addr, u32 src, u32 len); void SC0x36_KernelReadDBATs(bat_table_t * table); void SC0x37_KernelWriteDBATs(bat_table_t * table); diff --git a/src/main.cpp b/src/main.cpp index 2452e43..05982ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,15 +17,9 @@ #include "common/common.h" #include "controller_patcher/ControllerPatcher.hpp" -#include "controller_patcher/ConfigReader.hpp" -#include "controller_patcher/config/ConfigValues.hpp" -#include "controller_patcher/utils/CPRetainVars.hpp" -#include "controller_patcher/network/UDPServer.hpp" -#include "controller_patcher/network/TCPServer.hpp" #include "utils/function_patcher.h" #include "patcher/hid_controller_function_patcher.hpp" #include "kernel/kernel_functions.h" -#include "kernel/syscalls.h" #include "video/CursorDrawer.h" #include "utils/logger.h" #include "utils/StringTools.h" @@ -33,7 +27,7 @@ #include "system/memory.h" /* Entry point */ -extern "C" int Menu_Main(void){ +extern "C" s32 Menu_Main(void){ //!******************************************************************* //! Initialize function pointers * //!******************************************************************* @@ -56,7 +50,7 @@ extern "C" int Menu_Main(void){ //!******************************************************************* //! Initialize HID Config * //!******************************************************************* - log_print("Initializing the controller data\n"); + log_printf("Menu_Main (line %d): Initializing the controller data\n",__LINE__); bool res = ControllerPatcher::Init(); if(!res){ SplashScreen(5, std::string("Error. The app starts in 5 seconds without patches.").c_str()); @@ -67,23 +61,24 @@ extern "C" int Menu_Main(void){ ControllerPatcher::enableControllerMapping(); ControllerPatcher::startNetworkServer(); - int result = 0; + s32 result = 0; if(isInMiiMakerHBL()){ //!******************************************************************* //! Initialize heap memory * //!******************************************************************* - log_print("Initialize memory management\n"); + log_printf("Menu_Main (line %d): Initialize memory management\n",__LINE__); memoryInitialize(); - log_printf("Mount SD partition\n"); + log_printf("Menu_Main (line %d): Mount SD partition\n",__LINE__); mount_sd_fat("sd"); - log_printf("Start main application\n"); + log_printf("Menu_Main (line %d): Start main application\n",__LINE__); result = Application::instance()->exec(); - log_printf("Main application stopped result: %d\n",result); + log_printf("Menu_Main (line %d): Main application stopped result: %d\n",__LINE__,result); Application::destroyInstance(); - log_printf("Unmount SD\n"); + log_printf("Menu_Main (line %d): Unmount SD\n",__LINE__); unmount_sd_fat("sd"); + log_printf("Menu_Main (line %d): Release memory\n",__LINE__); memoryRelease(); ControllerPatcher::destroyConfigHelper(); } @@ -92,7 +87,7 @@ extern "C" int Menu_Main(void){ //!******************************************************************* //! Patching functions * //!******************************************************************* - log_print("Patching functions\n"); + log_printf("Menu_Main(line %d): Patching functions\n",__LINE__); ApplyPatches(); if(!isInMiiMakerHBL()){ @@ -101,11 +96,11 @@ extern "C" int Menu_Main(void){ } if(result == APPLICATION_CLOSE_APPLY){ - log_print("back to sysmenu\n"); + log_printf("Menu_Main (line %d): Loading the system menu.\n",__LINE__); SYSLaunchMenu(); return EXIT_RELAUNCH_ON_LOAD; } - log_print("back to hbl\n"); + log_printf("Menu_Main (line %d): Going back to the Homebrew Launcher\n",__LINE__); ControllerPatcher::restoreWiiUEnergySetting(); deInit(); return EXIT_SUCCESS; @@ -125,7 +120,7 @@ void deInit(){ ControllerPatcher::stopNetworkServer(); log_deinit(); } -int isInMiiMakerHBL(){ +s32 isInMiiMakerHBL(){ if (OSGetTitleID != 0 && ( OSGetTitleID() == 0x000500101004A200 || // mii maker eur OSGetTitleID() == 0x000500101004A100 || // mii maker usa @@ -138,9 +133,9 @@ int isInMiiMakerHBL(){ } -void SplashScreen(int time,const char * message){ +void SplashScreen(s32 time,const char * message){ // Prepare screen - int screen_buf0_size = 0; + s32 screen_buf0_size = 0; // Init screen and screen buffers OSScreenInit(); @@ -165,10 +160,10 @@ void SplashScreen(int time,const char * message){ OSScreenFlipBuffersEx(0); OSScreenFlipBuffersEx(1); - int tickswait = time * 1000*1000; - int times = 1000; - int sleepingtime = tickswait / 1000; - int i=0; + s32 tickswait = time * 1000*1000; + s32 times = 1000; + s32 sleepingtime = tickswait / 1000; + s32 i=0; while(i. - ****************************************************************************/ -#ifndef CONTROLLER_DEFS_H_ -#define CONTROLLER_DEFS_H_ - - -#endif //CONTROLLER_DEFS_H_ diff --git a/src/menu/InputGetterMenu.cpp b/src/menu/InputGetterMenu.cpp index d53366d..82d73fc 100644 --- a/src/menu/InputGetterMenu.cpp +++ b/src/menu/InputGetterMenu.cpp @@ -106,8 +106,8 @@ void InputGetterMenu::GetInputsAsync(InputGetterMenu * menu) void InputGetterMenu::GetInputs(CThread *thread, void *arg){ InputGetterMenu * args = (InputGetterMenu * )arg; - int gotPress = 0; - int inputsize = gHIDMaxDevices; + s32 gotPress = 0; + s32 inputsize = gHIDMaxDevices; InputData * hiddata = (InputData * ) malloc(sizeof(InputData)*inputsize); memset(hiddata,0,sizeof(InputData)*inputsize); @@ -115,14 +115,14 @@ void InputGetterMenu::GetInputs(CThread *thread, void *arg){ memset(&pad_result,0,sizeof(ControllerMappingPADInfo)); while(!gotPress){ - int foo = args->exitInputThread; + s32 foo = args->exitInputThread; foo +=1; if(args->exitInputThread)break; - int result = ControllerPatcher::gettingInputAllDevices(hiddata,inputsize); + s32 result = ControllerPatcher::gettingInputAllDevices(hiddata,inputsize); if(result > 0){ //log_printf("got %d results\n",result); - for(int i =0;ichanIdx >= 1 && controller->chanIdx <= 4 && controller->data.validPointer) { - int wpadIdx = controller->chanIdx - 1; + s32 wpadIdx = controller->chanIdx - 1; f32 posX = controller->data.x; f32 posY = controller->data.y; pointerImg[wpadIdx]->setPosition(posX, posY); @@ -175,7 +175,7 @@ void MainWindow::drawDrc(CVideo *video) drcElements[i]->draw(video); } - for(int i = 0; i < 4; i++) + for(s32 i = 0; i < 4; i++) { if(pointerValid[i]) { @@ -193,7 +193,7 @@ void MainWindow::drawTv(CVideo *video) tvElements[i]->draw(video); } - for(int i = 0; i < 4; i++) + for(s32 i = 0; i < 4; i++) { if(pointerValid[i]) { @@ -224,7 +224,7 @@ bool MainWindow::checkForRealProController(){ u32 type; bool changed = false; - for(int i = 0;i<4;i++){ + for(s32 i = 0;i<4;i++){ if(WPADProbe(i,&type) == 0){ UController_Type controller_type = UController_Type_Pro1; @@ -291,7 +291,7 @@ void MainWindow::removeFromAllElements(GuiElement * element){ } -void MainWindow::setState(int val, int c){ +void MainWindow::setState(s32 val, s32 c){ u32 drcSize = drcElements.size(); for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) { @@ -305,7 +305,7 @@ void MainWindow::setState(int val, int c){ } } -void MainWindow::clearState(int val, int c){ +void MainWindow::clearState(s32 val, s32 c){ u32 drcSize = drcElements.size(); for(u32 i = 0; (i < drcSize) && (i < drcElements.size()); ++i) { diff --git a/src/menu/MainWindow.h b/src/menu/MainWindow.h index 6d8d4b7..7d249cb 100644 --- a/src/menu/MainWindow.h +++ b/src/menu/MainWindow.h @@ -34,7 +34,7 @@ public: static MainWindow *instance; - static MainWindow *getInstance(int w,int h) { + static MainWindow *getInstance(s32 w,s32 h) { if(!instance){ instance = new MainWindow(w, h); } @@ -142,8 +142,8 @@ public: void appendToAllElements(GuiElement * element); void removeFromAllElements(GuiElement * element); - void setState(int i, int c = -1 ); - void clearState(int i, int c = -1); + void setState(s32 i, s32 c = -1 ); + void clearState(s32 i, s32 c = -1); void OpenInputGetterMenu(UController_Type controller_type); void openPageForController(UController_Type controller_type); @@ -158,7 +158,7 @@ public: } private: - MainWindow(int w, int h); + MainWindow(s32 w, s32 h); void SetupMainView(void); void OnOpenEffectFinish(GuiElement *element); @@ -170,7 +170,7 @@ private: void clickListEntryByController(UController_Type controller_type); - int width, height; + s32 width, height; std::vector drcElements; std::vector tvElements; diff --git a/src/menu/drc/MainWindowContent.cpp b/src/menu/drc/MainWindowContent.cpp index f3b3347..4e4d3a1 100644 --- a/src/menu/drc/MainWindowContent.cpp +++ b/src/menu/drc/MainWindowContent.cpp @@ -16,7 +16,7 @@ ****************************************************************************/ #include "MainWindowContent.h" -MainWindowContent::MainWindowContent(int w, int h) +MainWindowContent::MainWindowContent(s32 w, s32 h) : GuiFrame(w, h) , width(w) , height(h) diff --git a/src/menu/drc/MainWindowContent.h b/src/menu/drc/MainWindowContent.h index 17aa3df..27fb948 100644 --- a/src/menu/drc/MainWindowContent.h +++ b/src/menu/drc/MainWindowContent.h @@ -24,7 +24,7 @@ class MainWindowContent : public GuiFrame, public sigslot::has_slots<>{ public: - MainWindowContent(int w, int h); + MainWindowContent(s32 w, s32 h); virtual ~MainWindowContent(); void SetScreen(ContentTemplate * new_content); @@ -32,7 +32,7 @@ public: ContentTemplate * getContent(); private: - int width, height; + s32 width, height; GuiImage bgImageColor; GuiImageData * footer_imgdata; diff --git a/src/menu/drc/MainWindowDRC.cpp b/src/menu/drc/MainWindowDRC.cpp index 1b70d90..6db1a51 100644 --- a/src/menu/drc/MainWindowDRC.cpp +++ b/src/menu/drc/MainWindowDRC.cpp @@ -21,7 +21,7 @@ extern u32 hostIpAddress; -MainWindowDRC::MainWindowDRC(int w, int h) +MainWindowDRC::MainWindowDRC(s32 w, s32 h) : GuiConfigurationScreen(w, h) , width(w) , height(h) @@ -45,7 +45,7 @@ MainWindowDRC::MainWindowDRC(int w, int h) versionText.setText(fmt("%s - %s",APP_VERION,__DATE__)); versionText.setAlignment(ALIGN_TOP_LEFT); versionText.setPosition(windowSplitter_img.getOffsetX()+5,-25); - + ipAddress.setText(wfmt("TCP Server running on: %u.%u.%u.%u",(hostIpAddress >> 24) & 0xFF, (hostIpAddress >> 16) & 0xFF, (hostIpAddress >> 8) & 0xFF, (hostIpAddress >> 0) & 0xFF)); ipAddress.setAlignment(ALIGN_TOP_RIGHT); ipAddress.setPosition(-5,-25); @@ -63,7 +63,7 @@ void MainWindowDRC::clickListEntryByController(UController_Type controller_type) } } -void MainWindowDRC::setState(int i, int c){ +void MainWindowDRC::setState(s32 i, s32 c){ GuiFrame::setState(i,c); } diff --git a/src/menu/drc/MainWindowDRC.h b/src/menu/drc/MainWindowDRC.h index 08ca4a0..3603b95 100644 --- a/src/menu/drc/MainWindowDRC.h +++ b/src/menu/drc/MainWindowDRC.h @@ -25,12 +25,12 @@ class MainWindowDRC : public GuiConfigurationScreen, public sigslot::has_slots<>{ public: - MainWindowDRC(int w, int h); + MainWindowDRC(s32 w, s32 h); virtual ~MainWindowDRC(); void clickListEntryByController(UController_Type controller_type); private: - int width, height; + s32 width, height; GuiImageData * windowSplitter_imgdata; GuiImage windowSplitter_img; MainWindowContent content; @@ -38,7 +38,7 @@ private: GuiText versionText; GuiText ipAddress; - void setState(int i, int c); + void setState(s32 i, s32 c); void process(); }; diff --git a/src/menu/drc/MenuElementController.cpp b/src/menu/drc/MenuElementController.cpp index 7e6c15b..5de9fb6 100644 --- a/src/menu/drc/MenuElementController.cpp +++ b/src/menu/drc/MenuElementController.cpp @@ -65,7 +65,7 @@ MenuElementController::MenuElementController(UController_Type controllertype) notAttachedLabel.setColor(glm::vec4(0.2f,0.2f,0.2f,1.0f)); notAttachedLabel.setParent(&icon_img); - for(int i = 0;i<4;i++){ + for(s32 i = 0;i<4;i++){ ledImages.ledon[i] = new GuiImage(ledon_imgdata); ledImages.ledoff[i] = new GuiImage(ledoff_imgdata); @@ -127,7 +127,7 @@ MenuElementController::~MenuElementController() Resources::RemoveImageData(ledon_imgdata); Resources::RemoveImageData(ledoff_imgdata); - for(int i = 0;i<4;i++){ + for(s32 i = 0;i<4;i++){ if(ledImages.ledon[i]) delete ledImages.ledon[i]; if(ledImages.ledoff[i]) delete ledImages.ledoff[i]; } @@ -155,7 +155,7 @@ void MenuElementController::draw(CVideo *v){ std::string name = ""; controllerConnected = 0; - int found = ControllerPatcher::getActiveMappingSlot(getControllerType()); + s32 found = ControllerPatcher::getActiveMappingSlot(getControllerType()); if(found == -1){ name = "No device"; }else{ @@ -187,13 +187,13 @@ void MenuElementController::draw(CVideo *v){ proController_img.draw(v); controllerlabel.draw(v); } - int pad_active = 0; + bool pad_active = false; ControllerMappingPADInfo * info = ControllerPatcher::getControllerMappingInfo(getControllerType(),0); - for(int i = 0;i<4;i++){ + for(s32 i = 0;i<4;i++){ if(info != NULL && (info->pad == i && info->active)){ ledImages.ledon[i]->draw(v); - pad_active = 1; + pad_active = true; }else{ ledImages.ledoff[i]->draw(v); } @@ -204,7 +204,7 @@ void MenuElementController::draw(CVideo *v){ alpha = 1.0f; } - for(int i = 0;i<4;i++){ + for(s32 i = 0;i<4;i++){ ledImages.ledon[i]->setAlpha(alpha); ledImages.ledoff[i]->setAlpha(alpha); } diff --git a/src/menu/drc/MenuElementController.h b/src/menu/drc/MenuElementController.h index 2e720f2..cbf5ff6 100644 --- a/src/menu/drc/MenuElementController.h +++ b/src/menu/drc/MenuElementController.h @@ -21,7 +21,6 @@ #include "controller_patcher/patcher/ControllerPatcherDefs.h" #include "controller_patcher/utils/CPRetainVars.hpp" #include "utils/StringTools.h" -#include "menu/ControllerDefs.h" class MenuElementController : public MenuElement{ public: diff --git a/src/menu/drc/MenuListDRC.cpp b/src/menu/drc/MenuListDRC.cpp index dd6f79d..a20a94c 100644 --- a/src/menu/drc/MenuListDRC.cpp +++ b/src/menu/drc/MenuListDRC.cpp @@ -22,7 +22,7 @@ #include "content/ContentController.h" #include "utils/logger.h" -MenuListDRC::MenuListDRC(int w, int h,MainWindowContent * _contentWindow) +MenuListDRC::MenuListDRC(s32 w, s32 h,MainWindowContent * _contentWindow) : GuiFrame(w, h) , contentWindow(_contentWindow) , width(w) @@ -85,7 +85,7 @@ MenuListDRC::MenuListDRC(int w, int h,MainWindowContent * _contentWindow) } -void MenuListDRC::setState(int i, int c){ +void MenuListDRC::setState(s32 i, s32 c){ GuiFrame::setState(i,c); } @@ -112,14 +112,14 @@ void MenuListDRC::listAppend(GuiElement * listElement){ append(listElement); } -void MenuListDRC::OnDrag(GuiDragListener * listener, const GuiController * controller, GuiTrigger * trigger,int dx,int dy){ +void MenuListDRC::OnDrag(GuiDragListener * listener, const GuiController * controller, GuiTrigger * trigger,s32 dx,s32 dy){ addToTotalOffset((float)dy); scroll_needs_update = true; } void MenuListDRC::OnButtonClicked(GuiButton *button, const GuiController *controller, GuiTrigger *trigger){ MenuElement * element = NULL; - int i = 0; + s32 i = 0; for (std::vector::iterator it = listElementsButtons.begin() ; it != listElementsButtons.end(); ++it){ element = (*it); if(!element){continue; i++;} @@ -159,7 +159,7 @@ void MenuListDRC::update(GuiController * c){ if(dpad_selection_changed && (lastSelectedItem != selectedItem)){ lastSelectedItem = selectedItem; if(selectedItem >= 0 && (u32) selectedItem < listElementsButtons.size()){ - int i = 0; + s32 i = 0; MenuElement * element = NULL; for (std::vector::iterator it = listElementsButtons.begin() ; it != listElementsButtons.end(); ++it){ element = (*it); diff --git a/src/menu/drc/MenuListDRC.h b/src/menu/drc/MenuListDRC.h index c8f22f7..018824e 100644 --- a/src/menu/drc/MenuListDRC.h +++ b/src/menu/drc/MenuListDRC.h @@ -27,14 +27,14 @@ class MenuListDRC : public GuiFrame, public sigslot::has_slots<>{ public: - MenuListDRC(int w, int h,MainWindowContent * contentWindow); + MenuListDRC(s32 w, s32 h,MainWindowContent * contentWindow); virtual ~MenuListDRC(); MenuElement * getButtonElementByController(UController_Type controller_type); void OnButtonClicked(GuiButton * button, const GuiController *controller, GuiTrigger *trigger); private: MainWindowContent * contentWindow; - int width, height; + s32 width, height; GuiImage bgImageColor; MenuSeperator homeSeperator; MenuElementInfo elementHome; @@ -66,16 +66,16 @@ private: std::vector listElementsAll; std::vector listElementsButtons; - int sizeListElementsAll = 0; - int sizeListElementsButtons = 0; + s32 sizeListElementsAll = 0; + s32 sizeListElementsButtons = 0; - int selectedItem = 0; - int lastSelectedItem = -1; + s32 selectedItem = 0; + s32 lastSelectedItem = -1; - void setState(int i, int c); + void setState(s32 i, s32 c); void update(GuiController * c); - void OnDrag(GuiDragListener * listener, const GuiController * controller, GuiTrigger * trigger,int dx,int dy); + void OnDrag(GuiDragListener * listener, const GuiController * controller, GuiTrigger * trigger,s32 dx,s32 dy); void addToTotalOffset(f32 added_offset); void calculateAndSetOffsets(std::vector& elements,f32 total_offset); void listAppend(GuiElement * listElement); diff --git a/src/menu/drc/content/ContentAbout.cpp b/src/menu/drc/content/ContentAbout.cpp index a463d15..8697c1c 100644 --- a/src/menu/drc/content/ContentAbout.cpp +++ b/src/menu/drc/content/ContentAbout.cpp @@ -32,7 +32,7 @@ ContentAbout::ContentAbout(): ContentTemplate(){ f32 positionX2 = 250.0f; f32 positionX3 = 80.0f; - int fontSize = 28; + s32 fontSize = 28; glm::vec4 textColor = glm::vec4(0.3f,0.3f,0.3f,1.0f); text = new GuiText("Coding:", fontSize, textColor); diff --git a/src/menu/drc/content/ContentController.cpp b/src/menu/drc/content/ContentController.cpp index a44ea98..c2c1eb0 100644 --- a/src/menu/drc/content/ContentController.cpp +++ b/src/menu/drc/content/ContentController.cpp @@ -195,10 +195,10 @@ bool ContentController::isKeyboard(){ void ContentController::process(){ ContentTemplate::process(); - int connected = ControllerPatcher::getActiveMappingSlot(getControllerType()); + s32 connectedSlot = ControllerPatcher::getActiveMappingSlot(getControllerType()); //TODO: maybe just do it once and not every time? - if(connected != -1){ + if(connectedSlot != -1){ notConnectedFrame.setState(STATE_DISABLE_INPUT); notConnectedFrame.setVisible(false); connectedFrame.clearState(STATE_DISABLE_INPUT); diff --git a/src/menu/drc/content/ContentHelp.cpp b/src/menu/drc/content/ContentHelp.cpp index 43f6677..a0708f9 100644 --- a/src/menu/drc/content/ContentHelp.cpp +++ b/src/menu/drc/content/ContentHelp.cpp @@ -32,8 +32,8 @@ ContentHelp::ContentHelp(): ContentTemplate(){ //f32 positionX2 = 250.0f; //f32 positionX3 = 80.0f; - int fontSize = 35; - int fontSize2 = 24; + s32 fontSize = 35; + s32 fontSize2 = 24; glm::vec4 textColor = glm::vec4(0.3f,0.3f,0.3f,1.0f); text = new GuiText("My controller is not working!", fontSize, textColor); diff --git a/src/menu/drc/content/ContentNetworkHelp.cpp b/src/menu/drc/content/ContentNetworkHelp.cpp index 37dc327..04f3e80 100644 --- a/src/menu/drc/content/ContentNetworkHelp.cpp +++ b/src/menu/drc/content/ContentNetworkHelp.cpp @@ -32,8 +32,8 @@ ContentNetworkHelp::ContentNetworkHelp(): ContentTemplate(){ //f32 positionX2 = 250.0f; //f32 positionX3 = 80.0f; - int fontSize = 35; - int fontSize2 = 24; + s32 fontSize = 35; + s32 fontSize2 = 24; glm::vec4 textColor = glm::vec4(0.3f,0.3f,0.3f,1.0f); text = new GuiText("What is the Network Client?", fontSize, textColor); diff --git a/src/menu/tv/MainWindowTV.cpp b/src/menu/tv/MainWindowTV.cpp index e409add..1c444c6 100644 --- a/src/menu/tv/MainWindowTV.cpp +++ b/src/menu/tv/MainWindowTV.cpp @@ -24,7 +24,7 @@ TVControllerBanner *MainWindowTV::bannerInstance = NULL; -MainWindowTV::MainWindowTV(int w, int h) +MainWindowTV::MainWindowTV(s32 w, s32 h) : GuiConfigurationScreen(w, h) , width(w) , height(h) diff --git a/src/menu/tv/MainWindowTV.h b/src/menu/tv/MainWindowTV.h index 7c3d3a9..f72439b 100644 --- a/src/menu/tv/MainWindowTV.h +++ b/src/menu/tv/MainWindowTV.h @@ -29,13 +29,13 @@ class CVideo; class MainWindowTV : public GuiConfigurationScreen{ public: - MainWindowTV(int w, int h); + MainWindowTV(s32 w, s32 h); virtual ~MainWindowTV(); static TVControllerBanner * bannerInstance; private: - int width, height; + s32 width, height; GuiImageData *backgroundImageData; GuiImage backgroundImage; diff --git a/src/menu/tv/TVButtonController.cpp b/src/menu/tv/TVButtonController.cpp index 51eb806..53cd7af 100644 --- a/src/menu/tv/TVButtonController.cpp +++ b/src/menu/tv/TVButtonController.cpp @@ -65,7 +65,7 @@ TVButtonController::TVButtonController(UController_Type controllertype) notAttachedLabel.setColor(glm::vec4(0.2f,0.2f,0.2f,1.0f)); notAttachedLabel.setParent(this); - for(int i = 0;i<4;i++){ + for(s32 i = 0;i<4;i++){ ledImages.ledon[i] = new GuiImage(ledon_imgdata); ledImages.ledoff[i] = new GuiImage(ledoff_imgdata); @@ -130,7 +130,7 @@ TVButtonController::~TVButtonController() Resources::RemoveImageData(ledon_imgdata); Resources::RemoveImageData(ledoff_imgdata); - for(int i = 0;i<4;i++){ + for(s32 i = 0;i<4;i++){ if(ledImages.ledon[i]) delete ledImages.ledon[i]; if(ledImages.ledoff[i]) delete ledImages.ledoff[i]; } @@ -166,14 +166,14 @@ void TVButtonController::draw(CVideo *v){ std::string name =""; controllerConnected = 0; - int found = ControllerPatcher::getActiveMappingSlot(getControllerType()); + s32 foundSlot = ControllerPatcher::getActiveMappingSlot(getControllerType()); - if(found == -1){ + if(foundSlot == -1){ name = "No device"; }else{ controllerConnected = 1; - ControllerMappingPADInfo * info = ControllerPatcher::getControllerMappingInfo(getControllerType(),found); + ControllerMappingPADInfo * info = ControllerPatcher::getControllerMappingInfo(getControllerType(),foundSlot); if(info !=NULL){ if(info->type == CM_Type_Controller){ drawControllerName(v,info->vidpid.vid,info->vidpid.pid); @@ -187,14 +187,14 @@ void TVButtonController::draw(CVideo *v){ notAttachedLabel.setText(name.c_str()); notAttachedLabel.draw(v); - int pad_active = 0; + bool pad_active = false; ControllerMappingPADInfo * info = ControllerPatcher::getControllerMappingInfo(getControllerType(),0); - for(int i = 0;i<4;i++){ + for(s32 i = 0;i<4;i++){ if(info != NULL && (info->pad == i && info->active)){ ledImages.ledon[i]->draw(v); - pad_active = 1; + pad_active = true; }else{ ledImages.ledoff[i]->draw(v); } @@ -204,7 +204,7 @@ void TVButtonController::draw(CVideo *v){ if(pad_active){ alpha = 1.0f; } - for(int i = 0;i<4;i++){ + for(s32 i = 0;i<4;i++){ ledImages.ledon[i]->setAlpha(alpha); ledImages.ledoff[i]->setAlpha(alpha); } diff --git a/src/menu/tv/TVControllerBanner.cpp b/src/menu/tv/TVControllerBanner.cpp index 67012b1..baeb2a1 100644 --- a/src/menu/tv/TVControllerBanner.cpp +++ b/src/menu/tv/TVControllerBanner.cpp @@ -27,7 +27,7 @@ #include "utils/StringTools.h" -TVControllerBanner::TVControllerBanner(int w, int h) +TVControllerBanner::TVControllerBanner(s32 w, s32 h) : GuiFrame(w, h) , background_imgdata(Resources::GetImageData("MainWindowTVBackgroundBanner.png")) , background_img(background_imgdata) diff --git a/src/menu/tv/TVControllerBanner.h b/src/menu/tv/TVControllerBanner.h index d1b8497..ba94f45 100644 --- a/src/menu/tv/TVControllerBanner.h +++ b/src/menu/tv/TVControllerBanner.h @@ -25,7 +25,7 @@ class TVControllerBanner : public GuiFrame, public sigslot::has_slots<> { public: - TVControllerBanner(int w, int h); + TVControllerBanner(s32 w, s32 h); virtual ~TVControllerBanner(); void draw(CVideo *pVideo); diff --git a/src/patcher/hid_controller_function_patcher.cpp b/src/patcher/hid_controller_function_patcher.cpp index 9a305c2..af9be90 100644 --- a/src/patcher/hid_controller_function_patcher.cpp +++ b/src/patcher/hid_controller_function_patcher.cpp @@ -50,8 +50,8 @@ DECL(void, __PPCExit, void){ real___PPCExit(); } -DECL(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error) { - int result = real_VPADRead(chan, buffer, buffer_size, error); +DECL(s32, VPADRead, s32 chan, VPADData *buffer, u32 buffer_size, s32 *error) { + s32 result = real_VPADRead(chan, buffer, buffer_size, error); if(gHIDAttached && buffer_size > 0){ @@ -82,7 +82,7 @@ DECL(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error) { DECL(s32,KPADReadEx, s32 chan, KPADData * buffer, u32 buffer_count, s32 *error ){ //log_printf("KPADReadEx\n"); if(buffer_count > 0){ - int res = ControllerPatcher::setProControllerDataFromHID((void*)&buffer[0],chan,PRO_CONTROLLER_MODE_KPADDATA); //Check if a controller is connected and fill the buffer with data. + s32 res = ControllerPatcher::setProControllerDataFromHID((void*)&buffer[0],chan,PRO_CONTROLLER_MODE_KPADDATA); //Check if a controller is connected and fill the buffer with data. if(res >= 0){ if(buffer[0].pro.btns_h & WPAD_PRO_BUTTON_HOME){ //Pro controller doesn't work in home menu so it's okay to let this enabled. @@ -213,5 +213,5 @@ hooks_magic_t method_hooks_hid_controller[] __attribute__((section(".data"))) = u32 method_hooks_size_hid_controller __attribute__((section(".data"))) = sizeof(method_hooks_hid_controller) / sizeof(hooks_magic_t); //! buffer to store our instructions needed for our replacements -volatile unsigned int method_calls_hid_controller[sizeof(method_hooks_hid_controller) / sizeof(hooks_magic_t) * FUNCTION_PATCHER_METHOD_STORE_SIZE] __attribute__((section(".data"))); +volatile u32 method_calls_hid_controller[sizeof(method_hooks_hid_controller) / sizeof(hooks_magic_t) * FUNCTION_PATCHER_METHOD_STORE_SIZE] __attribute__((section(".data"))); diff --git a/src/patcher/hid_controller_function_patcher.hpp b/src/patcher/hid_controller_function_patcher.hpp index cf8573f..65da449 100644 --- a/src/patcher/hid_controller_function_patcher.hpp +++ b/src/patcher/hid_controller_function_patcher.hpp @@ -26,7 +26,7 @@ extern "C" { extern hooks_magic_t method_hooks_hid_controller[]; extern u32 method_hooks_size_hid_controller; -extern volatile unsigned int method_calls_hid_controller[]; +extern volatile u32 method_calls_hid_controller[]; #ifdef __cplusplus } diff --git a/src/resources/Resources.cpp b/src/resources/Resources.cpp index eabee60..d4bee38 100644 --- a/src/resources/Resources.cpp +++ b/src/resources/Resources.cpp @@ -12,7 +12,7 @@ Resources * Resources::instance = NULL; void Resources::Clear() { - for(int i = 0; RecourceList[i].filename != NULL; ++i) + for(s32 i = 0; RecourceList[i].filename != NULL; ++i) { if(RecourceList[i].CustomFile) { @@ -38,7 +38,7 @@ bool Resources::LoadFiles(const char * path) bool result = false; Clear(); - for(int i = 0; RecourceList[i].filename != NULL; ++i) + for(s32 i = 0; RecourceList[i].filename != NULL; ++i) { std::string fullpath(path); fullpath += "/"; @@ -59,7 +59,7 @@ bool Resources::LoadFiles(const char * path) const u8 * Resources::GetFile(const char * filename) { - for(int i = 0; RecourceList[i].filename != NULL; ++i) + for(s32 i = 0; RecourceList[i].filename != NULL; ++i) { if(strcasecmp(filename, RecourceList[i].filename) == 0) { @@ -72,7 +72,7 @@ const u8 * Resources::GetFile(const char * filename) u32 Resources::GetFileSize(const char * filename) { - for(int i = 0; RecourceList[i].filename != NULL; ++i) + for(s32 i = 0; RecourceList[i].filename != NULL; ++i) { if(strcasecmp(filename, RecourceList[i].filename) == 0) { @@ -87,14 +87,14 @@ GuiImageData * Resources::GetImageData(const char * filename) if(!instance) instance = new Resources; - std::map >::iterator itr = instance->imageDataMap.find(std::string(filename)); + std::map >::iterator itr = instance->imageDataMap.find(std::string(filename)); if(itr != instance->imageDataMap.end()) { itr->second.first++; return itr->second.second; } - for(int i = 0; RecourceList[i].filename != NULL; ++i) + for(s32 i = 0; RecourceList[i].filename != NULL; ++i) { if(strcasecmp(filename, RecourceList[i].filename) == 0) { @@ -117,7 +117,7 @@ GuiImageData * Resources::GetImageData(const char * filename) void Resources::RemoveImageData(GuiImageData * image) { - std::map >::iterator itr; + std::map >::iterator itr; for(itr = instance->imageDataMap.begin(); itr != instance->imageDataMap.end(); itr++) { @@ -140,14 +140,14 @@ GuiSound * Resources::GetSound(const char * filename) if(!instance) instance = new Resources; - std::map >::iterator itr = instance->soundDataMap.find(std::string(filename)); + std::map >::iterator itr = instance->soundDataMap.find(std::string(filename)); if(itr != instance->soundDataMap.end()) { itr->second.first++; return itr->second.second; } - for(int i = 0; RecourceList[i].filename != NULL; ++i) + for(s32 i = 0; RecourceList[i].filename != NULL; ++i) { if(strcasecmp(filename, RecourceList[i].filename) == 0) { @@ -170,7 +170,7 @@ GuiSound * Resources::GetSound(const char * filename) void Resources::RemoveSound(GuiSound * sound) { - std::map >::iterator itr; + std::map >::iterator itr; for(itr = instance->soundDataMap.begin(); itr != instance->soundDataMap.end(); itr++) { diff --git a/src/resources/Resources.h b/src/resources/Resources.h index 3d0921b..57a361c 100644 --- a/src/resources/Resources.h +++ b/src/resources/Resources.h @@ -27,8 +27,8 @@ private: Resources() {} ~Resources() {} - std::map > imageDataMap; - std::map > soundDataMap; + std::map > imageDataMap; + std::map > soundDataMap; }; #endif diff --git a/src/sounds/BufferCircle.cpp b/src/sounds/BufferCircle.cpp index b0ee705..481e4a9 100644 --- a/src/sounds/BufferCircle.cpp +++ b/src/sounds/BufferCircle.cpp @@ -41,14 +41,14 @@ BufferCircle::~BufferCircle() BufferReady.clear(); } -void BufferCircle::SetBufferBlockSize(int size) +void BufferCircle::SetBufferBlockSize(s32 size) { if(size < 0) return; BufferBlockSize = size; - for(int i = 0; i < Size(); i++) + for(s32 i = 0; i < Size(); i++) { if(SoundBuffer[i] != NULL) free(SoundBuffer[i]); @@ -59,18 +59,18 @@ void BufferCircle::SetBufferBlockSize(int size) } } -void BufferCircle::Resize(int size) +void BufferCircle::Resize(s32 size) { while(size < Size()) RemoveBuffer(Size()-1); - int oldSize = Size(); + s32 oldSize = Size(); SoundBuffer.resize(size); BufferSize.resize(size); BufferReady.resize(size); - for(int i = oldSize; i < Size(); i++) + for(s32 i = oldSize; i < Size(); i++) { if(BufferBlockSize > 0) SoundBuffer[i] = (u8 *) memalign(32, ALIGN32(BufferBlockSize)); @@ -81,7 +81,7 @@ void BufferCircle::Resize(int size) } } -void BufferCircle::RemoveBuffer(int pos) +void BufferCircle::RemoveBuffer(s32 pos) { if(!Valid(pos)) return; @@ -96,7 +96,7 @@ void BufferCircle::RemoveBuffer(int pos) void BufferCircle::ClearBuffer() { - for(int i = 0; i < Size(); i++) + for(s32 i = 0; i < Size(); i++) { BufferSize[i] = 0; BufferReady[i] = false; @@ -106,7 +106,7 @@ void BufferCircle::ClearBuffer() void BufferCircle::FreeBuffer() { - for(int i = 0; i < Size(); i++) + for(s32 i = 0; i < Size(); i++) { if(SoundBuffer[i] != NULL) free(SoundBuffer[i]); @@ -125,7 +125,7 @@ void BufferCircle::LoadNext() which = Next(); } -void BufferCircle::SetBufferReady(int pos, bool state) +void BufferCircle::SetBufferReady(s32 pos, bool state) { if(!Valid(pos)) return; @@ -133,7 +133,7 @@ void BufferCircle::SetBufferReady(int pos, bool state) BufferReady[pos] = state; } -void BufferCircle::SetBufferSize(int pos, int size) +void BufferCircle::SetBufferSize(s32 pos, s32 size) { if(!Valid(pos)) return; diff --git a/src/sounds/BufferCircle.hpp b/src/sounds/BufferCircle.hpp index b07c1c4..683b4a9 100644 --- a/src/sounds/BufferCircle.hpp +++ b/src/sounds/BufferCircle.hpp @@ -37,13 +37,13 @@ class BufferCircle //!> Destructor ~BufferCircle(); //!> Set circle size - void Resize(int size); + void Resize(s32 size); //!> Get the circle size - int Size() { return SoundBuffer.size(); }; + s32 Size() { return SoundBuffer.size(); }; //!> Set/resize the buffer size - void SetBufferBlockSize(int size); + void SetBufferBlockSize(s32 size); //!> Remove a buffer - void RemoveBuffer(int pos); + void RemoveBuffer(s32 pos); //!> Set all buffers clear void ClearBuffer(); //!> Free all buffers @@ -53,28 +53,28 @@ class BufferCircle //!> Get the current buffer u8 * GetBuffer() { return GetBuffer(which); }; //!> Get a buffer at a position - u8 * GetBuffer(int pos) { if(!Valid(pos)) return NULL; else return SoundBuffer[pos]; }; + u8 * GetBuffer(s32 pos) { if(!Valid(pos)) return NULL; else return SoundBuffer[pos]; }; //!> Get current buffer size u32 GetBufferSize() { return GetBufferSize(which); }; //!> Get buffer size at position - u32 GetBufferSize(int pos) { if(!Valid(pos)) return 0; else return BufferSize[pos]; }; + u32 GetBufferSize(s32 pos) { if(!Valid(pos)) return 0; else return BufferSize[pos]; }; //!> Is current buffer ready bool IsBufferReady() { return IsBufferReady(which); }; //!> Is a buffer at a position ready - bool IsBufferReady(int pos) { if(!Valid(pos)) return false; else return BufferReady[pos]; }; + bool IsBufferReady(s32 pos) { if(!Valid(pos)) return false; else return BufferReady[pos]; }; //!> Set a buffer at a position to a ready state - void SetBufferReady(int pos, bool st); + void SetBufferReady(s32 pos, bool st); //!> Set the buffersize at a position - void SetBufferSize(int pos, int size); + void SetBufferSize(s32 pos, s32 size); //!> Get the current position in the circle u16 Which() { return which; }; //!> Get the next location inline u16 Next() { return (which+1 >= Size()) ? 0 : which+1; } - inline u16 Prev() { if(Size() == 0) return 0; else return ((int)which-1 < 0) ? Size()-1 : which-1; } + inline u16 Prev() { if(Size() == 0) return 0; else return ((s32)which-1 < 0) ? Size()-1 : which-1; } protected: //!> Check if the position is a valid position in the vector - bool Valid(int pos) { return !(pos < 0 || pos >= Size()); }; + bool Valid(s32 pos) { return !(pos < 0 || pos >= Size()); }; u16 which; u32 BufferBlockSize; diff --git a/src/sounds/Mp3Decoder.cpp b/src/sounds/Mp3Decoder.cpp index 1246b4a..ed9df1d 100644 --- a/src/sounds/Mp3Decoder.cpp +++ b/src/sounds/Mp3Decoder.cpp @@ -48,7 +48,7 @@ Mp3Decoder::Mp3Decoder(const char * filepath) OpenFile(); } -Mp3Decoder::Mp3Decoder(const u8 * snd, int len) +Mp3Decoder::Mp3Decoder(const u8 * snd, s32 len) : SoundDecoder(snd, len) { SoundType = SOUND_MP3; @@ -92,7 +92,7 @@ void Mp3Decoder::OpenFile() } u8 dummybuff[4096]; - int ret = Read(dummybuff, 4096, 0); + s32 ret = Read(dummybuff, 4096, 0); if(ret <= 0) { if(file_fd) @@ -106,7 +106,7 @@ void Mp3Decoder::OpenFile() Rewind(); } -int Mp3Decoder::Rewind() +s32 Mp3Decoder::Rewind() { mad_synth_finish(&Synth); mad_frame_finish(&Frame); @@ -136,7 +136,7 @@ static inline s16 FixedToShort(mad_fixed_t Fixed) return((s16)Fixed); } -int Mp3Decoder::Read(u8 * buffer, int buffer_size, int pos) +s32 Mp3Decoder::Read(u8 * buffer, s32 buffer_size, s32 pos) { if(!file_fd) return -1; @@ -170,8 +170,8 @@ int Mp3Decoder::Read(u8 * buffer, int buffer_size, int pos) if(Stream.buffer == NULL || Stream.error == MAD_ERROR_BUFLEN) { u8 * ReadStart = ReadBuffer; - int ReadSize = SoundBlockSize*SoundBlocks; - int Remaining = 0; + s32 ReadSize = SoundBlockSize*SoundBlocks; + s32 Remaining = 0; if(Stream.next_frame != NULL) { diff --git a/src/sounds/Mp3Decoder.hpp b/src/sounds/Mp3Decoder.hpp index ccc437b..d8f4c53 100644 --- a/src/sounds/Mp3Decoder.hpp +++ b/src/sounds/Mp3Decoder.hpp @@ -31,10 +31,10 @@ class Mp3Decoder : public SoundDecoder { public: Mp3Decoder(const char * filepath); - Mp3Decoder(const u8 * sound, int len); + Mp3Decoder(const u8 * sound, s32 len); virtual ~Mp3Decoder(); - int Rewind(); - int Read(u8 * buffer, int buffer_size, int pos); + s32 Rewind(); + s32 Read(u8 * buffer, s32 buffer_size, s32 pos); protected: void OpenFile(); struct mad_stream Stream; diff --git a/src/sounds/OggDecoder.cpp b/src/sounds/OggDecoder.cpp index abb64f4..12e5f6a 100644 --- a/src/sounds/OggDecoder.cpp +++ b/src/sounds/OggDecoder.cpp @@ -67,7 +67,7 @@ OggDecoder::OggDecoder(const char * filepath) OpenFile(); } -OggDecoder::OggDecoder(const u8 * snd, int len) +OggDecoder::OggDecoder(const u8 * snd, s32 len) : SoundDecoder(snd, len) { SoundType = SOUND_OGG; @@ -110,26 +110,26 @@ void OggDecoder::OpenFile() SampleRate = ogg_info->rate; } -int OggDecoder::Rewind() +s32 OggDecoder::Rewind() { if(!file_fd) return -1; - int ret = ov_time_seek(&ogg_file, 0); + s32 ret = ov_time_seek(&ogg_file, 0); CurPos = 0; EndOfFile = false; return ret; } -int OggDecoder::Read(u8 * buffer, int buffer_size, int pos) +s32 OggDecoder::Read(u8 * buffer, s32 buffer_size, s32 pos) { if(!file_fd) return -1; - int bitstream = 0; + s32 bitstream = 0; - int read = ov_read(&ogg_file, (char *) buffer, buffer_size, &bitstream); + s32 read = (s32) ov_read(&ogg_file, (char *) buffer, (int) buffer_size, (int *)&bitstream); if(read > 0) CurPos += read; diff --git a/src/sounds/OggDecoder.hpp b/src/sounds/OggDecoder.hpp index 8dc568e..9c4a947 100644 --- a/src/sounds/OggDecoder.hpp +++ b/src/sounds/OggDecoder.hpp @@ -32,10 +32,10 @@ class OggDecoder : public SoundDecoder { public: OggDecoder(const char * filepath); - OggDecoder(const u8 * snd, int len); + OggDecoder(const u8 * snd, s32 len); virtual ~OggDecoder(); - int Rewind(); - int Read(u8 * buffer, int buffer_size, int pos); + s32 Rewind(); + s32 Read(u8 * buffer, s32 buffer_size, s32 pos); protected: void OpenFile(); OggVorbis_File ogg_file; diff --git a/src/sounds/SoundDecoder.cpp b/src/sounds/SoundDecoder.cpp index e449170..3e60872 100644 --- a/src/sounds/SoundDecoder.cpp +++ b/src/sounds/SoundDecoder.cpp @@ -36,7 +36,7 @@ SoundDecoder::SoundDecoder(const std::string & filepath) Init(); } -SoundDecoder::SoundDecoder(const u8 * buffer, int size) +SoundDecoder::SoundDecoder(const u8 * buffer, s32 size) { file_fd = new CFile(buffer, size); Init(); @@ -78,7 +78,7 @@ void SoundDecoder::Init() ResampleRatio = 0; } -int SoundDecoder::Rewind() +s32 SoundDecoder::Rewind() { CurPos = 0; EndOfFile = false; @@ -87,9 +87,9 @@ int SoundDecoder::Rewind() return 0; } -int SoundDecoder::Read(u8 * buffer, int buffer_size, int pos) +s32 SoundDecoder::Read(u8 * buffer, s32 buffer_size, s32 pos) { - int ret = file_fd->read(buffer, buffer_size); + s32 ret = file_fd->read(buffer, buffer_size); CurPos += ret; return ret; @@ -113,7 +113,7 @@ void SoundDecoder::EnableUpsample(void) void SoundDecoder::Upsample(s16 *src, s16 *dst, u32 nr_src_samples, u32 nr_dst_samples) { - int timer = 0; + s32 timer = 0; for(u32 i = 0, n = 0; i < nr_dst_samples; i += 2) { @@ -129,7 +129,7 @@ void SoundDecoder::Upsample(s16 *src, s16 *dst, u32 nr_src_samples, u32 nr_dst_s timer += ResampleRatio; - if(timer >= (int)FixedPointScale) { + if(timer >= (s32)FixedPointScale) { n += 2; timer -= FixedPointScale; } @@ -152,7 +152,7 @@ void SoundDecoder::Decode() Decoding = true; - int done = 0; + s32 done = 0; u8 * write_buf = SoundBuffer.GetBuffer(whichLoad); if(!write_buf) { @@ -166,7 +166,7 @@ void SoundDecoder::Decode() while(done < SoundBlockSize) { - int ret = Read(&write_buf[done], SoundBlockSize-done, Tell()); + s32 ret = Read(&write_buf[done], SoundBlockSize-done, Tell()); if(ret <= 0) { @@ -192,8 +192,8 @@ void SoundDecoder::Decode() { memcpy(ResampleBuffer, write_buf, done); - int src_samples = done >> 1; - int dest_samples = ( src_samples * FixedPointScale ) / ResampleRatio; + s32 src_samples = done >> 1; + s32 dest_samples = ( src_samples * FixedPointScale ) / ResampleRatio; dest_samples &= ~0x01; Upsample((s16*)ResampleBuffer, (s16*)write_buf, src_samples, dest_samples); done = dest_samples << 1; @@ -205,7 +205,7 @@ void SoundDecoder::Decode() s16* monoBuf = (s16*)write_buf; done = done >> 1; - for(int i = 0; i < done; i++) + for(s32 i = 0; i < done; i++) monoBuf[i] = monoBuf[i << 1]; } diff --git a/src/sounds/SoundDecoder.hpp b/src/sounds/SoundDecoder.hpp index c0c9da1..73a4a1a 100644 --- a/src/sounds/SoundDecoder.hpp +++ b/src/sounds/SoundDecoder.hpp @@ -35,14 +35,14 @@ class SoundDecoder public: SoundDecoder(); SoundDecoder(const std::string & filepath); - SoundDecoder(const u8 * buffer, int size); + SoundDecoder(const u8 * buffer, s32 size); virtual ~SoundDecoder(); virtual void Lock() { mutex.lock(); } virtual void Unlock() { mutex.unlock(); } - virtual int Read(u8 * buffer, int buffer_size, int pos); - virtual int Tell() { return CurPos; } - virtual int Seek(int pos) { CurPos = pos; return file_fd->seek(CurPos, SEEK_SET); } - virtual int Rewind(); + virtual s32 Read(u8 * buffer, s32 buffer_size, s32 pos); + virtual s32 Tell() { return CurPos; } + virtual s32 Seek(s32 pos) { CurPos = pos; return file_fd->seek(CurPos, SEEK_SET); } + virtual s32 Rewind(); virtual u16 GetFormat() { return Format; } virtual u16 GetSampleRate() { return SampleRate; } virtual void Decode(); @@ -87,8 +87,8 @@ protected: u8 SoundType; u16 whichLoad; u16 SoundBlocks; - int SoundBlockSize; - int CurPos; + s32 SoundBlockSize; + s32 CurPos; bool ResampleTo48kHz; bool Loop; bool EndOfFile; diff --git a/src/sounds/SoundHandler.cpp b/src/sounds/SoundHandler.cpp index 68f9dd5..b7e3016 100644 --- a/src/sounds/SoundHandler.cpp +++ b/src/sounds/SoundHandler.cpp @@ -61,7 +61,7 @@ SoundHandler::~SoundHandler() ClearDecoderList(); } -void SoundHandler::AddDecoder(int voice, const char * filepath) +void SoundHandler::AddDecoder(s32 voice, const char * filepath) { if(voice < 0 || voice >= MAX_DECODERS) return; @@ -72,7 +72,7 @@ void SoundHandler::AddDecoder(int voice, const char * filepath) DecoderList[voice] = GetSoundDecoder(filepath); } -void SoundHandler::AddDecoder(int voice, const u8 * snd, int len) +void SoundHandler::AddDecoder(s32 voice, const u8 * snd, s32 len) { if(voice < 0 || voice >= MAX_DECODERS) return; @@ -83,7 +83,7 @@ void SoundHandler::AddDecoder(int voice, const u8 * snd, int len) DecoderList[voice] = GetSoundDecoder(snd, len); } -void SoundHandler::RemoveDecoder(int voice) +void SoundHandler::RemoveDecoder(s32 voice) { if(voice < 0 || voice >= MAX_DECODERS) return; @@ -137,7 +137,7 @@ static inline bool CheckMP3Signature(const u8 * buffer) return true; } - for(int i = 1; i < 13; i++) + for(s32 i = 1; i < 13; i++) { if(buffer[0] == MP3_Magic[i][0] && buffer[1] == MP3_Magic[i][1]) return true; @@ -182,10 +182,10 @@ SoundDecoder * SoundHandler::GetSoundDecoder(const char * filepath) return new SoundDecoder(filepath); } -SoundDecoder * SoundHandler::GetSoundDecoder(const u8 * sound, int length) +SoundDecoder * SoundHandler::GetSoundDecoder(const u8 * sound, s32 length) { const u8 * check = sound; - int counter = 0; + s32 counter = 0; while(check[0] == 0 && counter < length) { @@ -235,7 +235,7 @@ void SoundHandler::executeThread() // we would need MAX_DECODERS > Voice::PRIO_MAX for(u32 i = 0; i < MAX_DECODERS; ++i) { - int priority = (MAX_DECODERS - i) * Voice::PRIO_MAX / MAX_DECODERS; + s32 priority = (MAX_DECODERS - i) * Voice::PRIO_MAX / MAX_DECODERS; voiceList[i] = new Voice(priority); // allocate voice 0 with highest priority } diff --git a/src/sounds/SoundHandler.hpp b/src/sounds/SoundHandler.hpp index 7b0beb6..7c656e2 100644 --- a/src/sounds/SoundHandler.hpp +++ b/src/sounds/SoundHandler.hpp @@ -45,12 +45,12 @@ public: static void DestroyInstance() { delete handlerInstance; handlerInstance = NULL; } - void AddDecoder(int voice, const char * filepath); - void AddDecoder(int voice, const u8 * snd, int len); - void RemoveDecoder(int voice); + void AddDecoder(s32 voice, const char * filepath); + void AddDecoder(s32 voice, const u8 * snd, s32 len); + void RemoveDecoder(s32 voice); - SoundDecoder * getDecoder(int i) { return ((i < 0 || i >= MAX_DECODERS) ? NULL : DecoderList[i]); }; - Voice * getVoice(int i) { return ((i < 0 || i >= MAX_DECODERS) ? NULL : voiceList[i]); }; + SoundDecoder * getDecoder(s32 i) { return ((i < 0 || i >= MAX_DECODERS) ? NULL : DecoderList[i]); }; + Voice * getVoice(s32 i) { return ((i < 0 || i >= MAX_DECODERS) ? NULL : voiceList[i]); }; void ThreadSignal() { resumeThread(); }; bool IsDecoding() { return Decoding; }; @@ -64,7 +64,7 @@ protected: void ClearDecoderList(); SoundDecoder * GetSoundDecoder(const char * filepath); - SoundDecoder * GetSoundDecoder(const u8 * sound, int length); + SoundDecoder * GetSoundDecoder(const u8 * sound, s32 length); static SoundHandler * handlerInstance; diff --git a/src/sounds/Voice.h b/src/sounds/Voice.h index 63fd94e..21a18d4 100644 --- a/src/sounds/Voice.h +++ b/src/sounds/Voice.h @@ -38,7 +38,7 @@ public: STATE_STOP, }; - Voice(int prio) + Voice(s32 prio) : state(STATE_STOPPED) { lastLoopCounter = 0; diff --git a/src/sounds/WavDecoder.cpp b/src/sounds/WavDecoder.cpp index f241df0..09142f2 100644 --- a/src/sounds/WavDecoder.cpp +++ b/src/sounds/WavDecoder.cpp @@ -40,7 +40,7 @@ WavDecoder::WavDecoder(const char * filepath) OpenFile(); } -WavDecoder::WavDecoder(const u8 * snd, int len) +WavDecoder::WavDecoder(const u8 * snd, s32 len) : SoundDecoder(snd, len) { SoundType = SOUND_WAV; @@ -93,7 +93,7 @@ void WavDecoder::OpenFile() { DataOffset += 8+le32(DataChunk.size); file_fd->seek(DataOffset, SEEK_SET); - int ret = file_fd->read((u8 *) &DataChunk, sizeof(SWaveChunk)); + s32 ret = file_fd->read((u8 *) &DataChunk, sizeof(SWaveChunk)); if(ret <= 0) { CloseFile(); @@ -124,20 +124,20 @@ void WavDecoder::CloseFile() file_fd = NULL; } -int WavDecoder::Read(u8 * buffer, int buffer_size, int pos) +s32 WavDecoder::Read(u8 * buffer, s32 buffer_size, s32 pos) { if(!file_fd) return -1; - if(CurPos >= (int) DataSize) + if(CurPos >= (s32) DataSize) return 0; file_fd->seek(DataOffset+CurPos, SEEK_SET); - if(buffer_size > (int) DataSize-CurPos) + if(buffer_size > (s32) DataSize-CurPos) buffer_size = DataSize-CurPos; - int read = file_fd->read(buffer, buffer_size); + s32 read = file_fd->read(buffer, buffer_size); if(read > 0) { if (Is16Bit) diff --git a/src/sounds/WavDecoder.hpp b/src/sounds/WavDecoder.hpp index 5981883..67de796 100644 --- a/src/sounds/WavDecoder.hpp +++ b/src/sounds/WavDecoder.hpp @@ -57,9 +57,9 @@ class WavDecoder : public SoundDecoder { public: WavDecoder(const char * filepath); - WavDecoder(const u8 * snd, int len); + WavDecoder(const u8 * snd, s32 len); virtual ~WavDecoder(); - int Read(u8 * buffer, int buffer_size, int pos); + s32 Read(u8 * buffer, s32 buffer_size, s32 pos); protected: void OpenFile(); void CloseFile(); diff --git a/src/system/CThread.h b/src/system/CThread.h index 3fade45..fd9387b 100644 --- a/src/system/CThread.h +++ b/src/system/CThread.h @@ -29,7 +29,7 @@ public: typedef void (* Callback)(CThread *thread, void *arg); //! constructor - CThread(int iAttr, int iPriority = 16, int iStackSize = 0x8000, CThread::Callback callback = NULL, void *callbackArg = NULL) + CThread(s32 iAttr, s32 iPriority = 16, s32 iStackSize = 0x8000, CThread::Callback callback = NULL, void *callbackArg = NULL) : pThread(NULL) , pThreadStack(NULL) , pCallback(callback) @@ -49,7 +49,7 @@ public: //! destructor virtual ~CThread() { shutdownThread(); } - static CThread *create(CThread::Callback callback, void *callbackArg, int iAttr = eAttributeNone, int iPriority = 16, int iStackSize = 0x8000) + static CThread *create(CThread::Callback callback, void *callbackArg, s32 iAttr = eAttributeNone, s32 iPriority = 16, s32 iStackSize = 0x8000) { return ( new CThread(iAttr, iPriority, iStackSize, callback, callbackArg) ); } @@ -67,7 +67,7 @@ public: //! Resume thread virtual void resumeThread(void) { if(!isThreadSuspended()) return; if(pThread) OSResumeThread(pThread); } //! Set thread priority - virtual void setThreadPriority(int prio) { if(pThread) OSSetThreadPriority(pThread, prio); } + virtual void setThreadPriority(s32 prio) { if(pThread) OSSetThreadPriority(pThread, prio); } //! Check if thread is suspended virtual bool isThreadSuspended(void) const { if(pThread) return OSIsThreadSuspended(pThread); return false; } //! Check if thread is terminated @@ -105,13 +105,13 @@ public: eAttributePinnedAff = 0x10 }; private: - static int threadCallback(int argc, void *arg) + static s32 threadCallback(s32 argc, void *arg) { //! After call to start() continue with the internal function ((CThread *) arg)->executeThread(); return 0; } - int iAttributes; + s32 iAttributes; void *pThread; u8 *pThreadStack; Callback pCallback; diff --git a/src/system/exception_handler.c b/src/system/exception_handler.c index b642248..03609a8 100644 --- a/src/system/exception_handler.c +++ b/src/system/exception_handler.c @@ -80,7 +80,7 @@ static const char exception_print_formats[18][45] = { static unsigned char exception_cb(void * c, unsigned char exception_type) { char buf[850]; - int pos = 0; + s32 pos = 0; OSContext *context = (OSContext *) c; /* diff --git a/src/system/memory.c b/src/system/memory.c index 91f5392..790a6a6 100644 --- a/src/system/memory.c +++ b/src/system/memory.c @@ -34,32 +34,32 @@ //! Memory functions //! This is the only place where those are needed so lets keep them more or less private //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern unsigned int * pMEMAllocFromDefaultHeapEx; -extern unsigned int * pMEMAllocFromDefaultHeap; -extern unsigned int * pMEMFreeToDefaultHeap; +extern u32 * pMEMAllocFromDefaultHeapEx; +extern u32 * pMEMAllocFromDefaultHeap; +extern u32 * pMEMFreeToDefaultHeap; -extern int (* MEMGetBaseHeapHandle)(int mem_arena); -extern unsigned int (* MEMGetAllocatableSizeForFrmHeapEx)(int heap, int align); -extern void *(* MEMAllocFromFrmHeapEx)(int heap, unsigned int size, int align); -extern void (* MEMFreeToFrmHeap)(int heap, int mode); -extern void *(* MEMAllocFromExpHeapEx)(int heap, unsigned int size, int align); -extern int (* MEMCreateExpHeapEx)(void* address, unsigned int size, unsigned short flags); -extern void *(* MEMDestroyExpHeap)(int heap); -extern void (* MEMFreeToExpHeap)(int heap, void* ptr); +extern s32 (* MEMGetBaseHeapHandle)(s32 mem_arena); +extern u32 (* MEMGetAllocatableSizeForFrmHeapEx)(s32 heap, s32 align); +extern void *(* MEMAllocFromFrmHeapEx)(s32 heap, u32 size, s32 align); +extern void (* MEMFreeToFrmHeap)(s32 heap, s32 mode); +extern void *(* MEMAllocFromExpHeapEx)(s32 heap, u32 size, s32 align); +extern s32 (* MEMCreateExpHeapEx)(void* address, u32 size, unsigned short flags); +extern void *(* MEMDestroyExpHeap)(s32 heap); +extern void (* MEMFreeToExpHeap)(s32 heap, void* ptr); -static int mem1_heap = -1; -static int bucket_heap = -1; +static s32 mem1_heap = -1; +static s32 bucket_heap = -1; void memoryInitialize(void) { - int mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1); - unsigned int mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4); + s32 mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1); + u32 mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4); void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4); if(mem1_memory) mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0); - int bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET); - unsigned int bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4); + s32 bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET); + u32 bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4); void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4); if(bucket_memory) bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0); @@ -163,7 +163,7 @@ void *__wrap__realloc_r(struct _reent *r, void *p, size_t size) //!------------------------------------------------------------------------------------------- //! some wrappers //!------------------------------------------------------------------------------------------- -void * MEM2_alloc(unsigned int size, unsigned int align) +void * MEM2_alloc(u32 size, u32 align) { return __wrap_memalign(align, size); } @@ -173,7 +173,7 @@ void MEM2_free(void *ptr) __wrap_free(ptr); } -void * MEM1_alloc(unsigned int size, unsigned int align) +void * MEM1_alloc(u32 size, u32 align) { if (align < 4) align = 4; @@ -185,7 +185,7 @@ void MEM1_free(void *ptr) MEMFreeToExpHeap(mem1_heap, ptr); } -void * MEMBucket_alloc(unsigned int size, unsigned int align) +void * MEMBucket_alloc(u32 size, u32 align) { if (align < 4) align = 4; diff --git a/src/system/memory.h b/src/system/memory.h index 59764d0..db67a05 100644 --- a/src/system/memory.h +++ b/src/system/memory.h @@ -26,13 +26,13 @@ extern "C" { void memoryInitialize(void); void memoryRelease(void); -void * MEM2_alloc(unsigned int size, unsigned int align); +void * MEM2_alloc(u32 size, u32 align); void MEM2_free(void *ptr); -void * MEM1_alloc(unsigned int size, unsigned int align); +void * MEM1_alloc(u32 size, u32 align); void MEM1_free(void *ptr); -void * MEMBucket_alloc(unsigned int size, unsigned int align); +void * MEMBucket_alloc(u32 size, u32 align); void MEMBucket_free(void *ptr); #ifdef __cplusplus diff --git a/src/utils/StringTools.cpp b/src/utils/StringTools.cpp index debb6c7..2b0d84f 100644 --- a/src/utils/StringTools.cpp +++ b/src/utils/StringTools.cpp @@ -73,7 +73,7 @@ const wchar_t * wfmt(const char * format, ...) if((vasprintf(&tmp, format, va) >= 0) && tmp) { int bt; - int strlength = strlen(tmp); + s32 strlength = strlen(tmp); bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512 ); free(tmp); tmp = 0; @@ -92,9 +92,9 @@ const wchar_t * wfmt(const char * format, ...) return NULL; } -int strprintf(std::string &str, const char * format, ...) +s32 strprintf(std::string &str, const char * format, ...) { - int result = 0; + s32 result = 0; char * tmp = NULL; va_list va; @@ -146,7 +146,7 @@ bool char2wchar_t(const char * strChar, wchar_t * dest) return false; } -int strtokcmp(const char * string, const char * compare, const char * separator) +s32 strtokcmp(const char * string, const char * compare, const char * separator) { if(!string || !compare) return -1; @@ -169,7 +169,7 @@ int strtokcmp(const char * string, const char * compare, const char * separator) return -1; } -int strextcmp(const char * string, const char * extension, char seperator) +s32 strextcmp(const char * string, const char * extension, char seperator) { if(!string || !extension) return -1; @@ -187,7 +187,7 @@ std::vector stringSplit(const std::string & inValue, const std::str std::string value = inValue; std::vector result; while (true) { - unsigned int index = value.find(splitter); + u32 index = value.find(splitter); if (index == std::string::npos) { result.push_back(value); break; diff --git a/src/utils/StringTools.h b/src/utils/StringTools.h index bcf89c4..4d0e90f 100644 --- a/src/utils/StringTools.h +++ b/src/utils/StringTools.h @@ -32,11 +32,11 @@ const char * fmt(const char * format, ...); const wchar_t * wfmt(const char * format, ...); -int strprintf(std::string &str, const char * format, ...); +s32 strprintf(std::string &str, const char * format, ...); std::string strfmt(const char * format, ...); bool char2wchar_t(const char * src, wchar_t * dest); -int strtokcmp(const char * string, const char * compare, const char * separator); -int strextcmp(const char * string, const char * extension, char seperator); +s32 strtokcmp(const char * string, const char * compare, const char * separator); +s32 strextcmp(const char * string, const char * extension, char seperator); inline const char * FullpathToFilename(const char *path) { diff --git a/src/utils/function_patcher.cpp b/src/utils/function_patcher.cpp index 4f819f2..17554bf 100644 --- a/src/utils/function_patcher.cpp +++ b/src/utils/function_patcher.cpp @@ -36,19 +36,19 @@ * Patches a function that is loaded at the start of each application. Its not required to restore, at least when they are really dynamic. * "normal" functions should be patch with the normal patcher. Current Code by Maschell with the help of dimok. Orignal code by Chadderz. */ -void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int hook_information_size, volatile unsigned int dynamic_method_calls[]) +void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_size, volatile u32 dynamic_method_calls[]) { log_printf("Patching %d given functions\n",hook_information_size); /* Patch branches to it. */ - volatile unsigned int *space = &dynamic_method_calls[0]; + volatile u32 *space = &dynamic_method_calls[0]; - int method_hooks_count = hook_information_size; + s32 method_hooks_count = hook_information_size; u32 skip_instr = 1; u32 my_instr_len = 6; u32 instr_len = my_instr_len + skip_instr; u32 flush_len = 4*instr_len; - for(int i = 0; i < method_hooks_count; i++) + for(s32 i = 0; i < method_hooks_count; i++) { log_printf("Patching %s ...",method_hooks[i].functionName); if(method_hooks[i].functionType == STATIC_FUNCTION && method_hooks[i].alreadyPatched == 1){ @@ -63,10 +63,10 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int hook_information_ } u32 physical = 0; - unsigned int repl_addr = (unsigned int)method_hooks[i].replaceAddr; - unsigned int call_addr = (unsigned int)method_hooks[i].replaceCall; + u32 repl_addr = (u32)method_hooks[i].replaceAddr; + u32 call_addr = (u32)method_hooks[i].replaceCall; - unsigned int real_addr = GetAddressOfFunction(method_hooks[i].functionName,method_hooks[i].library); + u32 real_addr = GetAddressOfFunction(method_hooks[i].functionName,method_hooks[i].library); if(!real_addr){ log_printf("OSDynLoad_FindExport failed for %s\n", method_hooks[i].functionName); @@ -85,7 +85,7 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int hook_information_ if(DEBUG_LOG_DYN)log_printf("%s physical is located at %08X!\n", method_hooks[i].functionName,physical); - *(volatile unsigned int *)(call_addr) = (unsigned int)(space) - CODE_RW_BASE_OFFSET; + *(volatile u32 *)(call_addr) = (u32)(space) - CODE_RW_BASE_OFFSET; SC0x25_KernelCopyData((u32)space, physical, 4); @@ -127,7 +127,7 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int hook_information_ ICInvalidateRange((unsigned char*)(space - instr_len), flush_len); //setting jump back - unsigned int replace_instr = 0x48000002 | (repl_addr & 0x03fffffc); + u32 replace_instr = 0x48000002 | (repl_addr & 0x03fffffc); DCFlushRange(&replace_instr, 4); SC0x25_KernelCopyData(physical, (u32)OSEffectiveToPhysical(&replace_instr), 4); @@ -143,11 +143,11 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int hook_information_ /* ****************************************************************** */ /* RESTORE ORIGINAL INSTRUCTIONS */ /* ****************************************************************** */ -void RestoreInvidualInstructions(hooks_magic_t method_hooks[],int hook_information_size) +void RestoreInvidualInstructions(hooks_magic_t method_hooks[],s32 hook_information_size) { log_printf("Restoring given functions!\n"); - int method_hooks_count = hook_information_size; - for(int i = 0; i < method_hooks_count; i++) + s32 method_hooks_count = hook_information_size; + for(s32 i = 0; i < method_hooks_count; i++) { log_printf("Restoring %s... ",method_hooks[i].functionName); if(method_hooks[i].restoreInstruction == 0 || method_hooks[i].realAddr == 0){ @@ -155,7 +155,7 @@ void RestoreInvidualInstructions(hooks_magic_t method_hooks[],int hook_informati continue; } - unsigned int real_addr = GetAddressOfFunction(method_hooks[i].functionName,method_hooks[i].library); + u32 real_addr = GetAddressOfFunction(method_hooks[i].functionName,method_hooks[i].library); if(!real_addr){ log_printf("OSDynLoad_FindExport failed for %s\n", method_hooks[i].functionName); @@ -186,15 +186,15 @@ void RestoreInvidualInstructions(hooks_magic_t method_hooks[],int hook_informati log_print("Done with restoring given functions!\n"); } -int isDynamicFunction(unsigned int physicalAddress){ +s32 isDynamicFunction(u32 physicalAddress){ if((physicalAddress & 0x80000000) == 0x80000000){ return 1; } return 0; } -unsigned int GetAddressOfFunction(const char * functionName,unsigned int library){ - unsigned int real_addr = 0; +u32 GetAddressOfFunction(const char * functionName,u32 library){ + u32 real_addr = 0; if(strcmp(functionName, "OSDynLoad_Acquire") == 0) { @@ -203,7 +203,7 @@ unsigned int GetAddressOfFunction(const char * functionName,unsigned int library } else if(strcmp(functionName, "LiWaitOneChunk") == 0) { - real_addr = (unsigned int)addr_LiWaitOneChunk; + real_addr = (u32)addr_LiWaitOneChunk; return real_addr; } else if(strcmp(functionName, "LiBounceOneChunk") == 0) @@ -212,12 +212,12 @@ unsigned int GetAddressOfFunction(const char * functionName,unsigned int library if(OS_FIRMWARE >= 400) return 0; - unsigned int addr_LiBounceOneChunk = 0x010003A0; - real_addr = (unsigned int)addr_LiBounceOneChunk; + u32 addr_LiBounceOneChunk = 0x010003A0; + real_addr = (u32)addr_LiBounceOneChunk; return real_addr; } - unsigned int rpl_handle = 0; + u32 rpl_handle = 0; if(library == LIB_CORE_INIT){ if(DEBUG_LOG_DYN)log_printf("FindExport of %s! From LIB_CORE_INIT\n", functionName); if(coreinit_handle == 0){log_print("LIB_CORE_INIT not aquired\n"); return 0;} @@ -301,14 +301,14 @@ unsigned int GetAddressOfFunction(const char * functionName,unsigned int library return 0; } - if((u32)(*(volatile unsigned int*)(real_addr) & 0x48000002) == 0x48000000) + if((u32)(*(volatile u32*)(real_addr) & 0x48000002) == 0x48000000) { - unsigned int address_diff = (u32)(*(volatile unsigned int*)(real_addr) & 0x03FFFFFC); + u32 address_diff = (u32)(*(volatile u32*)(real_addr) & 0x03FFFFFC); if((address_diff & 0x03000000) == 0x03000000) { address_diff |= 0xFC000000; } real_addr += (int)address_diff; - if((u32)(*(volatile unsigned int*)(real_addr) & 0x48000002) == 0x48000000){ + if((u32)(*(volatile u32*)(real_addr) & 0x48000002) == 0x48000000){ return 0; } } diff --git a/src/utils/function_patcher.h b/src/utils/function_patcher.h index 7000ed9..38403c6 100644 --- a/src/utils/function_patcher.h +++ b/src/utils/function_patcher.h @@ -46,23 +46,23 @@ extern "C" { #define FUNCTION_PATCHER_METHOD_STORE_SIZE 7 typedef struct { - const unsigned int replaceAddr; - const unsigned int replaceCall; - const unsigned int library; + const u32 replaceAddr; + const u32 replaceCall; + const u32 library; const char functionName[50]; - unsigned int realAddr; - unsigned int restoreInstruction; + u32 realAddr; + u32 restoreInstruction; unsigned char functionType; unsigned char alreadyPatched; } hooks_magic_t; -void PatchInvidualMethodHooks(hooks_magic_t hook_information[],int hook_information_size, volatile unsigned int dynamic_method_calls[]); -void RestoreInvidualInstructions(hooks_magic_t hook_information[],int hook_information_size); -unsigned int GetAddressOfFunction(const char * functionName,unsigned int library); -int isDynamicFunction(unsigned int physicalAddress); +void PatchInvidualMethodHooks(hooks_magic_t hook_information[],s32 hook_information_size, volatile u32 dynamic_method_calls[]); +void RestoreInvidualInstructions(hooks_magic_t hook_information[],s32 hook_information_size); +u32 GetAddressOfFunction(const char * functionName,u32 library); +s32 isDynamicFunction(u32 physicalAddress); //Orignal code by Chadderz. -#define MAKE_MAGIC(x, lib,functionType) { (unsigned int) my_ ## x, (unsigned int) &real_ ## x, lib, # x,0,0,functionType,0} +#define MAKE_MAGIC(x, lib,functionType) { (u32) my_ ## x, (u32) &real_ ## x, lib, # x,0,0,functionType,0} #ifdef __cplusplus } diff --git a/src/utils/logger.c b/src/utils/logger.c index e1e411f..11141be 100644 --- a/src/utils/logger.c +++ b/src/utils/logger.c @@ -8,8 +8,8 @@ #include "logger.h" #ifdef DEBUG_LOGGER -static int log_socket = -1; -static volatile int log_lock = 0; +static s32 log_socket = -1; +static volatile s32 log_lock = 0; void log_init(const char * ipString) @@ -51,10 +51,10 @@ void log_print(const char *str) usleep(1000); log_lock = 1; - int len = strlen(str); - int ret; + s32 len = strlen(str); + s32 ret; while (len > 0) { - int block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet + s32 block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet ret = send(log_socket, str, block, 0); if(ret < 0) break; diff --git a/src/video/CursorDrawer.cpp b/src/video/CursorDrawer.cpp index 302a7f7..12981d2 100644 --- a/src/video/CursorDrawer.cpp +++ b/src/video/CursorDrawer.cpp @@ -69,7 +69,7 @@ void CursorDrawer::draw_Cursor(f32 x,f32 y) f32 widthScaleFactor = 1.0f / (f32)1280; f32 heightScaleFactor = 1.0f / (f32)720; - int width = 20; + s32 width = 20; glm::vec3 positionOffsets = glm::vec3(0.0f); diff --git a/src/video/shaders/ColorShader.cpp b/src/video/shaders/ColorShader.cpp index d8e963e..a631084 100644 --- a/src/video/shaders/ColorShader.cpp +++ b/src/video/shaders/ColorShader.cpp @@ -145,7 +145,7 @@ ColorShader::ColorShader() if(positionVtxs) { //! position vertex structure - int i = 0; + s32 i = 0; positionVtxs[i++] = -1.0f; positionVtxs[i++] = -1.0f; positionVtxs[i++] = 0.0f; positionVtxs[i++] = 1.0f; positionVtxs[i++] = -1.0f; positionVtxs[i++] = 0.0f; positionVtxs[i++] = 1.0f; positionVtxs[i++] = 1.0f; positionVtxs[i++] = 0.0f; diff --git a/src/video/shaders/FXAAShader.cpp b/src/video/shaders/FXAAShader.cpp index f86087b..88986e1 100644 --- a/src/video/shaders/FXAAShader.cpp +++ b/src/video/shaders/FXAAShader.cpp @@ -197,7 +197,7 @@ FXAAShader::FXAAShader() texCoords = (f32*)memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciTexCoordsVtxsSize); //! position vertex structure and texture coordinate vertex structure - int i = 0; + s32 i = 0; posVtxs[i++] = -1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; diff --git a/src/video/shaders/Shader3D.cpp b/src/video/shaders/Shader3D.cpp index 6857cd1..38feee9 100644 --- a/src/video/shaders/Shader3D.cpp +++ b/src/video/shaders/Shader3D.cpp @@ -233,7 +233,7 @@ Shader3D::Shader3D() texCoords = (f32*)memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciTexCoordsVtxsSize); //! position vertex structure and texture coordinate vertex structure - int i = 0; + s32 i = 0; posVtxs[i++] = -1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; diff --git a/src/video/shaders/ShaderFractalColor.cpp b/src/video/shaders/ShaderFractalColor.cpp index 7e8624c..72c2032 100644 --- a/src/video/shaders/ShaderFractalColor.cpp +++ b/src/video/shaders/ShaderFractalColor.cpp @@ -329,7 +329,7 @@ ShaderFractalColor::ShaderFractalColor() colorVtxs = (u8*)memalign(GX2_VERTEX_BUFFER_ALIGNMENT, ciColorVtxsSize); //! position vertex structure and texture coordinate vertex structure - int i = 0; + s32 i = 0; posVtxs[i++] = -1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; @@ -344,7 +344,7 @@ ShaderFractalColor::ShaderFractalColor() GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, texCoords, ciTexCoordsVtxsSize); - for(i = 0; i < (int)ciColorVtxsSize; i++) + for(i = 0; i < (s32)ciColorVtxsSize; i++) colorVtxs[i] = 0xff; GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, colorVtxs, ciColorVtxsSize); diff --git a/src/video/shaders/Texture2DShader.cpp b/src/video/shaders/Texture2DShader.cpp index ad7ac52..a0a1ce8 100644 --- a/src/video/shaders/Texture2DShader.cpp +++ b/src/video/shaders/Texture2DShader.cpp @@ -238,7 +238,7 @@ Texture2DShader::Texture2DShader() //! defaults for normal square //! position vertex structure and texture coordinate vertex structure - int i = 0; + s32 i = 0; posVtxs[i++] = -1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f;