home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / testi / corsoasm / sorgenti9 / lezione15h.s < prev    next >
Text File  |  1995-05-02  |  11KB  |  318 lines

  1.  
  2. ; Lezione15h.s        - Esempio degli effetti del BPLCON4 nella palette
  3.  
  4.     SECTION    AgaRulez,CODE
  5.  
  6. ;    Include    "DaWorkBench.s"    ; togliere il ; prima di salvare con "WO"
  7.  
  8. *****************************************************************************
  9.     include    "startup2.s"    ; Salva Copperlist Etc.
  10. *****************************************************************************
  11.  
  12.         ;5432109876543210
  13. DMASET    EQU    %1000001110000000    ; copper, bitplane DMA
  14.  
  15. WaitDisk    EQU    30    ; 50-150 al salvataggio (secondo i casi)
  16.  
  17. START:
  18.  
  19. ;    Puntiamo la pic AGA
  20.  
  21.     MOVE.L    #PICTURE,d0
  22.     LEA    BPLPOINTERS,A1    
  23.     MOVEQ    #8-1,D7            ;num of bitplanes -1
  24. POINTB:
  25.     move.w    d0,6(a1)        
  26.     swap    d0            
  27.     move.w    d0,2(a1)        
  28.     swap    d0            
  29.     addi.l    #10240,d0        ;lenght of bitplane
  30.     addq.w    #8,a1
  31.     dbra    d7,POINTB        ;Rifai D1 volte (D1=num of bitplanes)
  32.  
  33.     bsr.s    MettiColori
  34.  
  35.     MOVE.W    #DMASET,$96(a5)        ; DMACON - abilita bitplane, copper
  36.     move.l    #CopList,$80(a5)    ; Puntiamo la nostra COP
  37.     move.w    d0,$88(a5)        ; Facciamo partire la COP
  38.     move.w    #0,$1fc(a5)        ; Fmode azzerato, burst normale
  39.     move.w    #$c00,$106(a5)        ; BPLCON3 resettato
  40.     move.w    #$11,$10c(a5)        ; BPLCON4 resettato
  41.  
  42. LOOP:
  43.     MOVE.L    #$1ff00,d1    ; bit per la selezione tramite AND
  44.     MOVE.L    #$11000,d2    ; linea da aspettare = $110
  45. Waity1:
  46.     MOVE.L    4(A5),D0    ; VPOSR e VHPOSR - $dff004/$dff006
  47.     ANDI.L    D1,D0        ; Seleziona solo i bit della pos. verticale
  48.     CMPI.L    D2,D0        ; aspetta la linea $110
  49.     BNE.S    Waity1
  50.  
  51. Aspetta:
  52.     MOVE.L    4(A5),D0    ; VPOSR e VHPOSR - $dff004/$dff006
  53.     ANDI.L    D1,D0        ; Seleziona solo i bit della pos. verticale
  54.     CMPI.L    D2,D0        ; aspetta la linea $110
  55.     BEQ.S    Aspetta
  56.  
  57.     bsr.s    CambiaCon4
  58.  
  59.     BTST    #6,$BFE001
  60.     BNE.S    LOOP
  61.     RTS
  62.  
  63. CambiaCon4:
  64.     addq.b    #1,ContaSpetta
  65.     cmp.b    #20,ContaSpetta    ; Passati 20 frames?
  66.     bne.s    NonAncora    
  67.     clr.b    ContaSpetta    ; resetta il "timer"
  68.     addq.b    #1,MioCon4    ; Cambia il byte alto di bplcon4
  69. NonAncora:
  70.     rts
  71.  
  72. ContaSpetta:
  73.     dc.w    0
  74.  
  75. MettiColori:
  76.     LEA    PICTURE+(10240*8),A0    ; indirizzo della color palette alla
  77.                     ; fine della figura -> in A0
  78.     LEA    COLP0+2,A1        ; Indirizzo del primo registro
  79.                     ; settato per i nibble ALTI
  80.     LEA    COLP0B+2,A2        ; Indirizzo del primo registro
  81.                     ; settato per i nibble BASSI
  82.     MOVEQ    #8-1,d7            ; 8 banchi da 32 registri ciascuno
  83. ConvertiPaletteBank:
  84.     moveq    #0,d0
  85.     moveq    #0,d2
  86.     moveq    #0,d3
  87.     moveq    #32-1,d6    ; 32 registri colore per banco
  88.  
  89. DaLongARegistri:    ; loop che trasforma i colori $00RrGgBb.l nelle 2
  90.             ; word $0RGB, $0rgb adatte ai registri copper.
  91.  
  92. ; Conversione dei nibble bassi da $00RgGgBb (long) al colore aga $0rgb (word)
  93.  
  94.     MOVE.B    1(A0),(a2)    ; Byte alto del colore $00Rr0000 copiato
  95.                 ; nel registro cop per nibble bassi
  96.     ANDI.B    #%00001111,(a2) ; Seleziona solo il nibble BASSO ($0r)
  97.     move.b    2(a0),d2    ; Prendi il byte $0000Gg00 dal colore a 24bit
  98.     lsl.b    #4,d2        ; Sposta a sinistra di 4 bit il nibble basso
  99.                 ; del GREEN, "trasformandolo" in nibble alto
  100.                 ; di del byte basso di D2 ($g0)
  101.     move.b    3(a0),d3    ; Prendi il byte $000000Bb dal colore a 24bit
  102.     ANDI.B    #%00001111,d3    ; Seleziona solo il nibble BASSO ($0b)
  103.     or.b    d2,d3        ; "FONDI" i nibble bassi di green e blu...
  104.     move.b    d3,1(a2)    ; Formando il byte basso finale $gb da mettere
  105.                 ; nel registro colore, dopo il byte $0r, per
  106.                 ; formare la word $0rgb dei nibble bassi
  107.  
  108. ; Conversione dei nibble alti da $00RgGgBb (long) al colore aga $0RGB (word)
  109.  
  110.     MOVE.B    1(A0),d0    ; Byte alto del colore $00Rr0000 in d0
  111.     ANDI.B    #%11110000,d0    ; Seleziona solo il nibble ALTO ($R0)
  112.     lsr.b    #4,d0        ; Shifta a destra di 4 bit il nibble, in modo
  113.                 ; che diventi il nibble basso del byte ($0R)
  114.     move.b    d0,(a1)        ; Copia il byte alto $0R nel color register
  115.     move.b    2(a0),d2    ; Prendi il byte $0000Gg00 dal colore a 24bit
  116.     ANDI.B    #%11110000,d2    ; Seleziona solo il nibble ALTO ($G0)
  117.     move.b    3(a0),d3    ; Prendi il byte $000000Bb dal colore a 24 bit
  118.     ANDI.B    #%11110000,d3    ; Seleziona solo il nibble ALTO ($B0)
  119.     lsr.b    #4,d3        ; Shiftalo di 4 bit a destra trasformandolo in
  120.                 ; nibble basso del byte basso di d3 ($0B)
  121.     ori.b    d2,d3        ; Fondi i nibble alti di green e blu ($G0+$0B)
  122.     move.b    d3,1(a1)    ; Formando il byte basso finale $GB da mettere
  123.                 ; nel registro colore, dopo il byte $0R, per
  124.                 ; formare la word $0RGB dei nibble alti.
  125.  
  126.     addq.w    #4,a0        ; Saltiamo al prossimo colore .l della palette
  127.                 ; attaccata in fondo alla pic
  128.     addq.w    #4,a1        ; Saltiamo al prossimo registro colore per i
  129.                 ; nibble ALTI in Copperlist
  130.     addq.w    #4,a2        ; Saltiamo al prossimo registro colore per i
  131.                 ; nibble BASSI in Copperlist
  132.  
  133.     dbra    d6,DaLongARegistri
  134.  
  135.     add.w    #(128+8),a1    ; salta i registri colore + il dc.w $106,xxx
  136.                 ; dei nibble ALTI
  137.     add.w    #(128+8),a2    ; salta i registri colore + il dc.w $106,xxx
  138.                 ; dei nibble BASSI
  139.  
  140.     dbra    d7,ConvertiPaletteBank    ; Converte un banco da 32 colori per
  141.     rts                ; loop. 8 loop per i 256 colori.
  142.  
  143.  
  144. ;*****************************************************************************
  145. ;*                COPPERLIST                     *
  146. ;*****************************************************************************
  147.  
  148.     CNOP    0,8    ; Allineo a 64 bit
  149.  
  150.     section    coppera,data_C
  151.  
  152. COPLIST:
  153.     dc.w    $8E,$2c81    ; DiwStrt
  154.     dc.w    $90,$2cc1    ; DiwStop
  155.     dc.w    $92,$0038    ; DdfStart
  156.     dc.w    $94,$00d0    ; DdfStop
  157.     dc.w    $102,0        ; BplCon1
  158.     dc.w    $104,0        ; BplCon2
  159.     dc.w    $108,0        ; Bpl1Mod
  160.     dc.w    $10a,0        ; Bpl2Mod
  161.     dc.w    $10c        ; BplCon4
  162. MioCon4:
  163.     dc.w    0
  164.  
  165.             ; 5432109876543210
  166.     dc.w    $100,%0000001000010001    ; 8 bitplane LOWRES 320x256. Per
  167.                     ; settare 8 planes setto il bit 4 e
  168.                     ; azzero i bit 12,13,14. Il bit 0 e'
  169.                     ; settato dato che abilita molte
  170.                     ; funzioni AGA che vedremo dopo.
  171.  
  172.     dc.w    $1fc,0        ; Burst mode azzerato (per ora!)
  173.  
  174. BPLPOINTERS:
  175.     dc.w $e0,0,$e2,0    ; primo     bitplane
  176.     dc.w $e4,0,$e6,0    ; secondo       "
  177.     dc.w $e8,0,$ea,0    ; terzo           "
  178.     dc.w $ec,0,$ee,0    ; quarto       "
  179.     dc.w $f0,0,$f2,0    ; quinto       "
  180.     dc.w $f4,0,$f6,0    ; sesto           "
  181.     dc.w $f8,0,$fA,0    ; settimo       "
  182.     dc.w $fC,0,$fE,0    ; ottavo       "
  183.  
  184. ; In questo caso la palette viene aggiornata da una routine, per cui basta
  185. ; lasciare azzerati i valori dei registri.
  186.  
  187.     DC.W    $106,$c00    ; SELEZIONA PALETTE 0 (0-31), NIBBLE ALTI
  188. COLP0:
  189.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  190.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  191.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  192.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  193.  
  194.     DC.W    $106,$e00    ; SELEZIONA PALETTE 0 (0-31), NIBBLE BASSI
  195. COLP0B:
  196.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  197.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  198.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  199.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  200.  
  201.     DC.W    $106,$2C00    ; SELEZIONA PALETTE 1 (32-63), NIBBLE ALTI
  202.  
  203.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  204.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  205.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  206.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  207.  
  208.     DC.W    $106,$2E00    ; SELEZIONA PALETTE 1 (32-63), NIBBLE BASSI
  209.  
  210.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  211.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  212.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  213.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  214.  
  215.     DC.W    $106,$4C00    ; SELEZIONA PALETTE 2 (64-95), NIBBLE ALTI
  216.  
  217.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  218.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  219.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  220.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  221.  
  222.     DC.W    $106,$4E00    ; SELEZIONA PALETTE 2 (64-95), NIBBLE BASSI
  223.  
  224.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  225.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  226.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  227.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  228.  
  229.     DC.W    $106,$6C00    ; SELEZIONA PALETTE 3 (96-127), NIBBLE ALTI
  230.  
  231.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  232.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  233.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  234.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  235.  
  236.     DC.W    $106,$6E00    ; SELEZIONA PALETTE 3 (96-127), NIBBLE BASSI
  237.  
  238.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  239.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  240.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  241.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  242.  
  243.     DC.W    $106,$8C00    ; SELEZIONA PALETTE 4 (128-159), NIBBLE ALTI
  244.  
  245.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  246.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  247.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  248.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  249.  
  250.     DC.W    $106,$8E00    ; SELEZIONA PALETTE 4 (128-159), NIBBLE BASSI
  251.  
  252.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  253.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  254.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  255.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  256.  
  257.     DC.W    $106,$AC00    ; SELEZIONA PALETTE 5 (160-191), NIBBLE ALTI
  258.  
  259.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  260.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  261.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  262.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  263.  
  264.     DC.W    $106,$AE00    ; SELEZIONA PALETTE 5 (160-191), NIBBLE BASSI
  265.  
  266.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  267.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  268.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  269.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  270.  
  271.     DC.W    $106,$CC00    ; SELEZIONA PALETTE 6 (192-223), NIBBLE ALTI
  272.  
  273.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  274.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  275.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  276.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  277.  
  278.     DC.W    $106,$CE00    ; SELEZIONA PALETTE 6 (192-223), NIBBLE BASSI
  279.  
  280.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  281.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  282.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  283.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  284.  
  285.     DC.W    $106,$EC00    ; SELEZIONA PALETTE 7 (224-255), NIBBLE ALTI
  286.  
  287.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  288.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  289.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  290.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  291.  
  292.     DC.W    $106,$EE00    ; SELEZIONA PALETTE 7 (224-255), NIBBLE BASSI
  293.  
  294.     DC.W    $180,0,$182,0,$184,0,$186,0,$188,0,$18A,0,$18C,0,$18E,0
  295.     DC.W    $190,0,$192,0,$194,0,$196,0,$198,0,$19A,0,$19C,0,$19E,0
  296.     DC.W    $1A0,0,$1A2,0,$1A4,0,$1A6,0,$1A8,0,$1AA,0,$1AC,0,$1AE,0
  297.     DC.W    $1B0,0,$1B2,0,$1B4,0,$1B6,0,$1B8,0,$1BA,0,$1BC,0,$1BE,0
  298.  
  299.     dc.w    $FFFF,$FFFE    ; Fine della copperlist
  300.  
  301. ;******************************************************************************
  302.  
  303. ; Figura RAW ad 8 bitplanes, cioe' a 256 colori
  304.  
  305.     CNOP    0,8    ; allineo a 64 bit
  306.  
  307. PICTURE:
  308.     INCBIN    "MURALE320*256*256c.RAW"
  309.  
  310.     end
  311.  
  312. Questo esempio non e' certo "bello", ma rende l'idea del funzionamento del
  313. registro, che e' certamente utile in certe routines che potreste fare,
  314. appositamente studiate per cambiare la palette.... potreste per esempio
  315. mettere un $10c ogni linea per cambiare la palette in modo diverso molte
  316. volte... per fare chissacche'....
  317.  
  318.