Neil & set_mix_table

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

Somebody please help me with this,

I=92m trying to use the mixing table in Neil, but I have a problem with th=
e
=93set_mix_table=94 procedure.

Here=92s what I=92m trying to do:


-- begin code

include neil.e

object junk
sequence pal
integer size

size =3D 64 -- size of a very dull sprite

SCREEN_W =3D 640
SCREEN_H =3D 480

-- create a black and white palette
pal =3D repeat(0,256)
for n=3D1 to 256 do
    pal[n] =3D (n-1) + #100 * (n-1) + #10000 * (n-1)
end for

if gfx_mode(SCREEN_W, SCREEN_H,8) then
    puts(1,"gfx problems")
    abort(1)
end if

set_all_palette(pal)

constant virtual_1 =3D virtual_screen(size, size), -- source
         virtual_2 =3D virtual_screen(SCREEN_W, SCREEN_H), --destination
         mix_table =3D allocate(#10000)

-- create a mixing table with an 'average' functionality
for y=3D0 to 255 do
    for x=3D0 to 255 do
        poke (mix_table + y * #100 + x, floor((x+y) / 2) )
    end for
end for

-- and now...
set_mix_table(virtual_1, mix_table) -- ERROR: Invalid sprite handle!

-- if I comment out the above command, the routine =91works=92
-- but the table seems to be random memory =91garbage=92.

-- make a very dull sprite
for y=3D1 to size do
    for x=3D1 to size do
        poke (virtual_1 + (y-1) * size+(x-1), 127)
    end for
end for

while get_key() =3D -1 do

    -- copy the sprite to the big virtual screen using mixer_blit
    do_command(
        mixer_blit,
        {virtual_1, 0,0, size, size},
        {virtual_2,rand(SCREEN_W)-5, rand (SCREEN_H)-5})

    -- copy the big virtual screen to the physical screen
    do_command(
        screen_blit,
        {virtual_2, 0,0, SCREEN_W, SCREEN_H},
        {screen, 0,0})

end while

-- end of code


Thanks in advance,


Tor

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

Search



Quick Links

User menu

Not signed in.

Misc Menu