;RIAnimlib v1.0 ;(C)1994 Reflective Images ;Written by Stephen McNamara ;June-July 1994  ;Updates: ;         - fixed anim loop off bug (nextframe ignored flag)  ;#rianimlib=57   bmap  `0<>2     "Not enough parameters"  !libs {#bitmaplib,#ia`1|#pd`2}    !libheader {#rianimlib,0,0,0,0}  !acommand {#long} !args {#long,#long,#long} !libs !subs {_InitAnim2,0,0} !args {#long,#long,#long,#long} !libs !subs {_InitAnim,0,0} !name {"RIAnimInit","(address,bitmap#,palette#[,xy_offset])"}  !acommand {#long} !args {#byte} !bmap {0,0} !subs {_NextAnimFrame,0,0} !name {"RINextAnimFrame","(bitmap#)"}  !astatement !args {#byte} !libs !subs {_AnimLoop,0,0} !name {"AnimLoop","On|Off"}  !libfin  _libfinit:     .GetChunkHeader: 'loop:   \.l     (a0),d0   H       'gotit   @.l    #2,a0   \.l     a0,a1   Q       'loop   .l   #0,d0    'gotit:   .l   #-1,d0      _AnimLoop:   ~.l    #0,doanimloop   .b     d0    P       'gotit    'gotit:   ~.l    #-1,doanimloop      ;================================================  _InitAnim2:   .l   #0,d3 ._InitAnim:   ~.b    d1,bitmapnumber   ~.b    d2,palettenumber   ~.l    d3,bitplaneoffset   ~.l    d0,a0   ].l    #"ANIM",8(a0)   H       'gotit   .l   #0,d0    'gotit:   ~.l    4(a0),animsize   =.l     d0,animsize   ~.l    d0,animaddress   ~.l    d0,nextanimframe   =.l     #28,nextanimframe    ~.l    #"BMHD",d0   ~.l    a0,a1   =.l     #2000,a1   Y       GetChunkHeader   .l     d0   P       'gotBMHD    'gotBMHD:   @.l    #8,a0   ~.w    (a0),animwidth   ~.w    2(a0),animheight   ~.b    8(a0),animdepth    ~.l    animaddress,d0   .l   #0,d1   ~.b    bitmapnumber,d1   ~.l    #-1,d2   ~.l    bitplaneoffset,d3   8   ,1    ~.l    animaddress,d0   .l   #0,d1   ~.b    palettenumber,d1   8       ~.l    animaddress,a0   ~.l    a0,thirdframe   ~.l    animsize,a1   ~.l    #"FORM",d0   Y       GetChunkHeader    @.l    #8,a0   ~.l    #"FORM",d0   Y       GetChunkHeader    @.l    #8,a0   ~.l    #"FORM",d0   Y       GetChunkHeader    ~.l    a0,nextanimframe    @.l    #8,a0   ~.l    #"FORM",d0   Y       GetChunkHeader    .l     d0   H       'nothirdframe   ~.l    a0,thirdframe  'nothirdframe: ;  MOVE.l    thirdframe,d0 ;  MOVE.l    d0,nextanimframe   .l   #-1,d0     ;a0=bitmap address ;d1=offset ._NextAnimFrame:   ~.l    nextanimframe,d0   P       'gotanim   ~.l    #0,d0    'gotanim:   .l   d1-d7/a0-a6,-(a7)   @.l    #8,a0   ~.l    a0,bitmapaddress    ~.l    d0,a0   ].l    #"FORM",(a0)   H       'gotaframe  'looparound:   .b     doanimloop   P       'yesloop   .l   (a7)+,d1-d7/a0-a6   .l   #0,d0    'yesloop:   ~.l    thirdframe,a0 'gotaframe:   ~.l    4(a0),d7   @.l    #8,a0   ~.l    a0,nextanimframe   =.l     d7,nextanimframe    @.l    #4,a0               ;skip ILBM   ].l    #"ANHD",(a0)   H       'gotANHD   .l   (a7)+,d1-d7/a0-a6   .l   #0,d0    'gotANHD   ~.b    8(a0),animtype   ~.l    28(a0),animtype7   =.l     4(a0),a0   @.l    #8,a0    ].l    #"CMAP",(a0)   P       'heynopalette   ~.l    a0,-(a7)   ~.l    a0,d0   .l   #0,d1   ~.b    palettenumber,d1               ;palette number   8      ~.l    (a7)+,a0   =.l     4(a0),a0   @.l    #8,a0 'heynopalette:   ].l    #"DLTA",(a0)   H       'yesdelta   .l   #0,d0    'yesdelta:   ~.l    bitmapaddress,a6   ~.b    animtype,d0    ].b    #5,d0   H       UnpackAnim5   ].b    #65,d0   H       UnpackAnim5   ].b    #7,d0   H       UnpackAnim7    .l   (a7)+,d1-d7/a0-a6   .l   #0,d0     ;a0=delta chunk header ;a6=pointer to bitplane array .UnpackAnim7:   @.l    #8,a0    ~.l    a0,a5   ~.l    a0,a4    .l   #0,d7   ~.w    -8(a6),d7   ~.l    #0,d4    .b     d0   H       UnpackAnim7Short    .l   #0,d0   ~.w    animwidth,d0   E.w     #5,d0   .w    #1,d0   ~.w    d0,animwidthtemp  unpacklooplong:   ~.l    (a6)+,a1                   ; get a bitplane   =.l     bitplaneoffset,a1   ~.l    (a5)+,d0   ~.l    28(a5),a3   .l     d0   H       'nodata  ;got some plane data to unpack   =.l     a4,d0   ~.l    d0,a0   =.l     a4,a3   Y       'unpackaplane 'nodata:   @.b    #1,d4   \.b     animdepth,d4   P       unpacklooplong    .l   (a7)+,d1-d7/a0-a6   .l   #-1,d0     'unpackaplane:   ~.w    animwidthtemp,d6                      ; 40 columns 'columnloop:   ~.l    a1,a2   @.l    #4,a1   ~.b    (a0)+,d3   P       'getdata   o      d6,'columnloop    'getdata:   .l   #0,d0   ~.b    (a0)+,d0   H       'condition0   W      #7,d0   P       'condition1 ;case 0: top bit is 0 ;so adjust y value downwards   ~.w    d0,d1   .w    d7,d1   =.l     d1,a2   .b    #1,d3   P       'getdata   o      d6,'columnloop     ;case 1: condition=0 so get repeat number and value 'condition0:   ~.b    (a0)+,d0                        ; repeat number   ~.l    (a3)+,d1                        ; data   .b     d0,d5   .b    #1,d0 'loop:   ~.l    d1,(a2)   =.l     d7,a2   o      d0,'loop    .b    #1,d3   P       'getdata   o      d6,'columnloop     ;case 2: condition>0 and condition<128 so get raw data 'condition1:   C.b    #%01111111,d0   .b     d0,d5   .b    #1,d0 'loop2:   ~.l    (a3)+,(a2)   =.l     d7,a2   o      d0,'loop2    .b    #1,d3   P       'getdata   o      d6,'columnloop     ;Short ANIM7 unpacking .UnpackAnim7Short:   ~.l    animtype7,d0   E.w     #4,d0   .w    #1,d0   ~.w    d0,animwidthtemp  unpackloopshort:   ~.l    (a6)+,a1                   ; get a bitplane   =.l     bitplaneoffset,a1   ~.l    (a5)+,d0   ~.l    28(a5),a3   .l     d0   H       'nodata  ;got some plane data to unpack   =.l     a4,d0   ~.l    d0,a0   =.l     a4,a3   Y       'unpackaplane 'nodata:   @.b    #1,d4   \.b     animdepth,d4   P       unpackloopshort    .l   (a7)+,d1-d7/a0-a6   .l   #-1,d0     'unpackaplane:   ~.w    animwidthtemp,d6                      ; 40 columns 'columnloop:   ~.l    a1,a2   @.l    #2,a1   ~.b    (a0)+,d3   P       'getdata   o      d6,'columnloop    'getdata:   .l   #0,d0   ~.b    (a0)+,d0   H       'condition0   W      #7,d0   P       'condition1 ;case 0: top bit is 0 ;so adjust y value downwards   ~.w    d0,d1   .w    d7,d1   =.l     d1,a2   .b    #1,d3   P       'getdata   o      d6,'columnloop     ;case 1: condition=0 so get repeat number and value 'condition0:   ~.b    (a0)+,d0                        ; repeat number   ~.w    (a3)+,d1                        ; data   .b     d0,d5   .b    #1,d0 'loop:   ~.w    d1,(a2)   =.l     d7,a2   o      d0,'loop    .b    #1,d3   P       'getdata   o      d6,'columnloop     ;case 2: condition>0 and condition<128 so get raw data 'condition1:   C.b    #%01111111,d0   .b     d0,d5   .b    #1,d0 'loop2:   ~.w    (a3)+,(a2)   =.l     d7,a2   o      d0,'loop2    .b    #1,d3   P       'getdata   o      d6,'columnloop     ;a0=pointer to DLTA chunk ;a6=pointer to bitplanes array .UnpackAnim5:   ~.l    bitmapaddress,a6   @.l    #8,a0    ~.l    a0,a5   ~.l    a0,a4    .l   #0,d7   ~.w    -8(a6),d7    ~.w    animwidth,d0   E.w     #3,d0   .w    #1,d0   ~.w    d0,animwidthtemp    ~.l    #0,d4 'unpackloop:   ~.l    (a6)+,a1                   ; get a bitplane   =.l     bitplaneoffset,a1   ~.l    (a5)+,d0   .l     d0   H       'nodata  ;got some plane data to unpack   =.l     a4,d0   ~.l    d0,a0   Y       'unpackaplane 'nodata:   @.b    #1,d4   \.b     animdepth,d4   P       'unpackloop    .l   (a7)+,d1-d7/a0-a6   .l   #-1,d0     'unpackaplane:   ~.w    animwidthtemp,d6                      ; 40 columns 'columnloop:   ~.l    a1,a2   @.l    #1,a1   ~.b    (a0)+,d3   P       'getdata   o      d6,'columnloop    'getdata:   .l   #0,d0   ~.b    (a0)+,d0   H       'condition0   W      #7,d0   P       'condition1 ;case 0: top bit is 0 ;so adjust y value downwards   ~.w    d0,d1   .w    d7,d1   =.l     d1,a2   .b    #1,d3   P       'getdata   o      d6,'columnloop     ;case 1: condition=0 so get repeat number and value 'condition0:   ~.b    (a0)+,d0                        ; repeat number   ~.b    (a0)+,d1                        ; data   .b    #1,d0 'loop:   ~.b    d1,(a2)   =.l     d7,a2   o      d0,'loop    .b    #1,d3   P       'getdata   o      d6,'columnloop     ;case 2: condition>0 and condition<128 so get raw data 'condition1:   C.b    #%01111111,d0   .b    #1,d0 'loop2:   ~.b    (a0)+,(a2)   =.l     d7,a2   o      d0,'loop2    .b    #1,d3   P       'getdata   o      d6,'columnloop     animaddress:     %.l  0 animsize:        %.l  0 nextanimframe:   %.l  0 animheight:      %.l  0 animdepth:       %.l  0 animwidth:       %.l  0 animwidthtemp:   %.w  0 bitmapaddress:   %.l  0 animtype7:       %.l  0 bitplaneoffset:  %.l  0 thirdframe:      %.l  0   ' doanimloop:       %.b  -1 bitmapnumber:     %.b  0 palettenumber:    %.b  0 animtype:         %.b  0  