Advertisement
Guest User

free ipod also cinematic code

a guest
Mar 24th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.96 KB | None | 0 0
  1. ;==========================MAIN SEQUENCING CODE=========================================
  2.  
  3. !F_SequenceFlag = $2A
  4. !F_LazerFlag = $2B
  5. !F_PortalFlag = $2C
  6. !F_FlashingFlag = $2D
  7. !F_OpenFlag = $2E
  8.  
  9. !V_Timer = $2F
  10. !V_LazerWidth = $31
  11. !V_LazerWidthCurrent = $32
  12. !V_LazerMiddle = $33
  13. !V_Cutoff = $34
  14.  
  15. !C_LazerBase = #$0140
  16. !C_Flash1 = #$0160
  17. !C_Flash2 = #$016B
  18. !C_Flash3 = #$017B
  19. !C_OpenPortalTime = #$0180
  20. !C_TeleportTime = #$01C0
  21.  
  22. LDA !F_SequenceFlag ;check to see if the cinematic sequence has started
  23. CMP #$00 ;if not don't run anything, and do not update the timer
  24. BEQ NoSequence
  25. LDA !F_LazerFlag ;check to see if it is time to start the lazer sequence
  26. CMP #$00 ;this is activated by a sprite in the level
  27. BEQ NoLazer
  28. JSR AllLazerCode
  29. NoLazer:
  30.  
  31. LDA !F_PortalFlag ;check to see if it is time to start the portal/wormhole sequence
  32. CMP #$00
  33. BEQ NoPortal
  34. JSR AllPortalCode
  35. NoPortal:
  36.  
  37. LDA !F_OpenFlag ;check to see if it is time to start the opened portal sequence
  38. CMP #$00 ;if not, skip the opened portal code
  39. BEQ NoOpen
  40. JSR AllOpenPortalCode
  41. NoOpen:
  42.  
  43. REP #$20
  44. INC !V_Timer ;update the timer
  45. LDA !V_Timer ;see if it is time to end this giant cutscene and teleport to the beginning of the level
  46. CMP !C_TeleportTime
  47. BNE NoSequence
  48. JSR AllTeleportCode
  49. NoSequence:
  50. SEP #$20
  51. RTS
  52.  
  53. ;===========================LAZER SUBROUTINE===================================================
  54.  
  55. AllLazerCode:
  56.  
  57. LDA #$22
  58. STA $41
  59. STA $42
  60. LDA #$02
  61. STA $43 ;setup lazer window properties
  62. LDA #$20
  63. TSB $44
  64. LDA #$10
  65. TRB $44
  66.  
  67. LDA #$41 ;\
  68. STA $4370 ; |
  69. LDA #$26 ; |
  70. STA $4371 ; |Enable HDMA
  71. LDA.b #IdrPointers ; |
  72. STA $4372 ; |
  73. LDA.b #IdrPointers>>8 ; |
  74. STA $4373 ; |
  75. LDA.b #IdrPointers>>16 ; |
  76. STA $4374 ; |
  77. STZ $4377 ; |
  78. LDA #$80 ; |HDMA enable
  79. TSB $0D9F ;/
  80.  
  81.  
  82.  
  83. REP #$10
  84. LDX !V_Timer ;here timer acts as an index to determine width of the lazer
  85. CPX #$0010 ;it runs the growing sequence when less than 1
  86. BCC Growing
  87. CPX #$0060
  88. BCS Shrinking ;and runs the shrinking sequence when greater than 60
  89. LDA #$08
  90. STA !V_LazerWidth ;when betweeen those values, the lazer is set at maximum width
  91. REP #$20
  92. TXA
  93. AND #$0001
  94. BEQ ShiftLeft
  95. SEP #$20
  96. LDA !V_LazerMiddle
  97. CLC
  98. ADC #$02
  99. STA !V_LazerMiddle
  100. BRA NoEndLazer
  101. ShiftLeft:
  102. SEP #$20
  103. LDA !V_LazerMiddle
  104. SEC
  105. SBC #$02
  106. STA !V_LazerMiddle
  107. BRA NoEndLazer
  108. Shrinking:
  109. REP #$20
  110. TXA
  111. SEC
  112. SBC #$004F ;here we offset the timer when above 100 so the index doesn't have to be that many terms of just 8's
  113. TAX
  114. SEP #$20
  115. Growing:
  116.  
  117. LDA LazerWidthTable,x
  118. STA !V_LazerWidth
  119. CMP #$00 ;if we reach the end of the sequence of widths (i.e. the lazer shrinks to width 00)
  120. BNE NoEndLazer ;set the lazer flag back to 00 so we don't run the lazer code anymore
  121. STZ !F_LazerFlag ;and set the portal flag to 01 so we can start the portal sequence
  122. LDA #$01
  123. STA !F_PortalFlag
  124. NoEndLazer:
  125.  
  126. STZ !V_LazerWidthCurrent
  127. LDX !C_LazerBase ;lazer base says how many scanlines down the lazer window should start at
  128. ImaFireinMahLazor:
  129. LDA !V_LazerMiddle
  130. SEC
  131. SBC !V_LazerWidthCurrent ;middle of the screen - lazer width gives us the left border of the lazer
  132. STA $04A0,x ;store that to window1 left-bound for this scanline
  133. LDA !V_LazerMiddle
  134. CLC
  135. ADC !V_LazerWidthCurrent ;add this time to get the right border
  136. STA $04A1,x ;store that to window1 right-bound for this scanline
  137. LDA !V_LazerWidthCurrent
  138. CMP !V_LazerWidth
  139. BEQ NoIncLazerWidth
  140. INC !V_LazerWidthCurrent
  141. NoIncLazerWidth:
  142. DEX
  143. DEX ;decreace the index x so we can move up a scanline
  144. CPX #$0000 ;if we haven't reached the top scanline...
  145. BNE ImaFireinMahLazor ;...run the code again
  146. SEP #$10
  147. RTS
  148.  
  149. ;===========================PORTAL SUBROUTINE====================================================
  150.  
  151. AllPortalCode:
  152.  
  153. LDA $123456
  154.  
  155.  
  156. LDA #$02
  157. STA $41
  158. STZ $43 ;setup portal window properties.
  159.  
  160.  
  161. REP #$30
  162. LDA #$00FF
  163. LDX #$0000
  164. Clearwindowloop: ;clear window 1
  165. STA $04A0,x
  166. INX
  167. INX
  168. CPX #$01C2
  169. BNE Clearwindowloop
  170. SEP #$30
  171.  
  172. LDA $123457
  173.  
  174. LDA !F_FlashingFlag ;durring the portal sequence, there will be 3 frames where the screen flashes full with window 1
  175. CMP #$00 ;check if this is one of those times, and if so don't run the rest of the portal sequence
  176. BEQ NoFlashing
  177.  
  178. REP #$30
  179. LDA #$FF00
  180. LDX #$0000
  181. Fillwindowloop: ;fill the screen with window 1 (flash)
  182. STA $04A0,x
  183. INX
  184. INX
  185. CPX #$01C2
  186. BNE Fillwindowloop
  187. SEP #$30
  188.  
  189. STZ !F_FlashingFlag
  190. JMP NoPortal
  191. NoFlashing:
  192.  
  193. LDA $123458
  194.  
  195. REP #$30
  196. LDA !V_Timer ;now we're going to use the timer as an index for how many scanlines down the circle window should start (it will increase with time)
  197. SBC #$00E0 ;offset by the frame that this code first runs, plus the height of the circle (so at first the circle is not on screen at all) 64 + 60
  198. SEC
  199. AND #$FFFE
  200. TAX ;x now holds the scanline index
  201. LDY #$0000 ;load y with a new incrementing index to determine what 'circle value' to use from out circle table
  202. SEP #$20
  203. PortalLoop:
  204. CPY #$00C8 ;if the circle index has a value larger than the number of values in circle table...
  205. BCS DoneWithCircle ;we are done drawing the circle, and we should finish the portal code
  206. CPX #$01C0 ;if the scanline index has a value larger than the total number of scanline values in the HDMA table...
  207. BCS CircleOutOfRange ;...this part of the circle is either above or below the screen, so we shouldn't draw it
  208. LDA CircleTable,y ;get the y offset to correctly draw the circle length at this scanline-bound
  209. STA $04A0,x ;and set it to the left bound of this scanline
  210. INY
  211. LDA CircleTable,y ;do it again for the right bound
  212. INY
  213. INX
  214. STA $04A0,x ;and set it to the right bound of this scanline
  215. INX
  216. BRA PortalLoop
  217. CircleOutOfRange:
  218. INY
  219. INY
  220. INX
  221. INX
  222. BRA PortalLoop ;we're BRAing because the loop breaks out conditionally at the beginning
  223. DoneWithCircle:
  224.  
  225.  
  226. EndPortalLoop:
  227.  
  228. LDA $123459
  229.  
  230. REP #$20
  231. SEP #$10 ;A is 16-bit, X and Y are 8-bit
  232.  
  233. LDA !V_Timer ;check to see if it is time to do any of the "flashes" from before
  234. CMP !C_Flash1 ;it will happen on the next frame
  235. BEQ Flash
  236. CMP !C_Flash2
  237. BEQ Flash
  238. CMP !C_Flash3
  239. BEQ Flash
  240. CMP !C_OpenPortalTime ;check to see if the portal sequence is done, and it is time to "open" it
  241. BNE NoSetOpen
  242. SEP #$20
  243. LDA #$01 ;if so, set the flag
  244. STA !F_OpenFlag
  245. STZ !F_PortalFlag
  246. NoSetOpen:
  247. SEP #$20
  248. RTS
  249.  
  250. Flash:
  251. SEP #$20
  252. LDA #$01
  253. STA !F_FlashingFlag
  254.  
  255. LDA #$22
  256. STA $41
  257. LDA #$02
  258. STA $43 ;setup flash window properties
  259.  
  260. RTS
  261.  
  262.  
  263. ;===========================OPENED PORTAL SUBROUTINE==================================================
  264.  
  265. AllOpenPortalCode:
  266. REP #$30
  267. LDA #$FF00
  268. LDX #$0000
  269. Fillwindowloop2: ;fill the screen with window 1 (portal)
  270. STA $04A0,x
  271. INX
  272. INX
  273. CPX #$01C2
  274. BNE Fillwindowloop2
  275. SEP #$30
  276. ;there will also probably be some non-windowing HDMA stuff here to make the ocean background scroll in an interesting way
  277. RTS
  278.  
  279. ;============================TELEPORT SUBROUTINE======================================================
  280.  
  281. AllTeleportCode:
  282. SEP #$20
  283. LDA #$06 ;teleport
  284. STA $71
  285. STZ $89
  286. STZ $88
  287. RTS
  288.  
  289. ;============================TABLES AND POINTERS======================================================
  290.  
  291. CircleTable:
  292. db $77, $89, $72, $8e, $6f, $91, $6d, $93, $6b, $95, $69, $97, $67, $99, $65, $9b
  293. db $64, $9c, $62, $9e, $61, $9f, $60, $a0, $5f, $a1, $5e, $a2, $5d, $a3, $5c, $a4
  294. db $5b, $a5, $5a, $a6, $59, $a7, $58, $a8, $58, $a8, $57, $a9, $56, $aa, $56, $aa
  295. db $55, $ab, $55, $ab, $54, $ac, $54, $ac, $53, $ad, $53, $ad, $52, $ae, $52, $ae
  296. db $51, $af, $51, $af, $51, $af, $50, $b0, $50, $b0, $50, $b0, $50, $b0, $50, $b0
  297. db $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1
  298. db $4f, $b1, $4e, $b2, $4e, $b2, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1
  299. db $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $50, $b0, $50, $b0, $50, $b0, $50, $b0
  300. db $50, $b0, $51, $af, $51, $af, $51, $af, $52, $ae, $52, $ae, $53, $ad, $53, $ad
  301. db $54, $ac, $54, $ac, $55, $ab, $55, $ab, $56, $aa, $56, $aa, $57, $a9, $58, $a8
  302. db $58, $a8, $59, $a7, $5a, $a6, $5b, $a5, $5c, $a4, $5d, $a3, $5e, $a2, $5f, $a1
  303. db $60, $a0, $61, $9f, $62, $9e, $64, $9c, $65, $9b, $67, $99, $69, $97, $6b, $95
  304. db $6d, $93, $6f, $91, $72, $8e, $77, $89
  305.  
  306. LazerWidthTable:
  307. db $01, $01, $01, $01, $01, $01, $02, $02, $02, $02, $03, $03, $04
  308. db $06, $08, $08, $06, $04, $03, $03, $03, $03, $02, $02, $02, $02
  309. db $02, $02, $01, $01, $01, $01, $01, $01, $00
  310.  
  311. IdrPointers:
  312. db $F0 : dw $04A0
  313. db $F0 : dw $0580
  314. db $00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement