Basic Questions and Answers Thread

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

  1. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    396
    Location:
    Town Creek, AL
    Thanks. and here I thought the DMA Queue was all I needed, guess I was wrong.
    second question.
    As I've said, I've converted the Level Select into an options and separated the two.
    LevelSelectRam = $FFFFF5C1
    CharacterRam = $FFFFF5C2

    Code:
    Levsel_Char:
      cmpi.b #1,(LevelSelectRam)
      beq LevSel_NoMove
      tst.w ($FFFFFF82).w ; is item $14 selected?
      bne.s LevSel_Debug_Mode ; if not, branch
     
      cmpi.b #1,(CharacterRam)
      beq LevSel_Char_Left
     
      move.b ($FFFFF605).w,d1
      andi.b #ButtonRight,d1  ; is left/right pressed?
      beq LevSel_NoMove ; if not, branch
      move.b #1,(characterRam)
      bra Levsel_Char_Sound
    LevSel_Char_left:
     
     
      move.b ($FFFFF605).w,d1
      andi.b #ButtonLeft,d1  ; is left/right pressed?
      beq LevSel_NoMove ; if not, branch
      clr.b (characterRam)
     
    Levsel_Char_Sound:
      move.w #$CD,d0
      bsr.w PlaySound_Special ; play special stage exit sound
      rts
    what can I change to have it to go through...
    right as...
    00 - Sonic 1
    01 - Sonic 2
    02 - Sonic 3
    03 - Sonic Nebula (from a spritesheet I found via google)
    back to 00
    and left in reverse order
    Edit: Nevermind, I just took some code from sound test and make a Character_Swap to jump to
     
    Last edited: Jun 13, 2020
  2. DeltaWooloo

    DeltaWooloo A hacker, helper, friend and a Wooloo Member

    Joined:
    Aug 7, 2019
    Messages:
    221
    Just have a question about sound effects: I have s1smps2asm installed and it works fine, I also have flamewing S3K driver files with me. I want to port a sound effect from Sonic 3 to Sonic 1 using asm. How do I do that?
     
  3. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    861
    Location:
    Portland, Maine
    I'm trying to add a pause menu to my Sonic 1 hack. The difficulty in this is that I'm going to have to run a single object while leaving every other object alone. Using the subroutines "ObjectsLoad" and "BuildSprites" will display the sprite, but also run everything else. Because of this, I've tried condensing everything needed to display the sprite into the code of the sprite itself with no luck of getting it to display.
    Code:
    Obj07:
            moveq    #0,d0
            move.b    $24(a0),d0
            move.w    Obj07_Table(pc,d0.w),d1
            jmp    Obj07_Table(pc,d1.w)
    ; ===========================================================================
    Obj07_Table:    dc.w Obj07_Init-Obj07_Table; 0
            dc.w Obj07_Main-Obj07_Table; 1
    ; ===========================================================================
    
    Obj07_Init:
            addq.b    #2,$24(a0)
            move.b    #0,$1A(a0)
            make_art_tile    ArtTile_Explode,0,1
    
    Obj07_Main:
            moveq    #0,d5
            moveq    #0,d4
            bclr    #7,1(a0)
            move.b    1(a0),d0
            move.b    d0,d4
            move.w    #$130,d2        ; x-position
            move.w    #$D8,d3            ; y-position
            movea.l    #Map_Obj07,a1
            moveq    #0,d1
            move.b    $1A(a0),d1
            add.w    d1,d1
            adda.w    (a1,d1.w),a1
            moveq    #0,d1
            move.b    (a1)+,d1
            subq.b    #1,d1
            bsr.w    sub_D750
            bset    #7,1(a0)
            rts    
    Code:
    loc_13CA:
            move.b    #$10,($FFFFF62A).w
            jsr    DelayProgram ;wait...
            movem.l    d0-d5/a0-a2,-(sp)
            movea.l    ($FFFFB540).w,a0
            jsr        Obj07
            movem.l    (sp)+,d0-d5/a0-a2
            move.b    ($FFFFF605).w,d0
            or.b    ($FFFFF607).w,d0
            andi.b    #$80,d0
            beq.s     loc_13CA
    The reserved object SSTs have been moved from $FFFFD000 to $FFFFB000 in this hack. make_art_tile just sets 2(a0).

    Also, if I try adding back in the code for slow-motion mode, it messes with the reserved object SST RAM. This part is not a priority until the main issue can be fixed.
     
  4. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,870
    a2 should contain the current sprite table buffer position, set this to the first slot..

    Code:
    		lea	($FFFFF800).w,a2
    Doing this via the method you're doing above though, if you have for example 4 sprite pieces which make up this pause menu, what will happen in theory is the first four sprites in the table will be overwritten, since the HUD is the first rendering object, it's sprite pieces will be overwritten, so you'll find the score and the time will be missing.

    As a quick hack, you can reserve these slots in the sprite table until the object is ready to implant its pieces, goto "BuildSprites", and after the clearing of d5, put this in:

    Code:
    		lea	(Map_Obj07).l,a1	; load pause menu mappings
    		adda.w	(a1),a1			; load address of first frame
    		moveq	#$00,d0			; clear d0
    		move.b	(a1),d0			; load number of sprite pieces needed to be reserved
    		subq.w	#$01,d0			; minus 1 for dbf
    		bcs.s	BS_NoPause		; if there were no sprites in the list, skip reservation
    
    BD_ReservePause:
    		addq.b	#$01,d5			; increase sprite link ID
    		move.l	d5,(a2)+		; clear Y position, shape, and set the link ID
    		move.l	d5,(a2)+		; clear the pattern index, clear X position (as long as it's below 80, it'll be fine)
    		dbf	d0,BD_ReservePause	; repeat for all sprite pieces
    		
    BS_NoPause:
    This'll ensure the slots are reserved such that the objects will not render to the sprite table until the slots after the pause menu, you just have to make sure you send blank sprites to these first few slots after the pause menu is finished. Furthermore, it'll only reserve enough slots for the first frame, if you have other frames then you'll want to reserve the slots for the frame which uses the most pieces.

    Personally though, I don't think this is the best way to go about rendering a pause menu, I would recommend accessing the sprite table directly (without an object) and handling it via that way, but the whole sprite building routine would need some major rewrite to handle it efficiently. If you don't want to go that far, then I personally would opt for changing the link ID of the first slot to point to 4F's slot (the last slot), then get that slot to point to 4E, then 4D, then 4C (for however many pause menu sprites you have), then have the last piece (for example 4C) link to slot 01 again. The only piece which'll display in-front would be the first piece (the "SCOR") piece, but it's in the top corner and I'd assume your pause menu will be in the middle. But this'll save you having to reserve slots, and it'll only overwrite the lowest priority pieces whilst allowing the menu high priority display.

    Realistically though, Sonic games were not built for handling these sorts of things, I guess the novelty of pause menus were not a big thing in 1991, most games just displayed "PAUSE" and that's it. But I cannot stress enough that you're really looking for a rewrite of some kind or a hi-jacking of the sprite table if you don't want to rewrite, both of which are very specific to your pause menu's design.

    EDIT: Oh! One thing I didn't think of, when Sonic dies, a different loop is used, one which loads the object slots into a0, and simply calls "DisplaySprite" without running the object's code, and then uses "BuildSprites", this might be more beneficial to you, especially considering the pause subroutine has its own loop. Load your object to a0 and run its routines and call "DisplaySprite", then run through the other objects but don't run their routines, just call "DIsplaySprite", then afterwards call "BuildSprites" and that should in theory do the trick too.
     
    Last edited: Jun 17, 2020
    ProjectFM likes this.
  5. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    861
    Location:
    Portland, Maine
    I went the route of using "RunObjectDisplayOnly", and that made it much easier. I just had it run the menu object's code, then do a display only run of everything else. Also, I caught that
    Code:
        movea.l    ($FFFFB540).w,a0
    will set the value as the address rather than $FFFFB540, so I have to use lea instead. I tend to get those two mixed up.
     
  6. John Belotti

    John Belotti Newcomer Member

    Joined:
    Mar 14, 2017
    Messages:
    15
    Location:
    Rochester Hills, MI
    I've decided to replace the vanilla 1-Up track in Maxidrive (the one from S3 is in place even if it's kinda overused), although there is one issue. When the replacement tune ends, the rest of the game's audio does not fade back in until another music track plays. Is there something I gotta fix? I can say it was a midi file (from the PC version to make it a bit easier) converted to a SMPS with ValleyBell's tool. Not sure if it's regarding the midi file or other files in the disassembly causing this.
     
  7. DeltaWooloo

    DeltaWooloo A hacker, helper, friend and a Wooloo Member

    Joined:
    Aug 7, 2019
    Messages:
    221
    Well, in terms like this, you must add a flag via hex editing. That would be E4, which initiates to the previous song played. You need to place it somewhere near the end of the music file and see how it sounds. If the music cuts off and plays back the song, you need to place it somewhere else. Find it and place it closer to the end.
     
  8. penPhobic

    penPhobic No laughing near the emerald! Member

    Joined:
    Dec 11, 2016
    Messages:
    55
    Location:
    Basement
    Hello again! Is it possible to import DAC (bin) files in Audacity outside of SEGA chant? I tried it and all I hear is short static noise. How many rates should I change?

    Hint: Sonic 3K drums
     
    Last edited: Jun 20, 2020
  9. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,802
    Location:
    italy
    They're not in a PCM format which can directly be opened by common wave editors, but Stealth took care of that.

    Note that the link above is for history alone, because the download within that topic is dead. So, once you read the how, go here for the meat.

    Ironically, my own mirror is dead.
     
    ProjectFM and penPhobic like this.
  10. AURORA☆FIELDS

    AURORA☆FIELDS the cute one here Member

    Joined:
    Oct 7, 2011
    Messages:
    734
    Location:
    Finlandia
    This was actually recently ripped by Markey, but with (at least nearly) accurate sample rate and all the different rates included as well, and they have a wav header. Have a link.
     
    AkumaYin, ProjectFM and penPhobic like this.
  11. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    94
    Location:
    Italy
    Hi,I'm back here!
    Sorry for the inconvenience, I have two basic questions.
    1- How can I keep sonic from losing his lives?
    2-This is a complicated question...
    I wish if sonic destroys the "S" monitor,it will be possible to access the special stage(and with this you will understand what the new feature of my hack will be).
    Obviously this changes are for sonic 1GitHub.
    I hope I have explained myself well.
     
  12. ralakimus

    ralakimus pretty much a dead account Member

    Joined:
    Aug 26, 2013
    Messages:
    1,069
    @Angel X
    1) If you take a look at "GameOver" in "_incObj/Sonic (part 2).asm", you will see:
    Code:
            addq.b    #1,(f_lifecount).w ; update lives counter
            subq.b    #1,(v_lives).w    ; subtract 1 from number of lives
            bne.s    loc_138D4
    First line tells the game to update the life count in the HUD, and then the last 2 actually subtracts the life count and then branches to loc_138D4 if the life count isn't 0 yet. Basically, you'll wanna remove these 3 lines of code and make sure it always goes to loc_138D4.

    2) Just so we are clear, do you mean you want the S monitor to take you to the special stage immediately, or do you want it to make the giant ring appear at the end of the level?
     
  13. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    94
    Location:
    Italy
    Thanks for the reply:D
    I wanted that the giant ring appears at the end of the level.
    if sonic dies I prefer that the player hit the monitor again to get to special stage.
     
  14. ralakimus

    ralakimus pretty much a dead account Member

    Joined:
    Aug 26, 2013
    Messages:
    1,069
    @Angel X Okay, the process is pretty simple.

    The first thing you should do is find a free byte in RAM that will hold the flag for when Sonic hits the monitor. Since you want this flag to be reset when you die, have it cleared somewhere in Level_SkipClr.

    The next step in this is to lake a look at "GRing_Main" in "_incObj/4B Giant Ring.asm". You will see this:
    Code:
            cmpi.w    #50,(v_rings).w    ; do you have at least 50 rings?
            bcc.s    GRing_Okay    ; if yes, branch
            rts    
    These 3 lines then check if you have at least 50 rings, and if you do, branch to "GRing_Okay". The rts exits out of the object code, effectively hiding it if you don't have 50 rings. What you should do is make the 50 rings comparison line check if your new flag is nonzero, and change the branch instruction to reflect how you want it to branch.

    Finally, you'll want to take a look at "Pow_ChkS" in "_incObj/2E Monitor Content Power-Up.asm". You will see this:
    Code:
    Pow_ChkS:
            cmpi.b    #7,d0        ; does monitor contain 'S'?
            bne.s    Pow_ChkEnd
            nop    
    First 2 lines check if the monitor had an "S" icon, and if not, branch to Pow_ChkEnd. The "nop" means "no operation", so hitting the monitor literally does nothing. Replace the "nop" with an instruction to set your new flag.

    Basically, this all just makes the S monitor set a flag, which enables the giant ring, and has that flag cleared when a level starts or is reset.
     
    Last edited: Jun 28, 2020
  15. FruitcakeDog

    FruitcakeDog Newcomer Member

    Joined:
    May 28, 2020
    Messages:
    14
    Location:
    United Kingdom
    Hope I’m not interrupting anything here.

    There’s a project I’m working on where I wish to replace Sonic’s vanilla sprites in Sonic 1 with the ones used in Sonic 2 Beta. However, the walking, looking up and crouching animations have more frames in S2 Beta than they do in S1. Is there a way to port over the full animations for these sprites without potentially messing up any of the other sprites?

    I’ll be using Flex 2 to pull this off and am not intending to use any sprites left unused in OG Sonic 1, meaning they could possibly be used for any extra graphic data.
     
  16. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    861
    Location:
    Portland, Maine
    You shouldn't have any issues as long as you edit _anim/Sonic.asm to correspond with the new sprites. In that file, the first byte of every animation is the speed. $FF at the end of an animation restarts the animation. $FE, $xx will go back $xx frames in the animation. ($FF, $01 would be if you want to stay on the last frame). $FD, $xx will jump to animation $xx.

    Sonic's walking animation will be 12 frames instead of 6, so you will have to edit the code which makes Sonic use his rotated frames because they will now be 12 frames apart instead of 6. You also need to speed up Sonic's walking animation to account for the extra frames. To do this, replace everything from loc_13A9C to the rts with the corresponding code from Sonic 2 Beta.
    Code:
    loc_13A9C:
            lea     (SonAni_Run), a1
            cmpi.w  #$600,d2
            bcc.s   @angle
            lea     (SonAni_Walk), a1
    
        @angle:
            move.b  d0,d1
            lsr.b   #$1,d1
            add.b   d1,d0
            add.b   d0,d0
            add.b   d0,d0
            move.b  d0,d3
            neg.w   d2
            addi.w  #$800,d2
            bpl.s   @speed
            moveq    #0,d2
    
        @speed:
            lsr.w   #$8,d2
            lsr.w   #$1,d2
            move.b  d2, $1E(a0)
            bsr     SAnim_Do2
            add.b   d3, $1A(a0)
            rts    
    Note: Sonic 2 Beta spaces the running frames for each angle 12 frames apart despite the animation being only 4 frames long. If you plan on cutting out those frames, you should move the @angle label to between the two "add.b d0,d0" lines.

    Finally, if you are importing each sprite using Flex 2, I recommend instead just copying the art, mappings, dynamic pattern load cues files from the Sonic 2 Wai Beta disassembly. You'll have to convert the mappings and DPLCs from Sonic 2's format to Sonic 1's first. You can also grab the disassembly's equivalent of _anim/Sonic.asm, which goes under the label "Sonic_AnimateData".
     
    Last edited: Jun 29, 2020
    Geeovanni and FruitcakeDog like this.
  17. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    94
    Location:
    Italy
    Hello!
    I managed to put infinite lives to sonic but I don't know how to create a flag.
    I know what they are but I can't understand how to properly declare them.
     
  18. ralakimus

    ralakimus pretty much a dead account Member

    Joined:
    Aug 26, 2013
    Messages:
    1,069
    Find a free byte of RAM to use. You can use this to help find one. Take a look at Variables.asm to see how RAM addresses are assigned names in your disassembly.
     
  19. FruitcakeDog

    FruitcakeDog Newcomer Member

    Joined:
    May 28, 2020
    Messages:
    14
    Location:
    United Kingdom
    Just went looking through the disassembly files and whilst I couldn’t find a file called ‘Sonic_AnimateData’ I did find a label for it in ‘obj01_Sonic’. Is this the right one? If so, how do I port it over?
     
  20. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    861
    Location:
    Portland, Maine
    The label for it is what I was referring to. To port it over, replace what's in the file "_anim/Sonic.asm" with the data underneath the label "Sonic_AnimateData". Then, use your text editor to replace the phrase "Sonic_Animate" with "SonicAni". You'll also have to remove "s1" from "s1lzslide" and "s1lzhang". The order of the table is consistent between Sonic 1 and Sonic 2 Beta. The only parts that have changed are ones that were unused in Sonic 1 such as the warp animations.
     
    FruitcakeDog likes this.