From e1e1b579575cc1d9838e0958322c6f6b5939a5c7 Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Mon, 14 Mar 2016 15:53:23 +1100 Subject: [PATCH] Working hori scroller --- 019.hori_scroll/hori_scroll.s | 68 +++++++++++++++++++++-------------- 019.hori_scroll/init.s | 6 ++-- 019.hori_scroll/utils.s | 4 +-- 3 files changed, 46 insertions(+), 32 deletions(-) diff --git a/019.hori_scroll/hori_scroll.s b/019.hori_scroll/hori_scroll.s index f905134..c44bed2 100644 --- a/019.hori_scroll/hori_scroll.s +++ b/019.hori_scroll/hori_scroll.s @@ -4,45 +4,53 @@ include "constants.i" -entry: +Entry: lea CUSTOM,a6 - bsr init + bsr Init .mainLoop: - bsr waitVerticalBlank - ;; bsr scrollPlayfield - bsr horiScrollPlayfield - bsr updateHoriScrollPos + bsr WaitVerticalBlank + + move.l #0,bitplaneAddress + bsr HoriScrollPlayfield + bsr VertScrollPlayfield + lea copper(pc),a0 + move.l bitplaneAddress,d0 + bsr PokeBitplanePointers + + bsr UpdateHoriScrollPos + bsr UpdateVertScrollPos bra .mainLoop -setupBitScroll: +SetupHoriScrollBitDelay: ;; d0 = number of bits to scroll movem.l d0/d1,-(sp) - move.l d0,d1 + move.w d0,d1 lsl.w #4,d1 or.w d1,d0 move.w d0,BPLCON1(a6) movem.l (sp)+,d0/d1 rts - -horiScrollPlayfield: + + +HoriScrollPlayfield: movem.l d0-a6,-(sp) move.l hpos,d0 lsr.l #3,d0 ;bytes to scroll - lea copper(pc),a0 - bsr pokeBitplanePointers + add.l d0,bitplaneAddress move.l hpos,d1 and.l #$F,d1 move.l #$F,d0 - sub.l d1,d0 - bsr setupBitScroll + sub.l d1,d0 ;bits to delay + bsr SetupHoriScrollBitDelay .done: movem.l (sp)+,d0-a6 rts -updateHoriScrollPos: + +UpdateHoriScrollPos: movem.l d0-a6,-(sp) cmp.l #1,directionLeft beq .left @@ -66,12 +74,10 @@ updateHoriScrollPos: .done: movem.l (sp)+,d0-a6 rts - -scrollPlayfield: + + +UpdateVertScrollPos: 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 @@ -94,11 +100,17 @@ scrollPlayfield: .done: movem.l (sp)+,d0-a6 rts + + +VertScrollPlayfield: + movem.l d0-a6,-(sp) + move.l vpos,d0 + add.l d0,bitplaneAddress + movem.l (sp)+,d0-a6 + rts - include "init.s" - include "utils.s" - -pokeBitplanePointers: + +PokeBitplanePointers: ;; d0 = scroll offset ;; a0 = BPLP copper list address movem.l d0-a6,-(sp) @@ -115,13 +127,15 @@ pokeBitplanePointers: dbra d0,.bitplaneloop movem.l (sp)+,d0-a6 rts - -installColorPalette: +InstallColorPalette: include "out/image-palette.s" rts -counter: + include "init.s" + include "utils.s" + +bitplaneAddress: dc.l 0 vpos: dc.l 0 diff --git a/019.hori_scroll/init.s b/019.hori_scroll/init.s index 0143c0f..7f70653 100644 --- a/019.hori_scroll/init.s +++ b/019.hori_scroll/init.s @@ -1,16 +1,16 @@ include "../include/bplconbits.i" ;; custom chip base globally in a6 -init: +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 + bsr.s InstallColorPalette moveq.l #0,d0 lea copper(pc),a0 - bsr.s pokeBitplanePointers + bsr.s PokeBitplanePointers ;; set up playfield move.w #(RASTER_Y_START<<8)|RASTER_X_START,DIWSTRT(a6) diff --git a/019.hori_scroll/utils.s b/019.hori_scroll/utils.s index bdde568..de1d279 100644 --- a/019.hori_scroll/utils.s +++ b/019.hori_scroll/utils.s @@ -1,4 +1,4 @@ -waitVerticalBlank: +WaitVerticalBlank: movem.l d0-a6,-(sp) .loop move.l $dff004,d0 and.l #$1ff00,d0 @@ -9,7 +9,7 @@ waitVerticalBlank: -waitRaster: ;wait for rasterline d0.w. Modifies d0-d2/a0. +WaitRaster: ;wait for rasterline d0.w. Modifies d0-d2/a0. movem.l d0-a6,-(sp) move.l #$1ff00,d2 lsl.l #8,d0