--- BasiliskII/src/audio.cpp 1999/10/03 14:16:25 1.1 +++ BasiliskII/src/audio.cpp 2001/02/02 20:52:56 1.7 @@ -1,7 +1,7 @@ /* * audio.cpp - Audio support * - * Basilisk II (C) 1997-1999 Christian Bauer + * Basilisk II (C) 1997-2001 Christian Bauer * Portions (C) 1997-1999 Marc Hellwig * * This program is free software; you can redistribute it and/or modify @@ -48,6 +48,16 @@ bool AudioAvailable = false; // Flag: a /* + * Reset audio emulation + */ + +void AudioReset(void) +{ + audio_data = 0; +} + + +/* * Get audio info */ @@ -113,27 +123,39 @@ static int32 AudioGetInfo(uint32 infoPtr } case siSpeakerMute: - WriteMacInt16(infoPtr, audio_get_main_mute()); + WriteMacInt16(infoPtr, audio_get_speaker_mute()); break; case siSpeakerVolume: - WriteMacInt32(infoPtr, audio_get_main_volume()); + WriteMacInt32(infoPtr, audio_get_speaker_volume()); + break; + + case siHeadphoneMute: + WriteMacInt16(infoPtr, 0); + break; + + case siHeadphoneVolume: + WriteMacInt32(infoPtr, 0x01000100); + break; + + case siHeadphoneVolumeSteps: + WriteMacInt16(infoPtr, 13); break; case siHardwareMute: - WriteMacInt16(infoPtr, audio_get_dac_mute()); + WriteMacInt16(infoPtr, audio_get_main_mute()); break; case siHardwareVolume: - WriteMacInt32(infoPtr, audio_get_dac_volume()); + WriteMacInt32(infoPtr, audio_get_main_volume()); break; - case siHardwareBusy: - WriteMacInt16(infoPtr, AudioStatus.num_sources != 0); + case siHardwareVolumeSteps: + WriteMacInt16(infoPtr, 13); break; - case siHardwareVolumeSteps: - WriteMacInt16(infoPtr, 64); + case siHardwareBusy: + WriteMacInt16(infoPtr, AudioStatus.num_sources != 0); break; default: // Delegate to Apple Mixer @@ -197,21 +219,25 @@ static int32 AudioSetInfo(uint32 infoPtr return badChannel; case siSpeakerMute: - audio_set_main_mute((uint16)infoPtr); + audio_set_speaker_mute((uint16)infoPtr); break; case siSpeakerVolume: D(bug(" set speaker volume %08lx\n", infoPtr)); - audio_set_main_volume(infoPtr); + audio_set_speaker_volume(infoPtr); + break; + + case siHeadphoneMute: + case siHeadphoneVolume: break; case siHardwareMute: - audio_set_dac_mute((uint16)infoPtr); + audio_set_main_mute((uint16)infoPtr); break; case siHardwareVolume: D(bug(" set hardware volume %08lx\n", infoPtr)); - audio_set_dac_volume(infoPtr); + audio_set_main_volume(infoPtr); break; default: // Delegate to Apple Mixer @@ -351,7 +377,7 @@ adat_error: printf("FATAL: audio compone return noErr; case kComponentVersionSelect: - return 0x00010002; + return 0x00010003; case kComponentCloseSelect: open_count--; @@ -378,7 +404,7 @@ adat_error: printf("FATAL: audio compone // Init sound component data WriteMacInt32(audio_data + adatData + scd_flags, 0); - WriteMacInt32(audio_data + adatData + scd_format, AudioStatus.sample_size == 16 ? 'twos' : 'raw '); + WriteMacInt32(audio_data + adatData + scd_format, AudioStatus.sample_size == 16 ? FOURCC('t','w','o','s') : FOURCC('r','a','w',' ')); WriteMacInt16(audio_data + adatData + scd_numChannels, AudioStatus.channels); WriteMacInt16(audio_data + adatData + scd_sampleSize, AudioStatus.sample_size); WriteMacInt32(audio_data + adatData + scd_sampleRate, AudioStatus.sample_rate); @@ -444,3 +470,128 @@ delegate: // Delegate call to Apple Mixe return badComponentSelector; } } + + +/* + * Sound input driver Open() routine + */ + +int16 SoundInOpen(uint32 pb, uint32 dce) +{ + D(bug("SoundInOpen\n")); + return noErr; +} + + +/* + * Sound input driver Prime() routine + */ + +int16 SoundInPrime(uint32 pb, uint32 dce) +{ + D(bug("SoundInPrime\n")); + //!! + return paramErr; +} + + +/* + * Sound input driver Control() routine + */ + +int16 SoundInControl(uint32 pb, uint32 dce) +{ + 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 + + 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) { + default: + return -231; // siUnknownInfoType + } +} + + +/* + * Sound input driver Status() routine + */ + +int16 SoundInStatus(uint32 pb, uint32 dce) +{ + uint16 code = ReadMacInt16(pb + csCode); + D(bug("SoundInStatus %d\n", code)); + 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)); + switch (selector) { +#if 0 + case siDeviceName: { + const char *str = GetString(STR_SOUND_IN_NAME); + param[0] = 0; + memcpy((void *)param[1], str, strlen(str)); + return noErr; + } + + case siDeviceIcon: { + M68kRegisters r; + static const uint16 proc[] = { + 0x558f, // subq.l #2,sp + 0xa994, // CurResFile + 0x4267, // clr.w -(sp) + 0xa998, // UseResFile + 0x598f, // subq.l #4,sp + 0x4879, 0x4943, 0x4e23, // move.l #'ICN#',-(sp) + 0x3f3c, 0xbf76, // move.w #-16522,-(sp) + 0xa9a0, // GetResource + 0x245f, // move.l (sp)+,a2 + 0xa998, // UseResFile + 0x200a, // move.l a2,d0 + 0x6604, // bne 1 + 0x7000, // moveq #0,d0 + M68K_RTS, + 0x2f0a, //1 move.l a2,-(sp) + 0xa992, // DetachResource + 0x204a, // move.l a2,a0 + 0xa04a, // HNoPurge + 0x7001, // moveq #1,d0 + M68K_RTS + }; + Execute68k((uint32)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 + } +#endif + default: + return -231; // siUnknownInfoType + } +} + + +/* + * Sound input driver Close() routine + */ + +int16 SoundInClose(uint32 pb, uint32 dce) +{ + D(bug("SoundInClose\n")); + return noErr; +}