Basic Questions and Answers Thread

Discussion in 'Discussion & Q&A' started by Malevolence, Jul 7, 2009.

  1. RandomAvatarFan

    RandomAvatarFan Well-Known Member Member

    Joined:
    Apr 10, 2009
    Messages:
    100
    Well, thank you both for your help and explanations so far, but I'm feeling like if it's getting a bit more than a "Basic Question" and turning into a: "Solve my problem for me." I'll keep tinkering a bit more, but when my imagination fails me I'll be back.
     
  2. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    I encountered a strange problem. This is S1 stuff.

    Earlier, I noticed the random number routine would always generate numbers ending by A in d1 (d0 is the one to use to get a properly random number). So I decided to modify the routine a little to get numbers that don't always end in A.

    This way:


    move.l d1,d0
    asl.l #2,d1
    add.l d0,d1
    swap d1 ; added this
    asl.l #3,d1
    add.l d0,d1
    ; move.w d1,d0 ; removed these
    ; swap d1
    ; add.w d1,d0
    ; move.w d0,d1
    swap d1
    move.l d1,($FFFFF636).w
    rts

    After doing that, I launched my hack in regen, and when I tried opening my cheat screen, the game showed me a "zero divide" error. And I can't understand why.

    The cheat screen loads and works fine as long as I don't modify the randomnumber routine. There's no division in its code and it's game mode $20.

    Here's where it really gets weirder though: even if I just add two "nop" (didn't try with 1, but I guess the result would be similar) at the beginning of the unmodified RandomNumber routine, the error is shown again! This time it's an address error though.

    In other words, every time I change the length of the RandomNumber routine, my cheat screen crashes on launch even though it has absolutely nothing to do with that routine.

    Any idea or explanation is welcome.
     
  3. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,772
    Location:
    italy
    My first suggestion would be to implement Flamewing's error screen, so you can see the code which triggers the error.
     
  4. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    I'm using S1, an old disassembly & asm68k, so from what I read in his topic, I won't be able to use it for at least 3 reasons. ^^'
     
  5. MarkeyJester

    MarkeyJester ! % # @ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,788
    In the original game, although the changed pseudo random number is saved into d1, and then saved back into the RAM space. It is in fact d0 which Sonic Team use after calling the routine in most cases.

    Regardless though...

    You say, cheat menu and $20 game mode. I get the feeling you have Sonic 2's level select menu in there. I could be wrong, but it seems predictable as many run through that same direction.

    If you don't have a decent error display screen, then I suggest using the following instructions:

    move #$2700,sr
    move.l #$C0400000,($C00004).l
    move.w #$0EEE,($C00000).l
    bra.s *Now, the idea is, in your game mode $20. You place this somewhere in the routine, assemble, and run. For example:
    Code:
    		...
    		jsr	BuildSprites
    		moveq	#0,d0
    		bsr.w	LoadPLC2
    		move.w	#0,($FFFFFFE4).w
    		move.w	#0,($FFFFFFE6).w
    
    	move	#$2700,sr
    	move.l	#$C0400000,($C00004).l
    	move.w	#$0EEE,($C00000).l
    	bra.s	*				; Trap
    
    		move.w	($FFFFF60C).w,d0
    		ori.b	#$40,d0
    		move.w	d0,($C00004).l
    		bsr.w	Pal_FadeTo
    		...
    If the game freezes with a red boarder/background. Then you'll know that the instructions before the trap ran without "directly crashing". So, it is assumed that the crash will occur later on down the routine. So then you cut the trap out and place it further down and check once again. If the game crashes without a red boarder/background, then the crash occured before the trap. If that makes sense.
    It can be time consuming, but it will help you to narrow out exactly where the crash occurs.
     
  6. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    It's an entirely custom screen mode actually.

    So I tried this, and it appeared the game never reached the cheat screen. The last thing it was doing was fading out the music, then rts. That's from Title_ChkLevSel, so I think it returns to MainGameLoop after that.

    Then I looked at what I did (long ago), and here's what's there:


    GameModeArray:
    bra.w SegaScreen ; Sega Screen ($00)
    bra.w TitleScreen ; Title Screen ($04)
    bra.w Level ; Demo Mode ($08)
    bra.w Level ; Normal Level ($0C)
    bra.w SpecialStage ; Special Stage ($10)
    bra.w ContinueScreen ; Continue Screen ($14)
    bra.w EndingSequence ; End of game sequence ($18)
    jmp Credits ; Credits ($1C)
    jmp CheatMenu ; Cheat menu B+Start ($20)
    rts

    Here, I see this problem: JMP followed by a long takes 6 bytes, not 4 bytes, so the game mode should be 22, not 20. If I remember correctly, the MD will just skip the bytes it can't read as instructions, so it can explain why I had no problem before.

    So I replaced it with a $22 and changed the AND mask applied on d0 to $3E, and now it works.

    I guess the changes in RandomNumber moved the Credits routine to an address that could be read as instructions, therefore they weren't skipped and resulted in an error, or something like that.
     
  7. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    864
    The method Sonic 2 uses for game modes too far away for a word-sized branch is to have it branch to a label that jumps to the actual code.
     
  8. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    I don't really see the benefit of that, aside from making sure the AND mask will always provide an address to a game mode even if the value in FFF600 is corrupted.

    Actually it can hide a bigger problem if that happens. :/

    It's good to know though, thanks.
     
  9. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Yay, new bug, new question. >_>

    How do I read error messages? I have an error message telling me "$00024FB8 $00003A43", I just wish it could mean something.

    I know, flamewing's debugger would do magic there, but I don't have it and don't know how to put it in S1.

    Knowing what/if there is anything to do with the information the game gives me could help a lot though.
     
  10. Shockwave

    Shockwave 3 Time Stones Member

    Joined:
    Dec 18, 2013
    Messages:
    121
    Location:
    LA, CA
    Well, from what I've gathered fixing errors that I've come across, the first number ($24FB8 in this case) is the offset in the ROM where the error occurs and the second number is the instruction or address causing said error. Of course you'd have to recognize the code in hex form to find what you need to change in the ASM file, which can be annoying. I may be missing an important detail or two, and I apologize if I am , but in my experience that's always been the case and I've always been able to fix the problem based on knowing that much, so I hope that helps you out.
     
    Last edited by a moderator: Mar 26, 2014
  11. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    The problem is, in 24FB8 is the code of the switch object, and there isn't any switch in the level.

    I mean, if 24FB8 is the address, I just open my rom in my hex editor, go in 24FB8, copy what I find there to disassemble a bit of the data and recognize the code from my disassembly, right?

    But it's really just not that at all, it's a completely unrelated object. I even checked, there's no such object in memory at that point. :/
     
  12. MarkeyJester

    MarkeyJester ! % # @ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,788
    The actual problem may not be where it crashes, for example:

    Code:
    		jmp	(a0)
    In this example, if a0 contains the wrong value/address. Then the 68k will still jump to that offset, and will then crash at that offset, and not the jump.
     
    Last edited by a moderator: Mar 26, 2014
  13. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    That's what I feared, so it's probably just a wrong address being read, the program get there and crashes.

    Well, it looks like I managed to solve it by clearing the ram from 1000 to D000 after the special stage, but it's really annoying not to know what was happening. :/
     
  14. TheStoneBanana

    TheStoneBanana The Bananaman Member

    Joined:
    Nov 27, 2013
    Messages:
    604
    Location:
    The Milky Way Galaxy
    Quick question.

    I grabbed Sonic 2 Nick Arcade .inis for SonLVL, but they seem to reference to a disassembly that I can't find. The ones archived on Sonic Retro are the Text-Only one, and the IDA Pro one. So, what do I use?
     
  15. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    864
  16. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    389
    Location:
    Town Creek, AL
    I had just edited obj8A in Sonic 1 to load Richter Belmont In. Worked fine. However after adding Uzumaki Naruto, and editind obj8A again to have also Uzumaki Naruto Believe It, Warning : Instruction has been word aligned. Line 30547 which is for GHZ EGGMAN CODE moveq #0,d0. Building is fine, but this is causing Lockup when eggman is loaded at GHZ3. i've changed to move.w and get the same result. even deleted obj8a's additions. any way to fix this?
     
  17. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,772
    Location:
    italy
    The most likely explanation is that the new data you added to object 8A (in particular I think the culprit might be obj8A.asm) is uneven and you forgot to add an "even" directive afterwards, which causes the following code ("Object 3D - Eggman (GHZ)") not to be aligned. Make sure obj8A.asm ends with an "even" directive, or add one in the main asm file right before the Obj3D label.
     
    Last edited by a moderator: Mar 30, 2014
  18. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    389
    Location:
    Town Creek, AL
    kinda odd Nineko. I tried this and nada. recoded and tried again and that part's fixed, but still GHZ3 EGGMAN crashes it out. I Punch in the level select, go to GHZ3, Everything seems fine untill eggman is loaded. "Address error" Shows up.thinking about moving character branching codes to the start of obj8A's routine and try that way, and iy didn't work. maybe i'll start it over again...
     
    Last edited by a moderator: Mar 30, 2014
  19. Painto

    Painto Samodzierżca Najdłuższego Kija Member

    Joined:
    Mar 24, 2014
    Messages:
    315
    Location:
    Poland
    I think is not very complicated, so I post it here.

    I have a Sonic 1 related question.

    So, I decided to expand my level select so it looks like this:

    [​IMG]

    I managed to do much things like making the Sound Test start at 00, add error sound effect from Sonic 2 (or more exactly, from the S2 Clone Driver files), add more lines, change the Sound Test digits position, etc.

    But there's one very weird thing - I can't build the ROM when adding check of 0600 LSelectPointer. It says the following error

    C:USERSARTURDESKTOPMOJHACKSONIC1.ASM<3524> : Error : Illegal value <164>And the line 3524 is...

    Code:
    move.w LSelectPointers(pc,d0.w),d0 ; load level number
     When I delete the check, the error dissapears and I can build it normally. How to fix this? If needed, this is how the part of the Level Select code where's the problem looks.

    EDIT: Nevermind, with help of SGD i fixed this.
     
    Last edited by a moderator: Apr 1, 2014
  20. Litebolt

    Litebolt Newcomer Trialist

    Joined:
    Apr 18, 2013
    Messages:
    17
    I have added the "Sonic" Results Text from Sonic 3 to Sonic 1, but this happened:                                                           Does anybody know how to fix it?

    /monthly_04_2014/post-2455-0-98118800-1396900768_thumb.png
     

    Attached Files:

    Last edited by a moderator: Apr 7, 2014