+#ifdef ASM_6502
+#ifdef DEBUG_ASM_6502
+extern uint8 nes_internal_ram[0x800];
+#endif
+
+void asmcpu_unpack(void)
+{
+ nes_registers[0] = X.A << 24;
+ nes_registers[1] = X.X;
+ nes_registers[2] = X.Y;
+ pc_base = 0;
+ nes_registers[3] = X.PC;
+ X6502_Rebase_a();
+ nes_registers[4] = X.S << 24;
+ nes_registers[4]|= X.IRQlow << 8;
+ if (MapIRQHook)
+ nes_registers[4] |= 1<<16; // MapIRQHook set bit
+ nes_registers[7] = (uint32)X.count << 16;
+
+ // NVUB DIZC
+ nes_registers[4]|= X.P & 0x5d;
+ nes_registers[5] = X.P << 24; // N
+ if (!(X.P&0x02)) nes_registers[5] |= 1; // Z
+
+#ifdef DEBUG_ASM_6502
+ memcpy(nes_internal_ram, RAM, 0x800);
+#endif
+}
+
+void asmcpu_pack(void)
+{
+ X.A = nes_registers[0] >> 24;
+ X.X = nes_registers[1];
+ X.Y = nes_registers[2];
+ X.PC= nes_registers[3] - pc_base;
+ X.S = nes_registers[4] >> 24;
+ X.IRQlow = nes_registers[4] >> 8;
+ X.count = (int32) nes_registers[7] >> 16;
+
+ // NVUB DIZC
+ X.P = nes_registers[4] & 0x5d;
+ if ( nes_registers[5]&0x80000000) X.P |= 0x80; // N
+ if (!(nes_registers[5]&0x000000ff)) X.P |= 0x02; // Z
+}
+#endif
+