Actualizado jail_audio
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#ifndef __MIPSEL__
|
||||
#include "jail_audio.h"
|
||||
#include "stb_vorbis.c"
|
||||
|
||||
@@ -77,7 +78,7 @@ void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) {
|
||||
|
||||
JA_Music JA_LoadMusic(const char* filename) {
|
||||
int chan, samplerate;
|
||||
JA_Music music = (JA_Music)SDL_malloc(sizeof(JA_Music_t));
|
||||
JA_Music music = new JA_Music_t();
|
||||
music->samples = stb_vorbis_decode_filename(filename, &chan, &samplerate, &music->output);
|
||||
|
||||
SDL_AudioCVT cvt;
|
||||
@@ -129,8 +130,8 @@ JA_Music_state JA_GetMusicState() {
|
||||
|
||||
void JA_DeleteMusic(JA_Music music) {
|
||||
if (current_music == music) current_music = NULL;
|
||||
free(music->output);
|
||||
free(music);
|
||||
SDL_free(music->output);
|
||||
delete music;
|
||||
}
|
||||
|
||||
JA_Sound JA_LoadSound(const char* filename) {
|
||||
@@ -144,7 +145,7 @@ JA_Sound JA_LoadSound(const char* filename) {
|
||||
cvt.buf = (Uint8 *) SDL_malloc(cvt.len * cvt.len_mult);
|
||||
SDL_memcpy(cvt.buf, sound->buffer, sound->length);
|
||||
SDL_ConvertAudio(&cvt);
|
||||
free(sound->buffer);
|
||||
SDL_FreeWAV(sound->buffer);
|
||||
sound->buffer = cvt.buf;
|
||||
sound->length = cvt.len_cvt;
|
||||
|
||||
@@ -167,7 +168,7 @@ void JA_DeleteSound(JA_Sound sound) {
|
||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
||||
if (channels[i].sound == sound) JA_StopChannel(i);
|
||||
}
|
||||
SDL_FreeWAV(sound->buffer);
|
||||
SDL_free(sound->buffer);
|
||||
delete sound;
|
||||
}
|
||||
|
||||
@@ -209,4 +210,4 @@ JA_Channel_state JA_GetChannelState(const int channel) {
|
||||
if (channel < 0 || channel >= JA_MAX_SIMULTANEOUS_CHANNELS) return JA_CHANNEL_INVALID;
|
||||
return channels[channel].state;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "ifdefs.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
enum JA_Channel_state { JA_CHANNEL_INVALID, JA_CHANNEL_FREE, JA_CHANNEL_PLAYING, JA_CHANNEL_PAUSED };
|
||||
enum JA_Music_state { JA_MUSIC_INVALID, JA_MUSIC_PLAYING, JA_MUSIC_PAUSED, JA_MUSIC_STOPPED };
|
||||
|
||||
@@ -267,188 +267,188 @@ void CreateActor(Tactor &a, Uint8 kind, Uint8 id, Sint16 dstx, Sint16 dsty, Sint
|
||||
void setExecutablePath(std::string path)
|
||||
{
|
||||
executablePath = path.substr(0, path.find_last_of("\\/"));
|
||||
printf("path: %s\n", executablePath.c_str());
|
||||
//printf("path: %s\n", executablePath.c_str());
|
||||
|
||||
std::string p;
|
||||
SDL_RWops *file;
|
||||
|
||||
p = FILE_MAP_VOLCANO = executablePath + "/../data/volcano.map.bak1";
|
||||
printf("%s\n",p.c_str());
|
||||
// printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_TILES_VOLCANO = executablePath + "/../media/gfx/tiles_volcano.png";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_TILES_SURFACE = executablePath + "/../media/gfx/tiles_surface.png";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_BKG_SURFACE = executablePath + "/../media/gfx/bkg_surface.png";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_MENU = executablePath + "/../media/gfx/menu.png";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_MENU_ANIMATION = executablePath + "/../media/gfx/menu_animation.png";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_ACTORS = executablePath + "/../media/gfx/actors.png";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_PLAYER = executablePath + "/../media/gfx/player.png";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_HUD = executablePath + "/../media/gfx/hud.png";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_FILTER = executablePath + "/../media/gfx/filter.png";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_SOUND_JUMP = executablePath + "/../media/sound/sound_player_jump.wav";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_SOUND_DEATH = executablePath + "/../media/sound/sound_player_death.wav";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_SOUND_COIN = executablePath + "/../media/sound/sound_player_coin.wav";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_SOUND_MENU_LOGO = executablePath + "/../media/sound/sound_menu_logo.wav";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_SOUND_MENU_START = executablePath + "/../media/sound/sound_menu_start.wav";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_SOUND_DROP_ENEMY = executablePath + "/../media/sound/sound_drop_enemy.wav";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_SOUND_DROP_SPLAT = executablePath + "/../media/sound/sound_drop_splat.wav";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_MUSIC_SURFACE = executablePath + "/../media/music/music_surface.ogg";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_MUSIC_VOLCANO = executablePath + "/../media/music/music_volcano.ogg";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
|
||||
p = FILE_MUSIC_MENU = executablePath + "/../media/music/music_menu.ogg";
|
||||
printf("%s\n",p.c_str());
|
||||
//printf("%s\n",p.c_str());
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file == NULL)
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
//printf("Checking file %-20s [OK]\n", p.c_str());
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
@@ -1997,14 +1997,14 @@ int main(int argc, char *args[])
|
||||
fullscreen = false;
|
||||
|
||||
// Inicializa SDL
|
||||
printf("Init SDL..\n");
|
||||
//printf("Init SDL..\n");
|
||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_HAPTIC);
|
||||
window = SDL_CreateWindow((WINDOW_TITLE + BUILD).c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
|
||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
SDL_RenderSetLogicalSize(renderer, 320, 240);
|
||||
|
||||
// Inicia las variables con las rutas de los ficheros
|
||||
printf("Init paths..\n");
|
||||
//printf("Init paths..\n");
|
||||
setExecutablePath(args[0]);
|
||||
|
||||
// Inicializa el audio
|
||||
|
||||
Reference in New Issue
Block a user