Cross Compiled C code for Atari 800 XL
So... I spent some time setting this up on a Windows 10 laptop environment, which involved downloading and installing cc65 and adding the /bin folder to the PATH - I'll get screenshots from that laptop and paste down below - the reason I mention this is because that setup did not have the cl65 executable that allows you to do the compile/link all in one go, you have to do it step by step, which isn't a major problem, but it is interesting to do & understand what is happening behind the scenes.
In my UBuntu linux environment, all that I did was:
$ sudo apt-get install cc65
Then I used snap to install atari800xl-linux
This allowed me to have an emulator for the atari800xl locally.
Once the cc65 (cc = cross compiler) is installed you can use it straight away.
I used the code from this page as a quick example.
As you can see below, the simple C code is located in it's own folder, I then used the cl65 command to make the output file, for the Atari800xl it is best to call the output file with the extension .xex
Then using the F1 command in the emulator, you pick the .xex file and it loads straight away, pressing <enter> then using the WASD keys to move the cursor around and draw dots and when finished press the Q key and it'll finish.
So...my coding & artistic ability is shown by the following C code output:
Okay, so that was a nice exercise.
<insert the Windows 10 experience here>
First things first, navigate to HERE and then follow the instructions to download the Windows snapshot.
I extracted this into a >dev >atari > cc65 folder that then shows all the sub-dirs such as asminc / bin / cfg / html / include / lib / samples / target
As it states, add the #bin folder location to the PATH environment variable in the usual windows way (that has been the same since version 3.1!)
Just an observation, within the #target folder there are all the sub-folders for the target machines, you'll note there is atari / atari5200 / atari7800 and atarixl - this is handy to know as sometimes when I was compiling and attempting to use atarixl it would fail, but using atari5200 or just atari would work fine.
I downloaded and install Altirra-4.10 from the inter-webs HERE that just involved downloading the latest file:
I then unzipped that into my >dev >atari folder as >Altirra-4.10
Created a shortcut to the .exe file and dropped it on the desktop for ease of access.
That is pretty much it for the setup.
Using the same C code as from the linux environment, I created a >dev >coding >c >app2 folder and dropped the app.c file into it.
The nice thing about using the Windows version is that the cl65 command works that allows you to do the compilation in a single command line and not have to do the individual steps, which is nice.
> cc65 -O -t atarixl app2.c #compiles C code and generates app2.s file
> ca65 app2.s #translates assembly source
> ld65 -o app2.xex -t atarixl app2.o atarixl.lib #link .o files to atarixl and output to .xex file
as stated, could use > cl65 here instead to do it in one go.
Now, load the Altirra.exe emulator up, select File / Boot image, select app2.xex
Cold Reboot the emulator and this will execute on restart the app2 that will show the output program!
job done.
On a real machine, you need Atari DOS 2.5 or compatible, turn on Atari and type: DOS at the BASIC prompt, then choose
N.create mem.sav
then choose
L.Binary Load
and enter
app2
Then the program will run on the real Atari 800 XL hardware.
<Now insert the github repo's that I found that could prove interesting including the C library that could be useful to use.>
Now that I've been able to demonstrate to myself that I can write simple C code, compile & build and deploy and execute it - now all I have to do is figure out what to do next :-D
Comments
Post a Comment