1. RE: C structs & bad aftershave...
- Posted by Steve <bleak_outlook at hotmail.com> Feb 25, 2006
- 447 views
Anyone have any idea about this? Do you need more information? Is it not possible? Hello? :) Steve Steve wrote: > > > Ok no Old Spice... I just wanted some attention! :) > > Background: Lest I get ahead of myself. > I am using M Akita's SDL for Eu wrapper. SDL is compiled into a DLL. > I want to access a member of a C structure. > > typedef struct{ > Uint32 hw_available:1; > Uint32 wm_available:1; > Uint32 blit_hw:1; > Uint32 blit_hw_CC:1; > Uint32 blit_hw_A:1; > Uint32 blit_sw:1; > Uint32 blit_sw_CC:1; > Uint32 blit_sw_A:1; > Uint32 blit_fill; > Uint32 video_mem; > SDL_PixelFormat *vfmt; > } SDL_VideoInfo; > > I can access its value by doing this: > > atom videoInfo > > videoInfo = SDL_GetVideoInfo() > > How do I, using Euphoria, best go about reading the above bit flags? > I have tried this: > > <EuCode) > sequence mbits > atom lflg > > mbits = int_to_bits(videoInfo) > > sprintf("flags: %d %d %d ...<snip>", {mbits[1], mbits[2], ...<snip>}) > > <EuCode> > > Which gives me some really odd results. When I peek 36 bytes into this > structure, and grab 4 bytes, I do get the correct amount of video memory > > for my graphics card. There ends my success though. > > Could someone explain to me how to access the bit flags of that struct? > I seem to be doing this all wrong despite my best intentions. :) > > For more info, here is the SDL API page. > http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API > > Thanks again. As always, you guys rule. >
2. RE: C structs & bad aftershave...
- Posted by Bernie Ryan <xotron at bluefrog.com> Feb 25, 2006
- 436 views
Steve wrote: > > > Anyone have any idea about this? > > Do you need more information? Is it not possible? > > Hello? :) > > Steve > > > Steve wrote: > > > > > > Ok no Old Spice... I just wanted some attention! :) > > > > Background: Lest I get ahead of myself. > > I am using M Akita's SDL for Eu wrapper. SDL is compiled into a DLL. > > I want to access a member of a C structure. > > > > typedef struct{ > > Uint32 hw_available:1; > > Uint32 wm_available:1; > > Uint32 blit_hw:1; > > Uint32 blit_hw_CC:1; > > Uint32 blit_hw_A:1; > > Uint32 blit_sw:1; > > Uint32 blit_sw_CC:1; > > Uint32 blit_sw_A:1; > > Uint32 blit_fill; > > Uint32 video_mem; > > SDL_PixelFormat *vfmt; > > } SDL_VideoInfo; > > > > I can access its value by doing this: > > > > atom videoInfo > > > > videoInfo = SDL_GetVideoInfo() > > > > How do I, using Euphoria, best go about reading the above bit flags? > > I have tried this: > > > > <EuCode) > > sequence mbits > > atom lflg > > > > mbits = int_to_bits(videoInfo) > > > > sprintf("flags: %d %d %d ...<snip>", {mbits[1], mbits[2], ...<snip>}) > > > <font color="#330033">> <EuCode></font> > <font color="#330033">> </font> > <font color="#330033">> Which gives me some really odd results. When I > </font><font color="#FF00FF">peek </font><font color="#330033">36 bytes into this > </font> > <font color="#330033">> structure, </font><font color="#0000FF">and > </font><font color="#330033">grab 4 bytes, I </font><font color="#0000FF">do > </font><font color="#330033">get the correct amount of video memory </font> > <font color="#330033">> </font> > <font color="#330033">> </font><font color="#0000FF">for </font><font > color="#330033">my graphics card. There ends my success though.</font> > <font color="#330033">> </font> > <font color="#330033">> Could someone explain </font><font color="#0000FF">to > </font><font color="#330033">me how </font><font color="#0000FF">to </font><font > color="#330033">access the bit flags of that struct?</font> > <font color="#330033">> I seem </font><font color="#0000FF">to </font><font > color="#330033">be doing this all wrong despite my best intentions. :)</font> > <font color="#330033">> </font> > <font color="#330033">> For more info, here is the SDL API page.</font> > <font color="#330033">> http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API</font> > <font color="#330033">> </font> > <font color="#330033">> Thanks again. As always, you guys rule.</font> > <font color="#330033">> </font> > <font color="#330033"></font> > <font color="#330033"></font> Steve: Uint32 is a 32bit unsigned integer In order to look at bitfield hw_available you have to AND the binary number 1000 0000 0000 0000 or #8000 hex with Uint32 portion of the structure Therefore: and_bits(Uint32,#8000) would give you hw_available -- binary 0010 0000 0000 0000 and_bits(Uint32,#4000) would give you blit_hw etc. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
3. RE: C structs & bad aftershave...
- Posted by Bernie Ryan <xotron at bluefrog.com> Feb 25, 2006
- 432 views
Steve wrote: > > > Anyone have any idea about this? > > Do you need more information? Is it not possible? > > Hello? :) > > Steve > > > Steve wrote: > > > > > > Ok no Old Spice... I just wanted some attention! :) > > > > Background: Lest I get ahead of myself. > > I am using M Akita's SDL for Eu wrapper. SDL is compiled into a DLL. > > I want to access a member of a C structure. > > > > typedef struct{ > > Uint32 hw_available:1; > > Uint32 wm_available:1; > > Uint32 blit_hw:1; > > Uint32 blit_hw_CC:1; > > Uint32 blit_hw_A:1; > > Uint32 blit_sw:1; > > Uint32 blit_sw_CC:1; > > Uint32 blit_sw_A:1; > > Uint32 blit_fill; > > Uint32 video_mem; > > SDL_PixelFormat *vfmt; > > } SDL_VideoInfo; > > > > I can access its value by doing this: > > > > atom videoInfo > > > > videoInfo = SDL_GetVideoInfo() > > > > How do I, using Euphoria, best go about reading the above bit flags? > > I have tried this: > > > > <EuCode) > > sequence mbits > > atom lflg > > > > mbits = int_to_bits(videoInfo) > > > > sprintf("flags: %d %d %d ...<snip>", {mbits[1], mbits[2], ...<snip>}) > > > <font color="#330033">> <EuCode></font> > <font color="#330033">> </font> > <font color="#330033">> Which gives me some really odd results. When I > </font><font color="#FF00FF">peek </font><font color="#330033">36 bytes into this > </font> > <font color="#330033">> structure, </font><font color="#0000FF">and > </font><font color="#330033">grab 4 bytes, I </font><font color="#0000FF">do > </font><font color="#330033">get the correct amount of video memory </font> > <font color="#330033">> </font> > <font color="#330033">> </font><font color="#0000FF">for </font><font > color="#330033">my graphics card. There ends my success though.</font> > <font color="#330033">> </font> > <font color="#330033">> Could someone explain </font><font color="#0000FF">to > </font><font color="#330033">me how </font><font color="#0000FF">to </font><font > color="#330033">access the bit flags of that struct?</font> > <font color="#330033">> I seem </font><font color="#0000FF">to </font><font > color="#330033">be doing this all wrong despite my best intentions. :)</font> > <font color="#330033">> </font> > <font color="#330033">> For more info, here is the SDL API page.</font> > <font color="#330033">> http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API</font> > <font color="#330033">> </font> > <font color="#330033">> Thanks again. As always, you guys rule.</font> > <font color="#330033">> </font> > <font color="#330033"></font> > <font color="#330033"></font> Steve: The part of the structure Uint32 is a 32bit unsigned integer In order to look at bitfield hw_available for example, you have to AND the binary number 1000 0000 0000 0000 or #8000 hex with Uint32 portion of the structure Therefore: and_bits(Uint32,#8000) would give you hw_available -- binary 0010 0000 0000 0000 and_bits(Uint32,#2000) would give you blit_hw etc. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
4. RE: C structs & bad aftershave...
- Posted by Bernie Ryan <xotron at bluefrog.com> Feb 25, 2006
- 446 views
Steve ignore the first post I typed #4000 instead of #2000 and sent it before I could correct it Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
5. RE: C structs & bad aftershave...
- Posted by Steve <bleak_outlook at hotmail.com> Feb 25, 2006
- 463 views
Hi Bernie, Thanks for the response. I just wanted to see if this example is up the right tree or not: atom videoInfo videoInfo = SDL_GetVideoInfo() if and_bits(videoInfo, #8000) then -- hw available else -- hw unavailable end if Does that look correct? Thanks for the help! Steve Bernie Ryan wrote: > > > posted by: Bernie Ryan <xotron at bluefrog.com> > > > Steve wrote: > > > > > > Anyone have any idea about this? > > > > Do you need more information? Is it not possible? > > > > Hello? :) > > > > Steve > > > > > > Steve wrote: > > > > > > > > > Ok no Old Spice... I just wanted some attention! :) > > > > > > Background: Lest I get ahead of myself. > > > I am using M Akita's SDL for Eu wrapper. SDL is compiled into a DLL. > > > I want to access a member of a C structure. > > > > > > typedef struct{ > > > Uint32 hw_available:1; > > > Uint32 wm_available:1; > > > Uint32 blit_hw:1; > > > Uint32 blit_hw_CC:1; > > > Uint32 blit_hw_A:1; > > > Uint32 blit_sw:1; > > > Uint32 blit_sw_CC:1; > > > Uint32 blit_sw_A:1; > > > Uint32 blit_fill; > > > Uint32 video_mem; > > > SDL_PixelFormat *vfmt; > > > } SDL_VideoInfo; > > > > > > I can access its value by doing this: > > > > > > atom videoInfo > > > > > > videoInfo = SDL_GetVideoInfo() > > > > > > How do I, using Euphoria, best go about reading the above bit flags? > > > I have tried this: > > > > > > <EuCode) > > > sequence mbits > > > atom lflg > > > > > > mbits = int_to_bits(videoInfo) > > > > > > sprintf("flags: %d %d %d ...<snip>", {mbits[1], mbits[2], ...<snip>}) > > > > > <font color="#330033">> <EuCode></font> > > <font color="#330033">> </font> > > <font color="#330033">> Which gives me some really odd results. When I > > </font><font color="#FF00FF">peek </font><font color="#330033">36 bytes > > into this </font> > > <font color="#330033">> structure, </font><font color="#0000FF">and > > </font><font color="#330033">grab 4 bytes, I </font><font > > color="#0000FF">do </font><font color="#330033">get the correct amount > > of video memory </font> > > <font color="#330033">> </font> > > <font color="#330033">> </font><font color="#0000FF">for </font><font > > color="#330033">my graphics card. There ends my success though.</font> > > <font color="#330033">> </font> > > <font color="#330033">> Could someone explain </font><font > > color="#0000FF">to </font><font color="#330033">me how </font><font > > color="#0000FF">to </font><font color="#330033">access the bit flags of > > that struct?</font> > > <font color="#330033">> I seem </font><font color="#0000FF">to > > </font><font color="#330033">be doing this all wrong despite my best > > intentions. :)</font> > > <font color="#330033">> </font> > > <font color="#330033">> For more info, here is the SDL API page.</font> > > <font color="#330033">> > > http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API</font> > > <font color="#330033">> </font> > > <font color="#330033">> Thanks again. As always, you guys rule.</font> > > <font color="#330033">> </font> > > <font color="#330033"></font> > > <font color="#330033"></font> > > Steve: > > The part of the structure Uint32 is a 32bit unsigned integer > > In order to look at bitfield hw_available for example, you have to AND > the binary number 1000 0000 0000 0000 or #8000 hex with > Uint32 portion of the structure > > Therefore: and_bits(Uint32,#8000) would give you hw_available > > -- binary 0010 0000 0000 0000 > and_bits(Uint32,#2000) would give you blit_hw > etc. > > Bernie > > My files in archive: > WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API > > Can be downloaded here: > > http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan >
6. RE: C structs & bad aftershave...
- Posted by Bernie Ryan <xotron at bluefrog.com> Feb 25, 2006
- 457 views
- Last edited Feb 26, 2006
Steve wrote: > > Hi Bernie, > > Thanks for the response. I just wanted to see if this example is up the > right tree or not: > > atom videoInfo > > videoInfo = SDL_GetVideoInfo() > > if and_bits(videoInfo, #8000) then > -- hw available > else > -- hw unavailable > end if > > Does that look correct? > > Thanks for the help! > > Steve > No you will get a pointer to the structure and you will have to peek4u the UINT32 part of the structure and use that value to and_bits(UINT32, #8000) Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
7. RE: C structs & bad aftershave...
- Posted by Steve <bleak_outlook at hotmail.com> Feb 25, 2006
- 476 views
- Last edited Feb 26, 2006
Ok I figured it out now. Thanks for all the help! Steve Bernie Ryan wrote: > > > posted by: Bernie Ryan <xotron at bluefrog.com> > > Steve wrote: > > > > Hi Bernie, > > > > Thanks for the response. I just wanted to see if this example is up the > > > > right tree or not: > > > > atom videoInfo > > > > videoInfo = SDL_GetVideoInfo() > > > > if and_bits(videoInfo, #8000) then > > -- hw available > > else > > -- hw unavailable > > end if > > > > Does that look correct? > > > > Thanks for the help! > > > > Steve > > > > No you will get a pointer to the structure and you will have > to peek4u the UINT32 part of the structure and use that value > to and_bits(UINT32, #8000) > > > Bernie > > My files in archive: > WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API > > Can be downloaded here: > > http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan >