English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. C/C++ (http://eab.abime.net/forumdisplay.php?f=118)
-   -   Any C/C++ example code? (http://eab.abime.net/showthread.php?t=76921)

vim 05 February 2015 23:36

Any C/C++ example code?
 
I did manage to get a small hello world compiling in AmigaDevCpp so that's a small step forward. Made a small guide also. Some questions if anyone has some answers.

AmiDevCpp only seems to be able to build for AmigaOS 3.x or have i just failed to find the settings for it? Would be nice to be able to build for Amiga 500.

Anyone that have some basic example program in C or C++ i could look at? Trying to make sense of the library's and the hardware usage.

Nekoniaow 06 February 2015 06:25

You can find some examples of OS-respectful programming in the Rom Kernel Manuals "Libraries Manual": http://amigadev.elowar.com/read/ADCD.../node0000.html

However, this is quite far away from the metal and you will have quite a few graphics.library structures to initialize and prepare before you can just display an empty screen. ;)
Example: http://amigadev.elowar.com/read/ADCD.../node032C.html

If you want to toy directly with the hardware (which frankly is more fun) you can start reading the real bible of the Amiga, the Hardware Reference Manual: http://amigadev.elowar.com/read/ADCD.../node0000.html. Inside you will find low level descriptions of the machine and how to program it via its custom chips registers. There's a lot to read but it's quite fascinating and very well written overall: if you know nothing about bitplanes for example you will find a complete explanation of how they are used to construct the display.

As for programming the hardware using C, all the hardware registers can be written-to/read-from using pointers. For example, changing the colour 0 of the palette can be done via:

Code:

*((unsigned short*)0xDFF180) = 0x0FFF; // Set colour 0 to white.
I believe there is a header file somewhere which already contains macros or structs to use to access all the custom registers so you don't have to type raw addresses such as 0xDFFxxx but I can't recall its name or where it is. :)

I guess more seasoned Amiga coders will point you to more recent and/or elaborated examples and/or docs though since I essentially gave you what I started with back in the days where there was no Internet yet. ;)

vim 06 February 2015 09:32

Thanks. I had some luck and also manage to find the Hardware Reference Manual at my local library. Now i can chill out at work and read it over lunch :).

Lonewolf10 06 February 2015 20:02

Quote:

Originally Posted by vim (Post 1002155)
Thanks. I had some luck and also manage to find the Hardware Reference Manual at my local library. Now i can chill out at work and read it over lunch :).

!!! ( where's a fainting emoticon when you need one... )

Photon 06 February 2015 22:51

Thread moved to the C/C++ forum :great

NovaCoder 09 February 2015 04:05

Quote:

Originally Posted by vim (Post 1002114)
I did manage to get a small hello world compiling in AmigaDevCpp so that's a small step forward. Made a small guide also. Some questions if anyone has some answers.

AmiDevCpp only seems to be able to build for AmigaOS 3.x or have i just failed to find the settings for it? Would be nice to be able to build for Amiga 500.

Anyone that have some basic example program in C or C++ i could look at? Trying to make sense of the library's and the hardware usage.

AmiDevCpp is a cross compiler, it can target many different platforms.

Not sure what you mean about the difference between compiling for OS 3.x and an A500...you do know that an A500 can run OS 3.x don't you?

I wrote some example C++ that might help you get started, it's a bit shit but will give you some ideas :p


http://eab.abime.net/showthread.php?t=61692

idrougge 10 February 2015 05:34

Here is the annotated source for a system friendly (?) version of Tetris: http://monkeyfighter.com/tetris.html


All times are GMT +2. The time now is 11:57.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.

Page generated in 0.08187 seconds with 11 queries