From e2d07b7f35debc8243273ce44b48d1573de43d62 Mon Sep 17 00:00:00 2001 From: kalymos Date: Sun, 20 Apr 2025 18:32:43 +0200 Subject: [PATCH] Too many things to summarize Refactoring of the setting file, to be able to have settings specifying the HYSTERESIS_MAX variable. Renamed precompilation variable in BIOS_patching file. Changing console selection in .ino file --- PSNee_V8.6/PSNee_V8.6/BIOS_patching.h | 3 +- PSNee_V8.6/PSNee_V8.6/MCU.h | 943 +++++++++++++------------- PSNee_V8.6/PSNee_V8.6/PSNee_V8.6.ino | 48 +- PSNee_V8.6/PSNee_V8.6/settings.h | 68 +- 4 files changed, 545 insertions(+), 517 deletions(-) diff --git a/PSNee_V8.6/PSNee_V8.6/BIOS_patching.h b/PSNee_V8.6/PSNee_V8.6/BIOS_patching.h index 6df181d..7e49f8b 100644 --- a/PSNee_V8.6/PSNee_V8.6/BIOS_patching.h +++ b/PSNee_V8.6/PSNee_V8.6/BIOS_patching.h @@ -1,7 +1,8 @@ #pragma once -#ifdef BIOS_PATCH +#if defined(SCPH_102) || defined(SCPH_100) || defined(SCPH_7000_9000) || defined(SCPH_5500) || defined(SCPH_3500_5000) || defined(SCPH_3000) || defined(SCPH_1000) + void Timer_Start(void); void Timer_Stop(void); diff --git a/PSNee_V8.6/PSNee_V8.6/MCU.h b/PSNee_V8.6/PSNee_V8.6/MCU.h index 9687be8..a9347d1 100644 --- a/PSNee_V8.6/PSNee_V8.6/MCU.h +++ b/PSNee_V8.6/PSNee_V8.6/MCU.h @@ -8,85 +8,85 @@ // ***************************************************************************************************************** //****************************************************************************************************************** -// Configuring the clock speed and associated registers. The formula for calculating +// Configuring the clock speed and associated registers. The formula for calculating // the clock frequency is F_CPU / (TCCR0B |= (1< + #include + #include + #include + #include + #include -#include -#include -#include -#include -#include -#include + // Global interrupt control settings + #define GLOBAL_INTERRUPT_ENABLE SREG |= (1 << 7) // Set the I-bit (bit 7) in the Status Register to enable global interrupts + #define GLOBAL_INTERRUPT_DISABLE SREG &= ~(1 << 7) // Clear the I-bit (bit 7) in the Status Register to disable global interrupts -// Global interrupt control settings -#define GLOBAL_INTERRUPT_ENABLE SREG |= (1<<7) // Set the I-bit (bit 7) in the Status Register to enable global interrupts -#define GLOBAL_INTERRUPT_DISABLE SREG &= ~(1<<7) // Clear the I-bit (bit 7) in the Status Register to disable global interrupts + // Enable/Disable timer interrupts + #define TIMER_INTERRUPT_ENABLE TIMSK0 |= (1 << OCIE0A) // Enable interrupt on Timer0 Compare Match A + #define TIMER_INTERRUPT_DISABLE TIMSK0 &= ~(1 << OCIE0A) // Disable interrupt on Timer0 Compare Match A -// Main pin configuration for input and output + // Main pin configuration for input and output -// Define the main pins as inputs -#define PIN_DATA_INPUT DDRB &= ~(1< -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include + #include -// Globale interrupt seting -#define GLOBAL_INTERRUPT_ENABLE SREG |= (1<<7) -#define GLOBAL_INTERRUPT_DISABLE SREG &= ~(1<<7) + // Globale interrupt seting + #define GLOBAL_INTERRUPT_ENABLE SREG |= (1 << 7) + #define GLOBAL_INTERRUPT_DISABLE SREG &= ~(1 << 7) -#define TIMER_INTERRUPT_ENABLE TIMSK0 |= (1< -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include + #include -// Globale interrupt seting -#define GLOBAL_INTERRUPT_ENABLE SREG |= (1<<7) -#define GLOBAL_INTERRUPT_DISABLE SREG &= ~(1<<7) + // Globale interrupt seting + #define GLOBAL_INTERRUPT_ENABLE SREG |= (1 << 7) + #define GLOBAL_INTERRUPT_DISABLE SREG &= ~(1 << 7) -// Handling the main pins + // Handling the main pins -// Main pins input -#define PIN_DATA_INPUT DDRB &= ~(1< -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include + #include -// Globale interrupt seting -#define GLOBAL_INTERRUPT_ENABLE SREG |= (1<<7) -#define GLOBAL_INTERRUPT_DISABLE SREG &= ~(1<<7) + // Globale interrupt seting + #define GLOBAL_INTERRUPT_ENABLE SREG |= (1 << 7) + #define GLOBAL_INTERRUPT_DISABLE SREG &= ~(1 << 7) -// Handling the main pins + // Handling the main pins -// Main pins input -#define PIN_DATA_INPUT DDRB &= ~(1< @@ -484,97 +499,97 @@ #include // Globale interrupt seting -#define GLOBAL_INTERRUPT_ENABLE __asm__ __volatile__ ("sei" ::) //CPU.SREG |= (1<<7) -#define GLOBAL_INTERRUPT_DISABLE __asm__ __volatile__ ("cli" ::) //CPU.SREG &= ~(1<<7) +#define GLOBAL_INTERRUPT_ENABLE __asm__ __volatile__("sei" ::) //CPU.SREG |= (1<<7) +#define GLOBAL_INTERRUPT_DISABLE __asm__ __volatile__("cli" ::) //CPU.SREG &= ~(1<<7) // Handling the main pins // Main pins input -#define PIN_DATA_INPUT PORTA.DIR = PIN2_bm -#define PIN_WFCK_INPUT PORTA.DIR = PIN1_bm // Create a mask (1<<0) with the first bit at 1 b00000001 uses the ~ operator to perform a bit inversion b11111110, -#define PIN_SQCK_INPUT PORTA.DIR = PIN4_bm // &= updates the DDRB register with the AND operator and the mask, DDRB bxxxxxxxx OR mask b11111110 = bxxxxxxx0 -#define PIN_SUBQ_INPUT PORTA.DIR = PIN3_bm - +#define PIN_DATA_INPUT PORTA.DIR = PIN2_bm +#define PIN_WFCK_INPUT PORTA.DIR = PIN1_bm // Create a mask (1<<0) with the first bit at 1 b00000001 uses the ~ operator to perform a bit inversion b11111110, +#define PIN_SQCK_INPUT PORTA.DIR = PIN4_bm // &= updates the DDRB register with the AND operator and the mask, DDRB bxxxxxxxx OR mask b11111110 = bxxxxxxx0 +#define PIN_SUBQ_INPUT PORTA.DIR = PIN3_bm + // Main pin output -#define PIN_DATA_OUTPUT PORTA.DIR |= PIN2_bm // Create a mask (1<<0) with the first bit at 1 b00000001, -#define PIN_WFCK_OUTPUT PORTA.DIR |= PIN1_bm // |= updates the DDRB register with the OR operator and the mask, DDRB bxxxxxxxx OR mask b00000001 = bxxxxxxx1 - +#define PIN_DATA_OUTPUT PORTA.DIR |= PIN2_bm // Create a mask (1<<0) with the first bit at 1 b00000001, +#define PIN_WFCK_OUTPUT PORTA.DIR |= PIN1_bm // |= updates the DDRB register with the OR operator and the mask, DDRB bxxxxxxxx OR mask b00000001 = bxxxxxxx1 + // Define pull-ups and set high at the main pin -#define PIN_DATA_SET PORTA.OUT |= PIN2_bm // Create a mask (1<<0) with the first bit at 1 b00000001, - // |= updates the PORTB register with the OR operator and the mask, PORTB bxxxxxxxx OR mask b00000001 = bxxxxxxx1 - +#define PIN_DATA_SET PORTA.OUT |= PIN2_bm // Create a mask (1<<0) with the first bit at 1 b00000001, + // |= updates the PORTB register with the OR operator and the mask, PORTB bxxxxxxxx OR mask b00000001 = bxxxxxxx1 + // Define pull-ups set down at the main pin -#define PIN_DATA_CLEAR PORTA.OUT &= ~PIN2_bm // Create a mask (1<<0) with the first bit at 1 b00000001 uses the ~ operator to perform a bit inversion b11111110, -#define PIN_WFCK_CLEAR PORTA.OUT &= ~PIN1_bm // &= updates the DDRB register with the AND operator and the mask, DDRB bxxxxxxxx OR mask b11111110 = bxxxxxxx0 - +#define PIN_DATA_CLEAR PORTA.OUT &= ~PIN2_bm // Create a mask (1<<0) with the first bit at 1 b00000001 uses the ~ operator to perform a bit inversion b11111110, +#define PIN_WFCK_CLEAR PORTA.OUT &= ~PIN1_bm // &= updates the DDRB register with the AND operator and the mask, DDRB bxxxxxxxx OR mask b11111110 = bxxxxxxx0 + // Read the main pins -#define PIN_SQCK_READ PORTA.IN & PIN4_bm // Create a mask (1<<6) with the six bit at 1 b00100000, -#define PIN_SUBQ_READ PORTA.IN & PIN3_bm // compare the PINB register and the mask with the AND operator, and returns the result, PINB bxx1xxxxx AND mask b00100000 = 1 -#define PIN_WFCK_READ PORTA.IN & PIN1_bm +#define PIN_SQCK_READ PORTA.IN& PIN4_bm // Create a mask (1<<6) with the six bit at 1 b00100000, +#define PIN_SUBQ_READ PORTA.IN& PIN3_bm // compare the PINB register and the mask with the AND operator, and returns the result, PINB bxx1xxxxx AND mask b00100000 = 1 +#define PIN_WFCK_READ PORTA.IN& PIN1_bm // Handling and use of the LED pin #define LED_RUN -#define PIN_LED_OUTPUT PORTB.DIR |= PIN2_bm -#define PIN_LED_ON PORTB.OUT |= PIN2_bm -#define PIN_LED_OFF PORTB.OUT &= ~PIN2_bm +#define PIN_LED_OUTPUT PORTB.DIR |= PIN2_bm +#define PIN_LED_ON PORTB.OUT |= PIN2_bm +#define PIN_LED_OFF PORTB.OUT &= ~PIN2_bm // Handling the BIOS patch // BIOS interrupt seting -#define TIMER_INTERRUPT_ENABLE TCA0.SPLIT.INTCTRL |= TCA_SINGLE_CMP0_bm -#define TIMER_INTERRUPT_DISABLE TCA0.SPLIT.INTCTRL &= ~TCA_SPLIT_HCMP0_bm +#define TIMER_INTERRUPT_ENABLE TCA0.SPLIT.INTCTRL |= TCA_SINGLE_CMP0_bm +#define TIMER_INTERRUPT_DISABLE TCA0.SPLIT.INTCTRL &= ~TCA_SPLIT_HCMP0_bm // BIOS timer clear -#define TIMER_TIFR_CLEAR TCA0.SPLIT.INTFLAGS = TCA_SPLIT_HCMP0_bm +#define TIMER_TIFR_CLEAR TCA0.SPLIT.INTFLAGS = TCA_SPLIT_HCMP0_bm // Pins input -#define PIN_AX_INPUT PORTB.DIR &= ~PIN3_bm -#define PIN_AY_INPUT PORTA.DIR &= ~PIN7_bm -#define PIN_DX_INPUT PORTA.DIR &= ~PIN6_bm +#define PIN_AX_INPUT PORTB.DIR &= ~PIN3_bm +#define PIN_AY_INPUT PORTA.DIR &= ~PIN7_bm +#define PIN_DX_INPUT PORTA.DIR &= ~PIN6_bm // Pin output -#define PIN_DX_OUTPUT PORTA.DIR |= PIN6_bm -// Define pull-ups set high -#define PIN_DX_SET PORTA.OUT |= PIN6_bm -// Define pull-ups set down -#define PIN_DX_CLEAR PORTA.OUT &= ~PIN6_bm +#define PIN_DX_OUTPUT PORTA.DIR |= PIN6_bm +// Define pull-ups set high +#define PIN_DX_SET PORTA.OUT |= PIN6_bm +// Define pull-ups set down +#define PIN_DX_CLEAR PORTA.OUT &= ~PIN6_bm // Read pins for BIOS patch -#define PIN_AX_READ PORTB.IN & PIN3_bm -#define PIN_AY_READ PORTA.IN & PIN6_bm +#define PIN_AX_READ PORTB.IN& PIN3_bm +#define PIN_AY_READ PORTA.IN& PIN6_bm // Handling the external interrupt //#define PIN_AX_INTERRUPT_ENABLE PORTB.PIN3CTRL |= (1< @@ -585,89 +600,89 @@ #include // Globale interrupt seting -#define GLOBAL_INTERRUPT_ENABLE SREG |= (1<<7) -#define GLOBAL_INTERRUPT_DISABLE SREG &= ~(1<<7) +#define GLOBAL_INTERRUPT_ENABLE SREG |= (1 << 7) +#define GLOBAL_INTERRUPT_DISABLE SREG &= ~(1 << 7) // Handling the main pins // Main pins input -#define PIN_DATA_INPUT DDRB &= ~(1< #include @@ -675,81 +690,79 @@ #define F_CPU 8000000L // Configuration du timer pour une fréquence de 100 kHz -#define TIMER_TCNT_CLEAR TIM2_CNT = 0x00 // ok Effacer le compteur du Timer 2 -#define SET_OCROA_DIV TIM2_ARR = 79 // not Définir la valeur de comparaison pour générer une interruption à 100 kHz -#define SET_TIMER_TCCROA TIM2_CR1 |= TIM_CR1_OPM // notMettre le Timer en mode One Pulse (à adapter selon le mode souhaité) -#define SET_TIMER_TCCROB TIM2_PSC = 0 // ok Définir le prescaler à 0 pour une fréquence maximale +#define TIMER_TCNT_CLEAR TIM2_CNT = 0x00 // ok Effacer le compteur du Timer 2 +#define SET_OCROA_DIV TIM2_ARR = 79 // not Définir la valeur de comparaison pour générer une interruption à 100 kHz +#define SET_TIMER_TCCROA TIM2_CR1 |= TIM_CR1_OPM // notMettre le Timer en mode One Pulse (à adapter selon le mode souhaité) +#define SET_TIMER_TCCROB TIM2_PSC = 0 // ok Définir le prescaler à 0 pour une fréquence maximale // Vecteur d'interruption pour le Timer 2 -#define CTC_TIMER_VECTOR TIM2_UP_IRQHandler // Remplacer par le vecteur d'interruption approprié +#define CTC_TIMER_VECTOR TIM2_UP_IRQHandler // Remplacer par le vecteur d'interruption approprié // Interruption globale -#define GLOBAL_INTERRUPT_ENABLE __enable_irq() -#define GLOBAL_INTERRUPT_DISABLE __disable_irq() +#define GLOBAL_INTERRUPT_ENABLE __enable_irq() +#define GLOBAL_INTERRUPT_DISABLE __disable_irq() // Configuration des broches GPIO -#define PIN_DATA_INPUT GPIOA->INDR &= ~(GPIO_MODER_MODER0) -#define PIN_WFCK_INPUT GPIOA->INDR &= ~(GPIO_MODER_MODER1) -#define PIN_SQCK_INPUT GPIOA->INDR &= ~(GPIO_MODER_MODER6) -#define PIN_SUBQ_INPUT GPIOA->INDR &= ~(GPIO_MODER_MODER7) +#define PIN_DATA_INPUT GPIOA->INDR &= ~(GPIO_MODER_MODER0) +#define PIN_WFCK_INPUT GPIOA->INDR &= ~(GPIO_MODER_MODER1) +#define PIN_SQCK_INPUT GPIOA->INDR &= ~(GPIO_MODER_MODER6) +#define PIN_SUBQ_INPUT GPIOA->INDR &= ~(GPIO_MODER_MODER7) -#define PIN_DATA_OUTPUT GPIOA->OUTDR |= (GPIO_MODER_MODER0_0) -#define PIN_WFCK_OUTPUT GPIOA->OUTDR |= (GPIO_MODER_MODER1_0) +#define PIN_DATA_OUTPUT GPIOA->OUTDR |= (GPIO_MODER_MODER0_0) +#define PIN_WFCK_OUTPUT GPIOA->OUTDR |= (GPIO_MODER_MODER1_0) -#define PIN_DATA_SET GPIOA->BSHR |= (GPIO_ODR_ODR_0) +#define PIN_DATA_SET GPIOA->BSHR |= (GPIO_ODR_ODR_0) -#define PIN_DATA_CLEAR GPIOA->BRC &= ~(GPIO_ODR_ODR_0) -#define PIN_WFCK_CLEAR GPIOA->BRC &= ~(GPIO_ODR_ODR_1) +#define PIN_DATA_CLEAR GPIOA->BRC &= ~(GPIO_ODR_ODR_0) +#define PIN_WFCK_CLEAR GPIOA->BRC &= ~(GPIO_ODR_ODR_1) -#define PIN_SQCK_READ (GPIOA->IDR & (GPIO_IDR_IDR_6)) -#define PIN_SUBQ_READ (GPIOA->IDR & (GPIO_IDR_IDR_7)) -#define PIN_WFCK_READ (GPIOA->IDR & (GPIO_IDR_IDR_1)) +#define PIN_SQCK_READ (GPIOA->IDR & (GPIO_IDR_IDR_6)) +#define PIN_SUBQ_READ (GPIOA->IDR & (GPIO_IDR_IDR_7)) +#define PIN_WFCK_READ (GPIOA->IDR & (GPIO_IDR_IDR_1)) // Gestion de la broche LED -#define PIN_LED_OUTPUT GPIOA->MODER |= (GPIO_MODER_MODER5_0) -#define PIN_LED_ON GPIOA->ODR |= (GPIO_ODR_ODR_5) -#define PIN_LED_OFF GPIOA->ODR &= ~(GPIO_ODR_ODR_5) +#define PIN_LED_OUTPUT GPIOA->MODER |= (GPIO_MODER_MODER5_0) +#define PIN_LED_ON GPIOA->ODR |= (GPIO_ODR_ODR_5) +#define PIN_LED_OFF GPIOA->ODR &= ~(GPIO_ODR_ODR_5) // Gestion des interruptions du timer -#define TIMER_INTERRUPT_ENABLE TIM2_DIER |= (TIM_DIER_UIE) -#define TIMER_INTERRUPT_DISABLE TIM2_DIER &= ~(TIM_DIER_UIE) -#define TIMER_TIFR_CLEAR TIM2_SR &= ~(TIM_SR_UIF) +#define TIMER_INTERRUPT_ENABLE TIM2_DIER |= (TIM_DIER_UIE) +#define TIMER_INTERRUPT_DISABLE TIM2_DIER &= ~(TIM_DIER_UIE) +#define TIMER_TIFR_CLEAR TIM2_SR &= ~(TIM_SR_UIF) // Configuration des broches pour le BIOS -#define PIN_AX_INPUT GPIOA->MODER &= ~(GPIO_MODER_MODER2) AFIO_EXTICR -#define PIN_AY_INPUT GPIOA->MODER &= ~(GPIO_MODER_MODER3) -#define PIN_DX_INPUT GPIOA->MODER &= ~(GPIO_MODER_MODER4) +#define PIN_AX_INPUT GPIOA->MODER &= ~(GPIO_MODER_MODER2)AFIO_EXTICR +#define PIN_AY_INPUT GPIOA->MODER &= ~(GPIO_MODER_MODER3) +#define PIN_DX_INPUT GPIOA->MODER &= ~(GPIO_MODER_MODER4) -#define PIN_DX_OUTPUT GPIOA->MODER |= (GPIO_MODER_MODER4_0) +#define PIN_DX_OUTPUT GPIOA->MODER |= (GPIO_MODER_MODER4_0) -#define PIN_DX_SET GPIOA->ODR |= (GPIO_ODR_ODR_4) +#define PIN_DX_SET GPIOA->ODR |= (GPIO_ODR_ODR_4) -#define PIN_DX_CLEAR GPIOA->ODR &= ~(GPIO_ODR_ODR_4) +#define PIN_DX_CLEAR GPIOA->ODR &= ~(GPIO_ODR_ODR_4) -#define PIN_AX_READ (GPIOA->IDR & (GPIO_IDR_IDR_2)) -#define PIN_AY_READ (GPIOA->IDR & (GPIO_IDR_IDR_3)) +#define PIN_AX_READ (GPIOA->IDR & (GPIO_IDR_IDR_2)) +#define PIN_AY_READ (GPIOA->IDR & (GPIO_IDR_IDR_3)) // Gestion des interruptions externes -#define PIN_AX_INTERRUPT_ENABLE EXTI->IMR |= (EXTI_IMR_MR0) //1<IMR |= (EXTI_IMR_MR1) +#define PIN_AX_INTERRUPT_ENABLE EXTI->IMR |= (EXTI_IMR_MR0) //1<IMR |= (EXTI_IMR_MR1) -#define PIN_AX_INTERRUPT_DISABLE EXTI->IMR &= ~(EXTI_IMR_MR0) //EXTI_INTENR -#define PIN_AY_INTERRUPT_DISABLE EXTI->IMR &= ~(EXTI_IMR_MR1) +#define PIN_AX_INTERRUPT_DISABLE EXTI->IMR &= ~(EXTI_IMR_MR0) //EXTI_INTENR +#define PIN_AY_INTERRUPT_DISABLE EXTI->IMR &= ~(EXTI_IMR_MR1) -#define PIN_AX_INTERRUPT_RISING EXTI->RTSR |= (EXTI_RTSR_TR0) //EXTI_RTENR -#define PIN_AY_INTERRUPT_RISING EXTI->RTSR |= (EXTI_RTSR_TR1) +#define PIN_AX_INTERRUPT_RISING EXTI->RTSR |= (EXTI_RTSR_TR0) //EXTI_RTENR +#define PIN_AY_INTERRUPT_RISING EXTI->RTSR |= (EXTI_RTSR_TR1) -#define PIN_AX_INTERRUPT_FALLING EXTI->FTSR |= (EXTI_FTENR_MR0) //EXTI_FTENR -#define PIN_AY_INTERRUPT_FALLING EXTI->FTSR |= (EXTI_FTENR_MR1) +#define PIN_AX_INTERRUPT_FALLING EXTI->FTSR |= (EXTI_FTENR_MR0) //EXTI_FTENR +#define PIN_AY_INTERRUPT_FALLING EXTI->FTSR |= (EXTI_FTENR_MR1) -#define PIN_AX_INTERRUPT_VECTOR EXTI0_IRQHandler -#define PIN_AY_INTERRUPT_VECTOR EXTI1_IRQHandler +#define PIN_AX_INTERRUPT_VECTOR EXTI0_IRQHandler +#define PIN_AY_INTERRUPT_VECTOR EXTI1_IRQHandler // Gestion de la broche de commutation pour le BIOS -#define PIN_SWITCH_INPUT GPIOA->MODER &= ~(GPIO_MODER_MODER5) -#define PIN_SWITCH_SET GPIOA->ODR |= (GPIO_ODR_ODR_5) -#define PIN_SWICHE_READ (GPIOA->IDR & (GPIO_IDR_IDR_5)) +#define PIN_SWITCH_INPUT GPIOA->MODER &= ~(GPIO_MODER_MODER5) +#define PIN_SWITCH_SET GPIOA->ODR |= (GPIO_ODR_ODR_5) +#define PIN_SWITCH_READ (GPIOA->IDR & (GPIO_IDR_IDR_5)) #endif - - diff --git a/PSNee_V8.6/PSNee_V8.6/PSNee_V8.6.ino b/PSNee_V8.6/PSNee_V8.6/PSNee_V8.6.ino index 6736865..70f138a 100644 --- a/PSNee_V8.6/PSNee_V8.6/PSNee_V8.6.ino +++ b/PSNee_V8.6/PSNee_V8.6/PSNee_V8.6.ino @@ -1,32 +1,52 @@ //------------------------------------------------------------------------------------------------ // Select your console //------------------------------------------------------------------------------------------------ -// Attention! -// If a BIOS checksum is specified, it is more important than the SCPH model number! -//------------------------------------------------------------------------------------------------ + +//Legacy mode works the same as V7. //All NTSC-U/C SCPH_xxx1, all PAL FAT models SCPH_xxx2, SCPH_103. It's 0.5 seconds longer than choosing a specific region. +//On models with problematic CD players the HYSTERESIS_MAX setting may be a little short. + //#define SCPH_xxxx -//Here the regions are specified -//#define SCPH_xxx1 // Use for all NTSC-U/C models. No BIOS patching needed. -//#define SCPH_xxx2 // Use for all PAL FAT models. No BIOS patching needed. -//#define SCPH_103 // Maybe for all SCPH_xxx3 but I have no info. +//-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- + +//Here the regions are specified. No BIOS patching needed. + +//Here the setting of HYSTERESIS_MAX goes up to 20. + +//#define SCPH_xxx1 // NTSC-U/C FAT. +//#define SCPH_xxx2 // PAL FAT. +//#define SCPH_xxx3 // NTSC-Asia FAT. + +//Here the HYSTERESIS_MAX setting is 15. + +//#define SCPH_101 // NTSC-U/C. +//#define SCPH_103 // NTSC-Asia. + +//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- + +//And all models that require a BIOS patch. + +//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +// Attention! +// If a BIOS checksum is specified, it is more important than the SCPH model number! +//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -//And all models that require a BIOS patch //#define SCPH_102 // DX - D0, AX - A7. BIOS ver. 4.4e, CRC 0BAD7EA9 | 4.5e, CRC 76B880E5 //#define SCPH_100 // DX - D0, AX - A7. BIOS ver. 4.3j, CRC F2AF798B //#define SCPH_7000_9000 // DX - D0, AX - A7. BIOS ver. 4.0j, CRC EC541CD0 //#define SCPH_5500 // DX - D0, AX - A5. BIOS ver. 3.0j, CRC FF3EEB8C //#define SCPH_3500_5000 // DX - D0, for 40-pin BIOS: AX - A4, for 32-pin BIOS: AX - A5. BIOS ver. 2.2j, CRC 24FC7E17 | 2.1j, CRC BC190209 //#define SCPH_3000 // DX - D5, for 40-pin BIOS: AX - A6, AY - A7, for 32-pin BIOS: AX - A7, AY - A8. BIOS ver. 1.1j, CRC 3539DEF6 -#define SCPH_1000 // DX - D5, for 40-pin BIOS: AX - A6, AY - A7, for 32-pin BIOS: AX - A7, AY - A8. BIOS ver. 1.0j, CRC 3B601FC8 +//#define SCPH_1000 // DX - D5, for 40-pin BIOS: AX - A6, AY - A7, for 32-pin BIOS: AX - A7, AY - A8. BIOS ver. 1.0j, CRC 3B601FC8 //------------------------------------------------------------------------------------------------ // Select your chip //------------------------------------------------------------------------------------------------ + //#define ATmega328_168 //#define ATmega32U4_16U4 //#define ATtiny85_45_25 @@ -65,7 +85,7 @@ //------------------------------------------------------------------------------------------------ #define LED_RUN // Turns on the LED when injections occur. D13 for Arduino, ATtiny add a led between PB3 (pin 2) and gnd with a 1k resistor in series, ATmega32U4 (Pro Micro) add a led between PB6 (pin 10) and gnd with a 1k resistor in series -//#define PATCH_SWICHE // Enables hardware support for disabling BIOS patching. Useful in rare cases where the BIOS patch prevents the playback of original games +#define PATCH_SWITCH // Enables hardware support for disabling BIOS patching. Useful in rare cases where the BIOS patch prevents the playback of original games //------------------------------------------------------------------------------------------------ // pointer and variable section @@ -78,8 +98,8 @@ //Initializing values ​​for region code injection timing #define DELAY_BETWEEN_BITS 4000 // 250 bits/s (microseconds) (ATtiny 8Mhz works from 3950 to 4100) PU-23 PU-22 MAX 4250 MIN 3850 #define DELAY_BETWEEN_INJECTIONS 90 // The sweet spot is around 80~100. For all observed models, the worst minimum time seen is 72, and it works well up to 250. -#define HYSTERESIS_MAX 17 // The sweet spot is between 11~19. All models have bad behavior below 11, PU-41 can start to have bad behavior beyond 20, for fat models we can go up to 60 - // On fat models if your reader is really bad you can increase this value in steps of 5. +//#define HYSTERESIS_MAX 17 // The sweet spot is between 11~19. All models have bad behavior below 11, PU-41 can start to have bad behavior beyond 20, for fat models we can go up to 60 + //Creation of the different variables for the counter volatile uint8_t count_isr = 0; @@ -293,10 +313,10 @@ void Init() { SET_TIMER_TCCROB; #endif -#if defined(PATCH_SW) && defined(BIOS_PATCH) +#if defined(PATCH_SWITCH) && defined(BIOS_PATCH) PIN_SWITCH_INPUT; PIN_SWITCH_SET; - if (PIN_SWICHE_READ = 0){ + if (PIN_SWITCH_READ == 0){ Flag_Switch =1; } #endif diff --git a/PSNee_V8.6/PSNee_V8.6/settings.h b/PSNee_V8.6/PSNee_V8.6/settings.h index e647712..b87c304 100644 --- a/PSNee_V8.6/PSNee_V8.6/settings.h +++ b/PSNee_V8.6/PSNee_V8.6/settings.h @@ -17,25 +17,10 @@ */ -#ifdef SCPH_xxxx -#define SCEZ -#endif - -#ifdef SCPH_xxx1 -#define SCEA -#endif - -#ifdef SCPH_xxx2 -#define SCEE -#endif - -#ifdef SCPH_103 -#define SCEI -#endif #ifdef SCPH_102 -#define SCEE -#define BIOS_PATCH +//#define SCEE +//#define BIOS_PATCH #define HOLD _delay_us(2.75) #define PATCHING _delay_us(0.2) #define CHECKPOINT 83900 @@ -43,8 +28,8 @@ #endif #ifdef SCPH_100 -#define SCEI -#define BIOS_PATCH +//#define SCEI +//#define BIOS_PATCH #define HOLD _delay_us(2.7) #define PATCHING _delay_us(0.2) #define CHECKPOINT 83900 @@ -52,8 +37,8 @@ #endif #ifdef SCPH_7000_9000 -#define SCEI -#define BIOS_PATCH +//#define SCEI +//#define BIOS_PATCH #define HOLD _delay_us(2.85) #define PATCHING _delay_us(0.1) #define CHECKPOINT 75270 @@ -61,8 +46,8 @@ #endif #ifdef SCPH_5500 -#define SCEI -#define BIOS_PATCH +//#define SCEI +//#define BIOS_PATCH #define HOLD _delay_us(2.85) #define PATCHING _delay_us(0.1) #define CHECKPOINT 76130 @@ -71,8 +56,8 @@ #endif #ifdef SCPH_3500_5000 -#define SCEI -#define BIOS_PATCH +//#define SCEI +//#define BIOS_PATCH #define HOLD _delay_us(2.85) #define PATCHING _delay_us(0.1) #define CHECKPOINT 75260 @@ -81,8 +66,8 @@ #endif #ifdef SCPH_3000 -#define SCEI -#define BIOS_PATCH +//#define SCEI +//#define BIOS_PATCH #define HOLD _delay_us(2.75) #define PATCHING _delay_us(0.1) #define CHECKPOINT 83000 @@ -97,8 +82,8 @@ #endif #ifdef SCPH_1000 -#define SCEI -#define BIOS_PATCH +//#define SCEI +//#define BIOS_PATCH #define HOLD _delay_us(2.7) #define PATCHING _delay_us(0.1) #define CHECKPOINT 83000 @@ -112,29 +97,38 @@ #define TRIGGER2 71 #endif -#ifdef SCEA +#if defined(SCPH_xxx1) || defined(SCPH_101) const char region[1] = {'a'}; #endif -#ifdef SCEE +#if defined(SCPH_102) || defined(SCPH_xxx2) const char region[1] = {'e'}; #endif -#ifdef SCEI +#if defined(SCPH_100) || defined(SCPH_7000_9000) || defined(SCPH_5500) || defined(SCPH_3500_5000) || defined(SCPH_3000) || defined(SCPH_1000) || defined(SCPH_103) || defined(SCPH_xxx3) const char region[1] = {'i'}; #endif -#ifdef SCEZ +#ifdef SCPH_xxxx const char region[3] = {'a', 'e', 'i'}; #endif -#if !defined(SCPH_xxx1) && !defined(SCPH_xxx2) && !defined(SCPH_103) && \ - !defined(SCPH_102) && !defined(SCPH_100) && !defined(SCPH_7000_9000) && \ +//All models have bad behavior below 11, PU-41 can start to have bad behavior beyond 20, for fat models we can go up to 60 +#if defined(SCPH_100) || defined(SCPH_101) || defined(SCPH_102) || defined(SCPH_103) || defined(SCPH_xxxx) +#define HYSTERESIS_MAX 15 +#endif + +#if defined(SCPH_xxx1) || defined(SCPH_xxx2) || defined(SCPH_xxx3) || defined(SCPH_7000_9000) || defined(SCPH_5500) || defined(SCPH_3500_5000) || defined(SCPH_3000) || defined(SCPH_1000) +#define HYSTERESIS_MAX 20 +#endif + +#if !defined(SCPH_xxx1) && !defined(SCPH_xxx2) && !defined(SCPH_xxx3) && !defined(SCPH_103) && \ + !defined(SCPH_102) && !defined(SCPH_101) && !defined(SCPH_100) && !defined(SCPH_7000_9000) && \ !defined(SCPH_5500) && !defined(SCPH_3500_5000) && !defined(SCPH_3000) && \ !defined(SCPH_1000) && !defined(SCPH_xxxx) #error "Console not selected! Please uncoment #define with SCPH model number." -#elif !(defined(SCPH_xxx1) ^ defined(SCPH_xxx2) ^ defined(SCPH_103) ^ \ - defined(SCPH_102) ^ defined(SCPH_100) ^ defined(SCPH_7000_9000) ^ \ +#elif !(defined(SCPH_xxx1) ^ defined(SCPH_xxx2) ^ defined(SCPH_xxx3) ^ defined(SCPH_103) ^ \ + defined(SCPH_102) ^ defined(SCPH_101) ^ defined(SCPH_100) ^ defined(SCPH_7000_9000) ^ \ defined(SCPH_5500) ^ defined(SCPH_3500_5000) ^ defined(SCPH_3000) ^ \ defined(SCPH_1000) ^ defined(SCPH_xxxx)) #error "May be selected only one console! Please check #define with SCPH model number."