home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / testi / corsoasm / sorgenti7 / lezione11l6b.s < prev    next >
Text File  |  1995-09-29  |  6KB  |  207 lines

  1.  
  2. ; Lezione11l6b.s    Routine di gestione del modo interlacciato (640x512)
  3. ;            che legge il bit 15 (LOF) del VPOSR ($dff004).
  4. ;            Premendo il tasto destro non si esegue tale routine,
  5. ;            e si nota come rimangano alle volte le linee pari o
  6. ;            le dispari in "pseudo-non lace".
  7.  
  8.     SECTION    Interlaccione,CODE
  9.  
  10. ;    Include    "DaWorkBench.s"    ; togliere il ; prima di salvare con "WO"
  11.  
  12. *****************************************************************************
  13.     include    "startup2.s"    ; Salva Copperlist Etc.
  14. *****************************************************************************
  15.  
  16.         ;5432109876543210
  17. DMASET    EQU    %1000001110000000    ; solo copper e bitplane DMA
  18.  
  19. WaitDisk    EQU    30
  20.  
  21. scr_bytes    = 40    ; Numero di bytes per ogni linea orizzontale.
  22.             ; Da questa si calcola la larghezza dello schermo,
  23.             ; moltiplicando i bytes per 8: schermo norm. 320/8=40
  24.             ; Es. per uno schermo largo 336 pixel, 336/8=42
  25.             ; larghezze esempio:
  26.             ; 264 pixel = 33 / 272 pixel = 34 / 280 pixel = 35
  27.             ; 360 pixel = 45 / 368 pixel = 46 / 376 pixel = 47
  28.             ; ... 640 pixel = 80 / 648 pixel = 81 ...
  29.  
  30. scr_h        = 256    ; Altezza dello schermo in linee
  31. scr_x        = $81    ; Inizio schermo, posizione XX (normale $xx81) (129)
  32. scr_y        = $2c    ; Inizio schermo, posizione YY (normale $2cxx) (44)
  33. scr_res        = 1    ; 2 = HighRes (640*xxx) / 1 = LowRes (320*xxx)
  34. scr_lace    = 1    ; 0 = non interlace (xxx*256) / 1 = interlace (xxx*512)
  35. ham        = 0    ; 0 = non ham / 1 = ham
  36. scr_bpl        = 4    ; Numero Bitplanes
  37.  
  38. ; parametri calcolati automaticamente
  39.  
  40. scr_w        = scr_bytes*8        ; larghezza dello schermo
  41. scr_size    = scr_bytes*scr_h    ; dimensione in bytes dello schermo
  42. BPLC0    = ((scr_res&2)<<14)+(scr_bpl<<12)+$200+(scr_lace<<2)+(ham<<11)
  43. DIWS    = (scr_y<<8)+scr_x
  44. DIWSt    = ((scr_y+scr_h/(scr_lace+1))&255)<<8+(scr_x+scr_w/scr_res)&255
  45. DDFS    = (scr_x-(16/scr_res+1))/2
  46. DDFSt    = DDFS+(8/scr_res)*(scr_bytes/2-scr_res)
  47.  
  48.  
  49. START:
  50. ;    puntiamo la figura
  51.  
  52.     MOVE.L    #Logo1,d0    ; dove puntare
  53.     LEA    BPLPOINTERS,A1    ; puntatori COP
  54.     MOVEQ    #4-1,D1        ; numero di bitplanes (qua sono 4)
  55. POINTBP:
  56.     move.w    d0,6(a1)
  57.     swap    d0
  58.     move.w    d0,2(a1)
  59.     swap    d0
  60.     ADD.L    #40*84,d0    ; + lunghezza bitplane (qua e' alto 84 linee)
  61.     addq.w    #8,a1
  62.     dbra    d1,POINTBP
  63.  
  64.  
  65.     MOVE.W    #DMASET,$96(a5)        ; DMACON - abilita bitplane, copper
  66.                     ; e sprites.
  67.  
  68.     move.l    #COPPERLIST,$80(a5)    ; Puntiamo la nostra COP
  69.     move.w    d0,$88(a5)        ; Facciamo partire la COP
  70.     move.w    #0,$1fc(a5)        ; Disattiva l'AGA
  71.     move.w    #$c00,$106(a5)        ; Disattiva l'AGA
  72.     move.w    #$11,$10c(a5)        ; Disattiva l'AGA
  73.  
  74. mouse:
  75.     MOVE.L    #$1ff00,d1    ; bit per la selezione tramite AND
  76.     MOVE.L    #$01000,d2    ; linea da aspettare = $000
  77. Waity1:
  78.     MOVE.L    4(A5),D0    ; VPOSR e VHPOSR - $dff004/$dff006
  79.     ANDI.L    D1,D0        ; Seleziona solo i bit della pos. verticale
  80.     CMPI.L    D2,D0        ; aspetta la linea $12c
  81.     BNE.S    Waity1
  82. Waity2:
  83.     MOVE.L    4(A5),D0    ; VPOSR e VHPOSR - $dff004/$dff006
  84.     ANDI.L    D1,D0        ; Seleziona solo i bit della pos. verticale
  85.     CMPI.L    D2,D0        ; aspetta la linea $12c
  86.     Beq.S    Waity2
  87.  
  88.     btst    #2,$16(A5)    ; Tasto destro premuto?
  89.     beq.s    NonLaceint
  90.  
  91.     bsr.s    laceint        ; Routine che punta linee pari o dispari
  92.                 ; ogni frame a seconda del bit LOF per
  93.                 ; l'interlace
  94. NonLaceint:
  95.     btst.b    #6,$bfe001    ; Mouse sinistro premuto?
  96.     bne.s    mouse
  97.     rts
  98.  
  99. ******************************************************************************
  100. ; INTERLACE ROUTINE - Testa il bit LOF (Long Frame) per sapere se si devono
  101. ; visualizzare le linee pari o quelle dispari, e punta di conseguenza.
  102. ******************************************************************************
  103.  
  104. LACEINT:
  105.     MOVE.L    #Logo1,D0    ; Indirizzo bitplanes
  106.     btst.b    #15-8,4(A5)    ; VPOSR LOF bit?
  107.     Beq.S    Faidispari    ; Se si, tocca alle linee dispari
  108.     ADD.L    #40,D0        ; Oppure aggiungi la lunghezza di una linea,
  109.                 ; facendo partire la visualizzazione dalla
  110.                 ; seconda: visualizzate linee pari!
  111. FaiDispari:
  112.     LEA    BPLPOINTERS,A1    ; PLANE POINTERS IN COPLIST
  113.     MOVEQ    #4-1,D7        ; NUM. DI BITPLANES -1
  114. LACELOOP:
  115.     MOVE.W    D0,6(A1)    ; Punta la figura
  116.     SWAP    D0
  117.     MOVE.W    D0,2(A1)
  118.     SWAP    D0
  119.     ADD.L    #40*84,D0    ; Lunghezza bitplane
  120.     ADDQ.w    #8,A1        ; Prossimi pointers
  121.     DBRA    D7,LACELOOP
  122.     RTS
  123.  
  124. *****************************************************************************
  125. ;            Copper List
  126. *****************************************************************************
  127.     section    copper,data_c        ; Chip data
  128.  
  129. Copperlist:
  130.     dc.w    $8e,DIWS    ; DiwStrt
  131.     dc.w    $90,DIWSt    ; DiwStop
  132.     dc.w    $92,DDFS    ; DdfStart
  133.     dc.w    $94,DDFSt    ; DdfStop
  134.  
  135.     dc.w    $102,0        ; BplCon1 - scroll register
  136.     dc.w    $104,0        ; BplCon2 - priority register
  137.     dc.w    $108,40        ; Bpl1Mod - \ INTERLACE: lungh. di una linea
  138.     dc.w    $10a,40        ; Bpl2Mod - / per saltare linee pari o disp.
  139.  
  140. ; Bitplane pointers
  141.  
  142. BPLPOINTERS:
  143.     dc.w $e0,$0000,$e2,$0000    ;primo     bitplane
  144.     dc.w $e4,$0000,$e6,$0000    ;secondo bitplane
  145.     dc.w $e8,$0000,$ea,$0000    ;terzo     bitplane
  146.     dc.w $ec,$0000,$ee,$0000    ;quarto     bitplane
  147.  
  148. ;            ; 5432109876543210
  149. ;    dc.w    $100,%0100001000000100    ; BPLCON0 - 4 planes lowres (16 colori)
  150. ;                    ; INTERLACCIATO (bit 2!)
  151.  
  152.     dc.w    $100,BPLC0    ; BplCon0 - calcolato automaticamente
  153.  
  154.  
  155. ; i primi 16 colori sono per il LOGO
  156.  
  157.     dc.w $180,$000,$182,$fff,$184,$200,$186,$310
  158.     dc.w $188,$410,$18a,$620,$18c,$841,$18e,$a73
  159.     dc.w $190,$b95,$192,$db6,$194,$dc7,$196,$111
  160.     dc.w $198,$222,$19a,$334,$19c,$99b,$19e,$446
  161.  
  162. ;    Mettiamo un poco di sfumature per la scenografia...
  163.  
  164.     dc.w    $5607,$fffe    ; Wait - $2c+84=$80
  165.     dc.w    $100,$204    ; bplcon0 - no bitplanes, MA BIT LACE SETTATO!
  166.     dc.w    $8007,$fffe    ; wait
  167.     dc.w    $180,$003    ; color0
  168.     dc.w    $8207,$fffe    ; wait
  169.     dc.w    $180,$005    ; color0
  170.     dc.w    $8507,$fffe    ; wait
  171.     dc.w    $180,$007    ; color0
  172.     dc.w    $8a07,$fffe    ; wait
  173.     dc.w    $180,$009    ; color0
  174.     dc.w    $9207,$fffe    ; wait
  175.     dc.w    $180,$00b    ; color0
  176.  
  177.     dc.w    $9e07,$fffe    ; wait
  178.     dc.w    $180,$999    ; color0
  179.     dc.w    $a007,$fffe    ; wait
  180.     dc.w    $180,$666    ; color0
  181.     dc.w    $a207,$fffe    ; wait
  182.     dc.w    $180,$222    ; color0
  183.     dc.w    $a407,$fffe    ; wait
  184.     dc.w    $180,$001    ; color0
  185.  
  186.     dc.l    $ffff,$fffe    ; Fine della copperlist
  187.  
  188.  
  189. *****************************************************************************
  190. ;                DISEGNO
  191. *****************************************************************************
  192.  
  193.     section    gfxstuff,data_c
  194.  
  195. ; Disegno largo 320 pixel, alto 84, a 4 bitplanes (16 colori).
  196.  
  197. Logo1:
  198.     incbin    'assembler2:sorgenti4/logo320*84*16c.raw'
  199.  
  200.     end
  201.  
  202. Avete notato che TUTTI i bplcon0 della copperlist devono avere il bit 2,
  203. quello dell'interlace, settato? Infatti, se l'ultimo BPLCON0 non avesse il
  204. bit settato, nonostante gli altri lo abbiano lo schermo non verrebbe
  205. interlacciato!
  206.  
  207.