1. Text_GUI .4

Thanks for the Text_Gui.  I haven't used it yet, but I have run the Demo
and like it.
I plan to include, at least, parts of it for one of my " in the works "
programs.
I skimmed the intense.e code and found the color and mono Screen
addresses.
I did some working with it and I have created a controlled test run were
I can
"poke" to the screen faster than I can "puts" to the screen.  I haven't
made a
function out of it YET!  When poke short sequences up to about 10
characters
the poke is about 4 or 8 times faster than puts. But even at a full 2000
characters
it slows down some but is still nearly TWICE as fast as puts.

  For those of you who would like to use this information
here are some HINTS on what I tried and finnally used.

When poking to the screen memmory in color your seqeunce has to be in the
following format.   chr = character to display,  colr = color attribute.
{chr, colr, chr, colr......}
Knowing this you will notice that you can't simply poke   "SAMPLE"
you would actually poke  {'S', clr, 'A', clr, 'M', clr, 'P', clr, 'L',
clr, 'E', clr}
to get that out of "SAMPLE" you have to create a loop that inserts the
color
attribute.
EXAMPLE 1

integer color
sequence s
s = "SAMPLE"
color = 15 -- bright white
-- Has to be twice length(s) becuase the end length(s) will be twice
-- length(s).
-- AND it has to by 2 because we are inserting color after each
character.
for a = 1 to length(s) * 2 by 2 do
  s = s[1..a] & color & s[a+1..length(s)] -- have to use length(s)
becuase the length is
                                -- is always increasing.
end for
--now s is ready for poking to screen.
------------------this Example WORKS but it is a BAD technique...
--this insertion method causes the "SAMPLE" to slowly SLIDE to make room
for the
--inserted color attributes.
--better code is
EXAMPLE 2

integer color
sequence s, s2

s = "SAMPLE"
color = 15

s2 = repeat(color, 2 * length(s))-- preparing s2 with colors
--now I will use a similar loop as above to insert the original string
for a = 1 to length(s) do  -- I am not sure but I believe incrementing by
1 is faster than
                        --incrementing by any other number.
  s2[a + a - 1] = s[a] -- this simply inserts s into the color prepared
seqeunce
end for
s = s2 -- sets s for use.
s2 = "" -- causes s2 to use less memory
-----------you use more memory with this technique and more command calls
---- and still have a loop that executes the same number of calls
---- but even with all this extra over head it is faster becuase you
aren't "sliding"
---- or making way for INSERTING color into a shorter string making it
redudantly
---- larger until till it meets the correct size.
----  ABOVE where I used "a+a" I could have used 2 * a but adding is few
times
---- faster than multiplying.

        load Danny's intense.e and search for #b80 and and #b00
#b80 is part of the address number of color and #b00 is for mono.
I don't remember the actual address numbers or I would have posted them.

Have fun                  Lucius L. Hilley III

new topic     » topic index » view message » categorize

2. Text_GUI .4

*** Reply to note of 02/14/97 06:19
thanks for the speed check. i noticed that it is /much/ faster to build
the string, and place the text into it, than it is to append the string
together. for example:

   -- this is slow
   target = ""
   for i = 1 to length( source ) do
      target = target & source[i]
   end for

   -- this is faster
   target = repeat( ' ', length( source ) )
   for i = 1 to length( source ) do
      target[i] = source[i]
   end do

which is why i build the attribute string, and the drop the text into it.

i need to go through the code in the near future, and add a test for mono/
color. i also need to make some variables for the screen size, so you can
change resolutions.

-- david cuny

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

Search



Quick Links

User menu

Not signed in.

Misc Menu