// File: Thilotilo[P]DoaERando/General.cpp
// Function: DoaERando::General::UpdateGeneral(DoaERando::ROM&)
void General::UpdateGeneral(ROM& rom)
{
    rom.WriteByte(address + STRENGTH_OFFSET, strength);
    rom.WriteByte(address + INTELLIGENCE_OFFSET, intelligence);
    rom.WriteByte(address + ZONE_OFFSET, zone);
    BYTE weaponPaletteByte = rom.ReadByte(address + WEAPON_OFFSET);
    weaponPaletteByte &= (~WEAPON_BITMASK);
    weaponPaletteByte |= weaponId;
    rom.WriteByte(address + WEAPON_OFFSET, weaponPaletteByte);
    rom.WriteByte(address + ENEMY_DEFENSE_OFFSET, enemyDefenseId);
    rom.WriteByte(address + ENEMY_SOLDIERS_OFFSET, enemySoldierExponent);
    rom.WriteByte(address + ALLY_SOLDIERS_OFFSET, allySoldierExponent);
    rom.WriteByte(address + TACTICS_LEVEL_OFFSET, enemyMaxTacticLevel);
    rom.WriteByte(address + AGILITY_OFFSET, agility);

    for (BYTE i = id; i < id + count - 1; ++i)
    {
        WriteEncounterableBit(i, false, rom);
        WriteRecruitableBit(i, false, rom);
    }
    WriteEncounterableBit(id + count - 1, encounterable, rom);
    WriteRecruitableBit(id + count - 1, recruitable, rom);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl $0x0, %esi
movzbl 0x6(%rax), %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl $0x1, %esi
movzbl 0x7(%rax), %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl $0x2, %esi
movzbl 0x8(%rax), %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl $0x4, %esi
callq 0x404bb0
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, -0x11(%rbp)
movzbl -0x11(%rbp), %ecx
andl $-0x20, %ecx
movb %cl, -0x11(%rbp)
movzbl 0x9(%rax), %edx
movzbl -0x11(%rbp), %ecx
orl %edx, %ecx
movb %cl, -0x11(%rbp)
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl $0x4, %esi
movzbl -0x11(%rbp), %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl $0x5, %esi
movzbl 0xa(%rax), %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl $0x6, %esi
movzbl 0xb(%rax), %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl $0x7, %esi
movzbl 0xc(%rax), %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl $0x8, %esi
movzbl 0xd(%rax), %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rdi
movl (%rax), %esi
addl $0x9, %esi
movzbl 0xe(%rax), %edx
callq 0x404c20
movq -0x20(%rbp), %rax
movb 0x4(%rax), %al
movb %al, -0x12(%rbp)
movq -0x20(%rbp), %rdx
movzbl -0x12(%rbp), %eax
movzbl 0x4(%rdx), %ecx
movzbl 0x5(%rdx), %edx
addl %edx, %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x415157
movb -0x12(%rbp), %al
movq -0x10(%rbp), %rdx
xorl %esi, %esi
movzbl %al, %edi
callq 0x4151b0
movb -0x12(%rbp), %al
movq -0x10(%rbp), %rdx
xorl %esi, %esi
movzbl %al, %edi
callq 0x415260
movb -0x12(%rbp), %al
addb $0x1, %al
movb %al, -0x12(%rbp)
jmp 0x415112
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %ecx
movzbl 0x5(%rax), %edx
addl %edx, %ecx
subl $0x1, %ecx
movb 0x23(%rax), %al
movq -0x10(%rbp), %rdx
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4151b0
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %ecx
movzbl 0x5(%rax), %edx
addl %edx, %ecx
subl $0x1, %ecx
movb 0x24(%rax), %al
movq -0x10(%rbp), %rdx
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x415260
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)