Author Topic: [CPCtelera] Help needed for converted Arkos Player 2  (Read 303 times)

0 Members and 1 Guest are viewing this topic.

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 348
  • Country: fr
  • Liked: 249
Hello,
i'm a trying to use Arkos Player 2 with CPCtelera / SDCC, i have managed to convert the assembly code (according to the work already done for Arkos Player 1) and make an example project.

I heard some noise but not the original music, i had to make some mistakes while converting but i have not idea what is wrong.

The music "AHarmlessGrenade" was exported in binary at 0x4000 and converted into array __at(0x4000).

Code: [Select]
#include <cpctelera.h>
#include "Music_AHarmlessGrenade.h"

extern void PLY_AKG_Init(void* songdata, u8 subSong) __z88dk_callee;
extern void PLY_AKG_Play();

void main(void) {
    cpct_disableFirmware();
    PLY_AKG_Init(G_Music_AHarmlessGrenade, 0);

    while (1)
    {
        cpct_waitVSYNC();
        PLY_AKG_Play();
    }
}

In the zip i have also included by convenient the original source code (PlayerAkg.asm_org and PlayerAkg_SoundEffects.asm_org)

Thanks,
Arnaud
« Last Edit: 16:29, 15 April 18 by Arnaud »

Offline freemac

  • CPC6128
  • ****
  • Posts: 218
  • Country: 00
  • Liked: 182
Re: [CPCtelera] Help needed for converted Arkos Player 2
« Reply #1 on: 16:36, 15 April 18 »
Relative jump
Code: [Select]
jr nc,. + 3does refer jump you disabled (in comments) :
Code: [Select]
;jp _PLY_AKG_Play          ;PLY_AKG_Start + 3.so it doesn't jump jump ?
« Last Edit: 16:47, 15 April 18 by freemac »

Offline freemac

  • CPC6128
  • ****
  • Posts: 218
  • Country: 00
  • Liked: 182
Re: [CPCtelera] Help needed for converted Arkos Player 2
« Reply #2 on: 16:44, 15 April 18 »
On https://github.com/renaudhelias/RubikCubePaletteCPC/blob/master/JDVPA%233_test/combat2.c

I compiled SKS with WinAPE and load it directly :
LoadFile("sks2000.bin", (char *)0x2000);
LoadFile("sudo3000.bin", (char *)0x3000);

and I implemented cpct_akp_musicInit() and cpct_akp_musicPlay() using a set of instruction for protecting "backup/restore Z80 state" inspired from http://norecess.cpcscene.net/using-interrupts.html

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 348
  • Country: fr
  • Liked: 249
Re: [CPCtelera] Help needed for converted Arkos Player 2
« Reply #3 on: 17:01, 15 April 18 »
Relative jump
Code: [Select]
jr nc,. + 3does refer jump you disabled (in comments) :
Code: [Select]
;jp _PLY_AKG_Play          ;PLY_AKG_Start + 3.so it doesn't jump jump ?

I comment this line because this commentary (i set back this line but it doesn't work either):
Code: [Select]
        ;Hooks for external calls. Can be removed if not needed.
and i call directly in C the functions  : PLY_AKG_Init and PLY_AKG_Play

On https://github.com/renaudhelias/RubikCubePaletteCPC/blob/master/JDVPA%233_test/combat2.c

I compiled SKS with WinAPE and load it directly :
LoadFile("sks2000.bin", (char *)0x2000);
LoadFile("sudo3000.bin", (char *)0x3000);

and I implemented cpct_akp_musicInit() and cpct_akp_musicPlay() using a set of instruction for protecting "backup/restore Z80 state" inspired from http://norecess.cpcscene.net/using-interrupts.html

If i can't make my code working i'll try this solution. Thanks.




Offline ronaldo

  • Dev
  • 6128 Plus
  • *****
  • Posts: 553
  • Country: es
    • Fremos Blog
  • Liked: 731
Re: [CPCtelera] Help needed for converted Arkos Player 2
« Reply #4 on: 23:37, 15 April 18 »
I heard some noise but not the original music, i had to make some mistakes while converting but i have not idea what is wrong.

Your problem is in the way you retrieve parameters. This is your code:

Code: [Select]
;Initializes the player.
;IN:    HL = music address.
;       A = subsong index (>=0).
_PLY_AKG_Init::
        ;; Get Parameters from the Stack
        pop  bc          ;; BC = Return address
        pop  hl          ;; HL = Music address
        pop  af          ;; A  = Subsong index (>=0)
        push bc          ;; [4] BC = Returning back address in the stack because function uses __z88dk_callee convention

The problem here is that PUSH AF gets the first 8-bit value from the stack in F and the second in A, because Z80 is little endian. Therefore, the value you want (subsong index) ends up in F and not in A. You may easily fix it doing this:

Code: [Select]
   pop  af          ;; AF = Return address
   pop  hl          ;; HL = Music address
   pop  bc          ;; C  = Subsong index (>=0)  (B = Rubbish)
   push af          ;; Save back return address in the stack to fullfill __z88dk_callee convention
   ld   a, c          ;; A = Subsong index

I've tested it and song plays. Don't know if more tweaks are requiered or not, but it plays.

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 348
  • Country: fr
  • Liked: 249
Re: [CPCtelera] Help needed for converted Arkos Player 2
« Reply #5 on: 13:15, 16 April 18 »
Your problem is in the way you retrieve parameters.
I add only three lines of my own and it's the problem  ::)

I've tested it and song plays. Don't know if more tweaks are requiered or not, but it plays.
Yes the music play, but only the first pattern.

Thanks for help @ronaldo.


Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 572
  • Country: fr
  • Liked: 501
Re: [CPCtelera] Help needed for converted Arkos Player 2
« Reply #6 on: 15:50, 16 April 18 »
I know nothing about CPCTelera, but just to be sure, does your music play fine when using the "normal" player and test code provided with AT2?

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 348
  • Country: fr
  • Liked: 249
Re: [CPCtelera] Help needed for converted Arkos Player 2
« Reply #7 on: 20:33, 16 April 18 »
I know nothing about CPCTelera, but just to be sure, does your music play fine when using the "normal" player and test code provided with AT2?

Just compiled and tested with RASM all is OK.

There's something wrong in my code.

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 572
  • Country: fr
  • Liked: 501
Re: [CPCtelera] Help needed for converted Arkos Player 2
« Reply #8 on: 00:09, 17 April 18 »
Quote
There's something wrong in my code.


That's what I wanted to hear :). When calling the init, make sure A is 0 (the first subsong). HL should point on your song, there's no trick there.

Offline Arnaud

  • Supporter
  • 464 Plus
  • *
  • Posts: 348
  • Country: fr
  • Liked: 249
Re: [CPCtelera] Help needed for converted Arkos Player 2
« Reply #9 on: 13:34, 17 April 18 »

That's what I wanted to hear :) . When calling the init, make sure A is 0 (the first subsong). HL should point on your song, there's no trick there.

The problem is not in my own code (@ronaldo correct it) but in my convertion to ASZ80 assembly.

@reidrac have already convert to ASZ80 the  lightweight player, maybe he can have idea of the problem ?  :D