News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_teopl

cpctelera arkos 2 conversion problem

Started by teopl, 20:32, 02 February 19

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

teopl

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

Arnaud

#1
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


teopl

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:


Arnaud

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 !

teopl

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


teopl

#5
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".


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}

Arnaud

Quote from: teopl on 13:14, 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)


teopl

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:


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}

teopl

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:

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

PLY_LW_ME_PITCHUPDOWN_NEGATIVESPEED: res 7,d
    or a
    sbc hl,de
    sbc a,0


instead of:

PLY_LW_ME_PITCHUPDOWN_NEGATIVESPEED: res 7,d
    or a
    sbc hl,de
    sbc a,#0

Targhan

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

teopl

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.

Targhan

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

teopl

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

teopl

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:

ld      a, #0

to this:

ld      a, #1

and do:

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?

Targhan

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.

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

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

Targhan

Additional question, are you sure you exported both subsongs, and not only the first one?
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

teopl

#16
Thanks for the explanation and yes that's it: I didn't export second subsong... Thanks!

So, I added this to command line exporter:

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

cperezgrin

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

Targhan

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

prototano

Thanks to this post and following the instructions of http://www.julien-nevo.com/arkostracker/index.php/using-a-song-in-production-using-any-assembler/  :D :D
I was able to get cpctelera + arkos2 working together.
I want to share another example:
https://github.com/cmp102/cpctelera/tree/a2c567f8b5bc2b092d68e865c12c74dd7c502938/examples/medium/arkostracker2
This is a cpctelera's fork with all tools and makefile's macros needed to integrate arkos2 on cpctelera in a similar way as arkos1 does. (It only works on linux and only uses the AKM player).
Video of the example:

https://www.youtube.com/watch?v=5S8n5FEkXms
Thank you a lot guys!   :D

Arnaud

Quote from: prototano on 13:57, 09 November 20
Thanks to this post and following the instructions of http://www.julien-nevo.com/arkostracker/index.php/using-a-song-in-production-using-any-assembler/  :D :D
I was able to get cpctelera + arkos2 working together.
I want to share another example:
https://github.com/cmp102/cpctelera/tree/a2c567f8b5bc2b092d68e865c12c74dd7c502938/examples/medium/arkostracker2
This is a cpctelera's fork with all tools and makefile's macros needed to integrate arkos2 on cpctelera in a similar way as arkos1 does. (It only works on linux and only uses the AKM player).
Thank you a lot guys!   :D
Thanks ! :)

cperezgrin

I'm back with this issue.
I managed to play arkos2 song with Lightweight format  with Arnaud example, but I need to do it with genereic format (AKG). This should be easy as I only need to change the call from PLY_LW_... to PLY_AKG_ But I noticed that the players included in Arkos2 (Arkos2\players\playerAkg\sources) are in .asm format and can't be simple renamed to .s to be included in the cpctelera make. I also noticed that the Lightweight player included in the first posts is different to the one included in Arkos2.
So I think there is need some kind of transformation to make those player functionable in cpctelera. The question is, is there already any PlayerAKG.s that compiles in cpctelera in the same way as PlayerLightweight.s does? I'm really a noob in ASM, maybe there's a easy way from the Arkos2 source file, but I don't know how.
Thanks

prototano

You can get a cpctelera's assembly version of the player if you compile it with rasm and disassembles it with disark.
I have a attach a version of AKM which we used on Promotion (Already converted to cpctelera's assembly).

prototano

Quote from: cperezgrin on 18:50, 24 November 20
I'm back with this issue.
I managed to play arkos2 song with Lightweight format  with Arnaud example, but I need to do it with genereic format (AKG). This should be easy as I only need to change the call from PLY_LW_... to PLY_AKG_ But I noticed that the players included in Arkos2 (Arkos2\players\playerAkg\sources) are in .asm format and can't be simple renamed to .s to be included in the cpctelera make. I also noticed that the Lightweight player included in the first posts is different to the one included in Arkos2.
So I think there is need some kind of transformation to make those player functionable in cpctelera. The question is, is there already any PlayerAKG.s that compiles in cpctelera in the same way as PlayerLightweight.s does? I'm really a noob in ASM, maybe there's a easy way from the Arkos2 source file, but I don't know how.
Thanks
Also the Akg version.  ;D

cperezgrin

Thanks @prototano (and very nice game Promotion)
I can now compile the new AKGPlayer, but the song doesn't play. I think the problem is when I include the song in the project. I'm doing it in a similar way I saw for Lightweight
./music/SongToAkg.exe --labelPrefix  "song" -spadr ".org" -spbyte ".db" -spword ".dw"  -sppostlbl ":" music/song.aks src/m_songAKG.s ; perl -i -p -e "s/db \"AT20\"/\.ascii \"AT20\"/g" src/m_songAKG.s ; perl -i -p -e "s/songStart:/_songAKGStart::/g" src/m_songAKG.s ; rm src/m_songAKG.s.bak
In the zip attached is the 'project'. With u8 player initialised to 0, the Lightweight player will start and plays ok. With player <>0, AKG player starts but don't play right
How should I process aks file to be included in a cpctelera project with AKG format?Any help will be welcome, thanks

Powered by SMFPacks Menu Editor Mod