Jump to content

  • Log In with Google      Sign In   
  • Create Account

New Old Things

A C64 Game - Step 78

Posted by , in C64 24 November 2012 - - - - - - · 1,176 views

Added and streamlined all story pages. Now we have locations (mentioned) and a crude "story arc". Plus a little animation on the last two bosses. There's no higher meaning behind the locations, I just wandered about USA with Google maps ;)

Showing no code this time, since it's merely added text to existing tables.

The aforementioned animation is a simple xor call on the sprite pointer:

		  lda SPRITE_POINTER_BASE,x
		  eor #1
		  sta SPRITE_POINTER_BASE,x

Attached Image


Previous Step Next Step

Attached Files




A C64 Game - Step 77

Posted by , in C64 17 November 2012 - - - - - - · 1,148 views

And another boss. This one is different, as it spawns bats to the left and right. And is only vulnerable during that part ;)

Attached Image

The boss routine is a bit bigger this time. The attacking bat code is already there, so nothing to add on that part.
As behaviours got increasingly complex I started to write the state values on top of the routines. Remember, any states with MSB set (>=128) mark the object as invincible.

;------------------------------------------------------------
;boss #5
;state 128 = find target Y
;state 129 = move towards target Y
;state 0 = attack
;state 130 = cool off
;------------------------------------------------------------
!zone BehaviourBoss6
BehaviourBoss6
BOSS_MOVE_SPEED = 1
		  lda SPRITE_HITBACK,x
		  beq .NoHitBack
		  dec SPRITE_HITBACK,x
		
		  ldy SPRITE_HITBACK,x
		  lda BOSS_FLASH_TABLE,y
		  sta VIC_SPRITE_COLOR,x
		
		  cpy #0
		  bne .NoHitBack
		  lda #1
		  sta VIC_SPRITE_COLOR,x
		  ;keep invulnerable
.NoHitBack	  
		  lda DELAYED_GENERIC_COUNTER
		  and #$03
		  bne .NoAnimUpdate
		
.NoAnimUpdate  
		  lda SPRITE_STATE,x
		  beq .Attack
		  cmp #128
		  bne +
		  jmp .FindTargetY
+		
		  cmp #129
		  beq .MoveTowardsTarget
		  cmp #130
		  beq .CoolOff
		
		  lda #0
		  sta SPRITE_STATE,x
		  rts
		
.CoolOff
		  inc SPRITE_MODE_POS,x
		  lda SPRITE_MODE_POS,x
		  cmp #30
		  bne +
		
		  lda #128
		  sta SPRITE_STATE,x
		
+		
		  rts
		
.Attack
		  inc SPRITE_MOVE_POS,x
		  lda SPRITE_MOVE_POS,x
		  and #$1f
		  cmp #$1f
		  beq +
		  rts
		
+		
		  ;free bats
		  inc SPRITE_MODE_POS,x
		  lda SPRITE_MODE_POS,x
		  cmp #5
		  bne +
		
		  lda #130
		  sta SPRITE_STATE,x
		  lda #0
		  sta SPRITE_MODE_POS,x
		  rts
		
+		
		  lda SPRITE_CHAR_POS_X,x
		  sta PARAM1
		  lda SPRITE_CHAR_POS_Y,x
		  sta PARAM2
		  inc PARAM2
		  stx PARAM10
		  jsr FindEmptySpriteSlot
		  beq ++
		
		  lda #TYPE_BAT_ATTACKING
		  sta PARAM3
		  jsr SpawnObject
		  lda #0
		  sta SPRITE_DIRECTION,x
		  jsr FindEmptySpriteSlot
		  beq ++
		  jsr SpawnObject
		  lda #1
		  sta SPRITE_DIRECTION,x
		
++		
		  ldx PARAM10
		  rts
		
		
.MoveTowardsTarget
		  ;player index in y
		  lda SPRITE_VALUE,x
		  cmp SPRITE_CHAR_POS_Y,x
		  bne +

		  ;arrived at target Y
		  lda #0
		  sta SPRITE_MODE_POS,x
		  sta SPRITE_STATE,x
		  rts
		
+		
		  bpl .MoveDown
		
		  ;move up?
		  lda SPRITE_DIRECTION_Y,x
		  bne .AlreadyLookingUp
		  lda SPRITE_MOVE_POS_Y,x
		  beq .TurnUNow
		  dec SPRITE_MOVE_POS_Y,x
		  bne .DoGhostMove
		
.TurnUNow		
		  ;turning now
		  lda #1
		  sta SPRITE_DIRECTION_Y,x
		  jmp .DoGhostMove
		
.AlreadyLookingUp
		  lda SPRITE_MOVE_POS_Y,x
		  cmp #BOSS_MOVE_SPEED
		  beq .DoGhostMove
		  inc SPRITE_MOVE_POS_Y,x
		  jmp .DoGhostMove
		
.MoveDown
		  lda SPRITE_DIRECTION_Y,x
		  beq .AlreadyLookingDown
		
		  lda SPRITE_MOVE_POS_Y,x
		  beq .TurnDNow
		  dec SPRITE_MOVE_POS_Y,x
		  bne .DoGhostMove
		
		  ;turning now
.TurnDNow		
		  lda #0
		  sta SPRITE_DIRECTION_Y,x
		  jmp .DoGhostMove
		
.AlreadyLookingDown
		  lda SPRITE_MOVE_POS_Y,x
		  cmp #BOSS_MOVE_SPEED
		  beq .DoGhostMove
		  inc SPRITE_MOVE_POS_Y,x
		  jmp .DoGhostMove
.DoGhostMove
		  ;move X times
		  ldy SPRITE_MOVE_POS_Y,x
		  sty PARAM4
		  beq .MoveDone
		
		  lda SPRITE_DIRECTION_Y,x
		  beq .DoDown
.MoveLoopU
		  jsr ObjectMoveUpBlocking
		  dec PARAM4
		  bne .MoveLoopU
		  jmp .MoveDone
		
.DoDown
.MoveLoopD
		  jsr ObjectMoveDownBlockingNoPlatform
		  dec PARAM4
		  bne .MoveLoopD
		
.MoveDone	  
		  rts
		
.FindTargetY
		  lda #4
		  sta PARAM5
		  lda #18
		  sta PARAM6
		  jsr GenerateRangedRandom
		  sta SPRITE_VALUE,x
		  inc SPRITE_STATE,x
		  rts

Have fun!


Previous Step Next Step

Attached Files




A C64 Game - Step 76

Posted by , in C64 10 November 2012 - - - - - - · 1,292 views

And yet another 10 stages. A few animation bugs show up with the water, in general there seems to be another fixing step coming up.

Attached Image

Have fun!


Previous Step Next Step

Attached Files




A C64 Game - Step 75

Posted by , in C64 03 November 2012 - - - - - - · 1,311 views

And more! Now the executable hit the load barrier, so Exomizer is the only way to go onwards (before it was optional). Added a new waterfall char with the same effect as low water.

Attached Image

At the same location the other char is initiated we add this:

ldx #0
-		
		  lda $F800 + 143 * 8,x
		  sta ANIM_TILE2_BYTES,x
		  sta ANIM_TILE2_BYTES + 8,x
		
		  inx
		  dey
		  cpx #8
		  bne -

At the location where we animate the first char we add this. Note that the second sta at $c000 is for the second char set.

;animate water tile
		  lda DELAYED_GENERIC_COUNTER
		  and #$03
		  bne +
		
		  inc ANIM_POS
		  lda ANIM_POS
		  and #$07
		  tay
		
		  lda ANIM_TILE_BYTES,y
		  sta $F800 + 111 * 8
		  sta $C000 + 111 * 8
		  lda ANIM_TILE_BYTES + 8,y
		  sta $F800 + 111 * 8 + 1
		  sta $C000 + 111 * 8 + 1
		  sty PARAM1
		  lda #7
		  sec
		  sbc PARAM1
		  tay
		  ldx #0
-		
		  lda ANIM_TILE2_BYTES,y
		  sta $F800 + 143 * 8,x
		  sta $C000 + 143 * 8,x
		
		  inx
		  iny
		  cpx #8
		  bne -
		
		
+


And finally, the actual check for the water char (143) is enhanced:

;check if we're in water
		  ldy SPRITE_CHAR_POS_Y,x
		  lda SCREEN_LINE_OFFSET_TABLE_LO,y
		  sta ZEROPAGE_POINTER_1
		  lda SCREEN_BACK_LINE_OFFSET_TABLE_HI,y
		  sta ZEROPAGE_POINTER_1 + 1
		  lda SPRITE_CHAR_POS_X,x
		  tay
		  lda (ZEROPAGE_POINTER_1),y
		  cmp #111
		  beq .NextObject
		  cmp #143
		  beq .NextObject

Another enhancement, due to packing. Now that the packer takes care of putting the sprites and characters sets at their target location we can comment them out (plus their copy routines).
With ACME or the C64 Studio assembler you do it like this:

!ifndef CRUNCHED {
CHARSET
		  !binary "j.chr"
CHARSET_2		
		  !binary "j2.chr"
		
SPRITES
		  !binary "j.spr"
END_OF_FILE
}

That's all there is to this step, have fun!


Previous Step Next Step

Attached Files







November 2012 »

S M T W T F S
    123
45678910
11121314151617
18192021222324
252627282930