diff --git a/018.vert_scroll/Makefile b/018.vert_scroll/Makefile new file mode 100644 index 0000000..00b268f --- /dev/null +++ b/018.vert_scroll/Makefile @@ -0,0 +1,19 @@ +MODULE=vert_scroll.s +FLOPPY=bin/vert_scroll.adf +IMAGEDATA=out/image-palette.s out/image-ham.bin +IMAGEFILE=../assets/gigi_full.png +SIZED_IMAGEFILE=out/image.png + +EXTRA=$(IMAGEDATA) init.s utils.s constants.i Makefile +BASE_ADDRESS=10000 +DITHER=--dither + +include ../shared/base.mk + +$(SIZED_IMAGEFILE): $(IMAGEFILE) $(RESIZE) Makefile + $(RESIZE) --width=320 --height=512 --blur=0.75 --input=$(IMAGEFILE) --output=$(SIZED_IMAGEFILE) + +$(IMAGEDATA): $(IMAGECON) $(SIZED_IMAGEFILE) Makefile + $(IMAGECON) --input $(SIZED_IMAGEFILE) --output out/image --colors 32 --output-bitplanes --output-palette-asm $(USE_PALETTE) --output-palette $(DITHER) --quantize + + diff --git a/018.vert_scroll/README.md b/018.vert_scroll/README.md new file mode 100644 index 0000000..3b9f5d1 --- /dev/null +++ b/018.vert_scroll/README.md @@ -0,0 +1,14 @@ +vertically scrolling the playfield +================================== + +Vertically scrolling the playfield is the easiest thing to do on the amiga ;-) + +Just offset the bitplane pointer addresses by the number of lines you want to scroll, and make sure you have enough bitplane data. + +Set the scroll speed by changing ```SCROLL_SPEED``` in [constants.i](constants.i) + +try it +------ + * [Download disk image](bin/vert_scroll.adf?raw=true) + * Run in SAE + diff --git a/018.vert_scroll/bin/vert_scroll.adf b/018.vert_scroll/bin/vert_scroll.adf new file mode 100644 index 0000000..a40a198 Binary files /dev/null and b/018.vert_scroll/bin/vert_scroll.adf differ diff --git a/018.vert_scroll/constants.i b/018.vert_scroll/constants.i new file mode 100644 index 0000000..780bc37 --- /dev/null +++ b/018.vert_scroll/constants.i @@ -0,0 +1,12 @@ +SCROLL_SPEED equ 5 +VPOSRLOFBIT equ 15 +LVL3_INT_VECTOR equ $6c +SCREEN_WIDTH equ 320 +SCREEN_HEIGHT equ (256) +SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8) +SCREEN_BIT_DEPTH equ 5 +SCREEN_RES equ 8 ; 8=lo resolution, 4=hi resolution +RASTER_X_START equ $81 ; hard coded coordinates from hardware manual +RASTER_Y_START equ $2c +RASTER_X_STOP equ RASTER_X_START+SCREEN_WIDTH +RASTER_Y_STOP equ RASTER_Y_START+256 diff --git a/018.vert_scroll/init.s b/018.vert_scroll/init.s new file mode 100644 index 0000000..6615edc --- /dev/null +++ b/018.vert_scroll/init.s @@ -0,0 +1,33 @@ + include "../include/bplconbits.i" + ;; custom chip base globally in a6 +init: + movem.l d0-a6,-(sp) + move #$7ff,DMACON(a6) ; disable all dma + move #$7fff,INTENA(a6) ; disable all interrupts + + ;; set up default palette + bsr.s installColorPalette + + moveq.l #0,d0 + lea copper(pc),a0 + bsr.s pokeBitplanePointers + + ;; set up playfield + move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6) + move.w #((RASTER_Y_STOP-256)<<8)|(RASTER_X_STOP-256),DIWSTOP(a6) + + move.w #(RASTER_X_START/2-SCREEN_RES),DDFSTRT(a6) + move.w #(RASTER_X_START/2-SCREEN_RES)+(8*((SCREEN_WIDTH/16)-1)),DDFSTOP(a6) + + move.w #(SCREEN_BIT_DEPTH<<12)|COLOR_ON,BPLCON0(a6) + move.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL1MOD(a6) + move.w #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH-SCREEN_WIDTH_BYTES,BPL2MOD(a6) + + ;; install copper list, then enable dma and selected interrupts + lea copper(pc),a0 + 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) + movem.l (sp)+,d0-a6 + rts \ No newline at end of file diff --git a/018.vert_scroll/utils.s b/018.vert_scroll/utils.s new file mode 100644 index 0000000..bdde568 --- /dev/null +++ b/018.vert_scroll/utils.s @@ -0,0 +1,23 @@ +waitVerticalBlank: + movem.l d0-a6,-(sp) +.loop move.l $dff004,d0 + and.l #$1ff00,d0 + cmp.l #303<<8,d0 + bne.b .loop + 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 \ No newline at end of file diff --git a/018.vert_scroll/vert_scroll.s b/018.vert_scroll/vert_scroll.s new file mode 100644 index 0000000..57a44a1 --- /dev/null +++ b/018.vert_scroll/vert_scroll.s @@ -0,0 +1,92 @@ + include "../include/registers.i" + include "hardware/dmabits.i" + include "hardware/intbits.i" + + include "constants.i" + +entry: + lea CUSTOM,a6 + bsr init + + +.mainLoop: + bsr waitVerticalBlank + bsr scrollPlayfield + bra .mainLoop + + +scrollPlayfield: + movem.l d0-a6,-(sp) + move.l vpos,d0 + lea copper(pc),a0 + bsr pokeBitplanePointers + cmp.l #1,directionUp + beq .up + add.l #SCROLL_SPEED*SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,vpos + cmp.l #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH*256,vpos + bge .switchToUp + bra .done +.switchToUp: + move.l #1,directionUp + move.l #SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH*256,vpos + bra .done +.up: + sub.l #SCROLL_SPEED*SCREEN_WIDTH_BYTES*SCREEN_BIT_DEPTH,vpos + cmp.l #0,vpos + ble .switchToDown + bra .done +.switchToDown: + move.l #0,directionUp + move.l #0,vpos + bra .done +.done: + movem.l (sp)+,d0-a6 + rts + + include "init.s" + include "utils.s" + +pokeBitplanePointers: + ;; d0 = scroll offset + ;; a0 = BPLP copper list address + movem.l d0-a6,-(sp) + lea bitplanes(pc),a1 + add.l d0, a1 + moveq #SCREEN_BIT_DEPTH-1,d0 +.bitplaneloop: + move.l a1,d1 + move.w d1,2(a0) + swap d1 + move.w d1,6(a0) + lea SCREEN_WIDTH_BYTES(a1),a1 + addq #8,a0 + dbra d0,.bitplaneloop + movem.l (sp)+,d0-a6 + rts + + +installColorPalette: + include "out/image-palette.s" + rts + +vpos: + dc.l 0 +directionUp: + dc.l 0 + +copper: + ;; bitplane pointers must be first else poking addresses will be incorrect + dc.w BPL1PTL,0 + dc.w BPL1PTH,0 + dc.w BPL2PTL,0 + dc.w BPL2PTH,0 + dc.w BPL3PTL,0 + dc.w BPL3PTH,0 + dc.w BPL4PTL,0 + dc.w BPL4PTH,0 + dc.w BPL5PTL,0 + dc.w BPL5PTH,0 + dc.l $fffffffe + +bitplanes: + incbin "out/image.bin" \ No newline at end of file