Added ZIP, DMS and floppy sound support

This commit is contained in:
fabio.olimpieri 2012-03-29 07:49:31 +00:00
parent b5feec8512
commit e1cf346493
9 changed files with 418 additions and 277 deletions

View File

@ -56,6 +56,7 @@ src/tools/genlinetoscr.exe:
clean: clean:
@echo Cleaning $(OBJ_DIR) @echo Cleaning $(OBJ_DIR)
@rm -rf $(OBJS) $(OBJ_DIR) src/machdep src/target.h src/md-fpp.h src/sysconfig.h $(SYMLINKS) @rm -rf $(OBJS) $(OBJ_DIR) src/machdep src/target.h src/md-fpp.h src/sysconfig.h $(SYMLINKS)
@rm -rf dist
@rm -f src/blit.h src/blitfunc.c src/blitfunc.h src/blittable.c src/linetoscr.c @rm -f src/blit.h src/blitfunc.c src/blitfunc.h src/blittable.c src/linetoscr.c
@rm -f uae.dol uae.elf @rm -f uae.dol uae.elf
cd src/tools/ && make -f Makefile.wii clean cd src/tools/ && make -f Makefile.wii clean
@ -143,7 +144,7 @@ COMMON_FLAGS := -g -O3 -G8 -mrvl -Wall -D__inline__=__inline__ $(MACHDEP) -Wno-u
INCLUDES := -Isrc/md-generic/ -Isrc/include -Isrc -I$(DEVKITPRO)/libogc/include -I$(DEVKITPRO)/libogc/include/SDL -I$(PORTLIBS)/include INCLUDES := -Isrc/md-generic/ -Isrc/include -Isrc -I$(DEVKITPRO)/libogc/include -I$(DEVKITPRO)/libogc/include/SDL -I$(PORTLIBS)/include
DEFINES := -DOS_WITHOUT_MEMORY_MANAGEMENT -DSAVESTATE -DUSE_SDL -DSUPPORT_THREADS -DCPUEMU_0 -DCPUEMU_5 -DCPUEMU_6 \ DEFINES := -DOS_WITHOUT_MEMORY_MANAGEMENT -DSAVESTATE -DUSE_SDL -DSUPPORT_THREADS -DCPUEMU_0 -DCPUEMU_5 -DCPUEMU_6 \
-DFPUEMU -DAGA -DAUTOCONFIG -DFILESYS \ -DFPUEMU -DAGA -DAUTOCONFIG -DFILESYS \
-DTD_START_HEIGHT=16 -DTD_START_HEIGHT=16 -DDRIVESOUND
CFLAGS := $(COMMON_FLAGS) $(INCLUDES) $(DEFINES) CFLAGS := $(COMMON_FLAGS) $(INCLUDES) $(DEFINES)
#unused defines; -DFDI2RAW #unused defines; -DFDI2RAW
@ -181,6 +182,7 @@ distsource:
cd .. && cp -r uae-wii uae-wii-v cd .. && cp -r uae-wii uae-wii-v
cd ../uae-wii-v && find . -name ".svn" | xargs rm -rf cd ../uae-wii-v && find . -name ".svn" | xargs rm -rf
cd .. && tar -czf uae-wii-v.tar.gz uae-wii-v cd .. && tar -czf uae-wii-v.tar.gz uae-wii-v
cd .. && rm -fr uae-wii-v
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------

View File

@ -21,17 +21,18 @@
#include "custom_private.h" #include "custom_private.h"
#include "newcpu.h" #include "newcpu.h"
#include "gensound.h" #include "gensound.h"
#include "driveclick.h"
#include "sounddep/sound.h" #include "sounddep/sound.h"
#include "events.h" #include "events.h"
#include "audio.h" #include "audio.h"
#include "savestate.h" #include "savestate.h"
#include "driveclick.h"
#ifdef AVIOUTPUT #ifdef AVIOUTPUT
# include "avioutput.h" # include "avioutput.h"
#endif #endif
#include "sinctable.h" #include "sinctable.h"
#include "gui.h" /* for gui_ledstate */ #include "gui.h" /* for gui_ledstate */
#define MAX_EV ~0ul #define MAX_EV ~0ul
//#define DEBUG_AUDIO //#define DEBUG_AUDIO
#define DEBUG_CHANNEL_MASK 15 #define DEBUG_CHANNEL_MASK 15

View File

@ -13,14 +13,21 @@
#include "uae.h" #include "uae.h"
#include "options.h" #include "options.h"
#include "driveclick.h"
#include "sounddep/sound.h" #include "sounddep/sound.h"
#include "zfile.h" #include "zfile.h"
#include "events.h" #include "events.h"
#include "driveclick.h"
#include "fsdb.h" #include "fsdb.h"
#include "resource/drive_click.c"
#include "resource/drive_snatch.c"
#include "resource/drive_spin.c"
#include "resource/drive_startup.c"
static struct drvsample drvs[4][DS_END]; static struct drvsample drvs[4][DS_END];
static int freq = 44100; static int freq = 44100;
@ -51,7 +58,18 @@ uae_s16 *decodewav (uae_u8 *s, int *lenp)
s += 4; s += 4;
len = s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24); len = s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24);
dst = xmalloc (len); dst = xmalloc (len);
#ifdef WORDS_BIGENDIAN
{
int i;
uae_u8* d = (uae_u8*) dst;
for (i = 0; i < len; i+= 2) {
d[i] = s[i + 5];
d[i+1] = s[i + 4];
}
}
#else
memcpy (dst, s + 4, len); memcpy (dst, s + 4, len);
#endif
*lenp = len / 2; *lenp = len / 2;
return dst; return dst;
} }
@ -65,24 +83,77 @@ static int loadsample (const char *path, struct drvsample *ds)
struct zfile *f; struct zfile *f;
uae_u8 *buf; uae_u8 *buf;
int size; int size;
int i;
f = zfile_fopen (path, "rb"); f = zfile_fopen (path, "rb");
if (!f) { if (!f) {
write_log ("driveclick: can't open '%s'\n", path); write_log ("driveclick: can't open '%s'\n", path);
return 0; return 0;
} }
// ("driveclick: loading '%s'\n", path);
zfile_fseek (f, 0, SEEK_END); zfile_fseek (f, 0, SEEK_END);
size = zfile_ftell (f); size = zfile_ftell (f);
buf = malloc (size); buf = malloc (size);
zfile_fseek (f, 0, SEEK_SET); zfile_fseek (f, 0, SEEK_SET);
zfile_fread (buf, size, 1, f); zfile_fread (buf, size, 1, f);
zfile_fclose (f); zfile_fclose (f);
/*
printf("size=%i \n", size);
for (i = 0; i < size; i++) {
printf("0x%02x,", buf[i]);
if (i % 20 == 19) {
printf("\n");
}
}
printf("\n");
flush(NULL);
}
*/
ds->len = size; ds->len = size;
ds->p = decodewav (buf, &ds->len); ds->p = decodewav (buf, &ds->len);
free (buf); free (buf);
return 1; return 1;
} }
//The same function as load sample, but the wav data is already in memory.
//No read, just decode.
static int loadsample_resource(int resId, struct drvsample *ds) {
uae_u8* buf = NULL;
int size;
switch (resId) {
case DS_CLICK: {
buf = res_drive_click;
size = res_drive_click_size;
} break;
case DS_SPIN :
case DS_SPINND: {
buf = res_drive_spin;
size = res_drive_spin_size;
} break;
case DS_START: {
buf = res_drive_startup;
size = res_drive_startup_size;
} break;
case DS_SNATCH: {
buf = res_drive_snatch;
size = res_drive_snatch_size;
} break;
default: return 0;
} //end of switch
//write_log("loading click resource %i \n", resId);
ds->len = size;
ds->p = decodewav (buf, &ds->len);
return 1;
}
static void freesample (struct drvsample *s) static void freesample (struct drvsample *s)
{ {
free (s->p); free (s->p);
@ -94,47 +165,72 @@ extern char *start_path;
void driveclick_init (void) void driveclick_init (void)
{ {
int v, vv, i, j; int v, vv, i, j;
char tmp[1000]; static char tmp_path[1024];
driveclick_free (); driveclick_free ();
vv = 0; vv = 0;
write_log("driveclick init...\n");
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (currprefs.dfxclick[i]) { if (currprefs.dfxclick[i]) {
/* TODO: Implement location of sample data */ /* TODO: Implement location of sample data */
#if 0 //load from resource
if (currprefs.dfxclick[i] > 0) { if (currprefs.dfxclick[i] > 0) { // > 0
v = 0; v = loadsample_resource(DS_CLICK, &drvs[i][DS_CLICK]);
if (driveclick_loadresource (drvs[i], currprefs.dfxclick[i])) v += loadsample_resource(DS_SPIN, &drvs[i][DS_SPIN]);
v = 3; v += loadsample_resource(DS_SPINND, &drvs[i][DS_SPINND]);
} else if (currprefs.dfxclick[i] == -1) { v += loadsample_resource(DS_SNATCH, &drvs[i][DS_SNATCH]);
sprintf (tmp, "%suae_data%cdrive_click_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]); v += loadsample_resource(DS_START, &drvs[i][DS_START]);
v = loadsample (tmp, &drvs[i][DS_CLICK]);
sprintf (tmp, "%suae_data%cdrive_spin_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]); } else
v += loadsample (tmp, &drvs[i][DS_SPIN]); //load from file
sprintf (tmp, "%suae_data%cdrive_spinnd_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]); if (currprefs.dfxclick[i] == -1) {
v += loadsample (tmp, &drvs[i][DS_SPINND]); #ifdef GEKKO //currprefs.dfxclickexternal[i] is the path to the wav directory (path contains trailing separator)
sprintf (tmp, "%suae_data%cdrive_startup_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]); sprintf (tmp_path, "%sdrive_click.wav", currprefs.dfxclickexternal[i]);
v += loadsample (tmp, &drvs[i][DS_START]); v = loadsample (tmp_path, &drvs[i][DS_CLICK]);
sprintf (tmp, "%suae_data%cdrive_snatch_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]); sprintf (tmp_path, "%sdrive_spin.wav", currprefs.dfxclickexternal[i]);
v += loadsample (tmp, &drvs[i][DS_SNATCH]); v += loadsample (tmp_path, &drvs[i][DS_SPIN]);
sprintf (tmp_path, "%sdrive_spinnd.wav", currprefs.dfxclickexternal[i]);
v += loadsample (tmp_path, &drvs[i][DS_SPINND]);
sprintf (tmp_path, "%sdrive_startup.wav", currprefs.dfxclickexternal[i]);
v += loadsample (tmp_path, &drvs[i][DS_START]);
sprintf (tmp_path, "%sdrive_snatch.wav", currprefs.dfxclickexternal[i]);
v += loadsample (tmp_path, &drvs[i][DS_SNATCH]);
#else
char * start_path = "."; //TODO - ??? set correct path
sprintf (tmp_path, "%suae_data%cdrive_click_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]);
v = loadsample (tmp_path, &drvs[i][DS_CLICK]);
sprintf (tmp_path, "%suae_data%cdrive_spin_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]);
v += loadsample (tmp_path, &drvs[i][DS_SPIN]);
sprintf (tmp_path, "%suae_data%cdrive_spinnd_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]);
v += loadsample (tmp_path, &drvs[i][DS_SPINND]);
sprintf (tmp_path, "%suae_data%cdrive_startup_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]);
v += loadsample (tmp_path, &drvs[i][DS_START]);
sprintf (tmp_path, "%suae_data%cdrive_snatch_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]);
v += loadsample (tmp_path, &drvs[i][DS_SNATCH]);
#endif /* GEKKO */
} }
if (v == 0) { if (v == 0) {
int j; int j;
for (j = 0; j < DS_END; j++) for (j = 0; j < DS_END; j++) {
freesample (&drvs[i][j]); freesample (&drvs[i][j]);
currprefs.dfxclick[i] = changed_prefs.dfxclick[i] = 0; }
currprefs.dfxclick[i] = changed_prefs.dfxclick[i] = 0;
} }
for (j = 0; j < DS_END; j++) for (j = 0; j < DS_END; j++) {
drvs[i][j].len <<= DS_SHIFT; drvs[i][j].len <<= DS_SHIFT;
}
drvs[i][DS_CLICK].pos = drvs[i][DS_CLICK].len; drvs[i][DS_CLICK].pos = drvs[i][DS_CLICK].len;
drvs[i][DS_SNATCH].pos = drvs[i][DS_SNATCH].len; drvs[i][DS_SNATCH].pos = drvs[i][DS_SNATCH].len;
vv += currprefs.dfxclick[i]; vv += currprefs.dfxclick[i];
#endif
} }
} }
if (vv > 0) { if (vv > 0) {
driveclick_reset (); write_log("reset driveclick \n");
click_initialized = 1; driveclick_reset ();
click_initialized = 1;
} }
} }

View File

@ -149,18 +149,16 @@ static const char *graphic_messages[] = {
/*00*/ "Correct aspect", /*00*/ "Correct aspect",
/*01*/ "^|off|100%|95%|93%|90%|custom", /*01*/ "^|off|100%|95%|93%|90%|custom",
/*02*/ " ", /*02*/ "Scanlines",
/*03*/ "Scanlines", /*03*/ "^|on|off",
/*04*/ "^|on|off", /*04*/ "Leds",
/*05*/ " ", /*05*/ "^|on|off",
/*06*/ "Leds", /*06*/ "Floppy sound",
/*07*/ "^|on|off", /*07*/ "^|on|off",
/*08*/ " ", /*08*/ "Port",
/*09*/ "Port", /*09*/ "^|SD|USB|SMB",
/*10*/ "^|SD|USB|SMB", /*10*/ "Rumble",
/*11*/ " ", /*11*/ "^|on|off",
/*12*/ "Rumble",
/*13*/ "^|on|off",
NULL NULL
}; };
@ -538,6 +536,25 @@ cfgfile_save(&changed_prefs, user_options, 0);
msgInfo("Configurations saved",3000,NULL); msgInfo("Configurations saved",3000,NULL);
} }
int get_dfxclick(void)
{
int sounddf_on = 0;
int i;
for (i=0; i < 4; i++)
if (changed_prefs.dfxclick[i]&&(changed_prefs.dfxtype[i]>=0)) sounddf_on =1;
return sounddf_on;
}
void set_dfxclick(int sounddf_on)
{
int i;
for (i=0; i < 4; i++)
if ((changed_prefs.dfxtype[i]>=0)&&(changed_prefs.dfxclick[i]!=sounddf_on))
changed_prefs.dfxclick[i] = sounddf_on;
}
static void emulation_options(void) static void emulation_options(void)
{ {
int submenus[7]; int submenus[7];
@ -571,7 +588,7 @@ static void emulation_options(void)
static void graphic_options(void) static void graphic_options(void)
{ {
int submenus[5]; int submenus[6];
int opt; int opt;
memset(submenus, 0, sizeof(submenus)); memset(submenus, 0, sizeof(submenus));
@ -580,8 +597,9 @@ static void graphic_options(void)
submenus[0] = get_gfx_aspect_ratio(); submenus[0] = get_gfx_aspect_ratio();
submenus[1] = !(changed_prefs.gfx_linedbl == 2) ; submenus[1] = !(changed_prefs.gfx_linedbl == 2) ;
submenus[2] = !changed_prefs.leds_on_screen; submenus[2] = !changed_prefs.leds_on_screen;
submenus[3] = changed_prefs.Port; submenus[3] = !get_dfxclick();
submenus[4] = !changed_prefs.rumble; submenus[4] = changed_prefs.Port;
submenus[5] = !changed_prefs.rumble;
opt = menu_select_title("Other options menu", opt = menu_select_title("Other options menu",
graphic_messages, submenus); graphic_messages, submenus);
@ -591,8 +609,9 @@ static void graphic_options(void)
set_gfx_aspect_ratio(submenus[0]); set_gfx_aspect_ratio(submenus[0]);
changed_prefs.gfx_linedbl = submenus[1] ? 1 : 2; changed_prefs.gfx_linedbl = submenus[1] ? 1 : 2;
changed_prefs.leds_on_screen = !submenus[2]; changed_prefs.leds_on_screen = !submenus[2];
set_Port(submenus[3]); set_dfxclick(!submenus[3]);
changed_prefs.rumble = !submenus[4]; set_Port(submenus[4]);
changed_prefs.rumble = !submenus[5];
currprefs.leds_on_screen = changed_prefs.leds_on_screen; currprefs.leds_on_screen = changed_prefs.leds_on_screen;
currprefs.rumble = changed_prefs.rumble; currprefs.rumble = changed_prefs.rumble;
} }

View File

@ -21,6 +21,14 @@
#include "menu.h" #include "menu.h"
#include "VirtualKeyboard.h" #include "VirtualKeyboard.h"
struct joyinfo {
SDL_Joystick *joy;
unsigned int axles;
unsigned int buttons;
};
extern unsigned int nr_joysticks;
extern struct joyinfo joys[];
typedef struct typedef struct
{ {
@ -269,7 +277,7 @@ static const char **get_file_list(const char *base_dir)
{ {
char buf[255]; char buf[255];
const char *exts[] = {".adf", ".ADF", ".adz", ".ADZ", ".ipf", ".IPF", ".fdi", ".FDI", const char *exts[] = {".adf", ".ADF", ".adz", ".ADZ", ".ipf", ".IPF", ".fdi", ".FDI",
".sav", ".SAV", ".uss", ".USS", ".rom", ".ROM", NULL}; ".sav", ".SAV", ".uss", ".USS", ".rom", ".ROM", ".zip",".ZIP",".dms", ".DMS",NULL};
struct stat st; struct stat st;
snprintf(buf, 255, "%s/%s", base_dir, de->d_name); snprintf(buf, 255, "%s/%s", base_dir, de->d_name);
@ -687,8 +695,8 @@ uint32_t menu_wait_key_press(void)
static int joy_keys_last; static int joy_keys_last;
/* Wii-specific, sorry */ /* Wii-specific, sorry */
for (nr = 0; nr < SDL_NumJoysticks(); nr++) { for (nr = 0; nr < nr_joysticks; nr++) {
joy = SDL_JoystickOpen(nr); joy = joys[nr].joy;
if (!joy) if (!joy)
continue; continue;

View File

@ -22,7 +22,7 @@
extern int gui_is_active; extern int gui_is_active;
static unsigned int nr_joysticks; unsigned int nr_joysticks;
static int initialized; static int initialized;
struct joyinfo { struct joyinfo {
@ -31,7 +31,7 @@ struct joyinfo {
unsigned int buttons; unsigned int buttons;
}; };
static struct joyinfo joys[MAX_INPUT_DEVICES]; struct joyinfo joys[MAX_INPUT_DEVICES];
//Wiimote Rumble //Wiimote Rumble
#ifdef GEKKO #ifdef GEKKO

View File

@ -186,6 +186,10 @@ int init_sound (void)
uae_sem_wait (&sound_init_sem); uae_sem_wait (&sound_init_sem);
SDL_PauseAudio (0); SDL_PauseAudio (0);
#ifdef DRIVESOUND
driveclick_init();
#endif
return have_sound; return have_sound;
} }

View File

@ -21,6 +21,9 @@ extern void reset_sound (void);
STATIC_INLINE void check_sound_buffers (void) STATIC_INLINE void check_sound_buffers (void)
{ {
if ((char *)sndbufpt - (char *)sndbuffer >= sndbufsize) { if ((char *)sndbufpt - (char *)sndbuffer >= sndbufsize) {
#ifdef DRIVESOUND
driveclick_mix ((uae_s16*)sndbuffer, sndbufsize >> 1);
#endif
finish_sound_buffer (); finish_sound_buffer ();
sndbufpt = sndbuffer; sndbufpt = sndbuffer;
} }

View File

@ -170,5 +170,13 @@ floppy1type=0
floppy2type=-1 floppy2type=-1
floppy3type=-1 floppy3type=-1
# Enable floppy sound
floppy0sound=1
floppy1sound=1
floppy_volume=33
floppy0soundext=/uae/wave/
floppy1soundext=/uae/wave/
# Set keyboard language. Possible values are de, dk, es, us, se, fr, it # Set keyboard language. Possible values are de, dk, es, us, se, fr, it
kbd_lang=us kbd_lang=us