Basic Questions and Answers Thread

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

  1. GenesisDoes

    GenesisDoes What Nintendont Member

    Joined:
    Jan 2, 2016
    Messages:
    159
    Location:
    Pittsburgh, PA
    In Sonic 1, how would I go about copying a single palette line from a secondary palette file into a particular palette line in CRAM, instead of the whole file? Basically, I want to copy the first palette line from the level palette's file (usually reserved for enemies, rings, yellow springs, etc) into CRAM's 2nd palette line, while keeping everything else intact. I don't think any of the PalLoad# routines in Sonic.asm can copy only a single palette line, just the whole file.
     

    Attached Files:

  2. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    PalLoad1 is for loading a palette for the fading routines, PalLoad2 is for direct loading.

    To do what you ask, all you have to do is a new entry in the Palette Pointers, with different settings. For instance, a setup like that would require copying your level palette's definition, using however the same length as Sonic's palette.

    EDIT: Looking page 219, I realized that I forgot to reply the last question from @D.A. Garden. Sorry for this!, my great excuse is that I became so busy that I have forgotten a lot of things, including this one.

    Anyways, the movement's code for subtype #4 is located at "Glass_Type04", and all you have to do is to divide the result got from copying (v_oscillate+$12).w to d0. A faster and CPU-friendly way to do it is through arithmetically bit shifting to the right, with "asr". Or just redirect to "Glass_Type00" if no movement is necessary.
     
    Last edited: Nov 16, 2016
  3. Stardust3033

    Stardust3033 Newcomer Trialist

    Joined:
    Oct 30, 2016
    Messages:
    5
    I know this is a dump question, but how do you add/make custom level chunks into Sonic 1. Like custom backgrounds and and that stuff. I looked everywhere and I can't seem to find the answer. Thank you.
     
  4. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    It's not a dump but a dumb basic question =P. Assuming you have a disassembly and know what project files refer to, on the level editors SonED2 and SonLVL it's pretty much straightforward. If you're going for more ambitious edits, and if this method happen to be easier for you, you can take a look at this: http://info.sonicretro.org/SCHG_How-to:Import_art_to_SonED2
    Or just import any kind of image within SonLVL and then arrange your tileset's memory usage. Always deleting your unused data and such, memory is very valuable at this point.
     
  5. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Sonic 1's levels can go up to 80 chunks, of which the first chunk (ID 00) is automatically NULL/Blank, and uneditable. However, these chunks are stored compressed on the ROM, which means they need to be unpacked into 68k RAM. The reserved space for chunks in Sonic 1 is A400 bytes, this gives you 51 editable chunks (IDs from 01 to 52).

    Sonic 1's levels often have all 51 chunks used in some form or another, so you will not be able to add new chunks for editing, you'll have to edit one of the pre-existing chunks to get what you want, however, some of the levels do have "unused" chunks which you can modify and use freely, without breaking the existing layouts.

    An alternative of course, is to have the chunks uncompressed and stored in the ROM and read from there, this will allow you to add/make extra chunks after 51, you'll have 2E extra chunks, this comes at the cost of a slightly larger ROM, and will require modifications to the level drawing/collision reading routines.
     
    FireRat likes this.
  6. Stardust3033

    Stardust3033 Newcomer Trialist

    Joined:
    Oct 30, 2016
    Messages:
    5
    Alright, thank you. I'll give it a shot!
     
  7. VioletVulpine

    VioletVulpine Newcomer Trialist

    Joined:
    Nov 16, 2016
    Messages:
    8
    Location:
    Ireland
    I'm a beginning hacker, I know the basics of ASM (not 68k though, but it's similar enough that a read of MarkeyJester's guide helped a lot) from college.

    I've been stumped on this for a few days, I want to add a boss hit counter to Sonic 2, like the one in Robotnik's Plan B (which I know is Sonic 1, but I imagine it's possible in S2), Here's the gist, I can't post code at the minute because I'm not on my PC. I'm using the Git disassembly.

    I edited the Miles life icon (the one that shows up in the bottom left) to show Eggman's Face and say BOSS, and saved it just fine and imported it. It uses Nemesis compression just like the Miles one. As for mappings, it uses the exact same mappings as the Miles life counter. And this is where I get stumped: I know the life counter NUMBER is an uncompressed art, I also know that it loads in the HUD_Base/HUD_Lives routine, but I'm not sure where the portrait and name are loaded in. I know they're in the PLR lists though so I added my Eggman counter to PLC1, but I have no idea where to go from there. I accept this may be a bit beyond my capabilities at the moment. I understand that PLRs are basically a list that the decompressor goes through to turn them into sprites, but I'm not getting like where it's loaded into the game.

    I'm not necessarily looking for "this is how you do it" type help, more "how this works", if that makes sense. Thanks in advance.
     
  8. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    In order to make the sprites display onscreen, you need to create sprite mappings for it, and add code to BuildHUD to make the game display those sprites when you're in a boss fight (I'm assuming you don't want to have it displayed all the time). You'll also need to add code to HudUpdate to load in art for the hit counter numbers according to how many HP the boss has (look for the life counter updating for an example).
     
    VioletVulpine likes this.
  9. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    I am gonna simplify a bit here, but there's just a lot to explain. You can probably find other topics or earlier replies here for more info on the subject.

    The way PLC's work, is you specify the art files and VRAM offsets to load to, and then on the game code give an index to it. Then during the next frames the game will go through the list of the entries, always making sure to decompress a certain number of tiles and write these to the VDP, which in turn will then store this information in VRAM, and allow showing these graphics properly in the future.

    Whilst the HUD code will just check if there needs to be an update to the time, rings, score, lives, or bonus counters, will convert the value for the field to decimal, and either use large or small numbers based on the decimal value. It will write each digit art to the VRAM, to the location where the art is stored at. This makes it quite easy to insert just any numbers there, and with a little piece of value you can make it do it. On the downside, this is really slow and therefore it uses flags to determine if an update is needed. You can probably poke the lives counter code and use it to figure out how to do this hit counter. You will likely need to make sure to create a new flag and update it accordingly to keep track of the score and if update is necessary.

    tl;dr it is fairly trivial thing to do, but you need to wrap your head around the code for a bit.
     
    VioletVulpine likes this.
  10. VioletVulpine

    VioletVulpine Newcomer Trialist

    Joined:
    Nov 16, 2016
    Messages:
    8
    Location:
    Ireland
    Thank you very much! I'm slowly starting to get it, I'll update this post later if I get it working/if I don't forget. I really appreciate the help.

    EDIT: Yeah, I'm still not getting it, unfortunately. I think I'll leave this until I've learned a bit more about working with the VDP and with PLCs. I see that the game loads the Std1 and 2 PLRs first but I don't see how/where they get actually placed in the game.
     
    Last edited: Nov 23, 2016
  11. Gamma V

    Gamma V Well-Known Member Member

    Joined:
    Oct 4, 2016
    Messages:
    63
    Location:
    Jenks, Oklahoma, 'Murrica
    I hope this hasn't been asked before and that asking such a question won't get me into trouble, but what subtypes are the elevators that move up in Casino Night Zone? SonLVL doesn't seem to have them defined at all.
     
  12. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    It's the distance the elevator should travel divided by eight.
     
  13. Baraksha

    Baraksha Well-Known Member Member

    Joined:
    Dec 23, 2015
    Messages:
    99
    Hey, been a while since I used this thread, so I lately started with a mini project I have been working on lately. now for this hack I need some more tiles for the Title Cards Art (ttlcards.bin). the few ways I was suggested to do this is to use DPLC or to use a "chart" (not sure exactly what that means). now my main issue is, i'm still not that experienced to know how to do neither of this things and not sure how they work.
     
    Last edited: Dec 18, 2016
  14. Polaristar

    Polaristar Newcomer Trialist

    Joined:
    Dec 26, 2016
    Messages:
    7
    Location:
    United States
    Greetings everyone, I need some help on a certain thing with Sonic 2: I've been following this guide ( http://info.sonicretro.org/SCHG_How-to:Add_New_Monitors#Sonic_2_INCOMPLETE.21: )
    And as you can see, it's incomplete. I got everything down and under, I just need to fix the weirdness of the rings.
    (You can see them in this uncropped screenie I did, at the top right.)
    My ChangeRingFrame is unaltered.
    [​IMG]
    I think the new Monitor Icon is overwriting the ring VRAM or something like that, but I can't be sure.
     
    Last edited: Dec 26, 2016
  15. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    Whats wrong with them..? I can't really see anything off there. Though, I would suggest moving them at least 16px from the edge there, as older TV's may crop either or both sides of the image (mine for example does 8px on left, but has some overscan in right, bastard thing...)
     
  16. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    I think those things at the top right are meant to be rings...

    Edit: ANYWAY, to fix that, you'd need to remove tiles from the monitor tileset, or somehow find a new place in VRAM to fit the expanded tileset.
     
    Last edited: Dec 26, 2016
    Polaristar and FATA- like this.
  17. Polaristar

    Polaristar Newcomer Trialist

    Joined:
    Dec 26, 2016
    Messages:
    7
    Location:
    United States
    Yeah, I should've been more specific. Anyways, I'll give it a shot, and report back if I have trouble.
     
  18. FATA-

    FATA- cmpi.w #$FA1A,d0 Member

    Joined:
    Dec 18, 2016
    Messages:
    20
    Location:
    Russian Federation, Saint Petersburg
    Hello guys,so I have one (very) stupid question. Recently I've started learning how palettes are changing and continued learning asm68k (which I really hate). So I've tried this (I'm using Sonic 1 Hivebrain's 2005 disassembly):
    Code:
    Obj0D_Touch:           
            move.w    ($FFFFD008).w,d0
            sub.w    8(a0),d0
            bcs.s    locret_EBBA
            cmpi.w    #$20,d0        ; is Sonic within $20 pixels of    the signpost?
            bcc.s    locret_EBBA    ; if not, branch
            move.w    #$CF,d0
            jsr    (PlaySound).l    ; play signpost    sound
            clr.b    ($FFFFFE1E).w    ; stop time counter
            jsr Pal_FadeFrom.w ;+
            jsr Pal_FadeTo.w ;+
            move.w    ($FFFFF72A).w,($FFFFF728).w ; lock screen position
            addq.b    #2,$24(a0)
    locret_EBBA:
            rts    
    Lines with "+" are mine (yeah, too much of them). So basically I've tried to do a simple thing- when sonic touches signpost, screen goes black for a second and then returns to normal. It actually happens but screen doesn't return to normal, game freezes
    [​IMG]
    I've tried a lot of things to fix it but neither of my ideas worked. I hope somebody will help me with this because I think the solution is obvious but I'm too dumb and I don't have enough experience to see it.Thanks in advance.
     
    Last edited: Dec 27, 2016
  19. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    Well, it is actually something easy to not realize, but most palette functions use both a0 and d7, which is fine in every single situation, EXCEPT for when you are in object code. This is because objects use a0 for storing object pointer and d7 to store object count. So when these are overwritten, an issue will arise somewhere down the line and end up crashing the game...

    But it is very easy to fix, before calling either, just insert this line;
    movem.l d7/a0,-(sp)

    It will push these variables in stack temporarily. Then, to return these to normal, just insert this line;
    movem.l (sp)+,d7/a0

    Basically, it is just the inverse. It will pop those variables we stored earlier from stack to d7 and a0.
     
  20. B. Comet

    B. Comet Is fun still infinite? Member

    Joined:
    Aug 19, 2016
    Messages:
    83
    Location:
    South America Zone
    I think those are very basic questions...

    Is there a way to make the levels of Sonic 1 larger? Especially Marble Zone.

    And... Is possible to change the palettes of the Titles in SonLVL?
    [​IMG]
    Changing the sprites would be way more easy if I know how to do it.