Arkos Tracker 2 in z88dk

Post Reply
eldeljar
Member
Posts: 30
Joined: Sun Feb 12, 2017 6:04 pm

Arkos Tracker 2 in z88dk

Post by eldeljar »

Hello, I would like to use music created with the Arkos Tracker 2 tool, but I am not able to do so.

The code is created with Rasm, but with the Rasm compiler and the "Diskark" tool you can generate the assembler code for SDCC.

The problem is that it generates a file with a .z80 extension and when trying to compile with z80asm it gives errors (before compiling I change the extension to .asm). I attach the file that has generated me for SDCC:

https://drive.google.com/file/d/1xnw_sK ... sp=sharing

I have looked at the documentation for z88dk but Arkos Tracker is not mentioned for music.

Does anyone use or have Arkos Tracker 2 integrated to work with z80asm?
If not, could someone tell me what changes I would have to make to the attached document to make it work with z80asm


Thank you
User avatar
jorgegv
Member
Posts: 136
Joined: Wed Nov 18, 2020 5:08 pm

Re: Arkos Tracker 2 in z88dk

Post by jorgegv »

In the "Disark" tool manual I see:
Of course the "source profile" parameter accept other values:

winape, maxam, pasmo, vasm, sdcc, orgams.
You can also omit the sourceProfile, in which case Disark produces a source with no specificity at all, which is fine for many many assemblers.
Did you try to generate assembler source for the different assemblers? It seems the macros/mnemonics used by the one you posted are not understood by z80asm, but maybe the "generic" profile mentioned in the docs will work?
andydansby
Member
Posts: 51
Joined: Fri May 27, 2016 8:58 pm

Re: Arkos Tracker 2 in z88dk

Post by andydansby »

Arkos Tracker 2 has been on my todo list for a while, but I just haven't gotten around to it. Best guess for it now is to compile it with the built in compiler and include it in an asm file as a binary blob with known entry points.
User avatar
dom
Well known member
Posts: 1692
Joined: Sun Jul 15, 2007 10:01 pm

Re: Arkos Tracker 2 in z88dk

Post by dom »

Because we've got WYZ and Vortex players in the library (for multiple targets) a while ago I was looking at including Arkos as well and getting it working across more exotic machines.

However, looking at the downloaded archive I just found it really confusing what player code needed to be included so I gave up - the kit I looked at had different players and implementations for zx, cpc, msx.

I suspect the best way to add it to a project is to either do it as a binary blob as @andydansby suggests or export as vasm (since I gave vasm z80asm compatible syntax when I first ported it).
eldeljar
Member
Posts: 30
Joined: Sun Feb 12, 2017 6:04 pm

Re: Arkos Tracker 2 in z88dk

Post by eldeljar »

Hello, thank you all very much for the answers.

Before answering, I mention that I am trying to integrate the player "The AKM (Minimalist) player".

@Jorgegv: I have tried with all the profiles.

@andydansby: I don't know what a "binary blob" is and how to do it.

Things I have changed to try to make it work:
- Add to the beginning of the code "SECTION code_user".
- I have added "DEFC" in front of the first line. The z80asm compiler gives no error, but I don't know if this is correct.
- The public functions I think are: _PLY_AKM_INIT, _PLY_AKM_STOP and _PLY_AKM_PLAY. I guess I would have to add "PUBLIC _PLY_AKM_INIT" to the beginning of the code to be able to use them from C.

Lastly, if this doesn't work, I'll contact the author of the "disark" tool to see if he can include "z80asm" between the profiles.
andydansby
Member
Posts: 51
Joined: Fri May 27, 2016 8:58 pm

Re: Arkos Tracker 2 in z88dk

Post by andydansby »

A binary blob is jargon for a chunk of data or code that's not native to the compiling program. It's usually, but not always, loaded via asm using a link into assembler with something like. This is just a quick overview, not a step by step.

In an assembler file, place a bit of code like:
BINARY "awesomeProgam.bin" ;;BINARY BLOB

What you would do is compile awesomeProgam.asm using an alternative assembler compiler, be it Rasm, SDCC or whatever. Generate a symbol table with that compiler. Using that symbol file, find the entry points to the program loadMusic, playMusic or the like and find the hex address. Link those addresses into your compiler pushing the correct values. You may want to use the IM2 to trigger a call to the player or some other means.

In a few weeks, I'm going to be posting a tutorial (I use older version of Z88dk, but it will pretty much all apply) on loading images into the compiler. It's really the same concept, except it's going to be a program that you will be loading instead. I may have caught up with writing and programming to touch base on this subject in a month or so. I can be a bit slow on the tutorials since I'm pretty busy as of late.

andy
eldeljar
Member
Posts: 30
Joined: Sun Feb 12, 2017 6:04 pm

Re: Arkos Tracker 2 in z88dk

Post by eldeljar »

@Andydansby thanks for the info I will try.

At the moment, I have modified the asm code generated for SDCC, and it already compiles me, although I don't know if it will work when I test it from the C code.

In C code I do the following:

Code: Select all

extern void PLAYER_ARKOS_INIT (unsigned int * songdata, unsigned int subSong);
extern void PLAYER_ARKOS_PLAY ();
extern void PLAYER_ARKOS_STOP ();
The code compiles me, but if I try to use any of those functions, it gives me an error because it cannot find the symbols. I have edited the .sym file, and they are not there.

The assembler file has the following code:

Code: Select all

SECTION code_user

    PUBLIC _PLY_AKM_INIT
    PUBLIC _PLY_AKM_STOP
    PUBLIC _PLY_AKM_PLAY


// The player code that I have modified.
include "akm_sdcc.asm"

// The test music exported from Arkos Tracker 2.
_SONG:
binary "test.akm"
I am also using an old version of z88dk, but I don't think that is the problem. I leave the current code in case someone also wants to do tests:

https://drive.google.com/file/d/1OzjCbs ... sp=sharing

I compile it with the following command:
zcc +msx -Cs -no-cleanup -v -m -g -s -subtype=rom -compiler=sdcc -SO3 --max-allocs-per-node20000 --reserve-regs-iy -create-app -pragma-define:CRT_MODEL=2 -pragma-define:CRT_ENABLE_STDIO=0 -o prueba.bin @zproject.lst --fsigned-char
Regarding the test music, it is not mine, it is an example music that the Arkos Tracker 2 program has when you download it.

The player may not work even if I manage to call those functions, but at least I can continue testing for changes in the code.

Sorry if the text is not quite correct, but I am translating with Google Translator.
User avatar
dom
Well known member
Posts: 1692
Joined: Sun Jul 15, 2007 10:01 pm

Re: Arkos Tracker 2 in z88dk

Post by dom »

eldeljar wrote: Mon Oct 04, 2021 6:56 pmIn C code I do the following:

Code: Select all

extern void PLAYER_ARKOS_INIT (unsigned int * songdata, unsigned int subSong);
extern void PLAYER_ARKOS_PLAY ();
extern void PLAYER_ARKOS_STOP ();
...

The assembler file has the following code:

Code: Select all

SECTION code_user

    PUBLIC _PLY_AKM_INIT
    PUBLIC _PLY_AKM_STOP
    PUBLIC _PLY_AKM_PLAY
[I've not actually run your code, but...]

The assembler file is defining and exporting functions with these names: PLY_AKM_INIT(), PLY_AKM_STOP(), PLY_AKM_PLAY(); - that's why PLAYER_ARKOS_PLAY() are reporting a link failure.

Two ways to solve this.

1. Rename the functions in the header file
2. Export as different names using defc:

Code: Select all

PUBLIC _PLAYER_ARKOS_PLAY

defc _PLAYER_ARKOS_PLAY = _PLY_AKM_PLAY
eldeljar
Member
Posts: 30
Joined: Sun Feb 12, 2017 6:04 pm

Re: Arkos Tracker 2 in z88dk

Post by eldeljar »

Hi, I have already corrected the code and it already compiles, but the music still does not work.

I'll keep modifying the code to see if I can get it to work.

If I get it to work, I will notify you in this forum.
User avatar
dom
Well known member
Posts: 1692
Joined: Sun Jul 15, 2007 10:01 pm

Re: Arkos Tracker 2 in z88dk

Post by dom »

I think I have something working - some sound is coming out at the very least - it doesn't sound particularly tuneful, but it might give some more hints.

- The player is self modifying/contains variables so needs to be placed into RAM - I just changed the section to be data_user rather than code_user to make this happen
- PLY_AKM_PLAY() needs to be called in a loop
derekfountain
Member
Posts: 112
Joined: Mon Mar 26, 2018 1:49 pm

Re: Arkos Tracker 2 in z88dk

Post by derekfountain »

I have one of the demo AT2 tunes working from a z88dk C program. I used rasm and the binary blob method, so not the ideal approach.

I've put a (Linux) project here:

https://github.com/derekfountain/z88dk- ... r2-example

if it's of any use to anyone.
andydansby
Member
Posts: 51
Joined: Fri May 27, 2016 8:58 pm

Re: Arkos Tracker 2 in z88dk

Post by andydansby »

derekfountain wrote: Fri Oct 08, 2021 10:31 am I have one of the demo AT2 tunes working from a z88dk C program. I used rasm and the binary blob method, so not the ideal approach.

I've put a (Linux) project here:

https://github.com/derekfountain/z88dk- ... r2-example

if it's of any use to anyone.
Really nice work.
User avatar
jorgegv
Member
Posts: 136
Joined: Wed Nov 18, 2020 5:08 pm

Re: Arkos Tracker 2 in z88dk

Post by jorgegv »

Hi people,

I'm in the process of integrating Arkos Tracker 2 into my RAGE1 engine, so I have revisited Derek's repo with the implementation of the blob method (thanks Derek!). I have added some new test using your method without an IM2 ISR, but from a main loop (the method I need for RAGE1), and it also works perfectly. You can accept this PR if you want: https://github.com/derekfountain/z88dk- ... ple/pull/1, then you can use the following to build a test without IM2:

Code: Select all

make -f Makefile-noim2
Besides that, and since I don't really like the blob method (for lack of flexibility), I have also been experimenting with the relocatable source method described here: https://www.julien-nevo.com/arkostracke ... th-disark/

The main difficulty with this method is that Disark tool does not generate Z88DK z80asm syntax (but it generates several others), so some mangling of the generated source is needed.

My code is here: https://github.com/jorgegv/z88dk-arkos-relocatable

I have followed the article procedure (assemble with RASM -> disassemble with Disark) and I opted for PASMO syntax, and then "converted" the source from PASMO syntax to Z88DK z80asm by applying some simple text substitutions (the kludgy perl conversion script is here: https://github.com/jorgegv/z88dk-arkos- ... o-z88dk.pl , the text conversions done are well commented there)

I'm not sure if I'm doing everything that is needed for the conversion. So far, the final processed ASM file compiles and links without problems, but the Player does not work (but it also does not hang).

My next idea is to do bare bones binary builds of the RASM source (original) and Z88DK source (processed), both compiled to the same ORG, to check if the generated binaries are the same byte by byte (they should).

Any ideas regarding conversion? Am I missing something?

I keep investigating.
andydansby
Member
Posts: 51
Joined: Fri May 27, 2016 8:58 pm

Re: Arkos Tracker 2 in z88dk

Post by andydansby »

I'm not sure how useful this will be to you, but I did finally cover Arkos 2 at:
https://zxspectrumcoding.wordpress.com/ ... lesson-13/
User avatar
jorgegv
Member
Posts: 136
Joined: Wed Nov 18, 2020 5:08 pm

Re: Arkos Tracker 2 in z88dk

Post by jorgegv »

Thanks andy. I had already read your Arkos post, but you seem to hardcode lots of addresses (found in map files), which is precisely what I want to avoid. I'd like to find a scriptable way of going from Arkos sources to Z88DK compatible sources that can be compiled to any address, not a fixed one.

Even the exported songs have a fixed ORG address, but I think it should not be necessary, since they are only data, not code (only DEFB, DEFW and labels).
User avatar
jorgegv
Member
Posts: 136
Joined: Wed Nov 18, 2020 5:08 pm

Re: Arkos Tracker 2 in z88dk

Post by jorgegv »

jorgegv wrote: Mon Sep 19, 2022 8:18 am My next idea is to do bare bones binary builds of the RASM source (original) and Z88DK source (processed), both compiled to the same ORG, to check if the generated binaries are the same byte by byte (they should).
And here is the output from that test:

Code: Select all

...
3 files with the same hash should be shown below:
f7ed59a40838f5c3a3f59c4a260d57637f5f574d  output-song-pasmo.bin
f7ed59a40838f5c3a3f59c4a260d57637f5f574d  output-song-rasm.bin
f7ed59a40838f5c3a3f59c4a260d57637f5f574d  output-song-z80asm.bin
3 files with the same hash should be shown below:
90b6251f24f28ad70f9c84993a527d0ab554eb06  output-player-pasmo.bin
90b6251f24f28ad70f9c84993a527d0ab554eb06  output-player-rasm.bin
f0f6e7144b8b7860319e031fe9670798352123d1  output-player-z80asm.bin
$ ls -l output*.bin
-rw-r--r-- 1 jorgegv jorgegv 3299 sep 19 14:02 output-player-pasmo.bin
-rw-r--r-- 1 jorgegv jorgegv 3299 sep 19 14:02 output-player-rasm.bin
-rw-r--r-- 1 jorgegv jorgegv 3299 sep 19 14:02 output-player-z80asm.bin
-rw-r--r-- 1 jorgegv jorgegv 4893 sep 19 14:02 output-song-pasmo.bin
-rw-r--r-- 1 jorgegv jorgegv 4893 sep 19 14:02 output-song-rasm.bin
-rw-r--r-- 1 jorgegv jorgegv 4893 sep 19 14:02 output-song-z80asm.bin
So, for the songs my conversion script is fine, but not for the player. The sizes of all related are the same, though. Will continue...
User avatar
jorgegv
Member
Posts: 136
Joined: Wed Nov 18, 2020 5:08 pm

Re: Arkos Tracker 2 in z88dk

Post by jorgegv »

Mmm my Converter for pasmo syntax does not understand the $ operator for the current assembly pointer value.

Is there any similar feature in z88dk-z80asm?
User avatar
jorgegv
Member
Posts: 136
Joined: Wed Nov 18, 2020 5:08 pm

Re: Arkos Tracker 2 in z88dk

Post by jorgegv »

ASMPC is the functionality I need. I took it from this z80asm syntax reference: https://github.com/obiwanjacobi/Zingula ... /z80asm.g4 , which was mentioned on this issue: https://github.com/z88dk/z88dk/issues/1219

I have modified my adapter script to translate the Pasmo syntax with the z80asm one, and now all binaries match, both for player and data!

Will keep informing :-)
User avatar
jorgegv
Member
Posts: 136
Joined: Wed Nov 18, 2020 5:08 pm

Re: Arkos Tracker 2 in z88dk

Post by jorgegv »

SUCCESS! Arkos can me compiled to any address and runs without issues!

As I said, interested souls can see the procedure in the repo indicated above, it has been updated with the working changes: https://github.com/jorgegv/z88dk-arkos-relocatable

Now on with mi integration into RAGE1.

Thanks for the support, team ;-)
Post Reply