BASIC sound effects

Todo sobre la creación, diseño y programación de nuevo software para
nuestro Spectrum

Moderador: Sir Cilve Sinclair

Responder
Avatar de Usuario
cheveron
Manic Miner
Mensajes: 280
Registrado: Lun Jun 28, 2010 6:14 pm
Ubicación: Londres
Contactar:

BASIC sound effects

Mensaje por cheveron » Dom Mar 03, 2013 11:24 am

¡Hola!

I was trying to come up with a way of doing interrupt driven beeper sound effects using a fixed number of t-states. I failed, but I did come up with a short routine which could be useful for adding sound effects to BASIC programs.

Código: Seleccionar todo

; simpleFX by Andrew Owen
; totally relocatable without recompiling

   ld     hl, 300      ; duration (0-14445)
   ld     a, (23624)   ; border colour
   and    %00111000    ; mask
   rrca                ; rotate
   rrca                ; right
   rrca                ; three
   ld     c, a         ; store it in C

loop:
   ld     a, (hl)      ; get byte from ROM
   and    %00010000    ; throw everything away except the MIC bit
   or     c            ; add the border colour
   out    (0xfe), a    ; write it
 
   ld     b, l         ; b, 0-255 for pitch or l/h for envelope

inner:
   djnz   inner        ; timing loop

   dec    hl           ; decrease pointer to ROM
   ld     a, h         ; test
   or     l            ; for zero
   ret    z            ; return if done
   jr     loop         ; else loop

And here's a BASIC version with the code stored just below the UDGs:

Código: Seleccionar todo

 10 CLEAR 65340
 20 RESTORE 100
 30 FOR m=65341 TO 65367
 40 READ d
 50 POKE m,d
 60 NEXT m
 70 RANDOMIZE USR 65341
 80 STOP
100 DATA 33,44,1,58,72,92,230
110 DATA 56,15,15,15,79,126,230
120 DATA 16,177,211,254,69,16
130 DATA 254,43,124,181,200,24
140 DATA 241
«Dime con quién andas, y te diré quién eres» — Cervantes

Avatar de Usuario
mcleod_ideafix
Johnny Jones
Mensajes: 3985
Registrado: Vie Sep 21, 2007 1:26 am
Ubicación: Jerez de la Frontera
Contactar:

Re: BASIC sound effects

Mensaje por mcleod_ideafix » Mar Mar 05, 2013 3:21 am

Y para los perezosos como para teclear un listado... (and for the lazy enough to type-in a BASIC listing...) TAP version
Web: ZX Projects | Twitter: @zxprojects

Avatar de Usuario
jevilon
Manic Miner
Mensajes: 288
Registrado: Mié Jul 23, 2008 1:15 pm
Ubicación: La Rioja

Re: BASIC sound effects

Mensaje por jevilon » Mar Mar 05, 2013 5:59 pm

¿Esto puede utilizarse en ZX basic (poniendolo en un bloque ASM)?

Avatar de Usuario
na_th_an
Nonamed
Mensajes: 1889
Registrado: Lun May 07, 2007 10:16 am
Ubicación: Andalucía

Re: BASIC sound effects

Mensaje por na_th_an » Mar Mar 05, 2013 6:03 pm

Sin problema alguno.

Avatar de Usuario
cheveron
Manic Miner
Mensajes: 280
Registrado: Lun Jun 28, 2010 6:14 pm
Ubicación: Londres
Contactar:

Re: BASIC sound effects

Mensaje por cheveron » Mié Mar 06, 2013 12:17 am

jevilon escribió:¿Esto puede utilizarse en ZX basic (poniendolo en un bloque ASM)?


Yes. The BASIC program includes the code and the code can be stored at any location as it only uses relative jumps. If you change the second and third data values you can change the duration of the noise. You can also do this by poking the two memory locations after the location at which the code starts.
«Dime con quién andas, y te diré quién eres» — Cervantes

Avatar de Usuario
jevilon
Manic Miner
Mensajes: 288
Registrado: Mié Jul 23, 2008 1:15 pm
Ubicación: La Rioja

Re: BASIC sound effects

Mensaje por jevilon » Mié Mar 06, 2013 1:09 am

Gracias
Thanks :)

Es un sonido bastante chulo para por ejemplo el sonido de mi varita de fuego jejejeje

Responder

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 42 invitados