removed all sound related stuff

This commit is contained in:
Christopher Roy Bratusek 2012-04-07 20:14:53 +02:00
parent 2b5772020f
commit 6e11c98ff2
11 changed files with 26 additions and 1510 deletions

View File

@ -1,383 +0,0 @@
/*
* Metaphrasis is a static conversion class for transforming RGBA image
* buffers into verious GX texture formats for Wii homebrew development.
* Copyright (C) 2008 Armin Tamzarian
*
* This file is part of Metaphrasis.
*
* Metaphrasis is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Metaphrasis 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Metaphrasis. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Metaphrasis.h"
/**
* Default constructor for the Metaphrasis class.
*/
Metaphrasis::Metaphrasis() {
}
/**
* Default destructor for the Metaphrasis class.
*/
Metaphrasis::~Metaphrasis() {
}
/**
* Convert the specified RGBA data buffer into the I4 texture format
*
* This routine converts the RGBA data buffer into the I4 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToI4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = bufferWidth * bufferHeight >> 1;
uint32_t* dataBufferI4 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferI4, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferI4;
for(uint16_t y = 0; y < bufferHeight; y += 8) {
for(uint16_t x = 0; x < bufferWidth; x += 8) {
for(uint16_t rows = 0; rows < 8; rows++) {
*dst++ = (src[((y + rows) * bufferWidth) + (x + 0)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 1)] & 0xf0) >> 4);
*dst++ = (src[((y + rows) * bufferWidth) + (x + 2)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 3)] & 0xf0) >> 4);
*dst++ = (src[((y + rows) * bufferWidth) + (x + 4)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 5)] & 0xf0) >> 4);
*dst++ = (src[((y + rows) * bufferWidth) + (x + 5)] & 0xf0) | ((src[((y + rows) * bufferWidth) + (x + 7)] & 0xf0) >> 4);
}
}
}
DCFlushRange(dataBufferI4, bufferSize);
return dataBufferI4;
}
/**
* Convert the specified RGBA data buffer into the I8 texture format
*
* This routine converts the RGBA data buffer into the I8 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToI8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = bufferWidth * bufferHeight;
uint32_t* dataBufferI8 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferI8, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferI8;
for(uint16_t y = 0; y < bufferHeight; y += 4) {
for(uint16_t x = 0; x < bufferWidth; x += 8) {
for(uint16_t rows = 0; rows < 4; rows++) {
*dst++ = src[((y + rows) * bufferWidth) + (x + 0)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 1)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 2)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 3)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 4)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 5)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 6)] & 0xff;
*dst++ = src[((y + rows) * bufferWidth) + (x + 7)] & 0xff;
}
}
}
DCFlushRange(dataBufferI8, bufferSize);
return dataBufferI8;
}
/**
* Downsample the specified RGBA value data buffer to an IA4 value.
*
* This routine downsamples the given RGBA data value into the IA4 texture data format.
*
* @param rgba A 32-bit RGBA value to convert to the IA4 format.
* @return The IA4 value of the given RGBA value.
*/
uint8_t Metaphrasis::convertRGBAToIA4(uint32_t rgba) {
uint8_t i, a;
i = (rgba >> 8) & 0xf0;
a = (rgba ) & 0xff;
return i | (a >> 4);
}
/**
* Convert the specified RGBA data buffer into the IA4 texture format
*
* This routine converts the RGBA data buffer into the IA4 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToIA4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = bufferWidth * bufferHeight;
uint32_t* dataBufferIA4 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferIA4, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferIA4;
for(uint16_t y = 0; y < bufferHeight; y += 4) {
for(uint16_t x = 0; x < bufferWidth; x += 8) {
for(uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 2)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 3)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 4)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 5)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 6)]);
*dst++ = Metaphrasis::convertRGBAToIA4(src[((y + rows) * bufferWidth) + (x + 7)]);
}
}
}
DCFlushRange(dataBufferIA4, bufferSize);
return dataBufferIA4;
}
/**
* Downsample the specified RGBA value data buffer to an IA8 value.
*
* This routine downsamples the given RGBA data value into the IA8 texture data format.
*
* @param rgba A 32-bit RGBA value to convert to the IA8 format.
* @return The IA8 value of the given RGBA value.
*/
uint16_t Metaphrasis::convertRGBAToIA8(uint32_t rgba) {
uint8_t i, a;
i = (rgba >> 8) & 0xff;
a = (rgba ) & 0xff;
return (i << 8) | a;
}
/**
* Convert the specified RGBA data buffer into the IA8 texture format
*
* This routine converts the RGBA data buffer into the IA8 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToIA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = (bufferWidth * bufferHeight) << 1;
uint32_t* dataBufferIA8 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferIA8, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint16_t *dst = (uint16_t *)dataBufferIA8;
for(uint16_t y = 0; y < bufferHeight; y += 4) {
for(uint16_t x = 0; x < bufferWidth; x += 4) {
for(uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 2)]);
*dst++ = Metaphrasis::convertRGBAToIA8(src[((y + rows) * bufferWidth) + (x + 3)]);
}
}
}
DCFlushRange(dataBufferIA8, bufferSize);
return dataBufferIA8;
}
/**
* Convert the specified RGBA data buffer into the RGBA8 texture format
*
* This routine converts the RGBA data buffer into the RGBA8 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToRGBA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = (bufferWidth * bufferHeight) << 2;
uint32_t* dataBufferRGBA8 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferRGBA8, 0x00, bufferSize);
uint8_t *src = (uint8_t *)rgbaBuffer;
uint8_t *dst = (uint8_t *)dataBufferRGBA8;
for(uint16_t block = 0; block < bufferHeight; block += 4) {
for(uint16_t i = 0; i < bufferWidth; i += 4) {
for (uint16_t c = 0; c < 4; c++) {
for (uint16_t ar = 0; ar < 4; ar++) {
*dst++ = src[(((i + ar) + ((block + c) * bufferWidth)) * 4) + 3];
*dst++ = src[((i + ar) + ((block + c) * bufferWidth)) * 4];
}
}
for (uint16_t c = 0; c < 4; c++) {
for (uint16_t gb = 0; gb < 4; gb++) {
*dst++ = src[(((i + gb) + ((block + c) * bufferWidth)) * 4) + 1];
*dst++ = src[(((i + gb) + ((block + c) * bufferWidth)) * 4) + 2];
}
}
}
}
DCFlushRange(dataBufferRGBA8, bufferSize);
return dataBufferRGBA8;
}
/**
* Downsample the specified RGBA value data buffer to an RGB565 value.
*
* This routine downsamples the given RGBA data value into the RGB565 texture data format.
* Attribution for this routine is given fully to NoNameNo of GRRLIB Wii library.
*
* @param rgba A 32-bit RGBA value to convert to the RGB565 format.
* @return The RGB565 value of the given RGBA value.
*/
uint16_t Metaphrasis::convertRGBAToRGB565(uint32_t rgba) {
uint8_t r, g, b;
r = (((rgba >> 24) & 0xff) * 31) / 255;
g = (((rgba >> 16) & 0xff) * 63) / 255;
b = (((rgba >> 8) & 0xff) * 31) / 255;
return (((r << 6) | g ) << 5 ) | b;
}
/**
* Convert the specified RGBA data buffer into the RGB565 texture format
*
* This routine converts the RGBA data buffer into the RGB565 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToRGB565(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = (bufferWidth * bufferHeight) << 1;
uint32_t* dataBufferRGB565 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferRGB565, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint16_t *dst = (uint16_t *)dataBufferRGB565;
for(uint16_t y = 0; y < bufferHeight; y += 4) {
for(uint16_t x = 0; x < bufferWidth; x += 4) {
for(uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 2)]);
*dst++ = Metaphrasis::convertRGBAToRGB565(src[((y + rows) * bufferWidth) + (x + 3)]);
}
}
}
DCFlushRange(dataBufferRGB565, bufferSize);
return dataBufferRGB565;
}
/**
* Downsample the specified RGBA value data buffer to an RGB5A3 value.
*
* This routine downsamples the given RGBA data value into the RGB5A3 texture data format.
* Attribution for this routine is given fully to WiiGator via the TehSkeen forum.
*
* @param rgba A 32-bit RGBA value to convert to the RGB5A3 format.
* @return The RGB5A3 value of the given RGBA value.
*/
uint16_t Metaphrasis::convertRGBAToRGB5A3(uint32_t rgba) {
uint32_t r, g, b, a;
uint16_t color;
r = (rgba >> 24) & 0xff;
g = (rgba >> 16) & 0xff;
b = (rgba >> 8) & 0xff;
a = (rgba ) & 0xff;
if (a > 0xe0) {
r = r >> 3;
g = g >> 3;
b = b >> 3;
color = (r << 10) | (g << 5) | b;
color |= 0x8000;
}
else {
r = r >> 4;
g = g >> 4;
b = b >> 4;
a = a >> 5;
color = (a << 12) | (r << 8) | (g << 4) | b;
}
return color;
}
/**
* Convert the specified RGBA data buffer into the RGB5A3 texture format
*
* This routine converts the RGBA data buffer into the RGB5A3 texture format and returns a pointer to the converted buffer.
*
* @param rgbaBuffer Buffer containing the temporarily rendered RGBA data.
* @param bufferWidth Pixel width of the data buffer.
* @param bufferHeight Pixel height of the data buffer.
* @return A pointer to the allocated buffer.
*/
uint32_t* Metaphrasis::convertBufferToRGB5A3(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight) {
uint32_t bufferSize = (bufferWidth * bufferHeight) << 1;
uint32_t* dataBufferRGB5A3 = (uint32_t *)memalign(32, bufferSize);
memset(dataBufferRGB5A3, 0x00, bufferSize);
uint32_t *src = (uint32_t *)rgbaBuffer;
uint16_t *dst = (uint16_t *)dataBufferRGB5A3;
for(uint16_t y = 0; y < bufferHeight; y += 4) {
for(uint16_t x = 0; x < bufferWidth; x += 4) {
for(uint16_t rows = 0; rows < 4; rows++) {
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 0)]);
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 1)]);
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 2)]);
*dst++ = Metaphrasis::convertRGBAToRGB5A3(src[((y + rows) * bufferWidth) + (x + 3)]);
}
}
}
DCFlushRange(dataBufferRGB5A3, bufferSize);
return dataBufferRGB5A3;
}

View File

@ -1,116 +0,0 @@
/*
* Metaphrasis is a static conversion class for transforming RGBA image
* buffers into verious GX texture formats for Wii homebrew development.
* Copyright (C) 2008 Armin Tamzarian
*
* This file is part of Metaphrasis.
*
* Metaphrasis is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Metaphrasis 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Metaphrasis. If not, see <http://www.gnu.org/licenses/>.
*/
/** \mainpage Metaphrasis
*
* \section sec_intro Introduction
*
* Metaphrasis is a static conversion class for transforming RGBA image buffers into verious GX texture formats for Wii homebrew development.
* <br>
* Metaphrasis is written in C++ and makes use of a community standard and newly developed algorithms for conversion of 32-bit RGBA data buffers into various GX texture formats common to both the Gamecube and Wii platforms.
* <p>
* This library was developed in-full by Armin Tamzarian with the support of developers in \#wiibrew on EFnet, Chaosteil of libwiisprite, and DrTwox of GRRLIB.
*
* \section sec_installation_source Installation (Source Code)
*
* -# Extract the Metaphrasis archive.
* -# Copy the contents of the <i>src</i> directory into your project's development path.
* -# Include the Metaphrasis header file in your code using syntax such as the following:
* \code
* #include "Metaphrasis.h"
* \endcode
*
* \section sec_installation_library Installation (Library)
*
* -# Extract the Metaphrasis archive.
* -# Copy the contents of the <i>lib</i> directory into your <i>devKitPro/libogc</i> directory.
* -# Include the Metaphrasis header file in your code using syntax such as the following:
* \code
* #include "Metaphrasis.h"
* \endcode
*
* \section sec_usage Usage
*
* -# Create a buffer full of 32-bit RGBA values noting both the pixel height and width of the buffer.
* -# Call one of the many conversion routines from within your code. (Note: All methods within the Metaphrasis class are static and thus no class instance need be allocated)
* \code
* uint32_t* rgba8Buffer = Metaphrasis::convertBufferToRGBA8(rgbaBuffer, bufferWidth, bufferHeight);
* \endcode
* -# Free your temporary RGBA value buffer if you no longer need said values.
*
* Currently supported conversion routines are as follows:
* \li convertBufferToI4
* \li convertBufferToI8
* \li convertBufferToIA4
* \li convertBufferToIA8
* \li convertBufferToRGBA8
* \li convertBufferToRGB565
* \li convertBufferToRGB5A3
*
* \section sec_license License
*
* Metaphrasis is distributed under the GNU Lesser General Public License.
*
* \section sec_contact Contact
*
* If you have any suggestions, questions, or comments regarding this library feel free to e-mail me at tamzarian1989 [at] gmail [dawt] com.
*/
#ifndef METAPHRASIS_H_
#define METAPHRASIS_H_
#include <gccore.h>
#include <stdint.h>
#include <malloc.h>
#include <string.h>
/*! \class Metaphrasis
* \brief A static conversion class for transforming RGBA image buffers into verious GX texture formats for
* Wii homebrew development.
* \author Armin Tamzarian
* \version 0.1.0
*
* Metaphrasis is a static conversion class for transforming RGBA image buffers into verious GX texture formats for
* Wii homebrew development. Metaphrasis is written in C++ and makes use of a community standard and newly developed
* algorithms for conversion of 32-bit RGBA data buffers into various GX texture formats common to both the Gamecube
* and Wii platforms.
*/
class Metaphrasis {
public:
Metaphrasis();
virtual ~Metaphrasis();
static uint32_t* convertBufferToI4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToI8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToIA4(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToIA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToRGBA8(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToRGB565(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint32_t* convertBufferToRGB5A3(uint32_t* rgbaBuffer, uint16_t bufferWidth, uint16_t bufferHeight);
static uint8_t convertRGBAToIA4(uint32_t rgba);
static uint16_t convertRGBAToIA8(uint32_t rgba);
static uint16_t convertRGBAToRGB565(uint32_t rgba);
static uint16_t convertRGBAToRGB5A3(uint32_t rgba);
};
#endif /*METAPHRASIS_H_*/

View File

@ -46,7 +46,6 @@
#include "video.h"
#include "filelist.h"
#include "input.h"
#include "oggplayer.h"
#include "sigslot.h"
extern FreeTypeGX * fontSystem;
@ -81,12 +80,6 @@ enum
STATE_DISABLED2
};
enum
{
SOUND_PCM,
SOUND_OGG
};
enum
{
IMAGE_TEXTURE,
@ -139,43 +132,6 @@ typedef struct _POINT {
#define EFFECT_SCALE 128
#define EFFECT_COLOR_TRANSITION 256
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
class GuiSound
{
public:
//!Constructor
//!\param s Pointer to the sound data
//!\param l Length of sound data
//!\param t Sound format type (SOUND_PCM or SOUND_OGG)
GuiSound(const u8 * s, int l, int t);
//!Destructor
~GuiSound();
//!Start sound playback
void Play();
//!Stop sound playback
void Stop();
//!Pause sound playback
void Pause();
//!Resume sound playback
void Resume();
//!Checks if the sound is currently playing
//!\return true if sound is playing, false otherwise
bool IsPlaying();
//!Set sound volume
//!\param v Sound volume (0-100)
void SetVolume(int v);
//!Set the sound to loop playback (only applies to OGG)
//!\param l Loop (true to loop)
void SetLoop(bool l);
protected:
const u8 * sound; //!< Pointer to the sound data
int type; //!< Sound format type (SOUND_PCM or SOUND_OGG)
s32 length; //!< Length of sound data
s32 voice; //!< Currently assigned ASND voice channel
s32 volume; //!< Sound volume (0-100)
bool loop; //!< Loop sound playback
};
//!Menu input trigger management. Determine if action is neccessary based on input data by comparing controller input data to a specific trigger element.
class GuiTrigger
{
@ -810,15 +766,6 @@ class GuiButton : public GuiElement
//!\param t Pointer to GuiText object
//!\param n Index of label to set (optional, default is 0)
void SetLabelClick(GuiText* t, int n = 0);
//!Sets the sound to play on over
//!\param s Pointer to GuiSound object
void SetSoundOver(GuiSound * s);
//!Sets the sound to play on hold
//!\param s Pointer to GuiSound object
void SetSoundHold(GuiSound * s);
//!Sets the sound to play on click
//!\param s Pointer to GuiSound object
void SetSoundClick(GuiSound * s);
//!Constantly called to draw the GuiButton
void Draw();
//!Constantly called to allow the GuiButton to respond to updated input data
@ -837,9 +784,6 @@ class GuiButton : public GuiElement
GuiText * labelOver[3]; //!< Label(s) to display for STATE_SELECTED
GuiText * labelHold[3]; //!< Label(s) to display for STATE_HELD
GuiText * labelClick[3]; //!< Label(s) to display for STATE_CLICKED
GuiSound * soundOver; //!< Sound to play for STATE_SELECTED
GuiSound * soundHold; //!< Sound to play for STATE_HELD
GuiSound * soundClick; //!< Sound to play for STATE_CLICKED
};
typedef struct _keytype {
@ -899,8 +843,6 @@ class GuiKeyboard : public GuiWindow
GuiImageData * keyMediumOver;
GuiImageData * keyLarge;
GuiImageData * keyLargeOver;
// GuiSound * keySoundOver;
// GuiSound * keySoundClick;
GuiTrigger * trigA;
int letterPos;
@ -994,8 +936,6 @@ class GuiOptionBrowser : public GuiElement
GuiImageData * arrowUp;
GuiImageData * arrowUpOver;
// GuiSound * btnSoundOver;
// GuiSound * btnSoundClick;
GuiTrigger * trigA;
};
@ -1044,8 +984,6 @@ class GuiFileBrowser : public GuiElement
GuiImageData * scrollbarBox;
GuiImageData * scrollbarBoxOver;
GuiSound * btnSoundOver;
GuiSound * btnSoundClick;
GuiTrigger * trigA;
GuiTrigger * trigHeldA;
};

View File

@ -34,9 +34,6 @@ GuiButton::GuiButton(int w, int h)
labelClick[i] = NULL;
}
soundOver = NULL;
soundHold = NULL;
soundClick = NULL;
selectable = true;
holdable = false;
clickable = true;
@ -109,18 +106,6 @@ void GuiButton::SetLabelClick(GuiText* txt, int n)
labelClick[n] = txt;
if(txt) txt->SetParent(this);
}
void GuiButton::SetSoundOver(GuiSound * snd)
{
soundOver = snd;
}
void GuiButton::SetSoundHold(GuiSound * snd)
{
soundHold = snd;
}
void GuiButton::SetSoundClick(GuiSound * snd)
{
soundClick = snd;
}
/**
* Draw the button on screen
@ -175,9 +160,6 @@ void GuiButton::Update(GuiTrigger * t)
if(this->Rumble())
rumbleRequest[t->chan] = 1;
if(soundOver)
soundOver->Play();
if(effectsOver && !effects)
{
// initiate effects
@ -233,8 +215,6 @@ void GuiButton::Update(GuiTrigger * t)
{
this->SetState(STATE_CLICKED, t->chan);
if(soundClick)
soundClick->Play();
}
}
else if(trigger[i]->type == TRIGGER_BUTTON_ONLY)

View File

@ -65,20 +65,18 @@ GuiCodeboard::GuiCodeboard(char * t, u32 max)
else if(i == 3)
keyTextboxImg[i]->SetPosition(75, 0);
this->Append(keyTextboxImg[i]);
kbText[i] = new GuiText("\0", 20, (GXColor){0, 0, 0, 0xff});
kbText[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
kbText[i]->SetPosition(keyTextboxImg[i]->GetLeft() + keyTextboxImg[i]->GetWidth()/2, 13);
this->Append(kbText[i]);
}
key = new GuiImageData(keyboard_key_png);
keyOver = new GuiImageData(keyboard_key_over_png);
keyMedium = new GuiImageData(keyboard_mediumkey_png);
keyMediumOver = new GuiImageData(keyboard_mediumkey_over_png);
// keySoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM);
// keySoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);
trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigB = new GuiTrigger;
@ -86,7 +84,7 @@ GuiCodeboard::GuiCodeboard(char * t, u32 max)
int distance = 40;
int pos = (width-(3*key->GetWidth()+2*distance))/2;
keyBackImg = new GuiImage(keyMedium);
keyBackOverImg = new GuiImage(keyMediumOver);
keyBackText = new GuiText("i", 40, (GXColor){0, 0, 0, 0xff});
@ -95,8 +93,6 @@ GuiCodeboard::GuiCodeboard(char * t, u32 max)
keyBack->SetImage(keyBackImg);
keyBack->SetImageOver(keyBackOverImg);
keyBack->SetLabel(keyBackText);
// keyBack->SetSoundOver(keySoundOver);
// keyBack->SetSoundClick(keySoundClick);
keyBack->SetTrigger(trigA);
keyBack->SetTrigger(trigB);
keyBack->SetPosition(pos-keyMedium->GetWidth()+key->GetWidth(), 3*(key->GetWidth() + 20)+80);
@ -110,8 +106,6 @@ GuiCodeboard::GuiCodeboard(char * t, u32 max)
keyEmpty->SetImage(keyEmptyImg);
keyEmpty->SetImageOver(keyEmptyOverImg);
keyEmpty->SetLabel(keyEmptyText);
// keyEmpty->SetSoundOver(keySoundOver);
// keyEmpty->SetSoundClick(keySoundClick);
keyEmpty->SetTrigger(trigA);
keyEmpty->SetPosition(pos+2*(key->GetWidth()+distance), 3*(key->GetWidth() + 20)+80);
keyEmpty->SetEffectGrow();
@ -133,8 +127,6 @@ GuiCodeboard::GuiCodeboard(char * t, u32 max)
keyBtn[i][j] = new GuiButton(key->GetWidth(), key->GetHeight());
keyBtn[i][j]->SetImage(keyImg[i][j]);
keyBtn[i][j]->SetImageOver(keyImgOver[i][j]);
// keyBtn[i][j]->SetSoundOver(keySoundOver);
// keyBtn[i][j]->SetSoundClick(keySoundClick);
keyBtn[i][j]->SetTrigger(trigA);
keyBtn[i][j]->SetLabel(keyTxt[i][j]);
keyBtn[i][j]->SetPosition(pos+j*(key->GetWidth()+distance), i*(key->GetWidth() + 20)+80);
@ -168,8 +160,6 @@ GuiCodeboard::~GuiCodeboard()
delete keyOver;
delete keyMedium;
delete keyMediumOver;
// delete keySoundOver;
// delete keySoundClick;
delete trigA;
for(int i=0; i<4; i++)
@ -227,15 +217,15 @@ void GuiCodeboard::Update(GuiTrigger * t)
if(update)
{
txt[0] = keys[i][j].ch;
keyTxt[i][j]->SetText(txt);
}
if(keyBtn[i][j]->GetState() == STATE_CLICKED)
{
if((signed)strlen(kbtextstr) < kbtextmaxlen)
kbtextstr[strlen(kbtextstr)] = keys[i][j].ch;
int letter = strlen(kbtextstr) -1;
string buffer = kbtextstr;
kbText[letter]->SetText(buffer.substr(letter, 1).c_str());

View File

@ -147,9 +147,6 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, bool Br)
keyLarge = new GuiImageData(keyboard_largekey_png);
keyLargeOver = new GuiImageData(keyboard_largekey_over_png);
// keySoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM);
// keySoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);
keyBrImg = new GuiImage(keyMedium);
keyBrOverImg = new GuiImage(keyMediumOver);
keyBrText = new GuiText(tr("Linebreak"), 20, (GXColor){0, 0, 0, 0xff});
@ -157,14 +154,12 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, bool Br)
keyBr->SetImage(keyBrImg);
keyBr->SetImageOver(keyBrOverImg);
keyBr->SetLabel(keyBrText);
// keyBr->SetSoundOver(keySoundOver);
// keyBr->SetSoundClick(keySoundClick);
keyBr->SetTrigger(trigA);
keyBr->SetPosition(0, 4*42+80);
keyBr->SetEffectGrow();
if(br)
this->Append(keyBr);
keyBackImg = new GuiImage(keyMedium);
keyBackOverImg = new GuiImage(keyMediumOver);
keyBackText = new GuiText("Back", 20, (GXColor){0, 0, 0, 0xff});
@ -172,8 +167,6 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, bool Br)
keyBack->SetImage(keyBackImg);
keyBack->SetImageOver(keyBackOverImg);
keyBack->SetLabel(keyBackText);
// keyBack->SetSoundOver(keySoundOver);
// keyBack->SetSoundClick(keySoundClick);
keyBack->SetTrigger(trigA);
keyBack->SetPosition(10*42+40, 0*42+80);
keyBack->SetEffectGrow();
@ -186,8 +179,6 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, bool Br)
keyCaps->SetImage(keyCapsImg);
keyCaps->SetImageOver(keyCapsOverImg);
keyCaps->SetLabel(keyCapsText);
// keyCaps->SetSoundOver(keySoundOver);
// keyCaps->SetSoundClick(keySoundClick);
keyCaps->SetTrigger(trigA);
keyCaps->SetPosition(0, 2*42+80);
keyCaps->SetEffectGrow();
@ -200,8 +191,6 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, bool Br)
keyShift->SetImage(keyShiftImg);
keyShift->SetImageOver(keyShiftOverImg);
keyShift->SetLabel(keyShiftText);
// keyShift->SetSoundOver(keySoundOver);
// keyShift->SetSoundClick(keySoundClick);
keyShift->SetTrigger(trigA);
keyShift->SetPosition(21, 3*42+80);
keyShift->SetEffectGrow();
@ -212,8 +201,6 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, bool Br)
keySpace = new GuiButton(keyLarge->GetWidth(), keyLarge->GetHeight());
keySpace->SetImage(keySpaceImg);
keySpace->SetImageOver(keySpaceOverImg);
// keySpace->SetSoundOver(keySoundOver);
// keySpace->SetSoundClick(keySoundClick);
keySpace->SetTrigger(trigA);
keySpace->SetPosition(0, 4*42+80);
keySpace->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@ -227,8 +214,6 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, bool Br)
keyEmpty->SetImage(keyEmptyImg);
keyEmpty->SetImageOver(keyEmptyOverImg);
keyEmpty->SetLabel(keyEmptyText);
// keyEmpty->SetSoundOver(keySoundOver);
// keyEmpty->SetSoundClick(keySoundClick);
keyEmpty->SetTrigger(trigA);
keyEmpty->SetPosition(10*42+40, 4*42+80);
keyEmpty->SetEffectGrow();
@ -251,8 +236,6 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, bool Br)
keyBtn[i][j] = new GuiButton(key->GetWidth(), key->GetHeight());
keyBtn[i][j]->SetImage(keyImg[i][j]);
keyBtn[i][j]->SetImageOver(keyImgOver[i][j]);
// keyBtn[i][j]->SetSoundOver(keySoundOver);
// keyBtn[i][j]->SetSoundClick(keySoundClick);
keyBtn[i][j]->SetTrigger(trigA);
keyBtn[i][j]->SetLabel(keyTxt[i][j]);
keyBtn[i][j]->SetPosition(j*42+21*i+40, i*42+80);
@ -306,8 +289,6 @@ GuiKeyboard::~GuiKeyboard()
delete keyMediumOver;
delete keyLarge;
delete keyLargeOver;
// delete keySoundOver;
// delete keySoundClick;
delete trigA;
for(int i=0; i<4; i++)
@ -337,7 +318,7 @@ void GuiKeyboard::Update(GuiTrigger * t)
}
bool update = false;
if(keySpace->GetState() == STATE_CLICKED)
{
keySpace->SetState(STATE_SELECTED, t->chan);
@ -345,14 +326,14 @@ void GuiKeyboard::Update(GuiTrigger * t)
{
for(int x = strlen(kbtextstr); x > kbText->GetLetterPos() + letterPos; x--)
kbtextstr[x] = kbtextstr[x-1];
kbtextstr[kbText->GetLetterPos() + letterPos] = ' ';
if(strlen(kbtextstr) > MAX_KEYBOARD_DISPLAY)
letterPos++;
else
kbText->SetLetterPos(kbText->GetLetterPos() +1);
kbText->SetText(GetDisplayText(letterPos, kbtextstr));
textpointerImg->SetPosition(-kbText->GetTextWidth()/2 + kbText->GetTextWidthToPosition(kbText->GetLetterPos()) +1, 10);
}
@ -364,7 +345,7 @@ void GuiKeyboard::Update(GuiTrigger * t)
{
for(int i = kbText->GetLetterPos() + letterPos -1; i < (signed)strlen(kbtextstr) -1; i++)
kbtextstr[i] = kbtextstr[i +1];
kbtextstr[strlen(kbtextstr) -1] = 0;
if(letterPos > 0)
{
@ -376,7 +357,7 @@ void GuiKeyboard::Update(GuiTrigger * t)
kbText->SetText(GetDisplayText(letterPos, kbtextstr));
kbText->SetLetterPos(kbText->GetLetterPos()-1);
}
textpointerImg->SetPosition(-kbText->GetTextWidth()/2 + kbText->GetTextWidthToPosition(kbText->GetLetterPos()) +1, 10);
}
}
@ -387,14 +368,14 @@ void GuiKeyboard::Update(GuiTrigger * t)
{
for(int x = strlen(kbtextstr); x > kbText->GetLetterPos() + letterPos; x--)
kbtextstr[x] = kbtextstr[x-1];
kbtextstr[kbText->GetLetterPos() + letterPos] = '';
if(strlen(kbtextstr) > MAX_KEYBOARD_DISPLAY)
letterPos++;
else
kbText->SetLetterPos(kbText->GetLetterPos() +1);
kbText->SetText(GetDisplayText(letterPos, kbtextstr));
textpointerImg->SetPosition(-kbText->GetTextWidth()/2 + kbText->GetTextWidthToPosition(kbText->GetLetterPos()) +1, 10);
}
@ -403,7 +384,7 @@ void GuiKeyboard::Update(GuiTrigger * t)
{
while (strlen(kbtextstr) > 0)
kbtextstr[strlen(kbtextstr)-1] = 0;
letterPos = 0;
kbText->SetLetterPos(0);
kbText->SetText(GetDisplayText(letterPos, kbtextstr));
@ -425,12 +406,12 @@ void GuiKeyboard::Update(GuiTrigger * t)
else if(textpointerBtn->GetState() == STATE_CLICKED)
{
int pos = kbText->GetTextMaxWidth((int)t->wpad->ir.x-48 - (width - kbText->GetTextWidth()) /2);
if(pos == 0)
textpointerImg->SetPosition(-kbText->GetTextWidth()/2, 10);
else
textpointerImg->SetPosition(-kbText->GetTextWidth()/2 + pos + 1, 10);
textpointerBtn->SetState(STATE_SELECTED, t->chan);
}
@ -463,9 +444,9 @@ void GuiKeyboard::Update(GuiTrigger * t)
{
for(int x = strlen(kbtextstr); x > kbText->GetLetterPos() + letterPos; x--)
kbtextstr[x] = kbtextstr[x-1];
kbtextstr[kbText->GetLetterPos() + letterPos] = keys[i][j].chShift;
if(strlen(kbtextstr) > MAX_KEYBOARD_DISPLAY)
letterPos++;
else
@ -475,9 +456,9 @@ void GuiKeyboard::Update(GuiTrigger * t)
{
for(int x = strlen(kbtextstr); x > kbText->GetLetterPos() + letterPos; x--)
kbtextstr[x] = kbtextstr[x-1];
kbtextstr[kbText->GetLetterPos() + letterPos] = keys[i][j].ch;
if(strlen(kbtextstr) > MAX_KEYBOARD_DISPLAY)
letterPos++;
else
@ -486,7 +467,7 @@ void GuiKeyboard::Update(GuiTrigger * t)
}
kbText->SetText(GetDisplayText(letterPos, kbtextstr));
textpointerImg->SetPosition(-kbText->GetTextWidth()/2 + kbText->GetTextWidthToPosition(kbText->GetLetterPos()) +1, 10);
if(shift)
{
shift ^= 1;
@ -527,7 +508,7 @@ void GuiKeyboard::Update(GuiTrigger * t)
}
else if(t->Down())
this->MoveSelectionVert(1);
if(changed)
{
changed = false;

View File

@ -57,8 +57,6 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l)
arrowUpBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
arrowUpBtn->SetSelectable(false);
arrowUpBtn->SetTrigger(trigA);
// arrowUpBtn->SetSoundOver(btnSoundOver);
// arrowUpBtn->SetSoundClick(btnSoundClick);
arrowDownBtn = new GuiButton(arrowDownImg->GetWidth(), arrowDownImg->GetHeight());
arrowDownBtn->SetParent(this);
@ -67,8 +65,6 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l)
arrowDownBtn->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
arrowDownBtn->SetSelectable(false);
arrowDownBtn->SetTrigger(trigA);
// arrowDownBtn->SetSoundOver(btnSoundOver);
// arrowDownBtn->SetSoundClick(btnSoundClick);
for(int i=0; i<PAGESIZE; i++)
{
@ -89,7 +85,6 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l)
optionBtn[i]->SetImageOver(optionBg[i]);
optionBtn[i]->SetPosition(2,30*i+3);
optionBtn[i]->SetTrigger(trigA);
// optionBtn[i]->SetSoundClick(btnSoundClick);
}
}
@ -117,8 +112,6 @@ GuiOptionBrowser::~GuiOptionBrowser()
delete arrowUpOver;
delete trigA;
// delete btnSoundOver;
// delete btnSoundClick;
for(int i=0; i<PAGESIZE; i++)
{

View File

@ -1,155 +0,0 @@
/****************************************************************************
* libwiigui
*
* Tantric 2009
*
* gui_sound.cpp
*
* GUI class definitions
***************************************************************************/
#include "gui.h"
/**
* Constructor for the GuiSound class.
*/
GuiSound::GuiSound(const u8 * snd, s32 len, int t)
{
sound = snd;
length = len;
type = t;
voice = -1;
volume = 100;
loop = false;
}
/**
* Destructor for the GuiSound class.
*/
GuiSound::~GuiSound()
{
#ifndef NO_SOUND
if(type == SOUND_OGG)
StopOgg();
#endif
}
void GuiSound::Play()
{
#ifndef NO_SOUND
int vol;
switch(type)
{
case SOUND_PCM:
vol = 255*(volume/100.0);
voice = ASND_GetFirstUnusedVoice();
if(voice >= 0)
ASND_SetVoice(voice, VOICE_STEREO_16BIT, 48000, 0,
(u8 *)sound, length, vol, vol, NULL);
break;
case SOUND_OGG:
voice = 0;
if(loop)
PlayOgg((char *)sound, length, 0, OGG_INFINITE_TIME);
else
PlayOgg((char *)sound, length, 0, OGG_ONE_TIME);
SetVolumeOgg(255*(volume/100.0));
break;
}
#endif
}
void GuiSound::Stop()
{
#ifndef NO_SOUND
if(voice < 0)
return;
switch(type)
{
case SOUND_PCM:
ASND_StopVoice(voice);
break;
case SOUND_OGG:
StopOgg();
break;
}
#endif
}
void GuiSound::Pause()
{
#ifndef NO_SOUND
if(voice < 0)
return;
switch(type)
{
case SOUND_PCM:
ASND_PauseVoice(voice, 1);
break;
case SOUND_OGG:
PauseOgg(1);
break;
}
#endif
}
void GuiSound::Resume()
{
#ifndef NO_SOUND
if(voice < 0)
return;
switch(type)
{
case SOUND_PCM:
ASND_PauseVoice(voice, 0);
break;
case SOUND_OGG:
PauseOgg(0);
break;
}
#endif
}
bool GuiSound::IsPlaying()
{
if(ASND_StatusVoice(voice) == SND_WORKING || ASND_StatusVoice(voice) == SND_WAITING)
return true;
else
return false;
}
void GuiSound::SetVolume(int vol)
{
#ifndef NO_SOUND
volume = vol;
if(voice < 0)
return;
int newvol = 255*(volume/100.0);
switch(type)
{
case SOUND_PCM:
ASND_ChangeVolumeVoice(voice, newvol, newvol);
break;
case SOUND_OGG:
SetVolumeOgg(255*(volume/100.0));
break;
}
#endif
}
void GuiSound::SetLoop(bool l)
{
loop = l;
}

View File

@ -1,539 +0,0 @@
/*
Copyright (c) 2008 Francisco Muñoz 'Hermes' <www.elotrolado.net>
All rights reserved.
Proper (standard) vorbis usage by Tantric, 2009
Threading modifications/corrections by Tantric, 2009
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
- The names of the contributors may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NO_SOUND
#include "oggplayer.h"
#include <gccore.h>
#include <unistd.h>
#include <string.h>
/* functions to read the Ogg file from memory */
static struct
{
char *mem;
int size;
int pos;
} file[4];
static int f_read(void * punt, int bytes, int blocks, int *f)
{
int b;
int c;
int d;
if (bytes * blocks <= 0)
return 0;
blocks = bytes * blocks;
c = 0;
while (blocks > 0)
{
b = blocks;
if (b > 4096)
b = 4096;
if (*f >= 0x666 && *f <= 0x669)
{
d = (*f) - 0x666;
if (file[d].size == 0)
return -1;
if ((file[d].pos + b) > file[d].size)
b = file[d].size - file[d].pos;
if (b > 0)
{
memcpy(punt, file[d].mem + file[d].pos, b);
file[d].pos += b;
}
}
else
b = read(*f, ((char *) punt) + c, b);
if (b <= 0)
{
return c / bytes;
}
c += b;
blocks -= b;
}
return c / bytes;
}
static int f_seek(int *f, ogg_int64_t offset, int mode)
{
if(f==NULL) return(-1);
int k, d;
mode &= 3;
if (*f >= 0x666 && *f <= 0x669)
{
d = (*f) - 0x666;
k = 0;
if (file[d].size == 0)
return -1;
if (mode == 0)
{
if ((offset) >= file[d].size)
{
file[d].pos = file[d].size;
k = -1;
}
else if ((offset) < 0)
{
file[d].pos = 0;
k = -1;
}
else
file[d].pos = offset;
}
if (mode == 1)
{
if ((file[d].pos + offset) >= file[d].size)
{
file[d].pos = file[d].size;
k = -1;
}
else if ((file[d].pos + offset) < 0)
{
file[d].pos = 0;
k = -1;
}
else
file[d].pos += offset;
}
if (mode == 2)
{
if ((file[d].size + offset) >= file[d].size)
{
file[d].pos = file[d].size;
k = -1;
}
else if ((file[d].size + offset) < 0)
{
file[d].pos = 0;
k = -1;
}
else
file[d].pos = file[d].size + offset;
}
}
else
k = lseek(*f, (int) offset, mode);
if (k < 0)
k = -1;
else
k = 0;
return k;
}
static int f_close(int *f)
{
int d;
if (*f >= 0x666 && *f <= 0x669)
{
d = (*f) - 0x666;
file[d].size = 0;
file[d].pos = 0;
if (file[d].mem)
{
file[d].mem = (void *) 0;
}
return 0;
}
else
return close(*f);
return 0;
}
static long f_tell(int *f)
{
int k, d;
if (*f >= 0x666 && *f <= 0x669)
{
d = (*f) - 0x666;
k = file[d].pos;
}
else
k = lseek(*f, 0, 1);
return (long) k;
}
static int mem_open(char * ogg, int size)
{
static int one = 1;
int n;
if (one)
{
one = 0;
for (n = 0; n < 4; n++)
file[n].size = 0;
}
for (n = 0; n < 4; n++)
{
if (file[n].size == 0)
{
file[n].mem = ogg;
file[n].size = size;
file[n].pos = 0;
return (0x666 + n);
}
}
return -1;
}
static int mem_close(int fd)
{
if (fd >= 0x666 && fd <= 0x669) // it is a memory file descriptor?
{
fd -= 0x666;
file[fd].size = 0;
return 0;
}
else
return f_close(&fd);
}
static ov_callbacks callbacks = {
(size_t (*)(void *, size_t, size_t, void *)) f_read,
(int (*)(void *, ogg_int64_t, int)) f_seek,
(int (*)(void *)) f_close,
(long (*)(void *)) f_tell
};
/* OGG control */
#define READ_SAMPLES 4096 // samples that it must read before to send
#define MAX_PCMOUT 4096 // minimum size to read ogg samples
typedef struct
{
OggVorbis_File vf;
vorbis_info *vi;
int current_section;
// OGG file operation
int fd;
int mode;
int eof;
int flag;
int volume;
int seek_time;
/* OGG buffer control */
short pcmout[2][READ_SAMPLES + MAX_PCMOUT * 2]; /* take 4k out of the data segment, not the stack */
int pcmout_pos;
int pcm_indx;
} private_data_ogg;
static private_data_ogg private_ogg;
// OGG thread control
#define STACKSIZE 8192
static u8 oggplayer_stack[STACKSIZE];
static lwpq_t oggplayer_queue = LWP_TQUEUE_NULL;
static lwp_t h_oggplayer = LWP_THREAD_NULL;
static int ogg_thread_running = 0;
static void ogg_add_callback(int voice)
{
if (!ogg_thread_running)
{
ASND_StopVoice(0);
return;
}
if (private_ogg.flag & 128)
return; // Ogg is paused
if (private_ogg.pcm_indx >= READ_SAMPLES)
{
if (ASND_AddVoice(0,
(void *) private_ogg.pcmout[private_ogg.pcmout_pos],
private_ogg.pcm_indx << 1) == 0)
{
private_ogg.pcmout_pos ^= 1;
private_ogg.pcm_indx = 0;
private_ogg.flag = 0;
LWP_ThreadSignal(oggplayer_queue);
}
}
else
{
if (private_ogg.flag & 64)
{
private_ogg.flag &= ~64;
LWP_ThreadSignal(oggplayer_queue);
}
}
}
static void * ogg_player_thread(private_data_ogg * priv)
{
int first_time = 1;
long ret;
//init
LWP_InitQueue(&oggplayer_queue);
priv[0].vi = ov_info(&priv[0].vf, -1);
ASND_Pause(0);
priv[0].pcm_indx = 0;
priv[0].pcmout_pos = 0;
priv[0].eof = 0;
priv[0].flag = 0;
priv[0].current_section = 0;
ogg_thread_running = 1;
while (!priv[0].eof && ogg_thread_running)
{
if (priv[0].flag)
LWP_ThreadSleep(oggplayer_queue); // wait only when i have samples to send
if (priv[0].flag == 0) // wait to all samples are sent
{
if (ASND_TestPointer(0, priv[0].pcmout[priv[0].pcmout_pos])
&& ASND_StatusVoice(0) != SND_UNUSED)
{
priv[0].flag |= 64;
continue;
}
if (priv[0].pcm_indx < READ_SAMPLES)
{
priv[0].flag = 3;
if (priv[0].seek_time >= 0)
{
ov_time_seek(&priv[0].vf, priv[0].seek_time);
priv[0].seek_time = -1;
}
ret
= ov_read(
&priv[0].vf,
(void *) &priv[0].pcmout[priv[0].pcmout_pos][priv[0].pcm_indx],
MAX_PCMOUT,/*0,2,1,*/&priv[0].current_section);
priv[0].flag &= 192;
if (ret == 0)
{
/* EOF */
if (priv[0].mode & 1)
ov_time_seek(&priv[0].vf, 0); // repeat
else
priv[0].eof = 1; // stops
}
else if (ret < 0)
{
/* error in the stream. Not a problem, just reporting it in
case we (the app) cares. In this case, we don't. */
if (ret != OV_HOLE)
{
if (priv[0].mode & 1)
ov_time_seek(&priv[0].vf, 0); // repeat
else
priv[0].eof = 1; // stops
}
}
else
{
/* we don't bother dealing with sample rate changes, etc, but
you'll have to*/
priv[0].pcm_indx += ret >> 1; //get 16 bits samples
}
}
else
priv[0].flag = 1;
}
if (priv[0].flag == 1)
{
if (ASND_StatusVoice(0) == SND_UNUSED || first_time)
{
first_time = 0;
if (priv[0].vi->channels == 2)
{
ASND_SetVoice(0, VOICE_STEREO_16BIT, priv[0].vi->rate, 0,
(void *) priv[0].pcmout[priv[0].pcmout_pos],
priv[0].pcm_indx << 1, priv[0].volume,
priv[0].volume, ogg_add_callback);
priv[0].pcmout_pos ^= 1;
priv[0].pcm_indx = 0;
priv[0].flag = 0;
}
else
{
ASND_SetVoice(0, VOICE_MONO_16BIT, priv[0].vi->rate, 0,
(void *) priv[0].pcmout[priv[0].pcmout_pos],
priv[0].pcm_indx << 1, priv[0].volume,
priv[0].volume, ogg_add_callback);
priv[0].pcmout_pos ^= 1;
priv[0].pcm_indx = 0;
priv[0].flag = 0;
}
}
}
usleep(100);
}
ov_clear(&priv[0].vf);
priv[0].fd = -1;
priv[0].pcm_indx = 0;
return 0;
}
void StopOgg()
{
ASND_StopVoice(0);
ogg_thread_running = 0;
if(h_oggplayer != LWP_THREAD_NULL)
{
if(oggplayer_queue != LWP_TQUEUE_NULL)
LWP_ThreadSignal(oggplayer_queue);
LWP_JoinThread(h_oggplayer, NULL);
h_oggplayer = LWP_THREAD_NULL;
}
if(oggplayer_queue != LWP_TQUEUE_NULL)
{
LWP_CloseQueue(oggplayer_queue);
oggplayer_queue = LWP_TQUEUE_NULL;
}
}
int PlayOgg(char * buf, int buflen, int time_pos, int mode)
{
StopOgg();
private_ogg.fd = mem_open(buf, buflen);
if (private_ogg.fd < 0)
{
private_ogg.fd = -1;
return -1;
}
private_ogg.mode = mode;
private_ogg.eof = 0;
private_ogg.volume = 127;
private_ogg.flag = 0;
private_ogg.seek_time = -1;
if (time_pos > 0)
private_ogg.seek_time = time_pos;
if (ov_open_callbacks((void *) &private_ogg.fd, &private_ogg.vf, NULL, 0, callbacks) < 0)
{
mem_close(private_ogg.fd); // mem_close() can too close files from devices
private_ogg.fd = -1;
ogg_thread_running = 0;
return -1;
}
if (LWP_CreateThread(&h_oggplayer, (void *) ogg_player_thread,
&private_ogg, oggplayer_stack, STACKSIZE, 80) == -1)
{
ogg_thread_running = 0;
ov_clear(&private_ogg.vf);
private_ogg.fd = -1;
return -1;
}
return 0;
}
void PauseOgg(int pause)
{
if (pause)
{
private_ogg.flag |= 128;
}
else
{
if (private_ogg.flag & 128)
{
private_ogg.flag |= 64;
private_ogg.flag &= ~128;
if (ogg_thread_running > 0)
{
LWP_ThreadSignal(oggplayer_queue);
}
}
}
}
int StatusOgg()
{
if (ogg_thread_running == 0)
return -1; // Error
else if (private_ogg.eof)
return 255; // EOF
else if (private_ogg.flag & 128)
return 2; // paused
else
return 1; // running
}
void SetVolumeOgg(int volume)
{
private_ogg.volume = volume;
ASND_ChangeVolumeVoice(0, volume, volume);
}
s32 GetTimeOgg()
{
int ret;
if (ogg_thread_running == 0 || private_ogg.fd < 0)
return 0;
ret = ((s32) ov_time_tell(&private_ogg.vf));
if (ret < 0)
ret = 0;
return ret;
}
void SetTimeOgg(s32 time_pos)
{
if (time_pos >= 0)
private_ogg.seek_time = time_pos;
}
#endif

View File

@ -1,174 +0,0 @@
/*
Copyright (c) 2008 Francisco Muñoz 'Hermes' <www.elotrolado.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
- The names of the contributors may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NO_SOUND
#ifndef __OGGPLAYER_H__
#define __OGGPLAYER_H__
#include <asndlib.h>
#include <tremor/ivorbiscodec.h>
#include <tremor/ivorbisfile.h>
#ifdef __cplusplus
extern "C"
{
#endif
#define OGG_ONE_TIME 0
#define OGG_INFINITE_TIME 1
#define OGG_STATUS_RUNNING 1
#define OGG_STATUS_ERR -1
#define OGG_STATUS_PAUSED 2
#define OGG_STATUS_EOF 255
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Player OGG functions */
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* int PlayOgg(int fd, int time_pos, int mode);
Play an Ogg file. This file can be loaded from memory (mem_open(void *ogg, int size_ogg)) or from device with open("device:file.ogg",O_RDONLY,0);
NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail.
-- Params ---
fd: file descriptor from open() or mem_open()
time_pos: initial time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds
mode: Use OGG_ONE_TIME or OGG_INFINITE_TIME. When you use OGG_ONE_TIME the sound stops and StatusOgg() return OGG_STATUS_EOF
return: 0- Ok, -1 Error
*/
int PlayOgg(char * buf, int buflen, int time_pos, int mode);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void StopOgg();
Stop an Ogg file.
NOTE: The file is closed and the player thread is released
-- Params ---
*/
void StopOgg();
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void PauseOgg(int pause);
Pause an Ogg file.
-- Params ---
pause: 0 -> continue, 1-> pause
*/
void PauseOgg(int pause);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* int StatusOgg();
Return the Ogg status
-- Params ---
return: OGG_STATUS_RUNNING
OGG_STATUS_ERR -> not initialized?
OGG_STATUS_PAUSED
OGG_STATUS_EOF -> player stopped by End Of File
*/
int StatusOgg();
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void SetVolumeOgg(int volume);
Set the Ogg playing volume.
NOTE: it change the volume of voice 0 (used for the Ogg player)
-- Params ---
volume: 0 to 255 (max)
*/
void SetVolumeOgg(int volume);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* s32 GetTimeOgg();
Return the Ogg time from the starts of the file
-- Params ---
return: 0 -> Ok or error condition (you must ignore this value)
>0 -> time in milliseconds from the starts
*/
s32 GetTimeOgg();
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void SetTimeOgg(s32 time_pos);
Set the time position
NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail.
-- Params ---
time_pos: time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds
*/
void SetTimeOgg(s32 time_pos);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@ -16,6 +16,7 @@
- BUGFIX: only show 'launch priiloader' in external loaders prompt,
if priiloader is really installed
- changed loading address from 0x81230000 to 0x81330000
- removed all sound related code
- updated PNGu
//rev37: