Jiri's text.e

new topic     » topic index » view thread      » older message » newer message

I saw stated that you generally poke and entire sequence instead of
one byte at a time because it is generally faster.  Well I don't disagree
with the speed of pokeing entire sequences.  I do however feel that
in the case of BUILDING the color coded sequence to be poked
you lose some speed.  It is suprisingly faster to poke a character
then poke its color than it is to build the sequence of character
and its color and then poke the sequence.

Of course you may now some sequence magic that I haven't
come across as of yet.  I believe in my attempt I used.

function build_string(sequence text, integer color)
  integer l, inc
  integer color-- assume this contains both foreground & background.
  sequence s

  l = length(s) * 2
  s = repeat(color, l)
  inc = 1
  for A = 1 to l by 2 do
    s[A] = text[inc]
    inc = inc + 1
  end for

  return s
end function

I also notice that your fill_block could be optimized.
First you must build and keep a pattern for faster
building of the sequence.

sequence pattern
pattern = repeat(0, 4000)--max screen size
for A = 2 to 4000 by 2 do
  pattern[A] = 1
end for
global procedure fill_block(integer row,integer column,integer width,
                            integer height, integer char)
    -- fill given block using character char and current color attributes
    sequence s
    integer a,w
    w=2*width
    s=repeat(char,w)

--    for i=2 to w by 2 do s[i]=ca end for -- Your code
    s = s + pattern[1..w] * ca -- My code

    a=so+2*(row-1)*nc+2*(column-1)      -- top left corner
    w=2*nc
    for h=1 to height do
        poke(a,s)
        a=a+w
    end for
end procedure
_________________________

Lucius L. Hilley III    lhilley at cdc.net
http://www.cdc.net/~lhilley
http://www.americanantiques.com
http://www.dragonvet.com
_________________________

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu