Advertisement
glokyfull

masked sprite less bugged but still don't work

Nov 20th, 2023
1,134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. tout est buggé j'en peut plus
  4.  
  5.  
  6. subpixel equ 4
  7. subpixel2 equ 8
  8. nbbob   equ 10
  9.  
  10. start:
  11.  
  12.     clr.l -(sp)
  13.     move.w #$20,-(sp)
  14.     trap #1
  15.     addq.l #6,sp
  16.  
  17.     lea spritedeca,a0
  18.     move.w #16*2*16-1,d0
  19. .toto   clr.w (a0)+
  20.     dbf d0,.toto
  21.  
  22. ;   move.l $44e.w,d0  
  23. ;    clr.w -(sp)
  24. ;    move.l d0,-(sp)
  25. ;    move.l d0,-(sp)
  26. ;    move.w #5,-(sp)
  27. ;    trap #14
  28. ;    lea 12(sp),sp
  29. ;
  30.  
  31.     jsr extractsprite
  32.  
  33.    jsr prepare_segments
  34.  
  35. ; creation convx et convy
  36. ;   move.l #$8000,d0    ;     offset,motif or
  37. ;   lea convx,a0
  38. ;.loopconvx
  39. ;   rept subpixel
  40. ;     move.l d0,(a0)+
  41. ;   endr
  42. ;   lsr.w #1,d0
  43. ;   bne.s .loopconvx
  44. ;   add.l #$00088000,d0
  45. ;   cmp.l #$00a08000,d0
  46. ;   bne.s .loopconvx
  47. ;
  48. ;   move.w #0,d0
  49. ;   move.w #199,d1
  50. ;   lea convy,a0
  51. ;.loopconvy
  52. ;   rept subpixel
  53. ;   move.w d0,(a0)+
  54. ;   endr
  55. ;   add #160,d0
  56. ;   dbf d1,.loopconvy
  57. ;
  58.  
  59.     move.l ptrConvX,a0
  60.     ;lea codegenliste,a1
  61.     move.w #19,d0
  62.     moveq #0,d2
  63. .loop3
  64.     lea codegenliste,a1
  65.     lea codeeffliste,a3
  66.     moveq #15,d3
  67. .loop2
  68.     move.l (a3)+,d5
  69.     move.l (a1)+,d1
  70.     rept subpixel2
  71.     move.w d2,(a0)+     ; offset
  72.     move.l d5,(a0)+     ; code effacement
  73.     move.l d1,(a0)+     ; code affichage
  74.  
  75.     endr
  76.  
  77.     dbf d3,.loop2
  78.     addq.w #8,d2
  79.     dbf d0,.loop3
  80.  
  81.     move.l ptrConvY,a0
  82.     moveq #0,d2
  83.     move.w #160,d1
  84.     move.w #199,d0      ; pas de cliping pour l'instant
  85. .loop4
  86.     rept subpixel2
  87.     move.w d2,(a0)+
  88.     endr
  89.     add d1,d2
  90.     dbf d0,.loop4
  91.  
  92.     jsr convsinus
  93.    
  94. main
  95.     jsr swap_screen
  96.  
  97.     jsr majAngle
  98.     jsr calcAllPos
  99.  
  100.  
  101.     jsr waitvbl
  102.     ;jsr swap_screen
  103.     move.l log,d0
  104.    
  105.    
  106.     cmp.b #$b9,$fffffc02.w
  107.     beq.s .fin
  108.     jmp main
  109. .fin
  110.  
  111.     move.l $44e.w,d0
  112.     lsr.w #8,d0
  113.     move.l d0,$ffff8200.w
  114.     bsr waitvbl
  115.     move.l $44e.w,d0  
  116.  
  117.     move.w #1,-(sp)
  118.  
  119.     move.l d0,-(sp)
  120.  
  121.     move.l d0,-(sp)
  122.  
  123.     move.w #5,-(sp)
  124.  
  125.     trap #14
  126.  
  127.     lea 12(sp),sp
  128.  
  129.    
  130.  
  131.     clr.w -(sp)
  132.     trap #1
  133.  
  134. cptdeca dc.w 0
  135. angles  dc.w 128,128,50,70
  136. ajoutangle  dc.w 14,7,512-11,6
  137.  
  138.  
  139. majangle
  140.     lea ajoutangle,a0
  141.     lea angles,a1
  142.     moveq #3,d7
  143. .loop
  144.     move.w (a0)+,d0
  145.     move.w (a1),d1
  146.     add d0,d1
  147.     and.w #511,d1
  148.     move.w d1,(a1)+
  149.     dbf d7,.loop
  150.  
  151.     rts
  152.  
  153. convsinus
  154.     move.l sinx1,a1
  155.     move.l sinx2,a2
  156.     lea sin512,a0
  157.     move.w #511,d0
  158.     move.w ptrconvX+2,d4
  159. .loop
  160.     moveq #0,d1
  161.     move.w (a0)+,d1
  162.     add.w #32767,d1
  163.  
  164.     move.l d1,d2
  165.     mulu #(40*2-8)*subpixel2,d1
  166.     mulu #(60*2-8)*subpixel2,d2   ; 8 subpixel
  167.     ;asl #1,d1
  168.     ;asl #1,d2
  169.     swap d1
  170.     swap d2
  171. ; *10 = *8+*2 = *2(*4+1)
  172.  
  173.     add d1,d1
  174.     move.w d1,d3
  175.     add.w d3,d3 *4
  176.     add.w d3,d3
  177.     add d3,d1   ; d1 = d1 * 10
  178. ;   and.w #-4,d1
  179.  
  180. ;   and.w #-4,d2
  181.  
  182.     add d2,d2
  183.     move.w d2,d3
  184.     add d3,d3
  185.     add d3,d3
  186.     add d3,d2
  187.  
  188.     add d4,d1               ; premiere table de sinus, on ajoute l'offset de convX
  189.     move.w d1,(a1)+
  190.     move.w d2,(a2)+
  191.     dbf d0,.loop
  192.    
  193.  
  194.     move.w ptrConvY+2,d4
  195.     move.l siny1,a1
  196.     move.l siny2,a2
  197.     lea sin512,a0
  198.     move.w #511,d0
  199. .loopy
  200.     moveq #0,d1
  201.     move.w (a0)+,d1
  202.     add.w #32767,d1
  203.     move.l d1,d2
  204.     mulu #(40*2-8)*subpixel2*2,d1
  205.     mulu #(60*2-8)*subpixel2*2,d2
  206. ;   asl #1,d1
  207. ;   asl #1,d2
  208.     swap d1
  209.     swap d2
  210.     and.w #-2,d1
  211.     and.w #-2,d2
  212.     add d4,d1           ; ajoute l'offset segment
  213.     move.w d1,(a1)+
  214.     move.w d2,(a2)+
  215.     dbf d0,.loopy
  216.  
  217.  
  218. ; createContigustable
  219. ;
  220. ; a0 = ram
  221. ; d0 = nombre d'element de la table sinus
  222. ; d1 = pas interne
  223. ; d2 = nombre de copie de valeurs
  224. ; a3 = table de sinus d'amplitude final
  225. ;
  226. ; pendant le fonctionnement:
  227. ; constante  d3,d4,d5 = pas interne,*2,*4
  228. ;
  229. ;
  230. ;
  231.  
  232. ; retour:
  233. ; a0 = ram
  234. ; a1 = adresse table de d0 adresses  reftable pris a partir de la ram
  235. ;  
  236.  
  237.     lea ram3,a0
  238.     move.w #512,d0
  239.     move.w #nbbob,d2 ; nombre de copie de valeur
  240.     move.w #5,d1        ; pas interne 5 /512
  241.     move.l sinx1,a3
  242.     jsr createContigustable
  243.     move.l a1,ptrref1
  244.  
  245.     move.w #512,d0
  246.     move.w #10,d1
  247.     move.w #nbbob,d2
  248.     move.l sinx2,a3
  249.     jsr createContigustable
  250.     move.l a1,ptrref2
  251.  
  252.     move.w #512,d0
  253.     move.w #6,d1
  254.     move.w #nbbob,d2
  255.     move.l siny1,a3
  256.     jsr createContigustable
  257.     move.l a1,ptrref3
  258.  
  259.     move.w #512,d0
  260.     move.w #512-4,d1
  261.     move.w #nbbob,d2
  262.     move.l siny2,a3
  263.     jsr createContigustable
  264.     move.l a1,ptrref4
  265.     rts
  266.  
  267.  
  268. ang1    dc.w 128
  269. ang2    dc.w 128
  270. ang3    dc.w 0
  271. ang4    dc.w 0
  272. ajoutang1   dc.w 4
  273. ajoutang2   dc.w 11
  274. ajoutang3   dc.w 512-8
  275. ajoutang4  dc.w 6
  276. calcAllpos
  277.     move.l ptrref1,a5
  278.     move.l ptrref2,a1
  279.     move.w ang1,d0
  280.     add d0,d0
  281.     add d0,d0
  282.     add.w d0,a5
  283.     move.w ang2,d0
  284.     add d0,d0
  285.     add.w d0,d0
  286.     add.w d0,a1
  287.  
  288.     move.l ptrref3,a2
  289.     move.l ptrref4,a3
  290.     move.w ang3,d0
  291.     add d0,d0
  292.     add d0,d0
  293.     add d0,a2
  294.     move.w ang4,d0
  295.     add d0,d0
  296.     add d0,d0
  297.     add d0,a3
  298.  
  299.     move.l (a5),a5
  300.     move.l (a1),a1
  301.     move.l (a2),a2
  302.     move.l (a3),a3
  303.     lea efface1lst,a4
  304.  
  305.     move.l ptrConvX,d0
  306.     move.l ptrConvY,d1
  307.     move.l ptrscr1,d3
  308.  
  309.     move.w #nbbob,d2
  310. .loopcalcul
  311.  
  312.     move.w (a5)+,d0
  313.     add.w (a1)+,d0
  314.     move.w (a2)+,d1
  315.     add (a3)+,d1
  316.  
  317.     move.l d1,a6
  318.     move.w (a6),d3          ;  y*160
  319.  
  320.     move.l d0,a6
  321.     add.w (a6)+,d3
  322.     move.w d3,(a4)+         ; effacement offset
  323.     move.l (a6)+,(a4)+      ; routine d'effacement
  324.  
  325.     move.l (a6),a6          ; routine d'affichage
  326.     move.l d3,a0
  327.  
  328.     jsr (a6)
  329.     dbf d7,.loopcalcul
  330.  
  331.     lea ang1,a0
  332.     lea 8(a0),a1
  333.     movem.w (a1),d0-d3
  334.  
  335.     move.w (a0),d4
  336.     add.w d0,d4
  337.     move.w #511,d5
  338.     and d5,d4
  339.     move.w d4,(a0)+
  340.  
  341.     move.w (a0),d4
  342.     add.w d1,d4
  343.     and d5,d4
  344.     move.w d4,(a0)+
  345.  
  346.     move.w (a0),d4
  347.     add.w d2,d4
  348.     and d5,d4
  349.     move.w d4,(a0)+
  350.  
  351.     move.w (a0),d4
  352.     add.w d3,d4
  353.     and d5,d4
  354.     move.w d4,(a0)+
  355. ; maj angle fait
  356.  
  357.     rts
  358.  
  359. prepare_segments
  360.    
  361.     move.l #screenbuf,d0
  362.     moveq #4,d1
  363.     swap d1
  364.     jsr getMem1                 ; prepare 16 zone memoire allant de 32768 a 1 octet (puissance de 2)
  365.  
  366.     lea ptrMem,a0
  367.     movem.l (a0)+,d0-d3         ; 1 buffer de 32k un de 16k un de 8k un de 4k  pas aligné mais contigu au meme segment  
  368.  
  369.     move.l d3,sinX1         ; sinx1 x2 y1 y2 devenu des pointeur sur
  370.                             ; 512 word
  371.     move.l #1024,d5
  372.     add.l d5,d3
  373.     move.l d3,sinX2
  374.     add.l d5,d3
  375.     move.l d3,sinY1
  376.     add.l d5,d3
  377.     move.l d3,sinY2                 ; place pour 4k = 4 table de 512 word
  378.  
  379.  
  380.                                 ; cad poid fort de l'adresse du buffer est toujours a la meme valeur
  381.     move.l d0,ptrConvY          ; 32k alloué pour convy: 1856*2 en comptant cliping haut bas de 16 pixel de hauteur et 4 subpixel
  382.     add.l #2*1856,d0
  383.     ; 30912 octet libre
  384.     move.l d0,ptrConvX  ; 12800 octet pour 320 pixel 4 subpixel 10 octet (adresseEFF,adresseAFF,offset)
  385.     add.l #12800+32*10*4,d0     ; pile poil 4 subpixel  convy 232*8 subpixel*2 + 352*8 subpixel*10 octet
  386.     moveq #0,d4                 ; 31872 octet sur 32768
  387.     move.w #1024,d4
  388.     lea sinx1,a1
  389.     move.l d0,(a1)+
  390.     add.l d4,d0
  391.     move.l d0,(a1)+
  392.     add.l d4,d0
  393.     move.l d0,(a1)+
  394.     add.l d4,d0
  395.     move.l d0,(a1)+
  396.    
  397.     move.l d1,ptr16k
  398.     move.l d2,ptrFlag           ; 8k max pour les flag, sinus dont le nombre d'element ne depasse pas 8192
  399.     move.l d3,ptr4k
  400.  
  401.     move.l #screenbuf,d0
  402.     moveq #1,d1
  403.     swap d1
  404.     add.l d1,d0
  405.     clr.w d0
  406.     move.l d0,log
  407.     move.l d0,ptrscr1
  408.     add.l d1,d0
  409.     move.l d0,phys
  410.     move.l d0,ptrscr2
  411.     add.l d1,d0
  412.     move.l d0,ptrscr3
  413.     add.l d1,d0
  414.     move.l d0,ptrscr4
  415.  
  416. ;   add.l d1,d0
  417. ;   move.l d0,convX
  418. ;   add.l #320*subpixel*8,d0
  419. ;   add.l d1,d0
  420. ;   move.l d0,convY
  421.  
  422.     rts
  423. waitvbl
  424.     move.w $468.w,d0
  425. .loop   cmp.w $468.w,d0
  426.     beq.s .loop
  427.     rts
  428.  
  429. swap_screen
  430.     move.l log,d0
  431.     move.l phys,d1
  432.     move.l d0,phys
  433.     move.l d1,log
  434.     lsr.w #8,d0
  435.     move.l d0,$ffff8200.w
  436.     rts
  437.  
  438. extractsprite
  439.     lea pi1+2,a0
  440.     movem.w (a0),d0-d3
  441.     movem.w d0-d3,$ffff8240.w
  442.     lea pi1+34,a0
  443.    
  444.     lea spritedeca,a1
  445.     moveq #0,d1
  446.     moveq #15,d7
  447. .loop0
  448.     move.l (a0),d0
  449.     lea 160(a0),a0
  450.     move.l d0,(a1)+
  451.     move.l d1,(a1)+
  452.     dbf d7,.loop0
  453.  
  454.     moveq #14,d7
  455.     lea spritedeca,a1
  456.     move.l a1,a3
  457.     lea 128(a1),a2
  458.     move.l a2,a4
  459. .copyandshift
  460.     move.w #15,d6
  461. .ligne
  462. ;   rept 2
  463. ;   move.w (a1)+,d0
  464. ;   move.w 2(a1),d1
  465. ;   move.w #0,ccr       ; set x to 0
  466. ;   roxr #1,d0
  467. ;   roxr #1,d1
  468. ;   move.w d0,(a2)+
  469. ;   move.w d1,2(a2)
  470. ;   ;lea 2(a1),a1
  471. ;   ;lea 2(a2),a2
  472. ;   endr
  473.  
  474.     MOVE.L (A1)+,(A2)+
  475.     MOVE.L (A1)+,(A2)+
  476.     LEA -8(A2),A2
  477.     MOVE.B #0,CCR
  478.     ROXR (A2)
  479.     ROXR 4(A2)
  480.     MOVE.B #0,CCR
  481.     ROXR 2(A2)
  482.     ROXR 6(a2)
  483.  
  484.     lea 8(a2),a2
  485.     dbf d6,.ligne
  486.     lea 128(a3),a3
  487.     lea 128(a4),a4
  488.     move.l a3,a1
  489.     move.l a4,a2
  490.  
  491. ;   lea 4(a2),a2
  492. ;   lea 4(a1),a1
  493.     dbf d7,.copyandshift
  494.    
  495. makecodegen
  496.     lea spritedeca,a0
  497.     lea ram,a1
  498.     lea codegenliste,a2
  499.     lea codeeffliste,a3
  500.     lea ram2,a4
  501.     moveq #15,d0
  502. .loopSprite
  503.     move.l a4,(a3)+
  504.     move.l a1,(a2)+
  505.     moveq #15,d1
  506.     moveq #0,d6     ; offset
  507. .loopligne
  508.     move.w (a0)+,d2
  509.     move.w (a0)+,d3
  510.     move.w (a0)+,d4
  511.     move.w (a0)+,d5
  512.     tst.w d2
  513.     bne.s .1
  514.     tst.w d3
  515.     beq.s .nerienfaire
  516.     ; or.w #d3,offset+2(a0)
  517.     move.w d3,d7
  518.     addq #2,d6
  519.     bsr orwd7d6_2
  520.     subq #2,d6
  521.    
  522.  
  523.  
  524.     bra.s .suite
  525. .1  ; d2 contient kekchose
  526.     tst.w d3
  527.     beq.s .wordd2
  528.     ; or.l #d2d3,offset(a0)
  529.     move.w d2,d7
  530.     swap d7
  531.     move.w d3,d7
  532.     bsr orld7d6
  533.     bra.s .suite
  534. .wordd2
  535.     ; or.w #d2,offset(a0)
  536.     move.w d2,d7
  537.     bsr orwd7d6
  538.     bra.s .suite
  539. .nerienfaire
  540.     nop
  541. .suite
  542.     tst.w d4
  543.     bne.s .2
  544.     tst.w d5
  545.     beq.s .nerienfaire2
  546.     ; or.w #d5,offset+8+2(a0)
  547.     move.w d5,d7
  548.     add.w #10,d6
  549.     bsr orwd7d6_2
  550.     sub.w #10,d6
  551.  
  552.  
  553.     bra.s .suite2  
  554. .2  tst.w d5
  555.     beq.s .wordd4
  556.     ; or.l #d4d5,offset+8(a0)
  557.     move.w d4,d7
  558.     swap d7
  559.     move.w d5,d7
  560.     addq.w #8,d6
  561.     bsr orld7d6
  562.     subq #8,d6
  563.  
  564.     bra.s .suite2
  565. .wordd4
  566.     ; or.w #d4,offset+8(a0)
  567.     move.w d4,d7
  568.     addq #8,d6
  569.     bsr orwd7d6
  570.     subq #8,d6
  571.     bra.s .suite2
  572. .nerienfaire2
  573.     nop
  574. .suite2
  575.     add #160,d6
  576.     dbf d1,.loopligne
  577.     move.w #$4e75,(a1)+
  578.     move.w #$4e75,(a4)+
  579.     dbf d0,.loopSprite
  580.     rts
  581. orwd7d6
  582. ;   move.l d2,-(sp)
  583.     move.w d7,d2   ; plus besoin de d2
  584.     swap d2
  585.     move.w d7,d2
  586.     not.l d2
  587.  
  588.     ; and.l d2,d6(a0)   02a8
  589.  
  590.     move.w #$02a8,(a1)+     ; + 8 octet au code genere
  591.     move.l d2,(a1)+
  592.     move.w d6,(a1)+
  593.  
  594.  
  595.     move.w #$68,(a1)+
  596.     move.w d7,(a1)+
  597.     move.w d6,(a1)+
  598.  
  599.     move.w #$2140,(a4)+     ; since it's masked on 2 plan, the clearing is long instead of word
  600.  
  601.     move.w d6,(A4)+         ; ($2140 instead of $3140) (move.l d0,d6(a0) instead of move.w d0,d6(a0))
  602.  
  603. ;   move.l (sp)+,d2
  604.     rts
  605. orwd7d6_2                   ; cas ou orwd7d6 mais sur le deuxieme plan, l'effacement se fait naturellement sur le premier plan
  606. ;   move.l d2,-(sp)
  607.     move.w d7,d2   ; plus besoin de d2
  608.     swap d2
  609.     move.w d7,d2
  610.     not.l d2
  611.  
  612.     ; and.l d2,d6(a0)   02a8
  613.  
  614.     move.w #$02a8,(a1)+     ; + 8 octet au code genere
  615.     move.l d2,(a1)+
  616.     move.w d6,(a1)
  617.     subq.w #2,(a1)+
  618.  
  619.  
  620.  
  621.     move.w #$68,(a1)+
  622.     move.w d7,(a1)+
  623.     move.w d6,(a1)+
  624.  
  625.     move.w #$2140,(a4)+     ; since it's masked on 2 plan, the clearing is long instead of word
  626.  
  627.     move.w d6,(A4)          ; ($2140 instead of $3140) (move.l d0,d6(a0) instead of move.w d0,d6(a0))
  628.     subq.w #2,(a4)+         ; on and.l sur le plan 0 et 1 et pas 1 et 2
  629. ;   move.l (sp)+,d2
  630.     rts
  631. orld7d6
  632.     ; d7 = le data sur 2 plan
  633.     ;
  634.  
  635. ;   move.l d2,-(sp)
  636. ;   move.l d3,-(sp)
  637.     move.w d7,d2
  638.     swap d7
  639.     or.w d7,d2
  640.     swap d7     ; remet d7 a la bonne valeur
  641.     not.w d2
  642.     move.w d2,d3
  643.     swap d2
  644.     move.w d3,d2
  645.     ; d2.l = masque a partir des 2 valeur poid fort poid faible de d7
  646.  
  647.     move.w #$02a8,(a1)+
  648.     move.l d2,(a1)+
  649.     move.w d6,(a1)+             ; + 8 octets
  650.  
  651.     move.w #$A8,(a1)+
  652.     move.l d7,(a1)+
  653.     move.w d6,(a1)+
  654.  
  655.     move.w #$2140,(a4)+
  656.     move.w d6,(a4)+
  657.  
  658. ;   ;move.l (sp)+,d3
  659. ;   move.l (sp)+,d2
  660.  
  661.     rts
  662.    
  663.     BSS
  664.     ds.l 1
  665.     ds.b 65536
  666. screenbuf
  667.     ds.w 65536
  668.     ds.w 65536
  669. log     ds.l 1
  670. phys    ds.l 1
  671. ptrscr1 ds.l 1
  672. ptrscr2 ds.l 1
  673. ptrscr3 ds.l 1
  674. ptrscr4 ds.l 1
  675.  
  676.  
  677. ;convx  ds.l 320*subpixel
  678. ;convy  ds.w 200*subpixel
  679.  
  680. ptrconvX ds.l 1
  681. ptrconvY ds.l 1
  682.  
  683.     BSS
  684.  
  685.  
  686. efface1lst
  687.         ds.l nbbob
  688.         ds.l nbbob
  689. efface2lst
  690.         ds.l nbbob
  691.         ds.l nbbob
  692.  
  693.  
  694. sinx1   ds.l 1   ds.w 512
  695. sinx2   ds.l 1   ds.w 512
  696. siny1   ds.l 1   ds.w 512
  697. siny2   ds.l 1   ds.w 512
  698.  
  699. ptrref1 ds.l 1
  700. ptrref2 ds.l 1
  701. ptrref3 ds.l 1
  702. ptrref4 ds.l 1
  703.  
  704.  
  705. codegenliste    ds.l 16
  706. codeeffliste    ds.l 16
  707. ram ds.b ($b24dA-$b19f2)+2000
  708.     ds.l 5000
  709. ram2    ds.l 5000
  710.     ds.l 5000
  711. ram3    ds.l 16000
  712.    
  713. ;convxSprite    ds.l 320*2*subpixel
  714.    
  715.  
  716. sprite  ds.w 32
  717.  
  718. spritedeca
  719.     ds.w 128*16
  720.  
  721.  
  722.     DATA
  723. sin512:         ; sin 512 element amplitude 32766
  724.     dc.w 0,402,804,1206,1607,2009,2410,2811
  725.     dc.w 3211,3611,4010,4409,4807,5205,5601,5997
  726.     dc.w 6392,6786,7179,7570,7961,8350,8739,9125
  727.     dc.w 9511,9895,10278,10659,11038,11416,11792,12166
  728.     dc.w 12539,12909,13278,13644,14009,14371,14731,15090
  729.     dc.w 15445,15799,16150,16498,16845,17188,17529,17868
  730.     dc.w 18203,18536,18866,19194,19518,19840,20158,20474
  731.     dc.w 20786,21095,21401,21704,22004,22300,22593,22882
  732.     dc.w 23169,23451,23730,24006,24278,24546,24810,25071
  733.     dc.w 25328,25581,25830,26076,26317,26555,26788,27018
  734.     dc.w 27243,27465,27682,27895,28104,28308,28509,28705
  735.     dc.w 28897,29084,29267,29445,29620,29789,29954,30115
  736.     dc.w 30271,30423,30570,30712,30850,30983,31112,31236
  737.     dc.w 31355,31469,31579,31683,31784,31879,31969,32055
  738.     dc.w 32136,32212,32283,32349,32411,32467,32519,32566
  739.     dc.w 32608,32645,32677,32704,32726,32743,32756,32763
  740.     dc.w 32766,32763,32756,32743,32726,32704,32677,32645
  741.     dc.w 32608,32566,32519,32467,32411,32349,32283,32212
  742.     dc.w 32136,32055,31969,31879,31784,31683,31579,31469
  743.     dc.w 31355,31236,31112,30983,30850,30712,30570,30423
  744.     dc.w 30271,30115,29954,29789,29620,29445,29267,29084
  745.     dc.w 28897,28705,28509,28308,28104,27895,27682,27465
  746.     dc.w 27243,27018,26788,26555,26317,26076,25830,25581
  747.     dc.w 25328,25071,24810,24546,24278,24006,23730,23451
  748.     dc.w 23169,22882,22593,22300,22004,21704,21401,21095
  749.     dc.w 20786,20474,20158,19840,19518,19194,18866,18536
  750.     dc.w 18203,17868,17529,17188,16845,16498,16150,15799
  751.     dc.w 15445,15090,14731,14371,14009,13644,13278,12909
  752.     dc.w 12539,12166,11792,11416,11038,10659,10278,9895
  753.     dc.w 9511,9125,8739,8350,7961,7570,7179,6786
  754.     dc.w 6392,5997,5601,5205,4807,4409,4010,3611
  755.     dc.w 3211,2811,2410,2009,1607,1206,804,402
  756.     dc.w 0,-402,-804,-1206,-1607,-2009,-2410,-2811
  757.     dc.w -3211,-3611,-4010,-4409,-4807,-5205,-5601,-5997
  758.     dc.w -6392,-6786,-7179,-7570,-7961,-8350,-8739,-9125
  759.     dc.w -9511,-9895,-10278,-10659,-11038,-11416,-11792,-12166
  760.     dc.w -12539,-12909,-13278,-13644,-14009,-14371,-14731,-15090
  761.     dc.w -15445,-15799,-16150,-16498,-16845,-17188,-17529,-17868
  762.     dc.w -18203,-18536,-18866,-19194,-19518,-19840,-20158,-20474
  763.     dc.w -20786,-21095,-21401,-21704,-22004,-22300,-22593,-22882
  764.     dc.w -23169,-23451,-23730,-24006,-24278,-24546,-24810,-25071
  765.     dc.w -25328,-25581,-25830,-26076,-26317,-26555,-26788,-27018
  766.     dc.w -27243,-27465,-27682,-27895,-28104,-28308,-28509,-28705
  767.     dc.w -28897,-29084,-29267,-29445,-29620,-29789,-29954,-30115
  768.     dc.w -30271,-30423,-30570,-30712,-30850,-30983,-31112,-31236
  769.     dc.w -31355,-31469,-31579,-31683,-31784,-31879,-31969,-32055
  770.     dc.w -32136,-32212,-32283,-32349,-32411,-32467,-32519,-32566
  771.     dc.w -32608,-32645,-32677,-32704,-32726,-32743,-32756,-32763
  772.     dc.w -32766,-32763,-32756,-32743,-32726,-32704,-32677,-32645
  773.     dc.w -32608,-32566,-32519,-32467,-32411,-32349,-32283,-32212
  774.     dc.w -32136,-32055,-31969,-31879,-31784,-31683,-31579,-31469
  775.     dc.w -31355,-31236,-31112,-30983,-30850,-30712,-30570,-30423
  776.     dc.w -30271,-30115,-29954,-29789,-29620,-29445,-29267,-29084
  777.     dc.w -28897,-28705,-28509,-28308,-28104,-27895,-27682,-27465
  778.     dc.w -27243,-27018,-26788,-26555,-26317,-26076,-25830,-25581
  779.     dc.w -25328,-25071,-24810,-24546,-24278,-24006,-23730,-23451
  780.     dc.w -23169,-22882,-22593,-22300,-22004,-21704,-21401,-21095
  781.     dc.w -20786,-20474,-20158,-19840,-19518,-19194,-18866,-18536
  782.     dc.w -18203,-17868,-17529,-17188,-16845,-16498,-16150,-15799
  783.     dc.w -15445,-15090,-14731,-14371,-14009,-13644,-13278,-12909
  784.     dc.w -12539,-12166,-11792,-11416,-11038,-10659,-10278,-9895
  785.     dc.w -9511,-9125,-8739,-8350,-7961,-7570,-7179,-6786
  786.     dc.w -6392,-5997,-5601,-5205,-4807,-4409,-4010,-3611
  787.     dc.w -3211,-2811,-2410,-2009,-1607,-1206,-804,-402
  788. sin896:     ; sin 896 element amplitude 32766
  789.     dc.w 0,229,459,689,918,1148,1378,1607
  790.     dc.w 1837,2066,2295,2524,2753,2982,3211,3440
  791.     dc.w 3668,3896,4124,4352,4580,4807,5034,5261
  792.     dc.w 5488,5714,5941,6166,6392,6617,6842,7066
  793.     dc.w 7291,7514,7738,7961,8184,8406,8628,8849
  794.     dc.w 9070,9291,9511,9731,9950,10168,10387,10604
  795.     dc.w 10821,11038,11254,11470,11685,11899,12113,12326
  796.     dc.w 12539,12750,12962,13173,13383,13592,13801,14009
  797.     dc.w 14216,14423,14629,14834,15038,15242,15445,15648
  798.     dc.w 15849,16050,16250,16449,16647,16845,17041,17237
  799.     dc.w 17432,17626,17819,18012,18203,18394,18584,18772
  800.     dc.w 18960,19147,19333,19518,19702,19885,20067,20249
  801.     dc.w 20429,20608,20786,20963,21139,21314,21488,21661
  802.     dc.w 21833,22004,22174,22342,22510,22676,22841,23006
  803.     dc.w 23169,23330,23491,23651,23809,23967,24123,24278
  804.     dc.w 24431,24584,24735,24885,25034,25182,25328,25473
  805.     dc.w 25617,25760,25901,26041,26180,26317,26454,26589
  806.     dc.w 26722,26854,26985,27115,27243,27370,27496,27620
  807.     dc.w 27743,27865,27985,28104,28221,28337,28452,28565
  808.     dc.w 28677,28788,28897,29004,29110,29215,29318,29420
  809.     dc.w 29521,29620,29717,29813,29908,30001,30093,30183
  810.     dc.w 30271,30359,30444,30528,30611,30692,30772,30850
  811.     dc.w 30927,31002,31076,31148,31218,31287,31355,31421
  812.     dc.w 31485,31548,31609,31669,31727,31784,31839,31892
  813.     dc.w 31944,31994,32043,32090,32136,32180,32222,32263
  814.     dc.w 32303,32340,32376,32411,32444,32475,32505,32533
  815.     dc.w 32559,32584,32608,32629,32650,32668,32685,32700
  816.     dc.w 32714,32726,32737,32745,32753,32758,32762,32765
  817.     dc.w 32766,32765,32762,32758,32753,32745,32737,32726
  818.     dc.w 32714,32700,32685,32668,32650,32629,32608,32584
  819.     dc.w 32559,32533,32505,32475,32444,32411,32376,32340
  820.     dc.w 32303,32263,32222,32180,32136,32090,32043,31994
  821.     dc.w 31944,31892,31839,31784,31727,31669,31609,31548
  822.     dc.w 31485,31421,31355,31287,31218,31148,31076,31002
  823.     dc.w 30927,30850,30772,30692,30611,30528,30444,30359
  824.     dc.w 30271,30183,30093,30001,29908,29813,29717,29620
  825.     dc.w 29521,29420,29318,29215,29110,29004,28897,28788
  826.     dc.w 28677,28565,28452,28337,28221,28104,27985,27865
  827.     dc.w 27743,27620,27496,27370,27243,27115,26985,26854
  828.     dc.w 26722,26589,26454,26317,26180,26041,25901,25760
  829.     dc.w 25617,25473,25328,25182,25034,24885,24735,24584
  830.     dc.w 24431,24278,24123,23967,23809,23651,23491,23330
  831.     dc.w 23169,23006,22841,22676,22510,22342,22174,22004
  832.     dc.w 21833,21661,21488,21314,21139,20963,20786,20608
  833.     dc.w 20429,20249,20067,19885,19702,19518,19333,19147
  834.     dc.w 18960,18772,18584,18394,18203,18012,17819,17626
  835.     dc.w 17432,17237,17041,16845,16647,16449,16250,16050
  836.     dc.w 15849,15648,15445,15242,15038,14834,14629,14423
  837.     dc.w 14216,14009,13801,13592,13383,13173,12962,12750
  838.     dc.w 12539,12326,12113,11899,11685,11470,11254,11038
  839.     dc.w 10821,10604,10387,10168,9950,9731,9511,9291
  840.     dc.w 9070,8849,8628,8406,8184,7961,7738,7514
  841.     dc.w 7291,7066,6842,6617,6392,6166,5941,5714
  842.     dc.w 5488,5261,5034,4807,4580,4352,4124,3896
  843.     dc.w 3668,3440,3211,2982,2753,2524,2295,2066
  844.     dc.w 1837,1607,1378,1148,918,689,459,229
  845.     dc.w 0,-229,-459,-689,-918,-1148,-1378,-1607
  846.     dc.w -1837,-2066,-2295,-2524,-2753,-2982,-3211,-3440
  847.     dc.w -3668,-3896,-4124,-4352,-4580,-4807,-5034,-5261
  848.     dc.w -5488,-5714,-5941,-6166,-6392,-6617,-6842,-7066
  849.     dc.w -7291,-7514,-7738,-7961,-8184,-8406,-8628,-8849
  850.     dc.w -9070,-9291,-9511,-9731,-9950,-10168,-10387,-10604
  851.     dc.w -10821,-11038,-11254,-11470,-11685,-11899,-12113,-12326
  852.     dc.w -12539,-12750,-12962,-13173,-13383,-13592,-13801,-14009
  853.     dc.w -14216,-14423,-14629,-14834,-15038,-15242,-15445,-15648
  854.     dc.w -15849,-16050,-16250,-16449,-16647,-16845,-17041,-17237
  855.     dc.w -17432,-17626,-17819,-18012,-18203,-18394,-18584,-18772
  856.     dc.w -18960,-19147,-19333,-19518,-19702,-19885,-20067,-20249
  857.     dc.w -20429,-20608,-20786,-20963,-21139,-21314,-21488,-21661
  858.     dc.w -21833,-22004,-22174,-22342,-22510,-22676,-22841,-23006
  859.     dc.w -23169,-23330,-23491,-23651,-23809,-23967,-24123,-24278
  860.     dc.w -24431,-24584,-24735,-24885,-25034,-25182,-25328,-25473
  861.     dc.w -25617,-25760,-25901,-26041,-26180,-26317,-26454,-26589
  862.     dc.w -26722,-26854,-26985,-27115,-27243,-27370,-27496,-27620
  863.     dc.w -27743,-27865,-27985,-28104,-28221,-28337,-28452,-28565
  864.     dc.w -28677,-28788,-28897,-29004,-29110,-29215,-29318,-29420
  865.     dc.w -29521,-29620,-29717,-29813,-29908,-30001,-30093,-30183
  866.     dc.w -30271,-30359,-30444,-30528,-30611,-30692,-30772,-30850
  867.     dc.w -30927,-31002,-31076,-31148,-31218,-31287,-31355,-31421
  868.     dc.w -31485,-31548,-31609,-31669,-31727,-31784,-31839,-31892
  869.     dc.w -31944,-31994,-32043,-32090,-32136,-32180,-32222,-32263
  870.     dc.w -32303,-32340,-32376,-32411,-32444,-32475,-32505,-32533
  871.     dc.w -32559,-32584,-32608,-32629,-32650,-32668,-32685,-32700
  872.     dc.w -32714,-32726,-32737,-32745,-32753,-32758,-32762,-32765
  873.     dc.w -32766,-32765,-32762,-32758,-32753,-32745,-32737,-32726
  874.     dc.w -32714,-32700,-32685,-32668,-32650,-32629,-32608,-32584
  875.     dc.w -32559,-32533,-32505,-32475,-32444,-32411,-32376,-32340
  876.     dc.w -32303,-32263,-32222,-32180,-32136,-32090,-32043,-31994
  877.     dc.w -31944,-31892,-31839,-31784,-31727,-31669,-31609,-31548
  878.     dc.w -31485,-31421,-31355,-31287,-31218,-31148,-31076,-31002
  879.     dc.w -30927,-30850,-30772,-30692,-30611,-30528,-30444,-30359
  880.     dc.w -30271,-30183,-30093,-30001,-29908,-29813,-29717,-29620
  881.     dc.w -29521,-29420,-29318,-29215,-29110,-29004,-28897,-28788
  882.     dc.w -28677,-28565,-28452,-28337,-28221,-28104,-27985,-27865
  883.     dc.w -27743,-27620,-27496,-27370,-27243,-27115,-26985,-26854
  884.     dc.w -26722,-26589,-26454,-26317,-26180,-26041,-25901,-25760
  885.     dc.w -25617,-25473,-25328,-25182,-25034,-24885,-24735,-24584
  886.     dc.w -24431,-24278,-24123,-23967,-23809,-23651,-23491,-23330
  887.     dc.w -23169,-23006,-22841,-22676,-22510,-22342,-22174,-22004
  888.     dc.w -21833,-21661,-21488,-21314,-21139,-20963,-20786,-20608
  889.     dc.w -20429,-20249,-20067,-19885,-19702,-19518,-19333,-19147
  890.     dc.w -18960,-18772,-18584,-18394,-18203,-18012,-17819,-17626
  891.     dc.w -17432,-17237,-17041,-16845,-16647,-16449,-16250,-16050
  892.     dc.w -15849,-15648,-15445,-15242,-15038,-14834,-14629,-14423
  893.     dc.w -14216,-14009,-13801,-13592,-13383,-13173,-12962,-12750
  894.     dc.w -12539,-12326,-12113,-11899,-11685,-11470,-11254,-11038
  895.     dc.w -10821,-10604,-10387,-10168,-9950,-9731,-9511,-9291
  896.     dc.w -9070,-8849,-8628,-8406,-8184,-7961,-7738,-7514
  897.     dc.w -7291,-7066,-6842,-6617,-6392,-6166,-5941,-5714
  898.     dc.w -5488,-5261,-5034,-4807,-4580,-4352,-4124,-3896
  899.     dc.w -3668,-3440,-3211,-2982,-2753,-2524,-2295,-2066
  900.     dc.w -1837,-1607,-1378,-1148,-918,-689,-459,-229
  901.  
  902.  
  903.  
  904. pi1 incbin 'SPRITE2.PI1'
  905.  
  906.     TEXT
  907. createContigustable
  908. ;
  909. ; a0 = ram
  910. ; d0 = nombre d'element de la table sinus
  911. ; d1 = pas interne
  912. ; d2 = nombre de copie de valeurs
  913. ; a3 = table de sinus d'amplitude final
  914. ;
  915. ; pendant le fonctionnement:
  916. ; constante  d3,d4,d5 = pas interne,*2,*4
  917. ;
  918. ;
  919. ;
  920.  
  921. ; retour:
  922. ; a0 = ram
  923. ; a1 = adresse table de d0 adresses  reftable pris a partir de la ram
  924. ;  
  925.  
  926.     move.l a0,a1        ; a1 = table refsin
  927.     move.l a1,-(sp)
  928.     move.w d0,d3
  929.     add.w d3,d3     ; *2
  930.     move.l a3,a4
  931.     add.w d3,a4
  932.     add.w d3,d3     ; *4
  933.     add.w d3,a0         ; a0 =ram
  934.  
  935.  
  936.  
  937.     lea tempbuffer,a2
  938.     move.w d0,d4
  939.     lsr #2,d4
  940.     moveq #0,d3
  941. .clearFlag
  942.     move.l d3,(a2)+
  943.     dbf d4,.clearFlag   ; +- 4 octet
  944.  
  945.     lea tempbuffer,a2
  946.     move.l a2,a5
  947.     add.w d0,a5
  948.    
  949.  
  950.  
  951.     ;moveq #0,d5            ; angle
  952.    
  953.     move.w d1,d3        ; pas interne<>0
  954.     move.w d3,d4
  955.     add d4,d4           ; pas interne*2
  956.     move.w d4,d5
  957.     add.w d5,d5         ; pas interne*4
  958.     neg.w d0
  959.     move.w d0,.auto1+2          ; nombre d'elements
  960.     move.w d0,.auto1b+2
  961.     add.w d0,d0
  962.     move.w d0,.auto2+2
  963.     move.w d0,.auto2b+2
  964.     move.w d0,.auto2c+2
  965.     add.w d0,d0
  966.     move.w d0,.auto3+2
  967.     move.w d0,.auto3b+2
  968. ;----------------------------------------
  969.     bra.s .loop
  970. .loopaddq
  971.     addq.w #2,a3
  972.     addq.w #4,a1
  973.     ; ps le tst.b (a2) deux ligne plus loin est redondant quand on sort de la boucle dans le code flaga1
  974.     move.w (a3),d7
  975.     bra.s .11
  976. .loop
  977.     move.w (a3),d7
  978.     tst.b (a2)
  979.     bne.s .flaga1
  980. .11 st.b (a2)
  981.     move.l a0,(a1)      ; on stoque l'adresse de la valeur dans table refsin
  982.     move.w d7,(a0)+
  983.     ; on met a jour a3 avec le pas interne*2
  984.     ; on met a jour a2 avec le pas interne (flags)
  985.     add.w d3,a2
  986.     add.w d4,a3
  987.     add.w d5,a1
  988.  
  989.     cmp.l a2,a5
  990.     bgt.s .loop
  991. .auto1
  992.     lea 0(a2),a2
  993. .auto2
  994.     lea 0(a3),a3
  995. .auto3
  996.     lea 0(a1),a1
  997.     bra.s .loop
  998. .flaga1
  999.     move.w d2,d6        ; nombre de copie
  1000.     ;subq.w #1,d6
  1001.  
  1002.     move.l a3,-(sp)
  1003. .cpy
  1004.     move.w d7,(a0)+
  1005.     add.w d4,a3
  1006.     cmp.l a3,a4
  1007.     bgt.s .1
  1008. .auto2b
  1009.     lea 0(a3),a3
  1010.  
  1011. .1
  1012.     move.w (a3),d7
  1013.     dbf d6,.cpy
  1014.     move.l (sp)+,a3
  1015.  
  1016.     addq.w #1,a2
  1017.     cmp.l a2,a5
  1018.     bgt.s .2
  1019. .auto1b
  1020.     lea 0(a2),a2
  1021. .auto2c
  1022.     lea 0(a3),a3
  1023. .auto3b
  1024.     lea 0(a1),a1
  1025. .2
  1026.     ; s'assurer qu'on est pas en fin de tableau:
  1027.     ;
  1028.     ;
  1029.  
  1030.     tst.b (a2)
  1031.     beq.s .loopaddq
  1032. .fin
  1033.     move.l (sp)+,a1
  1034.  
  1035.     rts
  1036.    
  1037.     BSS
  1038. segmentX    ds.w 1
  1039. segmentY    ds.w 1
  1040. tempbuffer
  1041.     ds.w 2048
  1042.  
  1043.     TEXT
  1044. ;
  1045. ;
  1046. ;
  1047. ; mem lib
  1048. ;
  1049.  
  1050. ;; exemple d'utilisation
  1051. ;   move.l #buffer,d0
  1052. ;   move.l #8*65536,d1 taille totale du buffer aligné sur 64k
  1053. ;   jsr getmem1
  1054. ;   lea -16*4(a0),a0
  1055. ;   nop
  1056. ;   nop
  1057. ;   nop
  1058. ;   nop
  1059. ;   illegal
  1060. ; format de memoire
  1061. ;toto           ; le label toto est la pour verifier l'algo
  1062. ;   ds.b 65536 
  1063. ;buffer ds.l 65536*2    8*64k               ; buffer sera aligné sur 64k donc un peu avant
  1064. ;fin                                            ; et apres un peu de memoire libre entre fin buffer et label fin
  1065.  
  1066. getmem1:
  1067.  
  1068. ; d0 = adresse segment 64k non aligné
  1069. ; d1 = nombre de segment a la suite*64k
  1070. ; retour: a0 = liste d'adresse
  1071. ; (a0)+ = 32k buffer
  1072. ; (a0)+ = 16k buffer
  1073. ; (a0)+ = 8k buffer
  1074. ; (a0)+ = 4k buffer
  1075. ; (a0)+ = 2k
  1076. ; (a0)+ = 1k
  1077. ; (a0)+ = 512
  1078. ; (a0)+ = 256
  1079. ; (a0)+ = 128
  1080. ; (a0)+ = 64 octet
  1081. ;
  1082. ; a0: 64 octet = 16 adresses
  1083.  
  1084.     ; metre le buffer start dans d4
  1085.  
  1086.     moveq.w #1,d5
  1087.     swap d5
  1088.     move.l d0,d4
  1089.     sub.l d5,d4     ; start memoire basse
  1090.     move.l d0,d3
  1091.     clr.w d3        ;  debut multiple de 64k  fin memoire basse
  1092.     ; d3 = start segment
  1093.    
  1094.    
  1095.     move.l d4,d7
  1096.     sub.l d3,d7     ; d7 = taille en bas
  1097.                 ; d4 = start bas
  1098.    
  1099.     add.l d1,d3     ; d3+ 4*64k = adresse start haut
  1100.  
  1101.  
  1102.    
  1103.     lea ptrMem,a0
  1104.     moveq #0,d6
  1105.     move.w #$8000,d6
  1106.    
  1107. .loop
  1108.     move.w d6,d1
  1109.     and.w d7,d1
  1110.  
  1111.     ; bit 15 a 0 ?
  1112.     tst.w d1
  1113.     bne.s .before           ; was beq
  1114.     move.l d3,(a0)+
  1115.     add.l d6,d3
  1116.    
  1117.     bra.s .suite
  1118. .before
  1119.     move.l d4,(a0)+
  1120.     add.l d6,d4
  1121. .suite
  1122.     lsr #1,d5
  1123.     bne.s .loop         ; ici ca s'arrete a un buffer de 1 octet il faudrai faire un meilleur test
  1124.    
  1125.     lea -64(a0),a0                  ; et s'arreter a un plus gros buffer
  1126.     rts
  1127.    
  1128.  
  1129.  
  1130.  
  1131. ptrMem      ds.l 16         ; dans ram apres l'appel de getmem1 adresses contenant les bloc memoire utilisable comme on veut
  1132.  
  1133. ;;;             ; les label entour? de ;;; doivent etre dans l'ordre et contigu (ne pas deplacer l'un des label)
  1134. ;ptrtabsin1 ds.l 1
  1135. ;ptrtabsin2 ds.l 1
  1136. ;ptrtabsin3 ds.l 1
  1137. ;ptrtabsin4 ds.l 1
  1138. ptr16k  ds.l 1
  1139. ptr4k   ds.l 1
  1140. ptrflag ds.l 1
  1141. ;;;
  1142.  
  1143.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement