A loader in Gfa

GFA BASIC-related articles in here please

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

User avatar
Tomchi
Captain Atari
Captain Atari
Posts: 377
Joined: Sat Jun 10, 2006 5:17 pm
Location: Au bord de la rivière
Contact:

A loader in Gfa

Postby Tomchi » Tue Aug 22, 2006 10:54 am

Hi everybody.

I'm trying to make a loader in gfa, a menu in which you can select the prog you want to run. For this I use the easy EXEC 0 function .
But I would like to load the prog in memory, once loaded put a picture on the screen and then run it.

It seems the EXEC function doesn't allow that kind of stuff. There's also the GEMDOS 75 which seems to allow you to load the prog and run it using different parameters ..

As I'm a level -100 coder, I just don't manage to understand how this works :oops:

Can someone help me explaining how I can do it ?

Thanks
There's no way to happiness, happiness is the way ...

Noextra

User avatar
Mug UK
Administrator
Administrator
Posts: 11322
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Postby Mug UK » Tue Aug 22, 2006 11:09 am

The PEXEC command can load and then execute but it can also load into memory and execute when you let it.

Read the various GEMDOS/BIOS/XBIOS guides out there for the complete description of how to use the PEXEC.

Just remember to set a very small amount of memory in your GFA loader with (I think) a special parameter at the start of your listing.

I've got some source code for stuff like this on my site (I think).
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

User avatar
tobe
Atari God
Atari God
Posts: 1459
Joined: Sat Jan 24, 2004 10:06 am
Location: Lyon, France
Contact:

Postby tobe » Tue Aug 22, 2006 11:32 am

muguk wrote:Just remember to set a very small amount of memory in your GFA loader with (I think) a special parameter at the start of your listing.

$M<memory> if I remember well.
step 1: introduce bug, step 2: fix bug, step 3: goto step 1.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5016
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Postby simonsunnyboy » Tue Aug 22, 2006 3:44 pm

Make sure to free all unused memory with MSHRINK().
I don't know how to do that with GFA directly but I think RESERVE will do the trick in the end.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

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

Postby lp » Tue Aug 22, 2006 6:18 pm

Would loading the picture just before pexec() call solve it?
If not look into pexec() mode 3, this will load the program, but not start it.
You then issue another pexec() call with special parameters to actually run it at a later time.

User avatar
Tomchi
Captain Atari
Captain Atari
Posts: 377
Joined: Sat Jun 10, 2006 5:17 pm
Location: Au bord de la rivière
Contact:

Postby Tomchi » Tue Aug 22, 2006 6:41 pm

Ip,

Nevermind if i have to load the pic before loading the prog.
Sorry guys for making you loose your time but I repeat I'm no coder !!

So, in my Gfa manual i can read pexec() in the decription of GEMDOS 75
but what's that ? There's no further information about it ... I guessed that was something like an equivalent of C code or something like that :oops:
I'm using Gfa 3.0 ...
BTW here is what i read in my book:

r%=GEMDOS(75,m%,L:p%,L:c%,L:e%)
m% mode 0:load and run, 3:load, 4:run, 5:Base page
p% adress of the prog or Base pasge if m%=4
c% Adresse de la ligne d'instruction ( instruction lign adress?) exept if m%=4
e% adresse de la chaine d'environnement (environment string adress ?) exept if m%=4

Just don't know what the hell c% and e% could be ???
I tried to do a mode 3 to see what the adress of the base page could be ( tried it even with EXEC 3 ) but the result is -15 ....
I'm lost !!!

I tried to download some ( many ) stuffs on MugUK's site but it seems that nothing relevant to this is in the files ....
There's no way to happiness, happiness is the way ...

Noextra

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

Postby lp » Tue Aug 22, 2006 7:16 pm

What you need is more than just the GFA manual. 'The Atari Compendium' contains more detailed information on system calls.

See: http://www.fortunecity.com/skyscraper/a ... gemdos.htm
Search for 'pexec()'

You would use mode 3 to load it, then mode 4 to start it.

GFA happens to have many commands built in that are really just wrappers for system calls, thus in the case of EXEC(), this is really the same as the gemdos call pexec().

One problem you will run into, GFA only allows strings for the last 2 parameters of EXEC(), but the system call requires the basepage passed in the commandline for mode 4. The trick here is to use the gemdos() command and not the EXEC() command.

Something along the lines of:
path$="blah..."+chr$(0) !very important strings be null terminated
cmd$=chr$(0)
env$=chr$(0)+chr$(0)
bp%=gemdos(75,W:3,L:V:path$,L:V:cmd$,L:V:env$) !load it, don't run it
if bp%<=false
' something went wrong
endif
' do what ever here, load pic, ...
void gemdos(75,W:4,L:false,L:bp%,L:false) !now run it
' W: means pass as word
' L: means pass a long
' W: and L: are determined by the documentation for the operating system
' if you leave these out, GFA assumes W:

Maybe that helps. I know this stuff can be frustrating.

User avatar
Tomchi
Captain Atari
Captain Atari
Posts: 377
Joined: Sat Jun 10, 2006 5:17 pm
Location: Au bord de la rivière
Contact:

Postby Tomchi » Wed Aug 23, 2006 11:37 am

lp wrote:Maybe that helps. I know this stuff can be frustrating.


Help ? No ...

I JUST HAVE TO CALL YOU MASTER !!!

It really works well, indeed I had to try many times and read the GEMDOS errors table ( thx for the link too ! ) to put some RESERVE at the beggining of the Gfa prog .... :oops:

Many thanks for having spent your time explaining me that stuff !
I've always wondered how to do that but in the 90's I didn't know anybody who could help me about that ...
There's no way to happiness, happiness is the way ...

Noextra

User avatar
Mug UK
Administrator
Administrator
Posts: 11322
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Postby Mug UK » Wed Aug 23, 2006 3:54 pm

Oops! :oops: My apologies. The code I thought you wanted was for my Black Tiger hack which did in assembly what you were trying to do in GFA. Sorry!

My Black Tiger hack loaded up the small loader program and then changed the filename of another executable that was to be loaded - either the normal version or the hacked version as my normal trainer envelope wouldn't work on it due to some weird compiler they'd used.
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

User avatar
Tomchi
Captain Atari
Captain Atari
Posts: 377
Joined: Sat Jun 10, 2006 5:17 pm
Location: Au bord de la rivière
Contact:

Postby Tomchi » Wed Aug 23, 2006 5:47 pm

Nevermind muguk, allready nice trying to help me ;)
There's no way to happiness, happiness is the way ...

Noextra

User avatar
Zorro 2
Administrator
Administrator
Posts: 2198
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Postby Zorro 2 » Fri Aug 25, 2006 4:03 pm

I try to do GFA BASIC since a long time and I give you a little code to see how to load prg + wait + launch + wait + quit clean in gfa.
The secret of this function gemdos is you must reserve a little memory like 5000 (et c'est tout !).

I'm sure with this code you'll have no bomb :wink:

Code: Select all

'
' Postcharger un programme avec lancement diff‚r‚
' GFA-BASIC              PEXEC2.GFA
'
' R‚server pour le programme 5000 octets
' de la m‚moire r‚serv‚e par le BASIC.
'
$C+
ON ERROR GOSUB fin
ON BREAK GOSUB fin
'
RESERVE 5000
.
super%=GEMDOS(&H20,L:0)
key|=BYTE{&H484}
inter|=BYTE{&HFFFA09}
re&=XBIOS(4)
xb%=XBIOS(2)
OUT 4,18
~XBIOS(5,L:-1,L:-1,W:0)
.
nomfich$="D:\al_06\al_6a.PRG"+CHR$(0)
parametre$=CHR$(0)
environnemt$=CHR$(0)
'
nomfich%=VARPTR(nomfich$)
parametre%=VARPTR(parametre$)
environnemt%=VARPTR(environnemt$)
'
PRINT "Voici le programme appelant."
PRINT
'
' Mode 3: charger un programme
'
basepge%=GEMDOS(&H4B,3,L:nomfich%,L:parametre%,L:environnemt%)
'
IF basepge%<0
  PRINT "Une erreur s'est produite quelque part!!!"
  PRINT
  VOID GEMDOS(7)  ! Crawcin attend un appui touche
  @fin
ELSE
  '
  PRINT "Le programme est charg‚. Tapez une touche pour le lancer!"
  PRINT
  VOID GEMDOS(7)  ! Crawcin attend un appui touche
  CLS
  PRINT "LANCEMENT..."
  '
  ' Mode 4: lancer le programme
  '
  VOID GEMDOS(&H4B,4,L:0,L:basepge%,L:0)
  '
ENDIF
'
CLS
PRINT "Revoici le programme appelant!"
~INP(2)
'
' Annuler la modification de la m‚moire:
' (ne fonctionne pas parfaitement sous l'interpr‚teur...)
'
@fin
'
PROCEDURE fin
  '
  CLS
  BYTE{&H484}=key|
  BYTE{&HFFFA09}=inter|
  ~XBIOS(5,L:xb%,L:xb%,W:re&)
  OUT 4,8
  SETCOLOR 15,1911
  SETCOLOR 0,0
  ~GEMDOS(&H20,L:super%)
  EDIT
  '
RETURN
'
Member of NoExtra Team

User avatar
Tomchi
Captain Atari
Captain Atari
Posts: 377
Joined: Sat Jun 10, 2006 5:17 pm
Location: Au bord de la rivière
Contact:

Postby Tomchi » Fri Aug 25, 2006 5:45 pm

thanx for the init and end though i don"t get the use of key and inter ...
And what about this $C+ at the top of your listing ?
As for the main trick it's exactly what Ip told me ;)
There's no way to happiness, happiness is the way ...

Noextra

User avatar
Zorro 2
Administrator
Administrator
Posts: 2198
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Postby Zorro 2 » Fri Aug 25, 2006 6:21 pm

Tomchi wrote:thanx for the init and end though i don"t get the use of key and inter ...
And what about this $C+ at the top of your listing ?
As for the main trick it's exactly what Ip told me ;)

About $C+, it's an additional option, you can see all of them with the compiler in adding some options on the line. I put it all the time even if I don't use INLINE command !

The code source can give you some idea like a loop... I re-use an old original PEXEC standard code but I manage the code to use all programs. In fact, only programs who don't use PEXEC function himself :twisted:

I engage you to see my GFA BASIC part on my website, maybe you can learn some tricks :?:
Member of NoExtra Team

User avatar
Tomchi
Captain Atari
Captain Atari
Posts: 377
Joined: Sat Jun 10, 2006 5:17 pm
Location: Au bord de la rivière
Contact:

Postby Tomchi » Fri Aug 25, 2006 6:35 pm

As you know i'm quite busy with DCK poo :P but indeed i want to learn coding !!!!
Gfa seems to be something I can learn .
I wish I was clever enough to learn assembly but the tutorials I read brought me back to reality !!! :D

Thx a lot
There's no way to happiness, happiness is the way ...

Noextra

User avatar
Tomchi
Captain Atari
Captain Atari
Posts: 377
Joined: Sat Jun 10, 2006 5:17 pm
Location: Au bord de la rivière
Contact:

Postby Tomchi » Fri Aug 25, 2006 9:10 pm

yeah in fact i already went in your website many times ... It's a very good site ...
As for the gfa stuffs, the xlr8 rout and the punchs ( ST Mag rulez, forget the restz !!! lol ) seem to be helpful to me . But loading a pic and setting resolution is something I already know, basic stuffs such as these just run as basis but i need more !!! ;)
There's no way to happiness, happiness is the way ...

Noextra

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

Postby lp » Fri Aug 25, 2006 9:17 pm

Tomchi wrote:And what about this $C+ at the top of your listing ?


Since I have made repairs to the compiler I can tell you exactly what $C+ does. Option $C+ instructs the compiler to save and restore some critical registers it relies on for it's own internal use. It only effects the C: and CALL commands. If you don't use these 2 commands, it has no effect at all. The default behavior is to not save the registers, as GFA trusts you to leave a3 to a6 alone. But if you wish to use a3 to a6, then $C+ comes in handy.

Little example:

$C+
' bunch of gfa code...
' C+ causes compiler to insert movem.l a3-a6,-(sp) just before C:
result%=C:assembler_routine%(L:param1%,L:param2%)
' then the compiler inserts movem.l (sp)+,a3-a6 after the C:
' more gfa code...
END

Also whilst I was skimming back over the thread. Just a quick note. The MSHRINK() command is completely broken when compiled, nasty bug in the compiler. It will return -40 always because it passes the parameters backwards to gemdos and fails. It does however work ok in the editor. Best to use the direct gemdos call or use a revised compiler.

User avatar
Tomchi
Captain Atari
Captain Atari
Posts: 377
Joined: Sat Jun 10, 2006 5:17 pm
Location: Au bord de la rivière
Contact:

Memory problems now ...

Postby Tomchi » Thu Sep 27, 2007 11:02 am

And ....... YES, I'm back on this thread !

More than one year has passed and I'm on the way to finish my stuffs.
But then I still got a problem ... not very surprising though !

As some people know I intend to do a compilation of screens I've done using D.C.K and I want to code a loader in gfa which displays a pic and some text between two screens .
I do it using steem with 2mb ram.
Everything runs well exept I have a 3 bombs error when trying to load the eighth or ninth screen ....
Tried with 1 mb ram and I just can run 3 or 4 screens.
So I guess ( ouch genius :D ) that's memory problem.

My new question is how to clear the free memory before loading the next screen ?

I do reserve about 20k for the pics and little anim.
Does the Gfa load the screens randomly in memory ? or one after the other ? (well seems to be that )
I tried some tricks as
adr%=fre(0)-20000
' bla bla bla
'pexec
~MFREE(adr%)
'loop
but that doesn't change anything ...

Is there a way to know where the screens are loaded, or force gfa to load them in a special place ?

these memory manipulations are definitively hard :(
There's no way to happiness, happiness is the way ...

Noextra

User avatar
Tomchi
Captain Atari
Captain Atari
Posts: 377
Joined: Sat Jun 10, 2006 5:17 pm
Location: Au bord de la rivière
Contact:

Postby Tomchi » Thu Sep 27, 2007 12:49 pm

My apologies :$
Please forgive me !!!
I think I 've got it
just have to mfree bp% ....
seems to work from begining to the end now !
I'll wait this evening to compile it and see if it works on my real machine ...
There's no way to happiness, happiness is the way ...

Noextra

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

Postby lp » Thu Sep 27, 2007 1:29 pm

Depending on how you pexec(mode?) the sub programs, the memory can be owned by the calling application, thus you have to manage the memory yourself after it terminates.

I'm also back after nearly 8 months of doing next to nothing.
Squashing some newly found bugs in the gfa compiler. 8O

I wish you luck, hope you have solved it. :D


Social Media

     

Return to “GFA BASIC”

Who is online

Users browsing this forum: No registered users and 2 guests