[comp.sys.atari.st] autostarting GEM programs

egisin@watmath.waterloo.edu (Eric Gisin) (02/05/88)

In article <1988Feb3.080736.14303@mntgfx.mentor.com>, dclemans@mntgfx.mentor.com (Dave Clemans) writes:
> Re: autostarting GEM programs
> 
> My understanding is that what the autostart programs do is to set up a
> small TSR routine attached to the vertical blank interrupt vector.  On each
> interrupt the code looks around and tries to guess whether or not GEM is
> initialized yet.  If it looks initialized it disengages from the vertical
> blank interrupt and starts the requested GEM program.  Whether or not a
> specific version of this technique works with all versions of the ROM's
> depends on specifically how the code checks for GEM being initialized.

Having disassembled gemstart recently, I'll describe what I found out.

It installs a VBL routine (in slot 1, not checking if it is in use)
that waits until the line-F trap handler is initialized (changes).
GEM uses the line-F opcodes as a "short" procedure call.
It wraps it own line-F handler around GEM's handler,
which intercepts two line-F opcodes (I don't know what they are).
When the handler encounters one of these opcodes, it looks up an address
in the ROM relative to the caller's PC, and uses that
in some way to pass the name of a program to be started by GEM.

I wish people who write this type of program would distribute
source; the programs are bound to break with new version of the OS.
I guess someone will have to disassemble gemstart and try to fix it.
(not me, I don't have an assembler)

Jinfu@cup.portal.com (02/07/88)

Some people have requested the source of gemstart (or startgem). I
happen have a copy of the source code. A complete ARCed copy follow:

It doesn't work with the new ROM found in Mega series. If someone can
make it work I will appreciate.

========================  Cut from here  ===========================
table
 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
begin 644 startgem.arc
M&@)35$%25$=%32Y)3D8 #    &T.;E);.0P   !D.EQM<V@N<')G#0H:"%-4z
M05)41T5-+E!21P"= 0  ;0YI4DE$. ,   Q@-   $,#/P !D $"2$$2? &X@y
M7@$@\(,'  %(] 1@51% #R=!H#R9 >R@+#4#*30,(&J(O@"W)& S ^ ?/S #x
M860,D.J%18( ?N0PV?$'2&_\ # @>="64*(6?8#$\F2GFXX)0')YXC+ &P81w
M #0X,]"!E$13<C5%^<^=!%X#Z1CI6,*)$RI/HBC[9T_(J8X@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(OI6 1/  5!( )Ig
M(R%),@93(55B\$Z0EP:29W9%($5/D"-0@!UZ!P)!@#&_ AH             f
K                                                            e
 d
end
=====================  Cut from here  ========================