// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::ImproveMap()
void Randomizer::ImproveMap()
{
    // Add Bridge under ZGL's house
    myRom->WriteByte(0x160C3, 0x2A);
    myRom->WriteByte(0x160F2, 0xF1);
    // Add Bridge from Chang Sha to Po Yang
    myRom->WriteByte(0x1802C, 0xC8);
    myRom->WriteByte(0x18031, 0x22);
    myRom->WriteByte(0x18032, 0x22);
    myRom->WriteByte(0x18033, 0x22);
    myRom->WriteByte(0x18034, 0x28);
    myRom->WriteByte(0x18035, 0x4A);
    myRom->WriteByte(0x18036, 0xDC);
    myRom->WriteByte(0x18037, 0xDC);
    myRom->WriteByte(0x18053, 0xF7);
    myRom->WriteByte(0x18054, 0x07);
    myRom->WriteByte(0x18618, 0x27);
    // Add Bridge from Xu Zhou to Ji Zhou
    myRom->WriteByte(0x18838, 0xFE);
    myRom->WriteByte(0x18839, 0x4A);
    myRom->WriteByte(0x1883A, 0xDC);
    myRom->WriteByte(0x1883B, 0xDC);
    myRom->WriteByte(0x1883C, 0xDC);
    myRom->WriteByte(0x1883D, 0xDC);
    myRom->WriteByte(0x1883E, 0xCF);
    myRom->WriteByte(0x1883F, 0x60);
    myRom->WriteByte(0x18878, 0x7C);
    myRom->WriteByte(0x188BF, 0xA7);
    myRom->WriteByte(0x188C7, 0x41);
    myRom->WriteByte(0x189EE, 0xCD);
    myRom->WriteByte(0x189EF, 0xFE);
    myRom->WriteByte(0x189DE, 0xCD);
    // Add Hills in Ji Zhou
    myRom->WriteByte(0x1889A, 0x87);
    // Add Hills in Zone 2
    myRom->WriteByte(0x1842C, 0x87);
    // Enable all story-trigger bridges
    myRom->WriteByte(0x34781, 0x01);    // Automatically enable the bridge in the Qing Zhou cave
    myRom->WriteByte(0x34782, 0x01);    // Automatically enable the bridge from Luo Yang to Chin
    myRom->WriteByte(0x34784, 0x01);    // Automatically enable the bridge from Nan Yang to Ji Zhou
    myRom->WriteByte(0x34788, 0x01);    // Automatically enable the bridge from Gui Yang to Wu
    // Fix Luo Yang lookup.
    // Right now, the version of Luo Yang we get is based upon the status of the Chin bridge.  Since
    // we've permanently enabled it, that means we only get the restored Luo Yang castle, which means
    // that we can't fight the original Luo Yang, nor can we recruit the general in it, nor can we
    // use the Gold Key.  To fix this, we just want to change it to use the new Luo Yang gates to
    // determine which version we want to load.
    myRom->WriteByte(0x3BCF9, 0x77);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq (%rax), %rdi
movl $0x160c3, %esi          # imm = 0x160C3
movl $0x2a, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x160f2, %esi          # imm = 0x160F2
movl $0xf1, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1802c, %esi          # imm = 0x1802C
movl $0xc8, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18031, %esi          # imm = 0x18031
movl $0x22, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18032, %esi          # imm = 0x18032
movl $0x22, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18033, %esi          # imm = 0x18033
movl $0x22, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18034, %esi          # imm = 0x18034
movl $0x28, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18035, %esi          # imm = 0x18035
movl $0x4a, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18036, %esi          # imm = 0x18036
movl $0xdc, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18037, %esi          # imm = 0x18037
movl $0xdc, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18053, %esi          # imm = 0x18053
movl $0xf7, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18054, %esi          # imm = 0x18054
movl $0x7, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18618, %esi          # imm = 0x18618
movl $0x27, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18838, %esi          # imm = 0x18838
movl $0xfe, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18839, %esi          # imm = 0x18839
movl $0x4a, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1883a, %esi          # imm = 0x1883A
movl $0xdc, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1883b, %esi          # imm = 0x1883B
movl $0xdc, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1883c, %esi          # imm = 0x1883C
movl $0xdc, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1883d, %esi          # imm = 0x1883D
movl $0xdc, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1883e, %esi          # imm = 0x1883E
movl $0xcf, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1883f, %esi          # imm = 0x1883F
movl $0x60, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x18878, %esi          # imm = 0x18878
movl $0x7c, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x188bf, %esi          # imm = 0x188BF
movl $0xa7, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x188c7, %esi          # imm = 0x188C7
movl $0x41, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x189ee, %esi          # imm = 0x189EE
movl $0xcd, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x189ef, %esi          # imm = 0x189EF
movl $0xfe, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x189de, %esi          # imm = 0x189DE
movl $0xcd, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1889a, %esi          # imm = 0x1889A
movl $0x87, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1842c, %esi          # imm = 0x1842C
movl $0x87, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x34781, %esi          # imm = 0x34781
movl $0x1, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x34782, %esi          # imm = 0x34782
movl $0x1, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x34784, %esi          # imm = 0x34784
movl $0x1, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x34788, %esi          # imm = 0x34788
movl $0x1, %edx
callq 0x404c20
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x3bcf9, %esi          # imm = 0x3BCF9
movl $0x77, %edx
callq 0x404c20
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)