Author Topic: cpctelera arkos 2 conversion problem  (Read 1632 times)

0 Members and 1 Guest are viewing this topic.

Offline teopl

  • CPC664
  • ***
  • Posts: 110
  • Country: cs
  • Liked: 45
  • Likes Given: 93
cpctelera arkos 2 conversion problem
« on: 21:32, 02 February 19 »
Hi everyone!

I have a problem trying to play Arkos2 song using cpctelera 1.4 - the sound just doesn't play.

I have attached zip with code and everything showing 2 versions which differ only in generated music (.h and .s) but the version with music generated from Arkos2 doesn't play.

More detailed info:

Version OK:
---
- used Arkos1 song "molusk.aks"
- converted with script like this: "cpct_aks2c -m 0x40 -o all_music -od src -id song00 assets/molusk.aks"
- script used Arkos1 conversion binary with only "-a" option to set address

Version NOT OK:
---
- used Arkos2 song "excellence.aks"
-  converted with script like this: "cpct_aks2c.arkos2.sh -m 0x40 -o all_music -od src -id song00 assets/excellence.aks"
- script used Arkos2 conversion binary with options "-adr" for address and "-bin" to export binary

PS

I have read similar topic here "www.cpcwiki.eu/forum/programming/(cpctelera)-help-needed-for-converted-arkos-player-2/" but I just don't understand the issue, so any help would be great...

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 598
  • Country: fr
  • Liked: 478
  • Likes Given: 1036
Re: cpctelera arkos 2 conversion problem
« Reply #1 on: 11:27, 03 February 19 »
Hello,
first of all, Arkos2 is not compatible with Arkos1 and CPCTelera provides only Arkos1 support.
You cannot use either the converter and the player of CPCTelera to play Arkos2 songs and Fx.

For information Arkos2 provides the players in Arkos Tracker 2\players

Here a working version of your code for Arkos2, i used another song (HarmelessGrenard).
The zip contains the player LightWeight (in arkos2PLayer/) compatible with SDCC/CPCTelera.

To export another song go to "File -> Export -> Export as LightWeight (AKL)" and export as "Source File" you can uncheck "Generate configuration file"
Save your file with .s extension, and you'll have to make some simple modifications in the file (see song/grenade.s as example)

Have fun with Arkos2  :)
Arnaud

« Last Edit: 11:47, 03 February 19 by Arnaud »

Offline teopl

  • CPC664
  • ***
  • Posts: 110
  • Country: cs
  • Liked: 45
  • Likes Given: 93
Re: cpctelera arkos 2 conversion problem
« Reply #2 on: 13:28, 03 February 19 »
Thank you Arnaud, all worked well - your code and also I managed to export and use my song.

I have put the song on 0x40 (I am not sure what is first safe place to put it - any idea?) and these are the code changes I made on the exported song:


Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 598
  • Country: fr
  • Liked: 478
  • Likes Given: 1036
Re: cpctelera arkos 2 conversion problem
« Reply #3 on: 13:36, 03 February 19 »
When exporting song in src assembly, there is no need to specify the memory address, the C compiler will locate the song data for us.

This new feature of Arkos2 is really useful !

Offline teopl

  • CPC664
  • ***
  • Posts: 110
  • Country: cs
  • Liked: 45
  • Likes Given: 93
Re: cpctelera arkos 2 conversion problem
« Reply #4 on: 14:14, 03 February 19 »
But where is the song then located in memory?

(Sorry if I missed something - I don't quite understand the memory layout and how everything works)

My logic to move the song to 0x40 was:

Since the stack grows from 0xC000 downwards, I wanted to pack memory like this:

0x0040 - 0x ? ? ? ? : song
0x ? ? ? ? - 0x$$$$ : code/gfx (this is done by setting Z80CODELOC variable in cpctelera build_config.mk)

So the stack can have largest space possible (0x$$$$ - 0xC000) and also leave the possibility to move the stack to maybe use double buffering for graphics later...


Offline teopl

  • CPC664
  • ***
  • Posts: 110
  • Country: cs
  • Liked: 45
  • Likes Given: 93
Re: cpctelera arkos 2 conversion problem
« Reply #5 on: 16:53, 03 February 19 »
Btw, here is short script which makes the conversion compatible with my cpctelera code: (so this can be done automatically in the build process)

You just need Arkos2 conversion binary "SongToLightweight.exe".

Code: [Select]
SONG_NAME="Arkos2Song"
SONG_INPUT="assets/${SONG_NAME}.aks"
SONG_OUTPUT="src/song_${SONG_NAME}.s"
SONG_ADR="0x40"
./tools/arkos2/SongToLightweight.exe -adr ${SONG_ADR} --labelPrefix "${SONG_NAME}_" -spadr ".org" -spbyte ".db" -spword ".dw"  -sppostlbl ":" ${SONG_INPUT} ${SONG_OUTPUT} >/dev/null 2>&1
perl -i -p -e "s/^.*\.org.*\n/\t\.area __${SONG_NAME}_SongStart \(ABS\)\n\t\.org ${SONG_ADR}\n/g" ${SONG_OUTPUT}
perl -i -p -e "s/db \"ATLW\"/\.ascii \"ATLW\"/g" ${SONG_OUTPUT}
perl -i -p -e "s/${SONG_NAME}_SongStart:/_${SONG_NAME}_SongStart::/g" ${SONG_OUTPUT}
« Last Edit: 16:55, 03 February 19 by teopl »

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 598
  • Country: fr
  • Liked: 478
  • Likes Given: 1036
Re: cpctelera arkos 2 conversion problem
« Reply #6 on: 20:11, 03 February 19 »
But where is the song then located in memory?

The song will added in memory with your game code and other data from 0x40, you don't have to bother where it is located.
If your game or your song is too large it will possibly overwrite the stack location, but you'll see the size of your program at the end of the build process in the Highest address information.

To sum up :
0x0040 - 0x ? ? ? ? : Song / Code / Gfx (Z80CODELOC = 0x40)
0x$$$$ - 0xC000 : Stack Default location (can be changed with cpct_setStackLocation)


Offline teopl

  • CPC664
  • ***
  • Posts: 110
  • Country: cs
  • Liked: 45
  • Likes Given: 93
Re: cpctelera arkos 2 conversion problem
« Reply #7 on: 21:43, 03 February 19 »
Well that is great, I tested this and it works, thank you again!

If someone needs this:

0) Download Arnaud's attached source (The player code is a little different then the one provided in Arkos2 player folder)

1) Z80CODELOC := 0x0040

2) Convert Arkos2 song to cpctelera compatible source:

Code: [Select]
SONG_NAME="Arkos2Song"
SONG_INPUT="assets/${SONG_NAME}.aks"
SONG_OUTPUT="src/song_${SONG_NAME}.s"
./tools/arkos2/SongToLightweight.exe --labelPrefix "${SONG_NAME}_" -spadr ".org" -spbyte ".db" -spword ".dw"  -sppostlbl ":" ${SONG_INPUT} ${SONG_OUTPUT} >/dev/null 2>&1
perl -i -p -e "s/db \"ATLW\"/\.ascii \"ATLW\"/g" ${SONG_OUTPUT}
perl -i -p -e "s/${SONG_NAME}_SongStart:/_${SONG_NAME}_SongStart::/g" ${SONG_OUTPUT}

Offline teopl

  • CPC664
  • ***
  • Posts: 110
  • Country: cs
  • Liked: 45
  • Likes Given: 93
Re: cpctelera arkos 2 conversion problem
« Reply #8 on: 01:07, 21 July 19 »
Since this is better topic to talk about arkos2 and cpctelera then this http://www.cpcwiki.eu/forum/programming/cpctelera-sdcc-order-of-variables-in-struct/

I will attach here example cpctelera+arkos2 project made based on this tutorial: http://www.julien-nevo.com/arkostracker/index.php/exporting-and-using-a-music/

So if you need arkos2 with cpctelera you can start from this:

Code: [Select]
- download attached zip
- run:
./make_all_with_colors.sh
./run.sh

The player is AKG, taken from Arkos2 bundle, but I suggest to use Lightweight player since it occupies less memory.

@Targhan I think I found issue when using Disark on PlayerLightweight.asm :

The generated sdcc assembler file has a line which will not compile:

Code: [Select]
PLY_LW_ME_PITCHUPDOWN_NEGATIVESPEED: res 7,d
    or a
    sbc hl,de
    sbc a,0

instead of:

Code: [Select]
PLY_LW_ME_PITCHUPDOWN_NEGATIVESPEED: res 7,d
    or a
    sbc hl,de
    sbc a,#0

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.119
  • Country: fr
  • Liked: 1051
  • Likes Given: 152
Re: cpctelera arkos 2 conversion problem
« Reply #9 on: 21:00, 21 July 19 »
You are corrrect!! I don't understand how I could miss that, since I tested it, but it is corrected in the next version which should be released next week. Thanks for reporting!
Targhan/Arkos

Arkos Tracker 2 - alpha 9 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

Offline teopl

  • CPC664
  • ***
  • Posts: 110
  • Country: cs
  • Liked: 45
  • Likes Given: 93
Re: cpctelera arkos 2 conversion problem
« Reply #10 on: 23:13, 21 July 19 »
Great to hear that there is new version on the way! :)

I must admit that I am still having issues when using arkos2 player in my game (the attached example worked ok but in game it has "random" crashes), so I think I will revert to arkos1 until better times (like when it's integrated in cpctelera or when I have time to investigate further).

I guess the issue is on my side but anyway... no time to bother with that but I will leave the arkos2 code inside so it can be switched later.

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.119
  • Country: fr
  • Liked: 1051
  • Likes Given: 152
Re: cpctelera arkos 2 conversion problem
« Reply #11 on: 23:42, 21 July 19 »
The AT2 player is proven, test united, and used in many projects so I'm pretty sure I'm not to blame :). What you can do is try to import it as a binary blob first, see if there random crash still happen. Remember that SP and ALL the registers (including the auxiliary ones) are used by the player.
Targhan/Arkos

Arkos Tracker 2 - alpha 9 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

Offline teopl

  • CPC664
  • ***
  • Posts: 110
  • Country: cs
  • Liked: 45
  • Likes Given: 93
Re: cpctelera arkos 2 conversion problem
« Reply #12 on: 00:45, 22 July 19 »
Well what can I say, thanks for motivating me to find a problem... :)

It was indeed in my code... (not even worth mentioning)

So now, again I am back to Arkos2... what a journey...

Offline teopl

  • CPC664
  • ***
  • Posts: 110
  • Country: cs
  • Liked: 45
  • Likes Given: 93
Re: cpctelera arkos 2 conversion problem
« Reply #13 on: 14:53, 10 August 19 »
Hi, I have new issue.

I attached updated Arkos2 + cpctelera project. (with new arkos2 sources and binaries)

Problem is that if I can't play second subsong (index 1) so if you change this:

Code: [Select]
ld      a, #0
to this:

Code: [Select]
ld      a, #1
and do:

Code: [Select]
make clean; ./make_all_with_colors.sh; ./run.sh
it will not play although the subsong is playable from Arkos2 player. Any ideas? (from the code, the A register should contain subsong index)

Also I am wondering:

1. Can I actually save memory if using several subsongs which share instruments (in one file) compared to several songs (in separate files)?
2. Can I do song compression/decompression before doing INIT? If yes, is that useful in terms of saving memory?

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.119
  • Country: fr
  • Liked: 1051
  • Likes Given: 152
Re: cpctelera arkos 2 conversion problem
« Reply #14 on: 15:46, 10 August 19 »
I don't know anything about cpctelera, but I just tested your AKS file with the AKG and LW players, and both subsongs plays perfectly. So the problem must come from your side.

Quote
1. Can I actually save memory if using several subsongs which share instruments (in one file) compared to several songs (in separate files)?
That's what Subsongs are for. All the subsongs share the same instruments, arpeggio and pitch tables, saving a bit of memory. Though this is probably not what costs the most in a song, you can still save a few hundred bytes for complex songs.

Quote
2. Can I do song compression/decompression before doing INIT? If yes, is that useful in terms of saving memory?
Compression will save data on disc. The music player will need the music fully decompressed in memory, so unless I didn't understand what you mean, no, you won't save any memory. Or maybe you want to unpack your song only when needed? Then yes, if you don't want to/can't load songs from disc, yes, it will save memory, but only while the song is NOT playing. But at some point, you'll have the compressed and uncompressed song in memory... Makes sure you have enough of it.
Targhan/Arkos

Arkos Tracker 2 - alpha 9 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

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.119
  • Country: fr
  • Liked: 1051
  • Likes Given: 152
Re: cpctelera arkos 2 conversion problem
« Reply #15 on: 16:01, 10 August 19 »
Additional question, are you sure you exported both subsongs, and not only the first one?
Targhan/Arkos

Arkos Tracker 2 - alpha 9 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

Offline teopl

  • CPC664
  • ***
  • Posts: 110
  • Country: cs
  • Liked: 45
  • Likes Given: 93
Re: cpctelera arkos 2 conversion problem
« Reply #16 on: 16:37, 10 August 19 »
Thanks for the explanation and yes that's it: I didn't export second subsong... Thanks!

So, I added this to command line exporter:
Code: [Select]
--subsongsAndPsgs s1p1,s2p1
About compression / decompression, I understand, so it's like any other resource - I can compress it, but will I gain more free memory it depends on the usage.

I saw that there is option: --exportSeveralFiles so I may experment a little with it to try to see if I can save memory in case of several compressed subsongs and only one decompressed which is currently playing. (or maybe even split subsongs to more smaller subsongs...)

Edit: wrong topic...
« Last Edit: 11:42, 13 June 20 by teopl »

Offline cperezgrin

  • CPC464
  • **
  • Posts: 25
  • Country: es
  • Liked: 14
  • Likes Given: 5
Re: cpctelera arkos 2 conversion problem
« Reply #17 on: 13:43, 02 July 20 »
Thanks to both of you for this way to use Arkos 2 songs with the current version of cpctelera. But I have some problems when exporting. It seems some features are not supported for AKL format like "Warning: Track &A, line &A: Effect 3 not supported in this format."
Is there an easy way to solve this? I have to say that I'm not familiarised with trackers, maybe there's a simple fix.

Also thanks to Targhan for his Tracker

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.119
  • Country: fr
  • Liked: 1051
  • Likes Given: 152
Re: cpctelera arkos 2 conversion problem
« Reply #18 on: 18:50, 02 July 20 »
This is "normal". AKL (=lightweight) and AKM (minimalist) are smaller players that you use if you want to save some memory. However, they are also more limited, hence the warnings. Please read the documentation for more information.

My suggestion is to start with the AKG player, which is the "generic" player, and suited for most projects.

... Or you can simply remove the use of the incriminated effect, if your song doesn't suffer from it.
Targhan/Arkos

Arkos Tracker 2 - alpha 9 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