def parse_special_check(assignment): check = assignment.value assert isinstance(check, expression.SpecialCheck) actions = parse_actionD(ParameterAssignment(assignment.param, expression.ConstantNumeric(check.results[0]))) value = check.value if check.mask is not None: value &= check.mask value += check.mask << 32 assert check.varsize == 8 else: assert check.varsize <= 4 actions.append(action7.SkipAction(9, check.varnum, check.varsize, check.op, value, 1)) actions.extend(parse_actionD(ParameterAssignment(assignment.param, expression.ConstantNumeric(check.results[1])))) return actions
def get_tracktypelist_action(table_prop_id, cond_tracktype_not_defined, tracktype_list): action6.free_parameters.save() act6 = action6.Action6() action_list = [] action0, offset = create_action0(0x08, expression.ConstantNumeric(0), act6, action_list) id_table = [] offset += 1 # Skip property number for tracktype in tracktype_list: if isinstance(tracktype, expression.StringLiteral): id_table.append(tracktype) offset += 4 continue param, extra_actions = actionD.get_tmp_parameter( expression.ConstantNumeric( expression.parse_string_to_dword(tracktype[-1]))) action_list.extend(extra_actions) for idx in range(len(tracktype) - 2, -1, -1): val = expression.ConstantNumeric( expression.parse_string_to_dword(tracktype[idx])) action_list.append( action7.SkipAction(0x09, 0x00, 4, (cond_tracktype_not_defined, None), val.value, 1)) action_list.append( actionD.ActionD( expression.ConstantNumeric(param), expression.ConstantNumeric(0xFF), nmlop.ASSIGN, expression.ConstantNumeric(0xFF), val, )) act6.modify_bytes(param, 4, offset) id_table.append(expression.StringLiteral(r"\00\00\00\00", None)) offset += 4 action0.prop_list.append(IDListProp(table_prop_id, id_table)) action0.num_ids = len(tracktype_list) if len(act6.modifications) > 0: action_list.append(act6) action_list.append(action0) action6.free_parameters.restore() return action_list