Advertisement
glokyfull

palette2.s

Sep 4th, 2022
2,248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. lstorder
  3. a equ 0
  4. b equ 32
  5. c equ 64
  6.     dc.b a,b,c
  7.     dc.b a,c,b
  8.     dc.b b,a,c
  9.     dc.b c,a,b
  10.     dc.b b,c,a
  11.     dc.b c,b,a
  12.     dc.b 0
  13.     even
  14. red     dc.w 0,$100,$200,$300,$400,$500,$600,$700,$800,$900,$a00,$b00,$c00,$d00,$e00,$f00
  15. green   dc.w 0,$10,$20,$30,$40,$50,$60,$70,$80,$90,$a0,$b0,$c0,$d0,$e0,$f0
  16. blue    dc.w 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  17.  
  18.  
  19.  
  20. makemultipalette
  21. ; construit 6 palette a partir de la palette de base en changeant l'ordre des composante rvb
  22.  
  23. ; a0 = palette de base        format dc.b r,v,b,r,v,b,r,v,b etc
  24. ; a1 = ram  contenant palette convertit en word $rvb
  25. ; d0 = nombre de couleur     
  26.  
  27.     lea lstorder,a2
  28.     move.l a0,a6
  29.     moveq #5,d6
  30. .mp
  31.     move.w d0,d7
  32.     subq #1,d7
  33.  
  34.     moveq #0,d3
  35.     move.b (a2)+,d3
  36.     lea red,a3
  37.     move.l a3,a4
  38.     move.l a3,a5
  39.     add.w d3,a3
  40.  
  41.     move.b (a2)+,d3
  42.     add.w d3,a4
  43.     move.b (a2)+,d3
  44.     add.w d3,a5
  45.  
  46. .loop  
  47.     move.b (a0)+,d2     ; composante
  48.     ext.w d2
  49.     add d2,d2
  50.     move (a3,d2),d4
  51.     move.b (a0)+,d2     ; composante
  52.     ext.w d2
  53.     add d2,d2
  54.     or (a4,d2),d4
  55.     move.b (a0)+,d2     ; composante
  56.     ext.w d2
  57.     add d2,d2
  58.     or (a5,d2),d4
  59.  
  60.     move.w d4,(a1)+
  61.     dbf d7,.loop   
  62.  
  63.     move.l a6,a0
  64.     dbf d6,.mp
  65.  
  66.     rts
  67. convRVBtoW
  68. ; a0 = liste r,v,b
  69. ; a1 = ram liste $rvb
  70. ; d0 = nombre de composante (r v b)
  71.     lea red,a4      ; red
  72.     lea 32(a4),a5   ; green
  73.     lea 32(a5),a6   ; blue
  74.  
  75.     move.w d0,d7
  76.     subq #1,d7
  77.  
  78.     moveq #0,d3
  79. .loop
  80.     move.b (a0)+,d3     ; red
  81.     add d3,d3
  82.     move.w (a4,d3),d4
  83.     move.b (a0)+,d3
  84.     add d3,d3
  85.     or.w (a5,d3),d4
  86.     move.b (a0)+,d3
  87.     add d3,d3
  88.     or.w (a6,d3),d4
  89.     move.w d4,(a1)+
  90.     dbf d7,.loop
  91.     rts
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103. convclassicpalette
  104. ; converti 16 couleur format dc.b r,v,b  en dc.w $rvb
  105.  
  106. ; a0 = 16 couleur word  $rvb
  107. ; a1 = format dc.b r,v,b  , r,v,b  , r,v,b  , etc
  108. ;
  109.  
  110.     moveq #15,d0
  111. .loop
  112.     move.b (a0)+,d1     ; rouge
  113.     move.b (a0)+,d2     ; $vb
  114.     move.b d2,d3
  115.     lsr.b #4,d2         ; vert
  116.     and.b #$F,d3        ; bleu
  117.    
  118.     move.b d1,(a1)+
  119.     move.b d2,(a1)+
  120.     move.b d3,(a1)+
  121.     dbf d0,.loop
  122.     rts
  123. convbetween2classicpalette
  124. ; convertit 2 palette de 16 couleur format r,v,b en 16 palettes
  125. ; intermediaire de palette1 a palette2
  126. ; idem au format dc.b r,v,b
  127. ; NOTE:  format STF
  128.  
  129.  
  130. ; a0 = format r,v,b, r,b,v,r,b,v,etc depart
  131. ; a1 = idem arrivé
  132. ; a2 = 16* r,v,b de depart a arrivé
  133.  
  134.  
  135.    
  136.     moveq #3*16-1,d0
  137. .loop
  138.  
  139.     move.b (a1)+,d2
  140.     move.b (a0)+,d1
  141.     move.b d1,d3        ; valeur de depart
  142.     sub.b d1,d2
  143.     add.b d2,d2
  144.     moveq #1,d6
  145.     ext.w d2
  146.     bpl.s .ok
  147.     neg.w d2
  148.     move.w #-1,d6
  149. .ok
  150.     moveq #15,d7
  151. .0
  152.     move.w #30,d4
  153.     move.w #-15,d5
  154.     bra.s .2
  155. .1  lea 16*3(a2),a2
  156. .2  move.b d1,(a2)
  157.     add.b d2,d5
  158.     dbge d7,.1
  159.     tst.w d7
  160.     bmi.s .fin
  161.     sub.b d4,d5
  162.     add.b d6,d1
  163.     dbf d7,.1
  164. .fin
  165.     lea -15*3*16+1(a2),a2
  166.    
  167.     dbf d0,.loop
  168.    
  169.     rts
  170.    
  171. convbetween2pal
  172. ; a0 = palette type $rvb
  173. ; a1 = palette type $rvb
  174. ; a2 = ram resultat 16*$rvb
  175.  
  176.     movem.l a0-a2,-(sp)
  177.    
  178.     ;move.l a0,a0
  179.     lea tempbuffer1,a1
  180.     jsr convclassicpalette
  181.     movem.l (sp)+,a0-a2
  182.     move.l a1,a0
  183.     lea tempbuffer2,a1
  184.     move.l a2,-(sp)
  185.     jsr convclassicpalette
  186.     lea tempbuffer1,a0    16*3
  187.     lea tempbuffer2,a1    16*3
  188.     lea tempbuffer3,a2    16* 16*3
  189.     jsr convbetween2classicpalette
  190.    
  191.     move.l (sp)+,a1          ; ram resultat 16*$rvb
  192.     move.w #16*16,d0        ; 16 palette de 16 triplet (r,v,b)
  193.     lea tempbuffer3,a0
  194.     jsr convRVBtoW
  195.    
  196.     rts
  197.    
  198.    
  199. ; sinlib
  200.  
  201. signedscaletable
  202. ; d0 ; nombre d'element
  203. ; a0 ; signed constant table 16 bit
  204. ; a1 ; ram
  205. ; d1 : log size 1 = lsl #1=*2 (convy)  2 = lsl #2 = *4 (convx) (note ne tient pas compte des subpixel
  206. ; d2 : amplitude demandé * nbsubpixel
  207.  
  208.     move.w d0,-(sp)
  209.     subq #1,d0
  210. .loop1
  211.     move.w (a0)+,d3
  212.     ext.l d3
  213.     muls d2,d3
  214.     clr.w d3
  215.     swap d3
  216.     asl #2,d3
  217.    
  218.     BSS
  219. tempbuffer1 ds.b 16*3
  220. tempbuffer2 ds.b 16*3
  221. tempbuffer3 ds.b 16*16*3
  222.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement