mirror of
https://frontier.innolan.net/github/AmigaExamples.git
synced 2025-11-20 09:43:54 +00:00
Vertical scroll example
This commit is contained in:
19
018.vert_scroll/Makefile
Normal file
19
018.vert_scroll/Makefile
Normal file
@ -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
|
||||||
|
|
||||||
|
|
||||||
14
018.vert_scroll/README.md
Normal file
14
018.vert_scroll/README.md
Normal file
@ -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)
|
||||||
|
* <a href="http://alpine9000.github.io/ScriptedAmigaEmulator/#amiga_examples/vert_scroll.adf" target="_blank">Run in SAE</a>
|
||||||
|
|
||||||
BIN
018.vert_scroll/bin/vert_scroll.adf
Normal file
BIN
018.vert_scroll/bin/vert_scroll.adf
Normal file
Binary file not shown.
12
018.vert_scroll/constants.i
Normal file
12
018.vert_scroll/constants.i
Normal file
@ -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
|
||||||
33
018.vert_scroll/init.s
Normal file
33
018.vert_scroll/init.s
Normal file
@ -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
|
||||||
23
018.vert_scroll/utils.s
Normal file
23
018.vert_scroll/utils.s
Normal file
@ -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
|
||||||
92
018.vert_scroll/vert_scroll.s
Normal file
92
018.vert_scroll/vert_scroll.s
Normal file
@ -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"
|
||||||
Reference in New Issue
Block a user