English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 17 August 2022, 22:23   #1
8bitsten
Registered User
 
Join Date: Apr 2022
Location: Brno
Posts: 30
Start with C programming on Amiga article

I just published the article "Start with C programming on Amiga" https://link.medium.com/L4pbtrCGzsb

I don't know why I spend several days writing it... I guess I had some inner urge to write it to keep all information in one place.

Maybe it will help someone. If you find any mistakes, let me know, and I'll be happy to fix them.
8bitsten is offline  
Old 17 August 2022, 23:20   #2
Minuous
Coder/webmaster/gamer
 
Minuous's Avatar
 
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,630
That site seems to have some problems, it shows the text for 3-4 seconds and then the page just blanks. It might be a better idea to upload it somewhere else in a more accessible format.
Minuous is offline  
Old 18 August 2022, 12:42   #3
AlfaRomeo
A1200 040 SAM440EP 667
 
AlfaRomeo's Avatar
 
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
@8bitsten: good work, keep it

@Minuous: I can see the text with no problems.
AlfaRomeo is offline  
Old 18 August 2022, 13:41   #4
Pyromania
Moderator
 
Pyromania's Avatar
 
Join Date: Jan 2002
Location: Chicago, IL
Posts: 3,375
It’s working here too.
Pyromania is offline  
Old 18 August 2022, 14:46   #5
Jami
Bruno
 
Jami's Avatar
 
Join Date: Aug 2020
Location: Nantes / France
Posts: 111
8bitsten : very nice intro to VBCC system !
The diagrams are very intuitive and the information very valuable.


As regards amiga.lib :
Quote:
Linking against amiga.lib is necessary to call any function from shared libraries
With latest VBCC, linking with amiga.lib is not necessary to call function from OS shared libraries.
By default, VBCC uses inline calls defined in .H files and does not use stub functions in amiga.lib.
(Of course, linking with amiga.lib is needed if you define the
_NO_INLINE
preprocessor macro.)

Last edited by Jami; 18 August 2022 at 17:12.
Jami is offline  
Old 18 August 2022, 16:58   #6
DisasterIncarna
Registered User
 
DisasterIncarna's Avatar
 
Join Date: Oct 2021
Location: England
Posts: 1,170
Code:
I build the program I usually immediately test it on the Amiga Forever emulator made by a company called Cloanto.
Cloanto did not make any emulator, they use WinUAE and just bundle stuff together.

Interesting read tho.
DisasterIncarna is offline  
Old 19 August 2022, 10:26   #7
8bitsten
Registered User
 
Join Date: Apr 2022
Location: Brno
Posts: 30
Quote:
Cloanto did not make any emulator, they use WinUAE and just bundle stuff together.
@DisasterIncarna: Thanks for that comment and thanks for reading. I originally have a paragraph regarding WinUAE, but I have removed it - not sure why... I put it back and I add some more facts including a link to the nice 1996 article about UAE with the interview with Bernd Schmidt. You are right - it is fair to give credits to (Win)UAE authors (or at least some of them).

Have a nice day
STeN
8bitsten is offline  
Old 19 August 2022, 19:53   #8
DisasterIncarna
Registered User
 
DisasterIncarna's Avatar
 
Join Date: Oct 2021
Location: England
Posts: 1,170
its a good read, when you said vbcc was cross-compile i was surprised to see your screenshot of the c64, didnt think cross-compile included the c64 at all, thought it was lucky the amiga is an option never mind the good old 8bit.
DisasterIncarna is offline  
Old 19 August 2022, 20:13   #9
8bitsten
Registered User
 
Join Date: Apr 2022
Location: Brno
Posts: 30
Quote:
didnt think cross-compile included the c64 at all
@DisasterIncarna I thought that for 6502 nobody uses C, until I read that some new games (for cartridges mostly I think) are done as a combination of C (I guess that C65 is used as a preferred compiler) and ASM, plus there is new MEGA65 for which VBCC is apparently used and C128 is probably also OK with double the RAM size and CPU speed. I was using VASM and VLINK from VBCC for VIC-20, but with 3kB of RAM the C is a big no-go here.
8bitsten is offline  
Old 20 August 2022, 11:40   #10
8bitsten
Registered User
 
Join Date: Apr 2022
Location: Brno
Posts: 30
Quote:
As regards amiga.lib :
Quote:
Linking against amiga.lib is necessary to call any function from shared libraries
With latest VBCC, linking with amiga.lib is not necessary to call function from OS shared libraries.
By default, VBCC uses inline calls defined in .H files and does not use stub functions in amiga.lib.
(Of course, linking with amiga.lib is needed if you define the _NO_INLINE preprocessor macro.)
@Jami Can you please help me with that a bit? If I remove the
-lamiga
parameter from he
vc
call from the example makefile from the article (see GitHub) the linker reports the following error:


Code:
Digesting symbol information:
hellointuition.o: In "_main":
Error 21: hellointuition.o (CODE+0x1e): Reference to undefined symbol _OpenLibrary.
Error 21: hellointuition.o (CODE+0xd0): Reference to undefined symbol _OpenWindow.
hellointuition.o: In "l16":
Error 21: hellointuition.o (CODE+0x108): Reference to undefined symbol _Wait.
hellointuition.o: In "l21":
Error 21: hellointuition.o (CODE+0x142): Reference to undefined symbol _GetMsg.
hellointuition.o: In "l29":
Error 21: hellointuition.o (CODE+0x16e): Reference to undefined symbol _ReplyMsg.
hellointuition.o: In "l18":
Error 21: hellointuition.o (CODE+0x17e): Reference to undefined symbol _CloseWindow.
hellointuition.o: In "l35":
Error 21: hellointuition.o (CODE+0x1c4): Reference to undefined symbol _CloseLibrary.
I am probably making something wrong?

Versions I am using:
  • vlink v0.17a
  • vbccm68k v0.9i pre
  • vasmm68k_mot v1.9a

Thanks a lot!
Regards,
STeN
8bitsten is offline  
Old 20 August 2022, 22:26   #11
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by 8bitsten View Post
I thought that for 6502 nobody uses C
C was already used quite a lot in the past. Not for the VIC-20, of course, but I remember Lazycow did most games in C with a small assembler core.
Volker's new 6502 backend for vbcc generates really good code, supports many 6502-targets, including special features like bank switching.

Quote:
Originally Posted by 8bitsten View Post
If I remove the
-lamiga
parameter from he
vc
call from the example makefile from the article (see GitHub) the linker reports the following error:
To be able to use assembler inlines for the OS-calls you have to include
<proto/exec.h>
instead of
<clib/exec_protos.h>
. This is true for most (all?) AmigaOS compilers. The headers under
proto
make sure that your compiler's optimal OS-call mechanism is being used.

There are still reasons to link with
amiga.lib
, though. Support functions like
DoMethod
,
CallHook
,
NewList
,
BeginIO
, etc., do not exist in any AmigaOS shared library.
phx is offline  
Old 21 August 2022, 11:34   #12
Jami
Bruno
 
Jami's Avatar
 
Join Date: Aug 2020
Location: Nantes / France
Posts: 111
@8bitsten : of course, I can not provide a better explanation than phx
You can look at my pull request on github : with little modifications, I have been able to compile and run your code successfully without -lamiga linking.
Jami is offline  
Old 26 August 2022, 09:27   #13
8bitsten
Registered User
 
Join Date: Apr 2022
Location: Brno
Posts: 30
@phx and @Jami

Thanks a lot for your comments and pull request. I have learned again something new. I have updated the article accordingly.

This forum is great!
8bitsten 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
Sprite Programming article, would like to add a screenshot or video Photon Coders. Asm / Hardware 7 29 August 2021 00:02
Can you be 'too old' to start to learn programming? markpjd Retrogaming General Discussion 57 18 April 2015 16:10
How to start Amiga Programming? (ASM/C) DBAlex Coders. General 11 08 April 2010 14:25
CU Amiga Article Request Lloydy246 AMR suggestions and feedback 3 09 November 2007 19:00
Amiga article over at bhlegend Bloodwych Amiga scene 7 10 May 2003 15:25

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 14:48.

Top

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