1
0
mirror of https://github.com/kalymos/PsNee.git synced 2026-03-05 11:03:54 +00:00

Layout modification

This commit is contained in:
kalymos
2025-05-09 16:40:22 +02:00
parent b34eea696a
commit 4959bbe2c7
4 changed files with 154 additions and 154 deletions

View File

@@ -1,9 +1,6 @@
#pragma once
#if defined(SCPH_102A) || 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);
@@ -11,101 +8,97 @@ extern volatile uint8_t count_isr;
extern volatile uint32_t microsec;
extern volatile uint32_t millisec;
volatile uint8_t impulse = 0;
volatile uint8_t patch = 0;
#endif
#if defined(SCPH_102) || defined(SCPH_100) || defined(SCPH_7000_9000) || defined(SCPH_5500) || defined(SCPH_3500_5000) || defined(SCPH_3000) || defined(SCPH_1000)
ISR(PIN_AX_INTERRUPT_VECTOR) {
impulse++;
if (impulse == TRIGGER){ // If impulse reaches the value defined by TRIGGER, the following actions are performed:
HOLD;
#ifdef HIGH_PATCH
PIN_DX_SET;
#endif
PIN_DX_OUTPUT;
PATCHING;
#ifdef HIGH_PATCH
PIN_DX_CLEAR;
#endif
PIN_DX_INPUT;
PIN_AX_INTERRUPT_DISABLE;
ISR(PIN_AX_INTERRUPT_VECTOR) {
impulse++;
if (impulse == TRIGGER){ // If impulse reaches the value defined by TRIGGER, the following actions are performed:
HOLD;
#ifdef HIGH_PATCH
PIN_DX_SET;
#endif
PIN_DX_OUTPUT;
PATCHING;
#ifdef HIGH_PATCH
PIN_DX_CLEAR;
#endif
PIN_DX_INPUT;
PIN_AX_INTERRUPT_DISABLE;
impulse = 0;
patch = 1; // patch is set to 1, indicating that the first patch is completed.
}
}
impulse = 0;
patch = 1; // patch is set to 1, indicating that the first patch is completed.
}
}
#ifdef HIGH_PATCH
#ifdef HIGH_PATCH
ISR(PIN_AY_INTERRUPT_VECTOR){
ISR(PIN_AY_INTERRUPT_VECTOR){
impulse++;
if (impulse == TRIGGER2) // If impulse reaches the value defined by TRIGGER2, the following actions are performed:
{
HOLD2;
PIN_DX_OUTPUT;
PATCHING2;
PIN_DX_INPUT;
PIN_AY_INTERRUPT_DISABLE;
impulse++;
if (impulse == TRIGGER2) // If impulse reaches the value defined by TRIGGER2, the following actions are performed:
{
HOLD2;
PIN_DX_OUTPUT;
PATCHING2;
PIN_DX_INPUT;
PIN_AY_INTERRUPT_DISABLE;
patch = 2; // patch is set to 2, indicating that the second patch is completed.
}
}
#endif
patch = 2; // patch is set to 2, indicating that the second patch is completed.
}
}
void Bios_Patching(){
// If LOW_TRIGGER is defined
#ifdef LOW_TRIGGER
PIN_AX_INTERRUPT_FALLING;
#else
PIN_AX_INTERRUPT_RISING;
#endif
if (PIN_AX_READ != 0) // If the AX pin is high
{
while (PIN_AX_READ != 0); // Wait for it to go low
while (PIN_AX_READ == 0); // Then wait for it to go high again.
}
else // If the AX pin is low
{
while (PIN_AX_READ == 0); // Wait for it to go high.
}
Timer_Start();
while (microsec < CHECKPOINT); // Wait until the number of microseconds elapsed reaches a value defined by CHECKPOINT.
Timer_Stop();
PIN_AX_INTERRUPT_ENABLE;
while (patch != 1); // Wait for the first stage of the patch to complete:
#ifdef HIGH_PATCH
#ifdef HIGH_PATCH
PIN_AY_INTERRUPT_FALLING;
#else
PIN_AY_INTERRUPT_RISING;
#endif
while (PIN_AY_READ != 0); // Wait for it to go low
Timer_Start();
while (microsec < CHECKPOINT2); // Wait until the number of microseconds elapsed reaches a value defined by CHECKPOINT2.
Timer_Stop();
PIN_AY_INTERRUPT_ENABLE;
while (patch != 2); // Wait for the second stage of the patch to complete:
#endif
}
#endif
void Bios_Patching(){
// If LOW_TRIGGER is defined
#ifdef LOW_TRIGGER
PIN_AX_INTERRUPT_FALLING;
#else
PIN_AX_INTERRUPT_RISING;
#endif
if (PIN_AX_READ != 0) // If the AX pin is high
{
while (PIN_AX_READ != 0); // Wait for it to go low
while (PIN_AX_READ == 0); // Then wait for it to go high again.
}
else // If the AX pin is low
{
while (PIN_AX_READ == 0); // Wait for it to go high.
}
Timer_Start();
while (microsec < CHECKPOINT); // Wait until the number of microseconds elapsed reaches a value defined by CHECKPOINT.
Timer_Stop();
PIN_AX_INTERRUPT_ENABLE;
while (patch != 1); // Wait for the first stage of the patch to complete:
#ifdef HIGH_PATCH
#ifdef HIGH_PATCH
PIN_AY_INTERRUPT_FALLING;
#else
PIN_AY_INTERRUPT_RISING;
#endif
while (PIN_AY_READ != 0); // Wait for it to go low
Timer_Start();
while (microsec < CHECKPOINT2); // Wait until the number of microseconds elapsed reaches a value defined by CHECKPOINT2.
Timer_Stop();
PIN_AY_INTERRUPT_ENABLE;
while (patch != 2); // Wait for the second stage of the patch to complete:
#endif
}
#endif
#ifdef SCPH_102A
void Bios_Patching_SCPH_102A() {
#ifdef SCPH_102_legacy
//void Bios_Patching_SCPH_102_legacy() {
// PIN_AX_INPUT; //A18
// PIN_DX_INPUT; //D2
@@ -145,7 +138,7 @@ void Bios_Patching_SCPH_102A() {
// }
// Original function equivalent to NTSC_fix(), using macros
void Bios_Patching_SCPH_102A(void) {
void Bios_Patching_SCPH_102_legacy(void) {
// configure A18 and D2 as inputs
PIN_AX_INPUT;

View File

@@ -1,6 +1,6 @@
// *****************************************************************************************************************
// Configuration for different microcontrollers (MUC) to ensure compatibility with the code:
// - Defines the clock speed, timers, and interrupts for each MUC.
// Configuration for different microcontrollers (MCU) to ensure compatibility with the code:
// - Defines the clock speed, timers, and interrupts for each MCU.
// - Configures I/O pins for data, clocks, and switches according to the requirements.
// - Enables pull-up resistors on input pins where needed.
// - Manages external interrupts and LED outputs for system feedback.
@@ -158,14 +158,13 @@
#endif
// Handling the BIOS patch
#if defined(SCPH_102) || defined(SCPH_102A) || defined(SCPH_100) || defined(SCPH_7000_9000) || defined(SCPH_5500) || defined(SCPH_3500_5000) || defined(SCPH_3000) || defined(SCPH_1000)
#if defined(SCPH_102) || defined(SCPH_102_legacy) || defined(SCPH_100) || defined(SCPH_7000_9000) || defined(SCPH_5500) || defined(SCPH_3500_5000) || defined(SCPH_3000) || defined(SCPH_1000)
// Clear the timer interrupt flag
#define TIMER_TIFR_CLEAR TIFR0 |= (1 << OCF0A) // Clear the Timer0 Compare Match A interrupt flag
// Define input pins for the BIOS patch
#define PIN_AX_INPUT DDRD &= ~(1 << DDD2) // Set DDRD register to configure PIND2 as input
#define PIN_AY_INPUT DDRD &= ~(1 << DDD3) // Set DDRD register to configure PIND3 as input
#define PIN_DX_INPUT DDRD &= ~(1 << DDD4) // Set DDRD register to configure PIND4 as input
// Define output pins for the BIOS patch
@@ -179,24 +178,26 @@
// Read the input pins for the BIOS patch
#define PIN_AX_READ (PIND & (1 << PIND2)) // Read the state of PIND2
#define PIN_AY_READ (PIND & (1 << PIND3)) // Read the state of PIND3
// External interrupt configuration for BIOS patch
#define PIN_AX_INTERRUPT_ENABLE EIMSK |= (1 << INT0) // Enable external interrupt on INT0 (PINB2)
#define PIN_AY_INTERRUPT_ENABLE EIMSK |= (1 << INT1) // Enable external interrupt on INT1 (PINB3)
#define PIN_AX_INTERRUPT_DISABLE EIMSK &= ~(1 << INT0) // Disable external interrupt on INT0
#define PIN_AY_INTERRUPT_DISABLE EIMSK &= ~(1 << INT1) // Disable external interrupt on INT1
#define PIN_AX_INTERRUPT_RISING EICRA |= (1 << ISC01) | (1 << ISC00) // Configure INT0 for rising edge trigger
#define PIN_AY_INTERRUPT_RISING EICRA |= (1 << ISC11) | (1 << ISC10) // Configure INT1 for rising edge trigger
#define PIN_AX_INTERRUPT_FALLING (EICRA = (EICRA & ~(1 << ISC00)) | (1 << ISC01)) // Configure INT0 for falling edge trigger
#define PIN_AY_INTERRUPT_FALLING (EICRA = (EICRA & ~(1 << ISC10)) | (1 << ISC11)) // Configure INT1 for falling edge trigger
// Interrupt vectors for external interrupts
#define PIN_AX_INTERRUPT_VECTOR INT0_vect // Interrupt vector for INT0 (external interrupt)
#define PIN_AY_INTERRUPT_VECTOR INT1_vect // Interrupt vector for INT1 (external interrupt)
// Defin PIN_AY for HIGH_PATCH
#if defined(SCPH_3000) || defined(SCPH_1000)
#define PIN_AY_INPUT DDRD &= ~(1 << DDD3) // Set DDRD register to configure PIND3 as input
#define PIN_AY_READ (PIND & (1 << PIND3)) // Read the state of PIND3
#define PIN_AY_INTERRUPT_ENABLE EIMSK |= (1 << INT1) // Enable external interrupt on INT1 (PINB3)
#define PIN_AY_INTERRUPT_DISABLE EIMSK &= ~(1 << INT1) // Disable external interrupt on INT1
#define PIN_AY_INTERRUPT_RISING EICRA |= (1 << ISC11) | (1 << ISC10) // Configure INT1 for rising edge trigger
#define PIN_AY_INTERRUPT_FALLING (EICRA = (EICRA & ~(1 << ISC10)) | (1 << ISC11)) // Configure INT1 for falling edge trigger
#define PIN_AY_INTERRUPT_VECTOR INT1_vect // Interrupt vector for INT1 (external interrupt)
#endif
// Handle switch input for BIOS patch
#ifdef PATCH_SWITCH
@@ -262,7 +263,7 @@
#endif
// Handling the BIOS patch
#if defined(SCPH_102) || defined(SCPH_102A) || defined(SCPH_100) || defined(SCPH_7000_9000) || defined(SCPH_5500) || defined(SCPH_3500_5000) || defined(SCPH_3000) || defined(SCPH_1000)
#if defined(SCPH_102) || defined(SCPH_102_legacy) || defined(SCPH_100) || defined(SCPH_7000_9000) || defined(SCPH_5500) || defined(SCPH_3500_5000) || defined(SCPH_3000) || defined(SCPH_1000)
// Pins input
#define PIN_AX_INPUT DDRD &= ~(1 << DDD1)
#define PIN_AY_INPUT DDRD &= ~(1 << DDD0)

View File

@@ -1,56 +1,44 @@
// PSNee-8.7.0
// PSNee-8.7.0
//------------------------------------------------------------------------------------------------
// Console selection
//------------------------------------------------------------------------------------------------
//No BIOS patching.
// SCPH model number | common noun | HYSTERESIS_MAX
// No BIOS patching.
// You can use injection via USB.
// // HYSTERESIS | region |
//-------------------------------------------------------------------------------------------------
//#define SCPH_xxx1 | NTSC-U/C FAT | 25
//#define SCPH_xxx2 | PAL FAT | 25
//#define SCPH_xxx3 | NTSC-Asia FAT | 25
//#define SCPH_101 | NTSC-U/C | 15
//#define SCPH_103 | NTSC-Asia | 15
//#define SCPH_xxxx // 15 | All | mode works the same as V7.
//#define SCPH_xxxx_25 // 25 | All | Only FAT! For models with problematic CD players.
//Models that require a BIOS patch.
// Adres pin
// SCPH model number | Data pin | 32-pin BIOS | 40-pin BIOS | BIOS ver
// Models that require a BIOS patch.
// | Adres pin |
// SCPH model number // Data pin | 32-pin BIOS | 40-pin BIOS | BIOS version
//-------------------------------------------------------------------------------------------------
//#define SCPH_102 | DX - D0 | AX - A7 | | 4.4e, 4.5e
//#define SCPH_102A | ! works in progress DX - D2, AX - A18. | 4.4e, 4.5e
//#define SCPH_100 | DX - D0 | AX - A7 | | 4.3j
//#define SCPH_7000 - 9000 | DX - D0 | AX - A7 | | 4.0j - CRC EC541CD0
//#define SCPH_5500 | DX - D0 | AX - A5 | | 3.0j - CRC FF3EEB8C
//#define SCPH_3500 - 5000 | DX - D0 | AX - A5 | AX - A4 | 2.2j - CRC 24FC7E17, 2.1j - CRC BC190209
//#define SCPH_3000 | DX - D5 | AX - A7, AY - A8 | AX - A6, AY - A7 | 1.1j - CRC 3539DEF6
//#define SCPH_1000 | DX - D5 | AX - A7, AY - A8 | AX - A6, AY - A7 | 1.0j - CRC 3B601FC8
//#define SCPH_102 // DX - D0 | AX - A7 | | 4.4e - CRC 0BAD7EA9, 4.5e -CRC 76B880E5
//#define SCPH_102_legacy // ! works in progress DX - D2, AX - A18. | 4.4e - CRC 0BAD7EA9, 4.5e -CRC 76B880E5
//#define SCPH_100 // DX - D0 | AX - A7 | | 4.3j - CRC F2AF798B
//#define SCPH_7000_9000 // DX - D0 | AX - A7 | | 4.0j - CRC EC541CD0
//#define SCPH_5500 // DX - D0 | AX - A5 | | 3.0j - CRC FF3EEB8C
//#define SCPH_3500_5000 // DX - D0 | AX - A5 | AX - A4 | 2.2j - CRC 24FC7E17, 2.1j - CRC BC190209
//#define SCPH_3000 // DX - D5 | AX - A7, AY - A8 | AX - A6, AY - A7 | 1.1j - CRC 3539DEF6
//#define SCPH_1000 // DX - D5 | AX - A7, AY - A8 | AX - A6, AY - A7 | 1.0j - CRC 3B601FC8
//
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// Attention!
// If a BIOS checksum is specified, it is more important than the SCPH model number!
// Caution!
// For the patch to work, the BIOS version is more important than the SCPH number,
// and you MUST use injection via ISP!
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//Legacy mode works the same as V7. NTSC-U/C SCPH_xxx1, PAL FAT models SCPH_xxx2, NTSC-Asia SCPH_xxx3.
// | HYSTERESIS_MAX |
//--------------------------------------------------------------
//#define SCPH_xxxx | 15 | Legacy
//#define SCPH_hyma | 25 | For models with problematic CD players
//------------------------------------------------------------------------------------------------
// MCU selection
//------------------------------------------------------------------------------------------------
// MCU | Arduino
//--------------------------------------------------------------
//#define ATmega328_168 | Nano, Pro Mini, Uno
//#define ATmega32U4_16U4 | Micro, Pro Micro
//#define ATtiny85_45_25 | ATtiny
// MCU // Arduino
//------------------------------------------------------------------------------------------------
//#define ATmega328_168 // Nano, Pro Mini, Uno
//#define ATmega32U4_16U4 // Micro, Pro Micro
//#define ATtiny85_45_25 // ATtiny
//------------------------------------------------------------------------------------------------
// Options
@@ -60,11 +48,29 @@
// 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_SWITCH // Enables hardware support for disabling BIOS patching.
// With SCPH_7000 - 9000 models, Bios 4.0j, the bios patch prevents reading memory cards in the console interface, and in some cases can cause a crash.
// With SCPH_7000 - 9000 models, Bios 4.0j, the bios patch prevents reading memory cards in the console interface, and in some cases can cause a crash (No problem in game).
// In rare cases where the BIOS patch prevents the playback of original games.
//------------------------------------------------------------------------------------------------
// Fuses, Pinout
// Make your own sauce
//------------------------------------------------------------------------------------------------
// Here you can have fun making your ideal mode, you just have to choose a region, and a duration of histeresis.
// Region
//------------------------------------------------------------------------------------------------
//#define SCEA // AMERICA
//#define SCEE // EUROP
//#define SCEI // ASIA
//#define All // All regions
// Hysteresis
//------------------------------------------------------------------------------------------------
//#define HYSTERESIS_MAX 15 // All model
//#define HYSTERESIS_MAX 25 // Only FAT! For models with problematic CD players.
//------------------------------------------------------------------------------------------------
// Summary of practical information. Fuses. Pinout
//------------------------------------------------------------------------------------------------
/*
@@ -174,7 +180,7 @@ ISR(CTC_TIMER_VECTOR) {
// unwanted immediate interrupts.
//
// Notes:
// - The actual timer configuration is handled in MUC.h.
// - The actual timer configuration is handled in MCU.h.
// - This function ensures that all supported MCUs behave consistently.
//
// *****************************************************************************************
@@ -364,8 +370,8 @@ int main() {
#endif
if (Flag_Switch == 0) {
#ifdef SCPH_102A
Bios_Patching_SCPH_102A();
#ifdef SCPH_102_legacy
Bios_Patching_SCPH_102_legacy();
#else
Bios_Patching();
#endif

View File

@@ -17,7 +17,7 @@
*/
#ifdef SCPH_102A
#ifdef SCPH_102_legacy
//#define SCEE
#define BIOS_PATCH
#define SATBILIZATIONPOINT 100
@@ -105,39 +105,39 @@
#define TRIGGER2 71
#endif
#if defined(SCPH_xxx1) || defined(SCPH_101)
#ifdef SCEA
const char region[3] = {'a', 'a', 'a'};
#endif
#if defined(SCPH_102) || defined(SCPH_xxx2) || defined(SCPH_102A)
#if defined(SCEE) || defined(SCPH_102)
const char region[3] = {'e', 'e', 'e'};
#endif
#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)
#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(SCEI)
const char region[3] = {'i', 'i', 'i'};
#endif
#if defined(SCPH_xxxx) || defined(SCPH_hyma)
#if defined(SCPH_xxxx) || defined(SCPH_xxxx_25) || defined(SCPH_102_legacy) || defined(All)
const char region[3] = {'a', 'e', 'i'};
#endif
//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_102A) || defined(SCPH_103) || defined(SCPH_xxxx)
#if defined(SCPH_102) || defined(SCPH_102_legacy) || defined(SCPH_103) || defined(SCPH_xxxx) //|| defined(HYSTERESIS_15)
#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) || defined(SCPH_hyma)
#if defined(SCPH_7000_9000) || defined(SCPH_5500) || defined(SCPH_3500_5000) || defined(SCPH_3000) || defined(SCPH_1000) || defined(SCPH_xxxx_25)// || defined(HYSTERESIS_25)
#define HYSTERESIS_MAX 25
#endif
#if !defined(SCPH_xxx1) && !defined(SCPH_xxx2) && !defined(SCPH_xxx3) && !defined(SCPH_103) && \
#if !defined(SCEA) && !defined(SCEE) && !defined(SCEI) && !defined(All) && !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) && !defined(SCPH_102A) && !defined(SCPH_hyma)
!defined(SCPH_1000) && !defined(SCPH_xxxx) && !defined(SCPH_102_legacy) && !defined(SCPH_xxxx_25)
#error "Console not selected! Please uncoment #define with SCPH model number."
#elif !(defined(SCPH_xxx1) ^ defined(SCPH_xxx2) ^ defined(SCPH_xxx3) ^ defined(SCPH_103) ^ \
#elif !(defined(SCEA) ^ defined(SCEE) ^ defined(SCEAI) ^ defined(All) ^ 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) ^ defined(SCPH_102A) ^ defined(SCPH_hyma))
defined(SCPH_1000) ^ defined(SCPH_xxxx) ^ defined(SCPH_102_legacy) ^ defined(SCPH_xxxx_25))
#error "May be selected only one console! Please check #define with SCPH model number."
#endif