Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LoopCmdWorldNumber:
- .byte $03, $03, $06, $06, $06, $06, $06, $06, $07, $07, $07
- LoopCmdPageNumber:
- .byte $05, $09, $04, $05, $06, $08, $09, $0a, $06, $0b, $10
- LoopCmdYPosition:
- .byte $40, $b0, $b0, $80, $40, $40, $80, $40, $f0, $f0, $f0
- .code
- .proc ExecGameLoopback
- mb Player_PageLoc := Player_PageLoc - #4 ; send player back four pages
- mb CurrentPageLoc := CurrentPageLoc - #4 ; send current page back four pages
- mb ScreenLeft_PageLoc := ScreenLeft_PageLoc - #4
- mb ScreenRight_PageLoc := ScreenRight_PageLoc - #4
- mb AreaObjectPageLoc := AreaObjectPageLoc - #4
- lda #0 ; initialize page select for both
- sta EnemyObjectPageSel ; area and enemy objects
- sta AreaObjectPageSel
- sta EnemyDataOffset ; initialize enemy object data offset
- sta EnemyObjectPageLoc ; and enemy object page control
- mb AreaDataOffset := AreaDataOfsLoopback[ y ] ; adjust area object offset based on which loop command we encountered
- rts
- .endproc
- .proc ProcLoopCommand
- ; check if loop command was found AND at we are at the correct Column
- ; LoopCommand is set by DecodeAreaData
- if LoopCommand && ( CurrentColumnPos == zero )
- ; Y as index to start at the end of each set of data + 1
- ldy #$0b
- repeat
- ; if no matching data found, do next part
- if dey == negative goto ChkEnemyFrenzy
- ; check to see if one of the world numbers matches our current world number AND
- ; if one of the page numbers matches the page we're currently on:
- until WorldNumber = LoopCmdWorldNumber[ y ] && CurrentPageLoc = LoopCmdPageNumber[ y ]
- ; we are at the right spot onscreen for current level:
- ; now check player postion:
- ; check to see if the player is at the correct position AND on solid ground (i.e. not jumping or falling)
- if Player_Y_Position = LoopCmdYPosition[ y ] && Player_State = #0
- ; Not world 7? Then this check is good, correct path was taken..
- ; exit this part and clear Loop and MultiLoop variable
- if WorldNumber <> #WORLD7 goto InitMultLoop
- ; increment counter for correct progression for world 7
- inc MultiLoopCorrectCntr
- IncLoopPass:
- ; increment master multi-part counter
- inc MultiLoopPassCntr
- ; have we done all three parts? if not, clear loop command and continue
- if MultiLoopPassCntr <> #3 goto InitLCmd
- ; if so, have we done them all correctly? if not we will fall through and loop
- if MultiLoopCorrectCntr = #3 goto InitMultLoop
- else Z clear
- ; Player in wrong position. If this is world 7, jump back and
- ; increment the counter.
- if WorldNumber = #WORLD7 goto IncLoopPass
- endif
- ; if player is not in right place, setup values for loop back
- jsr ExecGameLoopback
- jsr KillAllEnemies
- ; initialize counters used for multi-part loop commands for world 7
- InitMultLoop:
- lda #0
- sta MultiLoopPassCntr
- sta MultiLoopCorrectCntr
- ; initialize loop command flag. This code won't run again until LoopCommand is set
- InitLCmd:
- lda #0
- sta LoopCommand
- endif
- ; fall through to next routine
- .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement