Previous Thread
Next Thread
Print Thread
Page 1 of 2 1 2
#106364 07/05/16 09:42 PM
Joined: May 2012
Posts: 555
Likes: 1
S
Senior Member
OP Offline
Senior Member
S
Joined: May 2012
Posts: 555
Likes: 1
I'd like to run a few dozen of automated tests on the driver I'm working on, and lua looks useful for this. Ideally, the tests should check screen contents while they are running, but I can get by without that -- i.e. stuff some keyboard input, wait a while, stuff more input, capture a screenshot, repeat.

How can I manipulate dip switches, though? "for k,v in pairs(manager:machine():ioport().ports) do print (k) end" enumerates them, but "print (manager:machine():ioport().ports[':SA1'].fields[':'])" fails with:

attempt to index a userdata value (field ':SA1')

Joined: Jan 2012
Posts: 883
Likes: 12
C
Senior Member
Offline
Senior Member
C
Joined: Jan 2012
Posts: 883
Likes: 12
You can't just print fields as it's a pointer to a C class. You need to do call a function that can operate on it. Here's the list https://github.com/mamedev/mame/blob/master/src/frontend/mame/luaengine.cpp#L2415 . If you want to read the port though you'd use ports[':SA1']:read(). Here's something I wrote to automate finding credit cheats that's an example http://www.mamecheat.co.uk/forums/viewtopic.php?f=2&t=12245 . There is a way to take screenshots too https://github.com/mamedev/mame/blob/master/src/frontend/mame/luaengine.cpp#L2469 .

Last edited by crazyc; 07/05/16 09:59 PM.
Joined: May 2012
Posts: 555
Likes: 1
S
Senior Member
OP Offline
Senior Member
S
Joined: May 2012
Posts: 555
Likes: 1
Instead of screenshots, I'm thinking of taking md5 hash of frame buffer; there's a pure lua impl of md5 at https://github.com/kikito/md5.lua, haven't checked yet if lua can get at the actual displayed pixels.

Joined: Jan 2012
Posts: 883
Likes: 12
C
Senior Member
Offline
Senior Member
C
Joined: Jan 2012
Posts: 883
Likes: 12
Looks like it currently can't put a screen shot in a buffer. It would either have to be added or you'd have to save the shot to a file then open it again.

Joined: May 2012
Posts: 555
Likes: 1
S
Senior Member
OP Offline
Senior Member
S
Joined: May 2012
Posts: 555
Likes: 1
Some progress using plan B ("stuff some keyboard input, wait a while, stuff more input, capture a screenshot, repeat") and kyua + atf + lua + pngcmp.

Code:
% kyua test
ms1201_tests.sh:t00  ->  passed  [0.028s]
ms1201_tests.sh:t01  ->  passed  [3.926s]
ms1201_tests.sh:t02  ->  passed  [7.742s]
ms1201_tests.sh:t03  ->  passed  [4.499s]
ms1201_tests.sh:t04  ->  passed  [8.230s]
ms1201_tests.sh:t11  ->  passed  [11.441s]
ms1201_tests.sh:t12  ->  failed: atf-check failed; see the output of the test for details  [7.314s]
ms1201_tests.sh:t13  ->  passed  [7.197s]
ms1201_tests.sh:t14  ->  passed  [251.440s]
ms1201_tests.sh:t21  ->  failed: atf-check failed; see the output of the test for details  [16.619s]
ms1201_tests.sh:t22  ->  passed  [17.719s]
ms1201_tests.sh:t23  ->  passed  [19.205s]
ms1201_tests.sh:t24  ->  passed  [98.905s]
ms1201_tests.sh:t25  ->  passed  [8.900s]
ms1201_tests.sh:t26  ->  passed  [9.995s]
ms1201_tests.sh:t31  ->  passed  [13.914s]
ms1201_tests.sh:t32  ->  passed  [28.393s]
ms1201_tests.sh:t33  ->  passed  [25.903s]
ms1201_tests.sh:t41  ->  passed  [5.015s]
ms1201_tests.sh:t42  ->  failed: atf-check failed; see the output of the test for details  [72.094s]


'passing' test just means that emulator didn't crash and screenshots match, some of the actual tests running in the emulator are failing; not sure how to report that to atf.

Joined: May 2012
Posts: 555
Likes: 1
S
Senior Member
OP Offline
Senior Member
S
Joined: May 2012
Posts: 555
Likes: 1
Apparently Lua cannot control cassette tape motor, or am I missing something?

Joined: Jan 2006
Posts: 3,690
Very Senior Member
Offline
Very Senior Member
Joined: Jan 2006
Posts: 3,690
LUA can only access port defined in the driver and not the UI inputs.
I hope someone can lift eventually this limitation, but I've been unable to make it smile

Joined: May 2004
Posts: 1,740
Likes: 8
H
Very Senior Member
Offline
Very Senior Member
H
Joined: May 2004
Posts: 1,740
Likes: 8
should the cassette player buttons not be actual emulation buttons anyway? for external cassette players they should be devices, with buttons..

you might have more than one (if we emulate tape-to-tape recorders etc.)

just putting it out there, but the concept that play/stop/record with a single cassette player driven directly by the core seems to be one of the more outdated concepts we have.

Joined: Jan 2006
Posts: 3,690
Very Senior Member
Offline
Very Senior Member
Joined: Jan 2006
Posts: 3,690
we already can have more than one, if you control the cassette drive from the internal menu (you just toggle between the drives in the UI)
it's only the shortcut key that is by default mapped to drive 1 and cannot control further drives

that said, I agree it would be great to make cassette players devices with inputs rather than devices whose inputs are handled by the core, it's just a problem of finding the time to do it

Joined: Aug 2015
Posts: 405
Senior Member
Offline
Senior Member
Joined: Aug 2015
Posts: 405
Isn't the cassette interface just a serial bit stream with modulation? There are also modems and fax machines in the same theme so maybe there are some similarities that can be generalized and tested together.


Because I can
Page 1 of 2 1 2

Link Copied to Clipboard
Who's Online Now
1 members (1 invisible), 31 guests, and 1 robot.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,158
Posts119,916
Members5,034
Most Online1,283
Dec 21st, 2022
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Forum hosted by www.retrogamesformac.com