home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / DEMOS / MEGADEMO / PASSIONP.ARJ / PASSIONP.MSA / JELLY / GENERATE.S < prev    next >
Text File  |  1997-03-05  |  9KB  |  222 lines

  1. ; *************************************************************************
  2. ; *****       Routine which generates the code for the zoomer.        *****
  3. ; *************************************************************************
  4. ; The zoomrouts are generated taking in account that the size of the source
  5. ; image is 96. The zoomrouts for a size between 0-46 are not generated, the
  6. ; routine only puts a rts for this size. The zoomrouts for a size between
  7. ; 48-96 are generated and are ending with a rts too. The adresses of the
  8. ; 48 routines (48 because the zoomed size must be even) are saved in the
  9. ; table pointed by a1.The size of all the routines is 34884 bytes.
  10. ; *************************************************************************
  11. ;     A zoom routine is composed like this: There is a big part of it which
  12. ; consists into linear to planar conversion, and as the size is defined,
  13. ; the pixels not to show are passed with an "addq.l #$1,a0". (Considering
  14. ; a0 contains the adress of the linear image.) During the generation of a
  15. ; zoom of a given size I have to calculate when a pixel must be passed.
  16. ; This is made with a kind of real number... I had a certain coef to the
  17. ; error, and if there isn't an overflow I must pass the next pixel. So if
  18. ; the carry is set, we draw a point, if not we pass one point and draw
  19. ; one. (By the way, original_size/zoomed_size is always =<2, that's why
  20. ; only this 2 case are possible.) The zoom coefficient is then calculated
  21. ; like this: N=nb of points to pass, then we must do N carry clear and
  22. ;            96-2*N carry set, so coef=(96-2*N)*65536/(96-N).
  23. ;    An other thing to understand, is that if the zoomed_size is not a
  24. ; multiple of 16 (96 or 64) then the two extreme words are not full! So
  25. ; we must have the 4 planes on the left 16 pixels set to 0 before we begin
  26. ; to work on them, and on the right 16 pixels we must rotate the planes
  27. ; left so that the first pixie is just after the last word.
  28. ; *************************************************************************
  29. ; The parameters of the generated routs are:
  30. ;    a0.l = adress of linear sourceline.
  31. ;    a1.l = adress of the planar dest.line.
  32. ;    a2.l = adress where to jump after the zoom.
  33. ;           ( Jsr & Rts are too slow. )
  34. ; The sourceline must be so that the 4 most significant bits of each bytes
  35. ; are the value of the pixel.
  36. ; The registers d0-d4 are used by the routines.
  37. ; *************************************************************************
  38. ; Parameters:    a0.l = adress where to generate the code.
  39. ;    a1.l = adress where to save the adresses of the zoomrouts.
  40.  
  41.   Section TEXT
  42.  
  43.   movem.l    d0-a6,-(sp)
  44.  rept    24    ; The size between 0-46 are not taken in
  45.   move.l    a0,(a1)+    ; account, so just generate "jmp (a2)".
  46.   move.w    #$4ed2,(a0)+
  47.  endr
  48.  
  49.   move.l    #.zoom_coefs,a2    ; They are a bit hard to calculate, so...
  50.   move.w    #24,a3    ; The first routine for a size of 2*24=48.
  51. .generate_one_zoom:
  52.   move.l    a0,(a1)+    ; Save the adress of the routine.
  53.   cmp.w    #32,a3    ; Is the size bigger than 64?
  54.   bgt.s    .bigger_64
  55. .lower_64:        ; If size=<64 then image begins on the 5th
  56.   move.w    #$5089,(a0)+    ; word, so generate the "addq.l #$8,a1".
  57. .bigger_64:        ; If size>64, it begins on 1st word.
  58.   move.w    (a2)+,d0    ; d0=zoom_coef for this size.
  59.   moveq.l    #96,d1    ; d1=error.
  60.   move.w    a3,d2    ; d2=size/2 mod(16)=nb of pixels on the
  61.   and.w    #$f,d2    ; "extremes" sets of 16 pixels.
  62.   move.w    a3,d4    ; d4=size/32=nb of "full" words/2.
  63.   lsr.w    #$4,d4
  64.   add.w    d4,d4    ; d4=nb of "full" words.
  65.   cmp.w    #$0,d2    ; If size/2 mod(16)=0, then there are no
  66.   beq.s    .full_sets    ; "incomplete" words.
  67.  
  68. .left_case:        ; First incomplete extremity.
  69.   move.w    #$7200,(a0)+    ; Generates "moveq.l #$0,d1".
  70.   move.w    #$7400,(a0)+    ; And the same for d2-d4.
  71.   move.w    #$7600,(a0)+
  72.   move.w    #$7800,(a0)+
  73.   move.w    d2,d3    ; Nb of points on the extremities.
  74.   subq.w    #$1,d3    ; Beware the dbra.
  75. .left_one_point:
  76.   add.w    d0,d1    ; error=error+zoom_coef.
  77.   bcs.s    .left_overflow
  78. .left_no_overflow:    ; If no overflow, the pass one source
  79.   move.w    #$5288,(a0)+    ; point by generating an "addq.l #$1,a0".
  80. .left_overflow:
  81.   move.w    #$1018,(a0)+    ; Generate a "move.b (a0)+,d0".
  82.   move.w    #$d000,(a0)+    ; Generate the linear-planar conversion
  83.   move.w    #$d944,(a0)+    ; by generating "add.b d0,d0"
  84.   move.w    #$d000,(a0)+    ; then "addx.w d4,d4" and then the same
  85.   move.w    #$d743,(a0)+    ; with d3-d1.
  86.   move.w    #$d000,(a0)+
  87.   move.w    #$d542,(a0)+
  88.   move.w    #$d000,(a0)+
  89.   move.w    #$d341,(a0)+
  90.   dbra    d3,.left_one_point
  91.   move.l    #$4891001e,(a0)+ ; "movem.w d1-d4,(a1)".
  92.   move.w    #$5089,(a0)+    ; "addq.l #$8,a1".
  93.  
  94. .full_sets:        ; Generate code for the "full" sets.
  95.   subq.w    #$1,d4    ; Beware the dbra.
  96. .one_full_set:
  97.   moveq.l    #$f,d3    ; 16 points for a full set.
  98. .full_one_point:
  99.   add.w    d0,d1    ; error=error+zoom_coef.
  100.   bcs.s    .full_overflow
  101. .full_no_overflow:    ; If no overflow, the pass one source
  102.   move.w    #$5288,(a0)+    ; point by generating an "addq.l #$1,a0".
  103. .full_overflow:
  104.   move.w    #$1018,(a0)+    ; Generate a "move.b (a0)+,d0".
  105.   move.w    #$d000,(a0)+    ; Generate the linear-planar conversion
  106.   move.w    #$d944,(a0)+    ; by generating "add.b d0,d0"
  107.   move.w    #$d000,(a0)+    ; then "addx.w d4,d4" and then the same
  108.   move.w    #$d743,(a0)+    ; with d3-d1.
  109.   move.w    #$d000,(a0)+
  110.   move.w    #$d542,(a0)+
  111.   move.w    #$d000,(a0)+
  112.   move.w    #$d341,(a0)+
  113.   dbra    d3,.full_one_point
  114.   move.l    #$4891001e,(a0)+ ; "movem.w d1-d4,(a1)".
  115.   move.w    #$5089,(a0)+    ; "addq.l #$8,a1".
  116.   dbra    d4,.one_full_set
  117.  
  118.   cmp.w    #$0,d2    ; Check if there is an incomplete set
  119.   beq    .end_one_zoom    ; after the full sets.
  120. .right_case:        ; Second incomplete extremity.
  121.   move.w    d2,d3    ; d3=nb of points to generate.
  122.   subq.w    #$1,d3    ; Beware the dbra.
  123. .right_one_point:
  124.   add.w    d0,d1    ; error=error+zoom_coef.
  125.   bcs.s    .right_overflow
  126. .right_no_overflow:    ; If no overflow, the pass one source
  127.   move.w    #$5288,(a0)+    ; point by generating an "addq.l #$1,a0".
  128. .right_overflow:
  129.   move.w    #$1018,(a0)+    ; Generate a "move.b (a0)+,d0".
  130.   move.w    #$d000,(a0)+    ; Generate the linear-planar conversion
  131.   move.w    #$d944,(a0)+    ; by generating "add.b d0,d0"
  132.   move.w    #$d000,(a0)+    ; then "addx.w d4,d4" and then the same
  133.   move.w    #$d743,(a0)+    ; with d3-d1.
  134.   move.w    #$d000,(a0)+
  135.   move.w    #$d542,(a0)+
  136.   move.w    #$d000,(a0)+
  137.   move.w    #$d341,(a0)+
  138.   dbra    d3,.right_one_point
  139.  
  140. ; The right extremity must be rotated left so that the 16-(size/2 mod(16))
  141. ; points on the left of this set are 0.
  142. .right_rotation:
  143.   cmp.w    #$f,d2    ; Only one rotation?
  144.   bne.s    .right_more_1
  145.   move.w    #$d041,(a0)+    ; Then the quickest method to rotate
  146.   move.w    #$d042,(a0)+    ; the bitplanes is to generate an
  147.   move.w    #$d043,(a0)+    ; "add.w dx,dx" on all bitplanes.
  148.   move.w    #$d044,(a0)+
  149.   bra    .right_end
  150. .right_more_1:
  151.   cmp.w    #$8,d2    ; More than 8 rotations?
  152.   blt.s    .right_more_8
  153. .right_less_8:        ; We must create the opcode for a
  154.   move.w    #$10,d3    ; "lsl.w #16-d2,dx" instruction.
  155.   sub.w    d2,d3    ; d3=16-d2=nb of rotations.
  156.   and.w    #%111,d3    ; In the opcode a rotation of 8=0.
  157.   lsl.w    #$8,d3    ; Put nb_rot at its place in opcode.
  158.   add.w    d3,d3
  159.   move.w    #$e149,d2    ; Opcode for a "lsl.w #0,d1".
  160.   or.w    d3,d2    ; Put the good nb of rot in opcode.
  161.   move.w    d2,(a0)+
  162.   move.w    #$e14a,d2    ; Do the same with d2-d4.
  163.   or.w    d3,d2
  164.   move.w    d2,(a0)+
  165.   move.w    #$e14b,d2
  166.   or.w    d3,d2
  167.   move.w    d2,(a0)+
  168.   move.w    #$e14c,d2
  169.   or.w    d3,d2
  170.   move.w    d2,(a0)+
  171.   bra.s    .right_end
  172. .right_more_8:        ; We must rotate by 8 and re-rotate.
  173.   move.w    #$e149,(a0)+    ; "lsl.w #$8,d1".
  174.   move.w    #$e14a,(a0)+    ; The same with d2-d4.
  175.   move.w    #$e14b,(a0)+
  176.   move.w    #$e14c,(a0)+    
  177.   cmp.w    #$7,d2    ; 9 rotations?
  178.   bne.s    .right_not_9
  179.   move.w    #$d041,(a0)+    ; Then the quickest method to rotate
  180.   move.w    #$d042,(a0)+    ; the bitplanes is to generate an
  181.   move.w    #$d043,(a0)+    ; "add.w dx,dx" on all bitplanes.
  182.   move.w    #$d044,(a0)+
  183.   bra.s    .right_end
  184. .right_not_9:        ; We must create the opcode for a
  185.   move.w    #$8,d3    ; "lsl.w #8-d2,dx" instruction.
  186.   sub.w    d2,d3    ; d3=16-d2=nb of rotations.
  187.   and.w    #%111,d3    ; In the opcode a rotation of 8=0.
  188.   lsl.w    #$8,d3    ; Put nb_rot at its place in opcode.
  189.   add.w    d3,d3
  190.   move.w    #$e149,d2    ; Opcode for a "lsl.w #0,d1".
  191.   or.w    d3,d2    ; Put the good nb of rot in opcode.
  192.   move.w    d2,(a0)+
  193.   move.w    #$e14a,d2    ; Do the same with d2-d4.
  194.   or.w    d3,d2
  195.   move.w    d2,(a0)+
  196.   move.w    #$e14b,d2
  197.   or.w    d3,d2
  198.   move.w    d2,(a0)+
  199.   move.w    #$e14c,d2
  200.   or.w    d3,d2
  201.   move.w    d2,(a0)+
  202.  
  203. .right_end:
  204.   move.l    #$4891001e,(a0)+ ; "movem.w d1-d4,(a1)".
  205.   move.w    #$5089,(a0)+    ; "addq.l #$8,a1".
  206.  
  207. .end_one_zoom:        ; The end of the zoom.
  208.   subq.l    #$2,a0    ; The last "addq.l #$8,a1" is unusefull.
  209.   move.w    #$4ed2,(a0)+    ; "jmp (a2)"=end of this rout.
  210.   addq.w    #$1,a3    ; Next size.
  211.   cmp.w    #48,a3    ; It was the last size?
  212.   ble    .generate_one_zoom
  213.   movem.l    (sp)+,d0-a6
  214.   rts
  215.  
  216. .zoom_coefs:
  217.   dc.w    00000,05243,10083,14564,18725
  218.   dc.w    22599,26215,29597,32768,35757
  219.   dc.w    38551,41195,43691,46053,48290
  220.   dc.w    50413,52429,54347,56174,57916
  221.   dc.w    59579,61167,62687,64142,65535
  222.