don't click here

Basic Questions & Answers thread

Discussion in 'Engineering & Reverse Engineering' started by Tweaker, May 29, 2008.

  1. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    Thanks again Mainmemory. Sorry for the constant stream of questions, but I got more.

    1: How do I change where an object tries to get it's 8x8 graphics from in the VRAM? This enemy is interfereing with level graphics, so I edited the loading cues to put the graphics in a sfer place, but now the enemy is displaying the graphics is was originally overwriting.

    2:SonED2 is giving me a hard time. I've been trying to make a new spriteset so I an make adjusting the level a bit easier, but I'm having an issue with SonED2 crashing whenever I try to load the new image. As far as I can tell, there's nothing wrong with the data or with the image (Which is a paletted PCX file, based off of a screenshot I took using Genecyst and assembled in Photoshop).

    Code (Text):
    1. # of Sprites in set 4:  5
    2.  ;HIDDEN PALACE SET
    3.  
    4.         ;BBat
    5.         Sprite 0 file:  40
    6.         xoff in file:   0
    7.         yoff in file:   0
    8.                 Width:  64
    9.                 Height: 32
    10.  
    11.         ;Stego
    12.         Sprite 1 file:  40
    13.         xoff in file:   64
    14.         yoff in file:   0
    15.                 Width:  64
    16.                 Height: 32
    17.  
    18.         ;Redz
    19.         Sprite 2 file:  40
    20.         xoff in file:   64
    21.         yoff in file:   32
    22.                 Width:  32
    23.                 Height: 32
    24.  
    25.         ;HPZ Glowing Orb
    26.         Sprite 3 file:  40
    27.         xoff in file:   0
    28.         yoff in file:   64
    29.                 Width:  32
    30.                 Height: 32
    31.  
    32.         ;FALLING PLATFORM
    33.         Sprite 4 file:  40
    34.         xoff in file:   32
    35.         yoff in file:   64
    36.                 Width:  96
    37.                 Height: 32
    And here's the image:

    s2obj40.pcx

    Thanks in advance for any help.
     
  2. vladikcomper

    vladikcomper

    Tech Member
    209
    150
    43
    Sonic Warped
    Find object's code, find where it's sets word 2(a0). This is so-called art pointer. The format is the following (in bits)

    Code (Text):
    1. %pcc- -ttt tttt tttt
    p - Priority flag, sprites appear on top of all when this bit is set. Used by HUD and Level Results cards.
    c - Bits, specifying the palette line, used by sprite
    t - Bits, representing the index of the first tile in VRAM for the object art.

    If we present it in hexadecimal form, the word will look like this:

    Code (Text):
    1. $XTTT
    Where X nibble contains p and c bits, and the last three nibbles contain number of the first tile in VRAM. For example, if you find something like this:

    Code (ASM):
    1. move.w  #$2380,2(a0)
    Here, object's first tile will be tile $380 in VRAM. To get the number of the tile, take the VRAM offset you're using in Pattern Load Cues and divide it by $20. You can even make the assembler calculate this for you, like so:

    Code (ASM):
    1. move.w  #$2000+($YourVRAMOffset/$20),2(a0)
     
  3. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,758
    341
    63
    SonLVL
    SonED2 is extremely picky with data. It probably only accepts 320x200 images. Though my only experience with SonED2's object definitions is writing a program to convert them to SonLVL format.
     
  4. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    Knowing this, would is actually be be possible to make enemies load from different places in VRAM depending on the zone/act? I would imagine so, but I've only just started experimenting with branches.

    Unfortunately, it looks like SonED2 just doesn't like me. I guess text descriptions will have to do for now, or I'll switch to SonLvL.
     
  5. vladikcomper

    vladikcomper

    Tech Member
    209
    150
    43
    Sonic Warped
    It's not a big deal...
    Code (ASM):
    1.  
    2.     move.w  #xxxx,art_tile(a0)      ; use default art pointer
    3.     cmpi.b  #emerald_hill_zone,Current_Zone ; are we in EHZ?
    4.     bne.s   +               ; if not, branch
    5.     move.w  #yyyy,art_tile(a0)      ; use special art pointer instead
    6. +
    Also, in my previous port I said the variable you should be looking for is 2(a0). I was thinking Sonic 1 here. If you're using newest Sonic 2 disassemblies, 2(a0) appears as art_tile(a0).
     
  6. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    Yeah, I noticed the difference.

    So, that code is really useful, thank you very much!

    Edit: Does anyone know where I can edit the highlight per each selection on the level select screen? I changed the mappings on my Level Select and they need to be reconfigured.
     
  7. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,758
    341
    63
    SonLVL
    From the Hg disassembly (I know you're using the old one, but the information still applies):
    Code (ASM):
    1. ;byte_96EE:
    2. LevSel_MarkTable:   ; 4 bytes per level select entry
    3. ; line primary, 2*column ($E fields), line secondary, 2*column secondary (1 field)
    What this means is that each level has four bytes, which is then split into two groups: "primary" for the level's name, and "secondary" for the act number (levels with no acts use 0,0). The level name has a fixed width of 14 characters, and the act number has a fixed width of 1 character.
    So the first entry for Emerald Hill Zone 1 looks like
    Code (ASM):
    1.     dc.b   3,  6,  3,$24    ;0
    Which means that the level's name is at row 3, column 3 (3*2=6), and the act number is at row 3, column 18 (18*2=36=$24).
     
  8. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    Thanks, I understand it perfectly now!

    Any idea how I could change the secondary field to be 4 long instead of 1 so I can use "Act1" and "Act2" instead of just single numbers?
    Also, I need to move the sound test 00's. Do you know anything about that?

    Also, one more thing needs changing. The number of options and the controls.
     
  9. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,758
    341
    63
    SonLVL
    Under loc_95B8:, just above the line cmpi.w #$15,(Level_select_zone).w, you'll see the lines
    Code (ASM):
    1.     move.w  (a1)+,d0
    2.     add.w   d3,d0
    3.     move.w  d0,(a6)
    Those three lines read a tile from the mappings, change the palette, then write it to VRAM. To make it change 4 tiles, change it to:
    Code (ASM):
    1.     moveq   #(4-1),d2
    2. -   move.w  (a1)+,d0
    3.     add.w   d3,d0
    4.     move.w  d0,(a6)
    5.     dbf d2,-
    The position of the sound test number in the level select is controlled by the first line under loc_965A:. The $49440003 is a VRAM Write command for the VDP. There are two ways you could go about editing it: one is to find and use a VDP calculator, the other is to copy some functions and constants from the Hg disassembly.
     
  10. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    The first thing worked great, thanks.

    The second one.. Um.. Maybe I'm crazy, but it seems to only be changing their locations in the VRAM, not onscreen.
     
  11. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,758
    341
    63
    SonLVL
    It's writing to the area of VRAM which holds Plane A's tilemap. Basically, given specific X and Y coordinates where the numbers should appear, $C000+(x*2)+(y*$80) gives you the VRAM address to write to.
     
  12. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    I think I'll do the second after all. I did the calculation you gave me properly and put it through a VDP calculator and I ended up wit scrambled dots everywhere when I went to sound test.

    Looking at the Hg version actually, it seems like it's much more user friendly, maybe I should convert my hack over to that while it's still early?
     
  13. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,758
    341
    63
    SonLVL
    I like the Hg disassembly a lot. I just now pushed a commit that should make it even simpler to change the location of the sound test numbers.
     
  14. Jimmy Hedgehog

    Jimmy Hedgehog

    Member
    1,728
    8
    18
    England - Slough
    Getting the motivation to continue old projects
    Hey, random question, in Sonic 1 (Hivebrain disassembly), how would I be able to temporarily change Sonic's pallet? Guessing something to do with PalLoad and perhaps creating another one of those (since there're four there, two of which for water pallets), but I have no idea how those routines link back to a pallet file. Basically my objective is for his pallet to change after a certain action (hitting a monitor) and changing back when hit sort of thing, but any sort of hint towards changing his pallet at certain times would be helpful ^^
     
  15. Invincibility routine is a good place to look at to see how things are made temporary. The palette loading routine is a good place to start to see how to load a palette. So your setup would be:


    Is routine flag set?
    If not, skip

    If yes, run following code
    change palette.
    set counter
    is counter up? If yes, change palette back

    end code
     
  16. Jimmy Hedgehog

    Jimmy Hedgehog

    Member
    1,728
    8
    18
    England - Slough
    Getting the motivation to continue old projects
    Hmm...I can't seem to figure out how it actually goes about changing the pallet when something happens, like how it changes when he goes in the water. I'm only really seeing stuff that's loaded when the level is, unless I'm missing something here.
     
  17. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    Okay, so I've got most of my project converted to fit the Hg disassembly now. One thing I liked was the simplicity of the title cards... Well, the apparent simplicity. Then I tried to add a new zone:
    [​IMG]

    And it did this:

    [​IMG]
    Any ideas?
     
  18. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,758
    341
    63
    SonLVL
    The TitleCardLetters array only controls which letters get loaded per zone, the order and placement of the letters are plain sprite mappings at Obj34_MapUnc_147BA.
    The first 15 entries in the table point to the mapping for each zone in its internal order.
    The simplest way to edit them is probably to use Sonic 2 - Text Code Generator's Zone Title Card editor, type the name of your level, then take the text in the Mappings box and paste it over the mappings in s2.asm, making sure to keep the original label.
     
  19. Selbi

    Selbi

    The Euphonic Mess Member
    1,503
    58
    28
    Northern Germany
    Sonic ERaZor
    Though my tool for created for the old Xenowhirl version. I don't know how much that one and the Hg differ from each other (and quite frankly, I can't be bothered to check either), but if I remember correctly it was very different and simplified.
     
  20. TheInvisibleSun

    TheInvisibleSun

    OVER THE TOP TECHNO-BLAST Member
    1,628
    193
    43
    Buffalo, NY, USA
    The Water
    Essentially, whenever loading palettes, you pretty much tell the game to load the specified palette to the desired RAM location, and use it instead of what it was using before. Also, if I remember correctly (it's been a few months), the underwater palettes are already loaded when the stage is loaded, and they use a different subroutine to load (Pal_Load4 Water, I believe).

    Adding to what Irixion said, you should also look at how the shield works as far as 'temporary' functionality goes.