Previous Thread
Next Thread
Print Thread
Joined: Feb 2014
Posts: 589
Likes: 5
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 589
Likes: 5
Hi guys,

I was configuring a machine's slots using the UI, and getting everything "just right", with the different devices and options and then having to figure out the CLI options to launch that from a command line.

Sometimes its really difficult to get the options and names just right.

It should be possible to use the manager:machine().devices table to extract the slot options from the device tag:

Code
function printt(t) for i,j in pairs(t) do print(i,j) end end
printt(manager:machine().devices)

function match_string(a) for word in string.gmatch(a,"([%a%d_]+)") do print(word) end end
for i,j in pairs(manager:machine().devices) do print("device "..i) match_string(i) end

Code
device :sl1:parallel:pic_ctx:ap2000
sl1
parallel
pic_ctx
ap2000

which map to the options:

-sl1 parallel -sl1:parallel:pic_ctx ap2000

Of course, there's a lot of devices that aren't relevant and would need to be filtered out like:
Code
device :sl1:parallel:pic_ctx:ap2000:cr_stepper
sl1
parallel
pic_ctx
ap2000
cr_stepper

and you could inspect the images table to get the mounted floppies and hard drives:

Code
for i,j in pairs(manager:machine().images) do 
         print("device "..i) match_string(i) 
         print("filename = "..manager:machine().images[i]:filename()) 
end

device flop1
flop1
filename = /home/Downloads/ColorPrintShop.DSK



Just an idea I was playing with.

Joined: Mar 2001
Posts: 16,715
Likes: 11
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 16,715
Likes: 11
I'm not quite sure what you're going for here, but -listslots and -listmedia do those things.

Joined: Feb 2004
Posts: 2,237
Likes: 6
Very Senior Member
Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,237
Likes: 6
You can also view it dynamically in a front-end, or using the minimaws sample script.

Joined: Feb 2014
Posts: 589
Likes: 5
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 589
Likes: 5
To give more of an example:

I use the UI to configure the slots of the ct486 just the way I like it, then I reset to use that configuration:

[Linked Image from i.imgur.com]

and then I spend a bit of time to figure out how to reproduce that config from the command line.


True, -listslots will give you a list of all the options.

Ohh, ok, you can also change the configuration from the default to see all of the possibilities (I didn't know that, well I learned something)

./mame64 ct486 -isa1 ultra14f -listslots

isa1:ultra14f:scsi:0 cdd2000 Philips CDD2000 CD-R
cdr4210 Creative Technology Blaster CD-R 4210
cdrn820s Caravelle CDR-N820s
cdrom SCSI CD-ROM
cw7501 Panasonic CW-7501 CD-R
harddisk SCSI Hard Disk
s1410 Xebec S1410 5.25 Inch Winchester Disk Controller
smoc501 Sony SMO-C501 MO Disk Controller


and specifying your files with file manager:

[Linked Image from i.imgur.com]


and then a lua script could take all of the slots and files you set up in the UI and give you a command line that would reproduce exactly that configuration.

-board4:lpt:lpt:centronics ap2000 -hard1 hd128MB -hard2 hd128MBpt



Hmmm, minimaws looks very interesting, thanks for the pointer, Vas. (now I have to look up the word elide 8-)

Joined: Mar 2001
Posts: 16,715
Likes: 11
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 16,715
Likes: 11
Yeah, -listslots and -listmedia do change according to the other slot options you specify. That's how frontends that support it (I think only QMC2 still, but I may be wrong) dynamically change the options.

For instance, if you remove the Disk II controller from the default apple2e configuration, -listmedia will only show the cassette.

Joined: Feb 2014
Posts: 589
Likes: 5
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 589
Likes: 5
I added this to luaengine.cpp and it seems to give me all of the options that aren't "default":

Code
	machine_type.set("slotoptions", sol::property([this](running_machine &r) {
			std::string result;
			for (device_slot_interface &slot : slot_interface_iterator(r.root_device()))
			{
				if (slot.has_selectable_options())
				{

					if (machine().options().slot_option(slot.slot_name()).specified_value().compare(std::string("")) != 0)
						result += (std::string("-")+std::string(slot.slot_name())+" "+
									machine().options().slot_option(slot.slot_name()).specified_value().c_str()+
									std::string("\n"));
				}
			}
			return result;
		}));
		



and from the console:

Code
[MAME]> print(manager:machine().slotoptions)
-board3:ide:ide:1 hdd
-board4:lpt:lpt:centronics ap2000

and if I change a bunch of options and reset:

Code
[MAME]> print(manager:machine().slotoptions)
-board3:ide:ide:1 hdd
-board4:lpt:lpt:centronics ap2000
-isa3 aha1542b
-isa3:aha1542b:scsi:0 cdd2000
-isa3:aha1542b:scsi:1 cdr4210
-isa3:aha1542b:scsi:3 cdd2000



and put together with this lua script:

Code
print (manager:machine():system().name) 
print (manager:machine().slotoptions) 
for i,j in pairs(manager:machine().images) do 
    if j:filename() ~= nil then print("-"..i.." "..j:filename().." ") 
    end
end


will give for example:

Code
cpc6128
-centronics ap2000

-floppydisk1 prntmast 
-flop1 prntmast 

Last edited by Golden Child; 10/26/20 02:28 AM.
Joined: Feb 2014
Posts: 589
Likes: 5
G
Senior Member
OP Offline
Senior Member
G
Joined: Feb 2014
Posts: 589
Likes: 5
And if you want all of the specified slot options, how about a slotoptionsfull:

Code
machine_type.set("slotoptions", sol::property([this](running_machine &r) {
			std::string result;
			for (device_slot_interface &slot : slot_interface_iterator(r.root_device()))
			{
				if (slot.has_selectable_options())
				{
					std::string specified_value = machine().options().slot_option(slot.slot_name()).specified_value();
					if (specified_value.compare(std::string("")) != 0)
					{
						result += (std::string("-")+std::string(slot.slot_name())+" "+
									specified_value.c_str()+
									std::string("\n"));
					}
				}
			}
			return result;
		}));


	machine_type.set("slotoptionsfull", sol::property([this](running_machine &r) {
			std::string result;
			for (device_slot_interface &slot : slot_interface_iterator(r.root_device()))
			{
//				if (slot.has_selectable_options())
				{
					{
						result += (std::string("-")+std::string(slot.slot_name())+" "+
									machine().options().slot_option(slot.slot_name()).value().c_str()+
									std::string("\n"));									
					}
				}
			}
			return result;
		}));


and trying it out:

Code
[MAME]> print(manager:machine().slotoptions)
-board3:ide:ide:1 hdd
-board4:lpt:lpt:centronics ap2000

[MAME]> print(manager:machine().slotoptionsfull)
-kbd ms_naturl
-board1 fdcsmc
-board1:fdcsmc:fdc:0 35hd
-board1:fdcsmc:fdc:1 35hd
-board2 comat
-board2:comat:serport0 logitech_mouse
-board2:comat:serport1 
-board3 ide
-board3:ide:ide:0 hdd
-board3:ide:ide:1 hdd
-board4 lpt
-board4:lpt:lpt:centronics ap2000
-isa1 svga_et4k
-isa2 
-isa3 
-isa4 
-isa5 

[MAME]> 



Link Copied to Clipboard
Who's Online Now
3 members (Stiletto, R. Belmont, Hydreigon), 33 guests, and 3 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics8,919
Posts117,179
Members4,989
Most Online890
Jan 17th, 2020
Forum Host
These forums are hosted by www.retrogamesformac.com
Forum hosted by www.retrogamesformac.com