+void p32x_pwm_schedule(unsigned int now)
+{
+ int tm;
+
+ if (Pico32x.emu_flags & P32XF_PWM_PEND)
+ return; // already scheduled
+ if (Pico32x.sh2irqs & P32XI_PWM)
+ return; // previous not acked
+ if (!((Pico32x.sh2irq_mask[0] | Pico32x.sh2irq_mask[1]) & 1))
+ return; // masked by everyone
+
+ tm = (Pico32x.regs[0x30 / 2] & 0x0f00) >> 8;
+ tm = ((tm - 1) & 0x0f) + 1;
+ p32x_event_schedule(P32X_EVENT_PWM, now, pwm_cycles * tm / 3);
+ Pico32x.emu_flags |= P32XF_PWM_PEND;
+}
+