CPCWiki forum

General Category => Programming => Topic started by: Fabrizio on 20:01, 11 October 17

Title: Struggling to get any sound with Assembly in Z88DK
Post by: Fabrizio on 20:01, 11 October 17
Hi everyone,


has any of you tried to produce any sound (even a single beep) with Z88DK?

I have tried both writing onto PSG registers or using sound queues but either no sound or cracling sounds are produced.


I do not understand if some paging is hiding the routines... and what I should do to get some sounds.


For example the following code produces no sound if embedded in a C function (I have successfully embedded Assembly code in C to do graphics).



#asm
   ld bc,$3807
   call writepsg_ping
   ld bc,$0001
   call writepsg_ping 
   ld bc,$c000
   call writepsg_ping 
   ld bc,$0f08
   call writepsg_ping 
   ret

   writepsg_ping:
      ld   a,b
      di 
      ld    b, $f4
      out   (c), a
      ld    b, $f6
      in    a, (c)
      or    $c0
      out   (c), a
      and   $3f
      out   (c), a
      ld    b, $f4
      out   (c), c
      ld    b,$f6
      ld    c, a
      or    $80
      out   (c), a
      out   (c), c
      ei 
      ret
      
#endasm   
Title: Re: Struggling to get any sound with Assembly in Z88DK
Post by: Targhan on 09:43, 12 October 17
The value sent to register 7 should be &3e (only the channel 1 is open), but your value should work anyway. I didn't check the PSG code though. There shouldn't be any need for the DI/EI, as unless asked to, the system doesn't change the PSG values. I suggest debugging this with Winape (open the Register window to make sure the values are well sent). Maybe your framework is automatically stopping the sound when your code ends?


As a very raw test, put a DI : JR $ at the end of your code. Infinite loop indeed, but at least it will prove that your code works without being hindered by anything else.
Title: Re: Struggling to get any sound with Assembly in Z88DK
Post by: andycadley on 21:01, 12 October 17

You've got an endian issue, so you're mixing up the register number and the value to output. Try something like this;


ld bc,&07f8
call writepsg_ping
ld bc,&0108
call writepsg_ping
ld bc,&00c0
call writepsg_ping
ld bc,&080f
call writepsg_ping
loop: jp loop


which (along with your writepsg_ping) gets me a noise in WinAPE.
Powered by SMFPacks Menu Editor Mod