Author Topic: Arkos2 Questions  (Read 253 times)

0 Members and 1 Guest are viewing this topic.

Offline teopl

  • CPC664
  • ***
  • Posts: 78
  • Country: cs
  • Liked: 36
  • Likes Given: 55
Arkos2 Questions
« on: 00:22, 15 October 19 »
Hello,

I have some Arkos2 questions so better to open a new thread.

For now, only 2 :)

1) Is there some easy way to detect sound effect (instrument) length in ms?

2) What am I missing when I don't hear the sounds effect volume change? I use the following function and Lightweight player and all is good (music and correct sfx are played) but looks like volume is not influencing the sound.

Code: [Select]
// REMARK: channel and volume are merged to one 2-byte variable
// ---
// channel  = channel (0 - 2)
// volume   = inverted volume (0 - 16)
// sfx      = sound effect number (>= 1)
static void _sfx_play(u16 channel_and_volume, u16 sfx) __z88dk_callee __naked {

    // get params from stack
    __asm__("pop iy");  // ret address first because __z88dk_callee convention
    __asm__("pop bc");
    __asm__("pop hl");
    __asm__("push iy"); // ret address last  because __z88dk_callee convention
    __asm__("ld a, l"); // ; Sound effect number(>= 1)
    __asm__("call _PLY_LW_PLAYSOUNDEFFECT");
    __asm__("ret");
}

The sfx player code: (sfx volume should be in BC)

Code: [Select]
;Plays a sound effect. If a previous one was already playing on the same channel, it is replaced.
;This does not actually plays the sound effect, but programs its playing.
;The music player, when called, will call the PLY_LW_PlaySoundEffectsStream method below.
;IN:    A = Sound effect number (>0!).
;       C = The channel where to play the sound effect (0, 1, 2).
;       B = Inverted volume (0 = full volume, 16 = no sound). Hardware sounds are also lowered.
PLY_LW_PlaySoundEffectDisarkGenerateExternalLabel:
PLY_LW_PlaySoundEffect:
        ;Gets the address to the sound effect.
        dec a                   ;The 0th is not encoded.

Edit: (added question 3)

3) Is there a smart way to mute song and play sfx at the same time (except the one I am using now - playing the empty song) ?
« Last Edit: 00:23, 15 October 19 by teopl »

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 960
  • Country: fr
  • Liked: 920
  • Likes Given: 141
Re: Arkos2 Questions
« Reply #1 on: 01:30, 15 October 19 »
Quick reply!

1) detect a sound effect length in ms???
I don't understand WHY you'd do that. Is it before you play the sound? You can get the sfx duration by multiplying its speed (+1) with how many lines the sound is composed of. If you play the sfx at 50hz, you can deduce the duration quite easily.

2) Warning, the volume is in B, not BC! And it is managed correctly. Remember, 0 is full volume, 16 is no sound at all.

3) Using an empty song is indeed a solution, especially if you have already the player and you use music from time to time. If you DON'T have music, you can use the standalone SFX player, also in the package. Of course you use both players, but it would be a waste of memory.
Targhan/Arkos

Arkos Tracker 2 - alpha 7 now released! - Follow the news on Twitter!
Disark A cross-platform Z80 disassembler/source converter

Imperial Mahjong
Orion Prime

Offline teopl

  • CPC664
  • ***
  • Posts: 78
  • Country: cs
  • Liked: 36
  • Likes Given: 55
Re: Arkos2 Questions
« Reply #2 on: 00:17, 16 October 19 »
Thanks!

1) Yes this is before I play sound to detect if a sfx is done before playing a new one, that method with multiplying lines with speed is just fine

2) I have very limited asm knowledge, I thought that pop-ing to BC will put one byte to B and another to C (I have 2 byte argument in function)... So that should be channel and volume. I may not tested this correctly also...

3) Ok, empty song it is then :)

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 960
  • Country: fr
  • Liked: 920
  • Likes Given: 141
Re: Arkos2 Questions
« Reply #3 on: 00:35, 16 October 19 »
2) Yes indeed, POP BC changes both B & C. But I don't know what you put in these registers, so debug what you put in here (but I guess you did already...). Tell me if you manage to solve this (or not).
Targhan/Arkos

Arkos Tracker 2 - alpha 7 now released! - Follow the news on Twitter!
Disark A cross-platform Z80 disassembler/source converter

Imperial Mahjong
Orion Prime

Offline teopl

  • CPC664
  • ***
  • Posts: 78
  • Country: cs
  • Liked: 36
  • Likes Given: 55
Re: Arkos2 Questions
« Reply #4 on: 22:11, 16 October 19 »
2) what a strange thing, I made a mistake!  :laugh: sorry for my ignorance, I just can't help myself sometimes :picard:
for (really) unknown reasons I didn't even bother to check if I combined the volume and channel like they should be guessing that something else must be the problem...

anyway, I did my first debug asm code so that's good...

thanks again, but most of all thanks for Arkos and the future it brings... (and let's hope for even less bytes the songs take!)