Yay thanx, got it running (only correction is the flag branch at the start though that's a fault on my behalf). Also used it to work out a high jump code. By the way how do these flags work in Sonic 2 (#7,status(a0)), they're different to the coding for them in Sonic 1. Is there a way to work out a separate new flag (I tried #8,status(a0) and it didn't work so I'm guessing it's more complex than that)?
Well basically status(a0) refers to a byte in Sonic's SST, and each bit in that byte is used for a flag. There are 8 bits in a single byte and they're numbered from 0 (least significant) to 7 (most significant), so that's why #8,status(a0) won't work. However, if you need to store more flags you can use another byte in the SST which isn't used for any other purpose. One such byte is $20, so you have space for 8 flags in there (#0,$20(a0) to #7,$20(a0)).
Hmm, when I try the $20 flag it just screws up the two moves that formerly used that flag, both seem to work fine using the same status flag. Two more queries (sorry for asking so many, these are the last two obstacles and I think I can upload an early build of my project): * Does anyone know which part of the coding to alter for the breakable objects (Obj2F, 32 and 3D I believe) in the game so as another animation or flag can break them. I looked at these codes but they are unlabelled and I have no idea where the branch or coding for spin attacks to break them is. * My dissassembly doesn't seem to have the mapping file ObjCE meaning I can't edit the mappings for the ending animation. Is this the same with all versions of the Sonic 2 dissassembly, if so is there any way to get around it.
I didn't understand what really happens, the game checks for animations and if Sonic touched the top of the object. Take a look at this (this is for Obj2F, but the other two work like this as well): Code (ASM): loc_23368: move.w (Chain_Bonus_counter).w,objoff_38(a0) -> move.b (MainCharacter+anim).w,objoff_32(a0) -> move.b (Sidekick+anim).w,objoff_33(a0) moveq #0,d1 move.b width_pixels(a0),d1 addi.w #$B,d1 moveq #0,d2 move.b y_radius(a0),d2 move.w d2,d3 addq.w #1,d3 move.w x_pos(a0),d4 bsr.w JmpTo3_SolidObject move.b status(a0),d0 andi.b #$18,d0 bne.s loc_233A4 BranchTo_JmpTo9_MarkObjGone bra.w JmpTo9_MarkObjGone ; =========================================================================== loc_233A4: cmpi.b #$18,d0 bne.s loc_23408 -> cmpi.b #2,objoff_32(a0) -> bne.s loc_233C0 The lines are responsible for the animation check. I'm guesing you want Amy to be able to destroy the things with her hammer. If that's so, you will need to change the last line before the label BranchTo_JmpTo9_MarkObjGone (the bne.s line) to a branch and also comment out the first two lines of loc_233A4. Below that, you finally got your animation check, replace that with whatever number you have. However, now the player can destroy the block anywhere on the screen, so you should do a distance check somewhere (If I remember correctly, I already told you how to do that on Sonic 1, so I won't repeat myself, unless you don't understand it of course). Object CE is using the same mapping file as Object CF, meaning the file is called objCF.bin.
Well there are some elements that don't translate, the player's X and Y axis flags that subtract from the position of the object for example. Also what kind of branch do you mean for the bne.s line, to what part? Tried CF as well, just gives garbage sprites on SonMapEd (I think I can make out the mappings of the sprites I need but the tiles don't map properly on them).
This is because SonMapEd doesn't handle the backward references in the mappings file (like the 1/2/3 mappings). And of course, since they reference mappings outside of the file, it has no idea where they are (in fact, it probably ignores negative offsets altogether, or treats them like unsigned offsets and sees they're past the end of the file, and gives up). A solution would be to copy the missing mappings from the mappings file in which they are defined (obj34, IIRC), but I think there are a few more mappings with positive offsets after those with negative offsets, and SonMapEd stops reading the mappings as soon as it encounters one with a negative offset, so it'd be easier to do with an hex editor or ASM.
@ Psi: Code (ASM): [asm]loc_23368: move.w (Chain_Bonus_counter).w,objoff_38(a0) move.b (MainCharacter+anim).w,objoff_32(a0) ; get Sonic's Animation here move.b (Sidekick+anim).w,objoff_33(a0) ; get Tails' Animation here moveq #0,d1 move.b width_pixels(a0),d1 addi.w #$B,d1 moveq #0,d2 move.b y_radius(a0),d2 move.w d2,d3 addq.w #1,d3 move.w x_pos(a0),d4 bsr.w JmpTo3_SolidObject move.b status(a0),d0 andi.b #$18,d0 bra.s loc_233A4 ; changed from bne.s BranchTo_JmpTo9_MarkObjGone bra.w JmpTo9_MarkObjGone ; =========================================================================== loc_233A4: ;cmpi.b #$18,d0 ;bne.s loc_23408 cmpi.b #2,objoff_32(a0) ; put in your animation ID here bne.s loc_233C0 This is what I meant, hopefully you understand it now. As for the the mappings thing, I'm lost here, sorry. =(
Okay I tried modifying the code as so: Code (ASM): [asm] bra.s loc_233A4 BranchTo_JmpTo9_MarkObjGone bra.w JmpTo9_MarkObjGone ; =========================================================================== loc_233A4: ; cmpi.b #$18,d0 ; bne.s loc_23408 cmpi.b #$23,anim(a0) beq.w Break_Obj2F cmpi.b #2,objoff_32(a0) bne.s loc_233C0 Break_Obj2F: cmpi.b #$23,anim(a0) beq.s Obj2F_NoHammerAttack; if not, branch moveq #0,d0 ; clear d0 move.w $8(a0),d0 ; load springs's X-pos to d0 sub.w x_pos(a0),d0; substract Amy's X-pos from it bpl.s Obj2F_XPositive ; if answer is positive, branch neg.w d0 ; otherwise negate d0 Obj2F_XPositive: cmpi.w #35,d0 ; is Amy within 35 pixels of the spring (X-axis)? bge.s Obj2F_NoHammerAttack; if not, branch moveq #0,d0 ; clear d0 move.w $C(a0),d0 ; load springs's Y-pos to d0 sub.w y_pos(a0),d0; substract Amy's Y-pos from it bpl.s Obj2F_YPositive ; if answer is positive, branch neg.w d0 ; otherwise negate d0 Obj2F_YPositive: cmpi.w #35,d0 ; is Amy within 35 pixels of the spring (Y-axis)? bge.s Obj2F_NoHammerAttack; if not, branch bra.s Hit_Obj2F ; otherwise make spring bouncing Obj2F_NoHammerAttack: rts ; return Spin_Obj2F: cmpi.b #2,objoff_32(a0) bne.s loc_233C0 Hit_Obj2F: tst.b subtype(a0) bmi.s loc_233F0 cmpi.b #$E,(MainCharacter+layer).w beq.s loc_233F0 loc_233C0: move.b #$C,(MainCharacter+layer).w move.b #$D,(MainCharacter+layer_plus).w cmpi.b #2,objoff_33(a0) bne.s loc_233E2 tst.b subtype(a0) bmi.s loc_233F0 cmpi.b #$E,(Sidekick+layer).w beq.s loc_233F0 loc_233E2: move.b #$C,(Sidekick+layer).w move.b #$D,(Sidekick+layer_plus).w bra.w BranchTo_JmpTo9_MarkObjGone [/CODE] I also had to edit the branch below due to the jump distance being to long. However when I try it, the objects break automatically before they are even onscreen (except in the case of the hill top loop blockades, which just screw up the loop collision). Ignore the spring comments, the code is copied from another part of the asm and merely notes where the player collides with the object.
You loaded the anim from (a0) where it should be (a1). But you don't need to do that, you just can edit the check of objoff_32 (it loads sonic's/tails' animation there) Code (ASM): cmpi.b #$23,objoff_32(a0) bne.s loc_233C0
While it gets obj32 (rocks) to break upon that animation it still has no distance value (eg. hammer on the other side of the screen and it still breaks). And I tried it for obj2f and it's still screws up the loop collision and the blockade won't break.
That's because you checked for the distance using the object's position, not Sonic's (or Amy's in this case). Instead of $8(a0), you should use (MainCharacter+$8).w. To avoid an endless conversation, I just put the code in here for you: Code (ASM): loc_233A4: cmpi.b #$23,objoff_32(a0) bne.s loc_233C0 move.w $8(a0),d0 ; load block's X-pos to d0 sub.w (MainCharacter+$8).w,d0 ; substract Amy's X-pos from it bpl.s Obj2F_XPositive ; if answer is positive, branch neg.w d0 ; otherwise negate d0 Obj2F_XPositive: cmpi.w #35,d0 ; is Amy within 35 pixels of the spring (X-axis)? bge.s Obj2F_NoHammerAttack ; if not, branch move.w $C(a0),d0 ; load springs's Y-pos to d0 sub.w (MainCharacter+$8).w,d0 ; substract Amy's Y-pos from it bpl.s Obj2F_YPositive ; if answer is positive, branch neg.w d0 ; otherwise negate d0 Obj2F_YPositive: cmpi.w #35,d0 ; is Amy within 35 pixels of the spring (Y-axis)? bge.s Obj2F_NoHammerAttack ; if not, branch bra.s Hit_Obj2F ; otherwise make spring bouncing Obj2F_NoHammerAttack: rts ; return Hit_Obj2F: Since I don't have the source, I'm not sure if it works though.
Right so. Got a question I'd like answered. Shouldn't be too hard. For whatever particularly dumb reason I have, I want to allow the extra life music to not kill the PSG. You know, so I can actually have PSG notes in my 1up sound or so that I can hear sonic's jump noise during the 1up track. I had a look at the code myself, but I can't quite wrap my head around it (I'm not entirely sure, but I think it has to do with the area around "Sound_81to9F:" PS, I'm using the SVN disassem
So yeah, got two questions myself: 1: It was pretty easy to increase the number of characters per line in a the Level Select (I changed it from $17 to $1B). However, now the position of the text is messed up of course. There is this line: Code (ASM): move.l #$62100003,d4 ; screen position (text) But what do I need to edit move it 2 tiles to the left? EDIT: $620C0003, thanks to MarkeyJester on IRC. 2: Simalar to my last question, I was wondering if something like this is possible: Code (ASM): move.b #2,($FFFFFF9F).w ; set $FF9F to 2 ... move.b ($FFFFFF9F).w,d0 ; get current number of $FF9F lea ((Some_Text)+d0).l,a1 ; this should become Some_Text2 Thing is, I have multiple textes to be loaded like this, and I was wondering if there's something like this possible to save me time.
I have a small question, because I am very confused. My Sonic 1 hack, somehow has SRAM, when I didn't even enable SRAM in the disassembly, let alone I didn't set an address for the SRAM to be enabled. I did add a few files to change the title screen, and I added the code to fix the Sega sound. What I am confused is, how the heck did that happen? (It doesn't work at all, but Fusion saved a SRM file and "loads" it when I play my hack...) Could it be the files I added to edit the title screen?
If emulators detect any write to $200000-$20FFFF, they assume the game has SRAM. This is because some games don't label SRAM usage properly in the header so they just go by that assumption. Make sure you aren't writing to that area, basically. Also, get rid of the SRM file or Fusion will insist in that the game has SRAM.
Still doesn't work, I've tried switching the code all over the place and also tried adding a reset d0 command, but still no success. And cancelling out those first two lines in the original Obj2F code is what causes the Hill Top loops to screw up (though they revert to normal once you break the blockade). I can get the animation to activate breaking the objects, but it doesn't recognise the distance limit for them and thus you can break them from opposite ends of the screen (or even offscreen).
It's not possible to simply concatenate labels like that, but you can use an offset table. E.g. have something like: Code (ASM): Text_Table: dc.l Some_Text_0 dc.l Some_Text_1 dc.l Some_Text_2 ... and then to use it in your code do Code (ASM): moveq #0,d0 move.b ($FFFFFF9F).w,d0 add.w d0,d0 add.w d0,d0 ; multiply by 4 movea.l Text_Table(pc,d0.w),a1 ; a1 now contains the address of the appropriate text This is assuming that you keep this code very close to Text_Table. If it's a bit further away change the last line to: Code (ASM): lea Text_Table(pc),a1 movea.l (a1,d0.w),a1 Another thing to note is that it's a better idea to pre-scale your index before putting it in $FFFFFF9F, I.e. instead of setting it to 0, 1, 2, 3 etc. you set it to 0, 4, 8, $C etc. That way you avoid having to manually multiply it (you can get rid of the two add.w d0,d0 lines), and it's for a similar reason that object routines are always in increments of two and game modes are always in increments of 4.
I can't bee 100% sure but at some point in the past, I swear someone released a collection of Samples/instruments/voices used in the sonic games/genesis, for use in a tracker program (Open MPT). If such a collection has been released, can someone be kind enough to point me to them? I've tried the search feature and the info section, hell even Google, with no luck
@Psi: I don't want pages of conversation. Go to IRC (you know which channel), we try to figure it out there. Probably this one: http://sonicresearch.org/smps.
That's for importing the songs themselves. I believe he's looking for The Ultimate Mega Drive Soundfont.