GEM programming - where to start?
Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team
- MaLICiouS
- Obsessive compulsive Atari behavior
- Posts: 127
- Joined: Tue Jun 05, 2007 4:01 pm
- Location: Sweden
- Contact:
GEM programming - where to start?
Hi folks!
I've just built a gcc 3.3.3 cross compiler using the instructions at http://perso.orange.fr/patrice.mandin/v ... ss333.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.
I've just built a gcc 3.3.3 cross compiler using the instructions at http://perso.orange.fr/patrice.mandin/v ... ss333.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.
c code
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!
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!
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!
- Zorro 2
- Administrator
- Posts: 2308
- Joined: Tue May 21, 2002 12:44 pm
- Location: Grenoble (38) - France
- Contact:
Re: GEM programming - where to start?
I think you can find some interesting sources on Wiki or on this board. Maybe mister Nyh can give you some help to begin.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?
Last edited by Zorro 2 on Tue Jun 12, 2007 10:04 am, edited 1 time in total.
Re: c code
First Google hit I get for C tutorial: http://einstein.drexel.edu/courses/Comp ... /C_basics/charles wrote:well i can help , but we will have to "beaver" together....
i've been wanting to learn a little about 'c'
Read it, try it, see how it goes.
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: i own a bunch of stuff , manuals, books, programs, i wish to know basics for 'c' how to form loop ,
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.charles wrote:how procedures function,variables ,etc,etc,etc
just the basics ...like arrays , for next loops... what the heck does" { " and "}" stand for ????
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...
- MaLICiouS
- Obsessive compulsive Atari behavior
- Posts: 127
- Joined: Tue Jun 05, 2007 4:01 pm
- Location: Sweden
- Contact:
Re: GEM programming - where to start?
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.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.
Re: GEM programming - where to start?
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 thoMaLICiouS wrote:Hi folks!
I've just built a gcc 3.3.3 cross compiler using the instructions at http://perso.orange.fr/patrice.mandin/v ... ss333.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?

tá'n poc ar buile!
- MaLICiouS
- Obsessive compulsive Atari behavior
- Posts: 127
- Joined: Tue Jun 05, 2007 4:01 pm
- Location: Sweden
- Contact:
Re: GEM programming - where to start?
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!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
Re: GEM programming - where to start?
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...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!
tá'n poc ar buile!
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).MaLICiouS wrote:Tried the Pure C headers with my gcc cross-compiler. I eventually saw the shell prompt after about 40000 compiler errorsI'll have a look at the Pure C compiler, though.
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
- MaLICiouS
- Obsessive compulsive Atari behavior
- Posts: 127
- Joined: Tue Jun 05, 2007 4:01 pm
- Location: Sweden
- Contact:
Thanks a lot! I'll check it out!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

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
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
-
- Atari User
- Posts: 34
- Joined: Wed Jan 16, 2008 9:59 am
- Location: Gloucestershire, UK
Re: GEM programming - where to start?
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.
Re: GEM programming - where to start?
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.
Re: GEM programming - where to start?
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 thoughwhyatmyage 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.

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
VanillaMiNT - Falcon060 - Milan060 - Falcon040 - MIST - Mega STE - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
VanillaMiNT - Falcon060 - Milan060 - Falcon040 - MIST - Mega STE - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
Re: GEM programming - where to start?
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.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.
Hans Wessels
Re: GEM programming - where to start?
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.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.
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
VanillaMiNT - Falcon060 - Milan060 - Falcon040 - MIST - Mega STE - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
VanillaMiNT - Falcon060 - Milan060 - Falcon040 - MIST - Mega STE - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
Re: GEM programming - where to start?
Did you check the menu called "Compile"?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?"

Jo Even
VanillaMiNT - Falcon060 - Milan060 - Falcon040 - MIST - Mega STE - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
VanillaMiNT - Falcon060 - Milan060 - Falcon040 - MIST - Mega STE - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
Re: GEM programming - where to start?
A very quick start to Pure C:joska wrote:Did you check the menu called "Compile"?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?"
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;
}
(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
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Hans Wessels
Re: GEM programming - where to start?
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?Nyh wrote:A very quick start to Pure C:
...
tá'n poc ar buile!
Re: GEM programming - where to start?
You can, there are ttp-versions of the compiler and linker.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?
Jo Even
VanillaMiNT - Falcon060 - Milan060 - Falcon040 - MIST - Mega STE - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
VanillaMiNT - Falcon060 - Milan060 - Falcon040 - MIST - Mega STE - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
Re: GEM programming - where to start?
Yes. There is: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?
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
Re: GEM programming - where to start?
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 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.
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.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.
Jo Even
VanillaMiNT - Falcon060 - Milan060 - Falcon040 - MIST - Mega STE - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
VanillaMiNT - Falcon060 - Milan060 - Falcon040 - MIST - Mega STE - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64
Re: GEM programming - where to start?
That's cool, I'm looking forward to trying it now - thanks again Nyh.
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.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...
tá'n poc ar buile!