don't click here

Basic Questions & Answers thread

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

  1. Quickman

    Quickman

    be attitude for gains Tech Member
    5,595
    18
    18
    :x
    omg porjcet
    Part of me wants to say the problem there is running out of Megadrive sprites, but I don't know for certain.

    EDIT: Quoting due to new page.

     
  2. Hanoch

    Hanoch

    Also known as TheKnock, Birashot Member
    491
    0
    0
    Israel
    everything
    click on the tile and you will see it on the blue window bar above labeled as Tile: T/N
    Where T is the current tile and N is the number of tiles in the file.
     
  3. Animemaster

    Animemaster

    Prison bitch! Member
    346
    0
    0
    UK
    Sonic 1 Revelation
    Well least I know now its not because the tile was beyond $ff, but that still leaves me wondering what the problems is. If it is done by screen mapings, is there not away to do the way I've done it? you know with it all fixed.
     
  4. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    I need some help at some maths: I'm trying to make the entire palette black-white on pause. Now I tried to find out how to find the correct grey colour; however, I have no idea. It's somewhere in the middle of all three colours, I.e.:
    But I can't explain myself how this is getting calculated. Any ideas?

    (Btw, I posted this here since it's for a hack and not general.)
     
  5. Hanoch

    Hanoch

    Also known as TheKnock, Birashot Member
    491
    0
    0
    Israel
    everything
    Are you using sonmaped? If so, I would highly suggest you to use soned2 or hivepal to edit the palette.
     
  6. MoDule

    MoDule

    Tech Member
    327
    24
    18
    Procrastinating from writing bug-fix guides
    What you've got here is called "luma". It's the perceived brightness of a color and is calculated as R*0.30 + G*59 + B*0.11. Using this formula on the RGB values you prvided you get a luma of Y' = 114*0.30 + 81*0.59 + 141*0.11 = 97.5, which is your gray value. Hope that helps.
     
  7. Sonic Adventure DX Question
    I was wondering, how easy would it be to replace sounds in Sonic Adventure DX for the PC? I found a DAT file unpacker at the Hacking CulT, but the link I found for the DAT re-packer is long dead. Replacing the raw WAV files doesn't do anything and if you delete the DAT file the WAV file belongs to, it knocks out all those sound effects that belonged to that file (rather than crashing the game, oddly enough), so I'm at a loss as to how to repack the WAVs... Any advice would be great, but a link to the DAT repacker would be even better.

    Thank in advance!

    Nevermind. I found it. Apparently, I wasn't looking hard enough. XD
     
  8. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    Uhm, I actually didn't mean how to edit the palette, but how to find out the right grey value.

    Ok, what? So you have a constant formula, R*0.30 + G*59 + B*0.11, which is on every single of the about 16.5M colours the same or just on the example I gave you? Would be nice if you try to make it foolproof. :V

    Btw, searched on Google, and found this, but it seems even more complicated than the things you told me...
     
  9. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    I'm trying to figure out a problem with an attack code in my game. Basically it plays the animation and moves accordingly, however when I turn or fall off a ledge while doing it, the animations resets rather than continuing. Here is the code if that helps:

    Code (Text):
    1. ; ---------------------------------------------------------------------------
    2. ; Subroutine allowing Sonic to attack
    3. ; ---------------------------------------------------------------------------
    4.  
    5. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
    6.  
    7.  
    8. Sonic_Hammer:
    9.         cmp.b    #$1F,$1C(a0)
    10.         bne.s    lol7
    11.         move.w    $14(a0),d0
    12.         move.w    d0,d1
    13.         asr.w    #3,d1
    14.         sub.w    d1,d0
    15.         move.w    d0,$14(a0)
    16.         rts
    17. lol7:
    18.         btst    #6,($FFFFF603).w; is A button pressed?
    19.         beq    lol    ; if not branch
    20.         move.b    #$1F,$1C(a0); show hammer animation
    21.  
    22.         move.w    $14(a0),d0
    23.         btst    #0,$22(a0)
    24.         beq    lol8
    25.         neg.w    d0
    26. lol8:
    27.         cmp.w    #$400,d0
    28.         bgt    lol
    29.         move.w    #$400,d0
    30.         btst    #0,$22(a0)
    31.         beq    lol9
    32.         neg.w    d0
    33. lol9:        
    34.         move.w    d0,$14(a0)
    35. lol:
    36.         move.w    $10(a0),d0
    37.         tst.w    d0
    38.         bpl    label
    39.         neg.w    d0
    40. label:
    41.         cmpi.w    #$600,d0
    42.         bgt    Sonic_Hammer_Return
    43.         btst     #6,($FFFFF603).w; is A button pressed?    
    44.         beq.b     Sonic_Hammer_return; if not, return
    45.         move.b     #$1F,$1C(a0) ; show animation $20
    46.         move.w    #$BD,d0
    47.         jsr    (PlaySound_Special).l
    48.        
    49. Sonic_Hammer_return:    
    50.         rts
    51. ; End of function Sonic_Hammer
    I also made alterations to Sonic_MoveLeft and Right for it to work:

    Code (Text):
    1. move.w   d0,$14(a0)
    2. cmp.b     #$1F,$1C(a0); Use attack animation
    3. beq         lol2
    4. move.b    #0,$1C(a0); use walking animation
    5. lol2:
    MoveRight has the same code but with a different named branch.

    As well as Obj01_NotRight

    Code (Text):
    1. cmp.b     #$1F,$1C(a0)
    2. beq         lol4
    3. move.b   #5,$1C(a0); use "standing" animation
    4. lol4:
     
  10. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    I wasn't really able to get what you want, but:
    Are you lazy at making correct comments or were you really not knowing what you are doing there? =P

    Code (Text):
    1.         move.w    d0,$14(a0)
    2.         cmp.b    #$1F,$1C(a0); is animation $1F being showed?
    3.         beq.s    lol2    ; if yes, branch
    4.         move.b    #0,$1C(a0); use walking animation
    5. lol2:
    That should be clearer.
     
  11. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Whoops, a bit of both really, I was just quickly jotting some basic notes so I remember bits, it was done a while after I put it in, I admit I got help for this code, a simplified version had problems so qiuu made an altered one, though I'm not sure what certain parts are (I've probably botched it somewhere).
     
  12. MoDule

    MoDule

    Tech Member
    327
    24
    18
    Procrastinating from writing bug-fix guides
    That formula should work for every color. It's certainly not something I came up with out of the blue.
    I'm sure you are aware there are diffent ways to represent colors other than RGB, for instance HSL, where you describe a color by its frequency, or which part of the rainbow it comes from, its saturation, which is how far the color is from gray and its lightness, which can be calculated in a number of ways. If you want the brightness value to be what comes closest to what humans perceive as brightness you calculate its luma component, which simply takes into consideration how much each primary color contributes to the perceived brightness of a color.
    I should also note that technically you want to use luminance, but luma is what gives you the black and white color from your example.

    If you scroll down a little farther you'll see a link to the article on Luma. You'll want to use Rec. 601 luma.
     
  13. nineko

    nineko

    I am the Holy Cat Tech Member
    6,309
    486
    63
    italy
    When I convert something to grayscale I usually just take the average of the R, G, and B values (e.g. (R+G+B)/3). Looks good enough.
     
  14. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,202
    432
    63
    Japan
    Basically what nineko said, it's known as getting the mean of a list of values.

    take each value and add them to gether, then divide by the number of values you added, so for example:

    2, 6, E

    2 + 6 = 8 + E = 16 / 3 = 7

    now because of the way the genesis/megadrive's VDP works, it NEEDS to be 9-bit 1110 (Or simply an even value), so you can use the "and" command for this, simply "and" E of the value:

    7 & E = 6

    thus 6 is your closest avarage.

    ASM example: (d0 = full colour)

    Code (ASM):
    1. ; ===========================================================================
    2. ; ---------------------------------------------------------------------------
    3.         moveq   #$00,d1                 ; clear d1
    4.         move.b  d0,d1                   ; copy Green and Red of colour to d1
    5.         lsr.b   #$04,d1                 ; get only Green amount
    6.         move.b  d0,d2                   ; copy Green and Red of colour to d2
    7.         and.b   #$0E,d2                 ; get only Red amount
    8.         lsr.w   #$08,d0                 ; get only Blue amount of d0
    9.         add.b   d1,d0                   ; add Green amount to Blue amount
    10.         add.b   d2,d0                   ; then add Red to the amount
    11.         divu.w  #$03,d0                 ; divide by 3
    12.         and.b   #$0E,d0                 ; keep it an even value (Keep 9-bit VDP)
    13.         move.b  d0,d1                   ; copy to d1
    14.         lsl.b   #$04,d1                 ; shift to left nybble
    15.         add.b   d1,d0                   ; add to d0 (Setting the green)
    16.         lsl.w   #$04,d1                 ; shift to next left nybble
    17.         add.w   d1,d0                   ; add to d0 (Setting the blue)
    18. ; ---------------------------------------------------------------------------
    19. ; ===========================================================================
    d0 now equals greyscale colour

    (If I've made a mistake here somewhere, or any of you feel it could be optimized better, then feel free to correct it)
     
  15. Selbi

    Selbi

    The Euphonic Mess Member
    1,497
    48
    28
    Northern Germany
    Sonic ERaZor
    Code (ASM):
    1. Pal_MakeBlackWhite:
    2.         lea ($FFFFFB00).w,a0 ; get palette
    3.         moveq   #0,d3       ; clear d3
    4.         move.b  #$3F,d3     ; set d3 to $3F (+1 for the first run)
    5.  
    6. Pal_MBW_Loop:
    7.         moveq   #0,d0       ; clear d0
    8.         move.w  (a0),d0     ; get colour
    9.         moveq   #0,d1       ; clear d1
    10.         move.b  d0,d1       ; copy Green and Red of colour to d1
    11.         lsr.b   #4,d1       ; get only Green amount
    12.         move.b  d0,d2       ; copy Green and Red of colour to d2
    13.         and.b   #$E,d2      ; get only Red amount
    14.         lsr.w   #8,d0       ; get only Blue amount of d0
    15.         add.b   d1,d0       ; add Green amount to Blue amount
    16.         add.b   d2,d0       ; then add Red to the amount
    17.         divu.w  #3,d0       ; divide by 3
    18.         and.b   #$E,d0      ; keep it an even value (Keep 9-bit VDP)
    19.         move.b  d0,d1       ; copy to d1
    20.         lsl.b   #4,d1       ; shift to left nybble
    21.         add.b   d1,d0       ; add to d0 (Setting the green)
    22.         lsl.w   #4,d1       ; shift to next left nybble
    23.         add.w   d1,d0       ; add to d0 (Setting the blue)
    24.         move.w  d0,(a0)+    ; set new colour
    25.         dbf d3,Pal_MBW_Loop ; loop for each colour
    26.         rts         ; return
    This worked just fine. Big thanks (the rest of my questions I will tell you on IRC =P).
     
  16. Tets

    Tets

    one rude dude Oldbie
    905
    72
    28
    Getting back into the hacking thing here, or trying to. I'm running Ubuntu now, and I can't seem to get the Sonic 2 2007 disassembly to build with the Linux build tools from the wiki.

    Code (Text):
    1. ~/s2hax$ sh build
    2. linux/asl: relocation error: linux/asl: symbol __guard, version GLIBC_2.3.2 not defined in file libc.so.6 with link time reference
    What have I done wrong, and how can I fix it?
     
  17. Mairtrus

    Mairtrus

    Get a load of this!! Tech Member
    27
    0
    0
    Mendoza, Argentina
    Sonic Z. The Z DOESN'T means nothing.
    Exists any information of the music format used in the Sonic Advance series?
     
  18. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Okay I've tried editing Sonic's title sprites on SonMapEd but when I save the thing onto the ROM I get the error message

    Code (Text):
    1.                        bsr.w  MvSonicOnPtfm
    2. s1comb.asm(21857) : Error 06054 : Branch offset (0xffff7fc6) out of range
    3.  
    4. 1 error encountered processing file 's1comb.asm'
    5. 36892 source statements in 47397 lines processed in 0.7 seconds
    Anyone know what the problem might be here?
     
  19. amphobius

    amphobius

    doing more important things with my life Member
    2,120
    0
    16
    life
    Change the bsr.w into a jsr. That should work just fine from there. :)
     
  20. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Okay tried that (had to change several lines plus MvSonicOnPtfm2 it seems), now I'm getting this error:

    Code (Text):
    1. s1comb.asm(6211) : Error 06052 : Branch offset (-32956) out of range at address 0
    2.  
    3. s1comb.asm(6224) : Error 06052 : Branch offset (-32930) out of range at address 0