Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;==========================MAIN SEQUENCING CODE=========================================
- !F_SequenceFlag = $2A
- !F_LazerFlag = $2B
- !F_PortalFlag = $2C
- !F_FlashingFlag = $2D
- !F_OpenFlag = $2E
- !V_Timer = $2F
- !V_LazerWidth = $31
- !V_LazerWidthCurrent = $32
- !V_LazerMiddle = $33
- !V_Cutoff = $34
- !C_LazerBase = #$0140
- !C_Flash1 = #$0160
- !C_Flash2 = #$016B
- !C_Flash3 = #$017B
- !C_OpenPortalTime = #$0180
- !C_TeleportTime = #$01C0
- LDA !F_SequenceFlag ;check to see if the cinematic sequence has started
- CMP #$00 ;if not don't run anything, and do not update the timer
- BEQ NoSequence
- LDA !F_LazerFlag ;check to see if it is time to start the lazer sequence
- CMP #$00 ;this is activated by a sprite in the level
- BEQ NoLazer
- JSR AllLazerCode
- NoLazer:
- LDA !F_PortalFlag ;check to see if it is time to start the portal/wormhole sequence
- CMP #$00
- BEQ NoPortal
- JSR AllPortalCode
- NoPortal:
- LDA !F_OpenFlag ;check to see if it is time to start the opened portal sequence
- CMP #$00 ;if not, skip the opened portal code
- BEQ NoOpen
- JSR AllOpenPortalCode
- NoOpen:
- REP #$20
- INC !V_Timer ;update the timer
- LDA !V_Timer ;see if it is time to end this giant cutscene and teleport to the beginning of the level
- CMP !C_TeleportTime
- BNE NoSequence
- JSR AllTeleportCode
- NoSequence:
- SEP #$20
- RTS
- ;===========================LAZER SUBROUTINE===================================================
- AllLazerCode:
- LDA #$22
- STA $41
- STA $42
- LDA #$02
- STA $43 ;setup lazer window properties
- LDA #$20
- TSB $44
- LDA #$10
- TRB $44
- LDA #$41 ;\
- STA $4370 ; |
- LDA #$26 ; |
- STA $4371 ; |Enable HDMA
- LDA.b #IdrPointers ; |
- STA $4372 ; |
- LDA.b #IdrPointers>>8 ; |
- STA $4373 ; |
- LDA.b #IdrPointers>>16 ; |
- STA $4374 ; |
- STZ $4377 ; |
- LDA #$80 ; |HDMA enable
- TSB $0D9F ;/
- REP #$10
- LDX !V_Timer ;here timer acts as an index to determine width of the lazer
- CPX #$0010 ;it runs the growing sequence when less than 1
- BCC Growing
- CPX #$0060
- BCS Shrinking ;and runs the shrinking sequence when greater than 60
- LDA #$08
- STA !V_LazerWidth ;when betweeen those values, the lazer is set at maximum width
- REP #$20
- TXA
- AND #$0001
- BEQ ShiftLeft
- SEP #$20
- LDA !V_LazerMiddle
- CLC
- ADC #$02
- STA !V_LazerMiddle
- BRA NoEndLazer
- ShiftLeft:
- SEP #$20
- LDA !V_LazerMiddle
- SEC
- SBC #$02
- STA !V_LazerMiddle
- BRA NoEndLazer
- Shrinking:
- REP #$20
- TXA
- SEC
- 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
- TAX
- SEP #$20
- Growing:
- LDA LazerWidthTable,x
- STA !V_LazerWidth
- CMP #$00 ;if we reach the end of the sequence of widths (i.e. the lazer shrinks to width 00)
- BNE NoEndLazer ;set the lazer flag back to 00 so we don't run the lazer code anymore
- STZ !F_LazerFlag ;and set the portal flag to 01 so we can start the portal sequence
- LDA #$01
- STA !F_PortalFlag
- NoEndLazer:
- STZ !V_LazerWidthCurrent
- LDX !C_LazerBase ;lazer base says how many scanlines down the lazer window should start at
- ImaFireinMahLazor:
- LDA !V_LazerMiddle
- SEC
- SBC !V_LazerWidthCurrent ;middle of the screen - lazer width gives us the left border of the lazer
- STA $04A0,x ;store that to window1 left-bound for this scanline
- LDA !V_LazerMiddle
- CLC
- ADC !V_LazerWidthCurrent ;add this time to get the right border
- STA $04A1,x ;store that to window1 right-bound for this scanline
- LDA !V_LazerWidthCurrent
- CMP !V_LazerWidth
- BEQ NoIncLazerWidth
- INC !V_LazerWidthCurrent
- NoIncLazerWidth:
- DEX
- DEX ;decreace the index x so we can move up a scanline
- CPX #$0000 ;if we haven't reached the top scanline...
- BNE ImaFireinMahLazor ;...run the code again
- SEP #$10
- RTS
- ;===========================PORTAL SUBROUTINE====================================================
- AllPortalCode:
- LDA $123456
- LDA #$02
- STA $41
- STZ $43 ;setup portal window properties.
- REP #$30
- LDA #$00FF
- LDX #$0000
- Clearwindowloop: ;clear window 1
- STA $04A0,x
- INX
- INX
- CPX #$01C2
- BNE Clearwindowloop
- SEP #$30
- LDA $123457
- LDA !F_FlashingFlag ;durring the portal sequence, there will be 3 frames where the screen flashes full with window 1
- CMP #$00 ;check if this is one of those times, and if so don't run the rest of the portal sequence
- BEQ NoFlashing
- REP #$30
- LDA #$FF00
- LDX #$0000
- Fillwindowloop: ;fill the screen with window 1 (flash)
- STA $04A0,x
- INX
- INX
- CPX #$01C2
- BNE Fillwindowloop
- SEP #$30
- STZ !F_FlashingFlag
- JMP NoPortal
- NoFlashing:
- LDA $123458
- REP #$30
- 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)
- 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
- SEC
- AND #$FFFE
- TAX ;x now holds the scanline index
- LDY #$0000 ;load y with a new incrementing index to determine what 'circle value' to use from out circle table
- SEP #$20
- PortalLoop:
- CPY #$00C8 ;if the circle index has a value larger than the number of values in circle table...
- BCS DoneWithCircle ;we are done drawing the circle, and we should finish the portal code
- CPX #$01C0 ;if the scanline index has a value larger than the total number of scanline values in the HDMA table...
- BCS CircleOutOfRange ;...this part of the circle is either above or below the screen, so we shouldn't draw it
- LDA CircleTable,y ;get the y offset to correctly draw the circle length at this scanline-bound
- STA $04A0,x ;and set it to the left bound of this scanline
- INY
- LDA CircleTable,y ;do it again for the right bound
- INY
- INX
- STA $04A0,x ;and set it to the right bound of this scanline
- INX
- BRA PortalLoop
- CircleOutOfRange:
- INY
- INY
- INX
- INX
- BRA PortalLoop ;we're BRAing because the loop breaks out conditionally at the beginning
- DoneWithCircle:
- EndPortalLoop:
- LDA $123459
- REP #$20
- SEP #$10 ;A is 16-bit, X and Y are 8-bit
- LDA !V_Timer ;check to see if it is time to do any of the "flashes" from before
- CMP !C_Flash1 ;it will happen on the next frame
- BEQ Flash
- CMP !C_Flash2
- BEQ Flash
- CMP !C_Flash3
- BEQ Flash
- CMP !C_OpenPortalTime ;check to see if the portal sequence is done, and it is time to "open" it
- BNE NoSetOpen
- SEP #$20
- LDA #$01 ;if so, set the flag
- STA !F_OpenFlag
- STZ !F_PortalFlag
- NoSetOpen:
- SEP #$20
- RTS
- Flash:
- SEP #$20
- LDA #$01
- STA !F_FlashingFlag
- LDA #$22
- STA $41
- LDA #$02
- STA $43 ;setup flash window properties
- RTS
- ;===========================OPENED PORTAL SUBROUTINE==================================================
- AllOpenPortalCode:
- REP #$30
- LDA #$FF00
- LDX #$0000
- Fillwindowloop2: ;fill the screen with window 1 (portal)
- STA $04A0,x
- INX
- INX
- CPX #$01C2
- BNE Fillwindowloop2
- SEP #$30
- ;there will also probably be some non-windowing HDMA stuff here to make the ocean background scroll in an interesting way
- RTS
- ;============================TELEPORT SUBROUTINE======================================================
- AllTeleportCode:
- SEP #$20
- LDA #$06 ;teleport
- STA $71
- STZ $89
- STZ $88
- RTS
- ;============================TABLES AND POINTERS======================================================
- CircleTable:
- db $77, $89, $72, $8e, $6f, $91, $6d, $93, $6b, $95, $69, $97, $67, $99, $65, $9b
- db $64, $9c, $62, $9e, $61, $9f, $60, $a0, $5f, $a1, $5e, $a2, $5d, $a3, $5c, $a4
- db $5b, $a5, $5a, $a6, $59, $a7, $58, $a8, $58, $a8, $57, $a9, $56, $aa, $56, $aa
- db $55, $ab, $55, $ab, $54, $ac, $54, $ac, $53, $ad, $53, $ad, $52, $ae, $52, $ae
- db $51, $af, $51, $af, $51, $af, $50, $b0, $50, $b0, $50, $b0, $50, $b0, $50, $b0
- db $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1
- db $4f, $b1, $4e, $b2, $4e, $b2, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1
- db $4f, $b1, $4f, $b1, $4f, $b1, $4f, $b1, $50, $b0, $50, $b0, $50, $b0, $50, $b0
- db $50, $b0, $51, $af, $51, $af, $51, $af, $52, $ae, $52, $ae, $53, $ad, $53, $ad
- db $54, $ac, $54, $ac, $55, $ab, $55, $ab, $56, $aa, $56, $aa, $57, $a9, $58, $a8
- db $58, $a8, $59, $a7, $5a, $a6, $5b, $a5, $5c, $a4, $5d, $a3, $5e, $a2, $5f, $a1
- db $60, $a0, $61, $9f, $62, $9e, $64, $9c, $65, $9b, $67, $99, $69, $97, $6b, $95
- db $6d, $93, $6f, $91, $72, $8e, $77, $89
- LazerWidthTable:
- db $01, $01, $01, $01, $01, $01, $02, $02, $02, $02, $03, $03, $04
- db $06, $08, $08, $06, $04, $03, $03, $03, $03, $02, $02, $02, $02
- db $02, $02, $01, $01, $01, $01, $01, $01, $00
- IdrPointers:
- db $F0 : dw $04A0
- db $F0 : dw $0580
- db $00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement