Skip to content

Commit 87d995e

Browse files
committed
Add SYS_GetBusFrequency
Add SYS_GetFlipperRevision
1 parent c06efe3 commit 87d995e

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

gc/ogc/system.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ void SYS_StartPMC(u32 mcr0val,u32 mcr1val);
310310
void SYS_DumpPMC(void);
311311
void SYS_StopPMC(void);
312312
void SYS_ResetPMC(void);
313+
u32 SYS_GetBusFrequency(void);
313314
f32 SYS_GetCoreMultiplier(void);
314315
u32 SYS_GetCoreFrequency(void);
315316
s8 SYS_GetCoreTemperature(void);
@@ -411,7 +412,9 @@ resetcallback SYS_SetResetCallback(resetcallback cb);
411412

412413
u32 SYS_ResetButtonDown(void);
413414

414-
#if defined(HW_RVL)
415+
#if defined(HW_DOL)
416+
u32 SYS_GetFlipperRevision(void);
417+
#elif defined(HW_RVL)
415418
u32 SYS_GetHollywoodRevision(void);
416419

417420
void* SYS_GetArena2Lo(void);

libogc/system.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ void SYS_PreMain(void)
10751075

10761076
u32 SYS_ResetButtonDown(void)
10771077
{
1078-
return (!(_piReg[0]&0x00010000));
1078+
return _SHIFTR(_piReg[0],16,1)^1;
10791079
}
10801080

10811081
#if defined(HW_DOL)
@@ -1922,8 +1922,17 @@ u32 SYS_GetConsoleType(void)
19221922
{
19231923
u32 type;
19241924
type = *((u32*)0x8000002c);
1925+
if(!type) {
1926+
type = SYS_CONSOLE_RETAIL_HW1;
1927+
type += SYS_GetFlipperRevision();
1928+
}
19251929
return type;
19261930
}
1931+
1932+
u32 SYS_GetFlipperRevision(void)
1933+
{
1934+
return _SHIFTR(_piReg[11],28,4);
1935+
}
19271936
#elif defined(HW_RVL)
19281937
u32 SYS_GetConsoleType(void)
19291938
{
@@ -1965,6 +1974,14 @@ u32 SYS_GetHollywoodRevision(void)
19651974
}
19661975
#endif
19671976

1977+
u32 SYS_GetBusFrequency(void)
1978+
{
1979+
u32 clock;
1980+
clock = *((u32*)0x800000f8);
1981+
if(!clock) clock = TB_BUS_CLOCK;
1982+
return clock;
1983+
}
1984+
19681985
f32 SYS_GetCoreMultiplier(void)
19691986
{
19701987
u32 pvr,hid1;
@@ -2013,7 +2030,10 @@ u32 SYS_GetCoreFrequency(void)
20132030
{
20142031
u32 clock;
20152032
clock = *((u32*)0x800000fc);
2016-
if(!clock) clock = TB_BUS_CLOCK * SYS_GetCoreMultiplier();
2033+
if(!clock) {
2034+
clock = SYS_GetBusFrequency();
2035+
clock *= SYS_GetCoreMultiplier();
2036+
}
20172037
if(!clock) clock = TB_CORE_CLOCK;
20182038
return clock;
20192039
}

0 commit comments

Comments
 (0)