Main > Software Forum
MAME scripty things!
PL1:
--- Quote from: 10yard on November 24, 2021, 06:56:09 pm ---I get problems when using the files downloaded from the Google Drive. These files appear to be out of date. The author has since made some enhancements on github to verify that you are running the defender rom during initialisation.
Scott - Can you replace with github files and repeat your tests.
--- End quote ---
Nice catch, Jon. :cheers:
Init.lua on the Google Drive is exports.version = '1' and the one on Github is exports.version = '2'.
(Plugin.json from both locations has the same SHA-1 so they are confirmed identical.)
The "Code" button on the https://github.com/AaronBPaden/defenderlr page doesn't seem to work with either of my browsers. :banghead:
Good news:
By clicking on the filename then on the "Raw" button on the right side just above the first line of code, the file opens in the browser and you can save it.
https://raw.githubusercontent.com/AaronBPaden/defenderlr/master/init.lua
SHA-1: 67248D36DE5D72156C2563423D711738320926DD
https://raw.githubusercontent.com/AaronBPaden/defenderlr/master/plugin.json
SHA-1: DB56FA79742545F012C08464B17ABBDA65F21110
Mixed news:
Tried the files saved from those links with the command line you posted for Defender.
- As expected, the command line you posted launches the game and plugin. No custom .ini file needed for this approach.
- If you launch from the MAME built-in FE you'll need the defender.ini file with "plugin defenderlr".
There are definite improvements in v2 like being able to run the MAME built-in FE by just launching the executable.
There are also definite stability issues, usually when switching between games.
- If you don't change games, it appears to be very stable. ;D
- When you try to switch to a different game, sometimes it works but sometimes it locks up -- around 50-50 odds. :dunno
- The instability could also be caused by my e-mail client or browser pages auto-refreshing and bogging things down.
-- I've never seen that cause problems in MAME before, but this old system is getting a bit squirrely. :embarassed:
- Tomorrow I'll try adding a few more games to see if there's any instability when switching between them or if it's only triggered when Defender and this plugin are involved.
Scott
10yard:
--- Quote from: PL1 on November 24, 2021, 09:43:25 pm ---Mixed news:
Tried the files saved from those links with the command line you posted for Defender.
- As expected, the command line you posted launches the game and plugin. No custom .ini file needed for this approach.
- If you launch from the MAME built-in FE you'll need the defender.ini file with "plugin defenderlr".
There are definite improvements in v2 like being able to run the MAME built-in FE by just launching the executable.
There are also definite stability issues, usually when switching between games.
- If you don't change games, it appears to be very stable. ;D
- When you try to switch to a different game, sometimes it works but sometimes it locks up -- around 50-50 odds. :dunno
- The instability could also be caused by my e-mail client or browser pages auto-refreshing and bogging things down.
-- I've never seen that cause problems in MAME before, but this old system is getting a bit squirrely. :embarassed:
- Tomorrow I'll try adding a few more games to see if there's any instability when switching between them or if it's only triggered when Defender and this plugin are involved.
Scott
--- End quote ---
I was able to replicate your reported stability issues when switching between games in the mame frontend.
I found this to be due to the input capture routine (input:seq_pressed) still being active after user presses escape key (to exit the game).
I fixed the issue by clearing out input variables and unregistering the frame callback on exit and when starting up a game that is not defender.
Updated plugin files are in the zip.
If you are able to test again Scott and confirm all good. I will submit my changes to the author so hopefully he can update his git repo.
Jon
PL1:
--- Quote from: 10yard on November 25, 2021, 08:23:21 am ---I fixed the issue by clearing out input variables and unregistering the frame callback on exit and when starting up a game that is not defender.
Updated plugin files are in the zip.
If you are able to test again Scott and confirm all good. I will submit my changes to the author so hopefully he can update his git repo.
--- End quote ---
:applaud: :notworthy: :applaud: :notworthy: :applaud:
Confirmed. Your updated files look rock solid. :cheers:
I know the "defender.ini" file is really simple, but it wouldn't hurt to include it on the Github.
The other thing that he should have is a Readme.md file to explain the plugin and how to use it for those who are . . . less technically inclined . . . and don't know how the MAME plugin system works. ;)
Maybe something like this?
The opening is mostly borrowed from his Reddit post here.
One unknown item is whether or not the plugin works with versions of MAME before v0.231. :dunno
- One Redditor tried it with v0.167, but that version was way too old for some of the features in the script.
--- Quote ---The defenderlr plugin
This plugin is adapted from the original by oomek here and works with MAME [v0.231?] or newer.
It should work with whatever you have configured to act as a joystick with no configuration.
I know someone asks about defender every few months, and I've been meaning to get this working for me for a long time, but I've just now gotten around to it. This makes the game way more playable, though I still prefer Defender II for the 2600. The enemies in the arcade original are pretty devious and dodge your laser gun like alien ninja.
A note about the implementation. I tried to avoid writing to memory by detecting the facing of the player and triggering the reverse button, but it didn't work. While I was able to successfully detect the facing, triggering the reverse button didn't reliably work and I couldn't figure out why. So I fell back to the behavior in the original plugin of writing to memory. There doesn't seem to be any side-effects from casual observation.
Anyway the fact that you can do this with no modifications to mame is pretty cool.
Configuring MAME
Can you launch Defender in MAME? "mame.exe defender"
- If not, you need to find the correct version of the "defender.zip" ROM file for your version of MAME and put it the "\mame\roms" folder. (ROM not provided here.)
If you don't already have one, create a mame.ini file using the "mame -cc" (create config) command.
- Open it in Notepad and verify that it contains "plugins 1". (enabled)
--- Code: ---#
# SCRIPTING OPTIONS
#
autoboot_command
autoboot_delay 0
autoboot_script
console 0
plugins 1
--- End code ---
- Next, check the paths for inis and plugins so you know where to put those files so MAME can find them.
For example, "inipath .;ini;ini/presets" indicates that MAME will look for ini files in three folders "\mame\", "\mame\ini\", and "\mame\ini\presets\".
--- Code: ---#
# CORE SEARCH PATH OPTIONS
#
homepath .
rompath roms
hashpath hash
samplepath samples
artpath artwork
ctrlrpath ctrlr
inipath .;ini;ini/presets
fontpath .
cheatpath cheat
crosshairpath crosshair
pluginspath plugins
--- End code ---
Make a "\mame\plugins\defenderlr\" folder.
- Put the init.lua and plugin.json plugin files in that folder.
Make a text file named "defender.ini" in either the ini folder or the same folder as the MAME executable.
- It should contain the text "plugin defenderlr".
Enable the defenderlr plugin via the MAME user interface "plugins" menu.
or
Edit the "plugin.ini" file and change "defenderlr 0" (disabled) to "defenderlr 1". (enabled)
--- Code: ---#
# PLUGINS OPTIONS
#
autofire 0
cheat 0
cheatfind 0
commonui 0
console 0
data 1
defenderlr 1
--- End code ---
Now you're ready to play Defender and blast those pesky aliens. :)
--- End quote ---
Scott
10yard:
--- Quote from: PL1 on November 25, 2021, 11:43:49 am --- :applaud: :notworthy: :applaud: :notworthy: :applaud:
Confirmed. Your updated files look rock solid. :cheers:
--- End quote ---
Fantastic! Thanks for testing.
--- Quote from: PL1 on November 25, 2021, 11:43:49 am ---I know the "defender.ini" file is really simple, but it wouldn't hurt to include it on the Github.
The other thing that he should have is a Readme.md file to explain the plugin and how to use it for those who are . . . less technically inclined . . . and don't know how the MAME plugin system works. ;)
Maybe something like this?
The opening is mostly borrowed from his Reddit post here.
--- End quote ---
Yes, the readme and ini files will be a great help to most. Thanks for pulling them together.
--- Quote from: PL1 on November 25, 2021, 11:43:49 am ---One unknown item is whether or not the plugin works with versions of MAME before v0.231. :dunno
- One Redditor tried it with v0.167, but that version was way too old for some of the features in the script.
--- End quote ---
Compatibility should be possible back to v0.196 but a tweak will be required for that. I discovered this myself when building the LUA interface for my DK frontend.
We must account for a change to MAME's LUA data structures when initialising the machine.
Instead of:
--- Code: ---input = manager.machine.input
ioport = manager.machine.ioport
memory = manager.machine.devices[':maincpu'].spaces['program']
--- End code ---
We need to run a version check and also check the userdata structure (since this changed ~v0.227 too!). Also nice to output a warning if it's not going to work (pre v0.196). Something like this should work.
--- Code: ---if tonumber(emu.app_version()) >= 0.196 then
if type(manager.machine) == "userdata" then
mac = manager.machine
else
mac = manager:machine()
end
input = mac.input
ioport = mac.ioport
memory = mac.devices[':maincpu'].spaces['program']
else
print("ERROR: This plugin requires MAME version 0.196 or greater.")
end
--- End code ---
I have a test system set up already for 0.196, 0.227 and 0.238 so will verify against them all. If that's good then i'll post the updated plugin here and sync with the author on github.
Jon
10yard:
The updated defenderlr plugin is attached and is bundled with the readme file as prepared by PL1.
This is a stability fix to ensure the plugin does not lockup on exit or when switching games in the MAME frontend.
I can verify that the plugin will work with MAME v0.227 and greater. To go back to v0.196 would require some work as some of the key LUA functionality was not available in the earlier versions (i.e. type_seq). I don't want to start hacking up the code further so have let it be at that.
I'm pleased to have stumbled across this Defender plugin. It's a much nicer way to control the ship.
Thanks to Scott for his thorough (as usual) breakdown of the issue.
Edit - I have messaged Aaron (the author of defenderlr) with the hope that he will merge my changes and the readme from PL1.
Jon
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version