SCRYDOSBox-XReferenceReadscreen_map_findAlso in MAME
screen_map_find
Name the screen your program is showing, from its screen map: a file of the program's screens and the named areas of each.
screen_map_find()
Try it
screen_map_write below.Which screen is the game showing?
screen_map_find(){
"summary": "screen_map_find: play (file), 1 control",
"matched": true,
"screen": "play",
"layer": "file",
"controls": [
{"name": "court", "rect": [200, 80, 80, 40], "centre": [240, 100]}
]
}The game shows play, a screen of the loaded file (layer file). Its area court is the rectangle at 200, 80, with its centre at 240, 100.
The whole reply
{
"summary": "screen_map_find: play (file), 1 control",
"status": "ok",
"matched": true,
"screen": "play",
"layer": "file",
"kind": "pixel",
"size": [320, 200],
"controls": [
{"name": "court", "rect": [200, 80, 80, 40], "centre": [240, 100]}
]
}Arguments
Takes no argument.
What comes back
- matched
truewhen a screen of the map is the one showing.- screen
- The name of the screen that matched.
- controls
- The matched screen's named areas, each with
name,rectandcentre, in the program's own units. - layer
- Where the screen was found:
sessionfor a screen added in this session,filefor one of the loaded map. - screens_mapped
- When nothing matched: how many screens the map holds.
screens_triedsays how many had the right kind and size. - view_fits
falsewhen the picture's size cannot be the map's, seen through thescaleandmarginit was loaded with.
All 10 reply fields
controls(array)kind(string)layer(string)matched(boolean)screen(string)screens_mapped(integer)screens_tried(integer)screens_unjudged(integer)size(array)view_fits(boolean)
What it refuses
- No screen mapped yet: load a map or add a screen with
screen_map_write(needs_call). - A video mode
screen_viewcannot read (no_channel).
Why it works this way
A screen matches when its kind and size are the ones showing and each of its regions has the fingerprint the map recorded. Screens added this session are tried first, then the loaded file's.
The areas of the matched screen are what send_mouse(target=) clicks by name. The click acts on the screen this tool last matched, and what is drawn is not compared again. After anything that may have changed the screen, call it again at a stop.
A screen added with cells index is compared by palette index, not by colour.
Related tools
The contract your client receives
Which mapped screen the machine shows. Reply: `matched`, `kind` and `size`; when matched,
`screen`, `layer`, `controls` (`name`, `rect`, `centre`), in the program's units; when not,
`screens_mapped` and, if the view fits the map, `screens_tried` and `screens_unjudged`
(signed by index on a screen whose pens cannot be read), else `view_fits` false. None mapped:
`needs_call`.
Reference: REFERENCE.md, Screen maps.