From: notaz Date: Fri, 7 Nov 2014 23:43:06 +0000 (+0200) Subject: add ability to disable loader sync X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d4349fc1c542c6a70712f508b4fdaa9eb5f14ee;p=megadrive.git add ability to disable loader sync --- diff --git a/host/main.c b/host/main.c index 434eaa9..c3a850b 100644 --- a/host/main.c +++ b/host/main.c @@ -673,6 +673,7 @@ int main(int argc, char *argv[]) const char *logfn = NULL; uint8_t *tas_data = NULL; int use_vsync = 0; // frame increment on vsync + int no_start_seq = 0; int tas_skip = 0; int enable_sent = 0; int abort_sent = 0; @@ -718,6 +719,9 @@ int main(int argc, char *argv[]) case 'v': use_vsync = 1; continue; + case 'n': + no_start_seq = 1; + continue; default: fprintf(stderr, "bad arg: %s\n", argv[i]); return 1; @@ -1043,6 +1047,7 @@ int main(int argc, char *argv[]) pkt_out.enable.stream_to = (tas_data != NULL); pkt_out.enable.stream_from = (outf != NULL); pkt_out.enable.use_readinc = !use_vsync; + pkt_out.enable.no_start_seq = no_start_seq; ret = submit_urb(dev.fd, &urb[URB_DATA_OUT], dev.ifaces[0].ep_out, &pkt_out, sizeof(pkt_out)); diff --git a/main.c b/main.c index 794317b..96b895f 100644 --- a/main.c +++ b/main.c @@ -194,6 +194,33 @@ static void portc_isr_frameinc_do_from(void) g.frame_cnt++; } +static void choose_isrs(void) +{ + if (g.stream_enable_to) { + if (g.use_readinc) { + attachInterruptVector(IRQ_PORTB, portb_isr_do_to_inc); + attachInterruptVector(IRQ_PORTC, portc_isr_nop); + } + else { + attachInterruptVector(IRQ_PORTB, portb_isr_do_to); + attachInterruptVector(IRQ_PORTC, portc_isr_frameinc); + } + } + else if (g.stream_enable_from) { + g.use_pending = 1; + if (g.use_readinc) { + attachInterruptVector(IRQ_PORTB, + portb_isr_fixed_do_from); + attachInterruptVector(IRQ_PORTC, portc_isr_nop); + } + else { + attachInterruptVector(IRQ_PORTB, portb_isr_fixed); + attachInterruptVector(IRQ_PORTC, + portc_isr_frameinc_do_from); + } + } +} + static void udelay(uint32_t us) { uint32_t start = micros(); @@ -276,30 +303,8 @@ static void do_start_seq(void) } __disable_irq(); + choose_isrs(); g.stream_started = 1; - if (g.stream_enable_to) { - if (g.use_readinc) { - attachInterruptVector(IRQ_PORTB, portb_isr_do_to_inc); - attachInterruptVector(IRQ_PORTC, portc_isr_nop); - } - else { - attachInterruptVector(IRQ_PORTB, portb_isr_do_to); - attachInterruptVector(IRQ_PORTC, portc_isr_frameinc); - } - } - else if (g.stream_enable_from) { - g.use_pending = 1; - if (g.use_readinc) { - attachInterruptVector(IRQ_PORTB, - portb_isr_fixed_do_from); - attachInterruptVector(IRQ_PORTC, portc_isr_nop); - } - else { - attachInterruptVector(IRQ_PORTB, portb_isr_fixed); - attachInterruptVector(IRQ_PORTC, - portc_isr_frameinc_do_from); - } - } __enable_irq(); } @@ -350,6 +355,11 @@ static void do_usb(void *buf) g.stream_enable_to = pkt->enable.stream_to; g.stream_enable_from = pkt->enable.stream_from; g.use_readinc = pkt->enable.use_readinc; + if (pkt->enable.no_start_seq) { + GPIOD_PDOR = 0x3f; + choose_isrs(); + g.stream_started = 1; + } __enable_irq(); break; case PKT_STREAM_ABORT: diff --git a/pkts.h b/pkts.h index a51b0d0..16877f6 100644 --- a/pkts.h +++ b/pkts.h @@ -22,6 +22,7 @@ struct tas_pkt { uint8_t stream_from; // frame increment on read uint8_t use_readinc; + uint8_t no_start_seq; } enable; }; } __attribute__((packed));