From: notaz Date: Thu, 23 Oct 2014 23:59:40 +0000 (+0300) Subject: megaed-sv: more tests X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eea25dd137e6a818db0a31e35cd57090c47dff08;p=megadrive.git megaed-sv: more tests --- diff --git a/megaed-sv/asmtools.h b/megaed-sv/asmtools.h index 46ce1c0..ff3c42b 100644 --- a/megaed-sv/asmtools.h +++ b/megaed-sv/asmtools.h @@ -1,4 +1,5 @@ void read_joy_responses(u8 resp[8*5]); -void test_joy_read_log(u8 *dest, int size); +void test_joy_read_log(u8 *dest, int size, int do_sync); void test_joy_read_log_vsync(u8 *dest, int size); +void test_byte_write(u8 *dest, int size, int seed); void run_game(u16 mapper, int tas_sync); diff --git a/megaed-sv/asmtools.s b/megaed-sv/asmtools.s index 7b7e759..2ed3df7 100644 --- a/megaed-sv/asmtools.s +++ b/megaed-sv/asmtools.s @@ -49,20 +49,13 @@ read_joy_responses: rts -.global test_joy_read_log /* u8 *dest, int size */ -test_joy_read_log: - ldarg 0, 0, a1 - ldarg 1, 0, d0 - movem.l d2-d7, -(sp) - movea.l #0xa10003, a0 - move.l d0, d7 - -.macro joy_read_log_prep - move.l #0x40, d1 - moveq.l #0, d0 - move.b d1, (6,a0) - move.b d1, (a0) - +/* expects: + * a0 = #0xa10003 + * d0 = #0 + * d1 = #0x40 + * trashes d2, d3 + */ +sync_with_teensy: 0: /* wait for special code */ move.b d1, (a0) move.b (a0), d2 @@ -84,8 +77,11 @@ test_joy_read_log: 0: /* wait enough for teensy to setup it's stuff */ subq.l #1, d2 /* 8 */ bgt.s 0b /* 10 */ -.endm -.macro nop_ + + rts + + +.macro t_nop /* * when communicating with 3.3V teensy: * - no nops: see old value on multiple pins randomly @@ -96,20 +92,38 @@ test_joy_read_log: nop .endm - joy_read_log_prep + +.global test_joy_read_log /* u8 *dest, int size, int do_sync */ +test_joy_read_log: + ldarg 0, 0, a1 + ldarg 1, 0, d0 + ldarg 2, 0, d1 + movem.l d2-d7, -(sp) + movea.l #0xa10003, a0 + move.l d0, d7 + move.l d1, d6 + + moveq.l #0, d0 + move.l #0x40, d1 + move.b d1, (6,a0) + move.b d1, (a0) + + tst.l d6 + beq.s 2f + bsr sync_with_teensy 2: /* save data */ move.b d0, (a0) - nop_ + t_nop move.b (a0), d2 move.b d1, (a0) - nop_ + t_nop move.b (a0), d3 move.b d0, (a0) - nop_ + t_nop move.b (a0), d4 move.b d1, (a0) - nop_ + t_nop move.b (a0), d5 .if 0 /* broken on Mega-ED v9?? */ @@ -147,8 +161,12 @@ test_joy_read_log_vsync: movea.l #0xc00005, a2 move.l d0, d7 - /* syncs, sets d0=0, d1=0x40 */ - joy_read_log_prep + move.l #0x40, d1 + moveq.l #0, d0 + move.b d1, (6,a0) + move.b d1, (a0) + + bsr sync_with_teensy 2: /* save data */ move.b d0, (a0) @@ -174,6 +192,48 @@ test_joy_read_log_vsync: rts +.global test_byte_write /* u8 *dest, int size, int seed */ +test_byte_write: + ldarg 0, 0, a0 + ldarg 1, 0, d0 + ldarg 2, 0, d1 + movem.l d2-d7, -(sp) + + move.l a0, a1 + add.l d0, a1 + move.l d1, d7 +0: + move.b d7, d0 + addq.b #1, d7 + move.b d7, d1 + addq.b #1, d7 + move.b d7, d2 + addq.b #1, d7 + move.b d7, d3 + addq.b #1, d7 + move.b d7, d4 + addq.b #1, d7 + move.b d7, d5 + addq.b #1, d7 + move.b d7, d6 + addq.b #1, d7 + + move.b d0, (a0)+ + move.b d1, (a0)+ + move.b d2, (a0)+ + move.b d3, (a0)+ + move.b d4, (a0)+ + move.b d5, (a0)+ + move.b d6, (a0)+ + move.b d7, (a0)+ + addq.b #1, d7 + cmp.l a1, a0 + blt.s 0b + + movem.l (sp)+, d2-d7 + rts + + .global run_game /* u16 mapper, int tas_sync */ run_game: move.w #0x2700, sr diff --git a/megaed-sv/main.c b/megaed-sv/main.c index fa0c163..4473c5c 100644 --- a/megaed-sv/main.c +++ b/megaed-sv/main.c @@ -386,13 +386,15 @@ static void test_joy_latency(int *min_out, int *max_out) static int do_test(OsRoutine *ed, u8 b3) { int min = 0, max = 0; + int i, t, len, seed; + u8 *p, v; switch (b3) { case '0': printf("reading..\n"); - test_joy_read_log((void *)0x200000, 0x20000); - //test_joy_read_log((void *)0xff0200, 0x0f000); + test_joy_read_log((void *)0x200000, 0x20000, 1); + //test_joy_read_log((void *)0xff0200, 0x0f000, 1); printf("done\n"); return 0; case '1': @@ -400,6 +402,47 @@ static int do_test(OsRoutine *ed, u8 b3) test_joy_read_log_vsync((void *)0x200000, 3600 * 2); printf("done\n"); return 0; + case '2': + case '3': + printf("3btn_idle test..\n"); + p = (void *)0x200000; + len = 0x20000; + test_joy_read_log(p, len, b3 == '3'); + for (i = 0; i < len; i++) { + static const u8 e[2] = { 0x33, 0x7f }; + v = e[i & 1]; + if (p[i] != v) + printf("%06x: bad: %02x %02x\n", &p[i], p[i], v); + } + printf("done\n"); + return 0; + case '4': + printf("3btn_idle data test..\n"); + p = (void *)0x200000; + len = 0x20000; + for (i = 0; i < len; i++) { + static const u8 e[2] = { 0x33, 0x7f }; + v = e[i & 1]; + if (p[i] != v) + printf("%06x: bad: %02x %02x\n", &p[i], p[i], v); + } + printf("done\n"); + return 0; + case '5': + seed = read8(0xC00009); + printf("testing, seed=%02x\n", seed); + p = (void *)0x200000; + len = 0x100000; + test_byte_write(p, len, seed); + for (t = 0; t < 2; t++) { + for (i = 0; i < len; i++) { + v = (u8)(i + seed); + if (p[i] != v) + printf("%06x: bad: %02x %02x\n", &p[i], p[i], v); + } + printf("done (%d)\n", t); + } + return 0; case 'j': test_joy_latency(&min, &max); printf("latency: %d - %d\n\n", min, max);