🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

A C64 Game - Step 80

posted in New Old Things
Published December 08, 2012
Advertisement

Did you notice the huge door in the background? It's about time it opens!



That's actually pretty simple. At the jump-to-next level code we add a check. Whether the open door animation is shown depends on a bit in the LEVEL_CONFIG byte.

GoToNextLevel 
          lda LEVEL_CONFIG 
          and #$04 
          beq .NoDoorAnim 
          jsr DoorAnim
          
.NoDoorAnim


The actual animation is straight forward. The door location is hard coded, and we simply copy the characters one step to the outer side and replace the innermost characters with empty space.

Notice that we use a method which is not possible that easy in todays code: We have a local code loop until the door is completely opened.
Since there are no events to be handled, messages to be retrieved or other OS specific code required, we can do that.

;------------------------------------------------------------
;open door animation
;------------------------------------------------------------
!zone DoorAnim
DoorAnim 
          lda #0 
          sta LEVEL_DONE_DELAY
          
.DoorAnimLoop 
          jsr WaitFrame 
          inc LEVEL_DONE_DELAY 
          lda LEVEL_DONE_DELAY 
          and #$07 
          bne .DoorAnimLoop 
          
          ;open door (16,11) 
          lda #11 
          sta PARAM2 
- 
          ldy PARAM2 
          lda SCREEN_LINE_OFFSET_TABLE_LO,y 
          sta ZEROPAGE_POINTER_1 
          lda SCREEN_LINE_OFFSET_TABLE_HI,y 
          sta ZEROPAGE_POINTER_1 + 1 
          ldy #17 
          lda (ZEROPAGE_POINTER_1),y 
          dey 
          sta (ZEROPAGE_POINTER_1),y 
          ldy #18 
          lda (ZEROPAGE_POINTER_1),y 
          dey 
          sta (ZEROPAGE_POINTER_1),y 
          ldy #19 
          lda (ZEROPAGE_POINTER_1),y 
          dey 
          sta (ZEROPAGE_POINTER_1),y 
          
          lda #32 
          ldy #19 
          sta (ZEROPAGE_POINTER_1),y 
          ldy #22 
          lda (ZEROPAGE_POINTER_1),y 
          iny 
          sta (ZEROPAGE_POINTER_1),y 
          ldy #21 
          lda (ZEROPAGE_POINTER_1),y 
          iny 
          sta (ZEROPAGE_POINTER_1),y 
          ldy #20 
          lda (ZEROPAGE_POINTER_1),y 
          iny 
          sta (ZEROPAGE_POINTER_1),y 
          lda #32 
          ldy #20 
          sta (ZEROPAGE_POINTER_1),y 
          
          inc PARAM2 
          lda PARAM2 
          cmp #21 
          bne - 
          
          ; 
          lda LEVEL_DONE_DELAY 
          lsr 
          lsr 
          lsr 
          cmp #4 
          bne .DoorAnimLoop 
          
          ;door is fully open now
- 
          jsr WaitFrame 
          inc LEVEL_DONE_DELAY 
          lda LEVEL_DONE_DELAY 
          cmp #200 
          bne - 
          
          rts

Also, since I'm going on vacation this tutorial takes a break until next year. Thanks for your support so far, have fun!

step80.zip

Previous Step Next Step


Previous Entry A C64 Game - Step 79
1 likes 2 comments

Comments

Programming020195BRook
Ooooooo What could be inside that room?
December 10, 2012 03:58 AM
Endurion
Well, unfortunately you'll have to wait until next year.
Or look at the earlier served Retro Remakes site ;)
December 10, 2012 05:09 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement