Author Topic: Struggling to get any sound with Assembly in Z88DK  (Read 145 times)

0 Members and 1 Guest are viewing this topic.

Offline Fabrizio

  • CPC464
  • **
  • Posts: 19
  • Country: fr
  • Liked: 3
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   

Online Targhan

  • Supporter
  • 464 Plus
  • *
  • Posts: 425
  • Country: fr
  • Liked: 335
Re: Struggling to get any sound with Assembly in Z88DK
« Reply #1 on: 11: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.

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 726
  • Liked: 289
Re: Struggling to get any sound with Assembly in Z88DK
« Reply #2 on: 23: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.