// File: mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::restore(Rnes::PpuState const&)
void Ppu::restore(const PpuState &pb) {
  cycle = pb.cycle();
  frame = pb.frame();

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

  for (int i = 0; i < pb.spriteram_size(); i++) {
    const PpuState_SpriteState &sprite = pb.spriteram(i);
    spriteRam[i].yCoordMinus1 = sprite.ycoordminus1();
    spriteRam[i].tileIndex = sprite.tileindex();
    spriteRam[i].attr = sprite.attr();
    spriteRam[i].xCoord = sprite.xcoord();
  }

  vramToggle = pb.vramtoggle();
  vramFineXScroll = pb.vramfinexscroll();
  vramCurrentAddr = pb.vramcurrentaddr();
  vramTempAddr = pb.vramtempaddr();
  vramMachineAddr = pb.vrammachineaddr();
  vramReadLatch = pb.vramreadlatch();
  scrollingMachineState = pb.scrollingmachinestate();
  xScrollOrigin = pb.xscrollorigin();
  yScrollOrigin = pb.yscrollorigin();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24cc0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rdi
callq 0x24ce0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24d00
movl %eax, %ecx
movl -0x2c(%rbp), %eax
cmpl %ecx, %eax
jge 0x23a06
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x24d20
movl %eax, %ecx
movq -0x28(%rbp), %rax
movb %cl, %dl
movslq -0x14(%rbp), %rcx
movb %dl, 0x28(%rax,%rcx)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x239c7
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24d50
movl %eax, %ecx
movl -0x30(%rbp), %eax
cmpl %ecx, %eax
jge 0x23aab
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x24d70
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x24da0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movb %cl, %dl
movslq -0x18(%rbp), %rcx
movb %dl, 0x30(%rax,%rcx,4)
movq -0x20(%rbp), %rdi
callq 0x24dc0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movb %cl, %dl
movslq -0x18(%rbp), %rcx
movb %dl, 0x31(%rax,%rcx,4)
movq -0x20(%rbp), %rdi
callq 0x24de0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movb %cl, %dl
movslq -0x18(%rbp), %rcx
movb %dl, 0x32(%rax,%rcx,4)
movq -0x20(%rbp), %rdi
callq 0x24e00
movl %eax, %ecx
movq -0x28(%rbp), %rax
movb %cl, %dl
movslq -0x18(%rbp), %rcx
movb %dl, 0x33(%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x23a0d
movq -0x10(%rbp), %rdi
callq 0x24e20
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x130(%rax)
movq -0x10(%rbp), %rdi
callq 0x24e40
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x134(%rax)
movq -0x10(%rbp), %rdi
callq 0x24e60
movl %eax, %ecx
movq -0x28(%rbp), %rax
movw %cx, 0x138(%rax)
movq -0x10(%rbp), %rdi
callq 0x24e80
movl %eax, %ecx
movq -0x28(%rbp), %rax
movw %cx, 0x13a(%rax)
movq -0x10(%rbp), %rdi
callq 0x24ea0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movw %cx, 0x13c(%rax)
movq -0x10(%rbp), %rdi
callq 0x24ec0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movb %cl, 0x13e(%rax)
movq -0x10(%rbp), %rdi
callq 0x24ee0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x140(%rax)
movq -0x10(%rbp), %rdi
callq 0x24f00
movl %eax, %ecx
movq -0x28(%rbp), %rax
movb %cl, 0x144(%rax)
movq -0x10(%rbp), %rdi
callq 0x24f20
movl %eax, %ecx
movq -0x28(%rbp), %rax
movb %cl, 0x145(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)