Code:
;===========================================================================
; Draw Multiple Rows Of 2 BitPlanes Tiles To Screen
;===========================================================================
section Tutorial,code_c
move.l 4,a6 ;Get base of exec lib
lea gfxlib(pc),a1 ;Address of gfxlib string to a1
jsr OpenLib(a6) ;Call OpenLibrary()
move.l d0,gfxbase ;Save base of graphics library
;-------------------------------------------------------------------------
SetupBitPlanePointers:
lea BitPlanePointers,a0
;Insert bitplane addresses into bitplane pointers into 'copperlist'
move.l #BitPlane1,d0
move.l #BitPlane2,d1
move.w d0,6(a0)
swap d0
move.w d0,2(a0)
move.w d1,14(a0)
swap d1
move.w d1,10(a0)
Draw2BitPlaneTileToScreen:
move.l #BitPlane1,a0
move.l #BitPlane2,a1
move.l #Tile1BitPlane1,a2
move.l #Tile1BitPlane2,a3
move.l #15,d0 ;Tile Lenght
move.l #19,d1 ;Tiles Drawn Count
move.l #12,d2 ;Rows Counter
DrawLoop:
move.w (a2)+,(a0)
move.w (a3)+,(a1)
add.l #40,a0
add.l #40,a1
dbra d0,DrawLoop
sub.l #638,a0
sub.l #638,a1
move.l #Tile1BitPlane1,a2
move.l #Tile1BitPlane2,a3
move.l #15,d0 ;Tile Lenght
dbra d1,DrawLoop
add.l #640,a0
add.l #640,a1
move.l #19,d1 ;Tiles Drawn Count
dbra d2,DrawLoop
move.l #CopperList,$dff080
mouse:
btst #6,$bfe001 ;Left mouse clicked?
bne mouse ;No,continue loop until mouse pressed
move.l gfxbase(pc),a1 ;Base of graphics.library to a1
move.l 38(a1),$dff080 ;Restore old copperlist
jsr -414(a6) ;Call CloseLibrary()
moveq #0,d0
rts
;-------------------------------------------------------------------------
CopperList:
dc.w $008e,$2c81,$0090,$3fc1 ; Setting up display,
dc.w $0092,$0038,$0094,$00d0 ; modulo and so on
dc.w $0102,$0000,$0104,$0000 ;Sprite Priority"No Sprites"
dc.w $0106,$0000,$0108,$0000
dc.w $010a,$0000
;-------------------------------------------------------------------------
SpritePointers:
dc.w $0120,NullSprite,$0122,NullSprite
dc.w $0124,NullSprite,$0126,NullSprite
dc.w $0128,NullSprite,$012a,NullSprite
dc.w $012c,NullSprite,$012e,NullSprite
dc.w $0130,NullSprite,$0132,NullSprite
dc.w $0134,NullSprite,$0136,NullSprite
dc.w $0138,NullSprite,$013a,NullSprite
dc.w $013c,NullSprite,$013e,NullSprite
;-------------------------------------------------------------------------
; Setting up the colors
;-------------------------------------------------------------------------
dc.w BitPlaneColor0,$0000,BitPlaneColor1,$0f00
dc.w BitPlaneColor2,$0a0f,BitPlaneColor3,$000f
;-------------------------------------------------------------------------
dc.w $0100,$2200 ;2 Bitplanes,Color Burst
;-------------------------------------------------------------------------
BitPlanePointers:
;-------------------------------------------------------------------------
dc.w $00e0,$0000,$00e2,$0000 ;BitPlanePointer1
dc.w $00e4,$0000,$00e6,$0000 ;BitPlanePointer2
dc.w $ffff,$fffe
;-------------------------------------------------------------------------
Tile1BitPlane1:
dc.w %1111111111111111
dc.w %1000000000000001
dc.w %1011111111111101
dc.w %1010000000000101
dc.w %1010000000000101
dc.w %1010000000000101
dc.w %1010000110000101
dc.w %1010000110000101
dc.w %1010001111000101
dc.w %1010001111000101
dc.w %1010000000000101
dc.w %1010000000000101
dc.w %1010000000000101
dc.w %1011111111111101
dc.w %1000000000000001
dc.w %1111111111111111
Tile1BitPlane2:
dc.w %0000000000000000
dc.w %0000000000000000
dc.w %0011111111111100
dc.w %0010000000000100
dc.w %0010000000000100
dc.w %0010000000000100
dc.w %0010000000000100
dc.w %0010000000000100
dc.w %0010000000000100
dc.w %0010000000000100
dc.w %0010000000000100
dc.w %0010000000000100
dc.w %0010000000000100
dc.w %0011111111111100
dc.w %0000000000000000
dc.w %0000000000000000
;-----------------------------------------------
;Equates
;-----------------------------------------------
BitPlaneColor0 equ $0180
BitPlaneColor1 equ $0182
BitPlaneColor2 equ $0184
BitPlaneColor3 equ $0186
NullSprite EQU $0000
;---------------------------------------------------------------
OpenLib equ -408
gfxlib: dc.b "graphics.library",0,0
gfxbase: dc.l 0
;---------------------------------------------------------------
section blah,bss_c
;---------------------------------------------------------------
BitPlane1: ds.b 320*256/8*1
BitPlane2: ds.b 320*256/8*1