1. Re: split scroll FASTER :)

>I am working on an application that requires split scroll on a
>graphics screen (like two windows to the same graphics
>image). The program I have enclosed does what I intend
>but extremely slowly.
>
>Can anybody out there come up with a solution on how to speed it up
>without reducing the size of the image or increasing the scroll step?
>
>Saludos
>Adam H. Jackson

I have studied your split scroll and I have come to the conclusion.

You are changing only half the screen but ReWriting the entire
screen.   You need to only ReWrite the half that you are changing.

I have redesigned all your functions to where they
can be used in an include file if you set them to global.

I have also redesigned the main some and have added
a return to the original screen mode after execution ends.

I slightly changed the part_screen function to where it
only updates the half of the screen that you pass to it.

Because of the changes I made it now runs at least
2 times as fast.

The code follows in ascii form
--====2scroll2.ex====but faster==================
include graphics.e
include image.e

-- to create a random 640 x 400 bitmap (for demonstration purposes)
function create_image()
    sequence image
    image=repeat(repeat(0,640),400)
    for y=1 to 400 by 1 do
        for x=1 to 640 by 1 do
            image[y][x]=rand(256)
        end for
    end for
    return image
end function

-- sets graphics mode 320 x 200 256 colours
procedure set_screen()
    integer check
    check=graphics_mode(19)
end procedure

-- gets the two sections from image1 and appends in
image2-----------------
function part_screen(sequence image,sequence update,sequence p)
    atom p1,p2,p3
    p1 = p[1]
    p2 = p[2]
    p3 = p1 + 158
    for l=0 to 199 do
        update[l+1]=image[p2+l][p1..p3]
    end for
    return update
end function

-- Key control for scroll ----------------------------------------
function control(sequence p)
    integer key
    sequence t1 ,t2
    t1=p[1] t2=p[2] -- create temp
    key=-1
    while key = -1 do
        key=get_key()
    end while
    if key=27 then abort(1)
    elsif 327 < key and key < 402 then
        if key=331 then t1[1]=t1[1]-1 p[3] = 1 -- left 1
        elsif key=333 then t1[1]=t1[1]+1 p[3]=1 -- right 1
        elsif key=328 then t1[2]=t1[2]-1 p[3]=1 -- up 1
        elsif key=336 then t1[2]=t1[2]+1 p[3]=1 -- down 1
        elsif key=371 then t2[1]=t2[1]-1 p[3]=2 -- right 2
        elsif key=372 then t2[1]=t2[1]+1 p[3]=2 -- left 2
        elsif key=397 then t2[2]=t2[2]-1 p[3]=2 -- up 2
        elsif key=401 then t2[2]=t2[2]+1 p[3]=2 -- down 2
        end if
    end if
    if t1[1]<0 or t1[1]>640-180 then t1[1]=p[1][1] end if -- limit x
    if t1[2]<0 or t1[2]>400-200 then t1[2]=p[1][2] end if -- limit y
    if t2[1]<0 or t2[1]>640-180 then t2[1]=p[2][1] end if -- limit x
    if t2[2]<0 or t2[2]>400-200 then t2[2]=p[2][2] end if -- limit y
    p[1]=t1 p[2]=t2 -- transfer temp to real
    return p
end function
-- main ------------------------------------------------------
integer chk
sequence image1 -- contains original full image
sequence p1, p2 -- p1 contains image scroll part1 and p2 similiar.
sequence p  -- coordinates of two sections (p = {{p1x, p1y}, {p2x, p2y}})

set_screen()
image1 = create_image()
p = {{0, 0}, {0, 0}, 1} -- starting point
p1 = repeat(0, 200)
p1 = part_screen(image1, p1, {1, 1})
p2 = p1

clear_screen()
display_image({0, 0}, p1)
display_image({161, 0}, p2)
while 1 do
    if p[3] = 1 then
        p1 = part_screen(image1,  p1, p[1] + 1)
        display_image({0, 0}, p1)
    else -- or elsif p[3] = 2 then
        p2 = part_screen(image1,  p2, p[2] + 1)
        display_image({161, 0}, p2)
    end if
    p = control(p)
end while
chk = graphics_mode(-1)
--=========================================
--Lucius Lamar Hilley III
--   E-mail at luciuslhilleyiii at juno.com
--  I can only support file transfers of less than 64K and in UUE format.

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu