• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

Another IIci ROM hack

techknight

Well-known member
like me pretty much. But i enjoy reading and working with you "code hacker/driver types" That I dont know much about.

Put the 2 brains together, we can make anything. I can make hardware, while you can make drivers :)

 

Trash80toHP_Mini

NIGHT STALKER
Amen to that! :approve:

I'm more of a "find the cubic to put the building blocks" from the diagrams kinda hacker. I do a little of this and a little of that, but don't really have the chops to be in either techno-camp.

My hat's off to both of you hackers . . .

. . . I'm perpetually the outrider, the pentagonal peg in a round or square socketed world . . . :eek:)

Makin' connections, drawing parallels and takin'em off on tangents or wedgin'em into the cracks'd be more my kinda' thing. }:)

 

MacJunky

Well-known member
We definitely need a PIRATE Emoticon! }:)
pirate.gifidk how pirateish this is, there is not really much room for a hat/parrot even if you shifted it down and to the side.

Also have one in blue if the black is too much.pirate2.gif

 

MacJunky

Well-known member
Pirates do not wear beige.. >_>

Fine, but he keeps his red dot because he is a pirate. :p

pirate3.1.gif

The upper eyepatch string looks a bit odd, but imo it looks worse if you try to make it thinner.. One might the strings at 90 degrees or something... *shrug*

pirate3.0.gif

 

dougg3

Well-known member
Good point techknight, we can take over the world!!!! Muahahahaha!

Haha, awesome icons! That would be a sweet Happy Mac icon to use on my IIci! (In black and white)

Back on page 1, bbraun pointed out that the Sound Driver section of Inside Macintosh: Volume II may be relevant. It is! It is!

I decided to take a step backward instead. I'm looking at a regular old Mac II ROM, because I believe it uses the exact same Apple Sound Chip that's found in the IIci. Plus, the ROM is smaller than the IIci's ROM so there's less searching involved. I located the Sound Driver in ROM, so IM: Volume II's reference may help me understand what the various functions are supposed to be doing. The book says that the sound driver is "Not in ROM", but I think it's talking about in the Mac 128k and 512k, long before the II came out.

I'm gonna figure this sucker out once and for all! :approve:

 

techknight

Well-known member
. . . I'm perpetually the outrider, the pentagonal peg in a round or square socketed world . . . :eek:)
When I was a kid, I once watched a cartoon, it was called Darkwing Duck. You remind me of the character megavolt. He was a pentagonal peg in a square world.

 

dougg3

Well-known member
Eureka!

I have figured out how to play sampled sounds with the Apple Sound Chip. When I diassembled the Mac II's ROM sound driver, it helped me see how it controls the chip, but it didn't give me everything I needed. It appears that the Mac II's ROM sound driver is driven by a vertical blanking interrupt task that writes some samples into the ASC's FIFO every so often, so it doesn't use any of the FIFO status bits as far as I can tell. I could be wrong, though. I also tried disassembling an old system file, but I couldn't figure out how to find the Sound Manager in there, and I couldn't find anything writing directly into the ASC. Maybe it uses the sound driver to do its playback? No biggie though...

I started out by writing samples to the sound chip without worrying about the FIFO status bits. Instead I added some delay loops in my code to wait long enough to not fill the FIFO up completely, but not too long that the FIFO empties out completely. After a ton of trial and error compiling directly on the IIci to get the delays right, I finally found a decent combination and I was able to play the LC III & later/Performa/most Quadra series startup chime from a Mac program by writing directly to the chip. Unfortunately it would sometimes work and sometimes not -- sometimes the FIFO would end up draining, and I'd hear little crackles in the sound and stuff like that. I figured it was because of interrupts, but I wanted to get it working with the FIFO status bits rather than a cheesy time delay. The FIFO status bits are a more reliable way to tell when it's time to write more data to the chip--it'll signal when the FIFO is half empty, so you can fill it up again. Luckily the MAME/MESS project has some info on those bits.

At this point I was sick of waiting 2 minutes after every code change for the IIci to re-compile my app, so I set up my iMac G4 to do the compiling. The IIci could load the compiled program over AppleTalk quickly. Luckily my IIci has an Ethernet card :) This made it WAY simpler to experiment with the FIFO status bits. I got something that would sometimes work, and sometimes would hang waiting for the FIFO half-empty bit to come on (it never would). Like I said earlier, I am pretty sure this is because an interrupt is stealing the status bit from me sometimes. To test that theory, I disabled interrupts during my program, and BOOM! It worked! A perfect playback! I even took the sampled startup chime and repeated it 9 times to get a longer sound file. It played completely perfectly every time.

I am 99% sure that there is enough unused space in the IIci ROM to hold the sampled LC III startup chime! I'll see if I can make it work as a startup sound soon!

P.S. I remember Darkwing Duck! I was more into Ninja Turtles and the Nickelodeon shows like Doug and Rugrats though :)

 

olePigeon

Well-known member
Whoa! Are you saying you could implement a sampled startup sound into a IIci?

You're cool as sh*t, mister. :cool:

 

techknight

Well-known member
yup, i remember all those shows too now.

As far as playing sampled sounds, thats crazy. At least your able to control the sound chip.

Instead of disabling the interrupts, why dont you put a jump vector/hook in the VB interrupt? that way at least the computer responds while its running.

 

Dennis Nedry

Well-known member
The IIci can ordinarily play sampled sounds. dougg3 is cleverly making a direct hardware-level sampled sound player which can be injected into the IIci's ROM. The IIci doesn't probably have much interrupt activity yet when the startup sound plays, so it probably won't be an issue.

You are doing some very interesting stuff, dougg3. If you had a dedicated task that you wanted a IIci to do very efficiently, you could theoretically figure out the hardware and have a really zippy 100% ROM-based Mac with no operating system.

 

dougg3

Well-known member
Thanks guys! Yes olePigeon that's exactly what I'm saying :) techknight, I agree that I shouldn't disable interrupts if I were making an app other people will use...but if I were making an app I'd just use the sound manager instead. The reason I disabled interrupts was to prevent the normal Mac sound driver's interrupt from stealing the status bits from me, just so I could deduce how the chip works.

You're right Dennis Nedry--it would be possible to do some crazy stuff efficiently by directly writing to the chips...

Anyway, I refined the algorithm tonight. Now it's basically:

- Write into the FIFO until it's full

- Wait until the FIFO is half empty

- Lather, rinse, repeat until I'm out of samples

That seems to be how the original ASC was designed to be used, because that is the algorithm the status bits enable me to implement. I'm in the process of sticking it into the ROM and I should have a demo video ready tonight if all goes as planned!

It's shocking how few assembly instructions it takes. Makes me wonder why they didn't do it in the IIci :)

Edit: Arghhh! I put my new sound generator into the IIci ROM, and...nothing happened except the speaker clicked. The computer continued to boot just fine though, so I can't be too far off from making it work...I must be missing one of the initialization parameters that the system takes care of.

 

dougg3

Well-known member
BRAIN FART ALERT! BRAIN FART ALERT!

I accidentally had the line that loads the number of samples commented out. This was probably causing it to play a zero-length sound, or at least a REALLY short sound.

It's all because I'm using GNU binutils as my assembler, and it uses a different comment style than every other assembler (it uses /* C-style comments */ instead of a semicolon before the comment, along with a bunch of other wacky ideas like prefixing register names with a % sign). In my hurry to get the sound playing, I forgot to add an ending */ on one of my lines after changing the comment style over, and it commented out the entire next line, which happened to be the line that loads the number of sound samples. I thought I was going crazy!! I think that's the first time ever that too much code commenting has bitten me in the butt.

The ROM image correctly plays the sampled sound when I try it in MESS now, but I'm way too tired to take the IIci apart tonight. There's still a chance that MESS works and the actual hardware doesn't, but I bet it will work. Tomorrow (ummm, I mean later today) will be the day it happens!

 

kite210

Well-known member
Can't wait to see what happens, this is pretty much the holy grail of hacks to me. I've always wanted to change the start up sound.

 

dougg3

Well-known member
Wait no longer :)

It works!!! My code would have worked fine the first time if I hadn't accidentally commented that line out.


And for anyone without YouTube, you can at least hear it in action:

http://homepage.mac.com/macg3/SampledIIciStartupChime.mp3

The only limit holding me back from longer sounds is ROM space. That sound uses up about 31k of the 35k available, so to do anything much longer than that, we're going to have to look toward ROM expansion, which I believe Dennis Nedry did (right?). I suppose the other option would be to downsample a sound to 11 KHz to allow double the length, but then the sound quality starts to suffer.

 

Dennis Nedry

Well-known member
I was never able to test the expanded ROM space, but I did provide the extra address lines to my larger ROM chips. I don't see any reason why it wouldn't work. If you have bigger ROM chips, I can tell you how to hook up these extra 2 address lines. We're basically limited to 2 extra address lines (4x storage space) because of the pins available on these sorts of ROMs. To go higher, we would have to make a special ROM SIMM instead of using the original locations on the logic board. Many additional address lines are available in the ROM SIMM slot.

 

Dennis Nedry

Well-known member
The ROM SIMM Slot pinout for the IIci is here:

http://68kmla.org/wiki/Macintosh_IIci_RAM_and_ROM_Pathways

You can use a continuity tester to see how the address lines on the ROM chips are connected to the ROM SIMM slot. Then just use your ROM chip pinout to hook up the next two! I traced around the board and found more convenient spots to tap into these two address lines, but there's no reason why you couldn't solder wires directly from behind the SIMM slot to the extra address pins on your ROMs.

 
Top