diff --git a/BasiliskII/src/MacOSX/AudioDevice.cpp b/BasiliskII/src/MacOSX/AudioDevice.cpp index 9fe065f6..7b6e860e 100644 --- a/BasiliskII/src/MacOSX/AudioDevice.cpp +++ b/BasiliskII/src/MacOSX/AudioDevice.cpp @@ -51,23 +51,23 @@ void AudioDevice::Init(AudioDeviceID devid, bool isInput) UInt32 propsize; propsize = sizeof(UInt32); - verify_noerr(AudioDeviceGetProperty(mID, 0, mIsInput, kAudioDevicePropertySafetyOffset, &propsize, &mSafetyOffset)); + __Verify_noErr(AudioDeviceGetProperty(mID, 0, mIsInput, kAudioDevicePropertySafetyOffset, &propsize, &mSafetyOffset)); propsize = sizeof(UInt32); - verify_noerr(AudioDeviceGetProperty(mID, 0, mIsInput, kAudioDevicePropertyBufferFrameSize, &propsize, &mBufferSizeFrames)); + __Verify_noErr(AudioDeviceGetProperty(mID, 0, mIsInput, kAudioDevicePropertyBufferFrameSize, &propsize, &mBufferSizeFrames)); propsize = sizeof(AudioStreamBasicDescription); - verify_noerr(AudioDeviceGetProperty(mID, 0, mIsInput, kAudioDevicePropertyStreamFormat, &propsize, &mFormat)); + __Verify_noErr(AudioDeviceGetProperty(mID, 0, mIsInput, kAudioDevicePropertyStreamFormat, &propsize, &mFormat)); } void AudioDevice::SetBufferSize(UInt32 size) { UInt32 propsize = sizeof(UInt32); - verify_noerr(AudioDeviceSetProperty(mID, NULL, 0, mIsInput, kAudioDevicePropertyBufferFrameSize, propsize, &size)); + __Verify_noErr(AudioDeviceSetProperty(mID, NULL, 0, mIsInput, kAudioDevicePropertyBufferFrameSize, propsize, &size)); propsize = sizeof(UInt32); - verify_noerr(AudioDeviceGetProperty(mID, 0, mIsInput, kAudioDevicePropertyBufferFrameSize, &propsize, &mBufferSizeFrames)); + __Verify_noErr(AudioDeviceGetProperty(mID, 0, mIsInput, kAudioDevicePropertyBufferFrameSize, &propsize, &mBufferSizeFrames)); } int AudioDevice::CountChannels() @@ -92,6 +92,6 @@ int AudioDevice::CountChannels() char * AudioDevice::GetName(char *buf, UInt32 maxlen) { - verify_noerr(AudioDeviceGetProperty(mID, 0, mIsInput, kAudioDevicePropertyDeviceName, &maxlen, buf)); + __Verify_noErr(AudioDeviceGetProperty(mID, 0, mIsInput, kAudioDevicePropertyDeviceName, &maxlen, buf)); return buf; } diff --git a/BasiliskII/src/MacOSX/BasiliskII.xcodeproj/project.pbxproj b/BasiliskII/src/MacOSX/BasiliskII.xcodeproj/project.pbxproj index 54a3e047..6b9cd01d 100644 --- a/BasiliskII/src/MacOSX/BasiliskII.xcodeproj/project.pbxproj +++ b/BasiliskII/src/MacOSX/BasiliskII.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 5D5C3B0A24B2DF3500CDAB41 /* bincue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D5C3B0924B2DF3400CDAB41 /* bincue.cpp */; }; 752F26F91F240E51001032B4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 752F26F81F240E51001032B4 /* Foundation.framework */; }; 752F26FB1F240E69001032B4 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 752F26FA1F240E69001032B4 /* IOKit.framework */; }; 752F27011F242BAF001032B4 /* prefs_sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752F27001F242BAF001032B4 /* prefs_sdl.cpp */; }; @@ -49,7 +50,6 @@ 7539E1E11F23B25A006B2DF2 /* user_strings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E1221F23B25A006B2DF2 /* user_strings.cpp */; }; 7539E1E21F23B25A006B2DF2 /* video.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E1231F23B25A006B2DF2 /* video.cpp */; }; 7539E1E31F23B25A006B2DF2 /* xpram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E1241F23B25A006B2DF2 /* xpram.cpp */; }; - 7539E23F1F23B32A006B2DF2 /* bincue_unix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E1F01F23B329006B2DF2 /* bincue_unix.cpp */; }; 7539E24A1F23B32A006B2DF2 /* disk_sparsebundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E1FD1F23B32A006B2DF2 /* disk_sparsebundle.cpp */; }; 7539E2681F23B32A006B2DF2 /* rpc_unix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E2241F23B32A006B2DF2 /* rpc_unix.cpp */; }; 7539E26C1F23B32A006B2DF2 /* sshpty.c in Sources */ = {isa = PBXBuildFile; fileRef = 7539E22A1F23B32A006B2DF2 /* sshpty.c */; }; @@ -115,6 +115,15 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 5D5C3B0924B2DF3400CDAB41 /* bincue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bincue.cpp; path = ../bincue.cpp; sourceTree = ""; }; + 5D5C3B0B24B2DF4200CDAB41 /* bincue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bincue.h; sourceTree = ""; }; + 5DDE95122255D075004D0E79 /* AudioBackEnd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioBackEnd.h; sourceTree = ""; }; + 5DDE95132255D076004D0E79 /* AudioDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioDevice.cpp; sourceTree = ""; }; + 5DDE95142255D076004D0E79 /* AudioDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioDevice.h; sourceTree = ""; }; + 5DDE95152255D076004D0E79 /* audio_macosx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audio_macosx.cpp; sourceTree = ""; }; + 5DDE95162255D076004D0E79 /* MacOSX_sound_if.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacOSX_sound_if.cpp; sourceTree = ""; }; + 5DDE95172255D076004D0E79 /* AudioBackEnd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioBackEnd.cpp; sourceTree = ""; }; + 5DDE95182255D076004D0E79 /* MacOSX_sound_if.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacOSX_sound_if.h; sourceTree = ""; }; 752F26F81F240E51001032B4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 752F26FA1F240E69001032B4 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; 752F27001F242BAF001032B4 /* prefs_sdl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = prefs_sdl.cpp; sourceTree = ""; }; @@ -226,8 +235,6 @@ 7539E1221F23B25A006B2DF2 /* user_strings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = user_strings.cpp; path = ../user_strings.cpp; sourceTree = ""; }; 7539E1231F23B25A006B2DF2 /* video.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = video.cpp; path = ../video.cpp; sourceTree = ""; }; 7539E1241F23B25A006B2DF2 /* xpram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = xpram.cpp; path = ../xpram.cpp; sourceTree = ""; }; - 7539E1F01F23B329006B2DF2 /* bincue_unix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bincue_unix.cpp; sourceTree = ""; }; - 7539E1F11F23B329006B2DF2 /* bincue_unix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bincue_unix.h; sourceTree = ""; }; 7539E1F81F23B329006B2DF2 /* gtk-osx.patch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "gtk-osx.patch"; sourceTree = ""; }; 7539E1FA1F23B32A006B2DF2 /* mkstandalone */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = mkstandalone; sourceTree = ""; }; 7539E1FC1F23B32A006B2DF2 /* testlmem.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = testlmem.sh; sourceTree = ""; }; @@ -472,6 +479,7 @@ 7539DFD91F23B25A006B2DF2 /* adb.h */, 7539DFDA1F23B25A006B2DF2 /* audio.h */, 7539DFDB1F23B25A006B2DF2 /* audio_defs.h */, + 5D5C3B0B24B2DF4200CDAB41 /* bincue.h */, 7539DFDC1F23B25A006B2DF2 /* cdrom.h */, 7539DFDD1F23B25A006B2DF2 /* clip.h */, 7539DFDE1F23B25A006B2DF2 /* debug.h */, @@ -525,6 +533,13 @@ 756C1B321F252FC100620917 /* utils_macosx.h */, 756C1B331F252FC100620917 /* utils_macosx.mm */, 7539E02E1F23B25A006B2DF2 /* Versions.html */, + 5DDE95152255D076004D0E79 /* audio_macosx.cpp */, + 5DDE95172255D076004D0E79 /* AudioBackEnd.cpp */, + 5DDE95122255D075004D0E79 /* AudioBackEnd.h */, + 5DDE95132255D076004D0E79 /* AudioDevice.cpp */, + 5DDE95142255D076004D0E79 /* AudioDevice.h */, + 5DDE95162255D076004D0E79 /* MacOSX_sound_if.cpp */, + 5DDE95182255D076004D0E79 /* MacOSX_sound_if.h */, ); name = MacOSX; sourceTree = ""; @@ -607,6 +622,7 @@ children = ( 7539DFC91F23B25A006B2DF2 /* adb.cpp */, 7539DFCA1F23B25A006B2DF2 /* audio.cpp */, + 5D5C3B0924B2DF3400CDAB41 /* bincue.cpp */, 7539DFCB1F23B25A006B2DF2 /* cdrom.cpp */, 7539DFCC1F23B25A006B2DF2 /* CrossPlatform */, 7539DFD41F23B25A006B2DF2 /* disk.cpp */, @@ -642,8 +658,6 @@ 7539E1E91F23B329006B2DF2 /* Unix */ = { isa = PBXGroup; children = ( - 7539E1F01F23B329006B2DF2 /* bincue_unix.cpp */, - 7539E1F11F23B329006B2DF2 /* bincue_unix.h */, 7539E1F71F23B329006B2DF2 /* Darwin */, 7539E1FD1F23B32A006B2DF2 /* disk_sparsebundle.cpp */, 7539E1FE1F23B32A006B2DF2 /* disk_unix.h */, @@ -838,6 +852,7 @@ 753253321F5368370024025B /* cpuemu.cpp in Sources */, 7539E2701F23B32A006B2DF2 /* tinyxml2.cpp in Sources */, 7539E1721F23B25A006B2DF2 /* rsrc_patches.cpp in Sources */, + 5D5C3B0A24B2DF3500CDAB41 /* bincue.cpp in Sources */, 7539E2931F23C56F006B2DF2 /* serial_dummy.cpp in Sources */, 7539E1981F23B25A006B2DF2 /* exceptions.cpp in Sources */, 75CBCF771F5DB65E00830063 /* video_sdl.cpp in Sources */, @@ -874,7 +889,6 @@ 7539E18E1F23B25A006B2DF2 /* sony.cpp in Sources */, 7539E26F1F23B32A006B2DF2 /* timer_unix.cpp in Sources */, 7539E12E1F23B25A006B2DF2 /* extfs.cpp in Sources */, - 7539E23F1F23B32A006B2DF2 /* bincue_unix.cpp in Sources */, 7539E12C1F23B25A006B2DF2 /* emul_op.cpp in Sources */, E413D92720D260BC00E437D8 /* debug.c in Sources */, E413D92220D260BC00E437D8 /* mbuf.c in Sources */, @@ -1050,10 +1064,15 @@ GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_ENABLE_PASCAL_STRINGS = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", ENABLE_MACOSX_ETHERHELPER, HAVE_CONFIG_H, + "USE_XCODE=1", + "DEBUG=1", + "USE_SDL_AUDIO=1", + "BINCUE=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_USE_STANDARD_INCLUDE_SEARCHING = YES; @@ -1111,6 +1130,9 @@ "$(inherited)", ENABLE_MACOSX_ETHERHELPER, HAVE_CONFIG_H, + "USE_XCODE=1", + "USE_SDL_AUDIO=1", + "BINCUE=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_USE_STANDARD_INCLUDE_SEARCHING = YES; diff --git a/BasiliskII/src/MacOSX/MacOSX_sound_if.h b/BasiliskII/src/MacOSX/MacOSX_sound_if.h index 5cfdd438..06e06da4 100644 --- a/BasiliskII/src/MacOSX/MacOSX_sound_if.h +++ b/BasiliskII/src/MacOSX/MacOSX_sound_if.h @@ -18,6 +18,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef MACOSX_SOUND_IF +#define MACOSX_SOUND_IF typedef int (*audioCallback)(void); @@ -39,3 +41,5 @@ class OSXsoundOutput { unsigned int bufferSizeFrames(); int sendAudioBuffer(void *buffer, int numFrames); }; + +#endif diff --git a/BasiliskII/src/MacOSX/audio_macosx.cpp b/BasiliskII/src/MacOSX/audio_macosx.cpp index 840d2f13..5e5d25a3 100644 --- a/BasiliskII/src/MacOSX/audio_macosx.cpp +++ b/BasiliskII/src/MacOSX/audio_macosx.cpp @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef USE_SDL_AUDIO + #include "sysdeps.h" #include @@ -269,3 +271,5 @@ static int audioInt(void) TriggerInterrupt(); return 0; } + +#endif diff --git a/BasiliskII/src/SDL/audio_sdl.cpp b/BasiliskII/src/SDL/audio_sdl.cpp index 6bff36c3..45286738 100644 --- a/BasiliskII/src/SDL/audio_sdl.cpp +++ b/BasiliskII/src/SDL/audio_sdl.cpp @@ -34,7 +34,7 @@ #include "debug.h" #if defined(BINCUE) -#include "bincue_unix.h" +#include "bincue.h" #endif @@ -112,7 +112,7 @@ static bool open_sdl_audio(void) #if defined(BINCUE) OpenAudio_bincue(audio_spec.freq, audio_spec.format, audio_spec.channels, - audio_spec.silence); + audio_spec.silence, audio_volume); #endif #if SDL_VERSION_ATLEAST(2,0,0) @@ -249,11 +249,13 @@ static void stream_func(void *arg, uint8 *stream, int stream_len) } else { // Audio not active, play silence -silence: memset(stream, silence_byte, stream_len); + silence: memset(stream, silence_byte, stream_len); } + #if defined(BINCUE) - MixAudio_bincue(stream, stream_len); + MixAudio_bincue(stream, stream_len, audio_volume); #endif + } diff --git a/BasiliskII/src/Unix/Makefile.in b/BasiliskII/src/Unix/Makefile.in index 42f1b049..1b911c68 100644 --- a/BasiliskII/src/Unix/Makefile.in +++ b/BasiliskII/src/Unix/Makefile.in @@ -100,7 +100,7 @@ define GUI_SRCS_LIST_TO_OBJS endef GUI_OBJS = $(GUI_SRCS_LIST_TO_OBJS) ifeq ($(USE_BINCUE),yes) -GUI_OBJS += bincue_unix.o +GUI_OBJS += bincue.o endif GUI_SRCS := $(GUI_SRCS:%=@top_srcdir@/%) diff --git a/BasiliskII/src/Unix/configure.ac b/BasiliskII/src/Unix/configure.ac index b3bfc3b9..a812738b 100755 --- a/BasiliskII/src/Unix/configure.ac +++ b/BasiliskII/src/Unix/configure.ac @@ -369,6 +369,7 @@ AS_IF([test "x$with_bincue" = "xyes" ], [have_bincue=yes], [have_bincue=no]) AS_IF([test "x$have_bincue" = "xyes" ], [ if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then DEFINES="$DEFINES -DBINCUE" + CPPFLAGS="$CPPFLAGS -DBINCUE" AC_SUBST(USE_BINCUE, yes) else AC_MSG_ERROR([You need SDL Audio to use BINCUE support.]) @@ -898,7 +899,7 @@ fi dnl BINCUE overrides if [[ "x$have_bincue" = "xyes" ]]; then - EXTRASYSSRCS="$EXTRASYSSRCS bincue_unix.cpp" + EXTRASYSSRCS="$EXTRASYSSRCS bincue.cpp" fi dnl libvhd overrides diff --git a/BasiliskII/src/Unix/sys_unix.cpp b/BasiliskII/src/Unix/sys_unix.cpp index 9c25feb5..9cfc06ce 100755 --- a/BasiliskII/src/Unix/sys_unix.cpp +++ b/BasiliskII/src/Unix/sys_unix.cpp @@ -59,7 +59,7 @@ #include "disk_unix.h" #if defined(BINCUE) -#include "bincue_unix.h" +#include "bincue.h" #endif @@ -1407,8 +1407,13 @@ bool SysCDScan(void *arg, uint8 start_m, uint8 start_s, uint8 start_f, bool reve mac_file_handle *fh = (mac_file_handle *)arg; if (!fh) return false; - - // Not supported under Linux + +#if defined(BINCUE) + if (fh->is_bincue) + return CDScan_bincue(fh->bincue_fd,start_m,start_s,start_f,reverse); +#endif + + // Not supported outside bincue return false; } @@ -1422,6 +1427,11 @@ void SysCDSetVolume(void *arg, uint8 left, uint8 right) mac_file_handle *fh = (mac_file_handle *)arg; if (!fh) return; + +#if defined(BINCUE) + if (fh->is_bincue) + CDSetVol_bincue(fh->bincue_fd,left,right); +#endif if (fh->is_cdrom) { #if defined(__linux__) @@ -1450,6 +1460,12 @@ void SysCDGetVolume(void *arg, uint8 &left, uint8 &right) return; left = right = 0; + +#if defined(BINCUE) + if (fh->is_bincue) + CDGetVol_bincue(fh->bincue_fd,&left,&right); +#endif + if (fh->is_cdrom) { #if defined(__linux__) cdrom_volctrl vol; 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/Windows/Makefile.in b/BasiliskII/src/Windows/Makefile.in index 156d1f81..40fc67db 100755 --- a/BasiliskII/src/Windows/Makefile.in +++ b/BasiliskII/src/Windows/Makefile.in @@ -31,6 +31,8 @@ SLIRP_SRCS = \ ../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c SLIRP_OBJS = $(SLIRP_SRCS:../slirp/%.c=$(OBJ_DIR)/slirp-%.o) +USE_BINCUE = @USE_BINCUE@ + LN_S = @LN_S@ WINDRES = @WINDRES@ CC = @CC@ @@ -42,6 +44,7 @@ DEFS = @DEFS@ @DEFINES@ LDFLAGS = @LDFLAGS@ -Wl,-Bstatic LIBS = @LIBS@ -lws2_32 -lwsock32 -liphlpapi CPUSRCS = @CPUSRCS@ +EXTRASRCS = @EXTRASRCS@ HOST_CC = gcc HOST_CXX = g++ @@ -68,7 +71,7 @@ SRCS = ../main.cpp main_windows.cpp ../prefs.cpp ../prefs_items.cpp prefs_window ../extfs.cpp extfs_windows.cpp ../user_strings.cpp user_strings_windows.cpp \ vm_alloc.cpp sigsegv.cpp posix_emu.cpp util_windows.cpp \ ../dummy/prefs_editor_dummy.cpp BasiliskII.rc \ - $(CDENABLESRCS) $(ROUTERSRCS) $(CPUSRCS) $(SLIRP_OBJS) + $(CDENABLESRCS) $(ROUTERSRCS) $(CPUSRCS) $(EXTRASRCS) $(SLIRP_OBJS) UI_SRCS = ../prefs.cpp prefs_windows.cpp prefs_editor_gtk.cpp xpram_windows.cpp \ ../prefs_items.cpp ../user_strings.cpp user_strings_windows.cpp util_windows.cpp \ diff --git a/BasiliskII/src/Windows/configure.ac b/BasiliskII/src/Windows/configure.ac index a13a3983..33540135 100755 --- a/BasiliskII/src/Windows/configure.ac +++ b/BasiliskII/src/Windows/configure.ac @@ -36,6 +36,9 @@ AC_ARG_ENABLE(fpe, dnl External packages. AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes]) +AC_ARG_WITH(bincue, + AS_HELP_STRING([--with-bincue], [Allow cdrom image files in bin/cue mode])) + dnl Addressing modes. AC_ARG_ENABLE(addressing, [ --enable-addressing=AM specify the addressing mode to use [default=fastest]], @@ -85,6 +88,14 @@ AC_SUBST(WANT_GTK) dnl We use 64-bit file size support if possible. AC_SYS_LARGEFILE +dnl BINCUE +AS_IF([test "x$with_bincue" = "xyes" ], [have_bincue=yes], [have_bincue=no]) +AS_IF([test "x$have_bincue" = "xyes" ], [ + DEFINES="$DEFINES -DBINCUE" + CPPFLAGS="$CPPFLAGS -DBINCUE" + AC_SUBST(USE_BINCUE, yes) +], [AC_SUBST(USE_BINCUE, no)]) + dnl Checks for header files. AC_HEADER_STDC @@ -304,6 +315,11 @@ elif [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_X86_64" = "xyes" ]]; then fi fi +dnl BINCUE overrides +if [[ "x$have_bincue" = "xyes" ]]; then + EXTRASRCS="$EXTRASRCS bincue.cpp" +fi + dnl Enable JIT compiler, if possible. if [[ "x$WANT_JIT" = "xyes" -a "x$CAN_JIT" ]]; then JITSRCS="$JITSRCS ../uae_cpu/compiler/compemu_support.cpp ../uae_cpu/compiler/compemu_fpp.cpp compstbl.o cpustbl_nf.o" @@ -552,6 +568,7 @@ dnl Generate Makefile. AC_SUBST(DEFINES) AC_SUBST(CPUINCLUDES) AC_SUBST(CPUSRCS) +AC_SUBST(EXTRASRCS) AC_CONFIG_FILES([Makefile]) AC_OUTPUT @@ -564,6 +581,7 @@ echo JIT debug mode ......................... : $WANT_JIT_DEBUG echo Floating-Point emulation core .......... : $FPE_CORE echo Assembly optimizations ................. : $ASM_OPTIMIZATIONS echo Addressing mode ........................ : $ADDRESSING_MODE +echo BINCUE support ......................... : $have_bincue echo GTK user interface ..................... : $WANT_GTK echo echo "Configuration done. Now type \"make\" (or \"gmake\")." diff --git a/BasiliskII/src/Windows/main_windows.cpp b/BasiliskII/src/Windows/main_windows.cpp index 3cdb871c..e8d39095 100755 --- a/BasiliskII/src/Windows/main_windows.cpp +++ b/BasiliskII/src/Windows/main_windows.cpp @@ -361,10 +361,10 @@ int main(int argc, char **argv) D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac)); // Get rom file path from preferences - auto rom_path = tstr(PrefsFindString("rom")); + const char* rom_path = PrefsFindString("rom"); // Load Mac ROM - HANDLE rom_fh = CreateFile(rom_path ? rom_path.get() : ROM_FILE_NAME, + HANDLE rom_fh = CreateFile((rom_path != NULL) ? rom_path : ROM_FILE_NAME, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, diff --git a/BasiliskII/src/Windows/sys_windows.cpp b/BasiliskII/src/Windows/sys_windows.cpp index 21e2df0e..8e876307 100755 --- a/BasiliskII/src/Windows/sys_windows.cpp +++ b/BasiliskII/src/Windows/sys_windows.cpp @@ -40,6 +40,10 @@ using std::min; #include "cdenable/cache.h" #include "cdenable/eject_nt.h" +#if defined(BINCUE) +#include "bincue.h" +#endif + #define DEBUG 0 #include "debug.h" @@ -56,6 +60,12 @@ struct file_handle { loff_t file_size; // Size of file data (only valid if is_file is true) cachetype cache; bool is_media_present; + +#if defined(BINCUE) + bool is_bincue; // Flag: BIN CUE file + void *bincue_fd; + file_handle() {is_bincue = false;} // default bincue false +#endif }; // Open file handles @@ -462,6 +472,11 @@ void *Sys_open(const char *path_name, bool read_only) read_only = true; // Open file + +#if defined(BINCUE) + void *binfd = open_bincue(name); // check if bincue +#endif + HANDLE h = CreateFile( name, read_only ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE, @@ -486,6 +501,16 @@ void *Sys_open(const char *path_name, bool read_only) fh->is_floppy = false; fh->is_cdrom = false; +#if defined(BINCUE) + if (binfd) { + fh->bincue_fd = binfd; + fh->is_bincue = true; + fh->is_media_present = true; + sys_add_file_handle(fh); + return fh; + } +#endif + // Detect disk image file layout loff_t size = GetFileSize(h, NULL); DWORD bytes_read; @@ -517,6 +542,11 @@ void Sys_close(void *arg) sys_remove_file_handle(fh); +#if defined(BINCUE) + if (fh->is_bincue) + close_bincue(fh->bincue_fd); +#endif + if (fh->is_cdrom) { cache_final(&fh->cache); SysAllowRemoval((void *)fh); @@ -543,6 +573,11 @@ size_t Sys_read(void *arg, void *buffer, loff_t offset, size_t length) if (!fh) return 0; +#if defined(BINCUE) + if (fh->is_bincue) + return read_bincue(fh->bincue_fd, buffer, offset, length); +#endif + DWORD bytes_read = 0; if (fh->is_file) { @@ -623,6 +658,11 @@ loff_t SysGetFileSize(void *arg) if (!fh) return true; +#if defined(BINCUE) + if (fh->is_bincue) + return size_bincue(fh->bincue_fd); +#endif + if (fh->is_file) return fh->file_size; else if (fh->is_cdrom) @@ -644,6 +684,13 @@ void SysEject(void *arg) if (!fh) return; +#if defined(BINCUE) + if (fh->is_bincue) { + fh->is_media_present = false; + return; + } +#endif + if (fh->is_cdrom && fh->fh) { fh->is_media_present = false; // Commented out because there was some problems, but can't remember @@ -782,16 +829,26 @@ void SysAllowRemoval(void *arg) bool SysCDReadTOC(void *arg, uint8 *toc) { file_handle *fh = (file_handle *)arg; - if (!fh || !fh->fh || !fh->is_cdrom) + if (!fh) return false; - DWORD dummy; - return DeviceIoControl(fh->fh, - IOCTL_CDROM_READ_TOC, - NULL, 0, - toc, min((int)sizeof(CDROM_TOC), 804), - &dummy, - NULL) != FALSE; +#if defined(BINCUE) + if (fh->is_bincue) + return readtoc_bincue(fh->bincue_fd, toc); +#endif + + if (fh->is_cdrom) { + + DWORD dummy; + return DeviceIoControl(fh->fh, + IOCTL_CDROM_READ_TOC, + NULL, 0, + toc, min((int)sizeof(CDROM_TOC), 804), + &dummy, + NULL) != FALSE; + + } else + return false; } @@ -802,26 +859,34 @@ bool SysCDReadTOC(void *arg, uint8 *toc) bool SysCDGetPosition(void *arg, uint8 *pos) { file_handle *fh = (file_handle *)arg; - if (!fh || !fh->fh || !fh->is_cdrom) + if (!fh) return false; - SUB_Q_CHANNEL_DATA q_data; +#if defined(BINCUE) + if (fh->is_bincue) + return GetPosition_bincue(fh->bincue_fd, pos); +#endif - CDROM_SUB_Q_DATA_FORMAT q_format; - q_format.Format = IOCTL_CDROM_CURRENT_POSITION; - q_format.Track = 0; // used only by ISRC reads + if (fh->is_cdrom) { + SUB_Q_CHANNEL_DATA q_data; - DWORD dwBytesReturned = 0; - bool ok = DeviceIoControl(fh->fh, - IOCTL_CDROM_READ_Q_CHANNEL, - &q_format, sizeof(CDROM_SUB_Q_DATA_FORMAT), - &q_data, sizeof(SUB_Q_CHANNEL_DATA), - &dwBytesReturned, - NULL) != FALSE; - if (ok) - memcpy(pos, &q_data.CurrentPosition, sizeof(SUB_Q_CURRENT_POSITION)); + CDROM_SUB_Q_DATA_FORMAT q_format; + q_format.Format = IOCTL_CDROM_CURRENT_POSITION; + q_format.Track = 0; // used only by ISRC reads - return ok; + DWORD dwBytesReturned = 0; + bool ok = DeviceIoControl(fh->fh, + IOCTL_CDROM_READ_Q_CHANNEL, + &q_format, sizeof(CDROM_SUB_Q_DATA_FORMAT), + &q_data, sizeof(SUB_Q_CHANNEL_DATA), + &dwBytesReturned, + NULL) != FALSE; + if (ok) + memcpy(pos, &q_data.CurrentPosition, sizeof(SUB_Q_CURRENT_POSITION)); + + return ok; + } else + return false; } @@ -832,24 +897,32 @@ bool SysCDGetPosition(void *arg, uint8 *pos) bool SysCDPlay(void *arg, uint8 start_m, uint8 start_s, uint8 start_f, uint8 end_m, uint8 end_s, uint8 end_f) { file_handle *fh = (file_handle *)arg; - if (!fh || !fh->fh || !fh->is_cdrom) + if (!fh) return false; - CDROM_PLAY_AUDIO_MSF msf; - msf.StartingM = start_m; - msf.StartingS = start_s; - msf.StartingF = start_f; - msf.EndingM = end_m; - msf.EndingS = end_s; - msf.EndingF = end_f; +#if defined(BINCUE) + if (fh->is_bincue) + return CDPlay_bincue(fh->bincue_fd, start_m, start_s, start_f, end_m, end_s, end_f); +#endif - DWORD dwBytesReturned = 0; - return DeviceIoControl(fh->fh, - IOCTL_CDROM_PLAY_AUDIO_MSF, - &msf, sizeof(CDROM_PLAY_AUDIO_MSF), - NULL, 0, - &dwBytesReturned, - NULL) != FALSE; + if (fh->is_cdrom) { + CDROM_PLAY_AUDIO_MSF msf; + msf.StartingM = start_m; + msf.StartingS = start_s; + msf.StartingF = start_f; + msf.EndingM = end_m; + msf.EndingS = end_s; + msf.EndingF = end_f; + + DWORD dwBytesReturned = 0; + return DeviceIoControl(fh->fh, + IOCTL_CDROM_PLAY_AUDIO_MSF, + &msf, sizeof(CDROM_PLAY_AUDIO_MSF), + NULL, 0, + &dwBytesReturned, + NULL) != FALSE; + } else + return false; } @@ -860,16 +933,24 @@ bool SysCDPlay(void *arg, uint8 start_m, uint8 start_s, uint8 start_f, uint8 end bool SysCDPause(void *arg) { file_handle *fh = (file_handle *)arg; - if (!fh || !fh->fh || !fh->is_cdrom) + if (!fh) return false; - DWORD dwBytesReturned = 0; - return DeviceIoControl(fh->fh, - IOCTL_CDROM_PAUSE_AUDIO, - NULL, 0, - NULL, 0, - &dwBytesReturned, - NULL) != FALSE; +#if defined(BINCUE) + if (fh->is_bincue) + return CDPause_bincue(fh->bincue_fd); +#endif + + if (fh->is_cdrom) { + DWORD dwBytesReturned = 0; + return DeviceIoControl(fh->fh, + IOCTL_CDROM_PAUSE_AUDIO, + NULL, 0, + NULL, 0, + &dwBytesReturned, + NULL) != FALSE; + } else + return false; } @@ -880,15 +961,23 @@ bool SysCDPause(void *arg) bool SysCDResume(void *arg) { file_handle *fh = (file_handle *)arg; - if (!fh || !fh->fh || !fh->is_cdrom) + if (!fh) return false; - DWORD dwBytesReturned = 0; - return DeviceIoControl(fh->fh, - IOCTL_CDROM_RESUME_AUDIO, - NULL, 0, - NULL, 0, - &dwBytesReturned, NULL) != FALSE; +#if defined(BINCUE) + if (fh->is_bincue) + return CDResume_bincue(fh->bincue_fd); +#endif + + if (fh->is_cdrom) { + DWORD dwBytesReturned = 0; + return DeviceIoControl(fh->fh, + IOCTL_CDROM_RESUME_AUDIO, + NULL, 0, + NULL, 0, + &dwBytesReturned, NULL) != FALSE; + } else + return false; } @@ -899,16 +988,24 @@ bool SysCDResume(void *arg) bool SysCDStop(void *arg, uint8 lead_out_m, uint8 lead_out_s, uint8 lead_out_f) { file_handle *fh = (file_handle *)arg; - if (!fh || !fh->fh || !fh->is_cdrom) + if (!fh) return false; - DWORD dwBytesReturned = 0; - return DeviceIoControl(fh->fh, - IOCTL_CDROM_STOP_AUDIO, - NULL, 0, - NULL, 0, - &dwBytesReturned, - NULL) != FALSE; +#if defined(BINCUE) + if (fh->is_bincue) + return CDStop_bincue(fh->bincue_fd); +#endif + + if (fh->is_cdrom) { + DWORD dwBytesReturned = 0; + return DeviceIoControl(fh->fh, + IOCTL_CDROM_STOP_AUDIO, + NULL, 0, + NULL, 0, + &dwBytesReturned, + NULL) != FALSE; + } else + return false; } @@ -919,21 +1016,30 @@ bool SysCDStop(void *arg, uint8 lead_out_m, uint8 lead_out_s, uint8 lead_out_f) bool SysCDScan(void *arg, uint8 start_m, uint8 start_s, uint8 start_f, bool reverse) { file_handle *fh = (file_handle *)arg; - if (!fh || !fh->fh || !fh->is_cdrom) + if (!fh) return false; - CDROM_SEEK_AUDIO_MSF msf; - msf.M = start_m; - msf.S = start_s; - msf.F = start_f; +#if defined(BINCUE) + if (fh->is_bincue) + return CDScan_bincue(fh->bincue_fd,start_m,start_s,start_f,reverse); +#endif - DWORD dwBytesReturned = 0; - return DeviceIoControl(fh->fh, - IOCTL_CDROM_SEEK_AUDIO_MSF, - &msf, sizeof(CDROM_SEEK_AUDIO_MSF), - NULL, 0, - &dwBytesReturned, - NULL) != FALSE; + if (fh->is_cdrom) { + + CDROM_SEEK_AUDIO_MSF msf; + msf.M = start_m; + msf.S = start_s; + msf.F = start_f; + + DWORD dwBytesReturned = 0; + return DeviceIoControl(fh->fh, + IOCTL_CDROM_SEEK_AUDIO_MSF, + &msf, sizeof(CDROM_SEEK_AUDIO_MSF), + NULL, 0, + &dwBytesReturned, + NULL) != FALSE; + } else + return false; } @@ -944,22 +1050,30 @@ bool SysCDScan(void *arg, uint8 start_m, uint8 start_s, uint8 start_f, bool reve void SysCDSetVolume(void *arg, uint8 left, uint8 right) { file_handle *fh = (file_handle *)arg; - if (!fh || !fh->fh || !fh->is_cdrom) + if (!fh) return; - VOLUME_CONTROL vc; - vc.PortVolume[0] = left; - vc.PortVolume[1] = right; - vc.PortVolume[2] = left; - vc.PortVolume[3] = right; +#if defined(BINCUE) + if (fh->is_bincue) + CDSetVol_bincue(fh->bincue_fd,left,right); +#endif - DWORD dwBytesReturned = 0; - DeviceIoControl(fh->fh, - IOCTL_CDROM_SET_VOLUME, - &vc, sizeof(VOLUME_CONTROL), - NULL, 0, - &dwBytesReturned, - NULL); + if (fh->is_cdrom) { + + VOLUME_CONTROL vc; + vc.PortVolume[0] = left; + vc.PortVolume[1] = right; + vc.PortVolume[2] = left; + vc.PortVolume[3] = right; + + DWORD dwBytesReturned = 0; + DeviceIoControl(fh->fh, + IOCTL_CDROM_SET_VOLUME, + &vc, sizeof(VOLUME_CONTROL), + NULL, 0, + &dwBytesReturned, + NULL); + } } @@ -974,21 +1088,27 @@ void SysCDGetVolume(void *arg, uint8 &left, uint8 &right) return; left = right = 0; - if (!fh->fh || !fh->is_cdrom) - return; - VOLUME_CONTROL vc; - memset(&vc, 0, sizeof(vc)); +#if defined(BINCUE) + if (fh->is_bincue) + CDGetVol_bincue(fh->bincue_fd,&left,&right); +#endif + + if (fh->is_cdrom) { - DWORD dwBytesReturned = 0; - if (DeviceIoControl(fh->fh, - IOCTL_CDROM_GET_VOLUME, - NULL, 0, - &vc, sizeof(VOLUME_CONTROL), - &dwBytesReturned, - NULL)) - { - left = vc.PortVolume[0]; - right = vc.PortVolume[1]; + VOLUME_CONTROL vc; + memset(&vc, 0, sizeof(vc)); + + DWORD dwBytesReturned = 0; + if (DeviceIoControl(fh->fh, + IOCTL_CDROM_GET_VOLUME, + NULL, 0, + &vc, sizeof(VOLUME_CONTROL), + &dwBytesReturned, + NULL)) + { + left = vc.PortVolume[0]; + right = vc.PortVolume[1]; + } } } diff --git a/BasiliskII/src/Windows/sysdeps.h b/BasiliskII/src/Windows/sysdeps.h index 35a92f3b..ac040a43 100755 --- a/BasiliskII/src/Windows/sysdeps.h +++ b/BasiliskII/src/Windows/sysdeps.h @@ -21,11 +21,6 @@ #ifndef SYSDEPS_H #define SYSDEPS_H -#ifdef __MINGW32__ -#define _UNICODE -#define UNICODE -#endif - #if !defined _MSC_VER && !defined __STDC__ #error "Your compiler is not ANSI. Get a real one." #endif diff --git a/BasiliskII/src/audio.cpp b/BasiliskII/src/audio.cpp index 00a89996..6a52a0ef 100644 --- a/BasiliskII/src/audio.cpp +++ b/BasiliskII/src/audio.cpp @@ -31,6 +31,8 @@ #include "main.h" #include "audio.h" #include "audio_defs.h" +#include "user_strings.h" +#include "cdrom.h" #define DEBUG 0 #include "debug.h" @@ -533,7 +535,7 @@ delegate: // Delegate call to Apple Mixer } } - +// not currently using these functions /* * Sound input driver Open() routine */ @@ -553,7 +555,20 @@ int16 SoundInPrime(uint32 pb, uint32 dce) { D(bug("SoundInPrime\n")); //!! - return paramErr; + + uint16 code = ReadMacInt16(pb + csCode); + D(bug("SoundInControl %d\n", code)); + + if (code == 1) { + D(bug(" SoundInKillIO\n")); + //!! + return noErr; + } + + if (code != 2) + return -231; // siUnknownInfoType + + return noErr; } @@ -574,12 +589,20 @@ int16 SoundInControl(uint32 pb, uint32 dce) if (code != 2) return -231; // siUnknownInfoType - - 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)); + + uint32 selector = ReadMacInt32(pb + csParam); // 4-byte selector (should match via FOURCC above) switch (selector) { + case siInitializeDriver: { +// If possible, the driver initializes the device to a sampling rate of 22 kHz, a sample size of 8 bits, mono recording, no compression, automatic gain control on, and all other features off. + return noErr; + } + + case siCloseDriver: { +// The sound input device driver should stop any recording in progress, deallocate the input hardware, and initialize local variables to default settings. + return noErr; + } + default: return -231; // siUnknownInfoType } @@ -590,58 +613,123 @@ int16 SoundInControl(uint32 pb, uint32 dce) * Sound input driver Status() routine */ -int16 SoundInStatus(uint32 pb, uint32 dce) +int16 SoundInStatus(uint32 pb, uint32 dce) // A0 points to Device Manager parameter block (pb) and A1 to device control entry (dce) { uint16 code = ReadMacInt16(pb + csCode); D(bug("SoundInStatus %d\n", code)); if (code != 2) return -231; // siUnknownInfoType + + // two choices on return + // 1: if under 18 bytes, place # of bytes at (pb+csParam) and write from (pb+csParam+4) on + // 2: if over 18 bytes, place 0 at (pb+csParam) and directly write into buffer pointed to by bufferptr + uint32 selector = ReadMacInt32(pb + csParam); // 4-byte selector (should match via FOURCC above) + uint32 bufferptr = ReadMacInt32(pb + csParam + 4); // 4-byte address to the buffer in vm memory - 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 - case siDeviceName: { - const char *str = GetString(STR_SOUND_IN_NAME); - param[0] = 0; - memcpy((void *)param[1], str, strlen(str)); +//#if 0 + case siDeviceName: { // return name in STR255 format + const uint8 str[] = { // size 9 + 0x08, // 1-byte length + 0x42, 0x75, // Bu + 0x69, 0x6c, // il + 0x74, 0x2d, // t- + 0x69, 0x6e // in + }; + WriteMacInt32(pb + csParam, 0); // response will directly be written into buffer +// vm_memcpy(bufferptr, str, 9); + memcpy(Mac2HostAddr(bufferptr),str,9); return noErr; } case siDeviceIcon: { - M68kRegisters r; - static const uint8 proc[] = { - 0x55, 0x8f, // subq.l #2,sp - 0xa9, 0x94, // CurResFile - 0x42, 0x67, // clr.w -(sp) - 0xa9, 0x98, // UseResFile - 0x59, 0x8f, // subq.l #4,sp - 0x48, 0x79, 0x49, 0x43, 0x4e, 0x23, // move.l #'ICN#',-(sp) - 0x3f, 0x3c, 0xbf, 0x76, // move.w #-16522,-(sp) - 0xa9, 0xa0, // GetResource - 0x24, 0x5f, // move.l (sp)+,a2 - 0xa9, 0x98, // UseResFile - 0x20, 0x0a, // move.l a2,d0 - 0x66, 0x04, // bne 1 - 0x70, 0x00, // moveq #0,d0 - M68K_RTS >> 8, M68K_RTS & 0xff, - 0x2f, 0x0a, //1 move.l a2,-(sp) - 0xa9, 0x92, // DetachResource - 0x20, 0x4a, // move.l a2,a0 - 0xa0, 0x4a, // HNoPurge - 0x70, 0x01, // moveq #1,d0 - M68K_RTS >> 8, M68K_RTS & 0xff - }; - Execute68k(Host2MacAddr((uint8 *)proc), &r); - if (r.d[0]) { - param[0] = 4; // Length of returned data - param[1] = r.a[2]; // Handle to icon suite - return noErr; - } else - return -192; // resNotFound + // Borrow ICN resource from cd rom driver, just a hack since loading a true ICN would be better + WriteMacInt32(pb + csParam, 0); + WriteMacInt32(bufferptr, CDROMIconAddr); + return noErr; + + // 68k code causes crash in sheep and link error in basilisk +// M68kRegisters r; +// static const uint8 proc[] = { +// 0x55, 0x8f, // subq.l #2,sp +// 0xa9, 0x94, // CurResFile +// 0x42, 0x67, // clr.w -(sp) +// 0xa9, 0x98, // UseResFile +// 0x59, 0x8f, // subq.l #4,sp +// 0x48, 0x79, 0x49, 0x43, 0x4e, 0x23, // move.l #'ICN#',-(sp) +// 0x3f, 0x3c, 0xbf, 0x76, // move.w #-16522,-(sp) +// 0xa9, 0xa0, // GetResource +// 0x24, 0x5f, // move.l (sp)+,a2 +// 0xa9, 0x98, // UseResFile +// 0x20, 0x0a, // move.l a2,d0 +// 0x66, 0x04, // bne 1 +// 0x70, 0x00, // moveq #0,d0 +// M68K_RTS >> 8, M68K_RTS & 0xff, +// 0x2f, 0x0a, //1 move.l a2,-(sp) +// 0xa9, 0x92, // DetachResource +// 0x20, 0x4a, // move.l a2,a0 +// 0xa0, 0x4a, // HNoPurge +// 0x70, 0x01, // moveq #1,d0 +// M68K_RTS >> 8, M68K_RTS & 0xff +// }; +// Execute68k(Host2MacAddr((uint8 *)proc), &r); +// if (r.d[0]) { +// WriteMacInt32(pb + csParam, 4); // Length of returned data +// WriteMacInt32(pb + csParam + 4, r.a[2]); // Handle to icon suite +// return noErr; +// } else +// return -192; // resNotFound } -#endif + + case siInputSource: { + // return -231 if only 1 or index if more + return -231; + +// WriteMacInt32(pb + csParam, 4); +// WriteMacInt32(pb + csParam + 4, 1); // index 1 +// return noErr; + } + + case siInputSourceNames: { // list of sources in STR# resource format + // return -231 if only 1 or handle to STR# resource if more + return -231; + +// const uint8 str[] = { +// 0x00, 0x02, // 2-byte count of #strings +// 0x0b, // byte size indicator (up to 255 length supported) +// 0x49, 0x6e, // start of string in ASCII, In +// 0x74, 0x65, // te +// 0x72, 0x6e, // rn +// 0x61, 0x6c, // al +// 0x20, 0x43, // C +// 0x44, // D +// 0x0a, // size is 10 +// 0x4d, 0x69, // Mi +// 0x63, 0x72, // cr +// 0x6f, 0x70, // op +// 0x68, 0x6f, // ho +// 0x6e, 0x65, // ne +// }; +// +// WriteMacInt32(pb + csParam, 0); +// vm_memcpy(bufferptr, str, 25); +// return noErr; + } + + case siOptionsDialog: { + // 0 if no options box supported and 1 if so + WriteMacInt32(pb + csParam, 4); + WriteMacInt32(pb + csParam + 4, 0); + return noErr; + } + + case siPlayThruOnOff: { + // playthrough volume, 0 is off and 7 is max + WriteMacInt32(pb + csParam, 4); + WriteMacInt32(pb + csParam + 4, 0); + return noErr; + } +//#endif default: return -231; // siUnknownInfoType } diff --git a/BasiliskII/src/Unix/bincue_unix.cpp b/BasiliskII/src/bincue.cpp similarity index 56% rename from BasiliskII/src/Unix/bincue_unix.cpp rename to BasiliskII/src/bincue.cpp index 612cf790..a500811f 100644 --- a/BasiliskII/src/Unix/bincue_unix.cpp +++ b/BasiliskII/src/bincue.cpp @@ -41,6 +41,8 @@ #include #include +#include + #ifdef OSX_CORE_AUDIO #include "../MacOSX/MacOSX_sound_if.h" static int bincue_core_audio_callback(void); @@ -51,15 +53,20 @@ static int bincue_core_audio_callback(void); #include #endif -#include "bincue_unix.h" +#ifdef WIN32 +#define bzero(b,len) (memset((b), '\0', (len)), (void) 0) +#define bcopy(b1,b2,len) (memmove((b2), (b1), (len)), (void) 0) +#endif + +#include "bincue.h" #define DEBUG 0 #include "debug.h" #define MAXTRACK 100 #define MAXLINE 512 #define CD_FRAMES 75 -#define RAW_SECTOR_SIZE 2352 -#define COOKED_SECTOR_SIZE 2048 +//#define RAW_SECTOR_SIZE 2352 +//#define COOKED_SECTOR_SIZE 2048 // Bits of Track Control Field -- These are standard for scsi cd players @@ -91,6 +98,7 @@ typedef struct { unsigned int length; // Track length in frames loff_t fileoffset; // Track frame start within file unsigned int pregap; // Silence in frames to generate + unsigned int postgap; // Silence in frames to generate at end unsigned char tcf; // Track control field } Track; @@ -99,7 +107,10 @@ typedef struct { unsigned int length; // file length in frames int binfh; // binary file handle int tcnt; // number of tracks - Track tracks[MAXTRACK]; + Track tracks[MAXTRACK]; // Track management + int raw_sector_size; // Raw bytes to read per sector + int cooked_sector_size; // Actual data bytes per sector (depends on Mode) + int header_size; // Number of bytes used in header } CueSheet; typedef struct { @@ -110,10 +121,17 @@ typedef struct { unsigned int audioend; // end position if playing (frames) unsigned int silence; // pregap (silence) bytes unsigned char audiostatus; // See defines above for status + uint8 volume_left; // CD player volume (left) + uint8 volume_right; // CD player volume (right) + uint8 volume_mono; // CD player single-channel volume loff_t fileoffset; // offset from file beginning to audiostart + bool audio_enabled = false; // audio initialized for this player? #ifdef OSX_CORE_AUDIO OSXsoundOutput soundoutput; #endif +#ifdef USE_SDL_AUDIO + SDL_AudioStream *stream; +#endif } CDPlayer; // Minute,Second,Frame data type @@ -127,15 +145,24 @@ typedef struct { static unsigned int totalPregap; static unsigned int prestart; -// Audio System State +// Audio System Variables -static bool audio_enabled = false; static uint8 silence_byte; -// CD Player state. Note only one player is supported ! +// CD Player state; multiple players supported through vectors -static CDPlayer player; +std::vector players; + +CDPlayer* currently_playing = NULL; + +CDPlayer* CSToPlayer(CueSheet* cs) +{ + for (std::vector::iterator it = players.begin(); it != players.end(); ++it) + if (cs == (*it)->cs) // look for cuesheet matching existing player + return *it; + return NULL; // if no player with the cuesheet found, return null player +} static void FramesToMSF(unsigned int frames, MSF *msf) { @@ -181,7 +208,7 @@ static bool AddTrack(CueSheet *cs) } } - curr->fileoffset = curr->start * RAW_SECTOR_SIZE; + curr->fileoffset = curr->start * cs->raw_sector_size; // now we patch up the indicated time @@ -236,6 +263,11 @@ static bool ParseCueSheet(FILE *fh, CueSheet *cs, const char *cuefile) totalPregap = 0; prestart = 0; + + // Use Audio CD settings by default, otherwise data mode will be specified + cs->raw_sector_size = 2352; + cs->cooked_sector_size = 2352; + cs->header_size = 0; while (fgets(line, MAXLINE, fh) != NULL) { Track *curr = &cs->tracks[cs->tcnt]; @@ -294,11 +326,24 @@ static bool ParseCueSheet(FILE *fh, CueSheet *cs, const char *cuefile) } curr->number = i_track; - // parse track type + // parse track type and update sector size for data discs if applicable field = strtok(NULL, " \t\n\r"); - if (!strcmp("MODE1/2352", field)) { + if (!strcmp("MODE1/2352", field)) { // red-book CD-ROM standard curr->tcf = DATA; + cs->raw_sector_size = 2352; + cs->cooked_sector_size = 2048; + cs->header_size = 16; // remaining 288 bytes for error detection + } else if (!strcmp("MODE2/2352", field)) { // yellow-book CD-ROM standard + curr->tcf = DATA; + cs->raw_sector_size = 2352; + cs->cooked_sector_size = 2336; // no error bytes at end + cs->header_size = 16; + } else if (!strcmp("MODE1/2048", field)) { // pure data CD-ROM + curr->tcf = DATA; + cs->raw_sector_size = 2048; + cs->cooked_sector_size = 2048; + cs->header_size = 0; // no header or error bytes } else if (!strcmp("AUDIO", field)) { curr->tcf = AUDIO; } else { @@ -342,8 +387,18 @@ static bool ParseCueSheet(FILE *fh, CueSheet *cs, const char *cuefile) } curr->pregap = MSFToFrames(msf); + } else if (!strcmp("POSTGAP", keyword)) { + MSF msf; + char *field = strtok(NULL, " \t\n\r"); + if (3 != sscanf(field, "%d:%d:%d", + &msf.m, &msf.s, &msf.f)) { + D(bug("Expected postgap frame\n")); + goto fail; + } + curr->postgap = MSFToFrames(msf); + // Ignored directives - + } else if (!strcmp("TITLE", keyword)) { } else if (!strcmp("PERFORMER", keyword)) { } else if (!strcmp("REM", keyword)) { @@ -377,8 +432,12 @@ static bool LoadCueSheet(const char *cuefile, CueSheet *cs) if (!ParseCueSheet(fh, cs, cuefile)) goto fail; // Open bin file and find length - - if ((binfh = open(cs->binfile,O_RDONLY)) < 0) { + #ifdef WIN32 + binfh = open(cs->binfile,O_RDONLY|O_BINARY); + #else + binfh = open(cs->binfile,O_RDONLY); + #endif + if (binfh < 0) { D(bug("Can't read bin file %s\n", cs->binfile)); goto fail; } @@ -392,7 +451,7 @@ static bool LoadCueSheet(const char *cuefile, CueSheet *cs) tlast = &cs->tracks[cs->tcnt - 1]; - tlast->length = buf.st_size/RAW_SECTOR_SIZE + tlast->length = buf.st_size/cs->raw_sector_size - tlast->start + totalPregap; if (tlast->length < 0) { @@ -402,7 +461,7 @@ static bool LoadCueSheet(const char *cuefile, CueSheet *cs) // save bin file length and pointer - cs->length = buf.st_size/RAW_SECTOR_SIZE; + cs->length = buf.st_size/cs->raw_sector_size; cs->binfh = binfh; fclose(fh); @@ -423,45 +482,62 @@ static bool LoadCueSheet(const char *cuefile, CueSheet *cs) void *open_bincue(const char *name) { - CueSheet *cs; - - if (player.cs == NULL) { - cs = (CueSheet *) malloc(sizeof(CueSheet)); - if (!cs) { - D(bug("malloc failed\n")); - return NULL; - } - - if (LoadCueSheet(name, cs)) { - player.cs = cs; -#ifdef OSX_CORE_AUDIO - audio_enabled = true; -#endif - if (audio_enabled) - player.audiostatus = CDROM_AUDIO_NO_STATUS; - else - player.audiostatus = CDROM_AUDIO_INVALID; - player.audiofh = dup(cs->binfh); - return cs; - } - else - free(cs); + CueSheet *cs = (CueSheet *) malloc(sizeof(CueSheet)); + if (!cs) { + D(bug("malloc failed\n")); + return NULL; } + + if (LoadCueSheet(name, cs)) { + CDPlayer *player = (CDPlayer *) malloc(sizeof(CDPlayer)); + player->cs = cs; + player->volume_left = 0; + player->volume_right = 0; + player->volume_mono = 0; +#ifdef OSX_CORE_AUDIO + player->audio_enabled = true; +#endif + if (player->audio_enabled) + player->audiostatus = CDROM_AUDIO_NO_STATUS; + else + player->audiostatus = CDROM_AUDIO_INVALID; + player->audiofh = dup(cs->binfh); + + // add to list of available CD players + players.push_back(player); + + return cs; + } + else + free(cs); + return NULL; } void close_bincue(void *fh) { - - + CueSheet *cs = (CueSheet *) fh; + CDPlayer *player = CSToPlayer(cs); + + if (cs && player) { + free(cs); +#ifdef USE_SDL_AUDIO + if (player->stream) // if audiostream has been opened, free it as well + free(player->stream); +#endif + free(player); + } } /* * File read (cooked) * Data are stored in raw sectors of which only COOKED_SECTOR_SIZE - * bytes are valid -- the remaining include 16 bytes at the beginning + * bytes are valid -- the remaining include header bytes at the beginning * of each raw sector and RAW_SECTOR_SIZE - COOKED_SECTOR_SIZE - bytes - * at the end + * at the end for error correction + * + * The actual number of bytes used for header, raw, cooked, error depend + * on mode specified in the cuesheet * * We assume that a read request can land in the middle of * sector. We compute the byte address of that sector (sec) @@ -473,20 +549,20 @@ void close_bincue(void *fh) size_t read_bincue(void *fh, void *b, loff_t offset, size_t len) { + CueSheet *cs = (CueSheet *) fh; + size_t bytes_read = 0; // bytes read so far unsigned char *buf = (unsigned char *) b; // target buffer - unsigned char secbuf[RAW_SECTOR_SIZE]; // temporary buffer + unsigned char secbuf[cs->raw_sector_size]; // temporary buffer - off_t sec = ((offset/COOKED_SECTOR_SIZE) * RAW_SECTOR_SIZE); - off_t secoff = offset % COOKED_SECTOR_SIZE; + off_t sec = ((offset/cs->cooked_sector_size) * cs->raw_sector_size); + off_t secoff = offset % cs->cooked_sector_size; // sec contains location (in bytes) of next raw sector to read // secoff contains offset within that sector at which to start // reading since we can request a read that starts in the middle // of a sector - CueSheet *cs = (CueSheet *) fh; - if (cs == NULL || lseek(cs->binfh, sec, SEEK_SET) < 0) { return -1; } @@ -495,19 +571,19 @@ size_t read_bincue(void *fh, void *b, loff_t offset, size_t len) // bytes available in next raw sector or len (bytes) // we want whichever is less - size_t available = COOKED_SECTOR_SIZE - secoff; + size_t available = cs->cooked_sector_size - secoff; available = (available > len) ? len : available; // read the next raw sector - if (read(cs->binfh, secbuf, RAW_SECTOR_SIZE) != RAW_SECTOR_SIZE) { + if (read(cs->binfh, secbuf, cs->raw_sector_size) != cs->raw_sector_size) { return bytes_read; } - // copy cooked sector bytes (skip first 16) + // copy cooked sector bytes (skip header if needed, typically 16 bytes) // we want out of those available - bcopy(&secbuf[16+secoff], &buf[bytes_read], available); + bcopy(&secbuf[cs->header_size+secoff], &buf[bytes_read], available); // next sector we start at the beginning @@ -524,7 +600,7 @@ size_t read_bincue(void *fh, void *b, loff_t offset, size_t len) loff_t size_bincue(void *fh) { if (fh) { - return ((CueSheet *)fh)->length * COOKED_SECTOR_SIZE; + return ((CueSheet *)fh)->length * ((CueSheet *)fh)->cooked_sector_size; } return 0; } @@ -571,20 +647,22 @@ bool readtoc_bincue(void *fh, unsigned char *toc) bool GetPosition_bincue(void *fh, uint8 *pos) { CueSheet *cs = (CueSheet *) fh; - if (cs && player.cs == cs) { + CDPlayer *player = CSToPlayer(cs); + + if (cs && player) { MSF abs, rel; - int fpos = player.audioposition / RAW_SECTOR_SIZE + player.audiostart; + int fpos = player->audioposition / cs->raw_sector_size + player->audiostart; int trackno = PositionToTrack(cs, fpos); - if (!audio_enabled) + if (!(player->audio_enabled)) return false; FramesToMSF(fpos, &abs); if (trackno < cs->tcnt) { // compute position relative to start of frame - unsigned int position = player.audioposition/RAW_SECTOR_SIZE + - player.audiostart - player.cs->tracks[trackno].start; + unsigned int position = player->audioposition/cs->raw_sector_size + + player->audiostart - player->cs->tracks[trackno].start; FramesToMSF(position, &rel); } @@ -592,7 +670,7 @@ bool GetPosition_bincue(void *fh, uint8 *pos) FramesToMSF(0, &rel); *pos++ = 0; - *pos++ = player.audiostatus; + *pos++ = player->audiostatus; *pos++ = 0; *pos++ = 12; // Sub-Q data length *pos++ = 0; @@ -608,7 +686,7 @@ bool GetPosition_bincue(void *fh, uint8 *pos) *pos++ = rel.m; *pos++ = rel.s; *pos++ = rel.f; - *pos++ = 0; +// *pos++ = 0; // D(bug("CDROM position %02d:%02d:%02d track %02d\n", abs.m, abs.s, abs.f, trackno)); return true; } @@ -616,14 +694,26 @@ bool GetPosition_bincue(void *fh, uint8 *pos) return false; } +void CDPause_playing(CDPlayer* player) { + if (currently_playing && currently_playing != player) { + currently_playing->audiostatus = CDROM_AUDIO_PAUSED; + currently_playing = NULL; + } +} + bool CDPause_bincue(void *fh) { CueSheet *cs = (CueSheet *) fh; - if (cs && cs == player.cs) { - if (player.audiostatus == CDROM_AUDIO_PLAY) { - player.audiostatus = CDROM_AUDIO_PAUSED; - return true; - } + CDPlayer *player = CSToPlayer(cs); + + if (cs && player) { + // Pause another player if needed + CDPause_playing(player); + + // doesn't matter if it was playing, just ensure it's now paused + player->audiostatus = CDROM_AUDIO_PAUSED; + currently_playing = NULL; + return true; } return false; } @@ -631,13 +721,19 @@ bool CDPause_bincue(void *fh) bool CDStop_bincue(void *fh) { CueSheet *cs = (CueSheet *) fh; - - if (cs && cs == player.cs) { + CDPlayer *player = CSToPlayer(cs); + + if (cs && player) { + // Pause another player if needed + CDPause_playing(player); + #ifdef OSX_CORE_AUDIO - player.soundoutput.stop(); + player->soundoutput.stop(); #endif - if (player.audiostatus != CDROM_AUDIO_INVALID) - player.audiostatus = CDROM_AUDIO_NO_STATUS; + if (player->audiostatus != CDROM_AUDIO_INVALID) + player->audiostatus = CDROM_AUDIO_NO_STATUS; + + currently_playing = NULL; return true; } return false; @@ -646,11 +742,16 @@ bool CDStop_bincue(void *fh) bool CDResume_bincue(void *fh) { CueSheet *cs = (CueSheet *) fh; - if (cs && cs == player.cs) { - if (player.audiostatus == CDROM_AUDIO_PAUSED) { - player.audiostatus = CDROM_AUDIO_PLAY; - return true; - } + CDPlayer *player = CSToPlayer(cs); + + if (cs && player) { + // Pause another player if needed + CDPause_playing(player); + + // doesn't matter if it was paused, just ensure this one plays now + player->audiostatus = CDROM_AUDIO_PLAY; + currently_playing = player; + return true; } return false; } @@ -658,8 +759,13 @@ bool CDResume_bincue(void *fh) bool CDPlay_bincue(void *fh, uint8 start_m, uint8 start_s, uint8 start_f, uint8 end_m, uint8 end_s, uint8 end_f) { - CueSheet *cs = (CueSheet *)fh; - if (cs && cs == player.cs) { + CueSheet *cs = (CueSheet *) fh; + CDPlayer *player = CSToPlayer(cs); + + if (cs && player) { + // Pause another player if needed + CDPause_playing(player); + int track; MSF msf; @@ -667,42 +773,42 @@ bool CDPlay_bincue(void *fh, uint8 start_m, uint8 start_s, uint8 start_f, SDL_LockAudio(); #endif - player.audiostatus = CDROM_AUDIO_NO_STATUS; + player->audiostatus = CDROM_AUDIO_NO_STATUS; - player.audiostart = (start_m * 60 * CD_FRAMES) + + player->audiostart = (start_m * 60 * CD_FRAMES) + (start_s * CD_FRAMES) + start_f; - player.audioend = (end_m * 60 * CD_FRAMES) + (end_s * CD_FRAMES) + end_f; + player->audioend = (end_m * 60 * CD_FRAMES) + (end_s * CD_FRAMES) + end_f; - track = PositionToTrack(player.cs, player.audiostart); + track = PositionToTrack(player->cs, player->audiostart); - if (track < player.cs->tcnt) { - player.audioposition = 0; + if (track < player->cs->tcnt) { + player->audioposition = 0; // here we need to compute silence - if (player.audiostart - player.cs->tracks[track].start > - player.cs->tracks[track].pregap) - player.silence = 0; + if (player->audiostart - player->cs->tracks[track].start > + player->cs->tracks[track].pregap) + player->silence = 0; else - player.silence = (player.cs->tracks[track].pregap - - player.audiostart + - player.cs->tracks[track].start) * RAW_SECTOR_SIZE; + player->silence = (player->cs->tracks[track].pregap - + player->audiostart + + player->cs->tracks[track].start) * cs->raw_sector_size; - player.fileoffset = player.cs->tracks[track].fileoffset; + player->fileoffset = player->cs->tracks[track].fileoffset; - D(bug("file offset %d\n", (unsigned int) player.fileoffset)); + D(bug("file offset %d\n", (unsigned int) player->fileoffset)); // fix up file offset if beyond the silence bytes - if (!player.silence) // not at the beginning - player.fileoffset += (player.audiostart - - player.cs->tracks[track].start - - player.cs->tracks[track].pregap) * RAW_SECTOR_SIZE; + if (!player->silence) // not at the beginning + player->fileoffset += (player->audiostart - + player->cs->tracks[track].start - + player->cs->tracks[track].pregap) * cs->raw_sector_size; - FramesToMSF(player.cs->tracks[track].start, &msf); + FramesToMSF(player->cs->tracks[track].start, &msf); D(bug("CDPlay_bincue track %02d start %02d:%02d:%02d silence %d", - player.cs->tracks[track].number, msf.m, msf.s, msf.f, - player.silence/RAW_SECTOR_SIZE)); + player->cs->tracks[track].number, msf.m, msf.s, msf.f, + player->silence/cs->raw_sector_size)); D(bug(" Stop %02u:%02u:%02u\n", end_m, end_s, end_f)); } else @@ -712,21 +818,71 @@ bool CDPlay_bincue(void *fh, uint8 start_m, uint8 start_s, uint8 start_f, SDL_UnlockAudio(); #endif - if (audio_enabled) { - player.audiostatus = CDROM_AUDIO_PLAY; + if (player->audio_enabled) { + player->audiostatus = CDROM_AUDIO_PLAY; #ifdef OSX_CORE_AUDIO D(bug("starting os x sound")); - player.soundoutput.setCallback(bincue_core_audio_callback); + player->soundoutput.setCallback(bincue_core_audio_callback); // should be from current track ! - player.soundoutput.start(16, 2, 44100); + player->soundoutput.start(16, 2, 44100); #endif + currently_playing = player; return true; } } return false; } -static uint8 *fill_buffer(int stream_len) +bool CDScan_bincue(void *fh, uint8 start_m, uint8 start_s, uint8 start_f, bool reverse) { + CueSheet *cs = (CueSheet *) fh; + CDPlayer *player = CSToPlayer(cs); + + if (cs && player) { + uint8 scanrate = 8; // 8x scan default but could use different value or make configurable + + MSF msf; + msf.m = start_m; msf.s = start_s; msf.f = start_f; + int current_frame = MSFToFrames(msf); + + if (reverse) { + msf.s -= scanrate; + int goto_frame = MSFToFrames(msf); + player->audioposition -= (current_frame - goto_frame) * player->cs->raw_sector_size; + } + else { + msf.s += scanrate; + int goto_frame = MSFToFrames(msf); + player->audioposition += (goto_frame - current_frame) * player->cs->raw_sector_size; + } + return true; + } + return false; +} + +void CDSetVol_bincue(void* fh, uint8 left, uint8 right) { + CueSheet *cs = (CueSheet *) fh; + CDPlayer *player = CSToPlayer(cs); + + if (cs && player) { + // Convert from classic Mac's 0-255 to 0-128; + // calculate mono mix as well in place of panning + player->volume_left = (left*128)/255; + player->volume_right = (right*128)/255; + player->volume_mono = (player->volume_left + player->volume_right)/2; // use avg + } +} + +void CDGetVol_bincue(void* fh, uint8* left, uint8* right) { + CueSheet *cs = (CueSheet *) fh; + CDPlayer *player = CSToPlayer(cs); + + if (cs && player) { // Convert from 0-128 to 0-255 scale + *left = (player->volume_left*255)/128; + *right = (player->volume_right*255)/128; + } +} + +static uint8 *fill_buffer(int stream_len, CDPlayer* player) { static uint8 *buf = 0; static int bufsize = 0; @@ -745,44 +901,44 @@ static uint8 *fill_buffer(int stream_len) } memset(buf, silence_byte, stream_len); + + if (player->audiostatus == CDROM_AUDIO_PLAY) { + int remaining_silence = player->silence - player->audioposition; - if (player.audiostatus == CDROM_AUDIO_PLAY) { - int remaining_silence = player.silence - player.audioposition; - - if (player.audiostart + player.audioposition/RAW_SECTOR_SIZE - >= player.audioend) { - player.audiostatus = CDROM_AUDIO_COMPLETED; + if (player->audiostart + player->audioposition/player->cs->raw_sector_size + >= player->audioend) { + player->audiostatus = CDROM_AUDIO_COMPLETED; return buf; } if (remaining_silence >= stream_len) { - player.audioposition += stream_len; + player->audioposition += stream_len; return buf; } if (remaining_silence > 0) { offset += remaining_silence; - player.audioposition += remaining_silence; + player->audioposition += remaining_silence; } int ret = 0; - int available = ((player.audioend - player.audiostart) * - RAW_SECTOR_SIZE) - player.audioposition; + int available = ((player->audioend - player->audiostart) * + player->cs->raw_sector_size) - player->audioposition; if (available > (stream_len - offset)) available = stream_len - offset; - if (lseek(player.audiofh, - player.fileoffset + player.audioposition - player.silence, + if (lseek(player->audiofh, + player->fileoffset + player->audioposition - player->silence, SEEK_SET) < 0) return NULL; if (available < 0) { - player.audioposition += available; // correct end !; + player->audioposition += available; // correct end !; available = 0; } - if ((ret = read(player.audiofh, &buf[offset], available)) >= 0) { - player.audioposition += ret; + if ((ret = read(player->audiofh, &buf[offset], available)) >= 0) { + player->audioposition += ret; offset += ret; available -= ret; } @@ -790,33 +946,56 @@ static uint8 *fill_buffer(int stream_len) while (offset < stream_len) { buf[offset++] = silence_byte; if (available-- > 0){ - player.audioposition++; + player->audioposition++; } } - } + } return buf; } #ifdef USE_SDL_AUDIO -void MixAudio_bincue(uint8 *stream, int stream_len) +void MixAudio_bincue(uint8 *stream, int stream_len, int volume) { - if (audio_enabled && (player.audiostatus == CDROM_AUDIO_PLAY)) { - uint8 *buf = fill_buffer(stream_len); - if (buf) - SDL_MixAudio(stream, buf, stream_len, SDL_MIX_MAXVOLUME); + if (currently_playing) { + + CDPlayer *player = currently_playing; + + if (player->audiostatus == CDROM_AUDIO_PLAY) { + uint8 *buf = fill_buffer(stream_len, player); + if (buf) + SDL_AudioStreamPut(player->stream, buf, stream_len); + int avail = SDL_AudioStreamAvailable(player->stream); + if (avail >= stream_len) { + uint8 converted[stream_len]; + SDL_AudioStreamGet(player->stream, converted, stream_len); + SDL_MixAudio(stream, converted, stream_len, player->volume_mono); + } + } + } } -void OpenAudio_bincue(int freq, int format, int channels, uint8 silence) +void OpenAudio_bincue(int freq, int format, int channels, uint8 silence, int volume) { - if (freq == 44100 && format == AUDIO_S16MSB && channels == 2) { - audio_enabled = true; - silence_byte = silence; - } - else { - D(bug("unexpected frequency %d , format %d, or channels %d\n", - freq, format, channels)); + // setup silence at init + silence_byte = silence; + + // init players + for (std::vector::iterator it = players.begin(); it != players.end(); ++it) + { + CDPlayer *player = *it; + + // set player volume based on SDL volume + player->volume_left = player->volume_right = player->volume_mono = volume; + // audio stream handles converting cd audio to destination output + player->stream = SDL_NewAudioStream(AUDIO_S16LSB, 2, 44100, format, channels, freq); + if (player->stream == NULL) { + D(bug("Failed to open CD player audio stream using SDL!")); + } + else { + player->audio_enabled = true; + } } } #endif @@ -824,13 +1003,18 @@ void OpenAudio_bincue(int freq, int format, int channels, uint8 silence) #ifdef OSX_CORE_AUDIO static int bincue_core_audio_callback(void) { - int frames = player.soundoutput.bufferSizeFrames(); - uint8 *buf = fill_buffer(frames*4); + for (std::vector::iterator it = players.begin(); it != players.end(); ++it) + { + CDPlayer *player = *it; + + int frames = player->soundoutput.bufferSizeFrames(); + uint8 *buf = fill_buffer(frames*4); - // D(bug("Audio request %d\n", stream_len)); + // D(bug("Audio request %d\n", stream_len)); - player.soundoutput.sendAudioBuffer((void *) buf, (buf ? frames : 0)); + player->soundoutput.sendAudioBuffer((void *) buf, (buf ? frames : 0)); - return 1; + return 1; + } } #endif diff --git a/BasiliskII/src/cdrom.cpp b/BasiliskII/src/cdrom.cpp index 370322d1..36250297 100644 --- a/BasiliskII/src/cdrom.cpp +++ b/BasiliskII/src/cdrom.cpp @@ -58,7 +58,7 @@ const uint8 CDROMIcon[258] = { 0x8a, 0xaa, 0xaa, 0xe4, 0x8d, 0x55, 0x55, 0xc4, 0x86, 0xaa, 0xab, 0xc4, 0x83, 0x55, 0x57, 0x84, 0x81, 0xaa, 0xaf, 0x04, 0x80, 0xf5, 0x7e, 0x04, 0x80, 0x3f, 0xf8, 0x04, 0x80, 0x0f, 0xe0, 0x04, 0xff, 0xff, 0xff, 0xfc, 0x80, 0x00, 0x00, 0x04, 0x80, 0x1f, 0xf0, 0x04, 0x7f, 0xff, 0xff, 0xf8, - + 0x3f, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, @@ -67,7 +67,7 @@ const uint8 CDROMIcon[258] = { 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xf8, - + 0, 0 }; @@ -103,7 +103,7 @@ static const uint8 bin2bcd[256] = { }; static const uint8 bcd2bin[256] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -126,9 +126,9 @@ static const uint8 bcd2bin[256] = { struct cdrom_drive_info { cdrom_drive_info() : num(0), fh(NULL), start_byte(0), status(0) {} cdrom_drive_info(void *fh_) : num(0), fh(fh_), start_byte(0), status(0) {} - + void close_fh(void) { SysAllowRemoval(fh); Sys_close(fh); } - + int num; // Drive number void *fh; // File handle int block_size; // CD-ROM block size @@ -136,12 +136,15 @@ struct cdrom_drive_info { loff_t start_byte; // Start of HFS partition on disk bool to_be_mounted; // Flag: drive must be mounted in accRun bool mount_non_hfs; // Flag: Issue disk-inserted events for non-HFS disks - + uint8 toc[804]; // TOC of currently inserted disk uint8 lead_out[3]; // MSF address of lead-out track uint8 stop_at[3]; // MSF address of audio play stopping point - + uint8 start_at[3]; // MSF address of position set by track search or audio play + uint8 play_mode; // Audio play mode + uint8 play_order; // Play mode order (normal, shuffle, program) + bool repeat; // Repeat flag uint8 power_mode; // Power mode uint32 status; // Mac address of drive status record }; @@ -150,6 +153,8 @@ struct cdrom_drive_info { typedef vector drive_vec; static drive_vec drives; +int last_drive_num; // track last drive called to support multiple audio CDs + // Icon address (Mac address space, set by PatchROM()) uint32 CDROMIconAddr; @@ -165,8 +170,10 @@ static drive_vec::iterator get_drive_info(int num) { drive_vec::iterator info, end = drives.end(); for (info = drives.begin(); info != end; ++info) { - if (info->num == num) + if (info->num == num) { + last_drive_num = num; return info; + } } return info; } @@ -181,18 +188,18 @@ static void find_hfs_partition(cdrom_drive_info &info) info.start_byte = 0; uint8 *map = new uint8[512]; D(bug("Looking for HFS partitions on CD-ROM...\n")); - + // Search first 64 blocks for HFS partition for (int i=0; i<64; i++) { if (Sys_read(info.fh, map, i * 512, 512) != 512) break; D(bug(" block %d, signature '%c%c' (%02x%02x)\n", i, map[0], map[1], map[0], map[1])); - + // Not a partition map block? Then look at next block uint16 sig = (map[0] << 8) | map[1]; if (sig != 0x504d) continue; - + // Partition map block found, Apple HFS partition? if (strcmp((char *)(map + 48), "Apple_HFS") == 0) { info.start_byte = (loff_t)((map[8] << 24) | (map[9] << 16) | (map[10] << 8) | map[11]) << 9; @@ -214,7 +221,7 @@ static void read_toc(cdrom_drive_info &info) // Read TOC memset(info.toc, 0, sizeof(info.toc)); SysCDReadTOC(info.fh, info.toc); - + #if DEBUG // Dump TOC for debugging D(bug(" TOC:\n %02x%02x%02x%02x : %d bytes, first track = %d, last track = %d\n", info.toc[0], info.toc[1], info.toc[2], info.toc[3], (info.toc[0] << 8) | info.toc[1], info.toc[2], info.toc[3])); @@ -226,7 +233,12 @@ static void read_toc(cdrom_drive_info &info) break; } #endif - + + // Default start + info.start_at[0] = 0; + info.start_at[1] = 0; + info.start_at[2] = 0; + // Find lead-out track info.lead_out[0] = 0; info.lead_out[1] = 0; @@ -288,16 +300,25 @@ static bool position2msf(const cdrom_drive_info &info, uint16 postype, uint32 po void CDROMInit(void) { // No drives specified in prefs? Then add defaults - if (PrefsFindString("cdrom", 0) == NULL) + if (PrefsFindString("cdrom", 0) == NULL) { SysAddCDROMPrefs(); - - // Add drives specified in preferences - int index = 0; - const char *str; - while ((str = PrefsFindString("cdrom", index++)) != NULL) { - void *fh = Sys_open(str, true); - if (fh) - drives.push_back(cdrom_drive_info(fh)); + } + else { + // Add drives specified in preferences + int index = 0; + const char *str; + while ((str = PrefsFindString("cdrom", index++)) != NULL) { + void *fh = Sys_open(str, true); + if (fh) + drives.push_back(cdrom_drive_info(fh)); + } + } + + if (!drives.empty()) { // set to first drive by default + last_drive_num = drives.begin()->num; + } + else { + last_drive_num = 0; } } @@ -348,15 +369,15 @@ static void mount_mountable_volumes(void) { drive_vec::iterator info, end = drives.end(); for (info = drives.begin(); info != end; ++info) { - + // Disk in drive? if (ReadMacInt8(info->status + dsDiskInPlace) == 0) { - + // No, check if disk was inserted if (SysIsDiskInserted(info->fh)) CDROMMountVolume(info->fh); } - + // Mount disk if flagged if (info->to_be_mounted) { D(bug(" mounting drive %d\n", info->num)); @@ -377,25 +398,27 @@ static void mount_mountable_volumes(void) int16 CDROMOpen(uint32 pb, uint32 dce) { D(bug("CDROMOpen\n")); - + // Set up DCE WriteMacInt32(dce + dCtlPosition, 0); acc_run_called = false; - + // Install drives drive_vec::iterator info, end = drives.end(); for (info = drives.begin(); info != end; ++info) { - + info->num = FindFreeDriveNumber(1); info->to_be_mounted = false; - + if (info->fh) { info->mount_non_hfs = true; info->block_size = 512; info->twok_offset = -1; info->play_mode = 0x09; + info->play_order = 0; + info->repeat = 0; info->power_mode = 0; - + // Allocate drive status record M68kRegisters r; r.d[0] = SIZEOF_DrvSts; @@ -404,12 +427,12 @@ int16 CDROMOpen(uint32 pb, uint32 dce) continue; info->status = r.a[0]; D(bug(" DrvSts at %08lx\n", info->status)); - + // Set up drive status WriteMacInt8(info->status + dsWriteProt, 0x80); WriteMacInt8(info->status + dsInstalled, 1); WriteMacInt8(info->status + dsSides, 1); - + // Disk in drive? if (SysIsDiskInserted(info->fh)) { SysPreventRemoval(info->fh); @@ -418,7 +441,7 @@ int16 CDROMOpen(uint32 pb, uint32 dce) find_hfs_partition(*info); info->to_be_mounted = true; } - + // Add drive to drive queue D(bug(" adding drive %d\n", info->num)); r.d[0] = (info->num << 16) | (CDROMRefNum & 0xffff); @@ -437,14 +460,14 @@ int16 CDROMOpen(uint32 pb, uint32 dce) int16 CDROMPrime(uint32 pb, uint32 dce) { WriteMacInt32(pb + ioActCount, 0); - + // Drive valid and disk inserted? drive_vec::iterator info = get_drive_info(ReadMacInt16(pb + ioVRefNum)); if (info == drives.end()) return nsDrvErr; if (ReadMacInt8(info->status + dsDiskInPlace) == 0) return offLinErr; - + // Get parameters void *buffer = Mac2HostAddr(ReadMacInt32(pb + ioBuffer)); size_t length = ReadMacInt32(pb + ioReqCount); @@ -452,17 +475,17 @@ int16 CDROMPrime(uint32 pb, uint32 dce) if ((length & (info->block_size - 1)) || (position & (info->block_size - 1))) return paramErr; info->twok_offset = (position + info->start_byte) & 0x7ff; - + size_t actual = 0; if ((ReadMacInt16(pb + ioTrap) & 0xff) == aRdCmd) { - + // Read actual = Sys_read(info->fh, buffer, position + info->start_byte, length); if (actual != length) { - + // Read error, tried to read HFS root block? if (length == 0x200 && position == 0x400) { - + // Yes, fake (otherwise audio CDs won't get mounted) memset(buffer, 0, 0x200); actual = 0x200; @@ -473,7 +496,7 @@ int16 CDROMPrime(uint32 pb, uint32 dce) } else { return wPrErr; } - + // Update ParamBlock and DCE WriteMacInt32(pb + ioActCount, actual); WriteMacInt32(dce + dCtlPosition, ReadMacInt32(dce + dCtlPosition) + actual); @@ -489,34 +512,36 @@ int16 CDROMControl(uint32 pb, uint32 dce) { uint16 code = ReadMacInt16(pb + csCode); D(bug("CDROMControl %d\n", code)); - + // General codes switch (code) { case 1: // KillIO return noErr; - + case 65: { // Periodic action (accRun, "insert" disks on startup) mount_mountable_volumes(); WriteMacInt16(dce + dCtlFlags, ReadMacInt16(dce + dCtlFlags) & ~0x2000); // Disable periodic action acc_run_called = true; return noErr; } - + case 81: // Set poll freq WriteMacInt16(dce + dCtlDelay, ReadMacInt16(pb + csParam)); return noErr; } - + // Drive valid? drive_vec::iterator info = get_drive_info(ReadMacInt16(pb + ioVRefNum)); if (info == drives.end()) { if (drives.empty()) { return nsDrvErr; } else { - info = drives.begin(); // This is needed for Apple's Audio CD program + // Audio calls tend to end up without correct reference + // Real mac would just play first disc, but we can guess correct one from last data call + info = get_drive_info(last_drive_num); } } - + // Drive-specific codes switch (code) { case 5: // VerifyTheDisc @@ -524,28 +549,54 @@ int16 CDROMControl(uint32 pb, uint32 dce) return noErr; else return offLinErr; - + case 6: // FormatTheDisc return writErr; - + case 7: // EjectTheDisc if (ReadMacInt8(info->status + dsDiskInPlace) > 0) { SysAllowRemoval(info->fh); SysEject(info->fh); WriteMacInt8(info->status + dsDiskInPlace, 0); info->twok_offset = -1; + return noErr; + } else { + return offLinErr; } - return noErr; - + case 21: // GetDriveIcon case 22: // GetMediaIcon WriteMacInt32(pb + csParam, CDROMIconAddr); return noErr; - + case 23: // GetDriveInfo WriteMacInt32(pb + csParam, 0x00000b01); // Unspecified external removable SCSI disk return noErr; - + + // TODO: revist this section, is it necessary with DriverGestalt also in Status section? + case 43: { // DriverGestalt + int selector = ReadMacInt32(pb + csParam); + switch (selector) { + case FOURCC('v','e','r','s'): + WriteMacInt32(pb + csParam + 4, 0x05208000); // vers 5.2.0 + break; + case FOURCC('d','e','v','t'): + WriteMacInt32(pb + csParam + 4, FOURCC('c','d','r','m')); + break; + case FOURCC('i','n','t','f'): + case FOURCC('d','A','P','I'): + WriteMacInt32(pb + csParam + 4, FOURCC('a','t','p','i')); + break; + case FOURCC('s','y','n','c'): + WriteMacInt32(pb + csParam + 4, 1); // true/false = sync/async + break; + case FOURCC('c','d','3','d'): + WriteMacInt32(pb + csParam + 4, 0); + break; + } + return noErr; + } + case 70: { // SetPowerMode uint8 mode = ReadMacInt8(pb + csParam); if (mode > 3) { @@ -555,11 +606,11 @@ int16 CDROMControl(uint32 pb, uint32 dce) return noErr; } } - + case 76: // ModifyPostEvent info->mount_non_hfs = ReadMacInt16(pb + csParam) != 0; return noErr; - + case 79: { // Change block size uint16 size = ReadMacInt16(pb + csParam); D(bug(" change block size to %d bytes\n", size)); @@ -570,7 +621,7 @@ int16 CDROMControl(uint32 pb, uint32 dce) return noErr; } } - + case 80: // SetUserEject if (ReadMacInt8(info->status + dsDiskInPlace) > 0) { if (ReadMacInt16(pb + csParam) == 1) @@ -581,11 +632,11 @@ int16 CDROMControl(uint32 pb, uint32 dce) } else { return offLinErr; } - + case 100: { // ReadTOC if (ReadMacInt8(info->status + dsDiskInPlace) == 0) return offLinErr; - + int action = ReadMacInt16(pb + csParam); D(bug(" read TOC %d\n", action)); switch (action) { @@ -594,26 +645,26 @@ int16 CDROMControl(uint32 pb, uint32 dce) WriteMacInt8(pb + csParam + 1, bin2bcd[info->toc[3]]); WriteMacInt16(pb + csParam + 2, 0); break; - + case 2: // Get lead out MSF starting address WriteMacInt8(pb + csParam, bin2bcd[info->lead_out[0]]); WriteMacInt8(pb + csParam + 1, bin2bcd[info->lead_out[1]]); WriteMacInt8(pb + csParam + 2, bin2bcd[info->lead_out[2]]); WriteMacInt8(pb + csParam + 3, 0); break; - + case 3: { // Get track starting address uint32 buf = ReadMacInt32(pb + csParam + 2); uint16 buf_size = ReadMacInt16(pb + csParam + 6); int track = bcd2bin[ReadMacInt8(pb + csParam + 8)]; - + // Search start track in TOC int i; for (i=4; i<804; i+=8) { if (info->toc[i+2] == track) break; } - + // Fill buffer if (i != 804) { while (buf_size > 0) { @@ -621,18 +672,91 @@ int16 CDROMControl(uint32 pb, uint32 dce) WriteMacInt8(buf, bin2bcd[info->toc[i+5]]); buf++; // M WriteMacInt8(buf, bin2bcd[info->toc[i+6]]); buf++; // S WriteMacInt8(buf, bin2bcd[info->toc[i+7]]); buf++; // F - + // Lead-Out? Then stop if (info->toc[i+2] == 0xaa) break; - + buf_size -= 4; i += 8; } } break; } - + + case 4: { // Type 4 TOC for non-AppleCD SC + uint32 buf = ReadMacInt32(pb + csParam + 2); + uint16 buf_size = 512; // buffer must be 512 bytes for this TOC type + + // start filling buffer + WriteMacInt8(buf, 0); buf++; // first byte reserved for 0 + buf_size--; + + int i = 4; + // in TOC, first 4 are session and/or track number; so tracks start at i = 4 + // (info->toc[2] is first track num and info->toc[3] is last num) + // each track entry is 8 bytes: + // 0: unused, 1: control, 2: tracknum, 3: unused + // 4: unused, 5: MIN, 6: SEC, 7: FRAME + + // entry for point A0 (first track num) + WriteMacInt8(buf, info->toc[i+1] & 0x0f); buf++; // control field + WriteMacInt8(buf, bin2bcd[info->toc[2]]); buf++; // track number + WriteMacInt8(buf, bin2bcd[info->toc[i+5]]); buf++; // PMIN + WriteMacInt8(buf, bin2bcd[info->toc[i+6]]); buf++; // PSEC + WriteMacInt8(buf, bin2bcd[info->toc[i+7]]); buf++; // PFRAME + buf_size -= 5; // every 8 bits written decreases byte buffer size by 1 + + // entry for point A1 (last track) + int buf_a1 = buf; // save for filling last track num + buf += 5; buf_size -= 5; + + // entry for point A2 (address of start of lead out) + int buf_a2 = buf; // save for filling at end + buf += 5; buf_size -= 5; + + // Fill buffer + while (i <= 804 && buf_size > 1) { // index 511 never used + // Lead out? then fill a2 and stop + if (info->toc[i+2] == 0xaa) { + // entry for point a2 + WriteMacInt8(buf_a2, info->toc[i+1] & 0x0f); // Control + WriteMacInt8(buf_a2 + 1, bin2bcd[info->toc[i+2]]); // tracknum + WriteMacInt8(buf_a2 + 2, bin2bcd[info->lead_out[0]]); // M, same as toc[i+5] + WriteMacInt8(buf_a2 + 3, bin2bcd[info->lead_out[1]]); // S + WriteMacInt8(buf_a2 + 4, bin2bcd[info->lead_out[2]]); // F + break; + } + + WriteMacInt8(buf, info->toc[i+1] & 0x0f); buf++; // Control + WriteMacInt8(buf, bin2bcd[info->toc[i+2]]); buf++; // tracknum + WriteMacInt8(buf, bin2bcd[info->toc[i+5]]); buf++; // M + WriteMacInt8(buf, bin2bcd[info->toc[i+6]]); buf++; // S + WriteMacInt8(buf, bin2bcd[info->toc[i+7]]); buf++; // F + + // Last track? fill a1 as well + if (info->toc[i+2] == info->toc[3]) { + // entry for point a1 + WriteMacInt8(buf_a1, info->toc[i+1] & 0x0f); // Control + WriteMacInt8(buf_a1 + 1, bin2bcd[info->toc[3]]); // tracknum + WriteMacInt8(buf_a1 + 2, bin2bcd[info->toc[i+5]]); // M + WriteMacInt8(buf_a1 + 3, bin2bcd[info->toc[i+6]]); // S + WriteMacInt8(buf_a1 + 4, bin2bcd[info->toc[i+7]]); // F + } + + buf_size -= 5; + i += 8; + } + + // fill rest of buffer with zeroes + while (buf_size > 0) { + WriteMacInt8(buf, 0); buf++; + buf_size--; + } + + break; + } + case 5: // Get session information WriteMacInt16(pb + csParam, 1); // First session number WriteMacInt16(pb + csParam + 2, 1); // Last session number @@ -642,20 +766,20 @@ int16 CDROMControl(uint32 pb, uint32 dce) WriteMacInt8(pb + csParam + 8, bin2bcd[info->toc[10]]); // S WriteMacInt8(pb + csParam + 9, bin2bcd[info->toc[11]]); // F break; - + default: printf("FATAL: .AppleCD/Control(100): unimplemented TOC type\n"); return paramErr; } return noErr; } - + case 101: { // ReadTheQSubcode if (ReadMacInt8(info->status + dsDiskInPlace) == 0) { Mac_memset(pb + csParam, 0, 10); return offLinErr; } - + uint8 pos[16]; if (SysCDGetPosition(info->fh, pos)) { uint32 p = pb + csParam; @@ -674,51 +798,51 @@ int16 CDROMControl(uint32 pb, uint32 dce) return ioErr; } } - + case 102: // ReadHeader printf("FATAL: .AppleCD/Control(102): unimplemented call\n"); return controlErr; - + case 103: { // AudioTrackSearch D(bug(" AudioTrackSearch postype %d, pos %08x, hold %d\n", ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), ReadMacInt16(pb + csParam + 6))); if (ReadMacInt8(info->status + dsDiskInPlace) == 0) return offLinErr; - - uint8 start_m, start_s, start_f; - if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, start_m, start_s, start_f)) + + if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, info->start_at[0], info->start_at[1], info->start_at[2])) return paramErr; info->play_mode = ReadMacInt8(pb + csParam + 9) & 0x0f; - if (!SysCDPlay(info->fh, start_m, start_s, start_f, info->stop_at[0], info->stop_at[1], info->stop_at[2])) + if (!SysCDPlay(info->fh, info->start_at[0], info->start_at[1], info->start_at[2], info->stop_at[0], info->stop_at[1], info->stop_at[2])) return paramErr; if (ReadMacInt16(pb + csParam + 6) == 0) // Hold SysCDPause(info->fh); return noErr; } - + case 104: // AudioPlay D(bug(" AudioPlay postype %d, pos %08lx, hold %d\n", ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), ReadMacInt16(pb + csParam + 6))); if (ReadMacInt8(info->status + dsDiskInPlace) == 0) return offLinErr; - + + if (ReadMacInt16(pb + csParam + 6)) { // Given stopping address if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), true, info->stop_at[0], info->stop_at[1], info->stop_at[2])) return paramErr; } else { // Given starting address - uint8 start_m, start_s, start_f; - if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, start_m, start_s, start_f)) - return paramErr; - info->play_mode = ReadMacInt8(pb + csParam + 9) & 0x0f; - if (!SysCDPlay(info->fh, start_m, start_s, start_f, info->stop_at[0], info->stop_at[1], info->stop_at[2])) + if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, info->start_at[0], info->start_at[1], info->start_at[2])) return paramErr; } + // Still need to process the AudioPlay command + info->play_mode = ReadMacInt8(pb + csParam + 9) & 0x0f; + if (!SysCDPlay(info->fh, info->start_at[0], info->start_at[1], info->start_at[2], info->stop_at[0], info->stop_at[1], info->stop_at[2])) + return paramErr; return noErr; - + case 105: // AudioPause if (ReadMacInt8(info->status + dsDiskInPlace) == 0) return offLinErr; - + switch (ReadMacInt32(pb + csParam)) { case 0: if (!SysCDResume(info->fh)) @@ -732,12 +856,12 @@ int16 CDROMControl(uint32 pb, uint32 dce) return paramErr; } return noErr; - + case 106: // AudioStop D(bug(" AudioStop postype %d, pos %08lx\n", ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2))); if (ReadMacInt8(info->status + dsDiskInPlace) == 0) return offLinErr; - + if (ReadMacInt16(pb + csParam) == 0 && ReadMacInt32(pb + csParam + 2) == 0) { // Stop immediately if (!SysCDStop(info->fh, info->lead_out[0], info->lead_out[1], info->lead_out[2])) @@ -748,15 +872,15 @@ int16 CDROMControl(uint32 pb, uint32 dce) return paramErr; } return noErr; - + case 107: { // AudioStatus if (ReadMacInt8(info->status + dsDiskInPlace) == 0) return offLinErr; - + uint8 pos[16]; if (!SysCDGetPosition(info->fh, pos)) return paramErr; - + uint32 p = pb + csParam; switch (pos[1]) { case 0x11: @@ -783,34 +907,33 @@ int16 CDROMControl(uint32 pb, uint32 dce) WriteMacInt8(p, bin2bcd[pos[11]]); p++; // F (abs) return noErr; } - + case 108: { // AudioScan if (ReadMacInt8(info->status + dsDiskInPlace) == 0) return offLinErr; - - uint8 start_m, start_s, start_f; - if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, start_m, start_s, start_f)) + + if (!position2msf(*info, ReadMacInt16(pb + csParam), ReadMacInt32(pb + csParam + 2), false, info->start_at[0], info->start_at[1], info->start_at[2])) return paramErr; - - if (!SysCDScan(info->fh, start_m, start_s, start_f, ReadMacInt16(pb + csParam + 6) != 0)) { + + if (!SysCDScan(info->fh, info->start_at[0], info->start_at[1], info->start_at[2], ReadMacInt16(pb + csParam + 6) != 0)) { return paramErr; } else { return noErr; } } - + case 109: // AudioControl SysCDSetVolume(info->fh, ReadMacInt8(pb + csParam), ReadMacInt8(pb + csParam + 1)); return noErr; - + case 110: // ReadMCN printf("FATAL: .AppleCD/Control(110): unimplemented call\n"); return controlErr; - + case 111: // ReadISRC printf("FATAL: .AppleCD/Control(111): unimplemented call\n"); return controlErr; - + case 112: { // ReadAudioVolume uint8 left = 0, right = 0; SysCDGetVolume(info->fh, left, right); @@ -818,43 +941,50 @@ int16 CDROMControl(uint32 pb, uint32 dce) WriteMacInt8(pb + csParam + 1, right); return noErr; } - + case 113: // GetSpindleSpeed WriteMacInt16(pb + csParam, 0xff); return noErr; - + case 114: // SetSpindleSpeed return noErr; - + case 115: // ReadAudio printf("FATAL: .AppleCD/Control(115): unimplemented call\n"); return controlErr; - + case 116: // ReadAllSubcodes printf("FATAL: .AppleCD/Control(116): unimplemented call\n"); return controlErr; - + case 122: // SetTrackList printf("FATAL: .AppleCD/Control(122): unimplemented call\n"); return controlErr; - + case 123: // GetTrackList printf("FATAL: .AppleCD/Control(123): unimplemented call\n"); return controlErr; - + case 124: // GetTrackIndex printf("FATAL: .AppleCD/Control(124): unimplemented call\n"); return controlErr; - + case 125: // SetPlayMode - D(bug(" SetPlayMode %04x\n", ReadMacInt16(pb + csParam))); - printf("FATAL: .AppleCD/Control(125): unimplemented call\n"); - return controlErr; - - case 126: // GetPlayMode (Apple's Audio CD program needs this) - WriteMacInt16(pb + csParam, 0); + // repeat flag (0 is off, 1 is on) + info->repeat = ReadMacInt8(pb + csParam); + // playmode (0 is normal, 1 is shuffle, 2 is program mode) + info->play_order = ReadMacInt8(pb + csParam + 1); + // D(bug(" SetPlayMode %04x\n", ReadMacInt16(pb + csParam))); + // printf("FATAL: .AppleCD/Control(125): unimplemented call\n"); return noErr; - + + case 126: // GetPlayMode (Apple's Audio CD program needs this) + // repeat flag + WriteMacInt8(pb + csParam, bcd2bin[info->repeat]); + // playmode + WriteMacInt8(pb + csParam + 1, bcd2bin[info->play_order]); + return noErr; + default: printf("WARNING: Unknown CDROMControl(%d)\n", code); return controlErr; @@ -871,7 +1001,7 @@ int16 CDROMStatus(uint32 pb, uint32 dce) drive_vec::iterator info = get_drive_info(ReadMacInt16(pb + ioVRefNum)); uint16 code = ReadMacInt16(pb + csCode); D(bug("CDROMStatus %d\n", code)); - + // General codes (we can get these even if the drive was invalid) switch (code) { case 43: { // DriverGestalt @@ -885,10 +1015,12 @@ int16 CDROMStatus(uint32 pb, uint32 dce) WriteMacInt32(pb + csParam + 4, FOURCC('c','d','r','m')); break; case FOURCC('i','n','t','f'): // Interface type - WriteMacInt32(pb + csParam + 4, EMULATOR_ID_4); +// WriteMacInt32(pb + csParam + 4, EMULATOR_ID_4); + WriteMacInt32(pb + csParam + 4, FOURCC('a','t','p','i')); break; case FOURCC('s','y','n','c'): // Only synchronous operation? WriteMacInt32(pb + csParam + 4, 0x01000000); +// WriteMacInt32(pb + csParam + 4, 1); break; case FOURCC('b','o','o','t'): // Boot ID if (info != drives.end()) @@ -912,12 +1044,15 @@ int16 CDROMStatus(uint32 pb, uint32 dce) case FOURCC('v','m','o','p'): // Virtual memory attributes WriteMacInt32(pb + csParam + 4, 0); // Drive not available for VM break; + case FOURCC('c', 'd', '3', 'd'): + WriteMacInt16(pb + csParam + 4, 0); + break; default: return statusErr; } return noErr; } - + case 97: { // WhoIsThere uint8 drives_present = 0; drive_vec::iterator info, end = drives.end(); @@ -929,15 +1064,16 @@ int16 CDROMStatus(uint32 pb, uint32 dce) return noErr; } } - + // Drive valid? if (info == drives.end()) { - if (drives.empty()) + if (drives.empty()) { return nsDrvErr; - else - info = drives.begin(); // This is needed for Apple's Audio CD program + } else { + info = get_drive_info(last_drive_num); + } } - + // Drive-specific codes switch (code) { case 6: // Return format list @@ -950,15 +1086,15 @@ int16 CDROMStatus(uint32 pb, uint32 dce) } else { return paramErr; } - + case 8: // DriveStatus Mac2Mac_memcpy(pb + csParam, info->status, 22); return noErr; - + case 70: // GetPowerMode WriteMacInt16(pb + csParam, info->power_mode << 8); return noErr; - + case 95: // Get2KOffset if (info->twok_offset > 0) { WriteMacInt16(pb + csParam, info->twok_offset); @@ -966,24 +1102,24 @@ int16 CDROMStatus(uint32 pb, uint32 dce) } else { return statusErr; } - + case 96: // Get drive type WriteMacInt16(pb + csParam, 3); // Apple CD 300 or newer return noErr; - + case 98: // Get block size WriteMacInt16(pb + csParam, info->block_size); return noErr; - + case 120: // Return device ident WriteMacInt32(pb + csParam, 0); return noErr; - + case 121: // Get CD features WriteMacInt16(pb + csParam, 0x0200); // 300 KB/s WriteMacInt16(pb + csParam + 2, 0x0c00); // SCSI-2, stereo return noErr; - + default: printf("WARNING: Unknown CDROMStatus(%d)\n", code); return statusErr; @@ -999,6 +1135,6 @@ void CDROMInterrupt(void) { if (!acc_run_called) return; - + mount_mountable_volumes(); } diff --git a/BasiliskII/src/include/audio_defs.h b/BasiliskII/src/include/audio_defs.h index c52b7d70..4f69f38e 100644 --- a/BasiliskII/src/include/audio_defs.h +++ b/BasiliskII/src/include/audio_defs.h @@ -72,14 +72,20 @@ const uint32 siHardwareMute = FOURCC('h','m','u','t'); // mute state of all ha const uint32 siHardwareVolume = FOURCC('h','v','o','l'); // volume level of all hardware const uint32 siHardwareVolumeSteps = FOURCC('h','s','t','p'); // number of volume steps for hardware const uint32 siHardwareBusy = FOURCC('h','w','b','s'); // sound hardware is in use +const uint32 siHardwareFormat = FOURCC('h','w','f','m'); // hardware format const uint32 siHeadphoneMute = FOURCC('p','m','u','t'); // mute state of headphone const uint32 siHeadphoneVolume = FOURCC('p','v','o','l'); // volume level of headphone const uint32 siHeadphoneVolumeSteps = FOURCC('h','d','s','t'); // number of volume steps for headphone const uint32 siSpeakerMute = FOURCC('s','m','u','t'); // mute state of all built-in speakers const uint32 siSpeakerVolume = FOURCC('s','v','o','l'); // volume level of built-in speaker -const uint32 siDeviceName = FOURCC('n','a','m','e'); -const uint32 siDeviceIcon = FOURCC('i','c','o','n'); -const uint32 siHardwareFormat = FOURCC('h','w','f','m'); +const uint32 siDeviceName = FOURCC('n','a','m','e'); // sound input name +const uint32 siDeviceIcon = FOURCC('i','c','o','n'); // sound input icon resource location +const uint32 siInputSourceNames = FOURCC('s','n','a','m'); // sound input source names +const uint32 siInputSource = FOURCC('s','o','u','r'); // sound input source selector +const uint32 siOptionsDialog = FOURCC('o','p','t','d'); // display options dialog box +const uint32 siPlayThruOnOff = FOURCC('p','l','t','h'); // play-through state +const uint32 siInitializeDriver = FOURCC('i','n','i','t'); // open sound input device +const uint32 siCloseDriver = FOURCC('c','l','o','s'); // close sound input device enum { // ComponentResource struct componentType = 0, diff --git a/BasiliskII/src/Unix/bincue_unix.h b/BasiliskII/src/include/bincue.h similarity index 79% rename from BasiliskII/src/Unix/bincue_unix.h rename to BasiliskII/src/include/bincue.h index dbf5d8b5..85a89486 100644 --- a/BasiliskII/src/Unix/bincue_unix.h +++ b/BasiliskII/src/include/bincue.h @@ -1,5 +1,5 @@ /* - * bincue_unix.h -- support for cdrom image files in bin/cue format + * bincue.h -- support for cdrom image files in bin/cue format * * (C) 2010 Geoffrey Brown * @@ -34,10 +34,13 @@ extern bool CDPlay_bincue(void *, uint8, uint8, extern bool CDPause_bincue(void *); extern bool CDResume_bincue(void *); extern bool CDStop_bincue(void *); +extern bool CDScan_bincue(void *, uint8, uint8, uint8, bool); +extern void CDSetVol_bincue(void *, uint8, uint8); +extern void CDGetVol_bincue(void *, uint8 *, uint8 *); #ifdef USE_SDL_AUDIO -extern void OpenAudio_bincue(int, int, int, uint8); -extern void MixAudio_bincue(uint8 *, int); +extern void OpenAudio_bincue(int, int, int, uint8, int); +extern void MixAudio_bincue(uint8 *, int, int); #endif #endif 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/Makefile b/SheepShaver/Makefile index 585417f4..ab077305 100644 --- a/SheepShaver/Makefile +++ b/SheepShaver/Makefile @@ -52,6 +52,7 @@ links: (cd src/Windows; if [ ! -e m4 ]; then ln -s ../../../BasiliskII/src/Unix/m4; fi) @list='adb.cpp audio.cpp cdrom.cpp disk.cpp extfs.cpp pict.c \ prefs.cpp scsi.cpp sony.cpp xpram.cpp \ + bincue.cpp include/bincue.h \ include/adb.h include/audio.h include/audio_defs.h \ include/cdrom.h include/clip.h include/debug.h include/disk.h \ include/extfs.h include/extfs_defs.h include/pict.h \ diff --git a/SheepShaver/src/MacOSX/SheepShaver.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SheepShaver/src/MacOSX/SheepShaver.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/SheepShaver/src/MacOSX/SheepShaver.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj b/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj index 2d6bc2d6..a686e0fb 100755 --- a/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj +++ b/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj @@ -28,9 +28,6 @@ 0846E4C114B1268B00574779 /* jit-cache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CDCD14A99EEF000B1711 /* jit-cache.cpp */; }; 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 */; }; - 0856CFE214A99EF0000B1711 /* cdrom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CD7814A99EEF000B1711 /* cdrom.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 */; }; @@ -55,7 +52,6 @@ 0856D07C14A99EF1000B1711 /* thunks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CEC114A99EF0000B1711 /* thunks.cpp */; }; 0856D07D14A99EF1000B1711 /* timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CEC214A99EF0000B1711 /* timer.cpp */; }; 0856D07E14A99EF1000B1711 /* about_window_unix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CEC414A99EF0000B1711 /* about_window_unix.cpp */; }; - 0856D08714A99EF1000B1711 /* bincue_unix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CECF14A99EF0000B1711 /* bincue_unix.cpp */; }; 0856D09814A99EF1000B1711 /* ether_unix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CEE314A99EF0000B1711 /* ether_unix.cpp */; }; 0856D0AA14A99EF1000B1711 /* main_unix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CEFB14A99EF0000B1711 /* main_unix.cpp */; }; 0856D10614A99EF1000B1711 /* prefs_unix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0856CF5A14A99EF0000B1711 /* prefs_unix.cpp */; }; @@ -80,6 +76,11 @@ 08CD42DC14B7B85B009CA2A2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08CD42DB14B7B85B009CA2A2 /* Cocoa.framework */; }; 08CD42E814B7B8AA009CA2A2 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08CD42E714B7B8AA009CA2A2 /* Carbon.framework */; }; 3D2C25B5221092BA00B635DE /* SheepVM.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3D2C25B4221092BA00B635DE /* SheepVM.icns */; }; + 5D2143D524B2DD90008BB372 /* bincue.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D2143D424B2DD90008BB372 /* bincue.h */; }; + 5D35961124B8F5FB0081EC8A /* bincue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D35961024B8F5FA0081EC8A /* bincue.cpp */; }; + 5D55CB40225584D000FF8E81 /* cdrom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D55CB3F225584D000FF8E81 /* cdrom.cpp */; }; + 5DE93B46247C71F200B2C821 /* adb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D3967BF2328D315003925D6 /* adb.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, ); }; }; @@ -156,9 +157,6 @@ 0846E52314B129DA00574779 /* ppc_asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = ppc_asm.S; sourceTree = ""; }; 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; }; - 0856CD7814A99EEF000B1711 /* cdrom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cdrom.cpp; path = ../cdrom.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; }; @@ -276,8 +274,6 @@ 0856CEC114A99EF0000B1711 /* thunks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = thunks.cpp; path = ../thunks.cpp; sourceTree = SOURCE_ROOT; }; 0856CEC214A99EF0000B1711 /* timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = timer.cpp; path = ../timer.cpp; sourceTree = SOURCE_ROOT; }; 0856CEC414A99EF0000B1711 /* about_window_unix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = about_window_unix.cpp; sourceTree = ""; }; - 0856CECF14A99EF0000B1711 /* bincue_unix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bincue_unix.cpp; sourceTree = ""; }; - 0856CED014A99EF0000B1711 /* bincue_unix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bincue_unix.h; sourceTree = ""; }; 0856CEE314A99EF0000B1711 /* ether_unix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ether_unix.cpp; sourceTree = ""; }; 0856CEFB14A99EF0000B1711 /* main_unix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main_unix.cpp; sourceTree = ""; }; 0856CF5A14A99EF0000B1711 /* prefs_unix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = prefs_unix.cpp; sourceTree = ""; }; @@ -326,6 +322,19 @@ 08CD42DB14B7B85B009CA2A2 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 08CD42E714B7B8AA009CA2A2 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = ""; }; 3D2C25B4221092BA00B635DE /* SheepVM.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = SheepVM.icns; sourceTree = ""; }; + 5D2143D424B2DD90008BB372 /* bincue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bincue.h; sourceTree = ""; }; + 5D35961024B8F5FA0081EC8A /* bincue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bincue.cpp; path = ../../../BasiliskII/src/bincue.cpp; sourceTree = ""; }; + 5D3967BF2328D315003925D6 /* adb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = adb.cpp; path = ../../../BasiliskII/src/adb.cpp; sourceTree = ""; }; + 5D55CB3F225584D000FF8E81 /* cdrom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cdrom.cpp; path = ../../../BasiliskII/src/cdrom.cpp; sourceTree = ""; }; + 5DDE94F82255C70C004D0E79 /* MacOSX_sound_if.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MacOSX_sound_if.h; path = ../../../BasiliskII/src/MacOSX/MacOSX_sound_if.h; sourceTree = ""; }; + 5DDE94FA2255C712004D0E79 /* MacOSX_sound_if.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MacOSX_sound_if.cpp; path = ../../../BasiliskII/src/MacOSX/MacOSX_sound_if.cpp; sourceTree = ""; }; + 5DDE94FD2255C740004D0E79 /* AudioBackEnd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioBackEnd.h; path = ../../../BasiliskII/src/MacOSX/AudioBackEnd.h; sourceTree = ""; }; + 5DDE94FF2255C74C004D0E79 /* AudioBackEnd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AudioBackEnd.cpp; path = ../../../BasiliskII/src/MacOSX/AudioBackEnd.cpp; sourceTree = ""; }; + 5DDE95082255C88E004D0E79 /* AudioDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AudioDevice.cpp; path = ../../../BasiliskII/src/MacOSX/AudioDevice.cpp; sourceTree = ""; }; + 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 = ""; }; @@ -455,9 +464,10 @@ isa = PBXGroup; children = ( 087B91B11B780EC900825F7F /* CrossPlatform */, - 0856CD4B14A99EEF000B1711 /* adb.cpp */, - 0856CD4C14A99EEF000B1711 /* audio.cpp */, - 0856CD7814A99EEF000B1711 /* cdrom.cpp */, + 5D3967BF2328D315003925D6 /* adb.cpp */, + 5DF4CB7E22B5BD5D00512A86 /* audio.cpp */, + 5D35961024B8F5FA0081EC8A /* bincue.cpp */, + 5D55CB3F225584D000FF8E81 /* cdrom.cpp */, 0856CD7D14A99EEF000B1711 /* disk.cpp */, 0856CD7E14A99EEF000B1711 /* dummy */, 0856CD8614A99EEF000B1711 /* emul_op.cpp */, @@ -508,6 +518,7 @@ 0856CD9014A99EEF000B1711 /* adb.h */, 0856CD9114A99EEF000B1711 /* audio.h */, 0856CD9214A99EEF000B1711 /* audio_defs.h */, + 5D2143D424B2DD90008BB372 /* bincue.h */, 0856CD9314A99EEF000B1711 /* cdrom.h */, 0856CD9414A99EEF000B1711 /* clip.h */, 0856CD9514A99EEF000B1711 /* cpu_emulation.h */, @@ -719,6 +730,12 @@ E4202602241250EE000508DF /* runtool.c */, 0873A76514ABD151004F12B7 /* config */, 0856D2D614A9A704000B1711 /* Launcher */, + 5DDE950D2255C8B3004D0E79 /* audio_defs_macosx.h */, + 5DDE950E2255C8B3004D0E79 /* audio_macosx.cpp */, + 5DDE94FD2255C740004D0E79 /* AudioBackEnd.h */, + 5DDE94FF2255C74C004D0E79 /* AudioBackEnd.cpp */, + 5DDE95082255C88E004D0E79 /* AudioDevice.cpp */, + 5DDE950B2255C895004D0E79 /* AudioBackEnd.h */, E456E2AC20C82B60006C8DC2 /* clip_macosx64.mm */, 0856CE2D14A99EF0000B1711 /* extfs_macosx.cpp */, 0879BDAF15A8B1AA00DC277D /* Info.plist.in */, @@ -729,6 +746,8 @@ 0856CE8714A99EF0000B1711 /* sys_darwin.cpp */, 0873A80014AC515D004F12B7 /* utils_macosx.h */, 0873A80114AC515D004F12B7 /* utils_macosx.mm */, + 5DDE94F82255C70C004D0E79 /* MacOSX_sound_if.h */, + 5DDE94FA2255C712004D0E79 /* MacOSX_sound_if.cpp */, ); name = MacOSX; sourceTree = ""; @@ -802,8 +821,6 @@ 08003F841E0624BD00A3ADAB /* dyngen_precompiled */, 082AC25614AA59DA00071F5E /* Darwin */, 0856CEC414A99EF0000B1711 /* about_window_unix.cpp */, - 0856CECF14A99EF0000B1711 /* bincue_unix.cpp */, - 0856CED014A99EF0000B1711 /* bincue_unix.h */, 083E370A16EFE85000CCCA59 /* disk_sparsebundle.cpp */, 083E370B16EFE85000CCCA59 /* disk_unix.h */, 0856CEE314A99EF0000B1711 /* ether_unix.cpp */, @@ -900,6 +917,7 @@ 08003F8F1E0624D100A3ADAB /* ppc-dyngen-ops-x86_32.hpp in Headers */, 08003F8E1E0624D100A3ADAB /* basic-dyngen-ops.hpp in Headers */, E4C9A03E1FD55CDC00CABBF9 /* basic-dyngen-ops-x86_64_macos.hpp in Headers */, + 5D2143D524B2DD90008BB372 /* bincue.h in Headers */, E4C9A0401FD55CE700CABBF9 /* ppc-dyngen-ops-x86_64_macos.hpp in Headers */, 08163339158C121000C449F9 /* dis-asm.h in Headers */, 08003F8C1E0624D100A3ADAB /* basic-dyngen-ops-x86_32.hpp in Headers */, @@ -1006,7 +1024,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "sed -i '' 's/@PACKAGE_VERSION@/2.5/g' \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\""; + shellScript = "sed -i '' 's/@PACKAGE_VERSION@/2.5/g' \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n"; }; E4202606241251C6000508DF /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -1052,18 +1070,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5DE93B46247C71F200B2C821 /* adb.cpp in Sources */, E44C460B20D262B0000583AE /* debug.c in Sources */, E44C460C20D262B0000583AE /* tcp_subr.c in Sources */, - 0856CFC114A99EF0000B1711 /* adb.cpp in Sources */, E44C461520D262B0000583AE /* ip_output.c in Sources */, - 0856CFC214A99EF0000B1711 /* audio.cpp in Sources */, - 0856CFE214A99EF0000B1711 /* cdrom.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 */, @@ -1082,6 +1099,7 @@ E44C461420D262B0000583AE /* ip_input.c in Sources */, E44C461320D262B0000583AE /* bootp.c in Sources */, 0856D05E14A99EF1000B1711 /* prefs.cpp in Sources */, + 5D55CB40225584D000FF8E81 /* cdrom.cpp in Sources */, 0856D05F14A99EF1000B1711 /* rom_patches.cpp in Sources */, 0856D06014A99EF1000B1711 /* rsrc_patches.cpp in Sources */, 0856D06114A99EF1000B1711 /* scsi.cpp in Sources */, @@ -1094,7 +1112,6 @@ 0856D07D14A99EF1000B1711 /* timer.cpp in Sources */, 0856D07E14A99EF1000B1711 /* about_window_unix.cpp in Sources */, E44C460720D262B0000583AE /* ip_icmp.c in Sources */, - 0856D08714A99EF1000B1711 /* bincue_unix.cpp in Sources */, E4CBF46120CFC451009F40CC /* video_sdl.cpp in Sources */, 0856D09814A99EF1000B1711 /* ether_unix.cpp in Sources */, 0856D0AA14A99EF1000B1711 /* main_unix.cpp in Sources */, @@ -1107,6 +1124,7 @@ 0856D10E14A99EF1000B1711 /* sys_unix.cpp in Sources */, E44C461720D262B0000583AE /* cksum.c in Sources */, 0856D10F14A99EF1000B1711 /* timer_unix.cpp in Sources */, + 5D35961124B8F5FB0081EC8A /* bincue.cpp in Sources */, 0856D11114A99EF1000B1711 /* user_strings_unix.cpp in Sources */, E44C461020D262B0000583AE /* slirp.c in Sources */, 0856D11614A99EF1000B1711 /* xpram_unix.cpp in Sources */, @@ -1157,10 +1175,12 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULE_DEBUGGING = YES; COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_OPTIMIZATION_LEVEL = 0; + GCC_OPTIMIZATION_LEVEL = 3; GCC_PREPROCESSOR_DEFINITIONS = ( "DATADIR=", HAVE_CONFIG_H, @@ -1182,6 +1202,7 @@ ); INSTALL_PATH = /usr/local/lib; MACOSX_DEPLOYMENT_TARGET = 10.7; + OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; PRODUCT_NAME = kpx_cpu; VALID_ARCHS = x86_64; }; @@ -1193,7 +1214,8 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LIBRARY = "libc++"; - COPY_PHASE_STRIP = YES; + CLANG_ENABLE_MODULE_DEBUGGING = YES; + COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_DYNAMIC_NO_PIC = YES; GCC_ENABLE_FIX_AND_CONTINUE = NO; @@ -1219,6 +1241,7 @@ ); INSTALL_PATH = /usr/local/lib; MACOSX_DEPLOYMENT_TARGET = 10.7; + OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; PRODUCT_NAME = kpx_cpu; VALID_ARCHS = x86_64; }; @@ -1274,6 +1297,8 @@ "_GNU_SOURCE=1", _THREAD_SAFE, _REENTRANT, + "BINCUE=1", + "USE_SDL_AUDIO=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_UNUSED_FUNCTION = YES; @@ -1337,6 +1362,8 @@ "_GNU_SOURCE=1", _THREAD_SAFE, _REENTRANT, + "BINCUE=1", + "USE_SDL_AUDIO=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_UNUSED_FUNCTION = YES; diff --git a/SheepShaver/src/Unix/Makefile.in b/SheepShaver/src/Unix/Makefile.in index ed6148a4..88ef3394 100644 --- a/SheepShaver/src/Unix/Makefile.in +++ b/SheepShaver/src/Unix/Makefile.in @@ -105,9 +105,6 @@ define GUI_SRCS_LIST_TO_OBJS $(basename $(notdir $(file)))))) endef GUI_OBJS = $(GUI_SRCS_LIST_TO_OBJS) -ifeq ($(USE_BINCUE),yes) -GUI_OBJS += bincue_unix.o -endif define DYNGENSRCS_LIST_TO_OBJS $(addprefix $(OBJ_DIR)/, $(addsuffix .dgo, $(foreach file, $(DYNGENSRCS), \ diff --git a/SheepShaver/src/Unix/bincue_unix.cpp b/SheepShaver/src/Unix/bincue_unix.cpp deleted file mode 120000 index f9ed574d..00000000 --- a/SheepShaver/src/Unix/bincue_unix.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../BasiliskII/src/Unix/bincue_unix.cpp \ No newline at end of file diff --git a/SheepShaver/src/Unix/bincue_unix.h b/SheepShaver/src/Unix/bincue_unix.h deleted file mode 120000 index 9c7e8c5c..00000000 --- a/SheepShaver/src/Unix/bincue_unix.h +++ /dev/null @@ -1 +0,0 @@ -../../../BasiliskII/src/Unix/bincue_unix.h \ No newline at end of file diff --git a/SheepShaver/src/Unix/configure.ac b/SheepShaver/src/Unix/configure.ac index 7c546e27..88a08c96 100755 --- a/SheepShaver/src/Unix/configure.ac +++ b/SheepShaver/src/Unix/configure.ac @@ -698,6 +698,7 @@ AS_IF([test "x$have_bincue" = "xyes" ], [ AC_SUBST(USE_BINCUE, no) else CPPFLAGS="$CPPFLAGS -DBINCUE $OSX_CORE_AUDIO" + DEFINES="$DEFINES -DBINCUE" AC_SUBST(USE_BINCUE, yes) fi ], [AC_SUBST(USE_BINCUE, no)]) @@ -781,7 +782,7 @@ fi dnl BINCUE overrides if [[ "x$have_bincue" = "xyes" ]]; then - EXTRASYSSRCS="$EXTRASYSSRCS bincue_unix.cpp" + EXTRASYSSRCS="$EXTRASYSSRCS bincue.cpp" fi dnl libvhd overrides diff --git a/SheepShaver/src/Windows/Makefile.in b/SheepShaver/src/Windows/Makefile.in index cb7a0650..6e3fedaa 100755 --- a/SheepShaver/src/Windows/Makefile.in +++ b/SheepShaver/src/Windows/Makefile.in @@ -29,6 +29,8 @@ SLIRP_SRCS = \ ../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c SLIRP_OBJS = $(SLIRP_SRCS:../slirp/%.c=$(OBJ_DIR)/slirp-%.o) +USE_BINCUE = @USE_BINCUE@ + LN_S = @LN_S@ WINDRES = @WINDRES@ CC = @CC@ @@ -41,6 +43,7 @@ LDFLAGS = @LDFLAGS@ -Wl,-Bstatic #TODO remove pthread part of that if irrelevant LIBS = @LIBS@ -lws2_32 -lwsock32 -liphlpapi CPUSRCS = @CPUSRCS@ +EXTRASRCS = @EXTRASRCS@ PERL = @PERL@ USE_DYNGEN = @USE_DYNGEN@ @@ -73,7 +76,7 @@ SRCS = ../main.cpp main_windows.cpp ../prefs.cpp ../prefs_items.cpp prefs_window about_window_windows.cpp ../user_strings.cpp user_strings_windows.cpp \ ../dummy/prefs_editor_dummy.cpp clip_windows.cpp util_windows.cpp \ vm_alloc.cpp sigsegv.cpp posix_emu.cpp SheepShaver.rc \ - $(CPUSRCS) $(ROUTERSRCS) $(SLIRP_OBJS) + $(CPUSRCS) $(ROUTERSRCS) $(EXTRASRCS) $(SLIRP_OBJS) UI_SRCS = ../prefs.cpp prefs_windows.cpp prefs_editor_gtk.cpp xpram_windows.cpp \ ../prefs_items.cpp ../user_strings.cpp user_strings_windows.cpp util_windows.cpp \ diff --git a/SheepShaver/src/Windows/configure.ac b/SheepShaver/src/Windows/configure.ac index 67d4adf2..73adb19d 100644 --- a/SheepShaver/src/Windows/configure.ac +++ b/SheepShaver/src/Windows/configure.ac @@ -16,6 +16,9 @@ AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [defa AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes]) AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes]) +AC_ARG_WITH(bincue, + AS_HELP_STRING([--with-bincue], [Allow cdrom image files in bin/cue mode])) + dnl Checks for programs. AC_PROG_CC AC_PROG_CPP @@ -199,6 +202,19 @@ cygwin) ;; esac +dnl BINCUE +AS_IF([test "x$with_bincue" = "xyes" ], [have_bincue=yes], [have_bincue=no]) +AS_IF([test "x$have_bincue" = "xyes" ], [ + DEFINES="$DEFINES -DBINCUE" + CPPFLAGS="$CPPFLAGS -DBINCUE" + AC_SUBST(USE_BINCUE, yes) +], [AC_SUBST(USE_BINCUE, no)]) + +dnl BINCUE overrides +if [[ "x$have_bincue" = "xyes" ]]; then + EXTRASRCS="$EXTRASRCS bincue.cpp" +fi + dnl CPU emulator sources CPUSRCS="\ ../kpx_cpu/src/mathlib/ieeefp.cpp \ @@ -278,6 +294,7 @@ AC_SUBST(USE_PREGENERATED_DYNGEN) AC_SUBST(DYNGENSRCS) AC_SUBST(DYNGEN_OP_FLAGS) AC_SUBST(CPUSRCS) +AC_SUBST(EXTRASRCS) AC_OUTPUT([Makefile]) dnl Print summary. @@ -286,6 +303,7 @@ echo SheepShaver configuration summary: echo echo Enable JIT compiler .............. : $WANT_JIT echo GTK user interface ............... : $WANT_GTK +echo BINCUE support ......................... : $have_bincue echo Enable VOSF ...................... : $WANT_VOSF echo echo "Configuration done. Now type \"make\"." diff --git a/SheepShaver/src/bincue.cpp b/SheepShaver/src/bincue.cpp new file mode 120000 index 00000000..a3de57df --- /dev/null +++ b/SheepShaver/src/bincue.cpp @@ -0,0 +1 @@ +../../BasiliskII/src/bincue.cpp \ No newline at end of file diff --git a/SheepShaver/src/include/bincue.h b/SheepShaver/src/include/bincue.h new file mode 120000 index 00000000..59a01bfb --- /dev/null +++ b/SheepShaver/src/include/bincue.h @@ -0,0 +1 @@ +../../../BasiliskII/src/include/bincue.h \ No newline at end of file diff --git a/SheepShaver/src/rom_patches.cpp b/SheepShaver/src/rom_patches.cpp index 83d6f17d..8f15b805 100644 --- a/SheepShaver/src/rom_patches.cpp +++ b/SheepShaver/src/rom_patches.cpp @@ -411,12 +411,12 @@ static const uint8 sony_driver[] = { // Replacement for .Sony driver static const uint8 disk_driver[] = { // Generic disk driver // Driver header DiskDriverFlags >> 8, DiskDriverFlags & 0xff, 0, 0, 0, 0, 0, 0, - 0x00, 0x18, // Open() offset - 0x00, 0x1c, // Prime() offset - 0x00, 0x20, // Control() offset - 0x00, 0x2c, // Status() offset - 0x00, 0x52, // Close() offset - 0x05, 0x2e, 0x44, 0x69, 0x73, 0x6b, // ".Disk" + 0x00, 0x1c, // Open() offset + 0x00, 0x20, // Prime() offset + 0x00, 0x24, // Control() offset + 0x00, 0x30, // Status() offset + 0x00, 0x56, // Close() offset + 0x08, 0x2e, 0x41, 0x54, 0x41, 0x44, 0x69, 0x73, 0x6b, 0x00, // ".ATADisk" // Open() M68K_EMUL_OP_DISK_OPEN >> 8, M68K_EMUL_OP_DISK_OPEN & 0xff, @@ -2362,6 +2362,7 @@ static bool patch_68k(void) *wp++ = htons(0x4e74); *wp++ = htons(0x0008); // rtd #8 } } + return true; } @@ -2418,7 +2419,7 @@ void InstallDrivers(void) WriteMacInt16(dce + dCtlFlags, DiskDriverFlags); // Open disk driver - SheepString disk_str("\005.Disk"); + SheepString disk_str("\010.ATADisk"); WriteMacInt32(pb + ioNamePtr, disk_str.addr()); r.a[0] = pb; Execute68kTrap(0xa000, &r); // Open() diff --git a/SheepShaver/src/rsrc_patches.cpp b/SheepShaver/src/rsrc_patches.cpp index 8bf0ac4f..ccd1c33d 100644 --- a/SheepShaver/src/rsrc_patches.cpp +++ b/SheepShaver/src/rsrc_patches.cpp @@ -517,12 +517,13 @@ void CheckLoad(uint32 type, int16 id, uint16 *p, uint32 size) D(bug(" patch applied\n")); } - } else if (type == FOURCC('D','R','V','R') && (id == -16501 || id == -16500)) { + // patch for -16501 resource ID not even needed? seems to run off native driver without +/* } else if (type == FOURCC('D','R','V','R') && (id == -16501)){// || id == -16500)) { // -16500 will patch over native driver and traps out to code, but very hard to re-implement there! D(bug("DRVR -16501/-16500 found\n")); // Install sound input driver memcpy(p, sound_input_driver, sizeof(sound_input_driver)); D(bug(" patch 1 applied\n")); - +*/ } else if (type == FOURCC('I','N','I','T') && id == 1 && size == (2416 >> 1)) { D(bug("INIT 1 (size 2416) found\n")); size >>= 1;