In the past I shortly attacked the SOZ2 Ghost related code in Sonic And Knuckles before taking a break. Want to take another crack at it. Most of the Ghost related code in Sandopolis Zone 2 is at bottom ( source from https://raw.githubusercontent.com/sonicretro/skdisasm/master/sonic3k.asm ) First a note: Since this code is from Sonic And Knuckles, i'm assuming that it can work independent of S3k , correct me if I am wrong. I can examine this code from several sources, my question is which is the best given Pros and Cons listed below . And also assuming it can run independent as Sk. 1. ( MOST UPDATED ) https://github.com/sonicretro/skdisasm run buildSK.bat and build a Sonic and Knuckles rom. Then Run debugging in Gensr57shell examine / compare the the .lst file as I run in gens and breakpoints. . The plus is that the labels address Loc_XXXX are the same as the rom address 2. ( MOST UPDATED ) https://github.com/sonicretro/skdisasm run buildS3Complete.bat setting 0 or 1 as a S3k rom. Lab_xxxx wont match the rom address. As the rom address of this github matche the sonic and knuckles alone build. 3. https://info.sonicretro.org/images/c/ca/Sonic_&_Knuckles_(IDA_Format_by_Stealth).rar Use the older Stealth IDA in IDA PRO. The plus Is I can run IDA pro LAB313RU IDA TOOL https://github.com/lab313ru/smd_ida_tools2 to debug and run in ida with his gens mod emulator. The con is it is an older build. Labels have different names that may not agree with what newer builds describe locations as. And it isn't as labeled and commented. Also the address of instructions and data in this build dont match the standalone SK build exactly. in . https://github.com/sonicretro/skdisasm with buildSK.bat 4. Ask Clownacy if he has the latest IDA database of https://github.com/sonicretro/skdisasm would be optimum if the labels matched the rom address. The same benefits of 3 in that I could run in IDA debugger with Lab313RU IDA TOOL. A Lot of comes down to how updated it is with most comments , accurate and more labels. Not sure if having labels address match the address between the s3kcomplete and sk alone build of 1 and 2 matters. And if the Stealth build offsets of code and data not matching that of the sonic and knuckles standalone of the newest github build matter? Question - Too much preparing for this task of examine a bit of code? Code (Text): Obj_SOZGhosts: move.l #loc_8F0CA,(a0) move.w #$120,$10(a0) move.w #$A0,$14(a0) loc_8F0CA: cmpi.b #2,(Player_1+character_id).w beq.s loc_8F0DA tst.b (Last_star_post_hit).w beq.w locret_8F436 loc_8F0DA: moveq #0,d0 move.b (_unkF7C3).w,d0 beq.s loc_8F112 move.b byte_8F118(pc,d0.w),d0 move.b (_unkFAAD).w,d1 cmp.b d0,d1 bhs.w locret_8F436 subq.w #1,$3A(a0) bpl.w locret_8F436 addq.b #1,d1 move.b d1,(_unkFAAD).w cmp.b d0,d1 bhs.s loc_8F108 move.w #$3F,$3A(a0) loc_8F108: lea ChildObjDat_8F674(pc),a2 jmp (CreateChild6_Simple).l ; --------------------------------------------------------------------------- loc_8F112: clr.b (_unkFAAD).w rts ; --------------------------------------------------------------------------- byte_8F118: dc.b 0 dc.b 1 dc.b 2 dc.b 2 dc.b 3 dc.b 3 ; --------------------------------------------------------------------------- loc_8F11E: moveq #0,d0 move.b 5(a0),d0 move.w off_8F19A(pc,d0.w),d1 jsr off_8F19A(pc,d1.w) lea DPLCPtr_SOZGhosts(pc),a2 jsr (Perform_DPLC).l tst.b 4(a0) bpl.s loc_8F16A tst.b (_unkF7C3).w beq.s loc_8F174 jsr (Check_PlayerCollision).l beq.s loc_8F15E jsr (Check_PlayerAttack).l bne.s loc_8F174 tst.b $34(a1) bne.s loc_8F15E jsr (HurtCharacter_Directly).l loc_8F15E: jsr (Add_SpriteToCollisionResponseList).l jmp (Draw_Sprite).l ; --------------------------------------------------------------------------- loc_8F16A: subq.b #1,(_unkFAAD).w jmp (Go_Delete_SpriteSlotted2).l ; --------------------------------------------------------------------------- loc_8F174: move.l #loc_8F37A,(a0) move.l #loc_8F16A,$34(a0) lea byte_8F6BF(pc),a1 jsr (Set_Raw_Animation).l moveq #signextendB(sfx_Bouncy),d0 jsr (Play_SFX).l jmp (Draw_Sprite).l ; --------------------------------------------------------------------------- off_8F19A: dc.w loc_8F1AC-off_8F19A dc.w loc_8F1DA-off_8F19A dc.w loc_8F1FE-off_8F19A dc.w loc_8F226-off_8F19A dc.w loc_8F26E-off_8F19A dc.w loc_8F2BE-off_8F19A dc.w loc_8F2E0-off_8F19A dc.w loc_8F322-off_8F19A dc.w loc_8F36E-off_8F19A ; --------------------------------------------------------------------------- loc_8F1AC: lea ObjDat4_8F61C(pc),a1 jsr (SetUp_ObjAttributesSlotted).l bclr #2,4(a0) bset #7,4(a0) move.b (_unkF7C3).w,$42(a0) move.b (_unkFAAD).w,$43(a0) bsr.w sub_8F538 moveq #signextendB(sfx_GhostAppear),d0 jsr (Play_SFX).l loc_8F1DA: jsr (Animate_RawMultiDelay).l tst.w d2 beq.s locret_8F1F2 cmpi.b #5,(_unkF7C3).w beq.s loc_8F1F4 move.b #4,5(a0) locret_8F1F2: rts ; --------------------------------------------------------------------------- loc_8F1F4: move.b #$C,5(a0) bra.w loc_8F58E ; --------------------------------------------------------------------------- loc_8F1FE: jsr (Animate_RawMultiDelay).l jsr (Swing_UpAndDown).l jsr (MoveSprite2).l bsr.w sub_8F4F0 move.b (_unkF7C3).w,d0 cmp.b $42(a0),d0 beq.s locret_8F224 move.b #6,5(a0) locret_8F224: rts ; --------------------------------------------------------------------------- loc_8F226: jsr (Animate_RawMultiDelay).l jsr (Swing_UpAndDown).l tst.w d3 bne.s loc_8F240 jsr (MoveSprite2).l bra.w sub_8F4F0 ; --------------------------------------------------------------------------- loc_8F240: move.b #8,5(a0) moveq #0,d0 move.b (_unkF7C3).w,d0 move.b byte_8F268(pc,d0.w),d1 beq.w locret_8F436 move.b d0,$42(a0) cmpi.b #5,d0 beq.s loc_8F1F4 move.b #4,5(a0) bra.w loc_8F58E ; --------------------------------------------------------------------------- byte_8F268: dc.b 0 dc.b 0 dc.b 0 dc.b 1 dc.b 0 dc.b 1 ; --------------------------------------------------------------------------- loc_8F26E: jsr (Swing_UpAndDown).l jsr (MoveSprite2).l bsr.w sub_8F4F0 jsr (Animate_RawMultiDelay).l beq.s locret_8F2B0 cmpi.b #2,$23(a0) bne.s locret_8F2B0 move.b #$A,5(a0) move.b (_unkF7C3).w,d0 move.b d0,$42(a0) add.w d0,d0 andi.w #$C,d0 movea.l off_8F2B2(pc,d0.w),a1 move.b (a1),$22(a0) jsr (Set_Raw_Animation).l locret_8F2B0: rts ; --------------------------------------------------------------------------- off_8F2B2: dc.l byte_8F6CC dc.l byte_8F6CC dc.l byte_8F6D4 ; --------------------------------------------------------------------------- loc_8F2BE: jsr (Swing_UpAndDown).l jsr (MoveSprite2).l bsr.w sub_8F4F0 jsr (Animate_RawMultiDelay).l tst.w d2 beq.s locret_8F2DE move.b #4,5(a0) locret_8F2DE: rts ; --------------------------------------------------------------------------- loc_8F2E0: jsr (Animate_RawMultiDelay).l jsr (Swing_UpAndDown).l jsr (MoveSprite2).l move.w $10(a0),d0 tst.w $18(a0) bmi.s loc_8F304 cmpi.w #$1A0,d0 bhi.s loc_8F30A rts ; --------------------------------------------------------------------------- loc_8F304: cmpi.w #$A0,d0 bhs.s locret_8F320 loc_8F30A: move.b #$E,5(a0) bchg #0,4(a0) neg.w $18(a0) move.w #$3B,$2E(a0) locret_8F320: rts ; --------------------------------------------------------------------------- loc_8F322: jsr (Animate_RawMultiDelay).l subq.w #1,$2E(a0) bpl.w locret_8F436 move.b #$10,5(a0) move.b #-$29,$28(a0) bset #2,4(a0) move.w (Camera_X_pos).w,d0 move.w $10(a0),d1 subi.w #$80,d1 add.w d1,d0 move.w d0,$10(a0) move.w (Camera_Y_pos).w,d0 move.w $14(a0),d1 subi.w #$80,d1 add.w d1,d0 move.w d0,$14(a0) move.w #$100,$1A(a0) rts ; --------------------------------------------------------------------------- loc_8F36E: jsr (Animate_RawMultiDelay).l jmp (MoveSprite2).l ; --------------------------------------------------------------------------- loc_8F37A: jsr (Animate_RawMultiDelay).l lea DPLCPtr_SOZGhosts(pc),a2 jsr (Perform_DPLC).l jmp (Draw_Sprite).l ; --------------------------------------------------------------------------- Obj_SOZGhostCapsuleLoadArt: moveq #0,d0 move.b $2C(a0),d0 movea.l off_8F3BE(pc,d0.w),a1 jsr (Check_PlayerInRange).l tst.l d0 beq.w locret_8F436 tst.w d0 beq.w locret_8F436 moveq #0,d0 move.b $2C(a0),d0 movea.l off_8F3C6(pc,d0.w),a1 jsr (a1) jmp (Delete_Current_Sprite).l ; --------------------------------------------------------------------------- off_8F3BE: dc.l word_8F3CE dc.l word_8F3D6 off_8F3C6: dc.l loc_8F3DE dc.l loc_8F3F0 word_8F3CE: dc.w $FFF0, $20, $FFC0, $80 word_8F3D6: dc.w $FFF0, $20, $FF80, $100 ; --------------------------------------------------------------------------- loc_8F3DE: lea PLC_8F3E8(pc),a1 jmp (Load_PLC_Raw).l ; --------------------------------------------------------------------------- PLC_8F3E8: dc.w 0 dc.l ArtNem_EggCapsule dc.w $A6C0 ; --------------------------------------------------------------------------- loc_8F3F0: jmp (LoadEnemyArt).l ; --------------------------------------------------------------------------- Obj_SOZGhostCapsule: lea ObjDat3_8F62E(pc),a1 jsr (SetUp_ObjAttributes).l move.l #loc_89C14,(a0) move.b #3,$2C(a0) lea ChildObjDat_8F646(pc),a2 jsr (CreateChild1_Normal).l tst.b (Last_star_post_hit).w bne.s loc_8F424 cmpi.b #2,(Player_1+character_id).w bne.s locret_8F436 loc_8F424: move.l #loc_89C54,(a0) move.b #1,$22(a0) bset #5,$38(a0) locret_8F436: rts ; --------------------------------------------------------------------------- loc_8F438: lea (word_86B3E).l,a1 jsr (SetUp_ObjAttributes3).l move.l #loc_8672A,(a0) tst.b (Last_star_post_hit).w beq.s locret_8F45C move.l #loc_86754,(a0) move.b #$C,$22(a0) locret_8F45C: rts ; --------------------------------------------------------------------------- loc_8F45E: moveq #0,d0 move.b 5(a0),d0 move.w off_8F488(pc,d0.w),d1 jsr off_8F488(pc,d1.w) tst.b $2C(a0) bne.s loc_8F482 lea DPLCPtr_SOZGhosts(pc),a2 jsr (Perform_DPLC).l jmp (Sprite_CheckDeleteSlotted).l ; --------------------------------------------------------------------------- loc_8F482: jmp (Sprite_CheckDelete).l ; --------------------------------------------------------------------------- off_8F488: dc.w loc_8F48E-off_8F488 dc.w loc_8F4D8-off_8F488 dc.w loc_8F4E2-off_8F488 ; --------------------------------------------------------------------------- loc_8F48E: moveq #0,d0 move.b $2C(a0),d0 add.w d0,d0 lea word_8F4C0(pc,d0.w),a1 move.w (a1)+,$18(a0) move.w (a1)+,$40(a0) jsr (Change_FlipXWithVelocity).l tst.w d0 bne.s loc_8F4B6 lea ObjDat4_8F61C(pc),a1 jmp (SetUp_ObjAttributesSlotted).l ; --------------------------------------------------------------------------- loc_8F4B6: lea ObjDat3_8F63A(pc),a1 jmp (SetUp_ObjAttributes).l ; --------------------------------------------------------------------------- word_8F4C0: dc.w $FE00, $FFE0 dc.w $200, $FFE0 dc.w $FD80, $FFE8 dc.w $280, $FFE8 dc.w $FD00, $FFF0 dc.w $300, $FFF0 ; --------------------------------------------------------------------------- loc_8F4D8: lea byte_8F68E(pc),a1 jsr (Animate_RawNoSST).l loc_8F4E2: move.w $40(a0),d0 add.w d0,$1A(a0) jmp (MoveSprite2).l ; =============== S U B R O U T I N E ======================================= sub_8F4F0: move.w $10(a0),d0 tst.w $18(a0) bmi.s loc_8F502 cmpi.w #$1A0,d0 bhi.s loc_8F508 rts ; --------------------------------------------------------------------------- loc_8F502: cmpi.w #$A0,d0 bhs.s locret_8F512 loc_8F508: bchg #0,4(a0) neg.w $18(a0) locret_8F512: rts ; End of function sub_8F4F0 ; --------------------------------------------------------------------------- loc_8F514: move.b #1,(Last_star_post_hit).w lea (SOZ2_Start).l,a1 move.w (a1)+,(Saved_X_pos).w move.w (a1)+,(Saved_Y_pos).w jsr (Save_Level_Data).l lea ChildObjDat_8F64E(pc),a2 jmp (CreateChild1_Normal).l ; =============== S U B R O U T I N E ======================================= sub_8F538: jsr (Random_Number).l andi.w #$FF,d0 subi.w #$7F,d0 add.w d0,$10(a0) moveq #0,d1 move.b (_unkF7C3).w,d1 add.w d1,d1 move.w word_8F582(pc,d1.w),d2 cmpi.w #$120,d0 bhs.s loc_8F564 bset #0,4(a0) neg.w d2 loc_8F564: move.w d2,$18(a0) andi.w #$C,d1 move.l off_8F576(pc,d1.w),$30(a0) bra.w loc_8F58E ; --------------------------------------------------------------------------- off_8F576: dc.l byte_8F682 dc.l byte_8F695 dc.l byte_8F6AA word_8F582: dc.w $FF00 dc.w $FF00 dc.w $FF00 dc.w $FE80 dc.w $FE80 dc.w $FE00 ; --------------------------------------------------------------------------- loc_8F58E: moveq #0,d0 move.b (_unkF7C3).w,d0 add.w d0,d0 move.w word_8F582(pc,d0.w),d1 tst.w $18(a0) bmi.s loc_8F5A2 neg.w d1 loc_8F5A2: move.w d1,$18(a0) add.w d0,d0 movea.l off_8F5C8(pc,d0.w),a1 bclr #0,$38(a0) jsr (a1) tst.w $1A(a0) bpl.s loc_8F5C2 bset #0,$38(a0) neg.w d0 loc_8F5C2: move.w d0,$1A(a0) rts ; End of function sub_8F538 ; --------------------------------------------------------------------------- off_8F5C8: dc.l loc_8F5E0 dc.l loc_8F5E0 dc.l loc_8F5E0 dc.l loc_8F5F0 dc.l loc_8F5F0 dc.l loc_8F606 ; --------------------------------------------------------------------------- loc_8F5E0: move.w #$40,d0 move.w d0,$3E(a0) move.w #4,$40(a0) rts ; --------------------------------------------------------------------------- loc_8F5F0: move.w #$80,d0 move.w d0,$3E(a0) move.w #8,$40(a0) bclr #0,$38(a0) rts ; --------------------------------------------------------------------------- loc_8F606: move.w #$C0,d0 move.w d0,$3E(a0) move.w #$10,$40(a0) bclr #0,$38(a0) rts ; --------------------------------------------------------------------------- ObjDat4_8F61C: dc.w 2 dc.w $A500 dc.w $12 dc.w 0 dc.l Map_SOZGhosts dc.w 0 dc.b $10 dc.b $14 dc.b 0 dc.b 0 ObjDat3_8F62E: dc.l Map_EggCapsule dc.w $8536 dc.w $180 dc.b $30 dc.b $20 dc.b 0 dc.b 0 ObjDat3_8F63A: dc.l Map_SOZGhosts dc.w $A500 dc.w $200 dc.b $30 dc.b $20 dc.b 0 dc.b 0 ChildObjDat_8F646: dc.w 0 dc.l loc_8F438 dc.w $DC ChildObjDat_8F64E: dc.w 5 dc.l loc_8F45E dc.w $F8FC dc.l loc_8F45E dc.w $8FC dc.l loc_8F45E dc.w $10FC dc.l loc_8F45E dc.w $F0FC dc.l loc_8F45E dc.w $18FC dc.l loc_8F45E dc.w $E8FC ChildObjDat_8F674: dc.w 0 dc.l loc_8F11E DPLCPtr_SOZGhosts: dc.l ArtUnc_SOZGhosts dc.l DPLC_SOZGhosts byte_8F682: dc.b $11, 3 dc.b $11, 3 dc.b $10, 3 dc.b $F, 4 dc.b $E, 4 dc.b $F8, $C byte_8F68E: dc.b 0 dc.b 3 dc.b 1 dc.b 3 dc.b 2 dc.b 4 dc.b $FC byte_8F695: dc.b $11, 3 dc.b $11, 3 dc.b $10, 3 dc.b $F, 4 dc.b $E, 4 dc.b $D, 4 dc.b $F8, $E dc.b 5, 3 dc.b 6, 3 dc.b 7, 4 dc.b $FC byte_8F6AA: dc.b $11, 3 dc.b $11, 3 dc.b $10, 3 dc.b $F, 4 dc.b $E, 4 dc.b $D, 4 dc.b $F8, $E dc.b $A, 3 dc.b $B, 3 dc.b $C, 4 dc.b $FC byte_8F6BF: dc.b $D, 4 dc.b $D, 4 dc.b $E, 4 dc.b $F, 4 dc.b $10, 3 dc.b $11, 3 dc.b $F4 byte_8F6CC: dc.b 3, 7 dc.b 3, 7 dc.b 4, 7 dc.b $F8, $D7 byte_8F6D4: dc.b 8, 7 dc.b 8, 7 dc.b 9, 7 dc.b $F8, $E4 DPLC_SOZGhosts: include "General/Sprites/SOZ Ghosts/DPLC - SOZ Ghosts.asm" ; ---------------------------------------------------------------------------