GEM programming - where to start?

C and PASCAL (or any other high-level languages) in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
MaLICiouS
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 127
Joined: Tue Jun 05, 2007 4:01 pm
Location: Sweden
Contact:

GEM programming - where to start?

Postby MaLICiouS » Mon Jun 11, 2007 12:13 pm

Hi folks!
I've just built a gcc 3.3.3 cross compiler using the instructions at http://perso.orange.fr/patrice.mandin/v3/en/howto-cross333.html.
Now I wonder where to start learning how to write programs for the GEM interface. I'm looking for example code in C and header files for GEM. Any ideas where to look?

EDIT: Oh, I intend to run my code on a 1040STE.

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2157
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

c code

Postby charles » Tue Jun 12, 2007 12:08 am

well i can help , but we will have to "beaver" together....
i've been wanting to learn a little about 'c'

i own a bunch of stuff , manuals, books, programs, i wish to know basics for 'c' how to form loop , how procedures function,variables ,etc,etc,etc
just the basics ...like arrays , for next loops... what the heck does" { " and "}" stand for ????

gem is really the same as any computer , just the address locations are differnt , and gem has limits because developed before some functions calls were implimented....which is why i programin basic .

ok charles
in fact i am looking at a book momentarilly called "programmers guide to gem" by sybex...balma /fitler..i am certain to help!
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
Zorro 2
Administrator
Administrator
Posts: 2192
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Re: GEM programming - where to start?

Postby Zorro 2 » Tue Jun 12, 2007 8:37 am

MaLICiouS wrote:Now I wonder where to start learning how to write programs for the GEM interface. I'm looking for example code in C and header files for GEM. Any ideas where to look?

I think you can find some interesting sources on Wiki or on this board. Maybe mister Nyh can give you some help to begin.
Last edited by Zorro 2 on Tue Jun 12, 2007 10:04 am, edited 1 time in total.
Member of NoExtra Team

User avatar
daeghnao
Captain Atari
Captain Atari
Posts: 479
Joined: Wed Oct 27, 2004 12:41 pm
Location: York, UK
Contact:

Re: c code

Postby daeghnao » Tue Jun 12, 2007 9:56 am

charles wrote:well i can help , but we will have to "beaver" together....
i've been wanting to learn a little about 'c'


First Google hit I get for C tutorial: http://einstein.drexel.edu/courses/CompPhys/General/C_basics/

Read it, try it, see how it goes.

charles wrote:i own a bunch of stuff , manuals, books, programs, i wish to know basics for 'c' how to form loop ,


C has "for", "while" and "do" structures for loops, but they'll look different to the way they look in BASIC. Particularly "for" which is much more general-purpose.

charles wrote:how procedures function,variables ,etc,etc,etc
just the basics ...like arrays , for next loops... what the heck does" { " and "}" stand for ????


Procedures are just functions that don't return a return value when they exit. C doesn't have a particular keyword that introduces a function, it's just a certain arrangement of types and names and ()s and {}s.

Variables are always declared before use, and you have to say what type they have. It's also a good idea to give them an initial value.

Arrays are intricately tied up with pointers. Don't try to do anything complex with arrays without thoroughly investigating pointers first.

The 'for' construct doesn't just do counting the way it does in BASIC, and it doesn't use a 'next' keyword.

The symbols { and } delineate a block. This is used as the body of a function definition and the body of an initialiser expression for structs and arrays. You can also use a sequence of statements in a block any place you could use a single statement, especially useful for "if", "for", "while", "switch" and so on.

PM if you're getting even more confused...

User avatar
MaLICiouS
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 127
Joined: Tue Jun 05, 2007 4:01 pm
Location: Sweden
Contact:

Re: GEM programming - where to start?

Postby MaLICiouS » Tue Jun 12, 2007 5:38 pm

Zorro 2 wrote:I think you can find some interesting sources on Wiki or on this board. Maybe mister Nyh can give you some help to begin.

I did find some interesting things on the wiki. Thanks! However, it would be a little tricky trying to code without the GEM headers. Googling doesn't give me anything. Simple programs using printf() and the like works like a charm. I'm thinking about porting the lszrz ZModem transfer software. Of course, a GEM GUI would be nice, but I'll manage without it.

User avatar
MaLICiouS
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 127
Joined: Tue Jun 05, 2007 4:01 pm
Location: Sweden
Contact:

Postby MaLICiouS » Tue Jun 12, 2007 6:32 pm

Hmm... found some header files at the Reservoir Gods site... trying them...

User avatar
Zorro 2
Administrator
Administrator
Posts: 2192
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Postby Zorro 2 » Wed Jun 13, 2007 9:31 am

If you are intresting, I can send you by mail a lot of source code in C.
Member of NoExtra Team

User avatar
MaLICiouS
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 127
Joined: Tue Jun 05, 2007 4:01 pm
Location: Sweden
Contact:

Postby MaLICiouS » Wed Jun 13, 2007 11:39 am

Zorro 2 wrote:If you are intresting, I can send you by mail a lot of source code in C.

Sure, why not? Wouldn't hurt. Tried the Pure C headers with my gcc cross-compiler. I eventually saw the shell prompt after about 40000 compiler errors :P I'll have a look at the Pure C compiler, though.

User avatar
Desty
Atari God
Atari God
Posts: 1955
Joined: Thu Apr 01, 2004 2:36 pm
Location: 53 21N 6 18W
Contact:

Re: GEM programming - where to start?

Postby Desty » Wed Jun 13, 2007 1:17 pm

MaLICiouS wrote:Hi folks!
I've just built a gcc 3.3.3 cross compiler using the instructions at http://perso.orange.fr/patrice.mandin/v3/en/howto-cross333.html.
Now I wonder where to start learning how to write programs for the GEM interface. I'm looking for example code in C and header files for GEM. Any ideas where to look?


Howya... I followed the same instructions (which took about a day of compiling and hassle... ouch). I've been reading the C-manship Complete (heh... C-man) book online by Clayton Walnum, but I haven't tried compiling any GEM stuff yet. Seems like a decent book tho :)
tá'n poc ar buile!

User avatar
MaLICiouS
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 127
Joined: Tue Jun 05, 2007 4:01 pm
Location: Sweden
Contact:

Re: GEM programming - where to start?

Postby MaLICiouS » Wed Jun 13, 2007 2:36 pm

Desty wrote:Howya... I followed the same instructions (which took about a day of compiling and hassle... ouch). I've been reading the C-manship Complete (heh... C-man) book online by Clayton Walnum, but I haven't tried compiling any GEM stuff yet. Seems like a decent book tho :)

Thanks a lot for the link! I'll have to mass-download it and convert it to ASCII, though (makes reading alot easier for me). Seems like a decent book, indeed!

User avatar
Desty
Atari God
Atari God
Posts: 1955
Joined: Thu Apr 01, 2004 2:36 pm
Location: 53 21N 6 18W
Contact:

Re: GEM programming - where to start?

Postby Desty » Wed Jun 13, 2007 10:59 pm

MaLICiouS wrote:Thanks a lot for the link! I'll have to mass-download it and convert it to ASCII, though (makes reading alot easier for me). Seems like a decent book, indeed!

One thing I forgot to mention - the word spacing is really dodgy for most of the book it seems, after the first chapter or so... it's readable but a bit difficult. Not sure how it happened, maybe an OCR thing...
tá'n poc ar buile!

User avatar
thothy
Hatari Developer
Hatari Developer
Posts: 420
Joined: Fri Jul 25, 2003 9:36 am
Location: Germany
Contact:

Postby thothy » Thu Jun 14, 2007 8:54 am

MaLICiouS wrote:Tried the Pure C headers with my gcc cross-compiler. I eventually saw the shell prompt after about 40000 compiler errors :P I'll have a look at the Pure C compiler, though.


For a start, I would recommend to use Pure-C itself (with the supplied Pure-C GEM header files - called aes.h and vdi.h if I remember clearly).
But if you want to use GCC (or a GCC cross-compiler) for compiling GEM programs, you have to use a GEM library that has been created for GCC. Using a Pure-C GEM library for GCC will not work!
You can get most GCC libraries from the Sparemint site (sparemint.atari.org) - for example you can get the GEMLib for cross compiling from http://sparemint.atariforge.net/sparemi ... -mint.html

User avatar
MaLICiouS
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 127
Joined: Tue Jun 05, 2007 4:01 pm
Location: Sweden
Contact:

Postby MaLICiouS » Sat Jul 21, 2007 9:26 am

thothy wrote:For a start, I would recommend to use Pure-C itself (with the supplied Pure-C GEM header files - called aes.h and vdi.h if I remember clearly).
But if you want to use GCC (or a GCC cross-compiler) for compiling GEM programs, you have to use a GEM library that has been created for GCC. Using a Pure-C GEM library for GCC will not work!
You can get most GCC libraries from the Sparemint site (sparemint.atari.org) - for example you can get the GEMLib for cross compiling from http://sparemint.atariforge.net/sparemi ... -mint.html

Thanks a lot! I'll check it out! :)
4MB 1040STe
4MB Mega/STE with FreeMiNT/XaAESm 40MB SCSI HD, 1.44M floppy
Recased Falcon030 with CT2, 64MB TT-RAM, 4MB ST-RAM, FreeMiNT/XaAES, EtherNEC and 40GB HDD

whyatmyage
Atari User
Atari User
Posts: 34
Joined: Wed Jan 16, 2008 9:59 am
Location: Gloucestershire, UK

Re: GEM programming - where to start?

Postby whyatmyage » Tue Jan 22, 2008 9:24 am

A bit off topic here but, which package should I use to write C progs for my old 1040STF?? Better still which are freely available as download! I hear names as Hisoft and Lattice. Gimme a clue.

User avatar
Desty
Atari God
Atari God
Posts: 1955
Joined: Thu Apr 01, 2004 2:36 pm
Location: 53 21N 6 18W
Contact:

Re: GEM programming - where to start?

Postby Desty » Tue Jan 22, 2008 10:55 am

A lot of guys go for Pure C, although I couldn't figure it out (i.e. I loaded the Pure C graphical shell, spent about 5 minutes going "uh... where's the compiler? how do I start a new file?" and gave up on it). I got gcc to work to some extent but didn't do too much with it (and it created 90k executables for "Hello world" in my config). Sozobon 2 seems to work okay once you find a decent command-shell for it - I'm using AShell. It's not 100% compatible with modern C (annoyingly for me, there's no #elif preprocessor directive) but it seems to do the job otherwise.

joska
Hardware Guru
Hardware Guru
Posts: 3793
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: GEM programming - where to start?

Postby joska » Tue Jan 22, 2008 10:59 am

whyatmyage wrote:A bit off topic here but, which package should I use to write C progs for my old 1040STF?? Better still which are freely available as download! I hear names as Hisoft and Lattice. Gimme a clue.


Do you want to do the development on the ST as well? Then PureC would be your best choice, it's very fast at compiling and will actually run on a 1 meg ST. Don't attempt to do any sort of C development without a harddisk though ;-)

If you use an emulator or virtual machine (like Aranym) for development I'd still recommend Pure C. Lattice C is also quite good but has a terrible editor (IMHO ofcourse). Although not strictly "free", you can download these compilers at the usual places.

For cross compiling you need GCC. I don't have any experience with cross compiling so you'll need to look elsewhere for more help/info on this.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: GEM programming - where to start?

Postby Nyh » Tue Jan 22, 2008 12:03 pm

whyatmyage wrote:A bit off topic here but, which package should I use to write C progs for my old 1040STF?? Better still which are freely available as download! I hear names as Hisoft and Lattice. Gimme a clue.

IMHO Pure C is the best C compiler available for the ST. The compiled code is quite good. It has got a nice shell and a superb debugger. The Pure C help file is excellent but I have got an German version. I am not sure whether an English version exists.

Hans Wessels

joska
Hardware Guru
Hardware Guru
Posts: 3793
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: GEM programming - where to start?

Postby joska » Tue Jan 22, 2008 2:41 pm

Nyh wrote:IMHO Pure C is the best C compiler available for the ST. The compiled code is quite good. It has got a nice shell and a superb debugger. The Pure C help file is excellent but I have got an German version. I am not sure whether an English version exists.


There is, but not by ASH. Dan Wilga translated the help file(s) years ago. The application itself has always had an English GUI, atleast mine has.

I totally agree with you about PureC though, I have been using Lattice C and GCC from time to time but prefer Pure C. Good, solid, simple development environment, fast compiling and quite good code. The standard libs are not that good though, there's some issues with the standard AES and VDI bindings.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

joska
Hardware Guru
Hardware Guru
Posts: 3793
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: GEM programming - where to start?

Postby joska » Tue Jan 22, 2008 2:47 pm

Desty wrote:A lot of guys go for Pure C, although I couldn't figure it out (i.e. I loaded the Pure C graphical shell, spent about 5 minutes going "uh... where's the compiler? how do I start a new file?"


Did you check the menu called "Compile"? ;)
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: GEM programming - where to start?

Postby Nyh » Tue Jan 22, 2008 4:13 pm

joska wrote:
Desty wrote:A lot of guys go for Pure C, although I couldn't figure it out (i.e. I loaded the Pure C graphical shell, spent about 5 minutes going "uh... where's the compiler? how do I start a new file?"


Did you check the menu called "Compile"? ;)

A very quick start to Pure C:

0 start PC.PRG
1 in menu PROJECT select "SELECT..."
2 use file selector to select "DEFAULT.PRJ"
3 in menu FILE select "OPEN .C"
4 enter HELLO.C inf file selector to create HELLO.C
5 enter in window:

Code: Select all

#include <stdio.h>

int main(void)
{
  printf("Hello World!");
  return 0;
}

6 in menu PROJECT select "RUN DEFAULT.PRJ"
(Advanced coders only)
7 edit DEFAULT.PRJ to create your own project using multiple files. Example:

Code: Select all

;*************************************************************************
;*
;*      Added by Insh_Allah for use with UNARJxxx             
;*
;*      TC 2.03 ATARI ST Version project file
;*
;*      5 Mai 1991                                       
;*
;*************************************************************************

;>>>>>>> DEFAULT.PRJ for use with single module programs <<<<<<<<

unarj.ttp                 ; name of executable program is topmost window
.C[-K -Y -I..\include -DGERMAN=0 -DARJ_CODE=0 -DUNARJ_JR=0 -DFINALOUTPUT=1]
.L[-S=16384]              ; and stacksize = 16 Kbyte!
.S[-S -Y -DUNARJ_FULL=1]

=

..\lib\ia_start.s           ; own headerfile because of evt_handler

parsing.c   (main.h, unarj_pr.h, args.h, dev.h, revision.h, _string_.h)
specials.c  (main.h, unarj_pr.h, args.h, dev.h, revision.h, _string_.h)
main.c         (main.h, unarj_pr.h, args.h, dev.h, revision.h, _string_.h)
unarj.c      (main.h, dev.h, unarj_pr.h, _string_.h)
ira.s       (decode.mac, decode.inc)
unix_str.s
read_buf.c  (main.h, dev.h, unarj_pr.h, _string_.h)
environ.c   (args.h, dev.h, main.h, unarj_pr.h, _string_.h)
statics1.c  (main.h, dev.h, unarj_pr.h, args.h, revision.h, _string_.h)
statics2.c  (main.h, dev.h, unarj_pr.h, args.h, revision.h, _string_.h)


; own FAST string library (Cstrlib partial replacement):
..\lib\cstrlib\fast\atari\fast_str.prj        ; project called from a project file
; own additional library:
..\lib\addition\addition.prj          ; for mkdir() & exist()
..\lib\cstrlib\UNIXSTR.prj             ; memcpy and all other poo...
..\lib\cstrlib\_c2type.c
 
PCTOSLIB.LIB       ; TOS library
PCSTDLIB.LIB       ; standard library
; pcfltlib.lib
PCEXTLIB.LIB       ; extended library
; PCLNALIB.LIB       ; LINE-A library: needed for font-swapping stuff

decodest.s  (decode.mac, decode.inc)   ; assembly stuff

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

8 create real big projects now

Hans Wessels

User avatar
Desty
Atari God
Atari God
Posts: 1955
Joined: Thu Apr 01, 2004 2:36 pm
Location: 53 21N 6 18W
Contact:

Re: GEM programming - where to start?

Postby Desty » Thu Jan 24, 2008 12:48 am

Nyh wrote:A very quick start to Pure C:
...

Thanks Nyh, I'll give this a shot! If I don't like the GUI editor, do you know if the compiler can be used from the command-line, maybe with makefiles?
tá'n poc ar buile!

joska
Hardware Guru
Hardware Guru
Posts: 3793
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: GEM programming - where to start?

Postby joska » Thu Jan 24, 2008 7:11 am

Desty wrote:If I don't like the GUI editor, do you know if the compiler can be used from the command-line, maybe with makefiles?


You can, there are ttp-versions of the compiler and linker.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: GEM programming - where to start?

Postby Nyh » Thu Jan 24, 2008 10:31 am

Desty wrote:Thanks Nyh, I'll give this a shot! If I don't like the GUI editor, do you know if the compiler can be used from the command-line, maybe with makefiles?

Yes. There is:

cpp.ttp: the C preprosessor
pcc.ttp: the C compiler
plink.ttp: the linker
pasm.ttp: the assembler

I have no experience using make files on the Atari. AFAIK GNU make has been ported. Using Pure C with GNU make shouldn't be a problem.

I like the GUI a lot. You can double click on errors in the compiler output and the source file opens on the error line. You can press the Help key on function calls and the file with the function definition will open. Although these days I do most of my editing in UltraEdit on the PC and use the compiler in the emulator. Just press Alt-x in the emulator and the source will build. As long as you don't open source files in the PC editor there are no conflicts and even if you edit the source file in the Pure C editor UltraEdit will detect the change as soon as you save the file. The only thing you shouldn't do is edit a file in UltraEdit while it is opened in Pure C.

Hans Wessels

joska
Hardware Guru
Hardware Guru
Posts: 3793
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: GEM programming - where to start?

Postby joska » Thu Jan 24, 2008 11:11 am

Nyh wrote:I have no experience using make files on the Atari. AFAIK GNU make has been ported. Using Pure C with GNU make shouldn't be a problem.


It should work. Look for a TOS/MagiC-compatible gcc distribution and use it's make. But I really don't see the point in using GNU make with PureC - the reason I prefer PureC is speed and the GUI, you loose both when you introduce make...

Nyh wrote:I like the GUI a lot. You can double click on errors in the compiler output and the source file opens on the error line. You can press the Help key on function calls and the file with the function definition will open.


You can also press Help on keywords and library calls to view it's documentation. Very neat feature, PureC was way ahead of it's time when it comes to online help and documentation. And if you have a third party library (or make your own) with documentation in ST-Guide format, you can convert the ST Guide-file to Pure C help file, and the library's documentation will be instantly available in PureC. Atleast for me this is essential for efficient coding.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
Desty
Atari God
Atari God
Posts: 1955
Joined: Thu Apr 01, 2004 2:36 pm
Location: 53 21N 6 18W
Contact:

Re: GEM programming - where to start?

Postby Desty » Thu Jan 24, 2008 1:03 pm

That's cool, I'm looking forward to trying it now - thanks again Nyh.

joska wrote:But I really don't see the point in using GNU make with PureC - the reason I prefer PureC is speed and the GUI, you loose both when you introduce make...

I don't see how you would lose speed unless make is very slow on the ST? The whole point of using it is that it can speed up building larger projects by virtue of not having to manage lots of compiler options yourself... I've only used my own makefiles on the PC for some embedded development, but it helped out there for sure.
tá'n poc ar buile!


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 2 guests