Re: Fastest Print to Screen

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

>I stumbled across "perform.doc" and read that puts ain't the way to go
>for speed. I tried display_text_image() but apparently it would be a
>pain to parse out the sequence I want printed with all the colors in
>between, or maybe it wouldn't.

Ralf already gave you code for saving and displaying text images, but I
think you are looking for is a fast(er) way to put characters and strings=

directly to the screen.
What you are searching for, is maybe this: routines to write sequences
directly to the video memory, including cls() - a fast clear screen - and=

clreol() - clear to end of line.
The procedure write() has the parameters row, column, colors (fore- and
background) and the sequence to write.
I found it somewhere, some of the routines are contributed by others.
Careful tho.. you need to check if the row and column coordinates are on
screen.

-- begin Euphoria code
include graphics.e

constant TextRows =3D text_rows(28)   -- my favorite resolution
constant ScrLen =3D TextRows * 80

global sequence Screen
Screen =3D repeat(' ', ScrLen + ScrLen)

sequence vc
vc =3D video_config()

constant so =3D #B8000    -- the adress of the start of (color) video mem=
ory

procedure cls(integer BkColor, integer TxtColor)
-- clear screen *and* set atrributes
integer attrib
    attrib =3D TxtColor + (16 * BkColor)
    for ch =3D 1 to ScrLen do
        Screen[ch + ch] =3D attrib
    end for
    poke(so, Screen)
end procedure   -- cls()

procedure write(integer row,integer col,integer a,sequence s)
    sequence sa
    sa =3D repeat(a, length(s) + length(s))
    for i =3D 1 to length(s) do
        sa[i + i - 1] =3D s[i]
    end for
    poke(so+((row-1)*80+col-1)*2,sa)
end procedure  -- write

procedure clreol(integer TxtColor, integer BkColor)
-- clear to end of line, with given attribute
integer attrib
sequence CurPos
    attrib =3D (#10 * BkColor) + TxtColor
    CurPos =3D get_position()
    write(CurPos[1], CurPos[2], attrib, repeat(' ', 80-CurPos[2]))
    position(CurPos[1], CurPos[2])
end procedure -- clreol()

procedure char(integer row, integer col, integer ch, integer a)
-- put a single character on the screen
-- a is text attribute:  a =3D text_color + 16*background_color
-- it is easier in the hexadecimal notation: e.g.  #1F is bright
-- white text (F) on blue background (1)
    poke(so+((row-1)*80]+col-1)*2,{ch,a})
end procedure  -- char

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

Search



Quick Links

User menu

Not signed in.

Misc Menu