示例#1
0
def test_first_constraint():
    # v  U D
    # 0  0 0
    # 1  x 1
    # 2  1-2
    # 3  2 3
    # 4  3
    manager = ConstraintManager({RomVariant.USA, RomVariant.DEMO})
    constraint = Constraint()
    constraint.romA = RomVariant.USA
    constraint.addressA = 1
    constraint.romB = RomVariant.DEMO
    constraint.addressB = 2
    manager.add_constraint(constraint)
    manager.rebuild_relations()
    assert_same_address(manager, RomVariant.USA, 0)
    assert_same_address(manager, RomVariant.DEMO, 0)
    assert_same_address(manager, RomVariant.DEMO, 1)
    assert_same_address(manager, RomVariant.DEMO, 2)
    assert_same_address(manager, RomVariant.DEMO, 3)
    assert_same_address(manager, RomVariant.DEMO, 0xffffff)
    assert_differing_address(manager, RomVariant.USA, 1, 2)
    assert_differing_address(manager, RomVariant.USA, 2, 3)
    assert_differing_address(manager, RomVariant.USA, 0xffffff, 0xffffff + 1)
    print('---')
    assert -1 == manager.to_local(RomVariant.USA, 1)
示例#2
0
def add_u_d_constraint(manager: ConstraintManager, usa_address: int,
                       demo_address: int):
    constraint = Constraint()
    constraint.romA = RomVariant.USA
    constraint.addressA = usa_address
    constraint.romB = RomVariant.DEMO
    constraint.addressB = demo_address
    manager.add_constraint(constraint)
示例#3
0
def add_e_d_constraint(manager: ConstraintManager, eu_address: int,
                       demo_address: int):
    constraint = Constraint()
    constraint.romA = RomVariant.EU
    constraint.addressA = eu_address
    constraint.romB = RomVariant.DEMO
    constraint.addressB = demo_address
    manager.add_constraint(constraint)
示例#4
0
def add_u_e_constraint(manager: ConstraintManager, usa_address: int,
                       eu_address: int):
    constraint = Constraint()
    constraint.romA = RomVariant.USA
    constraint.addressA = usa_address
    constraint.romB = RomVariant.EU
    constraint.addressB = eu_address
    manager.add_constraint(constraint)
示例#5
0
def add_u_j_constraint(manager: ConstraintManager, usa_address: int,
                       jp_address: int):
    constraint = Constraint()
    constraint.romA = RomVariant.USA
    constraint.addressA = usa_address
    constraint.romB = RomVariant.JP
    constraint.addressB = jp_address
    manager.add_constraint(constraint)
示例#6
0
def add_j_e_constraint(manager: ConstraintManager, jp_address: int,
                       eu_address: int):
    constraint = Constraint()
    constraint.romA = RomVariant.JP
    constraint.addressA = jp_address
    constraint.romB = RomVariant.EU
    constraint.addressB = eu_address
    manager.add_constraint(constraint)
示例#7
0
def add_j_d_constraint(manager: ConstraintManager, jp_address: int,
                       demo_address: int):
    constraint = Constraint()
    constraint.romA = RomVariant.JP
    constraint.addressA = jp_address
    constraint.romB = RomVariant.DEMO
    constraint.addressB = demo_address
    manager.add_constraint(constraint)
示例#8
0
def test_longer_constraint():
    # v   E   J
    # 0   0   0
    # 1   x   1
    # ... ... ...
    # 100 1---100
    # 101 2   101
    manager = ConstraintManager({RomVariant.EU, RomVariant.JP})
    constraint = Constraint()
    constraint.romA = RomVariant.JP
    constraint.addressA = 100
    constraint.romB = RomVariant.EU
    constraint.addressB = 1
    manager.add_constraint(constraint)
    manager.rebuild_relations()
    assert_same_address(manager, RomVariant.EU, 0)
    assert_same_address(manager, RomVariant.JP, 0)
    assert_same_address(manager, RomVariant.JP, 100)
    assert_same_address(manager, RomVariant.JP, 5000)
    assert -1 == manager.to_local(RomVariant.EU, 1)
    assert_differing_address(manager, RomVariant.EU, 1, 100)
    assert_differing_address(manager, RomVariant.EU, 100, 199)