1. Fast Image Routine & Saving a sequence

#######################
                    Faster Image Routines
                #######################

        I have just seen the XP3 image routines and noticed that they could
be a lot faster, i will start off with the VGA memory addressing.
        The VGA memory is 64000 bytes big, it's NOT 320*200. Remember that
you needn't have to locate a pixel on screen by x & y positions,
unless you really want to!! And if you do, do not calculate your pos
in memory with (y*200), but make a look-up table. You should always
make a look-up table in graphic-mode. Doing stuff like * and / takes
more time from the CPU then using an Euphoria Pixel routine.
        Better not use sequences, but allocate memory space and copy pieces
of memory to the VGA memory.
        If you want to copy more than one entire row, poke it all in once
instead of poking row by row. However the you must poke an entire
row, cause after the place where the row ends the new one should
start!
        Why does 0 or 6 return 1 instead of 6 ?? and does anyone know why
you can't use XOR on sequences??? It would be helpfull for sprites,
the best idea would be to have mem_copy functions with OR, XOR, NOT &
AND.  And to have the ability to skip a number of bytes each 320 or
200 or any other specified value with a mem_copy command,  (If anyone
at RDS woud be so nice to include it in a new version, ask me for
details about the suggestion to skip a number of values, i'll then
explain it better.)
        If you use sprites, you must copy each horizontal line seperately,
if you do so (and you must for sprites) you should start each line
where the first not see-through pixel is. You can store these values
in a look-up table(sequence!) . And offcourse you must end where the
last not see-through pixel is, this speeds sprites with a lot of
see-through pixels on the side up a lot! Also mark for each sprite if
it has any see-through pixels NOT on a side. Cause if all the pixels
are on the side, you needn't have to check for see-through pixels.
Balls in pinball games could be draw a lot quicker that way, starting
each horizontal line where the real image begins and ending each
horizontal line where the real picture ends.
        The above sprite method is not usefull when your sprite is as width
as the screen, if it is you should copy all the horizontal lines in
once instead of each line seperately.
        You can also use sequences, then you must have a virtual screen
with the background data and a virtual screen with the foreground
data, each of the SAME size. Don't use a 2-dimensioned sequence, but
use one long sequence, cause it uses less memory, and can be poked
very quickly to the screen in once . (Only if the virtual screens
have the sane width as the real screen!)
        The only comment on the XP3 source is that they poke each line
seperately which they needn't, they can poke it all in once!!
`````````````````````````````````````````````````````````````````````

                #########################
                    Saving a sequence to disk
                #########################
        The XP3 source also allows you to load & save multiple pictures to
disk, that's handy but very restrictive. I'll write a routine which
save an Euphoria sequence to disk with LZH Compression maintaining
it's orgininal structure. That kind of routine can be used for a much
more purposes. I will be using the same technique as i used in EDM.E
`````````````````````````````````````````````````````````````````````

        BTW This mail maight look really negative about your routines(XP3),
but i'm not. I have much more inspiration now thanks to your
routines, and your alpha version of your game looks really nice,
still i would change the code the poke virtual screens (like the ones
you use) in once, not row by row!       And i really appriciate people
sharing code like this, take for example lord generic production
which problely has really nice routines, but they aren't available
unless you pay them money. I know that they earn the money and they
problely need it too, but it's unfair to all the people (including
you) who do give their techniques away for free. He uses the font
library and sound blaster routines, but do they get any of the money
he earns with it?? I do not know, but i am curious, if not it would
be so unfair!! (Since they do got to pay for his routines!!)

        I know, it was too long, i should be ashamed and your problely
didn't read it all too, well that's your problem isn't it??

BTW How many dutch people are on this ??
        (I know about 2)


Ralf Nieuwenhuijsen
nieuwen at xs4all.nl
````````````````````````````````````````````````````````````````

new topic     » topic index » view message » categorize

2. Re: Fast Image Routine & Saving a sequence

>                #######################
>                    Faster Image Routines
>                #######################
>
>        I have just seen the XP3 image routines and noticed that they could


Am I missing something? What are the "XP3 image routines"?

>                #########################
>                    Saving a sequence to disk
>                #########################
>        The XP3 source also allows you to load & save multiple
>pictures to disk, that's handy but very restrictive. I'll write a
>routine which save an Euphoria sequence to disk with LZH Compression
>maintaining it's orgininal structure. That kind of routine can be
>used for a much more purposes. I will be using the same technique as
>i used in EDM.E

Let me know when it's done and I'll check it out.

>And i really appriciate
>people sharing code like this, take for example lord generic
>production which problely has really nice routines, but they aren't
>available unless you pay them money. I know that they earn the money
>and they problely need it too, but it's unfair to all the people
>(including you) who do give their techniques away for free. He uses
>the font library and sound blaster routines, but do they get any of
>the money he earns with it?? I do not know, but i am curious, if not
>it would be so unfair!! (Since they do got to pay for his
>routines!!)

Please. Let's not get into *that* flame war again. We've already gone
in circles about the fairness of Packard selling his code. I think to
sell or not to sell is the authors personal choice. I myself plan to
sell *some* code if I ever write anything worth selling.

~~>Joseph Martin
~~>E-mail:  joe at cyber-wizard.com
~~>URL: http://users.exis.net/~jam/

new topic     » goto parent     » topic index » view message » categorize

3. Re: Fast Image Routine & Saving a sequence

On Tue, 27 May 1997 22:28:53 +0000 Ralf Nieuwenhuijsen
<nieuwen at magigimmix.xs4all.nl> writes:
>---------------------- Information from the mail header
>
>        Why does 0 or 6 return 1 instead of 6 ??

Answer is that or is a logical operator just like | in C
or_bits is the bitwise operator in euphoria like || in C.
or_bits was an after thouht so it is a function not a
normal operator.  Examples are below.

x = 0 or 6
-- x = 1
y = or_bits(0, 6)
--- y = 6

>and does anyone know why you can't use XOR on sequences???
>It would be helpfull for sprites,


I can't see where xor_bits() would be useful.
PLEASE enlighten me.
I know that just using or_bits() is a cheap method of
transparency.  I say cheap because it doesn't achieve
TRUE transparency. The original colors are mangled
in the attempt to create transparency.

These two functions should do all you need.
The color to be used as transparent can be any color
from 0 to 255.
You must keep in mind that your background image
MUST be of exact size and shape as your foreground
image. EXAMPLE


Screen is this size
+-----------------+
|                 |
|                 |
|                 |
|                 |
+-----------------+
You want to place image here.
+-----------------+
|                 |
|      +---+      |
|      |   |      |
|      +---+      |
+-----------------+
You must cut that section of the screen to
be used as the background image to be mixed.

foreg = sequence
backg = same shape sequence as foreg
fimage = Filter_Image(foreg, BLACK)

fimage is a filter of the foreground to be kept
this can be created once and used every time
You use the foreg to create a mixed image.
A mixed image is an image that shows the backg
through the foreg. The mixed image can then
be displayed to the screen without checking
for transparency with difficult and painfully
slow LOOPS.

Filter_image is slow because it uses multiplying.
The equality check is slow enough.
For a very slight increase in speed you can replace
fimage = (fimage = color)
with
fimage = not fimage

However this will not allow any color. It checks for
ONLY black.  color zero (0)

global function Filter_Image(sequence fimage, integer color)
  fimage = (fimage = color)
  fimage = fimage * 255
  return fimage
end function

global function Mix_Image(sequence fore, sequence back, sequence filter)
  filter = and_bits(filter, back)
  filter = or_bits(filter, fore)
  return filter
end function

>                #########################
>                    Saving a sequence to disk
>                #########################
>        The XP3 source also allows you to load & save multiple
>pictures to
>disk, that's handy but very restrictive. I'll write a routine which
>save an Euphoria sequence to disk with LZH Compression maintaining
>it's orgininal structure. That kind of routine can be used for a much
>more purposes. I will be using the same technique as i used in EDM.E
>
>Ralf Nieuwenhuijsen
>nieuwen at xs4all.nl

I will be interested in seeing this routine. I have many
uses for this.

--Lucius Lamar Hilley III
--  E-mail at luciuslhilleyiii at juno.com
--  I support transferring of files less than 60K.
--  I can Decode both UU and Base64 format.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Fast Image Routine & Saving a sequence

> you use) in once, not row by row!       And i really appriciate people
> sharing code like this, take for example lord generic production
> which problely has really nice routines, but they aren't available
> unless you pay them money. I know that they earn the money and they
> problely need it too, but it's unfair to all the people (including
> you) who do give their techniques away for free. He uses the font
> library and sound blaster routines, but do they get any of the money
> he earns with it?? I do not know, but i am curious, if not it would
> be so unfair!! (Since they do got to pay for his routines!!)

The documentation and license's included in "The Book" are only for our
code.  I don't document anyone else's code, only how we used it in our
productions.  Anyone who buys the book learns how WE did OUR game.  If
Jacques or Jiri want to document their work (I really wish they would) so
everyone understands it, I would LOVE to see the book (and would pay for
it in a heartbeat)

As for royalties being paid to other euphoria programmers whose code I'm
using in our games, that is our policy.  If we use an include file created
by someone in this group or anyone else, regardless of whether or not it
was released in the public domain, we pay royalties based on net sales of
the product.  (assuming we EVER sell any)  Everyone who has a credit in
our games gets a cut of whatever we make.

Michael Packard
Lord Generic Productions
lgp at exo.com http://exo.com/~lgp
A Crash Course in Game Design and Production
http://exo.com/~lgp/euphoria

new topic     » goto parent     » topic index » view message » categorize

5. Re: Fast Image Routine & Saving a sequence

On Tue, 27 May 1997, Ralf Nieuwenhuijsen wrote:
>         The VGA memory is 64000 bytes big, it's NOT 320*200. Remember that

huh?  320*200=64000.

Michael Packard
Lord Generic Productions
lgp at exo.com http://exo.com/~lgp
A Crash Course in Game Design and Production
http://exo.com/~lgp/euphoria

new topic     » goto parent     » topic index » view message » categorize

6. Re: Fast Image Routine & Saving a sequence

>[ I'm not gonna put your long message in here ...]
        (I'm gonna try to write a longer one.. ..let's see who wins!)

        First, thanx for the simple and easy to use code. I can now use it
in my code without any function or proceure. Using less of those is
the best optimization you can have. Just plotting a pixel goes faster
if you do it directly with a machine_proc() call.
        My only real point was that sometimes it isn't nessesary to poke
each line seperately. If you made a sequence of 6400 length if stead
of a 2d sequence of 320 * 200 you have the possibility to poke the
total screen in once!!
        And i thought that in some way XOR was used to make an sprite-mask,
guess not! If someones says their is a technique using XOR, tell me.
        I am not on this list-serv to talk about moral values and stuff, but
read my other mail, where i make my point clear and closed. However
know that i have never knew that this discussion had already
happened.
        Still, each time i use pokes & peekes i feel a bit bad, cause i am
just trowing away all the portability that Euphoria has to offer. And
i insult Euphoria by not using their normal pixel & display_image
routine, by not using them i admit that there are weak and i think
next releases of Euphoria should fix this.
        Also i wonder how quick a program runs when you write a pre-compiler
that changes all the calls to constant variables to their value, it
might be a lot and i think that in a next Euphoria release the ex.exe
program should be made to handle ENUMS and NAMES. Names are then used
for a specified sequence entry and enums for values of a specified
sequence entry or atom. Cause now you have to write a zillion lines
of code just containing constants.
        And a look-up table in Euphoria is slow, not as slow as multiplying,
but slow cause it has flexibilities it doesn't need, a look-up table
doesn't need the ability to be changed in any way. (Size, Values..)
        Maybe Euphoria needs a new data type called tables, a fixed size,
fixed dimensioned sequence optimized for speed , but with two big
advantage, they should handle slicing like this:

        my_table[2..3][3..8][0..10] = {4,5,6,{5,6}}

        And they should allow uninitialized entries. When a routine is
called given a uninitialized value, it should be ignored. Tables
containing those values offcourse not!
        For extra speed it would be nice if you could specify the number of
bits it is using or just say sequence, which means that it is a
sequence table. Offcourse a sequence can also contain tables.

        Oops, i'm keep on loosing my subject and move over to another.

~~~~~~~~~~~~~~~~~~~
Ralf Nieuwenhuijsen
nieuwen at xs4all.nl

new topic     » goto parent     » topic index » view message » categorize

7. Re: Fast Image Routine & Saving a sequence

>         My only real point was that sometimes it isn't nessesary to poke
> each line seperately. If you made a sequence of 6400 length if stead
> of a 2d sequence of 320 * 200 you have the possibility to poke the
> total screen in once!!

I tried this on my computer, and I found that poking the screen row
by row is about 14% FASTER than doing it all at once.
Did you try this?

Michael Bolin

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu