src/emu/inptport.c
| r2866 | r2867 | |
| 240 | 240 | /* private input port state */ |
| 241 | 241 | struct _input_port_private |
| 242 | 242 | { |
| 243 | /* global state */ |
| 244 | UINT8 safe_to_read; /* clear at start; set after state is loaded */ |
| 245 | |
| 243 | 246 | /* types */ |
| 244 | 247 | input_type_state * typestatelist; /* list of live type states */ |
| 245 | 248 | input_type_state * type_to_typestate[__ipt_max][MAX_PLAYERS]; /* map from type/player to type state */ |
| r2866 | r2867 | |
| 1210 | 1213 | callback_field_info *custom; |
| 1211 | 1214 | input_port_value result; |
| 1212 | 1215 | |
| 1216 | assert_always(portdata->safe_to_read, "Input ports cannot be read at init time!"); |
| 1217 | |
| 1213 | 1218 | /* start with the digital */ |
| 1214 | 1219 | result = port->state->digital; |
| 1215 | 1220 | |
| r2866 | r2867 | |
| 1275 | 1280 | input_port_value input_port_read(running_machine *machine, const char *tag) |
| 1276 | 1281 | { |
| 1277 | 1282 | const input_port_config *port = input_port_by_tag(machine->portconfig, tag); |
| 1278 | | assert_always(mame_get_phase(machine) != MAME_PHASE_INIT, "Input ports cannot be read at init time!"); |
| 1279 | 1283 | if (port == NULL) |
| 1280 | 1284 | fatalerror("Unable to locate input port '%s'", tag); |
| 1281 | 1285 | return input_port_read_direct(port); |
| r2866 | r2867 | |
| 1291 | 1295 | input_port_value input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue) |
| 1292 | 1296 | { |
| 1293 | 1297 | const input_port_config *port = input_port_by_tag(machine->portconfig, tag); |
| 1294 | | assert_always(mame_get_phase(machine) != MAME_PHASE_INIT, "Input ports cannot be read at init time!"); |
| 1295 | 1298 | return (port == NULL) ? defvalue : input_port_read_direct(port); |
| 1296 | 1299 | } |
| 1297 | 1300 | |
| r2866 | r2867 | |
| 1304 | 1307 | input_port_value input_port_read_indexed(running_machine *machine, int portnum) |
| 1305 | 1308 | { |
| 1306 | 1309 | const input_port_config *port = input_port_by_index(machine->portconfig, portnum); |
| 1307 | | assert_always(mame_get_phase(machine) != MAME_PHASE_INIT, "Input ports cannot be read at init time!"); |
| 1308 | 1310 | return (port == NULL) ? 0 : input_port_read_direct(port); |
| 1309 | 1311 | } |
| 1310 | 1312 | |
| r2866 | r2867 | |
| 3381 | 3383 | |
| 3382 | 3384 | /* in the completion phase, we finish the initialization with the final ports */ |
| 3383 | 3385 | if (config_type == CONFIG_TYPE_FINAL) |
| 3386 | { |
| 3387 | portdata->safe_to_read = TRUE; |
| 3384 | 3388 | frame_update(machine); |
| 3389 | } |
| 3385 | 3390 | |
| 3386 | 3391 | /* early exit if no data to parse */ |
| 3387 | 3392 | if (parentnode == NULL) |