1. For RDS: peeking and poking WORDs

Hi,

Any chance of adding routines to poke & peek WORDs in additions to the ones to
poke/peek BYTEs and DWORDs.

I ask this because when using Euphoria to access 16bit DIBs or DirectDraw
Surfaces, the ability to poke/peek single WORDs would be very nice/helpful.  As
it stands, I have to break my 16bit color into bytes and poke then into memory as
a sequence.  When reading colors, I either have to read two bytes and re-combine
them or read four bytes and pull out/re-combine the bytes.

In addition, some Windows structures, BMPINFOHEADER for instance, have WORD
sized elements.  Instead of being able to do something simple like this:

  poke2( pBIH + BIH_biBitCount, wordVal )

I have to do something like:

poke( pBIH + BIH_biBitCount, {wordVal, floor(wordVal/256)}) -- being sure to
  poke the low byte first

I think code would be simpler and clearer if there where WORD poke'ing/peek'ing
routines available.

Thanks for reading,
David

new topic     » topic index » view message » categorize

2. Re: For RDS: peeking and poking WORDs

David Guy writes:
> Any chance of adding routines to poke & peek WORDs in
> additions to the ones to poke/peek BYTEs and DWORDs.

I'm not really inclined to add peek2()/poke2(), since
reading/writing 2 bytes at a time isn't nearly as common
on 32-bit machines, as reading/writing 1 or 4 bytes.
You can easily make your own peek2/poke2, and you will
only suffer if they are critical to performance.

> In addition, some Windows structures, BMPINFOHEADER
> for instance, have WORD sized elements.

It would not be a performance problem, if you
are just reading a few words from the header of a bitmap file.

> poke( pBIH + BIH_biBitCount, {wordVal, floor(wordVal/256)})

floor(a/b) is pretty efficient - it just does a single integer divide
at the machine level - the floor operation is optimized out.

I'm not sure if it's faster to poke (or peek) a sequence of
2 elements, as you have done, or do two separate pokes.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu