News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Struggling to get any sound with Assembly in Z88DK

Started by Fabrizio, 20:01, 11 October 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Fabrizio

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   

Targhan

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.
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

andycadley


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