A C64 Game - Step 68

posted in New Old Things
Published September 15, 2012
Advertisement

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.



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 + 1clcadc #( ( 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

Previous Entry A C64 Game - Step 67
1 likes 5 comments

Comments

Programming020195BRook
Are you going to be making more games like this after?
September 19, 2012 06:18 AM
Endurion
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.
September 22, 2012 05:11 AM
Programming020195BRook
You made Soulless: http://www.psytronik.net/main/index.php?option=com_content&view=article&id=97:soulless&catid=34:commodore-64&Itemid=57 ???

AMAZING!!!!! :D
September 22, 2012 10:15 AM
Endurion
Yeah :) The graphic and music are pure gold.

The game itself is quite simple technically and pretty similar to the code here ;)
September 22, 2012 03:36 PM
Programming020195BRook
Soulless is a superb looking game!!! I love the music too!
September 22, 2012 09:32 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement