Advertisement
glokyfull

palette.s

Oct 15th, 2022
1,955
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; palette.s, the non equilibred version of palette transition (better appropriate for palette)
  2. ; in fact it's the debugged version, used with c2pla7b.s
  3.  
  4. lstorder
  5. a equ 0
  6. b equ 32
  7. c equ 64
  8.     dc.b a,b,c
  9.     dc.b a,c,b
  10.     dc.b b,a,c
  11.     dc.b c,a,b
  12.     dc.b b,c,a
  13.     dc.b c,b,a
  14.     dc.b 0
  15.     even
  16. red     dc.w 0,$100,$200,$300,$400,$500,$600,$700,$800,$900,$a00,$b00,$c00,$d00,$e00,$f00
  17. green   dc.w 0,$10,$20,$30,$40,$50,$60,$70,$80,$90,$a0,$b0,$c0,$d0,$e0,$f0
  18. blue    dc.w 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  19.  
  20.  
  21.  
  22. makemultipalette
  23. ; construit 6 palette a partir de la palette de base en changeant l'ordre des composante rvb
  24.  
  25. ; a0 = palette de base        format dc.b r,v,b,r,v,b,r,v,b etc
  26. ; a1 = ram  contenant palette convertit en word $rvb
  27. ; d0 = nombre de couleur     
  28.  
  29.     lea lstorder,a2
  30.     move.l a0,a6
  31.     moveq #5,d6
  32. .mp
  33.     move.w d0,d7
  34.     subq #1,d7
  35.  
  36.     moveq #0,d3
  37.     move.b (a2)+,d3
  38.     lea red,a3
  39.     move.l a3,a4
  40.     move.l a3,a5
  41.     add.w d3,a3
  42.  
  43.     move.b (a2)+,d3
  44.     add.w d3,a4
  45.     move.b (a2)+,d3
  46.     add.w d3,a5
  47.  
  48. .loop  
  49.     move.b (a0)+,d2     ; composante
  50.     ext.w d2
  51.     add d2,d2
  52.     move (a3,d2),d4
  53.     move.b (a0)+,d2     ; composante
  54.     ext.w d2
  55.     add d2,d2
  56.     or (a4,d2),d4
  57.     move.b (a0)+,d2     ; composante
  58.     ext.w d2
  59.     add d2,d2
  60.     or (a5,d2),d4
  61.  
  62.     move.w d4,(a1)+
  63.     dbf d7,.loop   
  64.  
  65.     move.l a6,a0
  66.     dbf d6,.mp
  67.  
  68.     rts
  69. convRVBtoW
  70. ; a0 = liste r,v,b
  71. ; a1 = ram liste $rvb
  72. ; d0 = nombre de composante (r v b)
  73.     lea red,a4      ; red
  74.     lea 32(a4),a5   ; green
  75.     lea 32(a5),a6   ; blue
  76.  
  77.     move.w d0,d7
  78.     subq #1,d7
  79.  
  80.     moveq #0,d3
  81. .loop
  82.     move.b (a0)+,d3     ; red
  83.     add d3,d3
  84.     move.w (a4,d3),d4
  85.     move.b (a0)+,d3
  86.     add d3,d3
  87.     or.w (a5,d3),d4
  88.     move.b (a0)+,d3
  89.     add d3,d3
  90.     or.w (a6,d3),d4
  91.     move.w d4,(a1)+
  92.     dbf d7,.loop
  93.     rts
  94.  
  95.  
  96. convclassicpalette
  97. ; converti 16 couleur format dc.b r,v,b  en dc.w $rvb
  98.  
  99. ; a0 = 16 couleur word  $rvb
  100. ; a1 = format dc.b r,v,b  , r,v,b  , r,v,b  , etc
  101. ;
  102.  
  103.     moveq #15,d0
  104. .loop
  105.     move.b (a0)+,d1     ; rouge
  106.     move.b (a0)+,d2     ; $vb
  107.     move.b d2,d3
  108.     lsr.b #4,d2         ; vert
  109.     and.b #$F,d3        ; bleu
  110.    
  111.     move.b d1,(a1)+
  112.     move.b d2,(a1)+
  113.     move.b d3,(a1)+
  114.     dbf d0,.loop
  115.     rts
  116. convbetween2classicpalette
  117. ; convertit 2 palette de 16 couleur format r,v,b en 16 palettes
  118. ; intermediaire de palette1 a palette2
  119. ; idem au format dc.b r,v,b
  120. ; NOTE:  format STF
  121.  
  122.  
  123. ; a0 = format r,v,b, r,b,v,r,b,v,etc depart
  124. ; a1 = idem arrivé
  125. ; a2 = 16* r,v,b de depart a arrivé
  126.  
  127.  
  128.    
  129.     moveq #3*16-1,d0
  130. .loop
  131.  
  132.     move.b (a1)+,d2
  133.     move.b (a0)+,d1
  134.     move.b d1,d3        ; valeur de depart
  135.     sub.b d1,d2
  136.     add.b d2,d2
  137.     moveq #1,d6
  138.     ext.w d2
  139.     bpl.s .ok
  140.     neg.w d2
  141.     move.w #-1,d6
  142. .ok
  143.     moveq #15,d7
  144. .0
  145.     move.w #30,d4
  146.     move.w #0,d5    ;-15 here it was move.w #-15,d5 whitch was the equilibred version but false method for palette
  147.                     ; it's the only change i done
  148.     bra.s .2
  149. .1  lea 16*3(a2),a2
  150. .2  move.b d1,(a2)
  151.     add.b d2,d5
  152.     dbge d7,.1
  153.     tst.w d7
  154.     bmi.s .fin
  155.     sub.b d4,d5
  156.     add.b d6,d1
  157.     dbf d7,.1
  158. .fin
  159.     lea -15*3*16+1(a2),a2
  160.    
  161.     dbf d0,.loop
  162.    
  163.     rts
  164. couleurste015       dc.b 0,2,4,6,8,10,12,14,1,3,5,7,9,11,13,15
  165. couleur015ste       dc.b 0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15
  166. convbetween2classicpaletteSTE
  167. ; convertit 2 palette de 16 couleur format r,v,b en 16 palettes
  168. ; intermediaire de palette1 a palette2
  169. ; idem au format dc.b r,v,b
  170. ; NOTE:  format ST E
  171.  
  172.  
  173. ; a0 = format r,v,b, r,b,v,r,b,v,etc depart
  174. ; a1 = idem arrivé
  175. ; a2 = 16* r,v,b de depart a arrivé
  176.  
  177.     lea couleurste015,a3
  178.     lea couleur015ste,a4
  179.    
  180.    
  181.     move.l a2,-(sp)
  182.    
  183.     moveq #0,d2
  184.     moveq #0,d1
  185.    
  186.     moveq #3*16-1,d0
  187. .loop
  188.  
  189.     move.b (a1)+,d2
  190.     move.b (a3,d2),d2       ; conv palste to 0..15
  191.     move.b (a0)+,d1
  192.     move.b (a3,d1),d1
  193.    
  194.     move.b d1,d3        ; valeur de depart
  195.     sub.b d1,d2
  196.     add.b d2,d2
  197.     moveq #1,d6
  198.     ext.w d2
  199.     bpl.s .ok
  200.     neg.w d2
  201.     move.w #-1,d6
  202. .ok
  203.     moveq #15,d7
  204. .0
  205.     move.w #30,d4
  206.     move.w #-15,d5
  207.     bra.s .2
  208. .1  lea 16*3(a2),a2
  209. .2
  210.     move.b d1,(a2)
  211. ;   move.b (a4,d1),d1
  212. ;   move.b d1,(a2)
  213. ;   move.b (a3,d1),d1
  214.    
  215.  
  216.     add.b d2,d5
  217.     dbge d7,.1
  218.     tst.w d7
  219.     bmi.s .fin
  220.     sub.b d4,d5
  221.     add.b d6,d1
  222.     dbf d7,.1
  223. .fin
  224.     lea -15*3*16+1(a2),a2
  225.    
  226.     dbf d0,.loop
  227.     move.l (sp)+,a2
  228.     ; converti tout les composante en ste
  229.     move.w #3*16*16-1,d0
  230.     moveq #0,d1
  231.    
  232. .loop2
  233.     move.b (a2),d1
  234.     move.b (a4,d1.w),d1
  235.     move.b d1,(a2)+
  236.     dbf d0,.loop2
  237.    
  238.    
  239.     rts
  240.  
  241. convbetween2pal
  242. ; a0 = palette type $rvb
  243. ; a1 = palette type $rvb
  244. ; a2 = ram resultat 16*$rvb
  245.  
  246.     movem.l a0-a2,-(sp)
  247.    
  248.     ;move.l a0,a0
  249.     lea tempbuffer1,a1
  250.     jsr convclassicpalette
  251.     movem.l (sp)+,a0-a2
  252.     move.l a1,a0
  253.     lea tempbuffer2,a1
  254.     move.l a2,-(sp)
  255.     jsr convclassicpalette
  256.     lea tempbuffer1,a0    16*3
  257.     lea tempbuffer2,a1    16*3
  258.     lea tempbuffer3,a2    16* 16*3
  259.     jsr convbetween2classicpalette
  260.    
  261.     move.l (sp)+,a1          ; ram resultat 16*$rvb
  262.     move.w #16*16,d0        ; 16 palette de 16 triplet (r,v,b)
  263.     lea tempbuffer3,a0
  264.     jsr convRVBtoW
  265.    
  266.     rts
  267.  
  268. convbetween2palSTE
  269. ; a0 = palette type $rvb
  270. ; a1 = palette type $rvb
  271. ; a2 = ram resultat 16*$rvb
  272.  
  273.     movem.l a0-a2,-(sp)
  274.    
  275.     ;move.l a0,a0
  276.     lea tempbuffer1,a1
  277.     jsr convclassicpalette
  278.     movem.l (sp)+,a0-a2
  279.     move.l a1,a0
  280.     lea tempbuffer2,a1
  281.     move.l a2,-(sp)
  282.     jsr convclassicpalette
  283.     lea tempbuffer1,a0    16*3
  284.     lea tempbuffer2,a1    16*3
  285.     lea tempbuffer3,a2    16* 16*3
  286.     jsr convbetween2classicpaletteSTE
  287.    
  288.     move.l (sp)+,a1          ; ram resultat 16*$rvb
  289.     move.w #16*16,d0        ; 16 palette de 16 triplet (r,v,b)
  290.     lea tempbuffer3,a0
  291.     jsr convRVBtoW
  292.    
  293.     rts
  294.        
  295.     BSS
  296. tempbuffer1 ds.b 16*3
  297. tempbuffer2 ds.b 16*3
  298. tempbuffer3 ds.b 16*16*3
  299.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement