mirror of
https://github.com/mlaux/gb6.git
synced 2026-03-11 04:42:10 +00:00
The GB inc/dec instructions must preserve the carry flag and only modify Z. The JIT was capturing both Z and C from the 68k CCR, causing dec to incorrectly set carry on borrow (e.g. 0-1=FF). This broke Pokemon Crystal's xor_a_dec_a helper which returns with C=0 to signal "no action". The corrupted C=1 caused the scrolling menu to exit prematurely when pressing down past CANCEL, showing phantom items and garbage prices. Fix compile_set_z_flag to merge new Z with old C, and compile_set_c_flag to merge new C with old Z. Move and/or/xor immediates to compile_set_zc_flags since they should clear C.