Basic opendingux support
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ scripts
|
|||||||
todo.txt
|
todo.txt
|
||||||
data/config.bin
|
data/config.bin
|
||||||
data/score.bin
|
data/score.bin
|
||||||
|
*.opk
|
||||||
|
|||||||
9
default.gcw0.desktop
Normal file
9
default.gcw0.desktop
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Version=1.0
|
||||||
|
Type=Application
|
||||||
|
Name=Coffee Crisis
|
||||||
|
Comment=Coffee Crisis
|
||||||
|
Icon=icon
|
||||||
|
Exec=bin/coffee_crisis
|
||||||
|
Categories=games;Game;SDL;
|
||||||
|
Terminal=false
|
||||||
7
generate_opendingux
Executable file
7
generate_opendingux
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
cd source
|
||||||
|
/opt/gcw0-toolchain/usr/bin/mipsel-linux-g++ -g -D_GCWZERO -O2 -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/SDL2 -D_GNU_SOURCE=1 -D_REENTRANT -lSDL2 -lSDL2_mixer -std=c++11 *.cpp -o coffee_crisis_gcw0
|
||||||
|
mv coffee_crisis_gcw0 ../bin/coffee_crisis
|
||||||
|
cd ..
|
||||||
|
/opt/gcw0-toolchain/usr/bin/mksquashfs ./default.gcw0.desktop ./icon.png ./bin ./data ./media coffee_crisis.opk -all-root -noappend -no-exports -no-xattrs
|
||||||
@@ -2,6 +2,10 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "gamedirector.h"
|
#include "gamedirector.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#ifdef __MIPSEL __
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
const Uint8 *keystates;
|
const Uint8 *keystates;
|
||||||
float mSin[360]; // Vector con los valores del seno para 360 grados
|
float mSin[360]; // Vector con los valores del seno para 360 grados
|
||||||
@@ -41,6 +45,14 @@ GameDirector::GameDirector(std::string path)
|
|||||||
// Inicializa JailAudio
|
// Inicializa JailAudio
|
||||||
initJailAudio();
|
initJailAudio();
|
||||||
|
|
||||||
|
#ifdef __MIPSEL__
|
||||||
|
DIR* dir = opendir("/media/data/local/home/.coffee_crisis");
|
||||||
|
if (dir) { closedir(dir); }
|
||||||
|
else if (ENOENT == errno) {
|
||||||
|
int status = mkdir("/media/data/local/home/.coffee_crisis", 755);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Carga recursos
|
// Carga recursos
|
||||||
loadMediaProg();
|
loadMediaProg();
|
||||||
loadScoreFile();
|
loadScoreFile();
|
||||||
@@ -129,9 +141,15 @@ void GameDirector::initProg()
|
|||||||
mProg.keyboard.right = SDL_SCANCODE_RIGHT;
|
mProg.keyboard.right = SDL_SCANCODE_RIGHT;
|
||||||
mProg.keyboard.accept = SDL_SCANCODE_RETURN;
|
mProg.keyboard.accept = SDL_SCANCODE_RETURN;
|
||||||
mProg.keyboard.cancel = SDL_SCANCODE_ESCAPE;
|
mProg.keyboard.cancel = SDL_SCANCODE_ESCAPE;
|
||||||
|
#ifdef __MIPSEL__
|
||||||
|
mProg.keyboard.fire = SDL_SCANCODE_SPACE;
|
||||||
|
mProg.keyboard.fireLeft = SDL_SCANCODE_LSHIFT;
|
||||||
|
mProg.keyboard.fireRight = SDL_SCANCODE_LCTRL;
|
||||||
|
#else
|
||||||
mProg.keyboard.fire = SDL_SCANCODE_W;
|
mProg.keyboard.fire = SDL_SCANCODE_W;
|
||||||
mProg.keyboard.fireLeft = SDL_SCANCODE_Q;
|
mProg.keyboard.fireLeft = SDL_SCANCODE_Q;
|
||||||
mProg.keyboard.fireRight = SDL_SCANCODE_E;
|
mProg.keyboard.fireRight = SDL_SCANCODE_E;
|
||||||
|
#endif
|
||||||
mProg.keyboard.pause = SDL_SCANCODE_ESCAPE;
|
mProg.keyboard.pause = SDL_SCANCODE_ESCAPE;
|
||||||
mProg.keyboard.escape = SDL_SCANCODE_ESCAPE;
|
mProg.keyboard.escape = SDL_SCANCODE_ESCAPE;
|
||||||
|
|
||||||
@@ -1132,9 +1150,11 @@ void GameDirector::quitGame()
|
|||||||
void GameDirector::setFileList()
|
void GameDirector::setFileList()
|
||||||
{
|
{
|
||||||
// Ficheros binarios
|
// Ficheros binarios
|
||||||
mBinFile[BINFILE_SCORE].file = mProg.executablePath + "/" + "../data/score.bin";
|
#ifdef __MIPSEL__
|
||||||
mBinFile[BINFILE_DEMO].file = mProg.executablePath + "/" + "../data/demo.bin";
|
mBinFile[BINFILE_SCORE].file = "/media/data/local/home/.coffee_crisis/score.bin";
|
||||||
mBinFile[BINFILE_CONFIG].file = mProg.executablePath + "/" + "../data/config.bin";
|
mBinFile[BINFILE_DEMO].file = "/media/data/local/home/.coffee_crisis/demo.bin";
|
||||||
|
mBinFile[BINFILE_CONFIG].file = "/media/data/local/home/.coffee_crisis/config.bin";
|
||||||
|
#endif
|
||||||
|
|
||||||
// Musicas
|
// Musicas
|
||||||
mMusic[MUSIC_INTRO].file = mProg.executablePath + "/" + "../media/music/intro.ogg";
|
mMusic[MUSIC_INTRO].file = mProg.executablePath + "/" + "../media/music/intro.ogg";
|
||||||
@@ -4248,7 +4268,7 @@ void GameDirector::runIntro()
|
|||||||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||||||
{
|
{
|
||||||
// Reproduce la música
|
// Reproduce la música
|
||||||
JA_PlayMusic(mMusic[MUSIC_INTRO].music, false);
|
JA_PlayMusic(mMusic[MUSIC_INTRO].music, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((mProg.section == PROG_SECTION_INTRO) && (!exit()))
|
while ((mProg.section == PROG_SECTION_INTRO) && (!exit()))
|
||||||
@@ -4543,7 +4563,7 @@ void GameDirector::runTitle(Uint8 subsection)
|
|||||||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||||||
{
|
{
|
||||||
// Reproduce la música
|
// Reproduce la música
|
||||||
JA_PlayMusic(mMusic[MUSIC_TITLE].music, true);
|
JA_PlayMusic(mMusic[MUSIC_TITLE].music, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula la lógica de los objetos
|
// Calcula la lógica de los objetos
|
||||||
@@ -4745,7 +4765,7 @@ void GameDirector::runGame()
|
|||||||
{
|
{
|
||||||
// Reproduce la música
|
// Reproduce la música
|
||||||
if (mGame.player->isAlive())
|
if (mGame.player->isAlive())
|
||||||
JA_PlayMusic(mMusic[MUSIC_PLAYING].music, true);
|
JA_PlayMusic(mMusic[MUSIC_PLAYING].music, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
||||||
|
|||||||
@@ -11,7 +11,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include "/usr/include/SDL2/SDL.h"
|
#ifdef __MIPSEL__
|
||||||
|
#include "SDL.h"
|
||||||
|
#else
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UNUSED
|
#define UNUSED
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
#ifndef __MIPSEL__
|
||||||
#include "jail_audio.h"
|
#include "jail_audio.h"
|
||||||
#include "stb_vorbis.c"
|
#include "stb_vorbis.c"
|
||||||
//#include <SDL2/SDL.h>
|
|
||||||
|
|
||||||
#define JA_MAX_SIMULTANEOUS_CHANNELS 5
|
#define JA_MAX_SIMULTANEOUS_CHANNELS 5
|
||||||
|
|
||||||
@@ -210,4 +210,4 @@ JA_Channel_state JA_GetChannelState(const int channel) {
|
|||||||
if (channel < 0 || channel >= JA_MAX_SIMULTANEOUS_CHANNELS) return JA_CHANNEL_INVALID;
|
if (channel < 0 || channel >= JA_MAX_SIMULTANEOUS_CHANNELS) return JA_CHANNEL_INVALID;
|
||||||
return channels[channel].state;
|
return channels[channel].state;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
106
source/jail_audio_mipsel.cpp
Normal file
106
source/jail_audio_mipsel.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
#ifdef __MIPSEL__
|
||||||
|
#include "jail_audio.h"
|
||||||
|
#include "SDL_mixer.h"
|
||||||
|
|
||||||
|
struct JA_Sound_t {
|
||||||
|
Mix_Chunk *mix_chunk;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct JA_Music_t {
|
||||||
|
Mix_Music* mix_music;
|
||||||
|
};
|
||||||
|
|
||||||
|
JA_Music current_music{NULL};
|
||||||
|
|
||||||
|
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) {
|
||||||
|
Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024);
|
||||||
|
Mix_AllocateChannels(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
JA_Music JA_LoadMusic(const char* filename) {
|
||||||
|
int chan, samplerate;
|
||||||
|
JA_Music music = new JA_Music_t();
|
||||||
|
music->mix_music = Mix_LoadMUS(filename);
|
||||||
|
return music;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_PlayMusic(JA_Music music, const int loop) {
|
||||||
|
if (current_music == music) return;
|
||||||
|
if (current_music != NULL) {
|
||||||
|
Mix_HaltMusic();
|
||||||
|
}
|
||||||
|
current_music = music;
|
||||||
|
Mix_PlayMusic(music->mix_music, loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_PauseMusic() {
|
||||||
|
Mix_PauseMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_ResumeMusic() {
|
||||||
|
Mix_ResumeMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_StopMusic() {
|
||||||
|
Mix_HaltMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
JA_Music_state JA_GetMusicState() {
|
||||||
|
if (current_music == NULL) return JA_MUSIC_INVALID;
|
||||||
|
if (Mix_PausedMusic()) {
|
||||||
|
return JA_MUSIC_PAUSED;
|
||||||
|
} else if (Mix_PlayingMusic()) {
|
||||||
|
return JA_MUSIC_PLAYING;
|
||||||
|
} else {
|
||||||
|
return JA_MUSIC_STOPPED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_DeleteMusic(JA_Music music) {
|
||||||
|
if (current_music == music) {
|
||||||
|
Mix_HaltMusic();
|
||||||
|
current_music = NULL;
|
||||||
|
}
|
||||||
|
Mix_FreeMusic(music->mix_music);
|
||||||
|
delete music;
|
||||||
|
}
|
||||||
|
|
||||||
|
JA_Sound JA_LoadSound(const char* filename) {
|
||||||
|
JA_Sound sound = new JA_Sound_t();
|
||||||
|
sound->mix_chunk = Mix_LoadWAV(filename);
|
||||||
|
return sound;
|
||||||
|
}
|
||||||
|
|
||||||
|
int JA_PlaySound(JA_Sound sound, const int loop) {
|
||||||
|
int channel = Mix_PlayChannel(-1, sound->mix_chunk, loop);
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_DeleteSound(JA_Sound sound) {
|
||||||
|
Mix_FreeChunk(sound->mix_chunk);
|
||||||
|
delete sound;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_PauseChannel(const int channel) {
|
||||||
|
Mix_Pause(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_ResumeChannel(const int channel) {
|
||||||
|
Mix_Resume(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JA_StopChannel(const int channel) {
|
||||||
|
Mix_HaltChannel(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
JA_Channel_state JA_GetChannelState(const int channel) {
|
||||||
|
if (Mix_Paused(channel)) {
|
||||||
|
return JA_CHANNEL_PAUSED;
|
||||||
|
} else if (Mix_Playing(channel)) {
|
||||||
|
return JA_CHANNEL_PLAYING;
|
||||||
|
} else {
|
||||||
|
return JA_CHANNEL_FREE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user