SMI = Set if minus SNE = Set if Not Equal These instructions set the contents of a register to all 1s if the condition is met. Also works with practically any condition branches support too (for always setting, use ST, which is Set if True). PEA = Push Effective Address I don't remember exactly how it worked but it's something used by compilers so you don't want to mess with it...
PEA just pushes an effective address onto the stack. And a couple of other things to note about the Scc instructions is that they're always byte-sized, and they set the target address to false (all 0s) in case the condition isn't met (and set it to true (all 1s) if it is met, as Sik said above).
So it works basically like this? Code (ASM): moveq #5,d0 ; set d0 to $5 cmpi.b #6,d0 ; is d0 $6? sne d0 ; if not, set d0 to $0 cmpi.b #0,d0 ; is d0 $0? seq d0 ; if yes, set d0 to $1 (Ignore the stupidity in this code, it's just so I can understand it better.)
It sets d0 to $FF, not 1 (by all 1s I was referring to the individual bits). Basically, to give another example: Code (ASM): cmp.b #3,d5 ; is d5 3? seq d1 ; if it is, the lowest byte of d1 becomes $FF, otherwise it becomes $0 cmp.w #10,($FFFFFE20).w scc d2 ; ; if Sonic has >= 10 rings the lowest byte of d2 becomes $FF, otherwise it becomes 0 st ($FFFFFFB0).w ; always set a random address, same as move.b #$FF,($FFFFFFB0).w sf ($FFFFFFB1).w ; always clear a random address, same as clr.b ($FFFFFFB1).w
Ah got it (I wasn't sure about that 1s being bytes or bits). Just one last question: Is there any technical difference when using those commands, like it's faster, takes less space, etc?
There's no speed difference as long as the operand isn't a data register, but st X takes up two bytes less than move.b #$FF,X. sf X and clr.b X take up the same amount of space, which is two bytes less than move.b #0,X.
So, I'm porting Knuckles into a clean S2 Rom as an extra character, and I'm having a few troubles along the way: First of all, If I am standing on an object (such as a bridge) and I jump, and land on it, I sink 4 pixels into the floor. Second is gliding into a spring—the glide continues instead of getting canceled out as they're supposed to. Lastly, If I glide and then land on an object, instead of landing into a walk like in S2K/S3K, the falling stays for a bit, and then I am standing on the object. These are all flags not getting cleared I believe, but I cannot for the life in me find anything to fix these. Can anyone help? Thanks in advance Anything to do with loc_3F976? I'm at a loss
I doubt that, but I can tell you, the flag when the player is on an object, but shouldn't fall (when he's standing on something like a bridge) is bit 3 in $22(aX). The absolute RAM address to player one is $FFFFB022. I would try to find the correct locations and use one of these 2 lines: Code (ASM): bset #3,($FFFFB022).w ; set standing on object flag bclr #3,($FFFFB022).w ; clear standing on object flag
Sonic's object doesn't set the on object flag, except in a few areas. For anyone who's ported knuckles—Shobiz, Rika, SOTI, how did you get around this?
I've never ported Knuckles actually, but the spring problem should just be a matter of locating the part inside the spring's code which sets the player's flags and adding a clr.b $21(a1) and clr.b $1F(a1) there as well (assuming it keeps the player object in a1). No idea about the other problems though.
Anyone know where to edit the level... err, vector? In Sonic 1. I'm not sure what they would be called in ASM... But anyway, I want to change it so that the levels are two acts instead of three and I also want to add two extra zones. Where in the code can I do this? (There's probably multiple places where I have to chance it, though...)
You can edit the Level Order (misc\lvl_ord.bin). The format is a little hard to understand, but it goes basically like this (converted into ASM, but you should also get the point in a hex editor): Code (ASM): dc.w $0001, $0002 ; 1. GHZ 2 and 3 (1 is being loaded by default) dc.w $0200, $0000 ; 1. Go to MZ and play its first level dc.w $0101, $0102 ; 4. LZ 2 and 3 dc.w $0300, $0502 ; 4. Go to SLZ and play its first level (also, set up FZ, somehow...) dc.w $0201, $0202 ; 2. MZ 2 and 3 dc.w $0400, $0000 ; 2. Go to SYZ and play its first level dc.w $0301, $0302 ; 5. SLZ 2 and 3 dc.w $0500, $0000 ; 5. Go to SBZ and play its first level dc.w $0401, $0402 ; 3. SYZ 2 and 3 dc.w $0100, $0000 ; 3. Go to LZ and play its first level dc.w $0501, $0103 ; 6. SBZ 2 and LZ 4 (SBZ 3) dc.w $0000, $0000 ; 6. either null or play LZ, dunno... For the new zones, you can at least add one with this: http://info.sonicretro.org/SCHG_How-to:Add...zone_in_Sonic_1
Since asking #techies has been unhelpful, I'll have to ask here: Does anybody know where the the part of the Wing Fortress Zone cutscene that pushes the A button is? Right now he boosts off the platform and dies, so I need to change it to press the C button. fixed.
I didn't want to go public with this, but I have a problem. I asked MarkeyJester on this, but he couldn't find anything wrong with the code. We ruled out that it is a ram location problem (he suggested trying FFF7) That is a problem with my coding, I get the right idea of what to do and it seems plausible but doesn't work most of the time, thanks to some slight error that I overlooked. Fixing that slight error makes the cogs go, so to speak. I believe it is the same problem here.
May I ask again what you really wanted? You want a monitor, that gives the player an emerald when he finishes a level? You didn't want the emerald to be added just when the monitor got opened? You can do this: Code (ASM): Obj2E_ChkEggman: cmpi.b #1,d0 ; does monitor contain Eggman (or emerald in this case)? bne.s Obj2E_ChkSonic ; if not, branch move.b #$A4,d0 ; set sound $A4 by default tst.b ($FFFFFF90).w ; was flag already set? bne.s Obj2E_PlaySnd_Emerald ; if yes, branch addq.b #1,($FFFFFE57).w ; add one emerald move.b #$BF,d0 ; play sound $BF instead move.b #1,($FFFFFF90).w ; make sure this code doesn't get used again Obj2E_PlaySnd_Emerald: jmp PlaySound ; play whatever sound is in d0 Just clear $FFFFFF90 when the next level starts (Obj3A_NextLevel).
Sorry if this is a dumb question (I've only edited Sonic 1 before) is there coding in the Sonic 2 dissassembly to edit the animations similar to S1's anim folder?
There is, it's just not splitted into seperate files, but right in s2.asm. Sonic's animation script is for example at SonicAniData.
I did a hybrid of your code and mine and it works! Thank you. Code (Text): Obj2E_ChkEggman: ; XREF: Obj2E_Move addq.b #2,$24(a0) move.w #29,$1E(a0) move.b $1C(a0),d0 cmpi.b #1,d0; does monitor contain Eggman? bne.s Obj2E_ChkSonic cmpi.w #50,($FFFFFE20).w; do you have at least 50 rings? bcc.s Obj2E_Emerald; if yes, branch move.b #$A4,($FFFFF00A).w rts ; Eggman monitor does nothing Obj2E_Emerald: move.b #$A4,d0 ; set sound $A4 by default tst.b ($FFFFFF90).w; was flag already set? bne.s Obj2E_PlaySnd_Emerald; if yes, branch addq.b #1,($FFFFFE57).w; add one emerald move.b #$BF,d0 ; play sound $BF instead move.b #1,($FFFFFF90).w; make sure this code doesn't get used again Obj2E_PlaySnd_Emerald: jmp PlaySound; play whatever sound is in d0 Code (Text): Obj3A_NextLevel: ; XREF: Obj3A_Index clr.b ($FFFFFF90).w; emerald clear move.b ($FFFFFE10).w,d0 andi.w #7,d0 lsl.w #3,d0 move.b ($FFFFFE11).w,d1 andi.w #3,d1 add.w d1,d1 add.w d1,d0 move.w LevelOrder(pc,d0.w),d0; load level from level order array move.w d0,($FFFFFE10).w; set level number tst.w d0 bne.s Obj3A_ChkSS move.b #0,($FFFFF600).w; set game mode to level (00) ;fish bra.s Obj3A_Display2
Ehh... thanks for trying to help, but this is too much of a hassle for me after all. I think I'll just stick to creating engines from scratch, ones that I can read. :/