Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Sprite_10310:
- Obj17:
- moveq #0,d0
- move.b routine(a0),d0
- move.w Obj17_Index(pc,d0.w),d1
- jmp Obj17_Index(pc,d1.w)
- ; ===========================================================================
- ; off_1031E:
- Obj17_Index: offsetTable
- offsetTableEntry.w Obj17_Init ; 00 Load object art and mappings
- offsetTableEntry.w Obj17_Idle ; 02
- offsetTableEntry.w Obj17_Touched ; 04
- offsetTableEntry.w Obj17_Align ; 06
- offsetTableEntry.w Obj17_Charge ; 08
- offsetTableEntry.w Obj17_Delay ; 0A
- ; ===========================================================================
- ; loc_10324: Obj17_Main:
- Obj17_Init:
- ;addq.b #2,routine(a0)
- move.l #Obj17_MapUnc,mappings(a0)
- move.w #make_art_tile(ArtTile_ArtNem_Pole,1,0),art_tile(a0)
- move.b #4,render_flags(a0)
- move.b #3,priority(a0)
- move.b #8,width_pixels(a0)
- move.w x_pos(a0),$3C(a0) ;store x and y spawn positions
- move.w y_pos(a0),$3E(a0) ;''
- Obj17_Reset:
- move.b #$02,routine(a0) ; advance to next routine (for next frame)
- move.b #$40|$0F,collision_flags(a0)
- ;---------------------------------------------
- ;Obj17_Idle
- ;---------------------------------------------
- Obj17_Idle:
- move.l #$FFFFFF80,d2 ; prepare subtraction/and value
- move.w $3C(a0),d0 ; load object's original X spawn position
- and.w d2,d0 ; wrap to nearest object load block
- move.w (Camera_X_pos).w,d1 ; load screen's X position
- add.w d2,d1 ; move left a load block (include block to left of screen)
- and.w d2,d1 ; wrap to nearest object load block
- sub.w d1,d0 ; subtract from object's X spawn position
- cmpi.w #$0300-$80,d0 ; is the object still within the load area? (-$80 to +$2FF relative to screen)
- bhi.w DeleteObject ; if not, branch to delete the object (it's gone out of range)
- bra.w DisplaySprite ; save object to priority list for display
- ; ---------------------------------------------------------------------------
- ; Object 17 - 04 - Sonic touched the cannon
- ; ---------------------------------------------------------------------------
- Obj17_Touched:
- sf.b $20(a0) ; clear touch/collision response
- move.b #$81,($FFFFB02A).w ; force lock Sonic (no physics, control, gravity etc)
- lea ($FFFFB000).w,a1 ; load Sonic's object RAM slot
- ;move.b AniIDSonAni_Roll,$1C(a1); set Sonic's animation to rolling. Sonic will enter his pushing animation if I leave this in though...
- moveq #$00,d0 ; clear d0
- move.l d0,x_vel(a1) ; clear Sonic's X and Y speed
- move.w d0,inertia(a1) ; clear Sonic's ground speed
- move.b $22(a0),d0 ; load object's status
- andi.b #%00000001,d0 ; get only the mirror (left/right facing) status
- ori.b #%00000110,d0 ; set Sonic's "in-air" and "roll" status bits
- move.b d0,$22(a1) ; set Sonic's direction/status correctly
- sf.b $3C(a1) ; clear "height cap" flag (prevent release jump buttons effect)
- move.b #$02,$24(a1) ; ensure Sonic is in normal control mode
- addq.b #$02,$24(a0) ; advance to next routine (for next frame)
- ; ---------------------------------------------------------------------------
- ; Object 17 - 06 - aligning Sonic towards centre of cannon
- ; ---------------------------------------------------------------------------
- Obj17_Align:
- lea ($FFFFB000).w,a1 ; load Sonic's object RAM slot
- move.w x_pos(a1),d1 ; load Sonic's X and Y positions
- move.w y_pos(a1),d2 ; ''
- sub.w x_pos(a0),d1 ; subtract cannon's X and Y to get the distance
- sub.w y_pos(a0),d2 ; ''
- move.w d1,d0 ; check if Sonic is at object on X and Y already
- or.w d2,d0 ; ''
- beq.s Obj17_AlignFinish ; if so, branch
- jsr CalcAngle ; get the angle Sonic is from the cannon (00 - FF inside d0)
- jsr CalcSine ; get the sine/cosine (X and Y) using the angle in d0
- ext.l d1 ; sign extend to long-word
- ext.l d0 ; ''
- asl.l #$08,d1 ; multiply X and Y to x10000
- asl.l #$08,d0 ; ''
- sub.l d1,x_pos(a1) ; move Sonic towards the object on X
- sub.l d0,y_pos(a1) ; move Sonic towards the object on Y
- bra.w Obj17_Idle ; continue for deletion check and display
- Obj17_AlignFinish:
- addq.b #$02,$24(a0) ; advance to next routine (for next frame)
- move.b #$10,$3B(a0) ; set charge timer
- move.w #SndID_DoorSlam,d0 ; play charge/lock SFX
- jsr (PlaySound).l ; ''
- ; ---------------------------------------------------------------------------
- ; Object 17 - 08 - charging and firing the cannon
- ; ---------------------------------------------------------------------------
- Obj17_Charge:
- subq.w #$01,x_pos(a0) ; move cannon down
- addq.w #$01,y_pos(a0) ; move cannon left
- btst.b #$00,$22(a0) ; is object facing right?
- beq.s Obj17_ChargeRight ; if so, branch
- addq.w #$01+1,$08(a0) ; move cannon right instead
- Obj17_ChargeRight:
- subq.b #$01,$3B(a0) ; minus 1 from charge timer
- bcc.w Obj17_Idle ; if not finished, branch
- move.w $3C(a0),x_pos(a0) ; restore cannon's X position
- move.w $3E(a0),y_pos(a0) ; restore cannon's Y position
- move.l #$0C00F400,($FFFFB010).w ; set Sonic's X and Y speeds (up and right)
- btst.b #$00,$22(a0) ; is the cannon facing right?
- beq.s Obj17_ReleaseRight ; if so, branch
- neg.w ($FFFFB010).w ; reverse Sonic's X speed
- Obj17_ReleaseRight:
- sf.b ($FFFFB02A).w ; release Sonic
- move.b #$60,$3B(a0) ; set delay time before allowing cannon to activate again
- addq.b #$02,$24(a0) ; increase routine counter
- move.w #SndID_Teleport,d0 ; play release SFX
- jsr (PlaySound).l ; ''
- ; ---------------------------------------------------------------------------
- ; Object 17 - 0A - delaying to give Sonic time to shoot away from object
- ; ---------------------------------------------------------------------------
- Obj17_Delay:
- subq.b #$01,$3B(a0) ; minus 1 from delay timer
- bcc.w Obj17_Idle ; if not finished, branch
- bra.w Obj17_Reset ; branch to reset routine counter and collision/touch
- ; ===========================================================================
- ; loc_1044A:
- Obj17_Display:
- bra.w DisplaySprite
- ; ===========================================================================
- ; ===========================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement