mirror of
https://github.com/wiiu-env/libgui.git
synced 2024-12-24 15:21:50 +01:00
Compatible with latest WUT
This commit is contained in:
parent
03ad816adc
commit
21bb3b0417
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,6 @@
|
|||||||
build/*
|
build/*
|
||||||
release/*
|
release/*
|
||||||
libgui.cbp
|
libgui.cbp
|
||||||
|
lib/
|
||||||
|
*.bz2
|
||||||
|
libgui.layout
|
||||||
|
49
.travis.yml
49
.travis.yml
@ -1,49 +0,0 @@
|
|||||||
language: cpp
|
|
||||||
|
|
||||||
os: linux
|
|
||||||
sudo: false
|
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- DEVKITPRO=/opt/devkitpro
|
|
||||||
- WUT_ROOT=/opt/devkitpro/wut
|
|
||||||
- DEVKITPPC=/opt/devkitpro/devkitPPC
|
|
||||||
- PORTLIBREPOS=$HOME/portlibrepos
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- "$HOME/.local"
|
|
||||||
- "$DEVKITPRO"
|
|
||||||
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- p7zip-full
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- mkdir -p "${PORTLIBREPOS}"
|
|
||||||
- mkdir -p "${DEVKITPRO}"
|
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman.deb -O /tmp/devkitpro-pacman.deb; fi
|
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo dpkg -i /tmp/devkitpro-pacman.deb; fi
|
|
||||||
- yes | sudo dkp-pacman -Syu devkitPPC --needed
|
|
||||||
- wget $(curl -s https://api.github.com/repos/decaf-emu/wut/releases/latest | grep 'browser_' | grep 'linux' | cut -d\" -f4)
|
|
||||||
|
|
||||||
install:
|
|
||||||
- 7z x -y $(ls | grep "linux") -o${WUT_ROOT}
|
|
||||||
- 7z x -y ./libs/portlibs.zip -o${DEVKITPRO}
|
|
||||||
- cd $PORTLIBREPOS
|
|
||||||
- git clone https://github.com/Maschell/libutils.git -b wut
|
|
||||||
- cd libutils
|
|
||||||
- mkdir build && cd build
|
|
||||||
- cmake -DCMAKE_TOOLCHAIN_FILE=$WUT_ROOT/share/wut.toolchain.cmake -DCMAKE_INSTALL_PREFIX=$WUT_ROOT ../
|
|
||||||
- make install
|
|
||||||
- cd $PORTLIBREPOS
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- cd $TRAVIS_BUILD_DIR/
|
|
||||||
|
|
||||||
script:
|
|
||||||
- mkdir build && cd build
|
|
||||||
- cmake -DCMAKE_TOOLCHAIN_FILE=$WUT_ROOT/share/wut.toolchain.cmake -DCMAKE_INSTALL_PREFIX=$WUT_ROOT ../
|
|
||||||
- make install
|
|
@ -1,31 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.2)
|
|
||||||
project(guiwut)
|
|
||||||
include("${WUT_ROOT}/share/wut.cmake" REQUIRED)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCE_FILES *.c *.cpp)
|
|
||||||
file(GLOB_RECURSE HEADER_FILES *.h*)
|
|
||||||
|
|
||||||
add_library(guiwut STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
|
||||||
|
|
||||||
target_link_libraries(guiwut
|
|
||||||
utilswut)
|
|
||||||
|
|
||||||
|
|
||||||
include_directories("$ENV{WUT_ROOT}/include/libutilswut" REQUIRED)
|
|
||||||
include_directories("$ENV{DEVKITPRO}/portlibs/ppc/include" REQUIRED)
|
|
||||||
include_directories("$ENV{DEVKITPRO}/portlibs/ppc/include/freetype2" REQUIRED)
|
|
||||||
|
|
||||||
target_include_directories(guiwut PUBLIC "include")
|
|
||||||
target_include_directories(guiwut PRIVATE "src")
|
|
||||||
|
|
||||||
wut_enable_stdcpp(guiwut)
|
|
||||||
wut_default_malloc(guiwut)
|
|
||||||
|
|
||||||
target_include_directories(guiwut PUBLIC "include")
|
|
||||||
target_compile_options(guiwut PUBLIC "-D__LOGGING__")
|
|
||||||
|
|
||||||
install(TARGETS guiwut
|
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
|
|
||||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
|
|
||||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/include/libguiwut"
|
|
||||||
FILES_MATCHING PATTERN "*.h*")
|
|
162
Makefile
Normal file
162
Makefile
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
.SUFFIXES:
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ifeq ($(strip $(DEVKITPRO)),)
|
||||||
|
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
||||||
|
endif
|
||||||
|
|
||||||
|
TOPDIR ?= $(CURDIR)
|
||||||
|
|
||||||
|
include $(DEVKITPRO)/wut/share/wut_rules
|
||||||
|
|
||||||
|
export VER_MAJOR := 1
|
||||||
|
export VER_MINOR := 0
|
||||||
|
export VER_PATCH := 0
|
||||||
|
|
||||||
|
VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# TARGET is the name of the output
|
||||||
|
# BUILD is the directory where object files & intermediate files will be placed
|
||||||
|
# SOURCES is a list of directories containing source code
|
||||||
|
# DATA is a list of directories containing data files
|
||||||
|
# INCLUDES is a list of directories containing header files
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
TARGET := $(notdir $(CURDIR))
|
||||||
|
BUILD := build
|
||||||
|
SOURCES := source \
|
||||||
|
source/gui \
|
||||||
|
source/sounds \
|
||||||
|
source/video \
|
||||||
|
source/video/shaders \
|
||||||
|
|
||||||
|
DATA := data
|
||||||
|
INCLUDES := source \
|
||||||
|
include \
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# options for code generation
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
CFLAGS := -Wall -Werror -save-temps \
|
||||||
|
-ffunction-sections -fdata-sections \
|
||||||
|
$(MACHDEP) \
|
||||||
|
$(BUILD_CFLAGS)
|
||||||
|
|
||||||
|
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||||
|
|
||||||
|
CXXFLAGS := $(CFLAGS) -std=gnu++17
|
||||||
|
|
||||||
|
ASFLAGS := $(MACHDEP)
|
||||||
|
|
||||||
|
LDFLAGS = $(ARCH) -Wl,--gc-sections
|
||||||
|
|
||||||
|
|
||||||
|
LIBS :=
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
# include and lib
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
LIBDIRS := $(PORTLIBS) $(WUT_ROOT)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# no real need to edit anything past this point unless you need to add additional
|
||||||
|
# rules for different file extensions
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export TOPDIR := $(CURDIR)
|
||||||
|
|
||||||
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||||
|
|
||||||
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||||
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||||
|
DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def)))
|
||||||
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# use CXX for linking C++ projects, CC for standard C
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ifeq ($(strip $(CPPFILES)),)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export LD := $(CC)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export LD := $(CXX)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||||
|
export OFILES_SRC := $(DEFFILES:.def=.o) $(SFILES:.s=.o) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
|
||||||
|
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
||||||
|
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||||
|
|
||||||
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||||
|
-I. -I$(PORTLIBS_PATH)/ppc/include/freetype2
|
||||||
|
|
||||||
|
.PHONY: all dist-bin dist-src dist install clean
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
all: lib/libgui.a
|
||||||
|
|
||||||
|
dist-bin: all
|
||||||
|
@tar --exclude=*~ -cjf libgui-$(VERSION).tar.bz2 include lib
|
||||||
|
|
||||||
|
dist-src:
|
||||||
|
@tar --exclude=*~ -cjf libgui-src-$(VERSION).tar.bz2 include source Makefile
|
||||||
|
|
||||||
|
dist: dist-src dist-bin
|
||||||
|
|
||||||
|
install: dist-bin
|
||||||
|
mkdir -p $(DESTDIR)$(DEVKITPRO)/wut
|
||||||
|
bzip2 -cd libgui-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/wut
|
||||||
|
|
||||||
|
lib:
|
||||||
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
|
||||||
|
release:
|
||||||
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
|
||||||
|
lib/libgui.a :$(SOURCES) $(INCLUDES) | lib release
|
||||||
|
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
|
||||||
|
BUILD_CFLAGS="-DNDEBUG=1 -O2 -s" \
|
||||||
|
DEPSDIR=$(CURDIR)/release \
|
||||||
|
--no-print-directory -C release \
|
||||||
|
-f $(CURDIR)/Makefile
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
clean:
|
||||||
|
@echo clean ...
|
||||||
|
@rm -rf release lib
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
|
||||||
|
DEPENDS := $(OFILES:.o=.d)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# main targets
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
$(OUTPUT) : $(OFILES)
|
||||||
|
|
||||||
|
$(OFILES_SRC) : $(HFILES)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
%_bin.h %.bin.o : %.bin
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
@echo $(notdir $<)
|
||||||
|
@$(bin2o)
|
||||||
|
|
||||||
|
|
||||||
|
-include $(DEPENDS)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------------
|
@ -2,7 +2,7 @@
|
|||||||
#define _GAME_BG_IMAGE_H_
|
#define _GAME_BG_IMAGE_H_
|
||||||
|
|
||||||
#include <gui/GuiImageAsync.h>
|
#include <gui/GuiImageAsync.h>
|
||||||
#include <video/shaders/Shader3D.h>
|
#include <gui/video/shaders/Shader3D.h>
|
||||||
|
|
||||||
class GameBgImage : public GuiImageAsync {
|
class GameBgImage : public GuiImageAsync {
|
||||||
public:
|
public:
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define _GRID_BACKGROUND_H_
|
#define _GRID_BACKGROUND_H_
|
||||||
|
|
||||||
#include <gui/GuiImage.h>
|
#include <gui/GuiImage.h>
|
||||||
#include <video/shaders/Shader.h>
|
|
||||||
|
|
||||||
class GridBackground : public GuiImage {
|
class GridBackground : public GuiImage {
|
||||||
public:
|
public:
|
||||||
|
@ -33,10 +33,9 @@
|
|||||||
#include <gui/sigslot.h>
|
#include <gui/sigslot.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <system/AsyncDeleter.h>
|
#include <gui/system/AsyncDeleter.h>
|
||||||
#include <utils/logger.h>
|
|
||||||
|
|
||||||
#include <resources/Resources.h>
|
#include <gui/resources/Resources.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
EFFECT_NONE = 0x00,
|
EFFECT_NONE = 0x00,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#ifndef GUI_IMAGE_H_
|
#ifndef GUI_IMAGE_H_
|
||||||
#define GUI_IMAGE_H_
|
#define GUI_IMAGE_H_
|
||||||
|
|
||||||
#include <video/shaders/Shader.h>
|
#include <gui/video/shaders/Shader.h>
|
||||||
#include <gui/GuiElement.h>
|
#include <gui/GuiElement.h>
|
||||||
#include <gui/GuiImageData.h>
|
#include <gui/GuiImageData.h>
|
||||||
#include <gui/gx2_ext.h>
|
#include <gui/gx2_ext.h>
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <gui/GuiImage.h>
|
#include <gui/GuiImage.h>
|
||||||
#include <system/CThread.h>
|
#include <gui/system/CThread.h>
|
||||||
#include <system/CMutex.h>
|
#include <gui/system/CMutex.h>
|
||||||
|
|
||||||
class GuiImageAsync : public GuiImage {
|
class GuiImageAsync : public GuiImage {
|
||||||
public:
|
public:
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#define GUI_IMAGEDATA_H_
|
#define GUI_IMAGEDATA_H_
|
||||||
|
|
||||||
#include <gd.h>
|
#include <gd.h>
|
||||||
#include <system/AsyncDeleter.h>
|
#include <gui/system/AsyncDeleter.h>
|
||||||
#include <gui/gx2_ext.h>
|
#include <gui/gx2_ext.h>
|
||||||
#include <gx2/texture.h>
|
#include <gx2/texture.h>
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#ifndef GUI_SOUND_H_
|
#ifndef GUI_SOUND_H_
|
||||||
#define GUI_SOUND_H_
|
#define GUI_SOUND_H_
|
||||||
|
|
||||||
#include <system/AsyncDeleter.h>
|
#include <gui/system/AsyncDeleter.h>
|
||||||
|
|
||||||
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
|
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
|
||||||
class GuiSound : public AsyncDeleter::Element {
|
class GuiSound : public AsyncDeleter::Element {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <mad.h>
|
#include <mad.h>
|
||||||
|
|
||||||
#include <sounds/SoundDecoder.hpp>
|
#include <gui/sounds/SoundDecoder.hpp>
|
||||||
|
|
||||||
class Mp3Decoder : public SoundDecoder {
|
class Mp3Decoder : public SoundDecoder {
|
||||||
public:
|
public:
|
@ -26,7 +26,7 @@
|
|||||||
#include <tremor/ivorbiscodec.h>
|
#include <tremor/ivorbiscodec.h>
|
||||||
#include <tremor/ivorbisfile.h>
|
#include <tremor/ivorbisfile.h>
|
||||||
|
|
||||||
#include <sounds/SoundDecoder.hpp>
|
#include <gui/sounds/SoundDecoder.hpp>
|
||||||
|
|
||||||
class OggDecoder : public SoundDecoder {
|
class OggDecoder : public SoundDecoder {
|
||||||
public:
|
public:
|
@ -26,9 +26,11 @@
|
|||||||
#ifndef SOUND_DECODER_HPP
|
#ifndef SOUND_DECODER_HPP
|
||||||
#define SOUND_DECODER_HPP
|
#define SOUND_DECODER_HPP
|
||||||
|
|
||||||
#include <fs/CFile.hpp>
|
#include <string>
|
||||||
#include <system/CMutex.h>
|
#include <gui/system/CMutex.h>
|
||||||
#include <sounds/BufferCircle.hpp>
|
#include <gui/sounds/BufferCircle.hpp>
|
||||||
|
|
||||||
|
class CFile;
|
||||||
|
|
||||||
class SoundDecoder {
|
class SoundDecoder {
|
||||||
public:
|
public:
|
||||||
@ -46,10 +48,8 @@ public:
|
|||||||
virtual int32_t Tell() {
|
virtual int32_t Tell() {
|
||||||
return CurPos;
|
return CurPos;
|
||||||
}
|
}
|
||||||
virtual int32_t Seek(int32_t pos) {
|
virtual int32_t Seek(int32_t pos);
|
||||||
CurPos = pos;
|
|
||||||
return file_fd->seek(CurPos, SEEK_SET);
|
|
||||||
}
|
|
||||||
virtual int32_t Rewind();
|
virtual int32_t Rewind();
|
||||||
virtual uint16_t GetFormat() {
|
virtual uint16_t GetFormat() {
|
||||||
return Format;
|
return Format;
|
@ -28,9 +28,9 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <system/CThread.h>
|
#include <gui/system/CThread.h>
|
||||||
#include <sounds/SoundDecoder.hpp>
|
#include <gui/sounds/SoundDecoder.hpp>
|
||||||
#include <sounds/Voice.h>
|
#include <gui/sounds/Voice.h>
|
||||||
#include <sndcore2/voice.h>
|
#include <sndcore2/voice.h>
|
||||||
|
|
||||||
#define MAX_DECODERS 16 // can be increased up to 96
|
#define MAX_DECODERS 16 // can be increased up to 96
|
@ -26,7 +26,7 @@
|
|||||||
#ifndef WAVDECODER_HPP_
|
#ifndef WAVDECODER_HPP_
|
||||||
#define WAVDECODER_HPP_
|
#define WAVDECODER_HPP_
|
||||||
|
|
||||||
#include <sounds/SoundDecoder.hpp>
|
#include <gui/sounds/SoundDecoder.hpp>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t magicRIFF;
|
uint32_t magicRIFF;
|
76
include/gui/system/AsyncDeleter.h
Normal file
76
include/gui/system/AsyncDeleter.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2015 Dimok
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef _ASYNC_DELETER_H
|
||||||
|
#define _ASYNC_DELETER_H
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
|
#include "CThread.h"
|
||||||
|
#include "CMutex.h"
|
||||||
|
|
||||||
|
class AsyncDeleter : public CThread {
|
||||||
|
public:
|
||||||
|
static void destroyInstance() {
|
||||||
|
if(deleterInstance != NULL) {
|
||||||
|
delete deleterInstance;
|
||||||
|
deleterInstance = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Element {
|
||||||
|
public:
|
||||||
|
Element() {}
|
||||||
|
virtual ~Element() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void pushForDelete(AsyncDeleter::Element *e) {
|
||||||
|
if(!deleterInstance) {
|
||||||
|
deleterInstance = new AsyncDeleter();
|
||||||
|
}
|
||||||
|
deleterInstance->deleteElements.push(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL deleteListEmpty() {
|
||||||
|
if(!deleterInstance) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return deleterInstance->deleteElements.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL realListEmpty() {
|
||||||
|
if(!deleterInstance) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return deleterInstance->realDeleteElements.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void triggerDeleteProcess(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
AsyncDeleter();
|
||||||
|
virtual ~AsyncDeleter();
|
||||||
|
|
||||||
|
static AsyncDeleter *deleterInstance;
|
||||||
|
|
||||||
|
void executeThread(void);
|
||||||
|
|
||||||
|
BOOL exitApplication;
|
||||||
|
std::queue<AsyncDeleter::Element *> deleteElements;
|
||||||
|
std::queue<AsyncDeleter::Element *> realDeleteElements;
|
||||||
|
CMutex deleteMutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _ASYNC_DELETER_H
|
69
include/gui/system/CMutex.h
Normal file
69
include/gui/system/CMutex.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2015 Dimok
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef _CMUTEX_H_
|
||||||
|
#define _CMUTEX_H_
|
||||||
|
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <coreinit/mutex.h>
|
||||||
|
|
||||||
|
class CMutex
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMutex() {
|
||||||
|
pMutex = (OSMutex*) malloc(sizeof(OSMutex));
|
||||||
|
if(!pMutex)
|
||||||
|
return;
|
||||||
|
|
||||||
|
OSInitMutex(pMutex);
|
||||||
|
}
|
||||||
|
virtual ~CMutex() {
|
||||||
|
if(pMutex)
|
||||||
|
free(pMutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lock(void) {
|
||||||
|
if(pMutex)
|
||||||
|
OSLockMutex(pMutex);
|
||||||
|
}
|
||||||
|
void unlock(void) {
|
||||||
|
if(pMutex)
|
||||||
|
OSUnlockMutex(pMutex);
|
||||||
|
}
|
||||||
|
BOOL tryLock(void) {
|
||||||
|
if(!pMutex)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (OSTryLockMutex(pMutex) != 0);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
OSMutex *pMutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CMutexLock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMutexLock() {
|
||||||
|
mutex.lock();
|
||||||
|
}
|
||||||
|
virtual ~CMutexLock() {
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
CMutex mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _CMUTEX_H_
|
133
include/gui/system/CThread.h
Normal file
133
include/gui/system/CThread.h
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2015 Dimok
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef CTHREAD_H_
|
||||||
|
#define CTHREAD_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <coreinit/systeminfo.h>
|
||||||
|
#include <coreinit/thread.h>
|
||||||
|
|
||||||
|
class CThread {
|
||||||
|
public:
|
||||||
|
typedef void (* Callback)(CThread *thread, void *arg);
|
||||||
|
|
||||||
|
//! constructor
|
||||||
|
CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = NULL, void *callbackArg = NULL)
|
||||||
|
: pThread(NULL)
|
||||||
|
, pThreadStack(NULL)
|
||||||
|
, pCallback(callback)
|
||||||
|
, pCallbackArg(callbackArg) {
|
||||||
|
//! save attribute assignment
|
||||||
|
iAttributes = iAttr;
|
||||||
|
//! allocate the thread
|
||||||
|
pThread = (OSThread*)memalign(8, sizeof(OSThread));
|
||||||
|
//! allocate the stack
|
||||||
|
pThreadStack = (uint8_t *) memalign(0x20, iStackSize);
|
||||||
|
//! create the thread
|
||||||
|
if(pThread && pThreadStack)
|
||||||
|
OSCreateThread(pThread, &CThread::threadCallback, 1, (char*)this, pThreadStack+iStackSize, iStackSize, iPriority, iAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! destructor
|
||||||
|
virtual ~CThread() {
|
||||||
|
shutdownThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
static CThread *create(CThread::Callback callback, void *callbackArg, int32_t iAttr = eAttributeNone, int32_t iPriority = 16, int32_t iStackSize = 0x8000) {
|
||||||
|
return ( new CThread(iAttr, iPriority, iStackSize, callback, callbackArg) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Get thread ID
|
||||||
|
virtual void* getThread() const {
|
||||||
|
return pThread;
|
||||||
|
}
|
||||||
|
//! Thread entry function
|
||||||
|
virtual void executeThread(void) {
|
||||||
|
if(pCallback)
|
||||||
|
pCallback(this, pCallbackArg);
|
||||||
|
}
|
||||||
|
//! Suspend thread
|
||||||
|
virtual void suspendThread(void) {
|
||||||
|
if(isThreadSuspended()) return;
|
||||||
|
if(pThread) OSSuspendThread(pThread);
|
||||||
|
}
|
||||||
|
//! 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);
|
||||||
|
}
|
||||||
|
//! Check if thread is suspended
|
||||||
|
virtual BOOL isThreadSuspended(void) const {
|
||||||
|
if(pThread) return OSIsThreadSuspended(pThread);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//! Check if thread is terminated
|
||||||
|
virtual BOOL isThreadTerminated(void) const {
|
||||||
|
if(pThread) return OSIsThreadTerminated(pThread);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//! Check if thread is running
|
||||||
|
virtual BOOL isThreadRunning(void) const {
|
||||||
|
return !isThreadSuspended() && !isThreadRunning();
|
||||||
|
}
|
||||||
|
//! Shutdown thread
|
||||||
|
virtual void shutdownThread(void) {
|
||||||
|
//! wait for thread to finish
|
||||||
|
if(pThread && !(iAttributes & eAttributeDetach)) {
|
||||||
|
if(isThreadSuspended())
|
||||||
|
resumeThread();
|
||||||
|
|
||||||
|
OSJoinThread(pThread, NULL);
|
||||||
|
}
|
||||||
|
//! free the thread stack buffer
|
||||||
|
if(pThreadStack)
|
||||||
|
free(pThreadStack);
|
||||||
|
if(pThread)
|
||||||
|
free(pThread);
|
||||||
|
|
||||||
|
pThread = NULL;
|
||||||
|
pThreadStack = NULL;
|
||||||
|
}
|
||||||
|
//! Thread attributes
|
||||||
|
enum eCThreadAttributes {
|
||||||
|
eAttributeNone = 0x07,
|
||||||
|
eAttributeAffCore0 = 0x01,
|
||||||
|
eAttributeAffCore1 = 0x02,
|
||||||
|
eAttributeAffCore2 = 0x04,
|
||||||
|
eAttributeDetach = 0x08,
|
||||||
|
eAttributePinnedAff = 0x10
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
static int threadCallback(int argc, const char **argv) {
|
||||||
|
//! After call to start() continue with the internal function
|
||||||
|
((CThread *) argv)->executeThread();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int iAttributes;
|
||||||
|
OSThread *pThread;
|
||||||
|
uint8_t *pThreadStack;
|
||||||
|
Callback pCallback;
|
||||||
|
void *pCallbackArg;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -28,7 +28,7 @@
|
|||||||
#include <gx2/display.h>
|
#include <gx2/display.h>
|
||||||
#include <gui/gx2_ext.h>
|
#include <gui/gx2_ext.h>
|
||||||
|
|
||||||
#include <video/shaders/Shader.h>
|
#include <gui/video/shaders/Shader.h>
|
||||||
|
|
||||||
class CVideo {
|
class CVideo {
|
||||||
public:
|
public:
|
@ -17,9 +17,9 @@
|
|||||||
#ifndef __COLOR_SHADER_H_
|
#ifndef __COLOR_SHADER_H_
|
||||||
#define __COLOR_SHADER_H_
|
#define __COLOR_SHADER_H_
|
||||||
|
|
||||||
#include <video/shaders/VertexShader.h>
|
#include <gui/video/shaders/VertexShader.h>
|
||||||
#include <video/shaders/PixelShader.h>
|
#include <gui/video/shaders/PixelShader.h>
|
||||||
#include <video/shaders/FetchShader.h>
|
#include <gui/video/shaders/FetchShader.h>
|
||||||
|
|
||||||
class ColorShader : public Shader {
|
class ColorShader : public Shader {
|
||||||
private:
|
private:
|
@ -17,9 +17,9 @@
|
|||||||
#ifndef __FXAA_SHADER_H_
|
#ifndef __FXAA_SHADER_H_
|
||||||
#define __FXAA_SHADER_H_
|
#define __FXAA_SHADER_H_
|
||||||
|
|
||||||
#include <video/shaders/VertexShader.h>
|
#include <gui/video/shaders/VertexShader.h>
|
||||||
#include <video/shaders/PixelShader.h>
|
#include <gui/video/shaders/PixelShader.h>
|
||||||
#include <video/shaders/FetchShader.h>
|
#include <gui/video/shaders/FetchShader.h>
|
||||||
|
|
||||||
class FXAAShader : public Shader {
|
class FXAAShader : public Shader {
|
||||||
public:
|
public:
|
@ -17,7 +17,7 @@
|
|||||||
#ifndef FETCH_SHADER_H
|
#ifndef FETCH_SHADER_H
|
||||||
#define FETCH_SHADER_H
|
#define FETCH_SHADER_H
|
||||||
|
|
||||||
#include <video/shaders/Shader.h>
|
#include <gui/video/shaders/Shader.h>
|
||||||
|
|
||||||
class FetchShader : public Shader {
|
class FetchShader : public Shader {
|
||||||
public:
|
public:
|
@ -17,7 +17,7 @@
|
|||||||
#ifndef PIXEL_SHADER_H
|
#ifndef PIXEL_SHADER_H
|
||||||
#define PIXEL_SHADER_H
|
#define PIXEL_SHADER_H
|
||||||
|
|
||||||
#include <video/shaders/Shader.h>
|
#include <gui/video/shaders/Shader.h>
|
||||||
|
|
||||||
class PixelShader : public Shader {
|
class PixelShader : public Shader {
|
||||||
public:
|
public:
|
@ -19,12 +19,12 @@
|
|||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <utils/utils.h>
|
|
||||||
#include <gx2/shaders.h>
|
#include <gx2/shaders.h>
|
||||||
#include <gx2/mem.h>
|
#include <gx2/mem.h>
|
||||||
#include <gx2/enum.h>
|
#include <gx2/enum.h>
|
||||||
#include <gx2/registers.h>
|
#include <gx2/registers.h>
|
||||||
#include <gx2/draw.h>
|
#include <gx2/draw.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
class Shader {
|
class Shader {
|
||||||
protected:
|
protected:
|
@ -17,9 +17,9 @@
|
|||||||
#ifndef SHADER_3D_H_
|
#ifndef SHADER_3D_H_
|
||||||
#define SHADER_3D_H_
|
#define SHADER_3D_H_
|
||||||
|
|
||||||
#include <video/shaders/VertexShader.h>
|
#include <gui/video/shaders/VertexShader.h>
|
||||||
#include <video/shaders/PixelShader.h>
|
#include <gui/video/shaders/PixelShader.h>
|
||||||
#include <video/shaders/FetchShader.h>
|
#include <gui/video/shaders/FetchShader.h>
|
||||||
|
|
||||||
class Shader3D : public Shader {
|
class Shader3D : public Shader {
|
||||||
private:
|
private:
|
@ -17,9 +17,9 @@
|
|||||||
#ifndef SHADER_FRACTAL_COLOR_H_
|
#ifndef SHADER_FRACTAL_COLOR_H_
|
||||||
#define SHADER_FRACTAL_COLOR_H_
|
#define SHADER_FRACTAL_COLOR_H_
|
||||||
|
|
||||||
#include <video/shaders/VertexShader.h>
|
#include <gui/video/shaders/VertexShader.h>
|
||||||
#include <video/shaders/PixelShader.h>
|
#include <gui/video/shaders/PixelShader.h>
|
||||||
#include <video/shaders/FetchShader.h>
|
#include <gui/video/shaders/FetchShader.h>
|
||||||
class ShaderFractalColor : public Shader {
|
class ShaderFractalColor : public Shader {
|
||||||
private:
|
private:
|
||||||
ShaderFractalColor();
|
ShaderFractalColor();
|
@ -17,9 +17,9 @@
|
|||||||
#ifndef __TEXTURE_2D_SHADER_H_
|
#ifndef __TEXTURE_2D_SHADER_H_
|
||||||
#define __TEXTURE_2D_SHADER_H_
|
#define __TEXTURE_2D_SHADER_H_
|
||||||
|
|
||||||
#include <video/shaders/VertexShader.h>
|
#include <gui/video/shaders/VertexShader.h>
|
||||||
#include <video/shaders/PixelShader.h>
|
#include <gui/video/shaders/PixelShader.h>
|
||||||
#include <video/shaders/FetchShader.h>
|
#include <gui/video/shaders/FetchShader.h>
|
||||||
|
|
||||||
|
|
||||||
class Texture2DShader : public Shader {
|
class Texture2DShader : public Shader {
|
@ -18,7 +18,7 @@
|
|||||||
#define VERTEX_SHADER_H
|
#define VERTEX_SHADER_H
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <video/shaders/Shader.h>
|
#include <gui/video/shaders/Shader.h>
|
||||||
#include <gui/gx2_ext.h>
|
#include <gui/gx2_ext.h>
|
||||||
|
|
||||||
class VertexShader : public Shader {
|
class VertexShader : public Shader {
|
@ -1,33 +0,0 @@
|
|||||||
#ifndef RECOURCES_H_
|
|
||||||
#define RECOURCES_H_
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
//! forward declaration
|
|
||||||
class GuiImageData;
|
|
||||||
class GuiSound;
|
|
||||||
|
|
||||||
class Resources {
|
|
||||||
public:
|
|
||||||
static void Clear();
|
|
||||||
static bool LoadFiles(const char * path);
|
|
||||||
static const uint8_t * GetFile(const char * filename);
|
|
||||||
static uint32_t GetFileSize(const char * filename);
|
|
||||||
|
|
||||||
static GuiImageData * GetImageData(const char * filename);
|
|
||||||
static void RemoveImageData(GuiImageData * image);
|
|
||||||
|
|
||||||
static GuiSound * GetSound(const char * filename);
|
|
||||||
static void RemoveSound(GuiSound * sound);
|
|
||||||
private:
|
|
||||||
static Resources *instance;
|
|
||||||
|
|
||||||
Resources() {}
|
|
||||||
~Resources() {}
|
|
||||||
|
|
||||||
std::map<std::string, std::pair<uint32_t, GuiImageData *> > imageDataMap;
|
|
||||||
std::map<std::string, std::pair<uint32_t, GuiSound *> > soundDataMap;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,16 +0,0 @@
|
|||||||
#ifndef _FILELIST_H_
|
|
||||||
#define _FILELIST_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
typedef struct _ResourceFile {
|
|
||||||
const char *filename;
|
|
||||||
const uint8_t *DefaultFile;
|
|
||||||
const uint32_t &DefaultFileSize;
|
|
||||||
uint8_t *CustomFile;
|
|
||||||
uint32_t CustomFileSize;
|
|
||||||
} ResourceFile;
|
|
||||||
|
|
||||||
ResourceFile * getResourceList();
|
|
||||||
|
|
||||||
#endif
|
|
Binary file not shown.
61
source/fs/CFile.hpp
Normal file
61
source/fs/CFile.hpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#ifndef CFILE_HPP_
|
||||||
|
#define CFILE_HPP_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
|
#include <string.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <wut_types.h>
|
||||||
|
|
||||||
|
class CFile {
|
||||||
|
public:
|
||||||
|
enum eOpenTypes {
|
||||||
|
ReadOnly,
|
||||||
|
WriteOnly,
|
||||||
|
ReadWrite,
|
||||||
|
Append
|
||||||
|
};
|
||||||
|
|
||||||
|
CFile();
|
||||||
|
CFile(const std::string & filepath, eOpenTypes mode);
|
||||||
|
CFile(const uint8_t * memory, int32_t memsize);
|
||||||
|
virtual ~CFile();
|
||||||
|
|
||||||
|
int32_t open(const std::string & filepath, eOpenTypes mode);
|
||||||
|
int32_t open(const uint8_t * memory, int32_t memsize);
|
||||||
|
|
||||||
|
BOOL isOpen() const {
|
||||||
|
if(iFd >= 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if(mem_file)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void close();
|
||||||
|
|
||||||
|
int32_t read(uint8_t * ptr, size_t size);
|
||||||
|
int32_t write(const uint8_t * ptr, size_t size);
|
||||||
|
int32_t fwrite(const char *format, ...);
|
||||||
|
int32_t seek(long int offset, int32_t origin);
|
||||||
|
uint64_t tell() {
|
||||||
|
return pos;
|
||||||
|
};
|
||||||
|
uint64_t size() {
|
||||||
|
return filesize;
|
||||||
|
};
|
||||||
|
void rewind() {
|
||||||
|
this->seek(0, SEEK_SET);
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int32_t iFd;
|
||||||
|
const uint8_t * mem_file;
|
||||||
|
uint64_t filesize;
|
||||||
|
uint64_t pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
103
source/fs/DirList.h
Normal file
103
source/fs/DirList.h
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2010
|
||||||
|
* by Dimok
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any
|
||||||
|
* damages arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any
|
||||||
|
* purpose, including commercial applications, and to alter it and
|
||||||
|
* redistribute it freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you
|
||||||
|
* must not claim that you wrote the original software. If you use
|
||||||
|
* this software in a product, an acknowledgment in the product
|
||||||
|
* documentation would be appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and
|
||||||
|
* must not be misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* DirList Class
|
||||||
|
* for WiiXplorer 2010
|
||||||
|
***************************************************************************/
|
||||||
|
#ifndef ___DIRLIST_H_
|
||||||
|
#define ___DIRLIST_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <wut_types.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char * FilePath;
|
||||||
|
BOOL isDir;
|
||||||
|
} DirEntry;
|
||||||
|
|
||||||
|
class DirList {
|
||||||
|
public:
|
||||||
|
//!Constructor
|
||||||
|
DirList(void);
|
||||||
|
//!\param path Path from where to load the filelist of all files
|
||||||
|
//!\param filter A fileext that needs to be filtered
|
||||||
|
//!\param flags search/filter flags from the enum
|
||||||
|
DirList(const std::string & path, const char *filter = NULL, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff);
|
||||||
|
//!Destructor
|
||||||
|
virtual ~DirList();
|
||||||
|
//! Load all the files from a directory
|
||||||
|
BOOL LoadPath(const std::string & path, const char *filter = NULL, uint32_t flags = Files | Dirs, uint32_t maxDepth = 0xffffffff);
|
||||||
|
//! Get a filename of the list
|
||||||
|
//!\param list index
|
||||||
|
const char * GetFilename(int32_t index) const;
|
||||||
|
//! Get the a filepath of the list
|
||||||
|
//!\param list index
|
||||||
|
const char *GetFilepath(int32_t index) const {
|
||||||
|
if (!valid(index)) return "";
|
||||||
|
else return FileInfo[index].FilePath;
|
||||||
|
}
|
||||||
|
//! Get the a filesize of the list
|
||||||
|
//!\param list index
|
||||||
|
uint64_t GetFilesize(int32_t index) const;
|
||||||
|
//! Is index a dir or a file
|
||||||
|
//!\param list index
|
||||||
|
BOOL IsDir(int32_t index) const {
|
||||||
|
if(!valid(index)) return false;
|
||||||
|
return FileInfo[index].isDir;
|
||||||
|
};
|
||||||
|
//! Get the filecount of the whole list
|
||||||
|
int32_t 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
|
||||||
|
int32_t GetFileIndex(const char *filename) const;
|
||||||
|
//! Enum for search/filter flags
|
||||||
|
enum {
|
||||||
|
Files = 0x01,
|
||||||
|
Dirs = 0x02,
|
||||||
|
CheckSubfolders = 0x08,
|
||||||
|
};
|
||||||
|
protected:
|
||||||
|
// Internal parser
|
||||||
|
BOOL InternalLoadPath(std::string &path);
|
||||||
|
//!Add a list entrie
|
||||||
|
void AddEntrie(const std::string &filepath, const char * filename, BOOL isDir);
|
||||||
|
//! Clear the list
|
||||||
|
void ClearList();
|
||||||
|
//! Check if valid pos is requested
|
||||||
|
inline BOOL valid(uint32_t pos) const {
|
||||||
|
return (pos < FileInfo.size());
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t Flags;
|
||||||
|
uint32_t Depth;
|
||||||
|
const char *Filter;
|
||||||
|
std::vector<DirEntry> FileInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
16
source/fs/FSUtils.h
Normal file
16
source/fs/FSUtils.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef __FS_UTILS_H_
|
||||||
|
#define __FS_UTILS_H_
|
||||||
|
|
||||||
|
#include <wut_types.h>
|
||||||
|
|
||||||
|
class FSUtils {
|
||||||
|
public:
|
||||||
|
static int32_t LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size);
|
||||||
|
|
||||||
|
//! todo: C++ class
|
||||||
|
static int32_t CreateSubfolder(const char * fullpath);
|
||||||
|
static int32_t CheckFile(const char * filepath);
|
||||||
|
static BOOL saveBufferToFile(const char * path, void * buffer, uint32_t size);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __FS_UTILS_H_
|
@ -21,8 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gui/FreeTypeGX.h>
|
#include <gui/FreeTypeGX.h>
|
||||||
#include <video/CVideo.h>
|
#include <gui/video/CVideo.h>
|
||||||
#include <video/shaders/Texture2DShader.h>
|
#include <gui/video/shaders/Texture2DShader.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) {
|
|||||||
|
|
||||||
uint8_t *src = (uint8_t *)bmp->buffer;
|
uint8_t *src = (uint8_t *)bmp->buffer;
|
||||||
uint16_t *dst = (uint16_t *)charData->texture->surface.image;
|
uint16_t *dst = (uint16_t *)charData->texture->surface.image;
|
||||||
int32_t x, y;
|
uint32_t x, y;
|
||||||
|
|
||||||
for(y = 0; y < bmp->rows; y++) {
|
for(y = 0; y < bmp->rows; y++) {
|
||||||
for(x = 0; x < bmp->width; x++) {
|
for(x = 0; x < bmp->width; x++) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <gui/GameBgImage.h>
|
#include <gui/GameBgImage.h>
|
||||||
#include <video/CVideo.h>
|
#include <gui/video/CVideo.h>
|
||||||
#include <video/shaders/Shader3D.h>
|
#include <gui/video/shaders/Shader3D.h>
|
||||||
|
|
||||||
GameBgImage::GameBgImage(const std::string & filename, GuiImageData *preloadImage)
|
GameBgImage::GameBgImage(const std::string & filename, GuiImageData *preloadImage)
|
||||||
: GuiImageAsync(filename, preloadImage) {
|
: GuiImageAsync(filename, preloadImage) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <gui/GridBackground.h>
|
#include <gui/GridBackground.h>
|
||||||
#include <video/CVideo.h>
|
#include <gui/video/CVideo.h>
|
||||||
#include <video/shaders/Shader3D.h>
|
#include <gui/video/shaders/Shader3D.h>
|
||||||
|
#include "utils/utils.h"
|
||||||
|
|
||||||
static const float bgRepeat = 1000.0f;
|
static const float bgRepeat = 1000.0f;
|
||||||
static const float bgTexRotate = 39.0f;
|
static const float bgTexRotate = 39.0f;
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <gui/GuiDragListener.h>
|
#include <gui/GuiDragListener.h>
|
||||||
#include <gui/GuiController.h>
|
#include <gui/GuiController.h>
|
||||||
#include <utils/logger.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the GuiDragListener class.
|
* Constructor for the GuiDragListener class.
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <gui/GuiImage.h>
|
#include <gui/GuiImage.h>
|
||||||
#include <video/CVideo.h>
|
#include <gui/video/CVideo.h>
|
||||||
#include <video/shaders/Texture2DShader.h>
|
#include <gui/video/shaders/Texture2DShader.h>
|
||||||
#include <video/shaders/ColorShader.h>
|
#include <gui/video/shaders/ColorShader.h>
|
||||||
|
#include "utils/utils.h"
|
||||||
|
|
||||||
static const float fPiDiv180 = ((float)M_PI / 180.0f);
|
static const float fPiDiv180 = ((float)M_PI / 180.0f);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <gui/GuiImageAsync.h>
|
#include <gui/GuiImageAsync.h>
|
||||||
#include <fs/FSUtils.h>
|
#include "fs/FSUtils.h"
|
||||||
|
|
||||||
std::vector<GuiImageAsync *> GuiImageAsync::imageQueue;
|
std::vector<GuiImageAsync *> GuiImageAsync::imageQueue;
|
||||||
CThread * GuiImageAsync::pThread = NULL;
|
CThread * GuiImageAsync::pThread = NULL;
|
||||||
|
@ -15,8 +15,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <gui/GuiParticleImage.h>
|
#include <gui/GuiParticleImage.h>
|
||||||
#include <video/CVideo.h>
|
#include <gui/video/CVideo.h>
|
||||||
#include <video/shaders/ColorShader.h>
|
#include <gui/video/shaders/ColorShader.h>
|
||||||
|
#include "utils/utils.h"
|
||||||
|
|
||||||
#define CIRCLE_VERTEX_COUNT 36
|
#define CIRCLE_VERTEX_COUNT 36
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
* distribution.
|
* distribution.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <gui/GuiScrollbar.h>
|
#include <gui/GuiScrollbar.h>
|
||||||
#include <resources/Resources.h>
|
#include <gui/resources/Resources.h>
|
||||||
|
#include "utils/utils.h"
|
||||||
|
|
||||||
GuiScrollbar::GuiScrollbar(int32_t h)
|
GuiScrollbar::GuiScrollbar(int32_t h)
|
||||||
: touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
|
: touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utils/StringTools.h>
|
|
||||||
#include <utils/logger.h>
|
|
||||||
|
|
||||||
#include <gui/GuiSelectBox.h>
|
#include <gui/GuiSelectBox.h>
|
||||||
#include <gui/GuiImage.h>
|
#include <gui/GuiImage.h>
|
||||||
|
@ -14,8 +14,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
#include <stdio.h>
|
||||||
#include <gui/GuiSound.h>
|
#include <gui/GuiSound.h>
|
||||||
#include <sounds/SoundHandler.hpp>
|
#include <gui/sounds/SoundHandler.hpp>
|
||||||
|
|
||||||
GuiSound::GuiSound(const char * filepath) {
|
GuiSound::GuiSound(const char * filepath) {
|
||||||
voice = -1;
|
voice = -1;
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include <gui/GuiSwitch.h>
|
#include <gui/GuiSwitch.h>
|
||||||
#include <gui/GuiImage.h>
|
#include <gui/GuiImage.h>
|
||||||
#include <gui/GuiImageData.h>
|
#include <gui/GuiImageData.h>
|
||||||
#include <utils/logger.h>
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the GuiSwitch class.
|
* Constructor for the GuiSwitch class.
|
||||||
*/
|
*/
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <gui/GuiText.h>
|
#include <gui/GuiText.h>
|
||||||
#include <gui/FreeTypeGX.h>
|
#include <gui/FreeTypeGX.h>
|
||||||
#include <video/CVideo.h>
|
#include <gui/video/CVideo.h>
|
||||||
|
|
||||||
FreeTypeGX * GuiText::presentFont = NULL;
|
FreeTypeGX * GuiText::presentFont = NULL;
|
||||||
int32_t GuiText::presetSize = 28;
|
int32_t GuiText::presetSize = 28;
|
||||||
|
@ -1,180 +0,0 @@
|
|||||||
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <resources/Resources.h>
|
|
||||||
#include <resources/filelist.h>
|
|
||||||
#include <system/AsyncDeleter.h>
|
|
||||||
#include <fs/FSUtils.h>
|
|
||||||
#include <gui/GuiImageAsync.h>
|
|
||||||
#include <gui/GuiSound.h>
|
|
||||||
|
|
||||||
Resources * Resources::instance = NULL;
|
|
||||||
|
|
||||||
void Resources::Clear() {
|
|
||||||
ResourceFile * ResourceList = getResourceList();
|
|
||||||
if(ResourceList == NULL) return;
|
|
||||||
|
|
||||||
for(int32_t i = 0; ResourceList[i].filename != NULL; ++i) {
|
|
||||||
if(ResourceList[i].CustomFile) {
|
|
||||||
free(ResourceList[i].CustomFile);
|
|
||||||
ResourceList[i].CustomFile = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ResourceList[i].CustomFileSize != 0)
|
|
||||||
ResourceList[i].CustomFileSize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(instance)
|
|
||||||
delete instance;
|
|
||||||
|
|
||||||
instance = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Resources::LoadFiles(const char * path) {
|
|
||||||
if(!path)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
bool result = false;
|
|
||||||
Clear();
|
|
||||||
|
|
||||||
ResourceFile * ResourceList = getResourceList();
|
|
||||||
if(ResourceList == NULL) return false;
|
|
||||||
|
|
||||||
for(int32_t i = 0; ResourceList[i].filename != NULL; ++i) {
|
|
||||||
std::string fullpath(path);
|
|
||||||
fullpath += "/";
|
|
||||||
fullpath += ResourceList[i].filename;
|
|
||||||
|
|
||||||
uint8_t * buffer = NULL;
|
|
||||||
uint32_t filesize = 0;
|
|
||||||
|
|
||||||
FSUtils::LoadFileToMem(fullpath.c_str(), &buffer, &filesize);
|
|
||||||
|
|
||||||
ResourceList[i].CustomFile = buffer;
|
|
||||||
ResourceList[i].CustomFileSize = (uint32_t) filesize;
|
|
||||||
result |= (buffer != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint8_t * Resources::GetFile(const char * filename) {
|
|
||||||
ResourceFile * ResourceList = getResourceList();
|
|
||||||
if(ResourceList == NULL) return NULL;
|
|
||||||
|
|
||||||
for(int32_t i = 0; ResourceList[i].filename != NULL; ++i) {
|
|
||||||
if(strcasecmp(filename, ResourceList[i].filename) == 0) {
|
|
||||||
return (ResourceList[i].CustomFile ? ResourceList[i].CustomFile : ResourceList[i].DefaultFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t Resources::GetFileSize(const char * filename) {
|
|
||||||
ResourceFile * ResourceList = getResourceList();
|
|
||||||
if(ResourceList == NULL) return 0;
|
|
||||||
|
|
||||||
for(int32_t i = 0; ResourceList[i].filename != NULL; ++i) {
|
|
||||||
if(strcasecmp(filename, ResourceList[i].filename) == 0) {
|
|
||||||
return (ResourceList[i].CustomFile ? ResourceList[i].CustomFileSize : ResourceList[i].DefaultFileSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
GuiImageData * Resources::GetImageData(const char * filename) {
|
|
||||||
if(!instance)
|
|
||||||
instance = new Resources;
|
|
||||||
|
|
||||||
ResourceFile * ResourceList = getResourceList();
|
|
||||||
if(ResourceList == NULL) return NULL;
|
|
||||||
|
|
||||||
std::map<std::string, std::pair<uint32_t, GuiImageData *> >::iterator itr = instance->imageDataMap.find(std::string(filename));
|
|
||||||
if(itr != instance->imageDataMap.end()) {
|
|
||||||
itr->second.first++;
|
|
||||||
return itr->second.second;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int32_t i = 0; ResourceList[i].filename != NULL; ++i) {
|
|
||||||
if(strcasecmp(filename, ResourceList[i].filename) == 0) {
|
|
||||||
const uint8_t * buff = ResourceList[i].CustomFile ? ResourceList[i].CustomFile : ResourceList[i].DefaultFile;
|
|
||||||
const uint32_t size = ResourceList[i].CustomFile ? ResourceList[i].CustomFileSize : ResourceList[i].DefaultFileSize;
|
|
||||||
|
|
||||||
if(buff == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
GuiImageData * image = new GuiImageData(buff, size);
|
|
||||||
instance->imageDataMap[std::string(filename)].first = 1;
|
|
||||||
instance->imageDataMap[std::string(filename)].second = image;
|
|
||||||
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Resources::RemoveImageData(GuiImageData * image) {
|
|
||||||
std::map<std::string, std::pair<uint32_t, GuiImageData *> >::iterator itr;
|
|
||||||
|
|
||||||
for(itr = instance->imageDataMap.begin(); itr != instance->imageDataMap.end(); itr++) {
|
|
||||||
if(itr->second.second == image) {
|
|
||||||
itr->second.first--;
|
|
||||||
|
|
||||||
if(itr->second.first == 0) {
|
|
||||||
AsyncDeleter::pushForDelete( itr->second.second );
|
|
||||||
instance->imageDataMap.erase(itr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GuiSound * Resources::GetSound(const char * filename) {
|
|
||||||
if(!instance)
|
|
||||||
instance = new Resources;
|
|
||||||
|
|
||||||
std::map<std::string, std::pair<uint32_t, GuiSound *> >::iterator itr = instance->soundDataMap.find(std::string(filename));
|
|
||||||
if(itr != instance->soundDataMap.end()) {
|
|
||||||
itr->second.first++;
|
|
||||||
return itr->second.second;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceFile * ResourceList = getResourceList();
|
|
||||||
if(ResourceList == NULL) return NULL;
|
|
||||||
|
|
||||||
for(int32_t i = 0; ResourceList[i].filename != NULL; ++i) {
|
|
||||||
if(strcasecmp(filename, ResourceList[i].filename) == 0) {
|
|
||||||
const uint8_t * buff = ResourceList[i].CustomFile ? ResourceList[i].CustomFile : ResourceList[i].DefaultFile;
|
|
||||||
const uint32_t size = ResourceList[i].CustomFile ? ResourceList[i].CustomFileSize : ResourceList[i].DefaultFileSize;
|
|
||||||
|
|
||||||
if(buff == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
GuiSound * sound = new GuiSound(buff, size);
|
|
||||||
instance->soundDataMap[std::string(filename)].first = 1;
|
|
||||||
instance->soundDataMap[std::string(filename)].second = sound;
|
|
||||||
|
|
||||||
return sound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Resources::RemoveSound(GuiSound * sound) {
|
|
||||||
std::map<std::string, std::pair<uint32_t, GuiSound *> >::iterator itr;
|
|
||||||
|
|
||||||
for(itr = instance->soundDataMap.begin(); itr != instance->soundDataMap.end(); itr++) {
|
|
||||||
if(itr->second.second == sound) {
|
|
||||||
itr->second.first--;
|
|
||||||
|
|
||||||
if(itr->second.first == 0) {
|
|
||||||
AsyncDeleter::pushForDelete( itr->second.second );
|
|
||||||
instance->soundDataMap.erase(itr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,7 +25,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <utils/utils.h>
|
#include <utils/utils.h>
|
||||||
#include <sounds/BufferCircle.hpp>
|
#include <gui/sounds/BufferCircle.hpp>
|
||||||
|
|
||||||
BufferCircle::BufferCircle() {
|
BufferCircle::BufferCircle() {
|
||||||
which = 0;
|
which = 0;
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <coreinit/time.h>
|
#include <coreinit/time.h>
|
||||||
#include <coreinit/thread.h>
|
#include <coreinit/thread.h>
|
||||||
#include <sounds/Mp3Decoder.hpp>
|
#include <gui/sounds/Mp3Decoder.hpp>
|
||||||
|
#include "fs/CFile.hpp"
|
||||||
|
|
||||||
Mp3Decoder::Mp3Decoder(const char * filepath)
|
Mp3Decoder::Mp3Decoder(const char * filepath)
|
||||||
: SoundDecoder(filepath)
|
: SoundDecoder(filepath)
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <coreinit/time.h>
|
#include <coreinit/time.h>
|
||||||
#include <coreinit/thread.h>
|
#include <coreinit/thread.h>
|
||||||
#include <sounds/OggDecoder.hpp>
|
#include <gui/sounds/OggDecoder.hpp>
|
||||||
|
#include "fs/CFile.hpp"
|
||||||
|
|
||||||
static int ogg_read(void * punt, int bytes, int blocks, int *f) {
|
static int ogg_read(void * punt, int bytes, int blocks, int *f) {
|
||||||
return ((CFile *) f)->read((uint8_t *) punt, bytes*blocks);
|
return ((CFile *) f)->read((uint8_t *) punt, bytes*blocks);
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
#include <coreinit/time.h>
|
#include <coreinit/time.h>
|
||||||
#include <coreinit/thread.h>
|
#include <coreinit/thread.h>
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
#include <sounds/SoundDecoder.hpp>
|
#include <gui/sounds/SoundDecoder.hpp>
|
||||||
|
#include "fs/CFile.hpp"
|
||||||
|
|
||||||
static const uint32_t FixedPointShift = 15;
|
static const uint32_t FixedPointShift = 15;
|
||||||
static const uint32_t FixedPointScale = 1 << FixedPointShift;
|
static const uint32_t FixedPointScale = 1 << FixedPointShift;
|
||||||
@ -58,6 +59,11 @@ SoundDecoder::~SoundDecoder() {
|
|||||||
free(ResampleBuffer);
|
free(ResampleBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t SoundDecoder::Seek(int32_t pos) {
|
||||||
|
CurPos = pos;
|
||||||
|
return file_fd->seek(CurPos, SEEK_SET);
|
||||||
|
}
|
||||||
|
|
||||||
void SoundDecoder::Init() {
|
void SoundDecoder::Init() {
|
||||||
SoundType = SOUND_RAW;
|
SoundType = SOUND_RAW;
|
||||||
SoundBlocks = 8;
|
SoundBlocks = 8;
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <fs/CFile.hpp>
|
#include <fs/CFile.hpp>
|
||||||
#include <sounds/SoundHandler.hpp>
|
#include <gui/sounds/SoundHandler.hpp>
|
||||||
#include <sounds/WavDecoder.hpp>
|
#include <gui/sounds/WavDecoder.hpp>
|
||||||
#include <sounds/Mp3Decoder.hpp>
|
#include <gui/sounds/Mp3Decoder.hpp>
|
||||||
#include <sounds/OggDecoder.hpp>
|
#include <gui/sounds/OggDecoder.hpp>
|
||||||
#include <sndcore2/core.h>
|
#include <sndcore2/core.h>
|
||||||
|
|
||||||
SoundHandler * SoundHandler::handlerInstance = NULL;
|
SoundHandler * SoundHandler::handlerInstance = NULL;
|
||||||
@ -86,7 +86,11 @@ void SoundHandler::RemoveDecoder(int32_t voice) {
|
|||||||
if(voiceList[voice]->getState() != Voice::STATE_STOP)
|
if(voiceList[voice]->getState() != Voice::STATE_STOP)
|
||||||
voiceList[voice]->setState(Voice::STATE_STOP);
|
voiceList[voice]->setState(Voice::STATE_STOP);
|
||||||
|
|
||||||
while(voiceList[voice]->getState() != Voice::STATE_STOPPED)
|
// it shouldn't take longer than 3 ms actually but we wait up to 20
|
||||||
|
// on application quit the AX frame callback is not called anymore
|
||||||
|
// therefore this would end in endless loop if no timeout is defined
|
||||||
|
int timeOut = 20;
|
||||||
|
while(--timeOut && (voiceList[voice]->getState() != Voice::STATE_STOPPED))
|
||||||
OSSleepTicks(OSMicrosecondsToTicks(1000));
|
OSSleepTicks(OSMicrosecondsToTicks(1000));
|
||||||
}
|
}
|
||||||
SoundDecoder *decoder = DecoderList[voice];
|
SoundDecoder *decoder = DecoderList[voice];
|
||||||
|
@ -24,8 +24,9 @@
|
|||||||
* for WiiXplorer 2010
|
* for WiiXplorer 2010
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <utils/utils.h>
|
#include <gui/sounds/WavDecoder.hpp>
|
||||||
#include <sounds/WavDecoder.hpp>
|
#include "fs/CFile.hpp"
|
||||||
|
#include "utils/utils.h"
|
||||||
|
|
||||||
WavDecoder::WavDecoder(const char * filepath)
|
WavDecoder::WavDecoder(const char * filepath)
|
||||||
: SoundDecoder(filepath) {
|
: SoundDecoder(filepath) {
|
||||||
|
42
source/system/memory.h
Normal file
42
source/system/memory.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2015 Dimok
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __MEMORY_H_
|
||||||
|
#define __MEMORY_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
void memoryInitialize(void);
|
||||||
|
void memoryRelease(void);
|
||||||
|
|
||||||
|
void * MEM2_alloc(uint32_t size, uint32_t align);
|
||||||
|
void MEM2_free(void *ptr);
|
||||||
|
|
||||||
|
void * MEM1_alloc(uint32_t size, uint32_t align);
|
||||||
|
void MEM1_free(void *ptr);
|
||||||
|
|
||||||
|
void * MEMBucket_alloc(uint32_t size, uint32_t align);
|
||||||
|
void MEMBucket_free(void *ptr);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __MEMORY_H_
|
35
source/utils/utils.h
Normal file
35
source/utils/utils.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef __UTILS_H_
|
||||||
|
#define __UTILS_H_
|
||||||
|
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LIMIT(x, min, max) \
|
||||||
|
({ \
|
||||||
|
typeof( x ) _x = x; \
|
||||||
|
typeof( min ) _min = min; \
|
||||||
|
typeof( max ) _max = max; \
|
||||||
|
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define DegToRad(a) ( (a) * 0.01745329252f )
|
||||||
|
#define RadToDeg(a) ( (a) * 57.29577951f )
|
||||||
|
|
||||||
|
#define ALIGN4(x) (((x) + 3) & ~3)
|
||||||
|
#define ALIGN32(x) (((x) + 31) & ~31)
|
||||||
|
|
||||||
|
#define le16(i) ((((uint16_t) ((i) & 0xFF)) << 8) | ((uint16_t) (((i) & 0xFF00) >> 8)))
|
||||||
|
#define le32(i) ((((uint32_t)le16((i) & 0xFFFF)) << 16) | ((uint32_t)le16(((i) & 0xFFFF0000) >> 16)))
|
||||||
|
#define le64(i) ((((uint64_t)le32((i) & 0xFFFFFFFFLL)) << 32) | ((uint64_t)le32(((i) & 0xFFFFFFFF00000000LL) >> 32)))
|
||||||
|
|
||||||
|
//Needs to have log_init() called beforehand.
|
||||||
|
void dumpHex(const void* data, size_t size);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __UTILS_H_
|
@ -16,13 +16,15 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <video/CVideo.h>
|
#include <gui/video/CVideo.h>
|
||||||
#include <system/memory.h>
|
#include "system/memory.h"
|
||||||
#include <video/shaders/Texture2DShader.h>
|
#include <gui/video/shaders/Texture2DShader.h>
|
||||||
#include <video/shaders/ColorShader.h>
|
#include <gui/video/shaders/ColorShader.h>
|
||||||
#include <video/shaders/Shader3D.h>
|
#include <gui/video/shaders/Shader3D.h>
|
||||||
#include <video/shaders/ShaderFractalColor.h>
|
#include <gui/video/shaders/ShaderFractalColor.h>
|
||||||
#include <video/shaders/FXAAShader.h>
|
#include <gui/video/shaders/FXAAShader.h>
|
||||||
|
#include "utils/utils.h"
|
||||||
|
|
||||||
CVideo::CVideo(int32_t forceTvScanMode, int32_t forceDrcScanMode) {
|
CVideo::CVideo(int32_t forceTvScanMode, int32_t forceDrcScanMode) {
|
||||||
tvEnabled = false;
|
tvEnabled = false;
|
||||||
drcEnabled = false;
|
drcEnabled = false;
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <video/shaders/ColorShader.h>
|
#include <gui/video/shaders/ColorShader.h>
|
||||||
#include <video/shaders/FXAAShader.h>
|
#include <gui/video/shaders/FXAAShader.h>
|
||||||
#include <video/shaders/Shader3D.h>
|
#include <gui/video/shaders/Shader3D.h>
|
||||||
#include <video/shaders/ShaderFractalColor.h>
|
#include <gui/video/shaders/ShaderFractalColor.h>
|
||||||
#include <video/shaders/Texture2DShader.h>
|
#include <gui/video/shaders/Texture2DShader.h>
|
||||||
#include <video/CursorDrawer.h>
|
#include <gui/video/CursorDrawer.h>
|
||||||
|
|
||||||
CursorDrawer *CursorDrawer::instance = NULL;
|
CursorDrawer *CursorDrawer::instance = NULL;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <video/shaders/ColorShader.h>
|
#include <gui/video/shaders/ColorShader.h>
|
||||||
|
|
||||||
static const uint32_t cpVertexShaderProgram[] = {
|
static const uint32_t cpVertexShaderProgram[] = {
|
||||||
0x00000000,0x00008009,0x20000000,0x000078a0,
|
0x00000000,0x00008009,0x20000000,0x000078a0,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <video/shaders/FXAAShader.h>
|
#include <gui/video/shaders/FXAAShader.h>
|
||||||
|
|
||||||
static const uint32_t cpVertexShaderProgram[] = {
|
static const uint32_t cpVertexShaderProgram[] = {
|
||||||
0x00000000,0x00008009,0x20000000,0x000004a0,
|
0x00000000,0x00008009,0x20000000,0x000004a0,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <video/shaders/Shader3D.h>
|
#include <gui/video/shaders/Shader3D.h>
|
||||||
|
|
||||||
static const uint32_t cpVertexShaderProgram[] = {
|
static const uint32_t cpVertexShaderProgram[] = {
|
||||||
0x00000000,0x00008009,0x20000000,0x0000e4a1,
|
0x00000000,0x00008009,0x20000000,0x0000e4a1,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <video/shaders/ShaderFractalColor.h>
|
#include <gui/video/shaders/ShaderFractalColor.h>
|
||||||
|
|
||||||
static const uint32_t cpVertexShaderProgram[] = {
|
static const uint32_t cpVertexShaderProgram[] = {
|
||||||
0x00000000,0x00008009,0x20000000,0x0000eca1,
|
0x00000000,0x00008009,0x20000000,0x0000eca1,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <video/shaders/Texture2DShader.h>
|
#include <gui/video/shaders/Texture2DShader.h>
|
||||||
|
|
||||||
static const uint32_t cpVertexShaderProgram[] = {
|
static const uint32_t cpVertexShaderProgram[] = {
|
||||||
0x00000000,0x00008009,0x20000000,0x000080a0,
|
0x00000000,0x00008009,0x20000000,0x000080a0,
|
||||||
|
Loading…
Reference in New Issue
Block a user