From: notaz Date: Thu, 29 Jun 2023 20:26:04 +0000 (+0300) Subject: testpico: even more timer stir up X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=megadrive.git;a=commitdiff_plain;h=635f24506c5a883336e9028e0de7a4a5fb9b2226 testpico: even more timer stir up --- diff --git a/testpico/asmtools.S b/testpico/asmtools.S index 6be859a..24b6458 100644 --- a/testpico/asmtools.S +++ b/testpico/asmtools.S @@ -12,11 +12,11 @@ .global burn10 /* u16 val */ burn10: - ldarg 0, 0, d0 + ldargw 0, 0, d0 subq.l #1, d0 0: - dbra d0, 0b - rts + dbra d0, 0b /* 10|14 */ + rts /* 16 */ .global write16_x16 /* u32 a, u16 count, u16 d */ write16_x16: @@ -67,6 +67,16 @@ get_input: .endif rts +.global get_line +get_line: + movea.l #0xc00008, a0 + moveq.l #0, d0 +0: + move.b (a0), d0 /* 8 d2 = vcnt */ + cmp.b (a0), d0 /* 8 reread for super-rare corruption (torn read) */ + bne 0b + rts + .global write_and_read1 /* u32 a, u16 d, void *dst */ write_and_read1: ldarg 0, 0, a0 @@ -483,7 +493,7 @@ test_ym_ab_sync: ymwrite a0, a1, #0x27, #0x30 /* 30 disable, clear */ ymwrite a0, a1, #0x24, #0xfc /* 30 timer a */ - ymwrite a0, a1, #0x25, #0x01 /* 30 =15 - why 15? expected 16 */ + ymwrite a0, a1, #0x25, #0x01 /* 30 =15 */ ymwrite a0, a1, #0x26, #0xff /* 30 timer b shortest interval */ move.b #0x27, (a0) /* 12 addr prep */ nop @@ -496,15 +506,19 @@ test_ym_ab_sync: move.b (a0), d0 /* 8 */ and.b d1, d0 /* 4 */ beq 0b /* 10|8 */ -0: + move.b #0x3f, (a1) /* 12 start a, clear */ - move.w #(1800/10-1), d0 /* waste cycles */ -0: - dbra d0, 0b - ymwrite a0, a1, #0x24, #0x00 /* 30 show that rewriting count */ - ymwrite a0, a1, #0x25, #0x00 /* 30 does nothing */ - ymwrite a0, a1, #0x26, #0x00 /* 30 */ + move.w #(488/10), d0 /* waste cycles */ +0: dbra d0, 0b + + ymwrite a0, a1, #0x24, #0xf0 /* 30 show that rewriting count */ + ymwrite a0, a1, #0x25, #0x00 /* 30 does nothing until timer expires */ + + move.w #(488*2/10), d0 /* waste cycles */ +0: dbra d0, 0b + + ymwrite a0, a1, #0x26, #0xfc /* 30 same for timer b */ ymwrite a0, a1, #0x27, #0x0f /* 30 setting already set bits too */ moveq.l #0, d0 moveq.l #3, d1 @@ -515,4 +529,20 @@ test_ym_ab_sync: move.b (a0), d0 /* re-read, else very occasionally get 1 */ rts +.global test_ym_ab_sync2 +test_ym_ab_sync2: + movea.l #0xa04000, a0 + movea.l #0xa04001, a1 + +# move.b #0x3f, (a1) /* 12 clear */ + moveq.l #0, d0 + moveq.l #3, d1 + nop /* 4 need ~12c to clear */ +0: + move.b (a0), d0 /* 8 */ + and.b d1, d0 /* 4 */ + beq 0b /* 10|8 */ + move.b (a0), d0 /* re-read */ + rts + # vim:filetype=asmM68k:ts=4:sw=4:expandtab diff --git a/testpico/asmtools.h b/testpico/asmtools.h index 8711183..0b34a1a 100644 --- a/testpico/asmtools.h +++ b/testpico/asmtools.h @@ -11,7 +11,8 @@ void write16_x16(unsigned int addr, unsigned short count, short data); #define BTNM_D (1 << 1) #define BTNM_U (1 << 0) -int get_input(void); +short get_input(void); +short get_line(void); void write_and_read1(unsigned int a, unsigned short d, void *dst); void move_sr(unsigned short sr); short move_sr_and_read(unsigned short sr, unsigned int a); @@ -27,6 +28,7 @@ void test_v_h_2(void); void test_h_v_2(void); void test_ym_stopped_tick(void); short test_ym_ab_sync(void); +short test_ym_ab_sync2(void); extern const char test_hint[]; extern const char test_hint_end[]; diff --git a/testpico/main.c b/testpico/main.c index d7ed087..9c07110 100644 --- a/testpico/main.c +++ b/testpico/main.c @@ -1235,7 +1235,7 @@ static int t_tim_vcnt_loops(void) for (i = 0; i < lines; i++) expect_range(ok, ram16[i*2+1], 19, 21); expect(ok, ram16[lines*2+0], 0); - expect_range(ok, ram16[lines*2+1], 20, 21); + expect_range(ok, ram16[lines*2+1], 19, 21); return ok; } @@ -1409,9 +1409,19 @@ static int t_tim_ym_timerb_stop(void) static int t_tim_ym_timer_ab_sync(void) { - u16 v = test_ym_ab_sync(); + u16 v1, v2, v3, start, line_diff; int ok = 1; - expect(ok, v, 3); + v1 = test_ym_ab_sync(); + start = get_line(); + write8(0xa04001, 0x3f); // clear + burn10(3420*11/7/10); // ~11 scanlines + v2 = read8(0xa04000); + v3 = test_ym_ab_sync2(); + line_diff = get_line() - start; + expect(ok, v1, 3); + expect(ok, v2, 0); + expect(ok, v3, 3); + expect_range(ok, line_diff, 18, 19); return ok; } diff --git a/testpico/sega_gcc.s b/testpico/sega_gcc.s index d4fdc58..1e0116a 100644 --- a/testpico/sega_gcc.s +++ b/testpico/sega_gcc.s @@ -16,12 +16,12 @@ exc_tab: .ascii "J " .long 0x000000,0x3fffff .long 0xff0000,0xffffff - .ascii "RA"; .byte 0xf8,0x20 /* 1b0 */ - .long 0x200001,0x20ffff /* 1b4 */ - .ascii " " /* 1bc */ - .ascii " " /* 1c0 */ - .ascii " " - .ascii "JUE " /* 1f0 */ + .ascii "RA"; .byte 0xf8,0x20 /* 1b0 */ + .long 0x200001,0x20ffff /* 1b4 */ + .ascii " " /* 1bc */ + .ascii " " /* 1c0 */ + .ascii "src: https://github.com/notaz/megadrive/" /* 1c8 */ + .ascii "JUE " /* 1f0 */ # mystery landing area for reset with 32X on and RV=1 # 2c8 - 304 in multiples of 4