Basic Questions and Answers Thread

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

  1. Starfruity

    Starfruity Newcomer Trialist

    Joined:
    Jan 17, 2014
    Messages:
    18
    Okay, now that I got a chance to look into this "universal" sound driver, I'm not sure exactly how to use it. It says it's a modified S3&K sound driver, so should I port the S3 one then make the necessary changes, or am I getting this all wrong?

    EDIT: I tried including Z80 Sound Driver.asm in SoundDriverLoad and Kos_Z80 (probably not at all what I was supposed to do, but I'm just experimenting) and I got a ton of errors like "Unexpected character at end of line".
     
    Last edited by a moderator: Jan 24, 2014
  2. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    So I've recently decided to return to hacking. And I've been tinkering around with Sonic 2's dis-assembly; most recently, gathering an inspiration of the Sonic 2 remakes, Hidden Palace spoiler, I thought I'd try my hands coding that method in. Hidden Palace ported over fine, the problem is the transition.


    LevEvents_MCZ2_Routine3:
    cmp.w y_pos(a0),d0 ; has Sonic touched the bottom boundary?
    bcc.s +
    jsr Pal_FadeOut
    clr.b ($FFFFFE30).w
    move.b #1,(Control_Locked).w
    move.w $800,(Current_ZoneandAct).w
    move.b #1,(Level_started_flag).w
    rts
    +
    rts
    I created another event routine in MCZ2, which triggers the event of the transition. and had to figure out an exception, because the Sonic_Boundary_BottomCheck was forcing the characters to die.
     


    Sonic_Boundary_Bottom: ;;
    cmpi.w #$B01,(Current_ZoneAndAct).w
    blt.s +
    cmpi.w #$2000,($FFFFD008).w
    bcs.w +
    clearRAM Sprite_Table_Input,$400 ; fill $AC00-$AFFF with $0
    clearRAM Object_RAM,$2000 ; fill object RAM ($B000-$D5FF) with $0
    clearRAM Camera_RAM,$100 ; clear camera RAM and following variables
    move.w #1,($FFFFFE02).w ; restart the level
    move.w #$800,(Current_Zone).w
    rts
    +
    bra.w JmpTo_KillCharacterThe outgoing result after changing using this edit, I got the desired result for the transition. The problem I'm having rejects the characters to repeat the same transitions after the first one has been triggered.

    It might be a tad simple, but any help would be just fine.

     
     
    Last edited by a moderator: Jan 24, 2014
  3. ⸸ devon ⸸

    ⸸ devon ⸸ I am CRUSHING YOUR HEAD!!!! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,115
    EDIT: I do know now how to solve it. I was trying to figure out how you are trying to explain the error.
     
    Last edited by a moderator: Jan 24, 2014
  4. Mike B Berry

    Mike B Berry A grandiose return Member

    Joined:
    Jun 6, 2012
    Messages:
    377
    Location:
    New places, newer motivation
    Typical question. We don't, but I don't care. As its an inspiration for the remake, rather than the layouts from the beta. Sure its not that much of a difference, its more for a greater challenge.
     
  5. Flamewing

    Flamewing Elite Hacker Member

    Joined:
    Aug 28, 2011
    Messages:
    37
    Location:
    France
    Since I have been invoked, let me explain it out a bit. Yes, you can change palettes during HBlank; you can change it as many times as you want to, in fact, with the only limitations being bandwidth and the relative speed differences of the 68k and the VDP. Using the subCPU in Sega CD, you can even do a DMA to CRAM and have a different color every pixel; but this is not that useful in a game. And it does not work on emulators; in fact, in emulators you can basically change palette only "once" per scanline -- you can change as often as you want to, but it will only take effect on the next scanline.

    But the situation is not much better in real hardware; when writing to CRAM during HBlank, not only is the position of the writes not stable (that is, you can't always guarantee that you will change color to a certain value for a given pixel every time), but you get CRAM dots -- the color that is being written to CRAM is drawn in the middle of the line, instead of whatever color was supposed to go there. In fact, if you check the options screen of my hack in real hardware, you will see a mess of dots in four rows (but more on this later). Emulators generally implement neither of this; Exodus does, but its timings are all wrong.

    So the take-home message so far is that it is possible to change palettes with precision on a line-by-line basis, and (generally with less precision) in any given line only on real hardware, and you get garbage in the display as a consequence.

    There is one more quirk of the VDP that prevents you from seeing those CRAM dots more often -- they don't happen when you have a sprite drawn where they would go. This is the reason for the water surface in Sonic games -- they are there to hide the CRAM dots that would otherwise appear due to streaming the water palette in HBlank.

    Now, regarding my hack, which was mentioned: there is a lot of changing of palettes in several locations, but the players themselves are merely crammed into a single palette line + 1 color in another (Knuckles' socks). They don't use anything more advanced than careful merging of their palettes in a way that looks good.

    Regarding the parts that do use these more advanced effects: in the S1 part, the "original" Sonic 1&2 used HBlank to swap out colors; in the middle of the action, you can hardly see the CRAM dots, even if you know what you are looking for, because a small number of colors is transferred. My hack inherited some code from S1&2, and hence this also happens there. I added some more code to swap palettes in other parts of the game, leading it to also be seen in the S1->S2 transition (when the Wing Fortress is in view), and in Sky Chase and Wing Fortress (when the Tornado is in view) and the options screen, which I already mentioned (and which is the worst).

    I have been working to remove these CRAM dots, with great success; I am using the same technique used in S3&K of sending only 3 colors per line at the end of the line, so that the CRAM dots end up in the overscan area; the options screen is now spotless, and S1->S2 transition is almost there. Eventually, I will publish a more detailed explanation of this... but that is not now.
     
  6. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,883
    Location:
    italy
    Oh, so I remembered wrong. The waves on the water surface are indeed there to hide something, but not what I thought. Thanks for explaining.
     
  7. SuperEgg

    SuperEgg I'm a guy that knows that you know that I know Member

    Joined:
    Oct 17, 2009
    Messages:
    Location:
    THE BEST GOD DAMN STATE OF TEXAS
    You dirty bitch, I was already in progress with that idea. Well, I've got the level layout portion in the works, the level transition, not yet. Have you tried making the level size itself larger?
     
  8. ⸸ devon ⸸

    ⸸ devon ⸸ I am CRUSHING YOUR HEAD!!!! Member

    Joined:
    Aug 26, 2013
    Messages:
    1,115
     


    OK then. Now I figured out your problem and I think I have the solution.

    What I would do is to check if Sonic is in the pit first then check is Sonic is near the bottom of the pit, then do the transitions. LevEvents_MCZ2_Routine3 and Sonic_Boundary_Bottom do not need to be messed with. Instead, the transition code should be at the beginning of LevEvents_MCZ2_Routine1.

    So put a '+' after LevEvents_MCZ2_Routine1, undo the changes made to LevEvents_MCZ2_Routine3 and Sonic_Boundary_Bottom.

    Now some code before the '+'.

    First, you check if Sonic is left to the pit, which is $14F0, is he is, then it branches to the '+', where it continues on. Then you check is Sonic is right to the pit, which is $15A0, is he is, then branch to the '+'.

    Then we check is Sonic is near the bottom of the pit, so we don't activate the death code for Sonic. The bottom of the pit is $780. Just to be safe, we will check if Sonic is $10 pixels above the bottom, which is $770. Who can check is Sonic is lower than that if you want.

    Now we add the transition code. We will change the zone and act to HPZ1 and activate the level. We will take some code from Obj3A and edit is slightly, the code here switches the level properly:

    Code:
    
        move.w    #hidden_palace_zone,(Current_ZoneAndAct).w
    
        clr.b    (Last_star_pole_hit).w
    
        clr.b    (Last_star_pole_hit_2P).w
    
        move.w    #1,(Level_Inactive_flag).w
    
        rts
    
    
    
    


    At the end you should have this at the beginning of LevEvents_MCZ2_Routine1:

    LevEvents_MCZ2_Routine1:
        cmpi.w #$14F0,(MainCharacter+x_pos).w
        bls.s +
        cmpi.w #$15A0,(MainCharacter+x_pos).w
        bgt.s +
        cmpi.w #$770,(MainCharacter+y_pos).w
        bls.s +

        move.w #hidden_palace_zone,(Current_ZoneAndAct).w
        clr.b (Last_star_pole_hit).w
        clr.b (Last_star_pole_hit_2P).w
        move.w #1,(Level_Inactive_flag).w
        rts

    +




     

    This is my way for going into HPZ from MCZ in the pit. Here is a video, which you should have by the time you have completed this (0:00-0:07):

    https://www.youtube.com/watch?v=wWbzHWSQBkM

    NOTE: The Sonic falling animation in the video was just extra from me. Also, this also works for Tails or any character in control of Player 1.
     
    Last edited by a moderator: Jan 24, 2014
  9. Starfruity

    Starfruity Newcomer Trialist

    Joined:
    Jan 17, 2014
    Messages:
    18
    Hey Flamewing, since you're here anyway, care to give me a tutorial on your sound driver? Go easy on me, I don't know a thing about anything :p (and this is also assuming you're not elsewhere by this point). Actually, all I really need to know is do I need the regular S3&K driver ahead of time, or can I just use it straight away?
     
  10. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    One thing I notice immediately is that Take1HP treats the HP counter as a byte, while Test_0HP treats it as a word (two bytes).
     
  11. Starfruity

    Starfruity Newcomer Trialist

    Joined:
    Jan 17, 2014
    Messages:
    18
    Are you ignoring me so I'll experiment and figure it out by myself? I've tried porting the S3 sound driver and including Z80 Sound Driver.asm in various places and using the ASM music and sound files and I HAVE NO IDEA WHAT I'M DOING!
     
  12. TheStoneBanana

    TheStoneBanana banana Member

    Joined:
    Nov 27, 2013
    Messages:
    602
    Location:
    The Milky Way Galaxy
    Hey, maybe so. Nobody's going to do everything for you, so maybe they DO want you to experiment. Read up a bit more about the driver and crap and I'm sure you'll have a breakthrough. And, to be clear, I would help you, but honestly, I have no idea what I'd be doing either, yet I don't have an interest in another sound driver ATM, so...
     
  13. Starfruity

    Starfruity Newcomer Trialist

    Joined:
    Jan 17, 2014
    Messages:
    18
    I don't want everyone to do everything for me, but I do need something to get me started, in a way. I have no experience with sound drivers at all so I probably won't be able to figure this one out. Whatever, I'll keep trying and work on other parts of the hack.
     
  14. TheStoneBanana

    TheStoneBanana banana Member

    Joined:
    Nov 27, 2013
    Messages:
    602
    Location:
    The Milky Way Galaxy
    I see what you mean. Once again, I have no knowledge of Sound Drivers, nor do I seek to know, so good luck.
     
  15. RocketRobz

    RocketRobz Coolest of TWL, and Sonic fan Member

    Joined:
    Aug 20, 2009
    Messages:
    79
  16. Flamewing

    Flamewing Elite Hacker Member

    Joined:
    Aug 28, 2011
    Messages:
    37
    Location:
    France
    Starfuity: First thing you need to learn is patience; not everyone is checking the forums 24/7, and sometimes answers get delayed for several reasons. In your impatience, you just wasted two trialist posts for no good reason.

    Anyway: there is a tutorial for using my driver with Sonic 2 (here); I don't think anyone tried to put it in S1 yet (I know I haven't), so if you want it for S1, you are out of luck.

    Edit: Ah, I had forgotten about that tutorial Bobesh8 pointed out.
     
    Last edited by a moderator: Jan 26, 2014
  17. Misinko

    Misinko Oh SHIT it's the Biolizard! Member

    Joined:
    Apr 30, 2013
    Messages:
    725
    Location:
    Ohio
    Maybe people just haven't noticed yet. I've seen people get responded to a week after their question was posted. Like I've said before (and I'm joking here, don't get down my throat) "There's a little virtue called patience, that comes in handy in life." 

    Edit: Dang it Flamewing. You said what I wanted to say while I was typing :p 
     
    Last edited by a moderator: Jan 26, 2014
  18. Starfruity

    Starfruity Newcomer Trialist

    Joined:
    Jan 17, 2014
    Messages:
    18
    Aw, now I'm never gonna become a member now, because not only do I not know anything, but I'm impatient and wasting posts.

    Oh well. Back to the problem at hand. I already used the S3 driver to S1 tutorial and it's working fine, I just don't know how to change it to Flamewing's.

    P.S. Heh, everyone's editing their posts because others are typing at the same time. That's vaguely amusing.

    EDIT: No one's added it to Sonic 1 yet apparently, but Flamewing said that there was that tutorial for the S3 driver to S1 that he forgot about, so does that mean it is easy/possible? (I'm confused.) Maybe I shouldn't be trying to be so technical as a beginner and just stick with easy stuff.
     
    Last edited by a moderator: Jan 26, 2014
  19. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,883
    Location:
    italy
  20. Misinko

    Misinko Oh SHIT it's the Biolizard! Member

    Joined:
    Apr 30, 2013
    Messages:
    725
    Location:
    Ohio
    Ok, don't respond to this if you feel you're losing ground, but not knowing how to code isn't going to keep you from being a member. Asking totally reasonable questions is fine. When you ask stupid/pointless questions (like, "Can someone do diz for me?"), that's when things get hairy. I didn't know a single line of ASM starting out (nor do I now), and look at me. I became a member in 12 hours. Being impatient is a problem with a lot of newbies. However, you're handling it in a better way. I've seen people begging for others to do all the work for them because they were impatient. You, on the other hand. want to do it yourself, you just aren't patient enough for people to respond. Work on that, and you'll be fine. Here are two tips on becoming a member:

    1. Actually contribute something to the discussion. If you're giving feedback on a hack, don't post a 3 word response saying "Nice hax man!1!!1". Say what you like, and dislike, in detail

    2. Establish yourself. No one likes a copycat. I've seen people mimic others on the forums all the time (I myself am guilty of that) and they haven't received the best of responses. Be yourself. Handle situations how you would handle them, not how some pro-user would handle them. 

    Staff, feel free to trash this for going off-topic. I just felt it needed to be said. 
     
    Last edited by a moderator: Jan 26, 2014