From 8a7925917847d62c39cfcf4a82af7bfb0a90f295 Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Sun, 24 Apr 2016 12:15:00 +1000 Subject: [PATCH] first refactor towards multiple player sprites --- 028.bs/Makefile | 14 +++++ 028.bs/assets/robot.pal | 4 ++ 028.bs/game1.s | 7 ++- 028.bs/pig.s | 130 +++++++++++++++++----------------------- 028.bs/sprite_data.i | 110 ++++++++++++++++++++++++++++++++++ 5 files changed, 187 insertions(+), 78 deletions(-) create mode 100644 028.bs/assets/robot.pal create mode 100644 028.bs/sprite_data.i diff --git a/028.bs/Makefile b/028.bs/Makefile index a8da32e..2316a3a 100644 --- a/028.bs/Makefile +++ b/028.bs/Makefile @@ -25,6 +25,14 @@ IMAGES=foreground.png \ sprite_pig-5.png \ sprite_pig-6.png \ sprite_pig-7.png \ + sprite_robot-0.png \ + sprite_robot-1.png \ + sprite_robot-2.png \ + sprite_robot-3.png \ + sprite_robot-4.png \ + sprite_robot-5.png \ + sprite_robot-6.png \ + sprite_robot-7.png \ sprite_coin-0.png \ sprite_coin-1.png \ sprite_coin-2.png \ @@ -67,6 +75,9 @@ out/mpanel.bin: assets/mpanel.png out/sprite_pig-%.bin: out/sprite_pig-%.png $(IMAGECON) --input $< $(IMAGECON_ARGS) --colors 4 --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-palette --output-png --output-copperlist --output out/sprite_pig-$* --palette-offset 16 --use-palette=assets/pig.pal +out/sprite_robot-%.bin: out/sprite_robot-%.png + $(IMAGECON) --input $< $(IMAGECON_ARGS) --colors 4 --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-palette --output-png --output-copperlist --output out/sprite_robot-$* --palette-offset 16 --use-palette=assets/robot.pal + out/sprite_fallingPig-%.bin: out/sprite_fallingPig-%.png $(IMAGECON) --input $< $(IMAGECON_ARGS) --colors 4 --output-bitplanes --output-palette --full-color-palette-file --output-palette-asm --output-palette --output-png --output-copperlist --output out/sprite_fallingPig-$* --palette-offset 16 --use-palette=assets/pig.pal @@ -78,6 +89,9 @@ out/sprite_coin%.bin: out/sprite_coin%.png out/sprite_pig%.png: assets/assets.png ../tools/croppa/out/croppa --input=assets/assets.png --output=out/sprite_pig --width=16 --height=16 --rows=1 --cols=8 --dx=16 --dy=16 --x=192 --y=112 +out/sprite_robot%.png: assets/assets.png + ../tools/croppa/out/croppa --input=assets/assets.png --output=out/sprite_robot --width=16 --height=16 --rows=1 --cols=8 --dx=16 --dy=16 --x=192 --y=176 + out/sprite_fallingPig%.png: assets/assets.png ../tools/croppa/out/croppa --input=assets/assets.png --output=out/sprite_fallingPig --width=16 --height=16 --rows=1 --cols=5 --dx=16 --dy=16 --x=192 --y=128 diff --git a/028.bs/assets/robot.pal b/028.bs/assets/robot.pal new file mode 100644 index 0000000..2b71950 --- /dev/null +++ b/028.bs/assets/robot.pal @@ -0,0 +1,4 @@ +000 000 000 255 +095 112 160 255 +055 047 071 255 +063 073 121 255 diff --git a/028.bs/game1.s b/028.bs/game1.s index 5538022..57c7562 100644 --- a/028.bs/game1.s +++ b/028.bs/game1.s @@ -16,6 +16,7 @@ xdef mapSize xdef moving xdef foregroundScrollPixels + byteMap: dc.l Entry @@ -149,7 +150,7 @@ GameLoop: bra GameLoop Update: - jsr UpdatePig + jsr UpdatePlayer .backgroundUpdates: add.l #BACKGROUND_SCROLL_PIXELS,backgroundScrollX @@ -680,7 +681,7 @@ playAreaCopperPalettePtr2: dc.l $fffffffe InstallSpriteColorPalette: - include "out/sprite_pig-0-palette.s" + jsr InstallPlayerColorPalette include "out/sprite_coin-1-palette.s" rts @@ -773,6 +774,8 @@ InstallNextGreyPanelPalette: .done rts + + foregroundOnscreen: dc.l foregroundBitplanes1 foregroundOffscreen: diff --git a/028.bs/pig.s b/028.bs/pig.s index 373cc78..47bf3ca 100644 --- a/028.bs/pig.s +++ b/028.bs/pig.s @@ -1,6 +1,6 @@ include "includes.i" - xdef UpdatePig + xdef UpdatePlayer xdef ProcessJoystick xdef InitialisePig xdef HidePig @@ -11,9 +11,17 @@ xdef spriteLagX xdef spriteY xdef UpdatePigFallingAnimation + xdef InstallPlayerColorPalette +PLAYER_INSTALL_COLOR_PALETTE equ 0 +PLAYER_SPRITE_DATA equ 4 InitialisePig: + move.l playerSpriteConfig,a0 + move.l PLAYER_SPRITE_DATA(a0),d0 + add.l #6*PIG_SPRITE_VERTICAL_BYTES,d0 + move.l d0,currentSprite + move.w #0,spritePigFallingAnimation move.w #PIG_INITIAL_X,spriteX move.w #PIG_INITIAL_Y,spriteY @@ -48,60 +56,69 @@ UpdatePigFallingAnimation: rts -UpdatePig: +UpdatePlayer: ;; right + move.l playerSpriteConfig,a0 + move.l PLAYER_SPRITE_DATA(a0),d0 cmp.w #PIG_PAUSE_PIXELS,spriteR ble .skipRight add.w #PIG_MOVE_PIXELS,spriteX - move.l #spritePigRightJump,currentSprite + add.l #7*PIG_SPRITE_VERTICAL_BYTES,d0 + move.l d0,currentSprite .skipRight cmp.w #0,spriteR beq .notRight sub.w #1,spriteR cmp.w #PIG_PAUSE_PIXELS,spriteR bge .notRight - move.l #spritePigRight,currentSprite + add.l #6*PIG_SPRITE_VERTICAL_BYTES,d0 + move.l d0,currentSprite .notRight: ;; up cmp.w #PIG_PAUSE_PIXELS,spriteU ble .skipUp sub.w #PIG_MOVE_PIXELS,spriteY sub.w #PIG_MOVE_PIXELS,spriteYEnd - move.l #spritePigUpJump,currentSprite + add.l #1*PIG_SPRITE_VERTICAL_BYTES,d0 + move.l d0,currentSprite .skipUp: cmp.w #0,spriteU beq .notUp sub.w #1,spriteU cmp.w #PIG_PAUSE_PIXELS,spriteU bge .notUp - move.l #spritePigUp,currentSprite + move.l d0,currentSprite .notUp: ;; down cmp.w #PIG_PAUSE_PIXELS,spriteD ble .skipDown add.w #PIG_MOVE_PIXELS,spriteY add.w #PIG_MOVE_PIXELS,spriteYEnd - move.l #spritePigDownJump,currentSprite + add.l #3*PIG_SPRITE_VERTICAL_BYTES,d0 + move.l d0,currentSprite .skipDown: cmp.w #0,spriteD beq .notDown sub.w #1,spriteD cmp.w #PIG_PAUSE_PIXELS,spriteD bge .notDown - move.l #spritePigDown,currentSprite + add.l #2*PIG_SPRITE_VERTICAL_BYTES,d0 + move.l d0,currentSprite .notDown: ;; left cmp.w #PIG_PAUSE_PIXELS,spriteL ble .skipLeft sub.w #PIG_MOVE_PIXELS,spriteX - move.l #spritePigLeftJump,currentSprite + add.l #5*PIG_SPRITE_VERTICAL_BYTES,d0 + move.l d0,currentSprite .skipLeft cmp.w #0,spriteL beq .notLeft sub.w #1,spriteL cmp.w #PIG_PAUSE_PIXELS,spriteL bge .notLeft - move.l #spritePigLeft,currentSprite + add.l #4*PIG_SPRITE_VERTICAL_BYTES,d0 + move.l d0,currentSprite .notLeft: cmp.w #$cf,spriteX blt .noScroll @@ -176,73 +193,34 @@ SetupSpriteData: move.l #deadSprite,SPR6PTH(a6) move.l #deadSprite,SPR7PTH(a6) rts + +InstallPlayerColorPalette: + move.l playerSpriteConfig,a0 + move.l PLAYER_INSTALL_COLOR_PALETTE(a0),a1 + jsr (a1) + rts - -spritePigUp: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_pig-1.bin" ; up - dc.l 0 -spritePigUpJump: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_pig-0.bin" ; up jump - dc.l 0 -spritePigDown: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_pig-5.bin" ; down - dc.l 0 -spritePigDownJump: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_pig-4.bin" ; down jump - dc.l 0 -spritePigLeft: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_pig-7.bin" ; left - dc.l 0 -spritePigLeftJump: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_pig-6.bin" ; left jump - dc.l 0 -spritePigRight: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_pig-3.bin" ; right - dc.l 0 -spritePigRightJump: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_pig-2.bin" ; right jump - dc.l 0 -spriteFalling0: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_fallingPig-0.bin" - dc.l 0 -spriteFalling1: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_fallingPig-1.bin" - dc.l 0 -spriteFalling2: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_fallingPig-2.bin" - dc.l 0 -spriteFalling3: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_fallingPig-3.bin" - dc.l 0 -spriteFalling4: - dc.w 0,0 - dc.w 0,0 - incbin "out/sprite_fallingPig-4.bin" - dc.l 0 +InstallPigColorPalette: + include "out/sprite_pig-0-palette.s" + rts + +InstallRobotColorPalette: + include "out/sprite_robot-0-palette.s" + rts + +pigPlayerSpriteConfig: + dc.l InstallPigColorPalette + dc.l spritePig + +robotPlayerSpriteConfig: + dc.l InstallRobotColorPalette + dc.l spriteRobot + +playerSpriteConfig: + dc.l robotPlayerSpriteConfig + + include "sprite_data.i" + spritePigFallingAnimation: dc.w 0 currentSpriteOffset: diff --git a/028.bs/sprite_data.i b/028.bs/sprite_data.i new file mode 100644 index 0000000..0024650 --- /dev/null +++ b/028.bs/sprite_data.i @@ -0,0 +1,110 @@ +spritePig: +spritePigUp: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_pig-1.bin" ; 0, up + dc.l 0 +spritePigUpJump: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_pig-0.bin" ; 1, up jump + dc.l 0 +spritePigDown: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_pig-5.bin" ; 2, down + dc.l 0 +spritePigDownJump: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_pig-4.bin" ; 3, down jump + dc.l 0 +spritePigLeft: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_pig-7.bin" ; 4, left + dc.l 0 +spritePigLeftJump: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_pig-6.bin" ; 5, left jump + dc.l 0 +spritePigRight: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_pig-3.bin" ; 6, right + dc.l 0 +spritePigRightJump: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_pig-2.bin" ; 7, right jump + dc.l 0 + + +spriteRobot: +spriteRobotUp: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_robot-1.bin" ; 0, up + dc.l 0 +spriteRobotUpJump: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_robot-0.bin" ; 1, up jump + dc.l 0 +spriteRobotDown: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_robot-5.bin" ; 2, down + dc.l 0 +spriteRobotDownJump: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_robot-4.bin" ; 3, down jump + dc.l 0 +spriteRobotLeft: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_robot-7.bin" ; 4, left + dc.l 0 +spriteRobotLeftJump: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_robot-6.bin" ; 5, left jump + dc.l 0 +spriteRobotRight: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_robot-3.bin" ; 6, right + dc.l 0 +spriteRobotRightJump: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_robot-2.bin" ; 7, right jump + dc.l 0 + +spriteFalling0: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_fallingPig-0.bin" + dc.l 0 +spriteFalling1: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_fallingPig-1.bin" + dc.l 0 +spriteFalling2: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_fallingPig-2.bin" + dc.l 0 +spriteFalling3: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_fallingPig-3.bin" + dc.l 0 +spriteFalling4: + dc.w 0,0 + dc.w 0,0 + incbin "out/sprite_fallingPig-4.bin" + dc.l 0 \ No newline at end of file