Basic Questions and Answers Thread

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

  1. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    85
    Location:
    Italy
    It works, thank you!
    It's the first time I've been programming a ROM,
    so at first I will make many stupid mistakes XD
     
  2. Elijah Rosado

    Elijah Rosado Newcomer Trialist

    Joined:
    Feb 8, 2019
    Messages:
    1
    I hope I'm not interrupting, but I have one question: How do I port Sonic 3's end-of-level score tally in Sonic 1?
    I'm using HiveBrain's 2005 ASM68K Disassembly, Retro Graphics Toolkit, SonMapEd, and ConTEXT Programmers Editor on Windows 10.

    Here is an example of Sonic 3's score tally.

    [​IMG]
     
    Last edited: Jun 1, 2020
  3. FruitcakeDog

    FruitcakeDog Newcomer Member

    Joined:
    May 28, 2020
    Messages:
    10
    Location:
    United Kingdom
    Heya!
    This might seem like a dumb question to the more experienced hackers out there but how exactly do you go about adding custom music to Sonic 2? I’ve searched all over the web only to find nothing specifically for S2. I’m thinking of a somewhat simple-ish method similar to using mid2smps to port songs over to Sonic 1, unless it’s more complex than that.

    (Also worth noting this is my first time replying to this thread, so if I’ve screwed anything up let me know)
     
  4. Kurk

    Kurk Le crétin Member

    Joined:
    Jul 30, 2016
    Messages:
    64
    Location:
    Ikea office chair
  5. FruitcakeDog

    FruitcakeDog Newcomer Member

    Joined:
    May 28, 2020
    Messages:
    10
    Location:
    United Kingdom
    I’ll be sure to give this method a go. Thanks for responding so quickly!
     
  6. FruitcakeDog

    FruitcakeDog Newcomer Member

    Joined:
    May 28, 2020
    Messages:
    10
    Location:
    United Kingdom
    @Kurk I’ve just tried using the version of smps2asm you’ve linked and all it did was open a batch file for a millisecond before immediately closing. (I also put the Green Hill Zone bin file from the GitHub disassembly in the same folder as the program)
     
  7. Kurk

    Kurk Le crétin Member

    Joined:
    Jul 30, 2016
    Messages:
    64
    Location:
    Ikea office chair
    @FruitcakeDog You either need to run the command line or made a batch file to convert with smps2asm. Here's the layout of the batch file I use when converting with it:
    Code:
    smps2asm.exe -v 1 "blah.bin" "blah.asm" music
    The "-v #" signifies the version of the driver used. v1 is Sonic 1, v2 is Sonic 2, and v3-5 are Sonic3/K/3D. Hope this helps!
     
    ProjectFM likes this.
  8. FruitcakeDog

    FruitcakeDog Newcomer Member

    Joined:
    May 28, 2020
    Messages:
    10
    Location:
    United Kingdom
    It works perfectly now. Thanks a ton! :D
     
    Fadhil2314 and Kurk like this.
  9. John Belotti

    John Belotti Newcomer Member

    Joined:
    Mar 14, 2017
    Messages:
    13
    Location:
    Rochester Hills, MI
    How can a Genesis rom be engineered to work on Sega CD much like the Sonic 1 CD Remake from a long time ago? My project has interest of being ported to Sega CD, and I'm not quite sure how this can be done. Thanks in advance!
     
  10. death rapunzel

    death rapunzel i don't care anymore Member

    Joined:
    Aug 26, 2013
    Messages:
    1,062
    Location:
    Hell
    The Sega CD adds an extra CPU, a CD drive, an 8 channel PCM chip, a graphics manipulation chip, 256 KB of RAM that is used by both CPUs (Word RAM), 512 KB of RAM just used by the CD's CPU (PRG RAM), and Backup RAM (for save files). Only the Sega CD has direct access to this extra hardware besides Word RAM (even then, depending on the mode, either only 1 CPU can access it at one time, or it's split into 2 parts with each part going to a CPU) (another note is that the Genesis CPU can access a small window of PRG RAM by stopping the CD CPU and using its bus) It also cannot directly accese the Genesis hardware. The 2 CPUs can communication with each other using some communication registers.

    It also has 2 boot modes: Mode 1 (boot from cartridge), and Mode 2 (boot from BIOS). I will go into detail on how Mode 2 works, since that's what you're wanting to go for.

    The game disc image is laid out into 4 different sections: the header that holds information about the game and also a few extra tidbits of technical information, the initial program (small boot up code for the Genesis CPU), the sub program (main program for the CD CPU), and the filesystem.
    • The header will hold things like the disc type, game name, and information also seen in a Genesis header, and also the size and locations of the initial program and CD CPU program on the disc.
    • The initial program will hold the security code and the small tidbit of code made to set up the Genesis CPU for playing the game. This gets loaded at the start of Genesis RAM by the BIOS and executed there.
    • The sub program is just the main program code for the CD CPU. This is loaded at address $6000 in PRG RAM.
    • The filesystem is just the list of all the files and all of the file data. Typically in ISO-9660 format.
    Typically, the sub program would be set up to load data from the disc and interface with the CD hardware. On boot up, after the security code is run, in the initial program, it would wait for the CD CPU to get ready, and then tell the CD CPU to load the startup program code for it, and then jump to it.

    Overall, the process of running a Sega CD game typically just involves having file code loaded into RAM for it to run, and having the CD CPU handle working with the extra CD hardware, and have the 2 CPUs communicate with each other when needed. It doesn't always have to end up being this way, but it's the standard approach.

    For all the nitty gritty stuff, you should go check out some documentation for the Sega CD hardware and some example source code. All in all, the process of setting up a Sega CD game on disc is very different from a standard cartridge game. There IS always mode 1, though, and if you're interested, I can give an overview of that as well.

    In my personal opinion, though, if you're just wanting to use CD audio for the music, then either just use mode 1 or actually sit down and learn how something like SMPS works or get someone to help you out with that. It's not worth the hassle of setting up a disc game just for CD audio and not even utilizing the other hardware. And even then, unless you NEED ~700 MB to hold data, I would just stick to mode 1. Your choice, though.
     
    Last edited: Jun 2, 2020
    AkumaYin, ProjectFM and MarkeyJester like this.
  11. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    845
    Location:
    Portland, Maine
    I've been having a minor issue that I've spent a couple hours trying to fix when trying to work with Sonic 3K's HINT3 routine in Sonic 1. The following lines of code are in place so that the CRAM isn't written to when the water's surface is offscreen. (d1 is how many scanlines are switching the CRAM).
    Code:
            move.b    ($FFFFF625).w,d0
            subi.b    #200,d0    ; is H-int occuring below line 200?
            bcs.s    @transferColors    ; if it is, branch
            sub.b    d0,d1
            bcs.s    @skipTransfer
    When put in Sonic 1, when the water's surface goes offscreen while underwater, the entire screen uses the normal palette for a frame instead of the underwater palette.I've been trying to figure out the differences in the way Sonic 3K and Sonic 1 handle the water palette stuff, such as how Sonic 3K sets the H-INT counter to $FF by default while Sonic 1 set it to $DF, but no differences I've found are responsible for it using the normal palette for a frame. I'm starting to suspect it may have to do with more complicated stuff regarding timing.

    On a related note, is it necessary that CRAM isn't written to while the water's surface is offscreen? For HCZ, Sonic 3K uses the exact same routine as Sonic 1 does for switching the palette, and that doesn't stop switching the CRAM. The difference is that HINT3 works on multiple scanlines per frame instead of just one, so the artifacts it puts on the bottom of the screen when the water's surface is offscreen is taller.
     
  12. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    85
    Location:
    Italy
    Hello SSRG members!
    I'm here for a basic question, how do I change the order of the levels in sonic 1 (GitHub)?
    For what I have searched the order of the levels are in the file Level Order.bin (or lvl_ord.bin),but I haven't found it in my disassembly!
     
  13. Inferno

    Inferno Rom Hacker Member

    Joined:
    Oct 27, 2015
    Messages:
    31
    Location:
    Hidden Palace Zone, Westside Island
    In "3A Got Through Card.asm", look for LevelOrder: The level order is in ASM format in GitHub.
     
  14. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    85
    Location:
    Italy
    Thanks for your help, Inferno:D
    Now the problem is that I can't understand how to put the order of the levels.
    I did some experiments, but I'm not making the code work.
    Original code:
    Code:
    LevelOrder:
            ; Green Hill Zone
            dc.b id_GHZ, 1    ; Act 1
            dc.b id_GHZ, 2    ; Act 2
            dc.b id_MZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Labyrinth Zone
            dc.b id_LZ, 1    ; Act 1
            dc.b id_LZ, 2    ; Act 2
            dc.b id_SLZ, 0    ; Act 3
            dc.b id_SBZ, 2    ; Scrap Brain Zone Act 3
    
            ; Marble Zone
            dc.b id_MZ, 1    ; Act 1
            dc.b id_MZ, 2    ; Act 2
            dc.b id_SYZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Star Light Zone
            dc.b id_SLZ, 1    ; Act 1
            dc.b id_SLZ, 2    ; Act 2
            dc.b id_SBZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Spring Yard Zone
            dc.b id_SYZ, 1    ; Act 1
            dc.b id_SYZ, 2    ; Act 2
            dc.b id_LZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Scrap Brain Zone
            dc.b id_SBZ, 1    ; Act 1
            dc.b id_LZ, 3    ; Act 2
            dc.b 0, 0    ; Final Zone
            dc.b 0, 0
            even
            zonewarning LevelOrder,8
    
    My code:
    Code:
    LevelOrder:
            ; Green Hill Zone
            dc.b id_GHZ, 1    ; Act 1
            dc.b id_GHZ, 2    ; Act 2
            dc.b id_MZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Star Light Zone
            dc.b id_SLZ, 1    ; Act 1
            dc.b id_SLZ, 2    ; Act 2
            dc.b id_SBZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Spring Yard Zone
            dc.b id_SYZ, 1    ; Act 1
            dc.b id_SYZ, 2    ; Act 2
            dc.b id_LZ, 0    ; Act 3
            dc.b 0, 0
    
    
            ; Marble Zone
            dc.b id_MZ, 1    ; Act 1
            dc.b id_MZ, 2    ; Act 2
            dc.b id_SYZ, 0    ; Act 3
            dc.b 0, 0
    
            ; Scrap Brain Zone
            dc.b id_SBZ, 1    ; Act 1
            dc.b id_LZ, 3    ; Act 2
            dc.b 0, 0    ; Final Zone
            dc.b 0, 0
    
            ; Labyrinth Zone
            dc.b id_LZ, 1    ; Act 1
            dc.b id_LZ, 2    ; Act 2
            dc.b id_SLZ, 0    ; Act 3
            dc.b id_SBZ, 2    ; Scrap Brain Zone Act 3
            even
            zonewarning LevelOrder,8
    I left Labyrinth Zone last, because I want it to be a bonus level.
     
  15. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,853
    You are confusing the list's order, and the data's order.

    The list's order must ALWAYS be arranged such that it's; GHZ 1-4, LZ 1-4, MZ 1-4, SLZ 1-4, SYZ 1-4, SBZ 1-4, and you must NEVER change this structure.

    In order to change the level order, you change the data, not the list. For example, you want it to go from GHZ 3 to SLZ 1, you change the third line of Green Hill Zone's from:

    Code:
    	; Green Hill Zone
    	dc.b id_GHZ, 1	; Act 1
    	dc.b id_GHZ, 2	; Act 2
    	dc.b id_MZ, 0	; Act 3
    	dc.b 0, 0
    To:

    Code:
    	; Green Hill Zone
    	dc.b id_GHZ, 1	; Act 1
    	dc.b id_GHZ, 2	; Act 2
    	dc.b id_SLZ, 0	; Act 3
    	dc.b 0, 0
    After GHZ 3, the level will be SLZ 1, and it will read from SLZ 1's slot in the list once you've completed that level, but SLZ's list itself MUST be after MZ and before SYZ. Remember, it's not the list itself, it's the data. The byte on the left is the Zone ID to run next, and the byte on the right is the Act number to run next.

    Here is "probably" what you'd want (based on your above attempt), though I couldn't quite work out want you wanted to do with SBZ 3:

    Code:
    LevelOrder:
    	; Green Hill Zone
    	dc.b id_GHZ, 1	; Act 1
    	dc.b id_GHZ, 2	; Act 2
    	dc.b id_SLZ, 0	; Act 3
    	dc.b 0, 0
    
    	; Labyrinth Zone
    	dc.b id_LZ, 1	; Act 1
    	dc.b id_LZ, 2	; Act 2
    	dc.b 0, 0	; Act 3
    	dc.b id_SBZ, 2	; Scrap Brain Zone Act 3
    
    	; Marble Zone
    	dc.b id_MZ, 1	; Act 1
    	dc.b id_MZ, 2	; Act 2
    	dc.b id_SBZ, 0	; Act 3
    	dc.b 0, 0
    
    	; Star Light Zone
    	dc.b id_SLZ, 1	; Act 1
    	dc.b id_SLZ, 2	; Act 2
    	dc.b id_SYZ, 0	; Act 3
    	dc.b 0, 0
    
    	; Spring Yard Zone
    	dc.b id_SYZ, 1	; Act 1
    	dc.b id_SYZ, 2	; Act 2
    	dc.b id_MZ, 0	; Act 3
    	dc.b 0, 0
    
    	; Scrap Brain Zone
    	dc.b id_SBZ, 1	; Act 1
    	dc.b id_LZ, 3	; Act 2
    	dc.b id_LZ, 0	; Final Zone
    	dc.b 0, 0
    	even
    	zonewarning LevelOrder,8
     
    Last edited: Jun 11, 2020
    Inferno, ProjectFM and Angel X like this.
  16. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    85
    Location:
    Italy
    Thanks my hero!
    This was exactly what I wanted:D
    With this very useful information, I thought I would make a guide how to change the order of the levels in sonic 1 github disassembly (since it is not explained anywhere).
    Obviously I will quote you and Inferno;)
    One last question, and if I want to change the start zone?
    For example:
    1-MZ;
    2-GHZ;
    3-SYZ;
    4-ecc...
    I hope I have not made you exasperate with my many questions:confused:
     
    Last edited: Jun 11, 2020
  17. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    845
    Location:
    Portland, Maine
    At "Tit_ChkLevSel", right after the label, add:
    Code:
            move.b    #id_MZ,(v_zone).w
    or
    Code:
            move.w    #(id_MZ<<8)+0,(v_zone).w
    where the zero is the act number.
     
    Angel X, Inferno and MarkeyJester like this.
  18. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    393
    Location:
    Town Creek, AL
    Question.
    https://youtu.be/mjoUw1LY7G8
    I've made the level select in Sonic 1 into an option screen and separated the two successfully.
    However, with the character change (get into that problem later)
    0 = Sonic
    1 = Sonic 2 Sonic
    I recently added in Sonic 2 Sonic, but you see the problem at the end of the video. What could be causing this? I checked every Art/PLC, Map, and animations code, haven't found a problem.
    Hivebrain with the queueDMATransfer with spindash added being used.
    Edit: I should add it shows correctly on SonMapEd
     
  19. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    389
    Location:
    Russia
  20. Angel X

    Angel X Well-Known Member Member

    Joined:
    Sep 15, 2017
    Messages:
    85
    Location:
    Italy
    Thanks for the support!
    I will certainly experiment with these codes and if I can fully understand how it works I will give a guide as soon as possible:D