Amiga programming of the hardware in C language
category: code [glöplog]
Hello,
I know direct programming of the custom chips using C instead of Assembly is possible, see "Sunglasses at Night" demo for example.
I would like to know if resources like tutorials, documentation, source code examples exist.
Listing other demos (possibly with source code available), could also be of help.
The target is OCS, ECS, AGA.
Thanks, greetings
I know direct programming of the custom chips using C instead of Assembly is possible, see "Sunglasses at Night" demo for example.
I would like to know if resources like tutorials, documentation, source code examples exist.
Listing other demos (possibly with source code available), could also be of help.
The target is OCS, ECS, AGA.
Thanks, greetings
It's reasonably simple.
Usually the Amiga C compiler suite will already come with Amiga-specific headers, such as:
#include <hardware/custom.h>
#include <hardware/cia.h>
#include <hardware/dmabits.h>
With stuff like:
__far extern struct Custom custom;
__far extern struct CIA ciaa, ciab;
You can access the registers of the custom chips directly (it's all memory-mapped).
If you don't have these headers, you can download the Amiga NDK here:
http://www.haage-partner.de/download/AmigaOS/NDK39.lha
It contains all the Amiga-specific headers you'll need.
Documentation is just the Amiga Hardware Reference, you can find an online version here:
http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0000.html
Just study the documentation and write the proper values to the proper custom registers, and that's that :)
Usually the Amiga C compiler suite will already come with Amiga-specific headers, such as:
#include <hardware/custom.h>
#include <hardware/cia.h>
#include <hardware/dmabits.h>
With stuff like:
__far extern struct Custom custom;
__far extern struct CIA ciaa, ciab;
You can access the registers of the custom chips directly (it's all memory-mapped).
If you don't have these headers, you can download the Amiga NDK here:
http://www.haage-partner.de/download/AmigaOS/NDK39.lha
It contains all the Amiga-specific headers you'll need.
Documentation is just the Amiga Hardware Reference, you can find an online version here:
http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0000.html
Just study the documentation and write the proper values to the proper custom registers, and that's that :)
i think you want to read this thread: Here is my complete Amiga cross development tool chain and sample code - all in one package
Sunglasses at Night is an excellent demo that shows how much great performance can be achieved on a OCS machine using the C language.
On the opposite, if you are looking for a system-friendly C source that crawls on a 68000, you might look at my github here :
github.com/voitureblanche/projet-secret
github.com/astrofra/amiga-experiments/tree/master/ddln-nvt-demo
On the opposite, if you are looking for a system-friendly C source that crawls on a 68000, you might look at my github here :
github.com/voitureblanche/projet-secret
github.com/astrofra/amiga-experiments/tree/master/ddln-nvt-demo
I used to have the "Dice C" compiler (found some info and a download link for it as its now freeware http://www.binarydevotion.com/?p=76 ).. but got my PC so soon after I didn't get too deep into it.
The Menace Reconstruction :
Jimmy Maher, the author of the book "Amiga, the future was there" re-implemented the first level of the game Menace, in full-C. You will find the code on this page :
http://amiga.filfre.net/?page_id=17
Jimmy Maher, the author of the book "Amiga, the future was there" re-implemented the first level of the game Menace, in full-C. You will find the code on this page :
http://amiga.filfre.net/?page_id=17
@All
Thanks for the very interesting replies.
@fra
I wonder how the Menace remake (C) performs compared to the original game (Assembly).
Does it run at constant full frame rate (50 Hz) or?
Cool Amiga book by the way.
Thanks for the very interesting replies.
@fra
I wonder how the Menace remake (C) performs compared to the original game (Assembly).
Does it run at constant full frame rate (50 Hz) or?
Cool Amiga book by the way.
@Alientech : it does. The overhead of the C compiler is not that huge, actually :)
(even if, to be honest, this recreation doesn't include the mod replayer).
(even if, to be honest, this recreation doesn't include the mod replayer).
But... why only in C?) I think low level stuff is even easier to code in assembly. You could then just call those functions from C. And later if you feel like some bits could benefit from rewriting in asm you can do that.
Btw this demo is also a mix of both.
Btw this demo is also a mix of both.
@dodke
Yes C and Assembly can coexist, I agree.
In fact I remember that during the Commodore years, several games used to be programmed in C (the game logic) plus Assembly (the graphics engine / rendering).
Yes C and Assembly can coexist, I agree.
In fact I remember that during the Commodore years, several games used to be programmed in C (the game logic) plus Assembly (the graphics engine / rendering).
I think the same goes for a lot of the later Amiga demos, especially the AGA ones.
@fra
The original Menace coded in Assembly has smoother animations of the moving objects, I suppose 50 Hz against 25 Hz of the C remake.
I reserve the right to be wrong as I didn' t study the related sources, only had a quick look at Menace.c :)
The C remake is a cool achievement anyway.
Quote:
@Alientech : it does. The overhead of the C compiler is not that huge, actually :)
(even if, to be honest, this recreation doesn't include the mod replayer).
The original Menace coded in Assembly has smoother animations of the moving objects, I suppose 50 Hz against 25 Hz of the C remake.
I reserve the right to be wrong as I didn' t study the related sources, only had a quick look at Menace.c :)
The C remake is a cool achievement anyway.
I'm speaking with fairly little Amiga experience (1 prod.) but you can write/read volatile fixed memory addresses in a proper compiler, and most certainly just solve the critical stuff in assembler procedures or some intertwined inline assembler -- also look at naked/low-overhead calls -- this is mostly 486/Watcom stuff now though, but I don't imagine it being very different.
Otherwise: datadriven code, transform and output to PC and generated Amiga assembler, different way of demomaking (see Ferris' NVScene video on SNES stuff on that).
Otherwise: datadriven code, transform and output to PC and generated Amiga assembler, different way of demomaking (see Ferris' NVScene video on SNES stuff on that).
My approach is the same as dodke's, just write the time-critical / low level stuff in ASM and the rest in C. Best of both worlds IMO
http://sun.hasenbraten.de/vbcc/
I am using SAS/C 6.58 C compiler, legal copy purchased during the Commodore years as 6.50 and then upgrated, and I am really pleased with it.
Quote:
The original Menace coded in Assembly has smoother animations of the moving objects, I suppose 50 Hz against 25 Hz of the C remake.
I reserve the right to be wrong as I didn' t study the related sources, only had a quick look at Menace.c :)
The C remake is a cool achievement anyway.
But that is probably due to the implementation techniques used, rather than the programming language. If you give the same programming task to two programmers, where one has to use asm, and the other C(++), you cannot beforehand conclude, that the asm implementation will be the most performant.
Again about the original Menace game written in Assembly versus the remake written in C.
I believe the C remake is based on the making of the original Menace serie of articles as had appeared on Amiga Format
The original game, followed a quite common template, featuring:
1) silky-smooth background scrolling (hardware dual-playfield mode) at 50 Hz
2) player ship (hardware sprites) at 50 Hz
3) aliens (bobs) at 25 Hz
The C remake seems to keep all of the above and that is why it is a faithful reconstruction and a clear example of what can be achieved using C.
I believe the C remake is based on the making of the original Menace serie of articles as had appeared on Amiga Format
The original game, followed a quite common template, featuring:
1) silky-smooth background scrolling (hardware dual-playfield mode) at 50 Hz
2) player ship (hardware sprites) at 50 Hz
3) aliens (bobs) at 25 Hz
The C remake seems to keep all of the above and that is why it is a faithful reconstruction and a clear example of what can be achieved using C.