English Amiga Board


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

 
 
Thread Tools
Old 05 September 2015, 18:53   #21
desiv
Registered User
 
desiv's Avatar
 
Join Date: Oct 2009
Location: Salem, OR
Posts: 1,770
Quote:
Originally Posted by Leffmann View Post
Ok I see you're actually calling GCC.
Well, I don't totally understand what is calling what myself.. ;-)

But that worked!!!
(Much smaller Amiga executable too.. The original was 15k, the 1.3 version is 3.8k. ;-)

Thanx!

desiv
desiv is offline  
Old 05 September 2015, 23:46   #22
ReadOnlyCat
Code Kitten
 
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
Quote:
Originally Posted by desiv View Post
Well, I don't totally understand what is calling what myself.. ;-)

But that worked!!!
(Much smaller Amiga executable too.. The original was 15k, the 1.3 version is 3.8k. ;-)

desiv
When you call
m68k-amigaos-gcc
that's gcc. However the
vb<something>
utilities are part of the vbcc compiler (available at http://sun.hasenbraten.de/vbcc/).
ReadOnlyCat is offline  
Old 08 September 2015, 04:07   #23
desiv
Registered User
 
desiv's Avatar
 
Join Date: Oct 2009
Location: Salem, OR
Posts: 1,770
Moving forward...
I just did the basic open window example from "Amiga C for Beginners" (which I own again, and was the book I had back in the day.
I was able to compile it and get a window to pop up!!

I did have 1 line it didn't like:
if ((Window = OpenWindow(&NewWindow)) == NULL)
exit (FALSE);

I had to change it to:
if ((Window = (struct Window *) OpenWindow(&NewWindow)) == NULL)
exit (FALSE);

Even tho I did have:
struct Window *Window;
..near the top..

vbcc was giving me a:
> if ((Window = OpenWindow(&NewWindow)) == NULL)
error 39 in line 43 of "window.c": invalid types for assignment

Luckily, a quick google found the change...

So.. Making progress, but of course, looks like there will be differences (as expected).

I used DICE back in the day, and the book seems to expect you to use Aztec C (or Lattice).

Thanx again...

desiv
desiv is offline  
Old 08 September 2015, 05:22   #24
ReadOnlyCat
Code Kitten
 
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
Quote:
Originally Posted by desiv View Post
Moving forward...
I just did the basic open window example from "Amiga C for Beginners" (which I own again, and was the book I had back in the day.
I was able to compile it and get a window to pop up!!
Congratulations!

Quote:
Originally Posted by desiv View Post
I did have 1 line it didn't like:
if ((Window = OpenWindow(&NewWindow)) == NULL)
exit (FALSE);

I had to change it to:
if ((Window = (struct Window *) OpenWindow(&NewWindow)) == NULL)
exit (FALSE);

Even tho I did have:
struct Window *Window;
..near the top..

vbcc was giving me a:
> if ((Window = OpenWindow(&NewWindow)) == NULL)
error 39 in line 43 of "window.c": invalid types for assignment

Luckily, a quick google found the change...

desiv
It's probably because the function
OpenWindow
is not declared as returning a
struct Window*
but rather a
void *
. Which headers do you include?

It is a bit weird that you had to cast that return value.

This said, all compilers should behave the same with this code since it is 100% standard from what I can read.
ReadOnlyCat is offline  
Old 08 September 2015, 06:01   #25
desiv
Registered User
 
desiv's Avatar
 
Join Date: Oct 2009
Location: Salem, OR
Posts: 1,770
Quote:
Originally Posted by ReadOnlyCat View Post
This said, all compilers should behave the same with this code since it is 100% standard from what I can read.
You're right.
I had a typo in my extern struct.. (And I even had my glasses on.. Oh well. )

Fixed that and removed the specific struct and it works..
It does warn me when I compile:
me@mymachine ~/Retro/Amiga/DEV $ vc -o window window.c
> if ((Window = OpenWindow(&NewWindow)) == NULL)
warning 85 in line 43 of "window.c": assignment of different pointers

But it compiles and runs fine...
(I'll check for more typos later.. ;-)

desiv
desiv is offline  
Old 08 September 2015, 10:08   #26
nobody
Registered User
 
nobody's Avatar
 
Join Date: Dec 2013
Location: GR
Age: 47
Posts: 1,416
A simple countdown timer i did.
main() or other function is calling timer and pass an argument like timer(500);


int timer (int time)
{
if (time>=0)
{
printf("time %d\n",time);
time--;
Delay(50L); /*delay 50 frames (1sec) or 60L for NTSC*/
}
else
gameover(); /*another function for game over sequence*/
}
nobody is offline  
Old 14 June 2016, 11:13   #27
Zetr0
Ya' like it Retr0?
 
Zetr0's Avatar
 
Join Date: Jul 2005
Location: United Kingdom
Age: 49
Posts: 9,768
A big thanks for ReadOnlyCat putting me onto these threads.

For those that want to learn a bit more C/C++ there is w3schools.net as well as google - I would also humbly suggest having a look at nehe (http://nehe.gamedev.net/) to take their knowledge to the next level.

For Windows on the Amiga I would humbly suggest people look at GadTools - its a great program and gives you a WYSIWYG environment to create Screen / Window(s) and then provides the code / handlers you need - http://aminet.net/package/dev/misc/gt34_1


I am currently looking for a dev environment (playing with Hannibal's Dev Tool Chain) - as I want to try and port games / applications over to the Amiga (SDL etc) - its been well over 10 years since I hit C/C++ on the Amiga in any serious way - (used to use DICE - lots of Make File Mayhem!


I hope that helps =)
Zetr0 is offline  
Old 14 June 2016, 13:09   #28
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,347
Quote:
Originally Posted by Zetr0 View Post
For those that want to learn a bit more C/C++ there is w3schools.net as well as google
I was curious as to whether W3Schools had started doing C code as well as web stuff, and also to see if it was the same site as w3schools.com, so I went to w3schools.net...

Erm, well let's just say it's less about computer programming and more about human programming... Seems to be some sort of religious nut website with a look of '90s Geocities HTML about it. An interesting page I'm sure if religion or '90s web design are your bag, but not a whole lot of C
Daedalus is online now  
Old 15 June 2016, 08:07   #29
Zetr0
Ya' like it Retr0?
 
Zetr0's Avatar
 
Join Date: Jul 2005
Location: United Kingdom
Age: 49
Posts: 9,768
@Daedalus

Its been a few years since I was on there - I remember using it a lot for my HND - which would of been errr... 9 ish years ago?

And that was not the correct link LMFAO! - http://www.w3schools.com/ - there you go!


Interestingly there is no "C/C++" on there any more - just web based languages =(
Zetr0 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
A new Learning Demo for Amiga OCS and beyond. Toni Galvez Amiga scene 46 01 March 2015 15:20
Help with learning more about my A2000 and bring it up to speed? kurtis New to Emulation or Amiga scene 3 04 December 2014 18:35
I need help with my intro... I´m learning... Skillion76 Coders. General 10 27 September 2014 17:36
Suggestions for learning pmc Coders. Tutorials 248 20 October 2010 21:42
Learning assembler bLAZER Coders. General 1 12 May 2007 05:00

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 09:57.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08749 seconds with 13 queries