pouët.net

Go to bottom

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
added on the 2015-09-29 14:56:43 by AlienTech AlienTech
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 :)
added on the 2015-09-29 15:13:48 by Scali Scali
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
added on the 2015-09-29 15:40:26 by fra fra
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.
added on the 2015-09-29 15:57:49 by Canopy Canopy
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
added on the 2015-09-29 18:55:38 by fra fra
@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.
added on the 2015-09-30 13:48:05 by AlienTech AlienTech
@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).
added on the 2015-09-30 14:27:50 by fra fra
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.
added on the 2015-10-01 21:40:16 by dodke dodke
@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).
added on the 2015-10-02 13:48:11 by AlienTech AlienTech
I think the same goes for a lot of the later Amiga demos, especially the AGA ones.
added on the 2015-10-02 14:05:12 by Scali Scali
@fra

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.
added on the 2016-01-27 21:12:09 by AlienTech AlienTech
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).
added on the 2016-01-27 21:33:17 by superplek superplek
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
added on the 2016-01-27 21:46:43 by visy visy
http://sun.hasenbraten.de/vbcc/
added on the 2016-01-28 00:23:47 by Vousti Vousti
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.
added on the 2016-01-28 12:58:21 by AlienTech AlienTech
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.
added on the 2016-01-29 13:49:38 by AlienTech AlienTech

login

Go to top