home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / testi / corsoasm / sorgenti5 / lezione9h2r.s < prev    next >
Text File  |  1995-10-23  |  5KB  |  174 lines

  1.  
  2. ; Lezione9h2r.s    BLITTATA, in cui copiamo un rettangolo (in una pic RAWBLIT)
  3. ;        non allineato con una word, usando le maschere per "tappare".
  4. ;        Premendo il tasto destro si esegue la blittata "sporca"
  5. ;        Poi,premendo il tasto sinistro si esegue la blittata giusta
  6. ;        e infine premendo ancora il tasto destro si usce.
  7.  
  8.     SECTION    CiriCop,CODE
  9.  
  10. ;    Include    "DaWorkBench.s"    ; togliere il ; prima di salvare con "WO"
  11.  
  12. *****************************************************************************
  13.     include    "startup1.s"    ; Salva Copperlist Etc.
  14. *****************************************************************************
  15.  
  16.         ;5432109876543210
  17. DMASET    EQU    %1000001111000000    ; copper,bitplane,blitter DMA
  18.  
  19.  
  20. START:
  21.  
  22.     MOVE.L    #BITPLANE,d0    ; dove puntare
  23.     LEA    BPLPOINTERS,A1    ; puntatori COP
  24.     MOVEQ    #3-1,D1        ; numero di bitplanes (qua sono 3)
  25. POINTBP:
  26.     move.w    d0,6(a1)
  27.     swap    d0
  28.     move.w    d0,2(a1)
  29.     swap    d0
  30.                 ; QUI C'E` LA UNA DIFFERENZA RISPETTO
  31.                 ; ALLE IMMAGINI NORMALI!!!!!!
  32.     ADD.L    #40,d0        ; + LUNGHEZZA DI UNA RIGA !!!!!
  33.     addq.w    #8,a1
  34.     dbra    d1,POINTBP
  35.  
  36.     lea    $dff000,a5        ; CUSTOM REGISTER in a5
  37.     MOVE.W    #DMASET,$96(a5)        ; DMACON - abilita bitplane, copper
  38.     move.l    #COPPERLIST,$80(a5)    ; Puntiamo la nostra COP
  39.     move.w    d0,$88(a5)        ; Facciamo partire la COP
  40.     move.w    #0,$1fc(a5)        ; Disattiva l'AGA
  41.     move.w    #$c00,$106(a5)        ; Disattiva l'AGA
  42.     move.w    #$11,$10c(a5)        ; Disattiva l'AGA
  43.  
  44. mouse1:
  45.     btst    #2,$dff016        ; tasto destro del mouse premuto?
  46.     bne.s    mouse1            ; se no, aspetta
  47.  
  48. ; Prima Blittata, con le maschere che lasciano passare anche dati non
  49. ; desiderati
  50.  
  51.     lea    bitplane+((20*3*170)+80/16)*2,a0    ; ind. destinazione
  52.     move.w    #$ffff,d0                ; passa tutto
  53.     move.w    #$ffff,d1                ; passa tutto
  54.     bsr.s    copia
  55.  
  56. mouse2:
  57.     btst    #6,$bfe001    ; tasto sinistro del mouse premuto?
  58.     bne.s    mouse2        ; se no, torna a mouse2:
  59.  
  60. ; Seconda blittata, grazie alle maschere viene copiata solo 
  61. ; lettera "I"
  62.  
  63.     lea    bitplane+((20*3*170)+160/16)*2,a0    ; ind. destinazione
  64.     move.w    #%0000000000001111,d0    ; passano i 4 bit piu` a destra
  65.     move.w    #%1111000000000000,d1    ; passano i 4 bit piu` a sinistra
  66.     bsr.s    copia
  67.  
  68. mouse3:
  69.     btst    #2,$dff016    ; tasto destro del mouse premuto?
  70.     bne.s    mouse3        ; se no, aspetta
  71.  
  72.     rts
  73.  
  74. ;****************************************************************************
  75. ; Questa routine copia la figura sullo schermo.
  76. ;
  77. ; A0   - indirizzo destinazione
  78. ; D0.w - maschera prima word
  79. ; D1.w - maschera ultima word
  80. ;****************************************************************************
  81.  
  82. ;      ___________   
  83. ;     (_____ _____)  
  84. ;     /(_o(___)O_)\  
  85. ;    / ___________ \
  86. ;    \ \____l____/ /|
  87. ;    |\_`---'---'_/ |
  88. ;    | `---------'  |
  89. ;    |  T  xCz   T  |
  90. ;    l__|        l__|
  91. ;    (__)---^----(__)
  92. ;      T    T     |  
  93. ;     _l____l_____|_ 
  94. ;    (______X_______)
  95.  
  96. copia:
  97.     btst    #6,2(a5)    ; aspetta che il blitter finisca
  98. waitblit:
  99.     btst    #6,2(a5)
  100.     bne.s    waitblit
  101.  
  102.     move.l    #$09f00000,$40(a5)    ; BLTCON0 e BLTCON1 - copia da A a D
  103.  
  104.                     ; carica i parametri nelle maschere
  105.     move.w    d0,$44(a5)        ; BLTAFWM mask a sinistra
  106.     move.w    d1,$46(a5)        ; BLTALWM mask a destra
  107.  
  108. ; carica i puntatori
  109.  
  110.     move.l    #bitplane+((20*3*78)+128/16)*2,$50(a5) ; bltapt: sorgente fissa
  111.     move.l    a0,$54(a5)                   ; bltdpt: destinazione
  112.  
  113.     move.l #$00240024,$64(a5)        ; bltamod e bltdmod 
  114.  
  115.     move.w    #(3*60*64)+2,$58(a5)        ; bltsize
  116.                         ; altezza 60 linee e 3 planes
  117.                         ; larghezza 2 words
  118.                         
  119.     btst    #6,$02(a5)    ; dmaconr - aspetta che il blitter finisca
  120. waitblit2:
  121.     btst    #6,$02(a5)
  122.     bne.s    waitblit2
  123.     rts
  124.  
  125. ;****************************************************************************
  126.  
  127.     SECTION    GRAPHIC,DATA_C
  128.  
  129. COPPERLIST:
  130.     dc.w    $8E,$2c81    ; DiwStrt
  131.     dc.w    $90,$2cc1    ; DiwStop
  132.     dc.w    $92,$38        ; DdfStart
  133.     dc.w    $94,$d0        ; DdfStop
  134.     dc.w    $102,0        ; BplCon1
  135.     dc.w    $104,0        ; BplCon2
  136.  
  137.                 ; QUI C'E` UNA DIFFERENZA RISPETTO
  138.                 ; ALLE IMMAGINI NORMALI!!!!!!
  139.     dc.w    $108,80        ; VALORE MODULO = 2*20*(3-1)= 80
  140.     dc.w    $10a,80        ; ENTRAMBI I MODULI ALLO STESSO VALORE.
  141.  
  142.     dc.w    $100,$3200    ; bplcon0 - 3 bitplanes lowres
  143.  
  144. BPLPOINTERS:
  145.     dc.w $e0,$0000,$e2,$0000    ;primo     bitplane
  146.     dc.w $e4,$0000,$e6,$0000
  147.     dc.w $e8,$0000,$ea,$0000
  148.  
  149.     dc.w    $0180,$000    ; color0
  150.     dc.w    $0182,$475    ; color1
  151.     dc.w    $0184,$fff    ; color2
  152.     dc.w    $0186,$ccc    ; color3
  153.     dc.w    $0188,$999    ; color4
  154.     dc.w    $018a,$232    ; color5
  155.     dc.w    $018c,$777    ; color6
  156.     dc.w    $018e,$444    ; color7
  157.  
  158.     dc.w    $FFFF,$FFFE    ; Fine della copperlist
  159.  
  160. ;****************************************************************************
  161.  
  162. BITPLANE:
  163.     incbin    "assembler2:sorgenti6/amiga.rawblit"
  164.                     ; qua carichiamo la figura in
  165.                     ; formato RAWBLIT (o interleaved),
  166.                     ; convertita col KEFCON.
  167.     end
  168.  
  169. ;****************************************************************************
  170.  
  171. Questo esempio e` la versione rawblit di lezione9h2.s.
  172. Confrontate le differenze nelle formule per il calcolo dei valori da scrivere
  173. nei registri del blitter.
  174.