|
Post by Jonathan Cauldwell on Aug 12, 2004 13:15:09 GMT -5
Hi guys, I've been writing Spectrum games for a couple of decades now and thought it was about time I branched out and wrote one or two games for other Z80-based machines as well. So far it hasn't been too difficult to locate the technical information required to start knocking out a machine code game for the 464, I've even managed to write a little C program to convert my binaries to an emulator snapshot file for testing. Unfortunately, my knowledge of Amstrad BASIC lets me down and this is where I need assistance. I assume machine code programs require a simple BASIC loader program which reserves space in memory, auto-loads the machine code, then runs that with a call? Trouble is, I haven't a clue how to go about doing this. Can anyone help? Also, are there any emulators or PC utilities for creating emulator tape files, and converting those to sound samples which could be loaded into a genuine CPC? members.fortunecity.com/jonathan6/egghead
|
|
|
Post by Anthony Jordan on Aug 14, 2004 15:45:20 GMT -5
Hello Jonathan, Here is a bare minimum answer to your question. Please feel free to ask for more help.
Assuming you have written a machine code program called MYPROG.BIN designed to load at address &9000. The '&' means that the address is in hexadecimal. The loader program (probably called MYPROG.BAS) could look like this:
10 MEMORY &8FFF ' Just before the start of the m/c program 20 LOAD "MYPROG.BIN",&9000 ' The program's lowest address 30 CALL &9000 ' Or whatever is the start address 40 END
I hope this helps.
|
|
|
Post by Jonathan Cauldwell on Aug 18, 2004 5:45:03 GMT -5
Fantastic, that's helped significantly. It's very similar to the way the Spectrum does it! Thanks for that.
What's the command to save a block of code? I've tried specifying the start address and length of the code block as parameters in the save statement but get a syntax error.
Is it standard practice to load Amstrad games using CHAIN (like the BBC) so that they auto-run, or do I need to save my BASIC program in a way so that it auto-runs using LOAD?
You know, I'm getting to like this machine. It's probably a bit late for this year, but I might write a 464 game for next year's minigame competition.
|
|
|
Post by crap on Aug 18, 2004 7:53:22 GMT -5
Hi
To save a some binary data from memory to a file type
save "filename",b,start,length
eg.
save "myprog.bin",b,&9000,&500
Remember to use the memory command also.
|
|
|
Post by Jonathan Cauldwell on Aug 30, 2004 10:23:12 GMT -5
Thanks, that's just what I needed to know.
|
|
Tony
Full Member
Posts: 29
|
Post by Tony on Sept 17, 2004 19:52:44 GMT -5
"Is it standard practice to load Amstrad games using CHAIN (like the BBC) so that they auto-run"
Not quite, although there is a CHAIN command for loading BASIC programs (as far as I know)
", or do I need to save my BASIC program in a way so that it auto-runs using LOAD?"
Yes but using the RUN command instead.
First save "filename",b,start,length,auto-run-address
and then run "filename"
With this method RETurning from MC will reset the machine. I can't help you with this since I'm not an MC expert, I suppose there might be a way to return to BASIC.
|
|
|
Post by Jonathan Cauldwell on Sept 19, 2004 7:52:01 GMT -5
Auto-running binary files... Doh! I never considered that, probably because the Spectrum doesn't have that facility. You know, writing for the Amstrad has certainly meant having to look at games programming from a very slightly different angle to that required for the Sinclair machines.
It raises another question though: does this method automatically reserve space for the binary before it's loaded, like the MEMORY command does?
|
|
Tony
Full Member
Posts: 29
|
Post by Tony on Sept 24, 2004 17:42:26 GMT -5
The MEMORY command does this:
It specifies the maximum amount of memory available to your BASIC programs. (out of about 42K maximum)
eg. Memory 20000, means your BASIC program will only have about 20K of memory to use for code and data. If you want to load a bigger BASIC file (or type in more BASIC commands) you'll get a "MEMORY FULL" error message. This means that there is no case for your BASIC program of altering or overwritting anything that resides at memory position 20001 and up. So if you have some MC routines (to call from BASIC) or plain data at memory position 20001 and up, they will remain intact in case your BASIC program runs out of room. This is the way for a BASIC program and machine language code to happily co-exist.
"does this method automatically reserve space for the binary before it's loaded, like the MEMORY command does?"
So the answer is, I don't know but who cares? If you auto-execute a binary file and you don't intend on returning to BASIC from MC, then it doesn't matter if your BASIC program space is tidy or not.
Anyway, I'd tend to think that the RUN command takes care of this rather trivial issue by simulating an appropriate MEMORY command just before executing the MC.
To cut a long story short: just use the well-known methods you know and you should be fine. After all, most commercial CPC games would just include a BASIC loader that would then load the MC code in the way you already know. (Also, this way you can poke several values before calling the MC.)
I hope I didn't confuse you too much.
|
|
Tony
Full Member
Posts: 29
|
Post by Tony on Sept 24, 2004 17:45:57 GMT -5
PS. You do NOT need to specify an auto-run address. It's optional. So, you can just load the machine code program in a basic loader program and just call it.
peace
|
|
|
Post by Jonathan Cauldwell on Oct 10, 2004 12:26:24 GMT -5
Okay, thanks for your help. I'll probably go for the BASIC loader program method.
|
|