diff --git a/PSNee/MCU.h b/PSNee/MCU.h index 20ca294..d0bf87d 100644 --- a/PSNee/MCU.h +++ b/PSNee/MCU.h @@ -199,8 +199,8 @@ // Define the main pins as inputs #define PIN_DATA_INPUT DDRB &= ~(1 << DDB0) // Set DDRB register to configure PINB0 as input #define PIN_WFCK_INPUT DDRB &= ~(1 << DDB1) // Set DDRB register to configure PINB1 as input - #define PIN_SQCK_INPUT DDRD &= ~(1 << DDD6) // Set DDRB register to configure PINB6 as input - #define PIN_SUBQ_INPUT DDRD &= ~(1 << DDD7) // Set DDRB register to configure PINB7 as input + #define PIN_SQCK_INPUT DDRD &= ~(1 << DDD6) // Set DDRD register to configure PINB6 as input + #define PIN_SUBQ_INPUT DDRD &= ~(1 << DDD7) // Set DDRD register to configure PINB7 as input // Configure lines as outputs (for injection/override) #define PIN_DATA_OUTPUT DDRB |= (1 << DDB0) // Set DDRB register to configure PINB0 as output @@ -214,7 +214,7 @@ // Direct Register Reading (High-speed polling) #define PIN_SQCK_READ (!!(PIND & (1 << PIND6))) // Check if the value of PIND6 is high (1) #define PIN_SUBQ_READ (!!(PIND & (1 << PIND7))) // Check if the value of PIND7 is high (1) - #define PIN_WFCK_READ (!!(PINB & (1 << PINB1))) // Check if the value of PIND1 is high (1) + #define PIN_WFCK_READ (!!(PINB & (1 << PINB1))) // Check if the value of PINB1 is high (1) // --- Status Indication (LED) --- #ifdef LED_RUN @@ -244,7 +244,7 @@ #define PIN_AX_READ (!!(PIND & (1 << PIND2))) // Hardware Interrupt (INT0) for AX pulse counting - #define PIN_AX_INTERRUPT_ENABLE EIMSK |= (1<>= 1; if (PIN_SUBQ_READ) { @@ -510,11 +506,14 @@ void CaptureSUBQ(void) { if (SUBQBuffer[1] == 0x00 && SUBQBuffer[6] == 0x00) { /* - * HIT INCREMENT CONDITIONS: - * A. LEAD-IN PATTERNS: Detects TOC markers (A0-A2) or Track 01 at spiral start. - * (uint8_t)(SUBQBuffer[3] - 0x03) >= 0xF5 handles the 0x98 to 0x02 wrap-around. - * B. TRACKING LOCK: Maintains count if already synced and reading valid sectors. - */ + * HIT INCREMENT CONDITIONS: + * A. LEAD-IN PATTERNS: Detects TOC markers (A0-A2) or Track 01 at the spiral start. + * The calculation (uint8_t)(SUBQBuffer[3] - 0x03) >= 0xF5 handles + * the 0x98 to 0x02 wrap-around near the TOC boundary. + * B. TRACKING LOCK: Maintains the counter if already synced and reading + * valid sectors (Audio or Data). + */ + if ( (isDataSector && (SUBQBuffer[2] >= 0xA0 || (SUBQBuffer[2] == 0x01 && ( (uint8_t)(SUBQBuffer[3] - 0x03) >= 0xF5)))) || (hysteresis > 0 && (SUBQBuffer[0] == 0x01 || isDataSector)) ) { @@ -731,7 +730,7 @@ int main() { CaptureSUBQ(); // Confidence Filtering: Accumulate hits toward HYSTERESIS_MAX - // Validation and Data/TOC masking (0xD0) are handled inside the filter. + // Control byte masking (0xD0) and TOC pattern matching are handled inside the filter. FilterSUBQSamples(SUBQBuffer[0]); // Execution: Trigger SCEx injection once confidence (hysteresis) is reached