Advertisement
glokyfull

half working sprite 2plan (code6.s)

Nov 20th, 2023
1,039
0
201 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. subpixel equ 4
  2. subpixel2 equ 8
  3. nbbob   equ 80
  4.  
  5. start:
  6.  
  7.     clr.l -(sp)
  8.     move.w #$20,-(sp)
  9.     trap #1
  10.     addq.l #6,sp
  11.  
  12.     lea spritedeca,a0
  13.     move.w #16*2*16-1,d0
  14. .toto   clr.w (a0)+
  15.     dbf d0,.toto
  16.  
  17.    move.l $44e.w,d0  
  18.    clr.w -(sp)
  19.     move.l d0,-(sp)
  20.     move.l d0,-(sp)
  21.     move.w #5,-(sp)
  22.     trap #14
  23.     lea 12(sp),sp
  24.  
  25.  
  26.     jsr extractsprite
  27.  
  28.     jsr prepare_segments
  29.  
  30. ; creation convx et convy
  31. ;   move.l #$8000,d0    ;     offset,motif or
  32. ;   lea convx,a0
  33. ;.loopconvx
  34. ;   rept subpixel
  35. ;     move.l d0,(a0)+
  36. ;   endr
  37. ;   lsr.w #1,d0
  38. ;   bne.s .loopconvx
  39. ;   add.l #$00088000,d0
  40. ;   cmp.l #$00a08000,d0
  41. ;   bne.s .loopconvx
  42. ;
  43. ;   move.w #0,d0
  44. ;   move.w #199,d1
  45. ;   lea convy,a0
  46. ;.loopconvy
  47. ;   rept subpixel
  48. ;   move.w d0,(a0)+
  49. ;   endr
  50. ;   add #160,d0
  51. ;   dbf d1,.loopconvy
  52. ;
  53.  
  54.     move.l ptrConvX,a0
  55.     lea codegenliste,a1
  56.     move.w #19,d0
  57.     moveq #0,d2
  58. .loop3
  59.     lea codegenliste,a1
  60.     lea codeeffliste,a3
  61.     moveq #15,d3
  62. .loop2
  63.     move.l (a3),d5
  64.     move.l (a1)+,d1
  65.     rept subpixel2
  66.     move.w d2,(a0)+     ; offset
  67.     move.l d5,(a0)+     ; code effacement
  68.     move.l d1,(a0)+     ; code affichage
  69.  
  70.     endr
  71.  
  72.     dbf d3,.loop2
  73.     addq.w #8,d2
  74.     dbf d0,.loop3
  75.  
  76.     move.l ptrConvY,a0
  77.     moveq #0,d2
  78.     move.w #160,d1
  79.     move.w #199,d0      ; pas de cliping pour l'instant
  80. .loop4
  81.     rept subpixel2
  82.     move.w d2,(a0)+
  83.     endr
  84.     add d1,d2
  85.     dbf d0,.loop4
  86.  
  87.     jsr convsinus
  88.     jsr swap_screen
  89.    
  90. main
  91.  
  92.     jsr majAngle
  93.     jsr calcAllPos
  94.  
  95.  
  96.     move.w #$111,$ffff8240.w
  97.     jsr waitvbl
  98.     clr.w $ffff8240.w
  99.     ;jsr swap_screen
  100.     move.l log,d0
  101.    
  102.    
  103.     cmp.b #$b9,$fffffc02.w
  104.     beq.s .fin
  105.     jmp main
  106. .fin
  107.  
  108.     bsr waitvbl
  109.     move.l $44e.w,d0
  110.     lsr.w #8,d0
  111.     move.l d0,$ffff8200.w
  112.     bsr waitvbl
  113.     move.l $44e.w,d0  
  114. ;
  115.     move.w #1,-(sp)
  116. ;
  117.     move.l d0,-(sp)
  118. ;
  119.     move.l d0,-(sp)
  120. ;
  121.    move.w #5,-(sp)
  122. ;
  123.     trap #14
  124. ;
  125.     lea 12(sp),sp
  126.  
  127.    
  128.  
  129.     clr.w -(sp)
  130.     trap #1
  131.  
  132. cptdeca dc.w 0
  133. angles  dc.w 128,128,50,70
  134. ajoutangle  dc.w 21,3,512-2,1
  135.  
  136.  
  137. majangle
  138.     lea ajoutangle,a0
  139.     lea angles,a1
  140.     moveq #3,d7
  141. .loop
  142.     move.w (a0)+,d0
  143.     move.w (a1),d1
  144.     add d0,d1
  145.     and.w #511,d1
  146.     move.w d1,(a1)+
  147.     dbf d7,.loop
  148.  
  149.     rts
  150.  
  151. convsinus
  152.     move.l sinx1,a1
  153.     move.l sinx2,a2
  154.     lea sin512,a0
  155.     move.w #511,d0
  156.     move.w ptrconvX+2,d4
  157. .loop
  158.     moveq #0,d1
  159.     move.w (a0)+,d1
  160.     add.w #32767,d1
  161.  
  162.     move.l d1,d2
  163.     mulu #(180-8)*subpixel2,d1
  164.     mulu #(140-8)*subpixel2,d2   ; 8 subpixel
  165.     ;asl #1,d1
  166.     ;asl #1,d2
  167.     swap d1
  168.     swap d2
  169. ; *10 = *8+*2 = *2(*4+1)
  170.  
  171.     add d1,d1
  172.     move.w d1,d3
  173.     add.w d3,d3 *4
  174.     add.w d3,d3
  175.     add d3,d1   ; d1 = d1 * 10
  176. ;   and.w #-4,d1
  177.  
  178. ;   and.w #-4,d2
  179.  
  180.     add d2,d2
  181.     move.w d2,d3
  182.     add d3,d3
  183.     add d3,d3
  184.     add d3,d2
  185.  
  186.     add d4,d1               ; premiere table de sinus, on ajoute l'offset de convX
  187.     move.w d1,(a1)+
  188.     move.w d2,(a2)+
  189.     dbf d0,.loop
  190.    
  191.  
  192.     move.w ptrConvY+2,d4
  193.     move.l siny1,a1
  194.     move.l siny2,a2
  195.     lea sin512,a0
  196.     move.w #511,d0
  197. .loopy
  198.     moveq #0,d1
  199.     move.w (a0)+,d1
  200.     add.w #32767,d1
  201.     move.l d1,d2
  202.     mulu #(40*2-8)*subpixel2*2,d1
  203.     mulu #(60*2-8)*subpixel2*2,d2
  204. ;   asl #1,d1
  205. ;   asl #1,d2
  206.     swap d1
  207.     swap d2
  208.     and.w #-2,d1
  209.     and.w #-2,d2
  210.     add d4,d1           ; ajoute l'offset segment
  211.     move.w d1,(a1)+
  212.     move.w d2,(a2)+
  213.     dbf d0,.loopy
  214.  
  215.  
  216. ; createContigustable
  217. ;
  218. ; a0 = ram
  219. ; d0 = nombre d'element de la table sinus
  220. ; d1 = pas interne
  221. ; d2 = nombre de copie de valeurs
  222. ; a3 = table de sinus d'amplitude final
  223. ;
  224. ; pendant le fonctionnement:
  225. ; constante  d3,d4,d5 = pas interne,*2,*4
  226. ;
  227. ;
  228. ;
  229.  
  230. ; retour:
  231. ; a0 = ram
  232. ; a1 = adresse table de d0 adresses  reftable pris a partir de la ram
  233. ;  
  234.  
  235.     lea ram3,a0
  236.     move.w #512,d0
  237.     move.w #nbbob,d2 ; nombre de copie de valeur
  238.     move.w #11,d1       ; pas interne 5 /512
  239.     move.l sinx1,a3
  240.     jsr createContigustable
  241.     move.l a1,ptrref1
  242.  
  243.     move.w #512,d0
  244.     move.w #28,d1
  245.     move.w #nbbob,d2
  246.     move.l sinx2,a3
  247.     jsr createContigustable
  248.     move.l a1,ptrref2
  249.  
  250.     move.w #512,d0
  251.     move.w #512-12,d1
  252.     move.w #nbbob,d2
  253.     move.l siny1,a3
  254.     jsr createContigustable
  255.     move.l a1,ptrref3
  256.  
  257.     move.w #512,d0
  258.     move.w #512-24,d1
  259.     move.w #nbbob,d2
  260.     move.l siny2,a3
  261.     jsr createContigustable
  262.     move.l a1,ptrref4
  263.     rts
  264.  
  265.  
  266. ang1    dc.w 128
  267. ang2    dc.w 128
  268. ang3    dc.w 10
  269. ang4    dc.w 0
  270. ajoutang1   dc.w 4
  271. ajoutang2   dc.w 1
  272. ajoutang3   dc.w 512-3
  273. ajoutang4  dc.w 1
  274. calcAllpos
  275.     move.l ptrref1,a5
  276.     move.l ptrref2,a1
  277.     move.w ang1,d0
  278.     add d0,d0
  279.     add d0,d0
  280.     add.w d0,a5
  281.     move.w ang2,d0
  282.     add d0,d0
  283.     add.w d0,d0
  284.     add.w d0,a1
  285.  
  286.     move.l ptrref3,a2
  287.     move.l ptrref4,a3
  288.     move.w ang3,d0
  289.     add d0,d0
  290.     add d0,d0
  291.     add d0,a2
  292.     move.w ang4,d0
  293.     add d0,d0
  294.     add d0,d0
  295.     add d0,a3
  296.  
  297.     move.l (a5),a5
  298.     move.l (a1),a1
  299.     move.l (a2),a2
  300.     move.l (a3),a3
  301.  
  302.     lea efface1lst,a4
  303.  
  304.     move.l ptrConvX,d0
  305.     move.l ptrConvY,d1
  306.     move.l ptrscr1,d3
  307.  
  308.     move.w #nbbob-1,d2
  309. .loopcalcul
  310.  
  311.     move.w (a5)+,d0
  312.     add.w (a1)+,d0
  313.     move.w (a2)+,d1
  314.     add.w (a3)+,d1
  315.  
  316.     move.l d1,a6
  317.     move.w (a6),d3          ;  y*160
  318.  
  319.     move.l d0,a6
  320.     add.w (a6)+,d3
  321.     move.w d3,(a4)+         ; effacement offset
  322.     move.l (a6)+,(a4)+      ; routine d'effacement
  323.  
  324.     move.l (a6),a6          ; routine d'affichage
  325.     move.l d3,a0
  326.  
  327.     jsr (a6)
  328.     dbf d2,.loopcalcul
  329.  
  330.     lea ang1,a0
  331.     lea 8(a0),a1
  332.     movem.w (a1),d0-d3
  333.  
  334.     move.w (a0),d4
  335.     add.w d0,d4
  336.     move.w #511,d5
  337.     and d5,d4
  338.     move.w d4,(a0)+
  339.  
  340.     move.w (a0),d4
  341.     add.w d1,d4
  342.     and d5,d4
  343.     move.w d4,(a0)+
  344.  
  345.     move.w (a0),d4
  346.     add.w d2,d4
  347.     and d5,d4
  348.     move.w d4,(a0)+
  349.  
  350.     move.w (a0),d4
  351.     add.w d3,d4
  352.     and d5,d4
  353.     move.w d4,(a0)+
  354. ; maj angle fait
  355.  
  356.     rts
  357.  
  358. prepare_segments
  359.    
  360.     move.l #screenbuf,d0
  361.     moveq #4,d1
  362.     swap d1
  363.     jsr getMem1                 ; prepare 16 zone memoire allant de 32768 a 1 octet (puissance de 2)
  364.  
  365.     lea ptrMem,a0
  366.     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  
  367.  
  368.     move.l d3,sinX1         ; sinx1 x2 y1 y2 devenu des pointeur sur
  369.                             ; 512 word
  370.     move.l #1024,d5
  371.     add.l d5,d3
  372.     move.l d3,sinX2
  373.     add.l d5,d3
  374.     move.l d3,sinY1
  375.     add.l d5,d3
  376.     move.l d3,sinY2                 ; place pour 4k = 4 table de 512 word
  377.  
  378.  
  379.                                 ; cad poid fort de l'adresse du buffer est toujours a la meme valeur
  380.     move.l d0,ptrConvY          ; 32k alloué pour convy: 1856*2 en comptant cliping haut bas de 16 pixel de hauteur et 4 subpixel
  381.     add.l #2*1856,d0
  382.     ; 30912 octet libre
  383.     move.l d0,ptrConvX  ; 12800 octet pour 320 pixel 4 subpixel 10 octet (adresseEFF,adresseAFF,offset)
  384.     add.l #320*8*10,d0      ; pile poil 4 subpixel  convy 232*8 subpixel*2 + 352*8 subpixel*10 octet
  385.     moveq #0,d4                 ; 31872 octet sur 32768
  386.     move.w #1024,d4
  387.     lea sinx1,a1
  388.     move.l d0,(a1)+
  389.     add.l d4,d0
  390.     move.l d0,(a1)+
  391.     add.l d4,d0
  392.     move.l d0,(a1)+
  393.     add.l d4,d0
  394.     move.l d0,(a1)+
  395.    
  396.     move.l d1,ptr16k
  397.     move.l d2,ptrFlag           ; 8k max pour les flag, sinus dont le nombre d'element ne depasse pas 8192
  398.     move.l d3,ptr4k
  399.  
  400.     move.l #screenbuf,d0
  401.     moveq #1,d1
  402.     swap d1
  403.     add.l d1,d0
  404.     clr.w d0
  405.     move.l d0,log
  406.     move.l d0,ptrscr1
  407.     add.l d1,d0
  408.     move.l d0,phys
  409.     move.l d0,ptrscr2
  410.     add.l d1,d0
  411.     move.l d0,ptrscr3
  412.     add.l d1,d0
  413.     move.l d0,ptrscr4
  414.  
  415. ;   add.l d1,d0
  416. ;   move.l d0,convX
  417. ;   add.l #320*subpixel*8,d0
  418. ;   add.l d1,d0
  419. ;   move.l d0,convY
  420.  
  421.     rts
  422. waitvbl
  423.     move.w $468.w,d0
  424. .loop   cmp.w $468.w,d0
  425.     beq.s .loop
  426.     rts
  427.  
  428. swap_screen
  429.     move.l log,d0
  430.     move.l phys,d1
  431.     move.l d0,phys
  432.     move.l d1,log
  433.     lsr.w #8,d0
  434.     move.l d0,$ffff8200.w
  435.     rts
  436.  
  437. extractsprite
  438.     lea pi1+2,a0
  439.     movem.w (a0),d0-d3
  440.     movem.w d0-d3,$ffff8240.w
  441.     lea pi1+34,a0
  442.    
  443.     lea spritedeca,a1
  444.     moveq #0,d1
  445.     moveq #15,d7
  446. .loop0
  447.     move.l (a0),d0
  448.     lea 160(a0),a0
  449.     move.l d0,(a1)+
  450.     move.l d1,(a1)+
  451.     dbf d7,.loop0
  452.  
  453.     moveq #14,d7
  454.     lea spritedeca,a1
  455.     move.l a1,a3
  456.     lea 128(a1),a2
  457.     move.l a2,a4
  458. .copyandshift
  459.     move.w #15,d6
  460. .ligne
  461. ;   rept 2
  462. ;   move.w (a1)+,d0
  463. ;   move.w 2(a1),d1
  464. ;   move.w #0,ccr       ; set x to 0
  465. ;   roxr #1,d0
  466. ;   roxr #1,d1
  467. ;   move.w d0,(a2)+
  468. ;   move.w d1,2(a2)
  469. ;   ;lea 2(a1),a1
  470. ;   ;lea 2(a2),a2
  471. ;   endr
  472.  
  473.     MOVE.L (A1)+,(A2)+
  474.     MOVE.L (A1)+,(A2)+
  475.     LEA -8(A2),A2
  476.     MOVE.B #0,CCR
  477.     ROXR (A2)
  478.     ROXR 4(A2)
  479.     MOVE.B #0,CCR
  480.     ROXR 2(A2)
  481.     ROXR 6(a2)
  482.  
  483.     lea 8(a2),a2
  484.     dbf d6,.ligne
  485.     lea 128(a3),a3
  486.     lea 128(a4),a4
  487.     move.l a3,a1
  488.     move.l a4,a2
  489.  
  490. ;   lea 4(a2),a2
  491. ;   lea 4(a1),a1
  492.     dbf d7,.copyandshift
  493.    
  494. makecodegen
  495.     lea spritedeca,a0
  496.     lea ram,a1
  497.     lea codegenliste,a2
  498.     lea codeeffliste,a3
  499.     lea ram2,a4
  500.     moveq #15,d0
  501. .loopSprite
  502.     move.l a4,(a3)+
  503.     move.l a1,(a2)+
  504.     moveq #15,d1
  505.     moveq #0,d6     ; offset
  506. .loopligne
  507.     move.w (a0)+,d2
  508.     move.w (a0)+,d3
  509.     move.w (a0)+,d4
  510.     move.w (a0)+,d5
  511.     tst.w d2
  512.     bne.s .1
  513.     tst.w d3
  514.     beq.s .nerienfaire
  515.     ; or.w #d3,offset+2(a0)
  516.     move.w d3,d7
  517.     addq #2,d6
  518.     bsr orwd7d6_2
  519.     subq #2,d6
  520.    
  521.  
  522.  
  523.     bra.s .suite
  524. .1  ; d2 contient kekchose
  525.     tst.w d3
  526.     beq.s .wordd2
  527.     ; or.l #d2d3,offset(a0)
  528.     move.w d2,d7
  529.     swap d7
  530.     move.w d3,d7
  531.     bsr orld7d6
  532.     bra.s .suite
  533. .wordd2
  534.     ; or.w #d2,offset(a0)
  535.     move.w d2,d7
  536.     bsr orwd7d6
  537.     bra.s .suite
  538. .nerienfaire
  539.     nop
  540. .suite
  541.     tst.w d4
  542.     bne.s .2
  543.     tst.w d5
  544.     beq.s .nerienfaire2
  545.     ; or.w #d5,offset+8+2(a0)
  546.     move.w d5,d7
  547.     add.w #10,d6
  548.     bsr orwd7d6_2
  549.     sub.w #10,d6
  550.  
  551.  
  552.     bra.s .suite2  
  553. .2  tst.w d5
  554.     beq.s .wordd4
  555.     ; or.l #d4d5,offset+8(a0)
  556.     move.w d4,d7
  557.     swap d7
  558.     move.w d5,d7
  559.     addq.w #8,d6
  560.     bsr orld7d6
  561.     subq #8,d6
  562.  
  563.     bra.s .suite2
  564. .wordd4
  565.     ; or.w #d4,offset+8(a0)
  566.     move.w d4,d7
  567.     addq #8,d6
  568.     bsr orwd7d6
  569.     subq #8,d6
  570.     bra.s .suite2
  571. .nerienfaire2
  572.     nop
  573. .suite2
  574.     add #160,d6
  575.     dbf d1,.loopligne
  576.     move.w #$4e75,(a1)+
  577.     move.w #$4e75,(a4)+
  578.     dbf d0,.loopSprite
  579.     rts
  580. orwd7d6
  581. ;   move.l d2,-(sp)
  582.     move.w d7,d2   ; plus besoin de d2
  583.     swap d2
  584.     move.w d7,d2
  585.     not.l d2
  586.  
  587.     ; and.l d2,d6(a0)   02a8
  588.  
  589.     move.w #$02a8,(a1)+     ; + 8 octet au code genere
  590.     move.l d2,(a1)+
  591.     move.w d6,(a1)+
  592.  
  593.  
  594.     move.w #$68,(a1)+
  595.     move.w d7,(a1)+
  596.     move.w d6,(a1)+
  597.  
  598.     move.w #$2140,(a4)+     ; since it's masked on 2 plan, the clearing is long instead of word
  599.  
  600.     move.w d6,(A4)+         ; ($2140 instead of $3140) (move.l d0,d6(a0) instead of move.w d0,d6(a0))
  601.  
  602. ;   move.l (sp)+,d2
  603.     rts
  604. orwd7d6_2                   ; cas ou orwd7d6 mais sur le deuxieme plan, l'effacement se fait naturellement sur le premier plan
  605. ;   move.l d2,-(sp)
  606.     move.w d7,d2   ; plus besoin de d2
  607.     swap d2
  608.     move.w d7,d2
  609.     not.l d2
  610.  
  611.     ; and.l d2,d6(a0)   02a8
  612.  
  613.     move.w #$02a8,(a1)+     ; + 8 octet au code genere
  614.     move.l d2,(a1)+
  615.     move.w d6,(a1)
  616.     subq.w #2,(a1)+
  617.  
  618.  
  619.  
  620.     move.w #$68,(a1)+
  621.     move.w d7,(a1)+
  622.     move.w d6,(a1)+
  623.  
  624.     move.w #$2140,(a4)+     ; since it's masked on 2 plan, the clearing is long instead of word
  625.  
  626.     move.w d6,(A4)          ; ($2140 instead of $3140) (move.l d0,d6(a0) instead of move.w d0,d6(a0))
  627.     subq.w #2,(a4)+         ; on and.l sur le plan 0 et 1 et pas 1 et 2
  628. ;   move.l (sp)+,d2
  629.     rts
  630. orld7d6
  631.     ; d7 = le data sur 2 plan
  632.     ;
  633.  
  634. ;   move.l d2,-(sp)
  635. ;   move.l d3,-(sp)
  636.     move.w d7,d2
  637.     swap d7
  638.     or.w d7,d2
  639.     swap d7     ; remet d7 a la bonne valeur
  640.     not.w d2
  641.     move.w d2,d3
  642.     swap d2
  643.     move.w d3,d2
  644.     ; d2.l = masque a partir des 2 valeur poid fort poid faible de d7
  645.  
  646.     move.w #$02a8,(a1)+
  647.     move.l d2,(a1)+
  648.     move.w d6,(a1)+             ; + 8 octets
  649.  
  650.     move.w #$A8,(a1)+
  651.     move.l d7,(a1)+
  652.     move.w d6,(a1)+
  653.  
  654.     move.w #$2140,(a4)+
  655.     move.w d6,(a4)+
  656.  
  657. ;   ;move.l (sp)+,d3
  658. ;   move.l (sp)+,d2
  659.  
  660.     rts
  661.    
  662.     BSS
  663.     ds.l 1
  664.     ds.b 65536
  665. screenbuf
  666.     ds.w 65536
  667.     ds.w 65536
  668. log     ds.l 1
  669. phys    ds.l 1
  670. ptrscr1 ds.l 1
  671. ptrscr2 ds.l 1
  672. ptrscr3 ds.l 1
  673. ptrscr4 ds.l 1
  674.  
  675.  
  676. ;convx  ds.l 320*subpixel
  677. ;convy  ds.w 200*subpixel
  678.  
  679. ptrconvX ds.l 1
  680. ptrconvY ds.l 1
  681.  
  682.     BSS
  683.  
  684.  
  685. efface1lst
  686.         ds.l nbbob
  687.         ds.l nbbob
  688.  
  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 32000
  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 'SPRITE4.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. ;pgcd   ; de d0 et d1
  1129. ;; d0 le plus grand nombre
  1130. ;   cmp.w d1,d0
  1131. ;   blt.s .1
  1132. ;   exg d0,d1
  1133. ;.1
  1134. ;   : d0 > d1
  1135. ;    move.w d0,d2
  1136. ;
  1137. ;   sub d1,d0
  1138. ;    cmp d1,d0
  1139. ;    blt.s .1
  1140. ;    
  1141.  
  1142.  
  1143.  
  1144. ptrMem      ds.l 16         ; dans ram apres l'appel de getmem1 adresses contenant les bloc memoire utilisable comme on veut
  1145.  
  1146. ;;;             ; les label entour? de ;;; doivent etre dans l'ordre et contigu (ne pas deplacer l'un des label)
  1147. ;ptrtabsin1 ds.l 1
  1148. ;ptrtabsin2 ds.l 1
  1149. ;ptrtabsin3 ds.l 1
  1150. ;ptrtabsin4 ds.l 1
  1151. ptr16k  ds.l 1
  1152. ptr4k   ds.l 1
  1153. ptrflag ds.l 1
  1154. ;;;
  1155.  
  1156.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement