MAMEWorld >> MAME Artwork: Official
Previous thread Previous  View all threads Index   Next thread Next   Flat Mode Flat  

MooglyGuy
Renegade MAME Dev
Reged: 09/01/05
Posts: 2261
Send PM
Re: Help With Masks
12/05/21 10:38 AM


> For a number of games I have established that the joystick center/default position is
> "0xff" (rallyx is one such game in question). However, the other 8 positions don't
> respond to the usual "0x2", "0xb", etc. I've tried 02 and 04 and a number of other
> guesses, but I really don't know shit about hexadecimal or how it works. Can anyone
> point me in the right direction on this?

Rally X uses a 4-way joystick.

If you don't know shit about hexadecimal, then it's time to learn shit about hexadecimal, rather than cargo-culting your way through this stuff.

It's a lot easier to grasp hexadecimal when you stop thinking of the input values as random numbers, and start thinking of them in terms of the actual bits that are affected on the input port, by a player's input.

From the lowest (rightmost) bit to highest, Rally X's bits for player 1 are:

Bit 0: Service Button
Bit 1: Player Button
Bit 2: Left
Bit 3: Right
Bit 4: Down
Bit 5: Up
Bit 6: Start
Bit 7: Coin

The bits are all marked as IP_ACTIVE_LOW. That means that when the player isn't touching the controls at all, each bit will be "idle" at 1 (high). If the player activates that control, the bit will become "active" by turning to 0 (low).

So, with the bit positions denoted along the first line, all of the inputs being idle will give a value of:


Code:


76543210
--------
11111111



With the player pressing Right on the joystick, Bit 3 will turn from a 1 to a 0, so:


Code:


76543210
--------
11110111



And then the player presses Start while holding Right on the joystick, so Bit 6 turns from a 1 to a 0 as well:


Code:


76543210
--------
10110111



Now, how do you turn that from binary to hexadecimal? Pretty easily. Every group of 4 bits turns into one hexadecimal digit.

Hexadecimal is exactly like counting from 0 to 9 then rolling over to 10, except instead you count from 0 to 9, then continue from A to F, and *then* you roll over to 10 (which, therefore, has a value of 16).

In binary, each position to the left has a value 2 times more than the value to its right. Just like how in decimal, each position to the left has a value 10 times more than the value to its right.

An 8-bit binary value becomes exactly 2 hexadecimal digits, no more, no less, since each hexadecimal digit represents 4 bits. So by grouping the bits like so:


Code:


1011 | 0111



You can scribble the value of each bit up above it:


Code:


8 4 2 1 8 4 2 1
---------------------------------
1 0 1 1 | 0 1 1 1



Replace any '0' bits with, well, 0, and add plus signs:


Code:


8 + 0 + 2 + 1 0 + 4 + 2 + 1
---------------------------------
1 0 1 1 | 0 1 1 1



What is 8 + 2 + 1? 11. What is 4 + 2 + 1? 7.

If 10 is A, 11 is B, 12 is C, 13 is D, 14 is E, and 15 is F, then you have your answer: The value is B7.

If that's too much, then assuming you're on anything resembling a modern version of Windows, then the bundled Calculator program has a "Programmer" mode, where you can convert between binary, hexadecimal, and decimal with ease.







Entire thread
Subject Posted by Posted on
* Help With Masks Nightvoice 12/04/21 09:35 PM
. * Re: Help With Masks MooglyGuy  12/05/21 10:38 AM

Extra information Permissions
Moderator:  Mr. Do 
1 registered and 108 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 377