Added sound to GUI, Bold font for 640X480 GUI, writelog in some fprintf

This commit is contained in:
fabio.olimpieri 2015-01-10 11:35:34 +00:00
parent abe44a9e15
commit dead9a71ec
17 changed files with 240 additions and 109 deletions

View File

@ -201,11 +201,16 @@ dist:uae.dol
cp meta.xml $@/apps/uae/
cp icon.png $@/apps/uae/
cp font.ttf $@/apps/uae/
cp font_small.ttf $@/apps/uae/
cp README.Cloanto-Amiga_Forever $@/apps/uae/docs/
cp images/kb_amiga.png $@/apps/uae/images/
cp images/kb_amiga_small.png $@/apps/uae/images/
cp images/window_bg.png $@/apps/uae/images/
cp images/window_bg_small.png $@/apps/uae/images/
cp sound/menu_navigation_BE.raw $@/uae/wave
cp sound/select_BE.raw $@/uae/wave
cp sound/unselect_BE.raw $@/uae/wave
cp uaerc.wii $@/uae/uaerc
cp uaerc.smb $@/uae/
cp docs/configuration.txt $@/apps/uae/docs/

BIN
font.ttf

Binary file not shown.

BIN
font_small.ttf Normal file

Binary file not shown.

1
sound/README.txt Normal file
View File

@ -0,0 +1 @@
Raw files are 16 bits, 2 channels, 48k rate, signed integer

Binary file not shown.

Binary file not shown.

BIN
sound/select_BE.raw Normal file

Binary file not shown.

BIN
sound/select_LE.raw Normal file

Binary file not shown.

BIN
sound/unselect_BE.raw Normal file

Binary file not shown.

BIN
sound/unselect_LE.raw Normal file

Binary file not shown.

View File

@ -560,6 +560,7 @@ void save_options (FILE *f, const struct uae_prefs *p, int type)
cfgfile_write (f, "rumble1=%s\n", p->rumble[0]? "true" : "false");
cfgfile_write (f, "rumble2=%s\n", p->rumble[1]? "true" : "false");
cfgfile_write (f, "gfx_correct_ratio=%d\n", p->gfx_correct_ratio);
cfgfile_write (f, "gui_volume=%d\n", p->gui_volume);
#endif
#ifdef FILESYS
@ -890,6 +891,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value)
}
if (cfgfile_yesno (option, value, "write_logfile", &p->write_logfile))
return 1;
if (cfgfile_intval (option, value, "gui_volume", &p->gui_volume, 1)) return 1;
#endif
#ifdef DRIVESOUND
@ -2525,6 +2527,7 @@ void default_prefs (struct uae_prefs *p, int type)
p->rumble[1]= 0;
p->gfx_correct_ratio = 100;
p->write_logfile= 0;
p->gui_volume= 3;
#endif
#ifdef UAE_MINI

View File

@ -158,18 +158,16 @@ static const char *emulation_messages[] = {
static const char *audio_messages[] = {
/*00*/ "Sound ouput",
/*01*/ "^|none|normal|exact",
/*02*/ " ",
/*03*/ "Sound stereo separation",
/*04*/ "^|0|20%|40%|60%|80%|100%",
/*05*/ " ",
/*06*/ "Sound stereo delay",
/*07*/ "^|0|2|4|6|8|10",
/*08*/ " ",
/*09*/ "Sound interpolation",
/*10*/ "^|none|rh|crux|sinc",
/*11*/ " ",
/*12*/ "Floppy sound",
/*13*/ "^|on|off",
/*02*/ "Sound stereo separation",
/*03*/ "^|0|20%|40%|60%|80%|100%",
/*04*/ "Sound stereo delay",
/*05*/ "^|0|2|4|6|8|10",
/*06*/ "Sound interpolation",
/*07*/ "^|none|rh|crux|sinc",
/*08*/ "Floppy sound",
/*09*/ "^|on|off",
/*10*/ "Gui Volume",
/*11*/ "^|0|1|2|3|4|5",
NULL
};
@ -1213,7 +1211,7 @@ static void emulation_options(void)
static void audio_options(void)
{
int submenus[5];
int submenus[6];
int opt;
memset(submenus, 0, sizeof(submenus));
@ -1223,6 +1221,7 @@ static void audio_options(void)
submenus[2] = changed_prefs.sound_mixed_stereo/2;
submenus[3] = changed_prefs.sound_interpol;
submenus[4] = !get_dfxclick();
submenus[5] = changed_prefs.gui_volume;
opt = menu_select_title("Audio options menu",
audio_messages, submenus);
@ -1234,8 +1233,11 @@ static void audio_options(void)
changed_prefs.sound_mixed_stereo = submenus[2]*2;
changed_prefs.sound_interpol = submenus[3];
set_dfxclick(!submenus[4]);
changed_prefs.gui_volume = submenus[5];
fix_options_menu_sdl(1);
currprefs.gui_volume = changed_prefs.gui_volume;
}
static void set_gfx_resolution (int res)
@ -1386,7 +1388,7 @@ static void insert_keyboard_map(const char *key, const char *fmt, ...)
va_start(ap, fmt);
r = vsnprintf(buf, 255, fmt, ap);
if (r >= 255)
fprintf(stderr, "Too long string passed\n");
write_log("Too long string passed to insert keyboard map\n");
va_end(ap);
//printf("Mibb: %s:%s\n", buf, key);

View File

@ -25,6 +25,8 @@
#include "sysdeps.h"
#include "options.h"
#include "filesys.h"
#include "sounddep/sound.h"
#include "audio.h"
/* Uncomment for debugging output */
//#define DEBUG_MENU
@ -87,21 +89,24 @@ int FULL_DISPLAY_X; //640
int FULL_DISPLAY_Y; //480
int RATIO;
static SDL_Surface *real_screen;
#define IS_SUBMENU(p_msg) ( (p_msg)[0] == '^' )
#define IS_TEXT(p_msg) ( (p_msg)[0] == '#' || (p_msg)[0] == ' ' )
#define IS_MARKER(p_msg) ( (p_msg)[0] == '@' )
static int is_inited = 0;
static TTF_Font *menu_font16, *menu_font20,*menu_font8, *menu_font10 ;
#if defined(GEKKO)
#define FONT_PATH "/apps/uae/font.ttf"
#define FONT_PATH_SMALL "/apps/uae/font_small.ttf"
#else
#define FONT_PATH "FreeMono.ttf"
#define FONT_PATH "font.ttf"
#define FONT_PATH_SMALL "font_small.ttf"
#endif
static int is_inited = 0;
static TTF_Font *menu_font16, *menu_font20,*menu_font8, *menu_font10 ;
static SDL_Surface *image_window, *tmp_surface ;
static SDL_Surface *real_screen;
static char *click_buffer_pointer[3];
static int len_click_buffer[3];
int fh, fw;
@ -233,18 +238,22 @@ int msgYesNo(char *text, int default_opt, int x, int y)
key = menu_wait_key_press();
if (key & KEY_SELECT)
{
play_click(1);
return default_opt;
}
else if (key & KEY_ESCAPE)
{
play_click(2);
return 0;
}
else if (key & KEY_LEFT)
{
play_click(0);
default_opt = !default_opt;
}
else if (key & KEY_RIGHT)
{
play_click(0);
default_opt = !default_opt;
}
}
@ -493,7 +502,7 @@ void menu_print_font(SDL_Surface *screen, int r, int g, int b,
if (!font_surf)
{
fprintf(stderr, "%s\n", TTF_GetError());
write_log("%s\n", TTF_GetError());
exit(1);
}
@ -626,7 +635,7 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
{
fw = w;
fh = h;
fprintf(stderr, "%s\n", TTF_GetError());
write_log("%s\n", TTF_GetError());
exit(1);
}
@ -734,7 +743,7 @@ static void menu_init_internal(menu_t *p_menu, const char *title,
if (TTF_SizeText(p_font, p_menu->pp_msgs[p_menu->n_entries], &text_w_font, NULL) != 0)
{
fprintf(stderr, "%s\n", TTF_GetError());
write_log("%s\n", TTF_GetError());
exit(1);
}
if (text_w_font > p_menu->text_w)
@ -924,19 +933,19 @@ static int menu_select_internal(SDL_Surface *screen,
keys = menu_wait_key_press();
if (keys & KEY_UP)
select_next(p_menu, 0, -1, 1);
{select_next(p_menu, 0, -1, 1);play_click(0);}
else if (keys & KEY_DOWN)
select_next(p_menu, 0, 1, 1);
{select_next(p_menu, 0, 1, 1);play_click(0);}
else if (keys & KEY_PAGEUP)
select_next(p_menu, 0, -20, 0);
{select_next(p_menu, 0, -20, 0);play_click(0);}
else if (keys & KEY_PAGEDOWN)
select_next(p_menu, 0, 20, 0);
{select_next(p_menu, 0, 20, 0);play_click(0);}
else if (keys & KEY_LEFT)
select_next(p_menu, -1, 0 ,1);
{select_next(p_menu, -1, 0 ,1);play_click(0);}
else if (keys & KEY_RIGHT)
select_next(p_menu, 1, 0 ,1);
{select_next(p_menu, 1, 0 ,1);play_click(0);}
else if (keys & KEY_ESCAPE)
break;
{play_click(2);break;}
else if (keys & KEY_SELECT)
{
ret = p_menu->cur_sel;
@ -944,6 +953,7 @@ static int menu_select_internal(SDL_Surface *screen,
for (i=0; i<p_menu->n_submenus; i++)
p_submenus[i] = p_menu->p_submenus[i].sel;
play_click(1);
break;
}
/* Invoke the callback when an entry is selected */
@ -1123,24 +1133,24 @@ static TTF_Font *read_font(const char *path, int font_size)
FILE *fp = fopen(path, "r");
if (!data) {
fprintf(stderr, "Malloc failed\n");
write_log("Malloc failed\n");
exit(1);
}
if (!fp) {
fprintf(stderr, "Could not open font\n");
write_log("Could not open font\n");
exit(1);
}
fread(data, 1, 1 * 1024 * 1024, fp);
rw = SDL_RWFromMem(data, 1 * 1024 * 1024);
if (!rw)
{
fprintf(stderr, "Could not create RW: %s\n", SDL_GetError());
write_log("Could not create RW: %s\n", SDL_GetError());
exit(1);
}
out = TTF_OpenFontRW(rw, 1, font_size);
if (!out)
{
fprintf(stderr, "Unable to open font %s\n", path);
write_log("Unable to open font %s\n", path);
exit(1);
}
fclose(fp);
@ -1173,11 +1183,69 @@ void menu_init(SDL_Surface *screen)
menu_font16 = read_font(FONT_PATH, 16);
menu_font20 = read_font(FONT_PATH, 20);
menu_font8 = read_font(FONT_PATH, 8);
menu_font10 = read_font(FONT_PATH, 10);
menu_font8 = read_font(FONT_PATH_SMALL, 8);
menu_font10 = read_font(FONT_PATH_SMALL, 10);
real_screen = screen;
VirtualKeyboard_init(screen);
FILE *fichero;
int i;
for(i=0; i<3; i++)
{
switch (i)
{
#ifdef GEKKO
case 0:
fichero=fopen("/uae/wave/menu_navigation_BE.raw","rb"); //Menu up, down, left, right
break;
case 1:
fichero=fopen("/uae/wave/select_BE.raw","rb"); //Menu select
break;
case 2:
fichero=fopen("/uae/wave/unselect_BE.raw","rb"); //Menu unselect
break;
#else
case 0:
fichero=fopen("/uae/wave/menu_navigation_LE.raw","rb"); //Menu up, down, left, right
break;
case 1:
fichero=fopen("/uae/wave/select_LE.raw","rb"); //Menu select
break;
case 2:
fichero=fopen("/uae/wave/unselect_LE.raw","rb"); //Menu unselect
break;
#endif
}
if(fichero==NULL) {
write_log("Can't open button click wav file: %d\n", i);
exit(1);
}
fseek (fichero, 0, SEEK_END);
len_click_buffer[i]=ftell (fichero);
fseek (fichero, 0, SEEK_SET);
click_buffer_pointer[i]= (char *) malloc(len_click_buffer[i]);
if(click_buffer_pointer[i]==NULL) {
write_log("Can't allocate click wav buffer: %d\n",i);
exit(1);
}
fread(click_buffer_pointer[i], 1, len_click_buffer[i], fichero);
fclose(fichero);
}
is_inited = 1;
DEBUG_LOG("Menu is inited\n");
}
@ -1187,6 +1255,11 @@ void menu_deinit(void)
if (!is_inited) return;
is_inited = 0;
free(click_buffer_pointer[0]);
free(click_buffer_pointer[1]);
free(click_buffer_pointer[2]);
SDL_FreeSurface (image_window);
VirtualKeyboard_fini();
@ -1204,3 +1277,46 @@ int menu_is_inited(void)
{
return is_inited;
}
inline void memcpy_volume(uae_s16* dst, uae_s16* srt, int length, uae_s16 gui_volume)
{
int i;
int s16_len;
s16_len = length/2;
for (i=0; i<length; i+=2)
{
dst[i] = srt[i]>>gui_volume; //One channel
dst[i+1] = srt[i+1]>>gui_volume; //The other channel
}
}
void play_click(int sound)
{
int snd_bf_pointer;
uae_s16 gui_volume;
if (!changed_prefs.gui_volume) return;
if (changed_prefs.sound_stereo!=1) return; //Only stereo implemented
gui_volume = 5-changed_prefs.gui_volume;
if (gui_volume<0) gui_volume=0;
if (gui_volume>5) gui_volume=5;
audio_resume();
for(snd_bf_pointer=0; snd_bf_pointer< (len_click_buffer[sound]-sndbufsize); snd_bf_pointer+=sndbufsize)
{
memcpy_volume((uae_s16 *)sndbuffer, (uae_s16 *)(click_buffer_pointer[sound]+snd_bf_pointer), sndbufsize, gui_volume);
finish_sound_buffer();
}
memcpy(sndbuffer, click_buffer_pointer[sound] + snd_bf_pointer, len_click_buffer[sound] - snd_bf_pointer); //The last chunk
memset((char *) sndbuffer + len_click_buffer[sound]-snd_bf_pointer,0, sndbufsize -(len_click_buffer[sound]- snd_bf_pointer));
finish_sound_buffer();
clearbuffer();
audio_pause();
}

View File

@ -1,72 +1,74 @@
/*********************************************************************
*
* Copyright (C) 2004, 2008, Simon Kagstrom
* Copyright (C) 2010,2014, Fabio Olimpieri
*
* Filename: menu.h
* Author: Simon Kagstrom <simon.kagstrom@gmail.com>, Fabio Olimpieri
* Description:
*
* $Id$
*
********************************************************************/
#ifndef __MENU_H__
#define __MENU_H__
#include <SDL.h>
#include <SDL_ttf.h>
#include<SDL/SDL_image.h>
#include <stdint.h>
#if defined(__cplusplus)
extern "C" {
#endif
#define KEY_UP 1
#define KEY_DOWN 2
#define KEY_LEFT 4
#define KEY_RIGHT 8
#define KEY_SELECT 16
#define KEY_ESCAPE 32
#define KEY_PAGEDOWN 64
#define KEY_PAGEUP 128
#define KEY_HELP 256
#define MAX_DEVICE_ITEM 32
extern int FULL_DISPLAY_X; //640
extern int FULL_DISPLAY_Y; //480
extern int RATIO;
void menu_print_font(SDL_Surface *screen, int r, int g, int b, int x, int y, const char *msg, int font_size);
/* Various option selects */
int menu_select_title(const char *title, const char **pp_msgs, int *p_submenus);
int menu_select(const char **pp_msgs, int *p_submenus);
const char *menu_select_file(const char *dir_path,const char *selected_file, int which);
const char *menu_select_file_start(const char *dir_path, const char **d64_name);
uint32_t menu_wait_key_press(void);
void msgKill(SDL_Rect *rc);
int msgInfo(char *text, int duration, SDL_Rect *rc);
int msgYesNo(char *text, int def,int x, int y);
void menu_init(SDL_Surface *screen);
void menu_deinit(void);
int menu_is_inited(void);
int ext_matches(const char *name, const char *ext);
void flip_screen (void);
int menu_select_devices(void);
#if defined(__cplusplus)
}
#endif
#endif /* !__MENU_H__ */
/*********************************************************************
*
* Copyright (C) 2004, 2008, Simon Kagstrom
* Copyright (C) 2010,2014, Fabio Olimpieri
*
* Filename: menu.h
* Author: Simon Kagstrom <simon.kagstrom@gmail.com>, Fabio Olimpieri
* Description:
*
* $Id$
*
********************************************************************/
#ifndef __MENU_H__
#define __MENU_H__
#include <SDL.h>
#include <SDL_ttf.h>
#include<SDL/SDL_image.h>
#include <stdint.h>
#if defined(__cplusplus)
extern "C" {
#endif
#define KEY_UP 1
#define KEY_DOWN 2
#define KEY_LEFT 4
#define KEY_RIGHT 8
#define KEY_SELECT 16
#define KEY_ESCAPE 32
#define KEY_PAGEDOWN 64
#define KEY_PAGEUP 128
#define KEY_HELP 256
#define MAX_DEVICE_ITEM 32
extern int FULL_DISPLAY_X; //640
extern int FULL_DISPLAY_Y; //480
extern int RATIO;
void menu_print_font(SDL_Surface *screen, int r, int g, int b, int x, int y, const char *msg, int font_size);
/* Various option selects */
int menu_select_title(const char *title, const char **pp_msgs, int *p_submenus);
int menu_select(const char **pp_msgs, int *p_submenus);
const char *menu_select_file(const char *dir_path,const char *selected_file, int which);
const char *menu_select_file_start(const char *dir_path, const char **d64_name);
uint32_t menu_wait_key_press(void);
void msgKill(SDL_Rect *rc);
int msgInfo(char *text, int duration, SDL_Rect *rc);
int msgYesNo(char *text, int def,int x, int y);
void menu_init(SDL_Surface *screen);
void menu_deinit(void);
int menu_is_inited(void);
int ext_matches(const char *name, const char *ext);
void flip_screen (void);
int menu_select_devices(void);
void play_click(int sound);
#if defined(__cplusplus)
}
#endif
#endif /* !__MENU_H__ */

View File

@ -255,6 +255,7 @@ struct uae_prefs {
int Port; //SD, USB or SMB
int rumble[2];
int gfx_correct_ratio;
int gui_volume;
#endif
/* input */

View File

@ -29,7 +29,7 @@ static uae_sem_t data_available_sem, callback_done_sem, sound_init_sem;
static int in_callback, closing_sound;
static void clearbuffer (void)
void clearbuffer (void)
{
memset (sndbuffer, 0, sizeof (sndbuffer));
}
@ -70,7 +70,7 @@ int setup_sound (void)
spec.freq = currprefs.sound_freq;
spec.format = AUDIO_S16SYS;
spec.channels = currprefs.sound_stereo ? 2 : 1;
spec.callback = dummy_callback;
//spec.callback = dummy_callback;
spec.samples = spec.freq * currprefs.sound_latency / 1000;
spec.callback = sound_callback;
spec.userdata = 0;

View File

@ -20,6 +20,7 @@ extern void reset_sound (void);
extern void driveclick_mix(uae_s16*, int); //Also defined in driveclick.h
extern void driveclick_init(void); //Also defined in driveclick.h
extern void driveclick_free(void); //Also defined in driveclick.h
extern void clearbuffer (void);
STATIC_INLINE void check_sound_buffers (void)
{