glokyfull

code11

Dec 3rd, 2023
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. subpixel equ 4
  2. subpixel2 equ 6
  3. nbbob   equ 69
  4. spr_pi1 equ 0
  5. tempmachine equ 1
  6. start:
  7.  
  8. ;   clr.l -(sp)
  9. ;   move.w #$20,-(sp)
  10. ;   trap #1
  11. ;   addq.l #6,sp
  12.  
  13.  
  14.     jsr mjj_sys_init
  15.  
  16.     jsr prepare_segments
  17.  
  18.  
  19.  
  20.     lea sin1pack,a0
  21.     move.l sin512,a1
  22.     jsr depackperiod       
  23.  
  24.  
  25.     lea spritedeca,a0
  26.     move.w #16*2*16-1,d0
  27. .toto   clr.w (a0)+
  28.     dbf d0,.toto
  29.  
  30.     jsr extractsprite
  31.  
  32.  
  33. ; creation convx et convy
  34. ;   move.l #$8000,d0    ;     offset,motif or
  35. ;   lea convx,a0
  36. ;.loopconvx
  37. ;   rept subpixel
  38. ;     move.l d0,(a0)+
  39. ;   endr
  40. ;   lsr.w #1,d0
  41. ;   bne.s .loopconvx
  42. ;   add.l #$00088000,d0
  43. ;   cmp.l #$00a08000,d0
  44. ;   bne.s .loopconvx
  45. ;
  46. ;   move.w #0,d0
  47. ;   move.w #199,d1
  48. ;   lea convy,a0
  49. ;.loopconvy
  50. ;   rept subpixel
  51. ;   move.w d0,(a0)+
  52. ;   endr
  53. ;   add #160,d0
  54. ;   dbf d1,.loopconvy
  55. ;
  56.  
  57.     move.l ptrConvX,a0
  58.     lea codegenliste,a1
  59.     move.w #19,d0
  60.     moveq #0,d2
  61. .loop3
  62.     lea codegenliste,a1
  63.     lea codeeffliste,a3
  64.     moveq #15,d3
  65. .loop2
  66.     move.l (a3)+,d5
  67.     move.l (a1)+,d1
  68.     rept subpixel2
  69.     move.w d2,(a0)+     ; offset
  70.     move.l d5,(a0)+     ; code effacement
  71.     move.l d1,(a0)+     ; code affichage
  72.  
  73.     endr
  74.  
  75.     dbf d3,.loop2
  76.     addq.w #8,d2
  77.     dbf d0,.loop3
  78.  
  79.     move.l ptrConvY,a0
  80.     moveq #0,d2
  81.     move.w #160,d1
  82.     move.w #199,d0      ; pas de cliping pour l'instant
  83.     move.w #200*subpixel2,d7
  84.  
  85. .1  move.w d2,(a0)+
  86.     dbf d7,.1
  87.  
  88. .loop4
  89.     rept subpixel2
  90.     move.w d2,(a0)+
  91.     endr
  92.     add d1,d2
  93.     dbf d0,.loop4
  94.     jsr initcleartozerozero
  95.     jsr waitvbl
  96.     jsr swap_screen
  97.  
  98.     move.l #efface1lst,codecurefface
  99.     move.l log,d0
  100.     move.l d0,codelog
  101.     jsr convsinus
  102.     jmp main
  103. effaceallbob
  104.     move.l codelog,d1
  105.     move.l codecurefface,a4
  106.     move.w #nbbob-1,d6
  107.     moveq #0,d0
  108. .clear
  109.     move.w (a4)+,d1
  110.     move.l d1,a0
  111.     move.l (a4)+,a5
  112.     jsr (a5)
  113.     dbf d6,.clear
  114.     rts
  115.  
  116.     jsr waitvbl
  117. main
  118.     tst.w flagtransition
  119.     beq.s .11
  120.     jsr transfo1
  121. .11
  122.     move.l ptrscr1,d0
  123.  
  124.     add.l #160*16,d0
  125.  
  126.     lsr.w #8,d0
  127.     move.l d0,$ffff8200.w
  128.  
  129.     move.l #efface1lst,codecurefface
  130.     move.l ptrscr1,d0
  131.     move.l d0,codelog
  132.     move.l ptrscr1,log
  133.     jsr effaceallbob
  134.     jsr majAngle
  135.     jsr calcAllPos
  136.    
  137.     jsr waitvbl
  138.     tst.w flagtransition
  139.     beq.s .12
  140.     jsr transfo1
  141. .12
  142.  
  143.     move.l ptrscr2,d0
  144.  
  145.     add.l #160*16,d0
  146.     lsr.w #8,d0
  147.     move.l d0,$ffff8200.w
  148.  
  149.     move.l #efface2lst,codecurefface
  150.     move.l ptrscr2,d0
  151.     move.l d0,codelog
  152.     move.l ptrscr2,log
  153.  
  154.    
  155.     jsr effaceallbob
  156.     jsr majAngle
  157.     jsr calcAllPos
  158.     jsr waitvbl
  159.  
  160.     cmp.b #$b9,$fffffc02.w
  161.     beq.s .fin
  162.     jmp main
  163. .fin
  164.  
  165.     bsr waitvbl
  166.     move.l $44e.w,d0
  167.     lsr.w #8,d0
  168.     move.l d0,$ffff8200.w
  169.     bsr waitvbl
  170.     move.l $44e.w,d0  
  171.     move.w #1,-(sp)
  172.     move.l d0,-(sp)
  173.     move.l d0,-(sp)
  174.    move.w #5,-(sp)
  175.     trap #14
  176. ;
  177.     lea 12(sp),sp
  178.  
  179.    
  180.     jsr mjj_sys_fini   
  181.  
  182.     clr.w -(sp)
  183.     trap #1
  184.  
  185. initcleartozerozero
  186.     moveq #0,d0
  187.     move.l codeeffliste,d4
  188.     lea ptrlsteff,a2
  189.     moveq #2-1,d7
  190. xx4
  191.     move.w #nbbob-1,d6
  192.     move.l (a2)+,a3
  193. .clearall
  194.     move.w d0,(a3)+
  195.     move.l d4,(a3)+
  196.     dbf d6,.clearall
  197.  
  198.     dbf d7,xx4
  199.     rts
  200.  
  201.  
  202. majangle
  203.     lea ajoutangle,a0
  204.     lea angles,a1
  205.     moveq #3,d7
  206. .loop
  207.     move.w (a0)+,d0
  208.     move.w (a1),d1
  209.     add d0,d1
  210.     and.w #511,d1
  211.     move.w d1,(a1)+
  212.     dbf d7,.loop
  213.  
  214.     rts
  215.  
  216. convsinus
  217.     move.l sinx1,a1
  218.     move.l sinx2,a2
  219.     move.l sin512,a0
  220.     move.w #511,d0
  221.     move.w ptrconvX+2,d4
  222. .loop
  223.     moveq #0,d1
  224.     move.w (a0)+,d1
  225.     add.w #32767,d1
  226.  
  227.     move.l d1,d2
  228.     mulu #(160-8)*subpixel2,d1
  229.     mulu #(140-8)*subpixel2,d2   ; 8 subpixel
  230.     ;asl #1,d1
  231.     ;asl #1,d2
  232.     swap d1
  233.     add.w #5*subpixel2,d1   ; additionner 5 pixel a x
  234.     swap d2
  235. ; *10 = *8+*2 = *2(*4+1)
  236.  
  237.     add d1,d1
  238.     move.w d1,d3
  239.     add.w d3,d3 *4
  240.     add.w d3,d3
  241.     add d3,d1   ; d1 = d1 * 10
  242. ;   and.w #-4,d1
  243.  
  244. ;   and.w #-4,d2
  245.  
  246.     add d2,d2
  247.     move.w d2,d3
  248.     add d3,d3
  249.     add d3,d3
  250.     add d3,d2
  251.  
  252.     add d4,d1               ; premiere table de sinus, on ajoute l'offset de convX
  253.     move.w d1,(a1)+
  254.     move.w d2,(a2)+
  255.     dbf d0,.loop
  256.    
  257.  
  258.     move.w ptrConvY+2,d4
  259.     add.w #216*subpixel2*2,d4
  260.     move.l siny1,a1
  261.     move.l siny2,a2
  262.     move.l sin512,a0
  263.     move.w #511,d0
  264. .loopy
  265.     moveq #0,d1
  266.     move.w (a0)+,d1
  267.     add.w #32767,d1
  268.     move.l d1,d2
  269.     mulu #(80-8)*subpixel2*2,d1
  270.     mulu #(119-8)*subpixel2*2,d2
  271. ;   asl #1,d1
  272. ;   asl #1,d2
  273.     swap d1
  274.     swap d2
  275.     and.w #-2,d1
  276.     and.w #-2,d2
  277.     add d4,d1           ; ajoute l'offset segment
  278.     move.w d1,(a1)+
  279.     move.w d2,(a2)+
  280.     dbf d0,.loopy
  281.  
  282.  
  283. ; createContigustable
  284. ;
  285. ; a0 = ram
  286. ; d0 = nombre d'element de la table sinus
  287. ; d1 = pas interne
  288. ; d2 = nombre de copie de valeurs
  289. ; a3 = table de sinus d'amplitude final
  290. ;
  291. ; pendant le fonctionnement:
  292. ; constante  d3,d4,d5 = pas interne,*2,*4
  293. ;
  294. ;
  295. ;
  296.  
  297. ; retour:
  298. ; a0 = ram
  299. ; a1 = adresse table de d0 adresses  reftable pris a partir de la ram
  300. ;  
  301.  
  302. totoisback
  303.     move.l parametreInternStep,a6       ; le seul registre dispo
  304. .automodif
  305.     lea ram3,a0
  306.     move.w #512,d0
  307.     move.w #nbbob,d2 ; nombre de copie de valeur
  308.     move.w (a6)+,d1
  309.     ;move.w #512-13,d1      ; pas interne 5 /512
  310.     move.l sinx1,a3
  311.     jsr createContigustable
  312. .auto1  move.l a1,ptrref1
  313.  
  314.     move.w #512,d0
  315.     move.w (a6)+,d1
  316.     ;move.w #14,d1
  317.     move.w #nbbob,d2
  318.     move.l sinx2,a3
  319.     jsr createContigustable
  320. .auto2  move.l a1,ptrref2
  321.  
  322.     move.w #512,d0
  323.     move.w (a6)+,d1
  324.     ;move.w #512-16,d1
  325.     move.w #nbbob,d2
  326.     move.l siny1,a3
  327.     jsr createContigustable
  328. .auto3  move.l a1,ptrref3
  329.  
  330.     move.w #512,d0
  331.     ;   move.w #19,d1
  332.     move.w (a6)+,d1
  333.     move.w #nbbob,d2
  334.     move.l siny2,a3
  335.     jsr createContigustable
  336. .auto4  move.l a1,ptrref4
  337.  
  338.  
  339.     lea ajoutangle,a5
  340.     move.w (a6)+,(a5)+
  341.     move.w (a6)+,(a5)+
  342.     move.w (a6)+,(a5)+
  343.     move.w (a6)+,(a5)+
  344.     lea angles,a5
  345.     move.w #128,(a5)+
  346.     move.w #128,(a5)+
  347.     move.w #0,(a5)+
  348.     move.w #0,(a5)
  349.  
  350.     move.l a6,parametreInternStep
  351.     move.l (a6),d0
  352. tstt    cmp.l #$31415926,d0
  353.     bne.s .nolooop
  354.     move.l #fct,d0
  355.     move.l d0,parametreInternStep
  356. .nolooop
  357.  
  358. ;   lea .automodif+2,a0
  359. ;   move.l (a0),d0
  360. ;   cmp.l #ram3,d0
  361. ;   beq.s .modif1
  362. ;   move.l #ram3,(a0)
  363. ;   move.l #ptrref1,d1
  364. ;   move.l d1,.auto1+2
  365. ;   move.l #ptrref2,d1
  366. ;   move.l d1,.auto2+2
  367. ;   move.l #ptrref3,d1
  368. ;   move.l d1,.auto3+2
  369. ;   move.l #ptrref4,d1
  370. ;   move.l d1,.auto4+2
  371. ;
  372.     rts
  373. ;.modif1
  374. ;   move.l ptrscr3,d1   64k libre
  375. ;;  move.l d1,(a0)
  376. ;
  377. ;   move.l #ptrref5,d1
  378. ;   move.l d1,.auto1+2
  379. ;   move.l #ptrref6,d1
  380. ;   move.l d1,.auto2+2
  381. ;   move.l #ptrref7,d1
  382. ;   move.l d1,.auto3+2
  383. ;   move.l #ptrref8,d1
  384. ;   move.l d1,.auto4+2
  385. ;  
  386. ;   rts
  387.  
  388. parametreInternStep dc.l fct
  389.  
  390. fct dc.w 512-13,14,512-16,11
  391.        dc.w 3,4,7,6
  392.     dc.w 4,11,512-12,3
  393.        dc.w 9,512-13,17,6
  394.     dc.w 10,512-19,5,512-15
  395.        dc.w 2,4,1,3
  396.     dc.w 10,2,30,4
  397.        dc.w 4,9,5,8
  398.     dc.w 5,15,10,512-6
  399.        dc.w 10,9,11,7
  400.     dc.l $31415926
  401.  
  402.  
  403.  
  404. changefct
  405.     jmp totoisback
  406.     ; swap ptrref1..4 to ptrref5..8
  407. ;   lea ptrref1,a0
  408. ;   movem.l (a0),d0-d3
  409. ;   lea ptrref5,a1
  410. ;   movem.l (a1),d4-d7
  411. ;   movem.l d0-d3,(a1)
  412. ;   movem.l d4-d7,(a0)
  413. ;  
  414.     ;; to be continued
  415.        
  416.     ;rts
  417.  
  418.  
  419. ;superhackitVBL:            ; remplace it 70.w
  420. ;   addq.l #1,$466.w
  421. ;   movem.l d0-d7/a0-a6,-(sp)
  422. ;   lea (8+7)*4+2(sp),a0
  423. ;   move.l (a0),d0      ; adresse de retour de l'interuption
  424. ;   cmp.l #waitvbl,d0    d0-waitvbl>0   d0>waitvbl
  425. ;   bge.s .suitedutest
  426. ;  
  427. ;   jsr savejob
  428. ;
  429. ;   jmp .noprecalc
  430. ;.suitedutest
  431. ;   cmp.l #finwaitvbl,d0  d0-fin<0 d0<fin   ; en fait metre toute les routine
  432. ;                       ; qui calcul entre 2 adresse
  433. ;   bge.s .noprecalc   
  434. ;          
  435. ;   jsr savejob
  436. ;
  437. ;.noprecalc
  438. ;   movem.l (sp)+,d0-d7/a0-a6
  439. ;   rte
  440. ;savejob    move.l (a0),actualjob
  441. ;  
  442. ;
  443. calcAllpos
  444.     move.l ptrref1,a5
  445.     move.l ptrref2,a1
  446.     move.w ang1,d0
  447.     add d0,d0
  448.     add d0,d0
  449.     add.w d0,a5
  450.     move.w ang2,d0
  451.     add d0,d0
  452.     add.w d0,d0
  453.     add.w d0,a1
  454.  
  455.     move.l ptrref3,a2
  456.     move.l ptrref4,a3
  457.     move.w ang3,d0
  458.     add d0,d0
  459.     add d0,d0
  460.     add d0,a2
  461.     move.w ang4,d0
  462.     add d0,d0
  463.     add d0,d0
  464.     add d0,a3
  465.  
  466.     move.l (a5),a5
  467.     move.l (a1),a1
  468.     move.l (a2),a2
  469.     move.l (a3),a3
  470.  
  471.     move.l codecurefface,a4
  472.  
  473.     move.l ptrConvX,d0
  474.     move.l ptrConvY,d1
  475.     move.l log,d3
  476.  
  477.     move.w #nbbob-1,d2
  478.    
  479.     moveq #0,d4
  480.     move.w seuil,d5
  481. .loopcalcul
  482.  
  483.     move.w d5,d0
  484.     add.w (a2)+,d0
  485.     add.w (a3)+,d0
  486.  
  487.     move.l d0,a6
  488.     move.w (a6),d3          ;  y*160
  489.  
  490.     move.w (a5)+,d0
  491.     add.w (a1)+,d0
  492.  
  493.     move.l d0,a6
  494.     add.w (a6)+,d3
  495.     move.w d3,(a4)+         ; effacement offset
  496.     move.l (a6)+,(a4)+      ; routine d'effacement
  497.  
  498.     move.l (a6),a6          ; routine d'affichage
  499.     move.l d3,a0
  500.  
  501.     jsr (a6)
  502.     dbf d2,.loopcalcul
  503.  
  504.    
  505.     lea ang1,a0
  506.     lea 8(a0),a1
  507.     movem.w (a1),d0-d3
  508.  
  509.     move.w (a0),d4
  510.     add.w d0,d4
  511.     move.w #511,d5
  512.     and d5,d4
  513.     move.w d4,(a0)+
  514.  
  515.     move.w (a0),d4
  516.     add.w d1,d4
  517.     and d5,d4
  518.     move.w d4,(a0)+
  519.  
  520.     move.w (a0),d4
  521.     add.w d2,d4
  522.     and d5,d4
  523.     move.w d4,(a0)+
  524.  
  525.     move.w (a0),d4
  526.     add.w d3,d4
  527.     and d5,d4
  528.     move.w d4,(a0)+
  529. ; maj angle fait
  530.  
  531.     rts
  532.  
  533. prepare_segments
  534.    
  535.     move.l #screenbuf,d0
  536.     moveq #2,d1
  537.     swap d1
  538.     jsr getmem1                 ; prepare 16 zone memoire allant de 32768 a 1 octet (puissance de 2)
  539.  
  540.     lea ptrMem,a0
  541.     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  
  542.  
  543. ;   move.l d3,sinX1         ; sinx1 x2 y1 y2 devenu des pointeur sur
  544.                             ; 512 word
  545. ;   move.l #1024,d5
  546. ;   add.l d5,d3
  547. ;   move.l d3,sinX2
  548. ;   add.l d5,d3
  549. ;   move.l d3,sinY1
  550. ;   add.l d5,d3
  551. ;   move.l d3,sinY2                 ; place pour 4k = 4 table de 512 word
  552.  
  553.  
  554.                                 ; cad poid fort de l'adresse du buffer est toujours a la meme valeur
  555.     move.l d0,ptrConvY          ; 32k alloué pour convy: 1856*2 en comptant cliping haut bas de 16 pixel de hauteur et 4 subpixel
  556.     add.l #2*subpixel2*400,d0
  557.     ; 30912 octet libre
  558.     move.l d0,ptrConvX  ; 12800 octet pour 320 pixel 4 subpixel 10 octet (adresseEFF,adresseAFF,offset)
  559.     add.l #320*subpixel2*10,d0      ; pile poil 4 subpixel  convy 232*8 subpixel*2 + 352*8 subpixel*10 octet
  560.     moveq #0,d4                 ; 31872 octet sur 32768
  561.     move.w #1024,d4
  562.     lea sinx1,a1
  563.     move.l d0,(a1)+
  564.     add.l d4,d0
  565.     move.l d0,(a1)+
  566.     add.l d4,d0
  567.     move.l d0,(a1)+
  568.     add.l d4,d0
  569.     move.l d0,(a1)+
  570.     add.l d4,d0
  571.     move.l d0,flagtab  
  572.  
  573.     move.l d1,ptr16k
  574.     move.l d2,ptrFlag           ; 8k max pour les flag, sinus dont le nombre d'element ne depasse pas 8192
  575.     move.l d3,ptr4k
  576.  
  577.     lea ptrMem+4*4,a0
  578.     movem.l (a0)+,d0-d3
  579.     move.l d0,ptrvariable
  580.     move.l d1,sin512
  581.    
  582.    
  583.  
  584.     move.l #screenbuf,d0
  585.     moveq #1,d1
  586.     swap d1
  587.     clr.w d0
  588.     move.l d0,log
  589.     move.l d0,ptrscr1
  590.     add.l d1,d0
  591.     move.l d0,phys
  592.     move.l d0,ptrscr2
  593.     add.l d1,d0
  594.     move.l d0,ptrscr3
  595.     add.l d1,d0
  596.     move.l d0,ptrscr4
  597.  
  598. ;   add.l d1,d0
  599. ;   move.l d0,convX
  600. ;   add.l #320*subpixel*8,d0
  601. ;   add.l d1,d0
  602. ;   move.l d0,convY
  603.  
  604.     rts
  605. timer1  dc.w 700
  606. waitvbl
  607.     subq.w #1,timer1
  608.     tst.w timer1
  609.     bne.s .titi
  610.     move.w #700,timer1
  611.     move.w #1,flagtransition
  612.    
  613.    
  614. .titi
  615.     ifne tempmachine
  616.     not.w $ffff8240.w
  617.     rept 60
  618.     nop
  619.     endr
  620.     not.w $ffff8240.w
  621.     endc
  622.  
  623.     move.w $468.w,d0
  624. .loop   cmp.w $468.w,d0
  625.     beq.s .loop
  626.     rts
  627. nowaitvbl
  628. swap_screen
  629.     move.l log,d0
  630.     move.l phys,d1
  631.     move.l d0,phys
  632.     move.l d1,log
  633.  
  634.     add.l #16*160,d1
  635.    
  636.     lsr.w #8,d1
  637.     move.l d1,$ffff8200.w
  638.     rts
  639.  
  640. extractsprite
  641.  
  642.     ifne spr_pi1
  643.  
  644.         lea pi1+2,a0
  645.         movem.w (a0),d0-d3
  646.         movem.w d0-d3,$ffff8240.w
  647.         lea pi1+34,a0  
  648.    
  649.         lea spritedeca,a1
  650.         moveq #0,d1
  651.         moveq #15,d7
  652. .loop0
  653.         move.l (a0),d0
  654.         lea 160(a0),a0
  655.         move.l d0,(a1)+
  656.         move.l d1,(a1)+
  657.         dbf d7,.loop0
  658.     endc
  659.  
  660.     ifeq spr_pi1
  661.         lea pal_and_sprite,a0
  662.         movem.w (a0)+,d0-d3
  663.         movem.w d0-d3,$ffff8240.w
  664.         lea spritedeca,a1
  665.         moveq #0,d1
  666.         moveq #15,d7
  667. .loop000
  668.         move.l (a0)+,d0
  669.         move.l d0,(a1)+
  670.         move.l d1,(a1)+
  671.         dbf d7,.loop000
  672.     endc
  673.    
  674.  
  675.     moveq #14,d7
  676.     lea spritedeca,a1
  677.     move.l a1,a3
  678.     lea 128(a1),a2
  679.     move.l a2,a4
  680. .copyandshift
  681.     move.w #15,d6
  682. .ligne
  683.     MOVE.L (A1)+,(A2)+
  684.     MOVE.L (A1)+,(A2)+
  685.     LEA -8(A2),A2
  686.     MOVE.B #0,CCR
  687.     ROXR (A2)
  688.     ROXR 4(A2)
  689.     MOVE.B #0,CCR
  690.     ROXR 2(A2)
  691.     ROXR 6(a2)
  692.  
  693.     lea 8(a2),a2
  694.     dbf d6,.ligne
  695.     lea 128(a3),a3
  696.     lea 128(a4),a4
  697.     move.l a3,a1
  698.     move.l a4,a2
  699.  
  700. ;   lea 4(a2),a2
  701. ;   lea 4(a1),a1
  702.     dbf d7,.copyandshift
  703.    
  704. makecodegen
  705.     lea spritedeca,a0
  706.     lea ram,a1
  707.     lea codegenliste,a2
  708.     lea codeeffliste,a3
  709.     lea ram2,a4
  710.     moveq #15,d0
  711. .loopSprite
  712.     move.l a4,(a3)+
  713.     move.l a1,(a2)+
  714.     moveq #15,d1
  715.     moveq #0,d6     ; offset
  716. .loopligne
  717.     move.w (a0)+,d2
  718.     move.w (a0)+,d3
  719.     move.w (a0)+,d4
  720.     move.w (a0)+,d5
  721.     tst.w d2
  722.     bne.s .1
  723.     tst.w d3
  724.     beq.s .nerienfaire
  725.     ; or.w #d3,offset+2(a0)
  726.     move.w d3,d7
  727.     addq #2,d6
  728.     bsr orwd7d6_2
  729.     subq #2,d6
  730.    
  731.  
  732.  
  733.     bra.s .suite
  734. .1  ; d2 contient kekchose
  735.     tst.w d3
  736.     beq.s .wordd2
  737.     ; or.l #d2d3,offset(a0)
  738.     move.w d2,d7
  739.     swap d7
  740.     move.w d3,d7
  741.     bsr orld7d6
  742.     bra.s .suite
  743. .wordd2
  744.     ; or.w #d2,offset(a0)
  745.     move.w d2,d7
  746.     bsr orwd7d6
  747.     bra.s .suite
  748. .nerienfaire
  749.     nop
  750. .suite
  751.     tst.w d4
  752.     bne.s .2
  753.     tst.w d5
  754.     beq.s .nerienfaire2
  755.     ; or.w #d5,offset+8+2(a0)
  756.     move.w d5,d7
  757.     add.w #10,d6
  758.     bsr orwd7d6
  759.     sub.w #10,d6
  760.  
  761.  
  762.     bra.s .suite2  
  763. .2  tst.w d5
  764.     beq.s .wordd4
  765.     ; or.l #d4d5,offset+8(a0)
  766.     move.w d4,d7
  767.     swap d7
  768.     move.w d5,d7
  769.     addq.w #8,d6
  770.     bsr orld7d6
  771.     subq #8,d6
  772.  
  773.     bra.s .suite2
  774. .wordd4
  775.     ; or.w #d4,offset+8(a0)
  776.     move.w d4,d7
  777.     addq #8,d6
  778.     bsr orwd7d6
  779.     subq #8,d6
  780.     bra.s .suite2
  781. .nerienfaire2
  782.     nop
  783. .suite2
  784.     add #160,d6
  785.     dbf d1,.loopligne
  786.     move.w #$4e75,(a1)+
  787.     move.w #$4e75,(a4)+
  788.     dbf d0,.loopSprite
  789.     rts
  790. orwd7d6
  791. ;   move.l d2,-(sp)
  792.     move.w d7,d2   ; plus besoin de d2
  793.     swap d2
  794.     move.w d7,d2
  795.     not.l d2
  796.  
  797.     tst.w d2
  798.     beq.s .move
  799.  
  800.     ; and.l d2,d6(a0)   02a8
  801.  
  802.     move.w #$02a8,(a1)+     ; + 8 octet au code genere
  803.     move.l d2,(a1)+
  804.     move.w d6,(a1)+
  805.     bra.s .aa
  806. .move   move.w #$2144,(a1)+
  807.     move.w d6,(a1)+
  808. .aa
  809.     move.w #$68,(a1)+
  810.     move.w d7,(a1)+
  811.     move.w d6,(a1)+
  812.  
  813.     move.w #$2140,(a4)+     ; since it's masked on 2 plan, the clearing is long instead of word
  814.  
  815.     move.w d6,(A4)+         ; ($2140 instead of $3140) (move.l d0,d6(a0) instead of move.w d0,d6(a0))
  816.  
  817. ;   move.l (sp)+,d2
  818.     rts
  819. orwd7d6_2                   ; cas ou orwd7d6 mais sur le deuxieme plan, l'effacement se fait naturellement sur le premier plan
  820. ;   move.l d2,-(sp)
  821.     move.w d7,d2   ; plus besoin de d2
  822.     swap d2
  823.     move.w d7,d2
  824.     not.l d2
  825.     tst.w d2
  826.     beq.s .move
  827.     ; and.l d2,d6(a0)   02a8
  828.  
  829.     move.w #$02a8,(a1)+     ; + 8 octet au code genere
  830.     move.l d2,(a1)+
  831.     move.w d6,(a1)
  832.     subq.w #2,(a1)+
  833.     bra.s .aa
  834.  
  835. .move   move.w #$2144,(a1)+
  836.     move.w d6,(a1)
  837.     subq.w #2,(a1)+
  838.  
  839.  
  840. .aa
  841.     move.w #$68,(a1)+
  842.     move.w d7,(a1)+
  843.     move.w d6,(a1)+
  844.  
  845.     move.w #$2140,(a4)+     ; since it's masked on 2 plan, the clearing is long instead of word
  846.  
  847.     move.w d6,(A4)          ; ($2140 instead of $3140) (move.l d0,d6(a0) instead of move.w d0,d6(a0))
  848.     subq.w #2,(a4)+         ; on and.l sur le plan 0 et 1 et pas 1 et 2
  849. ;   move.l (sp)+,d2
  850.     rts
  851. orld7d6
  852.     ; d7 = le data sur 2 plan
  853.     ;
  854.  
  855. ;   move.l d2,-(sp)
  856. ;   move.l d3,-(sp)
  857.     move.w d7,d2
  858.     swap d7
  859.     or.w d7,d2
  860.     swap d7     ; remet d7 a la bonne valeur
  861.     not.w d2
  862.     move.w d2,d3
  863.     swap d2
  864.     move.w d3,d2
  865.     ; d2.l = masque a partir des 2 valeur poid fort poid faible de d7
  866.  
  867.     tst.l d2
  868.     bne.s .aa
  869.  
  870.     ; and.l #0 remplacer par un move.l d4,dep(a0)
  871.     move.w #$2144,(a1)+
  872.     move.w d6,(a1)+
  873.  
  874.     bra.s .bb
  875. .aa
  876.     move.w #$02a8,(a1)+
  877.     move.l d2,(a1)+
  878.     move.w d6,(a1)+
  879.                     ; + 8 octets
  880. .bb
  881.     move.w #$A8,(a1)+
  882.     move.l d7,(a1)+
  883.     move.w d6,(a1)+
  884.  
  885.     move.w #$2140,(a4)+
  886.     move.w d6,(a4)+
  887.  
  888. ;   ;move.l (sp)+,d3
  889. ;   move.l (sp)+,d2
  890.  
  891.     rts
  892.  
  893. cpttransfo  dc.w 200/2-1
  894. steptransfo dc.w -subpixel2*2*2
  895. transfo1
  896.     move.w steptransfo,d0
  897.     add.w d0,seuil
  898.     subq.w #1,cpttransfo
  899.     tst cpttransfo
  900.     bne.s .ok
  901.     tst.w steptransfo
  902.     bpl.s .stoptransition
  903.     move.w #200/2-1,cpttransfo
  904.     neg.w steptransfo
  905.     jsr changefct
  906.     rts
  907.    
  908. .stoptransition
  909.     neg.w steptransfo
  910.     move.w #200/2-1,cpttransfo
  911.     move.w #700,timer1
  912.     move.w #0,flagtransition
  913. .ok rts
  914.  
  915. flagtransition  dc.w 0
  916. createContigustable
  917. ;
  918. ; a0 = ram
  919. ; d0 = nombre d'element de la table sinus
  920. ; d1 = pas interne
  921. ; d2 = nombre de copie de valeurs
  922. ; a3 = table de sinus d'amplitude final
  923. ;
  924. ; pendant le fonctionnement:
  925. ; constante  d3,d4,d5 = pas interne,*2,*4
  926. ;
  927. ;
  928. ;
  929.  
  930. ; retour:
  931. ; a0 = ram
  932. ; a1 = adresse table de d0 adresses  reftable pris a partir de la ram
  933. ;  
  934.  
  935.     ;movem.l d0-d3/a0-a6,-(sp)
  936.    
  937.     move.l flagtab,a2
  938.     moveq #0,d3
  939.     move.l d3,(a2)+
  940.     move.l d3,(a2)+
  941.     lea 512-8(a2),a2
  942.     move.l d3,a4
  943.     move.l d3,a5
  944.     move.l d3,d4
  945.     move.l d3,d5
  946.     move.l d3,d6
  947.     move.l d3,d7
  948.  
  949.     rept 18
  950.     movem.l d3-d7/a4/a5,-(a2)   7 registre *4 = 28 octet 512/36=12 reste 8 octet
  951.     endr
  952.     SUBQ #8,a2          ; 36*14=504  512-504=8
  953.  
  954.  
  955.     move.l a0,a1        ; a1 = table refsin
  956.     move.l a1,-(sp)
  957.     move.w d0,d3
  958.     add.w d3,d3     ; *2
  959.     move.l a3,a4
  960.     add.w d3,a4
  961.     add.w d3,d3     ; *4
  962.     add.w d3,a0         ; a0 =ram
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.     ;move.l flagtab,a2
  975.     move.l a2,a5
  976.     add.w d0,a5
  977.    
  978.  
  979.  
  980.     moveq #0,d5         ; angle
  981.    
  982.     move.w d1,d3        ; pas interne<>0
  983.     move.w d3,d4
  984.     add d4,d4           ; pas interne*2
  985.     move.w d4,d5
  986.     add.w d5,d5         ; pas interne*4
  987.     neg.w d0
  988.     move.w d0,.auto1+2          ; nombre d'elements
  989.     move.w d0,.auto1b+2
  990.     add.w d0,d0
  991.     move.w d0,.auto2+2
  992.     move.w d0,.auto2b+2
  993.     move.w d0,.auto2c+2
  994.     add.w d0,d0
  995.     move.w d0,.auto3+2
  996.     move.w d0,.auto3b+2
  997. ;----------------------------------------
  998.     bra.s .loop
  999. .loopaddq
  1000.     addq.w #2,a3
  1001.     addq.w #4,a1
  1002.     ; ps le tst.b (a2) deux ligne plus loin est redondant quand on sort de la boucle dans le code flaga1
  1003.     move.w (a3),d7
  1004.     bra.s .11
  1005. .loop
  1006.     move.w (a3),d7
  1007.     tst.b (a2)
  1008.     bne.s .flaga1
  1009. .11 st.b (a2)
  1010.     move.l a0,(a1)      ; on stoque l'adresse de la valeur dans table refsin
  1011.     move.w d7,(a0)+
  1012.     ; on met a jour a3 avec le pas interne*2
  1013.     ; on met a jour a2 avec le pas interne (flags)
  1014.     add.w d3,a2
  1015.     add.w d4,a3
  1016.     add.w d5,a1
  1017.  
  1018.     cmp.l a2,a5
  1019.     bgt.s .loop
  1020. .auto1
  1021.     lea 0(a2),a2
  1022. .auto2
  1023.     lea 0(a3),a3
  1024. .auto3
  1025.     lea 0(a1),a1
  1026.     bra.s .loop
  1027. .flaga1
  1028.     move.w d2,d6        ; nombre de coPIE
  1029.     subq.w #1,d6
  1030.     ;addq.w #1,d6
  1031.  
  1032.     move.l a3,-(sp)
  1033. .cpy
  1034.     move.w d7,(a0)+
  1035.     add.w d4,a3
  1036.     cmp.l a3,a4
  1037.     bgt.s .1
  1038. .auto2b
  1039.     lea 0(a3),a3
  1040.  
  1041. .1
  1042.     move.w (a3),d7
  1043.     dbf d6,.cpy
  1044.     move.l (sp)+,a3
  1045.  
  1046.     addq.w #1,a2
  1047.     cmp.l a2,a5
  1048.     bgt.s .2
  1049. .auto1b
  1050.     lea 0(a2),a2
  1051. .auto2c
  1052.     lea 0(a3),a3
  1053. .auto3b
  1054.     lea 0(a1),a1
  1055. .2
  1056.     ; s'assurer qu'on est pas en fin de tableau:
  1057.     ;
  1058.     ;
  1059.  
  1060.     tst.b (a2)
  1061.     beq.s .loopaddq
  1062. .fin
  1063.     move.l (sp)+,a1
  1064.  
  1065.     rts
  1066.  
  1067. ; depack periodictable
  1068. ; a0 = packed data
  1069. ; a1 = unpacked data
  1070. depackperiod
  1071.     lea extnibble,a2
  1072.  
  1073.     move.w (a0)+,d0     ; nombre d'element de la table finale
  1074.     move.w (a0)+,d1     ; tab[0]
  1075.     move.w (a0)+,d2     ; delta[0]=tab[1]-tab[0]
  1076.     move.w d0,d3
  1077.     subq #2,d3      ; nombre de delta de delta: delta2[0]=delta[1]-delta[0]
  1078.     lsr #1,d3
  1079. .ok
  1080.     subq #1,d3
  1081.     ;bset #0,d3         ; si paire = nb impair d'element on set a +1
  1082.                         ; si impair  nb pair d'lement on ne change rien
  1083.     move.w d1,(a1)+     ; tab[0]
  1084.    
  1085. .loop
  1086.     add d2,d1           ; tab[0]+delta[0]=tab[1]
  1087.     move.w d1,(a1)+
  1088.    
  1089.     move.b (a0)+,d4      lire 2 valeur
  1090.     move.w d4,d5
  1091.     and.w #$F0,d4
  1092.     lsr #4,d4
  1093.     move.b (a2,d4.w),d4
  1094.     ext.w d4
  1095.     add d4,d2           : delta2[0]=delta[1]-delta[0]  d2= delta[1]=tab[2]-tab[1]
  1096.    
  1097.     add d2,d1
  1098.     move.w d1,(a1)+
  1099.     and.w #$F,d5
  1100.     move.b (a2,d5.w),d5
  1101.     ext.w d5
  1102.     add d5,d2
  1103.  
  1104.     dbf d3,.loop
  1105.     add d2,d1
  1106.     move.w d1,(a1)+
  1107.     rts
  1108.  
  1109. ;
  1110. ;
  1111. ;
  1112. ; mem lib
  1113. ;
  1114.  
  1115. ;; exemple d'utilisation
  1116. ;   move.l #buffer,d0
  1117. ;   move.l #8*65536,d1 taille totale du buffer aligné sur 64k
  1118. ;   jsr getmem1
  1119. ;   lea -16*4(a0),a0
  1120. ;   nop
  1121. ;   nop
  1122. ;   nop
  1123. ;   nop
  1124. ;   illegal
  1125. ; format de memoire
  1126. ;toto           ; le label toto est la pour verifier l'algo
  1127. ;   ds.b 65536 
  1128. ;buffer ds.l 65536*2    8*64k               ; buffer sera aligné sur 64k donc un peu avant
  1129. ;fin                                            ; et apres un peu de memoire libre entre fin buffer et label fin
  1130.  
  1131. ; warning ! extremely bugged edition of getmem1 ! (i must add 128k of unused ram)
  1132. ;
  1133. getmem1:
  1134.  
  1135. ; d0 = adresse segment 64k non aligné
  1136. ; d1 = nombre de segment a la suite*64k
  1137. ; retour: a0 = liste d'adresse
  1138. ; (a0)+ = 32k buffer
  1139. ; (a0)+ = 16k buffer
  1140. ; (a0)+ = 8k buffer
  1141. ; (a0)+ = 4k buffer
  1142. ; (a0)+ = 2k
  1143. ; (a0)+ = 1k
  1144. ; (a0)+ = 512
  1145. ; (a0)+ = 256
  1146. ; (a0)+ = 128
  1147. ; (a0)+ = 64 octet
  1148. ;
  1149. ; a0: 64 octet = 16 adresses
  1150.  
  1151.     ; metre le buffer start dans d4
  1152.  
  1153.     moveq.w #1,d5
  1154.     swap d5
  1155.     move.l d0,d4
  1156.     sub.l d5,d4     ; start memoire basse
  1157.    
  1158.     move.l d0,d3
  1159.     clr.w d3        ;  debut multiple de 64k  fin memoire basse
  1160.     ; d3 = start segment
  1161.    
  1162.    
  1163.     move.l d4,d7
  1164.     sub.l d3,d7     ; d7 = taille en bas
  1165.    
  1166.    
  1167.     add.l d1,d3     ; d3+ 4*64k = adresse start haut
  1168.  
  1169.  
  1170.    
  1171.     lea ptrMem,a0
  1172.     moveq #0,d6
  1173.     move.w #$8000,d6
  1174.    
  1175. .loop
  1176.     move.w d6,d1
  1177.     and.w d7,d1
  1178.  
  1179.     ; bit 15 a 0 ?
  1180.     tst.w d1
  1181.     beq.s .before           ; was beq
  1182.     move.l d3,(a0)+
  1183.     add.l d6,d3
  1184.    
  1185.     bra.s .suite
  1186. .before
  1187.     move.l d4,(a0)+
  1188.     add.l d6,d4
  1189. .suite
  1190.     lsr.w #1,d6
  1191.     tst.w d6
  1192.     bne.s .loop         ; ici ca s'arrete a un buffer de 1 octet il faudrai faire un meilleur test
  1193.    
  1194.     lea -64(a0),a0                  ; et s'arreter a un plus gros buffer
  1195.     rts
  1196.        
  1197. extnibble   dc.b 0,1,2,3,4,5,6,7,$F8,$f9,$fa,$fb,$fc,$fd,$fe,$ff
  1198.     even
  1199.  
  1200.     include 'BASEROU2.S'
  1201.    
  1202.  
  1203.  
  1204.     DATA
  1205. codelog dc.l 0
  1206. cptdeca dc.w 0
  1207. angles  dc.w 128,128,50,70
  1208. ajoutangle  dc.w 6+256,23,512-12,7+256
  1209. ptrlsteff   dc.l efface1lst
  1210.             dc.l efface2lst
  1211.             ;dc.l efface3lst
  1212.             ;dc.l efface4lst
  1213.  
  1214. ang1    dc.w 128
  1215. ang2    dc.w 128
  1216. ang3    dc.w 10
  1217. ang4    dc.w 0
  1218. ajoutang1   dc.w 4
  1219. ajoutang2   dc.w 1
  1220. ajoutang3   dc.w 512-3
  1221. ajoutang4  dc.w 1
  1222.    
  1223. packed_sinus_table:
  1224.    
  1225. sin1pack
  1226.    dc.w 512  ; nombre d'element depack
  1227.     dc.w 0
  1228.     dc.w 402
  1229.  
  1230.     dc.b      0,241,240,240,240,240,224,255,254,14,13,14,254,239,238,253
  1231.     dc.b      253,253,239,207,221,252,238,206,222,206,206,205,221,220,220,235
  1232.     dc.b      221,204,205,204,205,189,189,189,188,203,219,203,203,218,204,188
  1233.     dc.b      187,203,203,187,202,218,188,187,187,202,203,187,187,187,202,202
  1234.     dc.b      202,203,187,187,187,202,203,187,188,186,218,203,187,203,203,188
  1235.     dc.b      188,202,219,203,203,219,204,189,189,189,189,204,205,204,205,219
  1236.     dc.b      236,220,221,221,206,206,206,222,206,236,253,223,207,237,253,253
  1237.     dc.b      254,239,238,254,13,14,14,255,240,224,240,240,240,241,240,0
  1238.     dc.b      0,31,16,16,16,16,32,17,18,2,3,2,18,33,34,19
  1239.     dc.b      19,19,33,65,51,20,34,66,50,66,66,67,51,52,52,37
  1240.     dc.b      51,68,67,68,67,83,83,83,84,69,53,69,69,54,68,84
  1241.     dc.b      85,69,69,85,70,54,84,85,85,70,69,85,85,85,70,70
  1242.     dc.b      70,69,85,85,85,70,69,85,84,86,54,69,85,69,69,84
  1243.     dc.b      84,70,53,69,69,53,68,83,83,83,83,68,67,68,67,53
  1244.     dc.b      36,52,51,51,66,66,66,50,66,36,19,49,65,35,19,19
  1245.     dc.b      18,33,34,18,3,2,2,17,16,32,16,16,16,31,16,0
  1246.     even
  1247.  
  1248.  
  1249.     ifne spr_pi1
  1250. pi1 incbin 'SPRITE3.PI1'
  1251.     endc
  1252.  
  1253. pal_and_sprite
  1254.     ifeq spr_pi1
  1255.       incbin 'PAS3.SPR'
  1256.    
  1257.     endc
  1258. ;   even
  1259.     DATA
  1260. seuil   dc.w segmenty
  1261.    
  1262.     BSS
  1263.         rsreset
  1264. segmentX    rs.w 1
  1265. segmentY    rs.w 1 
  1266. codecurefface   ds.l 1
  1267. ;tempbuffer ds.w 2048
  1268.  
  1269. sin512 ds.l 1
  1270.  
  1271. ptrMem      ds.l 16         ; dans ram apres l'appel de getmem1 adresses contenant les bloc memoire utilisable comme on veut
  1272.  
  1273. ;;;             ; les label entour? de ;;; doivent etre dans l'ordre et contigu (ne pas deplacer l'un des label)
  1274. ;ptrtabsin1 ds.l 1
  1275. ;ptrtabsin2 ds.l 1
  1276. ;ptrtabsin3 ds.l 1
  1277. ;ptrtabsin4 ds.l 1
  1278. ptr16k  ds.l 1
  1279. ptr4k   ds.l 1
  1280. ptrflag ds.l 1
  1281. ;;;
  1282.  
  1283.    
  1284.     ds.b 65536
  1285. screenbuf
  1286.     ds.w 65536
  1287.     ;ds.w 65536
  1288.    
  1289. log     ds.l 1
  1290. phys    ds.l 1
  1291. ptrscr1 ds.l 1
  1292. ptrscr2 ds.l 1
  1293. ptrscr3 ds.l 1
  1294. ptrscr4 ds.l 1
  1295.  
  1296.  
  1297. ;convx  ds.l 320*subpixel
  1298. ;convy  ds.w 200*subpixel
  1299. ptrvariable ds.l 1
  1300. ptrconvX ds.l 1
  1301. ptrconvY ds.l 1
  1302.  
  1303. sinx1   ds.l 1   *ds.w 512
  1304. sinx2   ds.l 1   *ds.w 512
  1305. siny1   ds.l 1   *ds.w 512
  1306. siny2   ds.l 1   *ds.w 512
  1307.  
  1308. flagtab ds.l 1
  1309.  
  1310. ptrref1 ds.l 1
  1311. ptrref2 ds.l 1
  1312. ptrref3 ds.l 1
  1313. ptrref4 ds.l 1
  1314.  
  1315. ptrref5 ds.l 1
  1316. ptrref6 ds.l 1
  1317. ptrref7 ds.l 1
  1318. ptrref8 ds.l 1
  1319.  
  1320.  
  1321. efface1lst
  1322.         ds.w nbbob*6
  1323. efface2lst
  1324.         ds.w nbbob*6
  1325. ;efface3lst
  1326. ;       ds.w nbbob*6
  1327. ;efface4lst
  1328. ;       ds.w nbbob*6
  1329.  
  1330.  
  1331. codegenliste    ds.l 16
  1332. codeeffliste    ds.l 16
  1333. ram ds.b ($b24dA-$b19f2)+2000
  1334.     ds.b 3000
  1335. ram2    ds.b 5000
  1336. ;   ds.l 5000
  1337. ram3    ds.b 16000
  1338.    
  1339. ;convxSprite    ds.l 320*2*subpixel
  1340.    
  1341.  
  1342. sprite  ds.w 32
  1343.  
  1344. spritedeca
  1345.     ds.w 128*16
  1346.  
  1347.  
Add Comment
Please, Sign In to add comment