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);
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
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
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?? */
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)
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
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':
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);