English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 05 February 2015, 23:36   #1
vim
Coder of Games

vim's Avatar
 
Join Date: Feb 2015
Location: Sweden
Posts: 17
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.
vim is offline  
Old 06 February 2015, 06:25   #2
Nekoniaow
Banned

 
Join Date: Dec 2014
Location: Montreal
Posts: 129
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.
Nekoniaow is offline  
Old 06 February 2015, 09:32   #3
vim
Coder of Games

vim's Avatar
 
Join Date: Feb 2015
Location: Sweden
Posts: 17
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 .
vim is offline  
Old 06 February 2015, 20:02   #4
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 41
Posts: 1,924
Quote:
Originally Posted by vim View Post
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... )
Lonewolf10 is offline  
Old 06 February 2015, 22:51   #5
Photon
Moderator

Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 4,975
Thread moved to the C/C++ forum
Photon is offline  
Old 09 February 2015, 04:05   #6
NovaCoder
Registered User
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,091
Quote:
Originally Posted by vim View Post
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


http://eab.abime.net/showthread.php?t=61692
NovaCoder is offline  
Old 10 February 2015, 05:34   #7
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,011
Here is the annotated source for a system friendly (?) version of Tetris: http://monkeyfighter.com/tetris.html
idrougge is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
start up code help simon_m74 New to Emulation or Amiga scene 2 08 April 2013 22:24
What's this code doing? Jherek Carnelia Coders. General 13 15 August 2011 17:55
Source Code Thalion project.WinUAE - Kaillera 3 28 April 2006 09:55
Looking for some routine code Akira Coders. General 4 17 December 2003 23:51
3D code and/or internet code for Blitz Basic 2.1 EdzUp Retrogaming General Discussion 0 10 February 2002 11:40

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:19.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.14542 seconds with 15 queries