• entries
    104
  • comments
    101
  • views
    255226

A C64 Game - Step 68

Sign in to follow this  
Endurion

1799 views

Added a first version of Sams dark force, making it visible. It's not looking quite what I wanted it, but it is getting there.

step68.png

To make things faster for removal of the beam we calc the required length and direction of the beam:

          ;redraw black beam
          ldx PARAM6

          ldy SPRITE_CHAR_POS_Y,x
          dey
          sty SAM_FORCE_START_Y
          lda SCREEN_LINE_OFFSET_TABLE_LO,y
          sta ZEROPAGE_POINTER_1
          sta ZEROPAGE_POINTER_2
          lda SCREEN_LINE_OFFSET_TABLE_HI,y
          sta ZEROPAGE_POINTER_1 + 1
          clc
          adc #( ( SCREEN_COLOR - SCREEN_CHAR ) >> 8 )
          sta ZEROPAGE_POINTER_2 + 1

          ldy SPRITE_CHAR_POS_X,x
          lda SPRITE_DIRECTION,x
          sta PARAM1

          lda #0
          sta SAM_FORCE_LENGTH

          ldx SPRITE_HELD
          dex

-
          lda #253
          sta (ZEROPAGE_POINTER_1),y
          lda #6
          sta (ZEROPAGE_POINTER_2),y

          inc SAM_FORCE_LENGTH

          lda PARAM1
          bne ++

          iny
          jmp +

++
          dey

+
          tya
          cmp SPRITE_CHAR_POS_X,x
          bne -

          ;store for later removal
          ldx PARAM6
          lda PARAM1
          bne +

          ;going right
          lda SPRITE_CHAR_POS_X,x
          sta SAM_FORCE_START_X
          jmp ++


+
          ;going left
          sty SAM_FORCE_START_X
          inc SAM_FORCE_START_X

++
          ldy SPRITE_HELD
          dey



The beam needs to be removed once Sam stops pressing the fire button or he or his enemy dies. Aren't we glad that we already have a back buffer we can use to restore the background properly?

;restore play field from force beam
!zone RemoveForceBeam
RemoveForceBeam
          ldy SAM_FORCE_START_Y

          lda SCREEN_LINE_OFFSET_TABLE_LO,y
          sta ZEROPAGE_POINTER_1
          sta ZEROPAGE_POINTER_2
          sta ZEROPAGE_POINTER_3
          sta ZEROPAGE_POINTER_4
          lda SCREEN_LINE_OFFSET_TABLE_HI,y
          sta ZEROPAGE_POINTER_1 + 1
          clc
          adc #( ( SCREEN_COLOR - SCREEN_CHAR ) & 0xff00 ) >> 8
          sta ZEROPAGE_POINTER_2 + 1
          sec
          sbc #( ( SCREEN_COLOR - SCREEN_BACK_CHAR ) & 0xff00 ) >> 8
          sta ZEROPAGE_POINTER_3 + 1
          sec
          sbc #( ( SCREEN_BACK_CHAR - SCREEN_BACK_COLOR ) & 0xff00 ) >> 8
          sta ZEROPAGE_POINTER_4 + 1

          ldy SAM_FORCE_START_X

-
          lda (ZEROPAGE_POINTER_3),y
          sta (ZEROPAGE_POINTER_1),y
          lda (ZEROPAGE_POINTER_4),y
          sta (ZEROPAGE_POINTER_2),y

          iny
          dec SAM_FORCE_LENGTH
          bne -

          rts


So when Sam dies we modify existing code to:

          lda SPRITE_HELD
          beq +

          jsr RemoveForceBeam
          lda #0
          sta SPRITE_HELD
+


Voila! Carnage made more visible ;)

 

step68.zip

Previous Step Next Step

Sign in to follow this  


5 Comments


Recommended Comments

I'm already doing so, see Joe Gunn or Soulless :)

Also, on a lemon64 thread Smila (the graphician) put a few screenshots of soon to be worked on projects like Catnipped and Hyperion.
All those however are not done with code and tutorial steps like Supernatural.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now