Skip to content

Commit

Permalink
Load floppy drive sounds from fs-uae.dat (fixes missing drive sounds)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrodeSolheim committed Mar 31, 2016
1 parent 868dea1 commit c6d58ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 57 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Version 2.7.10dev:

* Load floppy drive sounds from fs-uae.dat (fixes missing drive sounds).
* Also look for named shaders in FS-UAE/Data/Shaders.
* Map Mod+cursors to Amiga cursor keys (useful with joystick emulation).

Expand Down
85 changes: 28 additions & 57 deletions src/od-fs/driveclick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "uae/fs.h"
#include "uae/glib.h"

#include <fs/data.h>

static const char *g_driveclick_path = "";
//static char *g_driveclick_name = NULL;

Expand All @@ -29,69 +31,38 @@ void amiga_set_drive_sound_name(const char *name)

int driveclick_loadresource (struct drvsample *sp, int drivetype)
{
int type, ok;
ok = 1;
for (type = 0; type < DS_END; type++) {
//int type = -1;
//int len = -1;
//unsigned char* data = NULL;
for (int type = 0; type < DS_END; type++) {
const char *name = NULL;
switch(type) {
case 0:
//type = DS_CLICK;
//data = drive_click_data;
//len = drive_click_data_size;
name = "drive_click.wav";
break;
case 1:
//type = DS_SPIN;
//data = drive_spin_data;
//len = drive_spin_data_size;
name = "drive_spin.wav";
break;
case 2:
//type = DS_SPINND;
//data = drive_spinnd_data;
//len = drive_spinnd_data_size;
name = "drive_spinnd.wav";
break;
case 3:
//type = DS_START;
//data = drive_startup_data;
//len = drive_startup_data_size;
name = "drive_startup.wav";
break;
case 4:
//type = DS_SNATCH;
//data = drive_snatch_data;
//len = drive_snatch_data_size;
name = "drive_snatch.wav";
break;
}

if (!name) {
switch (type) {
case 0:
name = "share/fs-uae/floppy_sounds/drive_click.wav";
break;
case 1:
name = "share/fs-uae/floppy_sounds/drive_spin.wav";
break;
case 2:
name = "share/fs-uae/floppy_sounds/drive_spinnd.wav";
break;
case 3:
name = "share/fs-uae/floppy_sounds/drive_startup.wav";
break;
case 4:
name = "share/fs-uae/floppy_sounds/drive_snatch.wav";
break;
default:
continue;
}

char *path = g_build_filename(g_driveclick_path, name, NULL);
int64_t size = fs_path_get_size(path);
if (size >= 0) {
char *data = NULL;
int size = 0;
if (fs_data_file_content(name, &data, &size) == 0) {
int len = (int) size;
void *buffer = g_malloc(len);
FILE* f = g_fopen(path, "rb");
int read = fread(buffer, 1, len, f);
if (read == size) {
struct drvsample* s = sp + type;
//write_log("decode drive click sample %d from %p len %d\n",
// type, data, len);
s->p = decodewav((uae_u8*) buffer, &len);
s->len = len;
}
g_free(buffer);
struct drvsample* s = sp + type;
s->p = decodewav((uae_u8*) data, &len);
s->len = len;
free(data);
}
g_free(path);
}
return ok;
return 1;
}

void driveclick_fdrawcmd_close(int drive)
Expand Down

0 comments on commit c6d58ee

Please sign in to comment.