MAMEWorld >> MAME Artwork: Official
View all threads Index   Threaded Mode Threaded  

Pages: 1

Nightvoice
MAME Fan
Reged: 03/19/10
Posts: 728
Loc: The Room Next To You
Send PM


Vas Crabb or Mr. Do: Request for Input
#388896 - 12/03/20 04:22 PM Attachment: champbas.zip 12233 KB (0 downloads)


I've run into the same problem with Champion Baseball as I did with Bosconian: it won't read the upper left/lower right joystick positions (or vice-versa as was the case with Bosconian). Is there a bit mask hitherto unexplored? I initially thought it may have been a driver bug, but I'm not sure now that I've run into it twice. See attached.



----------------------
I asked my cat what the meaning of life was... he noserized me and stuck his butt in my face.

My MAME/MESS artwork files: https://drive.google.com/open?id=1ABxeKgNIrKlIsyck7dx4V241NFQDWAF4
Related screen shots: https://drive.google.com/open?id=1U5IbvbVzYW97PuOOQuocvZFE_YJz7WIn



Nightvoice
MAME Fan
Reged: 03/19/10
Posts: 728
Loc: The Room Next To You
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Nightvoice]
#388897 - 12/03/20 04:23 PM Attachment: bosco.zip 4017 KB (2 downloads)


See prior post.



----------------------
I asked my cat what the meaning of life was... he noserized me and stuck his butt in my face.

My MAME/MESS artwork files: https://drive.google.com/open?id=1ABxeKgNIrKlIsyck7dx4V241NFQDWAF4
Related screen shots: https://drive.google.com/open?id=1U5IbvbVzYW97PuOOQuocvZFE_YJz7WIn



Mr. DoAdministrator
MAME Art Editor
Reged: 09/21/03
Posts: 4742
Loc: California
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Nightvoice]
#388899 - 12/03/20 08:51 PM Attachment: bosco.zip 4017 KB (2 downloads)


> I've run into the same problem with Champion Baseball as I did with Bosconian: it
> won't read the upper left/lower right joystick positions (or vice-versa as was the
> case with Bosconian). Is there a bit mask hitherto unexplored? I initially thought it
> may have been a driver bug, but I'm not sure now that I've run into it twice. See
> attached.

Fix attached... probably better if I explain how the whole inputraw thing works (well, for joysticks at least):

This is the Input_Port settings for Bosconian joystick:

PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY

The default state and inputmask is the sum of all the port_bits that you are grouping together; in this case, u/r/d/l... 1+2+4+8=15, which is f in hex (10=a, 11=b, etc.)

The state in the element for each position is the sum of all the inputs, minus the input you are defining... so RIGHT = 15-2 = 13 = d... UP+LEFT = 15-1-8 = 6

On average, a 4/8-way joystick for many games will have an inputmask of 0xf, but U/D/L/R aren't always in the same order, so you can't always copy/paste from one game to another; only if the inputs are in the same order, with the same port_bits.




RELAX and just have fun. Remember, it's all about the games.




Nightvoice
MAME Fan
Reged: 03/19/10
Posts: 728
Loc: The Room Next To You
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Mr. Do]
#388900 - 12/03/20 10:04 PM


Works great, thanks. I thought we were limited to 1-2-4-8. Guess not. Got every other game to work so far though, except Arch Rivals; it has a 49-way joystick, which is a bit beyond me.



----------------------
I asked my cat what the meaning of life was... he noserized me and stuck his butt in my face.

My MAME/MESS artwork files: https://drive.google.com/open?id=1ABxeKgNIrKlIsyck7dx4V241NFQDWAF4
Related screen shots: https://drive.google.com/open?id=1U5IbvbVzYW97PuOOQuocvZFE_YJz7WIn



MooglyGuy
Renegade MAME Dev
Reged: 09/01/05
Posts: 2086
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Mr. Do]
#388901 - 12/04/20 04:06 AM


> PORT_START("IN0")
> PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
> PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
> PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
> PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
>
> The default state and inputmask is the sum of all the port_bits that you are grouping
> together; in this case, u/r/d/l... 1+2+4+8=15, which is f in hex (10=a, 11=b, etc.)
>
> The state in the element for each position is the sum of all the inputs, minus the
> input you are defining... so RIGHT = 15-2 = 13 = d... UP+LEFT = 15-1-8 = 6

This is not strictly true.

It's true for Bosconian, but your "subtraction" method only holds true if the input definition uses IP_ACTIVE_LOW.

The part that I think you're missing here, and might be helpful to know, is to think of things not in terms of decimal values, or even hexadecimal values to start with, and consider the underlying binary instead.

Modern convention when writing binary numbers is to have the most significant (highest-value) bit to the left, and the least significant (lowest-value) bit to the right. Just like writing any other number, really.

The difference between IP_ACTIVE_HIGH and IP_ACTIVE_LOW is simply which value (0 or 1, respectively) is used to represent a given input "at rest" within the overall port.

Here's where thinking of it as a binary number comes in handy. You can write yourself out a little chart, like this (using Bosconian's input definition as a template):


Code:


LDRU
1111



This represents the state of the input port at rest, because as said above, IP_ACTIVE_LOW means that the corresponding bit will have a value of 1 when at rest.

Just like how each successive digit in a decimal number is worth 10 times the one to the right, each successive digit in a binary number is worth 2 times the one to the right. Just as with decimal, the rightmost position is the "one's" digit. So, going from right to left, we can calculate:

1 + 1*2 + 1*2*2 + 1*2*2*2

Simplifying:
1 + 1*2 + 1*4 + 1*8

Simplifying further:
1 + 2 + 4 + 8 = 15

Now, let's use the chart method to represent Down-Right on the joystick:


Code:


LDRU
1001



As before:
1 + 0*2 + 0*2*2 + 1*2*2*2
1 + 0*2 + 0*4 + 1*8
1 + 1*8
1 + 8 = 9

Lastly, the reason for my suggestion to go with a binary representation in your head is that it makes it much easier to convert between binary and hexadecimal. Why? Because rather than having weirdness when representing digits - where a single-digit hex value of "F" becomes a two-digit decimal value of "15", you can convert every group of four bits into a single hex digit:


Code:


0000: 0
0001: 1
0010: 2
0011: 3
0100: 4
0101: 5
0110: 6
0111: 7
1000: 8
1001: 9
1010: A
1011: B
1100: C
1101: D
1110: E
1111: F



This same property holds true for longer strings of binary numbers:

Code:


1101 1110 1010 1101 1011 1110 1110 1111
D E A D B E E F



Anyway, I don't know if any of this helps to demystify the underlying principles any, or if I've just managed to confuse you more, but hey.



Mr. DoAdministrator
MAME Art Editor
Reged: 09/21/03
Posts: 4742
Loc: California
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: MooglyGuy]
#388904 - 12/04/20 07:39 AM



> Anyway, I don't know if any of this helps to demystify the underlying principles any,
> or if I've just managed to confuse you more, but hey.

No... actually, this makes it all make more sense to me... I didn't actually understand the difference between Active Low vs High, and the way you laid it all out, it's actually logical now.

(I didn't understand "why" the "subtraction" thing worked; I just knew it did).



New question then... I tried to find an example of Active High, and I think I found my first anomaly where I'm stuck:

static INPUT_PORTS_START( espial )
PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START2 )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_COCKTAIL

PORT_START("IN2")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY


Since JOYSTICK_DOWN is in IN1, separate from the other three in IN2, I can't fully animate the upright 8-way stick? (Though I could still do the cocktail version?).




RELAX and just have fun. Remember, it's all about the games.




Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4202
Loc: Melbourne, Australia
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Mr. Do]
#388905 - 12/04/20 11:19 AM


> Since JOYSTICK_DOWN is in IN1, separate from the other three in IN2, I can't fully
> animate the upright 8-way stick? (Though I could still do the cocktail version?).

It can be done with Lua script, but not without. Remind me to show you how to do this one after MAME 0.227 is released (layout scripting is going to change substantially for MAME 0.227).



Nightvoice
MAME Fan
Reged: 03/19/10
Posts: 728
Loc: The Room Next To You
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Vas Crabb]
#388908 - 12/04/20 03:34 PM


> It can be done with Lua script, but not without. Remind me to show you how to do this
> one after MAME 0.227 is released (layout scripting is going to change substantially
> for MAME 0.227).

But everything we've done so far will still work, right?



----------------------
I asked my cat what the meaning of life was... he noserized me and stuck his butt in my face.

My MAME/MESS artwork files: https://drive.google.com/open?id=1ABxeKgNIrKlIsyck7dx4V241NFQDWAF4
Related screen shots: https://drive.google.com/open?id=1U5IbvbVzYW97PuOOQuocvZFE_YJz7WIn



Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4202
Loc: Melbourne, Australia
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Nightvoice]
#388918 - 12/05/20 04:36 AM


> > It can be done with Lua script, but not without. Remind me to show you how to do this
> > one after MAME 0.227 is released (layout scripting is going to change substantially
> > for MAME 0.227).
>
> But everything we've done so far will still work, right?

How many layouts with Lua scripts have you actually done? (To answer the question directly, Lua scripts in layouts will not be compatible between MAME 0.227 and earlier versions. Lua scripting is getting a major overhaul with a lot added functionality, but several incompatible changes.)



Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4202
Loc: Melbourne, Australia
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Mr. Do]
#388921 - 12/05/20 01:46 PM


> Since JOYSTICK_DOWN is in IN1, separate from the other three in IN2, I can't fully
> animate the upright 8-way stick? (Though I could still do the cocktail version?).

See attachment in the comment here: https://github.com/mamedev/mame/commit/c...omment-44831707

If build current master, you can get Espial working now.



Nightvoice
MAME Fan
Reged: 03/19/10
Posts: 728
Loc: The Room Next To You
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Vas Crabb]
#389323 - 12/31/20 08:36 PM


> > Since JOYSTICK_DOWN is in IN1, separate from the other three in IN2, I can't fully
> > animate the upright 8-way stick? (Though I could still do the cocktail version?).
>
> It can be done with Lua script, but not without. Remind me to show you how to do this
> one after MAME 0.227 is released (layout scripting is going to change substantially
> for MAME 0.227).

I got all of my files updated with working ball joysticks, but a few still don't fully work because of this. Just a prayer for the MAME gods to save us again.



----------------------
I asked my cat what the meaning of life was... he noserized me and stuck his butt in my face.

My MAME/MESS artwork files: https://drive.google.com/open?id=1ABxeKgNIrKlIsyck7dx4V241NFQDWAF4
Related screen shots: https://drive.google.com/open?id=1U5IbvbVzYW97PuOOQuocvZFE_YJz7WIn



Mr. DoAdministrator
MAME Art Editor
Reged: 09/21/03
Posts: 4742
Loc: California
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Nightvoice]
#389327 - 01/01/21 12:25 AM


> > > Since JOYSTICK_DOWN is in IN1, separate from the other three in IN2, I can't
> fully
> > > animate the upright 8-way stick? (Though I could still do the cocktail version?).
> >
> > It can be done with Lua script, but not without. Remind me to show you how to do
> this
> > one after MAME 0.227 is released (layout scripting is going to change substantially
> > for MAME 0.227).
>
> I got all of my files updated with working ball joysticks, but a few still don't
> fully work because of this. Just a prayer for the MAME gods to save us again.

This should be in 0.227. Vas posted documentation here:

https://docs.mamedev.org/techspecs/layout_script.html

The only "extra" on here, is that you can't simply run a game with default settings... you need to run it with the extra parameters to get the animation. If I'm reading everything right, you can still run the game with regular artwork, but you will get a warning that if the view you choose requires the plugin, and it is not used, then that view will not work?

He uses Espial as an example on that page, so you should be able to copy/paste that to see it working (I haven't had time to play with it yet).




RELAX and just have fun. Remember, it's all about the games.




Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4202
Loc: Melbourne, Australia
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Mr. Do]
#389333 - 01/01/21 03:47 AM Attachment: espial.zip 5 KB (1 downloads)


> > > > Since JOYSTICK_DOWN is in IN1, separate from the other three in IN2, I can't fully
> > > > animate the upright 8-way stick? (Though I could still do the cocktail
> version?).
> > >
> > > It can be done with Lua script, but not without. Remind me to show you how to do this
> > > one after MAME 0.227 is released (layout scripting is going to change substantially
> > > for MAME 0.227).
> >
> > I got all of my files updated with working ball joysticks, but a few still don't
> > fully work because of this. Just a prayer for the MAME gods to save us again.
>
> This should be in 0.227. Vas posted documentation here:
>
> https://docs.mamedev.org/techspecs/layout_script.html
>
> The only "extra" on here, is that you can't simply run a game with default
> settings... you need to run it with the extra parameters to get the animation. If I'm
> reading everything right, you can still run the game with regular artwork, but you
> will get a warning that if the view you choose requires the plugin, and it is not
> used, then that view will not work?

Yeah, the layout plugin has to be enabled for scripts in layouts to work. The view will still work without the layout plugin, but the joystick won’t visibly move on the screen.

I put the warning message in so the user will know they’re missing something if the plugin isn’t enabled. The cheat, autofire and data plugins are pretty popular, so people should know how to enable plugins in mame.ini by now.

> He uses Espial as an example on that page, so you should be able to copy/paste that
> to see it working (I haven't had time to play with it yet).

Complete scripted Espial artwork zip attached here, including the SVG graphics for the joysticks.

Let’s look at the bit manipulation code in a bit more detail. Here are the input ports for reference:

Code:

PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START2 )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_COCKTAIL

PORT_START("IN2")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY



But for simplicity, we want to rearrange the bits for both joysticks so they effectively look like this for each of the joysticks:

Code:

PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP )    PORT_8WAY
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY



We want the bits to be organised like this, from most significant to least significant (“.” represents an unused bit):

Code:

....RLDU



Let’s look at where the bits are for the first joystick (“.” represents a bit that isn’t used for this joystick):

Code:

IN1: ..D.....
IN2: L..UR...



  • Up is in IN2, and it’s four positions to the left of were we want it. We’ll need to shift it to the right by four positions.
  • Down is in IN2 and it’s also four positions to the left of where we want it, so we’ll need to shift it to the right by four positions as well.
  • Left is in IN2 and needs to be shifted to the right by five positions to get it to the correct place.
  • Right is in IN2, and already in the position we want, so it won’t need to be shifted.


Here’s the code that shuffles the bits for the first joystick:

Code:

p1_stick:set_state(
((in2_val & 0x10) >> 4) | -- shift up from IN2 bit 4 to bit 0
((in1_val & 0x20) >> 4) | -- shift down from IN1 bit 5 to bit 1
((in2_val & 0x80) >> 5) | -- shift left from IN2 bit 7 to bit 2
(in2_val & 0x08)) -- right is in IN2 bit 3


We isolate the bit for each direction using “&”, which is the bitwise and operator, and shift them as necessary with “>>”, the right shift operator (if we needed to shift to the left, we’d use “<<”, the left shift operator). We combine the bits with “|”, the bitwise or operator.

Now we’ll look at where the bits are for the second joystick:

Code:

IN1: .D.URL..



  • Up is in IN1, and it’s four positions to the left of were we want it. We’ll need to shift it to the right by four positions.
  • Down is in IN1 and it’s five positions to the left of where we want it, so we’ll need to shift it to the right by five positions.
  • Left is in IN1 and is is already in the position we want.
  • Right is in IN1, and also in the desired position.


The code to shuffle the bits here should be easy enough to understand now:

Code:

p2_stick:set_state(
((in1_val & 0x10) >> 4) | -- shift up from IN1 bit 4 to bit 0
((in1_val & 0x40) >> 5) | -- shift down from IN1 bit 6 to bit 1
(in1_val & 0x04) | -- left is in IN1 bit 2
(in1_val & 0x08)) -- right is in IN1 bit 3




Nightvoice
MAME Fan
Reged: 03/19/10
Posts: 728
Loc: The Room Next To You
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Vas Crabb]
#389336 - 01/01/21 07:31 AM


I can just about make sense of this, but.... can the properties only be changed for a view item? Or is there a syntax for changing them in a group item, i.e. for a control panel group?



Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4202
Loc: Melbourne, Australia
Send PM


Re: Vas Crabb or Mr. Do: Request for Input new [Re: Nightvoice]
#389339 - 01/01/21 03:02 PM


> I can just about make sense of this, but.... can the properties only be changed for a
> view item? Or is there a syntax for changing them in a group item, i.e. for a control
> panel group?

Groups and collections aren’t real objects in the final scene graph - they get expanded when the view is built up. It will work on elements added to the view via groups. You just want to make sure you have a unique ID for each element you need to access from the script.


Pages: 1

MAMEWorld >> MAME Artwork: Official
View all threads Index   Threaded Mode Threaded  

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