Urban Interactive – Project Development Blog

Some Boring But Important Stuff Done…

Posted in ROTJ by urbaninteractive on April 17, 2009

This week I worked on the behind the scenes stuff this week as my brain hasn’t been working very well due to sleep deprivation (though I’m loving being a father).  So what have I achieved between changing nappies and working?

+ Added config.ini file, allowing users to change settings to suit their systems (Screen Size, Controller Options, Game Play options, Invert Y axis etc).

+ Added user interface to change all these setting direct from within the game.

I’ve also added Analogue joystick support now.  In fact pretty much everything input is customizeable now.  In the past I could never figure out how to make the joystick work like a mouse and then it hit me… it’s so simple I felt stupid when I figured it out.  Anyway it works lovely now and when I get time I may add this to my 3D Star Strike remake. 

I’m concentrating on making the game “Mame Cab Friendly”.  By this I don’t mean it will run on Mame, but rather it could be installed on the same machine as Mame and use the same keystrokes etc.  Therefore if you have a Mame cab that has a coin door then my game will read these inputs as well.  The idea being you can have all the Star Wars vector games in one cab, and it should be transparent to the user what the game is actually running the game.

Advertisements

4 Responses

Subscribe to comments with RSS.

  1. StuC said, on April 17, 2009 at 4:32 pm

    Makes me want to resurrect my MAME cab build project…….

  2. urbaninteractive said, on April 17, 2009 at 8:43 pm

    Go for it… you have plenty of your own games which would look pretty cool on a 25″ monitor. In fact you should go the whole hog and make a real version of your Whack-A-Monty-Mole. Btw like the new look on your site, and belate Happy 40th fella.

  3. Xiaou2 said, on April 18, 2009 at 1:44 am

    Just to be clear…

    A joystick isnt treated or read like a mouse.

    A joystick has 2 ‘pots’ which are like volume knob dials:
    One for X (horizontal)
    One for Y (Vertical )

    The pots in the arcade are 5 ohms I believe. So, at full left, they would register
    0. At full right… 5. (raising or lowering decimal values) When the current is translated to computer… its usually assigned a ‘range’ from something like 0 – 255. This would give the player 255 possible values.

    In a game like Starwars, the pots have two gears driving them. This means that it takes less control movment to turn the pots further. Thus using almost all of the pots
    full travel used – to give the most possible Ranges of values.

    (you dont have to worry about gearing. Calibration routines will handle it)

    In analog joystick games, I believe the ranges are then calibrated to actual screen
    coordinates. So.. value x255,y255 on a 1024*768 screen would place the cursor
    in the furthest corner (if 255 is max value, and calibration is correct).

    Pots have the potential to de-calibrate. Usually this is simply due to the gears
    slipping. Or the centering springs not quite centered anymore when the game
    starts. I think it may also de-calibrate electrically when the pot wears, gets dirty,etc.

    Starwars had an Auto-Calibration system. AFAIK, the game monitored the values
    that came up… and could tell if the calibration point for ‘middle’ of the screen
    was off… and then it would auto fix the values to align to the correct screen
    positions. Starwars was an exception to many games, in that many arcade
    games require the Operator to go through a calibration routine before the game
    is ready for the public. The data is saved, and so the Op wont have to recalibrate
    unless the battery dies, or the players complain that the game isnt working
    quite right.

    A mouse is similar to a pot.. but, a mouse has no limits to how far it can travel.
    Building a Starwars yokes with mice guts instead of pots would actually cause
    problems. (a few have built like this, and they regretted it)

    You see… if the program stutters, or does not have exact perfect timing
    (game and or windows).. the device will de-calibrate. And, since there is no way to tell how far the mouse has traveled in either direction.. the game can not correct the calibration.

    With a pot, there is always a consistent set of values which can be read, reported,
    checked against previous data and last known positions.

    If you try to make the game react like a mouse, and make the joystick add
    a little bit of roll to it (adding values to roll the simulated mouse ball), it will not
    have correct calibration.. and not work well with real yokes.

    For example.. if I HOLD the yoke in the upper-mid-left… I want the cursor to
    Stay there. I dont want to put the yoke in that place.. and have the
    cursor continue to move.

    Now, there are two different mouse methods: typical, and Relative.

    Relative mouse positioning is used for Drawing tablets such as the Wacoms.
    Where you can drop the Electronic pen anywhere in the tablet, and the mouse
    pointer will “Snap” instantly to that same relative position on the screen.

    Relative is basically how Pots work.

    Normal mice are not relative. They have no idea where they are in relation to
    anything.

    • urbaninteractive said, on April 18, 2009 at 6:40 am

      Steve, you completely correct. This is how I handle the joystick today…

      I receive an X and Y input from the joystick. These values range from -1 to 1, with zero being the theoretical centre of the joystick movement on the given axis. Since I know the screen resolution the game is running in, I can calculate the two ratios which can be multiply by the joystick inputs to return a relative position on the screen. Here’s the code…

      ‘/// gameConfig.sw = is the screen width
      ‘/// gameConfig.sh = is the screen height

      ‘/// gameConfig.jyMaxX = is the largest X value the joystick returned
      ‘/// gameConfig.jyMinX = is the smallest X value the joystick returned

      ‘/// gameConfig.jyMaxY = is the largest Y value the joystick returned
      ‘/// gameConfig.jyMinY = is the smallest Y value the joystick returned

      gameConfig.xjyratio = gameConfig.sw / (gameConfig.jyMaxX – gameConfig.jyMinX)
      gameConfig.yjyratio = gameConfig.sh / (gameConfig.jyMaxY – gameConfig.jyMinY)

      ‘/// Now to position the cursor position I use the following functions…

      Function GetCursorX:Float()
      If gameConfig.controllerType = JOYSTICK Then
      Return gameConfig.hw + gameConfig.xjyratio * JoyX(gameConfig.JyPort)
      End If
      If gameConfig.controllerType = MOUSE Then
      Return MouseX()
      End If
      End Function

      Function GetCursorY:Float()
      If gameConfig.controllerType = JOYSTICK Then
      If gameConfig.invertedY = False Then
      Return gameConfig.hh + gameConfig.yjyratio * JoyY(gameConfig.JyPort)
      Else
      Return gameConfig.hh – gameConfig.yjyratio * JoyY(gameConfig.JyPort)
      EndIf
      End If
      If gameConfig.controllerType = MOUSE Then
      Return MouseY()
      End If
      End Function

      I do have a calibration routine working which gathers the min and max values of the each axis, and have been considering auto calibrating during the game as well. I will work on that in a few weeks time, as I need a joystick that auto centres first. So to conclude with the above code if you hold your joystick upper mid right then the cursor will stay there, it will not drift off. Just one important note, the game will not work with a digital joystick. The inputs must be analogue.

      Mice, as you correctly say are dealt with in a completely different way, and I wouldn’t expect any MAME cab guys to use a mouse to control this game. The mouse is there for users who may fancy a quick blast, and don’t want to hook up joystick and then calibrate them etc.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: