Added multiple keybinding configuration against ghosting + enable Overclocking on CG50/Graph 90+E (config Ptune F4)

This commit is contained in:
Sylvain PILLOT 2022-04-14 22:37:46 +02:00
parent 668efcb022
commit 901b5c16db
5 changed files with 234 additions and 116 deletions

View File

@ -2,6 +2,46 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src/parameters.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="505" topLine="0" />
</Cursor>
</File>
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="655" topLine="0" />
</Cursor>
</File>
<File name="src/fixed.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5" topLine="0" />
</Cursor>
</File>
<File name="src/include/circuit.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1093" topLine="47" />
</Cursor>
</File>
<File name="CMakeLists.txt" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="302" topLine="0" />
</Cursor>
</File>
<File name="src/src/utils.cc" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="30" topLine="0" />
</Cursor>
</File>
<File name="src/include/menus.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="505" topLine="0" />
</Cursor>
</File>
<File name="src/src/saves.cc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="294" topLine="2" />
</Cursor>
</File>
<File name="src/src/drawstuff.cc" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2807" topLine="14" />
@ -15,64 +55,14 @@
<Collapse line="131" />
</Folding>
</File>
<File name="src/fixed.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5" topLine="0" />
</Cursor>
</File>
<File name="src/include/camera.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="221" topLine="0" />
</Cursor>
</File>
<File name="src/include/utils.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="107" topLine="0" />
</Cursor>
</File>
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="655" topLine="0" />
</Cursor>
</File>
<File name="CMakeLists.txt" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="302" topLine="0" />
</Cursor>
</File>
<File name="src/clock.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="515" topLine="0" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="src/clock.cc" open="1" top="1" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="TODO.txt" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5691" topLine="162" />
</Cursor>
</File>
<File name="src/src/saves.cc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="294" topLine="2" />
</Cursor>
</File>
<File name="src/src/segment.cc" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="410" topLine="29" />
</Cursor>
</File>
<File name="src/include/saves.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="319" topLine="0" />
</Cursor>
</File>
<File name="src/src/cars.cc" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1019" topLine="8" />
</Cursor>
</File>
<File name="src/src/utils.cc" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="30" topLine="0" />
<Cursor1 position="251" topLine="0" />
</Cursor>
</File>
<File name="src/colors.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -80,51 +70,71 @@
<Cursor1 position="35" topLine="0" />
</Cursor>
</File>
<File name="src/include/circuit.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/clock.cc" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1093" topLine="47" />
<Cursor1 position="5691" topLine="162" />
</Cursor>
</File>
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/utils.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="203" topLine="0" />
<Cursor1 position="107" topLine="0" />
</Cursor>
</File>
<File name="src/include/menus.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/camera.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="505" topLine="0" />
<Cursor1 position="221" topLine="0" />
</Cursor>
</File>
<File name="src/src/menus.cc" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="27835" topLine="761" />
</Cursor>
<Folding>
<Collapse line="116" />
</Folding>
</File>
<File name="src/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
<Cursor>
<Cursor1 position="13032" topLine="337" />
<Cursor1 position="22297" topLine="536" />
</Cursor>
<Folding>
<Collapse line="141" />
<Collapse line="193" />
</Folding>
</File>
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
</Cursor>
</File>
<File name="src/include/segment.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="783" topLine="3" />
</Cursor>
</File>
<File name="src/src/segment.cc" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="410" topLine="29" />
</Cursor>
</File>
<File name="src/src/menus.cc" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="29263" topLine="681" />
</Cursor>
<Folding>
<Collapse line="116" />
</Folding>
</File>
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="203" topLine="0" />
</Cursor>
</File>
<File name="src/include/cars.h" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="412" topLine="1" />
</Cursor>
</File>
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/cars.cc" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="370" topLine="0" />
<Cursor1 position="1019" topLine="8" />
</Cursor>
</File>
<File name="src/parameters.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/saves.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="505" topLine="0" />
<Cursor1 position="319" topLine="0" />
</Cursor>
</File>
<File name="src/src/circuit.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -154,19 +164,9 @@
<Collapse line="1175" />
</Folding>
</File>
<File name="src/include/segment.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="783" topLine="3" />
</Cursor>
</File>
<File name="TODO.txt" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="251" topLine="0" />
</Cursor>
</File>
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
<Cursor1 position="370" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -44,10 +44,141 @@
#define SDMR3_CL2 *(volatile uint8_t *)0xFEC15040 // SDMR2 Address
#define SDMR3_CL3 *(volatile uint8_t *)0xFEC15060 // SDMR2 Address
#include <gint/mpu/tmu.h>
#include <gint/timer.h>
/* Arrays of standard and extra timers */
static tmu_t *TMU = SH7305_TMU.TMU;
static etmu_t *ETMU = SH7305_ETMU;
/* TSTR register for standard timers */
static volatile uint8_t *TSTR = &SH7305_TMU.TSTR;
bool runningTimers[3]; // 9 timers : 3 TMUs + 6 ETMUs
uint32_t initTimersTCNT[3];
uint32_t initTimersTCOR[3];
uint32_t newTimersTCNT[3];
uint32_t newTimersTCOR[3];
int initPphi;
int newPphi;
static int getPphi_sh7305(void)
{
/* The meaning of the PLL setting on SH7305 differs from the
documentation of SH7224; the value must not be doubled. */
int pll = CPG.FRQCR.STC + 1;
/* The FLL ratio is the value of the setting, halved if SELXM=1 */
int fll = CPG.FLLFRQ.FLF;
if(CPG.FLLFRQ.SELXM == 1) fll >>= 1;
/* On SH7724, the divider ratio is given by 1 / (setting + 1), but on
the SH7305 it is 1 / (2^setting + 1). */
int divb = CPG.FRQCR.BFC;
int divi = CPG.FRQCR.IFC;
int divp = CPG.FRQCR.P1FC;
/* Deduce the input frequency of divider 1 */
int base = 32768;
if(CPG.PLLCR.FLLE) base *= fll;
if(CPG.PLLCR.PLLE) base *= pll;
return (base >> (divp + 1));
}
//We list all running timers and store this in a table (true/false)
void listTimerStatus( void )
{
for(int k=0;k<3; k++)
{
if(k < 3)
{
tmu_t *T = &TMU[k];
runningTimers[k]= (!T->TCR.UNIE && !(*TSTR & (1 << k)));
}
// else
// {
// etmu_t *T = &ETMU[k-3];
// runningTimers[k]= (!T->TCR.UNIE && !T->TSTR);
// }
}
}
// We get all TCNT and TCOR of currently used timers
// And store these value into the
void getInitialTimersParameters( void )
{
for(int k=0;k<3; k++)
{
if (runningTimers[k]==true)
{
if(k < 3)
{
tmu_t *T = &TMU[k];
initTimersTCNT[k]= T->TCNT;
initTimersTCOR[k]= T->TCOR;
}
// else
// {
// etmu_t *T = &ETMU[k-3];
// initTimersTCNT[k]= T->TCNT;
// initTimersTCOR[k]= T->TCOR;
// }
}
}
}
static int callback(void)
{
return TIMER_CONTINUE;
}
//We update the timers with the new TCNT and new TCOR
void updateNewTimersParameters( void )
{
for(int k=0;k<3; k++)
{
if (runningTimers[k]==true)
{
timer_stop( k );
if(k < 3)
{
tmu_t *T = &TMU[k];
T->TCNT = newTimersTCNT[k];
T->TCOR = newTimersTCOR[k];
}
// else
// {
// etmu_t *T = &ETMU[k-3];
// T->TCNT = newTimersTCNT[k];
// T->TCOR = newTimersTCOR[k];
// }
timer_start(k);
}
}
}
//We compute the new TCNT and new TCOR
void computeNewTimersParameters( int initPphi_f, int newPphi_f )
{
for(int k=0;k<3; k++)
{
if (runningTimers[k]==true)
{
newTimersTCNT[k] = (uint32_t) ((uint64_t) initTimersTCNT[k] * (uint64_t) newPphi_f / (uint64_t) initPphi_f);
newTimersTCOR[k] = (uint32_t) ((uint64_t) initTimersTCOR[k] * (uint64_t) newPphi_f / (uint64_t) initPphi_f);
}
}
}
static overclock_level current_clock_state = OC_Default;
bool overclock_config_changed = false;
void SetOCDefault( void )
{
BSC.CS0WCR.WR = WAIT18;
@ -174,25 +305,23 @@ int clock_overclock( overclock_level level )
{
cpu_atomic_start();
listTimerStatus(); // we list the running timers
initPphi = getPphi_sh7305(); // we get the current P_Phi_f
getInitialTimersParameters(); // we collect the current TCNT and TCOR
if (level == OC_Default && current_clock_state!=OC_Default) SetOCDefault(), current_clock_state= OC_Default, overclock_config_changed=true;
if (level == OC_PtuneF2 && current_clock_state!=OC_PtuneF2) SetOCPtuneF2(), current_clock_state= OC_PtuneF2, overclock_config_changed=true;
if (level == OC_PtuneF3 && current_clock_state!=OC_PtuneF3) SetOCPtuneF3(), current_clock_state= OC_PtuneF3, overclock_config_changed=true;
if (level == OC_PtuneF4 && current_clock_state!=OC_PtuneF4) SetOCPtuneF4(), current_clock_state= OC_PtuneF4, overclock_config_changed=true;
if (level == OC_PtuneF5 && current_clock_state!=OC_PtuneF5) SetOCPtuneF5(), current_clock_state= OC_PtuneF5, overclock_config_changed=true;
/*
if (overclock_config_changed==true)
{
CPG.FRQCR.KICK = 1 ;
while((CPG.LSTATS & 1)!=0 && count<=1000)
{ count++; }
}
*/
newPphi = getPphi_sh7305(); // we get the new P_Phi_f after OC
computeNewTimersParameters( initPphi, newPphi ); // we compute the new TCNT and TCOR as per the new frequency
updateNewTimersParameters(); // we adjust the timers accordingly
cpu_atomic_end();
// if (count >= 1000) return -1;
// else return 1;
return 1;
}
else return 0;
}

View File

@ -5,6 +5,7 @@
extern "C" {
#endif
typedef enum
{
OC_Default = 0, // Default (118MHz)
@ -22,10 +23,9 @@ typedef enum
int clock_overclock( overclock_level level );
#ifdef __cplusplus
}
#endif
#endif /* OVERCLOCK_H */

View File

@ -34,9 +34,9 @@
#include "clock.h"
#define DEBUGXXX 0
#define OVERCLCK_ACTIVABLE 0
#define OVERCLCK_ACTIVABLE 1
char version[5] = {'V','1','.','0','4'};
char version[5] = {'V','1','.','0','5'};
extern bopti_image_t player;
@ -225,7 +225,7 @@ static void get_inputs( float dt, int index )
else cam->decX( CC*dt*speed/100 ); // more easy on normal roads
}
if(keydown(KEY_LEFT))
if(keydown(KEY_LEFT) || keydown(KEY_F5))
{
cam->decX(5.0*speed*direction);
@ -234,7 +234,7 @@ static void get_inputs( float dt, int index )
if (CC>0) viewside=0;
}
if(keydown(KEY_RIGHT))
if(keydown(KEY_RIGHT) || keydown(KEY_F6))
{
cam->incX(5.0*speed*direction);
@ -243,7 +243,7 @@ static void get_inputs( float dt, int index )
if (CC<0) viewside=0;
}
if(keydown(KEY_SHIFT)) // Accelerates
if(keydown(KEY_SHIFT) || keydown(KEY_XOT) || keydown(KEY_F1)) // Accelerates
{
if (direction==-1 && speed > 0)
{
@ -263,7 +263,7 @@ static void get_inputs( float dt, int index )
speedcontrol = true;
}
if(keydown(KEY_ALPHA)) // breaks or rear if speed <0
if(keydown(KEY_ALPHA) || keydown(KEY_FRAC) || keydown(KEY_F2)) // breaks or rear if speed <0
{
if (direction==1 && speed > 0)
{
@ -288,12 +288,6 @@ static void get_inputs( float dt, int index )
if(keydown(KEY_OPTN)) drawOptions();
#if IS_FXLIB==1
if(keydown(KEY_F1)) BDrawDeco = !BDrawDeco;
if(keydown(KEY_F2)) BDrawClds = !BDrawClds;
if(keydown(KEY_F3)) BDrawCars = !BDrawCars;
if(keydown(KEY_F4)) BDrawBack = !BDrawBack;
if(keydown(KEY_F5)) BDrawFPS = !BDrawFPS;
if(keydown(KEY_7)) screenshot = true;
if(keydown(KEY_8)) record = !record;
#endif // IS_FXLIB
@ -349,12 +343,6 @@ static void get_minimum_inputs( void )
if(keydown(KEY_OPTN)) drawOptions();
#if IS_FXLIB==1
if(keydown(KEY_F1)) BDrawDeco = !BDrawDeco;
if(keydown(KEY_F2)) BDrawClds = !BDrawClds;
if(keydown(KEY_F3)) BDrawCars = !BDrawCars;
if(keydown(KEY_F4)) BDrawBack = !BDrawBack;
if(keydown(KEY_F5)) BDrawFPS = !BDrawFPS;
if(keydown(KEY_7)) screenshot = true;
if(keydown(KEY_8)) record = !record;
#endif // IS_FXLIB
@ -727,6 +715,7 @@ int main(void)
if (BDrawCars && mode==0)
{
updateTraffic( dt, maxDistance );
for (unsigned int k=0; k<traffic.size(); k++) // Need to project 1 more segment than actual drawing

View File

@ -537,7 +537,7 @@ void getInputCredit( void )
int key = ev.key;
if (key==KEY_EXE)
if (key==KEY_EXE || key==KEY_EXIT)
doneMenuCredit = true;
#if IS_FXLIB==1