

! Aspect ratio of PHYSICS pictures should be 4:3 NOT 1:1 (x:y)
! The correct aspect ratioing is achieved by taking 4 points numbered
! (0,1,2,3) & interpolating them to points (0,1+1/3,2+2/3)
! o(A0) contains start addr of output line
! t(A1) contains start addr of current picture line
%routine alter aspect(%bytename o,t)

  *move.w #255,d0;!      Loop for all lines in origrinal picture
a:*move.w #63,d1;!       Loop for the 64 sets of 4 pts vertically
  *move.l a0,a2;!        Preserve addresses
  *move.l a1,a3
b:*move.b (a3),(a2);!    Copy current pt 0 to new pt 0
  *clr.l d2;!            Clear working registers
  *clr.l d3
  *clr.l d4
  *move.b 512(a3),d2;!   Get pt 1 one line up from pt 0(ie 512 bytes)
  *move.b 1024(a3),d3;!  Get pt 2 two lines up from pt 0
  *move.b 1536(a3),d4;!  Get pt 3 three lines up from pt 0
  *lsl.w  #1,d2;!        Multiply pt 1 by two (weighting factor in interpolation)
  *lsl.w  #1,d4;!        Multiply pt 3              ""           ""
  *add.w  d3,d2;!        Add in pt 2 to new pt 1
  *add.w  d3,d4;!        Add in pt 2 to new pt 3
  *divu   #3,d2;!        Divide by 3 to obtain pt 1+1/3
  *divu   #3,d4;!        Divide by 3 to obtain pt 2+2/3
  *move.b d2,512(a2);!   Store 1+1/3 one line up from current output point
  *move.b d4,1024(a2);!  Store 2+2/3 two lines up from current output point
  *adda.l #1536,a2;!     Move output pointer up three lines
  *adda.l #2048,a3;!     Move input pointer up four lines
  *dbra d1,b;!           Loop to do next group of 4 pts
  *adda.l #1,a0;!        Move output 1 place horizontally
  *adda.l #1,a1;!        Move input  1 place horizontally
  *dbra d0,a;!           Loop to do next vertical line

%end


! Take a 256*256 Image & Blow it up to 512*512
! Input line has start addr i(A0)
! Ouput line has start addr o(A1)
%routine blow up pic(%bytename i,o)

  *move.w #255,d0;!     Loop round for every line in image
a:*move.w #255,d1;!     Loop round for every pixel in line
b:*move.b (a0)+,d2;!    Get pixel byte from input line, move onto next
  *move.b d2,(a1);!     Store byte in output position
  *move.b d2,-512(a1);! & surrounding 3 neighbours
  *move.b d2,1(a1)
  *move.b d2,-511(a1)
  *addq #2,a1;!         Move onto next output position
  *dbra d1,b;!          Loop for next pixel from input
  *suba.l #768,a0;!     Move down to start of next input line
  *suba.l #1536,a1;!    Move down to start of next output line
  *dbra d0,a;!          Do next line

%end
