- Merge some linux and Windows code in JGE to improve maintenance
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-01-21 11:37:31 +00:00
parent b8d46db0a8
commit 0948dc611a
7 changed files with 16 additions and 1958 deletions

View File

@@ -468,6 +468,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\pc\JGfx.cpp"
>
</File>
<File
RelativePath="src\JGui.cpp"
>
@@ -570,20 +574,16 @@
RelativePath=".\src\JParticleSystem.cpp"
>
</File>
<File
RelativePath=".\src\win\JRenderer_Win.cpp"
>
</File>
<File
RelativePath=".\src\JResourceManager.cpp"
>
</File>
<File
RelativePath=".\src\win\JSocket_Win.cpp"
RelativePath=".\src\pc\JSfx.cpp"
>
</File>
<File
RelativePath=".\src\win\JSoundSystem_Win.cpp"
RelativePath=".\src\pc\JSocket.cpp"
>
</File>
<File

View File

@@ -17,7 +17,7 @@ GENERIC_OBJS = src/JApp.o src/JGBKFont.o \
src/Encoding.o src/JTTFont.o \
src/JMD2Model.o src/JOBJModel.o
PSP_OBJS = src/JSocket.o src/JGfx.o src/JSfx.o src/JAudio.o src/JMP3.o src/decoder_prx.o src/main.o src/vram.o
LINUX_OBJS = src/linux/JGfx.o src/linux/JSfx.o src/Xmain.o
LINUX_OBJS = src/pc/JGfx.o src/pc/JSfx.o src/Xmain.o
HGE_OBJS = src/hge/hgecolor.o src/hge/hgeparticle.o \

View File

@@ -1,204 +0,0 @@
//-------------------------------------------------------------------------------------
//
// 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>
//
//-------------------------------------------------------------------------------------
#include <png.h>
#include "../../Dependencies/include/fmod.h"
#include "../../include/JSoundSystem.h"
#include "../../include/JFileSystem.h"
//////////////////////////////////////////////////////////////////////////
JMusic::JMusic()
{
}
JMusic::~JMusic()
{
JSoundSystem::GetInstance()->StopMusic(this);
//JSoundSystem::GetInstance()->FreeMusic(this);
if (mTrack)
FSOUND_Sample_Free(mTrack);
}
//////////////////////////////////////////////////////////////////////////
JSample::JSample()
{
}
JSample::~JSample()
{
//JSoundSystem::GetInstance()->FreeSample(this);
if (mSample)
FSOUND_Sample_Free(mSample);
}
//////////////////////////////////////////////////////////////////////////
JSoundSystem* JSoundSystem::mInstance = NULL;
JSoundSystem* JSoundSystem::GetInstance()
{
if (mInstance == NULL)
{
mInstance = new JSoundSystem();
mInstance->InitSoundSystem();
}
return mInstance;
}
void JSoundSystem::Destroy()
{
if (mInstance)
{
mInstance->DestroySoundSystem();
delete mInstance;
mInstance = NULL;
}
}
JSoundSystem::JSoundSystem()
{
mVolume = 0;
mSampleVolume = 0;
mChannel = FSOUND_FREE;
}
JSoundSystem::~JSoundSystem()
{
}
void JSoundSystem::InitSoundSystem()
{
FSOUND_Init(44100, 32, 0);
}
void JSoundSystem::DestroySoundSystem()
{
FSOUND_Close();
}
JMusic *JSoundSystem::LoadMusic(const char *fileName)
{
JMusic* music = new JMusic();
if (music)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (fileSystem->OpenFile(fileName))
{
int size = fileSystem->GetFileSize();
char *buffer = new char[size];
fileSystem->ReadFile(buffer, size);
music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer;
fileSystem->CloseFile();
}
}
return music;
}
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
{
if (music && music->mTrack)
{
mChannel = FSOUND_PlaySound(mChannel, music->mTrack);
SetMusicVolume(mVolume);
if (looping)
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL);
else
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_OFF);
}
}
void JSoundSystem::StopMusic(JMusic *music __attribute__((unused)))
{
// if (music && music->mTrack)
// FMUSIC_StopSong(music->mTrack);
FSOUND_StopSound(mChannel);
}
void JSoundSystem::SetVolume(int volume){
SetMusicVolume(volume);
SetSfxVolume(volume);
}
void JSoundSystem::SetMusicVolume(int volume)
{
if (mChannel != FSOUND_FREE) FSOUND_SetVolumeAbsolute(mChannel,volume * 2.55);
mVolume = volume;
}
void JSoundSystem::SetSfxVolume(int volume){
//this sets the volume to all channels then reverts back the volume for music..
//that's a bit dirty but it works
FSOUND_SetVolumeAbsolute(FSOUND_ALL,volume * 2.55);
mSampleVolume = volume;
SetMusicVolume(mVolume);
}
JSample *JSoundSystem::LoadSample(const char *fileName)
{
JSample* sample = new JSample();
if (sample)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (fileSystem->OpenFile(fileName))
{
int size = fileSystem->GetFileSize();
char *buffer = new char[size];
fileSystem->ReadFile(buffer, size);
sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer;
fileSystem->CloseFile();
}
else
sample->mSample = NULL;
}
return sample;
}
void JSoundSystem::PlaySample(JSample *sample)
{
if (sample && sample->mSample){
int channel = FSOUND_PlaySound(FSOUND_FREE, sample->mSample);
FSOUND_SetVolumeAbsolute(channel,mSampleVolume * 2.55);
}
}

View File

@@ -8,6 +8,14 @@
//
//-------------------------------------------------------------------------------------
#ifdef WIN32
#pragma warning(disable : 4786)
extern int actualWidth;
extern int actualHeight;
#pragma comment( lib, "giflib.lib" )
#endif
#include "../../Dependencies/include/png.h"
#include "../../Dependencies/include/fmod.h"
@@ -29,7 +37,7 @@ extern "C" {
#include "../../include/JFileSystem.h"
#include "../../include/JAssert.h"
#ifdef WIN23
#ifdef WIN32
#ifndef __attribute__
#define __attribute__((a))
#endif

File diff suppressed because it is too large Load Diff