Guest User

Untitled

a guest
Sep 13th, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;*** Example for a simple Copperlist ***
  2.  
  3.      section main,code,chip
  4.  
  5. ;CustomChip-Register
  6.  
  7. INTENA = $9A       ; Interrupt-Enable-Register (write)
  8. DMACON = $96       ; DMA-control register (write)
  9. COLOR00 = $0180     ; Color palette register 0
  10. COLOR01 = $0182     ; Color palette register 1
  11. VHPOSR = $6
  12.  
  13. ;Copper Register
  14.  
  15. COP1LC = $80       ; Address of 1. Copper list
  16. COP2LC = $84       ; Address of 2. Copper list
  17. COPJMP1 = $88       ; Jump to Copper list 1
  18. COPJMP2 = $8A       ; Jump to Copper list 2
  19.  
  20. BPLCON0 = $100 ; Display control registers.
  21. BPLCON1 = $102
  22. BPLCON2 = $104
  23.  
  24. BPL1PTH = $0E0
  25. BPL1PTL = $0E2
  26. BPL1MOD = $108
  27. DIWSTRT = $08E
  28. DIWSTOP = $090
  29. DDFSTRT = $092
  30. DDFSTOP = $094
  31.  
  32. ;CIA-A Port Register A (Mouse key)
  33.  
  34. CIAAPRA = $BFE001
  35.  
  36. ;Exec Library Base Offsets
  37.  
  38. OpenLibrary = -552   ; Libname,Version / a1,d0
  39. Forbid     = -132
  40. Permit     = -138
  41. AllocMem   = -198   ; Byte Size,Requirements / d0,d1
  42. FreeMem    = -210   ; Memory Block,Byte Size / a1,d0
  43.  
  44. ;Graphics base
  45.  
  46. StartList  = 38
  47.  
  48. ;Other labels
  49.  
  50. Execbase   = 4
  51. Chip       = 2 ; Constant to request CHIP RAM
  52.  
  53.  
  54. ;*** Initialise-Program ***
  55.  
  56. _start:
  57.     move.l  Execbase,a6     ; We need exec to do anything!
  58.  
  59. ; Request memory for Copperlist
  60.     moveq   #CLsize,d0  ;Set Parameter for Allocmem
  61.     moveq   #Chip,d1    ;Ask for Chip RAM
  62.     jsr AllocMem(a6)    ;Request Memory
  63.     move.l  d0,CLadr    ;Address of the RAM-area memory
  64.     beq Ende        ;Error! -> End
  65.  
  66. ;copy Copperlist to CLadr
  67.     lea CLstart,a0
  68.     move.l  CLadr,a1
  69.     moveq   #CLsize-1,d0    ;Set loop value
  70. CLcopy: move.b  (a0)+,(a1)+ ;Copy Copperlist byte for byte
  71.     dbf d0,CLcopy
  72.  
  73. ; Request memory for Single Bitplane.
  74.     move.l  #BPMemSize,d0   ;Set Parameter for Allocmem
  75.     moveq   #Chip,d1    ;Ask for Chip RAM
  76.     jsr AllocMem(a6)    ;Request Memory
  77.     move.l  d0,BPMemoryPtr  ;Address of the RAM-area memory
  78.     beq Ende        ;Error! -> End
  79.  
  80. ; Fill the bitplane with stripe pattern.
  81.         move.l  BPMemoryPtr,a0
  82.         move.l  #%1111001100110000,d0
  83.         move.l  #(BPMemSize/2-1),d1
  84. BPFill: move.w  d0,(a0)+
  85.         dbf     d1,BPFill
  86.  
  87. ; Put the address of the bitplane in the appropriate
  88. ; position in the copper list.
  89.         move.l  CLadr,a1
  90.         move.l  BPMemoryPtr,d0
  91.         move.w  d0,6(a1) ; The low word goes in BPL1PTL
  92.         swap    d0
  93.         move.w  d0,2(a1) ; The high word goes in BPL1PTH (this works?)
  94.  
  95. ;*** Main program ***
  96.  
  97.     jsr Forbid(a6)  ;Task Switching off
  98.  
  99.     lea $DFF000,a5  ;Custom chip base address.
  100.     move.w  #$03a0,DMACON(a5) ;DMA off
  101.  
  102.         move.w  #%0001001000000000,BPLCON0(a5)
  103.         ; Set one bitplane, and enable colour.
  104.  
  105.         move.w  #$3081,DIWSTRT(a5)
  106.         move.w  #$30c1,DIWSTOP(a5)
  107.         move.w  #$0038,DDFSTRT(a5)
  108.         move.w  #$00d0,DDFSTOP(a5)
  109.  
  110.         move.w  #$0,BPLCON1(a5)   ; This is scrolling
  111.         move.w  #$0,BPLCON2(a5)   ; This is sprite priority
  112.  
  113.         move.w  #$0,BPL1MOD(a5) ;modulo 0
  114.  
  115.  
  116. ; Initialise copperlist.
  117.     move.l  CLadr,COP1LC(a5)  ;Address of the Copperlist to COP1LC
  118.     clr.w   COPJMP1(a5)   ;Load copperlist in program counter
  119.  
  120.     move.w  #$8380,DMACON(a5) ;$8xxx means set... we're setting:
  121.                                   ;Master, copper and bitplane.
  122.  
  123.    
  124.     ; Turn off drive motors, all drives
  125.     st.b $bfd100
  126.         move.b #$87,$bfd100
  127.  
  128. ;Wait for left mouse key
  129.  
  130. Wait:
  131.     btst    #6,CIAAPRA  ;Bit test
  132.     bne.s   Wait        ;Done? Else continue.
  133. Wait2:
  134.     btst    #6,CIAAPRA  ;Bit test again
  135.     beq.s   Wait2       ;Done? Else continue.
  136.     move.l  CLadr,-(a7)
  137.  
  138.     lea     4(a7),a7
  139. Wait3:
  140.     btst    #6,CIAAPRA  ;Bit test again
  141.     bne.s   Wait3       ;Done? Else continue.
  142.  
  143. ;*** End program ***
  144.  
  145. ;Restore old Copper list
  146.  
  147.     move.l  #GRname,a1  ;Get parameter for OpenLibrary
  148.     clr.l   d0
  149.     jsr OpenLibrary(a6) ;Graphics Library open
  150.     move.l  d0,a4       ;Address of GrahpicsBase to a4
  151.     move.l  StartList(a4),COP1LC(a5) ;Load address of Startlist
  152.     clr.w   COPJMP1(a5)
  153.     move.w  #$83E0,DMACON(a5)   ; All DMA on
  154.     jsr Permit(a6)      ;Task-Switching on
  155.  
  156. ;Free memory of Copperlist
  157.     move.l  CLadr,a1    ;Set parameter for FreeMem
  158.     moveq   #CLsize,d0
  159.     jsr FreeMem(a6) ;Memory freed
  160.  
  161. ;Free memory of bitplane
  162.     move.l  BPMemoryPtr,a1  ;Set parameter for FreeMem
  163.     move.l  #BPMemSize,d0
  164.     jsr FreeMem(a6) ;Memory freed
  165.  
  166. Ende:
  167.     clr.l   d0      ;Error flag erased
  168.     rts         ;End program
  169.  
  170.  
  171. BPMemSize  = ((320*256)/8) ; 320 across, 256 down, 8 bits per byte.
  172.  
  173. ; Copperlist
  174.  
  175. CLstart:
  176.        dc.w    BPL1PTH,$ffff   ;The program needs to put the BP MSW adr here.
  177.         dc.w    BPL1PTL,$ffff   ;The program needs to put the BP LSW adr here.
  178.  
  179.     dc.w    COLOR00,$0000   ;Background color black
  180.     dc.w    COLOR01,$0fff   ;Foreground color white
  181. ;   dc.w    $640f,$fffe ;On line 100 change to
  182. ;   dc.w    COLOR00,$0f00   ;BG = red
  183. ;   dc.w    COLOR01,$0000   ;FG = black
  184. ;   dc.w    $be0f,$fffe ;Line 190 to
  185. ;   dc.w    COLOR00,$0fb0   ;BG = gold
  186.     dc.w    $ffff,$fffe ;Impossible position: End of copperlist
  187.  
  188. CLend:
  189. CLsize = CLend-CLstart
  190.  
  191. ; Variables
  192. CLadr:
  193.     dc.l    0
  194.  
  195. BPMemoryPtr:
  196.        dc.l    0
  197.  
  198. GRname:
  199.     dc.b    "graphics.library",0
  200.     align   0,4
  201.  
  202.  
  203. END
  204. ;End of program
Add Comment
Please, Sign In to add comment