Page 1 of 1

Calling Memory Resident Code On Amstrad

Posted: Tue Sep 07, 2010 3:31 pm
by FishGuy876
Hi,

Working on a C port of a program for one of my friends, using z88dk and the Amstrad CPC. Something I wanted to be able to do was load a file from disk into ram and execute it (to run a replayer for a piece of music he has written). In BASIC, its currently done something like:

MEMORY &1FFF
LOAD"REPLAY.BIN",&4000
LOAD"TRACK.BIN",&4C00
CALL &4000,&4C00

The replayer handles system calls etc. so it doesn?t have to be called every vbl. I was wandering if there is a way to load a block into a memory address of my choice and call/execute it like the above basic example. Thanks.

Posted: Wed Sep 08, 2010 9:28 am
by dom
Yeah, you should be able to use open/read/close to load the block.

For calling you can either cheat: asm("call 0x4000"); or setup an function prototype and call it in a C way, here's one way to do that:

static void func();

#asm
defc _func = 0x4000
#endasm

int main()
{
func();
}

There's several other ways to do it - use a function pointer:


void (*func)();
func = 0x4000;
func();


You can even do it directly though it generates a warning that I can't remember what it means (suppress with -Wn48):

0x4000();

Posted: Wed Sep 08, 2010 1:04 pm
by FishGuy876
Hi,

Thanks for the tip. Will this same method work in passing a second parameter to CALL (which is used to tell the replayer where the music data is stored) ?

I got an email from someone suggesting an ASM call function, and again I need to see if I can pass a second parameter to it. My asm skills are not strong hehe. Thanks.

Andy

Posted: Fri Sep 10, 2010 3:33 pm
by arnoldemu
I see in another thread that you want to play starkos music.

I have created a library for z88dk which you could use to play starkos music.
You need to including it in your build, and then you can have the player and music data in memory how you wish without needing to call direct like this.

Posted: Fri Sep 10, 2010 3:39 pm
by FishGuy876
Hi,

YES! Please send me the info for replaying starkos music directly in z88dk. I have several tracks that are loaded into memory that get switched at different points. You can link here, or email me at andy@f1-software.com thanks!

Posted: Mon Sep 13, 2010 1:34 pm
by FishGuy876
Hi, certainly let me know when you are able to send that, I looked on the z88dk pages and can find no mention of it, so I am assuming its not included with the compiler as default. Thanks again :)

Posted: Fri Sep 17, 2010 8:39 am
by arnoldemu
FishGuy876 wrote:Hi, certainly let me know when you are able to send that, I looked on the z88dk pages and can find no mention of it, so I am assuming its not included with the compiler as default. Thanks again :)
You have mail.