Advertisement
Guest User

Untitled

a guest
Sep 27th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. LoopCmdWorldNumber:
  2.     .byte $03, $03, $06, $06, $06, $06, $06, $06, $07, $07, $07
  3.  
  4. LoopCmdPageNumber:
  5.     .byte $05, $09, $04, $05, $06, $08, $09, $0a, $06, $0b, $10
  6.  
  7. LoopCmdYPosition:
  8.     .byte $40, $b0, $b0, $80, $40, $40, $80, $40, $f0, $f0, $f0
  9.  
  10. .code
  11.  
  12. .proc ExecGameLoopback
  13.  
  14.     mb Player_PageLoc       := Player_PageLoc       - #4               ; send player back four pages
  15.     mb CurrentPageLoc       := CurrentPageLoc       - #4               ; send current page back four pages
  16.     mb ScreenLeft_PageLoc   := ScreenLeft_PageLoc   - #4
  17.     mb ScreenRight_PageLoc  := ScreenRight_PageLoc  - #4
  18.     mb AreaObjectPageLoc    := AreaObjectPageLoc    - #4
  19.  
  20.     lda #0                                        ; initialize page select for both
  21.     sta EnemyObjectPageSel                        ; area and enemy objects
  22.     sta AreaObjectPageSel
  23.     sta EnemyDataOffset                           ; initialize enemy object data offset
  24.     sta EnemyObjectPageLoc                        ; and enemy object page control
  25.  
  26.     mb AreaDataOffset := AreaDataOfsLoopback[ y ] ; adjust area object offset based on which loop command we encountered
  27.  
  28.     rts
  29.  
  30. .endproc
  31.  
  32.  
  33. .proc ProcLoopCommand
  34.  
  35.     ; check if loop command was found AND at we are at the correct Column
  36.     ; LoopCommand is set by DecodeAreaData
  37.    
  38.     if LoopCommand && ( CurrentColumnPos == zero )
  39.  
  40.         ; Y as index to start at the end of each set of data + 1
  41.         ldy #$0b                                  
  42.  
  43.         repeat
  44.              
  45.             ; if no matching data found, do next part
  46.             if dey == negative goto ChkEnemyFrenzy                    
  47.            
  48.             ; check to see if one of the world numbers matches our current world number AND
  49.             ; if one of the page numbers matches the page we're currently on:
  50.         until WorldNumber = LoopCmdWorldNumber[ y ] && CurrentPageLoc = LoopCmdPageNumber[ y ]
  51.        
  52.         ; we are at the right spot onscreen for current level:
  53.         ; now check player postion:
  54.  
  55.         ; check to see if the player is at the correct position AND on solid ground (i.e. not jumping or falling)
  56.         if Player_Y_Position = LoopCmdYPosition[ y ] && Player_State = #0
  57.            
  58.             ; Not world 7? Then this check is good, correct path was taken..
  59.             ; exit this part and clear Loop and MultiLoop variable
  60.             if WorldNumber <> #WORLD7 goto InitMultLoop
  61.  
  62.             ; increment counter for correct progression for world 7
  63.             inc MultiLoopCorrectCntr
  64.  
  65.             IncLoopPass:
  66.  
  67.             ; increment master multi-part counter
  68.             inc MultiLoopPassCntr
  69.             ; have we done all three parts? if not, clear loop command and continue
  70.             if MultiLoopPassCntr <> #3 goto InitLCmd
  71.            
  72.             ; if so, have we done them all correctly? if not we will fall through and loop
  73.             if MultiLoopCorrectCntr = #3 goto InitMultLoop            
  74.  
  75.         else Z clear
  76.             ; Player in wrong position. If this is world 7, jump back and
  77.             ; increment the counter.
  78.             if WorldNumber = #WORLD7 goto IncLoopPass                  
  79.         endif
  80.  
  81.         ; if player is not in right place, setup values for loop back
  82.         jsr ExecGameLoopback
  83.         jsr KillAllEnemies
  84.  
  85.         ; initialize counters used for multi-part loop commands for world 7
  86.         InitMultLoop:
  87.         lda #0                                    
  88.         sta MultiLoopPassCntr
  89.         sta MultiLoopCorrectCntr
  90.  
  91.         ; initialize loop command flag. This code won't run again until LoopCommand is set
  92.         InitLCmd:
  93.         lda #0
  94.         sta LoopCommand
  95.  
  96.     endif
  97.  
  98.     ; fall through to next routine
  99. .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement