Files
Matthew Stanley 52eb8e8a24 Fix encoded CD-ROM interrupt mask matching
Adapt the CD interrupt mask/status comparison from kem0x PR #14 and centralize it in a tested helper. The HC05 exposes numeric INT1..INT5 reasons but gates the line with a direct mask/status AND, so the common 0x07 mask must also pass INT4 and INT5.

Source: https://github.com/mstan/psxrecomp/pull/14

Source-commit: https://github.com/mstan/psxrecomp/commit/dd9e5c65073dd41fbac2d965d2f945a866ec59e2

Co-authored-by: Kareem Olim <kareemolim@gmail.com>
2026-07-13 21:38:58 -07:00

16 lines
595 B
C

#ifndef PSXRECOMP_CDROM_IRQ_H
#define PSXRECOMP_CDROM_IRQ_H
#include <stdint.h>
/* HINTSTS bits 0..2 contain an encoded interrupt reason (INT1..INT5), not
* independent one-hot flags. The controller nevertheless gates its IRQ line
* by directly ANDing HINTSTS with HINTMSK. In particular, mask 0x07 enables
* all five encoded reasons, including INT4 and INT5. */
static inline int cdrom_irq_mask_matches_reason(uint8_t irq_enable,
uint8_t irq_reason) {
return (irq_enable & irq_reason & 0x07u) != 0;
}
#endif /* PSXRECOMP_CDROM_IRQ_H */