Sound Manager 2.x Support

It’s again been quite a bit of time since last update, as we’ve been busy on doing other stuff for the latter half of 2021, and the winter – but now in spring, we again had time to work on the emulator. During the past couple weeks, Toni spent time finishing the first round of Sound Manager 2 research, so we were able to move to implementation phase last week. And after first week of coding, we already have a handful of test applications with (mostly) working Sound Manager 2 support – although, as planned, it is at moment limited only to applications running in the “classic” emulation mode. Here’s a short video demonstration of the new audio capabilities:

Sound Manager 2.x tests on M.A.C.E.

In the video, the following test applications are shown:

  • Civilization, with fully working sound output (exclusively with bufferCmds through ‘snd ‘ resources).
  • Prince of Persia 1, also fully working (interestingly, even without Sound Manager, PoP1 was able to *mostly* output audio with Sound Driver, but looping sounds (door opening) caused hang in that mode because of the way it used the Device Manager routines. With Sound Manager, none of those issues are present and all seems work fine (again, using bufferCmd commands).
  • Bard’s Tale was a bit different test case for us, as it uses soundCmd combined with noteCmd/restCmd etc commands to play the music. But it also works now, apparently fully.
  • Railroad Tycoon has also fully working sound support, again using bufferCmd with ‘snd ‘ resources like Civilization 1. This game has interestingly its own sound queuing system, separate from Sound Manager command queues – which allows funny way of queueing multiple sounds if invoked rapidly after each other, which eventually get played in turn after each other. Also this behaviour seems to match fully how audio in the game works on real Macs.
  • Pararena 1.3 also has now working sounds
  • And Pipe Dream finally also got sound and music
  • Finally, Loom also has working sound & music, although the Mac Plus/Classic style behaviour of music does sound a bit “fishy”. We checked that the music does sound same way at least on minivmac, although it appears to have been meant to be played using 4-channel output, while the “classic” hardware is limited to only one channel at once. This game also uses soundCmd/noteCmd to adjust playback frequency of samples, like Bard’s Tale. Also, there is still at least one known race condition issue in playback, which appears to actually be identical to a deadlock that happens also in minivmac, if the game is run under that emulator on faster than 1x speed.

Also, there’s working button click sounds in Speedometer system info window, and we’re working on getting sound to work also in Bolo soon (it uses apparently older style selectors for SoundDispatch at least in one case, which we don’t handle yet, so we need to improve that next).

All of the features of Sound Manager 2 haven’t been implemented yet, as we’ve been adding them “on demand” as we’ve been trying out various test applications. Some of features not yet implemented include:

  • Compressed sound decompression/compression
  • At moment, only ‘snth’ 5 (sampledSynth) synthesizer is supported (the squareWaveSynth and waveTableSynth still need to be added)
  • Sound Manager command timing is supposed to the drift-free Extended Time Manager tasks, but they for now default to regular TMTask behaviour. This will cause songs played using noteCmd/restCmd/etc, that depend on command duration for timing, to drift off a bit (at least in Bard’s Tale and Loom)
  • And as mentioned before, only Sound Manager 2.x for “classic” mode was implemented, so the color mode does not yet have audio. But that will follow up later as Sound Manager 3.x compatibility after we finish research on it (we plan to implement Component Manager emulation as first step on way to SM3 compatibility, which both allows us to provide Sound Component capabilities, and also allows in future other APIs that depend on Components to be implemented – such as QuickTime and Internet Config)

Other fixes

There are also a number of other improvements, of which some are listed here:

  • MDEF 0 now supports scrolling in popup menus, which allows the Machine Record selection popup to be opened in Speedometer, when screen size is smaller than the menu
  • Fixed issue in “classic” QuickDraw PICT color translation mapping, which was causing black credits screen in Railroad Tycoon
  • GhostWindow low-memory global handling was added – this fixes most of the issues in SuperPaint 1
  • ScalePt/FixDiv had a couple bugs, which caused at least two separate issues in MacDraw (related to calculation of object coordinates on the document)
  • Color search proc support and a couple color picker package traps were added (for HSV conversion) were added to allow Solarian 2 to work
  • Rounded windows (WDEF 1) finally have the close box (and color support) – this allows for example the about screen in Glider 2 & 3 to be closed 🙂
  • Allocation of WDCBs through OpenWD now check for existing working directories, to not flood the WDCB table and run out of memory. This happened at least with certain applications using the “Mercutio” MDEF, which on each message did SysEnvirons call, which in turn opened a WD in the system folder
  • A bunch of other important fixes
  • And finally, as first step of getting FPU support, Pukka has started implementation of the 68881/2 emulation, so we will eventually be able to run applications requiring the math co-processor instructions (such as Specular Logomotion and Pixar Typestry)

Full list of changes since last post

2022-04-12 23:42:44 +0300 • Fix typo in Bolo JSON config                      
2022-04-12 23:29:35 +0300 • Fix signed/unsigned comparison in FMSeek          
2022-04-12 23:28:33 +0300 • Tweak test apps for sound tests + add BoloSounds  
2022-04-12 22:06:17 +0300 • Fix classic QD color-to-mono translation mapping  
2022-04-12 21:31:19 +0300 • Implement rateCmd in snth 4101 (classic SM2)      
2022-04-12 21:24:47 +0300 • Fix uninitialized SndChannelPtr in SndPlay        
2022-04-12 00:48:08 +0300 • Add scrolling support to popup menu case of MDEF 0
2022-04-11 17:00:05 +0300 • Fix disposal of channel if SndNewChannel fails    
2022-04-11 16:45:48 +0300 • Some PrimeTime prep for extended timer mgr support
2022-04-11 16:43:27 +0300 • Fix timer task deactivation in RmvTime            
2022-04-11 16:42:37 +0300 • Fix setting of channel idle state from quietCmd   
2022-04-11 16:41:42 +0300 • Swap new buffer in note/freqCmd if already playing
2022-04-11 14:55:02 +0300 • Fix duration passed to timer in waitCmd           
2022-04-11 14:53:59 +0300 • Setup synthesizer state correct in noteCmd/freqCmd
2022-04-11 14:52:36 +0300 • Fix bug in checking whether timer was active      
2022-04-11 00:34:59 +0300 • Implement emptyCmd in snth 4101 (classic SM2)     
2022-04-11 00:33:56 +0300 • Fix sample rate conversion bug in soundCmd        
2022-04-09 19:10:16 +0300 • Handle noteCmd/freqCmd in snth 4101 (classic SM2) 
2022-04-09 00:02:14 +0300 • Implement waitCmd (classic SM2)                   
2022-04-09 00:02:01 +0300 • Implement restCmd in snth 4101 (classic SM2)      
2022-04-08 23:37:15 +0300 • Handle soundCmd in snth 4101 (classic SM2)        
2022-04-08 20:23:59 +0300 • Fix SM2 locking (dispose channel during playback) 
2022-04-08 20:21:14 +0300 • Fix  end-of-buffer handling in snth 4101 VBL Task 
2022-04-08 20:19:38 +0300 • Set correct state in quietCmd handler in snth 4101
2022-04-08 20:18:56 +0300 • Clear busy flag correctly at end of snth VBL Task 
2022-04-08 13:01:33 +0300 • Fix size mismatch when setting channelIdle flag   
2022-04-08 12:47:08 +0300 • Implement flushCmd handling (classic SM2)         
2022-04-08 12:46:50 +0300 • Implement SndDoImmediate (classic SM2)            
2022-04-08 12:25:55 +0300 • Implement freeCmd in snth 4101 (classic SM2)      
2022-04-08 12:25:41 +0300 • Fix a couple byteswap bugs in channel flags       
2022-04-08 12:23:09 +0300 • Implement SndDisposeChannel (classic SM2)         
2022-04-08 04:18:00 +0300 • Implement callbackCmd (classic SM2)               
2022-04-08 04:12:18 +0300 • Handle quietCmd in snth 4101                      
2022-04-08 03:56:40 +0300 • Implement resumeCmd handling                      
2022-04-08 03:47:29 +0300 • Handle tickleCmd in snth 4101 (classic SM2)       
2022-04-08 03:36:14 +0300 • Implement basic snth 4101 buffering (classic SM2) 
2022-04-08 03:34:44 +0300 • Implement Timer1 & tickleCmd sending (classic SM2)
2022-04-07 03:49:16 +0300 • Handle bufferCmd in 'snth' 4101 (classic SM2)     
2022-04-07 03:47:59 +0300 • Handle high-level pauseCmd (SM2 classic variant)  
2022-04-07 02:08:33 +0300 • Implement command timer & dequeueing (classic SM2)
2022-04-06 20:25:16 +0300 • Implement queueing in SndDoCommand (SM2 variant)  
2022-04-06 19:21:39 +0300 • Handle initCmd in 'snth' 5 (SM2 "classic" variant)
2022-04-06 18:21:17 +0300 • Implement availableCmd and versionCmd in 'snth' 5 
2022-04-06 18:08:38 +0300 • Implement quietCmd handler                        
2022-04-06 17:58:52 +0300 • SndAddModifier mostly implemented (SM2.x variant) 
2022-04-06 02:17:47 +0300 • Implement SndPlay 'snd ' format 1 resource parsing
2022-04-06 01:33:48 +0300 • Fix typo in previous commit                       
2022-04-06 01:33:08 +0300 • Initialize Sound Manager (and fix byteswap bug)   
2022-04-06 01:17:33 +0300 • Use SndAddModifier in SndNewChannel               
2022-04-06 01:14:29 +0300 • Add SndAddModifier trap (dummy stub at moment)    
2022-04-06 01:13:07 +0300 • SndNewChannel proto implementation (SM2.x variant)
2022-04-06 01:11:00 +0300 • Add snth 0x1005 (mac plus variant of sampledSynth)
2022-04-06 01:10:33 +0300 • Update sound manager headers with new information 
2022-04-03 22:31:59 +0300 • fix constants                                     
2022-04-03 21:32:09 +0300 • base for fpu                                      
2022-03-23 00:27:09 +0200 • Reinforce IODone to handle weirdness of SimCity1.3
2022-03-20 05:02:17 +0200 • Add missing GhostWindow check to FrontWindow trap 
2022-03-19 03:47:11 +0200 • Fix ScalePt special case byteswap bug             
2022-03-19 00:31:53 +0200 • Better fix for FixDiv overflow case               
2022-03-19 00:29:30 +0200 • Set MemErr to noErr when MoreMasters succeeds     
2022-03-18 04:39:24 +0200 • Avoid weird C bug causing FixDiv fail in release  
2022-03-08 03:14:17 +0200 • Add missing music file to PipeDream test app      
2022-02-17 22:40:14 +0200 • Re-use existing WDCB when possible (not MF-aware) 
2022-02-17 15:24:34 +0200 • Allow skip of selector high byte in some selectors
2022-02-17 15:20:12 +0200 • Fix overflow in iteration of WDCB list            
2022-01-12 02:43:01 +0200 • Implement _DelSearch (0xAA4C) Color Manager Trap  
2022-01-11 04:02:15 +0200 • Implement FADDL selector for FP68K in SANE        
2022-01-11 04:01:28 +0200 • Implement HSV2RGB in Pack12 (color picker package)
2022-01-10 00:25:46 +0200 • Implement RGB2HSV in Pack12 (color picker package)
2022-01-09 21:08:25 +0200 • Add dummy SndChannelStatus to SoundDispatch       
2022-01-09 08:56:43 +0200 • Call searchProc in _Color2Index trap when needed  
2022-01-09 08:56:05 +0200 • Implement _AddSearch (0xAA3A) Color Manager Trap  
2021-12-01 15:15:21 +0200 • Add dummy GNEFilter for modal dialogs             
2021-12-01 15:14:06 +0200 • Support kSpecialCaseGNEFilterProc mixedmode calls 
2021-11-03 05:54:14 +0200 • Fix handling of MP lock flag in MMSetSize24       
2021-11-03 05:52:18 +0200 • Fix measuring memory purge range in memory manager
2021-10-29 13:09:10 +0300 • Add Uninvited to test app JSON configs            
2021-10-27 14:52:29 +0300 • Fix calculation of offset to font name in 'ictb'  
2021-10-27 14:33:29 +0300 • Fix opOrigin PICT opcode (disposed wrong region)  
2021-10-27 13:54:33 +0300 • Fix typo in the Hornet JSON test app config file  
2021-10-27 13:31:04 +0300 • Add F/A-18 Hornet 2.0.1 to test app configs       
2021-10-27 13:30:38 +0300 • Fix SysEnvirons, use 'proc' instead of 'cput'     
2021-10-27 13:29:04 +0300 • Handle special palettes with bit 14 set in flags  
2021-10-27 05:13:14 +0300 • Fix minor Palette Manager bugs                    
2021-10-27 04:18:39 +0300 • Add ADB Manager & dummy CountADBs/GetADBInfo traps
2021-10-27 03:57:20 +0300 • Video DRVR: Handle status codes & add linear gamma
2021-09-26 20:45:07 +0300 • Disable SDL minimize/close keys (3rd party lib!!!)
2021-09-26 20:40:59 +0300 • Temp fix for return address of TRAP # instructions
2021-09-26 20:38:25 +0300 • Fix 32-bit overflow in ASR.W instruction          
2021-09-26 20:37:53 +0300 • Fix RTE instruction                               
2021-08-22 13:10:43 +0300 • Fix pattern masking bug in arithmetic rect blitter
2021-08-17 23:32:14 +0300 • Add dummy SRsrcInfo selector for Slot Manager     
2021-08-17 03:47:44 +0300 • Fix artifacting of outline/shadow color QD text   
2021-08-16 17:42:58 +0300 • Fix some Memory Manager type conversion warnings  
2021-08-16 17:42:03 +0300 • Add srcOr/srcXor/srcBic colorQD region blit modes 
2021-08-16 14:35:33 +0300 • Add missing WDEF 1 changes from previous commit   
2021-08-16 14:35:06 +0300 • WDEF 1 (rounded window) color support & GoAway box
2021-08-16 14:34:13 +0300 • Fix array overflow in the minilauncher hack proto 
2021-08-12 22:06:06 +0300 • Fix memory leak in DialogManager (Get)New(C)Dialog
2021-08-12 22:03:05 +0300 • Fix memory leak in CloseWindow (call CloseCPort)  
2021-07-29 19:48:49 +0300 • Add 1-to-2 bit non-colorizing pixel translator    
2021-07-13 23:42:11 +0300 • Sanity check ioNamePtr in _GetVol trap            
2021-07-13 23:41:02 +0300 • Add Bards Tale test app JSON configs              
2021-07-13 18:21:41 +0300 • Add Macintalk test app JSON configs               
2021-07-07 00:12:25 +0300 • Bump up version number                            
2021-07-07 00:12:14 +0300 • Fix VBL interrupt crash from start race condition 
2021-07-06 21:42:48 +0300 • Fix changes that broke .Sound DRVR #3             
2021-07-06 00:05:22 +0300 • Install dummy DRVR 4 at startup                   
2021-07-05 23:06:35 +0300 • Tweak Space Quest 1 config JSON (pass copy checks)
2021-07-05 23:06:02 +0300 • Add missing DskErr lowmem from previous commit    
2021-07-05 23:05:48 +0300 • Add dummy .Sony driver, allows DRVR 4 Status calls