bratt@csli.Stanford.EDU (Harry Bratt) (06/05/91)
I'm very new to programming the Amiga and I have a question which I couldn't find an answer to in any of the books I've looked at: How do you make a hardware sprite disappear without doing FreeSprite() ? Is there a safe and sanctioned way of doing this? I can think of some ways but they seem like kludges. I guess a related question is: is freeing it the best way to go? I'd rather just acquire a hardware sprite in the beginning of my program and keep it until the end, making it pop up and disappear when needed (it's just being used as a sort of pop-menu attached to the RMB - it never changes shape, etc.). So - should I be doing GetSprite(), FreeSprite() all over the place? Should I be doing a ChangeSprite() to point to a block of 0's? Should I MoveSprite() outside the bounds of the ViewPort??? Could I set the height to 0???????? The first way seems more work than necessary and the last 3 sound like kludges to one degree or another. -Harry bratt@csli.stanford.edu
valentin@public.BTR.COM (Valentin Pepelea) (06/07/91)
In article <19672@csli.Stanford.EDU> bratt@csli.Stanford.EDU (Harry Bratt) writes: > >How do you make a hardware sprite disappear without doing FreeSprite() ? >So - should I be doing GetSprite(), FreeSprite() all over the place? >Should I be doing a ChangeSprite() to point to a block of 0's? >Should I MoveSprite() outside the bounds of the ViewPort??? >Could I set the height to 0???????? Do not FreeSprite() like crazy. That function might take too long to execute. The way I clear the sprite is by ChangeSprite()'ing to a buffer full of 0's. I could just set the height to 0, but I would have to store the current height into a temporary variable, and I don't want to waste time doing that. >and the last 3 sound like kludges to one degree or another. Not kludges, but choose whatever method suits you best. Valentin -- "An operating system without virtual memory Name: Valentin Pepelea is an operating system without virtue." Phone: (408) 985-1700 Usenet: mips!btr!valentin - Ancient Inca Proverb Internet: valentin@btr.com
spence@cbmvax.commodore.com (Spencer Shanson) (06/08/91)
In article <2979@public.BTR.COM> valentin@public.BTR.COM (Valentin Pepelea) writes: >In article <19672@csli.Stanford.EDU> bratt@csli.Stanford.EDU (Harry Bratt) >writes: >> >>How do you make a hardware sprite disappear without doing FreeSprite() ? > >>So - should I be doing GetSprite(), FreeSprite() all over the place? >>Should I be doing a ChangeSprite() to point to a block of 0's? >>Should I MoveSprite() outside the bounds of the ViewPort??? >>Could I set the height to 0???????? > >Do not FreeSprite() like crazy. That function might take too long to execute. >The way I clear the sprite is by ChangeSprite()'ing to a buffer full of 0's. >I could just set the height to 0, but I would have to store the current height >into a temporary variable, and I don't want to waste time doing that. > Valentin, ChangeSprite() has to MoveSprite(), whereas FreeSprite() is much simpler - point the sprite to a default sprite of 0s. I would be surprised if you have found ChangeSprite() to be faster than FreeSprite(). >Valentin -- --------------------------------------------------------------------------- Spencer Shanson - Amiga Software Engineer | email: spence@commodore.COM | or uunet!cbmvax!spence All opinions expressed are my own, and do not | Bix: sshanson (necessarily) represent those of Commodore. | "Copper? I hardly even | know her!"
valentin@public.BTR.COM (Valentin Pepelea) (06/08/91)
In article <22258@cbmvax.commodore.com> spence@cbmvax.commodore.com (Spencer Shanson) writes: > >Valentin, ChangeSprite() has to MoveSprite(), whereas FreeSprite() >is much simpler - point the sprite to a default sprite of 0s. I would be >surprised if you have found ChangeSprite() to be faster than FreeSprite(). On the other hand, restoring the sprite will require an additional call to GetSprite(). So the question is whether FreeSprite() and GetSprite() together are faster than just ChangeSprite(), praticularly when you take into account the overhead of calling these functions. There are advantages to having access to the source code, so why don't you tell me. Valentin -- "An operating system without virtual memory Name: Valentin Pepelea is an operating system without virtue." Phone: (408) 985-1700 Usenet: mips!btr!valentin - Ancient Inca Proverb Internet: valentin@btr.com
spence@cbmvax.commodore.com (Spencer Shanson) (06/11/91)
In article <2987@public.BTR.COM> valentin@public.BTR.COM (Valentin Pepelea) writes: >In article <22258@cbmvax.commodore.com> spence@cbmvax.commodore.com (Spencer >Shanson) writes: >> >>Valentin, ChangeSprite() has to MoveSprite(), whereas FreeSprite() >>is much simpler - point the sprite to a default sprite of 0s. I would be >>surprised if you have found ChangeSprite() to be faster than FreeSprite(). > >On the other hand, restoring the sprite will require an additional call to >GetSprite(). So the question is whether FreeSprite() and GetSprite() together >are faster than just ChangeSprite(), praticularly when you take into account >the overhead of calling these functions. There are advantages to having access >to the source code, so why don't you tell me. > OK - we can either: 1) ChangeSprite() to offscreen 2) ChangeSprite() to onscreen or 1) FreeSprite() 2) GetSprite() 3) ChangeSprite() Now, GetSprite() is another simple function, whereas MoveSprite(), which is called indirectly when you use ChangeSprite(), is a relatively complex piece of code. So because a FreeSprite()/GetSprite() combination is one less call to ChangeSprite(), I believe it would be the faster method *from code inspection*. I haven't proved it though with experimentation. >Valentin >-- >"An operating system without virtual memory Name: Valentin Pepelea > is an operating system without virtue." Phone: (408) 985-1700 > Usenet: mips!btr!valentin > - Ancient Inca Proverb Internet: valentin@btr.com -- --------------------------------------------------------------------------- Spencer Shanson - Amiga Software Engineer | email: spence@commodore.COM | or uunet!cbmvax!spence All opinions expressed are my own, and do not | Bix: sshanson (necessarily) represent those of Commodore. | "Copper? I hardly even | know her!"