Back to the object porting problems (S2 -> S1)

Discussion in 'Discussion and Q&A Archive' started by DeoxysKyogre, Jan 31, 2011.

Thread Status:
Not open for further replies.
  1. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    Basically I'm trying to port the S2 pinball mode object (that one, which makes sonic roll and forces him to move to the right). But it's not working. I converted everything it seems to need, but it doesn't just want to work.



    Code:
    ; ===========================================================================
    
    ; ----------------------------------------------------------------------------
    
    ; Object 84 - Pinball mode enable/disable
    
    ; (used in Casino Night Zone to determine when Sonic should stay in a ball)
    
    ; ----------------------------------------------------------------------------
    
    ; Sprite_2115C:
    
    Obj1D:
    
    	moveq	#0,d0
    
    	move.b  $24(a0),d0
    
    	move.w	Obj1D_States(pc,d0.w),d1
    
    	jsr	Obj1D_States(pc,d1.w)
    
    	jmp	MarkObjGone3
    
    ; ===========================================================================
    
    ; off_21170:
    
    Obj1D_States:
    
    	dc.w Obj1D_Init - Obj1D_States&#59; 0
    
    	dc.w Obj1D_MainX - Obj1D_States&#59; 2
    
    	dc.w Obj1D_MainY - Obj1D_States&#59; 4
    
    ; ===========================================================================
    
    ; loc_21176:
    
    Obj1D_Init:
    
    	addq.b	#2,$24(a0)&#59; => Obj1D_MainX
    
    	move.l	#Map_Obj1D,4(a0)
    
    	move.w	#$6BC,2(a0)
    
    	ori.b	#4,1(a0)
    
    	move.b	#$10,$19(a0)
    
    	move.b	#5,$18(a0)
    
    	move.b	$28(a0),d0
    
    	btst	#2,d0
    
    	beq.s	Obj1D_Init_CheckX
    
    	addq.b	#2,$24(a0)&#59; => Obj1D_MainY
    
    	andi.w	#7,d0
    
    	move.b	d0,$1A(a0)
    
    	andi.w	#3,d0
    
    	add.w	d0,d0
    
    	move.w	word_211E8(pc,d0.w),$32(a0)
    
    	move.w	$C(a0),d1
    
    	lea	($FFFFB000).w,a1&#59; a1=character
    
    	cmp.w	$C(a1),d1
    
    	bcc.s	@Tubes
    
    	move.b	#1,$34(a0)
    
    @Tubes
    
    	lea	($FFFFB040).w,a1&#59; a1=character
    
    	cmp.w	$C(a1),d1
    
    	bcc.s	@Tubes2
    
    	move.b	#1,$35(a0)
    
    @Tubes2
    
    	bra.w	Obj1D_MainY
    
    ; ===========================================================================
    
    word_211E8:
    
    	dc.w   $20
    
    	dc.w   $40&#59; 1
    
    	dc.w   $80&#59; 2
    
    	dc.w  $100&#59; 3
    
    ; ===========================================================================
    
    ; loc_211F0:
    
    Obj1D_Init_CheckX:
    
    	andi.w	#3,d0
    
    	move.b	d0,$1A(a0)
    
    	add.w	d0,d0
    
    	move.w	word_211E8(pc,d0.w),$32(a0)
    
    	move.w	8(a0),d1
    
    	lea	($FFFFB000).w,a1&#59; a1=character
    
    	cmp.w	8(a1),d1
    
    	bcc.s	@Tubes3
    
    	move.b	#1,$34(a0)
    
    @Tubes3
    
    	lea	($FFFFB040).w,a1&#59; a1=character
    
    	cmp.w	8(a1),d1
    
    	bcc.s	Obj1D_MainX
    
    	move.b	#1,$35(a0)
    
    
    
    ; loc_21224:
    
    Obj1D_MainX:
    
    
    
    	tst.w	($FFFFFE08).w
    
    	bne.s	return_21284
    
    	move.w	8(a0),d1
    
    	lea	$34(a0),a2&#59; a2=object
    
    	lea	($FFFFB000).w,a1&#59; a1=character
    
    	bsr.s	@Tubes4
    
    	lea	($FFFFB040).w,a1&#59; a1=character
    
    	cmpi.w	#4,($FFFFF708).w&#59; TailsCPU_Flying
    
    	beq.s	return_21284
    
    
    
    @Tubes4	tst.b	(a2)+
    
    	bne.s	Obj1D_MainX_Alt
    
    	cmp.w	8(a1),d1
    
    	bhi.s	return_21284
    
    	move.b	#1,-1(a2)
    
    	move.w	$C(a0),d2
    
    	move.w	d2,d3
    
    	move.w	$32(a0),d4
    
    	sub.w	d4,d2
    
    	add.w	d4,d3
    
    	move.w	$C(a1),d4
    
    	cmp.w	d2,d4
    
    	bcs.s	return_21284
    
    	cmp.w	d3,d4
    
    	bcc.s	return_21284
    
    	btst	#0,1(a0)
    
    	bne.s	@Tubes5
    
    	move.b	#1,$39(a1)&#59; enable must-roll "pinball mode"
    
    	bra.s	loc_212C4
    
    ; ---------------------------------------------------------------------------
    
    @Tubes5:	move.b	#0,$39(a1)&#59; disable pinball mode
    
    
    
    return_21284:
    
    	rts
    
    ; ===========================================================================
    
    ; loc_21286:
    
    Obj1D_MainX_Alt:
    
    	cmp.w	8(a1),d1
    
    	bls.s	return_21284
    
    	move.b	#0,-1(a2)
    
    	move.w	$C(a0),d2
    
    	move.w	d2,d3
    
    	move.w	$32(a0),d4
    
    	sub.w	d4,d2
    
    	add.w	d4,d3
    
    	move.w	$C(a1),d4
    
    	cmp.w	d2,d4
    
    	bcs.s	return_21284
    
    	cmp.w	d3,d4
    
    	bcc.s	return_21284
    
    	btst	#0,1(a0)
    
    	beq.s	loc_212BC
    
    	move.b	#1,$39(a1)
    
    	bra.s	loc_212C4
    
    ; ===========================================================================
    
    
    
    loc_212BC:
    
    	move.b	#0,$39(a1)
    
    	rts
    
    ; ===========================================================================
    
    
    
    loc_212C4:
    
    	btst	#2,$22(a1)
    
    	beq.s	@Tubes6
    
    	rts
    
    ; ---------------------------------------------------------------------------
    
    @Tubes6:	bset	#2,$22(a1)
    
    	move.b	#$E,$16(a1)
    
    	move.b	#7,$17(a1)
    
    	move.b	#2,$1C(a1)
    
    	addq.w	#5,$C(a1)
    
    	move.w	#$BE,d0
    
    	jsr	(PlaySound).l
    
    	rts
    
    
    
    ; ===========================================================================
    
    ; loc_212F6:
    
    Obj1D_MainY:
    
    
    
    	tst.w	($FFFFFE08).w
    
    	bne.s	return_21350
    
    	move.w	$C(a0),d1
    
    	lea	$34(a0),a2&#59; a2=object
    
    	lea	($FFFFB000).w,a1&#59; a1=character
    
    	bsr.s	@Tubes7
    
    	lea	($FFFFB040).w,a1&#59; a1=character
    
    @Tubes7
    
    	tst.b	(a2)+
    
    	bne.s	Obj1D_MainY_Alt
    
    	cmp.w	$C(a1),d1
    
    	bhi.s	return_21350
    
    	move.b	#1,-1(a2)
    
    	move.w	8(a0),d2
    
    	move.w	d2,d3
    
    	move.w	$32(a0),d4
    
    	sub.w	d4,d2
    
    	add.w	d4,d3
    
    	move.w	8(a1),d4
    
    	cmp.w	d2,d4
    
    	bcs.s	return_21350
    
    	cmp.w	d3,d4
    
    	bcc.s	return_21350
    
    	btst	#0,1(a0)
    
    	bne.s	@Tubes8
    
    	move.b	#1,$39(a1)
    
    	bra.w	loc_212C4
    
    ; ---------------------------------------------------------------------------
    
    @Tubes8:	move.b	#0,$39(a1)
    
    
    
    return_21350:
    
    	rts
    
    ; ===========================================================================
    
    ; loc_21352:
    
    Obj1D_MainY_Alt:
    
    	cmp.w	$C(a1),d1
    
    	bls.s	return_21350
    
    	move.b	#0,-1(a2)
    
    	move.w	8(a0),d2
    
    	move.w	d2,d3
    
    	move.w	$32(a0),d4
    
    	sub.w	d4,d2
    
    	add.w	d4,d3
    
    	move.w	8(a1),d4
    
    	cmp.w	d2,d4
    
    	bcs.s	return_21350
    
    	cmp.w	d3,d4
    
    	bcc.s	return_21350
    
    	btst	#0,1(a0)
    
    	beq.s	@Tubes9
    
    	move.b	#1,$39(a1)
    
    	bra.w	loc_212C4
    
    ; ---------------------------------------------------------------------------
    
    @Tubes9:	move.b	#0,$39(a1)
    
    	rts
    
    ;Map_Obj1D:
    
    ;		rts
    
    MarkObjGone3:
    
    	tst.w	($FFFFFFD8).w
    
    	beq.s	MOG3_loc1
    
    	rts
    
    MOG3_loc1:
    
    	move.w	8(a0),d0
    
    	andi.w	#$FF80,d0
    
    	sub.w	($FFFFF7DA).w,d0
    
    	cmpi.w	#$280,d0
    
    	bhi.w	MOG3_loc2
    
    	rts
    
    MOG3_loc2:
    
    	lea	($FFFFFC00).w,a2
    
    	moveq	#0,d0
    
    	move.b	$23(a0),d0
    
    	beq.s	MOG3_loc3
    
    	bclr	#7,2(a2,d0.w)
    
    MOG3_loc3:
    
    	bra.w	DeleteObject
    
    ; ===========================================================================
    
    ; ---------------------------------------------------------------------------
    
    ; Sprite mappings - object 1D
    
    ; ---------------------------------------------------------------------------
    
    Map_obj1D:
    
    	include "_maps\obj1D.asm"

    I hope somebody can push me into the right direction. If somebody manages to make this work, I'll really appreciate it. Thanks from advance!


    - Deoxys Kyogre
     
  2. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    First of all S1 does this tile based. Second of all, all that the object does is set sonic's status forcefully and set the animation. The rest is relatively simple. Why you'd want to port an object that already exists is beyond me, but I hope I gave you pointers.
     
Thread Status:
Not open for further replies.