diff --git a/BasiliskII/src/Unix/sysdeps.h b/BasiliskII/src/Unix/sysdeps.h index 51a53c78..76406ae3 100644 --- a/BasiliskII/src/Unix/sysdeps.h +++ b/BasiliskII/src/Unix/sysdeps.h @@ -184,6 +184,96 @@ typedef off_t loff_t; typedef char * caddr_t; #endif + +/** + * Helper functions to byteswap data + **/ + +#if defined(__GNUC__) +#if defined(__x86_64__) || defined(__i386__) +// Linux/AMD64 currently has no asm optimized bswap_32() in +#define opt_bswap_32 do_opt_bswap_32 +static inline uint32 do_opt_bswap_32(uint32 x) +{ + uint32 v; + __asm__ __volatile__ ("bswap %0" : "=r" (v) : "0" (x)); + return v; +} +#endif +#endif + +#ifdef HAVE_BYTESWAP_H +#include +#endif + +#ifdef opt_bswap_16 +#undef bswap_16 +#define bswap_16 opt_bswap_16 +#endif +#ifndef bswap_16 +#define bswap_16 generic_bswap_16 +#endif + +static inline uint16 generic_bswap_16(uint16 x) +{ + return ((x & 0xff) << 8) | ((x >> 8) & 0xff); +} + +#ifdef opt_bswap_32 +#undef bswap_32 +#define bswap_32 opt_bswap_32 +#endif +#ifndef bswap_32 +#define bswap_32 generic_bswap_32 +#endif + +static inline uint32 generic_bswap_32(uint32 x) +{ + return (((x & 0xff000000) >> 24) | + ((x & 0x00ff0000) >> 8) | + ((x & 0x0000ff00) << 8) | + ((x & 0x000000ff) << 24) ); +} + +#if defined(__i386__) +#define opt_bswap_64 do_opt_bswap_64 +static inline uint64 do_opt_bswap_64(uint64 x) +{ + return (bswap_32(x >> 32) | (((uint64)bswap_32((uint32)x)) << 32)); +} +#endif + +#ifdef opt_bswap_64 +#undef bswap_64 +#define bswap_64 opt_bswap_64 +#endif +#ifndef bswap_64 +#define bswap_64 generic_bswap_64 +#endif + +static inline uint64 generic_bswap_64(uint64 x) +{ + return (((x & UVAL64(0xff00000000000000)) >> 56) | + ((x & UVAL64(0x00ff000000000000)) >> 40) | + ((x & UVAL64(0x0000ff0000000000)) >> 24) | + ((x & UVAL64(0x000000ff00000000)) >> 8) | + ((x & UVAL64(0x00000000ff000000)) << 8) | + ((x & UVAL64(0x0000000000ff0000)) << 24) | + ((x & UVAL64(0x000000000000ff00)) << 40) | + ((x & UVAL64(0x00000000000000ff)) << 56) ); +} + +#ifdef WORDS_BIGENDIAN +static inline uint16 tswap16(uint16 x) { return x; } +static inline uint32 tswap32(uint32 x) { return x; } +static inline uint64 tswap64(uint64 x) { return x; } +#else +static inline uint16 tswap16(uint16 x) { return bswap_16(x); } +static inline uint32 tswap32(uint32 x) { return bswap_32(x); } +static inline uint64 tswap64(uint64 x) { return bswap_64(x); } +#endif + + /* Time data type for Time Manager emulation */ #if defined(__MACH__) typedef mach_timespec_t tm_time_t; diff --git a/BasiliskII/src/audio.cpp b/BasiliskII/src/audio.cpp index 00a89996..1595d54f 100644 --- a/BasiliskII/src/audio.cpp +++ b/BasiliskII/src/audio.cpp @@ -31,6 +31,7 @@ #include "main.h" #include "audio.h" #include "audio_defs.h" +#include "user_strings.h" #define DEBUG 0 #include "debug.h" @@ -600,8 +601,9 @@ int16 SoundInStatus(uint32 pb, uint32 dce) uint32 *param = (uint32 *)Mac2HostAddr(pb + csParam); uint32 selector = param[0]; D(bug(" selector %c%c%c%c\n", selector >> 24, selector >> 16, selector >> 8, selector)); - switch (selector) { -#if 0 + uint32 selector_flipped = bswap_32(selector); // endianness of selector needs swapping? + switch (selector_flipped) { +//#if 0 case siDeviceName: { const char *str = GetString(STR_SOUND_IN_NAME); param[0] = 0; @@ -610,6 +612,7 @@ int16 SoundInStatus(uint32 pb, uint32 dce) } case siDeviceIcon: { + return -192; // early return: 68k code causes crash in sheep and link error in basilisk M68kRegisters r; static const uint8 proc[] = { 0x55, 0x8f, // subq.l #2,sp @@ -641,7 +644,7 @@ int16 SoundInStatus(uint32 pb, uint32 dce) } else return -192; // resNotFound } -#endif +//#endif default: return -231; // siUnknownInfoType } diff --git a/BasiliskII/src/include/user_strings.h b/BasiliskII/src/include/user_strings.h index c030b20e..1b9a4253 100644 --- a/BasiliskII/src/include/user_strings.h +++ b/BasiliskII/src/include/user_strings.h @@ -225,6 +225,9 @@ enum { STR_WINDOW_ITEM_MOUNT, STR_SUSPEND_WINDOW_TITLE, + // Audio + STR_SOUND_IN_NAME = 6000, + // External file system STR_EXTFS_NAME = 5000, STR_EXTFS_VOLUME_NAME diff --git a/BasiliskII/src/user_strings.cpp b/BasiliskII/src/user_strings.cpp index d182f633..41689552 100644 --- a/BasiliskII/src/user_strings.cpp +++ b/BasiliskII/src/user_strings.cpp @@ -243,6 +243,8 @@ user_string_def common_strings[] = { {STR_WINDOW_ITEM_MOUNT, "Mount"}, {STR_SUSPEND_WINDOW_TITLE, "Basilisk II suspended. Press space to reactivate."}, + {STR_SOUND_IN_NAME, "\010Built-In"}, + {STR_EXTFS_NAME, "Host Directory Tree"}, {STR_EXTFS_VOLUME_NAME, "Host"}, diff --git a/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj b/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj index dc5de2ad..061f85d2 100755 --- a/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj +++ b/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj @@ -29,7 +29,6 @@ 0846E4C214B1269600574779 /* basic-dyngen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CDC514A99EEF000B1711 /* basic-dyngen.cpp */; }; 0846E51314B128ED00574779 /* sheepshaver_glue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CDBB14A99EEF000B1711 /* sheepshaver_glue.cpp */; }; 0856CFC114A99EF0000B1711 /* adb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CD4B14A99EEF000B1711 /* adb.cpp */; }; - 0856CFC214A99EF0000B1711 /* audio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CD4C14A99EEF000B1711 /* audio.cpp */; }; 0856CFE614A99EF0000B1711 /* disk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CD7D14A99EEF000B1711 /* disk.cpp */; }; 0856CFEC14A99EF0000B1711 /* scsi_dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CD8414A99EEF000B1711 /* scsi_dummy.cpp */; }; 0856CFEE14A99EF0000B1711 /* emul_op.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CD8614A99EEF000B1711 /* emul_op.cpp */; }; @@ -96,6 +95,7 @@ 5DDE950F2255C8B4004D0E79 /* audio_defs_macosx.h in Headers */ = {isa = PBXBuildFile; fileRef = 5DDE950D2255C8B3004D0E79 /* audio_defs_macosx.h */; }; 5DDE95102255C8B4004D0E79 /* audio_macosx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DDE950E2255C8B3004D0E79 /* audio_macosx.cpp */; }; 5DDE95112255C8B4004D0E79 /* audio_macosx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DDE950E2255C8B3004D0E79 /* audio_macosx.cpp */; }; + 5DF4CB7F22B5BD5D00512A86 /* audio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DF4CB7E22B5BD5D00512A86 /* audio.cpp */; }; A7B1921418C35D4700791D8D /* DiskType.m in Sources */ = {isa = PBXBuildFile; fileRef = A7B1921318C35D4700791D8D /* DiskType.m */; }; E413A40320CF7E6D00FBE967 /* video_sdl2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E413A40220CF7E6D00FBE967 /* video_sdl2.cpp */; }; E4150D1220D557820077C51A /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E4150D1120D557820077C51A /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -170,7 +170,6 @@ 0846E55214B12B0D00574779 /* paranoia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = paranoia.cpp; sourceTree = ""; }; 0856CCC114A99E1C000B1711 /* SheepShaver.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SheepShaver.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0856CD4B14A99EEF000B1711 /* adb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = adb.cpp; path = ../adb.cpp; sourceTree = SOURCE_ROOT; }; - 0856CD4C14A99EEF000B1711 /* audio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = audio.cpp; path = ../audio.cpp; sourceTree = SOURCE_ROOT; }; 0856CD7D14A99EEF000B1711 /* disk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = disk.cpp; path = ../disk.cpp; sourceTree = SOURCE_ROOT; }; 0856CD8414A99EEF000B1711 /* scsi_dummy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scsi_dummy.cpp; sourceTree = ""; }; 0856CD8614A99EEF000B1711 /* emul_op.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = emul_op.cpp; path = ../emul_op.cpp; sourceTree = SOURCE_ROOT; }; @@ -350,6 +349,7 @@ 5DDE950B2255C895004D0E79 /* AudioBackEnd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioBackEnd.h; path = ../../../BasiliskII/src/MacOSX/AudioBackEnd.h; sourceTree = ""; }; 5DDE950D2255C8B3004D0E79 /* audio_defs_macosx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = audio_defs_macosx.h; path = ../../../BasiliskII/src/MacOSX/audio_defs_macosx.h; sourceTree = ""; }; 5DDE950E2255C8B3004D0E79 /* audio_macosx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = audio_macosx.cpp; path = ../../../BasiliskII/src/MacOSX/audio_macosx.cpp; sourceTree = ""; }; + 5DF4CB7E22B5BD5D00512A86 /* audio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = audio.cpp; path = ../../../BasiliskII/src/audio.cpp; sourceTree = ""; }; A7B1921218C35D4700791D8D /* DiskType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiskType.h; sourceTree = ""; }; A7B1921318C35D4700791D8D /* DiskType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DiskType.m; sourceTree = ""; }; E413A40220CF7E6D00FBE967 /* video_sdl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = video_sdl2.cpp; path = ../../../BasiliskII/src/SDL/video_sdl2.cpp; sourceTree = ""; }; @@ -477,7 +477,7 @@ children = ( 087B91B11B780EC900825F7F /* CrossPlatform */, 0856CD4B14A99EEF000B1711 /* adb.cpp */, - 0856CD4C14A99EEF000B1711 /* audio.cpp */, + 5DF4CB7E22B5BD5D00512A86 /* audio.cpp */, 5D55CB3F225584D000FF8E81 /* cdrom.cpp */, 0856CD7D14A99EEF000B1711 /* disk.cpp */, 0856CD7E14A99EEF000B1711 /* dummy */, @@ -1068,13 +1068,13 @@ E44C460C20D262B0000583AE /* tcp_subr.c in Sources */, 0856CFC114A99EF0000B1711 /* adb.cpp in Sources */, E44C461520D262B0000583AE /* ip_output.c in Sources */, - 0856CFC214A99EF0000B1711 /* audio.cpp in Sources */, E44C461820D262B0000583AE /* tcp_output.c in Sources */, 0856CFE614A99EF0000B1711 /* disk.cpp in Sources */, 0856CFEC14A99EF0000B1711 /* scsi_dummy.cpp in Sources */, E44C460E20D262B0000583AE /* sbuf.c in Sources */, 0856CFEE14A99EF0000B1711 /* emul_op.cpp in Sources */, 0856CFF014A99EF0000B1711 /* ether.cpp in Sources */, + 5DF4CB7F22B5BD5D00512A86 /* audio.cpp in Sources */, 0856CFF314A99EF0000B1711 /* extfs.cpp in Sources */, 0856CFF414A99EF0000B1711 /* gfxaccel.cpp in Sources */, 0856D00914A99EF0000B1711 /* macos_util.cpp in Sources */,