X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfcombine.c;h=d52aa71102cab87c29f55c4342294e963fb02552;hb=0b9b00579d7d74dd9107cd49c01be74282109b0b;hp=5f8622174a20c6992f8df616f8d0147fc2775b70;hpb=b75a03c88c7a57abe9e9bb92d1752c52ac6adfb2;p=swftools.git diff --git a/src/swfcombine.c b/src/swfcombine.c index 5f86221..d52aa71 100644 --- a/src/swfcombine.c +++ b/src/swfcombine.c @@ -288,7 +288,7 @@ static void makestackmaster(SWF*swf) TAG*tag; int t; SRECT box; - int fileversion = 1; + int fileversion = config.zlib?6:3; int frameRate = 256; RGBA rgb; rgb.r=rgb.b=rgb.g=0; @@ -480,13 +480,19 @@ TAG* write_sprite_defines(TAG*tag, SWF*sprite) case ST_SETBACKGROUNDCOLOR: msg(" deliberately ignoring BACKGROUNDCOLOR tag"); break; + case ST_SHOWFRAME: + msg(" deliberately ignoring SHOWFRAME tag"); + break; + case ST_REFLEX: + msg(" deliberately ignoring REFLEX tag"); + break; case 40: case 49: case 51: - msg(" found tag %d. This is a Generator template, isn't it?", tag->id); + msg(" found tag %d. This is a Generator template, isn't it?", rtag->id); break; default: - msg(" funny tag: %d is neither defining nor sprite", tag->id); + msg(" funny tag: %d is neither defining nor sprite", rtag->id); } } } @@ -497,7 +503,6 @@ TAG* write_sprite_defines(TAG*tag, SWF*sprite) void changedepth(TAG*tag, int add) { - /* fucking byteorders */ if(tag->id == ST_PLACEOBJECT) PUT16(&tag->data[2],GET16(&tag->data[2])+add); if(tag->id == ST_PLACEOBJECT2) @@ -506,6 +511,23 @@ void changedepth(TAG*tag, int add) PUT16(&tag->data[2],GET16(&tag->data[2])+add); if(tag->id == ST_REMOVEOBJECT2) PUT16(&tag->data[0],GET16(&tag->data[0])+add); + if(tag->id == ST_PLACEOBJECT2) { + SWFPLACEOBJECT obj; + U8 flags; + swf_SetTagPos(tag, 0); + flags = swf_GetU8(tag); + if(flags&2) swf_GetU16(tag); //id + if(flags&4) swf_GetMatrix(tag, 0); + if(flags&8) swf_GetCXForm(tag, 0,1); + if(flags&16) swf_GetU16(tag); //ratio + if(flags&64) { + swf_ResetReadBits(tag); + printf("%d->%d\n", GET16(&tag->data[tag->pos]), + GET16(&tag->data[tag->pos])+add); + PUT16(&tag->data[tag->pos],GET16(&tag->data[tag->pos])+add); + } + msg(" Depth relocation not fully working yet with clipdepths", tag->id); + } } void matrix_adjust(MATRIX*m, int movex, int movey, float scalex, float scaley, int scalepos) @@ -618,8 +640,9 @@ TAG* write_sprite(TAG*tag, SWF*sprite, int spriteid, int replaceddefine) rtag->id, rtag->len); tag = swf_InsertTag(tag, rtag->id); write_changepos(tag, rtag, config.movex, config.movey, config.scalex, config.scaley, 0); - - changedepth(tag, +2); + + if(config.clip || (config.overlay && !config.isframe)) + changedepth(tag, +2); if(tag->id == ST_SHOWFRAME) { @@ -643,9 +666,10 @@ static char tag_ok_for_slave(int id) TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefine, int flags) { int outputslave = 0; - int frame = 0; + int frame = 1; int sframe = 0; int slavewritten = 0; + int deletedepth = -1; TAG* rtag = master->firstTag; TAG* stag = slave->firstTag; @@ -670,6 +694,14 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi if(rtag->id == ST_SHOWFRAME) { frame ++; + tag = swf_InsertTag(tag, ST_SHOWFRAME); + if(deletedepth>=0) { + tag = swf_InsertTag(tag, ST_REMOVEOBJECT2); + swf_SetU16(tag, deletedepth); + deletedepth=-1; + } + rtag = rtag->next; + continue; } if(swf_isDefiningTag(rtag) && (flags&FLAGS_WRITEDEFINES)) @@ -703,7 +735,7 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi swf_SetBlock(tag, rtag->data, rtag->len); } } - if(frame == slaveframe) + if(frame == slaveframe) /* only happens with config.isframe: put slave at specific frame */ { if(flags&FLAGS_WRITESLAVE) { outputslave = 1; @@ -712,7 +744,8 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi if((flags&FLAGS_WRITESPRITE) && !slavewritten) { int id = get_free_id(masterbitmap); - int depth = 0; + int depth = 65535; + deletedepth = 65535; if(config.clip) { msg(" Can't combine --clip and --frame"); } @@ -753,6 +786,7 @@ TAG* write_master(TAG*tag, SWF*master, SWF*slave, int spriteid, int replaceddefi rtag->id, rtag->len); tag = swf_InsertTag(tag, rtag->id); write_changepos(tag, rtag, config.mastermovex, config.mastermovey, config.masterscalex, config.masterscaley, 1); + } } rtag = rtag->next; @@ -1201,9 +1235,11 @@ int main(int argn, char *argv[]) fi = open(outputname, O_BINARY|O_RDWR|O_TRUNC|O_CREAT, 0777); - if(config.zlib) + if(config.zlib) { + if(newswf.fileVersion < 6) + newswf.fileVersion = 6; swf_WriteSWC(fi, &newswf); - else { + } else { newswf.compressed = 0; swf_WriteSWF(fi, &newswf); }