********* REGS ************************************ ExecBase = 4 OpenLib = -552 CloseLib = -414 SysCopper = 38 CUSTOM = $DFF000 DMACONR = $002 DMACON = $096 VPOSR = $004 COP1LCH = $080 COPJMP1 = $088 COLOR00 = $180 COLOR01 = $182 BPLCON0 = $100 DIWSTRT = $08E DIWSTOP = $090 DDFSTRT = $092 DDFSTOP = $094 BPL1PTH = $0E0 BPL1PTL = $0E2 BPL2PTH = $0E4 BPL2PTL = $0E6 BPL3PTH = $0E8 BPL3PTL = $0EA BPL4PTH = $0EC BPL4PTL = $0EE BPL5PTH = $0F0 BPL5PTL = $0F2 BPL6PTH = $0F4 BPL6PTL = $0F6 ********* CONST *********************************** W = 320 ; screen/bitplane width in memory (in px) H = 200 ; screen/bitplane height in memoty (in px) BPLS = 5 ; number of bitplanes ********* INIT ************************************ run: move.l ExecBase,a6 ; get the addres of the graphics libary move.l #gfxname,a1 clr.l d0 jsr OpenLib(a6) tst.l d0 beq end move.l d0,gfxbase ; and save clr.l d0 ; get the address of the system copper move.l gfxbase,a6 move.l SysCopper(a6),d0 tst.l d0 beq end move.l d0,oldcopper ; and save lea CUSTOM,a6 ; move the base to a6 move.w DMACONR(a6),olddma ; save the current dma state ; from DMACONR move.w #$7FFF,DMACON(a6) ; deactivate all DMA channels move.w #$8380,DMACON(a6) ; activate copper+ BPL in DMA channel move.l #copper,COP1LCH(a6) ; move new copper to copper register move.w #0,COPJMP1(a6) ; (H and L) & activate new copper lea copperbpl,a0 ; set the needed variables before move.l #screen,d0 ; branching to rotine to bsr pokebpls ; poke bpls memoory ptr to copper ********* MAIN ************************************ main: bsr waitVBI ; wait for the vertical blanc ; before updating the screen btst #6,$BFE001 ; is lmb prssed bne main ; 0 = pressed ********* EXIT ************************************ clean: move.l ExecBase,a6 ; close graphics library move.l gfxbase,a1 jsr CloseLib(a6) end: lea CUSTOM,a6 move.l oldcopper,COP1LCH(a6) ; restore system copper move.w #$7FFF,DMACON(a6) ; deactivate all DMA channels or.w #$8200,olddma ; set bits 15 and 9 move.w olddma,DMACON(a6) ; retore old DMA to DMACON rts ********* ROUTINES *********************************** *** wait for vertical blank interrupt waitVBI: move.l $DFF004,d0 ; get VPOSR lsr.l #8,d0 ; shift 8 to left and.l #$1FF,d0 ; mask out the 9bits of vpos cmp.l #$138,d0 ; are we at VBI bne waitVBI ; no -> wait rts *** wait for a raster position waitraster: ; expects line to wait for in d1.w move.l $DFF004,d0 ; get VPOSR lsr.l #8,d0 ; shift 8 to left and.l #$1FF,d0 ; mask out the 9bits of vpos cmp.l d1,d0 ; are we at the wanted line bne waitraster ; no -> wait rts *** poke bipls addresses into copper * a0: bpls pointer in copperlist * d0: address of bpls in memory pokebpls: moveq #BPLS-1,d7 ; loop counter = number of bpls loopbpl: move.w d0,6(a0) ; low word in BPL1PTL swap d0 ; swap low and high move.w d0,2(a0) ; high word into BPL1PTH swap d0 ; original address back add.l #W/8*H,d0 ; d0 points to bpl2 data add.l #8,a0 ; a0 points to next bplptr dbf d7,loopbpl rts ********* DATA in FAST MEM ************************ gfxname: dc.b 'graphics.library',0 even gfxbase: ds.l 1 oldcopper: ds.l 1 olddma: ds.l 1 ********* DATA in CHIP MEM ************************ section copperlist,data_C copper: dc.w BPLCON0,BPLS<<12!$0200 ; set bitplane number dc.w DIWSTRT,$2C81 ; define display window size dc.w DIWSTOP,$F4C1 ; 320 X 200 pixels dc.w DDFSTRT,$38 ; define display data fetch dc.w DDFSTOP,$D0 ; size to 320 pxels copperbpl: dc.w BPL1PTH,$0000 ; give denise the pointer dc.w BPL1PTL,$0000 ; to the first bitplane dc.w BPL2PTH,$0000 ; give denise the pointer dc.w BPL2PTL,$0000 ; to the second bitplane dc.w BPL3PTH,$0000 ; give denise the pointer dc.w BPL3PTL,$0000 ; to the third bitplane dc.w BPL4PTH,$0000 ; give denise the pointer dc.w BPL4PTL,$0000 ; to the fotrh bitplane dc.w BPL5PTH,$0000 ; give denise the pointer dc.w BPL5PTL,$0000 ; to the fifth bitplane dc.w BPL6PTH,$0000 ; give denise the pointer dc.w BPL6PTL,$0000 ; to the sixth bitplane palette: include "AH_KingTut320x200x5.palette" dc.w $FFFF,$FFFE screen: incbin "AH_KingTut320x200x5.raw"