don't click here

Basic Questions & Answers thread

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

  1. nineko

    nineko

    I am the Holy Cat Tech Member
    6,308
    486
    63
    italy
    From what I know the Egg Prison should always work as an end of level trigger in Sonic 2, and the proof is that you can place them in any level with debug mode and they will always work. Of course they will have garbled graphics if you don't dynamically load the proper tiles while you're approaching the Egg Prison, even though this could give a spoiler to the player meaning he's on the right way.
    I don't know why your level doesn't work though. If a signpost is required by the engine just put one at a ridiculous location such as FFFF:FFFF so the player will never hit it. I don't think this is it but then again I am not familiar with Sonic 2 hacking so you should wait for other replies for a more precise opinion.
     
  2. SMTP

    SMTP

    Tech Member
    First off, what do you mean by "now it seems I can't play my level at all" ??
     
  3. DustArma

    DustArma

    Member
    1,338
    10
    18
    Santiago, Chile
    Learning Python.
    A quick question, what's the maximum size you can put on a sprite for Sonic before it starts fucking things up? (I would imagine a sprite too big would fuck up with something else)
     
  4. FraGag

    FraGag

    Tech Member
    Sprites can be at most 32x32 on the Genesis, so you're probably talking about a sprite mapping (or frame).

    There are many limits to consider. The VDP can only display 80 sprites (SonMapEd calls them 'pieces') at once, 20 sprites per line, etc. The limits are described on this page. Additionally, you have to consider how much VRAM is needed for the patterns that make up the image. Larger images need more VRAM, unless you reuse the same patterns. In the Sonic games, the VRAM is pretty full in most zones, so it can be difficult to find enough VRAM for new art without having to remove other things.
     
  5. DustArma

    DustArma

    Member
    1,338
    10
    18
    Santiago, Chile
    Learning Python.
    Thanks for the quick answer, I guess I'll just have to hope for the best with this.


    And one more thing I had forgotten.

    So, I've been working on this Sonic 2 hack and I'm switching Sonic's animations and adding new ones (this has nothing to do with the previous question), so, I added a falling animation when Sonic uses a spring, along with a SCD-like spring animation (HOW ORIGINAL :v:) , and they work fine, well, the SCD one does.

    The falling animation however has this... quirk... whenever Sonic falls from a spring into a wooden bridge, like those in EHZ, instead of reverting to the running animation he keeps using the falling animation until either he runs out of the momentum from the spring or I press either direction in the D-Pad.

    Code (Text):
    1.     dc.w SonAni_Fall - SonicAniData    ; 34; $22
    2. SonAni_Spring:    dc.b   4,$D8,$D9,$DA,$DB,$DC,$D8,$D9,$DA,$DB,$DC,$FD,$22
    3. SonAni_Fall:    dc.b      1,$D6,$D7,$FF
    So, I added SonAni_Fall just below SonAni_LieDown, I modified the spring animation to account for the new animations and linked it to the new falling animation.

    I'm sure I must be doing something wrong here, but honestly, I don't know what the fuck that is, some help would be appreciated.
     
  6. Glaber

    Glaber

    Has Beaten Sonic Genesis for GBA Oldbie
    How do I fix this using ESE2? [​IMG]
     
  7. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,161
    65
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    Have you edited the code for the title screen (or removed a strange-looking frame from the sprite mappings)? Because the title screen uses sprite masking to clip the bottom part of the sprite, faking the 'hidden behind the emblem' thing. This masking is done by having a sprite with X coordinate 0 (when in the sprite attribute table in VRAM; search for "Sprite masking, mode 1" in this document for more information).
     
  8. Glaber

    Glaber

    Has Beaten Sonic Genesis for GBA Oldbie
    All I did was check the box that turned on the Press Start Text in ESE2
    [​IMG]

    I'm just wondering if there is some way to fix the y position of the wing logo even using a hex editor. (ESE2 has one built in)
     
  9. vladikcomper

    vladikcomper

    Tech Member
    205
    134
    43
    Sonic Warped
    This probably happens because you've changed Sonic's start position in GHZ1. Restore at least his Y-coordinate to the original, so title screen's BG and FG will be at their places.
     
  10. Glaber

    Glaber

    Has Beaten Sonic Genesis for GBA Oldbie
    Sonic's start position in GHS affects the winglogo? Weird. Well lets see if that works.

    Edit: It worked. But why is the wing logo tied to Sonic's starting position in GHZ1?
     
  11. vladikcomper

    vladikcomper

    Tech Member
    205
    134
    43
    Sonic Warped
    I don't know exactly, I have a theory though.
    Title screen uses layout engine like all normal levels do, it calls a subroutine that loads level stuff for GHZ1, including Sonic's start pos etc. It also calls level deformation subroutines to scroll BG with deformation like in normal level. Those routines work with camera, which is affected by Sonic's coordinates, that's why camera is a bit bottomer than it supposed to be, so deformation routines scroll BG and FG upper. But sprites on the title screen have on-screen coordinates system, I.e. their coordinates are not depending on camera positions, so they stay at their places.
     
  12. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    So I was wondering what the shortest way to check if Sonic is within the range of a certain object is. I'm always doing it like this:

    Code (ASM):
    1.         move.w  ($FFFFD008).w,d0    ; get Sonic's X-pos
    2.         sub.w   $8(a0),d0       ; substract the X-pos from the current object from it
    3.         bpl.s   ResultPositive      ; if result is positive, branch
    4.         neg.w   d0          ; otherwise make it positive
    5.  
    6. ResultPositive:
    7.         cmpi.w  #$10,d0         ; is Sonic within $10 pixels of that object?
    8.         bgt.s   TooFarAway      ; if not, branch
    9.  
    But this makes 6 commands just for the X-position, which is VERY annoying. Is there any way to check the distance with less lines?
     
  13. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,742
    338
    63
    SonLVL
    I'm looking for information about data formats in Sonic 2: the bumpers in CNZ, and collision. And also all of the level data in Sonic 1. The wiki doesn't have anything on these.
     
  14. FraGag

    FraGag

    Tech Member
    I hope I got this right:
    Code (ASM):
    1.         move.w  ($FFFFD008).w,d0    ; get Sonic's X-pos
    2.         sub.w   $8(a0),d0       ; substract the X-pos from the current object from it
    3.         addi.w  #$10,d0
    4.         cmpi.w  #$20,d0         ; is Sonic within $10 pixels of that object?
    5.         bhi.s   TooFarAway      ; if not, branch
    I know, math is hard. :rolleyes:

    What's happening here is that I add $10 to d0, then check if d0 is greater than $20 (2 * $10) with an unsigned comparison (bhi instead of bgt). This means that if the value is negative, it will still be higher than $20 (e.g. -1 yields $FFFF). This only saves one instruction, but I don't think you can do much better than that (plus, it saves 2 lines because you don't need that extra label).
     
  15. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    Hey, two lines is better than nothing, so thanks for that. =)

    Just one thing I'm wondering about: Why would I need to write that add line? Why don't I just check for $10 in the cmp?
     
  16. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,201
    431
    63
    Japan
    Incase it's a negative result (10 pixels left), by adding, you increase it into positive, if it's too far left, it'll be negative, if it's too far right, it'll be higher than 20.
     
  17. Jimmy Hedgehog

    Jimmy Hedgehog

    Member
    1,728
    8
    18
    England - Slough
    Getting the motivation to continue old projects
    I forget, how do I make an object (or in my case part of an object sprite) use a different pallete line to the one it's using in Sonic 1? Also, my old lamp problem still persists
     
  18. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,201
    431
    63
    Japan
    The VDP has a "V-Ram setting" which is a word is size, this very same word format can be found used for map planes and sprites, the format is:

    XYZZ

    For Sonic 1 with sprites, there are two places it can be used. The first way is:

    Code (ASM):
    1.         move.w  #$XYZZ,$02(a?)
    This is the "main" V-Ram control, it controls all sprites of the object's mappings, so if I wanted to set it to use the second palette line, I set "CC" (as explained above) to 01, this makes "XYZZ" "2000", so by moving "2000" you set the object and it's sprites to use the second palette line.

    The second way is:

    Code (ASM):
    1.         dc.b    $03
    2.         dc.b    $YY,$SS,$VV,$VV,$XX
    3.         dc.b    $YY,$SS,$VV,$VV,$XX
    4.         dc.b    $YY,$SS,$VV,$VV,$XX
    These are mappings, each line being a "sprite" piece, the "VV" "VV" are together as a word ("VVVV"), this is the same format as "XYZZ", so you can set say the first sprite piece to use palette line 2 (CC = 01 | XYZZ = 2000) and start from the second tile in V-Ram (+0002), the second sprite piece to use palette line 4 and to be flipped upside-down (CC = 11 and F = 1 | XYZZ = 7000) and start from the 56th tile in V-Ram (+0056), and the third sprite piece to use the first palette line, in high plane and mirrored (P = 1 and CC = 00 and M = 1 | XYZZ = 8800) and start from the 780th tile in V-Ram (+0780):

    Code (ASM):
    1.         dc.b    $03
    2.         dc.b    $YY,$SS,$20,$02,$XX
    3.         dc.b    $YY,$SS,$70,$56,$XX
    4.         dc.b    $YY,$SS,$8F,$80,$XX
    Be warned, the XYZZ settings stored in the "main" V-Ram control (I.e. $02(a?)) will ADD to all the sprite's XYZZ's in sprite mappings.

    So if $02(a?) was 2010, then the first sprite would be $40,$12, the second sprite would be $10,$66, and the third sprite would be $AF,$90.
     
  19. Jimmy Hedgehog

    Jimmy Hedgehog

    Member
    1,728
    8
    18
    England - Slough
    Getting the motivation to continue old projects
    So, in what way would this apply to Obj79? (Lamppost) Which uses a the stage's first line for the main body rather than Sonic's? Where abouts do I look in terms of that object?
     
  20. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,201
    431
    63
    Japan
    Assuming you mean the third line, consider trying "Obj79_Main:" from "move.w #$7A0,2(a0)" to "move.w #$47A0,2(a0)", this will increase the lamppost (except the red hit ball) to the 3rd line. Of course, if you wanna be more specific with the pieces, then it's suggested looking in "_maps\obj79.asm":

    Code (ASM):
    1. byte_17100: dc.b 6                  ; ""untouched lamppost""
    2.         dc.b $E4, 1, 0, 0, $F8          ; half bottom body (left)
    3.         dc.b $E4, 1, 8, 0, 0            ; half bottom body (right)
    4.         dc.b $F4, 3, $20, 2, $F8        ; half top body (left)
    5.         dc.b $F4, 3, $28, 2, 0          ; half top body (right)
    6.         dc.b $D4, 1, 0, 6, $F8          ; half blue ball (left)
    7.         dc.b $D4, 1, 8, 6, 0            ; half blue ball (right)
    8. byte_1711F: dc.b 4                  ; ""Body (only) of lamppost when ball spins""
    9.         dc.b $E4, 1, 0, 0, $F8          ; half bottom body (left)
    10.         dc.b $E4, 1, 8, 0, 0            ; half bottom body (right)
    11.         dc.b $F4, 3, $20, 2, $F8        ; half top body (left)
    12.         dc.b $F4, 3, $28, 2, 0          ; half top body (right)
    13. byte_17134: dc.b 2                  ; ""Ball (only) that spins""
    14.         dc.b $F8, 1, 0, 8, $F8          ; half red ball (left)
    15.         dc.b $F8, 1, 8, 8, 0            ; half red ball (right)
    16. byte_1713F: dc.b 6                  ; ""touched lamppost""
    17.         dc.b $E4, 1, 0, 0, $F8          ; half bottom body (left)
    18.         dc.b $E4, 1, 8, 0, 0            ; half bottom body (right)
    19.         dc.b $F4, 3, $20, 2, $F8        ; half top body (left)
    20.         dc.b $F4, 3, $28, 2, 0          ; half top body (right)
    21.         dc.b $D4, 1, 0, 8, $F8          ; half red ball (left)
    22.         dc.b $D4, 1, 8, 8, 0            ; half red ball (right)
    I've labeled what each piece is, though I suspect you might use SonMapEd (if you do, then it's suggested you read it's instructions about palette changing pieces), the middel byte of each piece, if it's +00, it's the first line, if it's +20, it's the second line, if it's +40, it's the third line, if it's +60, it's the fourth line (Again, make sure there's a $ sign to represent it as a hex value).