Small fix
This commit is contained in:
parent
b6f20b6123
commit
fc6ed3a4b6
|
@ -1,13 +0,0 @@
|
|||
first simple game
|
||||
=================
|
||||
|
||||
screenshot
|
||||
----------
|
||||
|
||||
![Screenshot](screenshot.png?raw=true)
|
||||
|
||||
|
||||
try it
|
||||
------
|
||||
* [Download disk image](bin/game1.adf?raw=true)
|
||||
* <a href="http://alpine9000.github.io/ScriptedAmigaEmulator/#amiga_examples/game1.adf" target="_blank">Run in SAE</a>
|
|
@ -1,4 +1,4 @@
|
|||
EXAMPLE_NAME=game1
|
||||
EXAMPLE_NAME=parallax
|
||||
|
||||
# userstack used by bootblock
|
||||
USERSTACK_ADDRESS=7fffc
|
|
@ -0,0 +1,13 @@
|
|||
Simple parallax scrolling
|
||||
=========================
|
||||
|
||||
screenshot
|
||||
----------
|
||||
|
||||
![Screenshot](screenshot.png?raw=true)
|
||||
|
||||
|
||||
try it
|
||||
------
|
||||
* [Download disk image](bin/parallax.adf?raw=true)
|
||||
* <a href="http://alpine9000.github.io/ScriptedAmigaEmulator/#amiga_examples/parallax.adf" target="_blank">Run in SAE</a>
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
|
@ -130,14 +130,14 @@ BlueFill:
|
|||
;; d0 - color#
|
||||
;; d1 - height
|
||||
;; d2 - ypos
|
||||
move.l offscreen,a0
|
||||
move.l foregroundOffscreen,a0
|
||||
move.l #0,d0
|
||||
move.l #256,d1
|
||||
move.l #0,d2
|
||||
jsr BlitFillColor
|
||||
jsr WaitVerticalBlank
|
||||
jsr SwitchBuffers
|
||||
move.l offscreen,a0
|
||||
move.l foregroundOffscreen,a0
|
||||
move.l #0,d0
|
||||
move.l #256,d1
|
||||
move.l #0,d2
|
|
@ -1,5 +1,4 @@
|
|||
BACKGROUND_UPDATE_COUNT equ $3
|
||||
FOREGROUND_DELAY_BIT equ 0
|
||||
BACKGROUND_UPDATE_COUNT equ $1
|
||||
|
||||
SCREEN_WIDTH equ 320
|
||||
SCREEN_HEIGHT equ 256
|
|
@ -6,18 +6,16 @@ SwitchBuffers:
|
|||
;; offscreen - bitplane address
|
||||
;; movem.l d0/a0-a1,-(sp)
|
||||
|
||||
move.l fg_xpos,d0
|
||||
move.l foregroundX,d0
|
||||
lsr.l #3,d0 ; bytes to scroll
|
||||
move.l offscreen,a0
|
||||
move.l onscreen,offscreen
|
||||
move.l a0,onscreen
|
||||
move.l foregroundOffscreen,a0
|
||||
move.l foregroundOnscreen,foregroundOffscreen
|
||||
move.l a0,foregroundOnscreen
|
||||
move.l a0,a1
|
||||
lea copperListBpl1Ptr,a0
|
||||
jsr PokeBitplanePointers
|
||||
|
||||
btst #FOREGROUND_DELAY_BIT,d6 ; only swap the background buffer every second frame
|
||||
beq .skipBackgroundSwap
|
||||
move.l bg_xpos,d0
|
||||
move.l backgroundX,d0
|
||||
lsr.l #3,d0 ; bytes to scroll
|
||||
move.l backgroundOffscreen,a0
|
||||
move.l backgroundOnscreen,backgroundOffscreen
|
||||
|
@ -25,7 +23,6 @@ SwitchBuffers:
|
|||
move.l a0,a1
|
||||
lea copperListBpl2Ptr,a0
|
||||
jsr PokeBitplanePointers
|
||||
.skipBackgroundSwap:
|
||||
;; movem.l (sp)+,d0/a0-a1
|
||||
rts
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
include "includes.i"
|
||||
|
||||
xdef copperList
|
||||
xdef onscreen
|
||||
xdef offscreen
|
||||
xdef copperListBpl1Ptr
|
||||
xdef copperListBpl2Ptr
|
||||
xdef backgroundTiles
|
||||
xdef backgroundOnscreen
|
||||
xdef backgroundOffscreen
|
||||
xdef fg_xpos
|
||||
xdef bg_xpos
|
||||
xdef foregroundOnscreen
|
||||
xdef foregroundOffscreen
|
||||
xdef foregroundX
|
||||
xdef backgroundX
|
||||
|
||||
byteMap:
|
||||
dc.l Entry
|
||||
|
@ -33,25 +32,25 @@ Entry:
|
|||
;; d0 - fg bitplane pointer offset
|
||||
;; d1 - bg bitplane pointer offset
|
||||
move.l #0,d0
|
||||
move.l #1,d1
|
||||
move.l #0,d1
|
||||
jsr SwitchBuffers
|
||||
|
||||
move.w #(INTF_SETCLR|INTF_VERTB|INTF_INTEN),INTENA(a6)
|
||||
move.w #(DMAF_BLITTER|DMAF_SETCLR!DMAF_MASTER),DMACON(a6)
|
||||
|
||||
jsr Init ; enable the playfield
|
||||
jsr Init ; enable the playfield
|
||||
|
||||
|
||||
Reset:
|
||||
move.l #0,fg_xpos ; x pos (d1)
|
||||
move.l #0,fg_shift ; shift counter (d2)
|
||||
move.l #0,fg_tileIndex ; tile index (d3)
|
||||
move.l #0,bg_xpos
|
||||
move.l #0,bg_shift ; shift counter (d2)
|
||||
move.l #0,bg_tileIndex ; tile index (d3)
|
||||
move.l #BACKGROUND_UPDATE_COUNT,d6 (Frame count)
|
||||
move.l #0,foregroundX ; x pos
|
||||
move.l #0,fg_shift ; shift counter
|
||||
move.l #0,fg_tileIndex ; tile index
|
||||
move.l #0,backgroundX
|
||||
move.l #0,bg_shift ; shift counter
|
||||
move.l #0,bg_tileIndex ; tile index
|
||||
move.l #BACKGROUND_UPDATE_COUNT,d6 (frame count)
|
||||
jsr BlueFill
|
||||
move.l #11,frameCount
|
||||
move.l #0,frameCount
|
||||
|
||||
MainLoop:
|
||||
move.l frameCount,d6
|
||||
|
@ -64,34 +63,28 @@ MainLoop:
|
|||
|
||||
jsr SwitchBuffers ; takes bitplane pointer offset in d0
|
||||
|
||||
bsr RenderNextForegroundFrame
|
||||
|
||||
andi.b #BACKGROUND_UPDATE_COUNT,d6
|
||||
bne .skipBackgroundUpdates
|
||||
;; ---- Background updates ----------------------------------------
|
||||
.backgroundUpdates:
|
||||
add.l #1,bg_xpos
|
||||
add.l #1,backgroundX
|
||||
add.l #2,bg_tileIndex ; increment tile index
|
||||
bsr UpdateBackgroundShiftCounter
|
||||
.skipBackgroundUpdates:
|
||||
|
||||
btst #FOREGROUND_DELAY_BIT,d6
|
||||
beq .skipForegroundUpdates
|
||||
;; ---- Foreground updates ----------------------------------------
|
||||
.foregroundUpdates:
|
||||
add.l #1,fg_xpos
|
||||
add.l #1,foregroundX
|
||||
add.l #2,fg_tileIndex ; increment foreground tile index
|
||||
bsr UpdateShiftCounter
|
||||
.skipForegroundUpdates:
|
||||
|
||||
add.l #1,frameCount
|
||||
bra MainLoop
|
||||
|
||||
HoriScrollPlayfield:
|
||||
;; d0 - fg x position in pixels
|
||||
;; d1 - bg x position in pixels
|
||||
;; movem.l d0-d6,-(sp)
|
||||
|
||||
move.l bg_xpos,d0
|
||||
|
||||
move.l backgroundX,d0
|
||||
move.w d0,d2
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
and.w #$F,d2 ; pixels = 0xf - (hpos - (hpos_bytes*8))
|
||||
|
@ -99,7 +92,7 @@ HoriScrollPlayfield:
|
|||
sub.w d2,d0 ; bits to delay
|
||||
move.w d0,d5 ; d5 == bg bits to delay
|
||||
|
||||
move.l fg_xpos,d0
|
||||
move.l foregroundX,d0
|
||||
move.w d0,d2
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
and.w #$F,d2 ; pixels = 0xf - (hpos - (hpos_bytes*8))
|
||||
|
@ -108,23 +101,18 @@ HoriScrollPlayfield:
|
|||
|
||||
lsl.w #4,d5
|
||||
or.w d5,d0
|
||||
|
||||
move.w d0,BPLCON1(a6)
|
||||
|
||||
;; movem.l (sp)+,d0-d6
|
||||
rts
|
||||
|
||||
|
||||
|
||||
RenderNextBackgroundFrame:
|
||||
btst #FOREGROUND_DELAY_BIT,d6
|
||||
;; beq .s1
|
||||
lea backgroundMap,a2
|
||||
add.l bg_tileIndex,a2
|
||||
bsr RenderBackgroundTile
|
||||
.s1:
|
||||
rts
|
||||
|
||||
|
||||
|
||||
RenderNextForegroundFrame:
|
||||
lea map,a2
|
||||
add.l fg_tileIndex,a2
|
||||
|
@ -134,27 +122,25 @@ RenderNextForegroundFrame:
|
|||
.skip:
|
||||
bsr RenderForegroundTile
|
||||
rts
|
||||
|
||||
|
||||
|
||||
RenderForegroundTile:
|
||||
;; a2 - map
|
||||
;; movem.l a4,-(sp)
|
||||
move.l fg_xpos,d0
|
||||
move.l foregroundX,d0
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
move.l offscreen,a0
|
||||
move.l foregroundOffscreen,a0
|
||||
add.l d0,a0
|
||||
lea tilemap,a1
|
||||
add.l #BITPLANE_WIDTH_BYTES-2,a0 ; dest
|
||||
add.w (a2),a1 ; source tile
|
||||
move.l fg_shift,d2
|
||||
jsr BlitTile
|
||||
;; movem.l (sp)+,a4
|
||||
rts
|
||||
|
||||
|
||||
RenderBackgroundTile:
|
||||
;; a2 - map
|
||||
;; movem.l a1,-(sp)
|
||||
move.l bg_xpos,d0
|
||||
move.l backgroundX,d0
|
||||
lsr.w #3,d0 ; bytes to scroll
|
||||
move.l backgroundOffscreen,a0
|
||||
add.l d0,a0
|
||||
|
@ -163,9 +149,9 @@ RenderBackgroundTile:
|
|||
add.w (a2),a1 ; source tile
|
||||
move.l bg_shift,d2
|
||||
jsr BlitTile
|
||||
;; movem.l (sp)+,a4
|
||||
rts
|
||||
|
||||
|
||||
UpdateShiftCounter:
|
||||
cmp.l #15,fg_shift
|
||||
bne .s1
|
||||
|
@ -185,7 +171,8 @@ UpdateBackgroundShiftCounter:
|
|||
add.l #1,bg_shift
|
||||
.s2:
|
||||
rts
|
||||
|
||||
|
||||
|
||||
Level3InterruptHandler:
|
||||
movem.l d0-a6,-(sp)
|
||||
lea CUSTOM,a6
|
||||
|
@ -207,6 +194,7 @@ Level3InterruptHandler:
|
|||
movem.l (sp)+,d0-a6
|
||||
rte
|
||||
|
||||
|
||||
copperList:
|
||||
copperListBpl1Ptr:
|
||||
;; this is where bitplanes are assigned to playfields
|
||||
|
@ -228,32 +216,15 @@ copperListBpl2Ptr:
|
|||
dc.w BPL6PTH,0
|
||||
dc.l $fffffffe
|
||||
|
||||
if 0
|
||||
copperList:
|
||||
copperListBplPtr:
|
||||
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.w BPL6PTL,0
|
||||
dc.w BPL6PTH,0
|
||||
dc.l $fffffffe
|
||||
endif
|
||||
|
||||
InstallPalette:
|
||||
include "out/tilemap-palette.s"
|
||||
rts
|
||||
|
||||
onscreen:
|
||||
dc.l bitplanes1
|
||||
offscreen:
|
||||
dc.l bitplanes2
|
||||
foregroundOnscreen:
|
||||
dc.l foregroundBitplanes1
|
||||
foregroundOffscreen:
|
||||
dc.l foregroundBitplanes2
|
||||
|
||||
backgroundOnscreen:
|
||||
dc.l backgroundBitplanes1
|
||||
|
@ -265,22 +236,7 @@ tilemap:
|
|||
|
||||
backgroundTilemap:
|
||||
incbin "out/background.bin"
|
||||
|
||||
|
||||
bitplanes1:
|
||||
ds.b IMAGESIZE
|
||||
ds.b BITPLANE_WIDTH_BYTES*20
|
||||
bitplanes2:
|
||||
ds.b IMAGESIZE
|
||||
ds.b BITPLANE_WIDTH_BYTES*20
|
||||
|
||||
backgroundBitplanes1:
|
||||
ds.b IMAGESIZE
|
||||
ds.b BITPLANE_WIDTH_BYTES*20
|
||||
backgroundBitplanes2:
|
||||
ds.b IMAGESIZE
|
||||
ds.b BITPLANE_WIDTH_BYTES*20
|
||||
|
||||
|
||||
map:
|
||||
include "out/foreground-map.s"
|
||||
dc.w $FFFF
|
||||
|
@ -290,14 +246,14 @@ backgroundMap:
|
|||
|
||||
fg_shift:
|
||||
dc.l 0
|
||||
fg_xpos:
|
||||
foregroundX:
|
||||
dc.l 0
|
||||
fg_tileIndex:
|
||||
dc.l 0
|
||||
|
||||
bg_shift:
|
||||
dc.l 0
|
||||
bg_xpos:
|
||||
backgroundX:
|
||||
dc.l 0
|
||||
bg_tileIndex:
|
||||
dc.l 0
|
||||
|
@ -307,41 +263,20 @@ frameCount:
|
|||
|
||||
section .bss
|
||||
|
||||
foregroundBitplanes1:
|
||||
ds.b IMAGESIZE
|
||||
ds.b BITPLANE_WIDTH_BYTES*20
|
||||
foregroundBitplanes2:
|
||||
ds.b IMAGESIZE
|
||||
ds.b BITPLANE_WIDTH_BYTES*20
|
||||
|
||||
backgroundBitplanes1:
|
||||
ds.b IMAGESIZE
|
||||
ds.b BITPLANE_WIDTH_BYTES*20
|
||||
backgroundBitplanes2:
|
||||
ds.b IMAGESIZE
|
||||
ds.b BITPLANE_WIDTH_BYTES*20
|
||||
|
||||
startUserstack:
|
||||
ds.b $1000 ; size of stack
|
||||
userstack:
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
0: UpdateFG
|
||||
UpdateBG
|
||||
RenderFG
|
||||
RenderBG
|
||||
SwapBufferFG
|
||||
SwapBufferBG
|
||||
|
||||
1: RenderFG
|
||||
SwapBufferFG
|
||||
|
||||
2: UpdateFG
|
||||
RenderFG
|
||||
RenderBG
|
||||
SwapBufferFG
|
||||
SwapBufferBG
|
||||
|
||||
2: RenderFG
|
||||
SwapBufferFG
|
||||
|
||||
|
||||
000
|
||||
001
|
||||
010
|
||||
011
|
||||
100
|
||||
101
|
||||
110
|
||||
111
|
||||
userstack:
|
Loading…
Reference in New Issue