Short beeper routines in assembly

The place for codemasters or beginners to talk about programming any language for the Spectrum.
jetsetdanny
Dizzy
Posts: 85
Joined: Thu May 02, 2019 10:22 pm
Contact:

Re: Short beeper routines in assembly

Post by jetsetdanny »

utz wrote: Thu Nov 16, 2017 11:05 pm
Morkin wrote: Wed Nov 15, 2017 10:40 pm I liked the way you can just keep mucking about with the registers (DE, HL, BC), and the INCs and DECs to get very different effects.
Yeah, that's actually one of the things that I really like about the beeper. You can just throw almost random code at it and it will often do something interesting.

Anyway, here's a simple laser effect in 13 bytes. By initializing D with different values, you can control the length. 0x28 is approximately one full zap.

Code: Select all

	di
	ld d,#28		;length/iterations
loop
	add hl,de
	dec de
	ld a,h
	out (#fe),a
	ld a,e
	or d
	jr nz,loop
	
	ei
	ret

Hello,

I have used the "simple laser effect in 13 bytes" in a project related to a Jet Set Willy remake (to be released in early March if all goes well).

I want to give due credit in the Readme.

At the moment I can credit it as created by "utz". Utz, would you like to be credited in any other way? (like by your real name, for example). Please let me know :).
Website: JSW Central
User avatar
utz
Microbot
Posts: 116
Joined: Wed Nov 15, 2017 9:04 am
Contact:

Re: Short beeper routines in assembly

Post by utz »

Very kind of you wanting to credit me for this ;) Just "utz" is fine, or if you like you could throw in a link to my website, https://irrlichtproject.de.
jetsetdanny
Dizzy
Posts: 85
Joined: Thu May 02, 2019 10:22 pm
Contact:

Re: Short beeper routines in assembly

Post by jetsetdanny »

Thank you :). I will do as you suggest. When the game is released a month from now (if all goes well), apart from an announcement in the proper place on this forum I will also post a message here to give you the link so that you can see your code in action.
Website: JSW Central
jetsetdanny
Dizzy
Posts: 85
Joined: Thu May 02, 2019 10:22 pm
Contact:

Re: Short beeper routines in assembly

Post by jetsetdanny »

And so here it is, the game in which utz's "laser effect" routine has been used: "Madam Blavskja's Carnival Macabre 48K", a (slightly enhanced) port of Fabián Álvarez López (Adban de Corcy's) classic 128K Jet Set Willy game to 48K.

Utz is duly credited in Section II "Acknowledgements and thanks" of the Readme included in the ZIP file with said game. The laser effect, which is used in the game twice (in different ways), is then dissassembled (with a link to this thread) in Subsection 3 ("Playing the original game or with extra rooms") of Section X "Technical notes" of the Readme, and again in Subsection 6 ("Custom-made title screen") of Section X of the Readme. It is also mentioned in Subsection 19 ("Memory layout") of Section X, where it is indicated where the code which operates it resides in memory.

The ZIP with the game file (if you want to see the laser effect in action, besides discovering various other facets of this atmospheric JSW game, or if you want to have a look at its references in the Readme) can be downloaded freely e.g. from here.
Website: JSW Central
User avatar
R-Tape
Site Admin
Posts: 6409
Joined: Thu Nov 09, 2017 11:46 am

Re: Short beeper routines in assembly

Post by R-Tape »

Can anyone help with a short bit of asm code that sounds vaguely like the whistling sound of something falling?

It needs to be less than a frame, and perhaps can be CALLed with a different value so that the whistle can change in tone (or should that be pitch?) as the ground approaches.
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

Re: Short beeper routines in assembly

Post by Joefish »

Incidentally, for opening the treasure chests in Waterbelle End I wrote a sound routine that takes a delay, then reads a byte from ROM, does an AND 16, and uses that in an XOR to swap the speaker bit. So it's kind of a random element as to whether the speaker bit flips on every cycle of the beeper function. Vary the length of the delay loop, and it sounds very much like the ch-Ch-CH sound from Transformers, so I guess that's how that was done.

Whereas in Buzzsaw+ I randomly toggled bits of a steady high/low pattern; this gave a combination of noise and whining tone which sounds more like noisy machinery.

But the former is a more pleasant sound and probably better suited to simulating more natural noise effects. Unfortunately the one thing the beeper doesn't have is any sort of volume control. I know you can simulate it with very high speed pulsing but that can add a high pitch overtone if you're not fast enough so I haven't got the hang of that yet.

What I could do with for Waterbelle End is a more convincing 'fart' effect. You'd think that'd be an easy one for the Speccy, given its reputation!
Post Reply