Basic Questions and Answers Thread

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

  1. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    smpsplay.exe outputs v1.60 VGM files, as you said, and support for those is generally lacking. I think the hardware replayer needs v1.50 files, if not v1.10, even. Downgrading from v1.50 to v1.10 is easy, but v1.60 is an entirely different matter. I'm surprised that you say that other v1.60 files are working in the other programs.

    As for the drag and drop issue, no clue, and I can't check it now.
     
  2. breakthetargets

    breakthetargets Well-Known Member Member

    Joined:
    Aug 6, 2009
    Messages:
    180
    I see. So in this case, is there an older version of SMPSPlay that logs v1.50/v1.51 instead of v1.60? If not, then it's fine. Well to be fair, I only tested one v1.60 VGM file (should have checked more than one..., but I checked that it was v1.60 in VGMTool), and it was the VGM Crash provided from his SMPS cover of the Jurassic Park (GB) - Level 1. I'll ask the creator of the builders about support for V1.60 VGMs.
     
  3. ValleyBell

    ValleyBell Well-Known Member Member

    Joined:
    Dec 23, 2011
    Messages:
    166
    I'd probably use the SMPSPlay -> VGM -> WAV -> MP3 way.
    SMPSPlay itself can log WAV files, but if you enable WAV logging, it just creates one huge WAV that contains everything you do until you close the program. (And I think the sound quality is slightly better in VGMPlay. And it has more options regarding volume control and looping/fading.)

    I think I know that the problem could be. Your VGM has the DAC samples "compressed" as 4-bit DPCM (commonly used by SMPS games), which the hardware VGM player doesn't support. Crash's VGM uses raw 8-bit PCM instead.
    You can enforce raw PCM by editing the CompressVGM line in SMPSPlay/config.ini.
    (Compressed samples should be supported by all "software" VGM players that support VGM 1.60, btw.)
    I often had problems with dropping VGMs on VGMTool.exe (though for some reason, it worked as I tried it just now). I always open the tool first and then drag the VGM into the window.
    Also, I still use r5, because r6 has trouble with Unicode and replaces non-ANSI characters with question marks. (i.e. it destroys most Japanese VGM tags)

    EDIT: And no, SMPSPlay never logged VGM 1.50. It always used the "Play Sample" commands of v1.60, because those are way nicer to use than recording the DAC stream sample-by-sample.
     
    breakthetargets likes this.
  4. breakthetargets

    breakthetargets Well-Known Member Member

    Joined:
    Aug 6, 2009
    Messages:
    180
    @ValleyBell Thank you so much! It was the DPCM samples indeed. I was able to fix it with your dpcmtopcm tool. Also thanks for the heads up about the Unicode and non-ANSI character issues with r6.
     
  5. ValleyBell

    ValleyBell Well-Known Member Member

    Joined:
    Dec 23, 2011
    Messages:
    166
    I'm not sure if you got that right, but with "enforce raw PCM" I meant that SMPSPlay writes uncompressed PCM samples into the VGM even if DAC.ini points to DPCM samples. (so there is no need for dpcm2pcm)
     
  6. breakthetargets

    breakthetargets Well-Known Member Member

    Joined:
    Aug 6, 2009
    Messages:
    180
    I actually did edit that earlier to 0x00 from 0x01 expecting it would have fixed my issue back then with the DPCM samples, and that didn't work. I'm guessing that 0x00 is what it should be to "enforce raw PCM". If it isn't 0x00 then please correct me with what it should have been for future cases.
     
    Last edited: Aug 18, 2016
  7. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Hello.

    After trying to resolve my issue, i'm lost again.
    here:

    This is my problem and the illegal error screen.
    I have doing this http://info.sonicretro.org/SCHG_How-to:Add_a_new_zone_in_Sonic_1
    And then, import Frozen Island.

    I have removed all the objects to solve the illegal error, and then today i have started to edit the entire level but it's the same.

    As you can see, music doesn''t play (but i don't give a f*ck).

    So again, please someone have an idea :(?
    I have noticed that this error happens only when i'm killing two badniks (or more) at the same time.

    So i think the error comes when the object animal is loaded and then, the error comes from here:

    Code:
    ; ---------------------------------------------------------------------------
    ; Subroutine to load the art for the animals for the current zone
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    
    LoadAnimalPLC:
            moveq    #0,d0
            move.b    ($FFFFFE10).w,d0
            cmpi.w    #7,d0
            bhs.s    LoadAnimalPLC_New
            addi.w    #$15,d0
            bra.s    LoadPLC
    ; ---------------------------------------------------------------------------
    
    LoadAnimalPLC_New:
            subi.w    #7,d0
            ; multiply d0 by 3
            move.w    d0,d1
            add.w    d0,d0
            add.w    d1,d0
            ; add $22 (this is the index of the animal PLC for the first added zone)
            addi.w    #$22,d0
            ; bra.s    LoadPLC
    ; End of function LoadAnimalPLC
    From the new zone tutorial.
     
    Last edited: Aug 19, 2016
  8. TheStoneBanana

    TheStoneBanana banana Member

    Joined:
    Nov 27, 2013
    Messages:
    602
    Location:
    The Milky Way Galaxy
    In the listings file, check what is at location $CC02.
    The object loader itself uses a1 to calculate and jump to an object's code, and as you can see on the error screen, a1 contained $CC02 at the time of crash. It's possible that a1 was overwritten in the object, but I still think it's worth a shot to see what object is causing this.
     
    vladikcomper likes this.
  9. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    CC02: putain.png

    Like i think, this is the animal object that cause the error.
    I don't know how to fix it :(
     
  10. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    Your conclusion is correct: an invalid routine executed in Obj28 causes the game to behave abnormally, then crash.

    Thing is, the object's code initially attempts to load different animal depending on the current zone and a random number (0 or 1):
    Code:
    Obj28_FromEnemy:                        ; XREF: Obj28_Ending
                    addq.b  #2,$24(a0)
                    bsr.w   RandomNumber            ; d0 = random (0 .. $FFFFFFFF)
                    andi.w  #1,d0                   ; d0 = random (0 .. 1)
                    moveq   #0,d1
                    move.b  ($FFFFFE10).w,d1        ; d1 = ZoneId
                    add.w   d1,d1                   ; d1 = ZoneId*2
                    add.w   d0,d1                   ; d1 = ZoneId*2 + random (0 .. 1)
                    lea     Obj28_VarIndex(pc),a1   ; a1 -> Obj28_VarIndex
                    move.b  (a1,d1.w),d0            ; d0 = byte from (Obj28_VarIndex + ZoneId*2 + random (0 .. 1))
                    move.b  d0,$30(a0)              ; save to $30
    The value of byte $30(a0) is later converted to the object's routine counter $24(a0), once animal has hit the floor (as it's meant behave differently only afterwards).

    So, the bytes listed in the Obj28_VarIndex essentially tell what object's routine to use; there are 2 bytes per zone that are stored contiguously as the code suggests, just one of them is being picked based on a random number. If the list is not appended for the new zone, this may cause unwanted bytes to be passed as animal types when in this very zone, leading to what I may call undefined behavior (which stands for unstable game, glitches, that often end up with apparent crashes).

    I strongly recommend that you append Obj28_VarIndex with at least 4 bytes, in case your zone number is $07. This list seems to end strictly before zone $06, which is Ending sequence, meaning you need to place 2 dummy bytes to make up for zone $06 and, eventually, another 2 bytes for your new zone. You may copy any pair of already listed bytes if you're not sure which animal types to go with.
     
    TheInvisibleSun and Pacca like this.
  11. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Originally, i have this:
    Code:
    Obj28_VarIndex:    dc.b 0,    5, 2, 3, 6, 3, 4, 5, 4, 1, 0, 1
    And i have added 2 bytes for the ending and 2 for my new zone, and i have this:
    Code:
    Obj28_VarIndex:    dc.b 0,    5, 2, 3, 6, 3, 4, 5, 4, 1, 0, 1, 0, 5, 0, 5
    In the case, the green hill's bytes (i think), i will test it!
    Thank you Vlad!

    Apparantly, the bug is solved, so thank you again!
     
    Last edited: Aug 19, 2016
  12. TheDarkLordofCookies

    TheDarkLordofCookies Newcomer Trialist

    Joined:
    Aug 19, 2016
    Messages:
    2
    First of all, this will probably sound like an incredibly noob-ish question, but I have only started learning how to rom hack very recently.
    I'm using sonEd2, and experimenting with editing layouts and adding objects. As a test, I tried adding the spike balls from Spring Yard Zone, and the burrobots from Labyrinth Zone to Green Hill Zone. However, when I test the hacked rom, the spike balls and burrobots display as garbled sprites. So, two questions:

    Is this caused because Green Hill doesn't contain sprite data for those two objects?
    And of course, how do I fix this?
     
  13. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    The graphics for the game are displayed by loading them into a 10000 byte video memory space (known as VRAM), this limited space is enough to store most graphics for a single level, but not enough to store graphics for all levels and events of the game.

    New graphics depending on the level, screen, or event are loaded into VRAM (effectively swapping art around depending on need). Green Hill Zone has level graphics for that zone, and any graphics for sprites used in that zone. Since the Burrobot isn't normally used in that level, it's graphics are therefore not loaded to VRAM for that zone.

    Sonic 1 has a system known as the "Pattern Load Cues" system (PLC for short), this system will read lists of compressed graphics locations, followed by the VRAM address to decompress and dump graphics to, and process them as such. You can edit this list to load new sprite art if necessary, though be warned, you have a limited amount of VRAM, and therefore you might have to get rid of "something" already in Green Hill Zone, to make way for your burrobot and spike balls.

    I don't know which disassembly version you are using, so I cannot provide examples at the moment.

    You'll also need to consider the palette of colours being used, luckily, I think the burrobot and spike balls used colours that Sonic uses, so you should be able to get away with that.
     
  14. TheStoneBanana

    TheStoneBanana banana Member

    Joined:
    Nov 27, 2013
    Messages:
    602
    Location:
    The Milky Way Galaxy
    Hello!
    Considering it's your very first post, and you even said yourself that you only started to learn how to ROM hack very recently... I think a "noob-ish" question, as you call it, is appropriate. How else will you learn?

    To answer your question--
    The reason that the sprites appear garbled is because... well, they aren't even really loaded. There is a system within the game known as "Pattern Load Cues", where certain art is loaded into VRAM at certain times (kind of a bad description, but you'll see what I mean).There are badniks that are only used in one zone, so therefore, their art is only loaded for that zone in said zone's PLCs.

    If you're using the Hivebrain disassembly, go to '_inc/Pattern load cues.asm' and open it up. Scrolling through, you'll see an index at the beginning of all of the PLC entries, and then below the index are the PLC entries themselves. You'll see that in GHZ, the Burrobots (Nem_Burrobot) and Spikeballs (Nem_SyzSpike1 and Nem_SyzSpike2) are not loaded.

    So... what do you do?
    Well, you're going to need to make room within GHZ's PLCs to load the art. Considering the object is looking for art at a certain location, that location is where art is going to need to be replaced. For example, the Burrobot is loaded at location $94C0, and in GHZ, the Newtron is loaded at $9360 (and its art overlaps to $94C0) So... there you might need to make a compromise.
    That, or you could mess with the object itself to use art at different locations in VRAM based on the zone, but since you're just starting out, I wouldn't recommend that.

    EDIT: MAAAAARKEY NOOOOO.
    Ah well. Another explanation doesn't hurt, I suppose.
     
    Pacca likes this.
  15. TheDarkLordofCookies

    TheDarkLordofCookies Newcomer Trialist

    Joined:
    Aug 19, 2016
    Messages:
    2
    Thanks a lot for the explanation! I replaced the Nem_Newtron with Nem_Burrobot, however, now the burrobot uses garbled burrobot sprites, it still doesn't display them properly.

    EDIT: Nevermind, it worked after I changed $9360 to $94C0. Thanks a lot for the help, guys!
     
  16. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Just a simple question: Is it possible to make Sonic run onto water like in Sonic 3's hydrocity?

    If i'm able to edit the water surface collision?
     
  17. NiphFM

    NiphFM Host of the Mega Drive Music Contest Member

    Joined:
    Jun 5, 2015
    Messages:
    430
    Location:
    Music Plant Zone
    It would be, after all, all you'd have to do it set a check to see if Sonic's running fast enough and if he is, set the water ripples to solid (I think, don't count on this). I don't code, but if you think about how it works, you can kinda understand how it could put together.
     
  18. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Ok, let's go!

    Thanks!
     
  19. StephenUK

    StephenUK Working on a Quackshot disassembly Member

    Joined:
    Aug 5, 2007
    Messages:
    1,026
    Having done this in the past, there are a few steps involved. First of all, you need to disable the water movement effect (the up and down motion) as this will play hell with the code. Once you have disabled that, you need to run a check to test the position of the bottom of Sonic's running sprite against the current water height. If they match, check his speed. If that is high enough, set a custom flag for water running (so you can skip over the initial checking code while maintaining the run), clear Sonic's Y speed and fix his Y position, which you should have stored at the start of the routine. I have the code in front of me, and that's a very basic outline. I was thinking of sharing the code outright, but the problem there is that people don't learn and it'll be in every hack.
     
  20. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    No it's ok, don't share it, i will try to find by my own way (i hope :( )

    Disable the water movement effect is the most difficult part of the method?

    Also, thanks!

    EDIT: For now i have a little problem, i have added water to another zone and the palette used underwater is the sonic's palette line. Why?