Chromatic <[EMAIL PROTECTED]> wrote:
> Hi all,

> There are a couple of bugs, however.  First, I had to add some C-type
> conversion code to classes/unmanagedstruct.pmc.  It's almost certainly
> wrong, but without it, I wouldn't have gone as far.

enum_type_char was already there, uint8 is the same case. Fixed.

> ... This may be related
> to why it requires r 255, g 0, b 255 to draw a blue rectangle.

/Me thinks, that setting colors with the struct doesn't work. I've
change your sample to:

        # blue_color = _new_SDL_Color( 255, 255, 255 )
        .local int blue
        .local int red
        .local int green
        blue = 255 << 0
        red = 255 << 16
        green = 255 << 8

Passing one of these colors works fine (SDL_FillRect takes an UInt32
color value, not a pointer to a struct). But it probably should use
SDL_MapRGB() to be endian safe.

> Second, my PIR is undoubtedly funky.  Still, the results speak for
> themselves.

Some typos and returning from _init was missing - not too bad :)

> I've attached my patch to classes/unmanagedstruct.pmc and
> src/call_list.txt as well as the library files and my demo PIR.
> Enhancements and bug fixes welcome.

Applied with little fuzz.

> Be sure to run this in a directory containing "datatypes.pasm" or else
> fix it to find the copy with Parrot (I tried).

Such include files are searched in the current dir and in
runtime/parrot/include. If you aren't working inside parrot root,
setting a link helps (on OS that know, what a symlink is ;)

Below is the diff of the sample code (should that get checked in?)

leo

--- /home/lt/blue_rectangle.imc Sat Jan 31 15:18:02 2004
+++ blue_rectangle.imc  Sat Jan 31 15:17:36 2004
@@ -10,6 +10,8 @@
 .pcc_sub _init prototyped
        .include "library/sdl.pasm"
        _init_SDL_types()
+       .pcc_begin_return
+       .pcc_end_return
 .end

 .sub _MAIN
@@ -29,7 +31,6 @@
        new_SDL_Rect   = global "new_SDL_Rect"

        .pcc_begin prototyped
-               .arg 255
                .arg 65535
                .nci_call SDL_Init
        .pcc_end
@@ -37,20 +38,26 @@
        .pcc_begin prototyped
                .arg 640
                .arg 480
-               .arg  16
+               .arg  0
                .arg   0
                .nci_call SetVideoMode
                .result screen
        .pcc_end

        .local object blue_rect
-       .local object blue_color
-       .local Sub new_rect
-       .local Sub new_color
-       .local Sub update_rect
+       #.local object blue_color

        blue_rect = _new_SDL_Rect()
-       blue_color = _new_SDL_Color( 255, 0, 255 )
+       # blue_color = _new_SDL_Color( 255, 255, 255 )
+       .local int blue
+       .local int red
+       .local int green
+       blue = 255 << 0
+       red = 255 << 16
+       green = 255 << 8
+       print "blue = "
+       print blue
+       print "\n"

        set blue_rect['w'], 100
        set blue_rect['h'], 100
@@ -60,10 +67,13 @@
        .pcc_begin prototyped
                .arg screen
                .arg blue_rect
-               .arg blue_color
+               .arg blue
                .nci_call SDL_FillRect
+               .local int ok
+               .result ok
        .pcc_end

+       # update full screen (all 0 arguments)
        .pcc_begin prototyped
                .arg screen
                .arg 0
@@ -73,8 +83,7 @@
                .nci_call SDL_UpdateRect
        .pcc_end

-       set $I0, 2
-       sleep $I0
+       sleep 2

        .pcc_begin prototyped
                .nci_call SDL_Quit

Reply via email to