guide to GEM coding with AHCC

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

Moderators: exxos, 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

Postby peterlane » Sun Jun 19, 2016 11:42 am

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
Atari God
Atari God
Posts: 1404
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: guide to GEM coding with AHCC

Postby Cyprian » Sun Jun 19, 2016 12:54 pm

Great work!
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Aranym / Steem / Saint
http://260ste.appspot.com/

vido
Atari Super Hero
Atari Super Hero
Posts: 541
Joined: Mon Jan 31, 2011 7:39 pm

Re: guide to GEM coding with AHCC

Postby vido » Sun Jun 19, 2016 4:10 pm

This is realy great and important work!
Thank you!

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11990
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: guide to GEM coding with AHCC

Postby wongck » Mon Jun 20, 2016 11:39 am

cool.. looking forward to more proggies :)
My Stuff: FB/Falcon CT63+CTPCI_ATI_RTL8139 14+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 freak
Atari freak
Posts: 62
Joined: Sun Feb 17, 2008 4:29 pm

Re: guide to GEM coding with AHCC

Postby gstoll » Mon Jun 20, 2016 5:08 pm

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

Postby peterlane » Mon Jun 20, 2016 6:00 pm

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 freak
Atari freak
Posts: 62
Joined: Sun Feb 17, 2008 4:29 pm

Re: guide to GEM coding with AHCC

Postby gstoll » Tue Jun 21, 2016 3:47 am

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
Atari freak
Atari freak
Posts: 61
Joined: Sat Feb 20, 2016 9:45 am
Location: Canberra
Contact:

Re: guide to GEM coding with AHCC

Postby Smonson » Tue Jun 21, 2016 9:56 am

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

Postby peterlane » Tue Jun 21, 2016 10:42 am

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

Postby Mikefulton » Wed Jun 22, 2016 6:18 am

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

Postby peterlane » Tue Jul 12, 2016 9:07 am

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: 541
Joined: Mon Jan 31, 2011 7:39 pm

Re: guide to GEM coding with AHCC

Postby vido » Tue Jul 12, 2016 10:09 am

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: 1054
Joined: Mon Jul 23, 2012 8:57 pm
Location: Almost Heaven, West Virginia

Re: guide to GEM coding with AHCC

Postby TheNameOfTheGame » Tue Jul 12, 2016 5:31 pm

Nice job Peter! Thanks for compiling this information.

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11990
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: guide to GEM coding with AHCC

Postby wongck » Tue Jul 12, 2016 11:18 pm

i hope more people will study this make more modern and contemporary programs.
My Stuff: FB/Falcon CT63+CTPCI_ATI_RTL8139 14+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


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 2 guests