Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;*** Example for a simple Copperlist ***
- section main,code,chip
- ;CustomChip-Register
- INTENA = $9A ; Interrupt-Enable-Register (write)
- DMACON = $96 ; DMA-control register (write)
- COLOR00 = $0180 ; Color palette register 0
- COLOR01 = $0182 ; Color palette register 1
- VHPOSR = $6
- ;Copper Register
- COP1LC = $80 ; Address of 1. Copper list
- COP2LC = $84 ; Address of 2. Copper list
- COPJMP1 = $88 ; Jump to Copper list 1
- COPJMP2 = $8A ; Jump to Copper list 2
- BPLCON0 = $100 ; Display control registers.
- BPLCON1 = $102
- BPLCON2 = $104
- BPL1PTH = $0E0
- BPL1PTL = $0E2
- BPL1MOD = $108
- DIWSTRT = $08E
- DIWSTOP = $090
- DDFSTRT = $092
- DDFSTOP = $094
- ;CIA-A Port Register A (Mouse key)
- CIAAPRA = $BFE001
- ;Exec Library Base Offsets
- OpenLibrary = -552 ; Libname,Version / a1,d0
- Forbid = -132
- Permit = -138
- AllocMem = -198 ; Byte Size,Requirements / d0,d1
- FreeMem = -210 ; Memory Block,Byte Size / a1,d0
- ;Graphics base
- StartList = 38
- ;Other labels
- Execbase = 4
- Chip = 2 ; Constant to request CHIP RAM
- ;*** Initialise-Program ***
- _start:
- move.l Execbase,a6 ; We need exec to do anything!
- ; Request memory for Copperlist
- moveq #CLsize,d0 ;Set Parameter for Allocmem
- moveq #Chip,d1 ;Ask for Chip RAM
- jsr AllocMem(a6) ;Request Memory
- move.l d0,CLadr ;Address of the RAM-area memory
- beq Ende ;Error! -> End
- ;copy Copperlist to CLadr
- lea CLstart,a0
- move.l CLadr,a1
- moveq #CLsize-1,d0 ;Set loop value
- CLcopy: move.b (a0)+,(a1)+ ;Copy Copperlist byte for byte
- dbf d0,CLcopy
- ; Request memory for Single Bitplane.
- move.l #BPMemSize,d0 ;Set Parameter for Allocmem
- moveq #Chip,d1 ;Ask for Chip RAM
- jsr AllocMem(a6) ;Request Memory
- move.l d0,BPMemoryPtr ;Address of the RAM-area memory
- beq Ende ;Error! -> End
- ; Fill the bitplane with stripe pattern.
- move.l BPMemoryPtr,a0
- move.l #%1111001100110000,d0
- move.l #(BPMemSize/2-1),d1
- BPFill: move.w d0,(a0)+
- dbf d1,BPFill
- ; Put the address of the bitplane in the appropriate
- ; position in the copper list.
- move.l CLadr,a1
- move.l BPMemoryPtr,d0
- move.w d0,6(a1) ; The low word goes in BPL1PTL
- swap d0
- move.w d0,2(a1) ; The high word goes in BPL1PTH (this works?)
- ;*** Main program ***
- jsr Forbid(a6) ;Task Switching off
- lea $DFF000,a5 ;Custom chip base address.
- move.w #$03a0,DMACON(a5) ;DMA off
- move.w #%0001001000000000,BPLCON0(a5)
- ; Set one bitplane, and enable colour.
- move.w #$3081,DIWSTRT(a5)
- move.w #$30c1,DIWSTOP(a5)
- move.w #$0038,DDFSTRT(a5)
- move.w #$00d0,DDFSTOP(a5)
- move.w #$0,BPLCON1(a5) ; This is scrolling
- move.w #$0,BPLCON2(a5) ; This is sprite priority
- move.w #$0,BPL1MOD(a5) ;modulo 0
- ; Initialise copperlist.
- move.l CLadr,COP1LC(a5) ;Address of the Copperlist to COP1LC
- clr.w COPJMP1(a5) ;Load copperlist in program counter
- move.w #$8380,DMACON(a5) ;$8xxx means set... we're setting:
- ;Master, copper and bitplane.
- ; Turn off drive motors, all drives
- st.b $bfd100
- move.b #$87,$bfd100
- ;Wait for left mouse key
- Wait:
- btst #6,CIAAPRA ;Bit test
- bne.s Wait ;Done? Else continue.
- Wait2:
- btst #6,CIAAPRA ;Bit test again
- beq.s Wait2 ;Done? Else continue.
- move.l CLadr,-(a7)
- lea 4(a7),a7
- Wait3:
- btst #6,CIAAPRA ;Bit test again
- bne.s Wait3 ;Done? Else continue.
- ;*** End program ***
- ;Restore old Copper list
- move.l #GRname,a1 ;Get parameter for OpenLibrary
- clr.l d0
- jsr OpenLibrary(a6) ;Graphics Library open
- move.l d0,a4 ;Address of GrahpicsBase to a4
- move.l StartList(a4),COP1LC(a5) ;Load address of Startlist
- clr.w COPJMP1(a5)
- move.w #$83E0,DMACON(a5) ; All DMA on
- jsr Permit(a6) ;Task-Switching on
- ;Free memory of Copperlist
- move.l CLadr,a1 ;Set parameter for FreeMem
- moveq #CLsize,d0
- jsr FreeMem(a6) ;Memory freed
- ;Free memory of bitplane
- move.l BPMemoryPtr,a1 ;Set parameter for FreeMem
- move.l #BPMemSize,d0
- jsr FreeMem(a6) ;Memory freed
- Ende:
- clr.l d0 ;Error flag erased
- rts ;End program
- BPMemSize = ((320*256)/8) ; 320 across, 256 down, 8 bits per byte.
- ; Copperlist
- CLstart:
- dc.w BPL1PTH,$ffff ;The program needs to put the BP MSW adr here.
- dc.w BPL1PTL,$ffff ;The program needs to put the BP LSW adr here.
- dc.w COLOR00,$0000 ;Background color black
- dc.w COLOR01,$0fff ;Foreground color white
- ; dc.w $640f,$fffe ;On line 100 change to
- ; dc.w COLOR00,$0f00 ;BG = red
- ; dc.w COLOR01,$0000 ;FG = black
- ; dc.w $be0f,$fffe ;Line 190 to
- ; dc.w COLOR00,$0fb0 ;BG = gold
- dc.w $ffff,$fffe ;Impossible position: End of copperlist
- CLend:
- CLsize = CLend-CLstart
- ; Variables
- CLadr:
- dc.l 0
- BPMemoryPtr:
- dc.l 0
- GRname:
- dc.b "graphics.library",0
- align 0,4
- END
- ;End of program
Add Comment
Please, Sign In to add comment