Just some questions - Reply

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

Helge O Gundersen wrote:

>  1. Is there a way to display an image-sequence on screen which is
>  faster than display_image()? Maybe someone has written a good
>  procedure which is easy to use?

>  2. When I use get_mouse(), Euphoria do not register that I press a
>  mouse-button if I move the mouse at the same time. I wonder if there is
>  someone who can help me. I don't know anything about peek(), poke()
>  and so on, so please explain if I need to do low-level-programming.


For mode 19 with simple linear addressing I use put_image() below, which is
almost five times faster than display_image(), on my old gear anyway.

The function poll_mouse() returns combined status of  *all*   mouse buttons as
well as the mouse cursor position. You can also find it in ratbag.e, which is
included in the my font package (give me a break, guys, I am not selling it...).
But remember, in some resolutions, you will have to scale the coordinates to get
the correct answer.

Sorry, I know next to nothing about serial port communications. I hope this
helps a little. Jiri


-- snip ------------------------------------------------------------------------

include machine.e

function poll_mouse()
   -- returns mouse status: {button_status,x_coord,y_coord}
   -- button status: 0 .. no button pressed
   --                1 .. left button pressed
   --                2 .. right button pressed
   --                4 .. middle button pressed (if your rat has it)
   sequence  rl -- list of register values
   rl = repeat(0,10)
   rl[REG_AX] = 3
   rl = dos_interrupt(#33,rl)
   return {rl[REG_BX], rl[REG_CX], rl[REG_DX]}
end function   -- poll_mouse_status


-- snip ------------------------------------------------------------------------

-- faster display_image()

object junk
sequence s
atom dt,t
integer key

include graphics.e
include get.e
include image.e

procedure put_image(sequence s1, sequence s2)
   integer a,h
   h=length(s2)
   a=#A0000+s1[1]+s1[2]*320
   for i=1 to h do
      poke(a,s2[i])
      a=a+320
   end for
end procedure

-- test ------------------------------------------------------------------------

junk=graphics_mode(19)
tick_rate(100)
s=rand(repeat(repeat(15,25),20))

t=time()
for i=1 to 1000 do display_image({40,100},s) end for
dt=time()-t
printf(1,"%5.2f\n",dt)

t=time()
for i=1 to 1000 do put_image({80,100},s) end for
dt=time()-t
printf(1,"%5.2f\n",dt)

key = wait_key()
junk=graphics_mode(-1)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu