fixed big-endian handling in .sound.
[swftools.git] / src / swfc.c
index 2c23d95..17fefe6 100644 (file)
@@ -796,7 +796,7 @@ void s_box(char*name, int width, int height, RGBA color, int linewidth, char*tex
     tag = swf_InsertTag(tag, ST_DEFINESHAPE3);
     swf_ShapeNew(&s);
     if(linewidth)
-        ls1 = swf_ShapeAddLineStyle(s,linewidth,&color);
+        ls1 = swf_ShapeAddLineStyle(s,linewidth>=20?linewidth-20:0,&color);
     if(texture)
        fs1 = addFillStyle(s, &r2, texture);
 
@@ -819,37 +819,6 @@ void s_box(char*name, int width, int height, RGBA color, int linewidth, char*tex
     incrementid();
 }
 
-void swf_RecodeShapeData(U8*data, int bitlen, int in_bits_fill, int in_bits_line, 
-                         U8**destdata, U32*destbitlen, int out_bits_fill, int out_bits_line)
-{
-    SHAPE2 s2;
-    SHAPE s;
-    SHAPELINE*line;
-    memset(&s2, 0, sizeof(s2));
-    s2.lines = swf_ParseShapeData(data, bitlen, in_bits_fill, in_bits_line);
-    s2.numfillstyles = out_bits_fill?1<<(out_bits_fill-1):0;
-    s2.numlinestyles = out_bits_line?1<<(out_bits_line-1):0;
-    s2.fillstyles = rfx_calloc(sizeof(FILLSTYLE)*s2.numfillstyles);
-    s2.linestyles = rfx_calloc(sizeof(LINESTYLE)*s2.numlinestyles);
-
-    line = s2.lines;
-    while(line) {
-        if(line->fillstyle0 > s2.numfillstyles) line->fillstyle0 = 0;
-        if(line->fillstyle1 > s2.numfillstyles) line->fillstyle1 = 0;
-        if(line->linestyle > s2.numlinestyles) line->linestyle = 0;
-        line = line->next;
-    }
-
-    swf_Shape2ToShape(&s2,&s);
-
-    free(s2.fillstyles);
-    free(s2.linestyles);
-    free(s.fillstyle.data);
-    free(s.linestyle.data);
-    *destdata = s.data;
-    *destbitlen = s.bitlen;
-}
-
 void s_filled(char*name, char*outlinename, RGBA color, int linewidth, char*texture)
 {
     SRECT rect,r2;
@@ -865,7 +834,7 @@ void s_filled(char*name, char*outlinename, RGBA color, int linewidth, char*textu
     tag = swf_InsertTag(tag, ST_DEFINESHAPE3);
     swf_ShapeNew(&s);
     if(linewidth)
-        ls1 = swf_ShapeAddLineStyle(s,linewidth,&color);
+        ls1 = swf_ShapeAddLineStyle(s,linewidth>=20?linewidth-20:0,&color);
     if(texture)
        fs1 = addFillStyle(s, &r2, texture);
     
@@ -900,7 +869,7 @@ void s_circle(char*name, int r, RGBA color, int linewidth, char*texture)
     tag = swf_InsertTag(tag, ST_DEFINESHAPE3);
     swf_ShapeNew(&s);
     if(linewidth)
-        ls1 = swf_ShapeAddLineStyle(s,linewidth,&color);
+        ls1 = swf_ShapeAddLineStyle(s,linewidth>=20?linewidth-20:0,&color);
     if(texture)
        fs1 = addFillStyle(s, &r2, texture);
     swf_SetU16(tag,id);
@@ -1141,6 +1110,12 @@ void s_sound(char*name, char*filename)
        samples = (U16*)wav2.data;
        numsamples = wav2.size/2;
        free(wav.data);
+#ifdef WORDS_BIGENDIAN
+       /* swap bytes */
+       for(t=0;t<numsamples;t++) {
+           samples[t] = (samples[t]>>8)&0xff | (samples[t]<<8)&0xff00;
+       }
+#endif
     }
 
     tag = swf_InsertTag(tag, ST_DEFINESOUND);
@@ -1668,8 +1643,8 @@ int parseTwip(char*str)
            if(*s<'0' || *s>'9')
                syntaxerror("Not a coordinate: \"%s\"", str);
        }
-       if(l>2 || (l==2 && (dot[1]!='0' || dot[1]!='5'))) {
-           warning("precision loss: %s converted to twip", str);
+       if(l>2 || (l==2 && (dot[1]!='0' && dot[1]!='5'))) {
+           warning("precision loss: %s converted to twip: %s", str, dot);
            dot[2] = 0;
            l=2;
        }
@@ -2778,7 +2753,7 @@ static map_t parseArguments(char*command, char*pattern)
            }
        }
        if(pos==len) {
-           syntaxerror("don't know what to do with \"%s\". (All parameters for .%s already set)", text, command);
+           syntaxerror("Illegal argument \"%s\" to .%s", text, command);
        }
     }
 #if 0//def DEBUG