Welcome, Guest. Please login or register.

Author Topic: Amiga Basic  (Read 14672 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Re: Amiga Basic
« Reply #14 from previous page: January 10, 2009, 07:55:01 PM »
Quote

amiga_3k wrote:
@bloodline:

I'm ashamed to admit that I'm using a WinXP machine at the moment  :oops:. Any tip on what freeware c/c++ version to use on WinXP? I don't want to go through the hassle of installing VisualStudio.


I used to use MinGW and Bloodshed's Dev C++ on WinXP... it's a great IDE system and really fun to use.

If you use a Mac... then XCode is great... GDB makes life so simple...

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Re: Amiga Basic
« Reply #16 on: January 10, 2009, 09:19:55 PM »
Quote

amiga_3k wrote:
@ Bloodline:

Thanks a lot! I've just installed it and toying around with it. Has been a good 4 years since I last used C++ so I'm currently studying 'Hello World' again :-D.

I'll first try to get back into the basics of C++ again, then I'll try and add eyecandy step by step.



Cool, DevC++ uses gcc, so anything you write (and eventually with SDL), will be compilable (with little or no changes) on MacOSX and Linux as well... Oh and some old system called an armooger or something ;-)

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Re: Amiga Basic
« Reply #17 on: January 10, 2009, 09:25:41 PM »
Quote

motorollin wrote:
Quote
bloodline wrote:
char* just means that the function wants a pointer to the string rather than passing the whole string (which would be slow)... You proabably should have  referenced the string :-)

I really have no idea what any of that means... I'll just stick to basic ;-) I like programming because I enjoy thinking about the procedure and logic of how the application should work. What I don't like is the intricacies of the language getting in the way.

--
moto


Hehehe :-)

well, for those interested:

Code: [Select]

int  A = 5;   //means that the integer variable A = 5
int* B = &A;  //means that variable B, now is a pointer to the integer variable A


All types with a * after them are memory addresses.

The "&" operator means, "The Address of"

If you pass a variable to a function, you will notice in the C code that the variable is actually copied to a new variable for use in the function... if you pass a pointer of the variable to the function instead, then the function will act upon the original variable rather than a copy of it!

If the function requires char* and your string is in an array (it is important to remember that a string is an array of characters)... then you need to reference your array with a preceding "&" operator.

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Re: Amiga Basic
« Reply #18 on: January 10, 2009, 09:48:10 PM »
Quote

amiga_3k wrote:
@bloodline:

I think portability is a good thing. Especially with niches like the AmigaOS.

Don't expect top of the line action games. I'll first have a go at porting my JavaScript versions of Mastermind and 'HotNumber DeLuxe', both being rather old-school 2D games. Don't expect results very soon as I'm about to change homes (and computers, once again, next system probably an EeeBox).



Well, JavaScript is so close to C syntax it really shouldn't take long to get into... You are seriosuly going to love SDL, anyone who has spent much time blitting gfx around on the Amiga, will have no problems with SDL!

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Re: Amiga Basic
« Reply #19 on: January 11, 2009, 01:39:47 PM »
Quote

zylesea wrote:
@ bloodline

As an occasional programmer I again and again get into messes and troubles (at least when a ointer refers to a pointer and such complicated things) with pointers and references. I guess I know the logic behind it, but w/o regular practise it is often hard. But still from those three languages (C++, Matlab and Holywood) I seriously looked into I like it somehow most.

Anyway, I wanted to take the opportunity to advertise for Hollywood: Simple, but also powerful and write once, compile for MorphOS, AOS3.x, AOS4.x, Windows, OS X.


Honestly Pointers aren't really as bad as people make out... just think of a variable as a variable, just the same as in BASIC... then a pointer is the actual memory address of that variable and its datatype.

With a variable in any programming language, it has three properties... Its location in the computer (the address), its size (the datatype) and it's value (the data stored there).

A pointer is the first two properties, a variable is the second two properties.

when you define:
Code: [Select]


int A=5;



You know two things about it, the datatype (size), which is an integer (on Amiga that is 32bits) and you know its value (5).

To get the address you need to put an "&" in front of the variable... now you need to store that address, this is where the pointer comes in... since your variable is an interger, your pointer needs to know the size that it's pointing to thus:

Code: [Select]


int* B = A;



Has now stored the address and size of variable A into B.

Remember:
int is an integer variable.
int* is a pointer to an integer variable (it doesn't actually have to point to a variable, but that is another topic :-) ).

Now we can do thing a bit clever using the "*" operator... if you put the * in front of a pointer then all operations happen to the location pointed to by the pointer, thus:

Code: [Select]


 *B=6;
  A=6;



both of the above assignments do the same thing. Both assign the value 6 to the variable A. But really you can ignore pointers to begin with... they are only really needed for doing advanced stuff that you can't do with BASIC.


The big advantage of pointers is that they allow a function to act on the original variable rather than on of copy of the variable... thus the function doesn't need to return any value, and no data needs to be copied, making the whole process much faster. I have no idea how I could survive without pointers now :-D (I'm not looking forward to trying C#)...
But if you come from BASIC, function/procedure support is often very limited and you can just write your C code all inline (ie in the main function).

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Re: Amiga Basic
« Reply #20 on: January 11, 2009, 07:21:25 PM »
@zylesea

The explanation wasn't just for you :-)

If you find a nasty function that is complex yo use... just wrap it up in a nice friendly class, and document it well :-D