SHARE
TWEET

1-Up Polling

slydogstudios Apr 1st, 2015 305 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Polling to see if a player receives a 1-up. This method is limited to how many 1-ups a player
  2. ;  can get in the game. In this scenario, after getting a 1-up at 1 million points, the player
  3. ;  will receive no more extra men.
  4.  
  5. one_up_lo:
  6.         .byte <score_ten_thousands, <score_ten_thousands, <score_hun_thousands, <score_ten_thousands
  7.         .byte <score_hun_thousands, <score_ten_thousands, <score_hun_thousands, <score_ten_thousands
  8.         .byte <score_hun_thousands, <score_ten_thousands, <score_hun_thousands, <score_ten_thousands
  9.         .byte <score_hun_thousands, <score_ten_thousands, <score_hun_thousands, <score_ten_thousands
  10.         .byte <score_hun_thousands, <score_ten_thousands, <score_hun_thousands, <score_ten_thousands
  11.         .byte <score_millions
  12. one_up_hi:
  13.         .byte >score_ten_thousands, >score_ten_thousands, >score_hun_thousands, >score_ten_thousands
  14.         .byte >score_hun_thousands, >score_ten_thousands, >score_hun_thousands, >score_ten_thousands
  15.         .byte >score_hun_thousands, >score_ten_thousands, >score_hun_thousands, >score_ten_thousands
  16.         .byte >score_hun_thousands, >score_ten_thousands, >score_hun_thousands, >score_ten_thousands
  17.         .byte >score_hun_thousands, >score_ten_thousands, >score_hun_thousands, >score_ten_thousands
  18.         .byte >score_millions
  19. one_up_num:
  20.         .byte $02,$05,$01,$05
  21.         .byte $02,$05,$03,$05
  22.         .byte $04,$05,$05,$05
  23.         .byte $06,$05,$07,$05
  24.         .byte $08,$05,$09,$05
  25.         .byte $01
  26. test_one_up:
  27.         ldx one_up_test                         ; Load X with variable that keeps track of the offset
  28.         cpx #21                                 ;  for the scoring tables. If it gets to 21, the player
  29.         bcc :+                                  ;  has maxed out the ability to gain one-ups, and
  30.                 rts                             ;  the routine just returns.
  31. :       lda one_up_lo, x                        ; Get the address for the part of the score that needs
  32.         sta temp_16bit_2+0                      ;  to be checked...
  33.         lda one_up_hi, x                        ;
  34.         sta temp_16bit_2+1                      ;
  35.         ldy #$00                                ;
  36.         lda (temp_16bit_2), y                   ; ... and compare it to the number in the one_up_num
  37.         cmp one_up_num, x                       ;  table.
  38.         bne return_oneup                        ; If the number doesn't match, do nothing but return
  39.                 inc one_up_test                 ;  to the game, but if they match, increment the player's
  40.                 inc lives                       ;  lives by 1, increment the offset to check for the
  41.                 ldx #$0b                        ;  next one-up, and run the sound effect. After all this
  42.                 jmp return_sfx_routine          ;  is done, return to the game.
  43. return_oneup:                                   ;
  44.         rts                                     ;
RAW Paste Data
Top