The SAM Coupé's inbuit sound effects

On the creation of AY or Beeper music, including the packages used to do so.
Post Reply
User avatar
TMD2003
Rick Dangerous
Posts: 2047
Joined: Fri Apr 10, 2020 9:23 am
Location: Airstrip One
Contact:

The SAM Coupé's inbuit sound effects

Post by TMD2003 »

Not a lot of people know that I know this, but I do. While attempting to write a BASIC program for the SAM Coupé for last year's CSSCGC (which was as much of a roaring success as any Crap Game could be), I made use of as many of its improvements over the Spectrum as I could.

This includes four inbuilt sound effects that can be accessed by the BASIC commands ZAP, POW, ZOOM and BOOM. Whether or not they sound like their commands is purely subjective, but what is harder the argue against is that they sound like they could easily have been made on a Spectrum in 1982 with a working knowledge of how machine code sounds are generated.

The best thing about this is, the Sim Coupe emulator allows the SAM's ROM to be probed in much the same way as a disassembler. Open its debug screen and there is the ROM, expanded out into all its Z80 opcodes, including all the labels that are used in CALLs and the like. Even at my stage of learning Z80, which is "barely green", it shouldn't be too hard a job to extract the sound routines, right? I mean, look, there's the label ZAP at $EF56...

...wrong. It is a tangled, convoluted web of code that CALLs a whole ton of subroutines and there's only one solitary OUT in all the code I've found that looks like it's also checking the border colour to make sure it matches with what's already there... and there's a load of DIs and EIs as well, which are many miles above my level.

Is there anyone who might be able to make sense of it, or is there anyone who could listen to the sounds made by ZAP, POW, ZOOM and BOOM and instinctively know how they'd be recreated in a much simpler way?
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
azesmbog
Manic Miner
Posts: 307
Joined: Sat May 16, 2020 8:43 am

Re: The SAM Coupé's inbuit sound effects

Post by azesmbog »

Is it possible that the sounds emitted by ZAP, POW, ZOOM and BOOM do not sound through the beeper, but through the SAA1099?
User avatar
Stefan
Manic Miner
Posts: 823
Joined: Mon Nov 13, 2017 9:51 pm
Location: Belgium
Contact:

Re: The SAM Coupé's inbuit sound effects

Post by Stefan »

azesmbog wrote: Sat Jul 10, 2021 2:58 pm Is it possible that the sounds emitted by ZAP, POW, ZOOM and BOOM do not sound through the beeper, but through the SAA1099?
No, it's bashing port 254 (see the SAM ROM disassembly) - which may also be an easier reference than running through a disassembler.
User avatar
TMD2003
Rick Dangerous
Posts: 2047
Joined: Fri Apr 10, 2020 9:23 am
Location: Airstrip One
Contact:

Re: The SAM Coupé's inbuit sound effects

Post by TMD2003 »

Argh! This really is a pain.

First of all, here is a ZIP package of the four sound effects I'm trying to simulate, as (very small) WAV files: https://mega.nz/file/dSYRjQKZ#M4oXnvAcD ... iRh0Lss76Q

The rising "zoom" and falling "boom" really can't be difficult for someone who knows what they're doing with CALL 949, which is not me.

I knew of similar machine code sound effects from M.J. Levers' Defender, which I typed in at great length when I was much younger. I had no idea how it worked, only that it made sounds I couldn't make with BEEP (or, by that time, PLAY). So I've disassembled the few bytes of code that make brief rising and falling sound effects:

Falling effect (short duration, a very high-pitched start):

Code: Select all

	ld b,1
mark2:	push bc
	ld hl,15	; "HL"
loop2:	ld de,20 ; "DE1"
	push hl
	call 949
	pop hl
	ld de,16	; "DE2"
	and a
	adc hl,de
	ld a,l
	cp 255
	jr nz,loop2
	pop bc
	djnz mark2
	ret
Rising effect (a lower starting tone and longer duration):

Code: Select all

ld b,1
mark3:	push bc
	ld hl,768	; "HL"
loop3:	ld de,1	; "DE1"
	push hl
	call 949
	pop hl
	ld de,16	; "DE2"
	and a
	sbc hl,de
	jr nz,loop3
	pop bc
	djnz mark3
	ret
I've written a BASIC program to vary the values of HL, DE1 and DE2 for both effects, so that I can change the starting tone, duration and... whatever it is that DE2 does, but every time I vary HL or DE2 in either case, the effect goes haywire.

The program is included in the Mega package as an .SZX snapshot.

The routines to increase or decrease all the values seem to work... but am I doing something wrong, or is there a fundamental flaw with this plan?

Or is it just going to be a case of blindly flailing around in the dark until I just happen to get some values of HL, DE1 and DE2 that just happen to work the way I'm looking for?
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
Post Reply