Basic Questions and Answers Thread

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

  1. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    35
    Location:
    Hidden Palace Zone, Westside Island
    First of all, you haven't changed the SSTs to be the proper one. You aren't loading the mappings into the mappings SST, you're loading them into the insta-shield's Y position. If you didn't update that, you sure didn't update the rest.
    This:
    Code:
    move.b    #4,4(a0)
    Needs to be this:
    Code:
    move.b    #4,1(a0)
    Etc.
    When porting an object from another Sonic game, you need to update it correctly. Look at the function of these SSTs in S3 and try to find an equalivent in S1. If there is no equalivent (which there won't be for 3 SSTs here), then use some of Sonic's SST space for it, since the shields wouldn't use Sonic's SSTs, and since the SSTs are allocated per object, this would work.
     
  2. Samey

    Samey Le Bored Hedgie Member

    Joined:
    May 3, 2017
    Messages:
    49
    So I'm trying to make the Special Stage ring disappear when the act results screen shows up.

    The only problem is, I can't make out where it checks for if Sonic collided with it in the code.
    I'm using the Hivebrain Sonic 1 disassembly btw
     
  3. Iso Kilo

    Iso Kilo Local Wolf-Fox Member

    Joined:
    Oct 9, 2017
    Messages:
    271
    Location:
    Small Town in BC, Canada
    Obj4B_Collect:
    Code:
    Obj4B_Collect:                ; XREF: Obj4B_Index
            subq.b    #2,$24(a0)
            move.b    #0,$20(a0)
            bsr.w    SingleObjLoad
            bne.w    Obj4B_PlaySnd
            move.b    #$7C,0(a1)    ; load giant ring flash    object
            move.w    8(a0),8(a1)
            move.w    $C(a0),$C(a1)
            move.l    a0,$3C(a1)
            move.w    ($FFFFD008).w,d0 ; <<<< This
            cmp.w    8(a0),d0    ; has Sonic come from the left? <<<< And this
            bcs.s    Obj4B_PlaySnd    ; if yes, branch
            bset    #0,1(a1)    ; reverse flash    object
    Those lines first load Sonic's playfield X position into d0, and then compare if the big ring's X position is the same as Sonic's, if it is less than that it mean's Sonic comes from the left (That's what the bcs does, might be easier to remember with the mnemonic blo, since the branch on carry concept is kind of confusing)
     
    ProjectFM, Samey and DeltaWooloo like this.
  4. Samey

    Samey Le Bored Hedgie Member

    Joined:
    May 3, 2017
    Messages:
    49
    Ah, thanks! :)
     
  5. DeltaWooloo

    DeltaWooloo Sonic ReOne is almost done! Member

    Joined:
    Aug 7, 2019
    Messages:
    205
    Location:
    A shed
    Ever wondered why this happens when going through the title screen for too long?
    Screenshot 2020-04-10 at 22.54.23.png
    I believe it has something to do with Title_LoadText. I'm also staying at Hivebrain disassembly.
     
  6. Samey

    Samey Le Bored Hedgie Member

    Joined:
    May 3, 2017
    Messages:
    49
    I haven't seen that actually, maybe it has something to do with the level transition bugs? It looks very similar.
     
  7. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,857
    The Dynamic Screen Resizing is responsible for that.

    The Title Screen is using the scroll subroutines (DeformBgLayer) to run Green Hill Zone's background scrolling you see. Unfortunately, this subroutine follows the rules of; screen following the coordinates at D008 and D00C of RAM (the first object), and running the dynamic screen resizing routines (DynScrResizeLoad) to impose the right boundaries of a level where the screen cannot scroll passed.

    Green Hill Zone has its height set a certain range at the beginning of the level, so as the Camera tries to follow, it is stopped from going lower than that height. After 1780 on the X range, it'll resize the height and make it larger, and so now the screen can continue moving down to follow him.

    There are loads of hacky solutions such as, comparing the game mode to see if it's the title screen, and skipping over the height change, or forcing the Y position at D00C to be in such a spot that allows the camera to remain in place, perhaps $300 + ($E0 / 2) should do it. But the absolute solution would be to rewrite the way the title screen is handled in the first place, as the title screen does appear to be blatantly using aspects of the level when it shouldn't, and was manually hit with bricks to fit.
     
    ProjectFM and DeltaWooloo like this.
  8. Iso Kilo

    Iso Kilo Local Wolf-Fox Member

    Joined:
    Oct 9, 2017
    Messages:
    271
    Location:
    Small Town in BC, Canada
    Although I didn't want to just hand this out, this is how one would do this solution. Assuming you hadn't modified the resizing routine:
    Code:
    Resize_GHZ1:
            move.w    #$300,($FFFFF726).w ; set lower    y-boundary
            cmpi.w    #$1780,($FFFFF700).w ; has the camera reached $1780 on x-axis?
            bcs.s    locret_6E08    ; if not, branch
            cmpi.b    #4,($FFFFF600).w    ; Is the game at the title screen?
            beq.s    locret_6E08    ; If so, rts
            move.w    #$400,($FFFFF726).w ; set lower    y-boundary
    
    locret_6E08:
            rts
     
    MarkeyJester and DeltaWooloo like this.
  9. Iso Kilo

    Iso Kilo Local Wolf-Fox Member

    Joined:
    Oct 9, 2017
    Messages:
    271
    Location:
    Small Town in BC, Canada
    So I've been using Aurora Field's guide on speeding up level loading, however I'm stuck. In the section about not waiting for PLCs to load, I've been getting an illegal instruction error in loc_16AA:, which looks as so;
    Code:
    loc_16AA:                ; XREF: sub_165E
            movea.w    #8,a5
            bsr.w    NemDec3
            subq.w    #1,($FFFFF6F8).w
            beq.s    loc_16DC
            subq.w    #1,($FFFFF6FA).w
            bne.s    loc_16AA
            move.l    a0,PLCQueueAdr.w
            move.l    a3,($FFFFF6E0).w
            move.l    d0,($FFFFF6E4).w
            move.l    d1,($FFFFF6E8).w
            move.l    d2,($FFFFF6EC).w
            move.l    d5,($FFFFF6F0).w
            move.l    d6,($FFFFF6F4).w
    I'm not entirely sure why, and I apologize if the answer is so obvious.

    Edit 2 - While editing other bits and parts, the error seems to change here and there, ranging from line 1111 emulation and address errors. Still originating from loc_16AA:

    There's also another issue, but less so to do with the guide and more a compatibility problem. Before the crashing, just as I had added comper compressed tiles, the title screen was looking like this:
    [​IMG]
    And it's because of how Project 1: Two-Eight handles the title screen. Unlike most things that would just merge the Green Hill Zone tiles into 1 file, the 1: Two-Eight disasm does that, and gives the title screen 2 title screen files, or so it'd seem.

    Edit, while the game still crashes and I do need help on that, I just made the title screen use Nemesis compression again and that solved the issue
     
    Last edited: Apr 11, 2020
  10. DeltaWooloo

    DeltaWooloo Sonic ReOne is almost done! Member

    Joined:
    Aug 7, 2019
    Messages:
    205
    Location:
    A shed
    For speeding up the level loading, it actually worked for me. What's preventing you from stopping?
     
  11. Samey

    Samey Le Bored Hedgie Member

    Joined:
    May 3, 2017
    Messages:
    49
    ^ the title screen looks to still be using the tiles from the "sonic team presents" screen, so it might not be loading the new tiles at all. you might need to double-check the code for loading the title screen graphics.


    as for my issue with the big rings, turns out, the big ring never actually checks if you collided with it or not, instead, I believe it has the collision itself see if he collided with it.
    The code Kilo pointed out for me seemed to only be there to decide if the Ring Flash effect was supposed to be flipped or not. :/

    So, yeah, still no idea how to get this working.. ack..
     
    Last edited: Apr 12, 2020
    MarkeyJester likes this.
  12. DeltaWooloo

    DeltaWooloo Sonic ReOne is almost done! Member

    Joined:
    Aug 7, 2019
    Messages:
    205
    Location:
    A shed
    How can I convert sound effects from Sonic games such as from Sonic 3K to Sonic 1?
     
  13. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    850
    Location:
    Portland, Maine
    Most of the time, you just need to change the pointers. The first two bytes point to the voice table. Then for every 6 bytes afterward which represents a channel being played, the middle 2 bytes point to the start of that channel's code. (Source) Between the header and the voice table, if you see $F6, $F8, or $FC, then the two bytes after that will be a pointer. If you see $EB, then there will be a byte after it, then a pointer. (Source)

    Sonic 3K uses a Z80 sound driver, meaning the pointers will be relative to their place in the ROM. Also, every pointer will have its bytes flipped. Sonic 1 uses a 68k sound driver, meaning the pointers are relative to the start of the sound file. You can use the "find" function in a hex editor to search for where the sound is in a Sonic & Knuckles ROM. Then, go to a pointer, flip the bytes, and subtract the location of the sound file. Do this for every pointer. Keep in mind that Sonic 3K has a couple extra coordinate flags and hardcoded stuff that won't transfer to Sonic 1 properly, but most sounds should work fine. (Source)

    Alternatively, you can use a sound driver compatible with SMPS2ASM which can do all that stuff for you, or just use Sonic 3's sound driver.

    Edit: I have a question, now. I've implemented a level transition just like how Sonic 3 does it, but it's having the issue where one the leftmost chunks aren't drawn until the screen is moved away and back. I know this is a common issue since I've seen it when starting a level in some hacks, but I don't remember ever hearing a solution.

    Edit 2: I have Sonic 2's dirty flag ported over, so setting that did the trick. It still redraws a frame too late most of the time, but it's much better.

    Edit 3: This is kind of maddening for me since I'm going into unknown territory. There is some screen drawing routine that isn't redrawing the whole screen like I want it to, and it looks too dense with unknown code for me to figure out where I can make a reasonable change. Also, LoadTilesFromStart uses some of these routines, yet calling it does nothing to fix my problem.
     
    Last edited: Apr 14, 2020
    DeltaWooloo likes this.
  14. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    390
    Location:
    Russia
    If you wish S3K-esque level transitions work without altering much of S1/S2's level layout rendering engine, there are two simple prerequisites to do the trick:

    1) Make sure the end area of the current level matches the beginning of the next level (to where you're being transited). In other words, the last two 256x256 chunks you seeing at the end of current level (or the last four 128x128's, if you're borrowing S2's layout system) should exactly match the place in the layout of the next level where you're being transfered to.

    NOTICE: If you wish the next level to start differently when played without transition (for instance, when loaded via level select), you just have these first two chunks as a buffer of sorts, put Sonic on the third chunk and limit camera's left boundary so that the level "seems" to begin from the third chunk.
    2) Make sure the X-position of the first of those "final" chunks at the end of the level (where the camera left boundary is being set to) is divisible by $0200 (e.g. positions like $1800, $1A00, $2200 are fine). The same should be true for the matching chunk in the next level (but we just assume it starts at $0000 for simplicity). This way, the boundaries at which the level layout blocks will continue drawing/updating as Sonic moves will be properly aligned, thus any drawing glitches avoided.

    REASON: Level layouts are being drawn on the 512x256 ($0200 x $0100) pixel Plane A nametable and the horizontal/vertical scrolling is applied accordingly. As you move, game only draws one row/column of 16x16 blocks (in case of S1/S2, S3K is different); the entire screen or chunks are never redrawn during normal gameplay because it's very costy (S2 has one or two one-time exceptions, hence the so-called "dirty-flag")​


    I'm sorry, I can't get much into details right now, because I'm busy, and I hope I didn't miss anything important (I haven't touched this stuff in years). But relying on the above prerequisites I was able to get level transition working in my own hack, SWA, back in 2013 within 4-6 hours. It's not too difficult if done right.
     
    Inferno and ProjectFM like this.
  15. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    850
    Location:
    Portland, Maine
    Thank you so much Vladikcomper! The issue is that I wanted to make my levels as long as possible, so I set the boundary to #$3E80. Moving it back to #$3E00 fixed it.
     
  16. DeltaWooloo

    DeltaWooloo Sonic ReOne is almost done! Member

    Joined:
    Aug 7, 2019
    Messages:
    205
    Location:
    A shed
    Every time I want to load credits, the game doesn't let me and redirects me back to the SEGA screen. I have checked the code and it says jump to credit and not SEGA. How can I fix this?
     
  17. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    850
    Location:
    Portland, Maine
    Edit: Literally 1 minute later I realize my error. I screwed up rewriting the definition for the monitors.
     
  18. Fadhil2314

    Fadhil2314 Newcomer Member

    Joined:
    Apr 14, 2020
    Messages:
    13
    (Question)

    Is there's a way to port sonic's sprite from sonic 3 to sonic 1?
     
  19. KZG4

    KZG4 Back Pain the Person Member

    Joined:
    Jul 30, 2016
    Messages:
    73
    Location:
    Ikea office chair
    Fadhil2314 and DeltaWooloo like this.
  20. DeltaWooloo

    DeltaWooloo Sonic ReOne is almost done! Member

    Joined:
    Aug 7, 2019
    Messages:
    205
    Location:
    A shed
    All that needs is the palette and that's it.