Agnus handles the following on the Amiga:
You need to control DMACON: http://coppershade.org/articles/Code/Reference/DMACON/
DMACON.COPPER EQU %0000000010000000 DMACON.BITPLANE EQU %0000000100000000 DMACON.BLITTER EQU %0000000001000000 MOVE.W #%1000000111000000,DMACON MOVE.W #%0000000000111111,DMACON
#include <hardware/dmabits.h> // enable custom.dmacon = DMAF_SETCLR | DMAF_COPPER | DMAF_RASTER | DMAF_BLITTER; // disable custom.dmacon = DMAF_AUDIO | DMAF_DISK | DMAF_SPRITE;
There seems to be a real common pattern of setting:
BPLCON0/1
for bitplanes, resolution, and scrollBPL1/2MOD
for dealing with how bitplane data is storedDIWSTRT/DIWSTOP
for setting the corners of the displayThe normal NTSC DIWSTRT is ($2C81). The normal NTSC DIWSTOP is ($F4C1). The normal PAL DIWSTRT is ($2C81). The normal PAL DIWSTOP is ($2CC1).
PAL Lowres, 5 bitplanes
BPLCON0.COLOR EQU %0000001000000000 BPLCON0.BPU_5 EQU %0101000000000000 MOVE.W #(BPLCON0.COLOR|BPLCON0.BPU_5),BPLCON0 MOVE.W #0,BPLCON1 MOVE.W #0,BPL1MOD MOVE.W #0,BPL2MOD MOVE.W #$2C21,DIWSTRT MOVE.W #$2CC1,DIWSTOP ;MOVE.W #$38C1,DIWSTOP MOVE.W #$0038,DDFSTRT MOVE.W #$00D0,DDFSTOP
The code that is everywhere is:
WaitVBL: MOVE.L $DFF004,D0 AND.L #$1FF00,D0 CMP.L #300<<8,D0 BNE.B WaitVBL
void WaitVBL() { while ((custom.vposr & 0x1FF00) != (300 << 8)) {} }
This works because you're reading both `VPOSR` and `VHPOSR` in one operation into D0:
VPOSR VHPOSR | | | | | | | | | | | | | | | | | V8 | V7 | V6 | V5 | V4 | V3 | V2 | V1 | V0 | h | h | h | h | h | h | h | h |
AND.L #$1FF000,D0
masks out the h
and keeps the V#
. CMP.L #Height<<8
shifts height over 8 bits to the left, then compares the value to the results of the AND.
If you run this on an NTSC Amiga it will lock up!
There's also http://ada.untergrund.net/?p=boardthread&id=31&page=last
hardware/dmabits.h
– http://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodocs_2._guide/node00C8.htmlThese are bits that are ORed together. Remember, the more you enable, the more contention there is for RAM and CPU timing, especially on even clock cycles.
0-3 -- DMAF_AUDIO
– all four Paula audio channelsDMAF_AUD(0-3)
– the individual channels4 -- DMAF_DISK
– the floppy disk5 -- DMAF_SPRITE
– render sprites6 -- DMAF_BLITTER
– the blitter7 -- DMAF_COPPER
– the copper8 -- DMAF_RASTER
– denise screen rendering9 -- DMAF_MASTER
– enable all of the DMA not related to blitter settings10 -- DMAF_BLITHOG
– blitter wins over CPU15 -- DMAF_SETCLR
– enable these flags
You can also read some blitter-related flags on DMACONR
:
13 -- DMAF_BLTNZERO
– A blit operation happened and only zeroes were written14 -- DMAF_BLTDONE
– 0 if not working, 1 if busy