- Fixed MP3 play bug on the psp. MP3 files need to have NO Id3v2 tag, or they won't play. Also, volume control is broken
- added dt to moving W's easter egg movement.
- Added fullscreen for windows version
- other stuff ?
This commit is contained in:
wagic.the.homebrew
2008-11-19 12:21:23 +00:00
parent 2434571fa2
commit 349de34106
27 changed files with 1270 additions and 1012 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ OBJS = src/JApp.o src/JGBKFont.o \
src/tinyxml/tinystr.o src/tinyxml/tinyxml.o \ src/tinyxml/tinystr.o src/tinyxml/tinyxml.o \
src/tinyxml/tinyxmlparser.o src/tinyxml/tinyxmlerror.o \ src/tinyxml/tinyxmlparser.o src/tinyxml/tinyxmlerror.o \
src/main.o src/vram.o \ src/main.o src/vram.o \
src/JAudio.o src/JCooleyesMP3.o \ src/JAudio.o src/JMP3.o \
src/decoder_prx.o \ src/decoder_prx.o \
src/Encoding.o src/JTTFont.o \ src/Encoding.o src/JTTFont.o \
src/JMD2Model.o src/JOBJModel.o \ src/JMD2Model.o src/JOBJModel.o \
@@ -23,7 +23,7 @@ LIBDIR = lib/psp
CFLAGS = -O2 -G0 -Wall -DDEVHOOK -DPSPFW3XX CFLAGS = -O2 -G0 -Wall -DDEVHOOK -DPSPFW3XX
LIBS = -lgif -lfreetype -ljpeg -lpng -lz -lmikmod -lpsppower -lpspmpeg -lpspaudiocodec -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lm -lstdc++ LIBS = -lgif -lfreetype -ljpeg -lpng -lz -lmikmod -lpsppower -lpspmpeg -lpspaudiocodec -lpspaudiolib -lpspaudio -lpspmp3 -lpspgum -lpspgu -lpsprtc -lm -lstdc++
include $(PSPSDK)/lib/build.mak include $(PSPSDK)/lib/build.mak
+5 -5
View File
@@ -73,15 +73,15 @@ void setChannelFlag(int channel, int flag);
#define SAMPLE_PER_FRAME 1152 #define SAMPLE_PER_FRAME 1152
#define MAX_MP3_FILE 2 #define MAX_MP3_FILE 2
class JCooleyesMP3; class JMP3;
void PlayMP3(JCooleyesMP3 *mp3, bool looping = false); void PlayMP3(JMP3 *mp3, bool looping = false);
void StopMP3(); void StopMP3();
void ResumeMP3(); void ResumeMP3(JMP3 *mp3);
bool InitMP3Decoder();
void ReleaseMP3Decoder(); void ReleaseMP3Decoder();
void MP3AudioOutCallback(void* buf, unsigned int length, void *userdata); void MP3AudioOutCallback(void* buf, unsigned int length, void *userdata);
int decodeThread2(SceSize args, void *argp);
extern bool g_MP3DecoderOK; extern bool g_MP3DecoderOK;
#endif #endif
+59
View File
@@ -0,0 +1,59 @@
//-------------------------------------------------------------------------------------
//
// JGE is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// Copyright (c) 2008 Alexander Berl <raphael@fx-world.org>
// Copyright (c) 2008 WilLoW :--) <wagic.the.homebrew@gmail.com>
//
//-------------------------------------------------------------------------------------
#ifndef _JMP3_
#define _JMP3_
#include <string>
class JMP3
{
protected:
static bool loadModules();
int m_volume;
int m_samplesPlayed;
int m_inBufferSize, m_outBufferSize;
char m_inBuffer[16*1024]; // ?
short m_outBuffer[16*(1152/2)]; //?
int m_numChannels;
int m_samplingRate;
bool m_loop;
int m_lastDecoded;
int m_playTime;
public:
int m_paused;
int m_channel;
int m_mp3Handle;
int m_fileHandle;
static JMP3* mInstance;
JMP3(const std::string& filename, int inBufferSize= 16*1024, int outBufferSize =16*(1152/2));
~JMP3();
static void init();
bool fillBuffers();
bool load(const std::string& filename, int inBufferSize, int outBufferSize);
bool unload();
bool update();
bool play();
bool pause();
bool setLoop(bool loop);
int setVolume(int volume);
int playTime() const;
int playTimeMinutes();
int playTimeSeconds();
};
#endif
+3 -2
View File
@@ -36,7 +36,7 @@
#include <psprtc.h> #include <psprtc.h>
#include "JAudio.h" #include "JAudio.h"
#include "JCooleyesMP3.h" #include "JMP3.h"
#endif #endif
@@ -47,11 +47,12 @@ class JMusic
public: public:
JMusic(); JMusic();
~JMusic(); ~JMusic();
void Update();
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs
#else #else
JCooleyesMP3* mTrack; JMP3* mTrack;
#endif #endif
}; };
+1
View File
@@ -60,6 +60,7 @@
#define SCREEN_WIDTH_F 480.0f #define SCREEN_WIDTH_F 480.0f
#define SCREEN_HEIGHT_F 272.0f #define SCREEN_HEIGHT_F 272.0f
#ifdef WIN32 #ifdef WIN32
// #define DEFAULT_BLEND BLEND_DEFAULT // #define DEFAULT_BLEND BLEND_DEFAULT
// #define BLEND_OPTION_ADD BLEND_COLORADD // #define BLEND_OPTION_ADD BLEND_COLORADD
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+42 -97
View File
@@ -16,7 +16,7 @@
#include "../include/JGE.h" #include "../include/JGE.h"
#include "../include/JAudio.h" #include "../include/JAudio.h"
#include "../include/JCooleyesMP3.h" #include "../include/JMP3.h"
#include "../include/JFileSystem.h" #include "../include/JFileSystem.h"
#include "../include/decoder_prx.h" #include "../include/decoder_prx.h"
@@ -29,7 +29,7 @@ short g_DecodedDataOutputBuffer[SAMPLE_PER_FRAME<<2] __attribute__((aligned(64))
bool g_MP3DecoderOK = false; bool g_MP3DecoderOK = false;
bool g_GotEDRAM; bool g_GotEDRAM;
JCooleyesMP3* g_CurrentMP3; JMP3* g_CurrentMP3;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@@ -38,7 +38,7 @@ WAVDATA currentWav[NUMBER_WAV_CHANNELS]; //
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载, memLoad-是否加载至内 char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载, memLoad-是否加载至内磥E
{ {
JFileSystem* fileSystem = JFileSystem::GetInstance(); JFileSystem* fileSystem = JFileSystem::GetInstance();
@@ -172,7 +172,7 @@ void releaseWaveData(WAVDATA* p_wav) // WAVE
} }
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
void audioOutCallback(int channel, void* buf, unsigned int length) // 各通道回 void audioOutCallback(int channel, void* buf, unsigned int length) // 各通道回祦E
{ {
WAVDATA* p_wav = NULL; WAVDATA* p_wav = NULL;
memset(buf, 0, 4096); memset(buf, 0, 4096);
@@ -387,122 +387,67 @@ void audioInit() //
memset(&currentWav[i], 0, sizeof(WAVDATA)); memset(&currentWav[i], 0, sizeof(WAVDATA));
p_currentWav[i] = NULL; p_currentWav[i] = NULL;
} }
pspAudioInit(); JMP3::init();
pspAudioSetChannelCallback(0, audioOutCallback_0, NULL);
pspAudioSetChannelCallback(1, audioOutCallback_1, NULL);
pspAudioSetChannelCallback(2, audioOutCallback_2, NULL);
//pspAudioSetChannelCallback(3, audioOutCallback_3, NULL);
pspAudioSetChannelCallback(3, MP3AudioOutCallback, NULL);
InitMP3Decoder();
} }
void audioDestroy() void audioDestroy()
{ {
ReleaseMP3Decoder();
pspAudioEnd();
}
//////////////////////////////////////////////////////////////////////////
void MP3AudioOutCallback(void* buf, unsigned int length, void *userdata)
{
// PSP_NUM_AUDIO_SAMPLES is 1024, 16bit samples (short), 2 channels for stereo sound
memset(buf, 0, PSP_NUM_AUDIO_SAMPLES<<2);
if (g_CurrentMP3 != NULL)
g_CurrentMP3->FeedAudioData(buf, length);
} }
int mp3thread = 0;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void PlayMP3(JCooleyesMP3 *mp3, bool looping) void PlayMP3(JMP3 *mp3, bool looping)
{ {
if (g_MP3DecoderOK) if (mp3thread) StopMP3();
{ JMP3::mInstance = mp3;
g_CurrentMP3 = mp3; mp3->setLoop(looping);
mp3->InitBuffers(g_MP3CodecBuffer, g_DecoderBuffer, g_DecodedDataOutputBuffer); mp3->play();
mp3->Play(looping); mp3thread = sceKernelCreateThread("decodeThread2", decodeThread2, 0x12, 0xFA0, 0, 0);
} printf("thread id : %i\n", mp3thread);
sceKernelStartThread(mp3thread, 0, NULL);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void StopMP3() void StopMP3()
{ {
if (g_CurrentMP3 != NULL) printf("stop 1\n");
{ JMP3 * mp3 = JMP3::mInstance;
g_CurrentMP3->Stop(); printf("stop 2\n");
} if (mp3){
printf("stop 3\n");
mp3->pause();
printf("stop 4\n");
sceKernelWaitThreadEnd(mp3thread, NULL);
printf("stop 5\n");
sceKernelDeleteThread(mp3thread);
printf("stop 6\n");
mp3->unload();
printf("stop 7\n");
JMP3::mInstance = NULL;
mp3thread = 0;
}
printf("stop 8\n");
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void ResumeMP3() void ResumeMP3(JMP3 * mp3)
{ {
if (g_CurrentMP3 != NULL) mp3->play();
{
g_CurrentMP3->Resume();
}
} }
////////////////////////////////////////////////////////////////////////// int decodeThread2(SceSize args, void *argp){
bool InitMP3Decoder() JMP3 * mp3 = NULL;
{ while((mp3 = JMP3::mInstance) && !mp3->m_paused){
int result; mp3->update();
// if (sceKernelDevkitVersion() == 0x01050001)
// {
// LoadStartModule("flash0:/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL);
// LoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
// }
// else
// {
// sceUtilityLoadAvModule(PSP_AV_MODULE_AVCODEC);
// }
// result = pspSdkLoadStartModule("flash0:/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL);
// result = pspSdkLoadStartModule("flash0:/kd/videocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
// result = pspSdkLoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
// result = pspSdkLoadStartModule("flash0:/kd/mpegbase.prx", PSP_MEMORY_PARTITION_KERNEL);
// result = pspSdkLoadStartModule("flash0:/kd/mpeg_vsh.prx", PSP_MEMORY_PARTITION_USER);
//
// pspSdkFixupImports(result);
prx_static_init();
sceMpegInit();
memset(g_MP3CodecBuffer, 0, sizeof(g_MP3CodecBuffer));
if ( sceAudiocodecCheckNeedMem(g_MP3CodecBuffer, 0x1002) < 0 )
return false;
if ( sceAudiocodecGetEDRAM(g_MP3CodecBuffer, 0x1002) < 0 )
return false;
g_GotEDRAM = true;
if ( sceAudiocodecInit(g_MP3CodecBuffer, 0x1002) < 0 )
return false;
g_MP3DecoderOK = true;
return true;
//sceKernelDelayThread(10000);
}
return 0;
} }
//////////////////////////////////////////////////////////////////////////
void ReleaseMP3Decoder()
{
if ( g_GotEDRAM )
sceAudiocodecReleaseEDRAM(g_MP3CodecBuffer);
}
+233
View File
@@ -0,0 +1,233 @@
#include <pspkernel.h>
#include <pspdebug.h>
#include <stdio.h>
#include <pspaudio.h>
#include <pspmp3.h>
#include <psputility.h>
#include "../include/JAudio.h"
#include "../include/JFileSystem.h"
#include "../include/JMP3.h"
JMP3* JMP3::mInstance = NULL;
void JMP3::init() {
loadModules();
}
JMP3::JMP3(const std::string& filename, int inBufferSize, int outBufferSize) :
m_volume(PSP_AUDIO_VOLUME_MAX), m_paused(true), m_samplesPlayed(0) {
load(filename, inBufferSize,outBufferSize);
}
JMP3::~JMP3() {
unload();
}
bool JMP3::loadModules() {
int loadAvCodec = sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC);
if (loadAvCodec < 0) {
return false;
}
int loadMp3 = sceUtilityLoadModule(PSP_MODULE_AV_MP3);
if (loadMp3 < 0) {
return false;
}
return true;
}
bool JMP3::fillBuffers() {
SceUChar8* dest;
SceInt32 length;
SceInt32 pos;
int ret = sceMp3GetInfoToAddStreamData(m_mp3Handle, &dest, &length, &pos);
if (ret < 0)
return false;
if (sceIoLseek32(m_fileHandle, pos, SEEK_SET) < 0) {
return false;
}
int readLength = sceIoRead(m_fileHandle, dest, length);
if (readLength < 0)
return false;
ret = sceMp3NotifyAddStreamData(m_mp3Handle, readLength);
if (ret < 0)
return false;
return true;
}
bool JMP3::load(const std::string& filename, int inBufferSize, int outBufferSize) {
printf("load\n");
m_inBufferSize = inBufferSize;
printf("1\n");
//m_inBuffer = new char[m_inBufferSize];
//if (!m_inBuffer)
// return false;
m_outBufferSize = outBufferSize;
printf("2\n");
//m_outBuffer = new short[outBufferSize];
//if (!m_outBuffer)
// return false;
printf("3:%s\n",filename.c_str());
m_fileHandle = sceIoOpen(filename.c_str(), PSP_O_RDONLY, 0777);
if (m_fileHandle < 0)
return false;
printf("4\n");
int ret = sceMp3InitResource();
if (ret < 0)
return false;
SceMp3InitArg initArgs;
int fileSize = sceIoLseek32(m_fileHandle, 0, SEEK_END);
sceIoLseek32(m_fileHandle, 0, SEEK_SET);
unsigned char* testbuffer = new unsigned char[7456];
sceIoRead(m_fileHandle, testbuffer, 7456);
delete testbuffer;
initArgs.unk1 = 0;
initArgs.unk2 = 0;
initArgs.mp3StreamStart = 0;
initArgs.mp3StreamEnd = fileSize;
initArgs.mp3BufSize = m_inBufferSize;
initArgs.mp3Buf = (SceVoid*) m_inBuffer;
initArgs.pcmBufSize = m_outBufferSize;
initArgs.pcmBuf = (SceVoid*) m_outBuffer;
printf("5\n");
m_mp3Handle = sceMp3ReserveMp3Handle(&initArgs);
if (m_mp3Handle < 0)
return false;
// Alright we are all set up, let's fill the first buffer.
printf("5.5\n");
bool _filled= fillBuffers();
if (! _filled) return false;
printf("end = %i, bufsize = %i, outSize = %i\n", fileSize, m_inBufferSize, m_outBufferSize);
// Start this bitch up!
printf("6\n");
int start = sceMp3Init(m_mp3Handle);
if (start < 0)
return false;
printf("7\n");
m_numChannels = sceMp3GetMp3ChannelNum(m_mp3Handle);
printf("8\n");
m_samplingRate = sceMp3GetSamplingRate(m_mp3Handle);
return true;
}
bool JMP3::unload() {
printf("unload 1\n");
if (m_channel >= 0)
sceAudioSRCChRelease();
printf("unload 2\n");
sceMp3ReleaseMp3Handle(m_mp3Handle);
printf("unload 3\n");
sceMp3TermResource();
printf("unload 4\n");
sceIoClose(m_fileHandle);
printf("unload 5\n");
//delete[] m_inBuffer;
printf("unload 6\n");
//delete[] m_outBuffer;
printf("unload 7\n");
return true;
}
bool JMP3::update() {
if (!m_paused) {
if (sceMp3CheckStreamDataNeeded(m_mp3Handle) > 0) {
fillBuffers();
}
short* tempBuffer;
int numDecoded = 0;
while (true) {
numDecoded = sceMp3Decode(m_mp3Handle, &tempBuffer);
if (numDecoded > 0)
break;
int ret = sceMp3CheckStreamDataNeeded(m_mp3Handle);
if (ret <= 0)
break;
fillBuffers();
}
// Okay, let's see if we can't get something outputted :/
if (numDecoded == 0 || numDecoded == 0x80671402) {
sceMp3ResetPlayPosition(m_mp3Handle);
if (!m_loop)
m_paused = true;
m_samplesPlayed = 0;
} else {
if (m_channel < 0 || m_lastDecoded != numDecoded) {
if (m_channel >= 0)
sceAudioSRCChRelease();
m_channel = sceAudioSRCChReserve(numDecoded / (2 * m_numChannels), m_samplingRate, m_numChannels);
}
// Output
m_samplesPlayed += sceAudioSRCOutputBlocking(m_volume, tempBuffer);
m_playTime = (m_samplingRate > 0) ? (m_samplesPlayed / m_samplingRate) : 0;
}
}
return true;
}
bool JMP3::play() {
return (m_paused = false);
}
bool JMP3::pause() {
return (m_paused = true);
}
bool JMP3::setLoop(bool loop) {
sceMp3SetLoopNum(m_mp3Handle, (loop == true) ? -1 : 0);
return (m_loop = loop);
}
int JMP3::setVolume(int volume) {
return (m_volume = volume);
}
int JMP3::playTime() const {
return m_playTime;
}
int JMP3::playTimeMinutes() {
return m_playTime / 60;
}
int JMP3::playTimeSeconds() {
return m_playTime % 60;
}
+14 -43
View File
@@ -10,8 +10,9 @@
#include "../include/JSoundSystem.h" #include "../include/JSoundSystem.h"
#include "../include/JAudio.h" #include "../include/JAudio.h"
#include "../include/JCooleyesMP3.h" #include "../include/JMP3.h"
#include <string>
using std::string;
JMusic::JMusic() JMusic::JMusic()
{ {
@@ -26,6 +27,10 @@ JMusic::~JMusic()
delete mTrack; delete mTrack;
} }
void JMusic::Update(){
//if (mTrack) mTrack->update();
}
JSample::JSample() JSample::JSample()
{ {
mSample = NULL; mSample = NULL;
@@ -93,29 +98,17 @@ void JSoundSystem::DestroySoundSystem()
JMusic *JSoundSystem::LoadMusic(const char *fileName) JMusic *JSoundSystem::LoadMusic(const char *fileName)
{ {
//char s[strlen(fileName)+1]; string s = "Res/";
//strcpy(s, fileName); s.append(fileName);
JMusic *music = new JMusic(); JMusic *music = new JMusic();
if (music) if (music)
{ {
music->mTrack = new JCooleyesMP3(); music->mTrack = new JMP3(s);
if (music->mTrack)
music->mTrack->Load(fileName);
} }
JMP3::mInstance = music->mTrack;
return music; return music;
} }
// void JSoundSystem::FreeMusic(JMusic *music)
// {
// if (music)
// {
// if (music->mTrack)
// delete music->mTrack;
//
// }
// }
JSample *JSoundSystem::LoadSample(const char *fileName) JSample *JSoundSystem::LoadSample(const char *fileName)
{ {
@@ -132,30 +125,8 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
return sample; return sample;
} }
//
// void JSoundSystem::FreeMusic(JMusic *music)
// {
// if (music)
// {
// if (music->mTrack)
// {
// music->mTrack->Release();
// delete music->mTrack;
// }
// delete music;
// }
// }
// void JSoundSystem::FreeSample(JSample *sample)
// {
// if (sample)
// {
// releaseWaveData(sample->mSample);
// delete sample;
// }
// }
void JSoundSystem::PlayMusic(JMusic *music, bool looping) void JSoundSystem::PlayMusic(JMusic *music, bool looping)
{ {
@@ -174,8 +145,8 @@ void JSoundSystem::PlaySample(JSample *sample)
void JSoundSystem::SetVolume(int volume) void JSoundSystem::SetVolume(int volume)
{ {
JMP3 * mp3 = JMP3::mInstance;
mVolume = volume; if (mp3) mp3->setVolume(volume);
} }
@@ -188,7 +159,7 @@ void JSoundSystem::StopMusic(JMusic *music)
void JSoundSystem::ResumeMusic(JMusic *music) void JSoundSystem::ResumeMusic(JMusic *music)
{ {
ResumeMP3(); ResumeMP3(music->mTrack);
} }
+7 -2
View File
@@ -10,6 +10,8 @@
#ifdef WIN32 #ifdef WIN32
#pragma warning(disable : 4786) #pragma warning(disable : 4786)
extern int actualWidth;
extern int actualHeight;
#endif #endif
#include "../../Dependencies/include/png.h" #include "../../Dependencies/include/png.h"
@@ -192,13 +194,16 @@ void JRenderer::DestroyRenderer()
void JRenderer::BeginScene() void JRenderer::BeginScene()
{ {
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity (); // Reset The Modelview Matrix glLoadIdentity ();// Reset The Modelview Matrix
float scaleH = (float)actualHeight/SCREEN_HEIGHT_F;
float scaleW = (float)actualWidth/SCREEN_WIDTH_F;
glScalef(scaleW,scaleW,1.f);
} }
void JRenderer::EndScene() void JRenderer::EndScene()
{ {
glFlush (); glFlush ();
} }
+3
View File
@@ -21,6 +21,9 @@ JMusic::JMusic()
} }
void JMusic::Update(){
}
JMusic::~JMusic() JMusic::~JMusic()
{ {
JSoundSystem::GetInstance()->StopMusic(this); JSoundSystem::GetInstance()->StopMusic(this);
+21 -8
View File
@@ -10,7 +10,8 @@
* Visit My Site At nehe.gamedev.net * Visit My Site At nehe.gamedev.net
*/ */
int actualWidth;
int actualHeight;
#include <windows.h> // Header File For Windows #include <windows.h> // Header File For Windows
#include <gl\gl.h> // Header File For The OpenGL32 Library #include <gl\gl.h> // Header File For The OpenGL32 Library
@@ -42,6 +43,7 @@ HINSTANCE hInstance; // Holds The Instance Of The Application
bool active=TRUE; // Window Active Flag Set To TRUE By Default bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=FALSE; // Windowed Mode By Default bool fullscreen=FALSE; // Windowed Mode By Default
DWORD lastTickCount; DWORD lastTickCount;
BOOL g_keys[256]; BOOL g_keys[256];
@@ -142,17 +144,20 @@ GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize Th
height=1; // Making Height Equal One height=1; // Making Height Equal One
} }
glViewport(0,0,width,height); // Reset The Current Viewport actualWidth = width;
actualHeight = height;
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glScissor(0, 0, width, height);
glLoadIdentity(); // Reset The Projection Matrix glViewport (0, 0, width, height); // Reset The Current Viewport
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window gluOrtho2D(0.0f, (float) width-1.0f, 0.0f, (float) height -1.0f);
gluPerspective(75.0f,(GLfloat)width/(GLfloat)height,0.5f,1000.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix glLoadIdentity (); // Reset The Modelview Matrix
glDisable (GL_DEPTH_TEST);
} }
int InitGL(GLvoid) // All Setup For OpenGL Goes Here int InitGL(GLvoid) // All Setup For OpenGL Goes Here
@@ -303,6 +308,11 @@ GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{ {
actualWidth = width;
actualHeight = height;
GLuint PixelFormat; // Holds The Results After Searching For A Match GLuint PixelFormat; // Holds The Results After Searching For A Match
WNDCLASS wc; // Windows Class Structure WNDCLASS wc; // Windows Class Structure
DWORD dwExStyle; // Window Extended Style DWORD dwExStyle; // Window Extended Style
@@ -373,6 +383,8 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree
dwStyle= WS_OVERLAPPED | \ dwStyle= WS_OVERLAPPED | \
WS_CAPTION | \ WS_CAPTION | \
WS_MINIMIZEBOX | WS_MINIMIZEBOX |
WS_SIZEBOX |
WS_MAXIMIZEBOX |
//WS_MINIMIZE | //WS_MINIMIZE |
WS_SYSMENU;// | \ WS_SYSMENU;// | \
//WS_THICKFRAME ; //WS_THICKFRAME ;
@@ -565,6 +577,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
case WM_SIZE: // Resize The OpenGL Window case WM_SIZE: // Resize The OpenGL Window
{ {
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
return 0; // Jump Back return 0; // Jump Back
} }
+1 -1
View File
@@ -13,7 +13,7 @@ ASFLAGS = $(CXXFLAGS)
INCDIR = ../../JGE/include ../../JGE/include/psp ../../JGE/include/psp/freetype2 ../../JGE/src INCDIR = ../../JGE/include ../../JGE/include/psp ../../JGE/include/psp/freetype2 ../../JGE/src
LIBDIR = ../../JGE/lib/psp LIBDIR = ../../JGE/lib/psp
LDFLAGS = LDFLAGS =
LIBS = -ljge300 -lhgetools -lfreetype -ljpeg -lgif -lpng -lz -lm -lmikmod -lpsppower -lpspmpeg -lpspaudiocodec -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lstdc++ -lpspfpu LIBS = -ljge300 -lhgetools -lfreetype -ljpeg -lgif -lpng -lz -lm -lmikmod -lpsppower -lpspmpeg -lpspaudiocodec -lpspaudiolib -lpspaudio -lpspmp3 -lpspgum -lpspgu -lpsprtc -lstdc++ -lpspfpu
EXTRA_TARGETS = EBOOT.PBP EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = WTH?! PSP_EBOOT_TITLE = WTH?!
+1
View File
@@ -80,6 +80,7 @@ class GameApp: public JApp
static JResourceManager * CommonRes; static JResourceManager * CommonRes;
static hgeParticleSystem * Particles[6]; static hgeParticleSystem * Particles[6];
static int HasMusic; static int HasMusic;
static JMusic* music;
}; };
+11 -4
View File
@@ -194,9 +194,13 @@ class GameStateDeckViewer: public GameState, public JGuiListener
welcome_menu->Add(10, "Cancel"); welcome_menu->Add(10, "Cancel");
if (GameApp::HasMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){ if (GameApp::HasMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){
if (!bgMusic) bgMusic = JSoundSystem::GetInstance()->LoadMusic("sound/Track1.mp3"); if (GameApp::music){
if (bgMusic){ JSoundSystem::GetInstance()->StopMusic(GameApp::music);
JSoundSystem::GetInstance()->PlayMusic(bgMusic, true); SAFE_DELETE(GameApp::music);
}
GameApp::music = JSoundSystem::GetInstance()->LoadMusic("sound/track1.mp3");
if (GameApp::music){
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
} }
} }
colorFilter = ALL_COLORS; colorFilter = ALL_COLORS;
@@ -219,7 +223,10 @@ class GameStateDeckViewer: public GameState, public JGuiListener
virtual void End() virtual void End()
{ {
//mEngine->EnableVSync(false); //mEngine->EnableVSync(false);
if (bgMusic) JSoundSystem::GetInstance()->StopMusic(bgMusic); if (GameApp::music){
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
SAFE_DELETE(GameApp::music);
}
SAFE_DELETE(backTex); SAFE_DELETE(backTex);
SAFE_DELETE(backQuad); SAFE_DELETE(backQuad);
SAFE_DELETE(welcome_menu); SAFE_DELETE(welcome_menu);
+26 -19
View File
@@ -43,7 +43,7 @@ class GameStateMenu: public GameState, public JGuiListener
JQuad * mMovingW; JQuad * mMovingW;
float mCreditsYPos; float mCreditsYPos;
int currentState; int currentState;
JMusic * bgMusic; //JMusic * bgMusic;
int mVolume; int mVolume;
char nbcardsStr[400]; char nbcardsStr[400];
@@ -64,10 +64,11 @@ class GameStateMenu: public GameState, public JGuiListener
mGuiController = NULL; mGuiController = NULL;
subMenuController = NULL; subMenuController = NULL;
mIconsTexture = NULL; mIconsTexture = NULL;
bgMusic = NULL; //bgMusic = NULL;
timeIndex = 0; timeIndex = 0;
angleMultiplier = MIN_ANGLE_MULTIPLIER; angleMultiplier = MIN_ANGLE_MULTIPLIER;
yW = 55; yW = 55;
mVolume = 0;
} }
virtual ~GameStateMenu() virtual ~GameStateMenu()
@@ -90,7 +91,7 @@ class GameStateMenu: public GameState, public JGuiListener
mIconsTexture = JRenderer::GetInstance()->LoadTexture("graphics/menuicons.png", TEX_TYPE_USE_VRAM); mIconsTexture = JRenderer::GetInstance()->LoadTexture("graphics/menuicons.png", TEX_TYPE_USE_VRAM);
bgTexture = JRenderer::GetInstance()->LoadTexture("graphics/menutitle.png", TEX_TYPE_USE_VRAM); bgTexture = JRenderer::GetInstance()->LoadTexture("graphics/menutitle.png", TEX_TYPE_USE_VRAM);
movingWTexture = JRenderer::GetInstance()->LoadTexture("graphics/movingW.png", TEX_TYPE_USE_VRAM); movingWTexture = JRenderer::GetInstance()->LoadTexture("graphics/movingW.png", TEX_TYPE_USE_VRAM);
mBg = NEW JQuad(bgTexture, 0, 0, 256, 167); // Create background quad for rendering. mBg = NEW JQuad(bgTexture, 0, 0, 256, 166); // Create background quad for rendering.
mMovingW = NEW JQuad(movingWTexture, 2, 2, 84, 62); mMovingW = NEW JQuad(movingWTexture, 2, 2, 84, 62);
mBg->SetHotSpot(105,50); mBg->SetHotSpot(105,50);
mMovingW->SetHotSpot(72,16); mMovingW->SetHotSpot(72,16);
@@ -149,7 +150,7 @@ class GameStateMenu: public GameState, public JGuiListener
if (mBg) delete mBg; if (mBg) delete mBg;
if (mMovingW) delete mMovingW; if (mMovingW) delete mMovingW;
SAFE_DELETE (bgMusic); //SAFE_DELETE (bgMusic);
} }
@@ -157,16 +158,18 @@ class GameStateMenu: public GameState, public JGuiListener
JRenderer::GetInstance()->ResetPrivateVRAM(); JRenderer::GetInstance()->ResetPrivateVRAM();
JRenderer::GetInstance()->EnableVSync(true); JRenderer::GetInstance()->EnableVSync(true);
if (GameApp::HasMusic && !bgMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){
bgMusic = JSoundSystem::GetInstance()->LoadMusic("sound/Track0.mp3"); if (GameApp::HasMusic && !GameApp::music && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){
GameApp::music = JSoundSystem::GetInstance()->LoadMusic("sound/Track0.mp3");
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
} }
if (bgMusic){ if (GameApp::HasMusic && GameApp::music && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] == 0){
mVolume = 0; JSoundSystem::GetInstance()->StopMusic(GameApp::music);
JSoundSystem::GetInstance()->SetVolume(mVolume); SAFE_DELETE(GameApp::music);
JSoundSystem::GetInstance()->PlayMusic(bgMusic, true);
} }
} }
@@ -198,19 +201,23 @@ class GameStateMenu: public GameState, public JGuiListener
{ {
//mEngine->EnableVSync(false); //mEngine->EnableVSync(false);
if (bgMusic) // if (bgMusic)
{ // {
JSoundSystem::GetInstance()->StopMusic(bgMusic); //JSoundSystem::GetInstance()->StopMusic(bgMusic);
} //SAFE_DELETE(bgMusic);
// }
JRenderer::GetInstance()->EnableVSync(false); JRenderer::GetInstance()->EnableVSync(false);
} }
virtual void Update(float dt) virtual void Update(float dt)
{ {
if (bgMusic && mVolume < 2*GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME]){
mVolume++; if (GameApp::music){
JSoundSystem::GetInstance()->SetVolume(mVolume/2); /*if (mVolume < 2*GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME]){
mVolume++;
JSoundSystem::GetInstance()->SetVolume(mVolume/2);
}*/
} }
timeIndex += dt * 2; timeIndex += dt * 2;
@@ -282,7 +289,7 @@ class GameStateMenu: public GameState, public JGuiListener
if (mEngine->GetButtonState(PSP_CTRL_TRIANGLE) && (dt != 0)) if (mEngine->GetButtonState(PSP_CTRL_TRIANGLE) && (dt != 0))
{ {
angleMultiplier = (cos(timeIndex)*angleMultiplier - M_PI/3 - 0.1 - angleW) / dt; angleMultiplier = (cos(timeIndex)*angleMultiplier - M_PI/3 - 0.1 - angleW) / dt;
yW = yW + 0.001 + (yW - 55) / 1000; yW = yW + 5*dt + (yW - 55) *5* dt;
} }
else else
angleW = cos(timeIndex)*angleMultiplier - M_PI/3 - 0.1; angleW = cos(timeIndex)*angleMultiplier - M_PI/3 - 0.1;
@@ -290,7 +297,7 @@ class GameStateMenu: public GameState, public JGuiListener
else else
{ {
angleW += angleMultiplier * dt; angleW += angleMultiplier * dt;
yW = yW + 0.001 + (yW - 55) / 1000; yW = yW + 5*dt + (yW - 55) *5*dt;
} }
} }
+2
View File
@@ -6,6 +6,8 @@
#endif #endif
#ifdef _DEBUG #ifdef _DEBUG
//if you get the following error :'_NORMAL_BLOCK' : undeclared identifier,
// try to add #include "crtdbg.h" somewhere in your code before including this file
#define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#else #else
#define NEW new #define NEW new
+2
View File
@@ -21,6 +21,7 @@ const char * const GameState::menuTexts[]= {"--NEW--","Deck 1", "Deck 2", "Deck
JResourceManager* GameApp::CommonRes = NEW JResourceManager(); JResourceManager* GameApp::CommonRes = NEW JResourceManager();
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL}; hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
int GameApp::HasMusic = 1; int GameApp::HasMusic = 1;
JMusic * GameApp::music = NULL;
GameState::GameState(GameApp* parent): mParent(parent) GameState::GameState(GameApp* parent): mParent(parent)
{ {
@@ -75,6 +76,7 @@ void GameApp::Create()
} }
CommonRes->CreateTexture("graphics/menuicons.png"); CommonRes->CreateTexture("graphics/menuicons.png");
//Creating thes quad in this specific order allows us to have them in the correct order to call them by integer id //Creating thes quad in this specific order allows us to have them in the correct order to call them by integer id
CommonRes->CreateQuad("c_artifact", "graphics/menuicons.png", 2 + 6*36, 38, 32, 32); CommonRes->CreateQuad("c_artifact", "graphics/menuicons.png", 2 + 6*36, 38, 32, 32);
+9 -2
View File
@@ -181,6 +181,11 @@ void GameStateDuel::Update(float dt)
} }
}else if (mGamePhase == DUEL_PLAY){ }else if (mGamePhase == DUEL_PLAY){
//Stop the music before starting the game
if (GameApp::music){
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
SAFE_DELETE(GameApp::music);
}
if (!game){ if (!game){
GameObserver::Init(mPlayers, 2); GameObserver::Init(mPlayers, 2);
game = GameObserver::GetInstance(); game = GameObserver::GetInstance();
@@ -209,11 +214,13 @@ void GameStateDuel::Update(float dt)
}else{ }else{
mGamePhase = DUEL_END; mGamePhase = DUEL_END;
} }
}else if (mParent->players[0] == PLAYER_TYPE_CPU && mParent->players[1] == PLAYER_TYPE_CPU){ }else
#endif
if (mParent->players[0] == PLAYER_TYPE_CPU && mParent->players[1] == PLAYER_TYPE_CPU){
End(); End();
Start(); Start();
} }
#endif
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
} }
if (mEngine->GetButtonClick(PSP_CTRL_START)){ if (mEngine->GetButtonClick(PSP_CTRL_START)){
@@ -19,7 +19,7 @@ import os
import os.path import os.path
from mtgCommon import * from mtgCommon import *
setinfo=sets['SHM'] setinfo=sets['CK']
stripReminderText = False stripReminderText = False
conffile = open(setinfo['dir'] + ".conf", 'w') conffile = open(setinfo['dir'] + ".conf", 'w')
+1
View File
@@ -325,6 +325,7 @@ sets ={'BE':{'name':'Beta',
'CK':{'name':'Champions of Kamigawa', 'CK':{'name':'Champions of Kamigawa',
'dir':'CK', 'dir':'CK',
'abbrev':'CK', 'abbrev':'CK',
'gathdirs':['CHK/en-us'],
'gathabbrev': 'CHK', 'gathabbrev': 'CHK',
'gathname':'ChampionsofKamigawa', 'gathname':'ChampionsofKamigawa',
}, },