[comp.sys.amiga.programmer] RASTPORT from ML

v089pfrb@ubvmsd.cc.buffalo.edu (Jeffrey C Murphy) (03/14/91)

 How do you locate the rastport value from machine language if
your program is using the cli as the output window?

Thanx 
JM

Harvey_Taylor@mindlink.UUCP (Harvey Taylor) (03/15/91)

In <65143@eerie.acsu.Buffalo.EDU>, v089pfrb@ubvmsd.cc.buffalo.edu
                                        (Jeffrey C Murphy) writes:
|
| How do you locate the rastport value from machine language if
|your program is using the cli as the output window?
|

    You send you console task a packet, as outlined in the excerpt below.
 (Watch out for NULL values in the args returned. ie. Not a CLI, not a
  window)
+--
| A DiskInfo packet (ACTION_DISK_INFO = 25L) sent to the console handler
| ((struct MsgPort *)process->pr_ConsoleTask)) now returns not only the
| window pointer in the id_VolumeNode field, but also a pointer to the
| console IO block used by the console handler in the id_InUse field.
| (These fields are part of the InfoData structure that is filled
| in by sending the ACTION_DISK_INFO packet).  Remember that you must
| AllocMem your InfoData structure to assure longword alignment
| since a BPTR to the structure is arg[0] of the packet.
| A pointer to the ConUnit structure (see devices/conunit.h, .i)
| can be found via the console IO block pointer:
|      conUnit = (struct ConUnit *)
|                ((struct IOStdReq *)infoData->id_InUse)->io_Unit;
|
| There is a lot of useful information in the ConUnit structure
| such as text cursor position and limits.  If you are using the
| exec console.device directly, you should be able to get the
| ConUnit pointer from yourIoRequest->io_Unit.
+--

    If you are in the dark on DOS Packets you can take a look at:

    DOS Packets References
    ======================

    SENDPACKET.C by Lindsay (FF35 & 66)
    ASENDPACKET.C by Lindsay (FF35 & 66)
    CONPACKETS.C by Carol Scheppner (FF56)
    New DosPackets.txt by Carol Scheppner  (FF65)
    AMIGADOS.txt by Tim King
    MonProc.c by P. Lindsay  (FF69)
    MonProc.c by P. Lindsay  (FF79)
    PickPacket by Toebes & Walker (FF227)
    PacketSupport (a library) by O.Wagner (FF346)
    ---
    The Matt Dillon article in Trans-Ami #1
    The AmigaDOS Technical Reference Manual
    William Hawes in AA&J V3,#2.
    ---
    -het

    PS.
    I am collecting references on DOS Packets, Exec Devices, FileSystems.
 Email me your lists & I will summarize.

 "You put your eyes in your pocket & your nose on the ground.
  There oughta be some kinda law against you comin around." -R.Zimmerman

      Harvey Taylor      Meta Media Productions
      uunet!van-bc!rsoft!mindlink!Harvey_Taylor
               a186@mindlink.UUCP

dac@prolix.pub.uu.oz.au (Andrew Clayton) (03/15/91)

In article <65143@eerie.acsu.Buffalo.EDU>, Jeffrey C Murphy writes:

> 
>  How do you locate the rastport value from machine language if
> your program is using the cli as the output window?
> 
> Thanx 
> JM

Well, I reckon if you can work with ML, decoding the following Modula 2
(M2Sprint) code shouldn't prove too difficult. 

FROM RunTime       IMPORT ExecBase, IntuitionBase;

(*****************************************************************************)   
   intbase     := IntuitionBase;            (*All this hassle to get*)
   windowptr   := intbase^.ActiveWindow;    (*the magic item for DrawImage*)
   rport       := windowptr^.RPort;         (*called the RastPort!*)
(*****************************************************************************)


Good luck.

Dac
--
David Andrew Clayton. // _l _  _ dac@prolix.pub.uu.oz.au    *or*|I post.I am.
Canberra, Australia.\X/ (_](_l(_ ccadfa.cc.adfa.oz.au!prolix!dac@munnari.oz

d88ricwe@odalix.ida.liu.se (Rickard Westman) (03/16/91)

dac@prolix.pub.uu.oz.au (Andrew Clayton) writes:
>In article <65143@eerie.acsu.Buffalo.EDU>, Jeffrey C Murphy writes:

>>  How do you locate the rastport value from machine language if
>> your program is using the cli as the output window?

>(***************************************************************************)
>   intbase     := IntuitionBase;            (*All this hassle to get*)
>   windowptr   := intbase^.ActiveWindow;    (*the magic item for DrawImage*)
>   rport       := windowptr^.RPort;         (*called the RastPort!*)
>(***************************************************************************)

>Good luck.

Probably, he'll need it. ;-)

You (or the one who wrote that code) assume that the console window of
the current process is also the active window.  This may be true in
most cases, but clearly not in every case.  The user could, for
instance, deactivate the CLI window in which your program is run from
a script.  The Amiga will happily crash and burn if you use NULL as a
window pointer...

The only *right* way to do this is a bit more complex than your
suggestion.  You'll have to send a DiskInfo packet (ACTION_DISK_INFO = 25L) 
to the console handler ((struct MsgPort *)process->pr_ConsoleTask)).
In return, you will get a window pointer in the id_VolumeNode field,
and some other useful info.

For example code, look at Fred Fish #35.  I haven't seen this code myself,
but I assume it's written in C, so you will have to convert it to machine
language.  

Fish 35: ConsoleWindow
======================
Example program for finding the Intuition pointer to an 
AmigaDos CON: or RAW: window, so you can do WindowToFront,
graphics, and other interesting things.
(Requires AmigaDos 1.2)
Author: Andy Finkel and Robert Burns
--
Rickard Westman, University of Linkoping, Sweden

dac@prolix.pub.uu.oz.au (Andrew Clayton) (03/17/91)

In article <1991Mar16.121732.3678@ida.liu.se>, Rickard Westman writes:

> dac@prolix.pub.uu.oz.au (Andrew Clayton) writes:
> >In article <65143@eerie.acsu.Buffalo.EDU>, Jeffrey C Murphy writes:
> 
> >>  How do you locate the rastport value from machine language if
> >> your program is using the cli as the output window?
> 
> >(***************************************************************************)
> >   intbase     := IntuitionBase;            (*All this hassle to get*)
> >   windowptr   := intbase^.ActiveWindow;    (*the magic item for DrawImage*)
> >   rport       := windowptr^.RPort;         (*called the RastPort!*)
> >(***************************************************************************)
> 
> >Good luck.
> 
> Probably, he'll need it. ;-)
> 
> You (or the one who wrote that code) assume that the console window of
> the current process is also the active window.  This may be true in
> most cases, but clearly not in every case.  The user could, for
> instance, deactivate the CLI window in which your program is run from
> a script.  The Amiga will happily crash and burn if you use NULL as a
> window pointer...

Sure will. My one 'serious' program (Journal) uses that very lump of code,
and does indeed crash and burn if you start it up in background with
anything that causes it to display it's error graphic [yeah, yeah, graphics
in a CLI rastport is pretty tacky, but I thought it was cute].

> The only *right* way to do this is a bit more complex than your
> suggestion.  You'll have to send a DiskInfo packet (ACTION_DISK_INFO = 25L) 
> to the console handler ((struct MsgPort *)process->pr_ConsoleTask)).
> In return, you will get a window pointer in the id_VolumeNode field,
> and some other useful info.

Thanks.  Someone posted similar information to me a few months ago, and I
have lost it within 24Mb of assorted LHARCed archives :-(.  I'll save this
one in my source directory so that I can fix up Journal.

> Rickard Westman, University of Linkoping, Sweden

Dac
David Andrew Clayton. // _l _  _ dac@prolix.pub.uu.oz.au    *or*|I post.I am.
Canberra, Australia.\X/ (_](_l(_ ccadfa.cc.adfa.oz.au!prolix!dac@munnari.oz