~ubuntu-branches/ubuntu/maverick/ming/maverick

« back to all changes in this revision

Viewing changes to util/outputswf.c

  • Committer: Bazaar Package Importer
  • Author(s): Stuart R. Anderson
  • Date: 2006-06-27 13:42:49 UTC
  • Revision ID: james.westby@ubuntu.com-20060627134249-s4otq30syqzk00g1
Tags: 1:0.3.0-7
* Add ttftofft from upstream CVS, and add missing ming-font packages.
* Update to follow the new Python policy (Closes: #380870: Python transition
  (#2): you are building a private python module !)
* Fix a bug where font properties was being generated incorrectly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include "blocks/blocktypes.h"
 
3
#include "blocks/method.h"
 
4
#include "blocks/output.h"
 
5
#include "action.h"
 
6
#include "parser.h"
 
7
#include "decompile.h"
 
8
#define OUTPUTRET SWFOutput
 
9
#include "swfoutput.h"
 
10
#include "libming.h"
 
11
 
 
12
extern const char *blockName (SWFBlocktype header);
 
13
 
 
14
/*
 
15
 * This file contains output functions that can display the different SWF block
 
16
 * types in a human readable format.
 
17
 */
 
18
 
 
19
#define OUT_BEGIN(block) \
 
20
        struct block *sblock = (struct block *)pblock;
 
21
 
 
22
static struct SWFBlockOutput outputs[] = {
 
23
/* Add these back at they are converted 
 
24
  {SWF_CHARACTERSET, outputSWF_CHARACTERSET},
 
25
  {SWF_DEFINEBITS, outputSWF_DEFINEBITS},
 
26
  {SWF_DEFINEBITSJPEG2, outputSWF_DEFINEBITSJPEG2},
 
27
  {SWF_DEFINEBITSJPEG3, outputSWF_DEFINEBITSJPEG3},
 
28
  {SWF_DEFINEBITSPTR, outputSWF_DEFINEBITSPTR},
 
29
  {SWF_DEFINEBUTTON, outputSWF_DEFINEBUTTON},
 
30
  {SWF_DEFINEBUTTON2, outputSWF_DEFINEBUTTON2},
 
31
  {SWF_DEFINEBUTTONCXFORM, outputSWF_DEFINEBUTTONCXFORM},
 
32
  {SWF_DEFINEBUTTONSOUND, outputSWF_DEFINEBUTTONSOUND},
 
33
  {SWF_DEFINECOMMANDOBJ, outputSWF_DEFINECOMMANDOBJ},
 
34
  {SWF_DEFINEEDITTEXT, outputSWF_DEFINEEDITTEXT},
 
35
  {SWF_DEFINEFONT, outputSWF_DEFINEFONT},
 
36
*/
 
37
  {SWF_DEFINEFONT2, outputSWF_DEFINEFONT2},
 
38
/*
 
39
  {SWF_DEFINEFONTINFO, outputSWF_DEFINEFONTINFO},
 
40
  {SWF_DEFINELOSSLESS, outputSWF_DEFINELOSSLESS},
 
41
  {SWF_DEFINELOSSLESS2, outputSWF_DEFINELOSSLESS2},
 
42
  {SWF_DEFINEMORPHSHAPE, outputSWF_DEFINEMORPHSHAPE},
 
43
  {SWF_DEFINESHAPE, outputSWF_DEFINESHAPE},
 
44
  {SWF_DEFINESHAPE2, outputSWF_DEFINESHAPE2},
 
45
  {SWF_DEFINESHAPE3, outputSWF_DEFINESHAPE3},
 
46
  {SWF_DEFINESOUND, outputSWF_DEFINESOUND},
 
47
  {SWF_DEFINESPRITE, outputSWF_DEFINESPRITE},
 
48
  {SWF_DEFINETEXT, outputSWF_DEFINETEXT},
 
49
  {SWF_DEFINETEXT2, outputSWF_DEFINETEXT2},
 
50
  {SWF_DEFINETEXTFORMAT, outputSWF_DEFINETEXTFORMAT},
 
51
  {SWF_DEFINEVIDEO, outputSWF_DEFINEVIDEO},
 
52
  {SWF_DEFINEVIDEOSTREAM, outputSWF_DEFINEVIDEOSTREAM},
 
53
  {SWF_DOACTION, outputSWF_DOACTION},
 
54
  {SWF_ENABLEDEBUGGER, outputSWF_ENABLEDEBUGGER},
 
55
  {SWF_END, outputSWF_END},
 
56
  {SWF_EXPORTASSETS, outputSWF_EXPORTASSETS},
 
57
  {SWF_FONTREF, outputSWF_FONTREF},
 
58
  {SWF_FRAMELABEL, outputSWF_FRAMELABEL},
 
59
  {SWF_FRAMETAG, outputSWF_FRAMETAG},
 
60
  {SWF_FREEALL, outputSWF_FREEALL},
 
61
  {SWF_FREECHARACTER, outputSWF_FREECHARACTER},
 
62
  {SWF_GENCOMMAND, outputSWF_GENCOMMAND},
 
63
  {SWF_IMPORTASSETS, outputSWF_IMPORTASSETS},
 
64
  {SWF_JPEGTABLES, outputSWF_JPEGTABLES},
 
65
  {SWF_NAMECHARACTER, outputSWF_NAMECHARACTER},
 
66
  {SWF_PATHSAREPOSTSCRIPT, outputSWF_PATHSAREPOSTSCRIPT},
 
67
  {SWF_PLACEOBJECT, outputSWF_PLACEOBJECT},
 
68
  {SWF_PLACEOBJECT2, outputSWF_PLACEOBJECT2},
 
69
  {SWF_PREBUILT, outputSWF_PREBUILT},
 
70
  {SWF_PREBUILTCLIP, outputSWF_PREBUILTCLIP},
 
71
  {SWF_PROTECT, outputSWF_PROTECT},
 
72
  {SWF_REMOVEOBJECT, outputSWF_REMOVEOBJECT},
 
73
  {SWF_REMOVEOBJECT2, outputSWF_REMOVEOBJECT2},
 
74
  {SWF_SERIALNUMBER, outputSWF_SERIALNUMBER},
 
75
  {SWF_SETBACKGROUNDCOLOR, outputSWF_SETBACKGROUNDCOLOR},
 
76
  {SWF_SHOWFRAME, outputSWF_SHOWFRAME},
 
77
  {SWF_SOUNDSTREAMBLOCK, outputSWF_SOUNDSTREAMBLOCK},
 
78
  {SWF_SOUNDSTREAMHEAD, outputSWF_SOUNDSTREAMHEAD},
 
79
  {SWF_SOUNDSTREAMHEAD2, outputSWF_SOUNDSTREAMHEAD2},
 
80
  {SWF_STARTSOUND, outputSWF_STARTSOUND},
 
81
  {SWF_SYNCFRAME, outputSWF_SYNCFRAME},
 
82
  {SWF_INITACTION, outputSWF_INITACTION},
 
83
  {SWF_VIDEOFRAME, outputSWF_VIDEOFRAME},
 
84
*/
 
85
};
 
86
 
 
87
static int numOutputs = sizeof (outputs) / sizeof (struct SWFBlockOutput);
 
88
 
 
89
/* Output basic Flash Types */
 
90
 
 
91
#if 0
 
92
void
 
93
outputSWF_RGBA (SWF_RGBA * rgb, char *pname)
 
94
{
 
95
  printf (" RGBA: (");
 
96
  printf ("%2x,", rgb->red);
 
97
  printf ("%2x,", rgb->green);
 
98
  printf ("%2x,", rgb->blue);
 
99
  printf ("%2x)\n", rgb->alpha);
 
100
}
 
101
 
 
102
#endif
 
103
 
 
104
void
 
105
outputswfSWF_RECT (SWFOutput out,SWF_RECT * rect)
 
106
{
 
107
  SWFOutput_writeBits(out,rect->Nbits,5);
 
108
  SWFOutput_writeSBits(out,rect->Xmin,rect->Nbits);
 
109
  SWFOutput_writeSBits(out,rect->Xmax,rect->Nbits);
 
110
  SWFOutput_writeSBits(out,rect->Ymin,rect->Nbits);
 
111
  SWFOutput_writeSBits(out,rect->Ymax,rect->Nbits);
 
112
}
 
113
 
 
114
#if 0
 
115
void
 
116
outputSWF_MATRIX (SWF_MATRIX * matrix, char *name)
 
117
{
 
118
  printf (" Matrix: ");
 
119
  if (matrix->HasScale)
 
120
    {
 
121
      printf ("ScaleX %f ", matrix->ScaleX);
 
122
      printf ("ScaleY %f\n", matrix->ScaleY);
 
123
    }
 
124
  if (matrix->HasRotate)
 
125
    {
 
126
      printf ("RotateSkew0 %f ", matrix->RotateSkew0);
 
127
      printf ("RotateSkew1 %f\n", matrix->RotateSkew1);
 
128
    }
 
129
  printf ("   TranslateX %6ld ", matrix->TranslateX);
 
130
  printf ("TranslateY %6ld\n", matrix->TranslateY);
 
131
}
 
132
 
 
133
void
 
134
outputSWF_BUTTONRECORD (SWF_BUTTONRECORD *brec)
 
135
{
 
136
  printf (" BUTTONRECORD: ");
 
137
  printf ("  ButtonStateHitTest: %d ", brec->ButtonStateHitTest);
 
138
  printf ("  ButtonStateDown: %d ", brec->ButtonStateDown);
 
139
  printf ("  ButtonStateOver: %d ", brec->ButtonStateOver);
 
140
  printf ("  ButtonStateUp: %d\n", brec->ButtonStateUp);
 
141
  printf ("  CharacterID: %d\n", brec->CharacterId);
 
142
  printf ("  PlaceDepth: %d\n", brec->PlaceDepth);
 
143
}
 
144
 
 
145
void
 
146
outputSWF_BUTTONCONDACTION (SWF_BUTTONCONDACTION *bcarec)
 
147
{
 
148
#if 0
 
149
#ifdef NODECOMPILE
 
150
  int i;
 
151
#endif
 
152
#if !defined(ACTIONONLY)
 
153
  printf (" BUTTONCONDACTION: ");
 
154
  printf ("  CondActionSize: %d\n", bcarec->CondActionSize);
 
155
  printf ("  CondIdleToOverDown: %d ", bcarec->CondIdleToOverDown);
 
156
  printf ("  CondOutDownToIdle: %d ", bcarec->CondOutDownToIdle);
 
157
  printf ("  CondOutDownToOverDown: %d ", bcarec->CondOutDownToOverDown);
 
158
  printf ("  CondOverDownToOutDown: %d ", bcarec->CondOverDownToOutDown);
 
159
  printf ("  CondOverDownToOverUp: %d ", bcarec->CondOverDownToOverUp);
 
160
  printf ("  CondOverUpToOverDown: %d ", bcarec->CondOverUpToOverDown);
 
161
  printf ("  CondOverUpToIdle: %d ", bcarec->CondOverUpToIdle);
 
162
  printf ("  CondIdleToOverUp: %d ", bcarec->CondIdleToOverUp);
 
163
  printf ("  CondKeyPress: %d ", bcarec->CondKeyPress);
 
164
  printf ("  CondOverDownToIdle: %d ", bcarec->CondOverDownToIdle);
 
165
  printf ("\n");
 
166
#endif
 
167
#ifdef NODECOMPILE
 
168
  printf(" %d Actions\n", bcarec->numActions);
 
169
  for(i=0;i<bcarec->numActions;i++)
 
170
  outputSWF_ACTION(i,&(bcarec->Actions[i]));
 
171
#else
 
172
  printf (" %s\n", decompile5Action(bcarec->numActions,bcarec->Actions,0));
 
173
#endif
 
174
#endif
 
175
}
 
176
 
 
177
void
 
178
outputSWF_CLIPEVENTFLAGS (SWF_CLIPEVENTFLAGS * clipevflags )
 
179
{
 
180
  printf ("  ClipEventKeyUp: %d ", clipevflags->ClipEventKeyUp);
 
181
  printf ("  ClipEventKeyDown: %d ", clipevflags->ClipEventKeyDown);
 
182
  printf ("  ClipEventMouseUp: %d ", clipevflags->ClipEventMouseUp);
 
183
  printf ("  ClipEventMouseDown: %d ", clipevflags->ClipEventMouseDown);
 
184
  printf ("  ClipEventMouseMove: %d ", clipevflags->ClipEventMouseMove);
 
185
  printf ("  ClipEventUnload: %d ", clipevflags->ClipEventUnload);
 
186
  printf ("  ClipEventEnterFrame: %d ", clipevflags->ClipEventEnterFrame);
 
187
  printf ("  ClipEventLoad: %d ", clipevflags->ClipEventLoad);
 
188
  printf ("  ClipEventDragOver: %d ", clipevflags->ClipEventDragOver);
 
189
  printf ("  ClipEventRollOut: %d ", clipevflags->ClipEventRollOut);
 
190
  printf ("  ClipEventRollOver: %d ", clipevflags->ClipEventRollOver);
 
191
  printf ("  ClipEventReleaseOutside: %d ", clipevflags->ClipEventReleaseOutside);
 
192
  printf ("  ClipEventRelease: %d ", clipevflags->ClipEventRelease);
 
193
  printf ("  ClipEventPress: %d ", clipevflags->ClipEventPress);
 
194
  printf ("  ClipEventInitialize: %d ", clipevflags->ClipEventInitialize);
 
195
  printf ("  ClipEventData: %d ", clipevflags->ClipEventData);
 
196
  printf ("  ClipEventConstruct: %d ", clipevflags->ClipEventConstruct);
 
197
  printf ("  ClipEventKeyPress: %d ", clipevflags->ClipEventKeyPress);
 
198
  printf ("  ClipEventDragOut: %d ", clipevflags->ClipEventDragOut);
 
199
}
 
200
 
 
201
void
 
202
outputSWF_CLIPACTIONRECORD (SWF_CLIPACTIONRECORD * carec )
 
203
{
 
204
#if 0
 
205
#ifdef NODECOMPILE
 
206
  int i;
 
207
#endif
 
208
#if !defined(ACTIONONLY)
 
209
  outputSWF_CLIPEVENTFLAGS (&carec->EventFlag);
 
210
  printf(" %ld ActionRecordSize\n", carec->ActionRecordSize);
 
211
  printf(" %d KeyCode\n", carec->KeyCode);
 
212
#endif
 
213
#ifdef NODECOMPILE
 
214
  printf(" %d Actions\n", carec->numActions);
 
215
  for(i=0;i<carec->numActions;i++)
 
216
     outputSWF_ACTION(i,&(carec->Actions[i]));
 
217
#else
 
218
  printf (" %s\n", decompile5Action(carec->numActions,carec->Actions,0));
 
219
#endif
 
220
#endif
 
221
}
 
222
 
 
223
void
 
224
outputSWF_CLIPACTIONS (SWF_CLIPACTIONS * clipactions )
 
225
{
 
226
  int i;
 
227
#if !defined(ACTIONONLY)
 
228
  outputSWF_CLIPEVENTFLAGS (&clipactions->AllEventFlags);
 
229
  printf(" %d NumClipRecords\n", clipactions->NumClipRecords);
 
230
#endif
 
231
  for(i=0;i<clipactions->NumClipRecords;i++)
 
232
    outputSWF_CLIPACTIONRECORD(&(clipactions->ClipActionRecords[i]));
 
233
}
 
234
 
 
235
void
 
236
outputSWF_GRADIENTRECORD (SWF_GRADIENTRECORD * gradientrec, char *gname)
 
237
{
 
238
  printf (" Ratio: %d\n", gradientrec->Ratio);
 
239
  outputSWF_RGBA (&gradientrec->Color, "");
 
240
}
 
241
 
 
242
void
 
243
outputSWF_GRADIENT (SWF_GRADIENT * gradient, char *name)
 
244
{
 
245
  int i;
 
246
  printf (" Gradient: ");
 
247
  printf (" NumGradients: %d\n", gradient->NumGradients);
 
248
  for (i = 0; i < gradient->NumGradients; i++)
 
249
    outputSWF_GRADIENTRECORD (&(gradient->GradientRecords[i]),"");
 
250
}
 
251
 
 
252
 
 
253
void
 
254
outputSWF_FILLSTYLE (SWF_FILLSTYLE * fillstyle, char *name, int i)
 
255
{
 
256
  printf (" FillStyle: ");
 
257
  printf (" FillStyleType: %x\n", fillstyle->FillStyleType);
 
258
  switch (fillstyle->FillStyleType)
 
259
    {
 
260
    case 0x00:                  /* Solid Fill */
 
261
      outputSWF_RGBA (&fillstyle->Color, "");
 
262
      break;
 
263
    case 0x10:                  /* Linear Gradient Fill */
 
264
    case 0x12:                  /* Radial Gradient Fill */
 
265
      outputSWF_MATRIX (&fillstyle->GradientMatrix,"");
 
266
      outputSWF_GRADIENT (&fillstyle->Gradient,"");
 
267
      break;
 
268
    case 0x40:                  /* Repeating Bitmap Fill */
 
269
    case 0x41:                  /* Clipped Bitmap Fill */
 
270
    case 0x42:                  /* Non-smoothed Repeating Bitmap Fill */
 
271
    case 0x43:                  /* Non-smoothed Clipped Bitmap Fill */
 
272
      printf (" BitmapID: %d\n", fillstyle->BitmapId);
 
273
      outputSWF_MATRIX (&fillstyle->BitmapMatrix,"");
 
274
      break;
 
275
    }
 
276
}
 
277
 
 
278
void
 
279
outputSWF_FILLSTYLEARRAY (SWF_FILLSTYLEARRAY * fillstylearray, char *name)
 
280
{
 
281
  int count, i;
 
282
 
 
283
  printf (" FillStyleArray: ");
 
284
  printf (" FillStyleCount: %6d ", fillstylearray->FillStyleCount);
 
285
  printf (" FillStyleCountExtended: %6d\n",
 
286
          fillstylearray->FillStyleCountExtended);
 
287
  count =
 
288
    (fillstylearray->FillStyleCount !=
 
289
     0xff) ? fillstylearray->FillStyleCount : fillstylearray->
 
290
    FillStyleCountExtended;
 
291
  for (i = 0; i < count; i++)
 
292
    {
 
293
      outputSWF_FILLSTYLE (&(fillstylearray->FillStyles[i]),"",0);
 
294
    }
 
295
}
 
296
 
 
297
void
 
298
outputSWF_LINESTYLE (SWF_LINESTYLE * fillstyle, char *name, int i)
 
299
{
 
300
  printf (" LineStyle: ");
 
301
  printf (" Width: %d\n", fillstyle->Width);
 
302
  outputSWF_RGBA (&fillstyle->Color, "");
 
303
}
 
304
 
 
305
void
 
306
outputSWF_LINESTYLEARRAY (SWF_LINESTYLEARRAY * linestylearray, char *name)
 
307
{
 
308
 
 
309
  int count, i;
 
310
 
 
311
  printf (" LineStyleArray: ");
 
312
  printf (" LineStyleCount: %6d ", linestylearray->LineStyleCount);
 
313
  printf (" LineStyleCountExtended: %6d\n",
 
314
          linestylearray->LineStyleCountExtended);
 
315
  count =
 
316
    (linestylearray->LineStyleCount !=
 
317
     0xff) ? linestylearray->LineStyleCount : linestylearray->
 
318
    LineStyleCountExtended;
 
319
  for (i = 0; i < count; i++)
 
320
    {
 
321
      outputSWF_LINESTYLE (&(linestylearray->LineStyles[i]),"",0);
 
322
    }
 
323
}
 
324
#endif
 
325
 
 
326
void
 
327
outputswfSWF_SHAPERECORD (SWF_SHAPERECORD * shaperec, SWFOutput out, int fillBits, int lineBits)
 
328
{
 
329
  SWFOutput_writeBits(out,shaperec->EndShape.TypeFlag,1);
 
330
  if (shaperec->EndShape.TypeFlag)
 
331
    {
 
332
      /* An Edge Record */
 
333
      SWFOutput_writeBits(out,shaperec->StraightEdge.StraightEdge,1);
 
334
      if (shaperec->StraightEdge.StraightEdge == 1)
 
335
        {
 
336
          /* A Straight Edge Record */
 
337
          SWFOutput_writeBits(out,shaperec->StraightEdge.NumBits,4);
 
338
          SWFOutput_writeBits(out,shaperec->StraightEdge.GeneralLineFlag,1);
 
339
          if( shaperec->StraightEdge.GeneralLineFlag ) {
 
340
                  SWFOutput_writeSBits(out,shaperec->StraightEdge.DeltaX,shaperec->StraightEdge.NumBits+2);
 
341
                  SWFOutput_writeSBits(out,shaperec->StraightEdge.DeltaY,shaperec->StraightEdge.NumBits+2);
 
342
          } else {
 
343
                SWFOutput_writeSBits(out,shaperec->StraightEdge.VertLineFlag,1);
 
344
                if( shaperec->StraightEdge.VertLineFlag )  {
 
345
                  SWFOutput_writeSBits(out,shaperec->StraightEdge.VLDeltaY,shaperec->StraightEdge.NumBits+2);
 
346
                } else {
 
347
                  SWFOutput_writeSBits(out,shaperec->StraightEdge.VLDeltaX,shaperec->StraightEdge.NumBits+2);
 
348
                }
 
349
          }
 
350
        }
 
351
      else
 
352
        {
 
353
          /* A Curved Edge Record */
 
354
          SWFOutput_writeBits(out,shaperec->CurvedEdge.NumBits,4);
 
355
          SWFOutput_writeSBits(out,shaperec->CurvedEdge.ControlDeltaX,shaperec->CurvedEdge.NumBits+2);
 
356
          SWFOutput_writeSBits(out,shaperec->CurvedEdge.ControlDeltaY,shaperec->CurvedEdge.NumBits+2);
 
357
          SWFOutput_writeSBits(out,shaperec->CurvedEdge.AnchorDeltaX,shaperec->CurvedEdge.NumBits+2);
 
358
          SWFOutput_writeSBits(out,shaperec->CurvedEdge.AnchorDeltaY,shaperec->CurvedEdge.NumBits+2);
 
359
        }
 
360
    }
 
361
  else
 
362
    {
 
363
      /* A Non-Edge Record */
 
364
      if (shaperec->EndShape.EndOfShape == 0)
 
365
        {
 
366
          SWFOutput_writeBits(out,shaperec->EndShape.EndOfShape,5);
 
367
          return;
 
368
        }
 
369
      SWFOutput_writeBits(out,shaperec->StyleChange.StateNewStyles,1);
 
370
      SWFOutput_writeBits(out,shaperec->StyleChange.StateLineStyle,1);
 
371
      SWFOutput_writeBits(out,shaperec->StyleChange.StateFillStyle1,1);
 
372
      SWFOutput_writeBits(out,shaperec->StyleChange.StateFillStyle0,1);
 
373
      SWFOutput_writeBits(out,shaperec->StyleChange.StateMoveTo,1);
 
374
 
 
375
      if (shaperec->StyleChange.StateMoveTo)
 
376
        {
 
377
          SWFOutput_writeBits(out,shaperec->StyleChange.MoveBits,5);
 
378
          SWFOutput_writeSBits(out,shaperec->StyleChange.MoveDeltaX,shaperec->StyleChange.MoveBits);
 
379
          SWFOutput_writeSBits(out,shaperec->StyleChange.MoveDeltaY,shaperec->StyleChange.MoveBits);
 
380
        }
 
381
      if (shaperec->StyleChange.StateFillStyle0) {
 
382
          SWFOutput_writeBits(out,shaperec->StyleChange.FillStyle0,fillBits);
 
383
      }
 
384
      if (shaperec->StyleChange.StateFillStyle1) {
 
385
          SWFOutput_writeBits(out,shaperec->StyleChange.FillStyle1,fillBits);
 
386
      }
 
387
      if (shaperec->StyleChange.StateLineStyle) {
 
388
          SWFOutput_writeBits(out,shaperec->StyleChange.LineStyle,lineBits);
 
389
      }
 
390
    }
 
391
}
 
392
 
 
393
SWFOutput
 
394
outputswfSWF_SHAPE (SWF_SHAPE * shape)
 
395
{
 
396
  SWFOutput out;
 
397
  int i;
 
398
 
 
399
  out=newSWFOutput();
 
400
  SWFOutput_writeBits(out,shape->NumFillBits,4);
 
401
  SWFOutput_writeBits(out,shape->NumLineBits,4);
 
402
  for (i = 0; i < shape->NumShapeRecords; i++)
 
403
    {
 
404
      outputswfSWF_SHAPERECORD (&(shape->ShapeRecords[i]), out,shape->NumFillBits,shape->NumLineBits);
 
405
    }
 
406
  SWFOutput_byteAlign(out);
 
407
  return out;
 
408
}
 
409
 
 
410
#if 0
 
411
void
 
412
outputSWF_SHAPEWITHSTYLE (SWF_SHAPEWITHSTYLE * shape, int level, char *name)
 
413
{
 
414
/*
 
415
  int i;
 
416
 
 
417
  outputSWF_FILLSTYLEARRAY (&(shape->FillStyles),"");
 
418
  outputSWF_LINESTYLEARRAY (&(shape->LineStyles),"");
 
419
  printf (" NumFillBits: %d\n", shape->NumFillBits);
 
420
  printf (" NumLineBits: %d\n", shape->NumLineBits);
 
421
  for (i = 0; i < shape->NumShapeRecords; i++)
 
422
    {
 
423
      outputswfSWF_SHAPERECORD (&(shape->ShapeRecords[i]),name);
 
424
    }
 
425
*/
 
426
}
 
427
 
 
428
void
 
429
outputSWF_GLYPHENTRY (SWF_GLYPHENTRY *gerec)
 
430
{
 
431
        printf("   GlyphIndex[0] = %4.4lx ", gerec->GlyphIndex[0] );
 
432
        printf("   GlyphAdvance[0] = %4.4lx\n", gerec->GlyphAdvance[0] );
 
433
}
 
434
 
 
435
void
 
436
outputSWF_TEXTRECORD (SWF_TEXTRECORD *trec, int level)
 
437
{
 
438
  int i;
 
439
  printf (" TEXTRECORD: ");
 
440
  printf ("  TextRecordType: %d ", trec->TextRecordType);
 
441
  printf ("  StyleFlagsReserved: %d ", trec->StyleFlagsReserved);
 
442
  printf ("  StyleFlagHasFont: %d ", trec->StyleFlagHasFont);
 
443
  printf ("  StyleFlagHasColor: %d ", trec->StyleFlagHasColor);
 
444
  printf ("  StyleFlagHasYOffset: %d ", trec->StyleFlagHasYOffset);
 
445
  printf ("  StyleFlagHasXOffset: %d\n", trec->StyleFlagHasXOffset);
 
446
 
 
447
  if ( trec->TextRecordType == 0 )
 
448
  {
 
449
        /*
 
450
         * parser doesn't initialize any other
 
451
         * member when TextRecordType == 0,
 
452
         * see parseSWF_TEXTRECORD in parser.c
 
453
         */
 
454
        return;
 
455
  }
 
456
 
 
457
  if( trec->StyleFlagHasFont )
 
458
    printf ("  FontID: %d\n", trec->FontID);
 
459
  if( trec->StyleFlagHasColor ) {
 
460
    outputSWF_RGBA(&trec->TextColor, "" );
 
461
  }
 
462
  if( trec->StyleFlagHasYOffset || trec->StyleFlagHasXOffset ) {
 
463
    printf ("  XOffset: %d ", trec->XOffset);
 
464
    printf ("  YOffset: %d\n", trec->YOffset);
 
465
  }
 
466
  if( trec->StyleFlagHasFont )
 
467
    printf ("  TextHeight: %d\n", trec->TextHeight);
 
468
  printf ("  GlyphCount: %d\n", trec->GlyphCount);
 
469
  for(i=0;i<trec->GlyphCount;i++)
 
470
          outputSWF_GLYPHENTRY( &(trec->GlyphEntries[i]) );
 
471
}
 
472
 
 
473
 
 
474
/* Output Flash Blocks */
 
475
 
 
476
void
 
477
outputSWF_CHARACTERSET (SWF_Parserstruct * pblock)
 
478
{
 
479
  //OUT_BEGIN (SWF_CHARACTERSET);
 
480
 
 
481
}
 
482
 
 
483
void
 
484
outputSWF_DEFINEBITS (SWF_Parserstruct * pblock)
 
485
{
 
486
  //OUT_BEGIN (SWF_DEFINEBITS);
 
487
 
 
488
}
 
489
 
 
490
void
 
491
outputSWF_DEFINEBITSJPEG2 (SWF_Parserstruct * pblock)
 
492
{
 
493
  //OUT_BEGIN (SWF_DEFINEBITSJPEG2);
 
494
 
 
495
}
 
496
 
 
497
void
 
498
outputSWF_DEFINEBITSJPEG3 (SWF_Parserstruct * pblock)
 
499
{
 
500
  //OUT_BEGIN (SWF_DEFINEBITSJPEG3);
 
501
 
 
502
}
 
503
 
 
504
void
 
505
outputSWF_DEFINEBITSPTR (SWF_Parserstruct * pblock)
 
506
{
 
507
  //OUT_BEGIN (SWF_DEFINEBITSPTR);
 
508
 
 
509
}
 
510
 
 
511
void
 
512
outputSWF_DEFINEBUTTON (SWF_Parserstruct * pblock)
 
513
{
 
514
  //OUT_BEGIN (SWF_DEFINEBUTTON);
 
515
 
 
516
}
 
517
 
 
518
void
 
519
outputSWF_DEFINEBUTTON2 (SWF_Parserstruct * pblock)
 
520
{
 
521
  int i;
 
522
  OUT_BEGIN (SWF_DEFINEBUTTON2);
 
523
 
 
524
#if !defined(ACTIONONLY)
 
525
  printf (" CharacterID: %d\n", sblock->Buttonid);
 
526
  printf (" TrackAsMenu: %d\n", sblock->TrackAsMenu);
 
527
  printf (" ActionOffset: %d\n", sblock->ActionOffset);
 
528
  for(i=0;i<sblock->numCharacters;i++) {
 
529
          outputSWF_BUTTONRECORD( &(sblock->Characters[i]) );
 
530
  }
 
531
#endif
 
532
  for(i=0;i<sblock->numActions;i++) {
 
533
          outputSWF_BUTTONCONDACTION( &(sblock->Actions[i]) );
 
534
  }
 
535
 
 
536
}
 
537
 
 
538
void
 
539
outputSWF_DEFINEBUTTONCXFORM (SWF_Parserstruct * pblock)
 
540
{
 
541
  //OUT_BEGIN (SWF_DEFINEBUTTONCXFORM);
 
542
 
 
543
}
 
544
 
 
545
void
 
546
outputSWF_DEFINEBUTTONSOUND (SWF_Parserstruct * pblock)
 
547
{
 
548
  //OUT_BEGIN (SWF_DEFINEBUTTONSOUND);
 
549
 
 
550
}
 
551
 
 
552
void
 
553
outputSWF_DEFINECOMMANDOBJ (SWF_Parserstruct * pblock)
 
554
{
 
555
  //OUT_BEGIN (SWF_DEFINECOMMANDOBJ);
 
556
 
 
557
}
 
558
 
 
559
void
 
560
outputSWF_DEFINEEDITTEXT (SWF_Parserstruct * pblock)
 
561
{
 
562
  OUT_BEGIN (SWF_DEFINEEDITTEXT);
 
563
 
 
564
  printf (" CharacterID: %d\n", sblock->CharacterID);
 
565
  outputSWF_RECT (&(sblock->Bounds));
 
566
  printf (" Flags: ");
 
567
  printf (" HasText: %d ", sblock->HasText);
 
568
  printf (" WordWrap: %d ", sblock->WordWrap);
 
569
  printf (" Multiline: %d ", sblock->Multiline);
 
570
  printf (" Password: %d ", sblock->Password);
 
571
  printf (" ReadOnly: %d\n", sblock->ReadOnly);
 
572
  printf ("        ");
 
573
  printf (" HasTextColor: %d ", sblock->HasTextColor);
 
574
  printf (" HasMaxLength: %d ", sblock->HasMaxLength);
 
575
  printf (" HasFont: %d ", sblock->HasFont);
 
576
  printf (" AutoSize: %d ", sblock->AutoSize);
 
577
  printf (" HasLayout: %d\n", sblock->HasLayout);
 
578
  printf ("        ");
 
579
  printf (" NoSelect: %d ", sblock->NoSelect);
 
580
  printf (" Border: %d ", sblock->Border);
 
581
  printf (" HTML: %d ", sblock->HTML);
 
582
  printf (" UseOutlines: %d\n", sblock->UseOutlines);
 
583
  if (sblock->HasFont)
 
584
    {
 
585
      printf (" Font: ");
 
586
      printf (" FontID: %d ", sblock->FontID);
 
587
      printf (" FontHeight: %d\n", sblock->FontHeight);
 
588
    }
 
589
  if (sblock->HasTextColor)
 
590
    {
 
591
      outputSWF_RGBA (&sblock->TextColor,"");
 
592
    }
 
593
  if (sblock->HasLayout)
 
594
    {
 
595
      printf (" Layout:: ");
 
596
      printf (" Align: %d ", sblock->Align);
 
597
      printf (" LeftMargin: %d ", sblock->LeftMargin);
 
598
      printf (" RightMargin: %d ", sblock->RightMargin);
 
599
      printf (" Indent: %d ", sblock->Indent);
 
600
      printf (" Leading: %d\n", sblock->Leading);
 
601
    }
 
602
  printf (" VariableName: %s\n", sblock->VariableName);
 
603
  if (sblock->HasText)
 
604
    {
 
605
      printf (" InitialText: %s\n", sblock->InitialText);
 
606
    }
 
607
}
 
608
 
 
609
void
 
610
outputSWF_DEFINEFONT (SWF_Parserstruct * pblock)
 
611
{
 
612
  //OUT_BEGIN (SWF_DEFINEFONT);
 
613
 
 
614
}
 
615
#endif
 
616
 
 
617
SWFOutput
 
618
outputSWF_DEFINEFONT2 (SWF_Parserstruct * pblock)
 
619
{
 
620
  SWFOutput hdr0,hdr1,offsettbl,*glyphdata;
 
621
  int i,size, glyphbase;
 
622
  OUT_BEGIN (SWF_DEFINEFONT2);
 
623
 
 
624
 
 
625
  glyphdata = calloc(sblock->NumGlyphs,sizeof(SWFOutput *));
 
626
  size=0;
 
627
  for (i = 0; i < sblock->NumGlyphs; i++) {
 
628
        glyphdata[i] = outputswfSWF_SHAPE (&(sblock->GlyphShapeTable[i]));
 
629
        size+= SWFOutput_getLength(glyphdata[i]);
 
630
    }
 
631
 
 
632
  if( size > 0xffff ) 
 
633
    sblock->FontFlagsWideOffsets=1;
 
634
 
 
635
  if (sblock->FontFlagsWideOffsets) {
 
636
    glyphbase=(sblock->NumGlyphs*4)+4;
 
637
    sblock->OffsetTable.UI32[0]=glyphbase;
 
638
    sblock->CodeTableOffset.UI32=glyphbase;
 
639
  } else {
 
640
    glyphbase=(sblock->NumGlyphs*2)+2;
 
641
    sblock->CodeTableOffset.UI16=glyphbase;
 
642
    sblock->OffsetTable.UI16[0]=glyphbase;
 
643
    }
 
644
 
 
645
  for (i = 0; i < sblock->NumGlyphs; i++) {
 
646
        if (sblock->FontFlagsWideOffsets) {
 
647
          sblock->OffsetTable.UI32[i]=sblock->CodeTableOffset.UI32;
 
648
          sblock->CodeTableOffset.UI32=sblock->OffsetTable.UI32[i]+SWFOutput_getLength(glyphdata[i]);
 
649
        } else {
 
650
          sblock->OffsetTable.UI16[i]=sblock->CodeTableOffset.UI16;
 
651
          sblock->CodeTableOffset.UI16=sblock->OffsetTable.UI16[i]+SWFOutput_getLength(glyphdata[i]);
 
652
        }
 
653
    }
 
654
 
 
655
  offsettbl=newSWFOutput();
 
656
  for (i = 0; i < sblock->NumGlyphs; i++) {
 
657
      if (sblock->FontFlagsWideOffsets) {
 
658
        SWFOutput_writeUInt32(offsettbl,sblock->OffsetTable.UI32[i]);
 
659
      } else {
 
660
        SWFOutput_writeUInt16(offsettbl,sblock->OffsetTable.UI16[i]);
 
661
        }
 
662
    }
 
663
 
 
664
  /* Now that we have the glyph data, and it's offset, we can start assembling
 
665
     this block */
 
666
 
 
667
  size= 5               /* Initial header through FontNameLen */
 
668
        +(sblock->FontNameLen)  /* FontName */
 
669
        +2;             /* NumGlyphs */
 
670
 
 
671
  hdr1=newSizedSWFOutput(size);
 
672
  SWFOutput_writeUInt16(hdr1,sblock->FontID);
 
673
  SWFOutput_writeBits(hdr1,sblock->FontFlagsHasLayout,1);
 
674
  SWFOutput_writeBits(hdr1,sblock->FontFlagsShiftJis,1);
 
675
  SWFOutput_writeBits(hdr1,sblock->FontFlagsSmallText,1);
 
676
  SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagANSI,1);
 
677
  SWFOutput_writeBits(hdr1,sblock->FontFlagsWideOffsets,1);
 
678
  SWFOutput_writeBits(hdr1,sblock->FontFlagsWideCodes,1);
 
679
  SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagsItalics,1);
 
680
  SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagsBold,1);
 
681
  SWFOutput_writeUInt8(hdr1,sblock->LanguageCode);
 
682
  SWFOutput_writeUInt8(hdr1,sblock->FontNameLen);
 
683
  SWFOutput_writeBuffer(hdr1,(unsigned char *)sblock->FontName,sblock->FontNameLen);
 
684
  SWFOutput_writeUInt16(hdr1,sblock->NumGlyphs);
 
685
 
 
686
  /* Now, copy these parts into the hdr buffer */
 
687
  SWFOutput_writeToMethod(offsettbl,SWFOutputMethod,hdr1);
 
688
  destroySWFOutput(offsettbl);
 
689
  if (sblock->FontFlagsWideOffsets)
 
690
    {
 
691
        SWFOutput_writeUInt32(hdr1,sblock->CodeTableOffset.UI32);
 
692
    }
 
693
  else
 
694
    {
 
695
        SWFOutput_writeUInt16(hdr1,sblock->CodeTableOffset.UI16);
 
696
    }
 
697
  for (i = 0; i < sblock->NumGlyphs; i++) {
 
698
    SWFOutput_writeToMethod(glyphdata[i],SWFOutputMethod,hdr1);
 
699
    destroySWFOutput(glyphdata[i]);
 
700
  }
 
701
  free(glyphdata);
 
702
 
 
703
  /* Now, resume the normal linear processing this tag */
 
704
 
 
705
  for (i = 0; i < sblock->NumGlyphs; i++)
 
706
    {
 
707
        if( sblock->FontFlagsWideCodes ) {
 
708
          SWFOutput_writeUInt16(hdr1,sblock->CodeTable[i]);
 
709
        } else {
 
710
          SWFOutput_writeUInt8(hdr1,sblock->CodeTable[i]);
 
711
        }
 
712
    }
 
713
 
 
714
  if( sblock->FontFlagsHasLayout ) {
 
715
    SWFOutput_writeSInt16(hdr1,sblock->FontAscent);
 
716
    SWFOutput_writeSInt16(hdr1,sblock->FontDecent);
 
717
    SWFOutput_writeSInt16(hdr1,sblock->FontLeading);
 
718
    for (i = 0; i < sblock->NumGlyphs; i++) {
 
719
      SWFOutput_writeSInt16(hdr1,sblock->FontAdvanceTable[i]);
 
720
      }
 
721
    for (i = 0; i < sblock->NumGlyphs; i++) {
 
722
        outputswfSWF_RECT (hdr1,&(sblock->FontBoundsTable[i]));
 
723
        SWFOutput_byteAlign(hdr1);
 
724
      }
 
725
    SWFOutput_writeUInt16(hdr1,sblock->KerningCount);
 
726
    for (i = 0; i < sblock->KerningCount; i++) {
 
727
      if( sblock->FontFlagsWideCodes ) {
 
728
        SWFOutput_writeUInt16(hdr1,sblock->FontKerningTable[i].FontKerningCode1);
 
729
        SWFOutput_writeUInt16(hdr1,sblock->FontKerningTable[i].FontKerningCode2);
 
730
        SWFOutput_writeSInt16(hdr1,sblock->FontKerningTable[i].FontKerningAdjustment);
 
731
      } else {
 
732
        SWFOutput_writeUInt8(hdr1,sblock->FontKerningTable[i].FontKerningCode1);
 
733
        SWFOutput_writeUInt8(hdr1,sblock->FontKerningTable[i].FontKerningCode2);
 
734
        SWFOutput_writeSInt16(hdr1,sblock->FontKerningTable[i].FontKerningAdjustment);
 
735
      }
 
736
    }
 
737
  }
 
738
 
 
739
/* This code really belongs in outputTAGHeader() */
 
740
hdr0=newSizedSWFOutput(6);
 
741
 
 
742
if(SWFOutput_getLength(hdr1) <= 62 ) {
 
743
        SWFOutput_writeUInt16(hdr0,(SWF_DEFINEFONT2<<6)|SWFOutput_getLength(hdr1));
 
744
} else {
 
745
        SWFOutput_writeUInt16(hdr0,(SWF_DEFINEFONT2<<6)|0x3f);
 
746
        SWFOutput_writeUInt32(hdr0,SWFOutput_getLength(hdr1));
 
747
}
 
748
 
 
749
SWFOutput_writeToMethod(hdr1,SWFOutputMethod,hdr0);
 
750
destroySWFOutput(hdr1);
 
751
 
 
752
return hdr0;
 
753
}
 
754
 
 
755
#if 0
 
756
void
 
757
outputSWF_DEFINEFONTINFO (SWF_Parserstruct * pblock)
 
758
{
 
759
  //OUT_BEGIN (SWF_DEFINEFONTINFO);
 
760
 
 
761
}
 
762
 
 
763
void
 
764
outputSWF_DEFINELOSSLESS (SWF_Parserstruct * pblock)
 
765
{
 
766
  //OUT_BEGIN (SWF_DEFINELOSSLESS);
 
767
 
 
768
}
 
769
 
 
770
void
 
771
outputSWF_DEFINELOSSLESS2 (SWF_Parserstruct * pblock)
 
772
{
 
773
  //OUT_BEGIN (SWF_DEFINELOSSLESS2);
 
774
 
 
775
}
 
776
 
 
777
void
 
778
outputSWF_DEFINEMORPHSHAPE (SWF_Parserstruct * pblock)
 
779
{
 
780
  //OUT_BEGIN (SWF_DEFINEMORPHSHAPE);
 
781
 
 
782
}
 
783
 
 
784
void
 
785
outputSWF_DEFINESHAPE (SWF_Parserstruct * pblock)
 
786
{
 
787
  OUT_BEGIN (SWF_DEFINESHAPE);
 
788
 
 
789
  printf (" ShapeID: %d\n", sblock->ShapeID);
 
790
  outputSWF_RECT (&(sblock->ShapeBounds));
 
791
  outputSWF_SHAPEWITHSTYLE (&(sblock->Shapes),1,"");
 
792
}
 
793
 
 
794
void
 
795
outputSWF_DEFINESHAPE2 (SWF_Parserstruct * pblock)
 
796
{
 
797
  OUT_BEGIN (SWF_DEFINESHAPE2);
 
798
 
 
799
  printf (" ShapeID: %d\n", sblock->ShapeID);
 
800
  outputSWF_RECT (&(sblock->ShapeBounds));
 
801
  outputSWF_SHAPEWITHSTYLE (&(sblock->Shapes),2,"");
 
802
 
 
803
}
 
804
 
 
805
void
 
806
outputSWF_DEFINESHAPE3 (SWF_Parserstruct * pblock)
 
807
{
 
808
  OUT_BEGIN (SWF_DEFINESHAPE3);
 
809
 
 
810
  printf (" ShapeID: %d\n", sblock->ShapeID);
 
811
  outputSWF_RECT (&(sblock->ShapeBounds));
 
812
  outputSWF_SHAPEWITHSTYLE (&(sblock->Shapes),2,"");
 
813
 
 
814
}
 
815
 
 
816
void
 
817
outputSWF_DEFINESOUND (SWF_Parserstruct * pblock)
 
818
{
 
819
  //OUT_BEGIN (SWF_DEFINESOUND);
 
820
 
 
821
}
 
822
 
 
823
void
 
824
outputSWF_DEFINESPRITE (SWF_Parserstruct * pblock)
 
825
{
 
826
  OUT_BEGIN (SWF_DEFINESPRITE);
 
827
  printf(" SpriteId: %d\n", sblock->SpriteId );
 
828
  printf(" FrameCount: %d\n", sblock->FrameCount );
 
829
  printf(" BlockCount: %d\n", sblock->BlockCount );
 
830
 
 
831
}
 
832
 
 
833
void
 
834
outputSWF_DEFINETEXT (SWF_Parserstruct * pblock)
 
835
{
 
836
  int i;
 
837
  OUT_BEGIN (SWF_DEFINETEXT);
 
838
 
 
839
  printf(" CharacterID: %d\n", sblock->CharacterID );
 
840
  outputSWF_RECT( &sblock->TextBounds );
 
841
  outputSWF_MATRIX( &sblock->TextMatrix, "" );
 
842
  printf(" GlyphBits: %d\n", sblock->GlyphBits );
 
843
  printf(" AdvanceBits: %d\n", sblock->AdvanceBits );
 
844
  printf(" TextRecords: %d\n", sblock->numTextRecords );
 
845
  for(i=0;i<sblock->numTextRecords;i++) {
 
846
          outputSWF_TEXTRECORD(&(sblock->TextRecords[i]), 1 );
 
847
  }
 
848
 
 
849
}
 
850
 
 
851
void
 
852
outputSWF_DEFINETEXT2 (SWF_Parserstruct * pblock)
 
853
{
 
854
  int i;
 
855
  OUT_BEGIN (SWF_DEFINETEXT2);
 
856
 
 
857
  printf(" CharacterID: %d\n", sblock->CharacterID );
 
858
  outputSWF_RECT( &sblock->TextBounds );
 
859
  outputSWF_MATRIX( &sblock->TextMatrix, "" );
 
860
  printf(" GlyphBits: %d\n", sblock->GlyphBits );
 
861
  printf(" AdvanceBits: %d\n", sblock->AdvanceBits );
 
862
  printf(" TextRecords: %d\n", sblock->numTextRecords );
 
863
  for(i=0;i<sblock->numTextRecords;i++) {
 
864
          outputSWF_TEXTRECORD(&(sblock->TextRecords[i]), 2 );
 
865
  }
 
866
}
 
867
 
 
868
void
 
869
outputSWF_DEFINETEXTFORMAT (SWF_Parserstruct * pblock)
 
870
{
 
871
  //OUT_BEGIN (SWF_DEFINETEXTFORMAT);
 
872
 
 
873
}
 
874
 
 
875
void
 
876
outputSWF_DEFINEVIDEO (SWF_Parserstruct * pblock)
 
877
{
 
878
  //OUT_BEGIN (SWF_DEFINEVIDEO);
 
879
 
 
880
}
 
881
 
 
882
void
 
883
outputSWF_DEFINEVIDEOSTREAM (SWF_Parserstruct * pblock)
 
884
{
 
885
  //OUT_BEGIN (SWF_DEFINEVIDEOSTREAM);
 
886
 
 
887
}
 
888
 
 
889
void
 
890
outputSWF_DOACTION (SWF_Parserstruct * pblock)
 
891
{
 
892
#if 0
 
893
#ifdef NODECOMPILE
 
894
        int i;
 
895
#endif
 
896
        OUT_BEGIN (SWF_DOACTION);
 
897
 
 
898
#ifdef NODECOMPILE
 
899
        printf(" %d Actions\n", sblock->numActions);
 
900
        for(i=0;i<sblock->numActions;i++)
 
901
        outputSWF_ACTION(i,&(sblock->Actions[i]));
 
902
#else
 
903
        printf ("%s\n", decompile5Action(sblock->numActions,sblock->Actions,0));
 
904
#endif
 
905
#endif
 
906
 
 
907
}
 
908
 
 
909
void
 
910
outputSWF_ENABLEDEBUGGER (SWF_Parserstruct * pblock)
 
911
{
 
912
  //OUT_BEGIN (SWF_ENABLEDEBUGGER);
 
913
 
 
914
}
 
915
 
 
916
void
 
917
outputSWF_END (SWF_Parserstruct * pblock)
 
918
{
 
919
  //OUT_BEGIN (SWF_END);
 
920
 
 
921
}
 
922
 
 
923
void
 
924
outputSWF_EXPORTASSETS (SWF_Parserstruct * pblock)
 
925
{
 
926
  int i;
 
927
  OUT_BEGIN (SWF_EXPORTASSETS);
 
928
 
 
929
  printf (" num assets: %d\n", sblock->Count );
 
930
  for (i = 0; i < sblock->Count; i++)
 
931
    {
 
932
        printf (" Asset[%3.3d]: %s\n", sblock->Tags[i],
 
933
                  sblock->Names[i]);
 
934
    }
 
935
 
 
936
}
 
937
 
 
938
void
 
939
outputSWF_FONTREF (SWF_Parserstruct * pblock)
 
940
{
 
941
  //OUT_BEGIN (SWF_FONTREF);
 
942
 
 
943
}
 
944
 
 
945
void
 
946
outputSWF_FRAMELABEL (SWF_Parserstruct * pblock)
 
947
{
 
948
  //OUT_BEGIN (SWF_FRAMELABEL);
 
949
 
 
950
}
 
951
 
 
952
void
 
953
outputSWF_FRAMETAG (SWF_Parserstruct * pblock)
 
954
{
 
955
  //OUT_BEGIN (SWF_FRAMETAG);
 
956
 
 
957
}
 
958
 
 
959
void
 
960
outputSWF_FREEALL (SWF_Parserstruct * pblock)
 
961
{
 
962
  //OUT_BEGIN (SWF_FREEALL);
 
963
 
 
964
}
 
965
 
 
966
void
 
967
outputSWF_FREECHARACTER (SWF_Parserstruct * pblock)
 
968
{
 
969
  //OUT_BEGIN (SWF_FREECHARACTER);
 
970
 
 
971
}
 
972
 
 
973
void
 
974
outputSWF_GENCOMMAND (SWF_Parserstruct * pblock)
 
975
{
 
976
  //OUT_BEGIN (SWF_GENCOMMAND);
 
977
 
 
978
}
 
979
 
 
980
void
 
981
outputSWF_IMPORTASSETS (SWF_Parserstruct * pblock)
 
982
{
 
983
  int i;
 
984
  OUT_BEGIN (SWF_IMPORTASSETS);
 
985
 
 
986
  printf (" URL: %s\n", sblock->URL );
 
987
  printf (" num assets: %d\n", sblock->Count );
 
988
  for (i = 0; i < sblock->Count; i++)
 
989
    {
 
990
        printf (" Asset[%3.3d]: %s\n", sblock->Tags[i],
 
991
                  sblock->Names[i]);
 
992
    }
 
993
 
 
994
}
 
995
 
 
996
void
 
997
outputSWF_JPEGTABLES (SWF_Parserstruct * pblock)
 
998
{
 
999
  //OUT_BEGIN (SWF_JPEGTABLES);
 
1000
 
 
1001
}
 
1002
 
 
1003
void
 
1004
outputSWF_NAMECHARACTER (SWF_Parserstruct * pblock)
 
1005
{
 
1006
  //OUT_BEGIN (SWF_NAMECHARACTER);
 
1007
 
 
1008
}
 
1009
 
 
1010
void
 
1011
outputSWF_PATHSAREPOSTSCRIPT (SWF_Parserstruct * pblock)
 
1012
{
 
1013
  //OUT_BEGIN (SWF_PATHSAREPOSTSCRIPT);
 
1014
 
 
1015
}
 
1016
 
 
1017
void
 
1018
outputSWF_PLACEOBJECT (SWF_Parserstruct * pblock)
 
1019
{
 
1020
  //OUT_BEGIN (SWF_PLACEOBJECT);
 
1021
 
 
1022
}
 
1023
 
 
1024
void
 
1025
outputSWF_PLACEOBJECT2 (SWF_Parserstruct * pblock)
 
1026
{
 
1027
  OUT_BEGIN (SWF_PLACEOBJECT2);
 
1028
 
 
1029
#if !defined(ACTIONONLY)
 
1030
  printf(" PlaceFlagHasClipActions %d\n", sblock->PlaceFlagHasClipActions);
 
1031
  printf(" PlaceFlagHasClipDepth %d\n", sblock->PlaceFlagHasClipDepth);
 
1032
  printf(" PlaceFlagHasName %d\n", sblock->PlaceFlagHasName);
 
1033
  printf(" PlaceFlagHasRatio %d\n", sblock->PlaceFlagHasRatio);
 
1034
  printf(" PlaceFlagHasColorTransform %d\n", sblock->PlaceFlagHasColorTransform);
 
1035
  printf(" PlaceFlagHasMatrix %d\n", sblock->PlaceFlagHasMatrix);
 
1036
  printf(" PlaceFlagHasCharacter %d\n", sblock->PlaceFlagHasCharacter);
 
1037
  printf(" PlaceFlagMove %d\n", sblock->PlaceFlagMove);
 
1038
  printf(" Depth %d\n", sblock->Depth);
 
1039
  if( sblock->PlaceFlagHasCharacter )
 
1040
          printf( " CharacterId: %d\n", sblock->CharacterId );
 
1041
  if( sblock->PlaceFlagHasMatrix )
 
1042
        outputSWF_MATRIX (&(sblock->Matrix), "");
 
1043
/*
 
1044
  if( sblock->PlaceFlagHasColorTransform )
 
1045
        outputSWF_CXFORMWITHALPHA (&(sblock->ColorTransform), "");
 
1046
*/
 
1047
  if( sblock->PlaceFlagHasRatio )
 
1048
          printf( " Ratio: %d\n", sblock->Ratio );
 
1049
  if( sblock->PlaceFlagHasName )
 
1050
          printf( " Name: %s\n", sblock->Name );
 
1051
  if( sblock->PlaceFlagHasClipDepth )
 
1052
          printf( " ClipDepth: %d\n", sblock->ClipDepth );
 
1053
#endif
 
1054
  if( sblock->PlaceFlagHasClipActions )
 
1055
        outputSWF_CLIPACTIONS (&(sblock->ClipActions));
 
1056
}
 
1057
 
 
1058
void
 
1059
outputSWF_PREBUILT (SWF_Parserstruct * pblock)
 
1060
{
 
1061
  //OUT_BEGIN (SWF_PREBUILT);
 
1062
 
 
1063
}
 
1064
 
 
1065
void
 
1066
outputSWF_PREBUILTCLIP (SWF_Parserstruct * pblock)
 
1067
{
 
1068
  //OUT_BEGIN (SWF_PREBUILTCLIP);
 
1069
 
 
1070
}
 
1071
 
 
1072
void
 
1073
outputSWF_PROTECT (SWF_Parserstruct * pblock)
 
1074
{
 
1075
  OUT_BEGIN (SWF_PROTECT);
 
1076
 
 
1077
  printf(" Password: %s\n", sblock->Password);
 
1078
 
 
1079
}
 
1080
 
 
1081
void
 
1082
outputSWF_REMOVEOBJECT (SWF_Parserstruct * pblock)
 
1083
{
 
1084
  //OUT_BEGIN (SWF_REMOVEOBJECT);
 
1085
 
 
1086
}
 
1087
 
 
1088
void
 
1089
outputSWF_REMOVEOBJECT2 (SWF_Parserstruct * pblock)
 
1090
{
 
1091
  //OUT_BEGIN (SWF_REMOVEOBJECT2);
 
1092
 
 
1093
}
 
1094
 
 
1095
void
 
1096
outputSWF_SERIALNUMBER (SWF_Parserstruct * pblock)
 
1097
{
 
1098
  //OUT_BEGIN (SWF_SERIALNUMBER);
 
1099
 
 
1100
}
 
1101
 
 
1102
void
 
1103
outputSWF_SETBACKGROUNDCOLOR (SWF_Parserstruct * pblock)
 
1104
{
 
1105
  OUT_BEGIN (SWF_SETBACKGROUNDCOLOR);
 
1106
 
 
1107
  outputSWF_RGBA (&sblock->rgb, "");
 
1108
 
 
1109
}
 
1110
 
 
1111
void
 
1112
outputSWF_SHOWFRAME (SWF_Parserstruct * pblock)
 
1113
{
 
1114
  //OUT_BEGIN (SWF_SHOWFRAME);
 
1115
 
 
1116
}
 
1117
 
 
1118
void
 
1119
outputSWF_SOUNDSTREAMBLOCK (SWF_Parserstruct * pblock)
 
1120
{
 
1121
  //OUT_BEGIN (SWF_SOUNDSTREAMBLOCK);
 
1122
 
 
1123
}
 
1124
 
 
1125
void
 
1126
outputSWF_SOUNDSTREAMHEAD (SWF_Parserstruct * pblock)
 
1127
{
 
1128
  //OUT_BEGIN (SWF_SOUNDSTREAMHEAD);
 
1129
 
 
1130
}
 
1131
 
 
1132
void
 
1133
outputSWF_SOUNDSTREAMHEAD2 (SWF_Parserstruct * pblock)
 
1134
{
 
1135
  //OUT_BEGIN (SWF_SOUNDSTREAMHEAD2);
 
1136
 
 
1137
}
 
1138
 
 
1139
void
 
1140
outputSWF_STARTSOUND (SWF_Parserstruct * pblock)
 
1141
{
 
1142
  //OUT_BEGIN (SWF_STARTSOUND);
 
1143
 
 
1144
}
 
1145
 
 
1146
void
 
1147
outputSWF_SYNCFRAME (SWF_Parserstruct * pblock)
 
1148
{
 
1149
  //OUT_BEGIN (SWF_SYNCFRAME);
 
1150
 
 
1151
}
 
1152
 
 
1153
void
 
1154
outputSWF_INITACTION (SWF_Parserstruct * pblock)
 
1155
{
 
1156
#if 0
 
1157
#ifdef NODECOMPILE
 
1158
        int i;
 
1159
#endif
 
1160
        OUT_BEGIN (SWF_INITACTION);
 
1161
 
 
1162
#ifdef NODECOMPILE
 
1163
        printf(" %d Actions\n", sblock->numActions);
 
1164
        for(i=0;i<sblock->numActions;i++)
 
1165
        outputSWF_ACTION(i,&(sblock->Actions[i]));
 
1166
#else
 
1167
        printf ("%s\n", decompile5Action(sblock->numActions,sblock->Actions,0));
 
1168
#endif
 
1169
#endif
 
1170
 
 
1171
}
 
1172
void
 
1173
outputSWF_VIDEOFRAME (SWF_Parserstruct * pblock)
 
1174
{
 
1175
  //OUT_BEGIN (SWF_VIDEOFRAME);
 
1176
 
 
1177
}
 
1178
#endif
 
1179
 
 
1180
static SWFOutput swfout;
 
1181
 
 
1182
void
 
1183
outputHeader (struct Movie *m)
 
1184
{
 
1185
swfout=newSWFOutput();
 
1186
}
 
1187
 
 
1188
void
 
1189
outputTrailer (struct Movie *m)
 
1190
{
 
1191
SWFOutput out;
 
1192
 
 
1193
out=newSizedSWFOutput(30);
 
1194
SWFOutput_writeUInt8(out,'F');
 
1195
SWFOutput_writeUInt8(out,'W');
 
1196
SWFOutput_writeUInt8(out,'S');
 
1197
SWFOutput_writeUInt8(out,4);
 
1198
SWFOutput_writeUInt32(out,SWFOutput_getLength(swfout)+23 /*size of header*/);
 
1199
SWFOutput_writeBits(out,15,5);
 
1200
SWFOutput_writeSBits(out,m->frame.xMin,15);
 
1201
SWFOutput_writeSBits(out,m->frame.xMax,15);
 
1202
SWFOutput_writeSBits(out,m->frame.yMin,15);
 
1203
SWFOutput_writeSBits(out,m->frame.yMax,15);
 
1204
SWFOutput_byteAlign(out);
 
1205
SWFOutput_writeUInt16(out,m->rate);
 
1206
SWFOutput_writeUInt16(out,m->nFrames);
 
1207
SWFOutput_writeToMethod(out,fileOutputMethod,stdout);
 
1208
SWFOutput_writeToMethod(swfout,fileOutputMethod,stdout);
 
1209
destroySWFOutput(swfout);
 
1210
destroySWFOutput(out);
 
1211
}
 
1212
 
 
1213
void
 
1214
outputBlock (int type, SWF_Parserstruct * blockp, 
 
1215
                int offset, int length)
 
1216
{
 
1217
  SWFOutput blkout;
 
1218
  int i;
 
1219
 
 
1220
  if (type < 0)
 
1221
    return;
 
1222
 
 
1223
  for (i = 0; i < numOutputs; i++)
 
1224
    {
 
1225
      if (outputs[i].type == type)
 
1226
        {
 
1227
          blkout=outputs[i].output (blockp);
 
1228
          SWFOutput_writeToMethod(blkout,SWFOutputMethod,swfout);
 
1229
          destroySWFOutput(blkout);
 
1230
        }
 
1231
    }
 
1232
  return;
 
1233
}