GEM_0001
GEM_0001
GEM_0001
(--
INTRODUCTION TO GEM PROGRAMMING
1. INTRODUCTION
Thanks for your interest and support of the ST series of
computers. Enclosed is the documentation and software
package you have ordered. Read this section first to learn
how to organize your documentation and get quickly on the
road to ST product development.
1.1 WHO TO CONTACT IF YOU HAVE A PROBLEM:
Hardware problems Randy Hain (408)745-2466
Software questions John Feagans (408)745-4923
Package administration
and equipment orders Cindy Claveran (408)745-2568
2. DOCUMENTATION IN THIS PACKAGE:
The documentation may seem overwhelming at first, but it
is really easy to get started. All pages are pre-punched for
a three ring binder and the sections you will most commonly
access are The Guide (BIOS), GEMDOS, Volume I--VDI, and
Volume 2--AES. To start programming, the first files you
should read are on the MicroEMACS disk on how to use the
editor. This document contains info on compiling and linking
your first program. Later you may refer to other documents
in the package for detail on changing parameters of the
compiler, linker, and other utilities.
(
1. Non-disclosure agreement
Please sign and return to assure
future updates.
2. Question and Answer Newsletters
Commonly asked questions by
new developers.
3. Introduction to GEM programming
4. A Hitchhiker's Guide to the BIOS
5. Atari GEMDOS Reference Manual
6. GEM Programmer's Guide, VOl. l--VDI
7. GEM Programmer's Guide, Vol. 2--AES
8. GEM DOS Programmer's Guide
9. C Language Programming Guide
(i.gnore the references for CP 1M 68K)
The next series of documents are intended for the
advanced developer who wants to exercise the lowest level of
operating system:
10. Line-A Technical Reference Manual
11. Intelligent Keyboard (IKBD) Protocol
These next documents can be used by developers of
add-ons and those persons who just want to know more detail
about the machine:
( 12. Engineering Hardware Specification
-3-
INTRODUCTION TO GEM PROGRAMMING
-4-
INTRODUCTION TO GEM PROGRAMMING
-5-
INTRODUCTION TO GEM PROGRAMMING
4.2 LINKER
-6-
INTRODUCTION TO GEM PROGRAMMING
-7-
INTRODUCTION TO GEM PROGRAMMING
This disk contains the text editor you will use for
constructing your programs and a number of examples which
illustrate use of the AES and VDI.
CARDS folder containing:
MAKECARD.BAT
CARDS.C example dialog box and field usage.
CARD.H
CARDS.H
CTYPE.H
CTYPE.O
CARDS.RSC
DOCUMENT folder containing:
NEWFORM.DOC form keybd() and form button info.
DISK. TXT how to address 1772 through DMA port.
DOODLE folder containing:
LINKDO.BAT example draw program
DOODLE.C
DOORSC.C
DOODLE.H
DOS.H
TREEADDR.H
DOODLE.INP
DOOSTART.O
DOODLE.PRG
DOODLE.RSC
DOOSTART.S
EMACS folder containing:
ME.TTP the editor.
TUTOR. DOC how to .•.
TEXT1
TEXT2
TEXT3
FORMDO folder containing:
FRMTST.C
FORM.DEF
FORM.H
FRMTST.PRG
FORM.RSC
MENU folder containing:
MLINK.BAT example menu program
MENTST.C
MENTST.DEF
MENTST.H
MENTST.RSC
TEMPLATE folder containing:
TEMPLATE.C put your application in the middle
and have a functional GEM app.
-8-
INTRODUCTION TO GEM PROGRAMMING
,
-9-
INTRODUCTION TO GEM PROGRAMMING
------------------~------------
-10-
If)
INTRODUCTION TO GEM PROGRAMMING
( <obdefs.h>
GEMDOS <define.h> OSBIND.O object
BIOS <osbind.h>
XBIOS
"c" library <stdio.h> GEMLIB library
<math.h> LIBF library
All of the above libraries can be mixed depending on the
needs of the developer.
:(
-11-
11
INTRODUCTION TO GEM PROGRAMMING
-12-
1:1
INTRODUCTION TO GEM PROGRAMMING
7.1 BATCH.TTP
7.2 RM.PRG
-13-
INTRODUCTION TO GEM PROGRAMMING
continuing. /'
7.4 RELMOD.PRG
EXAMPLES
RELMOD FOO
Will look for a file called "FOO.68K", and produce a
file called "FOO.PRG".
RELMOD BAR -BAZ.ZIP
Will look for a file called "BAR.68K", and produce a
file called "BAR.PRG". Similarly, it will look for "BAZ.ZIP"
and produce "BAZ.PRG".
""".
-14-
INTRODUCTION TO GEM PROGRAMMING
-15-
IS
**** Atari Corp.
**** 1196 Borregas Avenue
**** Sunnyvale, Ca. 94086
******
** ** ** 1 July 1986
** ** **
** ** **
Errata
-1-
"
ERRATA JULY 1986
-2-
ERRATA JULY 1986
-3-
(~ ------------------------------------------------------------
AAA TTTTT AAA RRRR III **** SSS TTTTT
A A T A A R R I **** S T
S
Ao A T A A R R I **** S T
AAAAA T AAAAA RRRR I ****** SSS T
A A T A A R R I ** ** ** S T
A A T A A R R I ** ** ** S S T
A A T A A R R III ** ** ** SSS T
DDDD EEEEE V V EEEEE L 000 PPPP EEEEE RRRR SSS
D D E V V E L 0 0 P P E R R S S
D D E V V E L 0 0 P P E R R S
D D EEEE V V EEEE L 0 0 PPPP EEEE RRRR SSS
D D E V V E L 0 0 P E R R S
D D E VV E L 0 0 P E R R S S
DODD EEEEE V EEEEE LLLL 000 P EEEEE R R SSS
/9
Question and Answer Bulletin
:lo
Question and Answer Bulletin
construction set.
Q: I am running the batch program and get a bus error after
cO.prg has been running a little while compiling my program.
Could this be a bug in the compiler.
A: A bug is always possible but here are a few other things
to suspect when a problem like this occurs. The batch
program will abend if it cannot find a specified program to
load. You may also have an include file with something
illegal. That might explain why things proceed through the
pre-processor in abort in the first compile step. Another
thing to check is if you are running out of space on the disk
from which the compiler is running. Each step of the compile
creates some intermediate files which require space. It is
possible to specify to the compiler which drive to which it
writes the intermediate files.
Q: I am transferring files from my IBM PC to the ST using
ke~mit. ASCII files come over o.k. but binary files are
messed up.
A: When you transfer binary files you must tell the server
to SET FILE TYPE BIN. You must also tell kermit on the ST to
gi (get image) or si (send image).
Q: I am using ICED.PRG to design my icons for use in my
resource file. How do I load these icons into the RCS?
A: As an example, let us consider that you are in the RCS
and have created a dialog box. Drag the icon type from the
parts box into your work area. Select the work area and
select the icon you have just moved down. Bring down the
menu under the file heading and select the open. At this
point the open item will not load a new resource but will
load in and link the data for the icon file you select in the
file selector.
Q: What documentation errors do you know about in the
Hitchhiker's Guide to the BIOS?
A: The current Hitchhiker's Guide shows the initial PC being
set from $FCOOOO and the initial SP from $FC0004. These
values are reversed.
Hitchhiker's Guide is wrong in two places about the GEMDOS
call $20 to set supervisor mode. The flag to merely test the
current mode is $1 and not the $FFFFFFFF specified. The
latter will crash the system. Second, the returned value
from this function is $0 for user mode and $FF for supervisor
mode, not $0 and $1 as documented.
Q: To get started writing my program I need some more
example programs. Where can I find some?
Here are the latest questions from the Atari developers mailbag
as answered by John Feagans, Director of Software Technology.
Leave questions on Compuserve for PIN 70007,1072 or GO PCS57 for
Atari developer SIG information.
(
This months contents numeric pad that it has and
the VT-220 style that the ST
1 Corrections .•.•........... l has is that the cursor keys
2 BIOS . . . . . . . . . . . . . . . . . . . . . . 1 are located in the positions
3 DOS ••..•••.•.•••..••.••••. 2 of the *, -, +, and Enter key
4 VDI . . . . . . . . . . . . . . . . . . . . . . . 2 on the numeric pad. The enter
5 AES ••..••..•..•...•...••.• 2 key itself is split into two
6 Desktop . . . . . . . . . . . . . . . . . . . 3 smaller keys.
7 Accessories ...•........•.. 3
8 BASIC . . . . . . . . . . . . . . . . . . . . . 3
9 LOGO •• e· • • • • • • • • • • • • • • • • • • • 3
10 Development tools ......... 4
11 New On Compuserve ......•.. 4 2. BIOS
*
Q: How do I make the buffer
1. Corrections larger for communication over
the MIDI port?
In the March 1986 issue I
mis-stated a description of A: Use the xbios call
the real VT-52 keyboard. This Iorec(MIDI) to get the address
device actually does have a of a structure which contains
numeric pad and cursor keys. a pointer to the existing
The difference between the buffer. Change it to point to
3D
Question and Answer Bulletin
(' 7. Accessories
6. Desktop
Q: How does
* the AUTO folder
work? 8. BASIC
A: If you create a folder *
named AUTO, the system looks Q: The accountants in my 50
for i t on power-up boot and million dollar company do not
will execute any programs i t like my basic programs as
finds inside. If there is large numbers will end up with
more than one program, the a few pennies added to the
programs will be executed in end. What can I do?
the order that they were
created in the folder. These A: You are seeing the effect
programs are named *.prg but of a single precision
it is not possible to have an scientific math package. The
auto-starting GEM application. maximum number of significant
However, the programs may use digits that can be stored is 6
the VDI, DOS, and BIOS. A to 7. Decimal fractions
good example to try is to cannot be accurately
place STWriter inside an AUTO represented by a binary
folder and i t will start floating point structure. To
running on power-up. When you overcome the latter
exit STWriter, initialization limitation, you can store all
resumes and execution brings numbers as pennies, only
( up the desktop. AUTO folders
are generally used for drivers
inserting the decimal point
when inputting or outputting
such as those for the them. To gain extra
hard-disk and printers. significant digits you can
save each number as an integer
Q: How can you get the name of whole and fractional part. To
the data file that initiated a really gain significant digits
program with an installed you might consider writing
document type? some math routines which
operate and store numbers in
A: For programs that have strings.
undergone the . install
application option at the
desktop, it is easy to get the
name of the document. The
desktop program places the 9. LOGO
file name string in the
command tail. The command *
tail starts 80 hex into the Q: I keep getting an edit
base page. You can get this buffer full error. I have
information by accessing the tried turning off buffered
base page directly, or by graphics and not loading desk
main(argv,argc) from a C accessories to get more space.
program that uses gemstart.o. Will getting ROMs help me?
A: The edit buffer is a fixed
size. You need to break up
your program into smaller
31
Question and Answer Bulletin
1. Corrections
In this issue we return to the single column format. In trying to
make better use of space available by going to double-column
format, many readers could not follow the columns when reading
this newsletter on-line. Remember, your suggestions are always
welcome as are your questions.
2. BIOS
Q: Are
*
nulls deleted by TOS when communicating over the RS-232
port?
A: When you write a communications package it is important to
use the raw-unprocessed BIOS conin instead of a higher level
which may intercept control characters including control-C.
There is no reason for nulls to be deleted.
Q:
*
How do Europeans access the special characters in the Atari
charcter set?
A: The Atari character set is standard in all models of the ST
around the world. There are special versions of TOS for each
country which contain resources translated to the local language
and keyboard translation tables which decode the scan codes to
the character codes. The scan codes are always the same for the
same key positions because the IKBD controller is the same in all
models. The legends on the keys in those positions may vary by
country. Some countries have a dead-key function driver which is
in the auto folder at boot time. This driver installs in Trap 13
and monitors Bconin for the pressing of an accent mark. When the
next vowel is pressed, the correct character code is generated
for the application software.
3. DOS
Q: How
*
can I prevent alert boxes from printing when I get a DOS
error?
A: See the BIOS function setexc(vecnum,vec). Vecnum is the
number of the vector to get or set. Vec is the address to setup
in the vector slot else a get is performed if the value is -lL.
Vecnum $101 is the critical error handler. Insert your own
routine there and the alert boxes will cease printing. Be sure
to restore the old vector when you are finished.
4. VDI
Q:
*
What is the 6 x 6 font used for?
A: The smallest font is used for labeling icons in medium and
high resolution.
5. AES
Q:
*
How can I access the menu from a desk accessory?
A: There is no way that this can be done. Menu messages are
given to the desktop program (or currently running application
that generated the menu. You could generate your own pseudo menu
in your window but you would have to do everything yourself.
Q:
*
Do you need more than one resource file in your program so
that multiple resolutions are handled correctly?
A: It is only necessary to design one resource. The RCS stores
all the object positions and width and height in terms of byte
alligned character coordinates. When the file is loaded by the
rsrc load function, the x and width parameters are multiplied by
the current global character width and the y and the heigh by the
current global character height. Thus all the numbers are
adjusted to the current resolution you are working in.
6. LOGO
Q:
*
Are SETWRITE and SETREAD working?
A: These functions are currently un-implemented in ST Logo.
Q:
*
How can a user define his own fill pattern?
A: The example in the Logo manual has a typo. You must define
16 and not 15 values as shown to make the fill pattern work. The
last value reads "1280" and should be "128 0".
7. Development Tools
Q:
*
How do I increase the stack size in gemstart?
A: In the file gemstart.s you will find a comment about
allocating lk of stack space next to a add.l #500,dO. $100 is
alocated for the base page and $400 (lk bytes) is allocated for
the stack. To increase the stack to 2k, make the number $900.
Assemble this module and link the resulting object. There is an
interesting point to be made about the C run time library
function malloc here. malloc allocates space off this stack. A
new and improved gemstart will be available soon to allow you to
malloc more than lk. Keep in mind that this malloc is not Malloc
3S
Question and Answer Bulletin
the DOS function. The latter Malloc works fine if you have
previously done an Mshrink to return unused memory to the
operating system.
Q:
*
My program to spawn processes get the message "Not enough
free store." What is happening?
A: Sounds like you did not do an Mshrink to give memory back to
the DOS when your first program started running. (This was
verified later in the thread.)
Q:
*
How do you get wild cards to work in Kermit?
A: You must enclose the file name in quotes.
8. New On Compuserve
In data library 7 (for registered Atari Developers only) in the
Atari Developers SIG on Compuserve, the following files are new
this month:
lo68.prg the other linker program
ahdi.prg rev 5 hard disk driver.
hdx.prg hard disk partitioner.
hdx.rsc
wincap
ship.prg hard disk head parking.
invite. let UK show announcement.
newfrm.doc form button documentation.
ctype.o character typing module.
f2s.doc ROM making software.
f2s.prg
glue. doc
glue.prg
send.prg
end
math.h C header file support
string.h
qa3.doc previous Q/A bulletin.
1. Discussion
We would like to clear up a bit of the confusion on the use of
the Alcyon version 4.14 C compiler. The programs which are
actually new in the system are cp, cO, and c1, the as68, and
ar68. The Motorola FFP (libf) and the double precision math pack
(libm) are upgraded and a new addition respectively. All the
other tools and programs on the disks are the standard issue in
the regular developer's kit. GEMLIB was modified slightly by
Alcyon to include procedures needed by the new math libraries.
In the future, everyone will be updated with a new linker.
The files on the disks have been organized in a two disk system
for C- development. There is some redundancy on the linker and
compiler disks with regard to batch.ttp, wait, and rm. The
header files for the AES and VDI are not included since you
already have them on the standard kit. You may configure the
.bat files any way you wish, but be especially vigilant to cf.bat
and linkf.bat which are intended to work as a pair. cf.bat has
the -f option which is telling the new c-compiler to use the
Motorola fast floating point. If you mix cf.bat with link. bat,
the first symptom you will see is "printf.o multiply defined." I
have done this accidently with my keyboard. that has a sticking
"k" key. If you want to be safe, just make a batch file that
compiles and links your file in one operation. Remember also
./
that you must add stdio.h and ctype.h as before if you use those
functions.
2. BIOS
Q: How can you initiate a screen dump from the keyboard?
A: Hold down the <Alternate) key and press <Help>. Be sure you
have done the correct printer installation if you are using a
non-Atari printer capable of doing raster dumps. Repeat the key
sequence to halt the print at any time. The best part of this
feature is that you can activate it from any program even if it
does not use GEM.
Q: How do you turn off the cursor in a TOS application?
A: Send the VT-S2 escape to turn off the cursor. Look in the
Hitchhiker's Guide to the BIOS for a complete description of all
the escape codes.
-----------------------------------------------------------------
3. DOS
Q: How do I install partitions I have created with the hard disk
format program?
A: Select one of the drive icons on the desktop. Move the mouse
to the Options menu and select Install drive. Change the drive
identifier to your choice and select OK. Be sure to do a Save
desktop so that the installed drive will appear each time you
boot.
Q: How can I recover some files I accidently trashed?
A: There is hope -- but not much. If you have not created a new
file since your accident, you may be able to use a disk utility
to view sectors and piece it back together. However, those
sectors may be scattered allover your disk. The best medicine
is prevention. Leave the confirm deletes option connected.
4. VDI
Q: Looking into the VDIBIND library, I saw that there were many
functions which couldn't be found in VDIBIND.H. e.g. vro cpyfm,
vs clip. What is the rason for not including these in VDIBIND.
Can we include them or don't they work well?
A: VDIBIND.H is not necessary because all functions return an
integer value--if ever. All these functions are in the VDIBIND /
( object library.
Q: I was using vg text to output a string. When I switched to
line-a to output the characters of the string one character at a
time it was slower -- why?
A: When you pass a string to the VDI you are performing only one
Trap or software interrupt. If you use line-a, you do a software
interrupt--and all of the overhead--on each character you output.
In the end, the same code outputs the pixels to the video RAM.
In some cases, like this, VDI can exceed line-a.
Q: What is the standard address of screen memory?
A: Unlike older systems, the ST can have video display memory
located anywhere as long as it is on lk boundaries. Various
device drivers may be loaded in at boot time so it is impossible
to say that video memory has a fixed address. The only thing
that can be said for sure about the location is that it is
usually the high end of RAM.
5. AES
Q: Is it possible to track the mouse through the process of menu
( item selection? I need to change the appearance of items on the
fly.
A: No, this is not an option of the AES. The usual scenario is
to stay in the evnt multi until a menu event message is
returned.
Q: How many parameters does the objc_edit command have?
A: The correct number is five. The AES manual incorrectly states
six.
6. Desktop
Q: I would like to know if information from the desktop.inf is
available to normal applications. I have noticed that the
control panel and VT 52 emulator accessories have access to this
information.
A: It is the responsibility of every application in the system
to save and restore changes to system variables. We do not
recommend an application going in to directly change the
desktop.inf. There is a constant danger of user modifications
causing damage to the system that cannot be supported. The best
way to change colors is through the vdi. Modifying the hardware
7. BASIC
Q: How can I access the,RS-232 from BASIC?
A: Where X is a character: For output use OUT 1,X and for input
use X = INP(l).
8. Development Tools
Q: The function itoa is not in the C-runtime libraries. What
can I use for this function?
A: If you have a special case where you need a small number of
digits in a hurry, you can write a quick C function to convert an
integer to ASCII characters. Another way is if you have included
stdio, you can use sprintf to output an integer to a string.
Q: We are having serious troubles with C. The functions getchar
and stream reading does not work properly. In fact a German
version has modified "stdio.h" definitions, (sic) though it works
better has still problems.
A: There is another version of stdio.h floating around Europe
which uses a #define of get char to be a BIOS Bconin(CON). This
does not help the scanf function however. There is also a danger
in using this version because when you mix Gem DOS calls (which
the C run-time uses), and direct BIOS calls to get characters
from the keyboard. A symptom of this has been noted as "10
characters disappearing" as the DOS bufferes them up whenever a
printf is called. 'The safest replacements for getchar and scanf
are using Cconin and Cconrs+sscanf respectively.
9. New On Compuserve
In data library 7 (for registered Atari Developers only) in the
Atari Developers SIG on Compuserve, the following files are new
this month:
gemlib Works with both Alcyon versions.
test.c Example using stdio to 1st: and con:.
qa4.doc May Q/A newsletter.
ATARI CORP.
BY: BY:
TITLE: TITLE:
("
..
DATE: DATE:
1055L
(