WarpSE: 25 MHz 68HC000-based accelerator for Mac SE

phipli

Tinkerer
Sep 23, 2021
35
26
18
The final word on "good recordings"...


But it largely shows you what my previous video did. And it makes the stock SE audio stuttering all the more clear. I supposed the rest of you hear that stuttering too, right?

In any case, it shows ROBUST doesn't playback the Tetris theme music as perfectly as the stock SE audio.
Good work - looks like setting the volume level to 1 brought it down into range. I was nervous to suggest that in case Tetris cranked it back up on launch and toasted your recorder.

Like @Andy said, the stuttering sounds and looks like a background task hogging the CPU. As a quick test, perhaps boot with extensions off and see if it still does it.

Could you upload a few seconds of the sound out jack recordings of the stock SE and of the accelerator as .wavs? Just like 5 seconds of each so I could have a quick look at the waveform. It might give some clues, although perhaps any filtering in the sound output circuit will smooth out any obvious dropped samples or anything.

Please feel free to say no if you're not set up to do it easily.

If I record it from the youtube video it will have been through compression.
 
  • Like
Reactions: Zane Kaminski

Zane Kaminski

Administrator
Staff member
Founder
Sep 5, 2021
294
530
93
Columbus, Ohio, USA
It really stood out to me in the original recording too. So much so that I dug out my SE and ran Tetris on it to verify. I noticed you were running System 7 and I wonder if there's a background task causing the stuttering.

On my SE with 2.5 megs of memory, running System 6.0.8 without Multi Finder, no extensions like After Dark, and using an old spinning hard disk, I hear no stuttering. If I turn on Multi Finder, I didn't hear anything, maybe a very slight stutter, but that might have been my imagination. I'm not setup to run System 7 on my SE at the moment, but I suspect there's a periodic task running, an extension, or just the system trying to do a lot more that is causing the stuttering.

Back on topic with the accelerator and sound, are there Sound Manager code differences between System 6 and 7 that might be affecting sound distortion? Could fixes for System 7 cause issues in System 6?
I think the ultimate solution is gonna be to develop a slowdown function in the accelerator that exactly mimics the speed of the Mac SE. That will fix any and all speed-dependent problems, no matter the OS.

The origin of the sound problem is that the CPU is too fast and writes to the whole sound buffer before the Mac can finish playing it. This causes a skip in sound playback 60 times per second and the audio output sounds chopped up with this ugly 60 Hz tone superimposed on top from the repeated “pop” that occurs when the skip happens.

More specifically, in the sound manager, when generating four-voice sound, the CPU starts generating samples after vertical blanking approximately in the middle of the sound buffer. This is to basically give the motherboard logic a head start because even an unaccelerated CPU generates samples twice as fast as the motherboard plays them. With an accelerated CPU, this head start is not enough and the corruption occurs. If the CPU is really fast then a large portion of the sound buffer ends up overwritten and the skip is more obvious. If the CPU is only a little faster than stock, less of the sound buffer is overwritten before it can be played and the skip is smaller and less objectionable. Our goal is to slow the CPU down to exactly the right speed so that it does not outrun sound playback. Or maybe it can be a bit slower but we have to immediately disable the extra slowdown once any other I/O chip is accessed.

So whenever the accelerated CPU touches one of the I/O chips or writes to the sound buffer, slowdown will be triggered for the next 28-42 microseconds (0.028-0.042 milliseconds). The slowdown timer is restarted every time another write to the sound buffer occurs so that slowdown happens continuously in the sound manager’s routine to fill the buffer. If we had the slowdown speed exactly right then there would be absolutely zero issues with sound or any I/O device. “PDS-synchronized I/O slowdown” is close but it’s still a little bit faster than the Mac SE in the case where the CPU “thinks” in between bus cycles. Hence the sound is still a little messed up.

You can see this in the Speedometer results where I permanently enabled slowdown. In the CPU test, which could more accurately be called the memory latency test, the CPU’s performance is bus-limited, so the results are almost identical between the Mac SE and WarpSE. That is, there are very few instruction sequences in the CPU benchmark where the bus cycles are not back-to-back. But in the graphics and math tests, the instructions used end up causing the 68k to read some data from memory and then chew on it for a few clocks before doing another bus cycle. So the increased frequency helps in the math and graphics tests and the performance is faster than stock, which is not desirable during slowdown.

Therefore I have developed a new slowdown technique. During slowdown, all transactions will still be put out on the PDS to equalize the bus speed to stock, but instead of also putting 16 wait states, which was fairly heavy-handed, I’m gonna have the WarpSE skip sending some clock pulses to the fast CPU when the bus is idle. The logic in the fast clock domain will watch the 7.8336 MHz clock of the Mac and only pulse the fast CPU clock right after a 7.8336 MHz clock pulse occurs. This is tricky because there are some statistical/discrete math kind of subtleties relating to the relative phase of the 7.8336 MHz and 25 MHz clocks so the accelerator could still be a hair faster than stock during slowdown but I think it will be fine.

That’s the idea, that during slowdown the WarpSE will get as close as possible to how a regular Mac SE performs. Overall performance during four-voice sound playback will be around 16 MHz speed since the WarpSE spends half of the CPU at 7.8336 MHz and the other half of the time at 25 MHz. So the average is like 16.4 MHz. Single-voice sampled sound will be much faster since a smaller amount of time is spent writing to the sound buffer. I’ve written the code for this and will be trying it soon.
 
Last edited:
  • Like
Reactions: JDW

Zane Kaminski

Administrator
Staff member
Founder
Sep 5, 2021
294
530
93
Columbus, Ohio, USA
I had a random thought - could you implement an SRAM buffer? CPU processes audio...forwards to buffer...buffer forwards to sound output at 7.83MHz?
Yessss and it would improve performance but it requires a much more complicated bus bridge between the fast and PDS buses. Right now, the WarpSE can only put out an address/data onto the PDS that the fast CPU is driving at that moment. The bridge can latch the address/data and save it for later (posted write) so that the accelerated CPU can continue executing from onboard RAM/ROM. However the bridge cannot go out of order or mix writes from different sources such as a buffer with sound writes.

In the future, especially on a possible ‘030-based accelerator where you can’t slow the 68030 down precisely to 68000 speeds, we will have to do something like you’re describing. On a future ‘030 accelerator I would like the PDS bus bridge to have three sources from which it can get a transaction to do. There should be one buffer for video writes, one buffer for sound writes, and one other unbuffered input for everything else. The bus bridge will switch between these sources as appropriate. Video writes will go out at full speed in the absence of other writes, and sound writes will trickle out slowly so as to mimic the timing of a real 68000 writing to the sound buffer. Other writes will have priority and occur as soon as the ‘030 produces them. Of course a larger (BGA) FPGA is required for this since it needs to have enough pins to connect to all of the CPU pins as well as the PDS bus. Right now the WarpSE controller mostly only connects to the fast CPU, plus a few wires of the PDS bus, but none of either data bus.
 
Last edited:
  • Like
Reactions: JDW

JDW

Administrator
Staff member
Founder
Sep 2, 2021
1,400
1,224
113
53
Japan
youtube.com
First and foremost, what I'm about to say has nothing to do with the audio glitching when WarpSE is active and running ROBUST firmware. That has clearly been established, and Zane has written extensive thoughts about how he intends to proceed.



I will now provide more details about the "stuttering audio" that is clearly heard at times when I played Spectrum Holobyte TETRIS opening must on the stock 8MHz Mac SE booted into System 7.1. As per the two earlier comments that spoke about possible background processes, I ran the following tests:

TEST #1
1. I rebooted from my Kero's Mac Mods edition BlueSCSI v1 (mounted on the motherboard with Kay's Type-A SCSIrider and using a proven good 16GB V30 Gigastone MicroSD card) into System 6.0.8.
2. I disabled MultiFinder, and I killed most but not all of the startup INITs. I then rebooted.
3. Since I wasn't recording this time, I set the speaker Volume to 7 so I could better hear the music.
4. I launched Tetris, and it played the opening music to the end without a single stutter.

That test seems to prove that System 6.0.8 is okay, and to some extend my BlueSCSIv1 must also be OK too.

TEST #2
1. I used System Picker to boot my BSv1 into System 7.1, but this time I pressed Shift to Disable Extensions.
2. Speaker volume remained set to 7 from the previous test.
3. I launched Tetris, and it played the opening music with stutters, exactly like my prior audio recordings. (The stuttering only begins after the "ticker" text begins to flow left at the very bottom of the game screen.) This cannot be blamed on INITs or any known background processes not inherent to the OS.

TEST #3
1. I powered OFF and connected my fast IBM DGHS 4.5GB SCSI spinning platter hard drive (mounted inside an HD20 enclosure, with recapped PSU), to the SE and booted into System 7.1, with Extensions OFF.
2. I launched Tetris, and it played the opening music with stutters, exactly like TEST #2 and my prior audio recordings. This test seems to prove that my BSv1 is not at fault, and it even affects fast spinning platter hard drives too.

TEST CONCLUSIONS
You Mac SE owners running System 7.1 can now give Spectrum Holobyte Tetris a test yourself to see if your findings match mine in terms of "audio stuttering," which has nothing whatsoever to do with WarpSE. The stutters are NOT part of the WarpSE audio glitching problem. I merely noticed the stuttering in passing while doing the stock 8MHz test. Once others have chimed in saying it happens to them too while booted into System 7.1, even with Extensions off, then perhaps we can put the stuttering problem to rest and just say, "if you want to hear Tetris music in all its glory, use System 6."

NOTE: All my stock SE 8MHz tests until today have been done by completely removing the WarpSE, leaving no room for anyone to speculate about which clock speed was being used. But today, I tried out Zane's earlier advice (page 21 of this thread) for the very first time, which allows you to disable the WarpSE without removing it, which is a very nice feature to have when you have the back case screwed down. Here's what you must do:

1. Power OFF.
2. Press and hold the INTERRUPT SWITCH (switch closest to the back of the SE, NOT the triangle logo switch).
3. Power ON while still pressing INTERRUPT (not easy to do — press hard on INTERRUPT and don't let your finger slip).
4. There will be no bong and you will see vertical stripes on the CRT. Release the INTERRIPT SWITCH. You will then hear the Bong and stripes go away.
5. The SE will then do everything at the same slow 8MHz it normally does. I verified the clock speed in Speedometer 3. It gave me a CPU of about 1.09.
6. Even if you RESTART the Mac, it will remain in stock 8MHz Mode. Powering OFF and then ON again, without holding the INTERRUPT SWITCH will enable WarpSE again.

Lastly...

24-bit WAV files of the TETRIS MUSIC portion of my SONY D100 recordingscan be downloaded here:


I did not edit them down to 5 seconds out of fear somebody else would later ask for the full recordings. Also, I did not adjust amplitude at all. These are the RAW audio recordings that only trim out any parts not related to TETRIS MUSIC. So you will need to Normalize the amplitude yourself in Audacity, TwistedWave, or your favorite audio editor. Otherwise the volume may be a bit too low during playback. (Yes, I did boost the amplitude when making my video in FCPX to ensure the playback volume was largely the same for all recordings.)
 

JDW

Administrator
Staff member
Founder
Sep 2, 2021
1,400
1,224
113
53
Japan
youtube.com
I recommend testing Prince of Persia - that's the game my cards struggle with most.
Here are 48kHz 24-bit WAV files using WarpSE-ROBUST and the Stock SE, recorded with my SONY D100 at the Headphone Jack:


The Mac SE was booted into System 7.1 with extensions enabled. I used the TwistedWave audio editor to normalize both recordings to 0dB and made them mono (since I left my Stereo to Mono adapter at the office).

I listened to the audio via the Mac's speaker, via the Mac's headphone jack with cheap over-the-ear headphones, and later using my $429 AKG K702 Studio Reference headphones (with braided cable) on my modern Mac. To be honest, I really can't tell any noticeable difference. It's almost like there's no audio issue at all with WarpSE when playing back the Prince of Persia opening music.
 

phipli

Tinkerer
Sep 23, 2021
35
26
18
Here are 48kHz 24-bit WAV files using WarpSE-ROBUST and the Stock SE, recorded with my SONY D100 at the Headphone Jack:


The Mac SE was booted into System 7.1 with extensions enabled. I used the TwistedWave audio editor to normalize both recordings to 0dB and made them mono (since I left my Stereo to Mono adapter at the office).

I listened to the audio via the Mac's speaker, via the Mac's headphone jack with cheap over-the-ear headphones, and later using my $429 AKG K702 Studio Reference headphones (with braided cable) on my modern Mac. To be honest, I really can't tell any noticeable difference. It's almost like there's no audio issue at all with WarpSE when playing back the Prince of Persia opening music.
That is impressive.

All of my SE accelerators cause issues with Prince of Persia's intro music. Not like the issue you're having with Tetris, a different issue where the music keeps dropping out and notes hang. That's what I was checking for.

@Zane - historically there may have been two audio issues on SEs with accelerators. The one I've always struggled with is sample based music and audio recordings dropping out. Your card seems to be managing that issue well. Better than the Mobius and Total Systems cards.
 
  • Like
Reactions: JDW

JDW

Administrator
Staff member
Founder
Sep 2, 2021
1,400
1,224
113
53
Japan
youtube.com
[WarpSE] seems to be managing that issue well. Better than the Mobius and Total Systems cards.
And much better than the Levco (SuperMac) SpeedCard I own, and better than the Radius Accelerator owned by @techknight too!

At this point, I will tag @BFEXTU because he and I shared a lot of private messages in the summer of 2022 regarding the SpeedCard. He was a SuperMac engineer who had the unreleased copy of the v1.7 Control Panel. We discussion the audio glitching extensively, but nothing we tried worked to resolve the issue with the SpeedCard. He had originally thought the unreleased driver (v1.7 CP) might help, but it didn't. Anyway, maybe he would like to chime in after reading through our recent dialog in the last 2-3 pages of this thread.
 

JTRetro

New Tinkerer
Nov 3, 2021
9
7
3
So I have been doing some testing on Zane's new Mac SE accelerator as well, and have some results to post! One of the tests I did was to compare how Zane's accelerator performs in comparison to the Radius 16 and Radius 25mhz accelerators I have in my collection. Here is a screenshot of the test between the Radius 16 and Zane's:
Raduis 16 vs Zane.JPG

As you can see, Zane's accelerator is as fast as a Radius 16, with the exception of the math part of the test. Very impressive in my book!
 
  • Like
Reactions: JDW

JTRetro

New Tinkerer
Nov 3, 2021
9
7
3
And finally, something fun: A quick video of the game "Creepy Castle" playing while running Zane's accelerator. Sound and graphics are all very smooth! I apologize for the slight over-exposure.
 
  • Like
Reactions: JDW

JDW

Administrator
Staff member
Founder
Sep 2, 2021
1,400
1,224
113
53
Japan
youtube.com
And just to clarify for others reading this. The Radius Accelerator 16 and 25 cards use a 68020 CPU and 68881 FPU. WarpSE uses a 25MHz 68000, but no FPU. Hence the impressive performance.

@JTRetro what is the minimum System Software required for your Radius accelerator?

As mentioned in my previous post (video), WarpSE has no drivers to install, allowing me to even boot from System 0.85 and Finder 1.0 (because my SE has the original SE ROMs only compatible with 400K & 800K drives).