Re: Euphoria is 3 to 30 times faster than DJGPP! (warning! C code

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

BTW, if anyone wants to test out the code submitted earlier,
I have attached
image_save and image_display
that can be used to achieve somewhat faster screen writes
but beware, if you use a mouse on the screen with these
you'll get some strange effects near the top.

GRAPHICS MODE 261 ONLY example.

</snip>

global integer bank_start

sequence regs, dummy
atom win_func_ptr
integer bytes_per_line, bank_granularity
bytes_per_line = 1024
bank_granularity = 65536

regs = repeat(0, 10)
regs[REG_AX] = #4F05
regs[REG_BX] = #0000

global procedure pixel2(object data, sequence p)
    integer offset, len
    len = length(data)
    offset = p[2] * bytes_per_line + p[1]
    if offset < bank_start or offset + len > bank_start + 65536 then
       regs[REG_DX] = floor(offset / bank_granularity)
       dummy = dos_interrupt(#10, regs)
       bank_start = regs[REG_DX] * bank_granularity
    end if
    poke(#A0000 + offset - bank_start, data)
end procedure

global function get_pixel2(sequence p)
    integer offset
    offset = p[2] * bytes_per_line + p[1]
    if offset < bank_start or offset + p[3] > bank_start + 65536 then
       regs[REG_DX] = floor(offset / bank_granularity)
       dummy = dos_interrupt(#10, regs)
       bank_start = regs[REG_DX] * bank_granularity
    end if
    return peek({#A0000 + offset - bank_start, p[3]})
end function


-- save_image --------------------------------------------------------

global function image_save(integer x1, integer y1, integer x2, integer y2)
    sequence save
    integer width, height

    width  = x2 - x1 + 1
    height = y2 - y1 + 1

    save = repeat(0, height)
    bank_start = 0

    for x = 1 to height do
 save[x] = get_pixel({x1, y1, width})
      y1 += 1
    end for

    return save
end function

----------------------------------------------------------------------


-- Pixel Routine -----------------------------------------------------

global procedure image_display(sequence xy, sequence pixels)
    bank_start = 0
    for i = 1 to length(pixels) do
        pixel(pixels[i], xy)
        xy[2] += 1
    end for
end procedure

----------------------------------------------------------------------

<snip\>

eum

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

Search



Quick Links

User menu

Not signed in.

Misc Menu