tst.w (0xc00004).l
no_tmss:
+ /* want to do early PC transfer (with RAM/VRAM intact and such)?
+ * also give time PC to see start condition */
+ move.l #0x2000,d0
+0: dbra d0,0b
+
+ move.l #0xa10005,a0
+ btst.b #5,(a0)
+ bne no_early_transfer
+move.b #1,(0)
+ move.b #0x40,(0xa1000b).l /* port 2 ctrl */
+ move.b #0x00,(a0) /* port 2 data - start with TH low */
+ move.l #0x2000,d0
+0:
+ btst.b #4,(a0)
+ beq do_early_transfer
+ dbra d0,0b
+
+move.b #2,(0)
+ move.b #0,(0xa1000b).l
+ bra no_early_transfer /* timeout */
+
+do_early_transfer:
+move.b #9,(0)
+ bsr do_transfer
+
+no_early_transfer:
+
.if COPY_TO_EXP
/* copy to expansion device if magic number is set */
move.l #0x400000,a1
bne wait_tl_low0
menu_text txt_working, 13, 13, 0
- bra do_transfer
+ bsr do_transfer
+ bra return_to_main
# go back to main mode
return_to_main:
"\trecv <file> <addr> <size>\n"
"\tjump <addr>\n"
"\tio {r{8,16,32} <addr>,w{8,16,32} <addr> <data>}*\n"
- "\tloadstate <picodrive_savestate>\n", argv0);
+ "\tloadstate <picodrive_savestate>\n"
+ "\trecvvram <file>\n", argv0);
exit(1);
}
data[i + 1] = tmp;
}
}
+ else if (strcmp(argv[1], "recvvram") == 0)
+ {
+ if (argc != 3)
+ usage(argv[0]);
+
+ file = fopen(argv[2], "wb");
+ if (file == NULL) {
+ fprintf(stderr, "can't open file: %s\n", argv[2]);
+ return 1;
+ }
+
+ size = 0x10000;
+ memset(data, 0, size);
+ }
else
usage(argv[0]);
printf("regs: %02x %02x %02x\n",
inb(PORT_DATA), inb(PORT_STATUS), inb(PORT_CONTROL));
+
+ /* wait for start condition */
+ if (!(inb(PORT_STATUS) & 0x40))
+ printf("waiting for TH high..\n");
+ while (!(inb(PORT_STATUS) & 0x40))
+ usleep(10000);
+
outb(0xe8, PORT_CONTROL); /* TR low - request for transfer */
+ /* wait for request ack */
if (inb(PORT_STATUS) & 0x40)
printf("waiting for TH low..\n");
- while (inb(PORT_STATUS) & 0x40)
- usleep(100000);
+ for (i = 10000; inb(PORT_STATUS) & 0x40; i += 100) {
+ if (i > 100000)
+ i = 100000;
+ usleep(i);
+ }
outb(0xe0, PORT_CONTROL);
if (strcmp(argv[1], "send") == 0)
{
- send_cmd(CMD_MD_SEND);
+ send_cmd(CMD_PC_SEND);
send_byte((addr >> 16) & 0xff);
send_byte((addr >> 8) & 0xff);
send_byte((addr >> 0) & 0xff);
}
else if (strcmp(argv[1], "recv") == 0)
{
- send_cmd(CMD_MD_RECV);
+ send_cmd(CMD_PC_RECV);
send_byte((addr >> 16) & 0xff);
send_byte((addr >> 8) & 0xff);
send_byte((addr >> 0) & 0xff);
send_byte(data[i]);
}
}
+ else if (strcmp(argv[1], "recvvram") == 0)
+ {
+ send_cmd(CMD_VRAM_RECV);
+ output_to_input();
+
+ for (i = 0; i < size; i++)
+ {
+ if ((i & 0xff) == 0) {
+ printf("\b\b\b\b\b\b\b\b\b\b\b\b\b");
+ printf("%06x/%06x", i, size);
+ fflush(stdout);
+ }
+
+ data[i] = recv_byte();
+ }
+
+ fwrite(data, 1, size, file);
+ }
if (size != 0) {
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b");
move.l d2,d0
rts
+# send 1 byte in d0
+# in: a1 - data port
+# trash: d1,d2
send_byte:
send_one_byte
rts
+.macro switch_to_output
+0: /*Lwait_tl_low: PC should switch to rx mode before lowering tl */
+ move.b (a1),d0
+ btst.b #4,d0
+ bne 0b /*Lwait_tl_low*/
+
+ move.b #0x4f,(0xa1000b).l
+ move.b #0x40,(a1)
+.endm
+
.equ sat_maxsize, (80*8+0x200) /* sprites+max_align */
# make sure cache is invalidated
bra pcc_jump
bra pcc_io
bra pcc_loadstate
+ bra pcc_vram_send
bra pcc_test_code
bsr recv_ad
move.l d0,d3
-0: /*Lwait_tl_low: it should switch to rx mode before lowering tl */
- move.b (a1),d0
- btst.b #4,d0
- bne 0b /*Lwait_tl_low*/
-
- move.b #0x4f,(0xa1000b).l
- move.b #0x40,(a1)
+ switch_to_output
tr_send_loop:
move.b (a0)+,d0
bra pcc_io_loop
pcc_io_rx:
-0: /*Lwait_tl_low:*/
- move.b (a1),d0
- btst.b #4,d0
- bne 0b /*Lwait_tl_low*/
-
- move.b #0x4f,(0xa1000b).l
- move.b #0x40,(a1)
+ switch_to_output
cmp.b #IOSEQ_R32, d3
beq pcc_io_r32
bra return
+pcc_vram_send:
+ /* write VRAM */
+ move.l #0xc00000,a0
+ move.w #0x8f02,4(a0) /* auto increment 2 */
+ move.l #0,4(a0) /* VRAM read, addr 0 */
+ move.l #0x10000/2-1,d4
+
+ switch_to_output
+
+tr_vram_send_loop:
+ move.w (a0),d3
+ move.w d3,d0
+ lsr.w #8,d0
+ bsr send_byte
+ move.b d3,d0
+ bsr send_byte
+ dbra d4,tr_vram_send_loop
+
+ bra return
+
/* some random code */
move.l d2,(a1)+
move.l d3,(a1)+
move.l a0,(a1)+
- bra return_to_main
+ rts
+# bra return_to_main
# vim:filetype=asmM68k
/* all data is big endian */
#define CMD_PREFIX 0x5a
-#define CMD_MD_SEND 0xc1 /* send to MD: addr[3], len[3], data[] */
-#define CMD_MD_RECV 0xc2 /* recv from MD: addr[3], len[3], data[] */
+#define CMD_PC_SEND 0xc1 /* send to MD: addr[3], len[3], data[] */
+#define CMD_PC_RECV 0xc2 /* recv from MD: addr[3], len[3], data[] */
#define CMD_JUMP 0xc3 /* jump to addr: addr[3] */
#define CMD_IOSEQ 0xc4 /* perform i/o ops: count[2], [type[1], addr[3], data[{0,1,2,4}]]* */
#define CMD_LOADSTATE 0xc5 /* load PD state: vram[64k], cram[128], vsram[128], vdp[32] */
-#define CMD_TEST 0xc6 /* test code */
+#define CMD_VRAM_RECV 0xc6 /* recv from MD: vram[64k] */
+#define CMD_TEST 0xc7 /* test code */
-#define CMD_FIRST CMD_MD_SEND
+#define CMD_FIRST CMD_PC_SEND
#define CMD_LAST CMD_TEST
#define IOSEQ_R8 0xb0