[comp.sys.amiga] DiskObject

debate2@watdcsu.waterloo.edu (Dave Oh) (05/23/88)

Hello.  I'm trying to do some things with Workbench objects and I was
wondering... If I were to AllocRemember the DiskObect into CHIP ram,
would the subsequent Gadgets and Images be located there too?
 
Let's say, for example:
 
main() 
{
  struct DiskObject *dobj; 
       
  dobj = AllocRemember(&myRememberList,sizeof(struct DiskObject),          
         MEMF_CHIP|MEMF_CLEAR);
 
If I had this, would my dobj->do_Gadget.GadgetRender image be in Chip ram too?
 
Please help.   
 
:::> Dave Oh

uucp: debate2@watdcsu.waterloo.edu

cmcmanis%pepper@Sun.COM (Chuck McManis) (05/26/88)

In article <4725@watdcsu.waterloo.edu> (Dave Oh) writes:
> If I were to AllocRemember the DiskObect into CHIP ram, would the
> subsequent Gadgets and Images be located there too? 

No. The reason being that the other objects are pointed to by this
structure and haven't been allocated at all! In your example :
       
>  dobj = AllocRemember(&myRememberList,sizeof(struct DiskObject),          
>         MEMF_CHIP|MEMF_CLEAR);
>If I had this, would my dobj->do_Gadget.GadgetRender image be in Chip ram too?

Now you would have to follow that with an 
   dobj->do_Gadget.GadgetRender = AllocRemember(&mrl,sizeof(struct Image),
					MEMF_CHIP+MEMF_CLEAR);
(assuming you will have images for your icons.)

Also you don't have to put gadget or disk object structures in chip ram,
only the *image data* in image rendered gadgets. For for your typical gadget
that uses Images for rendering in the image structure only the 
ImageData pointer has to point to chip ram, everything else can be in
fast ram. All other types of gadgets can be completely in fast ram (this
includes borders and IntuiText etc). Basically, just remember your image
data has to be in chip ram, and that includes little images used for 
gadgets and the Bitmaps associated with windows and screens. 


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.

debate2@watdcsu.waterloo.edu (Dave Oh) (05/27/88)

In article <54486@sun.uucp> cmcmanis@sun.UUCP (Chuck McManis) writes:

>Now you would have to follow that with an 
>   dobj->do_Gadget.GadgetRender = AllocRemember(&mrl,sizeof(struct Image),
>					MEMF_CHIP+MEMF_CLEAR);
>(assuming you will have images for your icons.)

Ok... What if I were to call dobj=GetDiskObject(disk); ?
The GetDiskObject call returns a pointer to FAST ram, for gadget, diskobject
and image... I've tried to CopyMem(&dobj->do_Gadget.GadgetRender,&nimage,
sizeof(struct Image)); and I get a lock up!  Even in Manx SDB.
 
I figured that even thought the GetDiskObject returns FAST Ram memory,
All I'd have to do is just copymem it to another Image struct Allocated in
CHIP ram, and then redirect the dobj->do_Gadget.GadgetRender pointer to my
new Image struct.  this didn't work...
 
Is there a way to force GetDiskObject to return a pointer to CHIP ram?

:::> Dave Oh           uucp: debate2@watdcsu.waterloo.edu

dpvc@ur-tut (Davide P. Cervone) (06/01/88)

In article <4751@watdcsu.waterloo.edu> debate2@watdcsu.waterloo.edu (Dave Oh) writes:
>Ok... What if I were to call dobj=GetDiskObject(disk); ?
>The GetDiskObject call returns a pointer to FAST ram, for gadget, diskobject
>and image... I've tried to CopyMem(&dobj->do_Gadget.GadgetRender,&nimage,
>sizeof(struct Image)); and I get a lock up!  Even in Manx SDB.

But doesn't CopyMem use the blitter to move the memory?  If so, then you
CAN'T use it to move your image from FAST memory to CHIP.  You'll need to
have the CPU do the memory move, not the blitter.  There probably is a Manx 
library routine that does this (like movemem or something).

>I figured that even thought the GetDiskObject returns FAST Ram memory,
>All I'd have to do is just copymem it to another Image struct Allocated in
>CHIP ram, and then redirect the dobj->do_Gadget.GadgetRender pointer to my
>new Image struct.  this didn't work...

It should, provided you use the CPU to copy the memory instead of the blitter.

If I'm wrong about CopyMem using the blitter, then you can ignore this message.

Davide P. Cervone
dpvc@tut.cc.rochester.edu

elg@killer.UUCP (Eric Green) (06/01/88)

in article <2135@ur-tut.UUCP>, dpvc@ur-tut (Davide P. Cervone) says:
> Xref: killer comp.sys.amiga.tech:935 comp.sys.amiga:20028
> In article <4751@watdcsu.waterloo.edu> debate2@watdcsu.waterloo.edu (Dave Oh) writes:
>>Ok... What if I were to call dobj=GetDiskObject(disk); ?
>>The GetDiskObject call returns a pointer to FAST ram, for gadget, diskobject
>>and image... I've tried to CopyMem(&dobj->do_Gadget.GadgetRender,&nimage,
>>sizeof(struct Image)); and I get a lock up!  Even in Manx SDB.
> 
> But doesn't CopyMem use the blitter to move the memory?  If so, then you
> CAN'T use it to move your image from FAST memory to CHIP.  You'll need to
> have the CPU do the memory move, not the blitter.  There probably is a Manx 
> library routine that does this (like movemem or something).

CopyMem does not use the blitter. I've used it to copy data that's nowhere
near CHIP memory.

One thing to note about CopyMem and the corresponding Manx library routine
(movemem): they do not properly handle overlapping data areas. In particular,
they do a low-to-high move, ALWAYS... which, when the destination overlaps at
a higher address, overwrites the top of the source area before that area of
memory has been copied (thus garbaging everything). Ideally, they should
do a high-to-low move upon detecting such a condition. 

Note that this behavior is NOT documented, not even in the Manx 3.60 docs for
"movemem". I found out about it the hard way (doing block moves for a simple
full-screen editor :-(.  ).

I have a sample program that demonstrates the problem, but, alas, it's on the
Amiga at work, and I'm here on my 128 at home.

--
    Eric Lee Green                     {cuae2,ihnp4}!killer!elg
         Snail Mail P.O. Box 92191 Lafayette, LA 70509              
"Is a dream a lie if it don't come true, or is it something worse?"

ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (06/02/88)

In article <2135@ur-tut.UUCP> dpvc@tut.cc.rochester.edu.UUCP (Davide P. Cervone) writes:
>In article <4751@watdcsu.waterloo.edu> debate2@watdcsu.waterloo.edu (Dave Oh) writes:
>>The GetDiskObject call returns a pointer to FAST ram, for gadget, diskobject
>>and image... I've tried to CopyMem(&dobj->do_Gadget.GadgetRender,&nimage,
>>sizeof(struct Image)); and I get a lock up!  Even in Manx SDB.

	Try this:

	CopyMem (&dobj -> do_Gadget.GadgetRender,
		 &nimage,
-->		 (LONG) sizeof (struct Image));

	This is probably what's killing you.

>But doesn't CopyMem use the blitter to move the memory?  [ ... ]

	No.  I use it in FAST all the time.

>If I'm wrong about CopyMem using the blitter, then you can ignore this message.
>
	Oh.  Okay......

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape  ihnp4!pacbell -\
 \_ -_		Recumbent Bikes:	      dual ---> !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor

debate2@watdcsu.waterloo.edu (Dave Oh) (06/05/88)

In article <6148@well.UUCP> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes:
>In article <2135@ur-tut.UUCP> dpvc@tut.cc.rochester.edu.UUCP (Davide P. Cervone) writes:
>>In article <4751@watdcsu.waterloo.edu> debate2@watdcsu.waterloo.edu (Dave Oh) writes:
>>>The GetDiskObject call returns a pointer to FAST ram, for gadget, diskobject
>>>and image... I've tried to CopyMem(&dobj->do_Gadget.GadgetRender,&nimage,
>>>sizeof(struct Image)); and I get a lock up!  Even in Manx SDB.
>
>	Try this:
>
>	CopyMem (&dobj -> do_Gadget.GadgetRender,
>		 &nimage,
>-->		 (LONG) sizeof (struct Image));
>
>	This is probably what's killing you.
>
 
I tried the above and after looking at the struct dobj after the CopyMem, my
dobj pointers get wacked out of place and I get crazy values for do_type etc.
 
What could be doing this?  I'll show you the bit of code around the CopyMem:
 
IDisk(DiskName)
char *DiskName;
{
  struct DiskObject *gdisk;
  struct DiskList *DiskLst;
  struct Image    *Img;

  char Buffer[36];

  strcpy(Buffer,DiskName);
  strcat(Buffer,":Disk");
  printf("\nName: %s\n",Buffer);

  gdisk=GetDiskObject(Buffer);

  if(gdisk==0)
     printf("---- Cannot Open %s.info file. ----\n",Buffer);
  else {
     Img = (struct Image *)
           AllocRemember(&miscMemList,sizeof(struct Image),CHIPRAM);

     CopyMem(&gdisk->do_Gadget.GadgetRender,&Img,(LONG)sizeof(struct Image));
     gdisk->do_Gadget.GadgetRender = (APTR)Img;

     printf("version: %d\nType: %d\nXpos: %d\nYpos: %d\nStack: %d\n",
     gdisk->do_Version, gdisk->do_Type, gdisk->do_CurrentX, gdisk->do_CurrentY,
     gdisk->do_StackSize);
  }
}

Please help and thanx in advance.
 
:::> Dave Oh		uucp: debate2@watdcsu.waterloo.edu

debate2@watdcsu.waterloo.edu (Dave Oh) (06/15/88)

In article <2925@louie.udel.EDU> Dickson@his-phoenix-multics.arpa (Paul Dickson) writes:

>
>Looking back of the discussion so far, you haven't mention what version
>of the Manx compiler you are using (you only mentioned using Manx's
>SDB).  I'm only willing to believe that there's something wrong with the
>compiler only if you're using their latest version (3.6a?).  Version 3.4
>was pretty much well used.
>
>          -Paul Dickson

I am using Manx 3.6a and SDB.  Acutally, the problem lied where I was using
the & mbol to get the address of an address.
 
DObj->do_Gadget.GadgetRender is already a pointer, what I was doing was
getting the pointer to the pointer that was pointing to my Image struct
(did you all get that :-)  (Thanx Himash MacDonald!)
 
Now, the problem is I can't display my Gadget.  I used the AddGadget function
and I checked the TopEdge and LeftEdge of the image, and it is in the limits
of the window. The Image is in  CHIP But is still won't display.  I did a
RefreshGadgets and even refreshed the all displays and windows and screens!  Still no gadgets... 
 
Please help, _Again_ 
 
Thanx:   
 
:::> Dave			debate2@watdcsu.waterloo.edu

debate2@watdcsu.waterloo.edu (Dave Oh) (06/15/88)

In article <6201@well.UUCP> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes:
 
>:     CopyMem(&gdisk->do_Gadget.GadgetRender,&Img,(LONG)sizeof(struct Image));
>:	      ^
>	BZZT!  You are taking the address of the GadgetRender pointer, not
>the pointer itself (which is what you want).  Delete the '&' and you
>*should* be fine.
>
>	I should have seen this the first time....

You're Right... And you have to get rid of the & in front for Img struct.  I don't know how I couldn't see that.  (OK.  No more Pink Floyd while I program :-)
 
Thanx.
 
PS: Now how can I display this gadget.  I tried everything and It still won't display.  I AddGadget() it to my Backdrop window and then RefreshGadget() with no success.  I checked the TopEdge and LeftEdge attributes and they are within the limits of hte window.  What now, eh?
 
:::> Dave			debate2@watdcsu.waterloo.edu