mirror of
https://frontier.innolan.net/github/AmigaExamples.git
synced 2026-09-12 03:12:24 +00:00
Slightly simplified the blit routine
This commit is contained in:
+12
-12
@@ -7,21 +7,20 @@
|
||||
entry:
|
||||
lea CUSTOM,a6
|
||||
bsr init
|
||||
|
||||
|
||||
lea bitplanes(pc),a0
|
||||
lea emoji,a1
|
||||
lea emojiMask,a2
|
||||
.mainLoop:
|
||||
bsr waitvbl
|
||||
bsr moveBlitterObject
|
||||
bra.s .mainLoop
|
||||
|
||||
include "blit.s"
|
||||
include "init.s"
|
||||
|
||||
level3InterruptHandler:
|
||||
movem.l d0-a6,-(sp)
|
||||
move.w #INTF_VERTB,INTREQ(a6) ; clear interrupt bit
|
||||
|
||||
.moveBlitterObject:
|
||||
include "utils.s"
|
||||
|
||||
moveBlitterObject:
|
||||
lea xpos(pc),a3
|
||||
lea ypos(pc),a4
|
||||
add.l #1,xpos ; move the blitter object one pixel to the left
|
||||
@@ -35,12 +34,13 @@ level3InterruptHandler:
|
||||
bne.s .done
|
||||
move.l #0,ypos ; wrap y back to 0
|
||||
.done:
|
||||
rts
|
||||
|
||||
|
||||
.interruptComplete:
|
||||
movem.l (sp)+,d0-a6
|
||||
rte
|
||||
|
||||
|
||||
installPalette:
|
||||
include "out/image-palette.s"
|
||||
rts
|
||||
|
||||
xpos: dc.l 0
|
||||
ypos: dc.l 0
|
||||
|
||||
|
||||
Binary file not shown.
+15
-19
@@ -51,20 +51,16 @@ blitObject64:
|
||||
;; d1 = YPOS
|
||||
;; d4 = XPOS_BYTES
|
||||
|
||||
move.l d0,d2 ; d2 = XPOS
|
||||
move.l d0,d3 ; d3 = XPOS
|
||||
lsr.l #3,d3 ; d3 = XPOS_BYTES
|
||||
move.l d3,d4 ; d4 = XPOS_BYTES
|
||||
move.l d0,d3 ; d3 = XPOS
|
||||
lsr.l #4,d3 ; d3 = XPOS_WORDS
|
||||
lsl.l #4,d3 ; d3 = XPOS_NEAREST_WORD
|
||||
sub.l d3,d2 ; d2 = num pixels to shift
|
||||
lsl.w #8,d2 ; BLIT_SOURCE_SHIFT<<BLIT_ASHIFTSHIFT
|
||||
lsl.w #4,d2 ; BLIT_SOURCE_SHIFT<<BLIT_ASHIFTSHIFT
|
||||
move.w d0,d4 ; d4 = XPOS
|
||||
lsr.w #3,d4 ; d4 = XPOS_BYTES
|
||||
|
||||
move.w d2,BLTCON1(A6)
|
||||
ori.w #BLIT_SRCA|BLIT_SRCB|BLIT_SRCC|BLIT_DEST|BLIT_LF_MINTERM,d2
|
||||
move.w d2,BLTCON0(A6)
|
||||
;; this shift will give us the bits to shift (bits 0-3) in bits (12-15) of d0
|
||||
lsl.w #8,d0 ; BLIT_SOURCE_SHIFT<<BLIT_ASHIFTSHIFT
|
||||
lsl.w #4,d0 ; BLIT_SOURCE_SHIFT<<BLIT_ASHIFTSHIFT
|
||||
|
||||
move.w d0,BLTCON1(A6)
|
||||
ori.w #BLIT_SRCA|BLIT_SRCB|BLIT_SRCC|BLIT_DEST|BLIT_LF_MINTERM,d0
|
||||
move.w d0,BLTCON0(A6)
|
||||
|
||||
move.w #$ffff,BLTAFWM(a6) ; no mask for first word
|
||||
move.w #$0000,BLTALWM(a6) ; mask out last word
|
||||
@@ -75,13 +71,13 @@ blitObject64:
|
||||
move.l a2,BLTAPTH(a6) ; mask bitplane
|
||||
move.l a1,BLTBPTH(a6) ; bob bitplane
|
||||
|
||||
move.l #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,d3 ; d3 = SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH
|
||||
move.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,d3 ; d3 = SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH
|
||||
mulu.w d1,d3 ; d3 = YPOS*SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH
|
||||
move.l a0,d2 ; d2 = #bitplanes
|
||||
add.l d4,d2 ; d2 = #bitplanes+XPOS_BYTES
|
||||
add.l d3,d2 ; d2 = #bitplanes+XPOS_BYTES+(YPOS*SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH)
|
||||
move.l d2,BLTCPTH(a6) ;background top left corner
|
||||
move.l d2,BLTDPTH(a6) ;destination top left corner
|
||||
move.l a0,d0 ; d0 = #bitplanes
|
||||
add.w d4,d0 ; d0 = #bitplanes+XPOS_BYTES
|
||||
add.w d3,d0 ; d0 = #bitplanes+XPOS_BYTES+(YPOS*SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH)
|
||||
move.l d0,BLTCPTH(a6) ;background top left corner
|
||||
move.l d0,BLTDPTH(a6) ;destination top left corner
|
||||
|
||||
move.w #(BLIT_BOB_HEIGHT64*SCREEN_BIT_DEPTH)<<6|(BLIT_BOB_WIDTH64_WORDS),BLTSIZE(a6) ;rectangle size, starts blit
|
||||
movem.l (sp)+,d0-a6
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
init:
|
||||
movem.l d0-a6,-(sp)
|
||||
move #$7ff,DMACON(a6) ; disable all dma
|
||||
move #$7fff,INTENA(a6) ; disable all interrupts
|
||||
|
||||
lea level3InterruptHandler(pc),a3
|
||||
move.l a3,LVL3_INT_VECTOR
|
||||
move #$7fff,INTENA(a6) ; disable all interrupts
|
||||
|
||||
include "out/image-palette.s"
|
||||
;; set up default palette
|
||||
bsr.s installPalette
|
||||
|
||||
;; set up playfield
|
||||
move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6)
|
||||
@@ -38,6 +36,6 @@ init:
|
||||
move.l a0,COP1LC(a6)
|
||||
move.w COPJMP1(a6),d0
|
||||
move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_COPPER!DMAF_RASTER!DMAF_MASTER),DMACON(a6)
|
||||
move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6)
|
||||
;; move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6)
|
||||
movem.l (sp)+,d0-a6
|
||||
rts
|
||||
@@ -7,3 +7,17 @@ waitvbl:
|
||||
movem.l (sp)+,d0-a6
|
||||
rts
|
||||
|
||||
|
||||
|
||||
waitRaster: ;wait for rasterline d0.w. Modifies d0-d2/a0.
|
||||
movem.l d0-a6,-(sp)
|
||||
move.l #$1ff00,d2
|
||||
lsl.l #8,d0
|
||||
and.l d2,d0
|
||||
lea $dff004,a0
|
||||
.wr: move.l (a0),d1
|
||||
and.l d2,d1
|
||||
cmp.l d1,d0
|
||||
bne.s .wr
|
||||
movem.l (sp)+,d0-a6
|
||||
rts
|
||||
Reference in New Issue
Block a user