Welcome, Guest. Please login or register.

Author Topic: C++ on Amiga  (Read 14824 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline hayashiTopic starter

  • Jr. Member
  • **
  • Join Date: Jan 2009
  • Posts: 82
    • Show only replies by hayashi
    • http://www.d-linc.co.uk
C++ on Amiga
« on: August 30, 2009, 04:42:29 PM »
Hi,

After looking into programming in E, I'm considering learning C++ with intentions of either programming games for, or porting them to, 68k Amigas. (Someone I may be working on games with is already learning C++/OpenGL, so I could possibly share non-graphical code with/bug him for help)

Does anyone know what sort of material I should be getting, in terms of software and tutorials? I know I'll need to find a C compiler, standard libraries, and the AmigaOS 3 APIs, and some tutorials both on C++ (easy to find, google would probably work for me here) and how to code for the APIs (much harder to find). I'll also need some sort of library for playing back ProTracker modules.

Thanks, Matt
[UK] A1200 with 2GB hard drive and Apollo 1240 040/33MHz/16MB FastRAM | A500+ with trapdoor memory upgrade and A520 modulator and no battery or power supply

Floppy Drive Grim Reaper and DPaint lover
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show only replies by matthey
Re: C++ on Amiga
« Reply #1 on: August 30, 2009, 05:53:57 PM »
You should head over to http://www.utilitybase.com for help. I would recommend staying with C on the Amiga although GCC supports C++ on the Amiga. C++ is rarely used on the Amiga and it's slower. GCC is a major pain to set up on the Amiga. VBCC is a light weight Amiga compiler that is much easier to work with on the Amiga but does not support C++.

VBCC is here...

http://sun.hasenbraten.de/vbcc/

GCC is from the GeekGadgets CD on backtoroots.org (good luck!)...

http://geekgadgets.back2roots.org/

You should have the ROM Kernal Reference Manuals for documentation. The Libraries is the most important. They can be found on the internet. They are not updated past AmigaOS 2.x. You should have the latest SDK for AmigaOS 3.9. It can be found here...

http://aweb.sunsite.dk/download.php

That might get you started. It's not easy developing in C on a low end classic Amiga. There is some ide's available that help like this...

http://devplex.awardspace.biz/

or Murk's (free) may work already...

http://utilitybase.com/forum/index.php?action=vthread&forum=3&topic=1791&page=0
 

Offline SamuraiCrow

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2280
  • Country: us
  • Gender: Male
    • Show only replies by SamuraiCrow
Re: C++ on Amiga
« Reply #2 on: August 30, 2009, 06:26:44 PM »
http://aminet.net/mus/play/ptreplay_ahi.lha is what you want for playing ProTracker modules.  (This archive includes MorphOS as well as AmigaOS 3.x library versions.)

-edit-
http://aminet.net/package/mus/play/ptreplay66 is the original hardware-banging version BTW.
« Last Edit: August 30, 2009, 06:30:19 PM by SamuraiCrow »
 

Offline Caius

  • Sr. Member
  • ****
  • Join Date: Nov 2007
  • Posts: 294
    • Show only replies by Caius
Re: C++ on Amiga
« Reply #3 on: August 30, 2009, 06:34:37 PM »
Quote from: matthey;521499
C++ is rarely used on the Amiga and it's slower.


That's highly debatable. If you simply compile C sources with a C++ compiler there's no difference unless you're using a retarded compiler. C++ function objects can be inlined, while function pointers in C can not. Some sorting algorithms have proven to be many times faster on C++ due to this.

It is true that certain parts of the C++ language are slow, like using virtual functions in a tight loop. It's really a matter of knowing your language, knowing the little 'gotchas'.

In my experience, the main disadvantage with C++ is slower compiling, especially when using templates. But I'm a little tired of reading "use C instead" every time someone mentions C++ on the Amiga.
Theology is just a debate over who to frame for creating reality.
 

Offline bburtonpa

  • Newbie
  • *
  • Join Date: Sep 2006
  • Posts: 20
    • Show only replies by bburtonpa
Re: C++ on Amiga
« Reply #4 on: August 30, 2009, 06:58:59 PM »
I agree with Matthey about staying with C and avoiding C++ on the Amiga. If you use any part of the standard library e. g. streams, vectors, list, etc. expect code bloat.  That's not a problem if you have gigabytes of memory, but on Amiga systems, we're talking megabytes.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: C++ on Amiga
« Reply #5 on: August 30, 2009, 07:17:37 PM »
I use C++ on the 68k miggy all the time. It's fine, provided you know what you are doing. It's also a lot more convenient than C at times.

If you use heavyweight features like templates and RTTI, you'll get bloat, but metaprogramming and reflection aren't free.

On the other hand, you can create code that is effectively "C with classes", that is both compact and fast.
int p; // A
 

Offline Beast96GT

  • Full Member
  • ***
  • Join Date: Aug 2008
  • Posts: 191
    • Show only replies by Beast96GT
Re: C++ on Amiga
« Reply #6 on: August 30, 2009, 07:48:20 PM »
Has anyone mentioned AmiDevCpp?  It's a cross-platform IDE (I can use in on WinXP), that will let you choose your target like 68k, or PPC, etc.  It's pretty good, but I haven't had much time to really spend on it.  

Since I'm a PC graphics guy, I don't know (or can find) anything about graphics programming on the old miggy, which is what I'm trying to do with it.

Here's the link to AmiDevCpp:
http://amidevcpp.amiga-world.de/index.php?HR_LANG=english
 

Offline NovaCoder

Re: C++ on Amiga
« Reply #7 on: August 31, 2009, 12:39:51 AM »
Yep I think the idea that C++ is slower is not accurate these days, it's similar to the idea the C is slower than assembler (modern compilers produce very efficient assembler).

Anyway I've been using C++ on my 1200 for a port of DOTT.

I use StormC V4 which uses the GCC compiler and features an IDE with built in debugger which makes everything a lot easier.  You can still buy StromC V4 new for about $50.

It will take you longer to learn C++ of course, I spent a year learning straight C before I started looking at C++.
Life begins at 100 MIPS!


Nice Ports on AmiNet!
 

Offline SamuraiCrow

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2280
  • Country: us
  • Gender: Male
    • Show only replies by SamuraiCrow
Re: C++ on Amiga
« Reply #8 on: August 31, 2009, 12:42:40 AM »
@Hayashi

What made you decide to give up E?  It's not as powerful as C++ but it's as efficent as some C compilers and a LOT easier than C++.

@Beast96GT

What do you want to know about Amiga graphics programming?  You can find out a lot by getting the Amiga Developer CD version 2.1 and looking at the graphics libraries section of the RKRMs.
« Last Edit: August 31, 2009, 12:45:58 AM by SamuraiCrow »
 

Offline hayashiTopic starter

  • Jr. Member
  • **
  • Join Date: Jan 2009
  • Posts: 82
    • Show only replies by hayashi
    • http://www.d-linc.co.uk
Re: C++ on Amiga
« Reply #9 on: August 31, 2009, 03:27:35 AM »
@SamuraiCrow: A friend and I have had an idea for an RPG, which (if it ever moves out of planning) will likely be made first for Windows (and maybe Linux etc) using C++/OpenGL. If this happens, I really want to make an Amiga version (not a straight port, of course), and using the same language will of course help as we can trade core game code.

I was looking at trying to learn E, but now believe it's useless to spend time learning it when I could be learning a language that would both lend itself well to the above situation and be useful outside the Amiga.
[UK] A1200 with 2GB hard drive and Apollo 1240 040/33MHz/16MB FastRAM | A500+ with trapdoor memory upgrade and A520 modulator and no battery or power supply

Floppy Drive Grim Reaper and DPaint lover
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: C++ on Amiga
« Reply #10 on: August 31, 2009, 03:41:34 AM »
Quote
I was looking at trying to learn E, but now believe it's useless to spend time learning it when I could be learning a language that would both lend itself well to the above situation and be useful outside the Amiga.

To be fair, this is why I've never really bothered with amiga specific programming languages. Whatever I can't implement efficiently in C/C++, there's always assembler :D
int p; // A
 

Offline Beast96GT

  • Full Member
  • ***
  • Join Date: Aug 2008
  • Posts: 191
    • Show only replies by Beast96GT
Re: C++ on Amiga
« Reply #11 on: August 31, 2009, 04:44:27 AM »
Quote from: SamuraiCrow;521544

@Beast96GT

What do you want to know about Amiga graphics programming?  You can find out a lot by getting the Amiga Developer CD version 2.1 and looking at the graphics libraries section of the RKRMs.


On the PC I used BitBlt (Win32 C++) to write to a 32-bit back buffer that's swapped to the front buffer for a GDI game I wrote.  Now I work with OpenGL and DirectX that provide higher level access to graphics programming (I'm a console game developer), though still through C++.

I was kid when I had my Amiga and know nothing of the architecture.  I'm a very experienced C++ programmer, but I simply don't have the time to try and figure everything out from scratch with regards to the Amiga.  Maybe I can make it a process, but resources are what I need--else I get frustrated and take large breaks.

What can you tell me about this Ami Dev CD, and what are the RKRMs?  Thanks.
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show only replies by matthey
Re: C++ on Amiga
« Reply #12 on: August 31, 2009, 06:49:59 AM »
@Beast96GT

RKRM stands for ROM Kernal Reference Manual. Libraries and Devices are the most important ones. Look here for more...

http://gega.homelinux.net/AmigaDevDocs/

Also get the SDK for 3.9 from the AWeb site I listed above and look at the autodocs.

Here is a guide to setting up an Amiga C programming environment...

http://code.google.com/p/guidetoamigacompatibleprogramming/

Warp3D developer archive...

http://aminet.net/dev/misc/Warp3DDev-4.2a.lha

StormMesa developer archive...

http://aminet.net/util/libs/StormMesa_Dev.lha

Info on developing in 3D on Amiga...

http://vague.lorraine-design.com/the_vague_1.html
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show only replies by matthey
Re: C++ on Amiga
« Reply #13 on: August 31, 2009, 07:13:46 AM »
Quote from: NovaCoder;521543
Yep I think the idea that C++ is slower is not accurate these days, it's similar to the idea the C is slower than assembler (modern compilers produce very efficient assembler).


C IS slower than assembler. GCC's code optimization is a joke. Why is ffmpeg for the 68060 twice as fast with a few assembler routines compared to all C routines? I don't know much about C++ compared to C but I have seen too much assembly output from C programs to believe C is as fast as assembler. Plus I can beat it 95% of the time with assembler.
 

Offline NovaCoder

Re: C++ on Amiga
« Reply #14 on: August 31, 2009, 07:23:02 AM »
Quote from: matthey;521559
C IS slower than assembler. GCC's code optimization is a joke. Why is ffmpeg for the 68060 twice as fast with a few assembler routines compared to all C routines? I don't know much about C++ compared to C but I have seen too much assembly output from C programs to believe C is as fast as assembler. Plus I can beat it 95% of the time with assembler.



Well obviously over the years C/C++ compilers have improved massively and these days you'll improve performance more from looking at what the code is doing from a high-level rather than trying to hand-optimize algorithms (the quickest code is code you don't actually execute).  

I remember reading an assembler 'tuning' article which had an exercise to improve some compiler generated assembler by-hand.  When I went to make the change myself, I found that my newer version of the compiler had already produced exactly the same assembler as the article suggested ;)

I wasn't talking specifically about GCC, I was talking about modern compilers C++ in general.
« Last Edit: September 01, 2009, 12:40:31 AM by NovaCoder »
Life begins at 100 MIPS!


Nice Ports on AmiNet!