1. Re: extended mem_copy{}

> May i expect one more useful routine from you?
> that is the one managing "screen cutting" when the sprites are on the
> edge of the screen...
>
> I know that "screen cutting" can be handled with your routine by shifting the
> destination address, however, it's too complicate to beginner like me...

Here's some code that you can either put in a separate include file
or add to the end of ememcopy.e. It doesn't handle lists of images,
instead only a single one, like se_mem_copy().

The routines are:

set_screen_info(xsize, ysize, address)

This sets the info for the virtual (or real) screen. Call it before
using the other routines.

XSIZE = the width in pixels of the screen.
YSIZE = the height in pixels of the screen.
ADDRESS = the address of the screen

The defaults are : 320, 200, #A0000 (ordinary mode 19 screen)

set_clip_boundary(upleft, downright)

This sets the lines at which images will be clipped.

UPLEFT = {left X, top Y}
DOWNRIGHT = {right X, bottom Y}

The defaults are : {0, 0}, {319, 199} (full mode 19 screen)

display_clipped_image(kind, source, xpos, ypos, width, height)

This routine draw the image to the screen.

KIND = 1, 2, or 3 (The same as for se_mem_copy().)
SOURCE = The address of the first byte of the image. It must be
previously poked into memory, with each row immediately following the
row before it.
XPOS = The X position of the image on the screen
YPOS = The  Y position of the image
WIDTH = The width in pixels of the image
HEIGHT = The height of the image

Always specify the full height and width of the image. Clipping is
taken care of automatically.

Hope this helps...

Regards,
               Michael Bolin

-----------------------------------------------------------
integer screen_x,screen_y,lx,rx,uy,dy
atom screen_address

lx=0
rx=319
uy=0
dy=199
screen_x=320
screen_y=200
screen_address=#A0000

global procedure set_screen_info(atom x,atom y,atom a)
    -- x=width of screen
    -- y=height of screen
    -- a=address of screen
    screen_x=x
    screen_y=y
    screen_address=a
end procedure

global procedure set_clip_boundary(sequence ul,sequence dr)
    -- ul={left X,top Y}
    -- dr={right X,bottom Y}

    lx=ul[1]
    if lx<0 then lx=0 end if
    if lx>=screen_x then lx=screen_x end if
    uy=ul[2]
    if uy<0 then uy=0 end if
    if uy>=screen_y then uy=screen_y end if
    rx=dr[1] if rx<0 then rx=0 end if
    if rx>=screen_x then rx=screen_x end if
    dy=dr[2]
    if dy<0 then dy=0 end if
    if dy>=screen_y then dy=screen_y end if
end procedure

global procedure display_clipped_image(integer kind,atom src,atom xpos,
                                atom ypos,atom width,atom height)
    -- kind= 1 (normal) , 2 (0-masked) , 3 (behind)
    -- src= address of image to display
    -- xpos=x-offset from upperleft corner
    -- ypos=y-offset from upperleft corner
    -- width=x size of sprite
    -- height=y size of sprite

    atom e_p,s_a,d_a,work

    s_a = 0
    d_a = screen_x - width
    if ypos < uy then         -- off the top?
        work = uy - ypos
        ypos = ypos + work
        height = height - work
        src = src + width * work
        if height < 1 then
            return
        end if
    end if
    if (ypos + height - 1) > dy then      -- off the bottom?
        work = (ypos + height) - dy - 1
        height = height - work
        if ypos > dy then
            return
        end if
    end if
    if xpos < lx then         -- off the left?
        work = lx - xpos
        if work >= width then
            return
        end if
        width = width - work
        xpos = xpos + work
        src = src + work
        s_a = work
        d_a = d_a + work
    end if
    if xpos + width - 1 > rx then    -- off the right?
        work = (xpos + width) - rx - 1
        if work >= width then
            return
        end if
        width = width - work
        s_a = s_a + work
        d_a = d_a + work
    end if
    e_p = screen_address + ypos * screen_x + xpos
    se_mem_copy(kind,src,e_p,width,height,s_a,d_a)
end procedure
-------------------------------------------------------------------

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu