X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=testpico%2Fmain.c;h=1d27128bceb9b0c8563fdfc1da264be4af9ae70f;hb=HEAD;hp=d02a4680ad593eb59fb0d969633062c7a4e92fde;hpb=6474d733133dc605ee02e4e2e02f025c41d202df;p=megadrive.git diff --git a/testpico/main.c b/testpico/main.c index d02a468..2f7a4ec 100644 --- a/testpico/main.c +++ b/testpico/main.c @@ -346,10 +346,11 @@ void exception(const struct exc_frame *f) printf(" PC: %08x SR: %04x \n", f->g.pc, f->g.sr); sp_add = 6; } - for (i = 0; i < 8; i++) + sp = (u32 *)(f->ar[7] + sp_add); + for (i = 0; i < 7; i++) printf(" D%d: %08x A%d: %08x \n", i, f->dr[i], i, f->ar[i]); + printf(" D%d: %08x SP: %08x \n", i, f->dr[i], (u32)sp); printf(" \n"); - sp = (u32 *)(f->ar[7] + sp_add); printf(" %08x %08x %08x %08x\n", sp[0], sp[1], sp[2], sp[3]); printf(" %08x %08x %08x %08x\n", sp[4], sp[5], sp[6], sp[7]); } @@ -404,6 +405,14 @@ static void vdp_wait_for_line_0(void) ; } +static void wait_next_vsync(void) +{ + while (read16(VDP_CTRL_PORT) & SR_VB) + /* blanking */; + while (!(read16(VDP_CTRL_PORT) & SR_VB)) + /* not blanking */; +} + static void t_dma_zero_wrap_early(void) { const u32 *src = (const u32 *)0x3c0000; @@ -801,6 +810,33 @@ static int t_dma_fill_src(void) return ok; } +// should not see the busy flag +static int t_dma_busy_vram(void) +{ + const u32 *src = (const u32 *)0x3c0000; + u16 sr[3]; + int ok = 1; + + vdp_wait_for_line_0(); + + do_setup_dma(src, 1); + write32(VDP_CTRL_PORT, CTL_WRITE_VRAM(0x100) | CTL_WRITE_DMA); + sr[0] = read16(VDP_CTRL_PORT); + + do_setup_dma(src, 4); + write32(VDP_CTRL_PORT, CTL_WRITE_VRAM(0x100) | CTL_WRITE_DMA); + sr[1] = read16(VDP_CTRL_PORT); + + VDP_setReg(VDP_DMA_LEN0, 8); + write32(VDP_CTRL_PORT, CTL_WRITE_VRAM(0x100) | CTL_WRITE_DMA); + sr[2] = read16(VDP_CTRL_PORT); + + expect_bits(ok, sr[0], 0, SR_DMA); + expect_bits(ok, sr[1], 0, SR_DMA); + expect_bits(ok, sr[2], 0, SR_DMA); + return ok; +} + // (((a & 2) >> 1) ^ 1) | ((a & $400) >> 9) | (a & $3FC) | ((a & $1F800) >> 1) static int t_dma_128k(void) { @@ -1819,16 +1855,19 @@ static int t_32x_reset_btn(void) expect(ok, r32[0x20/4], 0x00005a20); expect(ok, r32[0x24/4], 0x5a5a5a24); expect(ok, r32[0x28/4], 0x5a5a5a28); - expect(ok, r32[0x2c/4], 0x07075a2c); // 7 - last_irq_vec + expect(ok, r32[0x2c/4], 0x075a5a2c); // 7 - last_irq_vec if (!(r16[0x00/2] & 0x8000)) { - expect(ok, r8 [0x81], 0); - expect(ok, r16[0x82/2], 0); - expect(ok, r16[0x84/2], 0); - expect(ok, r16[0x86/2], 0); - //expect(ok, r16[0x88/2], 0); // triggers fill? + expect(ok, r8 [0x81], 1); + expect(ok, r16[0x82/2], 1); + expect(ok, r16[0x84/2], 0xff); + expect(ok, r16[0x86/2], 0xffff); + expect(ok, r16[0x88/2], 0); expect(ok, r8 [0x8b] & ~2, 0); // FEN toggles periodically? expect(ok, r16[0x8c/2], 0); expect(ok, r16[0x8e/2], 0); + // setup vdp for t_32x_init + r8 [0x81] = 0; + r16[0x82/2] = r16[0x84/2] = r16[0x86/2] = 0; } r32[0x20/4] = r32[0x24/4] = r32[0x28/4] = r32[0x2c/4] = 0; for (s = 0; s < 2; s++) @@ -1846,7 +1885,18 @@ static int t_32x_reset_btn(void) expect(ok, s_icnt[i], 0x100); } expect(ok, m_icnt[7], 0x101); // VRES happened + expect(ok, s_icnt[7], 0x100); // masked on slave + + x32_cmd(CMD_GETSR, 0, 0, 1); + expect_sh2(ok, 1, r32[0x24/4] & ~1, 0xf0); // still masked + x32_cmd(CMD_SETSR, 0x10, 0, 1); + expect(ok, r16[0x00/2], 0x8083); + write8(r8, 0x00); // FM=0 + mem_barrier(); + expect(ok, m_icnt[7], 0x101); expect(ok, s_icnt[7], 0x101); + expect(ok, r32[0x2c/4], 0x00070000); // 7 - last_irq_vec + r32[0x2c/4] = 0; memcpy_(do_32x_disable, x32x_disable, x32x_disable_end - x32x_disable); @@ -1855,7 +1905,7 @@ static int t_32x_reset_btn(void) expect(ok, r16[0x00/2], 0x82); expect(ok, r16[0x02/2], 0); expect(ok, r16[0x04/2], 3); - expect(ok, r16[0x06/2], 1); // RV + expect(ok, r16[0x06/2], 0); // RV cleared by x32x_disable expect(ok, r32[0x08/4], 0x5a5a08); expect(ok, r32[0x0c/4], 0x5a5a0c); expect(ok, r16[0x10/2], 0x5a10); @@ -1863,7 +1913,6 @@ static int t_32x_reset_btn(void) // setup for t_32x_init, t_32x_sh_defaults r16[0x04/2] = 0; - r16[0x06/2] = 0; // can just set without ADEN r16[0x10/2] = 0x1234; // warm reset indicator mem_barrier(); expect(ok, r16[0x06/2], 0); // RV @@ -1907,9 +1956,40 @@ static int t_32x_init(void) r32[0x28/4] = 0; r32[0x2c/4] = 0; - // these have garbage or old values (survive MD's power cycle) + // check writable bits without ADEN + // 08,0c have garbage or old values (survive MD's power cycle) + write16(&r16[0x00/2], 0); + mem_barrier(); + expect(ok, r16[0x00/2], 0x80); + write16(&r16[0x00/2], 0xfffe); + mem_barrier(); + expect(ok, r16[0x00/2], 0x8082); + r16[0x00/2] = 0x82; + r16[0x02/2] = 0xffff; + r32[0x04/4] = 0xffffffff; + r32[0x08/4] = 0xffffffff; + r32[0x0c/4] = 0xffffffff; + r16[0x10/2] = 0xffff; + r32[0x14/4] = 0xffffffff; + r32[0x18/4] = 0xffffffff; + r32[0x1c/4] = 0xffffffff; + mem_barrier(); + expect(ok, r16[0x00/2], 0x82); + expect(ok, r16[0x02/2], 0x03); + expect(ok, r16[0x04/2], 0x03); + expect(ok, r16[0x06/2], 0x07); + expect(ok, r32[0x08/4], 0x00fffffe); + expect(ok, r32[0x0c/4], 0x00ffffff); + expect(ok, r16[0x10/2], 0xfffc); + expect(ok, r32[0x14/4], 0); + expect(ok, r16[0x18/2], 0); + expect(ok, r16[0x1a/2], 0x0101); + expect(ok, r32[0x1c/4], 0); + r16[0x02/2] = 0; + r32[0x04/4] = 0; r32[0x08/4] = 0; r32[0x0c/4] = 0; + r16[0x1a/2] = 0; // could just set RV, but BIOS reads ROM, so can't memcpy_(do_32x_enable, x32x_enable, @@ -2144,7 +2224,8 @@ static int t_32x_reg_w(void) // prepare for reset btn press tests static int t_32x_reset_prep(void) { - u32 *fbl_icnt = (u32 *)(0x840000 + IRQ_CNT_FB_BASE); + u32 *fbl = (u32 *)0x840000; + u32 *fbl_icnt = fbl + IRQ_CNT_FB_BASE / 4; u32 *r32 = (u32 *)0xa15100; u16 *r16 = (u16 *)r32; u8 *r8 = (u8 *)r32; @@ -2159,6 +2240,7 @@ static int t_32x_reset_prep(void) write32(&fbl_icnt[i], 0x01000100); x32_cmd(CMD_WRITE8, 0x20004001, 0x02, 0); // unmask cmd x32_cmd(CMD_WRITE8, 0x20004001, 0x02, 1); // unmask slave + x32_cmd(CMD_SETSR, 0xf0, 0, 1); // mask slave irqs (on the cpu) burn10(10); write8(r8, 0x00); // FM=0 expect(ok, r32[0x2c/4], 0); @@ -2174,6 +2256,21 @@ static int t_32x_reset_prep(void) r32[0x24/4] = 0x5a5a5a24; r32[0x28/4] = 0x5a5a5a28; r32[0x2c/4] = 0x5a5a5a2c; + if (!(r16[0x00/2] & 0x8000)) { + wait_next_vsync(); + r16[0x8a/2] = 0x0001; + mem_barrier(); + for (i = 0; i < 220/2; i++) + write32(&fbl[i], 0); + r8 [0x81] = 1; + r16[0x82/2] = 0xffff; + r16[0x84/2] = 0xffff; + r16[0x86/2] = 0xffff; + r16[0x8a/2] = 0x0000; + r16[0x8c/2] = 0xffff; + r16[0x8e/2] = 0xffff; + r16[0x100/2] = 0; + } return ok; } @@ -2203,6 +2300,7 @@ static const struct { { T_MD, t_dma_fill3_vsram, "dma fill3 vsram" }, { T_MD, t_dma_fill_dis, "dma fill disabled" }, { T_MD, t_dma_fill_src, "dma fill src incr" }, + { T_MD, t_dma_busy_vram, "dma no busy" }, { T_MD, t_dma_128k, "dma 128k mode" }, { T_MD, t_vdp_128k_b16, "vdp 128k addr bit16" }, // { t_vdp_128k_b16_inc, "vdp 128k bit16 inc" }, // mystery @@ -2284,14 +2382,6 @@ static void setup_z80(void) ; } -static void wait_next_vsync(void) -{ - while (read16(VDP_CTRL_PORT) & SR_VB) - /* blanking */; - while (!(read16(VDP_CTRL_PORT) & SR_VB)) - /* not blanking */; -} - static unused int hexinc(char *c) { (*c)++; @@ -2385,6 +2475,12 @@ int main() (v8 & 0x40) ? "pal" : "ntsc", have_32x ? "32X" : "", en_32x ? "+" : ""); + printf("reset hvc %04x->%04x\n", read16(-4), read16(-2)); + + // sanity check + extern u32 sh2_test[]; + if (sh2_test[0] != read32(0x3e0) || sh2_test[0x200/4] != read32(0x3e4)) + printf("bad 0x3c0 tab\n"); for (i = 0; i < ARRAY_SIZE(g_tests); i++) { // print test number if we haven't scrolled away @@ -2420,7 +2516,7 @@ int main() printf_ypos = 0; printf(" "); - if (have_32x) { + if (have_32x && (read16(0xa15100) & 1)) { u8 *p = (u8 *)0xff0040; u32 len = x32x_switch_rv_end - x32x_switch_rv; px32x_switch_rv = (void *)p; p += len; @@ -2434,14 +2530,18 @@ int main() // todo: broken printf px32x_switch_rv(0); } - for (i = 0; i < 60*60 && !(pget_input() & BTNM_A); i++) - wait_next_vsync(); + for (i = 0; i < 60*60 && !(pget_input() & BTNM_A); i++) { + while (read16(VDP_CTRL_PORT) & SR_VB) + write16(-4, read16(VDP_HV_COUNTER)); /* blanking */ + while (!(read16(VDP_CTRL_PORT) & SR_VB)) + write16(-4, read16(VDP_HV_COUNTER)); /* not blanking */; + } #ifndef PICO // blank due to my lame tv being burn-in prone VDP_setReg(VDP_MODE2, VDP_MODE2_MD); #endif while (!(pget_input() & BTNM_A)) - burn10(488*100/10); + write16(-4, read16(VDP_HV_COUNTER)); VDP_setReg(VDP_MODE2, VDP_MODE2_MD | VDP_MODE2_DMA | VDP_MODE2_DISP);