Basic Questions and Answers Thread

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

  1. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    What's the number that corresponds to one tile?
     
  2. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    A single tile is $20 bytes, the third instruction there has $160, this is to transfer 22 tiles... 22 x $20 = $2C0 divide by 2 (size of word) = $160.

    You could if you wanted to, set the instruction up like this:
    Code:
        move.w    #($20*22)/2,d3 ; DMA transfer length
    You can then simply edit the 22 to be the number of tiles you actually want to transfer. The assembler will handle converting the ($20*22)/2 into the $160 before the actual assembling occurs.

    EDIT: correction due to Sonic Team's stupid inconsistency >=(
     
    Last edited: Dec 20, 2017
    nineko and Pacca like this.
  3. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    I swear I've seen info on this issue before, but I can't seem to find any now. My issue is that after adding a substantial amount of data into Sonic 2 (I think the problem was triggered after I added some uncompressed artwork), Sonics' sprites occasionally display corrupt looking garbage instead of his normal tiles:
    [​IMG]
    This only happens with a handful of sprites, and the corrupted tiles change whenever I add/remove data and recompile. I have not modified Sonics' art, mappings, or DPLCs, nor have I touched the code that manages them. I've seen others mention this happening in completely different hacks, and I'm pretty sure this used to affect my other hack for a time too. I just don't remember what the fix is, and I can't find any info on it anymore :(
     
  4. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    That's the 128KB DMA boundary bug. If a DMA transfer (including DPLC entries) crosses a 128KB boundary within the ROM, the transfer will wrap around to the start of the 128KB block, reading garbage data. To fix it, you can change the alignment on the art file, shuffle data around until it works, split the DPLC into two requests, or edit the DPLC processing code to detect and automatically split problematic entries.
     
    MarkeyJester and Pacca like this.
  5. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Exiled

    Joined:
    Oct 7, 2011
    Messages:
    759
    QueueDMATransfer routine takes in the number of words (and the number is put directly into VDP registers), not bytes. So, the number of tiles is actually 22 and calculation should be $10*22.
     
    MarkeyJester likes this.
  6. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Ahhhh, really?

    I would've expected them to keep it as bytes personally, they align the source correctly for you in the routine, and convert the destination into the long-word write for you, so why not the same with the size... that's just, really inconsistently annoying...

    (Editing initial post).
     
    Niko and AURORA☆FIELDS like this.
  7. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    416
    Location:
    Town Creek, AL
    Retrying my hand on hacking Sonic 2.
    I've added the Hidden Palace Zone, yet haven't yet added in any badniks yet, gonna wait on that. Where are the art load cues for HPZ located at (Xenowhirl's disassembly)
    and using PlaneEd I have added text for Hidden Palace, yet can't select it. what bit of code do I change to push down on Oil Ocean 2 to select Hidden Palace (which is below OOZ2) and push up on Metropolis Zone 1 to select Hidden Palace?
     
  8. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    The pointers for object art lists are under ArtLoadCues. Hidden Palace uses cues 20 and 21 (which by default are set to PLC_10, or Oil Ocean Zones' cues; You'll have to make a new list here to restore HPZ).

    As for modifying the level select, I don't know too much about it, but what I do know is the result of this excellent guide by Clownacy. If you're diligent enough to study how it works, you should be able to edit the level select however you wish.
     
  9. BurningFlame

    BurningFlame Bang! Member

    Joined:
    Jan 1, 2017
    Messages:
    40
    Location:
    Vodkaland
    What is the maximum number of level's tiles in Sonic 1? I want to make a new zone (sort of) but I can't do this until I'll know how much limited I'm with graphics.
     
  10. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    It depends on how many tiles are reserved for enemies and objects. It's safest to stick with around $300 tiles though you can go up to $400.
     
  11. Bluestreak

    Bluestreak Lady in red, living in dread. Member

    Joined:
    Apr 1, 2016
    Messages:
    227
    Location:
    Eastwatch Island
    Having troubles getting Sonic R to work on my PC (using Cheatfreak's updater). I tried to use it both on the PC version AND Sonic R Redux as well, but to no avail. I have a Windows 10 computer, so any help?
     
  12. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    I've been having some really strange issues with Crabmeats' mappings (the Sonic 1 enemy). I'm trying to convert the mappings to Sonic 2s' format, but doing so via SonMapEd causes the object using the mappings to crash in the BuildSprites routine seemingly at random. I decided to try using Flex instead, but that editor won't even load the Sonic 1 mappings; it renders garbage in the sprite viewing area, and then locks up the controls.

    What the heck is so weird about Crabmeats' mappings file, and how can I convert it properly?
     
  13. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    I also have a Windows 10 computer, and the only problem I've had is that it fails to render sometimes on my NVIDIA GPU. Other than that, make sure you have the MSVC 2017 x86 redist installed.
    MappingsConverter?
     
    Niko likes this.
  14. Bluestreak

    Bluestreak Lady in red, living in dread. Member

    Joined:
    Apr 1, 2016
    Messages:
    227
    Location:
    Eastwatch Island
    @MainMemory Alright. I shall. I am also having issues fixing the Divide By Zero error in Sonic R Redux sadly. I have been using IDA from Hex-Rays. If I jump to the offset in which I need to find, it takes me to a completely different one, with 100% different stuff, which is nothing like the values I need to change.
     
  15. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    That's because you're entering a file offset, but IDA uses RAM addresses normally. You could use the menu option to jump to a file offset, or just use a hex editor.
     
  16. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    Mappings Converter gives the same results. Strangely, giving the object a completely different set of mappings (that I also converted from S1) works just fine, even when it asks for invalid frames (it displays garbage, but it's a heck of a lot better then a game crash). I've also tried adding evens, and using ASM and Binary format, same results. I guess I'll just have to remake them from scratch then :confused:
     
  17. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    Oh. Looking at the file from the 2005 disassembly (which I assume you're using), I can see exactly why programs can't read it properly: it puts two offsets on each line. Presumably all the programs only support one offset on each line (this is definitely true of MappingsConverter). You can fix it by just splitting them up so each offset has its own dc.w line.
     
  18. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    I'm actually using the mappings file from the Github disassembly, which seems to have already fixed that problem. Here's a pastebin of output in asm form so you can check it out. I modified it slightly; all the @s' have been replaced by "map_crab_at_". I honestly don't think that would change very much though. For some reason, it won't compile if I leave them in.
     
  19. MainMemory

    MainMemory Well-Known Member Member

    Joined:
    Mar 29, 2011
    Messages:
    922
    AS uses $$label or .label for temporary labels ($$ can be buggy though) instead of ASM68K's @label.
     
    Niko and Pacca like this.
  20. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    On further inspection, the mappings are not at fault, but the animations file; it sets the mappings frame to a ludicrously high value, which is obviously invalid, as the Crabmeat only has 7 frames defined in it's mappings. I have no idea why it does this, but that appears to be the problem; I manually tested all the frames, and they seem to work just fine.

    EDIT: It appears to do this as a hackish way to flip the sprite, which I guess S2 doesn't support. Weird...