From 34ca62a0eaa49ab931a23898493df2f8b470e817 Mon Sep 17 00:00:00 2001 From: alpine9000 Date: Wed, 20 Apr 2016 17:42:27 +1000 Subject: [PATCH] refactoring for multiple item sprites --- 028.game2/constants.i | 12 +++ 028.game2/game1.s | 2 + 028.game2/items.s | 168 +++++++++++++++++------------------------- 028.game2/macros.i | 43 +++++++++++ 4 files changed, 123 insertions(+), 102 deletions(-) diff --git a/028.game2/constants.i b/028.game2/constants.i index 7dc04d1..0ca16d4 100644 --- a/028.game2/constants.i +++ b/028.game2/constants.i @@ -17,6 +17,18 @@ FOREGROUND_PLAYAREA_WIDTH_WORDS equ 24 FOREGROUND_PLAYAREA_RIGHT_MARGIN_BYTES equ 12 FOREGROUND_PLAYAREA_HEIGHT_WORDS equ 8 +ITEM_SPRITE_HEIGHT equ 15 +ITEM_SPRITE_NUM_VERTICAL_SPRITES equ 8 +ITEM_SPRITE_BYTES equ (ITEM_SPRITE_NUM_VERTICAL_SPRITES*(64+4))+4 + +ITEM_X equ 0 +ITEM_LAGX equ 2 +ITEM_Y equ 4 +ITEM_LAGY equ 6 +ITEM_YEND equ 8 +ITEM_LAGYEND equ 10 +ITEM_INDEX equ 12 + SCREEN_WIDTH equ 320 SCREEN_HEIGHT equ 256 SCREEN_WIDTH_BYTES equ (SCREEN_WIDTH/8) diff --git a/028.game2/game1.s b/028.game2/game1.s index d25e86e..8842b26 100644 --- a/028.game2/game1.s +++ b/028.game2/game1.s @@ -374,6 +374,7 @@ message: align 4 copperList: + panelCopperListBpl1Ptr: dc.w BPL1PTL,0 dc.w BPL1PTH,0 @@ -411,6 +412,7 @@ copperListBpl1Ptr: dc.w BPL5PTL,0 dc.w BPL5PTH,0 + copperListBpl2Ptr: ;; 3 bitplanes per playfield, playfield2 gets bitplanes 2,4,6 dc.w BPL2PTL,0 diff --git a/028.game2/items.s b/028.game2/items.s index aa59af6..e601ea9 100644 --- a/028.game2/items.s +++ b/028.game2/items.s @@ -4,17 +4,30 @@ xdef ScrollItemSprites xdef RenderItemSprite -ScrollItemSprites: - ;; sub.w #1,itemX +ScrollItemSprites: + move.l #1,d0 + lsl.w #4,d0 ; multiply by 16 (item control structure size) + lea item1,a1 + add.l d0,a1 + move.l foregroundScrollPixels,d0 - sub.w d0,itemX + sub.w d0,ITEM_X(a1) rts SetupItemSpriteData: + ;; d0 - item slot + ;; d1 - sprite slot + move.l #1,d0 + lsl.w #4,d0 ; multiply by 16 (item control structure size) + lea item1,a1 + add.l d0,a1 + move.l currentItemSprite,a0 - cmp.w #13<<3,itemIndex + ;; add.l #64+4,a0 + + cmp.w #13<<3,ITEM_INDEX(a1) ble .dontResetIndex - move.l #0,itemIndex + move.l #0,ITEM_INDEX(a1) .dontResetIndex: cmp.l #deadSprite,a0 bne .setupSprite @@ -22,33 +35,42 @@ SetupItemSpriteData: .setupSprite: move.l #0,d0 - move.w itemIndex,d0 + move.w ITEM_INDEX(a1),d0 lsr.l #3,d0 - mulu.w #64+12,d0 + mulu.w #ITEM_SPRITE_BYTES,d0 add.l d0,a0 - move.w itemLagX,d0 + move.w ITEM_LAGX(a1),d0 lsr.w #FOREGROUND_SCROLL_SHIFT_CONVERT,d0 ; convert to pixels - move.w itemX,itemLagX + move.w ITEM_X(a1),ITEM_LAGX(a1) add.w #32,d0 move.w d0,d1 andi #1,d1 move.b d1,3(a0) ;spriteControl lsr.l #1,d0 move.b d0,1(a0) ;spriteHStart - move.w itemLagY,d0 - move.w itemY,itemLagY + move.w ITEM_LAGY(a1),d0 + move.w ITEM_Y(a1),ITEM_LAGY(a1) move.b d0,(a0) ;spriteVStart - move.w itemLagYEnd,d0 - move.w itemYEnd,itemLagYEnd + move.w ITEM_LAGYEND(a1),d0 + move.w ITEM_YEND(a1),ITEM_LAGYEND(a1) move.b d0,2(a0) ;spriteVStop .c1: + + move.l a0,SPR2PTH(a6) - add.w #1,itemIndex + + add.w #1,ITEM_INDEX(a1) rts RenderItemSprite: ;; d2 - y tile index ? - movem.l d2-d3,-(sp) + movem.l d2-d3,-(sp) + + move.l #1,d0 + lsl.w #4,d0 ; multiply by 16 (item control structure size) + lea item1,a1 + add.l d0,a1 + move.l foregroundScrollX,d0 lsr.w #FOREGROUND_SCROLL_SHIFT_CONVERT,d0 ; convert to pixels andi.w #$f,d0 @@ -59,13 +81,13 @@ RenderItemSprite: cmpi.w #0,(a3) beq .dontAddSprite move.l #deadSprite,currentItemSprite - move.w #337<