+static void portb_isr_read(void)
+{
+ uint32_t isfr, th;
+
+ isfr = PORTB_ISFR;
+ PORTB_ISFR = isfr;
+ th = (GPIOB_PDIR >> CORE_PIN0_BIT) & 1;
+
+ GPIOD_PDOR = g.stream[g.o][th];
+ g.edge_cnt++;
+}
+
+static void portc_isr_nop(void)
+{
+ uint32_t isfr;
+
+ isfr = PORTC_ISFR;
+ PORTC_ISFR = isfr;
+}
+
+// /vsync starts at line 235/259 (ntsc/pal), just as vcounter jumps back
+// we care when it comes out (/vsync goes high) after 3 lines at 238/262
+static void portc_isr_frameinc(void)
+{
+ uint32_t isfr;
+
+ isfr = PORTC_ISFR;
+ PORTC_ISFR = isfr;
+
+ g.o = (g.o + 1) & STREAM_BUF_MASK;
+ if (g.o == g.i) {
+ attachInterruptVector(IRQ_PORTB, portb_isr_fixed);
+ attachInterruptVector(IRQ_PORTC, portc_isr_nop);
+ }
+ g.frame_cnt++;
+}
+