don't click here

Basic Questions & Answers thread

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

  1. Lapper

    Lapper

    Lappering Tech Member
    1,782
    1,016
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    How would one convert a number to the hex equivilent?

    Like if I wanted to multiply the acceleration by an amount.

    (In the Sonic 1 dissasembly ofcourse)
     
  2. Selbi

    Selbi

    The Euphonic Mess Tech Member
    1,541
    155
    43
    Northern Germany
    Sonic ERaZor
    Number to hex? You know hex is the same as decimal, just written in another system. However, thanks to the assembler you can write in decimal without calculating to get a hex value, by simply not writing the $, e.g.:
    Code (ASM):
    1.         move.b  #$50,d0
    2.     equals
    3.         move.b  #80,d0
     
  3. Lapper

    Lapper

    Lappering Tech Member
    1,782
    1,016
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    Wow... I still don't get that!

    Where do the 50 and 80 have a relationship? And how does it know where the decimal point would be?
     
  4. Interrobang Pie

    Interrobang Pie

    Get a load of palm. Member
    24
    0
    0
    England
    Something that must be kept a SUPER SECRET.
    Start fiddling around with calc.exe. 50 (hex) = 80 (decimal)
     
  5. Lapper

    Lapper

    Lappering Tech Member
    1,782
    1,016
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    Does decimal mean wht I think it means?
    Because if the actual acceleration = 0.046875 (according to the physics guide), how does it relate to 50 or 80 at all?
    I am just starting out here. Just got the dissasembly, thinking I knew more than I did
     
  6. Selbi

    Selbi

    The Euphonic Mess Tech Member
    1,541
    155
    43
    Northern Germany
    Sonic ERaZor
    Maybe I should tell you how hex works:

    Hex stands for Hexadecimal, which comes from a foreign language (I suppose) and means 16. Decimal means 10.
    You say 16 for hexadecimal, because you have 16 different "numbers":
    Code (Text):
    1. Hexadecimal | Decimal
    2. 0 = 0
    3. 1 = 1
    4. 2 = 2
    5. 3 = 3
    6. 4 = 4
    7. 5 = 5
    8. 6 = 6
    9. 7 = 7
    10. 8 = 8
    11. 9 = 9
    12. A = 10
    13. B = 11
    14. C = 12
    15. D = 13
    16. E = 14
    17. F = 15
    After F you continue with 10, which equals 16 in decimal. This continues like this:
    Code (Text):
    1. Hexadecimal | Decimal
    2. 10 = 16
    3. 11 = 17
    4. 12 = 18
    5. ...
    6. 19 = 25
    7. 1A = 26
    8. ...
    9. 1F = 31
    10. 20 = 32
    11. ...
    If you continue this list, you will come to the point where you have 50 in hexadecimal, which equals 80 in decimal.

    And if you still don't get it, open up the windows calculator and set the view to professional (or whatever it's called in the english version). On the left you then have the choice to select between hex, dec, oct, and bin. Type in 80 in decimal, click on hex and you will see 50.
     
  7. Lapper

    Lapper

    Lappering Tech Member
    1,782
    1,016
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    Ah, Ok then. So if in Sonic he moves at (in decimal) 0.046875 (according to the physics guide), why in decimal is it 80 in the dissasembly.
     
  8. Selbi

    Selbi

    The Euphonic Mess Tech Member
    1,541
    155
    43
    Northern Germany
    Sonic ERaZor
    Because when Mercury made the physics guide, he made intended to make it for custom game engines (at least that's what I think, because you can't really do anything with this list when you are working on a disassembly).
     
  9. Lapper

    Lapper

    Lappering Tech Member
    1,782
    1,016
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    What about this bit:
    move.w #$28, ($FFFFF762).w ; Sonic's acceleration
    ----------------------^^^^^^^^^^^^-----------
     
  10. Selbi

    Selbi

    The Euphonic Mess Tech Member
    1,541
    155
    43
    Northern Germany
    Sonic ERaZor
    That's a RAM location. It's being written in hexadecimal as well, but it has nothing to do as a value itself, it's just where $28 is being put at.
     
  11. Lapper

    Lapper

    Lappering Tech Member
    1,782
    1,016
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    Ok, final mystery. I made the acceleration 28, which is half of 50 in hex according to calc.exe, but he goes about double the acceleration.
     
  12. nineko

    nineko

    I am the Holy Cat Tech Member
    6,421
    585
    93
    italy
    To complement what Selbi said, the asm MOVE instruction works like this (in this case, when you want to put a provided value to a known ram location):
    move.X value, (ram address).w
    If X is "b", then the value can be between 0 and 255 ($00 to $FF).
    If X is "w", then the value can be between 0 and 65535 ($0000 to $FFFF), and the ram location MUST be word aligned (e.g. multiple of 2).
    If X is "l", then the value can be between 0 and 4294967295 ($00000000 to $FFFFFFFF), and the ram location MUST be dword aligned (e.g. multiple of 4).

    The MOVE instruction can be used also between data registers, or using address registers instead of literal RAM values. There are at least a dozen of valid uses of MOVE.

    edit: Sonica, Sonic's default acceleration is $C over water, $18 with speed shoes, and $6 under water. Dunno where you got the $50 from.
    Also make sure to change ALL the instances where Sonic's acceleration is changed, or you'll get wrong results when Sonic gets in/out of water or gets/ungets speed shoes.
     
  13. Selbi

    Selbi

    The Euphonic Mess Tech Member
    1,541
    155
    43
    Northern Germany
    Sonic ERaZor
    The 50 was just an example to explain how hex works. It has nothing to do with this thing itself. The original acceleration is C (12 in decimal).
     
  14. Lapper

    Lapper

    Lappering Tech Member
    1,782
    1,016
    93
    England
    Sonic Studio, Sonic Physics Guide, Kyle & Lucy, Freedom Planet 2
    Actually, In the dissasemelly this is the oiginal speed line:
    Code (Text):
    1. move.w    #$50,($FFFFF762).w; Sonic's acceleration
     
  15. Interrobang Pie

    Interrobang Pie

    Get a load of palm. Member
    24
    0
    0
    England
    Something that must be kept a SUPER SECRET.
    Decimal is the 10-digit number format.
    Hexadecimal is the 16-digit number format.
    Dec: 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17...
    Hex: 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 10, 11...


    EDIT: You know what I hate? Pages that you don't read cause you think they don't exist.
     
  16. nineko

    nineko

    I am the Holy Cat Tech Member
    6,421
    585
    93
    italy
    You probably changed it by mistake and you forgot about that. I have a clean disassembly right in front of me and it says $C.
    Besides, as I said, look for ALL the instances where the ram location FFFFF762 is altered. There are at least half a dozen, and you have to change them ALL.
    $C = over water, no speed shoes
    $18 = over water, speed shoes
    $6 = under water

    This also means that if you put speed shoes in Labyrinth Zone without patching the code in some way, you're going to fuck up the physics hard. It's an easy fix though.
     
  17. Selbi

    Selbi

    The Euphonic Mess Tech Member
    1,541
    155
    43
    Northern Germany
    Sonic ERaZor
    I highly doubt that. The only possibility is that you or someone else already edited the line.

    @Interrobang Pie: That's why there is a nice button called "Preview Post", which also lists the newest posts while you were writing your post.
    EDIT: Ironically I just didn't press the button and got beaten by nineko.
     
  18. Interrobang Pie

    Interrobang Pie

    Get a load of palm. Member
    24
    0
    0
    England
    Something that must be kept a SUPER SECRET.
    Indeed.

    Hold on, are these locations for Sonic 1? If so, I should be learning from this.
     
  19. nineko

    nineko

    I am the Holy Cat Tech Member
    6,421
    585
    93
    italy
    Yes they are. They're also all documented here: SCHG:Sonic_the_Hedgehog/RAM_Editing
     
  20. DigitalDuck

    DigitalDuck

    Arriving four years late. Member
    5,461
    508
    93
    Lincs, UK
    TurBoa, S1RL
    It's a mixture of Greek and Latin.

    Hexa- is a Greek prefix meaning "six". Decimal comes from the Latin word decimalis which roughly means "made up of tenths". Therefore, hexadecimal is "made up of (ten plus six)ths", or "made up of sixteenths".

    And that's why English sucks.