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
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.
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.