Jump to content
ClockworkRobot

Analogue Hall Effect Arcade joystick for the Vectrex?

Recommended Posts

I think you've done a great job as usual, Jim! 👍

If I had some kind of Arcade cabinet to put this in, I'd be all over it! 😁

Share this post


Link to post
Share on other sites

That's great! Funny, that I finished today a "poor man's version" of an analog vectrex Flight stick, made only with parts that I happened to have. 🙂

 

 

Share this post


Link to post
Share on other sites

Here's some sneaky code (easily enough converted to ASM) that will take an analog joystick position and work out the direction of the handle, snapped to 16 compass points.  (I eventually managed to tweak this to avoid any expensive divides. There are a few 16 bit comparisons though.) Might come in useful.

 

(Do your own magnitude test if you need that too - remember comparing x^2+y^2 against r^2 is cheaper than comparing the square roots of both and gives the same result.)

 

static const int map[4][5] = {  
   {0, 1, 2, 3, 4},
   {8, 7, 6, 5, 4},
   {0, 15, 14, 13, 12},
   {8, 9, 10, 11, 12}
};

int sector(int x, int y) { 
  long tangent; 
  int quadrant = 0;
  if (x > 0) x = -x; else quadrant |= 2; 
  if (y > 0) y = -y; else quadrant |= 1;
  if (y != 0) {
    
    tangent = (long)x*32L;   
    
    if (tangent > y*6L  ) return map[quadrant][0]; 
    if (tangent > y*21L ) return map[quadrant][1]; 
    if (tangent > y*47L ) return map[quadrant][2]; 
    if (tangent > y*160L) return map[quadrant][3]; 
    
  }
  return map[quadrant][4];
}

Full test program in http://gtoal.com/vectrex/joystick-direction.c.html

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...