In Video.xs: removed use of goto. Added set_palette. In core_video.t tested set_palette
[sdlgit/SDL_perl.git] / src / Core / Video.xs
index a01aa2c..836fff1 100644 (file)
@@ -143,7 +143,9 @@ video_set_colors ( surface, start, ... )
        CODE:
                SDL_Color *colors,*temp;
                int i, length;
-               if ( items < 3 ) { RETVAL = 0;  goto all_done; }
+               if ( items < 3 ) { RETVAL = 0;}
+               else
+               {
                length = items - 2;
                colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1));
                for ( i = 0; i < length ; i++ ) {
@@ -154,9 +156,36 @@ video_set_colors ( surface, start, ... )
                }
                RETVAL = SDL_SetColors(surface, colors, start, length );
                safefree(colors);
+               }       
 
-       all_done:
        OUTPUT: 
                RETVAL
 
+int
+video_set_palette ( surface, flags, start, ... )
+       SDL_Surface *surface
+       int flags
+       int start
+
+       CODE:
+               SDL_Color *colors,*temp;
+               int i, length;
+               if ( items < 4 ) { 
+               RETVAL = 0;
+                       }
+               else
+               {               
+               length = items - 3;
+               colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1));
+               for ( i = 0; i < length ; i++ ){ 
+                       temp = (SDL_Color *)SvIV(ST(i+3));
+                       colors[i].r = temp->r;
+                       colors[i].g = temp->g;
+                       colors[i].b = temp->b;
+               }
+               RETVAL = SDL_SetPalette(surface, flags, colors, start, length );
+               safefree(colors);
+               }
+       OUTPUT: 
+               RETVAL