// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::save(Rnes::PpuState&)
void Ppu::save(PpuState &pb) {
  pb.set_cycle(cycle);
  pb.set_frame(frame);

  for (int i = 0; i < REG_COUNT; i++) {
    pb.add_regs(regs[i]);
  }

  for (int i = 0; i < spriteRamSize; i++) {
    PpuState_SpriteState *sprite = pb.add_spriteram();
    sprite->set_ycoordminus1(spriteRam[i].yCoordMinus1);
    sprite->set_tileindex(spriteRam[i].tileIndex);
    sprite->set_attr(spriteRam[i].attr);
    sprite->set_xcoord(spriteRam[i].xCoord);
  }

  pb.set_vramtoggle(vramToggle);
  pb.set_vramfinexscroll(vramFineXScroll);
  pb.set_vramcurrentaddr(vramCurrentAddr);
  pb.set_vramtempaddr(vramTempAddr);
  pb.set_vrammachineaddr(vramMachineAddr);
  pb.set_vramreadlatch(vramReadLatch);
  pb.set_scrollingmachinestate(scrollingMachineState);
  pb.set_xscrollorigin(xScrollOrigin);
  pb.set_yscrollorigin(yScrollOrigin);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x18(%rdi), %rax
movl 0x10(%rsi), %ecx
movl %ecx, %edx
orl $0x1, %edx
movl %edx, 0x10(%rsi)
movq %rax, 0x40(%rsi)
movq 0x20(%rdi), %rax
orl $0x3, %ecx
movl %ecx, 0x10(%rsi)
movq %rax, 0x48(%rsi)
leaq 0x18(%rsi), %r15
xorl %r12d, %r12d
movq %rdi, -0x30(%rbp)
movzbl 0x28(%r14,%r12), %r14d
movl 0x18(%rbx), %r13d
movl 0x1c(%rbx), %esi
cmpl %esi, %r13d
jne 0x19038
incl %esi
movq %r15, %rdi
callq 0xb670
movq %r15, %rdi
callq 0xb530
movl %r14d, (%rax,%r13,4)
leal 0x1(%r13), %eax
movl %eax, (%r15)
incq %r12
cmpq $0x8, %r12
movq -0x30(%rbp), %r14
jne 0x1901c
leaq 0x28(%rbx), %r15
xorl %r12d, %r12d
movq 0x38(%rbx), %rax
testq %rax, %rax
je 0x19084
movslq 0x30(%rbx), %rcx
movl (%rax), %edx
cmpl %edx, %ecx
jge 0x1907f
leal 0x1(%rcx), %edx
movl %edx, 0x30(%rbx)
movq 0x8(%rax,%rcx,8), %rax
jmp 0x190b3
cmpl 0x34(%rbx), %edx
jne 0x19091
movl 0x34(%rbx), %esi
incl %esi
movq %r15, %rdi
callq 0xb960
movq 0x38(%rbx), %rax
incl (%rax)
movq 0x28(%rbx), %rdi
callq 0x31e6c
movq 0x38(%rbx), %rcx
movslq 0x30(%rbx), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x30(%rbx)
movq %rax, 0x8(%rcx,%rdx,8)
movzbl 0x30(%r14,%r12,4), %ecx
movl 0x10(%rax), %edx
movl %edx, %esi
orl $0x1, %esi
movl %esi, 0x10(%rax)
movl %ecx, 0x18(%rax)
movzbl 0x31(%r14,%r12,4), %ecx
movl %edx, %esi
orl $0x3, %esi
movl %esi, 0x10(%rax)
movl %ecx, 0x1c(%rax)
movzbl 0x32(%r14,%r12,4), %ecx
movl %edx, %esi
orl $0x7, %esi
movl %esi, 0x10(%rax)
movl %ecx, 0x20(%rax)
movzbl 0x33(%r14,%r12,4), %ecx
orl $0xf, %edx
movl %edx, 0x10(%rax)
movl %ecx, 0x24(%rax)
incq %r12
cmpq $0x40, %r12
jne 0x1905f
movl 0x130(%r14), %ecx
movl 0x10(%rbx), %eax
movl %eax, %edx
orl $0x4, %edx
movl %edx, 0x10(%rbx)
movl %ecx, 0x50(%rbx)
movl 0x134(%r14), %ecx
movl %eax, %edx
orl $0xc, %edx
movl %edx, 0x10(%rbx)
movl %ecx, 0x54(%rbx)
movzwl 0x138(%r14), %ecx
movl %eax, %edx
orl $0x1c, %edx
movl %edx, 0x10(%rbx)
movl %ecx, 0x58(%rbx)
movzwl 0x13a(%r14), %ecx
movl %eax, %edx
orl $0x3c, %edx
movl %edx, 0x10(%rbx)
movl %ecx, 0x5c(%rbx)
movzwl 0x13c(%r14), %ecx
movl %eax, %edx
orl $0x7c, %edx
movl %edx, 0x10(%rbx)
movl %ecx, 0x60(%rbx)
movzbl 0x13e(%r14), %ecx
movl %eax, %edx
orl $0xfc, %edx
movl %edx, 0x10(%rbx)
movl %ecx, 0x64(%rbx)
movl 0x140(%r14), %ecx
movl %eax, %edx
orl $0x1fc, %edx            # imm = 0x1FC
movl %edx, 0x10(%rbx)
movl %ecx, 0x68(%rbx)
movzbl 0x144(%r14), %ecx
movl %eax, %edx
orl $0x3fc, %edx            # imm = 0x3FC
movl %edx, 0x10(%rbx)
movl %ecx, 0x6c(%rbx)
movzbl 0x145(%r14), %ecx
orl $0x7fc, %eax            # imm = 0x7FC
movl %eax, 0x10(%rbx)
movl %ecx, 0x70(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq