+static int t_irq_ack_h_v_2(void)
+{
+ u16 *ram = (u16 *)0xfff000;
+ u8 *ram8 = (u8 *)0xfff000;
+ u16 s0, s1;
+ int ok = 1;
+
+ ram[0] = ram[1] = ram[2] =
+ ram[4] = ram[5] = ram[6] = 0;
+ memcpy_((void *)0xff0100, test_hint, test_hint_end - test_hint);
+ memcpy_((void *)0xff0140, test_vint, test_vint_end - test_vint);
+ VDP_setReg(10, 0);
+ while (read8(VDP_HV_COUNTER) != 100)
+ ;
+ while (read8(VDP_HV_COUNTER) != 226)
+ ;
+ s0 = read16(VDP_CTRL_PORT);
+ test_h_v_2();
+ s1 = read16(VDP_CTRL_PORT);
+ VDP_setReg(VDP_MODE1, VDP_MODE1_PS);
+ VDP_setReg(VDP_MODE2, VDP_MODE2_MD | VDP_MODE2_DMA | VDP_MODE2_DISP);
+
+ expect(ok, ram[0], 2); // hint count
+ expect(ok, ram8[2], 226); // hint first line
+ expect(ok, ram8[4], 226); // hint last line
+ expect(ok, ram[4], 0); // vint count
+ expect(ok, ram8[10], 0); // vint line
+ expect_bits(ok, s0, SR_F, SR_F);
+ expect_bits(ok, s1, 0, SR_F);
+ return ok;
+}
+
+static void t_irq_f_flag(void)
+{
+ memcpy_((void *)0xff0140, test_f_vint, test_f_vint_end - test_f_vint);
+ memset_((void *)0xff0000, 0, 10);
+ VDP_setReg(VDP_MODE2, VDP_MODE2_MD | VDP_MODE2_IE0 | VDP_MODE2_DISP);
+ test_f();
+ VDP_setReg(VDP_MODE2, VDP_MODE2_MD | VDP_MODE2_DMA | VDP_MODE2_DISP);
+}
+
+static int t_irq_f_flag_h40(void)
+{
+ u8 f, *r = (u8 *)0xff0000;
+ int ok = 1;
+
+ t_irq_f_flag();
+
+ expect_bits(ok, r[0], 0, SR_F);
+ expect_bits(ok, r[1], 0, SR_F);
+ expect_bits(ok, r[2], 0, SR_F);
+ // hits 1-3 times in range 3-9, usually ~5
+ f = r[3] | r[4] | r[5] | r[6] | r[7];
+
+ expect_bits(ok, r[10], 0, SR_F);
+ expect_bits(ok, r[11], 0, SR_F);
+ expect_bits(ok, f, SR_F, SR_F);
+ return ok;
+}
+
+static int t_irq_f_flag_h32(void)
+{
+ u8 f, *r = (u8 *)0xff0000;
+ int ok = 1;
+
+ VDP_setReg(VDP_MODE4, 0x00);
+ t_irq_f_flag();
+ VDP_setReg(VDP_MODE4, 0x81);
+
+ expect_bits(ok, r[0], 0, SR_F);
+ expect_bits(ok, r[1], 0, SR_F);
+ // hits 1-3 times in range 2-7, usually 3
+ f = r[2] | r[3] | r[4] | r[5] | r[6] | r[7];
+
+ expect_bits(ok, r[8], 0, SR_F);
+ expect_bits(ok, r[9], 0, SR_F);
+ expect_bits(ok, r[10], 0, SR_F);
+ expect_bits(ok, r[11], 0, SR_F);
+ expect_bits(ok, f, SR_F, SR_F);
+ return ok;
+}
+