Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ---------------------------------------------------------------------------
- ; Object 60 - Orbinaut enemy (LZ, SLZ, SBZ)
- ; ---------------------------------------------------------------------------
- Obj60: ; XREF: Obj_Index
- moveq #0,d0
- move.b $24(a0),d0
- move.w Obj60_Index(pc,d0.w),d1
- jmp Obj60_Index(pc,d1.w)
- ; ===========================================================================
- Obj60_Index: dc.w Obj60_Main-Obj60_Index
- dc.w Obj60_ChkSonic-Obj60_Index
- dc.w Obj60_Display-Obj60_Index
- dc.w Obj60_MoveOrb-Obj60_Index
- dc.w Obj60_ChkDel2-Obj60_Index
- ; ===========================================================================
- Obj60_Main: ; XREF: Obj60_Index
- move.l #Map_obj60,4(a0) ; mappings
- move.w #$429,2(a0) ; SBZ specific code art and palette (sonic's palette)
- cmpi.b #5,($FFFFFE10).w ; check if level is SBZ
- beq.s loc_11D02 ; if it isn't, branch
- move.w #$2429,2(a0) ; SLZ specific code
- loc_11D02:
- cmpi.b #1,($FFFFFE10).w ; check if level is LZ
- bne.s loc_11D10 ; if not, branch
- move.w #$467,2(a0) ; LZ specific code
- loc_11D10:
- ori.b #4,1(a0) ; use playfield coordinates
- move.b #4,$18(a0) ; sprite priority
- move.b #$B,$20(a0) ; collision
- move.b #$C,$19(a0) ; width in pixels
- moveq #0,d2 ; clear d2
- lea $37(a0),a2 ; load an address in a2
- movea.l a2,a3 ; copy it into a3
- addq.w #1,a2 ; add 1 to the address in a2
- moveq #3,d1 ; set number of orbs to create (it happens once then does it 3 more times)
- Obj60_MakeOrbs:
- bsr.w SingleObjLoad2 ; load another object
- bne.s loc_11D90 ; if there is no free "space" (it failed), cancel ( use SingleObjLoad2 when you think that all the slots before the current object are occupied)
- addq.b #1,(a3) ; add 1 to a counter (used to tell how many objects are loaded to tell how many objects to delete)
- move.w a1,d5 ; move a1 to d5 (a1 is the address of the free object slot found by singleobjload2)
- subi.w #-$3000,d5 ; -$3000 = $D000, which is the start of the object RAM
- lsr.w #6,d5 ; dividing d5 by 1 lsh 6 ($40, also the size of all objects), getting the size of the object
- andi.w #$7F,d5 ; checks if everything is able to happen (isn't really needed)
- move.b d5,(a2)+ ; store index of spiked object
- move.b 0(a0),0(a1) ; load spiked orb object
- move.b #6,$24(a1) ; set routine counter for orbs (skip to Obj60_MoveOrb on the next frame)
- move.l 4(a0),4(a1) ; copy mappings
- move.w 2(a0),2(a1) ; copy palette and art location
- ori.b #4,1(a1) ; use playfield coordinates
- move.b #4,$18(a1) ; sprite priority
- move.b #8,$19(a1) ; width in pixels
- move.b #3,$1A(a1) ; animation frame
- move.b #$98,$20(a1) ; collision (harm)
- move.b d2,$26(a1) ; angle
- addi.b #$40,d2 ; add $40 to the angle (90 degrees)
- move.l a0,$3C(a1) ; stores the address of the parent object
- dbf d1,Obj60_MakeOrbs ; repeat sequence 3 more times
- loc_11D90:
- moveq #1,d0 ; changes the way the orbs rotate (set to a higher number to make the orbs go faster)
- btst #0,$22(a0) ; test if going left, if not, change the way of the rotation
- beq.s Obj60_Move
- neg.w d0 ; switch to make it go right
- Obj60_Move:
- move.b d0,$36(a0) ; set the speed at which the orbs rotate
- move.b $28(a0),$24(a0) ; if type is 02, skip the firing rountine
- addq.b #2,$24(a0) ; add 2 to routine counter
- move.w #-$40,$10(a0) ; move orbinaut to the left
- btst #0,$22(a0) ; is orbinaut reversed?
- beq.s locret_11DBC ; if not, branch
- neg.w $10(a0) ; move orbinaut to the right
- locret_11DBC:
- rts
- ; ===========================================================================
- Obj60_ChkSonic: ; XREF: Obj60_Index
- move.w ($FFFFD008).w,d0 ; put Sonic's X position in d0
- sub.w 8(a0),d0 ; subtract the orbinaut's X position
- bcc.s loc_11DCA ; if d0 is greater or equal to 0, branch
- neg.w d0 ; make d0 positive
- loc_11DCA:
- cmpi.w #$A0,d0 ; is Sonic within $A0 pixels of orbinaut?
- bcc.s Obj60_Animate ; if not, branch
- move.w ($FFFFD00C).w,d0 ; put Sonic's Y position in d0
- sub.w $C(a0),d0 ; subtract the orbitnaut's Y position
- bcc.s loc_11DDC ; if d0 is greater or equal to 0, branch
- neg.w d0 ; if not, make it positive
- loc_11DDC:
- cmpi.w #$50,d0 ; is Sonic within $50 pixels of orbinaut?
- bcc.s Obj60_Animate ; if not, branch
- tst.w ($FFFFFE08).w ; is debug mode on?
- bne.s Obj60_Animate ; if yes, branch
- move.b #1,$1C(a0) ; use "angry" animation
- Obj60_Animate:
- lea (Ani_obj60).l,a1 ; load it's animation
- bsr.w AnimateSprite
- bra.w Obj60_ChkDel ; check if it should be deleted
- ; ===========================================================================
- Obj60_Display: ; XREF: Obj60_Index
- bsr.w SpeedToPos ; makes the sprite catch up to where it should be (according to the code)
- Obj60_ChkDel: ; XREF: Obj60_Animate
- move.w 8(a0),d0 ; move the orbinaut's X position into d0
- andi.w #$FF80,d0 ; $FF80 = %1111111110000000 (checks if it's offscreen)
- move.w ($FFFFF700).w,d1 ; put plane A x-position into d1
- subi.w #$80,d1 ; subtract $80 from d1
- andi.w #$FF80,d1 ; checks if offscreen
- sub.w d1,d0 ; subtract d1 from d0
- cmpi.w #$280,d0 ; compare d0 to $280
- bhi.w Obj60_ChkGone ; branch if greater than $280
- bra.w DisplaySprite ; display an object when a0 is the RAM
- ; ===========================================================================
- Obj60_ChkGone: ; XREF: Obj60_ChkDel
- lea ($FFFFFC00).w,a2 ; respawn index
- moveq #0,d0 ; make d0 the value of #0
- move.b $23(a0),d0 ; gets the index
- beq.s loc_11E34 ; if 0, branch
- bclr #7,2(a2,d0.w) ; if d0 == 1, then it clears bit 7 at $FFFFFC03
- loc_11E34:
- lea $37(a0),a2 ; puts $37(a0) into a2
- moveq #0,d2 ; clears d2
- move.b (a2)+,d2 ; puts the number of orbs loaded into d2
- subq.w #1,d2 ; subtracts 1 from d2 (to use with dvf)
- bcs.s Obj60_Delete ; if the value is negative, branch
- loc_11E40:
- moveq #0,d0 ; clears d0
- move.b (a2)+,d0 ; get the index of the orb in the SST
- lsl.w #6,d0 ; multiply by $40
- addi.l #$FFD000,d0 ; add the start of the SST - now we have the address of the orb
- movea.l d0,a1 ; put that address in a1
- bsr.w DeleteObject2 ; delete the orb
- dbf d2,loc_11E40 ; process the next orb, if there's one
- Obj60_Delete:
- bra.w DeleteObject ; delete the orbinaut now
- ; ===========================================================================
- Obj60_MoveOrb: ; XREF: Obj60_Index
- movea.l $3C(a0),a1 ; get the parent orbinaut
- cmpi.b #$60,0(a1) ; is it still an orbinaut?
- bne.w DeleteObject ; if not, delete the orb
- cmpi.b #2,$1A(a1) ; does the orbinaut use the "angry" frame?
- bne.s Obj60_Circle ; if not, branch
- cmpi.b #$40,$26(a0) ; is the angle of the orb $40?
- bne.s Obj60_Circle ; if not, branch
- addq.b #2,$24(a0) ; increase routine counter
- subq.b #1,$37(a1) ; subtract 1 from the number of orbs around the orbinaut
- bne.s Obj60_FireOrb ; if there are orbs left, branch
- addq.b #2,$24(a1) ; increase the orbinaut's routine counter
- Obj60_FireOrb:
- move.w #-$200,$10(a0) ; move orb to the left (quickly)
- btst #0,$22(a1) ; is the orbinaut facing left?
- beq.s Obj60_Display2 ; if yes, branch
- neg.w $10(a0) ; move orb to the right (quickly)
- Obj60_Display2:
- bra.w DisplaySprite
- ; ===========================================================================
- Obj60_Circle: ; XREF: Obj60_MoveOrb
- move.b $26(a0),d0 ; get the angle of the orb
- jsr (CalcSine).l ; get the sine and cosine
- asr.w #4,d1 ; multiply d1 by $10
- add.w 8(a1),d1 ; add the X position of the orbinaut
- move.w d1,8(a0) ; use that as the new X position
- asr.w #4,d0 ; multiply d0 by $10
- add.w $C(a1),d0 ; add the Y position of the orbinaut
- move.w d0,$C(a0) ; use that as the new Y position
- move.b $36(a1),d0 ; get the rotation speed
- add.b d0,$26(a0) ; add that to the angle
- bra.w DisplaySprite ; display the orb
- ; ===========================================================================
- Obj60_ChkDel2: ; XREF: Obj60_Index
- bsr.w SpeedToPos ; move the object
- tst.b 1(a0) ; test the render flags
- bpl.w DeleteObject ; if the object is offscreen, delete it
- bra.w DisplaySprite ; if it isn't, display it
- ; ===========================================================================
- Ani_obj60:
- include "_anim\obj60.asm"
- ; ---------------------------------------------------------------------------
- ; Sprite mappings - Orbinaut enemy (LZ, SLZ, SBZ)
- ; ---------------------------------------------------------------------------
- Map_obj60:
- include "_maps\obj60.asm"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement