guide to GEM coding with AHCC

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

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

peterlane
Atari maniac
Atari maniac
Posts: 94
Joined: Tue Mar 05, 2013 2:44 pm
Contact:

guide to GEM coding with AHCC

Post by peterlane »

I put together some notes to remind myself how my GEM programs are working. Most of this comes from CManShip, and things I learnt working through a lot of my own misunderstandings. I've also been helped along at times by members of this forum. These notes try to put this information together in one place, and may be useful to anyone else learning how to write GEM programs using AHCC. So far, I have only covered how to work with windows.

The notes are in the form of a pdf document: http://peterlane.info/downloads/guide.pdf. I work through a series of progressively more complex versions of a sample program - the source code for these versions: http://peterlane.info/downloads/guide-source.zip The examples have been tested on a Firebee and an Atari ST.

Let me know if anything's unclear, or could be improved.

Enjoy!
Peter Lane
Firebee | STE (4Mb, TOS 2.06)
http://peterlane.info/firebee.html
User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 1949
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: guide to GEM coding with AHCC

Post by Cyprian »

Great work!
Portfolio / Lynx II / Jaguar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / Lynx Multi Card / LDW Super 2000 / XCA12 / SkunkBoard / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/
vido
Atari Super Hero
Atari Super Hero
Posts: 720
Joined: Mon Jan 31, 2011 7:39 pm

Re: guide to GEM coding with AHCC

Post by vido »

This is realy great and important work!
Thank you!
User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 12928
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: guide to GEM coding with AHCC

Post by wongck »

cool.. looking forward to more proggies :)
My Stuff: FB/Falcon CT63 CTPCI ATI RTL8139 USB 512MB 30GB HDD CF HxC_SD/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list
gstoll
Atari maniac
Atari maniac
Posts: 90
Joined: Sun Feb 17, 2008 4:29 pm

Re: guide to GEM coding with AHCC

Post by gstoll »

peterlane wrote: Let me know if anything's unclear, or could be improved.
In open_vwork you must set work_in[0] to 2 + Getret(). ("work_in[0] = 2 + Getrez();")

https://github.com/petercrlane/sokoban/ ... /windows.c : event_loop
It is not necessary to make a #if for some messages. For example WM_SHADED is also pressend in MagiC or WINX.
Last edited by gstoll on Tue Jun 21, 2016 3:36 am, edited 1 time in total.
peterlane
Atari maniac
Atari maniac
Posts: 94
Joined: Tue Mar 05, 2013 2:44 pm
Contact:

Re: guide to GEM coding with AHCC

Post by peterlane »

gstoll wrote: In open_vwork you must set work_in[2] to 2 + Getret(). ("work_in[10] = 2 + Getrez();")
Thanks for the suggestion. It prompted me to look again at the Atari Compendium, and I notice it says for work_in[0]: "For screen devices you should normally use the value Getrez() + 2, however, a value of 1 is acceptable if not using any loaded fonts"

I take it you mean work_in[0] = 2 + Getrez (); ?

(I admit, I took the code for open_vwork directly from CManShip and haven't questioned it.)
qstoll wrote: https://github.com/petercrlane/sokoban/ ... /windows.c : event_loop
It is not necessary to make a #if for some messages. For example WM_SHADED is also pressend in MagiC or WINX.
I put the #if in as I have previously had problems compiling code with TOS 4 features on my STe. I'll take another look at it though.
Peter Lane
Firebee | STE (4Mb, TOS 2.06)
http://peterlane.info/firebee.html
gstoll
Atari maniac
Atari maniac
Posts: 90
Joined: Sun Feb 17, 2008 4:29 pm

Re: guide to GEM coding with AHCC

Post by gstoll »

peterlane wrote: I take it you mean work_in[0] = 2 + Getrez (); ?
Yes, I was to fast with the submit buton.

peterlane wrote: I put the #if in as I have previously had problems compiling code with TOS 4 features on my STe.
Maybe you use floating point. The ST version from AHCC don't support them. With PureC you can use it.
User avatar
Smonson
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 135
Joined: Sat Feb 20, 2016 9:45 am
Location: Canberra
Contact:

Re: guide to GEM coding with AHCC

Post by Smonson »

This is cool. Thanks for posting this guide - as a GEM beginner, this can benefit me greatly!
peterlane
Atari maniac
Atari maniac
Posts: 94
Joined: Tue Mar 05, 2013 2:44 pm
Contact:

Re: guide to GEM coding with AHCC

Post by peterlane »

gstoll wrote: Maybe you use floating point. The ST version from AHCC don't support them. With PureC you can use it.
Yes, that was a problem at first, as CManShip uses float in calculating the slider position. That was one of the things I had to rewrite to get code compiling on an STe with AHCC.
Peter Lane
Firebee | STE (4Mb, TOS 2.06)
http://peterlane.info/firebee.html
User avatar
Mikefulton
Captain Atari
Captain Atari
Posts: 169
Joined: Sun Nov 29, 2015 10:27 am

Re: guide to GEM coding with AHCC

Post by Mikefulton »

peterlane wrote: Thanks for the suggestion. It prompted me to look again at the Atari Compendium, and I notice it says for work_in[0]: "For screen devices you should normally use the value Getrez() + 2, however, a value of 1 is acceptable if not using any loaded fonts"

I take it you mean work_in[0] = 2 + Getrez (); ?

(I admit, I took the code for open_vwork directly from CManShip and haven't questioned it.)
"is acceptable" in this case means "won't bite you in the ass most of the time"

But then, once in awhile, it does. The problem is, it's not just fonts. It can also be an issue with loadable screen drivers. It's a rare problem to be sure, but why take a short cut on something so simple and basic?
peterlane
Atari maniac
Atari maniac
Posts: 94
Joined: Tue Mar 05, 2013 2:44 pm
Contact:

Re: guide to GEM coding with AHCC

Post by peterlane »

Thanks for all the comments and feedback I have received about my guide. This encouraged me to complete the 'second half', and write out what I know about menus, dialogs, events and the scrap library. The Guide has now been extended and updated, and includes more example programs.

In summary, a sample program is constructed step by step, considering each aspect of AES window handling in turn. Later versions feature multiple windows with sliders, menus, and some built-in dialogs. Other example programs include a binary clock to illustrate timer events, a simple sketch program to illustrate mouse events, and a temperature conversion program to illustrate user-defined dialogs. All examples should compile and run on any Atari computer, from the Atari ST to clones such as the Firebee.

Just to emphasise, this is not intended as a complete description of GEM programming. My aim is to help smooth the transition to using AHCC from more comprehensive sources such as CManShip or Professional GEM, which were written for older compilers and conventions.

The guide can be read:

- online in html: http://peterlane.info/gemguide/html/index.html
- or in pdf: http://peterlane.info/downloads/gem-guide.pdf
- and should be read along with the source code: http://peterlane.info/downloads/guide-source.zip

A summary and all these links are on my web page: http://peterlane.info/firebee.html

Let me know of anything that's unclear, is wrong, or could be improved.
Peter Lane
Firebee | STE (4Mb, TOS 2.06)
http://peterlane.info/firebee.html
vido
Atari Super Hero
Atari Super Hero
Posts: 720
Joined: Mon Jan 31, 2011 7:39 pm

Re: guide to GEM coding with AHCC

Post by vido »

This is just great Peter!
This is what I was waiting for till now. Many many thatks!!!

Still ... do you have any plans to continue whit this guide. Maybe to describe libraries, some programming advices, ...
It would be cool for someone like me to get faster into C coding on Ataris ...

Vido
User avatar
TheNameOfTheGame
Atari God
Atari God
Posts: 1432
Joined: Mon Jul 23, 2012 8:57 pm
Location: Almost Heaven, West Virginia

Re: guide to GEM coding with AHCC

Post by TheNameOfTheGame »

Nice job Peter! Thanks for compiling this information.
User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 12928
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: guide to GEM coding with AHCC

Post by wongck »

i hope more people will study this make more modern and contemporary programs.
My Stuff: FB/Falcon CT63 CTPCI ATI RTL8139 USB 512MB 30GB HDD CF HxC_SD/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list
tschak909
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 138
Joined: Mon Mar 26, 2018 9:29 pm

Re: guide to GEM coding with AHCC

Post by tschak909 »

I'm trying to find a proper programming pattern to keep a bitmapped buffer and redraw into the window it when asked by the system, as I am writing a terminal program, and while I seem to be sort of getting it right, but not really...

-Thom
User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2511
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: guide to GEM coding with AHCC

Post by lp »

GEM does not provide any sort of AES message when data arrives that needs processed. You end up having to use an evnt_multi() with the timer option and then polling the serial port from a timer subroutine.

As for the bitmap buffering. From my own experience, GEM doesn't normally provide rendering to off screen buffers. In this case you end up rendering stuff to the bitmap yourself and then blitting it to a window. There is NVDI, which is a VDI replacement that adds the ability to render VDI calls to off screen buffers. The only problem there is you force the end user to install NVDI if they don't already have it. These off screen calls are pretty cool, but they don't seem to work on any machine using fVDI which drives graphics cards and some clones, like the FireBee.

My VNC app handles writes to the off screen buffer itself. My Boing demo relies on NVDI. My IRC app handles it entirely different, since it only needs text rendering, it buffers the text and renders it on the fly in the window. I'm by no means an expert ;)
User avatar
jfl
Atari Super Hero
Atari Super Hero
Posts: 902
Joined: Tue Jul 18, 2006 10:55 pm
Location: Liège, Belgium
Contact:

Re: guide to GEM coding with AHCC

Post by jfl »

lp wrote:These off screen calls are pretty cool, but they don't seem to work on any machine using fVDI which drives graphics cards and some clones, like the FireBee.
On the FireBee, NVDI runs and takes care of this. I know, it's confusing. I never could figure out how the VDI works on that machine :shrug:
User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2511
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: guide to GEM coding with AHCC

Post by lp »

jfl wrote:On the FireBee, NVDI runs and takes care of this. I know, it's confusing. I never could figure out how the VDI works on that machine :shrug:
Thanks for the clarification. I forgot you could install NVDI along side other drivers.
User avatar
bladeomega
Atari User
Atari User
Posts: 43
Joined: Wed Oct 08, 2008 11:38 pm

Re: guide to GEM coding with AHCC

Post by bladeomega »

Nice GEM coding guide Peter. Thx
sashapont
Captain Atari
Captain Atari
Posts: 153
Joined: Sat Jun 03, 2017 9:40 pm

Re: guide to GEM coding with AHCC

Post by sashapont »

Are there any sample with creating windows from rsc dialog?
Atari Falcon, Firebee
mikro
Hardware Guru
Hardware Guru
Posts: 2218
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: guide to GEM coding with AHCC

Post by mikro »

Did some make a copy of this guide? Peter seems to have disappeared, his website, his github, ... everything done.
czietz
Hardware Guru
Hardware Guru
Posts: 1244
Joined: Tue May 24, 2016 6:47 pm

Re: guide to GEM coding with AHCC

Post by czietz »

The document itself is on dev-docs: https://docs.dev-docs.org/htm/search.ph ... M+Programm. I might have the source code on my old computer, but I don't have it at hand.
User avatar
rudis
Captain Atari
Captain Atari
Posts: 168
Joined: Mon Feb 14, 2011 9:41 am

Re: guide to GEM coding with AHCC

Post by rudis »

ThorstenOtto
Atari God
Atari God
Posts: 1192
Joined: Sun Aug 03, 2014 5:54 pm

Re: guide to GEM coding with AHCC

Post by ThorstenOtto »

sashapont wrote:Are there any sample with creating windows from rsc dialog?
If you mean how to run dialog boxes in windows: there are several libraries capable of doing that (sysgem, easygem, windom etc)., some of them too complicated to learn from them, some not really programmed very clean.

You could take a look at them, but they might not be easy to understand, without already having quite a bit of knowledge about GEM.
User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 1949
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: guide to GEM coding with AHCC

Post by Cyprian »

WDIALOG allows you to use dialog boxes in windows
http://toshyp.atari.org/en/008008.html
Portfolio / Lynx II / Jaguar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / Lynx Multi Card / LDW Super 2000 / XCA12 / SkunkBoard / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/
Post Reply

Return to “C / PASCAL etc.”