View Single Post
Old 22 February 2013, 12:40   #3
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,519
As hooverphonique already mentioned you will use the Blitter's barrel shifter when you want to write a BOb to an x-position which is not word-aligned.

To make shifting work you have to read and write an extra word. This is the space where the barrel shifter will shift the bits. You will choose a BLTAFWM of $ffff and a BLTALWM of $0000 to ignore the extra word being read and written. The ASH value shifts the mask in BLTAFWM/BLTALWM as well as the source A, which is preloaded with $ffff, to function as a mask for your BOb (A can also be pointed to a variable mask in memory).

The minterm used is $CA, for D = (A & B) | (!A & C).

You see that you also need the B and the C channel. B is the source which is pointing to the image of your BOB. The A channel defines which pixels are blitted from B onto the screen (D). The C channel is used to read the screen destination, so a pixel from the screen will be preserved in those regions where the mask is 0.

BSH must be used to shift the B source by the same amount as A. In your case it would be 0 when the destination pointer is word aligned and 8 when not.

Below you find a quick draft of what to do (unfortunately I didn't test it). But it can easily be extended to place masked BOBs at arbitrary coordinates on the screen.

Code:
TILE_BLTDMOD    equ    HARDWARE_WIDTH-(TILE_WIDTH+2)
TILE_BLTAMOD    equ    TILE_HARDWIDTH-(TILE_WIDTH+2)

    moveq    #-1,d4
    clr.w    d4            ; BLTAFWM=$ffff, BLTALWM=$0000

    move.l    #TILE_BLTAMOD<<16|TILE_BLTDMOD,d5
    move.w    #8<<6|2,d6        ; 8 lines, 1 word (+1 extra word)

    move.l    #$07ca0000,d7        ; BLTCON0: use B,C,D, D=AB+/AC, CON1=0

    ; word-align source and destination pointer
    moveq    #-2,d2
    move.l    a5,d1
    and.l    d2,d1            ; d1 source
    move.l    a6,d0
    btst    #0,d0
    beq    aligned
    or.l    #$80008000,d7        ; set BLTCON0 ASH=8, BLTCON1 BSH=8
aligned:
    and.l    d2,d0            ; d0 destination

drawbob:
    btst    #6,DMACONR
    bne    drawbob

    move.l    d7,BLTCON0
    move.l    d5,BLTAMOD        ; set AMOD and DMOD
    swap    d5
    move.l    d5,BLTCMOD        ; set CMOD=DMOD and BMOD=AMOD
    movem.l    d0-d1,BLTAPTH        ; set BLTCPT and BLTBPT
    move.l    d0,BLTDPTH        ; BLTDPT==BLTCPT
    move.w    #$ffff,BLTADAT        ; always read $ffff from A as src mask
    move.l    d4,BLTAFWM
    move.w    d6,BLTSIZE
phx is offline  
 
Page generated in 0.04532 seconds with 11 queries