top of page

MacFlight: A MAME plugin for retro Mac flight sims


MacFlight with debug overlay
MacFlight with debug overlay

I've recently written my first MAME plugin 'MacFlight'. It's job is to turn a relative axis into an absolute one. It does this by looking for the X and Y axes of a joystick controller, translates this into a position on screen which is then converted to a mouse input. This means the your joystick controls the mouse and the mouse operates like a joystick. This is what you need for retro Mac flights sims!



Background


From an earlier blog post:

Joystick axes are normally absolute axes, they report exactly where they are. For example, if you use Win10 joy.cpl to test moving your joystick x-axis then moving your stick to the right would cause the pointer in the axes box to move to the right but releasing the stick would cause the pointer to jump to the centre position again. This is what we want in flight sims.
But a mouse uses relative axes, you move your mouse to the right the mouse pointer moves right, you stop moving the mouse and the pointer stays exactly where it is. This is what you want from a mouse.
As retro Macs treated their joysticks like a mouse device it used relative axes. So if you release a Mac joystick it doesn't snap back to a centre position. This is not what we want in Mac flight sims!
When trying to fix this I came across, an interesting utility ajoy2mouse on aminet. Used with the Mac emulator Shapeshifter on the Amiga, it does for the emulator what the Gravis applets did for their joysticks.

How it works


MacFlight works by first identifying the joystick devices MAME can see, If there is only one it uses it, otherwise it searches for the first device called joystick. It then finds the x and y axes of this device.


If you are running a profile for a number of devices (eg. joystick and throttle), the profile software may create a virtual device which appears as a single device to MAME. It may not be called joystick so if there's only one joystick device, MacFlight uses it.


It then identifies the screen resolution, which is used to calculate the mouse position and then waits 45 seconds for the emulated Mac to start, before getting the MAME memory manager for the emulated Mac. This gives the emulated Mac time to complete initialising before MacFlight starts sending mouse position data. Sending data before the Mac has started can cause it to fail.


Each time a frame is rendered the x and y axis of the joystick device is read and a new mouse position calculated. This calculated mouse x and y position is then sent by the MAME memory manager to the location used by the emulated Mac to store the mouse x and y co-ordinates. The memory locations are dependant on the configured memory of the emulated Mac.


Prerequisites


MAME v0.260 with a working emulated Quadra 800 configured with 32M of memory. Different memory configurations may not work due to a different memory location used to store the mouse co-ordinates.


Update: MacFlight v1.2 now supports 32, 64 or 128M memory configurations.


Installation


Download the MacFlight plugin and extract into the MAME plugins folder. There should be a macflight folder containing 2 files: init.lua and plugin.json.


Running


Run MAME with the following command:

mame macqd800 -hard1 mac761.chd -ramsize 32M -cheat -plugin macflight

Note: your hard disk image may have a different name.


After 45 seconds the mouse pointer should jump to the middle of the emulated Mac screen and the mouse pointer should be controllable with the joystick.


You may want to use MAME input settings to add a joystick button to the mouse click action, otherwise you still have to use your mouse button to click!


Debugging


To see the joystick that MacFlight found, run MAME with the following command:

mame macqd800 -hard1 mac761.chd -ramsize 32M -cheat -plugin macflight 
-w -console
Macflight in the MAME console
MacFlight logging in the MAME console

This opens the emulated Mac in a window (-w) and also opens a console window (-console) within the console you should see the joystick device and x/y axes found along with the emulated screen resolution.






If the emulated Mac needs longer to start, open init.lua in a text editor and search for the following:

-- time to wait (in seconds) for machine to start
local WAIT = 45;

Change WAIT to a larger amount of time, save the file and restart MAME.



To run MacFlight with the debugging overlay enabled, open init.lua and search for the following near the bottom of the file:

-- debugging overlay
-- emu.register_frame_done(draw_overlay, 'frame')

Uncomment the second line:

-- debugging overlay
emu.register_frame_done(draw_overlay, 'frame')

Restart MAME, you should now see the debugging info and joystick axes position.



Download


MacFlight v1.3 plugin.

  • Supports multi-monitor 640x480, 832x624 or 1152x870 resolutions (only at 128M memory).

macflightv13
.zip
Download ZIP • 3KB


MacFlight v1.2 plugin.

  • Now supports ram sizes 64M and 128M in addition to 32M.

macflightv12
.zip
Download ZIP • 3KB


MacFlight v1.1 plugin.

  • Now supports resolutions 832x624, 1024x768, 1152x870 in addition to 640x480.

  • Refactored screen resolution handling as MAME will always start the Mac in 640x480 before changing resolution.

  • Will now list all joystick devices and device items on the console, if an x or y axis can't be found.

macflightv11
.zip
Download ZIP • 3KB


MacFlight v1.0 plugin.

macflight
.zip
Download ZIP • 3KB

Future enhancements

  • The mouse pointer memory locations seem to be dependant on the configured memory, add locations for common memory sizes (eg. 64M 128M, etc). Hopefully they don't change with a 32M setup!

  • The joystick device and axes selection was based on my own setup, not sure how robust it is as other devices may report themselves to MAME differently.

  • Not sure how it works with an emulated multi-monitor setup, that still needs testing/fixing.

bottom of page