01 ; loop command data
02 LoopCmdWorldNumber: ; world number is one less than world displayed
03 .byte $03, $03, $06, $06, $06, $06, $06, $06, $07, $07, $07
04 LoopCmdPageNumber:
05 .byte $05, $09, $04, $05, $06, $08, $09, $0a, $06, $0b, $10
06 LoopCmdYPosition:
07 .byte $40, $b0, $b0, $80, $40, $40, $80, $40, $f0, $f0, $f0
08
09 .code
10
11 .proc ExecGameLoopback
12
13 mb Player_PageLoc := Player_PageLoc - #4 ; send player back 4 pages
14 mb CurrentPageLoc := CurrentPageLoc - #4 ; send current page back 4 pages
15 mb ScreenLeft_PageLoc := ScreenLeft_PageLoc - #4 ; ..etc
16 mb ScreenRight_PageLoc := ScreenRight_PageLoc - #4
17 mb AreaObjectPageLoc := AreaObjectPageLoc - #4
18
19 lda #$00 ; initialize page select for both
20 sta EnemyObjectPageSel ; area and enemy objects
21 sta AreaObjectPageSel
22 sta EnemyDataOffset ; initialize enemy object data offset
23 sta EnemyObjectPageLoc ; and enemy object page control
24
25 mb AreaDataOffset := AreaDataOfsLoopback[ y ] ; adjust area object offset based on which loop command we encountered
26
27 rts
28
29 .endproc
30
31
32 .proc ProcLoopCommand
33
34 if LoopCommand && CurrentColumnPos == zero ; check if loop command was found
35
36 ldy #$0b ; start at the end of each set of loop data
37
38 repeat
39
40 if dey == negative goto ChkEnemyFrenzy ; if no matching loops, do next
41
42 ; check to see if one of the world numbers matches our current world number AND
43 ; if one of the page numbers matches the page we're currently on:
44
45 until WorldNumber = LoopCmdWorldNumber[ y ] && CurrentPageLoc = LoopCmdPageNumber[ y ]
46
47 ; fall through to check player postion:
48 ; if the player is at the correct position AND on solid ground (i.e. not jumping or falling)
49 if Player_Y_Position = LoopCmdYPosition[ y ] && Player_State = #0
50
51 ; are we in world 7?
52 if WorldNumber <> #World7 goto InitMultLoop
53
54 inc MultiLoopCorrectCntr ; increment counter for correct progression
55
56 IncLoopPass:
57
58 inc MultiLoopPassCntr ; increment master multi-part counter
59 if MultiLoopPassCntr <> #3 goto InitLCmd ; have we done all three parts?
60 if MultiLoopCorrectCntr = #3 goto InitMultLoop ; if so, have we done them all correctly?
61
62 else Z clear
63 if WorldNumber = #World7 goto IncLoopPass ; are we in world 7?
64 endif
65
66
67 jsr ExecGameLoopback ; if player is not in right place, loop back
68 jsr KillAllEnemies
69
70 InitMultLoop:
71
72 lda #$00 ; initialize counters used for multi-part loop commands
73 sta MultiLoopPassCntr
74 sta MultiLoopCorrectCntr
75
76 InitLCmd:
77
78 lda #$00 ; initialize loop command flag
79 sta LoopCommand
80
81 endif
82
83 .endproc
No comments:
Post a Comment