;rifxlib=66  ;FX-library ;By Stephen McNamara ;(C)1994 Reflective Images  ;17/7/1994 ; As from this date, only the following only work on lorez ;  bitmaps: ZoomX8, ZoomXY, Derez ; Derez has been optimised for all derez values under 18 - it is ;  much faster doing these derezs now ; ClearBitmap and FadeInBitmap have had comments add at last! ;  These commands also have been adjusted to work on any size ;  bitmap.  At the moment, though, they operate on the whole ;  width of the bitmap. ;10/7/1994 ; ZoomX2 and ZoomX4 now work on any size bitmap. ;  Depth of zoom is taken from source bitmap but bitmaps can be ;  different heights and widths ; ZOOMX4 command is changed to include separate X and Y zooming, ;  this feature may be added to X2 and X8   bmap  `0<>2     "Not enough parameters"  !libs {#bitmaplib,#ia`1|#pd`2}    !libheader {#rifxlib,init,0,finit,0}  !astatement !args {#long,#long} !bmap {0,0} !subs {_clearbitmap2,0,0} !args {#long,#long,#word,#word} !bmap {0,0} !subs {_clearbitmap,0,0} !name {"ClearBitmap","bitmap#,delay[,height,offset]"}  !astatement !args {#long,#long,#long} !libs {#bitmaplib,#ia0|#pd0,#bitmaplib,#ia1|#pd1} !subs {_fadeinbitmap2,0,0} !args {#long,#long,#long,#word,#word,#word} !libs {#bitmaplib,#ia0|#pd0,#bitmaplib,#ia1|#pd1} !subs {_fadeinbitmap,0,0} !name {"FadeInBitmap","bitmapsource#,bitmapdest#,delay[,height,offset1,offset2]"}  !astatement !args {#byte,#byte,#long,#long,#word,#word} !libs {#bitmaplib,#ia0|#pd0,#bitmaplib,#ia1|#pd1} !subs {_zoomxy_no_xy,0,0} !args {#byte,#byte,#long,#long,#word,#word,#byte} !libs {#bitmaplib,#ia0|#pd0,#bitmaplib,#ia1|#pd1} !subs {_zoomx4_xy,0,0} !name {"ZoomX4","source#,dest#,sourceadd,destadd,width,height[,xy_select]"}  !acommand {#long} !args {#long,#long,#long,#long,#word,#word} !libs {#bitmaplib,#ia0|#pd0,#bitmaplib,#ia1|#pd1} !subs {_asmderez,0,0} !name {"Derez","source#,dest#,sourceadd,destadd,derez_value,height"}  !astatement !args {#word,#word,#word} !libs !subs {_AsmZoom,0,0} !name {"ZoomXY","xzoom,yzoom,height"}  !astatement !args {#long,#long,#long,#long} !libs {#bitmaplib,#ia0|#pd0,#bitmaplib,#ia1|#pd1} !subs {_InitZoomxy,0,0} !name {"InitZoomXY","source#,dest#,sourceadd,destadd"}  !astatement !args {#long,#long,#long,#long,#word,#word} !libs {#bitmaplib,#ia0|#pd0,#bitmaplib,#ia1|#pd1} !subs {_zoomx2,0,0} !name {"ZoomX2","source#,dest#,sourceadd,destadd,width,height"}  !astatement !args {#long,#long,#word,#word,#word} !libs !subs {_planetochunky,0,0} !name {"PlanarToChunky","bitmap_addr,dest_addr,width,height,depth"}  !astatement !args {#long,#long,#word,#word,#word} !libs !subs {_chunkytoplane,0,0} !name {"ChunkyToPlanar","source_addr,bitmap_addr,width,height,depth"}  !astatement !args {#byte,#byte,#long,#long,#word,#word} !libs {#bitmaplib,#ia0|#pd0,#bitmaplib,#ia1|#pd1} !subs {_zoomx8,0,0} !name {"ZoomX8","source#,dest#,sourceadd,destadd,width,height"}  !afunction {#long} !args {#byte,#word,#word} !bmap {0,0} !subs {_ADDValue,0,0} !name {"ADDValue","(bitmap#,x,y)"}  !astatement !args {#byte,#byte,#long,#long,#word,#word} !libs {#bitmaplib,#ia0|#pd0,#bitmaplib,#ia1|#pd1} !subs {_ReduceX2,0,0} !name {"ReduceX2","source#,dest#,sourceadd,destadd,width,height"}  finit:!nullsub{_libfinit,0,0} init: !nullsub{_libinit,0,0}  !libfin  _libfinit:   .l   tableaddress   P     'yup    'yup   ~.l  #1856,d0   ~.l  tableaddress,a1   8 $c003     _libinit:   ~.l  #1856,d0                  ; amount of memoru for LUTs   .l #%1,d1                    ; any memory please   .l #0,d2   8 $c002                     ; call Blitz allocmem    .l   d0   P     'gotmem     'gotmem:   ~.l  d0,tableaddress   ~.l  d0,a0 CreateReduceX2:   ~.l  a0,reducex2table   .l #0,d0 'loop:   .l #0,d1 'bit7:   W    #7,d0   H     'bit5   V    #3,d1 'bit5:   W    #5,d0   H     'bit3   V    #2,d1 'bit3:   W    #3,d0   H     'bit1   V    #1,d1 'bit1:   W    #1,d0   H     'endloop   V    #0,d1 'endloop:   ~.b  d1,(a0)+   @.w  #1,d0   ].w  #256,d0   P     'loop  CreateZoomX2:   ~.l  a0,zoomx2table   .l #0,d0 'loop:   .l #0,d1 'bit7:   W    #7,d0   H     'bit6   =.w   #%1100000000000000,d1 'bit6:   W    #6,d0   H     'bit5   =.w   #%11000000000000,d1 'bit5:   W    #5,d0   H     'bit4   =.w   #%110000000000,d1 'bit4:   W    #4,d0   H     'bit3   =.w   #%1100000000,d1 'bit3:   W    #3,d0   H     'bit2   =.b   #%11000000,d1 'bit2:   W    #2,d0   H     'bit1   =.b   #%110000,d1 'bit1:   W    #1,d0   H     'bit0   =.b   #%1100,d1 'bit0:   W    #0,d0   H     'endloop   =.b   #%11,d1 'endloop:   ~.w  d1,(a0)+   @.w  #1,d0   ].w  #256,d0   P     'loop  CreateZoomX4:   ~.l  a0,zoomx4table   .l #0,d0 'loop:   .l #0,d1 'bit7:   W    #7,d0   H     'bit6   =.l   #$f0000000,d1 'bit6:   W    #6,d0   H     'bit5   =.l   #$f000000,d1 'bit5:   W    #5,d0   H     'bit4   =.l   #$f00000,d1 'bit4:   W    #4,d0   H     'bit3   =.l   #$f0000,d1 'bit3:   W    #3,d0   H     'bit2   =.w   #$f000,d1 'bit2:   W    #2,d0   H     'bit1   =.w   #$f00,d1 'bit1:   W    #1,d0   H     'bit0   =.b   #$f0,d1 'bit0:   W    #0,d0   H     'endloop   =.b   #$f,d1 'endloop:   ~.l  d1,(a0)+   @.w  #1,d0   ].w  #256,d0   P     'loop  CreateZoomX8:   ~.l  a0,zoomx8table   .l #0,d0 'loop:   .l #0,d1 'bit3:   W    #3,d0   H     'bit2   =.l   #$ff000000,d1 'bit2:   W    #2,d0   H     'bit1   =.l   #$ff0000,d1 'bit1:   W    #1,d0   H     'bit0   =.w   #$ff00,d1 'bit0:   W    #0,d0   H     'endloop   =.b   #$ff,d1 'endloop:   ~.l  d1,(a0)+   @.b  #1,d0   ].b  #16,d0   P     'loop       ._planetochunky   .l d0-d7/a0-a6,-(a7)   ~.l  d0,a0    ~.l  d1,a1   ~.l  #"CKPL",(a1)+                     ; store header in plane   ~.w  d2,(a1)+                          ; store width in plane   ~.w  d3,(a1)+                          ; store height in plane   ~.w  d4,(a1)+                          ; store depth in plane    ~.b  d4,bitdepth                       ; store depth    E.w   #3,d2                             ; get width in bytes   C.l  #$ff,d2   .w  #1,d2                             ; adjust for dbra   ~.w  d2,bitwidth                       ; and store    .w  #1,d3                             ; adjust height for dbra   ~.w  d3,bitheight                      ; and store    ~.w  (a0),bitmapwidth                  ; store bitmap width    .l #0,d4   ~.b  5(a0),d4   .w  #1,d4   @.l  #8,a0   ~.l  (a0)+,TBPL0   ~.l  (a0)+,TBPL1   ~.l  (a0)+,TBPL2   ~.l  (a0)+,TBPL3   ~.l  (a0)+,TBPL4   ~.l  (a0)+,TBPL5   ~.l  (a0)+,TBPL6   ~.l  (a0)+,TBPL7    ~.w  bitheight,d7                      ; d7=line counter   ~.l  a1,a6    .l d0-d7/a0-a6,-(a7)   ~.l  4,a6   y     -$27c(a6)   .l (a7)+,d0-d7/a0-a6 'yloop:   ~.w  bitwidth,d6                       ; d6=width in bytes   .l #7,d5                             ; pointer to bit   .l #0,d3                             ; amount to add to bitplane pointer 'xloop   .l #0,d0 ; construct a byte from upto 8 bitplanes 'TSTBPL0:   ~.l  TBPL0,a1   =.l   d3,a1   W    d5,(a1)   H     'TSTBPL1   V    #0,d0 'TSTBPL1:   \.b   #1,bitdepth   H     'end_test   ~.l  TBPL1,a1   =.l   d3,a1   W    d5,(a1)   H     'TSTBPL2   V    #1,d0 'TSTBPL2:   \.b   #2,bitdepth   H     'end_test   ~.l  TBPL2,a1   =.l   d3,a1   W    d5,(a1)   H     'TSTBPL3   V    #2,d0 'TSTBPL3:   \.b   #3,bitdepth   H     'end_test   ~.l  TBPL3,a1   =.l   d3,a1   W    d5,(a1)   H     'TSTBPL4   V    #3,d0 'TSTBPL4:   \.b   #4,bitdepth   H     'end_test   ~.l  TBPL4,a1   =.l   d3,a1   W    d5,(a1)   H     'TSTBPL5   V    #4,d0 'TSTBPL5:   \.b   #5,bitdepth   H     'end_test   ~.l  TBPL5,a1   =.l   d3,a1   W    d5,(a1)   H     'TSTBPL6   V    #5,d0 'TSTBPL6:   \.b   #6,bitdepth   H     'end_test   ~.l  TBPL6,a1   =.l   d3,a1   W    d5,(a1)   H     'TSTBPL7   V    #6,d0 'TSTBPL7:   \.b   #7,bitdepth   H     'end_test   ~.l  TBPL7,a1   =.l   d3,a1   W    d5,(a1)   H     'end_test   V    #7,d0  'end_test:   ~.b  d0,(a6)+                            ; store byte   .b  #1,d5   Q     'xloop    @.b  #1,d3   .l #7,d5   o    d6,'xloop    .l #0,d5   ~.w  bitmapwidth,d5    =.l   d5,TBPL0   =.l   d5,TBPL1   =.l   d5,TBPL2   =.l   d5,TBPL3   =.l   d5,TBPL4   =.l   d5,TBPL5   =.l   d5,TBPL6   =.l   d5,TBPL7    o    d7,'yloop   .l (a7)+,d0-d7/a0-a6     ._chunkytoplane:   .l d0-d7/a0-a6,-(a7)    ~.l  d0,a0   ~.l  d1,a1    ~.b  d4,bitdepth                       ; store depth    .w  #1,d2                             ; adjust for dbra   ~.w  d2,bitwidth                       ; and store    .w  #1,d3                             ; adjust height for dbra   ~.w  d3,bitheight                      ; and store    ~.w  (a1),bitmapwidth                  ; store bitmap width    .l #0,d4   ~.b  5(a1),d4   .w  #1,d4   @.l  #8,a1   ~.l  a1,a5    .l d0-d7/a0-a6,-(a7)   ~.l  4,a6   y     -$27c(a6)   .l (a7)+,d0-d7/a0-a6   ~.l  a0,a6    .l #0,d4 ;a6=Addr Chunky   a5=Bitplane PTRS 'bitplane_loop:   ~.l  a6,a0   ~.l  (a5)+,a2   ~.l  a2,a1   ~.w  bitheight,d7                      ; d7=line counter 'yloop:   ~.w  bitwidth,d6                       ; d6=width in bytes   .l #31,d5                            ; d5=pointer to bit   .l #0,d1                             ; d4=bitplane pointer 'xloop:                                     ; d0=chunky byte   ~.b  (a0)+,d0                          ; d1=bitplane data   W    d4,d0   H     'not_set   V    d5,d1  'not_set:   .w  #1,d6   O     'end_of_line   .b  #1,d5   Q     'xloop    ~.l  d1,(a1)+   .l #0,d1   .l #31,d5   X     'xloop  'end_of_line   ~.l  d1,(a1)+   .l #0,d0   ~.w bitmapwidth,d0   =.l   d0,a2   ~.l  a2,a1   o    d7,'yloop    @.b  #1,d4   \.b   bitdepth,d4   P     'bitplane_loop   .l (a7)+,d0-d7/a0-a6      bitdepth:     %.b  1   ' bitwidth:     %.w  1 bitheight:    %.w  1 bitmapwidth:  %.w  1 TBPL0:        %.l  1 TBPL1:        %.l  1 TBPL2:        %.l  1 TBPL3:        %.l  1 TBPL4:        %.l  1 TBPL5:        %.l  1 TBPL6:        %.l  1 TBPL7:        %.l  1  ;Clear a bitmap backwards _clearbitmap2:   ~.w  2(a0),d2   .l #0,d3 ._clearbitmap:   .l a4-a6,-(a7)                  ;save registers   ~.l  d1,delay_timer               ;store delay value   ~.w  (a0),d1                      ;get EBWidth   E.w   #1,d1                        ;divide by 2   .w  #1,d1                        ;adjust for dbra   ~.w  d1,EWWidth                   ;even word width of clear   ~.w  4(a0),BDepth                 ;get depth   .w  #1,BDepth                    ;subtract 1    C.l  #$ffff,d2   ~.w  d2,BHeight   .w  #1,BHeight   =.w   d3,d2   .w  (a0),d2                      ;multiple by EBWidth   .l  #4,d2                        ;subtract 2 for loop    @.l  #8,a0   ~.w  BDepth,d0   z     bit_add(pc),a1   z     dest_add(pc),a2 Store_loop   ~.l  (a0)+,d1   =.l   d2,d1   ~.l  d1,(a1)+   ~.l  d1,(a2)+   o    d0,Store_loop  ;yer actual routine   .l #0,d5   ~.w  BHeight,d5                   ;get height   ~.w  #-19,d4                      ;stop value   ~.l  #%1010101010101010,d3        ;source mask Main_loop   .w   d5                           ;over 0?   O     Clear_a_line                 ; no - branch Mask_a_line   z     bit_add(pc),a1               ;get first dest pointers   ~.w  EWWidth,d6                   ;get width Xloop   ~.w  BDepth,d7                    ;get width   ~.l  a1,a0                        ;get dest pointer array bit_loop   ~.l  (a0),a2                      ;get bitplane   B.w   d3,(a2)                      ;mask word   .l  #2,(a0)+                     ;subtract 4 from source   o    d7,bit_loop                  ;loop for all bitplanes   o    d6,Xloop                     ;loop for all of line   .w   d3                           ;not mask for next line  Clear_a_line   .w   d4                           ;Clear this line?   O     End_loop                     ;no - branch   z     dest_add(pc),a1              ;get second dest pointers   ~.w  EWWidth,d6                   ;get width Xloop2   ~.w  BDepth,d7                    ;get depth   ~.l  a1,a0                        ;get array bit_loop2   ~.l  (a0),a2                      ;get bitplane pointer   ~.w  #0,(a2)                      ;clear word   .l  #2,(a0)+                     ;decrement pointer and adjust array   o    d7,bit_loop2                 ;loop for all planes   o    d6,Xloop2                    ;loop for all of width  End_loop   ~.l  delay_timer,d7               ;get delay value Slow_down_loop   .l  #1,d7                        ;simple instruction   P     Slow_down_loop               ;loop until 0    @.w  #1,d4                        ;1 more line done   .w  #1,d5                        ;decrement counter   ].w  #-20,d5                      ;is it the end?   P     Main_loop                    ;nop - branch    .l (a7)+,a4-a6                  ;restore registers                                     ;and exit  ;Copy a bitplane nicely! _fadeinbitmap2:   ~.w  2(a0),d3   .l #0,d4   .l #0,d5 ._fadeinbitmap:   .l a4-a6,-(a7)                  ;save resgisters   ~.l  d2,delay_timer               ;store delay value   ~.w  (a0),d2                      ;get EBWidth   E.w   #1,d2                        ;divide by 2   .w  #1,d2                        ;adjust for dbra   ~.w  d2,EWWidth                   ;even word width of clear   ~.w  4(a0),BDepth                 ;get depth to do   .w  #1,BDepth                    ;adjust for dbra    C.l  #$ffff,d3                    ;just in case   ~.w  d3,BHeight                   ;store height to do   .w  #1,BHeight                   ;adjust for dbra    .w  (a0),d4                      ;make pixel offsets   .w  (a0),d5                      ; into byte offsets    @.l  #8,a0                        ;get source bitplane pointers   @.l  #8,a1                        ;get dest bitplane poi\nters   ~.w  BDepth,d0                    ;get depth   z     bit_add(pc),a2               ;storage area source   z     dest_add(pc),a3              ;storage area dest 'Store_loop   ~.l  (a0)+,d1                     ;source bitplane   =.l   d4,d1                        ;add offset   ~.l  d1,(a2)+                     ;store pointer   ~.l  d1,(a3)+                     ;store pointer    ~.l  (a1)+,d1                     ; destination bitmap   =.l   d5,d1                        ;add offset   ~.l  d1,(a2)+                     ;store pointer   ~.l  d1,(a3)+                     ;store pointer   o    d0,'Store_loop               ;loop for all bitplanes  ;yer actual routine   .l #0,d5   ~.w  BHeight,d5                   ;get height   ~.w  #-19,d4                      ;stop value   ~.l  #%1010101010101010,d3        ;data mask  'Main_loop   .w   d5                           ;under 0?   O     'Clear_a_line                ;yup - branch 'Mask_a_line   z     bit_add(pc),a1               ;get pointers   ~.w  EWWidth,d6                   ;get width 'Xloop   ~.w  BDepth,d7                    ;get depth to do   ~.l  a1,a0                        ;get pointers 'bit_loop   ~.l  (a0),a2                      ;get source bitplane   ~.l  4(a0),a3                     ;get dest bitplane   ~.w  (a2),d0                      ;get a word of data   B.w   d3,d0                        ;and mask it   ~.w  d0,(a3)                      ;store in dest   @.l  #2,(a0)+                     ;adjust pointer and store   @.l  #2,(a0)+                     ;adjust pointer and store   o    d7,'bit_loop                 ;loop for all bitplanes   o    d6,'Xloop                    ;loop for all of width   .w   d3                           ;NOT mask for next line  'Clear_a_line   .w   d4                           ;do this line?   O     'End_loop                    ;no - branch   z     dest_add(pc),a1              ;get pointer array   ~.w  EWWidth,d6                   ;get width 'Xloop2   ~.w  BDepth,d7                    ;get depth   ~.l  a1,a0                        ;get array 'bit_loop2   ~.l  (a0),a2                      ;get source bitplane   ~.l  4(a0),a3                     ;get dest bitplane   ~.w  (a2),(a3)                    ;copy data over   @.l  #2,(a0)+                     ;adjust pointer   @.l  #2,(a0)+                     ;adjust pointer   o    d7,'bit_loop2                ;loop for all bitplanes    o    d6,'Xloop2                   ;loop for all of width  'End_loop   ~.l  delay_timer,d7               ;get delay value 'Slow_down_loop   .l  #1,d7                        ;simple instruction   P     'Slow_down_loop              ;loop until 0    @.w  #1,d4                        ;adjust counter   .w  #1,d5                        ;adjust counter   ].w  #-20,d5                      ;is it all done?   P     'Main_loop                   ;loop until it is    .l (a7)+,a4-a6                  ;restore registers                                     ;and exit    ' EWWidth:    %.w  0 BHeight:    %.w  0 BDepth:     %.w  0 delay_timer:%.l  0  ;================================  _zoomx4_xy:   ~.b  -1(a2),d7   X     _zoomx4 _zoomxy_no_xy:   [.b   d7 ._zoomx4:   .l   zoomx4table   P     'yup    'yup:   ~.b  d7,d0   .l d0-d7/a0-a6,-(a7)   ~.l  d2,d6   ~.l  d3,d7    .l #0,d2   ~.b  5(a0),d2   .b  #1,d2       ; adjust for dbra    z     8(a0),a5   z     8(a1),a6    ~.l  zoomx4table,a4    E.w   #3,d4   ~.w  d4,d3   .w  #1,d4       ; adjust for dbra   O     the_end   .w  #1,d5       ; adjust for dbra   O     the_end   ~.w  d4,xzoom   ~.w  d5,yzoom    ].b  #1,d0   H     X4_x   ].b  #2,d0   H     X4_y  ;Calculate source mod   .l #0,d5   ~.w  -8(a5),d5   .w   d3,d5  ;Calculate dest mod   .l #0,d4   ~.w  -8(a6),d4   ~.w  d4,bytesperline+2   D.w   #2,d4   D.w   #2,d3   .w   d3,d4   ~.l  d4,d3    ~.l  a5,sourcebitplanes  ;X4 - x and y 'x4do_bitplanes   ~.l  sourcebitplanes,a5   =.l   #4,sourcebitplanes   ~.l  (a5)+,a0   =.l   d6,a0   ~.l  (a6)+,a1   =.l   d7,a1    ~.l  a1,a2   =.l   bytesperline,a2   ~.l  a2,a3   =.l   bytesperline,a3   ~.l  a3,a5   =.l   bytesperline,a5    ~.w  yzoom,d1 'x4next_line   ~.w  xzoom,d0 'x4do_line   .l #0,d4   ~.b  (a0)+,d4   D.w   #2,d4   ~.l  0(a4,d4.w),d4    ~.l  d4,(a1)+   ~.l  d4,(a2)+   ~.l  d4,(a3)+   ~.l  d4,(a5)+    o    d0,'x4do_line    =.l   d5,a0   =.l   d3,a1   =.l   d3,a2   =.l   d3,a3   =.l   d3,a5    o    d1,'x4next_line    o    d2,'x4do_bitplanes   .l (a7)+,d0-d7/a0-a6       sourcebitplanes: %.l 0  X4_x: ;Calculate source mod   .l #0,d5   ~.w  -8(a5),d5   .w   d3,d5  ;Calculate dest mod   .l #0,d4   ~.w  -8(a6),d4   D.w   #2,d3   .w   d3,d4   ~.l  d4,d3  'x4do_bitplanes   ~.l  (a5)+,a0   =.l   d6,a0   ~.l  (a6)+,a1   =.l   d7,a1   ~.w  yzoom,d1 'x4next_line   ~.w  xzoom,d0 ;  MOVE.l  a0,a2 ;  MOVE.l  a1,a3 'x4do_line   .l #0,d4   ~.b  (a0)+,d4   .w   #2,d4   ~.l  0(a4,d4.w),(a1)+    o    d0,'x4do_line    =.l   d5,a0   =.l   d3,a1    o    d1,'x4next_line    o    d2,'x4do_bitplanes   .l (a7)+,d0-d7/a0-a6     X4_y: ;Calculate source mod   .l #0,d5   ~.w  -8(a5),d5   .w   d3,d5  ;Calculate dest mod   .l #0,d4   ~.w  -8(a6),d4   ~.w  d4,bytesperline+2   D.w   #2,d4   .w   d3,d4   ~.l  d4,d3    ~.l  a5,sourcebitplanes  'x4do_bitplanes   ~.l  sourcebitplanes,a5   =.l   #4,sourcebitplanes   ~.l  (a5)+,a0   =.l   d6,a0   ~.l  (a6)+,a1   =.l   d7,a1    ~.l  a1,a2   =.l   bytesperline,a2   ~.l  a2,a3   =.l   bytesperline,a3   ~.l  a3,a5   =.l   bytesperline,a5    ~.w  yzoom,d1 'x4next_line   ~.w  xzoom,d0 'x4do_line   ~.b  (a0)+,d4    ~.b  d4,(a1)+   ~.b  d4,(a2)+   ~.b  d4,(a3)+   ~.b  d4,(a5)+    o    d0,'x4do_line    =.l   d5,a0   =.l   d3,a1   =.l   d3,a2   =.l   d3,a3   =.l   d3,a5    o    d1,'x4next_line    o    d2,'x4do_bitplanes the_end:   .l (a7)+,d0-d7/a0-a6     ._zoomx2:   .l   zoomx2table   P     'yup    'yup:   .l d0-d7/a0-a6,-(a7)    ~.l  d2,d6   ~.l  d3,d7    .l #0,d2   ~.b  5(a0),d2   .b  #1,d2       ; adjust for dbra    z     8(a0),a5   z     8(a1),a6    ~.l  zoomx2table,a4    E.w   #3,d4   ~.w  d4,d3   .w  #1,d4       ; adjust for dbra   O     'the_end   .w  #1,d5       ; adjust for dbra   O     'the_end   ~.w  d4,xzoom   ~.w  d5,yzoom  ;Calculate source mod   .l #0,d5   ~.w  -8(a5),d5   .w   d3,d5  ;Calculate dest mod   .l #0,d4   ~.w  -8(a6),d4   ~.w  d4,bytesperline+2   .w   d3,d4   .w   d3,d4   ~.l  d4,d3   =.w   -8(a6),d3  'x2do_bitplanes   ~.l  (a5)+,a0   =.l   d6,a0   ~.l  (a6)+,a1   =.l   d7,a1    ~.l  a1,a2   =.l   bytesperline,a2   ~.w  yzoom,d1 'x2next_line   ~.w  xzoom,d0 'x2do_line   .l #0,d4   ~.b  (a0)+,d4   D.w   #1,d4   ~.w  0(a4,d4.w),d4  'x2drawbits   ~.w  d4,(a1)+   ~.w  d4,(a2)+    o    d0,'x2do_line    =.l   d5,a0   =.l   d3,a1   =.l   d3,a2    o    d1,'x2next_line    o    d2,'x2do_bitplanes 'the_end:   .l (a7)+,d0-d7/a0-a6     ._zoomx8   .l   zoomx8table   P     'yup    'yup:   .l d0-d7/a0-a6,-(a7)    ~.l  d2,d6   ~.l  d3,d7    .l #0,d2   ~.b  5(a0),d2   .b  #1,d2       ; adjust for dbra    z     8(a0),a5   z     8(a1),a6    ~.l  zoomx8table,a4    E.w   #3,d4   .w  #1,d4       ; adjust for dbra   O     'the_end   .w  #1,d5       ; adjust for dbra   O     'the_end   ~.w  d4,xzoom   ~.w  d5,yzoom  'do_bitplanes   ~.l  (a5)+,a0   =.l d6,a0   ~.l  (a6)+,a1   =.l d7,a1    ~.w  yzoom,d1 'next_line   ~.w  xzoom,d0   ~.l  a0,a2   ~.l  a1,a3 'do_line   ~.b  (a2)+,d4   ~.b  d4,d5   C.b  #$f,d5   C.l  #$f0,d4   }.b   #2,d4   ~.l  0(a4,d4.w),d3  'drawbits   ~.l  d3,(a3)   ~.l  d3,40(a3)   ~.l  d3,80(a3)   ~.l  d3,120(a3)   ~.l  d3,160(a3)   ~.l  d3,200(a3)   ~.l  d3,240(a3)   ~.l  d3,280(a3)    |.b   #2,d5   ~.l  0(a4,d5.w),d3   @.l  #4,a3   ~.l  d3,(a3)   ~.l  d3,40(a3)   ~.l  d3,80(a3)   ~.l  d3,120(a3)   ~.l  d3,160(a3)   ~.l  d3,200(a3)   ~.l  d3,240(a3)   ~.l  d3,280(a3)     @.l  #4,a3   o    d0,'do_line    z     40(a0),a0   z     320(a1),a1    o    d1,'next_line    o    d2,'do_bitplanes 'the_end   .l (a7)+,d0-d7/a0-a6     ._ReduceX2:   .l   reducex2table   P     'yup    'yup:   .l d0-d7/a0-a6,-(a7)    ~.l  d2,d6   ~.l  d3,d7    .l #0,d2   ~.b  5(a0),d2   .b  #1,d2       ; adjust for dbra    ~.w  (a0),d0   D.w   #1,d0   ~.w  d0,bytesperline+2   ~.w  (a1),bytesperline2+2   z     8(a0),a5   z     8(a1),a6    ~.l  reducex2table,a4    E.w   #3,d4   .w   d4,bytesperline+2   E.w   #1,d4   .w   d4,bytesperline2+2   .w  #1,d4       ; adjust for dbra   O     'the_end   E.w   #1,d5   .w  #1,d5       ; adjust for dbra   O     'the_end   ~.w  d4,xzoom   ~.w  d5,yzoom    .l #0,d4 'x2do_bitplanes   ~.l  (a5)+,a0   =.l   d6,a0   ~.l  (a6)+,a1   =.l   d7,a1   ~.w  yzoom,d1 'x2next_line   ~.w  xzoom,d0 'x2do_line   ~.b  (a0)+,d4   ~.b  0(a4,d4.w),d3    D.b   #4,d3    ~.b  (a0)+,d4   .b    0(a4,d4.w),d3    ~.b  d3,(a1)+    o    d0,'x2do_line    =.l   bytesperline,a0   =.l   bytesperline2,a1    o    d1,'x2next_line    o    d2,'x2do_bitplanes 'the_end:   .l (a7)+,d0-d7/a0-a6       ' bytesperline: %.l  0 bytesperline2:%.l  0 xzoom:        %.w  1 yzoom:        %.w  1  tableaddress: %.l  0 reducex2table:%.l  0 zoomx2table:  %.l  0 zoomx4table:  %.l  0 zoomx8table:  %.l  0  ._asmderez   .w   d4   P     'ok    'ok   .l d1-d7/a0-a6,-(a7)     ; save BLITZ registers   ~.w  d4,res_value          ; store res_value   ~.w  d4,res_value2         ; store again BUT   .w  #1,res_value2         ;  subtract 1 this time   ~.w  d5,height             ; store height AND   .w  #1,height             ;  subtract 1 for dbra   ~.b  5(a0),sbitdepth+1     ; get source bitplane depth   .w  #1,sbitdepth          ;  subtract 1 for dbra   z     8(a0),a0              ; get source's bitplane pointers   z     8(a1),a1              ; get dest's bitplane pointers    ~.w  sbitdepth,d0          ; get bitdepth in d0   z     bit_add(pc),a2        ; source bitplane storage   z     dest_add(pc),a3       ; dest bitplane storage 'store_bitplanes   ~.l  (a0)+,(a2)            ; copy source bitplane address   =.l   d2,(a2)+              ;  AND add offset value   ~.l  (a1)+,(a3)            ; copy dest bitplane address   =.l   d3,(a3)+              ;  AND add offset value   o    d0,'store_bitplanes   ; loop for all bitplanes    .w   res_value2            ; Is res_value2=0?   H     ScreenCopy            ; if so - SCREENCOPY    ].w  #2,res_value          ; Is res_value=2?   H     UnrezX2               ; yes - do FAST X2 unrez    .l #40,d7                ; 40 byte wide screen   .w  res_value,d7          ; X number of lines   ~.l  d7,add_value          ; gives us step value    ~.w  height,yvalue         ; store height in yvalue for use                                 ;  in loop   z     myline(pc),a5   .l #19,d0   .l #15,d1   ~.w  res_value,d3    .l #0,d2 'widthloop:   V    d1,d2   .w   d3,d1   Q     'widthloop ;  NOT.w   d2   ~.w  d2,(a5)+   .l #0,d2    =.w   #16,d1   O     'moretodo   o    d0,'widthloop   X     'yloop  'moretodo:   ~.w  #0,(a5)+   .w  #1,d0   O     'yloop   =.w   #16,d1   O     'moretodo   o    d0,'widthloop  'yloop:                         ; d6=bitplane loop   z     bit_add(pc),a0        ; d5=xloop   z     dest_add(pc),a6   ~.w  sbitdepth,d6 'bitplane_loop:   ~.w  yvalue,d7   ~.l  (a0),a1               ; a1=source   ~.l  a1,a2                 ; a2=source (corruptable)   ~.l  (a6),a3               ; a3=destination   .l #19,d5                ; x count for pixels   .l #0,d0   .l #0,d1    ].w  #16,res_value2   K     'bitbitplane_loop    z     myline(pc),a5   ~.w  #0,mytemp 'xloop:   .l #0,d0   .l #0,d2    ~.w  (a2)+,d0   ~.w  (a5)+,d2   B.w   d2,d0    ~.w  d0,d2    ~.w  res_value2,d4   .w  #1,d4 'myrollloop:   .l   #1,d2   .l    d2,d0   o    d4,'myrollloop   X     'dotherest  'dotherest:   .w    d1,d0    ~.w  d0,(a3)+       d0   ~.w  d0,d1    o    d5,'xloop                ; loop for whole line   X     'done_line  ;Bitmode: 'bitbitplane_loop: ;  MOVE.w  yvalue,d7 ;  MOVE.l  (a0),a1               ; a1=source ;  MOVE.l  a1,a2                 ; a2=source (corruptable) ;  MOVE.l  (a6),a3               ; a3=destination ;  MOVEQ.l #19,d5                ; x count for pixels   .l #15,d3                ; first bit to test on line 'bitxloop:   ~.w  res_value2,d4         ; get number of bits to set   ~.w  (a2),d0               ; get source word   W    d3,d0                 ; test bit of word   H     'clearbits            ; if not set - branch 'setbits:                       ; SETS bits in dest line   ~.w  (a3),d2               ; get destination word 'setbits_loop:   V    d3,d2                 ; set the bit!   .b  #1,d3                 ; decrease bit pointer   O     'setbits_word         ; if negative the get new word   o    d4,'setbits_loop      ; loop for all bits   X     'next_bit             ; branch to main line loop 'setbits_word:                  ; GETS a new destination word   @.l  #2,a2                 ; add 2 to source - IMPORTANT   ~.w  d2,(a3)+              ; move current word into dest   ~.w  (a3),d2               ; get new word   .l #15,d3                ; reset bit pointer   .b  #1,d5                 ; subtract 1 from # of words   O     'done_line            ; exit if we've overflowed the line   o    d4,'setbits_loop      ; loop for all bits to set   X     'next_bit             ; branch to main line loop  'clearbits                      ; CLEARS bits in dest line   ~.w  (a3),d2 'clearbits_loop:   U    d3,d2   .b  #1,d3   O     'clearbits_word   o    d4,'clearbits_loop   X     'next_bit 'clearbits_word:   @.w  #2,a2   ~.w  d2,(a3)+   ~.w  (a3),d2   .l #15,d3   .b  #1,d5   O     'done_line   o    d4,'clearbits_loop  'next_bit:   ~.w  d2,(a3)               ; store dest word   X     'bitxloop                ; loop for whole line    'done_line                      ; COPIES line vertically   ~.w  res_value,d4          ; get res_value   .w  #2,d4                 ; subtract 2 (dbra & current line)   ~.l  (a6),a1               ; get dest bitplane address   z     40(a1),a2             ; add 40 ti skip current line 'copy_line:   .w  #1,d7                 ; subtract 1 from height   O     'out_of_screen        ; Height negative? - OVERFLOW   ~.l  (a1)+,(a2)+           ; Copy 40 bytes   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   o    d4,'copy_line         ; loop around for all lines    ~.l  add_value,d4          ; move source bitplane pointer down   =.l   d4,(a0)               ;  by the current amount & store  'out_of_screen                  ; ALL Y SCREEN FILLED FOR 1 bitplane   @.l  #4,a0                 ; increment source bitplane pointer   ~.l  a2,(a6)+              ; store dest bitplane pointer   o    d6,'bitplane_loop     ; loop for all bitplanes    ~.w  res_value,d6   .w   d6,yvalue             ; decrease yvalue    .w   yvalue                ; test yvalue for OVERFLOW   O     get_out_of_it         ; yvalue NEGATIVE? - RTS   X     'yloop                ; loop for all lines get_out_of_it   .l (a7)+,d1-d7/a0-a6     ; restore BLITZ registers                              ; EXIT  UnrezX2   .l #0,d7                 ; clear d7   ~.w  height,d7             ; get height-1   @.w  #1,d7                 ; add 1 to height   E.w   #1,d7                 ; divide by 2 for FASTX2   .w  #1,d7                 ; subtract 1 for dbra    z     bit_add(pc),a0        ; get source pointers   z     dest_add(pc),a1       ; get dest pointers   ~.w  sbitdepth,d6          ; get bitplane depth 'X2bitloop   ~.l  (a0)+,a2              ; get source bitplane address   ~.l  (a1)+,a3              ; get dest bitplane address   ~.w  d7,d5                 ; copy height into temp 'X2yloop   ~.w  #9,d4                 ; do 10 longwords please 'X2xloop   ~.l  (a2)+,d0              ; get data   C.l  #%10101010101010101010101010101010,d0 ; MASK data   ~.l  d0,d1                 ; copy into d1   E.l   #1,d1                 ; roll 1 place to the right   .l    d1,d0                 ; OR with original data   ~.l  d0,(a3)+              ; store data   ~.l  d0,36(a3)             ; copy to line below as well   o    d4,'X2xloop            ; do whole line   z     40(a2),a2             ; adjust bitplane pointers   z     40(a3),a3             ;  to skip a whole line   o    d5,'X2yloop            ; loop for all lines   o    d6,'X2bitloop          ; loop for all bitplanes    .l (a7)+,d1-d7/a0-a6     ; restore BLITZ registers                              ; EXIT!    ' add_value:  %.l  1             ; step value for source bitplanes res_value:  %.w  1             ; store for unrez value res_value2: %.w  1             ; fast res_value for dbra use mytemp:     %.w  0  myline: %.w %0110110110110110,%1101101101101101,%1011011011011011         %.w %0110110110110110,%1101101101101101,%1011011011011011         %.w %0110110110110110,%1101101101101101,%1011011011011011         %.w %0110110110110110,%1101101101101101,%1011011011011011         %.w %0110110110110110,%1101101101101101,%1011011011011011         %.w %0110110110110110,%1101101101101101,%1011011011011011  myflag: %.b 0 '  ;.exit  ._AsmZoom   .w   d0   H     exithere   .w   d1   H     exithere    .l d1-d7/a0-a6,-(a7)     ; save BLITZ registers    ~.l  source_address,a0   ~.l  dest_address,a1   ~.l  add_source,d4   ~.l  add_dest,d5    ~.w  d0,xzoom_value        ; store zoom_value   .w  #1,xzoom_value   ~.w  d1,yzoom_value2       ; store yzoom   ~.w  d1,yzoom_value        ; store again BUT   .w  #1,yzoom_value        ;  subtract 1 this time   ~.w  d2,height             ; store height AND   .w  #1,height             ;  subtract 1 for dbra   ~.b  5(a0),sbitdepth+1     ; get source bitplane depth   .w  #1,sbitdepth          ;  subtract 1 for dbra   z     8(a0),a0              ; get source's bitplane pointers   z     8(a1),a1              ; get dest's bitplane pointers    ~.w  sbitdepth,d0          ; get bitdepth in d0   z     bit_add(pc),a2        ; source bitplane storage   z     dest_add(pc),a3       ; dest bitplane storage  'store_bitplanes   ~.l  (a0)+,(a2)            ; copy source bitplane address   =.l   d4,(a2)+              ;  AND add offset value   ~.l  (a1)+,(a3)            ; copy dest bitplane address   =.l   d5,(a3)+              ;  AND add offset value   o    d0,'store_bitplanes   ; loop for all bitplanes    .w   xzoom_value           ; Is xzoom_value=0?   P     'x_over_1             ; if so then check y    .w   yzoom_value           ; only screen copy if   H     ScreenCopy            ; xzoom & yzoom equal 1 'x_over_1   ~.w  height,yvalue         ; store height in yvalue for use                                 ;  in loop 'yloop:                         ; d6=bitplane loop   z     bit_add(pc),a0        ; d5=xloop   z     dest_add(pc),a6   ~.w  sbitdepth,d6 'bitplane_loop:   ~.w  yvalue,d7   ~.l  (a0),a1               ; a1=source   ~.l  a1,a2                 ; a2=source (corruptable)   ~.l  (a6),a3               ; a3=destination   ~.l  #9,d5                 ; x count for longwords wide   .l #31,d3                ; first bit to test on line   .l #31,d1 'xloop:   ~.w  xzoom_value,d4        ; get number of bits to set   ~.l  (a3),d2               ; get destination word   ~.l  (a2),d0   W    d1,d0                 ; test bit of word   H     'clearbits_loop       ; if not set - branch 'setbits_loop:                  ; SETS bits in dest line   V    d3,d2                 ; set the bit!   .b  #1,d3                 ; decrease bit pointer   O     'setbits_word         ; if negative the get new word   o    d4,'setbits_loop      ; loop for all bits   X     'next_bit             ; branch to main line loop 'setbits_word:                  ; GETS a new destination word   ~.l  d2,(a3)+              ; move current word into dest   ~.l  (a3),d2               ; get new word   .l #31,d3                ; reset bit pointer   .b  #1,d5                 ; subtract 1 from # of longwords   O     'done_line            ; exit if we've overflowed the line   o    d4,'setbits_loop      ; loop for all bits to set   X     'next_bit             ; branch to main line loop  'clearbits_loop:                ; CLEARS bits in dest line   U    d3,d2   .b  #1,d3   O     'clearbits_word   o    d4,'clearbits_loop   X     'next_bit 'clearbits_word:   ~.l  d2,(a3)+   ~.l  (a3),d2   .l #31,d3   .b  #1,d5   O     'done_line   o    d4,'clearbits_loop  'next_bit:   ~.l  d2,(a3)               ; store dest word   .b  #1,d1                 ; adjust source bit pointer   Q     'xloop                ; if positive then skip next   .l #31,d1                ; else reset pointer &   @.l  #4,a2                 ; increase address   X     'xloop                ; loop for whole line 'done_line                      ; COPIES line vertically   ~.w  yzoom_value,d4        ; get zoom_value   H     'yzoom1   .w  #1,d4                 ; subtract 2 (dbra & current line)   ~.l  (a6),a1               ; get dest bitplane address   z     40(a1),a2             ; add 40 to skip current line 'copy_line:   .w  #1,d7                 ; subtract 1 from height   O     'out_of_screen        ; Height negative? - OVERFLOW   ~.l  (a1)+,(a2)+           ; Copy 40 bytes   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   ~.l  (a1)+,(a2)+   o    d4,'copy_line         ; loop around for all lines   X     'out_of_screen  'yzoom1   ~.l  (a6),a2   =.l   #40,a2 'out_of_screen                  ; ALL Y SCREEN FILLED FOR 1 bitplane   =.l   #40,(a0)+             ; increment source bitplane pointer   ~.l  a2,(a6)+              ; store dest bitplane pointer   o    d6,'bitplane_loop     ; loop for all bitplanes    ~.w  yzoom_value2,d6       ; get zoom_value   .w   d6,yvalue             ; decrease yvalue   O     get_out_of_it2         ; yvalue NEGATIVE? - RTS   X     'yloop                ; loop for all lines get_out_of_it2:   .l (a7)+,d1-d7/a0-a6     ; restore BLITZ registers exithere:                              ; EXIT  ;General subroutine to copy one LOREZ bitmap to another ScreenCopy                      ; copy 1 bitmap to another   .l #0,d7                 ; clear d7   ~.w  height,d7             ; get height-1    z     bit_add(pc),a0        ; get source pointers   z     dest_add(pc),a1       ; get dest pointers   ~.w  sbitdepth,d6          ; get bitplane depth 'bitloop   ~.l  (a0)+,a2              ; get source bitplane address   ~.l  (a1)+,a3              ; get dest bitplane address   ~.w  d7,d5                 ; copy height into temp 'yloop   ~.l  (a2)+,(a3)+           ; copy data 1   ~.l  (a2)+,(a3)+           ; copy data 2   ~.l  (a2)+,(a3)+           ; copy data 3   ~.l  (a2)+,(a3)+           ; copy data 4   ~.l  (a2)+,(a3)+           ; copy data 5   ~.l  (a2)+,(a3)+           ; copy data 6   ~.l  (a2)+,(a3)+           ; copy data 7   ~.l  (a2)+,(a3)+           ; copy data 8   ~.l  (a2)+,(a3)+           ; copy data 9   ~.l  (a2)+,(a3)+           ; copy data A   o    d5,'yloop             ; loop for all lines   o    d6,'bitloop           ; loop for all bitplanes    .l (a7)+,d1-d7/a0-a6     ; save BLITZ registers                              ; EXIT!  yzoom_value: %.w  1 yzoom_value2:%.w  1 xzoom_value: %.w  1 ;================================================================= sbitdepth:      %.w  0            ; bitplane depth of source yvalue:         %.w  0            ; y counter for loops height:         %.w  0            ; height of bitmap-1 bit_add:        &.l  16            ; source bitplane pointers(16) dest_add:       &.l  16            ; dest bitplane pointers(16) source_address: %.l 0 dest_address:   %.l 0 add_source:     %.l 0 add_dest:       %.l 0 ;=================================================================  _InitZoomxy:   ~.l    a0,source_address   ~.l    a1,dest_address   ~.l    d2,add_source   ~.l    d3,add_dest     _ADDValue:   ~.w    (a0),d0   .w    d2,d0   C.l    #$ffff,d1   E.w     #3,d1   =.l     d1,d0     version: %.b "$VER: FX-Library v1.0 (17.7.1994)",0  