diff --git a/027.game1/README.md b/027.game1/README.md deleted file mode 100644 index 0efad5c..0000000 --- a/027.game1/README.md +++ /dev/null @@ -1,13 +0,0 @@ -first simple game -================= - -screenshot ----------- - -![Screenshot](screenshot.png?raw=true) - - -try it ------- - * [Download disk image](bin/game1.adf?raw=true) - * Run in SAE diff --git a/027.game1/Makefile b/027.parallax/Makefile similarity index 99% rename from 027.game1/Makefile rename to 027.parallax/Makefile index 1313a27..6fb3e4a 100644 --- a/027.game1/Makefile +++ b/027.parallax/Makefile @@ -1,4 +1,4 @@ -EXAMPLE_NAME=game1 +EXAMPLE_NAME=parallax # userstack used by bootblock USERSTACK_ADDRESS=7fffc diff --git a/027.parallax/README.md b/027.parallax/README.md new file mode 100644 index 0000000..26a20b7 --- /dev/null +++ b/027.parallax/README.md @@ -0,0 +1,13 @@ +Simple parallax scrolling +========================= + +screenshot +---------- + +![Screenshot](screenshot.png?raw=true) + + +try it +------ + * [Download disk image](bin/parallax.adf?raw=true) + * Run in SAE diff --git a/027.game1/alpine_bootblock.s b/027.parallax/alpine_bootblock.s similarity index 100% rename from 027.game1/alpine_bootblock.s rename to 027.parallax/alpine_bootblock.s diff --git a/027.game1/assets/background.pal b/027.parallax/assets/background.pal similarity index 100% rename from 027.game1/assets/background.pal rename to 027.parallax/assets/background.pal diff --git a/027.game1/assets/foreground.pal b/027.parallax/assets/foreground.pal similarity index 100% rename from 027.game1/assets/foreground.pal rename to 027.parallax/assets/foreground.pal diff --git a/027.game1/assets/foreground.png b/027.parallax/assets/foreground.png similarity index 100% rename from 027.game1/assets/foreground.png rename to 027.parallax/assets/foreground.png diff --git a/027.game1/assets/palette.pal b/027.parallax/assets/palette.pal similarity index 100% rename from 027.game1/assets/palette.pal rename to 027.parallax/assets/palette.pal diff --git a/027.game1/assets/tilemap.png b/027.parallax/assets/tilemap.png similarity index 100% rename from 027.game1/assets/tilemap.png rename to 027.parallax/assets/tilemap.png diff --git a/027.game1/background.tmx b/027.parallax/background.tmx similarity index 100% rename from 027.game1/background.tmx rename to 027.parallax/background.tmx diff --git a/027.game1/blit.s b/027.parallax/blit.s similarity index 98% rename from 027.game1/blit.s rename to 027.parallax/blit.s index e7aa899..5254acc 100644 --- a/027.game1/blit.s +++ b/027.parallax/blit.s @@ -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 diff --git a/027.game1/blitchar.s b/027.parallax/blitchar.s similarity index 100% rename from 027.game1/blitchar.s rename to 027.parallax/blitchar.s diff --git a/027.game1/constants.i b/027.parallax/constants.i similarity index 94% rename from 027.game1/constants.i rename to 027.parallax/constants.i index 6b58ae4..315e215 100644 --- a/027.game1/constants.i +++ b/027.parallax/constants.i @@ -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 diff --git a/027.game1/copperlist.s b/027.parallax/copperlist.s similarity index 100% rename from 027.game1/copperlist.s rename to 027.parallax/copperlist.s diff --git a/027.game1/cpu.s b/027.parallax/cpu.s similarity index 100% rename from 027.game1/cpu.s rename to 027.parallax/cpu.s diff --git a/027.game1/foreground.tmx b/027.parallax/foreground.tmx similarity index 100% rename from 027.game1/foreground.tmx rename to 027.parallax/foreground.tmx diff --git a/027.game1/image.s b/027.parallax/image.s similarity index 78% rename from 027.game1/image.s rename to 027.parallax/image.s index 87f569e..28c29ce 100644 --- a/027.game1/image.s +++ b/027.parallax/image.s @@ -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 diff --git a/027.game1/includes.i b/027.parallax/includes.i similarity index 100% rename from 027.game1/includes.i rename to 027.parallax/includes.i diff --git a/027.game1/init.s b/027.parallax/init.s similarity index 100% rename from 027.game1/init.s rename to 027.parallax/init.s diff --git a/027.game1/link.script.x b/027.parallax/link.script.x similarity index 100% rename from 027.game1/link.script.x rename to 027.parallax/link.script.x diff --git a/027.game1/macros.i b/027.parallax/macros.i similarity index 100% rename from 027.game1/macros.i rename to 027.parallax/macros.i diff --git a/027.game1/game1.s b/027.parallax/parallax.s similarity index 75% rename from 027.game1/game1.s rename to 027.parallax/parallax.s index e95aaa2..e31f8ea 100644 --- a/027.game1/game1.s +++ b/027.parallax/parallax.s @@ -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: \ No newline at end of file diff --git a/027.game1/utils.s b/027.parallax/utils.s similarity index 100% rename from 027.game1/utils.s rename to 027.parallax/utils.s