Arkos Tracker 2 in z88dk

eldeljar
Member
Posts: 33
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
Well known member
Posts: 287
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: 2072
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: 33
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: 33
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: 2072
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: 33
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: 2072
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: 121
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
Well known member
Posts: 287
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
Well known member
Posts: 287
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
Well known member
Posts: 287
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
Well known member
Posts: 287
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
Well known member
Posts: 287
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
Well known member
Posts: 287
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 ;-)
eldeljar
Member
Posts: 33
Joined: Sun Feb 12, 2017 6:04 pm

Re: Arkos Tracker 2 in z88dk

Post by eldeljar »

Hello, after a long time I have resumed this task. Thanks for all the answers.

I have taken jorgegv's project as an example, but I can't get it to work on an MSX Rom.
I have put the project on Github in case someone wants to review it and help me:

https://github.com/eldeljar/Arkos-Track ... SX-y-Z88dk

Thank you so much
User avatar
jorgegv
Well known member
Posts: 287
Joined: Wed Nov 18, 2020 5:08 pm

Re: Arkos Tracker 2 in z88dk

Post by jorgegv »

I'm away from my computer at the moment, but I think I recall Arkos using self modifying code in some places (at least the default player), which would make It unsuitable for ROMs.

I also believe there was a non-SMC versión of the player, so this would be way for you...

I'll review my notes when I arrive home tomorrow and report back.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: Arkos Tracker 2 in z88dk

Post by stefano »

there could be a way by putting the SMC code portion in a library and declare a smc section for it
Timmy
Well known member
Posts: 392
Joined: Sat Mar 10, 2012 4:18 pm

Re: Arkos Tracker 2 in z88dk

Post by Timmy »

I think I also recalled Arkos Tracker being self modifying as well, although I never looked at it closely.

It might also contain other spectrum specific stuff as well, like reading keypresses.

I'm not sure if modifying the SMC code is a good idea, unless the plan is that someone is going to keep support it.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Arkos Tracker 2 in z88dk

Post by dom »

It is SMC, however, maybe it's this easy? https://github.com/eldeljar/Arkos-Track ... kg.asm#L20
eldeljar
Member
Posts: 33
Joined: Sun Feb 12, 2017 6:04 pm

Re: Arkos Tracker 2 in z88dk

Post by eldeljar »

Thank you all very much for the answer.

I'm using in "CompileAT2Files.asm":

Code: Select all

PLY_AKM_ROM = 1
According to the documentation, in that case the code is not self-modifying.

Things I may be doing wrong:
- In the "playerZ88dk.asm" file there is an error.
- Has some error related to interruptions.

I am trying to use the following code:

Code: Select all

void playmusic(void) {
   M_PRESERVE_ALL;
   ply_akg_play();
   M_RESTORE_ALL;
}

// Setup interrupt
void setup_int() {
#ifndef NO_INTERRUPT
  #if __SPECTRUM__
   zx_im2_init(0xd300, 0xd4);
   add_raster_int(0x38);
  #endif
  #ifndef NO_INTERRUPT_INIT
   im1_init();
  #endif
   add_raster_int(playmusic);
#endif
}
void main(void) {

  ply_akg_init(SONG, 0 );

  printf("Before\n");

  setup_int();

  printf("After\n");
  
  while ( 1 ) {
}
Type "Before" and "After", but nothing sounds.
Post Reply