Welcome, Guest. Please login or register.

Author Topic: Basic Amiga-API coding  (Read 11880 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Basic Amiga-API coding
« on: July 31, 2006, 03:56:49 PM »
From time to time there pops up a thread where people complain that learning the Amiga-API would be so hard and that no good resources would be available.

Now, there is the the Amiga-C-Manual, but thats quite outdated, and there is the Yahoo-maillist amiga_bcg but here you will find all sorts of skill-levels and question mixed up.

And then you have the occasional tutorial in print-magazines, but I allways found they were trying to do to much at a time overwhelming the reader, and making it hard to figure out where the tutorial ends, and where the pseudo-functionallity starts.

I therefore decided *fanzy fanfare* to do my own !!

It's very basic
It's targeted a users with basic C-skills
It's examples won't try to be usefull in any kind
It's a one proble at a time approach
It expects the reader to look up further options and arguments himself

Preparing yourself for the ride:

http://home.arcor.de/dietmar_eilert/site/cubic/download.htm

Download atleast the Demo-versoin (should suffice), buying the full package is offcourse an even better idea (and no I'm not getting paid for writing this  :pissed: ), you may also wish to download the C/C++ Add-On Package, unless you know how to setup and use a bare compiler&documentation.

After installing, set Compiler to gcc (press blue box in toolbar), and target to amigaos3 (gcc 2.95.3). Useing other compilers and targets should be possible, but for the moment we should keep the possible problems to a minimum.
Now create a new project (the tilted white paper)and make it an Amiga project. After doing that open the created file main.c and paste the tutorial-source into it (yes, I'm sure there are more elegant ways of doing it, but for the moment this will do).

You should now be able to call "make all" (the 4 connected blue boxes) and "run" (white on green arrow).

O.k. here are the 1st chapters:

Intuition1
Intuition2

Once you got them working you should right-click some of the coloured keyword, selcect "look up word" (or something similar) to see other related functions, structures and tags.
I will not explain all of them, only those that aren't self-explaining and/or important.

As noted above these were written for OS3.x, no change is needed to adapt them for MorphOS-native (and same should go for AROS), adapting them to OS4-native would either need a pre-processor statement switching of the use of interfaces, or actully adding the code for interfaces. As none of this changes the way the API and it's functions work, this isn't neccasary until you have grown out of tutorials.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #1 on: July 31, 2006, 04:29:56 PM »
Sure, consider them freeware in the most orginal meaning of the word.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #2 on: July 31, 2006, 04:59:30 PM »
@Hans
AFAIK there is a way to switch back to the normal way to access the API, which would require only 1 #ifdef at the start.

Everything else would make things much to complicted for something that is intended to be simple.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #3 on: July 31, 2006, 05:27:19 PM »
@slash

1) I know that, but the point is keep it as simple as possible, not to teach finer details of C.

2) Since the 1st use of a that variable is assigning it a value there is no point in presetting it to one. It also makes it harder to keep track of those that need to be presetted, and doing it to every pointer would also bloat of both source and code.

3) pretty much the same as 2)

4) never heard of that one (and have no idea what it should be good for)
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #4 on: July 31, 2006, 05:54:28 PM »
@_yak_

Maybe I should at some point in time really start reading the compiler-docs further than what I need at that moment  :rtfm:
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #5 on: July 31, 2006, 07:19:38 PM »
Added 3rd chapter (yes I'm THAT bored)

Basic reacting on user-input, menus are next and watching more than 1 window will be chapter 5.

intuition3

After that I will move to the topic of graphics, simple drawing, blitting, chunky-images and window-refresh.

Would like to see some comments wether I'm  moving to fast or too slow.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #6 on: August 01, 2006, 05:04:19 PM »
@Karlos

No point for a flamefest, MUI rocks everything else sucks ....


I might at some later time do a simple GadTools-example (as GadTools is a s simple as it gets), and later on something bout MUI, since MUI is the only GUI that I use myself.

Nothing that would stop any given Triton-troll to to an Triton-t5utorial.

@AJCopland

Fixed that.

@Dagon

Does that mean I have to dig out my Dev-CD, search for that example, and on top of it find a way to make it even worse ???

Puih, thats 3 wishes at a time, and a chocolate-egg wound solve this one....
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #7 on: August 01, 2006, 06:16:36 PM »
Added chapter 4, basic menus.

intuition4
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #8 on: August 01, 2006, 08:50:42 PM »
 :oops:  :oops:  :oops:  :oops:  :oops:

Fixed.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #9 on: August 02, 2006, 04:14:37 AM »
@gklka

Either open GadTools by hand, or switch to "libnix" in the compiler-options (linker options).
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #10 on: August 02, 2006, 04:19:33 AM »
@tangletown

Again, GadTools seems to not been opened, dunno whether a compiler-switch will help for AROS.

The warnings can be ignored atm, but I assume it is the last "0" in each of the lines, replacing them with "NULL" might work.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #11 on: August 06, 2006, 10:36:17 AM »
Intuition5 getting input from multiple windows has just beed uploaded.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #12 on: August 08, 2006, 03:28:59 PM »
@r-tea

Hooks for handling (input?)events ??

There is the notify-system for normal input, and MUIC_Window has a function MUIM_Window_AddEventHandler, which will call any given object (needs to be a costum-class, but one can't do much in MUI without atleast one of those) whenever an event happens (and matches the pattern you supplied).

Not gonna do a full example on this one, but drop me a mail and I send you some code-snippets from SteamDraw covering this.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline KronosTopic starter

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show all replies
    • http://www.SteamDraw.de
Re: Basic Amiga-API coding
« Reply #13 on: August 08, 2006, 05:23:38 PM »
Intuition5 has now been removed....

Thats what ones gets trying to do something from memory, years after learning it by trial&error...

Next up GFX, and I'll try to really stay with the basics this time  :oops:
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else