Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2012
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 KB | None | 0 0
  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.  
  101.  
  102. ; Turn off drive motors, all drives
  103. st.b $bfd100
  104. move.b #$87,$bfd100
  105.  
  106. move.w #$03a0,DMACON(a5) ;DMA off
  107.  
  108. move.w #%0001001000000000,BPLCON0(a5)
  109. ; Set one bitplane, and enable colour.
  110.  
  111. move.w #$3081,DIWSTRT(a5)
  112. move.w #$30c1,DIWSTOP(a5)
  113. move.w #$0038,DDFSTRT(a5)
  114. move.w #$00d0,DDFSTOP(a5)
  115.  
  116. move.w #$0,BPLCON1(a5) ; This is scrolling
  117. move.w #$0,BPLCON2(a5) ; This is sprite priority
  118.  
  119. move.w #$0,BPL1MOD(a5) ;modulo 0
  120.  
  121.  
  122. ; Initialise copperlist.
  123. move.l CLadr,COP1LC(a5) ;Address of the Copperlist to COP1LC
  124. clr.w COPJMP1(a5) ;Load copperlist in program counter
  125.  
  126. move.w #$8380,DMACON(a5) ;$8xxx means set... we're setting:
  127. ;Master, copper and bitplane.
  128.  
  129. ;Wait for left mouse key
  130.  
  131. Wait:
  132. btst #6,CIAAPRA ;Bit test
  133. bne.s Wait ;Done? Else continue.
  134. Wait2:
  135. btst #6,CIAAPRA ;Bit test again
  136. beq.s Wait2 ;Done? Else continue.
  137. move.l CLadr,-(a7)
  138.  
  139. lea 4(a7),a7
  140. Wait3:
  141. btst #6,CIAAPRA ;Bit test again
  142. bne.s Wait3 ;Done? Else continue.
  143.  
  144. ;*** End program ***
  145.  
  146. ;Restore old Copper list
  147.  
  148. move.l #GRname,a1 ;Get parameter for OpenLibrary
  149. clr.l d0
  150. jsr OpenLibrary(a6) ;Graphics Library open
  151. move.l d0,a4 ;Address of GrahpicsBase to a4
  152. move.l StartList(a4),COP1LC(a5) ;Load address of Startlist
  153. clr.w COPJMP1(a5)
  154. move.w #$83E0,DMACON(a5) ; All DMA on
  155. jsr Permit(a6) ;Task-Switching on
  156.  
  157. ;Free memory of Copperlist
  158. move.l CLadr,a1 ;Set parameter for FreeMem
  159. moveq #CLsize,d0
  160. jsr FreeMem(a6) ;Memory freed
  161.  
  162. ;Free memory of bitplane
  163. move.l BPMemoryPtr,a1 ;Set parameter for FreeMem
  164. move.l #BPMemSize,d0
  165. jsr FreeMem(a6) ;Memory freed
  166.  
  167. Ende:
  168. clr.l d0 ;Error flag erased
  169. rts ;End program
  170.  
  171.  
  172. BPMemSize = ((320*256)/8) ; 320 across, 256 down, 8 bits per byte.
  173.  
  174. ; Copperlist
  175.  
  176. CLstart:
  177. dc.w BPL1PTH,$ffff ;The program needs to put the BP MSW adr here.
  178. dc.w BPL1PTL,$ffff ;The program needs to put the BP LSW adr here.
  179.  
  180. dc.w COLOR00,$0000 ;Background color black
  181. dc.w COLOR01,$0fff ;Foreground color white
  182. ; dc.w $640f,$fffe ;On line 100 change to
  183. ; dc.w COLOR00,$0f00 ;BG = red
  184. ; dc.w COLOR01,$0000 ;FG = black
  185. ; dc.w $be0f,$fffe ;Line 190 to
  186. ; dc.w COLOR00,$0fb0 ;BG = gold
  187. dc.w $ffff,$fffe ;Impossible position: End of copperlist
  188.  
  189. CLend:
  190. CLsize = CLend-CLstart
  191.  
  192. ; Variables
  193. CLadr:
  194. dc.l 0
  195.  
  196. BPMemoryPtr:
  197. dc.l 0
  198.  
  199. GRname:
  200. dc.b "graphics.library",0
  201. align 0,4
  202.  
  203.  
  204. END
  205. ;End of program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement